diff --git a/_cat b/_cat new file mode 100755 index 00000000..b9479b8e Binary files /dev/null and b/_cat differ diff --git a/_echo b/_echo new file mode 100755 index 00000000..3c5974f5 Binary files /dev/null and b/_echo differ diff --git a/_forktest b/_forktest new file mode 100755 index 00000000..d4caade8 Binary files /dev/null and b/_forktest differ diff --git a/_grep b/_grep new file mode 100755 index 00000000..6c864326 Binary files /dev/null and b/_grep differ diff --git a/_init b/_init new file mode 100755 index 00000000..2bad90f9 Binary files /dev/null and b/_init differ diff --git a/_kill b/_kill new file mode 100755 index 00000000..51b14004 Binary files /dev/null and b/_kill differ diff --git a/_ln b/_ln new file mode 100755 index 00000000..36c4dc4a Binary files /dev/null and b/_ln differ diff --git a/_ls b/_ls new file mode 100755 index 00000000..26d3ec75 Binary files /dev/null and b/_ls differ diff --git a/_mkdir b/_mkdir new file mode 100755 index 00000000..69d17ca3 Binary files /dev/null and b/_mkdir differ diff --git a/_null b/_null new file mode 100755 index 00000000..1d62091c Binary files /dev/null and b/_null differ diff --git a/_rm b/_rm new file mode 100755 index 00000000..bdf80c18 Binary files /dev/null and b/_rm differ diff --git a/_sh b/_sh new file mode 100755 index 00000000..364c49f9 Binary files /dev/null and b/_sh differ diff --git a/_shm_cnt b/_shm_cnt new file mode 100755 index 00000000..a84cee85 Binary files /dev/null and b/_shm_cnt differ diff --git a/_stressfs b/_stressfs new file mode 100755 index 00000000..1d4347fd Binary files /dev/null and b/_stressfs differ diff --git a/_usertests b/_usertests new file mode 100755 index 00000000..73fcd099 Binary files /dev/null and b/_usertests differ diff --git a/_wc b/_wc new file mode 100755 index 00000000..7b4a62cd Binary files /dev/null and b/_wc differ diff --git a/_zombie b/_zombie new file mode 100755 index 00000000..4d1407da Binary files /dev/null and b/_zombie differ diff --git a/bio.d b/bio.d new file mode 100644 index 00000000..b4bbd30f --- /dev/null +++ b/bio.d @@ -0,0 +1,2 @@ +bio.o: bio.c /usr/include/stdc-predef.h types.h defs.h param.h spinlock.h \ + sleeplock.h fs.h buf.h diff --git a/bio.o b/bio.o new file mode 100644 index 00000000..0238fb5c Binary files /dev/null and b/bio.o differ diff --git a/bootasm.d b/bootasm.d new file mode 100644 index 00000000..3b3dc195 --- /dev/null +++ b/bootasm.d @@ -0,0 +1 @@ +bootasm.o: bootasm.S asm.h memlayout.h mmu.h diff --git a/bootasm.o b/bootasm.o new file mode 100644 index 00000000..1f7a67f9 Binary files /dev/null and b/bootasm.o differ diff --git a/bootblock b/bootblock new file mode 100755 index 00000000..ff63c649 Binary files /dev/null and b/bootblock differ diff --git a/bootblock.asm b/bootblock.asm new file mode 100644 index 00000000..bf774190 --- /dev/null +++ b/bootblock.asm @@ -0,0 +1,353 @@ + +bootblock.o: file format elf32-i386 + + +Disassembly of section .text: + +00007c00 : +# with %cs=0 %ip=7c00. + +.code16 # Assemble for 16-bit mode +.globl start +start: + cli # BIOS enabled interrupts; disable + 7c00: fa cli + + # Zero data segment registers DS, ES, and SS. + xorw %ax,%ax # Set %ax to zero + 7c01: 31 c0 xor %eax,%eax + movw %ax,%ds # -> Data Segment + 7c03: 8e d8 mov %eax,%ds + movw %ax,%es # -> Extra Segment + 7c05: 8e c0 mov %eax,%es + movw %ax,%ss # -> Stack Segment + 7c07: 8e d0 mov %eax,%ss + +00007c09 : + + # Physical address line A20 is tied to zero so that the first PCs + # with 2 MB would run software that assumed 1 MB. Undo that. +seta20.1: + inb $0x64,%al # Wait for not busy + 7c09: e4 64 in $0x64,%al + testb $0x2,%al + 7c0b: a8 02 test $0x2,%al + jnz seta20.1 + 7c0d: 75 fa jne 7c09 + + movb $0xd1,%al # 0xd1 -> port 0x64 + 7c0f: b0 d1 mov $0xd1,%al + outb %al,$0x64 + 7c11: e6 64 out %al,$0x64 + +00007c13 : + +seta20.2: + inb $0x64,%al # Wait for not busy + 7c13: e4 64 in $0x64,%al + testb $0x2,%al + 7c15: a8 02 test $0x2,%al + jnz seta20.2 + 7c17: 75 fa jne 7c13 + + movb $0xdf,%al # 0xdf -> port 0x60 + 7c19: b0 df mov $0xdf,%al + outb %al,$0x60 + 7c1b: e6 60 out %al,$0x60 + + # Switch from real to protected mode. Use a bootstrap GDT that makes + # virtual addresses map directly to physical addresses so that the + # effective memory map doesn't change during the transition. + lgdt gdtdesc + 7c1d: 0f 01 16 lgdtl (%esi) + 7c20: 78 7c js 7c9e + movl %cr0, %eax + 7c22: 0f 20 c0 mov %cr0,%eax + orl $CR0_PE, %eax + 7c25: 66 83 c8 01 or $0x1,%ax + movl %eax, %cr0 + 7c29: 0f 22 c0 mov %eax,%cr0 + +//PAGEBREAK! + # Complete the transition to 32-bit protected mode by using a long jmp + # to reload %cs and %eip. The segment descriptors are set up with no + # translation, so that the mapping is still the identity mapping. + ljmp $(SEG_KCODE<<3), $start32 + 7c2c: ea .byte 0xea + 7c2d: 31 7c 08 00 xor %edi,0x0(%eax,%ecx,1) + +00007c31 : + +.code32 # Tell assembler to generate 32-bit code now. +start32: + # Set up the protected-mode data segment registers + movw $(SEG_KDATA<<3), %ax # Our data segment selector + 7c31: 66 b8 10 00 mov $0x10,%ax + movw %ax, %ds # -> DS: Data Segment + 7c35: 8e d8 mov %eax,%ds + movw %ax, %es # -> ES: Extra Segment + 7c37: 8e c0 mov %eax,%es + movw %ax, %ss # -> SS: Stack Segment + 7c39: 8e d0 mov %eax,%ss + movw $0, %ax # Zero segments not ready for use + 7c3b: 66 b8 00 00 mov $0x0,%ax + movw %ax, %fs # -> FS + 7c3f: 8e e0 mov %eax,%fs + movw %ax, %gs # -> GS + 7c41: 8e e8 mov %eax,%gs + + # Set up the stack pointer and call into C. + movl $start, %esp + 7c43: bc 00 7c 00 00 mov $0x7c00,%esp + call bootmain + 7c48: e8 e2 00 00 00 call 7d2f + + # If bootmain returns (it shouldn't), trigger a Bochs + # breakpoint if running under Bochs, then loop. + movw $0x8a00, %ax # 0x8a00 -> port 0x8a00 + 7c4d: 66 b8 00 8a mov $0x8a00,%ax + movw %ax, %dx + 7c51: 66 89 c2 mov %ax,%dx + outw %ax, %dx + 7c54: 66 ef out %ax,(%dx) + movw $0x8ae0, %ax # 0x8ae0 -> port 0x8a00 + 7c56: 66 b8 e0 8a mov $0x8ae0,%ax + outw %ax, %dx + 7c5a: 66 ef out %ax,(%dx) + +00007c5c : +spin: + jmp spin + 7c5c: eb fe jmp 7c5c + 7c5e: 66 90 xchg %ax,%ax + +00007c60 : + ... + 7c68: ff (bad) + 7c69: ff 00 incl (%eax) + 7c6b: 00 00 add %al,(%eax) + 7c6d: 9a cf 00 ff ff 00 00 lcall $0x0,$0xffff00cf + 7c74: 00 .byte 0x0 + 7c75: 92 xchg %eax,%edx + 7c76: cf iret + ... + +00007c78 : + 7c78: 17 pop %ss + 7c79: 00 60 7c add %ah,0x7c(%eax) + ... + +00007c7e : + entry(); +} + +void +waitdisk(void) +{ + 7c7e: 55 push %ebp + 7c7f: 89 e5 mov %esp,%ebp +static inline uchar +inb(ushort port) +{ + uchar data; + + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); + 7c81: ba f7 01 00 00 mov $0x1f7,%edx + 7c86: ec in (%dx),%al + // Wait for disk ready. + while((inb(0x1F7) & 0xC0) != 0x40) + 7c87: 83 e0 c0 and $0xffffffc0,%eax + 7c8a: 3c 40 cmp $0x40,%al + 7c8c: 75 f8 jne 7c86 + ; +} + 7c8e: 5d pop %ebp + 7c8f: c3 ret + +00007c90 : + +// Read a single sector at offset into dst. +void +readsect(void *dst, uint offset) +{ + 7c90: 55 push %ebp + 7c91: 89 e5 mov %esp,%ebp + 7c93: 57 push %edi + 7c94: 53 push %ebx + 7c95: 8b 5d 0c mov 0xc(%ebp),%ebx + // Issue command. + waitdisk(); + 7c98: e8 e1 ff ff ff call 7c7e +} + +static inline void +outb(ushort port, uchar data) +{ + asm volatile("out %0,%1" : : "a" (data), "d" (port)); + 7c9d: ba f2 01 00 00 mov $0x1f2,%edx + 7ca2: b8 01 00 00 00 mov $0x1,%eax + 7ca7: ee out %al,(%dx) + 7ca8: b2 f3 mov $0xf3,%dl + 7caa: 89 d8 mov %ebx,%eax + 7cac: ee out %al,(%dx) + 7cad: 0f b6 c7 movzbl %bh,%eax + 7cb0: b2 f4 mov $0xf4,%dl + 7cb2: ee out %al,(%dx) + outb(0x1F2, 1); // count = 1 + outb(0x1F3, offset); + outb(0x1F4, offset >> 8); + outb(0x1F5, offset >> 16); + 7cb3: 89 d8 mov %ebx,%eax + 7cb5: c1 e8 10 shr $0x10,%eax + 7cb8: b2 f5 mov $0xf5,%dl + 7cba: ee out %al,(%dx) + outb(0x1F6, (offset >> 24) | 0xE0); + 7cbb: c1 eb 18 shr $0x18,%ebx + 7cbe: 89 d8 mov %ebx,%eax + 7cc0: 83 c8 e0 or $0xffffffe0,%eax + 7cc3: b2 f6 mov $0xf6,%dl + 7cc5: ee out %al,(%dx) + 7cc6: b2 f7 mov $0xf7,%dl + 7cc8: b8 20 00 00 00 mov $0x20,%eax + 7ccd: ee out %al,(%dx) + outb(0x1F7, 0x20); // cmd 0x20 - read sectors + + // Read data. + waitdisk(); + 7cce: e8 ab ff ff ff call 7c7e + asm volatile("cld; rep insl" : + 7cd3: 8b 7d 08 mov 0x8(%ebp),%edi + 7cd6: b9 80 00 00 00 mov $0x80,%ecx + 7cdb: ba f0 01 00 00 mov $0x1f0,%edx + 7ce0: fc cld + 7ce1: f3 6d rep insl (%dx),%es:(%edi) + insl(0x1F0, dst, SECTSIZE/4); +} + 7ce3: 5b pop %ebx + 7ce4: 5f pop %edi + 7ce5: 5d pop %ebp + 7ce6: c3 ret + +00007ce7 : + +// Read 'count' bytes at 'offset' from kernel into physical address 'pa'. +// Might copy more than asked. +void +readseg(uchar* pa, uint count, uint offset) +{ + 7ce7: 55 push %ebp + 7ce8: 89 e5 mov %esp,%ebp + 7cea: 57 push %edi + 7ceb: 56 push %esi + 7cec: 53 push %ebx + 7ced: 83 ec 08 sub $0x8,%esp + 7cf0: 8b 5d 08 mov 0x8(%ebp),%ebx + 7cf3: 8b 75 10 mov 0x10(%ebp),%esi + uchar* epa; + + epa = pa + count; + 7cf6: 89 df mov %ebx,%edi + 7cf8: 03 7d 0c add 0xc(%ebp),%edi + + // Round down to sector boundary. + pa -= offset % SECTSIZE; + 7cfb: 89 f0 mov %esi,%eax + 7cfd: 25 ff 01 00 00 and $0x1ff,%eax + 7d02: 29 c3 sub %eax,%ebx + + // Translate from bytes to sectors; kernel starts at sector 1. + offset = (offset / SECTSIZE) + 1; + 7d04: c1 ee 09 shr $0x9,%esi + 7d07: 83 c6 01 add $0x1,%esi + + // If this is too slow, we could read lots of sectors at a time. + // We'd write more to memory than asked, but it doesn't matter -- + // we load in increasing order. + for(; pa < epa; pa += SECTSIZE, offset++) + 7d0a: 39 df cmp %ebx,%edi + 7d0c: 76 19 jbe 7d27 + readsect(pa, offset); + 7d0e: 89 74 24 04 mov %esi,0x4(%esp) + 7d12: 89 1c 24 mov %ebx,(%esp) + 7d15: e8 76 ff ff ff call 7c90 + for(; pa < epa; pa += SECTSIZE, offset++) + 7d1a: 81 c3 00 02 00 00 add $0x200,%ebx + 7d20: 83 c6 01 add $0x1,%esi + 7d23: 39 df cmp %ebx,%edi + 7d25: 77 e7 ja 7d0e +} + 7d27: 83 c4 08 add $0x8,%esp + 7d2a: 5b pop %ebx + 7d2b: 5e pop %esi + 7d2c: 5f pop %edi + 7d2d: 5d pop %ebp + 7d2e: c3 ret + +00007d2f : +{ + 7d2f: 55 push %ebp + 7d30: 89 e5 mov %esp,%ebp + 7d32: 57 push %edi + 7d33: 56 push %esi + 7d34: 53 push %ebx + 7d35: 83 ec 1c sub $0x1c,%esp + readseg((uchar*)elf, 4096, 0); + 7d38: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) + 7d3f: 00 + 7d40: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) + 7d47: 00 + 7d48: c7 04 24 00 00 01 00 movl $0x10000,(%esp) + 7d4f: e8 93 ff ff ff call 7ce7 + if(elf->magic != ELF_MAGIC) + 7d54: 81 3d 00 00 01 00 7f cmpl $0x464c457f,0x10000 + 7d5b: 45 4c 46 + 7d5e: 75 57 jne 7db7 + ph = (struct proghdr*)((uchar*)elf + elf->phoff); + 7d60: a1 1c 00 01 00 mov 0x1001c,%eax + 7d65: 8d 98 00 00 01 00 lea 0x10000(%eax),%ebx + eph = ph + elf->phnum; + 7d6b: 0f b7 35 2c 00 01 00 movzwl 0x1002c,%esi + 7d72: c1 e6 05 shl $0x5,%esi + 7d75: 01 de add %ebx,%esi + for(; ph < eph; ph++){ + 7d77: 39 f3 cmp %esi,%ebx + 7d79: 73 36 jae 7db1 + pa = (uchar*)ph->paddr; + 7d7b: 8b 7b 0c mov 0xc(%ebx),%edi + readseg(pa, ph->filesz, ph->off); + 7d7e: 8b 43 04 mov 0x4(%ebx),%eax + 7d81: 89 44 24 08 mov %eax,0x8(%esp) + 7d85: 8b 43 10 mov 0x10(%ebx),%eax + 7d88: 89 44 24 04 mov %eax,0x4(%esp) + 7d8c: 89 3c 24 mov %edi,(%esp) + 7d8f: e8 53 ff ff ff call 7ce7 + if(ph->memsz > ph->filesz) + 7d94: 8b 4b 14 mov 0x14(%ebx),%ecx + 7d97: 8b 43 10 mov 0x10(%ebx),%eax + 7d9a: 39 c1 cmp %eax,%ecx + 7d9c: 76 0c jbe 7daa + stosb(pa + ph->filesz, 0, ph->memsz - ph->filesz); + 7d9e: 01 c7 add %eax,%edi + 7da0: 29 c1 sub %eax,%ecx +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 7da2: b8 00 00 00 00 mov $0x0,%eax + 7da7: fc cld + 7da8: f3 aa rep stos %al,%es:(%edi) + for(; ph < eph; ph++){ + 7daa: 83 c3 20 add $0x20,%ebx + 7dad: 39 de cmp %ebx,%esi + 7daf: 77 ca ja 7d7b + entry(); + 7db1: ff 15 18 00 01 00 call *0x10018 +} + 7db7: 83 c4 1c add $0x1c,%esp + 7dba: 5b pop %ebx + 7dbb: 5e pop %esi + 7dbc: 5f pop %edi + 7dbd: 5d pop %ebp + 7dbe: c3 ret diff --git a/bootblock.o b/bootblock.o new file mode 100755 index 00000000..3235ef2c Binary files /dev/null and b/bootblock.o differ diff --git a/bootblockother.o b/bootblockother.o new file mode 100755 index 00000000..e4dd4d4c Binary files /dev/null and b/bootblockother.o differ diff --git a/bootmain.d b/bootmain.d new file mode 100644 index 00000000..b32eaf51 --- /dev/null +++ b/bootmain.d @@ -0,0 +1 @@ +bootmain.o: bootmain.c types.h elf.h x86.h memlayout.h diff --git a/bootmain.o b/bootmain.o new file mode 100644 index 00000000..0918ae69 Binary files /dev/null and b/bootmain.o differ diff --git a/cat.asm b/cat.asm new file mode 100644 index 00000000..1a0c1f90 --- /dev/null +++ b/cat.asm @@ -0,0 +1,1301 @@ + +_cat: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: + } +} + +int +main(int argc, char *argv[]) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 57 push %edi + 1004: 56 push %esi + int fd, i; + + if(argc <= 1){ + 1005: be 01 00 00 00 mov $0x1,%esi +{ + 100a: 53 push %ebx + 100b: 83 e4 f0 and $0xfffffff0,%esp + 100e: 83 ec 10 sub $0x10,%esp + 1011: 8b 45 0c mov 0xc(%ebp),%eax + if(argc <= 1){ + 1014: 83 7d 08 01 cmpl $0x1,0x8(%ebp) + 1018: 8d 58 04 lea 0x4(%eax),%ebx + 101b: 7e 5a jle 1077 + 101d: 8d 76 00 lea 0x0(%esi),%esi + cat(0); + exit(); + } + + for(i = 1; i < argc; i++){ + if((fd = open(argv[i], 0)) < 0){ + 1020: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1027: 00 + 1028: 8b 03 mov (%ebx),%eax + 102a: 89 04 24 mov %eax,(%esp) + 102d: e8 50 03 00 00 call 1382 + 1032: 85 c0 test %eax,%eax + 1034: 89 c7 mov %eax,%edi + 1036: 78 20 js 1058 + printf(1, "cat: cannot open %s\n", argv[i]); + exit(); + } + cat(fd); + 1038: 89 04 24 mov %eax,(%esp) + for(i = 1; i < argc; i++){ + 103b: 83 c6 01 add $0x1,%esi + 103e: 83 c3 04 add $0x4,%ebx + cat(fd); + 1041: e8 4a 00 00 00 call 1090 + close(fd); + 1046: 89 3c 24 mov %edi,(%esp) + 1049: e8 1c 03 00 00 call 136a + for(i = 1; i < argc; i++){ + 104e: 3b 75 08 cmp 0x8(%ebp),%esi + 1051: 75 cd jne 1020 + } + exit(); + 1053: e8 ea 02 00 00 call 1342 + printf(1, "cat: cannot open %s\n", argv[i]); + 1058: 8b 03 mov (%ebx),%eax + 105a: c7 44 24 04 64 18 00 movl $0x1864,0x4(%esp) + 1061: 00 + 1062: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1069: 89 44 24 08 mov %eax,0x8(%esp) + 106d: e8 2e 04 00 00 call 14a0 + exit(); + 1072: e8 cb 02 00 00 call 1342 + cat(0); + 1077: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 107e: e8 0d 00 00 00 call 1090 + exit(); + 1083: e8 ba 02 00 00 call 1342 + 1088: 66 90 xchg %ax,%ax + 108a: 66 90 xchg %ax,%ax + 108c: 66 90 xchg %ax,%ax + 108e: 66 90 xchg %ax,%ax + +00001090 : +{ + 1090: 55 push %ebp + 1091: 89 e5 mov %esp,%ebp + 1093: 56 push %esi + 1094: 53 push %ebx + 1095: 83 ec 10 sub $0x10,%esp + 1098: 8b 75 08 mov 0x8(%ebp),%esi + while((n = read(fd, buf, sizeof(buf))) > 0) { + 109b: eb 1f jmp 10bc + 109d: 8d 76 00 lea 0x0(%esi),%esi + if (write(1, buf, n) != n) { + 10a0: 89 5c 24 08 mov %ebx,0x8(%esp) + 10a4: c7 44 24 04 a0 1b 00 movl $0x1ba0,0x4(%esp) + 10ab: 00 + 10ac: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 10b3: e8 aa 02 00 00 call 1362 + 10b8: 39 d8 cmp %ebx,%eax + 10ba: 75 28 jne 10e4 + while((n = read(fd, buf, sizeof(buf))) > 0) { + 10bc: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) + 10c3: 00 + 10c4: c7 44 24 04 a0 1b 00 movl $0x1ba0,0x4(%esp) + 10cb: 00 + 10cc: 89 34 24 mov %esi,(%esp) + 10cf: e8 86 02 00 00 call 135a + 10d4: 83 f8 00 cmp $0x0,%eax + 10d7: 89 c3 mov %eax,%ebx + 10d9: 7f c5 jg 10a0 + if(n < 0){ + 10db: 75 20 jne 10fd +} + 10dd: 83 c4 10 add $0x10,%esp + 10e0: 5b pop %ebx + 10e1: 5e pop %esi + 10e2: 5d pop %ebp + 10e3: c3 ret + printf(1, "cat: write error\n"); + 10e4: c7 44 24 04 41 18 00 movl $0x1841,0x4(%esp) + 10eb: 00 + 10ec: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 10f3: e8 a8 03 00 00 call 14a0 + exit(); + 10f8: e8 45 02 00 00 call 1342 + printf(1, "cat: read error\n"); + 10fd: c7 44 24 04 53 18 00 movl $0x1853,0x4(%esp) + 1104: 00 + 1105: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 110c: e8 8f 03 00 00 call 14a0 + exit(); + 1111: e8 2c 02 00 00 call 1342 + 1116: 66 90 xchg %ax,%ax + 1118: 66 90 xchg %ax,%ax + 111a: 66 90 xchg %ax,%ax + 111c: 66 90 xchg %ax,%ax + 111e: 66 90 xchg %ax,%ax + +00001120 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1120: 55 push %ebp + 1121: 89 e5 mov %esp,%ebp + 1123: 8b 45 08 mov 0x8(%ebp),%eax + 1126: 8b 4d 0c mov 0xc(%ebp),%ecx + 1129: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 112a: 89 c2 mov %eax,%edx + 112c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1130: 83 c1 01 add $0x1,%ecx + 1133: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1137: 83 c2 01 add $0x1,%edx + 113a: 84 db test %bl,%bl + 113c: 88 5a ff mov %bl,-0x1(%edx) + 113f: 75 ef jne 1130 + ; + return os; +} + 1141: 5b pop %ebx + 1142: 5d pop %ebp + 1143: c3 ret + 1144: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 114a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001150 : + +int +strcmp(const char *p, const char *q) +{ + 1150: 55 push %ebp + 1151: 89 e5 mov %esp,%ebp + 1153: 8b 55 08 mov 0x8(%ebp),%edx + 1156: 53 push %ebx + 1157: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 115a: 0f b6 02 movzbl (%edx),%eax + 115d: 84 c0 test %al,%al + 115f: 74 2d je 118e + 1161: 0f b6 19 movzbl (%ecx),%ebx + 1164: 38 d8 cmp %bl,%al + 1166: 74 0e je 1176 + 1168: eb 2b jmp 1195 + 116a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1170: 38 c8 cmp %cl,%al + 1172: 75 15 jne 1189 + p++, q++; + 1174: 89 d9 mov %ebx,%ecx + 1176: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 1179: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 117c: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 117f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 1183: 84 c0 test %al,%al + 1185: 75 e9 jne 1170 + 1187: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 1189: 29 c8 sub %ecx,%eax +} + 118b: 5b pop %ebx + 118c: 5d pop %ebp + 118d: c3 ret + 118e: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 1191: 31 c0 xor %eax,%eax + 1193: eb f4 jmp 1189 + 1195: 0f b6 cb movzbl %bl,%ecx + 1198: eb ef jmp 1189 + 119a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +000011a0 : + +uint +strlen(char *s) +{ + 11a0: 55 push %ebp + 11a1: 89 e5 mov %esp,%ebp + 11a3: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 11a6: 80 39 00 cmpb $0x0,(%ecx) + 11a9: 74 12 je 11bd + 11ab: 31 d2 xor %edx,%edx + 11ad: 8d 76 00 lea 0x0(%esi),%esi + 11b0: 83 c2 01 add $0x1,%edx + 11b3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 11b7: 89 d0 mov %edx,%eax + 11b9: 75 f5 jne 11b0 + ; + return n; +} + 11bb: 5d pop %ebp + 11bc: c3 ret + for(n = 0; s[n]; n++) + 11bd: 31 c0 xor %eax,%eax +} + 11bf: 5d pop %ebp + 11c0: c3 ret + 11c1: eb 0d jmp 11d0 + 11c3: 90 nop + 11c4: 90 nop + 11c5: 90 nop + 11c6: 90 nop + 11c7: 90 nop + 11c8: 90 nop + 11c9: 90 nop + 11ca: 90 nop + 11cb: 90 nop + 11cc: 90 nop + 11cd: 90 nop + 11ce: 90 nop + 11cf: 90 nop + +000011d0 : + +void* +memset(void *dst, int c, uint n) +{ + 11d0: 55 push %ebp + 11d1: 89 e5 mov %esp,%ebp + 11d3: 8b 55 08 mov 0x8(%ebp),%edx + 11d6: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 11d7: 8b 4d 10 mov 0x10(%ebp),%ecx + 11da: 8b 45 0c mov 0xc(%ebp),%eax + 11dd: 89 d7 mov %edx,%edi + 11df: fc cld + 11e0: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 11e2: 89 d0 mov %edx,%eax + 11e4: 5f pop %edi + 11e5: 5d pop %ebp + 11e6: c3 ret + 11e7: 89 f6 mov %esi,%esi + 11e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +000011f0 : + +char* +strchr(const char *s, char c) +{ + 11f0: 55 push %ebp + 11f1: 89 e5 mov %esp,%ebp + 11f3: 8b 45 08 mov 0x8(%ebp),%eax + 11f6: 53 push %ebx + 11f7: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 11fa: 0f b6 18 movzbl (%eax),%ebx + 11fd: 84 db test %bl,%bl + 11ff: 74 1d je 121e + if(*s == c) + 1201: 38 d3 cmp %dl,%bl + 1203: 89 d1 mov %edx,%ecx + 1205: 75 0d jne 1214 + 1207: eb 17 jmp 1220 + 1209: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1210: 38 ca cmp %cl,%dl + 1212: 74 0c je 1220 + for(; *s; s++) + 1214: 83 c0 01 add $0x1,%eax + 1217: 0f b6 10 movzbl (%eax),%edx + 121a: 84 d2 test %dl,%dl + 121c: 75 f2 jne 1210 + return (char*)s; + return 0; + 121e: 31 c0 xor %eax,%eax +} + 1220: 5b pop %ebx + 1221: 5d pop %ebp + 1222: c3 ret + 1223: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001230 : + +char* +gets(char *buf, int max) +{ + 1230: 55 push %ebp + 1231: 89 e5 mov %esp,%ebp + 1233: 57 push %edi + 1234: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1235: 31 f6 xor %esi,%esi +{ + 1237: 53 push %ebx + 1238: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 123b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 123e: eb 31 jmp 1271 + cc = read(0, &c, 1); + 1240: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1247: 00 + 1248: 89 7c 24 04 mov %edi,0x4(%esp) + 124c: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1253: e8 02 01 00 00 call 135a + if(cc < 1) + 1258: 85 c0 test %eax,%eax + 125a: 7e 1d jle 1279 + break; + buf[i++] = c; + 125c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 1260: 89 de mov %ebx,%esi + buf[i++] = c; + 1262: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 1265: 3c 0d cmp $0xd,%al + buf[i++] = c; + 1267: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 126b: 74 0c je 1279 + 126d: 3c 0a cmp $0xa,%al + 126f: 74 08 je 1279 + for(i=0; i+1 < max; ){ + 1271: 8d 5e 01 lea 0x1(%esi),%ebx + 1274: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1277: 7c c7 jl 1240 + break; + } + buf[i] = '\0'; + 1279: 8b 45 08 mov 0x8(%ebp),%eax + 127c: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1280: 83 c4 2c add $0x2c,%esp + 1283: 5b pop %ebx + 1284: 5e pop %esi + 1285: 5f pop %edi + 1286: 5d pop %ebp + 1287: c3 ret + 1288: 90 nop + 1289: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001290 : + +int +stat(char *n, struct stat *st) +{ + 1290: 55 push %ebp + 1291: 89 e5 mov %esp,%ebp + 1293: 56 push %esi + 1294: 53 push %ebx + 1295: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 1298: 8b 45 08 mov 0x8(%ebp),%eax + 129b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 12a2: 00 + 12a3: 89 04 24 mov %eax,(%esp) + 12a6: e8 d7 00 00 00 call 1382 + if(fd < 0) + 12ab: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 12ad: 89 c3 mov %eax,%ebx + if(fd < 0) + 12af: 78 27 js 12d8 + return -1; + r = fstat(fd, st); + 12b1: 8b 45 0c mov 0xc(%ebp),%eax + 12b4: 89 1c 24 mov %ebx,(%esp) + 12b7: 89 44 24 04 mov %eax,0x4(%esp) + 12bb: e8 da 00 00 00 call 139a + close(fd); + 12c0: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 12c3: 89 c6 mov %eax,%esi + close(fd); + 12c5: e8 a0 00 00 00 call 136a + return r; + 12ca: 89 f0 mov %esi,%eax +} + 12cc: 83 c4 10 add $0x10,%esp + 12cf: 5b pop %ebx + 12d0: 5e pop %esi + 12d1: 5d pop %ebp + 12d2: c3 ret + 12d3: 90 nop + 12d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 12d8: b8 ff ff ff ff mov $0xffffffff,%eax + 12dd: eb ed jmp 12cc + 12df: 90 nop + +000012e0 : + +int +atoi(const char *s) +{ + 12e0: 55 push %ebp + 12e1: 89 e5 mov %esp,%ebp + 12e3: 8b 4d 08 mov 0x8(%ebp),%ecx + 12e6: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 12e7: 0f be 11 movsbl (%ecx),%edx + 12ea: 8d 42 d0 lea -0x30(%edx),%eax + 12ed: 3c 09 cmp $0x9,%al + n = 0; + 12ef: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 12f4: 77 17 ja 130d + 12f6: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 12f8: 83 c1 01 add $0x1,%ecx + 12fb: 8d 04 80 lea (%eax,%eax,4),%eax + 12fe: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1302: 0f be 11 movsbl (%ecx),%edx + 1305: 8d 5a d0 lea -0x30(%edx),%ebx + 1308: 80 fb 09 cmp $0x9,%bl + 130b: 76 eb jbe 12f8 + return n; +} + 130d: 5b pop %ebx + 130e: 5d pop %ebp + 130f: c3 ret + +00001310 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1310: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1311: 31 d2 xor %edx,%edx +{ + 1313: 89 e5 mov %esp,%ebp + 1315: 56 push %esi + 1316: 8b 45 08 mov 0x8(%ebp),%eax + 1319: 53 push %ebx + 131a: 8b 5d 10 mov 0x10(%ebp),%ebx + 131d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1320: 85 db test %ebx,%ebx + 1322: 7e 12 jle 1336 + 1324: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1328: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 132c: 88 0c 10 mov %cl,(%eax,%edx,1) + 132f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1332: 39 da cmp %ebx,%edx + 1334: 75 f2 jne 1328 + return vdst; +} + 1336: 5b pop %ebx + 1337: 5e pop %esi + 1338: 5d pop %ebp + 1339: c3 ret + +0000133a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 133a: b8 01 00 00 00 mov $0x1,%eax + 133f: cd 40 int $0x40 + 1341: c3 ret + +00001342 : +SYSCALL(exit) + 1342: b8 02 00 00 00 mov $0x2,%eax + 1347: cd 40 int $0x40 + 1349: c3 ret + +0000134a : +SYSCALL(wait) + 134a: b8 03 00 00 00 mov $0x3,%eax + 134f: cd 40 int $0x40 + 1351: c3 ret + +00001352 : +SYSCALL(pipe) + 1352: b8 04 00 00 00 mov $0x4,%eax + 1357: cd 40 int $0x40 + 1359: c3 ret + +0000135a : +SYSCALL(read) + 135a: b8 05 00 00 00 mov $0x5,%eax + 135f: cd 40 int $0x40 + 1361: c3 ret + +00001362 : +SYSCALL(write) + 1362: b8 10 00 00 00 mov $0x10,%eax + 1367: cd 40 int $0x40 + 1369: c3 ret + +0000136a : +SYSCALL(close) + 136a: b8 15 00 00 00 mov $0x15,%eax + 136f: cd 40 int $0x40 + 1371: c3 ret + +00001372 : +SYSCALL(kill) + 1372: b8 06 00 00 00 mov $0x6,%eax + 1377: cd 40 int $0x40 + 1379: c3 ret + +0000137a : +SYSCALL(exec) + 137a: b8 07 00 00 00 mov $0x7,%eax + 137f: cd 40 int $0x40 + 1381: c3 ret + +00001382 : +SYSCALL(open) + 1382: b8 0f 00 00 00 mov $0xf,%eax + 1387: cd 40 int $0x40 + 1389: c3 ret + +0000138a : +SYSCALL(mknod) + 138a: b8 11 00 00 00 mov $0x11,%eax + 138f: cd 40 int $0x40 + 1391: c3 ret + +00001392 : +SYSCALL(unlink) + 1392: b8 12 00 00 00 mov $0x12,%eax + 1397: cd 40 int $0x40 + 1399: c3 ret + +0000139a : +SYSCALL(fstat) + 139a: b8 08 00 00 00 mov $0x8,%eax + 139f: cd 40 int $0x40 + 13a1: c3 ret + +000013a2 : +SYSCALL(link) + 13a2: b8 13 00 00 00 mov $0x13,%eax + 13a7: cd 40 int $0x40 + 13a9: c3 ret + +000013aa : +SYSCALL(mkdir) + 13aa: b8 14 00 00 00 mov $0x14,%eax + 13af: cd 40 int $0x40 + 13b1: c3 ret + +000013b2 : +SYSCALL(chdir) + 13b2: b8 09 00 00 00 mov $0x9,%eax + 13b7: cd 40 int $0x40 + 13b9: c3 ret + +000013ba : +SYSCALL(dup) + 13ba: b8 0a 00 00 00 mov $0xa,%eax + 13bf: cd 40 int $0x40 + 13c1: c3 ret + +000013c2 : +SYSCALL(getpid) + 13c2: b8 0b 00 00 00 mov $0xb,%eax + 13c7: cd 40 int $0x40 + 13c9: c3 ret + +000013ca : +SYSCALL(sbrk) + 13ca: b8 0c 00 00 00 mov $0xc,%eax + 13cf: cd 40 int $0x40 + 13d1: c3 ret + +000013d2 : +SYSCALL(sleep) + 13d2: b8 0d 00 00 00 mov $0xd,%eax + 13d7: cd 40 int $0x40 + 13d9: c3 ret + +000013da : +SYSCALL(uptime) + 13da: b8 0e 00 00 00 mov $0xe,%eax + 13df: cd 40 int $0x40 + 13e1: c3 ret + +000013e2 : +SYSCALL(shm_open) + 13e2: b8 16 00 00 00 mov $0x16,%eax + 13e7: cd 40 int $0x40 + 13e9: c3 ret + +000013ea : +SYSCALL(shm_close) + 13ea: b8 17 00 00 00 mov $0x17,%eax + 13ef: cd 40 int $0x40 + 13f1: c3 ret + 13f2: 66 90 xchg %ax,%ax + 13f4: 66 90 xchg %ax,%ax + 13f6: 66 90 xchg %ax,%ax + 13f8: 66 90 xchg %ax,%ax + 13fa: 66 90 xchg %ax,%ax + 13fc: 66 90 xchg %ax,%ax + 13fe: 66 90 xchg %ax,%ax + +00001400 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 1400: 55 push %ebp + 1401: 89 e5 mov %esp,%ebp + 1403: 57 push %edi + 1404: 56 push %esi + 1405: 89 c6 mov %eax,%esi + 1407: 53 push %ebx + 1408: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 140b: 8b 5d 08 mov 0x8(%ebp),%ebx + 140e: 85 db test %ebx,%ebx + 1410: 74 09 je 141b + 1412: 89 d0 mov %edx,%eax + 1414: c1 e8 1f shr $0x1f,%eax + 1417: 84 c0 test %al,%al + 1419: 75 75 jne 1490 + neg = 1; + x = -xx; + } else { + x = xx; + 141b: 89 d0 mov %edx,%eax + neg = 0; + 141d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1424: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1427: 31 ff xor %edi,%edi + 1429: 89 ce mov %ecx,%esi + 142b: 8d 5d d7 lea -0x29(%ebp),%ebx + 142e: eb 02 jmp 1432 + do{ + buf[i++] = digits[x % base]; + 1430: 89 cf mov %ecx,%edi + 1432: 31 d2 xor %edx,%edx + 1434: f7 f6 div %esi + 1436: 8d 4f 01 lea 0x1(%edi),%ecx + 1439: 0f b6 92 80 18 00 00 movzbl 0x1880(%edx),%edx + }while((x /= base) != 0); + 1440: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 1442: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 1445: 75 e9 jne 1430 + if(neg) + 1447: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 144a: 89 c8 mov %ecx,%eax + 144c: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 144f: 85 d2 test %edx,%edx + 1451: 74 08 je 145b + buf[i++] = '-'; + 1453: 8d 4f 02 lea 0x2(%edi),%ecx + 1456: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 145b: 8d 79 ff lea -0x1(%ecx),%edi + 145e: 66 90 xchg %ax,%ax + 1460: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 1465: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 1468: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 146f: 00 + 1470: 89 5c 24 04 mov %ebx,0x4(%esp) + 1474: 89 34 24 mov %esi,(%esp) + 1477: 88 45 d7 mov %al,-0x29(%ebp) + 147a: e8 e3 fe ff ff call 1362 + while(--i >= 0) + 147f: 83 ff ff cmp $0xffffffff,%edi + 1482: 75 dc jne 1460 + putc(fd, buf[i]); +} + 1484: 83 c4 4c add $0x4c,%esp + 1487: 5b pop %ebx + 1488: 5e pop %esi + 1489: 5f pop %edi + 148a: 5d pop %ebp + 148b: c3 ret + 148c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 1490: 89 d0 mov %edx,%eax + 1492: f7 d8 neg %eax + neg = 1; + 1494: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 149b: eb 87 jmp 1424 + 149d: 8d 76 00 lea 0x0(%esi),%esi + +000014a0 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 14a0: 55 push %ebp + 14a1: 89 e5 mov %esp,%ebp + 14a3: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 14a4: 31 ff xor %edi,%edi +{ + 14a6: 56 push %esi + 14a7: 53 push %ebx + 14a8: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 14ab: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 14ae: 8d 45 10 lea 0x10(%ebp),%eax +{ + 14b1: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 14b4: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 14b7: 0f b6 13 movzbl (%ebx),%edx + 14ba: 83 c3 01 add $0x1,%ebx + 14bd: 84 d2 test %dl,%dl + 14bf: 75 39 jne 14fa + 14c1: e9 c2 00 00 00 jmp 1588 + 14c6: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 14c8: 83 fa 25 cmp $0x25,%edx + 14cb: 0f 84 bf 00 00 00 je 1590 + write(fd, &c, 1); + 14d1: 8d 45 e2 lea -0x1e(%ebp),%eax + 14d4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14db: 00 + 14dc: 89 44 24 04 mov %eax,0x4(%esp) + 14e0: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 14e3: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 14e6: e8 77 fe ff ff call 1362 + 14eb: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 14ee: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 14f2: 84 d2 test %dl,%dl + 14f4: 0f 84 8e 00 00 00 je 1588 + if(state == 0){ + 14fa: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 14fc: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 14ff: 74 c7 je 14c8 + } + } else if(state == '%'){ + 1501: 83 ff 25 cmp $0x25,%edi + 1504: 75 e5 jne 14eb + if(c == 'd'){ + 1506: 83 fa 64 cmp $0x64,%edx + 1509: 0f 84 31 01 00 00 je 1640 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 150f: 25 f7 00 00 00 and $0xf7,%eax + 1514: 83 f8 70 cmp $0x70,%eax + 1517: 0f 84 83 00 00 00 je 15a0 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 151d: 83 fa 73 cmp $0x73,%edx + 1520: 0f 84 a2 00 00 00 je 15c8 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1526: 83 fa 63 cmp $0x63,%edx + 1529: 0f 84 35 01 00 00 je 1664 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 152f: 83 fa 25 cmp $0x25,%edx + 1532: 0f 84 e0 00 00 00 je 1618 + write(fd, &c, 1); + 1538: 8d 45 e6 lea -0x1a(%ebp),%eax + 153b: 83 c3 01 add $0x1,%ebx + 153e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1545: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 1546: 31 ff xor %edi,%edi + write(fd, &c, 1); + 1548: 89 44 24 04 mov %eax,0x4(%esp) + 154c: 89 34 24 mov %esi,(%esp) + 154f: 89 55 d0 mov %edx,-0x30(%ebp) + 1552: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 1556: e8 07 fe ff ff call 1362 + putc(fd, c); + 155b: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 155e: 8d 45 e7 lea -0x19(%ebp),%eax + 1561: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1568: 00 + 1569: 89 44 24 04 mov %eax,0x4(%esp) + 156d: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 1570: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 1573: e8 ea fd ff ff call 1362 + for(i = 0; fmt[i]; i++){ + 1578: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 157c: 84 d2 test %dl,%dl + 157e: 0f 85 76 ff ff ff jne 14fa + 1584: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 1588: 83 c4 3c add $0x3c,%esp + 158b: 5b pop %ebx + 158c: 5e pop %esi + 158d: 5f pop %edi + 158e: 5d pop %ebp + 158f: c3 ret + state = '%'; + 1590: bf 25 00 00 00 mov $0x25,%edi + 1595: e9 51 ff ff ff jmp 14eb + 159a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 15a0: 8b 45 d4 mov -0x2c(%ebp),%eax + 15a3: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 15a8: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 15aa: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 15b1: 8b 10 mov (%eax),%edx + 15b3: 89 f0 mov %esi,%eax + 15b5: e8 46 fe ff ff call 1400 + ap++; + 15ba: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15be: e9 28 ff ff ff jmp 14eb + 15c3: 90 nop + 15c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 15c8: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 15cb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 15cf: 8b 38 mov (%eax),%edi + s = "(null)"; + 15d1: b8 79 18 00 00 mov $0x1879,%eax + 15d6: 85 ff test %edi,%edi + 15d8: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 15db: 0f b6 07 movzbl (%edi),%eax + 15de: 84 c0 test %al,%al + 15e0: 74 2a je 160c + 15e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 15e8: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 15eb: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 15ee: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 15f1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 15f8: 00 + 15f9: 89 44 24 04 mov %eax,0x4(%esp) + 15fd: 89 34 24 mov %esi,(%esp) + 1600: e8 5d fd ff ff call 1362 + while(*s != 0){ + 1605: 0f b6 07 movzbl (%edi),%eax + 1608: 84 c0 test %al,%al + 160a: 75 dc jne 15e8 + state = 0; + 160c: 31 ff xor %edi,%edi + 160e: e9 d8 fe ff ff jmp 14eb + 1613: 90 nop + 1614: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1618: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 161b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 161d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1624: 00 + 1625: 89 44 24 04 mov %eax,0x4(%esp) + 1629: 89 34 24 mov %esi,(%esp) + 162c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1630: e8 2d fd ff ff call 1362 + 1635: e9 b1 fe ff ff jmp 14eb + 163a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 1640: 8b 45 d4 mov -0x2c(%ebp),%eax + 1643: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 1648: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 164b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1652: 8b 10 mov (%eax),%edx + 1654: 89 f0 mov %esi,%eax + 1656: e8 a5 fd ff ff call 1400 + ap++; + 165b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 165f: e9 87 fe ff ff jmp 14eb + putc(fd, *ap); + 1664: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 1667: 31 ff xor %edi,%edi + putc(fd, *ap); + 1669: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 166b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1672: 00 + 1673: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 1676: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 1679: 8d 45 e4 lea -0x1c(%ebp),%eax + 167c: 89 44 24 04 mov %eax,0x4(%esp) + 1680: e8 dd fc ff ff call 1362 + ap++; + 1685: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 1689: e9 5d fe ff ff jmp 14eb + 168e: 66 90 xchg %ax,%ax + +00001690 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 1690: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1691: a1 80 1b 00 00 mov 0x1b80,%eax +{ + 1696: 89 e5 mov %esp,%ebp + 1698: 57 push %edi + 1699: 56 push %esi + 169a: 53 push %ebx + 169b: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 169e: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 16a0: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 16a3: 39 d0 cmp %edx,%eax + 16a5: 72 11 jb 16b8 + 16a7: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 16a8: 39 c8 cmp %ecx,%eax + 16aa: 72 04 jb 16b0 + 16ac: 39 ca cmp %ecx,%edx + 16ae: 72 10 jb 16c0 + 16b0: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 16b2: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 16b4: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 16b6: 73 f0 jae 16a8 + 16b8: 39 ca cmp %ecx,%edx + 16ba: 72 04 jb 16c0 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 16bc: 39 c8 cmp %ecx,%eax + 16be: 72 f0 jb 16b0 + break; + if(bp + bp->s.size == p->s.ptr){ + 16c0: 8b 73 fc mov -0x4(%ebx),%esi + 16c3: 8d 3c f2 lea (%edx,%esi,8),%edi + 16c6: 39 cf cmp %ecx,%edi + 16c8: 74 1e je 16e8 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 16ca: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 16cd: 8b 48 04 mov 0x4(%eax),%ecx + 16d0: 8d 34 c8 lea (%eax,%ecx,8),%esi + 16d3: 39 f2 cmp %esi,%edx + 16d5: 74 28 je 16ff + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 16d7: 89 10 mov %edx,(%eax) + freep = p; + 16d9: a3 80 1b 00 00 mov %eax,0x1b80 +} + 16de: 5b pop %ebx + 16df: 5e pop %esi + 16e0: 5f pop %edi + 16e1: 5d pop %ebp + 16e2: c3 ret + 16e3: 90 nop + 16e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 16e8: 03 71 04 add 0x4(%ecx),%esi + 16eb: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 16ee: 8b 08 mov (%eax),%ecx + 16f0: 8b 09 mov (%ecx),%ecx + 16f2: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 16f5: 8b 48 04 mov 0x4(%eax),%ecx + 16f8: 8d 34 c8 lea (%eax,%ecx,8),%esi + 16fb: 39 f2 cmp %esi,%edx + 16fd: 75 d8 jne 16d7 + p->s.size += bp->s.size; + 16ff: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 1702: a3 80 1b 00 00 mov %eax,0x1b80 + p->s.size += bp->s.size; + 1707: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 170a: 8b 53 f8 mov -0x8(%ebx),%edx + 170d: 89 10 mov %edx,(%eax) +} + 170f: 5b pop %ebx + 1710: 5e pop %esi + 1711: 5f pop %edi + 1712: 5d pop %ebp + 1713: c3 ret + 1714: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 171a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001720 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1720: 55 push %ebp + 1721: 89 e5 mov %esp,%ebp + 1723: 57 push %edi + 1724: 56 push %esi + 1725: 53 push %ebx + 1726: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1729: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 172c: 8b 1d 80 1b 00 00 mov 0x1b80,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1732: 8d 48 07 lea 0x7(%eax),%ecx + 1735: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1738: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 173a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 173d: 0f 84 9b 00 00 00 je 17de + 1743: 8b 13 mov (%ebx),%edx + 1745: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 1748: 39 fe cmp %edi,%esi + 174a: 76 64 jbe 17b0 + 174c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 1753: bb 00 80 00 00 mov $0x8000,%ebx + 1758: 89 45 e4 mov %eax,-0x1c(%ebp) + 175b: eb 0e jmp 176b + 175d: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 1760: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 1762: 8b 78 04 mov 0x4(%eax),%edi + 1765: 39 fe cmp %edi,%esi + 1767: 76 4f jbe 17b8 + 1769: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 176b: 3b 15 80 1b 00 00 cmp 0x1b80,%edx + 1771: 75 ed jne 1760 + if(nu < 4096) + 1773: 8b 45 e4 mov -0x1c(%ebp),%eax + 1776: 81 fe 00 10 00 00 cmp $0x1000,%esi + 177c: bf 00 10 00 00 mov $0x1000,%edi + 1781: 0f 43 fe cmovae %esi,%edi + 1784: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 1787: 89 04 24 mov %eax,(%esp) + 178a: e8 3b fc ff ff call 13ca + if(p == (char*)-1) + 178f: 83 f8 ff cmp $0xffffffff,%eax + 1792: 74 18 je 17ac + hp->s.size = nu; + 1794: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 1797: 83 c0 08 add $0x8,%eax + 179a: 89 04 24 mov %eax,(%esp) + 179d: e8 ee fe ff ff call 1690 + return freep; + 17a2: 8b 15 80 1b 00 00 mov 0x1b80,%edx + if((p = morecore(nunits)) == 0) + 17a8: 85 d2 test %edx,%edx + 17aa: 75 b4 jne 1760 + return 0; + 17ac: 31 c0 xor %eax,%eax + 17ae: eb 20 jmp 17d0 + if(p->s.size >= nunits){ + 17b0: 89 d0 mov %edx,%eax + 17b2: 89 da mov %ebx,%edx + 17b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 17b8: 39 fe cmp %edi,%esi + 17ba: 74 1c je 17d8 + p->s.size -= nunits; + 17bc: 29 f7 sub %esi,%edi + 17be: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 17c1: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 17c4: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 17c7: 89 15 80 1b 00 00 mov %edx,0x1b80 + return (void*)(p + 1); + 17cd: 83 c0 08 add $0x8,%eax + } +} + 17d0: 83 c4 1c add $0x1c,%esp + 17d3: 5b pop %ebx + 17d4: 5e pop %esi + 17d5: 5f pop %edi + 17d6: 5d pop %ebp + 17d7: c3 ret + prevp->s.ptr = p->s.ptr; + 17d8: 8b 08 mov (%eax),%ecx + 17da: 89 0a mov %ecx,(%edx) + 17dc: eb e9 jmp 17c7 + base.s.ptr = freep = prevp = &base; + 17de: c7 05 80 1b 00 00 84 movl $0x1b84,0x1b80 + 17e5: 1b 00 00 + base.s.size = 0; + 17e8: ba 84 1b 00 00 mov $0x1b84,%edx + base.s.ptr = freep = prevp = &base; + 17ed: c7 05 84 1b 00 00 84 movl $0x1b84,0x1b84 + 17f4: 1b 00 00 + base.s.size = 0; + 17f7: c7 05 88 1b 00 00 00 movl $0x0,0x1b88 + 17fe: 00 00 00 + 1801: e9 46 ff ff ff jmp 174c + 1806: 66 90 xchg %ax,%ax + 1808: 66 90 xchg %ax,%ax + 180a: 66 90 xchg %ax,%ax + 180c: 66 90 xchg %ax,%ax + 180e: 66 90 xchg %ax,%ax + +00001810 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1810: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1811: b9 01 00 00 00 mov $0x1,%ecx + 1816: 89 e5 mov %esp,%ebp + 1818: 8b 55 08 mov 0x8(%ebp),%edx + 181b: 90 nop + 181c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1820: 89 c8 mov %ecx,%eax + 1822: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1825: 85 c0 test %eax,%eax + 1827: 75 f7 jne 1820 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1829: 0f ae f0 mfence +} + 182c: 5d pop %ebp + 182d: c3 ret + 182e: 66 90 xchg %ax,%ax + +00001830 : + +void urelease (struct uspinlock *lk) { + 1830: 55 push %ebp + 1831: 89 e5 mov %esp,%ebp + 1833: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1836: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1839: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 183f: 5d pop %ebp + 1840: c3 ret diff --git a/cat.d b/cat.d new file mode 100644 index 00000000..8f55acca --- /dev/null +++ b/cat.d @@ -0,0 +1 @@ +cat.o: cat.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/cat.o b/cat.o new file mode 100644 index 00000000..207ec6b1 Binary files /dev/null and b/cat.o differ diff --git a/cat.sym b/cat.sym new file mode 100644 index 00000000..8004974f --- /dev/null +++ b/cat.sym @@ -0,0 +1,64 @@ +00001000 .text +00001841 .rodata +00001894 .eh_frame +00001b80 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 cat.c +00000000 ulib.c +00000000 printf.c +00001400 printint +00001880 digits.1359 +00000000 umalloc.c +00001b80 freep +00001b84 base +00000000 uspinlock.c +00001120 strcpy +000014a0 printf +00001310 memmove +0000138a mknod +000013e2 shm_open +00001230 gets +000013c2 getpid +00001090 cat +00001720 malloc +000013d2 sleep +00001352 pipe +00001362 write +0000139a fstat +00001372 kill +000013b2 chdir +0000137a exec +0000134a wait +0000135a read +00001392 unlink +00001810 uacquire +0000133a fork +000013ca sbrk +000013ea shm_close +000013da uptime +00001b6c __bss_start +000011d0 memset +00001000 main +00001150 strcmp +000013ba dup +00001ba0 buf +00001290 stat +00001b6c _edata +00001da0 _end +000013a2 link +00001342 exit +000012e0 atoi +000011a0 strlen +00001382 open +000011f0 strchr +000013aa mkdir +0000136a close +00001830 urelease +00001690 free diff --git a/console.d b/console.d new file mode 100644 index 00000000..7b5564c2 --- /dev/null +++ b/console.d @@ -0,0 +1,3 @@ +console.o: console.c /usr/include/stdc-predef.h types.h defs.h param.h \ + traps.h spinlock.h sleeplock.h fs.h file.h memlayout.h mmu.h proc.h \ + x86.h diff --git a/console.o b/console.o new file mode 100644 index 00000000..38356a01 Binary files /dev/null and b/console.o differ diff --git a/defs.h b/defs.h index 889539b9..d74be49c 100644 --- a/defs.h +++ b/defs.h @@ -180,15 +180,13 @@ int deallocuvm(pde_t*, uint, uint); void freevm(pde_t*); void inituvm(pde_t*, char*, uint); int loaduvm(pde_t*, char*, struct inode*, uint, uint); -pde_t* copyuvm(pde_t*, uint); +pde_t* copyuvm(pde_t*, uint, uint); // ** added an extra arg for stack void switchuvm(struct proc*); void switchkvm(void); int copyout(pde_t*, uint, void*, uint); void clearpteu(pde_t *pgdir, char *uva); -//made mappages visible (and removed static) to facilitate implementing shm -int -mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm); +// ** deleted mappages was giving compilation problems //shm.c void shminit(void); diff --git a/echo.asm b/echo.asm new file mode 100644 index 00000000..46b5f43c --- /dev/null +++ b/echo.asm @@ -0,0 +1,1220 @@ + +_echo: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: +#include "stat.h" +#include "user.h" + +int +main(int argc, char *argv[]) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 57 push %edi + 1004: 56 push %esi + 1005: 53 push %ebx + 1006: 83 e4 f0 and $0xfffffff0,%esp + 1009: 83 ec 10 sub $0x10,%esp + 100c: 8b 75 08 mov 0x8(%ebp),%esi + 100f: 8b 7d 0c mov 0xc(%ebp),%edi + int i; + + for(i = 1; i < argc; i++) + 1012: 83 fe 01 cmp $0x1,%esi + 1015: 7e 58 jle 106f + 1017: bb 01 00 00 00 mov $0x1,%ebx + 101c: eb 26 jmp 1044 + 101e: 66 90 xchg %ax,%ax + printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n"); + 1020: c7 44 24 0c a1 17 00 movl $0x17a1,0xc(%esp) + 1027: 00 + 1028: 8b 44 9f fc mov -0x4(%edi,%ebx,4),%eax + 102c: c7 44 24 04 a3 17 00 movl $0x17a3,0x4(%esp) + 1033: 00 + 1034: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 103b: 89 44 24 08 mov %eax,0x8(%esp) + 103f: e8 bc 03 00 00 call 1400 + 1044: 83 c3 01 add $0x1,%ebx + 1047: 39 f3 cmp %esi,%ebx + 1049: 75 d5 jne 1020 + 104b: c7 44 24 0c a8 17 00 movl $0x17a8,0xc(%esp) + 1052: 00 + 1053: 8b 44 9f fc mov -0x4(%edi,%ebx,4),%eax + 1057: c7 44 24 04 a3 17 00 movl $0x17a3,0x4(%esp) + 105e: 00 + 105f: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1066: 89 44 24 08 mov %eax,0x8(%esp) + 106a: e8 91 03 00 00 call 1400 + exit(); + 106f: e8 2e 02 00 00 call 12a2 + 1074: 66 90 xchg %ax,%ax + 1076: 66 90 xchg %ax,%ax + 1078: 66 90 xchg %ax,%ax + 107a: 66 90 xchg %ax,%ax + 107c: 66 90 xchg %ax,%ax + 107e: 66 90 xchg %ax,%ax + +00001080 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1080: 55 push %ebp + 1081: 89 e5 mov %esp,%ebp + 1083: 8b 45 08 mov 0x8(%ebp),%eax + 1086: 8b 4d 0c mov 0xc(%ebp),%ecx + 1089: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 108a: 89 c2 mov %eax,%edx + 108c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1090: 83 c1 01 add $0x1,%ecx + 1093: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1097: 83 c2 01 add $0x1,%edx + 109a: 84 db test %bl,%bl + 109c: 88 5a ff mov %bl,-0x1(%edx) + 109f: 75 ef jne 1090 + ; + return os; +} + 10a1: 5b pop %ebx + 10a2: 5d pop %ebp + 10a3: c3 ret + 10a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 10aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +000010b0 : + +int +strcmp(const char *p, const char *q) +{ + 10b0: 55 push %ebp + 10b1: 89 e5 mov %esp,%ebp + 10b3: 8b 55 08 mov 0x8(%ebp),%edx + 10b6: 53 push %ebx + 10b7: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 10ba: 0f b6 02 movzbl (%edx),%eax + 10bd: 84 c0 test %al,%al + 10bf: 74 2d je 10ee + 10c1: 0f b6 19 movzbl (%ecx),%ebx + 10c4: 38 d8 cmp %bl,%al + 10c6: 74 0e je 10d6 + 10c8: eb 2b jmp 10f5 + 10ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 10d0: 38 c8 cmp %cl,%al + 10d2: 75 15 jne 10e9 + p++, q++; + 10d4: 89 d9 mov %ebx,%ecx + 10d6: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 10d9: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 10dc: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 10df: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 10e3: 84 c0 test %al,%al + 10e5: 75 e9 jne 10d0 + 10e7: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 10e9: 29 c8 sub %ecx,%eax +} + 10eb: 5b pop %ebx + 10ec: 5d pop %ebp + 10ed: c3 ret + 10ee: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 10f1: 31 c0 xor %eax,%eax + 10f3: eb f4 jmp 10e9 + 10f5: 0f b6 cb movzbl %bl,%ecx + 10f8: eb ef jmp 10e9 + 10fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00001100 : + +uint +strlen(char *s) +{ + 1100: 55 push %ebp + 1101: 89 e5 mov %esp,%ebp + 1103: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 1106: 80 39 00 cmpb $0x0,(%ecx) + 1109: 74 12 je 111d + 110b: 31 d2 xor %edx,%edx + 110d: 8d 76 00 lea 0x0(%esi),%esi + 1110: 83 c2 01 add $0x1,%edx + 1113: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 1117: 89 d0 mov %edx,%eax + 1119: 75 f5 jne 1110 + ; + return n; +} + 111b: 5d pop %ebp + 111c: c3 ret + for(n = 0; s[n]; n++) + 111d: 31 c0 xor %eax,%eax +} + 111f: 5d pop %ebp + 1120: c3 ret + 1121: eb 0d jmp 1130 + 1123: 90 nop + 1124: 90 nop + 1125: 90 nop + 1126: 90 nop + 1127: 90 nop + 1128: 90 nop + 1129: 90 nop + 112a: 90 nop + 112b: 90 nop + 112c: 90 nop + 112d: 90 nop + 112e: 90 nop + 112f: 90 nop + +00001130 : + +void* +memset(void *dst, int c, uint n) +{ + 1130: 55 push %ebp + 1131: 89 e5 mov %esp,%ebp + 1133: 8b 55 08 mov 0x8(%ebp),%edx + 1136: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 1137: 8b 4d 10 mov 0x10(%ebp),%ecx + 113a: 8b 45 0c mov 0xc(%ebp),%eax + 113d: 89 d7 mov %edx,%edi + 113f: fc cld + 1140: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1142: 89 d0 mov %edx,%eax + 1144: 5f pop %edi + 1145: 5d pop %ebp + 1146: c3 ret + 1147: 89 f6 mov %esi,%esi + 1149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001150 : + +char* +strchr(const char *s, char c) +{ + 1150: 55 push %ebp + 1151: 89 e5 mov %esp,%ebp + 1153: 8b 45 08 mov 0x8(%ebp),%eax + 1156: 53 push %ebx + 1157: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 115a: 0f b6 18 movzbl (%eax),%ebx + 115d: 84 db test %bl,%bl + 115f: 74 1d je 117e + if(*s == c) + 1161: 38 d3 cmp %dl,%bl + 1163: 89 d1 mov %edx,%ecx + 1165: 75 0d jne 1174 + 1167: eb 17 jmp 1180 + 1169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1170: 38 ca cmp %cl,%dl + 1172: 74 0c je 1180 + for(; *s; s++) + 1174: 83 c0 01 add $0x1,%eax + 1177: 0f b6 10 movzbl (%eax),%edx + 117a: 84 d2 test %dl,%dl + 117c: 75 f2 jne 1170 + return (char*)s; + return 0; + 117e: 31 c0 xor %eax,%eax +} + 1180: 5b pop %ebx + 1181: 5d pop %ebp + 1182: c3 ret + 1183: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1189: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001190 : + +char* +gets(char *buf, int max) +{ + 1190: 55 push %ebp + 1191: 89 e5 mov %esp,%ebp + 1193: 57 push %edi + 1194: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1195: 31 f6 xor %esi,%esi +{ + 1197: 53 push %ebx + 1198: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 119b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 119e: eb 31 jmp 11d1 + cc = read(0, &c, 1); + 11a0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 11a7: 00 + 11a8: 89 7c 24 04 mov %edi,0x4(%esp) + 11ac: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 11b3: e8 02 01 00 00 call 12ba + if(cc < 1) + 11b8: 85 c0 test %eax,%eax + 11ba: 7e 1d jle 11d9 + break; + buf[i++] = c; + 11bc: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 11c0: 89 de mov %ebx,%esi + buf[i++] = c; + 11c2: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 11c5: 3c 0d cmp $0xd,%al + buf[i++] = c; + 11c7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 11cb: 74 0c je 11d9 + 11cd: 3c 0a cmp $0xa,%al + 11cf: 74 08 je 11d9 + for(i=0; i+1 < max; ){ + 11d1: 8d 5e 01 lea 0x1(%esi),%ebx + 11d4: 3b 5d 0c cmp 0xc(%ebp),%ebx + 11d7: 7c c7 jl 11a0 + break; + } + buf[i] = '\0'; + 11d9: 8b 45 08 mov 0x8(%ebp),%eax + 11dc: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 11e0: 83 c4 2c add $0x2c,%esp + 11e3: 5b pop %ebx + 11e4: 5e pop %esi + 11e5: 5f pop %edi + 11e6: 5d pop %ebp + 11e7: c3 ret + 11e8: 90 nop + 11e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000011f0 : + +int +stat(char *n, struct stat *st) +{ + 11f0: 55 push %ebp + 11f1: 89 e5 mov %esp,%ebp + 11f3: 56 push %esi + 11f4: 53 push %ebx + 11f5: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 11f8: 8b 45 08 mov 0x8(%ebp),%eax + 11fb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1202: 00 + 1203: 89 04 24 mov %eax,(%esp) + 1206: e8 d7 00 00 00 call 12e2 + if(fd < 0) + 120b: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 120d: 89 c3 mov %eax,%ebx + if(fd < 0) + 120f: 78 27 js 1238 + return -1; + r = fstat(fd, st); + 1211: 8b 45 0c mov 0xc(%ebp),%eax + 1214: 89 1c 24 mov %ebx,(%esp) + 1217: 89 44 24 04 mov %eax,0x4(%esp) + 121b: e8 da 00 00 00 call 12fa + close(fd); + 1220: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 1223: 89 c6 mov %eax,%esi + close(fd); + 1225: e8 a0 00 00 00 call 12ca + return r; + 122a: 89 f0 mov %esi,%eax +} + 122c: 83 c4 10 add $0x10,%esp + 122f: 5b pop %ebx + 1230: 5e pop %esi + 1231: 5d pop %ebp + 1232: c3 ret + 1233: 90 nop + 1234: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 1238: b8 ff ff ff ff mov $0xffffffff,%eax + 123d: eb ed jmp 122c + 123f: 90 nop + +00001240 : + +int +atoi(const char *s) +{ + 1240: 55 push %ebp + 1241: 89 e5 mov %esp,%ebp + 1243: 8b 4d 08 mov 0x8(%ebp),%ecx + 1246: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 1247: 0f be 11 movsbl (%ecx),%edx + 124a: 8d 42 d0 lea -0x30(%edx),%eax + 124d: 3c 09 cmp $0x9,%al + n = 0; + 124f: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 1254: 77 17 ja 126d + 1256: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 1258: 83 c1 01 add $0x1,%ecx + 125b: 8d 04 80 lea (%eax,%eax,4),%eax + 125e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1262: 0f be 11 movsbl (%ecx),%edx + 1265: 8d 5a d0 lea -0x30(%edx),%ebx + 1268: 80 fb 09 cmp $0x9,%bl + 126b: 76 eb jbe 1258 + return n; +} + 126d: 5b pop %ebx + 126e: 5d pop %ebp + 126f: c3 ret + +00001270 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1270: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1271: 31 d2 xor %edx,%edx +{ + 1273: 89 e5 mov %esp,%ebp + 1275: 56 push %esi + 1276: 8b 45 08 mov 0x8(%ebp),%eax + 1279: 53 push %ebx + 127a: 8b 5d 10 mov 0x10(%ebp),%ebx + 127d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1280: 85 db test %ebx,%ebx + 1282: 7e 12 jle 1296 + 1284: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1288: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 128c: 88 0c 10 mov %cl,(%eax,%edx,1) + 128f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1292: 39 da cmp %ebx,%edx + 1294: 75 f2 jne 1288 + return vdst; +} + 1296: 5b pop %ebx + 1297: 5e pop %esi + 1298: 5d pop %ebp + 1299: c3 ret + +0000129a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 129a: b8 01 00 00 00 mov $0x1,%eax + 129f: cd 40 int $0x40 + 12a1: c3 ret + +000012a2 : +SYSCALL(exit) + 12a2: b8 02 00 00 00 mov $0x2,%eax + 12a7: cd 40 int $0x40 + 12a9: c3 ret + +000012aa : +SYSCALL(wait) + 12aa: b8 03 00 00 00 mov $0x3,%eax + 12af: cd 40 int $0x40 + 12b1: c3 ret + +000012b2 : +SYSCALL(pipe) + 12b2: b8 04 00 00 00 mov $0x4,%eax + 12b7: cd 40 int $0x40 + 12b9: c3 ret + +000012ba : +SYSCALL(read) + 12ba: b8 05 00 00 00 mov $0x5,%eax + 12bf: cd 40 int $0x40 + 12c1: c3 ret + +000012c2 : +SYSCALL(write) + 12c2: b8 10 00 00 00 mov $0x10,%eax + 12c7: cd 40 int $0x40 + 12c9: c3 ret + +000012ca : +SYSCALL(close) + 12ca: b8 15 00 00 00 mov $0x15,%eax + 12cf: cd 40 int $0x40 + 12d1: c3 ret + +000012d2 : +SYSCALL(kill) + 12d2: b8 06 00 00 00 mov $0x6,%eax + 12d7: cd 40 int $0x40 + 12d9: c3 ret + +000012da : +SYSCALL(exec) + 12da: b8 07 00 00 00 mov $0x7,%eax + 12df: cd 40 int $0x40 + 12e1: c3 ret + +000012e2 : +SYSCALL(open) + 12e2: b8 0f 00 00 00 mov $0xf,%eax + 12e7: cd 40 int $0x40 + 12e9: c3 ret + +000012ea : +SYSCALL(mknod) + 12ea: b8 11 00 00 00 mov $0x11,%eax + 12ef: cd 40 int $0x40 + 12f1: c3 ret + +000012f2 : +SYSCALL(unlink) + 12f2: b8 12 00 00 00 mov $0x12,%eax + 12f7: cd 40 int $0x40 + 12f9: c3 ret + +000012fa : +SYSCALL(fstat) + 12fa: b8 08 00 00 00 mov $0x8,%eax + 12ff: cd 40 int $0x40 + 1301: c3 ret + +00001302 : +SYSCALL(link) + 1302: b8 13 00 00 00 mov $0x13,%eax + 1307: cd 40 int $0x40 + 1309: c3 ret + +0000130a : +SYSCALL(mkdir) + 130a: b8 14 00 00 00 mov $0x14,%eax + 130f: cd 40 int $0x40 + 1311: c3 ret + +00001312 : +SYSCALL(chdir) + 1312: b8 09 00 00 00 mov $0x9,%eax + 1317: cd 40 int $0x40 + 1319: c3 ret + +0000131a : +SYSCALL(dup) + 131a: b8 0a 00 00 00 mov $0xa,%eax + 131f: cd 40 int $0x40 + 1321: c3 ret + +00001322 : +SYSCALL(getpid) + 1322: b8 0b 00 00 00 mov $0xb,%eax + 1327: cd 40 int $0x40 + 1329: c3 ret + +0000132a : +SYSCALL(sbrk) + 132a: b8 0c 00 00 00 mov $0xc,%eax + 132f: cd 40 int $0x40 + 1331: c3 ret + +00001332 : +SYSCALL(sleep) + 1332: b8 0d 00 00 00 mov $0xd,%eax + 1337: cd 40 int $0x40 + 1339: c3 ret + +0000133a : +SYSCALL(uptime) + 133a: b8 0e 00 00 00 mov $0xe,%eax + 133f: cd 40 int $0x40 + 1341: c3 ret + +00001342 : +SYSCALL(shm_open) + 1342: b8 16 00 00 00 mov $0x16,%eax + 1347: cd 40 int $0x40 + 1349: c3 ret + +0000134a : +SYSCALL(shm_close) + 134a: b8 17 00 00 00 mov $0x17,%eax + 134f: cd 40 int $0x40 + 1351: c3 ret + 1352: 66 90 xchg %ax,%ax + 1354: 66 90 xchg %ax,%ax + 1356: 66 90 xchg %ax,%ax + 1358: 66 90 xchg %ax,%ax + 135a: 66 90 xchg %ax,%ax + 135c: 66 90 xchg %ax,%ax + 135e: 66 90 xchg %ax,%ax + +00001360 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 1360: 55 push %ebp + 1361: 89 e5 mov %esp,%ebp + 1363: 57 push %edi + 1364: 56 push %esi + 1365: 89 c6 mov %eax,%esi + 1367: 53 push %ebx + 1368: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 136b: 8b 5d 08 mov 0x8(%ebp),%ebx + 136e: 85 db test %ebx,%ebx + 1370: 74 09 je 137b + 1372: 89 d0 mov %edx,%eax + 1374: c1 e8 1f shr $0x1f,%eax + 1377: 84 c0 test %al,%al + 1379: 75 75 jne 13f0 + neg = 1; + x = -xx; + } else { + x = xx; + 137b: 89 d0 mov %edx,%eax + neg = 0; + 137d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1384: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1387: 31 ff xor %edi,%edi + 1389: 89 ce mov %ecx,%esi + 138b: 8d 5d d7 lea -0x29(%ebp),%ebx + 138e: eb 02 jmp 1392 + do{ + buf[i++] = digits[x % base]; + 1390: 89 cf mov %ecx,%edi + 1392: 31 d2 xor %edx,%edx + 1394: f7 f6 div %esi + 1396: 8d 4f 01 lea 0x1(%edi),%ecx + 1399: 0f b6 92 b1 17 00 00 movzbl 0x17b1(%edx),%edx + }while((x /= base) != 0); + 13a0: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 13a2: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 13a5: 75 e9 jne 1390 + if(neg) + 13a7: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 13aa: 89 c8 mov %ecx,%eax + 13ac: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 13af: 85 d2 test %edx,%edx + 13b1: 74 08 je 13bb + buf[i++] = '-'; + 13b3: 8d 4f 02 lea 0x2(%edi),%ecx + 13b6: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 13bb: 8d 79 ff lea -0x1(%ecx),%edi + 13be: 66 90 xchg %ax,%ax + 13c0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 13c5: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 13c8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 13cf: 00 + 13d0: 89 5c 24 04 mov %ebx,0x4(%esp) + 13d4: 89 34 24 mov %esi,(%esp) + 13d7: 88 45 d7 mov %al,-0x29(%ebp) + 13da: e8 e3 fe ff ff call 12c2 + while(--i >= 0) + 13df: 83 ff ff cmp $0xffffffff,%edi + 13e2: 75 dc jne 13c0 + putc(fd, buf[i]); +} + 13e4: 83 c4 4c add $0x4c,%esp + 13e7: 5b pop %ebx + 13e8: 5e pop %esi + 13e9: 5f pop %edi + 13ea: 5d pop %ebp + 13eb: c3 ret + 13ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 13f0: 89 d0 mov %edx,%eax + 13f2: f7 d8 neg %eax + neg = 1; + 13f4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 13fb: eb 87 jmp 1384 + 13fd: 8d 76 00 lea 0x0(%esi),%esi + +00001400 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 1400: 55 push %ebp + 1401: 89 e5 mov %esp,%ebp + 1403: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 1404: 31 ff xor %edi,%edi +{ + 1406: 56 push %esi + 1407: 53 push %ebx + 1408: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 140b: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 140e: 8d 45 10 lea 0x10(%ebp),%eax +{ + 1411: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 1414: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 1417: 0f b6 13 movzbl (%ebx),%edx + 141a: 83 c3 01 add $0x1,%ebx + 141d: 84 d2 test %dl,%dl + 141f: 75 39 jne 145a + 1421: e9 c2 00 00 00 jmp 14e8 + 1426: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 1428: 83 fa 25 cmp $0x25,%edx + 142b: 0f 84 bf 00 00 00 je 14f0 + write(fd, &c, 1); + 1431: 8d 45 e2 lea -0x1e(%ebp),%eax + 1434: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 143b: 00 + 143c: 89 44 24 04 mov %eax,0x4(%esp) + 1440: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 1443: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 1446: e8 77 fe ff ff call 12c2 + 144b: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 144e: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 1452: 84 d2 test %dl,%dl + 1454: 0f 84 8e 00 00 00 je 14e8 + if(state == 0){ + 145a: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 145c: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 145f: 74 c7 je 1428 + } + } else if(state == '%'){ + 1461: 83 ff 25 cmp $0x25,%edi + 1464: 75 e5 jne 144b + if(c == 'd'){ + 1466: 83 fa 64 cmp $0x64,%edx + 1469: 0f 84 31 01 00 00 je 15a0 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 146f: 25 f7 00 00 00 and $0xf7,%eax + 1474: 83 f8 70 cmp $0x70,%eax + 1477: 0f 84 83 00 00 00 je 1500 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 147d: 83 fa 73 cmp $0x73,%edx + 1480: 0f 84 a2 00 00 00 je 1528 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1486: 83 fa 63 cmp $0x63,%edx + 1489: 0f 84 35 01 00 00 je 15c4 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 148f: 83 fa 25 cmp $0x25,%edx + 1492: 0f 84 e0 00 00 00 je 1578 + write(fd, &c, 1); + 1498: 8d 45 e6 lea -0x1a(%ebp),%eax + 149b: 83 c3 01 add $0x1,%ebx + 149e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14a5: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 14a6: 31 ff xor %edi,%edi + write(fd, &c, 1); + 14a8: 89 44 24 04 mov %eax,0x4(%esp) + 14ac: 89 34 24 mov %esi,(%esp) + 14af: 89 55 d0 mov %edx,-0x30(%ebp) + 14b2: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 14b6: e8 07 fe ff ff call 12c2 + putc(fd, c); + 14bb: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 14be: 8d 45 e7 lea -0x19(%ebp),%eax + 14c1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14c8: 00 + 14c9: 89 44 24 04 mov %eax,0x4(%esp) + 14cd: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 14d0: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 14d3: e8 ea fd ff ff call 12c2 + for(i = 0; fmt[i]; i++){ + 14d8: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 14dc: 84 d2 test %dl,%dl + 14de: 0f 85 76 ff ff ff jne 145a + 14e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 14e8: 83 c4 3c add $0x3c,%esp + 14eb: 5b pop %ebx + 14ec: 5e pop %esi + 14ed: 5f pop %edi + 14ee: 5d pop %ebp + 14ef: c3 ret + state = '%'; + 14f0: bf 25 00 00 00 mov $0x25,%edi + 14f5: e9 51 ff ff ff jmp 144b + 14fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 1500: 8b 45 d4 mov -0x2c(%ebp),%eax + 1503: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 1508: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 150a: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1511: 8b 10 mov (%eax),%edx + 1513: 89 f0 mov %esi,%eax + 1515: e8 46 fe ff ff call 1360 + ap++; + 151a: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 151e: e9 28 ff ff ff jmp 144b + 1523: 90 nop + 1524: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 1528: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 152b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 152f: 8b 38 mov (%eax),%edi + s = "(null)"; + 1531: b8 aa 17 00 00 mov $0x17aa,%eax + 1536: 85 ff test %edi,%edi + 1538: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 153b: 0f b6 07 movzbl (%edi),%eax + 153e: 84 c0 test %al,%al + 1540: 74 2a je 156c + 1542: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1548: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 154b: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 154e: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 1551: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1558: 00 + 1559: 89 44 24 04 mov %eax,0x4(%esp) + 155d: 89 34 24 mov %esi,(%esp) + 1560: e8 5d fd ff ff call 12c2 + while(*s != 0){ + 1565: 0f b6 07 movzbl (%edi),%eax + 1568: 84 c0 test %al,%al + 156a: 75 dc jne 1548 + state = 0; + 156c: 31 ff xor %edi,%edi + 156e: e9 d8 fe ff ff jmp 144b + 1573: 90 nop + 1574: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1578: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 157b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 157d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1584: 00 + 1585: 89 44 24 04 mov %eax,0x4(%esp) + 1589: 89 34 24 mov %esi,(%esp) + 158c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1590: e8 2d fd ff ff call 12c2 + 1595: e9 b1 fe ff ff jmp 144b + 159a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 15a0: 8b 45 d4 mov -0x2c(%ebp),%eax + 15a3: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 15a8: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 15ab: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 15b2: 8b 10 mov (%eax),%edx + 15b4: 89 f0 mov %esi,%eax + 15b6: e8 a5 fd ff ff call 1360 + ap++; + 15bb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15bf: e9 87 fe ff ff jmp 144b + putc(fd, *ap); + 15c4: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 15c7: 31 ff xor %edi,%edi + putc(fd, *ap); + 15c9: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 15cb: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 15d2: 00 + 15d3: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 15d6: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 15d9: 8d 45 e4 lea -0x1c(%ebp),%eax + 15dc: 89 44 24 04 mov %eax,0x4(%esp) + 15e0: e8 dd fc ff ff call 12c2 + ap++; + 15e5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15e9: e9 5d fe ff ff jmp 144b + 15ee: 66 90 xchg %ax,%ax + +000015f0 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 15f0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15f1: a1 6c 1a 00 00 mov 0x1a6c,%eax +{ + 15f6: 89 e5 mov %esp,%ebp + 15f8: 57 push %edi + 15f9: 56 push %esi + 15fa: 53 push %ebx + 15fb: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15fe: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 1600: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1603: 39 d0 cmp %edx,%eax + 1605: 72 11 jb 1618 + 1607: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1608: 39 c8 cmp %ecx,%eax + 160a: 72 04 jb 1610 + 160c: 39 ca cmp %ecx,%edx + 160e: 72 10 jb 1620 + 1610: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1612: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1614: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1616: 73 f0 jae 1608 + 1618: 39 ca cmp %ecx,%edx + 161a: 72 04 jb 1620 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 161c: 39 c8 cmp %ecx,%eax + 161e: 72 f0 jb 1610 + break; + if(bp + bp->s.size == p->s.ptr){ + 1620: 8b 73 fc mov -0x4(%ebx),%esi + 1623: 8d 3c f2 lea (%edx,%esi,8),%edi + 1626: 39 cf cmp %ecx,%edi + 1628: 74 1e je 1648 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 162a: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 162d: 8b 48 04 mov 0x4(%eax),%ecx + 1630: 8d 34 c8 lea (%eax,%ecx,8),%esi + 1633: 39 f2 cmp %esi,%edx + 1635: 74 28 je 165f + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 1637: 89 10 mov %edx,(%eax) + freep = p; + 1639: a3 6c 1a 00 00 mov %eax,0x1a6c +} + 163e: 5b pop %ebx + 163f: 5e pop %esi + 1640: 5f pop %edi + 1641: 5d pop %ebp + 1642: c3 ret + 1643: 90 nop + 1644: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 1648: 03 71 04 add 0x4(%ecx),%esi + 164b: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 164e: 8b 08 mov (%eax),%ecx + 1650: 8b 09 mov (%ecx),%ecx + 1652: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 1655: 8b 48 04 mov 0x4(%eax),%ecx + 1658: 8d 34 c8 lea (%eax,%ecx,8),%esi + 165b: 39 f2 cmp %esi,%edx + 165d: 75 d8 jne 1637 + p->s.size += bp->s.size; + 165f: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 1662: a3 6c 1a 00 00 mov %eax,0x1a6c + p->s.size += bp->s.size; + 1667: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 166a: 8b 53 f8 mov -0x8(%ebx),%edx + 166d: 89 10 mov %edx,(%eax) +} + 166f: 5b pop %ebx + 1670: 5e pop %esi + 1671: 5f pop %edi + 1672: 5d pop %ebp + 1673: c3 ret + 1674: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 167a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001680 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1680: 55 push %ebp + 1681: 89 e5 mov %esp,%ebp + 1683: 57 push %edi + 1684: 56 push %esi + 1685: 53 push %ebx + 1686: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1689: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 168c: 8b 1d 6c 1a 00 00 mov 0x1a6c,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1692: 8d 48 07 lea 0x7(%eax),%ecx + 1695: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1698: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 169a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 169d: 0f 84 9b 00 00 00 je 173e + 16a3: 8b 13 mov (%ebx),%edx + 16a5: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 16a8: 39 fe cmp %edi,%esi + 16aa: 76 64 jbe 1710 + 16ac: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 16b3: bb 00 80 00 00 mov $0x8000,%ebx + 16b8: 89 45 e4 mov %eax,-0x1c(%ebp) + 16bb: eb 0e jmp 16cb + 16bd: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 16c0: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 16c2: 8b 78 04 mov 0x4(%eax),%edi + 16c5: 39 fe cmp %edi,%esi + 16c7: 76 4f jbe 1718 + 16c9: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 16cb: 3b 15 6c 1a 00 00 cmp 0x1a6c,%edx + 16d1: 75 ed jne 16c0 + if(nu < 4096) + 16d3: 8b 45 e4 mov -0x1c(%ebp),%eax + 16d6: 81 fe 00 10 00 00 cmp $0x1000,%esi + 16dc: bf 00 10 00 00 mov $0x1000,%edi + 16e1: 0f 43 fe cmovae %esi,%edi + 16e4: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 16e7: 89 04 24 mov %eax,(%esp) + 16ea: e8 3b fc ff ff call 132a + if(p == (char*)-1) + 16ef: 83 f8 ff cmp $0xffffffff,%eax + 16f2: 74 18 je 170c + hp->s.size = nu; + 16f4: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 16f7: 83 c0 08 add $0x8,%eax + 16fa: 89 04 24 mov %eax,(%esp) + 16fd: e8 ee fe ff ff call 15f0 + return freep; + 1702: 8b 15 6c 1a 00 00 mov 0x1a6c,%edx + if((p = morecore(nunits)) == 0) + 1708: 85 d2 test %edx,%edx + 170a: 75 b4 jne 16c0 + return 0; + 170c: 31 c0 xor %eax,%eax + 170e: eb 20 jmp 1730 + if(p->s.size >= nunits){ + 1710: 89 d0 mov %edx,%eax + 1712: 89 da mov %ebx,%edx + 1714: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 1718: 39 fe cmp %edi,%esi + 171a: 74 1c je 1738 + p->s.size -= nunits; + 171c: 29 f7 sub %esi,%edi + 171e: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 1721: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 1724: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 1727: 89 15 6c 1a 00 00 mov %edx,0x1a6c + return (void*)(p + 1); + 172d: 83 c0 08 add $0x8,%eax + } +} + 1730: 83 c4 1c add $0x1c,%esp + 1733: 5b pop %ebx + 1734: 5e pop %esi + 1735: 5f pop %edi + 1736: 5d pop %ebp + 1737: c3 ret + prevp->s.ptr = p->s.ptr; + 1738: 8b 08 mov (%eax),%ecx + 173a: 89 0a mov %ecx,(%edx) + 173c: eb e9 jmp 1727 + base.s.ptr = freep = prevp = &base; + 173e: c7 05 6c 1a 00 00 70 movl $0x1a70,0x1a6c + 1745: 1a 00 00 + base.s.size = 0; + 1748: ba 70 1a 00 00 mov $0x1a70,%edx + base.s.ptr = freep = prevp = &base; + 174d: c7 05 70 1a 00 00 70 movl $0x1a70,0x1a70 + 1754: 1a 00 00 + base.s.size = 0; + 1757: c7 05 74 1a 00 00 00 movl $0x0,0x1a74 + 175e: 00 00 00 + 1761: e9 46 ff ff ff jmp 16ac + 1766: 66 90 xchg %ax,%ax + 1768: 66 90 xchg %ax,%ax + 176a: 66 90 xchg %ax,%ax + 176c: 66 90 xchg %ax,%ax + 176e: 66 90 xchg %ax,%ax + +00001770 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1770: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1771: b9 01 00 00 00 mov $0x1,%ecx + 1776: 89 e5 mov %esp,%ebp + 1778: 8b 55 08 mov 0x8(%ebp),%edx + 177b: 90 nop + 177c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1780: 89 c8 mov %ecx,%eax + 1782: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1785: 85 c0 test %eax,%eax + 1787: 75 f7 jne 1780 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1789: 0f ae f0 mfence +} + 178c: 5d pop %ebp + 178d: c3 ret + 178e: 66 90 xchg %ax,%ax + +00001790 : + +void urelease (struct uspinlock *lk) { + 1790: 55 push %ebp + 1791: 89 e5 mov %esp,%ebp + 1793: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1796: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1799: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 179f: 5d pop %ebp + 17a0: c3 ret diff --git a/echo.d b/echo.d new file mode 100644 index 00000000..16a6098f --- /dev/null +++ b/echo.d @@ -0,0 +1 @@ +echo.o: echo.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/echo.o b/echo.o new file mode 100644 index 00000000..7f18a705 Binary files /dev/null and b/echo.o differ diff --git a/echo.sym b/echo.sym new file mode 100644 index 00000000..5c2052dc --- /dev/null +++ b/echo.sym @@ -0,0 +1,62 @@ +00001000 .text +000017a1 .rodata +000017c4 .eh_frame +00001a6c .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 echo.c +00000000 ulib.c +00000000 printf.c +00001360 printint +000017b1 digits.1359 +00000000 umalloc.c +00001a6c freep +00001a70 base +00000000 uspinlock.c +00001080 strcpy +00001400 printf +00001270 memmove +000012ea mknod +00001342 shm_open +00001190 gets +00001322 getpid +00001680 malloc +00001332 sleep +000012b2 pipe +000012c2 write +000012fa fstat +000012d2 kill +00001312 chdir +000012da exec +000012aa wait +000012ba read +000012f2 unlink +00001770 uacquire +0000129a fork +0000132a sbrk +0000134a shm_close +0000133a uptime +00001a6c __bss_start +00001130 memset +00001000 main +000010b0 strcmp +0000131a dup +000011f0 stat +00001a6c _edata +00001a78 _end +00001302 link +000012a2 exit +00001240 atoi +00001100 strlen +000012e2 open +00001150 strchr +0000130a mkdir +000012ca close +00001790 urelease +000015f0 free diff --git a/entry.o b/entry.o new file mode 100644 index 00000000..a14272f8 Binary files /dev/null and b/entry.o differ diff --git a/entryother b/entryother new file mode 100755 index 00000000..a7673dec Binary files /dev/null and b/entryother differ diff --git a/entryother.asm b/entryother.asm new file mode 100644 index 00000000..c845a5d2 --- /dev/null +++ b/entryother.asm @@ -0,0 +1,125 @@ + +bootblockother.o: file format elf32-i386 + + +Disassembly of section .text: + +00007000 : +# This code combines elements of bootasm.S and entry.S. + +.code16 +.globl start +start: + cli + 7000: fa cli + + # Zero data segment registers DS, ES, and SS. + xorw %ax,%ax + 7001: 31 c0 xor %eax,%eax + movw %ax,%ds + 7003: 8e d8 mov %eax,%ds + movw %ax,%es + 7005: 8e c0 mov %eax,%es + movw %ax,%ss + 7007: 8e d0 mov %eax,%ss + + # Switch from real to protected mode. Use a bootstrap GDT that makes + # virtual addresses map directly to physical addresses so that the + # effective memory map doesn't change during the transition. + lgdt gdtdesc + 7009: 0f 01 16 lgdtl (%esi) + 700c: 84 70 0f test %dh,0xf(%eax) + movl %cr0, %eax + 700f: 20 c0 and %al,%al + orl $CR0_PE, %eax + 7011: 66 83 c8 01 or $0x1,%ax + movl %eax, %cr0 + 7015: 0f 22 c0 mov %eax,%cr0 + + # Complete the transition to 32-bit protected mode by using a long jmp + # to reload %cs and %eip. The segment descriptors are set up with no + # translation, so that the mapping is still the identity mapping. + ljmpl $(SEG_KCODE<<3), $(start32) + 7018: 66 ea 20 70 00 00 ljmpw $0x0,$0x7020 + 701e: 08 00 or %al,(%eax) + +00007020 : + +//PAGEBREAK! +.code32 # Tell assembler to generate 32-bit code now. +start32: + # Set up the protected-mode data segment registers + movw $(SEG_KDATA<<3), %ax # Our data segment selector + 7020: 66 b8 10 00 mov $0x10,%ax + movw %ax, %ds # -> DS: Data Segment + 7024: 8e d8 mov %eax,%ds + movw %ax, %es # -> ES: Extra Segment + 7026: 8e c0 mov %eax,%es + movw %ax, %ss # -> SS: Stack Segment + 7028: 8e d0 mov %eax,%ss + movw $0, %ax # Zero segments not ready for use + 702a: 66 b8 00 00 mov $0x0,%ax + movw %ax, %fs # -> FS + 702e: 8e e0 mov %eax,%fs + movw %ax, %gs # -> GS + 7030: 8e e8 mov %eax,%gs + + # Turn on page size extension for 4Mbyte pages + movl %cr4, %eax + 7032: 0f 20 e0 mov %cr4,%eax + orl $(CR4_PSE), %eax + 7035: 83 c8 10 or $0x10,%eax + movl %eax, %cr4 + 7038: 0f 22 e0 mov %eax,%cr4 + # Use entrypgdir as our initial page table + movl (start-12), %eax + 703b: a1 f4 6f 00 00 mov 0x6ff4,%eax + movl %eax, %cr3 + 7040: 0f 22 d8 mov %eax,%cr3 + # Turn on paging. + movl %cr0, %eax + 7043: 0f 20 c0 mov %cr0,%eax + orl $(CR0_PE|CR0_PG|CR0_WP), %eax + 7046: 0d 01 00 01 80 or $0x80010001,%eax + movl %eax, %cr0 + 704b: 0f 22 c0 mov %eax,%cr0 + + # Switch to the stack allocated by startothers() + movl (start-4), %esp + 704e: 8b 25 fc 6f 00 00 mov 0x6ffc,%esp + # Call mpenter() + call *(start-8) + 7054: ff 15 f8 6f 00 00 call *0x6ff8 + + movw $0x8a00, %ax + 705a: 66 b8 00 8a mov $0x8a00,%ax + movw %ax, %dx + 705e: 66 89 c2 mov %ax,%dx + outw %ax, %dx + 7061: 66 ef out %ax,(%dx) + movw $0x8ae0, %ax + 7063: 66 b8 e0 8a mov $0x8ae0,%ax + outw %ax, %dx + 7067: 66 ef out %ax,(%dx) + +00007069 : +spin: + jmp spin + 7069: eb fe jmp 7069 + 706b: 90 nop + +0000706c : + ... + 7074: ff (bad) + 7075: ff 00 incl (%eax) + 7077: 00 00 add %al,(%eax) + 7079: 9a cf 00 ff ff 00 00 lcall $0x0,$0xffff00cf + 7080: 00 .byte 0x0 + 7081: 92 xchg %eax,%edx + 7082: cf iret + ... + +00007084 : + 7084: 17 pop %ss + 7085: 00 6c 70 00 add %ch,0x0(%eax,%esi,2) + ... diff --git a/entryother.d b/entryother.d new file mode 100644 index 00000000..a1403030 --- /dev/null +++ b/entryother.d @@ -0,0 +1 @@ +entryother.o: entryother.S asm.h memlayout.h mmu.h diff --git a/entryother.o b/entryother.o new file mode 100644 index 00000000..5ac656d5 Binary files /dev/null and b/entryother.o differ diff --git a/exec.c b/exec.c index b40134f3..0a55040b 100644 --- a/exec.c +++ b/exec.c @@ -59,14 +59,15 @@ exec(char *path, char **argv) iunlockput(ip); end_op(); ip = 0; - - // Allocate two pages at the next page boundary. - // Make the first inaccessible. Use the second as the user stack. + + // ** Moved the stack position + curproc->num_pages = 1; sz = PGROUNDUP(sz); - if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0) + uint top = KERNBASE - curproc->num_pages * 2 * PGSIZE; + if((sp = allocuvm(pgdir, top, KERNBASE)) == 0) goto bad; - clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); - sp = sz; + clearpteu(pgdir, (char*)(KERNBASE)); + // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { diff --git a/exec.d b/exec.d new file mode 100644 index 00000000..04002757 --- /dev/null +++ b/exec.d @@ -0,0 +1,2 @@ +exec.o: exec.c /usr/include/stdc-predef.h types.h param.h memlayout.h \ + mmu.h proc.h defs.h x86.h elf.h diff --git a/exec.o b/exec.o new file mode 100644 index 00000000..7090e1db Binary files /dev/null and b/exec.o differ diff --git a/file.d b/file.d new file mode 100644 index 00000000..fea73d11 --- /dev/null +++ b/file.d @@ -0,0 +1,2 @@ +file.o: file.c /usr/include/stdc-predef.h types.h defs.h param.h fs.h \ + spinlock.h sleeplock.h file.h diff --git a/file.o b/file.o new file mode 100644 index 00000000..3c9dbb0f Binary files /dev/null and b/file.o differ diff --git a/forktest.asm b/forktest.asm new file mode 100644 index 00000000..7cba8fd8 --- /dev/null +++ b/forktest.asm @@ -0,0 +1,652 @@ + +_forktest: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: + printf(1, "fork test OK\n"); +} + +int +main(void) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 83 e4 f0 and $0xfffffff0,%esp + forktest(); + 1006: e8 35 00 00 00 call 1040 + exit(); + 100b: e8 32 03 00 00 call 1342 + +00001010 : +{ + 1010: 55 push %ebp + 1011: 89 e5 mov %esp,%ebp + 1013: 53 push %ebx + 1014: 83 ec 14 sub $0x14,%esp + 1017: 8b 5d 0c mov 0xc(%ebp),%ebx + write(fd, s, strlen(s)); + 101a: 89 1c 24 mov %ebx,(%esp) + 101d: e8 7e 01 00 00 call 11a0 + 1022: 89 5c 24 04 mov %ebx,0x4(%esp) + 1026: 89 44 24 08 mov %eax,0x8(%esp) + 102a: 8b 45 08 mov 0x8(%ebp),%eax + 102d: 89 04 24 mov %eax,(%esp) + 1030: e8 2d 03 00 00 call 1362 +} + 1035: 83 c4 14 add $0x14,%esp + 1038: 5b pop %ebx + 1039: 5d pop %ebp + 103a: c3 ret + 103b: 90 nop + 103c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00001040 : +{ + 1040: 55 push %ebp + 1041: 89 e5 mov %esp,%ebp + 1043: 53 push %ebx + for(n=0; n + 105d: eb 13 jmp 1072 + 105f: 90 nop + if(pid == 0) + 1060: 0f 84 97 00 00 00 je 10fd + for(n=0; n + pid = fork(); + 1072: e8 c3 02 00 00 call 133a + if(pid < 0) + 1077: 85 c0 test %eax,%eax + 1079: 79 e5 jns 1060 + for(; n > 0; n--){ + 107b: 85 db test %ebx,%ebx + 107d: 8d 76 00 lea 0x0(%esi),%esi + 1080: 74 15 je 1097 + 1082: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if(wait() < 0){ + 1088: e8 bd 02 00 00 call 134a + 108d: 85 c0 test %eax,%eax + 108f: 90 nop + 1090: 78 57 js 10e9 + for(; n > 0; n--){ + 1092: 83 eb 01 sub $0x1,%ebx + 1095: 75 f1 jne 1088 + if(wait() != -1){ + 1097: e8 ae 02 00 00 call 134a + 109c: 83 f8 ff cmp $0xffffffff,%eax + 109f: 90 nop + 10a0: 75 60 jne 1102 + printf(1, "fork test OK\n"); + 10a2: c7 44 24 04 26 14 00 movl $0x1426,0x4(%esp) + 10a9: 00 + 10aa: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 10b1: e8 5a ff ff ff call 1010 +} + 10b6: 83 c4 14 add $0x14,%esp + 10b9: 5b pop %ebx + 10ba: 5d pop %ebp + 10bb: c3 ret + 10bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, s, strlen(s)); + 10c0: c7 04 24 34 14 00 00 movl $0x1434,(%esp) + 10c7: e8 d4 00 00 00 call 11a0 + 10cc: c7 44 24 04 34 14 00 movl $0x1434,0x4(%esp) + 10d3: 00 + 10d4: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 10db: 89 44 24 08 mov %eax,0x8(%esp) + 10df: e8 7e 02 00 00 call 1362 + exit(); + 10e4: e8 59 02 00 00 call 1342 + printf(1, "wait stopped early\n"); + 10e9: c7 44 24 04 ff 13 00 movl $0x13ff,0x4(%esp) + 10f0: 00 + 10f1: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 10f8: e8 13 ff ff ff call 1010 + exit(); + 10fd: e8 40 02 00 00 call 1342 + printf(1, "wait got too many\n"); + 1102: c7 44 24 04 13 14 00 movl $0x1413,0x4(%esp) + 1109: 00 + 110a: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1111: e8 fa fe ff ff call 1010 + exit(); + 1116: e8 27 02 00 00 call 1342 + 111b: 66 90 xchg %ax,%ax + 111d: 66 90 xchg %ax,%ax + 111f: 90 nop + +00001120 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1120: 55 push %ebp + 1121: 89 e5 mov %esp,%ebp + 1123: 8b 45 08 mov 0x8(%ebp),%eax + 1126: 8b 4d 0c mov 0xc(%ebp),%ecx + 1129: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 112a: 89 c2 mov %eax,%edx + 112c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1130: 83 c1 01 add $0x1,%ecx + 1133: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1137: 83 c2 01 add $0x1,%edx + 113a: 84 db test %bl,%bl + 113c: 88 5a ff mov %bl,-0x1(%edx) + 113f: 75 ef jne 1130 + ; + return os; +} + 1141: 5b pop %ebx + 1142: 5d pop %ebp + 1143: c3 ret + 1144: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 114a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001150 : + +int +strcmp(const char *p, const char *q) +{ + 1150: 55 push %ebp + 1151: 89 e5 mov %esp,%ebp + 1153: 8b 55 08 mov 0x8(%ebp),%edx + 1156: 53 push %ebx + 1157: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 115a: 0f b6 02 movzbl (%edx),%eax + 115d: 84 c0 test %al,%al + 115f: 74 2d je 118e + 1161: 0f b6 19 movzbl (%ecx),%ebx + 1164: 38 d8 cmp %bl,%al + 1166: 74 0e je 1176 + 1168: eb 2b jmp 1195 + 116a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1170: 38 c8 cmp %cl,%al + 1172: 75 15 jne 1189 + p++, q++; + 1174: 89 d9 mov %ebx,%ecx + 1176: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 1179: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 117c: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 117f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 1183: 84 c0 test %al,%al + 1185: 75 e9 jne 1170 + 1187: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 1189: 29 c8 sub %ecx,%eax +} + 118b: 5b pop %ebx + 118c: 5d pop %ebp + 118d: c3 ret + 118e: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 1191: 31 c0 xor %eax,%eax + 1193: eb f4 jmp 1189 + 1195: 0f b6 cb movzbl %bl,%ecx + 1198: eb ef jmp 1189 + 119a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +000011a0 : + +uint +strlen(char *s) +{ + 11a0: 55 push %ebp + 11a1: 89 e5 mov %esp,%ebp + 11a3: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 11a6: 80 39 00 cmpb $0x0,(%ecx) + 11a9: 74 12 je 11bd + 11ab: 31 d2 xor %edx,%edx + 11ad: 8d 76 00 lea 0x0(%esi),%esi + 11b0: 83 c2 01 add $0x1,%edx + 11b3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 11b7: 89 d0 mov %edx,%eax + 11b9: 75 f5 jne 11b0 + ; + return n; +} + 11bb: 5d pop %ebp + 11bc: c3 ret + for(n = 0; s[n]; n++) + 11bd: 31 c0 xor %eax,%eax +} + 11bf: 5d pop %ebp + 11c0: c3 ret + 11c1: eb 0d jmp 11d0 + 11c3: 90 nop + 11c4: 90 nop + 11c5: 90 nop + 11c6: 90 nop + 11c7: 90 nop + 11c8: 90 nop + 11c9: 90 nop + 11ca: 90 nop + 11cb: 90 nop + 11cc: 90 nop + 11cd: 90 nop + 11ce: 90 nop + 11cf: 90 nop + +000011d0 : + +void* +memset(void *dst, int c, uint n) +{ + 11d0: 55 push %ebp + 11d1: 89 e5 mov %esp,%ebp + 11d3: 8b 55 08 mov 0x8(%ebp),%edx + 11d6: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 11d7: 8b 4d 10 mov 0x10(%ebp),%ecx + 11da: 8b 45 0c mov 0xc(%ebp),%eax + 11dd: 89 d7 mov %edx,%edi + 11df: fc cld + 11e0: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 11e2: 89 d0 mov %edx,%eax + 11e4: 5f pop %edi + 11e5: 5d pop %ebp + 11e6: c3 ret + 11e7: 89 f6 mov %esi,%esi + 11e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +000011f0 : + +char* +strchr(const char *s, char c) +{ + 11f0: 55 push %ebp + 11f1: 89 e5 mov %esp,%ebp + 11f3: 8b 45 08 mov 0x8(%ebp),%eax + 11f6: 53 push %ebx + 11f7: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 11fa: 0f b6 18 movzbl (%eax),%ebx + 11fd: 84 db test %bl,%bl + 11ff: 74 1d je 121e + if(*s == c) + 1201: 38 d3 cmp %dl,%bl + 1203: 89 d1 mov %edx,%ecx + 1205: 75 0d jne 1214 + 1207: eb 17 jmp 1220 + 1209: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1210: 38 ca cmp %cl,%dl + 1212: 74 0c je 1220 + for(; *s; s++) + 1214: 83 c0 01 add $0x1,%eax + 1217: 0f b6 10 movzbl (%eax),%edx + 121a: 84 d2 test %dl,%dl + 121c: 75 f2 jne 1210 + return (char*)s; + return 0; + 121e: 31 c0 xor %eax,%eax +} + 1220: 5b pop %ebx + 1221: 5d pop %ebp + 1222: c3 ret + 1223: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001230 : + +char* +gets(char *buf, int max) +{ + 1230: 55 push %ebp + 1231: 89 e5 mov %esp,%ebp + 1233: 57 push %edi + 1234: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1235: 31 f6 xor %esi,%esi +{ + 1237: 53 push %ebx + 1238: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 123b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 123e: eb 31 jmp 1271 + cc = read(0, &c, 1); + 1240: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1247: 00 + 1248: 89 7c 24 04 mov %edi,0x4(%esp) + 124c: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1253: e8 02 01 00 00 call 135a + if(cc < 1) + 1258: 85 c0 test %eax,%eax + 125a: 7e 1d jle 1279 + break; + buf[i++] = c; + 125c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 1260: 89 de mov %ebx,%esi + buf[i++] = c; + 1262: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 1265: 3c 0d cmp $0xd,%al + buf[i++] = c; + 1267: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 126b: 74 0c je 1279 + 126d: 3c 0a cmp $0xa,%al + 126f: 74 08 je 1279 + for(i=0; i+1 < max; ){ + 1271: 8d 5e 01 lea 0x1(%esi),%ebx + 1274: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1277: 7c c7 jl 1240 + break; + } + buf[i] = '\0'; + 1279: 8b 45 08 mov 0x8(%ebp),%eax + 127c: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1280: 83 c4 2c add $0x2c,%esp + 1283: 5b pop %ebx + 1284: 5e pop %esi + 1285: 5f pop %edi + 1286: 5d pop %ebp + 1287: c3 ret + 1288: 90 nop + 1289: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001290 : + +int +stat(char *n, struct stat *st) +{ + 1290: 55 push %ebp + 1291: 89 e5 mov %esp,%ebp + 1293: 56 push %esi + 1294: 53 push %ebx + 1295: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 1298: 8b 45 08 mov 0x8(%ebp),%eax + 129b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 12a2: 00 + 12a3: 89 04 24 mov %eax,(%esp) + 12a6: e8 d7 00 00 00 call 1382 + if(fd < 0) + 12ab: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 12ad: 89 c3 mov %eax,%ebx + if(fd < 0) + 12af: 78 27 js 12d8 + return -1; + r = fstat(fd, st); + 12b1: 8b 45 0c mov 0xc(%ebp),%eax + 12b4: 89 1c 24 mov %ebx,(%esp) + 12b7: 89 44 24 04 mov %eax,0x4(%esp) + 12bb: e8 da 00 00 00 call 139a + close(fd); + 12c0: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 12c3: 89 c6 mov %eax,%esi + close(fd); + 12c5: e8 a0 00 00 00 call 136a + return r; + 12ca: 89 f0 mov %esi,%eax +} + 12cc: 83 c4 10 add $0x10,%esp + 12cf: 5b pop %ebx + 12d0: 5e pop %esi + 12d1: 5d pop %ebp + 12d2: c3 ret + 12d3: 90 nop + 12d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 12d8: b8 ff ff ff ff mov $0xffffffff,%eax + 12dd: eb ed jmp 12cc + 12df: 90 nop + +000012e0 : + +int +atoi(const char *s) +{ + 12e0: 55 push %ebp + 12e1: 89 e5 mov %esp,%ebp + 12e3: 8b 4d 08 mov 0x8(%ebp),%ecx + 12e6: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 12e7: 0f be 11 movsbl (%ecx),%edx + 12ea: 8d 42 d0 lea -0x30(%edx),%eax + 12ed: 3c 09 cmp $0x9,%al + n = 0; + 12ef: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 12f4: 77 17 ja 130d + 12f6: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 12f8: 83 c1 01 add $0x1,%ecx + 12fb: 8d 04 80 lea (%eax,%eax,4),%eax + 12fe: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1302: 0f be 11 movsbl (%ecx),%edx + 1305: 8d 5a d0 lea -0x30(%edx),%ebx + 1308: 80 fb 09 cmp $0x9,%bl + 130b: 76 eb jbe 12f8 + return n; +} + 130d: 5b pop %ebx + 130e: 5d pop %ebp + 130f: c3 ret + +00001310 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1310: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1311: 31 d2 xor %edx,%edx +{ + 1313: 89 e5 mov %esp,%ebp + 1315: 56 push %esi + 1316: 8b 45 08 mov 0x8(%ebp),%eax + 1319: 53 push %ebx + 131a: 8b 5d 10 mov 0x10(%ebp),%ebx + 131d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1320: 85 db test %ebx,%ebx + 1322: 7e 12 jle 1336 + 1324: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1328: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 132c: 88 0c 10 mov %cl,(%eax,%edx,1) + 132f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1332: 39 da cmp %ebx,%edx + 1334: 75 f2 jne 1328 + return vdst; +} + 1336: 5b pop %ebx + 1337: 5e pop %esi + 1338: 5d pop %ebp + 1339: c3 ret + +0000133a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 133a: b8 01 00 00 00 mov $0x1,%eax + 133f: cd 40 int $0x40 + 1341: c3 ret + +00001342 : +SYSCALL(exit) + 1342: b8 02 00 00 00 mov $0x2,%eax + 1347: cd 40 int $0x40 + 1349: c3 ret + +0000134a : +SYSCALL(wait) + 134a: b8 03 00 00 00 mov $0x3,%eax + 134f: cd 40 int $0x40 + 1351: c3 ret + +00001352 : +SYSCALL(pipe) + 1352: b8 04 00 00 00 mov $0x4,%eax + 1357: cd 40 int $0x40 + 1359: c3 ret + +0000135a : +SYSCALL(read) + 135a: b8 05 00 00 00 mov $0x5,%eax + 135f: cd 40 int $0x40 + 1361: c3 ret + +00001362 : +SYSCALL(write) + 1362: b8 10 00 00 00 mov $0x10,%eax + 1367: cd 40 int $0x40 + 1369: c3 ret + +0000136a : +SYSCALL(close) + 136a: b8 15 00 00 00 mov $0x15,%eax + 136f: cd 40 int $0x40 + 1371: c3 ret + +00001372 : +SYSCALL(kill) + 1372: b8 06 00 00 00 mov $0x6,%eax + 1377: cd 40 int $0x40 + 1379: c3 ret + +0000137a : +SYSCALL(exec) + 137a: b8 07 00 00 00 mov $0x7,%eax + 137f: cd 40 int $0x40 + 1381: c3 ret + +00001382 : +SYSCALL(open) + 1382: b8 0f 00 00 00 mov $0xf,%eax + 1387: cd 40 int $0x40 + 1389: c3 ret + +0000138a : +SYSCALL(mknod) + 138a: b8 11 00 00 00 mov $0x11,%eax + 138f: cd 40 int $0x40 + 1391: c3 ret + +00001392 : +SYSCALL(unlink) + 1392: b8 12 00 00 00 mov $0x12,%eax + 1397: cd 40 int $0x40 + 1399: c3 ret + +0000139a : +SYSCALL(fstat) + 139a: b8 08 00 00 00 mov $0x8,%eax + 139f: cd 40 int $0x40 + 13a1: c3 ret + +000013a2 : +SYSCALL(link) + 13a2: b8 13 00 00 00 mov $0x13,%eax + 13a7: cd 40 int $0x40 + 13a9: c3 ret + +000013aa : +SYSCALL(mkdir) + 13aa: b8 14 00 00 00 mov $0x14,%eax + 13af: cd 40 int $0x40 + 13b1: c3 ret + +000013b2 : +SYSCALL(chdir) + 13b2: b8 09 00 00 00 mov $0x9,%eax + 13b7: cd 40 int $0x40 + 13b9: c3 ret + +000013ba : +SYSCALL(dup) + 13ba: b8 0a 00 00 00 mov $0xa,%eax + 13bf: cd 40 int $0x40 + 13c1: c3 ret + +000013c2 : +SYSCALL(getpid) + 13c2: b8 0b 00 00 00 mov $0xb,%eax + 13c7: cd 40 int $0x40 + 13c9: c3 ret + +000013ca : +SYSCALL(sbrk) + 13ca: b8 0c 00 00 00 mov $0xc,%eax + 13cf: cd 40 int $0x40 + 13d1: c3 ret + +000013d2 : +SYSCALL(sleep) + 13d2: b8 0d 00 00 00 mov $0xd,%eax + 13d7: cd 40 int $0x40 + 13d9: c3 ret + +000013da : +SYSCALL(uptime) + 13da: b8 0e 00 00 00 mov $0xe,%eax + 13df: cd 40 int $0x40 + 13e1: c3 ret + +000013e2 : +SYSCALL(shm_open) + 13e2: b8 16 00 00 00 mov $0x16,%eax + 13e7: cd 40 int $0x40 + 13e9: c3 ret + +000013ea : +SYSCALL(shm_close) + 13ea: b8 17 00 00 00 mov $0x17,%eax + 13ef: cd 40 int $0x40 + 13f1: c3 ret diff --git a/forktest.d b/forktest.d new file mode 100644 index 00000000..d31a0c27 --- /dev/null +++ b/forktest.d @@ -0,0 +1 @@ +forktest.o: forktest.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/forktest.o b/forktest.o new file mode 100644 index 00000000..49e45679 Binary files /dev/null and b/forktest.o differ diff --git a/fs.d b/fs.d new file mode 100644 index 00000000..a1d05ccc --- /dev/null +++ b/fs.d @@ -0,0 +1,2 @@ +fs.o: fs.c /usr/include/stdc-predef.h types.h defs.h param.h stat.h mmu.h \ + proc.h spinlock.h sleeplock.h fs.h buf.h file.h diff --git a/fs.img b/fs.img new file mode 100644 index 00000000..4fdf99cb Binary files /dev/null and b/fs.img differ diff --git a/fs.o b/fs.o new file mode 100644 index 00000000..7b7d73c3 Binary files /dev/null and b/fs.o differ diff --git a/grep.asm b/grep.asm new file mode 100644 index 00000000..7d340970 --- /dev/null +++ b/grep.asm @@ -0,0 +1,1546 @@ + +_grep: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: + } +} + +int +main(int argc, char *argv[]) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 57 push %edi + 1004: 56 push %esi + 1005: 53 push %ebx + 1006: 83 e4 f0 and $0xfffffff0,%esp + 1009: 83 ec 10 sub $0x10,%esp + 100c: 8b 5d 0c mov 0xc(%ebp),%ebx + int fd, i; + char *pattern; + + if(argc <= 1){ + 100f: 83 7d 08 01 cmpl $0x1,0x8(%ebp) + 1013: 0f 8e 8b 00 00 00 jle 10a4 + printf(2, "usage: grep pattern [file ...]\n"); + exit(); + } + pattern = argv[1]; + 1019: 8b 43 04 mov 0x4(%ebx),%eax + 101c: 83 c3 08 add $0x8,%ebx + + if(argc <= 2){ + 101f: be 02 00 00 00 mov $0x2,%esi + 1024: 83 7d 08 02 cmpl $0x2,0x8(%ebp) + pattern = argv[1]; + 1028: 89 44 24 0c mov %eax,0xc(%esp) + if(argc <= 2){ + 102c: 74 61 je 108f + 102e: 66 90 xchg %ax,%ax + grep(pattern, 0); + exit(); + } + + for(i = 2; i < argc; i++){ + if((fd = open(argv[i], 0)) < 0){ + 1030: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1037: 00 + 1038: 8b 03 mov (%ebx),%eax + 103a: 89 04 24 mov %eax,(%esp) + 103d: e8 30 05 00 00 call 1572 + 1042: 85 c0 test %eax,%eax + 1044: 89 c7 mov %eax,%edi + 1046: 78 28 js 1070 + printf(1, "grep: cannot open %s\n", argv[i]); + exit(); + } + grep(pattern, fd); + 1048: 89 44 24 04 mov %eax,0x4(%esp) + 104c: 8b 44 24 0c mov 0xc(%esp),%eax + for(i = 2; i < argc; i++){ + 1050: 83 c6 01 add $0x1,%esi + 1053: 83 c3 04 add $0x4,%ebx + grep(pattern, fd); + 1056: 89 04 24 mov %eax,(%esp) + 1059: e8 a2 01 00 00 call 1200 + close(fd); + 105e: 89 3c 24 mov %edi,(%esp) + 1061: e8 f4 04 00 00 call 155a + for(i = 2; i < argc; i++){ + 1066: 39 75 08 cmp %esi,0x8(%ebp) + 1069: 7f c5 jg 1030 + } + exit(); + 106b: e8 c2 04 00 00 call 1532 + printf(1, "grep: cannot open %s\n", argv[i]); + 1070: 8b 03 mov (%ebx),%eax + 1072: c7 44 24 04 54 1a 00 movl $0x1a54,0x4(%esp) + 1079: 00 + 107a: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1081: 89 44 24 08 mov %eax,0x8(%esp) + 1085: e8 06 06 00 00 call 1690 + exit(); + 108a: e8 a3 04 00 00 call 1532 + grep(pattern, 0); + 108f: 89 04 24 mov %eax,(%esp) + 1092: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1099: 00 + 109a: e8 61 01 00 00 call 1200 + exit(); + 109f: e8 8e 04 00 00 call 1532 + printf(2, "usage: grep pattern [file ...]\n"); + 10a4: c7 44 24 04 34 1a 00 movl $0x1a34,0x4(%esp) + 10ab: 00 + 10ac: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 10b3: e8 d8 05 00 00 call 1690 + exit(); + 10b8: e8 75 04 00 00 call 1532 + 10bd: 66 90 xchg %ax,%ax + 10bf: 90 nop + +000010c0 : + return 0; +} + +// matchstar: search for c*re at beginning of text +int matchstar(int c, char *re, char *text) +{ + 10c0: 55 push %ebp + 10c1: 89 e5 mov %esp,%ebp + 10c3: 57 push %edi + 10c4: 56 push %esi + 10c5: 53 push %ebx + 10c6: 83 ec 1c sub $0x1c,%esp + 10c9: 8b 75 08 mov 0x8(%ebp),%esi + 10cc: 8b 7d 0c mov 0xc(%ebp),%edi + 10cf: 8b 5d 10 mov 0x10(%ebp),%ebx + 10d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + do{ // a * matches zero or more instances + if(matchhere(re, text)) + 10d8: 89 5c 24 04 mov %ebx,0x4(%esp) + 10dc: 89 3c 24 mov %edi,(%esp) + 10df: e8 3c 00 00 00 call 1120 + 10e4: 85 c0 test %eax,%eax + 10e6: 75 20 jne 1108 + return 1; + }while(*text!='\0' && (*text++==c || c=='.')); + 10e8: 0f be 13 movsbl (%ebx),%edx + 10eb: 84 d2 test %dl,%dl + 10ed: 74 0c je 10fb + 10ef: 83 c3 01 add $0x1,%ebx + 10f2: 39 f2 cmp %esi,%edx + 10f4: 74 e2 je 10d8 + 10f6: 83 fe 2e cmp $0x2e,%esi + 10f9: 74 dd je 10d8 + return 0; +} + 10fb: 83 c4 1c add $0x1c,%esp + 10fe: 5b pop %ebx + 10ff: 5e pop %esi + 1100: 5f pop %edi + 1101: 5d pop %ebp + 1102: c3 ret + 1103: 90 nop + 1104: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1108: 83 c4 1c add $0x1c,%esp + return 1; + 110b: b8 01 00 00 00 mov $0x1,%eax +} + 1110: 5b pop %ebx + 1111: 5e pop %esi + 1112: 5f pop %edi + 1113: 5d pop %ebp + 1114: c3 ret + 1115: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1119: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001120 : +{ + 1120: 55 push %ebp + 1121: 89 e5 mov %esp,%ebp + 1123: 53 push %ebx + 1124: 83 ec 14 sub $0x14,%esp + 1127: 8b 55 08 mov 0x8(%ebp),%edx + 112a: 8b 4d 0c mov 0xc(%ebp),%ecx + if(re[0] == '\0') + 112d: 0f be 02 movsbl (%edx),%eax + 1130: 84 c0 test %al,%al + 1132: 75 20 jne 1154 + 1134: eb 42 jmp 1178 + 1136: 66 90 xchg %ax,%ax + if(*text!='\0' && (re[0]=='.' || re[0]==*text)) + 1138: 0f b6 19 movzbl (%ecx),%ebx + 113b: 84 db test %bl,%bl + 113d: 74 31 je 1170 + 113f: 3c 2e cmp $0x2e,%al + 1141: 74 04 je 1147 + 1143: 38 d8 cmp %bl,%al + 1145: 75 29 jne 1170 + return matchhere(re+1, text+1); + 1147: 83 c2 01 add $0x1,%edx + if(re[0] == '\0') + 114a: 0f be 02 movsbl (%edx),%eax + return matchhere(re+1, text+1); + 114d: 83 c1 01 add $0x1,%ecx + if(re[0] == '\0') + 1150: 84 c0 test %al,%al + 1152: 74 24 je 1178 + if(re[1] == '*') + 1154: 0f b6 5a 01 movzbl 0x1(%edx),%ebx + 1158: 80 fb 2a cmp $0x2a,%bl + 115b: 74 2b je 1188 + if(re[0] == '$' && re[1] == '\0') + 115d: 3c 24 cmp $0x24,%al + 115f: 75 d7 jne 1138 + 1161: 84 db test %bl,%bl + 1163: 74 3c je 11a1 + if(*text!='\0' && (re[0]=='.' || re[0]==*text)) + 1165: 0f b6 19 movzbl (%ecx),%ebx + 1168: 84 db test %bl,%bl + 116a: 75 d7 jne 1143 + 116c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 1170: 31 c0 xor %eax,%eax +} + 1172: 83 c4 14 add $0x14,%esp + 1175: 5b pop %ebx + 1176: 5d pop %ebp + 1177: c3 ret + 1178: 83 c4 14 add $0x14,%esp + return 1; + 117b: b8 01 00 00 00 mov $0x1,%eax +} + 1180: 5b pop %ebx + 1181: 5d pop %ebp + 1182: c3 ret + 1183: 90 nop + 1184: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return matchstar(re[0], re+2, text); + 1188: 83 c2 02 add $0x2,%edx + 118b: 89 4c 24 08 mov %ecx,0x8(%esp) + 118f: 89 54 24 04 mov %edx,0x4(%esp) + 1193: 89 04 24 mov %eax,(%esp) + 1196: e8 25 ff ff ff call 10c0 +} + 119b: 83 c4 14 add $0x14,%esp + 119e: 5b pop %ebx + 119f: 5d pop %ebp + 11a0: c3 ret + return *text == '\0'; + 11a1: 31 c0 xor %eax,%eax + 11a3: 80 39 00 cmpb $0x0,(%ecx) + 11a6: 0f 94 c0 sete %al + 11a9: eb c7 jmp 1172 + 11ab: 90 nop + 11ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000011b0 : +{ + 11b0: 55 push %ebp + 11b1: 89 e5 mov %esp,%ebp + 11b3: 56 push %esi + 11b4: 53 push %ebx + 11b5: 83 ec 10 sub $0x10,%esp + 11b8: 8b 75 08 mov 0x8(%ebp),%esi + 11bb: 8b 5d 0c mov 0xc(%ebp),%ebx + if(re[0] == '^') + 11be: 80 3e 5e cmpb $0x5e,(%esi) + 11c1: 75 0e jne 11d1 + 11c3: eb 28 jmp 11ed + 11c5: 8d 76 00 lea 0x0(%esi),%esi + }while(*text++ != '\0'); + 11c8: 83 c3 01 add $0x1,%ebx + 11cb: 80 7b ff 00 cmpb $0x0,-0x1(%ebx) + 11cf: 74 15 je 11e6 + if(matchhere(re, text)) + 11d1: 89 5c 24 04 mov %ebx,0x4(%esp) + 11d5: 89 34 24 mov %esi,(%esp) + 11d8: e8 43 ff ff ff call 1120 + 11dd: 85 c0 test %eax,%eax + 11df: 74 e7 je 11c8 + return 1; + 11e1: b8 01 00 00 00 mov $0x1,%eax +} + 11e6: 83 c4 10 add $0x10,%esp + 11e9: 5b pop %ebx + 11ea: 5e pop %esi + 11eb: 5d pop %ebp + 11ec: c3 ret + return matchhere(re+1, text); + 11ed: 83 c6 01 add $0x1,%esi + 11f0: 89 75 08 mov %esi,0x8(%ebp) +} + 11f3: 83 c4 10 add $0x10,%esp + 11f6: 5b pop %ebx + 11f7: 5e pop %esi + 11f8: 5d pop %ebp + return matchhere(re+1, text); + 11f9: e9 22 ff ff ff jmp 1120 + 11fe: 66 90 xchg %ax,%ax + +00001200 : +{ + 1200: 55 push %ebp + 1201: 89 e5 mov %esp,%ebp + 1203: 57 push %edi + 1204: 56 push %esi + 1205: 53 push %ebx + 1206: 83 ec 1c sub $0x1c,%esp + 1209: 8b 75 08 mov 0x8(%ebp),%esi + m = 0; + 120c: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) + 1213: 90 nop + 1214: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){ + 1218: 8b 55 e4 mov -0x1c(%ebp),%edx + 121b: b8 ff 03 00 00 mov $0x3ff,%eax + 1220: 29 d0 sub %edx,%eax + 1222: 89 44 24 08 mov %eax,0x8(%esp) + 1226: 89 d0 mov %edx,%eax + 1228: 05 40 1e 00 00 add $0x1e40,%eax + 122d: 89 44 24 04 mov %eax,0x4(%esp) + 1231: 8b 45 0c mov 0xc(%ebp),%eax + 1234: 89 04 24 mov %eax,(%esp) + 1237: e8 0e 03 00 00 call 154a + 123c: 85 c0 test %eax,%eax + 123e: 0f 8e b8 00 00 00 jle 12fc + m += n; + 1244: 01 45 e4 add %eax,-0x1c(%ebp) + p = buf; + 1247: bb 40 1e 00 00 mov $0x1e40,%ebx + buf[m] = '\0'; + 124c: 8b 45 e4 mov -0x1c(%ebp),%eax + 124f: c6 80 40 1e 00 00 00 movb $0x0,0x1e40(%eax) + 1256: 66 90 xchg %ax,%ax + while((q = strchr(p, '\n')) != 0){ + 1258: c7 44 24 04 0a 00 00 movl $0xa,0x4(%esp) + 125f: 00 + 1260: 89 1c 24 mov %ebx,(%esp) + 1263: e8 78 01 00 00 call 13e0 + 1268: 85 c0 test %eax,%eax + 126a: 89 c7 mov %eax,%edi + 126c: 74 42 je 12b0 + *q = 0; + 126e: c6 07 00 movb $0x0,(%edi) + if(match(pattern, p)){ + 1271: 89 5c 24 04 mov %ebx,0x4(%esp) + 1275: 89 34 24 mov %esi,(%esp) + 1278: e8 33 ff ff ff call 11b0 + 127d: 85 c0 test %eax,%eax + 127f: 75 07 jne 1288 + 1281: 8d 5f 01 lea 0x1(%edi),%ebx + 1284: eb d2 jmp 1258 + 1286: 66 90 xchg %ax,%ax + *q = '\n'; + 1288: c6 07 0a movb $0xa,(%edi) + write(1, p, q+1 - p); + 128b: 83 c7 01 add $0x1,%edi + 128e: 89 f8 mov %edi,%eax + 1290: 29 d8 sub %ebx,%eax + 1292: 89 5c 24 04 mov %ebx,0x4(%esp) + 1296: 89 fb mov %edi,%ebx + 1298: 89 44 24 08 mov %eax,0x8(%esp) + 129c: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 12a3: e8 aa 02 00 00 call 1552 + 12a8: eb ae jmp 1258 + 12aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if(p == buf) + 12b0: 81 fb 40 1e 00 00 cmp $0x1e40,%ebx + 12b6: 74 38 je 12f0 + if(m > 0){ + 12b8: 8b 45 e4 mov -0x1c(%ebp),%eax + 12bb: 85 c0 test %eax,%eax + 12bd: 0f 8e 55 ff ff ff jle 1218 + m -= p - buf; + 12c3: b8 40 1e 00 00 mov $0x1e40,%eax + 12c8: 29 d8 sub %ebx,%eax + 12ca: 01 45 e4 add %eax,-0x1c(%ebp) + memmove(buf, p, m); + 12cd: 8b 45 e4 mov -0x1c(%ebp),%eax + 12d0: 89 5c 24 04 mov %ebx,0x4(%esp) + 12d4: c7 04 24 40 1e 00 00 movl $0x1e40,(%esp) + 12db: 89 44 24 08 mov %eax,0x8(%esp) + 12df: e8 1c 02 00 00 call 1500 + 12e4: e9 2f ff ff ff jmp 1218 + 12e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + m = 0; + 12f0: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) + 12f7: e9 1c ff ff ff jmp 1218 +} + 12fc: 83 c4 1c add $0x1c,%esp + 12ff: 5b pop %ebx + 1300: 5e pop %esi + 1301: 5f pop %edi + 1302: 5d pop %ebp + 1303: c3 ret + 1304: 66 90 xchg %ax,%ax + 1306: 66 90 xchg %ax,%ax + 1308: 66 90 xchg %ax,%ax + 130a: 66 90 xchg %ax,%ax + 130c: 66 90 xchg %ax,%ax + 130e: 66 90 xchg %ax,%ax + +00001310 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1310: 55 push %ebp + 1311: 89 e5 mov %esp,%ebp + 1313: 8b 45 08 mov 0x8(%ebp),%eax + 1316: 8b 4d 0c mov 0xc(%ebp),%ecx + 1319: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 131a: 89 c2 mov %eax,%edx + 131c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1320: 83 c1 01 add $0x1,%ecx + 1323: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1327: 83 c2 01 add $0x1,%edx + 132a: 84 db test %bl,%bl + 132c: 88 5a ff mov %bl,-0x1(%edx) + 132f: 75 ef jne 1320 + ; + return os; +} + 1331: 5b pop %ebx + 1332: 5d pop %ebp + 1333: c3 ret + 1334: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 133a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001340 : + +int +strcmp(const char *p, const char *q) +{ + 1340: 55 push %ebp + 1341: 89 e5 mov %esp,%ebp + 1343: 8b 55 08 mov 0x8(%ebp),%edx + 1346: 53 push %ebx + 1347: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 134a: 0f b6 02 movzbl (%edx),%eax + 134d: 84 c0 test %al,%al + 134f: 74 2d je 137e + 1351: 0f b6 19 movzbl (%ecx),%ebx + 1354: 38 d8 cmp %bl,%al + 1356: 74 0e je 1366 + 1358: eb 2b jmp 1385 + 135a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1360: 38 c8 cmp %cl,%al + 1362: 75 15 jne 1379 + p++, q++; + 1364: 89 d9 mov %ebx,%ecx + 1366: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 1369: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 136c: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 136f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 1373: 84 c0 test %al,%al + 1375: 75 e9 jne 1360 + 1377: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 1379: 29 c8 sub %ecx,%eax +} + 137b: 5b pop %ebx + 137c: 5d pop %ebp + 137d: c3 ret + 137e: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 1381: 31 c0 xor %eax,%eax + 1383: eb f4 jmp 1379 + 1385: 0f b6 cb movzbl %bl,%ecx + 1388: eb ef jmp 1379 + 138a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00001390 : + +uint +strlen(char *s) +{ + 1390: 55 push %ebp + 1391: 89 e5 mov %esp,%ebp + 1393: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 1396: 80 39 00 cmpb $0x0,(%ecx) + 1399: 74 12 je 13ad + 139b: 31 d2 xor %edx,%edx + 139d: 8d 76 00 lea 0x0(%esi),%esi + 13a0: 83 c2 01 add $0x1,%edx + 13a3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 13a7: 89 d0 mov %edx,%eax + 13a9: 75 f5 jne 13a0 + ; + return n; +} + 13ab: 5d pop %ebp + 13ac: c3 ret + for(n = 0; s[n]; n++) + 13ad: 31 c0 xor %eax,%eax +} + 13af: 5d pop %ebp + 13b0: c3 ret + 13b1: eb 0d jmp 13c0 + 13b3: 90 nop + 13b4: 90 nop + 13b5: 90 nop + 13b6: 90 nop + 13b7: 90 nop + 13b8: 90 nop + 13b9: 90 nop + 13ba: 90 nop + 13bb: 90 nop + 13bc: 90 nop + 13bd: 90 nop + 13be: 90 nop + 13bf: 90 nop + +000013c0 : + +void* +memset(void *dst, int c, uint n) +{ + 13c0: 55 push %ebp + 13c1: 89 e5 mov %esp,%ebp + 13c3: 8b 55 08 mov 0x8(%ebp),%edx + 13c6: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 13c7: 8b 4d 10 mov 0x10(%ebp),%ecx + 13ca: 8b 45 0c mov 0xc(%ebp),%eax + 13cd: 89 d7 mov %edx,%edi + 13cf: fc cld + 13d0: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 13d2: 89 d0 mov %edx,%eax + 13d4: 5f pop %edi + 13d5: 5d pop %ebp + 13d6: c3 ret + 13d7: 89 f6 mov %esi,%esi + 13d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +000013e0 : + +char* +strchr(const char *s, char c) +{ + 13e0: 55 push %ebp + 13e1: 89 e5 mov %esp,%ebp + 13e3: 8b 45 08 mov 0x8(%ebp),%eax + 13e6: 53 push %ebx + 13e7: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 13ea: 0f b6 18 movzbl (%eax),%ebx + 13ed: 84 db test %bl,%bl + 13ef: 74 1d je 140e + if(*s == c) + 13f1: 38 d3 cmp %dl,%bl + 13f3: 89 d1 mov %edx,%ecx + 13f5: 75 0d jne 1404 + 13f7: eb 17 jmp 1410 + 13f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1400: 38 ca cmp %cl,%dl + 1402: 74 0c je 1410 + for(; *s; s++) + 1404: 83 c0 01 add $0x1,%eax + 1407: 0f b6 10 movzbl (%eax),%edx + 140a: 84 d2 test %dl,%dl + 140c: 75 f2 jne 1400 + return (char*)s; + return 0; + 140e: 31 c0 xor %eax,%eax +} + 1410: 5b pop %ebx + 1411: 5d pop %ebp + 1412: c3 ret + 1413: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1419: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001420 : + +char* +gets(char *buf, int max) +{ + 1420: 55 push %ebp + 1421: 89 e5 mov %esp,%ebp + 1423: 57 push %edi + 1424: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1425: 31 f6 xor %esi,%esi +{ + 1427: 53 push %ebx + 1428: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 142b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 142e: eb 31 jmp 1461 + cc = read(0, &c, 1); + 1430: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1437: 00 + 1438: 89 7c 24 04 mov %edi,0x4(%esp) + 143c: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1443: e8 02 01 00 00 call 154a + if(cc < 1) + 1448: 85 c0 test %eax,%eax + 144a: 7e 1d jle 1469 + break; + buf[i++] = c; + 144c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 1450: 89 de mov %ebx,%esi + buf[i++] = c; + 1452: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 1455: 3c 0d cmp $0xd,%al + buf[i++] = c; + 1457: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 145b: 74 0c je 1469 + 145d: 3c 0a cmp $0xa,%al + 145f: 74 08 je 1469 + for(i=0; i+1 < max; ){ + 1461: 8d 5e 01 lea 0x1(%esi),%ebx + 1464: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1467: 7c c7 jl 1430 + break; + } + buf[i] = '\0'; + 1469: 8b 45 08 mov 0x8(%ebp),%eax + 146c: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1470: 83 c4 2c add $0x2c,%esp + 1473: 5b pop %ebx + 1474: 5e pop %esi + 1475: 5f pop %edi + 1476: 5d pop %ebp + 1477: c3 ret + 1478: 90 nop + 1479: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001480 : + +int +stat(char *n, struct stat *st) +{ + 1480: 55 push %ebp + 1481: 89 e5 mov %esp,%ebp + 1483: 56 push %esi + 1484: 53 push %ebx + 1485: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 1488: 8b 45 08 mov 0x8(%ebp),%eax + 148b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1492: 00 + 1493: 89 04 24 mov %eax,(%esp) + 1496: e8 d7 00 00 00 call 1572 + if(fd < 0) + 149b: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 149d: 89 c3 mov %eax,%ebx + if(fd < 0) + 149f: 78 27 js 14c8 + return -1; + r = fstat(fd, st); + 14a1: 8b 45 0c mov 0xc(%ebp),%eax + 14a4: 89 1c 24 mov %ebx,(%esp) + 14a7: 89 44 24 04 mov %eax,0x4(%esp) + 14ab: e8 da 00 00 00 call 158a + close(fd); + 14b0: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 14b3: 89 c6 mov %eax,%esi + close(fd); + 14b5: e8 a0 00 00 00 call 155a + return r; + 14ba: 89 f0 mov %esi,%eax +} + 14bc: 83 c4 10 add $0x10,%esp + 14bf: 5b pop %ebx + 14c0: 5e pop %esi + 14c1: 5d pop %ebp + 14c2: c3 ret + 14c3: 90 nop + 14c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 14c8: b8 ff ff ff ff mov $0xffffffff,%eax + 14cd: eb ed jmp 14bc + 14cf: 90 nop + +000014d0 : + +int +atoi(const char *s) +{ + 14d0: 55 push %ebp + 14d1: 89 e5 mov %esp,%ebp + 14d3: 8b 4d 08 mov 0x8(%ebp),%ecx + 14d6: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 14d7: 0f be 11 movsbl (%ecx),%edx + 14da: 8d 42 d0 lea -0x30(%edx),%eax + 14dd: 3c 09 cmp $0x9,%al + n = 0; + 14df: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 14e4: 77 17 ja 14fd + 14e6: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 14e8: 83 c1 01 add $0x1,%ecx + 14eb: 8d 04 80 lea (%eax,%eax,4),%eax + 14ee: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 14f2: 0f be 11 movsbl (%ecx),%edx + 14f5: 8d 5a d0 lea -0x30(%edx),%ebx + 14f8: 80 fb 09 cmp $0x9,%bl + 14fb: 76 eb jbe 14e8 + return n; +} + 14fd: 5b pop %ebx + 14fe: 5d pop %ebp + 14ff: c3 ret + +00001500 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1500: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1501: 31 d2 xor %edx,%edx +{ + 1503: 89 e5 mov %esp,%ebp + 1505: 56 push %esi + 1506: 8b 45 08 mov 0x8(%ebp),%eax + 1509: 53 push %ebx + 150a: 8b 5d 10 mov 0x10(%ebp),%ebx + 150d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1510: 85 db test %ebx,%ebx + 1512: 7e 12 jle 1526 + 1514: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1518: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 151c: 88 0c 10 mov %cl,(%eax,%edx,1) + 151f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1522: 39 da cmp %ebx,%edx + 1524: 75 f2 jne 1518 + return vdst; +} + 1526: 5b pop %ebx + 1527: 5e pop %esi + 1528: 5d pop %ebp + 1529: c3 ret + +0000152a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 152a: b8 01 00 00 00 mov $0x1,%eax + 152f: cd 40 int $0x40 + 1531: c3 ret + +00001532 : +SYSCALL(exit) + 1532: b8 02 00 00 00 mov $0x2,%eax + 1537: cd 40 int $0x40 + 1539: c3 ret + +0000153a : +SYSCALL(wait) + 153a: b8 03 00 00 00 mov $0x3,%eax + 153f: cd 40 int $0x40 + 1541: c3 ret + +00001542 : +SYSCALL(pipe) + 1542: b8 04 00 00 00 mov $0x4,%eax + 1547: cd 40 int $0x40 + 1549: c3 ret + +0000154a : +SYSCALL(read) + 154a: b8 05 00 00 00 mov $0x5,%eax + 154f: cd 40 int $0x40 + 1551: c3 ret + +00001552 : +SYSCALL(write) + 1552: b8 10 00 00 00 mov $0x10,%eax + 1557: cd 40 int $0x40 + 1559: c3 ret + +0000155a : +SYSCALL(close) + 155a: b8 15 00 00 00 mov $0x15,%eax + 155f: cd 40 int $0x40 + 1561: c3 ret + +00001562 : +SYSCALL(kill) + 1562: b8 06 00 00 00 mov $0x6,%eax + 1567: cd 40 int $0x40 + 1569: c3 ret + +0000156a : +SYSCALL(exec) + 156a: b8 07 00 00 00 mov $0x7,%eax + 156f: cd 40 int $0x40 + 1571: c3 ret + +00001572 : +SYSCALL(open) + 1572: b8 0f 00 00 00 mov $0xf,%eax + 1577: cd 40 int $0x40 + 1579: c3 ret + +0000157a : +SYSCALL(mknod) + 157a: b8 11 00 00 00 mov $0x11,%eax + 157f: cd 40 int $0x40 + 1581: c3 ret + +00001582 : +SYSCALL(unlink) + 1582: b8 12 00 00 00 mov $0x12,%eax + 1587: cd 40 int $0x40 + 1589: c3 ret + +0000158a : +SYSCALL(fstat) + 158a: b8 08 00 00 00 mov $0x8,%eax + 158f: cd 40 int $0x40 + 1591: c3 ret + +00001592 : +SYSCALL(link) + 1592: b8 13 00 00 00 mov $0x13,%eax + 1597: cd 40 int $0x40 + 1599: c3 ret + +0000159a : +SYSCALL(mkdir) + 159a: b8 14 00 00 00 mov $0x14,%eax + 159f: cd 40 int $0x40 + 15a1: c3 ret + +000015a2 : +SYSCALL(chdir) + 15a2: b8 09 00 00 00 mov $0x9,%eax + 15a7: cd 40 int $0x40 + 15a9: c3 ret + +000015aa : +SYSCALL(dup) + 15aa: b8 0a 00 00 00 mov $0xa,%eax + 15af: cd 40 int $0x40 + 15b1: c3 ret + +000015b2 : +SYSCALL(getpid) + 15b2: b8 0b 00 00 00 mov $0xb,%eax + 15b7: cd 40 int $0x40 + 15b9: c3 ret + +000015ba : +SYSCALL(sbrk) + 15ba: b8 0c 00 00 00 mov $0xc,%eax + 15bf: cd 40 int $0x40 + 15c1: c3 ret + +000015c2 : +SYSCALL(sleep) + 15c2: b8 0d 00 00 00 mov $0xd,%eax + 15c7: cd 40 int $0x40 + 15c9: c3 ret + +000015ca : +SYSCALL(uptime) + 15ca: b8 0e 00 00 00 mov $0xe,%eax + 15cf: cd 40 int $0x40 + 15d1: c3 ret + +000015d2 : +SYSCALL(shm_open) + 15d2: b8 16 00 00 00 mov $0x16,%eax + 15d7: cd 40 int $0x40 + 15d9: c3 ret + +000015da : +SYSCALL(shm_close) + 15da: b8 17 00 00 00 mov $0x17,%eax + 15df: cd 40 int $0x40 + 15e1: c3 ret + 15e2: 66 90 xchg %ax,%ax + 15e4: 66 90 xchg %ax,%ax + 15e6: 66 90 xchg %ax,%ax + 15e8: 66 90 xchg %ax,%ax + 15ea: 66 90 xchg %ax,%ax + 15ec: 66 90 xchg %ax,%ax + 15ee: 66 90 xchg %ax,%ax + +000015f0 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 15f0: 55 push %ebp + 15f1: 89 e5 mov %esp,%ebp + 15f3: 57 push %edi + 15f4: 56 push %esi + 15f5: 89 c6 mov %eax,%esi + 15f7: 53 push %ebx + 15f8: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 15fb: 8b 5d 08 mov 0x8(%ebp),%ebx + 15fe: 85 db test %ebx,%ebx + 1600: 74 09 je 160b + 1602: 89 d0 mov %edx,%eax + 1604: c1 e8 1f shr $0x1f,%eax + 1607: 84 c0 test %al,%al + 1609: 75 75 jne 1680 + neg = 1; + x = -xx; + } else { + x = xx; + 160b: 89 d0 mov %edx,%eax + neg = 0; + 160d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1614: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1617: 31 ff xor %edi,%edi + 1619: 89 ce mov %ecx,%esi + 161b: 8d 5d d7 lea -0x29(%ebp),%ebx + 161e: eb 02 jmp 1622 + do{ + buf[i++] = digits[x % base]; + 1620: 89 cf mov %ecx,%edi + 1622: 31 d2 xor %edx,%edx + 1624: f7 f6 div %esi + 1626: 8d 4f 01 lea 0x1(%edi),%ecx + 1629: 0f b6 92 71 1a 00 00 movzbl 0x1a71(%edx),%edx + }while((x /= base) != 0); + 1630: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 1632: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 1635: 75 e9 jne 1620 + if(neg) + 1637: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 163a: 89 c8 mov %ecx,%eax + 163c: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 163f: 85 d2 test %edx,%edx + 1641: 74 08 je 164b + buf[i++] = '-'; + 1643: 8d 4f 02 lea 0x2(%edi),%ecx + 1646: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 164b: 8d 79 ff lea -0x1(%ecx),%edi + 164e: 66 90 xchg %ax,%ax + 1650: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 1655: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 1658: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 165f: 00 + 1660: 89 5c 24 04 mov %ebx,0x4(%esp) + 1664: 89 34 24 mov %esi,(%esp) + 1667: 88 45 d7 mov %al,-0x29(%ebp) + 166a: e8 e3 fe ff ff call 1552 + while(--i >= 0) + 166f: 83 ff ff cmp $0xffffffff,%edi + 1672: 75 dc jne 1650 + putc(fd, buf[i]); +} + 1674: 83 c4 4c add $0x4c,%esp + 1677: 5b pop %ebx + 1678: 5e pop %esi + 1679: 5f pop %edi + 167a: 5d pop %ebp + 167b: c3 ret + 167c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 1680: 89 d0 mov %edx,%eax + 1682: f7 d8 neg %eax + neg = 1; + 1684: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 168b: eb 87 jmp 1614 + 168d: 8d 76 00 lea 0x0(%esi),%esi + +00001690 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 1690: 55 push %ebp + 1691: 89 e5 mov %esp,%ebp + 1693: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 1694: 31 ff xor %edi,%edi +{ + 1696: 56 push %esi + 1697: 53 push %ebx + 1698: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 169b: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 169e: 8d 45 10 lea 0x10(%ebp),%eax +{ + 16a1: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 16a4: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 16a7: 0f b6 13 movzbl (%ebx),%edx + 16aa: 83 c3 01 add $0x1,%ebx + 16ad: 84 d2 test %dl,%dl + 16af: 75 39 jne 16ea + 16b1: e9 c2 00 00 00 jmp 1778 + 16b6: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 16b8: 83 fa 25 cmp $0x25,%edx + 16bb: 0f 84 bf 00 00 00 je 1780 + write(fd, &c, 1); + 16c1: 8d 45 e2 lea -0x1e(%ebp),%eax + 16c4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 16cb: 00 + 16cc: 89 44 24 04 mov %eax,0x4(%esp) + 16d0: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 16d3: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 16d6: e8 77 fe ff ff call 1552 + 16db: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 16de: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 16e2: 84 d2 test %dl,%dl + 16e4: 0f 84 8e 00 00 00 je 1778 + if(state == 0){ + 16ea: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 16ec: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 16ef: 74 c7 je 16b8 + } + } else if(state == '%'){ + 16f1: 83 ff 25 cmp $0x25,%edi + 16f4: 75 e5 jne 16db + if(c == 'd'){ + 16f6: 83 fa 64 cmp $0x64,%edx + 16f9: 0f 84 31 01 00 00 je 1830 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 16ff: 25 f7 00 00 00 and $0xf7,%eax + 1704: 83 f8 70 cmp $0x70,%eax + 1707: 0f 84 83 00 00 00 je 1790 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 170d: 83 fa 73 cmp $0x73,%edx + 1710: 0f 84 a2 00 00 00 je 17b8 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1716: 83 fa 63 cmp $0x63,%edx + 1719: 0f 84 35 01 00 00 je 1854 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 171f: 83 fa 25 cmp $0x25,%edx + 1722: 0f 84 e0 00 00 00 je 1808 + write(fd, &c, 1); + 1728: 8d 45 e6 lea -0x1a(%ebp),%eax + 172b: 83 c3 01 add $0x1,%ebx + 172e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1735: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 1736: 31 ff xor %edi,%edi + write(fd, &c, 1); + 1738: 89 44 24 04 mov %eax,0x4(%esp) + 173c: 89 34 24 mov %esi,(%esp) + 173f: 89 55 d0 mov %edx,-0x30(%ebp) + 1742: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 1746: e8 07 fe ff ff call 1552 + putc(fd, c); + 174b: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 174e: 8d 45 e7 lea -0x19(%ebp),%eax + 1751: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1758: 00 + 1759: 89 44 24 04 mov %eax,0x4(%esp) + 175d: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 1760: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 1763: e8 ea fd ff ff call 1552 + for(i = 0; fmt[i]; i++){ + 1768: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 176c: 84 d2 test %dl,%dl + 176e: 0f 85 76 ff ff ff jne 16ea + 1774: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 1778: 83 c4 3c add $0x3c,%esp + 177b: 5b pop %ebx + 177c: 5e pop %esi + 177d: 5f pop %edi + 177e: 5d pop %ebp + 177f: c3 ret + state = '%'; + 1780: bf 25 00 00 00 mov $0x25,%edi + 1785: e9 51 ff ff ff jmp 16db + 178a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 1790: 8b 45 d4 mov -0x2c(%ebp),%eax + 1793: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 1798: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 179a: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 17a1: 8b 10 mov (%eax),%edx + 17a3: 89 f0 mov %esi,%eax + 17a5: e8 46 fe ff ff call 15f0 + ap++; + 17aa: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 17ae: e9 28 ff ff ff jmp 16db + 17b3: 90 nop + 17b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 17b8: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 17bb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 17bf: 8b 38 mov (%eax),%edi + s = "(null)"; + 17c1: b8 6a 1a 00 00 mov $0x1a6a,%eax + 17c6: 85 ff test %edi,%edi + 17c8: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 17cb: 0f b6 07 movzbl (%edi),%eax + 17ce: 84 c0 test %al,%al + 17d0: 74 2a je 17fc + 17d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 17d8: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 17db: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 17de: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 17e1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 17e8: 00 + 17e9: 89 44 24 04 mov %eax,0x4(%esp) + 17ed: 89 34 24 mov %esi,(%esp) + 17f0: e8 5d fd ff ff call 1552 + while(*s != 0){ + 17f5: 0f b6 07 movzbl (%edi),%eax + 17f8: 84 c0 test %al,%al + 17fa: 75 dc jne 17d8 + state = 0; + 17fc: 31 ff xor %edi,%edi + 17fe: e9 d8 fe ff ff jmp 16db + 1803: 90 nop + 1804: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1808: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 180b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 180d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1814: 00 + 1815: 89 44 24 04 mov %eax,0x4(%esp) + 1819: 89 34 24 mov %esi,(%esp) + 181c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1820: e8 2d fd ff ff call 1552 + 1825: e9 b1 fe ff ff jmp 16db + 182a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 1830: 8b 45 d4 mov -0x2c(%ebp),%eax + 1833: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 1838: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 183b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1842: 8b 10 mov (%eax),%edx + 1844: 89 f0 mov %esi,%eax + 1846: e8 a5 fd ff ff call 15f0 + ap++; + 184b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 184f: e9 87 fe ff ff jmp 16db + putc(fd, *ap); + 1854: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 1857: 31 ff xor %edi,%edi + putc(fd, *ap); + 1859: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 185b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1862: 00 + 1863: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 1866: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 1869: 8d 45 e4 lea -0x1c(%ebp),%eax + 186c: 89 44 24 04 mov %eax,0x4(%esp) + 1870: e8 dd fc ff ff call 1552 + ap++; + 1875: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 1879: e9 5d fe ff ff jmp 16db + 187e: 66 90 xchg %ax,%ax + +00001880 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 1880: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1881: a1 20 1e 00 00 mov 0x1e20,%eax +{ + 1886: 89 e5 mov %esp,%ebp + 1888: 57 push %edi + 1889: 56 push %esi + 188a: 53 push %ebx + 188b: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 188e: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 1890: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1893: 39 d0 cmp %edx,%eax + 1895: 72 11 jb 18a8 + 1897: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1898: 39 c8 cmp %ecx,%eax + 189a: 72 04 jb 18a0 + 189c: 39 ca cmp %ecx,%edx + 189e: 72 10 jb 18b0 + 18a0: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 18a2: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 18a4: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 18a6: 73 f0 jae 1898 + 18a8: 39 ca cmp %ecx,%edx + 18aa: 72 04 jb 18b0 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 18ac: 39 c8 cmp %ecx,%eax + 18ae: 72 f0 jb 18a0 + break; + if(bp + bp->s.size == p->s.ptr){ + 18b0: 8b 73 fc mov -0x4(%ebx),%esi + 18b3: 8d 3c f2 lea (%edx,%esi,8),%edi + 18b6: 39 cf cmp %ecx,%edi + 18b8: 74 1e je 18d8 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 18ba: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 18bd: 8b 48 04 mov 0x4(%eax),%ecx + 18c0: 8d 34 c8 lea (%eax,%ecx,8),%esi + 18c3: 39 f2 cmp %esi,%edx + 18c5: 74 28 je 18ef + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 18c7: 89 10 mov %edx,(%eax) + freep = p; + 18c9: a3 20 1e 00 00 mov %eax,0x1e20 +} + 18ce: 5b pop %ebx + 18cf: 5e pop %esi + 18d0: 5f pop %edi + 18d1: 5d pop %ebp + 18d2: c3 ret + 18d3: 90 nop + 18d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 18d8: 03 71 04 add 0x4(%ecx),%esi + 18db: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 18de: 8b 08 mov (%eax),%ecx + 18e0: 8b 09 mov (%ecx),%ecx + 18e2: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 18e5: 8b 48 04 mov 0x4(%eax),%ecx + 18e8: 8d 34 c8 lea (%eax,%ecx,8),%esi + 18eb: 39 f2 cmp %esi,%edx + 18ed: 75 d8 jne 18c7 + p->s.size += bp->s.size; + 18ef: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 18f2: a3 20 1e 00 00 mov %eax,0x1e20 + p->s.size += bp->s.size; + 18f7: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 18fa: 8b 53 f8 mov -0x8(%ebx),%edx + 18fd: 89 10 mov %edx,(%eax) +} + 18ff: 5b pop %ebx + 1900: 5e pop %esi + 1901: 5f pop %edi + 1902: 5d pop %ebp + 1903: c3 ret + 1904: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 190a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001910 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1910: 55 push %ebp + 1911: 89 e5 mov %esp,%ebp + 1913: 57 push %edi + 1914: 56 push %esi + 1915: 53 push %ebx + 1916: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1919: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 191c: 8b 1d 20 1e 00 00 mov 0x1e20,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1922: 8d 48 07 lea 0x7(%eax),%ecx + 1925: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1928: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 192a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 192d: 0f 84 9b 00 00 00 je 19ce + 1933: 8b 13 mov (%ebx),%edx + 1935: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 1938: 39 fe cmp %edi,%esi + 193a: 76 64 jbe 19a0 + 193c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 1943: bb 00 80 00 00 mov $0x8000,%ebx + 1948: 89 45 e4 mov %eax,-0x1c(%ebp) + 194b: eb 0e jmp 195b + 194d: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 1950: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 1952: 8b 78 04 mov 0x4(%eax),%edi + 1955: 39 fe cmp %edi,%esi + 1957: 76 4f jbe 19a8 + 1959: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 195b: 3b 15 20 1e 00 00 cmp 0x1e20,%edx + 1961: 75 ed jne 1950 + if(nu < 4096) + 1963: 8b 45 e4 mov -0x1c(%ebp),%eax + 1966: 81 fe 00 10 00 00 cmp $0x1000,%esi + 196c: bf 00 10 00 00 mov $0x1000,%edi + 1971: 0f 43 fe cmovae %esi,%edi + 1974: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 1977: 89 04 24 mov %eax,(%esp) + 197a: e8 3b fc ff ff call 15ba + if(p == (char*)-1) + 197f: 83 f8 ff cmp $0xffffffff,%eax + 1982: 74 18 je 199c + hp->s.size = nu; + 1984: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 1987: 83 c0 08 add $0x8,%eax + 198a: 89 04 24 mov %eax,(%esp) + 198d: e8 ee fe ff ff call 1880 + return freep; + 1992: 8b 15 20 1e 00 00 mov 0x1e20,%edx + if((p = morecore(nunits)) == 0) + 1998: 85 d2 test %edx,%edx + 199a: 75 b4 jne 1950 + return 0; + 199c: 31 c0 xor %eax,%eax + 199e: eb 20 jmp 19c0 + if(p->s.size >= nunits){ + 19a0: 89 d0 mov %edx,%eax + 19a2: 89 da mov %ebx,%edx + 19a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 19a8: 39 fe cmp %edi,%esi + 19aa: 74 1c je 19c8 + p->s.size -= nunits; + 19ac: 29 f7 sub %esi,%edi + 19ae: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 19b1: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 19b4: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 19b7: 89 15 20 1e 00 00 mov %edx,0x1e20 + return (void*)(p + 1); + 19bd: 83 c0 08 add $0x8,%eax + } +} + 19c0: 83 c4 1c add $0x1c,%esp + 19c3: 5b pop %ebx + 19c4: 5e pop %esi + 19c5: 5f pop %edi + 19c6: 5d pop %ebp + 19c7: c3 ret + prevp->s.ptr = p->s.ptr; + 19c8: 8b 08 mov (%eax),%ecx + 19ca: 89 0a mov %ecx,(%edx) + 19cc: eb e9 jmp 19b7 + base.s.ptr = freep = prevp = &base; + 19ce: c7 05 20 1e 00 00 24 movl $0x1e24,0x1e20 + 19d5: 1e 00 00 + base.s.size = 0; + 19d8: ba 24 1e 00 00 mov $0x1e24,%edx + base.s.ptr = freep = prevp = &base; + 19dd: c7 05 24 1e 00 00 24 movl $0x1e24,0x1e24 + 19e4: 1e 00 00 + base.s.size = 0; + 19e7: c7 05 28 1e 00 00 00 movl $0x0,0x1e28 + 19ee: 00 00 00 + 19f1: e9 46 ff ff ff jmp 193c + 19f6: 66 90 xchg %ax,%ax + 19f8: 66 90 xchg %ax,%ax + 19fa: 66 90 xchg %ax,%ax + 19fc: 66 90 xchg %ax,%ax + 19fe: 66 90 xchg %ax,%ax + +00001a00 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1a00: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1a01: b9 01 00 00 00 mov $0x1,%ecx + 1a06: 89 e5 mov %esp,%ebp + 1a08: 8b 55 08 mov 0x8(%ebp),%edx + 1a0b: 90 nop + 1a0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1a10: 89 c8 mov %ecx,%eax + 1a12: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1a15: 85 c0 test %eax,%eax + 1a17: 75 f7 jne 1a10 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1a19: 0f ae f0 mfence +} + 1a1c: 5d pop %ebp + 1a1d: c3 ret + 1a1e: 66 90 xchg %ax,%ax + +00001a20 : + +void urelease (struct uspinlock *lk) { + 1a20: 55 push %ebp + 1a21: 89 e5 mov %esp,%ebp + 1a23: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1a26: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1a29: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 1a2f: 5d pop %ebp + 1a30: c3 ret diff --git a/grep.d b/grep.d new file mode 100644 index 00000000..15fc65b0 --- /dev/null +++ b/grep.d @@ -0,0 +1 @@ +grep.o: grep.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/grep.o b/grep.o new file mode 100644 index 00000000..c588c004 Binary files /dev/null and b/grep.o differ diff --git a/grep.sym b/grep.sym new file mode 100644 index 00000000..bee3097d --- /dev/null +++ b/grep.sym @@ -0,0 +1,67 @@ +00001000 .text +00001a34 .rodata +00001a84 .eh_frame +00001e20 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 grep.c +00000000 ulib.c +00000000 printf.c +000015f0 printint +00001a71 digits.1359 +00000000 umalloc.c +00001e20 freep +00001e24 base +00000000 uspinlock.c +00001310 strcpy +00001690 printf +00001500 memmove +00001120 matchhere +0000157a mknod +000015d2 shm_open +00001420 gets +000015b2 getpid +00001200 grep +00001910 malloc +000015c2 sleep +00001542 pipe +00001552 write +0000158a fstat +00001562 kill +000015a2 chdir +0000156a exec +0000153a wait +0000154a read +00001582 unlink +00001a00 uacquire +0000152a fork +000015ba sbrk +000015da shm_close +000015ca uptime +00001e04 __bss_start +000013c0 memset +00001000 main +000010c0 matchstar +00001340 strcmp +000015aa dup +00001e40 buf +00001480 stat +00001e04 _edata +00002240 _end +000011b0 match +00001592 link +00001532 exit +000014d0 atoi +00001390 strlen +00001572 open +000013e0 strchr +0000159a mkdir +0000155a close +00001a20 urelease +00001880 free diff --git a/ide.d b/ide.d new file mode 100644 index 00000000..21155b97 --- /dev/null +++ b/ide.d @@ -0,0 +1,2 @@ +ide.o: ide.c /usr/include/stdc-predef.h types.h defs.h param.h \ + memlayout.h mmu.h proc.h x86.h traps.h spinlock.h sleeplock.h fs.h buf.h diff --git a/ide.o b/ide.o new file mode 100644 index 00000000..72520ae6 Binary files /dev/null and b/ide.o differ diff --git a/init.asm b/init.asm new file mode 100644 index 00000000..30a3d548 --- /dev/null +++ b/init.asm @@ -0,0 +1,1275 @@ + +_init: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: + +char *argv[] = { "sh", 0 }; + +int +main(void) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 53 push %ebx + 1004: 83 e4 f0 and $0xfffffff0,%esp + 1007: 83 ec 10 sub $0x10,%esp + int pid, wpid; + + if(open("console", O_RDWR) < 0){ + 100a: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) + 1011: 00 + 1012: c7 04 24 31 18 00 00 movl $0x1831,(%esp) + 1019: e8 54 03 00 00 call 1372 + 101e: 85 c0 test %eax,%eax + 1020: 0f 88 ac 00 00 00 js 10d2 + mknod("console", 1, 1); + open("console", O_RDWR); + } + dup(0); // stdout + 1026: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 102d: e8 78 03 00 00 call 13aa + dup(0); // stderr + 1032: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1039: e8 6c 03 00 00 call 13aa + 103e: 66 90 xchg %ax,%ax + + for(;;){ + printf(1, "init: starting sh\n"); + 1040: c7 44 24 04 39 18 00 movl $0x1839,0x4(%esp) + 1047: 00 + 1048: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 104f: e8 3c 04 00 00 call 1490 + pid = fork(); + 1054: e8 d1 02 00 00 call 132a + if(pid < 0){ + 1059: 85 c0 test %eax,%eax + pid = fork(); + 105b: 89 c3 mov %eax,%ebx + if(pid < 0){ + 105d: 78 2d js 108c + 105f: 90 nop + printf(1, "init: fork failed\n"); + exit(); + } + if(pid == 0){ + 1060: 74 43 je 10a5 + 1062: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + exec("sh", argv); + printf(1, "init: exec sh failed\n"); + exit(); + } + while((wpid=wait()) >= 0 && wpid != pid) + 1068: e8 cd 02 00 00 call 133a + 106d: 85 c0 test %eax,%eax + 106f: 90 nop + 1070: 78 ce js 1040 + 1072: 39 d8 cmp %ebx,%eax + 1074: 74 ca je 1040 + printf(1, "zombie!\n"); + 1076: c7 44 24 04 78 18 00 movl $0x1878,0x4(%esp) + 107d: 00 + 107e: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1085: e8 06 04 00 00 call 1490 + 108a: eb dc jmp 1068 + printf(1, "init: fork failed\n"); + 108c: c7 44 24 04 4c 18 00 movl $0x184c,0x4(%esp) + 1093: 00 + 1094: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 109b: e8 f0 03 00 00 call 1490 + exit(); + 10a0: e8 8d 02 00 00 call 1332 + exec("sh", argv); + 10a5: c7 44 24 04 40 1b 00 movl $0x1b40,0x4(%esp) + 10ac: 00 + 10ad: c7 04 24 5f 18 00 00 movl $0x185f,(%esp) + 10b4: e8 b1 02 00 00 call 136a + printf(1, "init: exec sh failed\n"); + 10b9: c7 44 24 04 62 18 00 movl $0x1862,0x4(%esp) + 10c0: 00 + 10c1: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 10c8: e8 c3 03 00 00 call 1490 + exit(); + 10cd: e8 60 02 00 00 call 1332 + mknod("console", 1, 1); + 10d2: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 10d9: 00 + 10da: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) + 10e1: 00 + 10e2: c7 04 24 31 18 00 00 movl $0x1831,(%esp) + 10e9: e8 8c 02 00 00 call 137a + open("console", O_RDWR); + 10ee: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) + 10f5: 00 + 10f6: c7 04 24 31 18 00 00 movl $0x1831,(%esp) + 10fd: e8 70 02 00 00 call 1372 + 1102: e9 1f ff ff ff jmp 1026 + 1107: 66 90 xchg %ax,%ax + 1109: 66 90 xchg %ax,%ax + 110b: 66 90 xchg %ax,%ax + 110d: 66 90 xchg %ax,%ax + 110f: 90 nop + +00001110 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1110: 55 push %ebp + 1111: 89 e5 mov %esp,%ebp + 1113: 8b 45 08 mov 0x8(%ebp),%eax + 1116: 8b 4d 0c mov 0xc(%ebp),%ecx + 1119: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 111a: 89 c2 mov %eax,%edx + 111c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1120: 83 c1 01 add $0x1,%ecx + 1123: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1127: 83 c2 01 add $0x1,%edx + 112a: 84 db test %bl,%bl + 112c: 88 5a ff mov %bl,-0x1(%edx) + 112f: 75 ef jne 1120 + ; + return os; +} + 1131: 5b pop %ebx + 1132: 5d pop %ebp + 1133: c3 ret + 1134: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 113a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001140 : + +int +strcmp(const char *p, const char *q) +{ + 1140: 55 push %ebp + 1141: 89 e5 mov %esp,%ebp + 1143: 8b 55 08 mov 0x8(%ebp),%edx + 1146: 53 push %ebx + 1147: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 114a: 0f b6 02 movzbl (%edx),%eax + 114d: 84 c0 test %al,%al + 114f: 74 2d je 117e + 1151: 0f b6 19 movzbl (%ecx),%ebx + 1154: 38 d8 cmp %bl,%al + 1156: 74 0e je 1166 + 1158: eb 2b jmp 1185 + 115a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1160: 38 c8 cmp %cl,%al + 1162: 75 15 jne 1179 + p++, q++; + 1164: 89 d9 mov %ebx,%ecx + 1166: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 1169: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 116c: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 116f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 1173: 84 c0 test %al,%al + 1175: 75 e9 jne 1160 + 1177: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 1179: 29 c8 sub %ecx,%eax +} + 117b: 5b pop %ebx + 117c: 5d pop %ebp + 117d: c3 ret + 117e: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 1181: 31 c0 xor %eax,%eax + 1183: eb f4 jmp 1179 + 1185: 0f b6 cb movzbl %bl,%ecx + 1188: eb ef jmp 1179 + 118a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00001190 : + +uint +strlen(char *s) +{ + 1190: 55 push %ebp + 1191: 89 e5 mov %esp,%ebp + 1193: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 1196: 80 39 00 cmpb $0x0,(%ecx) + 1199: 74 12 je 11ad + 119b: 31 d2 xor %edx,%edx + 119d: 8d 76 00 lea 0x0(%esi),%esi + 11a0: 83 c2 01 add $0x1,%edx + 11a3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 11a7: 89 d0 mov %edx,%eax + 11a9: 75 f5 jne 11a0 + ; + return n; +} + 11ab: 5d pop %ebp + 11ac: c3 ret + for(n = 0; s[n]; n++) + 11ad: 31 c0 xor %eax,%eax +} + 11af: 5d pop %ebp + 11b0: c3 ret + 11b1: eb 0d jmp 11c0 + 11b3: 90 nop + 11b4: 90 nop + 11b5: 90 nop + 11b6: 90 nop + 11b7: 90 nop + 11b8: 90 nop + 11b9: 90 nop + 11ba: 90 nop + 11bb: 90 nop + 11bc: 90 nop + 11bd: 90 nop + 11be: 90 nop + 11bf: 90 nop + +000011c0 : + +void* +memset(void *dst, int c, uint n) +{ + 11c0: 55 push %ebp + 11c1: 89 e5 mov %esp,%ebp + 11c3: 8b 55 08 mov 0x8(%ebp),%edx + 11c6: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 11c7: 8b 4d 10 mov 0x10(%ebp),%ecx + 11ca: 8b 45 0c mov 0xc(%ebp),%eax + 11cd: 89 d7 mov %edx,%edi + 11cf: fc cld + 11d0: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 11d2: 89 d0 mov %edx,%eax + 11d4: 5f pop %edi + 11d5: 5d pop %ebp + 11d6: c3 ret + 11d7: 89 f6 mov %esi,%esi + 11d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +000011e0 : + +char* +strchr(const char *s, char c) +{ + 11e0: 55 push %ebp + 11e1: 89 e5 mov %esp,%ebp + 11e3: 8b 45 08 mov 0x8(%ebp),%eax + 11e6: 53 push %ebx + 11e7: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 11ea: 0f b6 18 movzbl (%eax),%ebx + 11ed: 84 db test %bl,%bl + 11ef: 74 1d je 120e + if(*s == c) + 11f1: 38 d3 cmp %dl,%bl + 11f3: 89 d1 mov %edx,%ecx + 11f5: 75 0d jne 1204 + 11f7: eb 17 jmp 1210 + 11f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1200: 38 ca cmp %cl,%dl + 1202: 74 0c je 1210 + for(; *s; s++) + 1204: 83 c0 01 add $0x1,%eax + 1207: 0f b6 10 movzbl (%eax),%edx + 120a: 84 d2 test %dl,%dl + 120c: 75 f2 jne 1200 + return (char*)s; + return 0; + 120e: 31 c0 xor %eax,%eax +} + 1210: 5b pop %ebx + 1211: 5d pop %ebp + 1212: c3 ret + 1213: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001220 : + +char* +gets(char *buf, int max) +{ + 1220: 55 push %ebp + 1221: 89 e5 mov %esp,%ebp + 1223: 57 push %edi + 1224: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1225: 31 f6 xor %esi,%esi +{ + 1227: 53 push %ebx + 1228: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 122b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 122e: eb 31 jmp 1261 + cc = read(0, &c, 1); + 1230: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1237: 00 + 1238: 89 7c 24 04 mov %edi,0x4(%esp) + 123c: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1243: e8 02 01 00 00 call 134a + if(cc < 1) + 1248: 85 c0 test %eax,%eax + 124a: 7e 1d jle 1269 + break; + buf[i++] = c; + 124c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 1250: 89 de mov %ebx,%esi + buf[i++] = c; + 1252: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 1255: 3c 0d cmp $0xd,%al + buf[i++] = c; + 1257: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 125b: 74 0c je 1269 + 125d: 3c 0a cmp $0xa,%al + 125f: 74 08 je 1269 + for(i=0; i+1 < max; ){ + 1261: 8d 5e 01 lea 0x1(%esi),%ebx + 1264: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1267: 7c c7 jl 1230 + break; + } + buf[i] = '\0'; + 1269: 8b 45 08 mov 0x8(%ebp),%eax + 126c: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1270: 83 c4 2c add $0x2c,%esp + 1273: 5b pop %ebx + 1274: 5e pop %esi + 1275: 5f pop %edi + 1276: 5d pop %ebp + 1277: c3 ret + 1278: 90 nop + 1279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001280 : + +int +stat(char *n, struct stat *st) +{ + 1280: 55 push %ebp + 1281: 89 e5 mov %esp,%ebp + 1283: 56 push %esi + 1284: 53 push %ebx + 1285: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 1288: 8b 45 08 mov 0x8(%ebp),%eax + 128b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1292: 00 + 1293: 89 04 24 mov %eax,(%esp) + 1296: e8 d7 00 00 00 call 1372 + if(fd < 0) + 129b: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 129d: 89 c3 mov %eax,%ebx + if(fd < 0) + 129f: 78 27 js 12c8 + return -1; + r = fstat(fd, st); + 12a1: 8b 45 0c mov 0xc(%ebp),%eax + 12a4: 89 1c 24 mov %ebx,(%esp) + 12a7: 89 44 24 04 mov %eax,0x4(%esp) + 12ab: e8 da 00 00 00 call 138a + close(fd); + 12b0: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 12b3: 89 c6 mov %eax,%esi + close(fd); + 12b5: e8 a0 00 00 00 call 135a + return r; + 12ba: 89 f0 mov %esi,%eax +} + 12bc: 83 c4 10 add $0x10,%esp + 12bf: 5b pop %ebx + 12c0: 5e pop %esi + 12c1: 5d pop %ebp + 12c2: c3 ret + 12c3: 90 nop + 12c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 12c8: b8 ff ff ff ff mov $0xffffffff,%eax + 12cd: eb ed jmp 12bc + 12cf: 90 nop + +000012d0 : + +int +atoi(const char *s) +{ + 12d0: 55 push %ebp + 12d1: 89 e5 mov %esp,%ebp + 12d3: 8b 4d 08 mov 0x8(%ebp),%ecx + 12d6: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 12d7: 0f be 11 movsbl (%ecx),%edx + 12da: 8d 42 d0 lea -0x30(%edx),%eax + 12dd: 3c 09 cmp $0x9,%al + n = 0; + 12df: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 12e4: 77 17 ja 12fd + 12e6: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 12e8: 83 c1 01 add $0x1,%ecx + 12eb: 8d 04 80 lea (%eax,%eax,4),%eax + 12ee: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 12f2: 0f be 11 movsbl (%ecx),%edx + 12f5: 8d 5a d0 lea -0x30(%edx),%ebx + 12f8: 80 fb 09 cmp $0x9,%bl + 12fb: 76 eb jbe 12e8 + return n; +} + 12fd: 5b pop %ebx + 12fe: 5d pop %ebp + 12ff: c3 ret + +00001300 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1300: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1301: 31 d2 xor %edx,%edx +{ + 1303: 89 e5 mov %esp,%ebp + 1305: 56 push %esi + 1306: 8b 45 08 mov 0x8(%ebp),%eax + 1309: 53 push %ebx + 130a: 8b 5d 10 mov 0x10(%ebp),%ebx + 130d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1310: 85 db test %ebx,%ebx + 1312: 7e 12 jle 1326 + 1314: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1318: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 131c: 88 0c 10 mov %cl,(%eax,%edx,1) + 131f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1322: 39 da cmp %ebx,%edx + 1324: 75 f2 jne 1318 + return vdst; +} + 1326: 5b pop %ebx + 1327: 5e pop %esi + 1328: 5d pop %ebp + 1329: c3 ret + +0000132a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 132a: b8 01 00 00 00 mov $0x1,%eax + 132f: cd 40 int $0x40 + 1331: c3 ret + +00001332 : +SYSCALL(exit) + 1332: b8 02 00 00 00 mov $0x2,%eax + 1337: cd 40 int $0x40 + 1339: c3 ret + +0000133a : +SYSCALL(wait) + 133a: b8 03 00 00 00 mov $0x3,%eax + 133f: cd 40 int $0x40 + 1341: c3 ret + +00001342 : +SYSCALL(pipe) + 1342: b8 04 00 00 00 mov $0x4,%eax + 1347: cd 40 int $0x40 + 1349: c3 ret + +0000134a : +SYSCALL(read) + 134a: b8 05 00 00 00 mov $0x5,%eax + 134f: cd 40 int $0x40 + 1351: c3 ret + +00001352 : +SYSCALL(write) + 1352: b8 10 00 00 00 mov $0x10,%eax + 1357: cd 40 int $0x40 + 1359: c3 ret + +0000135a : +SYSCALL(close) + 135a: b8 15 00 00 00 mov $0x15,%eax + 135f: cd 40 int $0x40 + 1361: c3 ret + +00001362 : +SYSCALL(kill) + 1362: b8 06 00 00 00 mov $0x6,%eax + 1367: cd 40 int $0x40 + 1369: c3 ret + +0000136a : +SYSCALL(exec) + 136a: b8 07 00 00 00 mov $0x7,%eax + 136f: cd 40 int $0x40 + 1371: c3 ret + +00001372 : +SYSCALL(open) + 1372: b8 0f 00 00 00 mov $0xf,%eax + 1377: cd 40 int $0x40 + 1379: c3 ret + +0000137a : +SYSCALL(mknod) + 137a: b8 11 00 00 00 mov $0x11,%eax + 137f: cd 40 int $0x40 + 1381: c3 ret + +00001382 : +SYSCALL(unlink) + 1382: b8 12 00 00 00 mov $0x12,%eax + 1387: cd 40 int $0x40 + 1389: c3 ret + +0000138a : +SYSCALL(fstat) + 138a: b8 08 00 00 00 mov $0x8,%eax + 138f: cd 40 int $0x40 + 1391: c3 ret + +00001392 : +SYSCALL(link) + 1392: b8 13 00 00 00 mov $0x13,%eax + 1397: cd 40 int $0x40 + 1399: c3 ret + +0000139a : +SYSCALL(mkdir) + 139a: b8 14 00 00 00 mov $0x14,%eax + 139f: cd 40 int $0x40 + 13a1: c3 ret + +000013a2 : +SYSCALL(chdir) + 13a2: b8 09 00 00 00 mov $0x9,%eax + 13a7: cd 40 int $0x40 + 13a9: c3 ret + +000013aa : +SYSCALL(dup) + 13aa: b8 0a 00 00 00 mov $0xa,%eax + 13af: cd 40 int $0x40 + 13b1: c3 ret + +000013b2 : +SYSCALL(getpid) + 13b2: b8 0b 00 00 00 mov $0xb,%eax + 13b7: cd 40 int $0x40 + 13b9: c3 ret + +000013ba : +SYSCALL(sbrk) + 13ba: b8 0c 00 00 00 mov $0xc,%eax + 13bf: cd 40 int $0x40 + 13c1: c3 ret + +000013c2 : +SYSCALL(sleep) + 13c2: b8 0d 00 00 00 mov $0xd,%eax + 13c7: cd 40 int $0x40 + 13c9: c3 ret + +000013ca : +SYSCALL(uptime) + 13ca: b8 0e 00 00 00 mov $0xe,%eax + 13cf: cd 40 int $0x40 + 13d1: c3 ret + +000013d2 : +SYSCALL(shm_open) + 13d2: b8 16 00 00 00 mov $0x16,%eax + 13d7: cd 40 int $0x40 + 13d9: c3 ret + +000013da : +SYSCALL(shm_close) + 13da: b8 17 00 00 00 mov $0x17,%eax + 13df: cd 40 int $0x40 + 13e1: c3 ret + 13e2: 66 90 xchg %ax,%ax + 13e4: 66 90 xchg %ax,%ax + 13e6: 66 90 xchg %ax,%ax + 13e8: 66 90 xchg %ax,%ax + 13ea: 66 90 xchg %ax,%ax + 13ec: 66 90 xchg %ax,%ax + 13ee: 66 90 xchg %ax,%ax + +000013f0 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 13f0: 55 push %ebp + 13f1: 89 e5 mov %esp,%ebp + 13f3: 57 push %edi + 13f4: 56 push %esi + 13f5: 89 c6 mov %eax,%esi + 13f7: 53 push %ebx + 13f8: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 13fb: 8b 5d 08 mov 0x8(%ebp),%ebx + 13fe: 85 db test %ebx,%ebx + 1400: 74 09 je 140b + 1402: 89 d0 mov %edx,%eax + 1404: c1 e8 1f shr $0x1f,%eax + 1407: 84 c0 test %al,%al + 1409: 75 75 jne 1480 + neg = 1; + x = -xx; + } else { + x = xx; + 140b: 89 d0 mov %edx,%eax + neg = 0; + 140d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1414: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1417: 31 ff xor %edi,%edi + 1419: 89 ce mov %ecx,%esi + 141b: 8d 5d d7 lea -0x29(%ebp),%ebx + 141e: eb 02 jmp 1422 + do{ + buf[i++] = digits[x % base]; + 1420: 89 cf mov %ecx,%edi + 1422: 31 d2 xor %edx,%edx + 1424: f7 f6 div %esi + 1426: 8d 4f 01 lea 0x1(%edi),%ecx + 1429: 0f b6 92 88 18 00 00 movzbl 0x1888(%edx),%edx + }while((x /= base) != 0); + 1430: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 1432: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 1435: 75 e9 jne 1420 + if(neg) + 1437: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 143a: 89 c8 mov %ecx,%eax + 143c: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 143f: 85 d2 test %edx,%edx + 1441: 74 08 je 144b + buf[i++] = '-'; + 1443: 8d 4f 02 lea 0x2(%edi),%ecx + 1446: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 144b: 8d 79 ff lea -0x1(%ecx),%edi + 144e: 66 90 xchg %ax,%ax + 1450: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 1455: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 1458: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 145f: 00 + 1460: 89 5c 24 04 mov %ebx,0x4(%esp) + 1464: 89 34 24 mov %esi,(%esp) + 1467: 88 45 d7 mov %al,-0x29(%ebp) + 146a: e8 e3 fe ff ff call 1352 + while(--i >= 0) + 146f: 83 ff ff cmp $0xffffffff,%edi + 1472: 75 dc jne 1450 + putc(fd, buf[i]); +} + 1474: 83 c4 4c add $0x4c,%esp + 1477: 5b pop %ebx + 1478: 5e pop %esi + 1479: 5f pop %edi + 147a: 5d pop %ebp + 147b: c3 ret + 147c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 1480: 89 d0 mov %edx,%eax + 1482: f7 d8 neg %eax + neg = 1; + 1484: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 148b: eb 87 jmp 1414 + 148d: 8d 76 00 lea 0x0(%esi),%esi + +00001490 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 1490: 55 push %ebp + 1491: 89 e5 mov %esp,%ebp + 1493: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 1494: 31 ff xor %edi,%edi +{ + 1496: 56 push %esi + 1497: 53 push %ebx + 1498: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 149b: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 149e: 8d 45 10 lea 0x10(%ebp),%eax +{ + 14a1: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 14a4: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 14a7: 0f b6 13 movzbl (%ebx),%edx + 14aa: 83 c3 01 add $0x1,%ebx + 14ad: 84 d2 test %dl,%dl + 14af: 75 39 jne 14ea + 14b1: e9 c2 00 00 00 jmp 1578 + 14b6: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 14b8: 83 fa 25 cmp $0x25,%edx + 14bb: 0f 84 bf 00 00 00 je 1580 + write(fd, &c, 1); + 14c1: 8d 45 e2 lea -0x1e(%ebp),%eax + 14c4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14cb: 00 + 14cc: 89 44 24 04 mov %eax,0x4(%esp) + 14d0: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 14d3: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 14d6: e8 77 fe ff ff call 1352 + 14db: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 14de: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 14e2: 84 d2 test %dl,%dl + 14e4: 0f 84 8e 00 00 00 je 1578 + if(state == 0){ + 14ea: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 14ec: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 14ef: 74 c7 je 14b8 + } + } else if(state == '%'){ + 14f1: 83 ff 25 cmp $0x25,%edi + 14f4: 75 e5 jne 14db + if(c == 'd'){ + 14f6: 83 fa 64 cmp $0x64,%edx + 14f9: 0f 84 31 01 00 00 je 1630 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 14ff: 25 f7 00 00 00 and $0xf7,%eax + 1504: 83 f8 70 cmp $0x70,%eax + 1507: 0f 84 83 00 00 00 je 1590 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 150d: 83 fa 73 cmp $0x73,%edx + 1510: 0f 84 a2 00 00 00 je 15b8 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1516: 83 fa 63 cmp $0x63,%edx + 1519: 0f 84 35 01 00 00 je 1654 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 151f: 83 fa 25 cmp $0x25,%edx + 1522: 0f 84 e0 00 00 00 je 1608 + write(fd, &c, 1); + 1528: 8d 45 e6 lea -0x1a(%ebp),%eax + 152b: 83 c3 01 add $0x1,%ebx + 152e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1535: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 1536: 31 ff xor %edi,%edi + write(fd, &c, 1); + 1538: 89 44 24 04 mov %eax,0x4(%esp) + 153c: 89 34 24 mov %esi,(%esp) + 153f: 89 55 d0 mov %edx,-0x30(%ebp) + 1542: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 1546: e8 07 fe ff ff call 1352 + putc(fd, c); + 154b: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 154e: 8d 45 e7 lea -0x19(%ebp),%eax + 1551: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1558: 00 + 1559: 89 44 24 04 mov %eax,0x4(%esp) + 155d: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 1560: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 1563: e8 ea fd ff ff call 1352 + for(i = 0; fmt[i]; i++){ + 1568: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 156c: 84 d2 test %dl,%dl + 156e: 0f 85 76 ff ff ff jne 14ea + 1574: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 1578: 83 c4 3c add $0x3c,%esp + 157b: 5b pop %ebx + 157c: 5e pop %esi + 157d: 5f pop %edi + 157e: 5d pop %ebp + 157f: c3 ret + state = '%'; + 1580: bf 25 00 00 00 mov $0x25,%edi + 1585: e9 51 ff ff ff jmp 14db + 158a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 1590: 8b 45 d4 mov -0x2c(%ebp),%eax + 1593: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 1598: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 159a: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 15a1: 8b 10 mov (%eax),%edx + 15a3: 89 f0 mov %esi,%eax + 15a5: e8 46 fe ff ff call 13f0 + ap++; + 15aa: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15ae: e9 28 ff ff ff jmp 14db + 15b3: 90 nop + 15b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 15b8: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 15bb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 15bf: 8b 38 mov (%eax),%edi + s = "(null)"; + 15c1: b8 81 18 00 00 mov $0x1881,%eax + 15c6: 85 ff test %edi,%edi + 15c8: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 15cb: 0f b6 07 movzbl (%edi),%eax + 15ce: 84 c0 test %al,%al + 15d0: 74 2a je 15fc + 15d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 15d8: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 15db: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 15de: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 15e1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 15e8: 00 + 15e9: 89 44 24 04 mov %eax,0x4(%esp) + 15ed: 89 34 24 mov %esi,(%esp) + 15f0: e8 5d fd ff ff call 1352 + while(*s != 0){ + 15f5: 0f b6 07 movzbl (%edi),%eax + 15f8: 84 c0 test %al,%al + 15fa: 75 dc jne 15d8 + state = 0; + 15fc: 31 ff xor %edi,%edi + 15fe: e9 d8 fe ff ff jmp 14db + 1603: 90 nop + 1604: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1608: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 160b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 160d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1614: 00 + 1615: 89 44 24 04 mov %eax,0x4(%esp) + 1619: 89 34 24 mov %esi,(%esp) + 161c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1620: e8 2d fd ff ff call 1352 + 1625: e9 b1 fe ff ff jmp 14db + 162a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 1630: 8b 45 d4 mov -0x2c(%ebp),%eax + 1633: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 1638: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 163b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1642: 8b 10 mov (%eax),%edx + 1644: 89 f0 mov %esi,%eax + 1646: e8 a5 fd ff ff call 13f0 + ap++; + 164b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 164f: e9 87 fe ff ff jmp 14db + putc(fd, *ap); + 1654: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 1657: 31 ff xor %edi,%edi + putc(fd, *ap); + 1659: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 165b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1662: 00 + 1663: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 1666: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 1669: 8d 45 e4 lea -0x1c(%ebp),%eax + 166c: 89 44 24 04 mov %eax,0x4(%esp) + 1670: e8 dd fc ff ff call 1352 + ap++; + 1675: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 1679: e9 5d fe ff ff jmp 14db + 167e: 66 90 xchg %ax,%ax + +00001680 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 1680: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1681: a1 48 1b 00 00 mov 0x1b48,%eax +{ + 1686: 89 e5 mov %esp,%ebp + 1688: 57 push %edi + 1689: 56 push %esi + 168a: 53 push %ebx + 168b: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 168e: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 1690: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1693: 39 d0 cmp %edx,%eax + 1695: 72 11 jb 16a8 + 1697: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1698: 39 c8 cmp %ecx,%eax + 169a: 72 04 jb 16a0 + 169c: 39 ca cmp %ecx,%edx + 169e: 72 10 jb 16b0 + 16a0: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 16a2: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 16a4: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 16a6: 73 f0 jae 1698 + 16a8: 39 ca cmp %ecx,%edx + 16aa: 72 04 jb 16b0 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 16ac: 39 c8 cmp %ecx,%eax + 16ae: 72 f0 jb 16a0 + break; + if(bp + bp->s.size == p->s.ptr){ + 16b0: 8b 73 fc mov -0x4(%ebx),%esi + 16b3: 8d 3c f2 lea (%edx,%esi,8),%edi + 16b6: 39 cf cmp %ecx,%edi + 16b8: 74 1e je 16d8 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 16ba: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 16bd: 8b 48 04 mov 0x4(%eax),%ecx + 16c0: 8d 34 c8 lea (%eax,%ecx,8),%esi + 16c3: 39 f2 cmp %esi,%edx + 16c5: 74 28 je 16ef + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 16c7: 89 10 mov %edx,(%eax) + freep = p; + 16c9: a3 48 1b 00 00 mov %eax,0x1b48 +} + 16ce: 5b pop %ebx + 16cf: 5e pop %esi + 16d0: 5f pop %edi + 16d1: 5d pop %ebp + 16d2: c3 ret + 16d3: 90 nop + 16d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 16d8: 03 71 04 add 0x4(%ecx),%esi + 16db: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 16de: 8b 08 mov (%eax),%ecx + 16e0: 8b 09 mov (%ecx),%ecx + 16e2: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 16e5: 8b 48 04 mov 0x4(%eax),%ecx + 16e8: 8d 34 c8 lea (%eax,%ecx,8),%esi + 16eb: 39 f2 cmp %esi,%edx + 16ed: 75 d8 jne 16c7 + p->s.size += bp->s.size; + 16ef: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 16f2: a3 48 1b 00 00 mov %eax,0x1b48 + p->s.size += bp->s.size; + 16f7: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 16fa: 8b 53 f8 mov -0x8(%ebx),%edx + 16fd: 89 10 mov %edx,(%eax) +} + 16ff: 5b pop %ebx + 1700: 5e pop %esi + 1701: 5f pop %edi + 1702: 5d pop %ebp + 1703: c3 ret + 1704: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 170a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001710 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1710: 55 push %ebp + 1711: 89 e5 mov %esp,%ebp + 1713: 57 push %edi + 1714: 56 push %esi + 1715: 53 push %ebx + 1716: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1719: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 171c: 8b 1d 48 1b 00 00 mov 0x1b48,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1722: 8d 48 07 lea 0x7(%eax),%ecx + 1725: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1728: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 172a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 172d: 0f 84 9b 00 00 00 je 17ce + 1733: 8b 13 mov (%ebx),%edx + 1735: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 1738: 39 fe cmp %edi,%esi + 173a: 76 64 jbe 17a0 + 173c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 1743: bb 00 80 00 00 mov $0x8000,%ebx + 1748: 89 45 e4 mov %eax,-0x1c(%ebp) + 174b: eb 0e jmp 175b + 174d: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 1750: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 1752: 8b 78 04 mov 0x4(%eax),%edi + 1755: 39 fe cmp %edi,%esi + 1757: 76 4f jbe 17a8 + 1759: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 175b: 3b 15 48 1b 00 00 cmp 0x1b48,%edx + 1761: 75 ed jne 1750 + if(nu < 4096) + 1763: 8b 45 e4 mov -0x1c(%ebp),%eax + 1766: 81 fe 00 10 00 00 cmp $0x1000,%esi + 176c: bf 00 10 00 00 mov $0x1000,%edi + 1771: 0f 43 fe cmovae %esi,%edi + 1774: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 1777: 89 04 24 mov %eax,(%esp) + 177a: e8 3b fc ff ff call 13ba + if(p == (char*)-1) + 177f: 83 f8 ff cmp $0xffffffff,%eax + 1782: 74 18 je 179c + hp->s.size = nu; + 1784: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 1787: 83 c0 08 add $0x8,%eax + 178a: 89 04 24 mov %eax,(%esp) + 178d: e8 ee fe ff ff call 1680 + return freep; + 1792: 8b 15 48 1b 00 00 mov 0x1b48,%edx + if((p = morecore(nunits)) == 0) + 1798: 85 d2 test %edx,%edx + 179a: 75 b4 jne 1750 + return 0; + 179c: 31 c0 xor %eax,%eax + 179e: eb 20 jmp 17c0 + if(p->s.size >= nunits){ + 17a0: 89 d0 mov %edx,%eax + 17a2: 89 da mov %ebx,%edx + 17a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 17a8: 39 fe cmp %edi,%esi + 17aa: 74 1c je 17c8 + p->s.size -= nunits; + 17ac: 29 f7 sub %esi,%edi + 17ae: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 17b1: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 17b4: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 17b7: 89 15 48 1b 00 00 mov %edx,0x1b48 + return (void*)(p + 1); + 17bd: 83 c0 08 add $0x8,%eax + } +} + 17c0: 83 c4 1c add $0x1c,%esp + 17c3: 5b pop %ebx + 17c4: 5e pop %esi + 17c5: 5f pop %edi + 17c6: 5d pop %ebp + 17c7: c3 ret + prevp->s.ptr = p->s.ptr; + 17c8: 8b 08 mov (%eax),%ecx + 17ca: 89 0a mov %ecx,(%edx) + 17cc: eb e9 jmp 17b7 + base.s.ptr = freep = prevp = &base; + 17ce: c7 05 48 1b 00 00 4c movl $0x1b4c,0x1b48 + 17d5: 1b 00 00 + base.s.size = 0; + 17d8: ba 4c 1b 00 00 mov $0x1b4c,%edx + base.s.ptr = freep = prevp = &base; + 17dd: c7 05 4c 1b 00 00 4c movl $0x1b4c,0x1b4c + 17e4: 1b 00 00 + base.s.size = 0; + 17e7: c7 05 50 1b 00 00 00 movl $0x0,0x1b50 + 17ee: 00 00 00 + 17f1: e9 46 ff ff ff jmp 173c + 17f6: 66 90 xchg %ax,%ax + 17f8: 66 90 xchg %ax,%ax + 17fa: 66 90 xchg %ax,%ax + 17fc: 66 90 xchg %ax,%ax + 17fe: 66 90 xchg %ax,%ax + +00001800 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1800: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1801: b9 01 00 00 00 mov $0x1,%ecx + 1806: 89 e5 mov %esp,%ebp + 1808: 8b 55 08 mov 0x8(%ebp),%edx + 180b: 90 nop + 180c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1810: 89 c8 mov %ecx,%eax + 1812: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1815: 85 c0 test %eax,%eax + 1817: 75 f7 jne 1810 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1819: 0f ae f0 mfence +} + 181c: 5d pop %ebp + 181d: c3 ret + 181e: 66 90 xchg %ax,%ax + +00001820 : + +void urelease (struct uspinlock *lk) { + 1820: 55 push %ebp + 1821: 89 e5 mov %esp,%ebp + 1823: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1826: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1829: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 182f: 5d pop %ebp + 1830: c3 ret diff --git a/init.d b/init.d new file mode 100644 index 00000000..ee304c8a --- /dev/null +++ b/init.d @@ -0,0 +1 @@ +init.o: init.c /usr/include/stdc-predef.h types.h stat.h user.h fcntl.h diff --git a/init.o b/init.o new file mode 100644 index 00000000..436e1c1e Binary files /dev/null and b/init.o differ diff --git a/init.sym b/init.sym new file mode 100644 index 00000000..13cf85e4 --- /dev/null +++ b/init.sym @@ -0,0 +1,64 @@ +00001000 .text +00001831 .rodata +0000189c .eh_frame +00001b40 .data +00001b48 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 init.c +00000000 ulib.c +00000000 printf.c +000013f0 printint +00001888 digits.1359 +00000000 umalloc.c +00001b48 freep +00001b4c base +00000000 uspinlock.c +00001110 strcpy +00001490 printf +00001b40 argv +00001300 memmove +0000137a mknod +000013d2 shm_open +00001220 gets +000013b2 getpid +00001710 malloc +000013c2 sleep +00001342 pipe +00001352 write +0000138a fstat +00001362 kill +000013a2 chdir +0000136a exec +0000133a wait +0000134a read +00001382 unlink +00001800 uacquire +0000132a fork +000013ba sbrk +000013da shm_close +000013ca uptime +00001b48 __bss_start +000011c0 memset +00001000 main +00001140 strcmp +000013aa dup +00001280 stat +00001b48 _edata +00001b54 _end +00001392 link +00001332 exit +000012d0 atoi +00001190 strlen +00001372 open +000011e0 strchr +0000139a mkdir +0000135a close +00001820 urelease +00001680 free diff --git a/initcode b/initcode new file mode 100755 index 00000000..773d26c2 Binary files /dev/null and b/initcode differ diff --git a/initcode.asm b/initcode.asm new file mode 100644 index 00000000..3d5dae29 --- /dev/null +++ b/initcode.asm @@ -0,0 +1,43 @@ + +initcode.o: file format elf32-i386 + + +Disassembly of section .text: + +00000000 : + + +# exec(init, argv) +.globl start +start: + pushl $argv + 0: 68 24 00 00 00 push $0x24 + pushl $init + 5: 68 1c 00 00 00 push $0x1c + pushl $0 // where caller pc would be + a: 6a 00 push $0x0 + movl $SYS_exec, %eax + c: b8 07 00 00 00 mov $0x7,%eax + int $T_SYSCALL + 11: cd 40 int $0x40 + +00000013 : + +# for(;;) exit(); +exit: + movl $SYS_exit, %eax + 13: b8 02 00 00 00 mov $0x2,%eax + int $T_SYSCALL + 18: cd 40 int $0x40 + jmp exit + 1a: eb f7 jmp 13 + +0000001c : + 1c: 2f das + 1d: 69 6e 69 74 00 00 90 imul $0x90000074,0x69(%esi),%ebp + +00000024 : + 24: 1c 00 sbb $0x0,%al + 26: 00 00 add %al,(%eax) + 28: 00 00 add %al,(%eax) + ... diff --git a/initcode.d b/initcode.d new file mode 100644 index 00000000..ab1af4d0 --- /dev/null +++ b/initcode.d @@ -0,0 +1 @@ +initcode.o: initcode.S syscall.h traps.h diff --git a/initcode.o b/initcode.o new file mode 100644 index 00000000..ce836bbc Binary files /dev/null and b/initcode.o differ diff --git a/initcode.out b/initcode.out new file mode 100755 index 00000000..c746f6a7 Binary files /dev/null and b/initcode.out differ diff --git a/ioapic.d b/ioapic.d new file mode 100644 index 00000000..997e68a6 --- /dev/null +++ b/ioapic.d @@ -0,0 +1 @@ +ioapic.o: ioapic.c /usr/include/stdc-predef.h types.h defs.h traps.h diff --git a/ioapic.o b/ioapic.o new file mode 100644 index 00000000..98a35b27 Binary files /dev/null and b/ioapic.o differ diff --git a/kalloc.d b/kalloc.d new file mode 100644 index 00000000..512c5db5 --- /dev/null +++ b/kalloc.d @@ -0,0 +1,2 @@ +kalloc.o: kalloc.c /usr/include/stdc-predef.h types.h defs.h param.h \ + memlayout.h mmu.h spinlock.h diff --git a/kalloc.o b/kalloc.o new file mode 100644 index 00000000..925a2b67 Binary files /dev/null and b/kalloc.o differ diff --git a/kbd.d b/kbd.d new file mode 100644 index 00000000..92532baa --- /dev/null +++ b/kbd.d @@ -0,0 +1 @@ +kbd.o: kbd.c /usr/include/stdc-predef.h types.h x86.h defs.h kbd.h diff --git a/kbd.o b/kbd.o new file mode 100644 index 00000000..d3782925 Binary files /dev/null and b/kbd.o differ diff --git a/kernel b/kernel new file mode 100755 index 00000000..c8a5af81 Binary files /dev/null and b/kernel differ diff --git a/kernel.asm b/kernel.asm new file mode 100644 index 00000000..e394dc13 --- /dev/null +++ b/kernel.asm @@ -0,0 +1,15020 @@ + +kernel: file format elf32-i386 + + +Disassembly of section .text: + +80100000 : +80100000: 02 b0 ad 1b 00 00 add 0x1bad(%eax),%dh +80100006: 00 00 add %al,(%eax) +80100008: fe 4f 52 decb 0x52(%edi) +8010000b: e4 .byte 0xe4 + +8010000c : + +# Entering xv6 on boot processor, with paging off. +.globl entry +entry: + # Turn on page size extension for 4Mbyte pages + movl %cr4, %eax +8010000c: 0f 20 e0 mov %cr4,%eax + orl $(CR4_PSE), %eax +8010000f: 83 c8 10 or $0x10,%eax + movl %eax, %cr4 +80100012: 0f 22 e0 mov %eax,%cr4 + # Set page directory + movl $(V2P_WO(entrypgdir)), %eax +80100015: b8 00 90 10 00 mov $0x109000,%eax + movl %eax, %cr3 +8010001a: 0f 22 d8 mov %eax,%cr3 + # Turn on paging. + movl %cr0, %eax +8010001d: 0f 20 c0 mov %cr0,%eax + orl $(CR0_PG|CR0_WP), %eax +80100020: 0d 00 00 01 80 or $0x80010000,%eax + movl %eax, %cr0 +80100025: 0f 22 c0 mov %eax,%cr0 + + # Set up the stack pointer. + movl $(stack + KSTACKSIZE), %esp +80100028: bc c0 b5 10 80 mov $0x8010b5c0,%esp + + # Jump to main(), and switch to executing at + # high addresses. The indirect call is needed because + # the assembler produces a PC-relative instruction + # for a direct jump. + mov $main, %eax +8010002d: b8 f0 2d 10 80 mov $0x80102df0,%eax + jmp *%eax +80100032: ff e0 jmp *%eax +80100034: 66 90 xchg %ax,%ax +80100036: 66 90 xchg %ax,%ax +80100038: 66 90 xchg %ax,%ax +8010003a: 66 90 xchg %ax,%ax +8010003c: 66 90 xchg %ax,%ax +8010003e: 66 90 xchg %ax,%ax + +80100040 : + struct buf head; +} bcache; + +void +binit(void) +{ +80100040: 55 push %ebp +80100041: 89 e5 mov %esp,%ebp +80100043: 53 push %ebx + +//PAGEBREAK! + // Create linked list of buffers + bcache.head.prev = &bcache.head; + bcache.head.next = &bcache.head; + for(b = bcache.buf; b < bcache.buf+NBUF; b++){ +80100044: bb f4 b5 10 80 mov $0x8010b5f4,%ebx +{ +80100049: 83 ec 14 sub $0x14,%esp + initlock(&bcache.lock, "bcache"); +8010004c: c7 44 24 04 20 6e 10 movl $0x80106e20,0x4(%esp) +80100053: 80 +80100054: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) +8010005b: e8 f0 3f 00 00 call 80104050 + bcache.head.next = &bcache.head; +80100060: ba bc fc 10 80 mov $0x8010fcbc,%edx + bcache.head.prev = &bcache.head; +80100065: c7 05 0c fd 10 80 bc movl $0x8010fcbc,0x8010fd0c +8010006c: fc 10 80 + bcache.head.next = &bcache.head; +8010006f: c7 05 10 fd 10 80 bc movl $0x8010fcbc,0x8010fd10 +80100076: fc 10 80 +80100079: eb 09 jmp 80100084 +8010007b: 90 nop +8010007c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80100080: 89 da mov %ebx,%edx + for(b = bcache.buf; b < bcache.buf+NBUF; b++){ +80100082: 89 c3 mov %eax,%ebx +80100084: 8d 43 0c lea 0xc(%ebx),%eax + b->next = bcache.head.next; +80100087: 89 53 54 mov %edx,0x54(%ebx) + b->prev = &bcache.head; +8010008a: c7 43 50 bc fc 10 80 movl $0x8010fcbc,0x50(%ebx) + initsleeplock(&b->lock, "buffer"); +80100091: 89 04 24 mov %eax,(%esp) +80100094: c7 44 24 04 27 6e 10 movl $0x80106e27,0x4(%esp) +8010009b: 80 +8010009c: e8 9f 3e 00 00 call 80103f40 + bcache.head.next->prev = b; +801000a1: a1 10 fd 10 80 mov 0x8010fd10,%eax +801000a6: 89 58 50 mov %ebx,0x50(%eax) + for(b = bcache.buf; b < bcache.buf+NBUF; b++){ +801000a9: 8d 83 5c 02 00 00 lea 0x25c(%ebx),%eax +801000af: 3d bc fc 10 80 cmp $0x8010fcbc,%eax + bcache.head.next = b; +801000b4: 89 1d 10 fd 10 80 mov %ebx,0x8010fd10 + for(b = bcache.buf; b < bcache.buf+NBUF; b++){ +801000ba: 75 c4 jne 80100080 + } +} +801000bc: 83 c4 14 add $0x14,%esp +801000bf: 5b pop %ebx +801000c0: 5d pop %ebp +801000c1: c3 ret +801000c2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801000c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +801000d0 : +} + +// Return a locked buf with the contents of the indicated block. +struct buf* +bread(uint dev, uint blockno) +{ +801000d0: 55 push %ebp +801000d1: 89 e5 mov %esp,%ebp +801000d3: 57 push %edi +801000d4: 56 push %esi +801000d5: 53 push %ebx +801000d6: 83 ec 1c sub $0x1c,%esp +801000d9: 8b 75 08 mov 0x8(%ebp),%esi + acquire(&bcache.lock); +801000dc: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) +{ +801000e3: 8b 7d 0c mov 0xc(%ebp),%edi + acquire(&bcache.lock); +801000e6: e8 55 40 00 00 call 80104140 + for(b = bcache.head.next; b != &bcache.head; b = b->next){ +801000eb: 8b 1d 10 fd 10 80 mov 0x8010fd10,%ebx +801000f1: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx +801000f7: 75 12 jne 8010010b +801000f9: eb 25 jmp 80100120 +801000fb: 90 nop +801000fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80100100: 8b 5b 54 mov 0x54(%ebx),%ebx +80100103: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx +80100109: 74 15 je 80100120 + if(b->dev == dev && b->blockno == blockno){ +8010010b: 3b 73 04 cmp 0x4(%ebx),%esi +8010010e: 75 f0 jne 80100100 +80100110: 3b 7b 08 cmp 0x8(%ebx),%edi +80100113: 75 eb jne 80100100 + b->refcnt++; +80100115: 83 43 4c 01 addl $0x1,0x4c(%ebx) +80100119: eb 3f jmp 8010015a +8010011b: 90 nop +8010011c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + for(b = bcache.head.prev; b != &bcache.head; b = b->prev){ +80100120: 8b 1d 0c fd 10 80 mov 0x8010fd0c,%ebx +80100126: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx +8010012c: 75 0d jne 8010013b +8010012e: eb 58 jmp 80100188 +80100130: 8b 5b 50 mov 0x50(%ebx),%ebx +80100133: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx +80100139: 74 4d je 80100188 + if(b->refcnt == 0 && (b->flags & B_DIRTY) == 0) { +8010013b: 8b 43 4c mov 0x4c(%ebx),%eax +8010013e: 85 c0 test %eax,%eax +80100140: 75 ee jne 80100130 +80100142: f6 03 04 testb $0x4,(%ebx) +80100145: 75 e9 jne 80100130 + b->dev = dev; +80100147: 89 73 04 mov %esi,0x4(%ebx) + b->blockno = blockno; +8010014a: 89 7b 08 mov %edi,0x8(%ebx) + b->flags = 0; +8010014d: c7 03 00 00 00 00 movl $0x0,(%ebx) + b->refcnt = 1; +80100153: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) + release(&bcache.lock); +8010015a: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) +80100161: e8 ca 40 00 00 call 80104230 + acquiresleep(&b->lock); +80100166: 8d 43 0c lea 0xc(%ebx),%eax +80100169: 89 04 24 mov %eax,(%esp) +8010016c: e8 0f 3e 00 00 call 80103f80 + struct buf *b; + + b = bget(dev, blockno); + if((b->flags & B_VALID) == 0) { +80100171: f6 03 02 testb $0x2,(%ebx) +80100174: 75 08 jne 8010017e + iderw(b); +80100176: 89 1c 24 mov %ebx,(%esp) +80100179: e8 a2 1f 00 00 call 80102120 + } + return b; +} +8010017e: 83 c4 1c add $0x1c,%esp +80100181: 89 d8 mov %ebx,%eax +80100183: 5b pop %ebx +80100184: 5e pop %esi +80100185: 5f pop %edi +80100186: 5d pop %ebp +80100187: c3 ret + panic("bget: no buffers"); +80100188: c7 04 24 2e 6e 10 80 movl $0x80106e2e,(%esp) +8010018f: e8 cc 01 00 00 call 80100360 +80100194: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +8010019a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +801001a0 : + +// Write b's contents to disk. Must be locked. +void +bwrite(struct buf *b) +{ +801001a0: 55 push %ebp +801001a1: 89 e5 mov %esp,%ebp +801001a3: 53 push %ebx +801001a4: 83 ec 14 sub $0x14,%esp +801001a7: 8b 5d 08 mov 0x8(%ebp),%ebx + if(!holdingsleep(&b->lock)) +801001aa: 8d 43 0c lea 0xc(%ebx),%eax +801001ad: 89 04 24 mov %eax,(%esp) +801001b0: e8 6b 3e 00 00 call 80104020 +801001b5: 85 c0 test %eax,%eax +801001b7: 74 10 je 801001c9 + panic("bwrite"); + b->flags |= B_DIRTY; +801001b9: 83 0b 04 orl $0x4,(%ebx) + iderw(b); +801001bc: 89 5d 08 mov %ebx,0x8(%ebp) +} +801001bf: 83 c4 14 add $0x14,%esp +801001c2: 5b pop %ebx +801001c3: 5d pop %ebp + iderw(b); +801001c4: e9 57 1f 00 00 jmp 80102120 + panic("bwrite"); +801001c9: c7 04 24 3f 6e 10 80 movl $0x80106e3f,(%esp) +801001d0: e8 8b 01 00 00 call 80100360 +801001d5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801001d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +801001e0 : + +// Release a locked buffer. +// Move to the head of the MRU list. +void +brelse(struct buf *b) +{ +801001e0: 55 push %ebp +801001e1: 89 e5 mov %esp,%ebp +801001e3: 56 push %esi +801001e4: 53 push %ebx +801001e5: 83 ec 10 sub $0x10,%esp +801001e8: 8b 5d 08 mov 0x8(%ebp),%ebx + if(!holdingsleep(&b->lock)) +801001eb: 8d 73 0c lea 0xc(%ebx),%esi +801001ee: 89 34 24 mov %esi,(%esp) +801001f1: e8 2a 3e 00 00 call 80104020 +801001f6: 85 c0 test %eax,%eax +801001f8: 74 5b je 80100255 + panic("brelse"); + + releasesleep(&b->lock); +801001fa: 89 34 24 mov %esi,(%esp) +801001fd: e8 de 3d 00 00 call 80103fe0 + + acquire(&bcache.lock); +80100202: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) +80100209: e8 32 3f 00 00 call 80104140 + b->refcnt--; + if (b->refcnt == 0) { +8010020e: 83 6b 4c 01 subl $0x1,0x4c(%ebx) +80100212: 75 2f jne 80100243 + // no one is waiting for it. + b->next->prev = b->prev; +80100214: 8b 43 54 mov 0x54(%ebx),%eax +80100217: 8b 53 50 mov 0x50(%ebx),%edx +8010021a: 89 50 50 mov %edx,0x50(%eax) + b->prev->next = b->next; +8010021d: 8b 43 50 mov 0x50(%ebx),%eax +80100220: 8b 53 54 mov 0x54(%ebx),%edx +80100223: 89 50 54 mov %edx,0x54(%eax) + b->next = bcache.head.next; +80100226: a1 10 fd 10 80 mov 0x8010fd10,%eax + b->prev = &bcache.head; +8010022b: c7 43 50 bc fc 10 80 movl $0x8010fcbc,0x50(%ebx) + b->next = bcache.head.next; +80100232: 89 43 54 mov %eax,0x54(%ebx) + bcache.head.next->prev = b; +80100235: a1 10 fd 10 80 mov 0x8010fd10,%eax +8010023a: 89 58 50 mov %ebx,0x50(%eax) + bcache.head.next = b; +8010023d: 89 1d 10 fd 10 80 mov %ebx,0x8010fd10 + } + + release(&bcache.lock); +80100243: c7 45 08 c0 b5 10 80 movl $0x8010b5c0,0x8(%ebp) +} +8010024a: 83 c4 10 add $0x10,%esp +8010024d: 5b pop %ebx +8010024e: 5e pop %esi +8010024f: 5d pop %ebp + release(&bcache.lock); +80100250: e9 db 3f 00 00 jmp 80104230 + panic("brelse"); +80100255: c7 04 24 46 6e 10 80 movl $0x80106e46,(%esp) +8010025c: e8 ff 00 00 00 call 80100360 +80100261: 66 90 xchg %ax,%ax +80100263: 66 90 xchg %ax,%ax +80100265: 66 90 xchg %ax,%ax +80100267: 66 90 xchg %ax,%ax +80100269: 66 90 xchg %ax,%ax +8010026b: 66 90 xchg %ax,%ax +8010026d: 66 90 xchg %ax,%ax +8010026f: 90 nop + +80100270 : + } +} + +int +consoleread(struct inode *ip, char *dst, int n) +{ +80100270: 55 push %ebp +80100271: 89 e5 mov %esp,%ebp +80100273: 57 push %edi +80100274: 56 push %esi +80100275: 53 push %ebx +80100276: 83 ec 1c sub $0x1c,%esp +80100279: 8b 7d 08 mov 0x8(%ebp),%edi +8010027c: 8b 75 0c mov 0xc(%ebp),%esi + uint target; + int c; + + iunlock(ip); +8010027f: 89 3c 24 mov %edi,(%esp) +80100282: e8 09 15 00 00 call 80101790 + target = n; + acquire(&cons.lock); +80100287: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) +8010028e: e8 ad 3e 00 00 call 80104140 + while(n > 0){ +80100293: 8b 55 10 mov 0x10(%ebp),%edx +80100296: 85 d2 test %edx,%edx +80100298: 0f 8e bc 00 00 00 jle 8010035a +8010029e: 8b 5d 10 mov 0x10(%ebp),%ebx +801002a1: eb 25 jmp 801002c8 +801002a3: 90 nop +801002a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while(input.r == input.w){ + if(myproc()->killed){ +801002a8: e8 f3 33 00 00 call 801036a0 +801002ad: 8b 40 24 mov 0x24(%eax),%eax +801002b0: 85 c0 test %eax,%eax +801002b2: 75 74 jne 80100328 + release(&cons.lock); + ilock(ip); + return -1; + } + sleep(&input.r, &cons.lock); +801002b4: c7 44 24 04 20 a5 10 movl $0x8010a520,0x4(%esp) +801002bb: 80 +801002bc: c7 04 24 a0 ff 10 80 movl $0x8010ffa0,(%esp) +801002c3: e8 38 39 00 00 call 80103c00 + while(input.r == input.w){ +801002c8: a1 a0 ff 10 80 mov 0x8010ffa0,%eax +801002cd: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax +801002d3: 74 d3 je 801002a8 + } + c = input.buf[input.r++ % INPUT_BUF]; +801002d5: 8d 50 01 lea 0x1(%eax),%edx +801002d8: 89 15 a0 ff 10 80 mov %edx,0x8010ffa0 +801002de: 89 c2 mov %eax,%edx +801002e0: 83 e2 7f and $0x7f,%edx +801002e3: 0f b6 8a 20 ff 10 80 movzbl -0x7fef00e0(%edx),%ecx +801002ea: 0f be d1 movsbl %cl,%edx + if(c == C('D')){ // EOF +801002ed: 83 fa 04 cmp $0x4,%edx +801002f0: 74 57 je 80100349 + // caller gets a 0-byte result. + input.r--; + } + break; + } + *dst++ = c; +801002f2: 83 c6 01 add $0x1,%esi + --n; +801002f5: 83 eb 01 sub $0x1,%ebx + if(c == '\n') +801002f8: 83 fa 0a cmp $0xa,%edx + *dst++ = c; +801002fb: 88 4e ff mov %cl,-0x1(%esi) + if(c == '\n') +801002fe: 74 53 je 80100353 + while(n > 0){ +80100300: 85 db test %ebx,%ebx +80100302: 75 c4 jne 801002c8 +80100304: 8b 45 10 mov 0x10(%ebp),%eax + break; + } + release(&cons.lock); +80100307: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) +8010030e: 89 45 e4 mov %eax,-0x1c(%ebp) +80100311: e8 1a 3f 00 00 call 80104230 + ilock(ip); +80100316: 89 3c 24 mov %edi,(%esp) +80100319: e8 92 13 00 00 call 801016b0 +8010031e: 8b 45 e4 mov -0x1c(%ebp),%eax + + return target - n; +80100321: eb 1e jmp 80100341 +80100323: 90 nop +80100324: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + release(&cons.lock); +80100328: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) +8010032f: e8 fc 3e 00 00 call 80104230 + ilock(ip); +80100334: 89 3c 24 mov %edi,(%esp) +80100337: e8 74 13 00 00 call 801016b0 + return -1; +8010033c: b8 ff ff ff ff mov $0xffffffff,%eax +} +80100341: 83 c4 1c add $0x1c,%esp +80100344: 5b pop %ebx +80100345: 5e pop %esi +80100346: 5f pop %edi +80100347: 5d pop %ebp +80100348: c3 ret + if(n < target){ +80100349: 39 5d 10 cmp %ebx,0x10(%ebp) +8010034c: 76 05 jbe 80100353 + input.r--; +8010034e: a3 a0 ff 10 80 mov %eax,0x8010ffa0 +80100353: 8b 45 10 mov 0x10(%ebp),%eax +80100356: 29 d8 sub %ebx,%eax +80100358: eb ad jmp 80100307 + while(n > 0){ +8010035a: 31 c0 xor %eax,%eax +8010035c: eb a9 jmp 80100307 +8010035e: 66 90 xchg %ax,%ax + +80100360 : +{ +80100360: 55 push %ebp +80100361: 89 e5 mov %esp,%ebp +80100363: 56 push %esi +80100364: 53 push %ebx +80100365: 83 ec 40 sub $0x40,%esp +} + +static inline void +cli(void) +{ + asm volatile("cli"); +80100368: fa cli + cons.locking = 0; +80100369: c7 05 54 a5 10 80 00 movl $0x0,0x8010a554 +80100370: 00 00 00 + getcallerpcs(&s, pcs); +80100373: 8d 5d d0 lea -0x30(%ebp),%ebx + cprintf("lapicid %d: panic: ", lapicid()); +80100376: e8 e5 23 00 00 call 80102760 +8010037b: 8d 75 f8 lea -0x8(%ebp),%esi +8010037e: c7 04 24 4d 6e 10 80 movl $0x80106e4d,(%esp) +80100385: 89 44 24 04 mov %eax,0x4(%esp) +80100389: e8 c2 02 00 00 call 80100650 + cprintf(s); +8010038e: 8b 45 08 mov 0x8(%ebp),%eax +80100391: 89 04 24 mov %eax,(%esp) +80100394: e8 b7 02 00 00 call 80100650 + cprintf("\n"); +80100399: c7 04 24 ed 75 10 80 movl $0x801075ed,(%esp) +801003a0: e8 ab 02 00 00 call 80100650 + getcallerpcs(&s, pcs); +801003a5: 8d 45 08 lea 0x8(%ebp),%eax +801003a8: 89 5c 24 04 mov %ebx,0x4(%esp) +801003ac: 89 04 24 mov %eax,(%esp) +801003af: e8 bc 3c 00 00 call 80104070 +801003b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + cprintf(" %p", pcs[i]); +801003b8: 8b 03 mov (%ebx),%eax +801003ba: 83 c3 04 add $0x4,%ebx +801003bd: c7 04 24 61 6e 10 80 movl $0x80106e61,(%esp) +801003c4: 89 44 24 04 mov %eax,0x4(%esp) +801003c8: e8 83 02 00 00 call 80100650 + for(i=0; i<10; i++) +801003cd: 39 f3 cmp %esi,%ebx +801003cf: 75 e7 jne 801003b8 + panicked = 1; // freeze other CPU +801003d1: c7 05 58 a5 10 80 01 movl $0x1,0x8010a558 +801003d8: 00 00 00 +801003db: eb fe jmp 801003db +801003dd: 8d 76 00 lea 0x0(%esi),%esi + +801003e0 : + if(panicked){ +801003e0: 8b 15 58 a5 10 80 mov 0x8010a558,%edx +801003e6: 85 d2 test %edx,%edx +801003e8: 74 06 je 801003f0 +801003ea: fa cli +801003eb: eb fe jmp 801003eb +801003ed: 8d 76 00 lea 0x0(%esi),%esi +{ +801003f0: 55 push %ebp +801003f1: 89 e5 mov %esp,%ebp +801003f3: 57 push %edi +801003f4: 56 push %esi +801003f5: 53 push %ebx +801003f6: 89 c3 mov %eax,%ebx +801003f8: 83 ec 1c sub $0x1c,%esp + if(c == BACKSPACE){ +801003fb: 3d 00 01 00 00 cmp $0x100,%eax +80100400: 0f 84 ac 00 00 00 je 801004b2 + uartputc(c); +80100406: 89 04 24 mov %eax,(%esp) +80100409: e8 32 54 00 00 call 80105840 + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +8010040e: bf d4 03 00 00 mov $0x3d4,%edi +80100413: b8 0e 00 00 00 mov $0xe,%eax +80100418: 89 fa mov %edi,%edx +8010041a: ee out %al,(%dx) + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +8010041b: be d5 03 00 00 mov $0x3d5,%esi +80100420: 89 f2 mov %esi,%edx +80100422: ec in (%dx),%al + pos = inb(CRTPORT+1) << 8; +80100423: 0f b6 c8 movzbl %al,%ecx + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +80100426: 89 fa mov %edi,%edx +80100428: c1 e1 08 shl $0x8,%ecx +8010042b: b8 0f 00 00 00 mov $0xf,%eax +80100430: ee out %al,(%dx) + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +80100431: 89 f2 mov %esi,%edx +80100433: ec in (%dx),%al + pos |= inb(CRTPORT+1); +80100434: 0f b6 c0 movzbl %al,%eax +80100437: 09 c1 or %eax,%ecx + if(c == '\n') +80100439: 83 fb 0a cmp $0xa,%ebx +8010043c: 0f 84 0d 01 00 00 je 8010054f + else if(c == BACKSPACE){ +80100442: 81 fb 00 01 00 00 cmp $0x100,%ebx +80100448: 0f 84 e8 00 00 00 je 80100536 + crt[pos++] = (c&0xff) | 0x0700; // black on white +8010044e: 0f b6 db movzbl %bl,%ebx +80100451: 80 cf 07 or $0x7,%bh +80100454: 8d 79 01 lea 0x1(%ecx),%edi +80100457: 66 89 9c 09 00 80 0b mov %bx,-0x7ff48000(%ecx,%ecx,1) +8010045e: 80 + if(pos < 0 || pos > 25*80) +8010045f: 81 ff d0 07 00 00 cmp $0x7d0,%edi +80100465: 0f 87 bf 00 00 00 ja 8010052a + if((pos/80) >= 24){ // Scroll up. +8010046b: 81 ff 7f 07 00 00 cmp $0x77f,%edi +80100471: 7f 68 jg 801004db +80100473: 89 f8 mov %edi,%eax +80100475: 89 fb mov %edi,%ebx +80100477: c1 e8 08 shr $0x8,%eax +8010047a: 89 c6 mov %eax,%esi +8010047c: 8d 8c 3f 00 80 0b 80 lea -0x7ff48000(%edi,%edi,1),%ecx + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +80100483: bf d4 03 00 00 mov $0x3d4,%edi +80100488: b8 0e 00 00 00 mov $0xe,%eax +8010048d: 89 fa mov %edi,%edx +8010048f: ee out %al,(%dx) +80100490: 89 f0 mov %esi,%eax +80100492: b2 d5 mov $0xd5,%dl +80100494: ee out %al,(%dx) +80100495: b8 0f 00 00 00 mov $0xf,%eax +8010049a: 89 fa mov %edi,%edx +8010049c: ee out %al,(%dx) +8010049d: 89 d8 mov %ebx,%eax +8010049f: b2 d5 mov $0xd5,%dl +801004a1: ee out %al,(%dx) + crt[pos] = ' ' | 0x0700; +801004a2: b8 20 07 00 00 mov $0x720,%eax +801004a7: 66 89 01 mov %ax,(%ecx) +} +801004aa: 83 c4 1c add $0x1c,%esp +801004ad: 5b pop %ebx +801004ae: 5e pop %esi +801004af: 5f pop %edi +801004b0: 5d pop %ebp +801004b1: c3 ret + uartputc('\b'); uartputc(' '); uartputc('\b'); +801004b2: c7 04 24 08 00 00 00 movl $0x8,(%esp) +801004b9: e8 82 53 00 00 call 80105840 +801004be: c7 04 24 20 00 00 00 movl $0x20,(%esp) +801004c5: e8 76 53 00 00 call 80105840 +801004ca: c7 04 24 08 00 00 00 movl $0x8,(%esp) +801004d1: e8 6a 53 00 00 call 80105840 +801004d6: e9 33 ff ff ff jmp 8010040e + memmove(crt, crt+80, sizeof(crt[0])*23*80); +801004db: c7 44 24 08 60 0e 00 movl $0xe60,0x8(%esp) +801004e2: 00 + pos -= 80; +801004e3: 8d 5f b0 lea -0x50(%edi),%ebx + memmove(crt, crt+80, sizeof(crt[0])*23*80); +801004e6: c7 44 24 04 a0 80 0b movl $0x800b80a0,0x4(%esp) +801004ed: 80 + memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); +801004ee: 8d b4 1b 00 80 0b 80 lea -0x7ff48000(%ebx,%ebx,1),%esi + memmove(crt, crt+80, sizeof(crt[0])*23*80); +801004f5: c7 04 24 00 80 0b 80 movl $0x800b8000,(%esp) +801004fc: e8 1f 3e 00 00 call 80104320 + memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); +80100501: b8 d0 07 00 00 mov $0x7d0,%eax +80100506: 29 f8 sub %edi,%eax +80100508: 01 c0 add %eax,%eax +8010050a: 89 34 24 mov %esi,(%esp) +8010050d: 89 44 24 08 mov %eax,0x8(%esp) +80100511: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +80100518: 00 +80100519: e8 62 3d 00 00 call 80104280 +8010051e: 89 f1 mov %esi,%ecx +80100520: be 07 00 00 00 mov $0x7,%esi +80100525: e9 59 ff ff ff jmp 80100483 + panic("pos under/overflow"); +8010052a: c7 04 24 65 6e 10 80 movl $0x80106e65,(%esp) +80100531: e8 2a fe ff ff call 80100360 + if(pos > 0) --pos; +80100536: 85 c9 test %ecx,%ecx +80100538: 8d 79 ff lea -0x1(%ecx),%edi +8010053b: 0f 85 1e ff ff ff jne 8010045f +80100541: b9 00 80 0b 80 mov $0x800b8000,%ecx +80100546: 31 db xor %ebx,%ebx +80100548: 31 f6 xor %esi,%esi +8010054a: e9 34 ff ff ff jmp 80100483 + pos += 80 - pos%80; +8010054f: 89 c8 mov %ecx,%eax +80100551: ba 67 66 66 66 mov $0x66666667,%edx +80100556: f7 ea imul %edx +80100558: c1 ea 05 shr $0x5,%edx +8010055b: 8d 04 92 lea (%edx,%edx,4),%eax +8010055e: c1 e0 04 shl $0x4,%eax +80100561: 8d 78 50 lea 0x50(%eax),%edi +80100564: e9 f6 fe ff ff jmp 8010045f +80100569: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80100570 : +{ +80100570: 55 push %ebp +80100571: 89 e5 mov %esp,%ebp +80100573: 57 push %edi +80100574: 56 push %esi +80100575: 89 d6 mov %edx,%esi +80100577: 53 push %ebx +80100578: 83 ec 1c sub $0x1c,%esp + if(sign && (sign = xx < 0)) +8010057b: 85 c9 test %ecx,%ecx +8010057d: 74 61 je 801005e0 +8010057f: 85 c0 test %eax,%eax +80100581: 79 5d jns 801005e0 + x = -xx; +80100583: f7 d8 neg %eax +80100585: bf 01 00 00 00 mov $0x1,%edi + i = 0; +8010058a: 31 c9 xor %ecx,%ecx +8010058c: eb 04 jmp 80100592 +8010058e: 66 90 xchg %ax,%ax + buf[i++] = digits[x % base]; +80100590: 89 d9 mov %ebx,%ecx +80100592: 31 d2 xor %edx,%edx +80100594: f7 f6 div %esi +80100596: 8d 59 01 lea 0x1(%ecx),%ebx +80100599: 0f b6 92 90 6e 10 80 movzbl -0x7fef9170(%edx),%edx + }while((x /= base) != 0); +801005a0: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; +801005a2: 88 54 1d d7 mov %dl,-0x29(%ebp,%ebx,1) + }while((x /= base) != 0); +801005a6: 75 e8 jne 80100590 + if(sign) +801005a8: 85 ff test %edi,%edi + buf[i++] = digits[x % base]; +801005aa: 89 d8 mov %ebx,%eax + if(sign) +801005ac: 74 08 je 801005b6 + buf[i++] = '-'; +801005ae: 8d 59 02 lea 0x2(%ecx),%ebx +801005b1: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + while(--i >= 0) +801005b6: 83 eb 01 sub $0x1,%ebx +801005b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + consputc(buf[i]); +801005c0: 0f be 44 1d d8 movsbl -0x28(%ebp,%ebx,1),%eax + while(--i >= 0) +801005c5: 83 eb 01 sub $0x1,%ebx + consputc(buf[i]); +801005c8: e8 13 fe ff ff call 801003e0 + while(--i >= 0) +801005cd: 83 fb ff cmp $0xffffffff,%ebx +801005d0: 75 ee jne 801005c0 +} +801005d2: 83 c4 1c add $0x1c,%esp +801005d5: 5b pop %ebx +801005d6: 5e pop %esi +801005d7: 5f pop %edi +801005d8: 5d pop %ebp +801005d9: c3 ret +801005da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + x = xx; +801005e0: 31 ff xor %edi,%edi +801005e2: eb a6 jmp 8010058a +801005e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +801005ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +801005f0 : + +int +consolewrite(struct inode *ip, char *buf, int n) +{ +801005f0: 55 push %ebp +801005f1: 89 e5 mov %esp,%ebp +801005f3: 57 push %edi +801005f4: 56 push %esi +801005f5: 53 push %ebx +801005f6: 83 ec 1c sub $0x1c,%esp + int i; + + iunlock(ip); +801005f9: 8b 45 08 mov 0x8(%ebp),%eax +{ +801005fc: 8b 75 10 mov 0x10(%ebp),%esi + iunlock(ip); +801005ff: 89 04 24 mov %eax,(%esp) +80100602: e8 89 11 00 00 call 80101790 + acquire(&cons.lock); +80100607: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) +8010060e: e8 2d 3b 00 00 call 80104140 +80100613: 8b 7d 0c mov 0xc(%ebp),%edi + for(i = 0; i < n; i++) +80100616: 85 f6 test %esi,%esi +80100618: 8d 1c 37 lea (%edi,%esi,1),%ebx +8010061b: 7e 12 jle 8010062f +8010061d: 8d 76 00 lea 0x0(%esi),%esi + consputc(buf[i] & 0xff); +80100620: 0f b6 07 movzbl (%edi),%eax +80100623: 83 c7 01 add $0x1,%edi +80100626: e8 b5 fd ff ff call 801003e0 + for(i = 0; i < n; i++) +8010062b: 39 df cmp %ebx,%edi +8010062d: 75 f1 jne 80100620 + release(&cons.lock); +8010062f: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) +80100636: e8 f5 3b 00 00 call 80104230 + ilock(ip); +8010063b: 8b 45 08 mov 0x8(%ebp),%eax +8010063e: 89 04 24 mov %eax,(%esp) +80100641: e8 6a 10 00 00 call 801016b0 + + return n; +} +80100646: 83 c4 1c add $0x1c,%esp +80100649: 89 f0 mov %esi,%eax +8010064b: 5b pop %ebx +8010064c: 5e pop %esi +8010064d: 5f pop %edi +8010064e: 5d pop %ebp +8010064f: c3 ret + +80100650 : +{ +80100650: 55 push %ebp +80100651: 89 e5 mov %esp,%ebp +80100653: 57 push %edi +80100654: 56 push %esi +80100655: 53 push %ebx +80100656: 83 ec 1c sub $0x1c,%esp + locking = cons.locking; +80100659: a1 54 a5 10 80 mov 0x8010a554,%eax + if(locking) +8010065e: 85 c0 test %eax,%eax + locking = cons.locking; +80100660: 89 45 e0 mov %eax,-0x20(%ebp) + if(locking) +80100663: 0f 85 27 01 00 00 jne 80100790 + if (fmt == 0) +80100669: 8b 45 08 mov 0x8(%ebp),%eax +8010066c: 85 c0 test %eax,%eax +8010066e: 89 c1 mov %eax,%ecx +80100670: 0f 84 2b 01 00 00 je 801007a1 + for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ +80100676: 0f b6 00 movzbl (%eax),%eax +80100679: 31 db xor %ebx,%ebx +8010067b: 89 cf mov %ecx,%edi +8010067d: 8d 75 0c lea 0xc(%ebp),%esi +80100680: 85 c0 test %eax,%eax +80100682: 75 4c jne 801006d0 +80100684: eb 5f jmp 801006e5 +80100686: 66 90 xchg %ax,%ax + c = fmt[++i] & 0xff; +80100688: 83 c3 01 add $0x1,%ebx +8010068b: 0f b6 14 1f movzbl (%edi,%ebx,1),%edx + if(c == 0) +8010068f: 85 d2 test %edx,%edx +80100691: 74 52 je 801006e5 + switch(c){ +80100693: 83 fa 70 cmp $0x70,%edx +80100696: 74 72 je 8010070a +80100698: 7f 66 jg 80100700 +8010069a: 83 fa 25 cmp $0x25,%edx +8010069d: 8d 76 00 lea 0x0(%esi),%esi +801006a0: 0f 84 a2 00 00 00 je 80100748 +801006a6: 83 fa 64 cmp $0x64,%edx +801006a9: 75 7d jne 80100728 + printint(*argp++, 10, 1); +801006ab: 8d 46 04 lea 0x4(%esi),%eax +801006ae: b9 01 00 00 00 mov $0x1,%ecx +801006b3: 89 45 e4 mov %eax,-0x1c(%ebp) +801006b6: 8b 06 mov (%esi),%eax +801006b8: ba 0a 00 00 00 mov $0xa,%edx +801006bd: e8 ae fe ff ff call 80100570 +801006c2: 8b 75 e4 mov -0x1c(%ebp),%esi + for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ +801006c5: 83 c3 01 add $0x1,%ebx +801006c8: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax +801006cc: 85 c0 test %eax,%eax +801006ce: 74 15 je 801006e5 + if(c != '%'){ +801006d0: 83 f8 25 cmp $0x25,%eax +801006d3: 74 b3 je 80100688 + consputc(c); +801006d5: e8 06 fd ff ff call 801003e0 + for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ +801006da: 83 c3 01 add $0x1,%ebx +801006dd: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax +801006e1: 85 c0 test %eax,%eax +801006e3: 75 eb jne 801006d0 + if(locking) +801006e5: 8b 45 e0 mov -0x20(%ebp),%eax +801006e8: 85 c0 test %eax,%eax +801006ea: 74 0c je 801006f8 + release(&cons.lock); +801006ec: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) +801006f3: e8 38 3b 00 00 call 80104230 +} +801006f8: 83 c4 1c add $0x1c,%esp +801006fb: 5b pop %ebx +801006fc: 5e pop %esi +801006fd: 5f pop %edi +801006fe: 5d pop %ebp +801006ff: c3 ret + switch(c){ +80100700: 83 fa 73 cmp $0x73,%edx +80100703: 74 53 je 80100758 +80100705: 83 fa 78 cmp $0x78,%edx +80100708: 75 1e jne 80100728 + printint(*argp++, 16, 0); +8010070a: 8d 46 04 lea 0x4(%esi),%eax +8010070d: 31 c9 xor %ecx,%ecx +8010070f: 89 45 e4 mov %eax,-0x1c(%ebp) +80100712: 8b 06 mov (%esi),%eax +80100714: ba 10 00 00 00 mov $0x10,%edx +80100719: e8 52 fe ff ff call 80100570 +8010071e: 8b 75 e4 mov -0x1c(%ebp),%esi + break; +80100721: eb a2 jmp 801006c5 +80100723: 90 nop +80100724: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + consputc('%'); +80100728: b8 25 00 00 00 mov $0x25,%eax +8010072d: 89 55 e4 mov %edx,-0x1c(%ebp) +80100730: e8 ab fc ff ff call 801003e0 + consputc(c); +80100735: 8b 55 e4 mov -0x1c(%ebp),%edx +80100738: 89 d0 mov %edx,%eax +8010073a: e8 a1 fc ff ff call 801003e0 +8010073f: eb 99 jmp 801006da +80100741: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + consputc('%'); +80100748: b8 25 00 00 00 mov $0x25,%eax +8010074d: e8 8e fc ff ff call 801003e0 + break; +80100752: e9 6e ff ff ff jmp 801006c5 +80100757: 90 nop + if((s = (char*)*argp++) == 0) +80100758: 8d 46 04 lea 0x4(%esi),%eax +8010075b: 8b 36 mov (%esi),%esi +8010075d: 89 45 e4 mov %eax,-0x1c(%ebp) + s = "(null)"; +80100760: b8 78 6e 10 80 mov $0x80106e78,%eax +80100765: 85 f6 test %esi,%esi +80100767: 0f 44 f0 cmove %eax,%esi + for(; *s; s++) +8010076a: 0f be 06 movsbl (%esi),%eax +8010076d: 84 c0 test %al,%al +8010076f: 74 16 je 80100787 +80100771: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80100778: 83 c6 01 add $0x1,%esi + consputc(*s); +8010077b: e8 60 fc ff ff call 801003e0 + for(; *s; s++) +80100780: 0f be 06 movsbl (%esi),%eax +80100783: 84 c0 test %al,%al +80100785: 75 f1 jne 80100778 + if((s = (char*)*argp++) == 0) +80100787: 8b 75 e4 mov -0x1c(%ebp),%esi +8010078a: e9 36 ff ff ff jmp 801006c5 +8010078f: 90 nop + acquire(&cons.lock); +80100790: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) +80100797: e8 a4 39 00 00 call 80104140 +8010079c: e9 c8 fe ff ff jmp 80100669 + panic("null fmt"); +801007a1: c7 04 24 7f 6e 10 80 movl $0x80106e7f,(%esp) +801007a8: e8 b3 fb ff ff call 80100360 +801007ad: 8d 76 00 lea 0x0(%esi),%esi + +801007b0 : +{ +801007b0: 55 push %ebp +801007b1: 89 e5 mov %esp,%ebp +801007b3: 57 push %edi +801007b4: 56 push %esi + int c, doprocdump = 0; +801007b5: 31 f6 xor %esi,%esi +{ +801007b7: 53 push %ebx +801007b8: 83 ec 1c sub $0x1c,%esp +801007bb: 8b 5d 08 mov 0x8(%ebp),%ebx + acquire(&cons.lock); +801007be: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) +801007c5: e8 76 39 00 00 call 80104140 +801007ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + while((c = getc()) >= 0){ +801007d0: ff d3 call *%ebx +801007d2: 85 c0 test %eax,%eax +801007d4: 89 c7 mov %eax,%edi +801007d6: 78 48 js 80100820 + switch(c){ +801007d8: 83 ff 10 cmp $0x10,%edi +801007db: 0f 84 2f 01 00 00 je 80100910 +801007e1: 7e 5d jle 80100840 +801007e3: 83 ff 15 cmp $0x15,%edi +801007e6: 0f 84 d4 00 00 00 je 801008c0 +801007ec: 83 ff 7f cmp $0x7f,%edi +801007ef: 90 nop +801007f0: 75 53 jne 80100845 + if(input.e != input.w){ +801007f2: a1 a8 ff 10 80 mov 0x8010ffa8,%eax +801007f7: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax +801007fd: 74 d1 je 801007d0 + input.e--; +801007ff: 83 e8 01 sub $0x1,%eax +80100802: a3 a8 ff 10 80 mov %eax,0x8010ffa8 + consputc(BACKSPACE); +80100807: b8 00 01 00 00 mov $0x100,%eax +8010080c: e8 cf fb ff ff call 801003e0 + while((c = getc()) >= 0){ +80100811: ff d3 call *%ebx +80100813: 85 c0 test %eax,%eax +80100815: 89 c7 mov %eax,%edi +80100817: 79 bf jns 801007d8 +80100819: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + release(&cons.lock); +80100820: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) +80100827: e8 04 3a 00 00 call 80104230 + if(doprocdump) { +8010082c: 85 f6 test %esi,%esi +8010082e: 0f 85 ec 00 00 00 jne 80100920 +} +80100834: 83 c4 1c add $0x1c,%esp +80100837: 5b pop %ebx +80100838: 5e pop %esi +80100839: 5f pop %edi +8010083a: 5d pop %ebp +8010083b: c3 ret +8010083c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + switch(c){ +80100840: 83 ff 08 cmp $0x8,%edi +80100843: 74 ad je 801007f2 + if(c != 0 && input.e-input.r < INPUT_BUF){ +80100845: 85 ff test %edi,%edi +80100847: 74 87 je 801007d0 +80100849: a1 a8 ff 10 80 mov 0x8010ffa8,%eax +8010084e: 89 c2 mov %eax,%edx +80100850: 2b 15 a0 ff 10 80 sub 0x8010ffa0,%edx +80100856: 83 fa 7f cmp $0x7f,%edx +80100859: 0f 87 71 ff ff ff ja 801007d0 + input.buf[input.e++ % INPUT_BUF] = c; +8010085f: 8d 50 01 lea 0x1(%eax),%edx +80100862: 83 e0 7f and $0x7f,%eax + c = (c == '\r') ? '\n' : c; +80100865: 83 ff 0d cmp $0xd,%edi + input.buf[input.e++ % INPUT_BUF] = c; +80100868: 89 15 a8 ff 10 80 mov %edx,0x8010ffa8 + c = (c == '\r') ? '\n' : c; +8010086e: 0f 84 b8 00 00 00 je 8010092c + input.buf[input.e++ % INPUT_BUF] = c; +80100874: 89 f9 mov %edi,%ecx +80100876: 88 88 20 ff 10 80 mov %cl,-0x7fef00e0(%eax) + consputc(c); +8010087c: 89 f8 mov %edi,%eax +8010087e: e8 5d fb ff ff call 801003e0 + if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){ +80100883: 83 ff 04 cmp $0x4,%edi +80100886: a1 a8 ff 10 80 mov 0x8010ffa8,%eax +8010088b: 74 19 je 801008a6 +8010088d: 83 ff 0a cmp $0xa,%edi +80100890: 74 14 je 801008a6 +80100892: 8b 0d a0 ff 10 80 mov 0x8010ffa0,%ecx +80100898: 8d 91 80 00 00 00 lea 0x80(%ecx),%edx +8010089e: 39 d0 cmp %edx,%eax +801008a0: 0f 85 2a ff ff ff jne 801007d0 + wakeup(&input.r); +801008a6: c7 04 24 a0 ff 10 80 movl $0x8010ffa0,(%esp) + input.w = input.e; +801008ad: a3 a4 ff 10 80 mov %eax,0x8010ffa4 + wakeup(&input.r); +801008b2: e8 d9 34 00 00 call 80103d90 +801008b7: e9 14 ff ff ff jmp 801007d0 +801008bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while(input.e != input.w && +801008c0: a1 a8 ff 10 80 mov 0x8010ffa8,%eax +801008c5: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax +801008cb: 75 2b jne 801008f8 +801008cd: e9 fe fe ff ff jmp 801007d0 +801008d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + input.e--; +801008d8: a3 a8 ff 10 80 mov %eax,0x8010ffa8 + consputc(BACKSPACE); +801008dd: b8 00 01 00 00 mov $0x100,%eax +801008e2: e8 f9 fa ff ff call 801003e0 + while(input.e != input.w && +801008e7: a1 a8 ff 10 80 mov 0x8010ffa8,%eax +801008ec: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax +801008f2: 0f 84 d8 fe ff ff je 801007d0 + input.buf[(input.e-1) % INPUT_BUF] != '\n'){ +801008f8: 83 e8 01 sub $0x1,%eax +801008fb: 89 c2 mov %eax,%edx +801008fd: 83 e2 7f and $0x7f,%edx + while(input.e != input.w && +80100900: 80 ba 20 ff 10 80 0a cmpb $0xa,-0x7fef00e0(%edx) +80100907: 75 cf jne 801008d8 +80100909: e9 c2 fe ff ff jmp 801007d0 +8010090e: 66 90 xchg %ax,%ax + doprocdump = 1; +80100910: be 01 00 00 00 mov $0x1,%esi +80100915: e9 b6 fe ff ff jmp 801007d0 +8010091a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +} +80100920: 83 c4 1c add $0x1c,%esp +80100923: 5b pop %ebx +80100924: 5e pop %esi +80100925: 5f pop %edi +80100926: 5d pop %ebp + procdump(); // now call procdump() wo. cons.lock held +80100927: e9 44 35 00 00 jmp 80103e70 + input.buf[input.e++ % INPUT_BUF] = c; +8010092c: c6 80 20 ff 10 80 0a movb $0xa,-0x7fef00e0(%eax) + consputc(c); +80100933: b8 0a 00 00 00 mov $0xa,%eax +80100938: e8 a3 fa ff ff call 801003e0 +8010093d: a1 a8 ff 10 80 mov 0x8010ffa8,%eax +80100942: e9 5f ff ff ff jmp 801008a6 +80100947: 89 f6 mov %esi,%esi +80100949: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80100950 : + +void +consoleinit(void) +{ +80100950: 55 push %ebp +80100951: 89 e5 mov %esp,%ebp +80100953: 83 ec 18 sub $0x18,%esp + initlock(&cons.lock, "console"); +80100956: c7 44 24 04 88 6e 10 movl $0x80106e88,0x4(%esp) +8010095d: 80 +8010095e: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) +80100965: e8 e6 36 00 00 call 80104050 + + devsw[CONSOLE].write = consolewrite; + devsw[CONSOLE].read = consoleread; + cons.locking = 1; + + ioapicenable(IRQ_KBD, 0); +8010096a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +80100971: 00 +80100972: c7 04 24 01 00 00 00 movl $0x1,(%esp) + devsw[CONSOLE].write = consolewrite; +80100979: c7 05 6c 09 11 80 f0 movl $0x801005f0,0x8011096c +80100980: 05 10 80 + devsw[CONSOLE].read = consoleread; +80100983: c7 05 68 09 11 80 70 movl $0x80100270,0x80110968 +8010098a: 02 10 80 + cons.locking = 1; +8010098d: c7 05 54 a5 10 80 01 movl $0x1,0x8010a554 +80100994: 00 00 00 + ioapicenable(IRQ_KBD, 0); +80100997: e8 14 19 00 00 call 801022b0 +} +8010099c: c9 leave +8010099d: c3 ret +8010099e: 66 90 xchg %ax,%ax + +801009a0 : +#include "x86.h" +#include "elf.h" + +int +exec(char *path, char **argv) +{ +801009a0: 55 push %ebp +801009a1: 89 e5 mov %esp,%ebp +801009a3: 57 push %edi +801009a4: 56 push %esi +801009a5: 53 push %ebx +801009a6: 81 ec 2c 01 00 00 sub $0x12c,%esp + uint argc, sz, sp, ustack[3+MAXARG+1]; + struct elfhdr elf; + struct inode *ip; + struct proghdr ph; + pde_t *pgdir, *oldpgdir; + struct proc *curproc = myproc(); +801009ac: e8 ef 2c 00 00 call 801036a0 +801009b1: 89 85 f4 fe ff ff mov %eax,-0x10c(%ebp) + + begin_op(); +801009b7: e8 54 21 00 00 call 80102b10 + + if((ip = namei(path)) == 0){ +801009bc: 8b 45 08 mov 0x8(%ebp),%eax +801009bf: 89 04 24 mov %eax,(%esp) +801009c2: e8 39 15 00 00 call 80101f00 +801009c7: 85 c0 test %eax,%eax +801009c9: 89 c3 mov %eax,%ebx +801009cb: 0f 84 bd 01 00 00 je 80100b8e + end_op(); + cprintf("exec: fail\n"); + return -1; + } + ilock(ip); +801009d1: 89 04 24 mov %eax,(%esp) +801009d4: e8 d7 0c 00 00 call 801016b0 + pgdir = 0; + + // Check ELF header + if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf)) +801009d9: 8d 85 24 ff ff ff lea -0xdc(%ebp),%eax +801009df: c7 44 24 0c 34 00 00 movl $0x34,0xc(%esp) +801009e6: 00 +801009e7: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +801009ee: 00 +801009ef: 89 44 24 04 mov %eax,0x4(%esp) +801009f3: 89 1c 24 mov %ebx,(%esp) +801009f6: e8 65 0f 00 00 call 80101960 +801009fb: 83 f8 34 cmp $0x34,%eax +801009fe: 74 20 je 80100a20 + + bad: + if(pgdir) + freevm(pgdir); + if(ip){ + iunlockput(ip); +80100a00: 89 1c 24 mov %ebx,(%esp) +80100a03: e8 08 0f 00 00 call 80101910 + end_op(); +80100a08: e8 73 21 00 00 call 80102b80 + } + return -1; +80100a0d: b8 ff ff ff ff mov $0xffffffff,%eax +} +80100a12: 81 c4 2c 01 00 00 add $0x12c,%esp +80100a18: 5b pop %ebx +80100a19: 5e pop %esi +80100a1a: 5f pop %edi +80100a1b: 5d pop %ebp +80100a1c: c3 ret +80100a1d: 8d 76 00 lea 0x0(%esi),%esi + if(elf.magic != ELF_MAGIC) +80100a20: 81 bd 24 ff ff ff 7f cmpl $0x464c457f,-0xdc(%ebp) +80100a27: 45 4c 46 +80100a2a: 75 d4 jne 80100a00 + if((pgdir = setupkvm()) == 0) +80100a2c: e8 1f 60 00 00 call 80106a50 +80100a31: 85 c0 test %eax,%eax +80100a33: 89 85 f0 fe ff ff mov %eax,-0x110(%ebp) +80100a39: 74 c5 je 80100a00 + for(i=0, off=elf.phoff; i +80100a59: 31 ff xor %edi,%edi +80100a5b: eb 18 jmp 80100a75 +80100a5d: 8d 76 00 lea 0x0(%esi),%esi +80100a60: 0f b7 85 50 ff ff ff movzwl -0xb0(%ebp),%eax +80100a67: 83 c7 01 add $0x1,%edi +80100a6a: 83 c6 20 add $0x20,%esi +80100a6d: 39 f8 cmp %edi,%eax +80100a6f: 0f 8e be 00 00 00 jle 80100b33 + if(readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph)) +80100a75: 8d 85 04 ff ff ff lea -0xfc(%ebp),%eax +80100a7b: c7 44 24 0c 20 00 00 movl $0x20,0xc(%esp) +80100a82: 00 +80100a83: 89 74 24 08 mov %esi,0x8(%esp) +80100a87: 89 44 24 04 mov %eax,0x4(%esp) +80100a8b: 89 1c 24 mov %ebx,(%esp) +80100a8e: e8 cd 0e 00 00 call 80101960 +80100a93: 83 f8 20 cmp $0x20,%eax +80100a96: 0f 85 84 00 00 00 jne 80100b20 + if(ph.type != ELF_PROG_LOAD) +80100a9c: 83 bd 04 ff ff ff 01 cmpl $0x1,-0xfc(%ebp) +80100aa3: 75 bb jne 80100a60 + if(ph.memsz < ph.filesz) +80100aa5: 8b 85 18 ff ff ff mov -0xe8(%ebp),%eax +80100aab: 3b 85 14 ff ff ff cmp -0xec(%ebp),%eax +80100ab1: 72 6d jb 80100b20 + if(ph.vaddr + ph.memsz < ph.vaddr) +80100ab3: 03 85 0c ff ff ff add -0xf4(%ebp),%eax +80100ab9: 72 65 jb 80100b20 + if((sz = allocuvm(pgdir, sz, ph.vaddr + ph.memsz)) == 0) +80100abb: 89 44 24 08 mov %eax,0x8(%esp) +80100abf: 8b 85 ec fe ff ff mov -0x114(%ebp),%eax +80100ac5: 89 44 24 04 mov %eax,0x4(%esp) +80100ac9: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax +80100acf: 89 04 24 mov %eax,(%esp) +80100ad2: e8 c9 5d 00 00 call 801068a0 +80100ad7: 85 c0 test %eax,%eax +80100ad9: 89 85 ec fe ff ff mov %eax,-0x114(%ebp) +80100adf: 74 3f je 80100b20 + if(ph.vaddr % PGSIZE != 0) +80100ae1: 8b 85 0c ff ff ff mov -0xf4(%ebp),%eax +80100ae7: a9 ff 0f 00 00 test $0xfff,%eax +80100aec: 75 32 jne 80100b20 + if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) +80100aee: 8b 95 14 ff ff ff mov -0xec(%ebp),%edx +80100af4: 89 44 24 04 mov %eax,0x4(%esp) +80100af8: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax +80100afe: 89 5c 24 08 mov %ebx,0x8(%esp) +80100b02: 89 54 24 10 mov %edx,0x10(%esp) +80100b06: 8b 95 08 ff ff ff mov -0xf8(%ebp),%edx +80100b0c: 89 04 24 mov %eax,(%esp) +80100b0f: 89 54 24 0c mov %edx,0xc(%esp) +80100b13: e8 c8 5c 00 00 call 801067e0 +80100b18: 85 c0 test %eax,%eax +80100b1a: 0f 89 40 ff ff ff jns 80100a60 + freevm(pgdir); +80100b20: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax +80100b26: 89 04 24 mov %eax,(%esp) +80100b29: e8 a2 5e 00 00 call 801069d0 +80100b2e: e9 cd fe ff ff jmp 80100a00 + iunlockput(ip); +80100b33: 89 1c 24 mov %ebx,(%esp) +80100b36: e8 d5 0d 00 00 call 80101910 +80100b3b: 90 nop +80100b3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + end_op(); +80100b40: e8 3b 20 00 00 call 80102b80 + curproc->num_pages = 1; +80100b45: 8b 85 f4 fe ff ff mov -0x10c(%ebp),%eax +80100b4b: c7 40 7c 01 00 00 00 movl $0x1,0x7c(%eax) + if((sp = allocuvm(pgdir, top, KERNBASE)) == 0) +80100b52: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax +80100b58: c7 44 24 08 00 00 00 movl $0x80000000,0x8(%esp) +80100b5f: 80 +80100b60: c7 44 24 04 00 e0 ff movl $0x7fffe000,0x4(%esp) +80100b67: 7f +80100b68: 89 04 24 mov %eax,(%esp) +80100b6b: e8 30 5d 00 00 call 801068a0 +80100b70: 85 c0 test %eax,%eax +80100b72: 89 c3 mov %eax,%ebx +80100b74: 75 33 jne 80100ba9 + freevm(pgdir); +80100b76: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax +80100b7c: 89 04 24 mov %eax,(%esp) +80100b7f: e8 4c 5e 00 00 call 801069d0 + return -1; +80100b84: b8 ff ff ff ff mov $0xffffffff,%eax +80100b89: e9 84 fe ff ff jmp 80100a12 + end_op(); +80100b8e: e8 ed 1f 00 00 call 80102b80 + cprintf("exec: fail\n"); +80100b93: c7 04 24 a1 6e 10 80 movl $0x80106ea1,(%esp) +80100b9a: e8 b1 fa ff ff call 80100650 + return -1; +80100b9f: b8 ff ff ff ff mov $0xffffffff,%eax +80100ba4: e9 69 fe ff ff jmp 80100a12 + clearpteu(pgdir, (char*)(KERNBASE)); +80100ba9: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax +80100baf: c7 44 24 04 00 00 00 movl $0x80000000,0x4(%esp) +80100bb6: 80 +80100bb7: 89 04 24 mov %eax,(%esp) +80100bba: e8 41 5f 00 00 call 80106b00 + for(argc = 0; argv[argc]; argc++) { +80100bbf: 8b 45 0c mov 0xc(%ebp),%eax +80100bc2: 8b 00 mov (%eax),%eax +80100bc4: 85 c0 test %eax,%eax +80100bc6: 0f 84 61 01 00 00 je 80100d2d +80100bcc: 8b 4d 0c mov 0xc(%ebp),%ecx +80100bcf: 31 d2 xor %edx,%edx +80100bd1: 8d 71 04 lea 0x4(%ecx),%esi +80100bd4: 89 cf mov %ecx,%edi +80100bd6: 89 d1 mov %edx,%ecx +80100bd8: 89 f2 mov %esi,%edx +80100bda: 89 fe mov %edi,%esi +80100bdc: 89 cf mov %ecx,%edi +80100bde: eb 08 jmp 80100be8 +80100be0: 83 c2 04 add $0x4,%edx + if(argc >= MAXARG) +80100be3: 83 ff 20 cmp $0x20,%edi +80100be6: 74 8e je 80100b76 + sp = (sp - (strlen(argv[argc]) + 1)) & ~3; +80100be8: 89 04 24 mov %eax,(%esp) +80100beb: 89 95 e8 fe ff ff mov %edx,-0x118(%ebp) +80100bf1: e8 aa 38 00 00 call 801044a0 +80100bf6: f7 d0 not %eax +80100bf8: 01 c3 add %eax,%ebx + if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) +80100bfa: 8b 06 mov (%esi),%eax + sp = (sp - (strlen(argv[argc]) + 1)) & ~3; +80100bfc: 83 e3 fc and $0xfffffffc,%ebx + if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) +80100bff: 89 04 24 mov %eax,(%esp) +80100c02: e8 99 38 00 00 call 801044a0 +80100c07: 83 c0 01 add $0x1,%eax +80100c0a: 89 44 24 0c mov %eax,0xc(%esp) +80100c0e: 8b 06 mov (%esi),%eax +80100c10: 89 5c 24 04 mov %ebx,0x4(%esp) +80100c14: 89 44 24 08 mov %eax,0x8(%esp) +80100c18: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax +80100c1e: 89 04 24 mov %eax,(%esp) +80100c21: e8 ea 60 00 00 call 80106d10 +80100c26: 85 c0 test %eax,%eax +80100c28: 0f 88 48 ff ff ff js 80100b76 + for(argc = 0; argv[argc]; argc++) { +80100c2e: 8b 95 e8 fe ff ff mov -0x118(%ebp),%edx + ustack[3+argc] = sp; +80100c34: 8d 8d 58 ff ff ff lea -0xa8(%ebp),%ecx +80100c3a: 89 9c bd 64 ff ff ff mov %ebx,-0x9c(%ebp,%edi,4) + for(argc = 0; argv[argc]; argc++) { +80100c41: 83 c7 01 add $0x1,%edi +80100c44: 8b 02 mov (%edx),%eax +80100c46: 89 d6 mov %edx,%esi +80100c48: 85 c0 test %eax,%eax +80100c4a: 75 94 jne 80100be0 +80100c4c: 89 fa mov %edi,%edx + ustack[3+argc] = 0; +80100c4e: c7 84 95 64 ff ff ff movl $0x0,-0x9c(%ebp,%edx,4) +80100c55: 00 00 00 00 + ustack[2] = sp - (argc+1)*4; // argv pointer +80100c59: 8d 04 95 04 00 00 00 lea 0x4(,%edx,4),%eax + ustack[1] = argc; +80100c60: 89 95 5c ff ff ff mov %edx,-0xa4(%ebp) + ustack[2] = sp - (argc+1)*4; // argv pointer +80100c66: 89 da mov %ebx,%edx +80100c68: 29 c2 sub %eax,%edx + sp -= (3+argc+1) * 4; +80100c6a: 83 c0 0c add $0xc,%eax +80100c6d: 29 c3 sub %eax,%ebx + if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) +80100c6f: 89 44 24 0c mov %eax,0xc(%esp) +80100c73: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax +80100c79: 89 4c 24 08 mov %ecx,0x8(%esp) +80100c7d: 89 5c 24 04 mov %ebx,0x4(%esp) + ustack[0] = 0xffffffff; // fake return PC +80100c81: c7 85 58 ff ff ff ff movl $0xffffffff,-0xa8(%ebp) +80100c88: ff ff ff + if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) +80100c8b: 89 04 24 mov %eax,(%esp) + ustack[2] = sp - (argc+1)*4; // argv pointer +80100c8e: 89 95 60 ff ff ff mov %edx,-0xa0(%ebp) + if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) +80100c94: e8 77 60 00 00 call 80106d10 +80100c99: 85 c0 test %eax,%eax +80100c9b: 0f 88 d5 fe ff ff js 80100b76 + for(last=s=path; *s; s++) +80100ca1: 8b 45 08 mov 0x8(%ebp),%eax +80100ca4: 0f b6 10 movzbl (%eax),%edx +80100ca7: 84 d2 test %dl,%dl +80100ca9: 74 19 je 80100cc4 +80100cab: 8b 4d 08 mov 0x8(%ebp),%ecx +80100cae: 83 c0 01 add $0x1,%eax + last = s+1; +80100cb1: 80 fa 2f cmp $0x2f,%dl + for(last=s=path; *s; s++) +80100cb4: 0f b6 10 movzbl (%eax),%edx + last = s+1; +80100cb7: 0f 44 c8 cmove %eax,%ecx +80100cba: 83 c0 01 add $0x1,%eax + for(last=s=path; *s; s++) +80100cbd: 84 d2 test %dl,%dl +80100cbf: 75 f0 jne 80100cb1 +80100cc1: 89 4d 08 mov %ecx,0x8(%ebp) + safestrcpy(curproc->name, last, sizeof(curproc->name)); +80100cc4: 8b bd f4 fe ff ff mov -0x10c(%ebp),%edi +80100cca: 8b 45 08 mov 0x8(%ebp),%eax +80100ccd: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) +80100cd4: 00 +80100cd5: 89 44 24 04 mov %eax,0x4(%esp) +80100cd9: 89 f8 mov %edi,%eax +80100cdb: 83 c0 6c add $0x6c,%eax +80100cde: 89 04 24 mov %eax,(%esp) +80100ce1: e8 7a 37 00 00 call 80104460 + sz = PGROUNDUP(sz); +80100ce6: 8b 85 ec fe ff ff mov -0x114(%ebp),%eax + curproc->pgdir = pgdir; +80100cec: 8b 95 f0 fe ff ff mov -0x110(%ebp),%edx + oldpgdir = curproc->pgdir; +80100cf2: 8b 77 04 mov 0x4(%edi),%esi + sz = PGROUNDUP(sz); +80100cf5: 05 ff 0f 00 00 add $0xfff,%eax +80100cfa: 25 00 f0 ff ff and $0xfffff000,%eax +80100cff: 89 07 mov %eax,(%edi) + curproc->tf->eip = elf.entry; // main +80100d01: 8b 47 18 mov 0x18(%edi),%eax + curproc->pgdir = pgdir; +80100d04: 89 57 04 mov %edx,0x4(%edi) + curproc->tf->eip = elf.entry; // main +80100d07: 8b 95 3c ff ff ff mov -0xc4(%ebp),%edx +80100d0d: 89 50 38 mov %edx,0x38(%eax) + curproc->tf->esp = sp; +80100d10: 8b 47 18 mov 0x18(%edi),%eax +80100d13: 89 58 44 mov %ebx,0x44(%eax) + switchuvm(curproc); +80100d16: 89 3c 24 mov %edi,(%esp) +80100d19: e8 32 59 00 00 call 80106650 + freevm(oldpgdir); +80100d1e: 89 34 24 mov %esi,(%esp) +80100d21: e8 aa 5c 00 00 call 801069d0 + return 0; +80100d26: 31 c0 xor %eax,%eax +80100d28: e9 e5 fc ff ff jmp 80100a12 + for(argc = 0; argv[argc]; argc++) { +80100d2d: 31 d2 xor %edx,%edx +80100d2f: 8d 8d 58 ff ff ff lea -0xa8(%ebp),%ecx +80100d35: e9 14 ff ff ff jmp 80100c4e +80100d3a: 66 90 xchg %ax,%ax +80100d3c: 66 90 xchg %ax,%ax +80100d3e: 66 90 xchg %ax,%ax + +80100d40 : + struct file file[NFILE]; +} ftable; + +void +fileinit(void) +{ +80100d40: 55 push %ebp +80100d41: 89 e5 mov %esp,%ebp +80100d43: 83 ec 18 sub $0x18,%esp + initlock(&ftable.lock, "ftable"); +80100d46: c7 44 24 04 ad 6e 10 movl $0x80106ead,0x4(%esp) +80100d4d: 80 +80100d4e: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) +80100d55: e8 f6 32 00 00 call 80104050 +} +80100d5a: c9 leave +80100d5b: c3 ret +80100d5c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80100d60 : + +// Allocate a file structure. +struct file* +filealloc(void) +{ +80100d60: 55 push %ebp +80100d61: 89 e5 mov %esp,%ebp +80100d63: 53 push %ebx + struct file *f; + + acquire(&ftable.lock); + for(f = ftable.file; f < ftable.file + NFILE; f++){ +80100d64: bb f4 ff 10 80 mov $0x8010fff4,%ebx +{ +80100d69: 83 ec 14 sub $0x14,%esp + acquire(&ftable.lock); +80100d6c: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) +80100d73: e8 c8 33 00 00 call 80104140 +80100d78: eb 11 jmp 80100d8b +80100d7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for(f = ftable.file; f < ftable.file + NFILE; f++){ +80100d80: 83 c3 18 add $0x18,%ebx +80100d83: 81 fb 54 09 11 80 cmp $0x80110954,%ebx +80100d89: 74 25 je 80100db0 + if(f->ref == 0){ +80100d8b: 8b 43 04 mov 0x4(%ebx),%eax +80100d8e: 85 c0 test %eax,%eax +80100d90: 75 ee jne 80100d80 + f->ref = 1; + release(&ftable.lock); +80100d92: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) + f->ref = 1; +80100d99: c7 43 04 01 00 00 00 movl $0x1,0x4(%ebx) + release(&ftable.lock); +80100da0: e8 8b 34 00 00 call 80104230 + return f; + } + } + release(&ftable.lock); + return 0; +} +80100da5: 83 c4 14 add $0x14,%esp + return f; +80100da8: 89 d8 mov %ebx,%eax +} +80100daa: 5b pop %ebx +80100dab: 5d pop %ebp +80100dac: c3 ret +80100dad: 8d 76 00 lea 0x0(%esi),%esi + release(&ftable.lock); +80100db0: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) +80100db7: e8 74 34 00 00 call 80104230 +} +80100dbc: 83 c4 14 add $0x14,%esp + return 0; +80100dbf: 31 c0 xor %eax,%eax +} +80100dc1: 5b pop %ebx +80100dc2: 5d pop %ebp +80100dc3: c3 ret +80100dc4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80100dca: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +80100dd0 : + +// Increment ref count for file f. +struct file* +filedup(struct file *f) +{ +80100dd0: 55 push %ebp +80100dd1: 89 e5 mov %esp,%ebp +80100dd3: 53 push %ebx +80100dd4: 83 ec 14 sub $0x14,%esp +80100dd7: 8b 5d 08 mov 0x8(%ebp),%ebx + acquire(&ftable.lock); +80100dda: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) +80100de1: e8 5a 33 00 00 call 80104140 + if(f->ref < 1) +80100de6: 8b 43 04 mov 0x4(%ebx),%eax +80100de9: 85 c0 test %eax,%eax +80100deb: 7e 1a jle 80100e07 + panic("filedup"); + f->ref++; +80100ded: 83 c0 01 add $0x1,%eax +80100df0: 89 43 04 mov %eax,0x4(%ebx) + release(&ftable.lock); +80100df3: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) +80100dfa: e8 31 34 00 00 call 80104230 + return f; +} +80100dff: 83 c4 14 add $0x14,%esp +80100e02: 89 d8 mov %ebx,%eax +80100e04: 5b pop %ebx +80100e05: 5d pop %ebp +80100e06: c3 ret + panic("filedup"); +80100e07: c7 04 24 b4 6e 10 80 movl $0x80106eb4,(%esp) +80100e0e: e8 4d f5 ff ff call 80100360 +80100e13: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80100e19: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80100e20 : + +// Close file f. (Decrement ref count, close when reaches 0.) +void +fileclose(struct file *f) +{ +80100e20: 55 push %ebp +80100e21: 89 e5 mov %esp,%ebp +80100e23: 57 push %edi +80100e24: 56 push %esi +80100e25: 53 push %ebx +80100e26: 83 ec 1c sub $0x1c,%esp +80100e29: 8b 7d 08 mov 0x8(%ebp),%edi + struct file ff; + + acquire(&ftable.lock); +80100e2c: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) +80100e33: e8 08 33 00 00 call 80104140 + if(f->ref < 1) +80100e38: 8b 57 04 mov 0x4(%edi),%edx +80100e3b: 85 d2 test %edx,%edx +80100e3d: 0f 8e 89 00 00 00 jle 80100ecc + panic("fileclose"); + if(--f->ref > 0){ +80100e43: 83 ea 01 sub $0x1,%edx +80100e46: 85 d2 test %edx,%edx +80100e48: 89 57 04 mov %edx,0x4(%edi) +80100e4b: 74 13 je 80100e60 + release(&ftable.lock); +80100e4d: c7 45 08 c0 ff 10 80 movl $0x8010ffc0,0x8(%ebp) + else if(ff.type == FD_INODE){ + begin_op(); + iput(ff.ip); + end_op(); + } +} +80100e54: 83 c4 1c add $0x1c,%esp +80100e57: 5b pop %ebx +80100e58: 5e pop %esi +80100e59: 5f pop %edi +80100e5a: 5d pop %ebp + release(&ftable.lock); +80100e5b: e9 d0 33 00 00 jmp 80104230 + ff = *f; +80100e60: 0f b6 47 09 movzbl 0x9(%edi),%eax +80100e64: 8b 37 mov (%edi),%esi +80100e66: 8b 5f 0c mov 0xc(%edi),%ebx + f->type = FD_NONE; +80100e69: c7 07 00 00 00 00 movl $0x0,(%edi) + ff = *f; +80100e6f: 88 45 e7 mov %al,-0x19(%ebp) +80100e72: 8b 47 10 mov 0x10(%edi),%eax + release(&ftable.lock); +80100e75: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) + ff = *f; +80100e7c: 89 45 e0 mov %eax,-0x20(%ebp) + release(&ftable.lock); +80100e7f: e8 ac 33 00 00 call 80104230 + if(ff.type == FD_PIPE) +80100e84: 83 fe 01 cmp $0x1,%esi +80100e87: 74 0f je 80100e98 + else if(ff.type == FD_INODE){ +80100e89: 83 fe 02 cmp $0x2,%esi +80100e8c: 74 22 je 80100eb0 +} +80100e8e: 83 c4 1c add $0x1c,%esp +80100e91: 5b pop %ebx +80100e92: 5e pop %esi +80100e93: 5f pop %edi +80100e94: 5d pop %ebp +80100e95: c3 ret +80100e96: 66 90 xchg %ax,%ax + pipeclose(ff.pipe, ff.writable); +80100e98: 0f be 75 e7 movsbl -0x19(%ebp),%esi +80100e9c: 89 1c 24 mov %ebx,(%esp) +80100e9f: 89 74 24 04 mov %esi,0x4(%esp) +80100ea3: e8 b8 23 00 00 call 80103260 +80100ea8: eb e4 jmp 80100e8e +80100eaa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + begin_op(); +80100eb0: e8 5b 1c 00 00 call 80102b10 + iput(ff.ip); +80100eb5: 8b 45 e0 mov -0x20(%ebp),%eax +80100eb8: 89 04 24 mov %eax,(%esp) +80100ebb: e8 10 09 00 00 call 801017d0 +} +80100ec0: 83 c4 1c add $0x1c,%esp +80100ec3: 5b pop %ebx +80100ec4: 5e pop %esi +80100ec5: 5f pop %edi +80100ec6: 5d pop %ebp + end_op(); +80100ec7: e9 b4 1c 00 00 jmp 80102b80 + panic("fileclose"); +80100ecc: c7 04 24 bc 6e 10 80 movl $0x80106ebc,(%esp) +80100ed3: e8 88 f4 ff ff call 80100360 +80100ed8: 90 nop +80100ed9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80100ee0 : + +// Get metadata about file f. +int +filestat(struct file *f, struct stat *st) +{ +80100ee0: 55 push %ebp +80100ee1: 89 e5 mov %esp,%ebp +80100ee3: 53 push %ebx +80100ee4: 83 ec 14 sub $0x14,%esp +80100ee7: 8b 5d 08 mov 0x8(%ebp),%ebx + if(f->type == FD_INODE){ +80100eea: 83 3b 02 cmpl $0x2,(%ebx) +80100eed: 75 31 jne 80100f20 + ilock(f->ip); +80100eef: 8b 43 10 mov 0x10(%ebx),%eax +80100ef2: 89 04 24 mov %eax,(%esp) +80100ef5: e8 b6 07 00 00 call 801016b0 + stati(f->ip, st); +80100efa: 8b 45 0c mov 0xc(%ebp),%eax +80100efd: 89 44 24 04 mov %eax,0x4(%esp) +80100f01: 8b 43 10 mov 0x10(%ebx),%eax +80100f04: 89 04 24 mov %eax,(%esp) +80100f07: e8 24 0a 00 00 call 80101930 + iunlock(f->ip); +80100f0c: 8b 43 10 mov 0x10(%ebx),%eax +80100f0f: 89 04 24 mov %eax,(%esp) +80100f12: e8 79 08 00 00 call 80101790 + return 0; + } + return -1; +} +80100f17: 83 c4 14 add $0x14,%esp + return 0; +80100f1a: 31 c0 xor %eax,%eax +} +80100f1c: 5b pop %ebx +80100f1d: 5d pop %ebp +80100f1e: c3 ret +80100f1f: 90 nop +80100f20: 83 c4 14 add $0x14,%esp + return -1; +80100f23: b8 ff ff ff ff mov $0xffffffff,%eax +} +80100f28: 5b pop %ebx +80100f29: 5d pop %ebp +80100f2a: c3 ret +80100f2b: 90 nop +80100f2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80100f30 : + +// Read from file f. +int +fileread(struct file *f, char *addr, int n) +{ +80100f30: 55 push %ebp +80100f31: 89 e5 mov %esp,%ebp +80100f33: 57 push %edi +80100f34: 56 push %esi +80100f35: 53 push %ebx +80100f36: 83 ec 1c sub $0x1c,%esp +80100f39: 8b 5d 08 mov 0x8(%ebp),%ebx +80100f3c: 8b 75 0c mov 0xc(%ebp),%esi +80100f3f: 8b 7d 10 mov 0x10(%ebp),%edi + int r; + + if(f->readable == 0) +80100f42: 80 7b 08 00 cmpb $0x0,0x8(%ebx) +80100f46: 74 68 je 80100fb0 + return -1; + if(f->type == FD_PIPE) +80100f48: 8b 03 mov (%ebx),%eax +80100f4a: 83 f8 01 cmp $0x1,%eax +80100f4d: 74 49 je 80100f98 + return piperead(f->pipe, addr, n); + if(f->type == FD_INODE){ +80100f4f: 83 f8 02 cmp $0x2,%eax +80100f52: 75 63 jne 80100fb7 + ilock(f->ip); +80100f54: 8b 43 10 mov 0x10(%ebx),%eax +80100f57: 89 04 24 mov %eax,(%esp) +80100f5a: e8 51 07 00 00 call 801016b0 + if((r = readi(f->ip, addr, f->off, n)) > 0) +80100f5f: 89 7c 24 0c mov %edi,0xc(%esp) +80100f63: 8b 43 14 mov 0x14(%ebx),%eax +80100f66: 89 74 24 04 mov %esi,0x4(%esp) +80100f6a: 89 44 24 08 mov %eax,0x8(%esp) +80100f6e: 8b 43 10 mov 0x10(%ebx),%eax +80100f71: 89 04 24 mov %eax,(%esp) +80100f74: e8 e7 09 00 00 call 80101960 +80100f79: 85 c0 test %eax,%eax +80100f7b: 89 c6 mov %eax,%esi +80100f7d: 7e 03 jle 80100f82 + f->off += r; +80100f7f: 01 43 14 add %eax,0x14(%ebx) + iunlock(f->ip); +80100f82: 8b 43 10 mov 0x10(%ebx),%eax +80100f85: 89 04 24 mov %eax,(%esp) +80100f88: e8 03 08 00 00 call 80101790 + if((r = readi(f->ip, addr, f->off, n)) > 0) +80100f8d: 89 f0 mov %esi,%eax + return r; + } + panic("fileread"); +} +80100f8f: 83 c4 1c add $0x1c,%esp +80100f92: 5b pop %ebx +80100f93: 5e pop %esi +80100f94: 5f pop %edi +80100f95: 5d pop %ebp +80100f96: c3 ret +80100f97: 90 nop + return piperead(f->pipe, addr, n); +80100f98: 8b 43 0c mov 0xc(%ebx),%eax +80100f9b: 89 45 08 mov %eax,0x8(%ebp) +} +80100f9e: 83 c4 1c add $0x1c,%esp +80100fa1: 5b pop %ebx +80100fa2: 5e pop %esi +80100fa3: 5f pop %edi +80100fa4: 5d pop %ebp + return piperead(f->pipe, addr, n); +80100fa5: e9 36 24 00 00 jmp 801033e0 +80100faa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return -1; +80100fb0: b8 ff ff ff ff mov $0xffffffff,%eax +80100fb5: eb d8 jmp 80100f8f + panic("fileread"); +80100fb7: c7 04 24 c6 6e 10 80 movl $0x80106ec6,(%esp) +80100fbe: e8 9d f3 ff ff call 80100360 +80100fc3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80100fc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80100fd0 : + +//PAGEBREAK! +// Write to file f. +int +filewrite(struct file *f, char *addr, int n) +{ +80100fd0: 55 push %ebp +80100fd1: 89 e5 mov %esp,%ebp +80100fd3: 57 push %edi +80100fd4: 56 push %esi +80100fd5: 53 push %ebx +80100fd6: 83 ec 2c sub $0x2c,%esp +80100fd9: 8b 45 0c mov 0xc(%ebp),%eax +80100fdc: 8b 7d 08 mov 0x8(%ebp),%edi +80100fdf: 89 45 dc mov %eax,-0x24(%ebp) +80100fe2: 8b 45 10 mov 0x10(%ebp),%eax + int r; + + if(f->writable == 0) +80100fe5: 80 7f 09 00 cmpb $0x0,0x9(%edi) +{ +80100fe9: 89 45 e4 mov %eax,-0x1c(%ebp) + if(f->writable == 0) +80100fec: 0f 84 ae 00 00 00 je 801010a0 + return -1; + if(f->type == FD_PIPE) +80100ff2: 8b 07 mov (%edi),%eax +80100ff4: 83 f8 01 cmp $0x1,%eax +80100ff7: 0f 84 c2 00 00 00 je 801010bf + return pipewrite(f->pipe, addr, n); + if(f->type == FD_INODE){ +80100ffd: 83 f8 02 cmp $0x2,%eax +80101000: 0f 85 d7 00 00 00 jne 801010dd + // and 2 blocks of slop for non-aligned writes. + // this really belongs lower down, since writei() + // might be writing a device like the console. + int max = ((LOGSIZE-1-1-2) / 2) * 512; + int i = 0; + while(i < n){ +80101006: 8b 45 e4 mov -0x1c(%ebp),%eax +80101009: 31 db xor %ebx,%ebx +8010100b: 85 c0 test %eax,%eax +8010100d: 7f 31 jg 80101040 +8010100f: e9 9c 00 00 00 jmp 801010b0 +80101014: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + + begin_op(); + ilock(f->ip); + if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) + f->off += r; + iunlock(f->ip); +80101018: 8b 4f 10 mov 0x10(%edi),%ecx + f->off += r; +8010101b: 01 47 14 add %eax,0x14(%edi) +8010101e: 89 45 e0 mov %eax,-0x20(%ebp) + iunlock(f->ip); +80101021: 89 0c 24 mov %ecx,(%esp) +80101024: e8 67 07 00 00 call 80101790 + end_op(); +80101029: e8 52 1b 00 00 call 80102b80 +8010102e: 8b 45 e0 mov -0x20(%ebp),%eax + + if(r < 0) + break; + if(r != n1) +80101031: 39 f0 cmp %esi,%eax +80101033: 0f 85 98 00 00 00 jne 801010d1 + panic("short filewrite"); + i += r; +80101039: 01 c3 add %eax,%ebx + while(i < n){ +8010103b: 39 5d e4 cmp %ebx,-0x1c(%ebp) +8010103e: 7e 70 jle 801010b0 + int n1 = n - i; +80101040: 8b 75 e4 mov -0x1c(%ebp),%esi +80101043: b8 00 1a 00 00 mov $0x1a00,%eax +80101048: 29 de sub %ebx,%esi +8010104a: 81 fe 00 1a 00 00 cmp $0x1a00,%esi +80101050: 0f 4f f0 cmovg %eax,%esi + begin_op(); +80101053: e8 b8 1a 00 00 call 80102b10 + ilock(f->ip); +80101058: 8b 47 10 mov 0x10(%edi),%eax +8010105b: 89 04 24 mov %eax,(%esp) +8010105e: e8 4d 06 00 00 call 801016b0 + if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) +80101063: 89 74 24 0c mov %esi,0xc(%esp) +80101067: 8b 47 14 mov 0x14(%edi),%eax +8010106a: 89 44 24 08 mov %eax,0x8(%esp) +8010106e: 8b 45 dc mov -0x24(%ebp),%eax +80101071: 01 d8 add %ebx,%eax +80101073: 89 44 24 04 mov %eax,0x4(%esp) +80101077: 8b 47 10 mov 0x10(%edi),%eax +8010107a: 89 04 24 mov %eax,(%esp) +8010107d: e8 de 09 00 00 call 80101a60 +80101082: 85 c0 test %eax,%eax +80101084: 7f 92 jg 80101018 + iunlock(f->ip); +80101086: 8b 4f 10 mov 0x10(%edi),%ecx +80101089: 89 45 e0 mov %eax,-0x20(%ebp) +8010108c: 89 0c 24 mov %ecx,(%esp) +8010108f: e8 fc 06 00 00 call 80101790 + end_op(); +80101094: e8 e7 1a 00 00 call 80102b80 + if(r < 0) +80101099: 8b 45 e0 mov -0x20(%ebp),%eax +8010109c: 85 c0 test %eax,%eax +8010109e: 74 91 je 80101031 + } + return i == n ? n : -1; + } + panic("filewrite"); +} +801010a0: 83 c4 2c add $0x2c,%esp + return -1; +801010a3: b8 ff ff ff ff mov $0xffffffff,%eax +} +801010a8: 5b pop %ebx +801010a9: 5e pop %esi +801010aa: 5f pop %edi +801010ab: 5d pop %ebp +801010ac: c3 ret +801010ad: 8d 76 00 lea 0x0(%esi),%esi + return i == n ? n : -1; +801010b0: 3b 5d e4 cmp -0x1c(%ebp),%ebx +801010b3: 89 d8 mov %ebx,%eax +801010b5: 75 e9 jne 801010a0 +} +801010b7: 83 c4 2c add $0x2c,%esp +801010ba: 5b pop %ebx +801010bb: 5e pop %esi +801010bc: 5f pop %edi +801010bd: 5d pop %ebp +801010be: c3 ret + return pipewrite(f->pipe, addr, n); +801010bf: 8b 47 0c mov 0xc(%edi),%eax +801010c2: 89 45 08 mov %eax,0x8(%ebp) +} +801010c5: 83 c4 2c add $0x2c,%esp +801010c8: 5b pop %ebx +801010c9: 5e pop %esi +801010ca: 5f pop %edi +801010cb: 5d pop %ebp + return pipewrite(f->pipe, addr, n); +801010cc: e9 1f 22 00 00 jmp 801032f0 + panic("short filewrite"); +801010d1: c7 04 24 cf 6e 10 80 movl $0x80106ecf,(%esp) +801010d8: e8 83 f2 ff ff call 80100360 + panic("filewrite"); +801010dd: c7 04 24 d5 6e 10 80 movl $0x80106ed5,(%esp) +801010e4: e8 77 f2 ff ff call 80100360 +801010e9: 66 90 xchg %ax,%ax +801010eb: 66 90 xchg %ax,%ax +801010ed: 66 90 xchg %ax,%ax +801010ef: 90 nop + +801010f0 : +// Blocks. + +// Allocate a zeroed disk block. +static uint +balloc(uint dev) +{ +801010f0: 55 push %ebp +801010f1: 89 e5 mov %esp,%ebp +801010f3: 57 push %edi +801010f4: 56 push %esi +801010f5: 53 push %ebx +801010f6: 83 ec 2c sub $0x2c,%esp +801010f9: 89 45 d8 mov %eax,-0x28(%ebp) + int b, bi, m; + struct buf *bp; + + bp = 0; + for(b = 0; b < sb.size; b += BPB){ +801010fc: a1 c0 09 11 80 mov 0x801109c0,%eax +80101101: 85 c0 test %eax,%eax +80101103: 0f 84 8c 00 00 00 je 80101195 +80101109: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) + bp = bread(dev, BBLOCK(b, sb)); +80101110: 8b 75 dc mov -0x24(%ebp),%esi +80101113: 89 f0 mov %esi,%eax +80101115: c1 f8 0c sar $0xc,%eax +80101118: 03 05 d8 09 11 80 add 0x801109d8,%eax +8010111e: 89 44 24 04 mov %eax,0x4(%esp) +80101122: 8b 45 d8 mov -0x28(%ebp),%eax +80101125: 89 04 24 mov %eax,(%esp) +80101128: e8 a3 ef ff ff call 801000d0 +8010112d: 89 45 e4 mov %eax,-0x1c(%ebp) +80101130: a1 c0 09 11 80 mov 0x801109c0,%eax +80101135: 89 45 e0 mov %eax,-0x20(%ebp) + for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ +80101138: 31 c0 xor %eax,%eax +8010113a: eb 33 jmp 8010116f +8010113c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + m = 1 << (bi % 8); + if((bp->data[bi/8] & m) == 0){ // Is block free? +80101140: 8b 5d e4 mov -0x1c(%ebp),%ebx +80101143: 89 c2 mov %eax,%edx + m = 1 << (bi % 8); +80101145: 89 c1 mov %eax,%ecx + if((bp->data[bi/8] & m) == 0){ // Is block free? +80101147: c1 fa 03 sar $0x3,%edx + m = 1 << (bi % 8); +8010114a: 83 e1 07 and $0x7,%ecx +8010114d: bf 01 00 00 00 mov $0x1,%edi +80101152: d3 e7 shl %cl,%edi + if((bp->data[bi/8] & m) == 0){ // Is block free? +80101154: 0f b6 5c 13 5c movzbl 0x5c(%ebx,%edx,1),%ebx + m = 1 << (bi % 8); +80101159: 89 f9 mov %edi,%ecx + if((bp->data[bi/8] & m) == 0){ // Is block free? +8010115b: 0f b6 fb movzbl %bl,%edi +8010115e: 85 cf test %ecx,%edi +80101160: 74 46 je 801011a8 + for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ +80101162: 83 c0 01 add $0x1,%eax +80101165: 83 c6 01 add $0x1,%esi +80101168: 3d 00 10 00 00 cmp $0x1000,%eax +8010116d: 74 05 je 80101174 +8010116f: 3b 75 e0 cmp -0x20(%ebp),%esi +80101172: 72 cc jb 80101140 + brelse(bp); + bzero(dev, b + bi); + return b + bi; + } + } + brelse(bp); +80101174: 8b 45 e4 mov -0x1c(%ebp),%eax +80101177: 89 04 24 mov %eax,(%esp) +8010117a: e8 61 f0 ff ff call 801001e0 + for(b = 0; b < sb.size; b += BPB){ +8010117f: 81 45 dc 00 10 00 00 addl $0x1000,-0x24(%ebp) +80101186: 8b 45 dc mov -0x24(%ebp),%eax +80101189: 3b 05 c0 09 11 80 cmp 0x801109c0,%eax +8010118f: 0f 82 7b ff ff ff jb 80101110 + } + panic("balloc: out of blocks"); +80101195: c7 04 24 df 6e 10 80 movl $0x80106edf,(%esp) +8010119c: e8 bf f1 ff ff call 80100360 +801011a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + bp->data[bi/8] |= m; // Mark block in use. +801011a8: 09 d9 or %ebx,%ecx +801011aa: 8b 5d e4 mov -0x1c(%ebp),%ebx +801011ad: 88 4c 13 5c mov %cl,0x5c(%ebx,%edx,1) + log_write(bp); +801011b1: 89 1c 24 mov %ebx,(%esp) +801011b4: e8 f7 1a 00 00 call 80102cb0 + brelse(bp); +801011b9: 89 1c 24 mov %ebx,(%esp) +801011bc: e8 1f f0 ff ff call 801001e0 + bp = bread(dev, bno); +801011c1: 8b 45 d8 mov -0x28(%ebp),%eax +801011c4: 89 74 24 04 mov %esi,0x4(%esp) +801011c8: 89 04 24 mov %eax,(%esp) +801011cb: e8 00 ef ff ff call 801000d0 + memset(bp->data, 0, BSIZE); +801011d0: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) +801011d7: 00 +801011d8: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +801011df: 00 + bp = bread(dev, bno); +801011e0: 89 c3 mov %eax,%ebx + memset(bp->data, 0, BSIZE); +801011e2: 8d 40 5c lea 0x5c(%eax),%eax +801011e5: 89 04 24 mov %eax,(%esp) +801011e8: e8 93 30 00 00 call 80104280 + log_write(bp); +801011ed: 89 1c 24 mov %ebx,(%esp) +801011f0: e8 bb 1a 00 00 call 80102cb0 + brelse(bp); +801011f5: 89 1c 24 mov %ebx,(%esp) +801011f8: e8 e3 ef ff ff call 801001e0 +} +801011fd: 83 c4 2c add $0x2c,%esp +80101200: 89 f0 mov %esi,%eax +80101202: 5b pop %ebx +80101203: 5e pop %esi +80101204: 5f pop %edi +80101205: 5d pop %ebp +80101206: c3 ret +80101207: 89 f6 mov %esi,%esi +80101209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80101210 : +// Find the inode with number inum on device dev +// and return the in-memory copy. Does not lock +// the inode and does not read it from disk. +static struct inode* +iget(uint dev, uint inum) +{ +80101210: 55 push %ebp +80101211: 89 e5 mov %esp,%ebp +80101213: 57 push %edi +80101214: 89 c7 mov %eax,%edi +80101216: 56 push %esi + struct inode *ip, *empty; + + acquire(&icache.lock); + + // Is the inode already cached? + empty = 0; +80101217: 31 f6 xor %esi,%esi +{ +80101219: 53 push %ebx + for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ +8010121a: bb 14 0a 11 80 mov $0x80110a14,%ebx +{ +8010121f: 83 ec 1c sub $0x1c,%esp + acquire(&icache.lock); +80101222: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) +{ +80101229: 89 55 e4 mov %edx,-0x1c(%ebp) + acquire(&icache.lock); +8010122c: e8 0f 2f 00 00 call 80104140 + for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ +80101231: 8b 55 e4 mov -0x1c(%ebp),%edx +80101234: eb 14 jmp 8010124a +80101236: 66 90 xchg %ax,%ax + if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ + ip->ref++; + release(&icache.lock); + return ip; + } + if(empty == 0 && ip->ref == 0) // Remember empty slot. +80101238: 85 f6 test %esi,%esi +8010123a: 74 3c je 80101278 + for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ +8010123c: 81 c3 90 00 00 00 add $0x90,%ebx +80101242: 81 fb 34 26 11 80 cmp $0x80112634,%ebx +80101248: 74 46 je 80101290 + if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ +8010124a: 8b 4b 08 mov 0x8(%ebx),%ecx +8010124d: 85 c9 test %ecx,%ecx +8010124f: 7e e7 jle 80101238 +80101251: 39 3b cmp %edi,(%ebx) +80101253: 75 e3 jne 80101238 +80101255: 39 53 04 cmp %edx,0x4(%ebx) +80101258: 75 de jne 80101238 + ip->ref++; +8010125a: 83 c1 01 add $0x1,%ecx + return ip; +8010125d: 89 de mov %ebx,%esi + release(&icache.lock); +8010125f: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) + ip->ref++; +80101266: 89 4b 08 mov %ecx,0x8(%ebx) + release(&icache.lock); +80101269: e8 c2 2f 00 00 call 80104230 + ip->ref = 1; + ip->valid = 0; + release(&icache.lock); + + return ip; +} +8010126e: 83 c4 1c add $0x1c,%esp +80101271: 89 f0 mov %esi,%eax +80101273: 5b pop %ebx +80101274: 5e pop %esi +80101275: 5f pop %edi +80101276: 5d pop %ebp +80101277: c3 ret +80101278: 85 c9 test %ecx,%ecx +8010127a: 0f 44 f3 cmove %ebx,%esi + for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ +8010127d: 81 c3 90 00 00 00 add $0x90,%ebx +80101283: 81 fb 34 26 11 80 cmp $0x80112634,%ebx +80101289: 75 bf jne 8010124a +8010128b: 90 nop +8010128c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(empty == 0) +80101290: 85 f6 test %esi,%esi +80101292: 74 29 je 801012bd + ip->dev = dev; +80101294: 89 3e mov %edi,(%esi) + ip->inum = inum; +80101296: 89 56 04 mov %edx,0x4(%esi) + ip->ref = 1; +80101299: c7 46 08 01 00 00 00 movl $0x1,0x8(%esi) + ip->valid = 0; +801012a0: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) + release(&icache.lock); +801012a7: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) +801012ae: e8 7d 2f 00 00 call 80104230 +} +801012b3: 83 c4 1c add $0x1c,%esp +801012b6: 89 f0 mov %esi,%eax +801012b8: 5b pop %ebx +801012b9: 5e pop %esi +801012ba: 5f pop %edi +801012bb: 5d pop %ebp +801012bc: c3 ret + panic("iget: no inodes"); +801012bd: c7 04 24 f5 6e 10 80 movl $0x80106ef5,(%esp) +801012c4: e8 97 f0 ff ff call 80100360 +801012c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +801012d0 : + +// Return the disk block address of the nth block in inode ip. +// If there is no such block, bmap allocates one. +static uint +bmap(struct inode *ip, uint bn) +{ +801012d0: 55 push %ebp +801012d1: 89 e5 mov %esp,%ebp +801012d3: 57 push %edi +801012d4: 56 push %esi +801012d5: 53 push %ebx +801012d6: 89 c3 mov %eax,%ebx +801012d8: 83 ec 1c sub $0x1c,%esp + uint addr, *a; + struct buf *bp; + + if(bn < NDIRECT){ +801012db: 83 fa 0b cmp $0xb,%edx +801012de: 77 18 ja 801012f8 +801012e0: 8d 34 90 lea (%eax,%edx,4),%esi + if((addr = ip->addrs[bn]) == 0) +801012e3: 8b 46 5c mov 0x5c(%esi),%eax +801012e6: 85 c0 test %eax,%eax +801012e8: 74 66 je 80101350 + brelse(bp); + return addr; + } + + panic("bmap: out of range"); +} +801012ea: 83 c4 1c add $0x1c,%esp +801012ed: 5b pop %ebx +801012ee: 5e pop %esi +801012ef: 5f pop %edi +801012f0: 5d pop %ebp +801012f1: c3 ret +801012f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + bn -= NDIRECT; +801012f8: 8d 72 f4 lea -0xc(%edx),%esi + if(bn < NINDIRECT){ +801012fb: 83 fe 7f cmp $0x7f,%esi +801012fe: 77 77 ja 80101377 + if((addr = ip->addrs[NDIRECT]) == 0) +80101300: 8b 80 8c 00 00 00 mov 0x8c(%eax),%eax +80101306: 85 c0 test %eax,%eax +80101308: 74 5e je 80101368 + bp = bread(ip->dev, addr); +8010130a: 89 44 24 04 mov %eax,0x4(%esp) +8010130e: 8b 03 mov (%ebx),%eax +80101310: 89 04 24 mov %eax,(%esp) +80101313: e8 b8 ed ff ff call 801000d0 + if((addr = a[bn]) == 0){ +80101318: 8d 54 b0 5c lea 0x5c(%eax,%esi,4),%edx + bp = bread(ip->dev, addr); +8010131c: 89 c7 mov %eax,%edi + if((addr = a[bn]) == 0){ +8010131e: 8b 32 mov (%edx),%esi +80101320: 85 f6 test %esi,%esi +80101322: 75 19 jne 8010133d + a[bn] = addr = balloc(ip->dev); +80101324: 8b 03 mov (%ebx),%eax +80101326: 89 55 e4 mov %edx,-0x1c(%ebp) +80101329: e8 c2 fd ff ff call 801010f0 +8010132e: 8b 55 e4 mov -0x1c(%ebp),%edx +80101331: 89 02 mov %eax,(%edx) +80101333: 89 c6 mov %eax,%esi + log_write(bp); +80101335: 89 3c 24 mov %edi,(%esp) +80101338: e8 73 19 00 00 call 80102cb0 + brelse(bp); +8010133d: 89 3c 24 mov %edi,(%esp) +80101340: e8 9b ee ff ff call 801001e0 +} +80101345: 83 c4 1c add $0x1c,%esp + brelse(bp); +80101348: 89 f0 mov %esi,%eax +} +8010134a: 5b pop %ebx +8010134b: 5e pop %esi +8010134c: 5f pop %edi +8010134d: 5d pop %ebp +8010134e: c3 ret +8010134f: 90 nop + ip->addrs[bn] = addr = balloc(ip->dev); +80101350: 8b 03 mov (%ebx),%eax +80101352: e8 99 fd ff ff call 801010f0 +80101357: 89 46 5c mov %eax,0x5c(%esi) +} +8010135a: 83 c4 1c add $0x1c,%esp +8010135d: 5b pop %ebx +8010135e: 5e pop %esi +8010135f: 5f pop %edi +80101360: 5d pop %ebp +80101361: c3 ret +80101362: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + ip->addrs[NDIRECT] = addr = balloc(ip->dev); +80101368: 8b 03 mov (%ebx),%eax +8010136a: e8 81 fd ff ff call 801010f0 +8010136f: 89 83 8c 00 00 00 mov %eax,0x8c(%ebx) +80101375: eb 93 jmp 8010130a + panic("bmap: out of range"); +80101377: c7 04 24 05 6f 10 80 movl $0x80106f05,(%esp) +8010137e: e8 dd ef ff ff call 80100360 +80101383: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80101389: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80101390 : +{ +80101390: 55 push %ebp +80101391: 89 e5 mov %esp,%ebp +80101393: 56 push %esi +80101394: 53 push %ebx +80101395: 83 ec 10 sub $0x10,%esp + bp = bread(dev, 1); +80101398: 8b 45 08 mov 0x8(%ebp),%eax +8010139b: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +801013a2: 00 +{ +801013a3: 8b 75 0c mov 0xc(%ebp),%esi + bp = bread(dev, 1); +801013a6: 89 04 24 mov %eax,(%esp) +801013a9: e8 22 ed ff ff call 801000d0 + memmove(sb, bp->data, sizeof(*sb)); +801013ae: 89 34 24 mov %esi,(%esp) +801013b1: c7 44 24 08 1c 00 00 movl $0x1c,0x8(%esp) +801013b8: 00 + bp = bread(dev, 1); +801013b9: 89 c3 mov %eax,%ebx + memmove(sb, bp->data, sizeof(*sb)); +801013bb: 8d 40 5c lea 0x5c(%eax),%eax +801013be: 89 44 24 04 mov %eax,0x4(%esp) +801013c2: e8 59 2f 00 00 call 80104320 + brelse(bp); +801013c7: 89 5d 08 mov %ebx,0x8(%ebp) +} +801013ca: 83 c4 10 add $0x10,%esp +801013cd: 5b pop %ebx +801013ce: 5e pop %esi +801013cf: 5d pop %ebp + brelse(bp); +801013d0: e9 0b ee ff ff jmp 801001e0 +801013d5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801013d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +801013e0 : +{ +801013e0: 55 push %ebp +801013e1: 89 e5 mov %esp,%ebp +801013e3: 57 push %edi +801013e4: 89 d7 mov %edx,%edi +801013e6: 56 push %esi +801013e7: 53 push %ebx +801013e8: 89 c3 mov %eax,%ebx +801013ea: 83 ec 1c sub $0x1c,%esp + readsb(dev, &sb); +801013ed: 89 04 24 mov %eax,(%esp) +801013f0: c7 44 24 04 c0 09 11 movl $0x801109c0,0x4(%esp) +801013f7: 80 +801013f8: e8 93 ff ff ff call 80101390 + bp = bread(dev, BBLOCK(b, sb)); +801013fd: 89 fa mov %edi,%edx +801013ff: c1 ea 0c shr $0xc,%edx +80101402: 03 15 d8 09 11 80 add 0x801109d8,%edx +80101408: 89 1c 24 mov %ebx,(%esp) + m = 1 << (bi % 8); +8010140b: bb 01 00 00 00 mov $0x1,%ebx + bp = bread(dev, BBLOCK(b, sb)); +80101410: 89 54 24 04 mov %edx,0x4(%esp) +80101414: e8 b7 ec ff ff call 801000d0 + m = 1 << (bi % 8); +80101419: 89 f9 mov %edi,%ecx + bi = b % BPB; +8010141b: 81 e7 ff 0f 00 00 and $0xfff,%edi +80101421: 89 fa mov %edi,%edx + m = 1 << (bi % 8); +80101423: 83 e1 07 and $0x7,%ecx + if((bp->data[bi/8] & m) == 0) +80101426: c1 fa 03 sar $0x3,%edx + m = 1 << (bi % 8); +80101429: d3 e3 shl %cl,%ebx + bp = bread(dev, BBLOCK(b, sb)); +8010142b: 89 c6 mov %eax,%esi + if((bp->data[bi/8] & m) == 0) +8010142d: 0f b6 44 10 5c movzbl 0x5c(%eax,%edx,1),%eax +80101432: 0f b6 c8 movzbl %al,%ecx +80101435: 85 d9 test %ebx,%ecx +80101437: 74 20 je 80101459 + bp->data[bi/8] &= ~m; +80101439: f7 d3 not %ebx +8010143b: 21 c3 and %eax,%ebx +8010143d: 88 5c 16 5c mov %bl,0x5c(%esi,%edx,1) + log_write(bp); +80101441: 89 34 24 mov %esi,(%esp) +80101444: e8 67 18 00 00 call 80102cb0 + brelse(bp); +80101449: 89 34 24 mov %esi,(%esp) +8010144c: e8 8f ed ff ff call 801001e0 +} +80101451: 83 c4 1c add $0x1c,%esp +80101454: 5b pop %ebx +80101455: 5e pop %esi +80101456: 5f pop %edi +80101457: 5d pop %ebp +80101458: c3 ret + panic("freeing free block"); +80101459: c7 04 24 18 6f 10 80 movl $0x80106f18,(%esp) +80101460: e8 fb ee ff ff call 80100360 +80101465: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80101469: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80101470 : +{ +80101470: 55 push %ebp +80101471: 89 e5 mov %esp,%ebp +80101473: 53 push %ebx +80101474: bb 20 0a 11 80 mov $0x80110a20,%ebx +80101479: 83 ec 24 sub $0x24,%esp + initlock(&icache.lock, "icache"); +8010147c: c7 44 24 04 2b 6f 10 movl $0x80106f2b,0x4(%esp) +80101483: 80 +80101484: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) +8010148b: e8 c0 2b 00 00 call 80104050 + initsleeplock(&icache.inode[i].lock, "inode"); +80101490: 89 1c 24 mov %ebx,(%esp) +80101493: 81 c3 90 00 00 00 add $0x90,%ebx +80101499: c7 44 24 04 32 6f 10 movl $0x80106f32,0x4(%esp) +801014a0: 80 +801014a1: e8 9a 2a 00 00 call 80103f40 + for(i = 0; i < NINODE; i++) { +801014a6: 81 fb 40 26 11 80 cmp $0x80112640,%ebx +801014ac: 75 e2 jne 80101490 + readsb(dev, &sb); +801014ae: 8b 45 08 mov 0x8(%ebp),%eax +801014b1: c7 44 24 04 c0 09 11 movl $0x801109c0,0x4(%esp) +801014b8: 80 +801014b9: 89 04 24 mov %eax,(%esp) +801014bc: e8 cf fe ff ff call 80101390 + cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d\ +801014c1: a1 d8 09 11 80 mov 0x801109d8,%eax +801014c6: c7 04 24 98 6f 10 80 movl $0x80106f98,(%esp) +801014cd: 89 44 24 1c mov %eax,0x1c(%esp) +801014d1: a1 d4 09 11 80 mov 0x801109d4,%eax +801014d6: 89 44 24 18 mov %eax,0x18(%esp) +801014da: a1 d0 09 11 80 mov 0x801109d0,%eax +801014df: 89 44 24 14 mov %eax,0x14(%esp) +801014e3: a1 cc 09 11 80 mov 0x801109cc,%eax +801014e8: 89 44 24 10 mov %eax,0x10(%esp) +801014ec: a1 c8 09 11 80 mov 0x801109c8,%eax +801014f1: 89 44 24 0c mov %eax,0xc(%esp) +801014f5: a1 c4 09 11 80 mov 0x801109c4,%eax +801014fa: 89 44 24 08 mov %eax,0x8(%esp) +801014fe: a1 c0 09 11 80 mov 0x801109c0,%eax +80101503: 89 44 24 04 mov %eax,0x4(%esp) +80101507: e8 44 f1 ff ff call 80100650 +} +8010150c: 83 c4 24 add $0x24,%esp +8010150f: 5b pop %ebx +80101510: 5d pop %ebp +80101511: c3 ret +80101512: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80101519: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80101520 : +{ +80101520: 55 push %ebp +80101521: 89 e5 mov %esp,%ebp +80101523: 57 push %edi +80101524: 56 push %esi +80101525: 53 push %ebx +80101526: 83 ec 2c sub $0x2c,%esp +80101529: 8b 45 0c mov 0xc(%ebp),%eax + for(inum = 1; inum < sb.ninodes; inum++){ +8010152c: 83 3d c8 09 11 80 01 cmpl $0x1,0x801109c8 +{ +80101533: 8b 7d 08 mov 0x8(%ebp),%edi +80101536: 89 45 e4 mov %eax,-0x1c(%ebp) + for(inum = 1; inum < sb.ninodes; inum++){ +80101539: 0f 86 a2 00 00 00 jbe 801015e1 +8010153f: be 01 00 00 00 mov $0x1,%esi +80101544: bb 01 00 00 00 mov $0x1,%ebx +80101549: eb 1a jmp 80101565 +8010154b: 90 nop +8010154c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + brelse(bp); +80101550: 89 14 24 mov %edx,(%esp) + for(inum = 1; inum < sb.ninodes; inum++){ +80101553: 83 c3 01 add $0x1,%ebx + brelse(bp); +80101556: e8 85 ec ff ff call 801001e0 + for(inum = 1; inum < sb.ninodes; inum++){ +8010155b: 89 de mov %ebx,%esi +8010155d: 3b 1d c8 09 11 80 cmp 0x801109c8,%ebx +80101563: 73 7c jae 801015e1 + bp = bread(dev, IBLOCK(inum, sb)); +80101565: 89 f0 mov %esi,%eax +80101567: c1 e8 03 shr $0x3,%eax +8010156a: 03 05 d4 09 11 80 add 0x801109d4,%eax +80101570: 89 3c 24 mov %edi,(%esp) +80101573: 89 44 24 04 mov %eax,0x4(%esp) +80101577: e8 54 eb ff ff call 801000d0 +8010157c: 89 c2 mov %eax,%edx + dip = (struct dinode*)bp->data + inum%IPB; +8010157e: 89 f0 mov %esi,%eax +80101580: 83 e0 07 and $0x7,%eax +80101583: c1 e0 06 shl $0x6,%eax +80101586: 8d 4c 02 5c lea 0x5c(%edx,%eax,1),%ecx + if(dip->type == 0){ // a free inode +8010158a: 66 83 39 00 cmpw $0x0,(%ecx) +8010158e: 75 c0 jne 80101550 + memset(dip, 0, sizeof(*dip)); +80101590: 89 0c 24 mov %ecx,(%esp) +80101593: c7 44 24 08 40 00 00 movl $0x40,0x8(%esp) +8010159a: 00 +8010159b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +801015a2: 00 +801015a3: 89 55 dc mov %edx,-0x24(%ebp) +801015a6: 89 4d e0 mov %ecx,-0x20(%ebp) +801015a9: e8 d2 2c 00 00 call 80104280 + dip->type = type; +801015ae: 0f b7 45 e4 movzwl -0x1c(%ebp),%eax + log_write(bp); // mark it allocated on the disk +801015b2: 8b 55 dc mov -0x24(%ebp),%edx + dip->type = type; +801015b5: 8b 4d e0 mov -0x20(%ebp),%ecx + log_write(bp); // mark it allocated on the disk +801015b8: 89 55 e4 mov %edx,-0x1c(%ebp) + dip->type = type; +801015bb: 66 89 01 mov %ax,(%ecx) + log_write(bp); // mark it allocated on the disk +801015be: 89 14 24 mov %edx,(%esp) +801015c1: e8 ea 16 00 00 call 80102cb0 + brelse(bp); +801015c6: 8b 55 e4 mov -0x1c(%ebp),%edx +801015c9: 89 14 24 mov %edx,(%esp) +801015cc: e8 0f ec ff ff call 801001e0 +} +801015d1: 83 c4 2c add $0x2c,%esp + return iget(dev, inum); +801015d4: 89 f2 mov %esi,%edx +} +801015d6: 5b pop %ebx + return iget(dev, inum); +801015d7: 89 f8 mov %edi,%eax +} +801015d9: 5e pop %esi +801015da: 5f pop %edi +801015db: 5d pop %ebp + return iget(dev, inum); +801015dc: e9 2f fc ff ff jmp 80101210 + panic("ialloc: no inodes"); +801015e1: c7 04 24 38 6f 10 80 movl $0x80106f38,(%esp) +801015e8: e8 73 ed ff ff call 80100360 +801015ed: 8d 76 00 lea 0x0(%esi),%esi + +801015f0 : +{ +801015f0: 55 push %ebp +801015f1: 89 e5 mov %esp,%ebp +801015f3: 56 push %esi +801015f4: 53 push %ebx +801015f5: 83 ec 10 sub $0x10,%esp +801015f8: 8b 5d 08 mov 0x8(%ebp),%ebx + bp = bread(ip->dev, IBLOCK(ip->inum, sb)); +801015fb: 8b 43 04 mov 0x4(%ebx),%eax + memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); +801015fe: 83 c3 5c add $0x5c,%ebx + bp = bread(ip->dev, IBLOCK(ip->inum, sb)); +80101601: c1 e8 03 shr $0x3,%eax +80101604: 03 05 d4 09 11 80 add 0x801109d4,%eax +8010160a: 89 44 24 04 mov %eax,0x4(%esp) +8010160e: 8b 43 a4 mov -0x5c(%ebx),%eax +80101611: 89 04 24 mov %eax,(%esp) +80101614: e8 b7 ea ff ff call 801000d0 + dip = (struct dinode*)bp->data + ip->inum%IPB; +80101619: 8b 53 a8 mov -0x58(%ebx),%edx +8010161c: 83 e2 07 and $0x7,%edx +8010161f: c1 e2 06 shl $0x6,%edx +80101622: 8d 54 10 5c lea 0x5c(%eax,%edx,1),%edx + bp = bread(ip->dev, IBLOCK(ip->inum, sb)); +80101626: 89 c6 mov %eax,%esi + dip->type = ip->type; +80101628: 0f b7 43 f4 movzwl -0xc(%ebx),%eax + memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); +8010162c: 83 c2 0c add $0xc,%edx + dip->type = ip->type; +8010162f: 66 89 42 f4 mov %ax,-0xc(%edx) + dip->major = ip->major; +80101633: 0f b7 43 f6 movzwl -0xa(%ebx),%eax +80101637: 66 89 42 f6 mov %ax,-0xa(%edx) + dip->minor = ip->minor; +8010163b: 0f b7 43 f8 movzwl -0x8(%ebx),%eax +8010163f: 66 89 42 f8 mov %ax,-0x8(%edx) + dip->nlink = ip->nlink; +80101643: 0f b7 43 fa movzwl -0x6(%ebx),%eax +80101647: 66 89 42 fa mov %ax,-0x6(%edx) + dip->size = ip->size; +8010164b: 8b 43 fc mov -0x4(%ebx),%eax +8010164e: 89 42 fc mov %eax,-0x4(%edx) + memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); +80101651: 89 5c 24 04 mov %ebx,0x4(%esp) +80101655: 89 14 24 mov %edx,(%esp) +80101658: c7 44 24 08 34 00 00 movl $0x34,0x8(%esp) +8010165f: 00 +80101660: e8 bb 2c 00 00 call 80104320 + log_write(bp); +80101665: 89 34 24 mov %esi,(%esp) +80101668: e8 43 16 00 00 call 80102cb0 + brelse(bp); +8010166d: 89 75 08 mov %esi,0x8(%ebp) +} +80101670: 83 c4 10 add $0x10,%esp +80101673: 5b pop %ebx +80101674: 5e pop %esi +80101675: 5d pop %ebp + brelse(bp); +80101676: e9 65 eb ff ff jmp 801001e0 +8010167b: 90 nop +8010167c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80101680 : +{ +80101680: 55 push %ebp +80101681: 89 e5 mov %esp,%ebp +80101683: 53 push %ebx +80101684: 83 ec 14 sub $0x14,%esp +80101687: 8b 5d 08 mov 0x8(%ebp),%ebx + acquire(&icache.lock); +8010168a: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) +80101691: e8 aa 2a 00 00 call 80104140 + ip->ref++; +80101696: 83 43 08 01 addl $0x1,0x8(%ebx) + release(&icache.lock); +8010169a: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) +801016a1: e8 8a 2b 00 00 call 80104230 +} +801016a6: 83 c4 14 add $0x14,%esp +801016a9: 89 d8 mov %ebx,%eax +801016ab: 5b pop %ebx +801016ac: 5d pop %ebp +801016ad: c3 ret +801016ae: 66 90 xchg %ax,%ax + +801016b0 : +{ +801016b0: 55 push %ebp +801016b1: 89 e5 mov %esp,%ebp +801016b3: 56 push %esi +801016b4: 53 push %ebx +801016b5: 83 ec 10 sub $0x10,%esp +801016b8: 8b 5d 08 mov 0x8(%ebp),%ebx + if(ip == 0 || ip->ref < 1) +801016bb: 85 db test %ebx,%ebx +801016bd: 0f 84 b3 00 00 00 je 80101776 +801016c3: 8b 53 08 mov 0x8(%ebx),%edx +801016c6: 85 d2 test %edx,%edx +801016c8: 0f 8e a8 00 00 00 jle 80101776 + acquiresleep(&ip->lock); +801016ce: 8d 43 0c lea 0xc(%ebx),%eax +801016d1: 89 04 24 mov %eax,(%esp) +801016d4: e8 a7 28 00 00 call 80103f80 + if(ip->valid == 0){ +801016d9: 8b 43 4c mov 0x4c(%ebx),%eax +801016dc: 85 c0 test %eax,%eax +801016de: 74 08 je 801016e8 +} +801016e0: 83 c4 10 add $0x10,%esp +801016e3: 5b pop %ebx +801016e4: 5e pop %esi +801016e5: 5d pop %ebp +801016e6: c3 ret +801016e7: 90 nop + bp = bread(ip->dev, IBLOCK(ip->inum, sb)); +801016e8: 8b 43 04 mov 0x4(%ebx),%eax +801016eb: c1 e8 03 shr $0x3,%eax +801016ee: 03 05 d4 09 11 80 add 0x801109d4,%eax +801016f4: 89 44 24 04 mov %eax,0x4(%esp) +801016f8: 8b 03 mov (%ebx),%eax +801016fa: 89 04 24 mov %eax,(%esp) +801016fd: e8 ce e9 ff ff call 801000d0 + dip = (struct dinode*)bp->data + ip->inum%IPB; +80101702: 8b 53 04 mov 0x4(%ebx),%edx +80101705: 83 e2 07 and $0x7,%edx +80101708: c1 e2 06 shl $0x6,%edx +8010170b: 8d 54 10 5c lea 0x5c(%eax,%edx,1),%edx + bp = bread(ip->dev, IBLOCK(ip->inum, sb)); +8010170f: 89 c6 mov %eax,%esi + ip->type = dip->type; +80101711: 0f b7 02 movzwl (%edx),%eax + memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); +80101714: 83 c2 0c add $0xc,%edx + ip->type = dip->type; +80101717: 66 89 43 50 mov %ax,0x50(%ebx) + ip->major = dip->major; +8010171b: 0f b7 42 f6 movzwl -0xa(%edx),%eax +8010171f: 66 89 43 52 mov %ax,0x52(%ebx) + ip->minor = dip->minor; +80101723: 0f b7 42 f8 movzwl -0x8(%edx),%eax +80101727: 66 89 43 54 mov %ax,0x54(%ebx) + ip->nlink = dip->nlink; +8010172b: 0f b7 42 fa movzwl -0x6(%edx),%eax +8010172f: 66 89 43 56 mov %ax,0x56(%ebx) + ip->size = dip->size; +80101733: 8b 42 fc mov -0x4(%edx),%eax +80101736: 89 43 58 mov %eax,0x58(%ebx) + memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); +80101739: 8d 43 5c lea 0x5c(%ebx),%eax +8010173c: 89 54 24 04 mov %edx,0x4(%esp) +80101740: c7 44 24 08 34 00 00 movl $0x34,0x8(%esp) +80101747: 00 +80101748: 89 04 24 mov %eax,(%esp) +8010174b: e8 d0 2b 00 00 call 80104320 + brelse(bp); +80101750: 89 34 24 mov %esi,(%esp) +80101753: e8 88 ea ff ff call 801001e0 + if(ip->type == 0) +80101758: 66 83 7b 50 00 cmpw $0x0,0x50(%ebx) + ip->valid = 1; +8010175d: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) + if(ip->type == 0) +80101764: 0f 85 76 ff ff ff jne 801016e0 + panic("ilock: no type"); +8010176a: c7 04 24 50 6f 10 80 movl $0x80106f50,(%esp) +80101771: e8 ea eb ff ff call 80100360 + panic("ilock"); +80101776: c7 04 24 4a 6f 10 80 movl $0x80106f4a,(%esp) +8010177d: e8 de eb ff ff call 80100360 +80101782: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80101789: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80101790 : +{ +80101790: 55 push %ebp +80101791: 89 e5 mov %esp,%ebp +80101793: 56 push %esi +80101794: 53 push %ebx +80101795: 83 ec 10 sub $0x10,%esp +80101798: 8b 5d 08 mov 0x8(%ebp),%ebx + if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) +8010179b: 85 db test %ebx,%ebx +8010179d: 74 24 je 801017c3 +8010179f: 8d 73 0c lea 0xc(%ebx),%esi +801017a2: 89 34 24 mov %esi,(%esp) +801017a5: e8 76 28 00 00 call 80104020 +801017aa: 85 c0 test %eax,%eax +801017ac: 74 15 je 801017c3 +801017ae: 8b 43 08 mov 0x8(%ebx),%eax +801017b1: 85 c0 test %eax,%eax +801017b3: 7e 0e jle 801017c3 + releasesleep(&ip->lock); +801017b5: 89 75 08 mov %esi,0x8(%ebp) +} +801017b8: 83 c4 10 add $0x10,%esp +801017bb: 5b pop %ebx +801017bc: 5e pop %esi +801017bd: 5d pop %ebp + releasesleep(&ip->lock); +801017be: e9 1d 28 00 00 jmp 80103fe0 + panic("iunlock"); +801017c3: c7 04 24 5f 6f 10 80 movl $0x80106f5f,(%esp) +801017ca: e8 91 eb ff ff call 80100360 +801017cf: 90 nop + +801017d0 : +{ +801017d0: 55 push %ebp +801017d1: 89 e5 mov %esp,%ebp +801017d3: 57 push %edi +801017d4: 56 push %esi +801017d5: 53 push %ebx +801017d6: 83 ec 1c sub $0x1c,%esp +801017d9: 8b 75 08 mov 0x8(%ebp),%esi + acquiresleep(&ip->lock); +801017dc: 8d 7e 0c lea 0xc(%esi),%edi +801017df: 89 3c 24 mov %edi,(%esp) +801017e2: e8 99 27 00 00 call 80103f80 + if(ip->valid && ip->nlink == 0){ +801017e7: 8b 56 4c mov 0x4c(%esi),%edx +801017ea: 85 d2 test %edx,%edx +801017ec: 74 07 je 801017f5 +801017ee: 66 83 7e 56 00 cmpw $0x0,0x56(%esi) +801017f3: 74 2b je 80101820 + releasesleep(&ip->lock); +801017f5: 89 3c 24 mov %edi,(%esp) +801017f8: e8 e3 27 00 00 call 80103fe0 + acquire(&icache.lock); +801017fd: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) +80101804: e8 37 29 00 00 call 80104140 + ip->ref--; +80101809: 83 6e 08 01 subl $0x1,0x8(%esi) + release(&icache.lock); +8010180d: c7 45 08 e0 09 11 80 movl $0x801109e0,0x8(%ebp) +} +80101814: 83 c4 1c add $0x1c,%esp +80101817: 5b pop %ebx +80101818: 5e pop %esi +80101819: 5f pop %edi +8010181a: 5d pop %ebp + release(&icache.lock); +8010181b: e9 10 2a 00 00 jmp 80104230 + acquire(&icache.lock); +80101820: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) +80101827: e8 14 29 00 00 call 80104140 + int r = ip->ref; +8010182c: 8b 5e 08 mov 0x8(%esi),%ebx + release(&icache.lock); +8010182f: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) +80101836: e8 f5 29 00 00 call 80104230 + if(r == 1){ +8010183b: 83 fb 01 cmp $0x1,%ebx +8010183e: 75 b5 jne 801017f5 +80101840: 8d 4e 30 lea 0x30(%esi),%ecx +80101843: 89 f3 mov %esi,%ebx +80101845: 89 7d e4 mov %edi,-0x1c(%ebp) +80101848: 89 cf mov %ecx,%edi +8010184a: eb 0b jmp 80101857 +8010184c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80101850: 83 c3 04 add $0x4,%ebx +{ + int i, j; + struct buf *bp; + uint *a; + + for(i = 0; i < NDIRECT; i++){ +80101853: 39 fb cmp %edi,%ebx +80101855: 74 19 je 80101870 + if(ip->addrs[i]){ +80101857: 8b 53 5c mov 0x5c(%ebx),%edx +8010185a: 85 d2 test %edx,%edx +8010185c: 74 f2 je 80101850 + bfree(ip->dev, ip->addrs[i]); +8010185e: 8b 06 mov (%esi),%eax +80101860: e8 7b fb ff ff call 801013e0 + ip->addrs[i] = 0; +80101865: c7 43 5c 00 00 00 00 movl $0x0,0x5c(%ebx) +8010186c: eb e2 jmp 80101850 +8010186e: 66 90 xchg %ax,%ax + } + } + + if(ip->addrs[NDIRECT]){ +80101870: 8b 86 8c 00 00 00 mov 0x8c(%esi),%eax +80101876: 8b 7d e4 mov -0x1c(%ebp),%edi +80101879: 85 c0 test %eax,%eax +8010187b: 75 2b jne 801018a8 + brelse(bp); + bfree(ip->dev, ip->addrs[NDIRECT]); + ip->addrs[NDIRECT] = 0; + } + + ip->size = 0; +8010187d: c7 46 58 00 00 00 00 movl $0x0,0x58(%esi) + iupdate(ip); +80101884: 89 34 24 mov %esi,(%esp) +80101887: e8 64 fd ff ff call 801015f0 + ip->type = 0; +8010188c: 31 c0 xor %eax,%eax +8010188e: 66 89 46 50 mov %ax,0x50(%esi) + iupdate(ip); +80101892: 89 34 24 mov %esi,(%esp) +80101895: e8 56 fd ff ff call 801015f0 + ip->valid = 0; +8010189a: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) +801018a1: e9 4f ff ff ff jmp 801017f5 +801018a6: 66 90 xchg %ax,%ax + bp = bread(ip->dev, ip->addrs[NDIRECT]); +801018a8: 89 44 24 04 mov %eax,0x4(%esp) +801018ac: 8b 06 mov (%esi),%eax + for(j = 0; j < NINDIRECT; j++){ +801018ae: 31 db xor %ebx,%ebx + bp = bread(ip->dev, ip->addrs[NDIRECT]); +801018b0: 89 04 24 mov %eax,(%esp) +801018b3: e8 18 e8 ff ff call 801000d0 + for(j = 0; j < NINDIRECT; j++){ +801018b8: 89 7d e0 mov %edi,-0x20(%ebp) + a = (uint*)bp->data; +801018bb: 8d 48 5c lea 0x5c(%eax),%ecx + bp = bread(ip->dev, ip->addrs[NDIRECT]); +801018be: 89 45 e4 mov %eax,-0x1c(%ebp) + for(j = 0; j < NINDIRECT; j++){ +801018c1: 89 cf mov %ecx,%edi +801018c3: 31 c0 xor %eax,%eax +801018c5: eb 0e jmp 801018d5 +801018c7: 90 nop +801018c8: 83 c3 01 add $0x1,%ebx +801018cb: 81 fb 80 00 00 00 cmp $0x80,%ebx +801018d1: 89 d8 mov %ebx,%eax +801018d3: 74 10 je 801018e5 + if(a[j]) +801018d5: 8b 14 87 mov (%edi,%eax,4),%edx +801018d8: 85 d2 test %edx,%edx +801018da: 74 ec je 801018c8 + bfree(ip->dev, a[j]); +801018dc: 8b 06 mov (%esi),%eax +801018de: e8 fd fa ff ff call 801013e0 +801018e3: eb e3 jmp 801018c8 + brelse(bp); +801018e5: 8b 45 e4 mov -0x1c(%ebp),%eax +801018e8: 8b 7d e0 mov -0x20(%ebp),%edi +801018eb: 89 04 24 mov %eax,(%esp) +801018ee: e8 ed e8 ff ff call 801001e0 + bfree(ip->dev, ip->addrs[NDIRECT]); +801018f3: 8b 96 8c 00 00 00 mov 0x8c(%esi),%edx +801018f9: 8b 06 mov (%esi),%eax +801018fb: e8 e0 fa ff ff call 801013e0 + ip->addrs[NDIRECT] = 0; +80101900: c7 86 8c 00 00 00 00 movl $0x0,0x8c(%esi) +80101907: 00 00 00 +8010190a: e9 6e ff ff ff jmp 8010187d +8010190f: 90 nop + +80101910 : +{ +80101910: 55 push %ebp +80101911: 89 e5 mov %esp,%ebp +80101913: 53 push %ebx +80101914: 83 ec 14 sub $0x14,%esp +80101917: 8b 5d 08 mov 0x8(%ebp),%ebx + iunlock(ip); +8010191a: 89 1c 24 mov %ebx,(%esp) +8010191d: e8 6e fe ff ff call 80101790 + iput(ip); +80101922: 89 5d 08 mov %ebx,0x8(%ebp) +} +80101925: 83 c4 14 add $0x14,%esp +80101928: 5b pop %ebx +80101929: 5d pop %ebp + iput(ip); +8010192a: e9 a1 fe ff ff jmp 801017d0 +8010192f: 90 nop + +80101930 : + +// Copy stat information from inode. +// Caller must hold ip->lock. +void +stati(struct inode *ip, struct stat *st) +{ +80101930: 55 push %ebp +80101931: 89 e5 mov %esp,%ebp +80101933: 8b 55 08 mov 0x8(%ebp),%edx +80101936: 8b 45 0c mov 0xc(%ebp),%eax + st->dev = ip->dev; +80101939: 8b 0a mov (%edx),%ecx +8010193b: 89 48 04 mov %ecx,0x4(%eax) + st->ino = ip->inum; +8010193e: 8b 4a 04 mov 0x4(%edx),%ecx +80101941: 89 48 08 mov %ecx,0x8(%eax) + st->type = ip->type; +80101944: 0f b7 4a 50 movzwl 0x50(%edx),%ecx +80101948: 66 89 08 mov %cx,(%eax) + st->nlink = ip->nlink; +8010194b: 0f b7 4a 56 movzwl 0x56(%edx),%ecx +8010194f: 66 89 48 0c mov %cx,0xc(%eax) + st->size = ip->size; +80101953: 8b 52 58 mov 0x58(%edx),%edx +80101956: 89 50 10 mov %edx,0x10(%eax) +} +80101959: 5d pop %ebp +8010195a: c3 ret +8010195b: 90 nop +8010195c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80101960 : +//PAGEBREAK! +// Read data from inode. +// Caller must hold ip->lock. +int +readi(struct inode *ip, char *dst, uint off, uint n) +{ +80101960: 55 push %ebp +80101961: 89 e5 mov %esp,%ebp +80101963: 57 push %edi +80101964: 56 push %esi +80101965: 53 push %ebx +80101966: 83 ec 2c sub $0x2c,%esp +80101969: 8b 45 0c mov 0xc(%ebp),%eax +8010196c: 8b 7d 08 mov 0x8(%ebp),%edi +8010196f: 8b 75 10 mov 0x10(%ebp),%esi +80101972: 89 45 e0 mov %eax,-0x20(%ebp) +80101975: 8b 45 14 mov 0x14(%ebp),%eax + uint tot, m; + struct buf *bp; + + if(ip->type == T_DEV){ +80101978: 66 83 7f 50 03 cmpw $0x3,0x50(%edi) +{ +8010197d: 89 45 e4 mov %eax,-0x1c(%ebp) + if(ip->type == T_DEV){ +80101980: 0f 84 aa 00 00 00 je 80101a30 + if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) + return -1; + return devsw[ip->major].read(ip, dst, n); + } + + if(off > ip->size || off + n < off) +80101986: 8b 47 58 mov 0x58(%edi),%eax +80101989: 39 f0 cmp %esi,%eax +8010198b: 0f 82 c7 00 00 00 jb 80101a58 +80101991: 8b 5d e4 mov -0x1c(%ebp),%ebx +80101994: 89 da mov %ebx,%edx +80101996: 01 f2 add %esi,%edx +80101998: 0f 82 ba 00 00 00 jb 80101a58 + return -1; + if(off + n > ip->size) + n = ip->size - off; +8010199e: 89 c1 mov %eax,%ecx +801019a0: 29 f1 sub %esi,%ecx +801019a2: 39 d0 cmp %edx,%eax +801019a4: 0f 43 cb cmovae %ebx,%ecx + + for(tot=0; totsize - off; +801019ab: 89 4d e4 mov %ecx,-0x1c(%ebp) + for(tot=0; tot +801019b0: 89 7d d8 mov %edi,-0x28(%ebp) +801019b3: 89 c7 mov %eax,%edi +801019b5: 8d 76 00 lea 0x0(%esi),%esi + bp = bread(ip->dev, bmap(ip, off/BSIZE)); +801019b8: 8b 5d d8 mov -0x28(%ebp),%ebx +801019bb: 89 f2 mov %esi,%edx +801019bd: c1 ea 09 shr $0x9,%edx +801019c0: 89 d8 mov %ebx,%eax +801019c2: e8 09 f9 ff ff call 801012d0 +801019c7: 89 44 24 04 mov %eax,0x4(%esp) +801019cb: 8b 03 mov (%ebx),%eax + m = min(n - tot, BSIZE - off%BSIZE); +801019cd: bb 00 02 00 00 mov $0x200,%ebx + bp = bread(ip->dev, bmap(ip, off/BSIZE)); +801019d2: 89 04 24 mov %eax,(%esp) +801019d5: e8 f6 e6 ff ff call 801000d0 + m = min(n - tot, BSIZE - off%BSIZE); +801019da: 8b 4d e4 mov -0x1c(%ebp),%ecx +801019dd: 29 f9 sub %edi,%ecx + bp = bread(ip->dev, bmap(ip, off/BSIZE)); +801019df: 89 c2 mov %eax,%edx + m = min(n - tot, BSIZE - off%BSIZE); +801019e1: 89 f0 mov %esi,%eax +801019e3: 25 ff 01 00 00 and $0x1ff,%eax +801019e8: 29 c3 sub %eax,%ebx + memmove(dst, bp->data + off%BSIZE, m); +801019ea: 8d 44 02 5c lea 0x5c(%edx,%eax,1),%eax + m = min(n - tot, BSIZE - off%BSIZE); +801019ee: 39 cb cmp %ecx,%ebx + memmove(dst, bp->data + off%BSIZE, m); +801019f0: 89 44 24 04 mov %eax,0x4(%esp) +801019f4: 8b 45 e0 mov -0x20(%ebp),%eax + m = min(n - tot, BSIZE - off%BSIZE); +801019f7: 0f 47 d9 cmova %ecx,%ebx + memmove(dst, bp->data + off%BSIZE, m); +801019fa: 89 5c 24 08 mov %ebx,0x8(%esp) + for(tot=0; totdata + off%BSIZE, m); +80101a02: 89 55 dc mov %edx,-0x24(%ebp) +80101a05: 89 04 24 mov %eax,(%esp) +80101a08: e8 13 29 00 00 call 80104320 + brelse(bp); +80101a0d: 8b 55 dc mov -0x24(%ebp),%edx +80101a10: 89 14 24 mov %edx,(%esp) +80101a13: e8 c8 e7 ff ff call 801001e0 + for(tot=0; tot + } + return n; +80101a20: 8b 45 e4 mov -0x1c(%ebp),%eax +} +80101a23: 83 c4 2c add $0x2c,%esp +80101a26: 5b pop %ebx +80101a27: 5e pop %esi +80101a28: 5f pop %edi +80101a29: 5d pop %ebp +80101a2a: c3 ret +80101a2b: 90 nop +80101a2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) +80101a30: 0f bf 47 52 movswl 0x52(%edi),%eax +80101a34: 66 83 f8 09 cmp $0x9,%ax +80101a38: 77 1e ja 80101a58 +80101a3a: 8b 04 c5 60 09 11 80 mov -0x7feef6a0(,%eax,8),%eax +80101a41: 85 c0 test %eax,%eax +80101a43: 74 13 je 80101a58 + return devsw[ip->major].read(ip, dst, n); +80101a45: 8b 75 e4 mov -0x1c(%ebp),%esi +80101a48: 89 75 10 mov %esi,0x10(%ebp) +} +80101a4b: 83 c4 2c add $0x2c,%esp +80101a4e: 5b pop %ebx +80101a4f: 5e pop %esi +80101a50: 5f pop %edi +80101a51: 5d pop %ebp + return devsw[ip->major].read(ip, dst, n); +80101a52: ff e0 jmp *%eax +80101a54: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; +80101a58: b8 ff ff ff ff mov $0xffffffff,%eax +80101a5d: eb c4 jmp 80101a23 +80101a5f: 90 nop + +80101a60 : +// PAGEBREAK! +// Write data to inode. +// Caller must hold ip->lock. +int +writei(struct inode *ip, char *src, uint off, uint n) +{ +80101a60: 55 push %ebp +80101a61: 89 e5 mov %esp,%ebp +80101a63: 57 push %edi +80101a64: 56 push %esi +80101a65: 53 push %ebx +80101a66: 83 ec 2c sub $0x2c,%esp +80101a69: 8b 45 08 mov 0x8(%ebp),%eax +80101a6c: 8b 75 0c mov 0xc(%ebp),%esi +80101a6f: 8b 4d 14 mov 0x14(%ebp),%ecx + uint tot, m; + struct buf *bp; + + if(ip->type == T_DEV){ +80101a72: 66 83 78 50 03 cmpw $0x3,0x50(%eax) +{ +80101a77: 89 75 dc mov %esi,-0x24(%ebp) +80101a7a: 8b 75 10 mov 0x10(%ebp),%esi +80101a7d: 89 45 d8 mov %eax,-0x28(%ebp) +80101a80: 89 4d e0 mov %ecx,-0x20(%ebp) + if(ip->type == T_DEV){ +80101a83: 0f 84 b7 00 00 00 je 80101b40 + if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) + return -1; + return devsw[ip->major].write(ip, src, n); + } + + if(off > ip->size || off + n < off) +80101a89: 8b 45 d8 mov -0x28(%ebp),%eax +80101a8c: 39 70 58 cmp %esi,0x58(%eax) +80101a8f: 0f 82 e3 00 00 00 jb 80101b78 +80101a95: 8b 4d e0 mov -0x20(%ebp),%ecx +80101a98: 89 c8 mov %ecx,%eax +80101a9a: 01 f0 add %esi,%eax +80101a9c: 0f 82 d6 00 00 00 jb 80101b78 + return -1; + if(off + n > MAXFILE*BSIZE) +80101aa2: 3d 00 18 01 00 cmp $0x11800,%eax +80101aa7: 0f 87 cb 00 00 00 ja 80101b78 + return -1; + + for(tot=0; tot + bp = bread(ip->dev, bmap(ip, off/BSIZE)); +80101ab8: 8b 7d d8 mov -0x28(%ebp),%edi +80101abb: 89 f2 mov %esi,%edx + m = min(n - tot, BSIZE - off%BSIZE); +80101abd: bb 00 02 00 00 mov $0x200,%ebx + bp = bread(ip->dev, bmap(ip, off/BSIZE)); +80101ac2: c1 ea 09 shr $0x9,%edx +80101ac5: 89 f8 mov %edi,%eax +80101ac7: e8 04 f8 ff ff call 801012d0 +80101acc: 89 44 24 04 mov %eax,0x4(%esp) +80101ad0: 8b 07 mov (%edi),%eax +80101ad2: 89 04 24 mov %eax,(%esp) +80101ad5: e8 f6 e5 ff ff call 801000d0 + m = min(n - tot, BSIZE - off%BSIZE); +80101ada: 8b 4d e0 mov -0x20(%ebp),%ecx +80101add: 2b 4d e4 sub -0x1c(%ebp),%ecx + memmove(bp->data + off%BSIZE, src, m); +80101ae0: 8b 55 dc mov -0x24(%ebp),%edx + bp = bread(ip->dev, bmap(ip, off/BSIZE)); +80101ae3: 89 c7 mov %eax,%edi + m = min(n - tot, BSIZE - off%BSIZE); +80101ae5: 89 f0 mov %esi,%eax +80101ae7: 25 ff 01 00 00 and $0x1ff,%eax +80101aec: 29 c3 sub %eax,%ebx +80101aee: 39 cb cmp %ecx,%ebx +80101af0: 0f 47 d9 cmova %ecx,%ebx + memmove(bp->data + off%BSIZE, src, m); +80101af3: 8d 44 07 5c lea 0x5c(%edi,%eax,1),%eax + for(tot=0; totdata + off%BSIZE, src, m); +80101af9: 89 54 24 04 mov %edx,0x4(%esp) +80101afd: 89 5c 24 08 mov %ebx,0x8(%esp) +80101b01: 89 04 24 mov %eax,(%esp) +80101b04: e8 17 28 00 00 call 80104320 + log_write(bp); +80101b09: 89 3c 24 mov %edi,(%esp) +80101b0c: e8 9f 11 00 00 call 80102cb0 + brelse(bp); +80101b11: 89 3c 24 mov %edi,(%esp) +80101b14: e8 c7 e6 ff ff call 801001e0 + for(tot=0; tot + } + + if(n > 0 && off > ip->size){ +80101b27: 8b 45 d8 mov -0x28(%ebp),%eax +80101b2a: 39 70 58 cmp %esi,0x58(%eax) +80101b2d: 72 39 jb 80101b68 + ip->size = off; + iupdate(ip); + } + return n; +80101b2f: 8b 45 e0 mov -0x20(%ebp),%eax +} +80101b32: 83 c4 2c add $0x2c,%esp +80101b35: 5b pop %ebx +80101b36: 5e pop %esi +80101b37: 5f pop %edi +80101b38: 5d pop %ebp +80101b39: c3 ret +80101b3a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) +80101b40: 0f bf 40 52 movswl 0x52(%eax),%eax +80101b44: 66 83 f8 09 cmp $0x9,%ax +80101b48: 77 2e ja 80101b78 +80101b4a: 8b 04 c5 64 09 11 80 mov -0x7feef69c(,%eax,8),%eax +80101b51: 85 c0 test %eax,%eax +80101b53: 74 23 je 80101b78 + return devsw[ip->major].write(ip, src, n); +80101b55: 89 4d 10 mov %ecx,0x10(%ebp) +} +80101b58: 83 c4 2c add $0x2c,%esp +80101b5b: 5b pop %ebx +80101b5c: 5e pop %esi +80101b5d: 5f pop %edi +80101b5e: 5d pop %ebp + return devsw[ip->major].write(ip, src, n); +80101b5f: ff e0 jmp *%eax +80101b61: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + ip->size = off; +80101b68: 8b 45 d8 mov -0x28(%ebp),%eax +80101b6b: 89 70 58 mov %esi,0x58(%eax) + iupdate(ip); +80101b6e: 89 04 24 mov %eax,(%esp) +80101b71: e8 7a fa ff ff call 801015f0 +80101b76: eb b7 jmp 80101b2f +} +80101b78: 83 c4 2c add $0x2c,%esp + return -1; +80101b7b: b8 ff ff ff ff mov $0xffffffff,%eax +} +80101b80: 5b pop %ebx +80101b81: 5e pop %esi +80101b82: 5f pop %edi +80101b83: 5d pop %ebp +80101b84: c3 ret +80101b85: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80101b89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80101b90 : +//PAGEBREAK! +// Directories + +int +namecmp(const char *s, const char *t) +{ +80101b90: 55 push %ebp +80101b91: 89 e5 mov %esp,%ebp +80101b93: 83 ec 18 sub $0x18,%esp + return strncmp(s, t, DIRSIZ); +80101b96: 8b 45 0c mov 0xc(%ebp),%eax +80101b99: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) +80101ba0: 00 +80101ba1: 89 44 24 04 mov %eax,0x4(%esp) +80101ba5: 8b 45 08 mov 0x8(%ebp),%eax +80101ba8: 89 04 24 mov %eax,(%esp) +80101bab: e8 f0 27 00 00 call 801043a0 +} +80101bb0: c9 leave +80101bb1: c3 ret +80101bb2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80101bb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80101bc0 : + +// Look for a directory entry in a directory. +// If found, set *poff to byte offset of entry. +struct inode* +dirlookup(struct inode *dp, char *name, uint *poff) +{ +80101bc0: 55 push %ebp +80101bc1: 89 e5 mov %esp,%ebp +80101bc3: 57 push %edi +80101bc4: 56 push %esi +80101bc5: 53 push %ebx +80101bc6: 83 ec 2c sub $0x2c,%esp +80101bc9: 8b 5d 08 mov 0x8(%ebp),%ebx + uint off, inum; + struct dirent de; + + if(dp->type != T_DIR) +80101bcc: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) +80101bd1: 0f 85 97 00 00 00 jne 80101c6e + panic("dirlookup not DIR"); + + for(off = 0; off < dp->size; off += sizeof(de)){ +80101bd7: 8b 53 58 mov 0x58(%ebx),%edx +80101bda: 31 ff xor %edi,%edi +80101bdc: 8d 75 d8 lea -0x28(%ebp),%esi +80101bdf: 85 d2 test %edx,%edx +80101be1: 75 0d jne 80101bf0 +80101be3: eb 73 jmp 80101c58 +80101be5: 8d 76 00 lea 0x0(%esi),%esi +80101be8: 83 c7 10 add $0x10,%edi +80101beb: 39 7b 58 cmp %edi,0x58(%ebx) +80101bee: 76 68 jbe 80101c58 + if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) +80101bf0: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) +80101bf7: 00 +80101bf8: 89 7c 24 08 mov %edi,0x8(%esp) +80101bfc: 89 74 24 04 mov %esi,0x4(%esp) +80101c00: 89 1c 24 mov %ebx,(%esp) +80101c03: e8 58 fd ff ff call 80101960 +80101c08: 83 f8 10 cmp $0x10,%eax +80101c0b: 75 55 jne 80101c62 + panic("dirlookup read"); + if(de.inum == 0) +80101c0d: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) +80101c12: 74 d4 je 80101be8 + return strncmp(s, t, DIRSIZ); +80101c14: 8d 45 da lea -0x26(%ebp),%eax +80101c17: 89 44 24 04 mov %eax,0x4(%esp) +80101c1b: 8b 45 0c mov 0xc(%ebp),%eax +80101c1e: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) +80101c25: 00 +80101c26: 89 04 24 mov %eax,(%esp) +80101c29: e8 72 27 00 00 call 801043a0 + continue; + if(namecmp(name, de.name) == 0){ +80101c2e: 85 c0 test %eax,%eax +80101c30: 75 b6 jne 80101be8 + // entry matches path element + if(poff) +80101c32: 8b 45 10 mov 0x10(%ebp),%eax +80101c35: 85 c0 test %eax,%eax +80101c37: 74 05 je 80101c3e + *poff = off; +80101c39: 8b 45 10 mov 0x10(%ebp),%eax +80101c3c: 89 38 mov %edi,(%eax) + inum = de.inum; +80101c3e: 0f b7 55 d8 movzwl -0x28(%ebp),%edx + return iget(dp->dev, inum); +80101c42: 8b 03 mov (%ebx),%eax +80101c44: e8 c7 f5 ff ff call 80101210 + } + } + + return 0; +} +80101c49: 83 c4 2c add $0x2c,%esp +80101c4c: 5b pop %ebx +80101c4d: 5e pop %esi +80101c4e: 5f pop %edi +80101c4f: 5d pop %ebp +80101c50: c3 ret +80101c51: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80101c58: 83 c4 2c add $0x2c,%esp + return 0; +80101c5b: 31 c0 xor %eax,%eax +} +80101c5d: 5b pop %ebx +80101c5e: 5e pop %esi +80101c5f: 5f pop %edi +80101c60: 5d pop %ebp +80101c61: c3 ret + panic("dirlookup read"); +80101c62: c7 04 24 79 6f 10 80 movl $0x80106f79,(%esp) +80101c69: e8 f2 e6 ff ff call 80100360 + panic("dirlookup not DIR"); +80101c6e: c7 04 24 67 6f 10 80 movl $0x80106f67,(%esp) +80101c75: e8 e6 e6 ff ff call 80100360 +80101c7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80101c80 : +// If parent != 0, return the inode for the parent and copy the final +// path element into name, which must have room for DIRSIZ bytes. +// Must be called inside a transaction since it calls iput(). +static struct inode* +namex(char *path, int nameiparent, char *name) +{ +80101c80: 55 push %ebp +80101c81: 89 e5 mov %esp,%ebp +80101c83: 57 push %edi +80101c84: 89 cf mov %ecx,%edi +80101c86: 56 push %esi +80101c87: 53 push %ebx +80101c88: 89 c3 mov %eax,%ebx +80101c8a: 83 ec 2c sub $0x2c,%esp + struct inode *ip, *next; + + if(*path == '/') +80101c8d: 80 38 2f cmpb $0x2f,(%eax) +{ +80101c90: 89 55 e0 mov %edx,-0x20(%ebp) + if(*path == '/') +80101c93: 0f 84 51 01 00 00 je 80101dea + ip = iget(ROOTDEV, ROOTINO); + else + ip = idup(myproc()->cwd); +80101c99: e8 02 1a 00 00 call 801036a0 +80101c9e: 8b 70 68 mov 0x68(%eax),%esi + acquire(&icache.lock); +80101ca1: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) +80101ca8: e8 93 24 00 00 call 80104140 + ip->ref++; +80101cad: 83 46 08 01 addl $0x1,0x8(%esi) + release(&icache.lock); +80101cb1: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) +80101cb8: e8 73 25 00 00 call 80104230 +80101cbd: eb 04 jmp 80101cc3 +80101cbf: 90 nop + path++; +80101cc0: 83 c3 01 add $0x1,%ebx + while(*path == '/') +80101cc3: 0f b6 03 movzbl (%ebx),%eax +80101cc6: 3c 2f cmp $0x2f,%al +80101cc8: 74 f6 je 80101cc0 + if(*path == 0) +80101cca: 84 c0 test %al,%al +80101ccc: 0f 84 ed 00 00 00 je 80101dbf + while(*path != '/' && *path != 0) +80101cd2: 0f b6 03 movzbl (%ebx),%eax +80101cd5: 89 da mov %ebx,%edx +80101cd7: 84 c0 test %al,%al +80101cd9: 0f 84 b1 00 00 00 je 80101d90 +80101cdf: 3c 2f cmp $0x2f,%al +80101ce1: 75 0f jne 80101cf2 +80101ce3: e9 a8 00 00 00 jmp 80101d90 +80101ce8: 3c 2f cmp $0x2f,%al +80101cea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80101cf0: 74 0a je 80101cfc + path++; +80101cf2: 83 c2 01 add $0x1,%edx + while(*path != '/' && *path != 0) +80101cf5: 0f b6 02 movzbl (%edx),%eax +80101cf8: 84 c0 test %al,%al +80101cfa: 75 ec jne 80101ce8 +80101cfc: 89 d1 mov %edx,%ecx +80101cfe: 29 d9 sub %ebx,%ecx + if(len >= DIRSIZ) +80101d00: 83 f9 0d cmp $0xd,%ecx +80101d03: 0f 8e 8f 00 00 00 jle 80101d98 + memmove(name, s, DIRSIZ); +80101d09: 89 5c 24 04 mov %ebx,0x4(%esp) +80101d0d: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) +80101d14: 00 +80101d15: 89 3c 24 mov %edi,(%esp) +80101d18: 89 55 e4 mov %edx,-0x1c(%ebp) +80101d1b: e8 00 26 00 00 call 80104320 + path++; +80101d20: 8b 55 e4 mov -0x1c(%ebp),%edx +80101d23: 89 d3 mov %edx,%ebx + while(*path == '/') +80101d25: 80 3a 2f cmpb $0x2f,(%edx) +80101d28: 75 0e jne 80101d38 +80101d2a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + path++; +80101d30: 83 c3 01 add $0x1,%ebx + while(*path == '/') +80101d33: 80 3b 2f cmpb $0x2f,(%ebx) +80101d36: 74 f8 je 80101d30 + + while((path = skipelem(path, name)) != 0){ + ilock(ip); +80101d38: 89 34 24 mov %esi,(%esp) +80101d3b: e8 70 f9 ff ff call 801016b0 + if(ip->type != T_DIR){ +80101d40: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) +80101d45: 0f 85 85 00 00 00 jne 80101dd0 + iunlockput(ip); + return 0; + } + if(nameiparent && *path == '\0'){ +80101d4b: 8b 55 e0 mov -0x20(%ebp),%edx +80101d4e: 85 d2 test %edx,%edx +80101d50: 74 09 je 80101d5b +80101d52: 80 3b 00 cmpb $0x0,(%ebx) +80101d55: 0f 84 a5 00 00 00 je 80101e00 + // Stop one level early. + iunlock(ip); + return ip; + } + if((next = dirlookup(ip, name, 0)) == 0){ +80101d5b: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +80101d62: 00 +80101d63: 89 7c 24 04 mov %edi,0x4(%esp) +80101d67: 89 34 24 mov %esi,(%esp) +80101d6a: e8 51 fe ff ff call 80101bc0 +80101d6f: 85 c0 test %eax,%eax +80101d71: 74 5d je 80101dd0 + iunlock(ip); +80101d73: 89 34 24 mov %esi,(%esp) +80101d76: 89 45 e4 mov %eax,-0x1c(%ebp) +80101d79: e8 12 fa ff ff call 80101790 + iput(ip); +80101d7e: 89 34 24 mov %esi,(%esp) +80101d81: e8 4a fa ff ff call 801017d0 + iunlockput(ip); + return 0; + } + iunlockput(ip); + ip = next; +80101d86: 8b 45 e4 mov -0x1c(%ebp),%eax +80101d89: 89 c6 mov %eax,%esi +80101d8b: e9 33 ff ff ff jmp 80101cc3 + while(*path != '/' && *path != 0) +80101d90: 31 c9 xor %ecx,%ecx +80101d92: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + memmove(name, s, len); +80101d98: 89 4c 24 08 mov %ecx,0x8(%esp) +80101d9c: 89 5c 24 04 mov %ebx,0x4(%esp) +80101da0: 89 3c 24 mov %edi,(%esp) +80101da3: 89 55 dc mov %edx,-0x24(%ebp) +80101da6: 89 4d e4 mov %ecx,-0x1c(%ebp) +80101da9: e8 72 25 00 00 call 80104320 + name[len] = 0; +80101dae: 8b 4d e4 mov -0x1c(%ebp),%ecx +80101db1: 8b 55 dc mov -0x24(%ebp),%edx +80101db4: c6 04 0f 00 movb $0x0,(%edi,%ecx,1) +80101db8: 89 d3 mov %edx,%ebx +80101dba: e9 66 ff ff ff jmp 80101d25 + } + if(nameiparent){ +80101dbf: 8b 45 e0 mov -0x20(%ebp),%eax +80101dc2: 85 c0 test %eax,%eax +80101dc4: 75 4c jne 80101e12 +80101dc6: 89 f0 mov %esi,%eax + iput(ip); + return 0; + } + return ip; +} +80101dc8: 83 c4 2c add $0x2c,%esp +80101dcb: 5b pop %ebx +80101dcc: 5e pop %esi +80101dcd: 5f pop %edi +80101dce: 5d pop %ebp +80101dcf: c3 ret + iunlock(ip); +80101dd0: 89 34 24 mov %esi,(%esp) +80101dd3: e8 b8 f9 ff ff call 80101790 + iput(ip); +80101dd8: 89 34 24 mov %esi,(%esp) +80101ddb: e8 f0 f9 ff ff call 801017d0 +} +80101de0: 83 c4 2c add $0x2c,%esp + return 0; +80101de3: 31 c0 xor %eax,%eax +} +80101de5: 5b pop %ebx +80101de6: 5e pop %esi +80101de7: 5f pop %edi +80101de8: 5d pop %ebp +80101de9: c3 ret + ip = iget(ROOTDEV, ROOTINO); +80101dea: ba 01 00 00 00 mov $0x1,%edx +80101def: b8 01 00 00 00 mov $0x1,%eax +80101df4: e8 17 f4 ff ff call 80101210 +80101df9: 89 c6 mov %eax,%esi +80101dfb: e9 c3 fe ff ff jmp 80101cc3 + iunlock(ip); +80101e00: 89 34 24 mov %esi,(%esp) +80101e03: e8 88 f9 ff ff call 80101790 +} +80101e08: 83 c4 2c add $0x2c,%esp + return ip; +80101e0b: 89 f0 mov %esi,%eax +} +80101e0d: 5b pop %ebx +80101e0e: 5e pop %esi +80101e0f: 5f pop %edi +80101e10: 5d pop %ebp +80101e11: c3 ret + iput(ip); +80101e12: 89 34 24 mov %esi,(%esp) +80101e15: e8 b6 f9 ff ff call 801017d0 + return 0; +80101e1a: 31 c0 xor %eax,%eax +80101e1c: eb aa jmp 80101dc8 +80101e1e: 66 90 xchg %ax,%ax + +80101e20 : +{ +80101e20: 55 push %ebp +80101e21: 89 e5 mov %esp,%ebp +80101e23: 57 push %edi +80101e24: 56 push %esi +80101e25: 53 push %ebx +80101e26: 83 ec 2c sub $0x2c,%esp +80101e29: 8b 5d 08 mov 0x8(%ebp),%ebx + if((ip = dirlookup(dp, name, 0)) != 0){ +80101e2c: 8b 45 0c mov 0xc(%ebp),%eax +80101e2f: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +80101e36: 00 +80101e37: 89 1c 24 mov %ebx,(%esp) +80101e3a: 89 44 24 04 mov %eax,0x4(%esp) +80101e3e: e8 7d fd ff ff call 80101bc0 +80101e43: 85 c0 test %eax,%eax +80101e45: 0f 85 8b 00 00 00 jne 80101ed6 + for(off = 0; off < dp->size; off += sizeof(de)){ +80101e4b: 8b 43 58 mov 0x58(%ebx),%eax +80101e4e: 31 ff xor %edi,%edi +80101e50: 8d 75 d8 lea -0x28(%ebp),%esi +80101e53: 85 c0 test %eax,%eax +80101e55: 75 13 jne 80101e6a +80101e57: eb 35 jmp 80101e8e +80101e59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80101e60: 8d 57 10 lea 0x10(%edi),%edx +80101e63: 39 53 58 cmp %edx,0x58(%ebx) +80101e66: 89 d7 mov %edx,%edi +80101e68: 76 24 jbe 80101e8e + if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) +80101e6a: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) +80101e71: 00 +80101e72: 89 7c 24 08 mov %edi,0x8(%esp) +80101e76: 89 74 24 04 mov %esi,0x4(%esp) +80101e7a: 89 1c 24 mov %ebx,(%esp) +80101e7d: e8 de fa ff ff call 80101960 +80101e82: 83 f8 10 cmp $0x10,%eax +80101e85: 75 5e jne 80101ee5 + if(de.inum == 0) +80101e87: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) +80101e8c: 75 d2 jne 80101e60 + strncpy(de.name, name, DIRSIZ); +80101e8e: 8b 45 0c mov 0xc(%ebp),%eax +80101e91: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) +80101e98: 00 +80101e99: 89 44 24 04 mov %eax,0x4(%esp) +80101e9d: 8d 45 da lea -0x26(%ebp),%eax +80101ea0: 89 04 24 mov %eax,(%esp) +80101ea3: e8 68 25 00 00 call 80104410 + de.inum = inum; +80101ea8: 8b 45 10 mov 0x10(%ebp),%eax + if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) +80101eab: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) +80101eb2: 00 +80101eb3: 89 7c 24 08 mov %edi,0x8(%esp) +80101eb7: 89 74 24 04 mov %esi,0x4(%esp) +80101ebb: 89 1c 24 mov %ebx,(%esp) + de.inum = inum; +80101ebe: 66 89 45 d8 mov %ax,-0x28(%ebp) + if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) +80101ec2: e8 99 fb ff ff call 80101a60 +80101ec7: 83 f8 10 cmp $0x10,%eax +80101eca: 75 25 jne 80101ef1 + return 0; +80101ecc: 31 c0 xor %eax,%eax +} +80101ece: 83 c4 2c add $0x2c,%esp +80101ed1: 5b pop %ebx +80101ed2: 5e pop %esi +80101ed3: 5f pop %edi +80101ed4: 5d pop %ebp +80101ed5: c3 ret + iput(ip); +80101ed6: 89 04 24 mov %eax,(%esp) +80101ed9: e8 f2 f8 ff ff call 801017d0 + return -1; +80101ede: b8 ff ff ff ff mov $0xffffffff,%eax +80101ee3: eb e9 jmp 80101ece + panic("dirlink read"); +80101ee5: c7 04 24 88 6f 10 80 movl $0x80106f88,(%esp) +80101eec: e8 6f e4 ff ff call 80100360 + panic("dirlink"); +80101ef1: c7 04 24 86 75 10 80 movl $0x80107586,(%esp) +80101ef8: e8 63 e4 ff ff call 80100360 +80101efd: 8d 76 00 lea 0x0(%esi),%esi + +80101f00 : + +struct inode* +namei(char *path) +{ +80101f00: 55 push %ebp + char name[DIRSIZ]; + return namex(path, 0, name); +80101f01: 31 d2 xor %edx,%edx +{ +80101f03: 89 e5 mov %esp,%ebp +80101f05: 83 ec 18 sub $0x18,%esp + return namex(path, 0, name); +80101f08: 8b 45 08 mov 0x8(%ebp),%eax +80101f0b: 8d 4d ea lea -0x16(%ebp),%ecx +80101f0e: e8 6d fd ff ff call 80101c80 +} +80101f13: c9 leave +80101f14: c3 ret +80101f15: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80101f19: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80101f20 : + +struct inode* +nameiparent(char *path, char *name) +{ +80101f20: 55 push %ebp + return namex(path, 1, name); +80101f21: ba 01 00 00 00 mov $0x1,%edx +{ +80101f26: 89 e5 mov %esp,%ebp + return namex(path, 1, name); +80101f28: 8b 4d 0c mov 0xc(%ebp),%ecx +80101f2b: 8b 45 08 mov 0x8(%ebp),%eax +} +80101f2e: 5d pop %ebp + return namex(path, 1, name); +80101f2f: e9 4c fd ff ff jmp 80101c80 +80101f34: 66 90 xchg %ax,%ax +80101f36: 66 90 xchg %ax,%ax +80101f38: 66 90 xchg %ax,%ax +80101f3a: 66 90 xchg %ax,%ax +80101f3c: 66 90 xchg %ax,%ax +80101f3e: 66 90 xchg %ax,%ax + +80101f40 : +} + +// Start the request for b. Caller must hold idelock. +static void +idestart(struct buf *b) +{ +80101f40: 55 push %ebp +80101f41: 89 e5 mov %esp,%ebp +80101f43: 56 push %esi +80101f44: 89 c6 mov %eax,%esi +80101f46: 53 push %ebx +80101f47: 83 ec 10 sub $0x10,%esp + if(b == 0) +80101f4a: 85 c0 test %eax,%eax +80101f4c: 0f 84 99 00 00 00 je 80101feb + panic("idestart"); + if(b->blockno >= FSSIZE) +80101f52: 8b 48 08 mov 0x8(%eax),%ecx +80101f55: 81 f9 e7 03 00 00 cmp $0x3e7,%ecx +80101f5b: 0f 87 7e 00 00 00 ja 80101fdf + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +80101f61: ba f7 01 00 00 mov $0x1f7,%edx +80101f66: 66 90 xchg %ax,%ax +80101f68: ec in (%dx),%al + while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) +80101f69: 83 e0 c0 and $0xffffffc0,%eax +80101f6c: 3c 40 cmp $0x40,%al +80101f6e: 75 f8 jne 80101f68 + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +80101f70: 31 db xor %ebx,%ebx +80101f72: ba f6 03 00 00 mov $0x3f6,%edx +80101f77: 89 d8 mov %ebx,%eax +80101f79: ee out %al,(%dx) +80101f7a: ba f2 01 00 00 mov $0x1f2,%edx +80101f7f: b8 01 00 00 00 mov $0x1,%eax +80101f84: ee out %al,(%dx) +80101f85: 0f b6 c1 movzbl %cl,%eax +80101f88: b2 f3 mov $0xf3,%dl +80101f8a: ee out %al,(%dx) + + idewait(0); + outb(0x3f6, 0); // generate interrupt + outb(0x1f2, sector_per_block); // number of sectors + outb(0x1f3, sector & 0xff); + outb(0x1f4, (sector >> 8) & 0xff); +80101f8b: 89 c8 mov %ecx,%eax +80101f8d: b2 f4 mov $0xf4,%dl +80101f8f: c1 f8 08 sar $0x8,%eax +80101f92: ee out %al,(%dx) +80101f93: b2 f5 mov $0xf5,%dl +80101f95: 89 d8 mov %ebx,%eax +80101f97: ee out %al,(%dx) + outb(0x1f5, (sector >> 16) & 0xff); + outb(0x1f6, 0xe0 | ((b->dev&1)<<4) | ((sector>>24)&0x0f)); +80101f98: 0f b6 46 04 movzbl 0x4(%esi),%eax +80101f9c: b2 f6 mov $0xf6,%dl +80101f9e: 83 e0 01 and $0x1,%eax +80101fa1: c1 e0 04 shl $0x4,%eax +80101fa4: 83 c8 e0 or $0xffffffe0,%eax +80101fa7: ee out %al,(%dx) + if(b->flags & B_DIRTY){ +80101fa8: f6 06 04 testb $0x4,(%esi) +80101fab: 75 13 jne 80101fc0 +80101fad: ba f7 01 00 00 mov $0x1f7,%edx +80101fb2: b8 20 00 00 00 mov $0x20,%eax +80101fb7: ee out %al,(%dx) + outb(0x1f7, write_cmd); + outsl(0x1f0, b->data, BSIZE/4); + } else { + outb(0x1f7, read_cmd); + } +} +80101fb8: 83 c4 10 add $0x10,%esp +80101fbb: 5b pop %ebx +80101fbc: 5e pop %esi +80101fbd: 5d pop %ebp +80101fbe: c3 ret +80101fbf: 90 nop +80101fc0: b2 f7 mov $0xf7,%dl +80101fc2: b8 30 00 00 00 mov $0x30,%eax +80101fc7: ee out %al,(%dx) + asm volatile("cld; rep outsl" : +80101fc8: b9 80 00 00 00 mov $0x80,%ecx + outsl(0x1f0, b->data, BSIZE/4); +80101fcd: 83 c6 5c add $0x5c,%esi +80101fd0: ba f0 01 00 00 mov $0x1f0,%edx +80101fd5: fc cld +80101fd6: f3 6f rep outsl %ds:(%esi),(%dx) +} +80101fd8: 83 c4 10 add $0x10,%esp +80101fdb: 5b pop %ebx +80101fdc: 5e pop %esi +80101fdd: 5d pop %ebp +80101fde: c3 ret + panic("incorrect blockno"); +80101fdf: c7 04 24 f4 6f 10 80 movl $0x80106ff4,(%esp) +80101fe6: e8 75 e3 ff ff call 80100360 + panic("idestart"); +80101feb: c7 04 24 eb 6f 10 80 movl $0x80106feb,(%esp) +80101ff2: e8 69 e3 ff ff call 80100360 +80101ff7: 89 f6 mov %esi,%esi +80101ff9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80102000 : +{ +80102000: 55 push %ebp +80102001: 89 e5 mov %esp,%ebp +80102003: 83 ec 18 sub $0x18,%esp + initlock(&idelock, "ide"); +80102006: c7 44 24 04 06 70 10 movl $0x80107006,0x4(%esp) +8010200d: 80 +8010200e: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) +80102015: e8 36 20 00 00 call 80104050 + ioapicenable(IRQ_IDE, ncpu - 1); +8010201a: a1 00 2d 11 80 mov 0x80112d00,%eax +8010201f: c7 04 24 0e 00 00 00 movl $0xe,(%esp) +80102026: 83 e8 01 sub $0x1,%eax +80102029: 89 44 24 04 mov %eax,0x4(%esp) +8010202d: e8 7e 02 00 00 call 801022b0 + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +80102032: ba f7 01 00 00 mov $0x1f7,%edx +80102037: 90 nop +80102038: ec in (%dx),%al + while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) +80102039: 83 e0 c0 and $0xffffffc0,%eax +8010203c: 3c 40 cmp $0x40,%al +8010203e: 75 f8 jne 80102038 + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +80102040: ba f6 01 00 00 mov $0x1f6,%edx +80102045: b8 f0 ff ff ff mov $0xfffffff0,%eax +8010204a: ee out %al,(%dx) +8010204b: b9 e8 03 00 00 mov $0x3e8,%ecx + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +80102050: b2 f7 mov $0xf7,%dl +80102052: eb 09 jmp 8010205d +80102054: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + for(i=0; i<1000; i++){ +80102058: 83 e9 01 sub $0x1,%ecx +8010205b: 74 0f je 8010206c +8010205d: ec in (%dx),%al + if(inb(0x1f7) != 0){ +8010205e: 84 c0 test %al,%al +80102060: 74 f6 je 80102058 + havedisk1 = 1; +80102062: c7 05 60 a5 10 80 01 movl $0x1,0x8010a560 +80102069: 00 00 00 + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +8010206c: ba f6 01 00 00 mov $0x1f6,%edx +80102071: b8 e0 ff ff ff mov $0xffffffe0,%eax +80102076: ee out %al,(%dx) +} +80102077: c9 leave +80102078: c3 ret +80102079: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80102080 : + +// Interrupt handler. +void +ideintr(void) +{ +80102080: 55 push %ebp +80102081: 89 e5 mov %esp,%ebp +80102083: 57 push %edi +80102084: 56 push %esi +80102085: 53 push %ebx +80102086: 83 ec 1c sub $0x1c,%esp + struct buf *b; + + // First queued buffer is the active request. + acquire(&idelock); +80102089: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) +80102090: e8 ab 20 00 00 call 80104140 + + if((b = idequeue) == 0){ +80102095: 8b 1d 64 a5 10 80 mov 0x8010a564,%ebx +8010209b: 85 db test %ebx,%ebx +8010209d: 74 30 je 801020cf + release(&idelock); + return; + } + idequeue = b->qnext; +8010209f: 8b 43 58 mov 0x58(%ebx),%eax +801020a2: a3 64 a5 10 80 mov %eax,0x8010a564 + + // Read data if needed. + if(!(b->flags & B_DIRTY) && idewait(1) >= 0) +801020a7: 8b 33 mov (%ebx),%esi +801020a9: f7 c6 04 00 00 00 test $0x4,%esi +801020af: 74 37 je 801020e8 + insl(0x1f0, b->data, BSIZE/4); + + // Wake process waiting for this buf. + b->flags |= B_VALID; + b->flags &= ~B_DIRTY; +801020b1: 83 e6 fb and $0xfffffffb,%esi +801020b4: 83 ce 02 or $0x2,%esi +801020b7: 89 33 mov %esi,(%ebx) + wakeup(b); +801020b9: 89 1c 24 mov %ebx,(%esp) +801020bc: e8 cf 1c 00 00 call 80103d90 + + // Start disk on next buf in queue. + if(idequeue != 0) +801020c1: a1 64 a5 10 80 mov 0x8010a564,%eax +801020c6: 85 c0 test %eax,%eax +801020c8: 74 05 je 801020cf + idestart(idequeue); +801020ca: e8 71 fe ff ff call 80101f40 + release(&idelock); +801020cf: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) +801020d6: e8 55 21 00 00 call 80104230 + + release(&idelock); +} +801020db: 83 c4 1c add $0x1c,%esp +801020de: 5b pop %ebx +801020df: 5e pop %esi +801020e0: 5f pop %edi +801020e1: 5d pop %ebp +801020e2: c3 ret +801020e3: 90 nop +801020e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +801020e8: ba f7 01 00 00 mov $0x1f7,%edx +801020ed: 8d 76 00 lea 0x0(%esi),%esi +801020f0: ec in (%dx),%al + while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) +801020f1: 89 c1 mov %eax,%ecx +801020f3: 83 e1 c0 and $0xffffffc0,%ecx +801020f6: 80 f9 40 cmp $0x40,%cl +801020f9: 75 f5 jne 801020f0 + if(checkerr && (r & (IDE_DF|IDE_ERR)) != 0) +801020fb: a8 21 test $0x21,%al +801020fd: 75 b2 jne 801020b1 + insl(0x1f0, b->data, BSIZE/4); +801020ff: 8d 7b 5c lea 0x5c(%ebx),%edi + asm volatile("cld; rep insl" : +80102102: b9 80 00 00 00 mov $0x80,%ecx +80102107: ba f0 01 00 00 mov $0x1f0,%edx +8010210c: fc cld +8010210d: f3 6d rep insl (%dx),%es:(%edi) +8010210f: 8b 33 mov (%ebx),%esi +80102111: eb 9e jmp 801020b1 +80102113: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80102119: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80102120 : +// Sync buf with disk. +// If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID. +// Else if B_VALID is not set, read buf from disk, set B_VALID. +void +iderw(struct buf *b) +{ +80102120: 55 push %ebp +80102121: 89 e5 mov %esp,%ebp +80102123: 53 push %ebx +80102124: 83 ec 14 sub $0x14,%esp +80102127: 8b 5d 08 mov 0x8(%ebp),%ebx + struct buf **pp; + + if(!holdingsleep(&b->lock)) +8010212a: 8d 43 0c lea 0xc(%ebx),%eax +8010212d: 89 04 24 mov %eax,(%esp) +80102130: e8 eb 1e 00 00 call 80104020 +80102135: 85 c0 test %eax,%eax +80102137: 0f 84 9e 00 00 00 je 801021db + panic("iderw: buf not locked"); + if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) +8010213d: 8b 03 mov (%ebx),%eax +8010213f: 83 e0 06 and $0x6,%eax +80102142: 83 f8 02 cmp $0x2,%eax +80102145: 0f 84 a8 00 00 00 je 801021f3 + panic("iderw: nothing to do"); + if(b->dev != 0 && !havedisk1) +8010214b: 8b 53 04 mov 0x4(%ebx),%edx +8010214e: 85 d2 test %edx,%edx +80102150: 74 0d je 8010215f +80102152: a1 60 a5 10 80 mov 0x8010a560,%eax +80102157: 85 c0 test %eax,%eax +80102159: 0f 84 88 00 00 00 je 801021e7 + panic("iderw: ide disk 1 not present"); + + acquire(&idelock); //DOC:acquire-lock +8010215f: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) +80102166: e8 d5 1f 00 00 call 80104140 + + // Append b to idequeue. + b->qnext = 0; + for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue +8010216b: a1 64 a5 10 80 mov 0x8010a564,%eax + b->qnext = 0; +80102170: c7 43 58 00 00 00 00 movl $0x0,0x58(%ebx) + for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue +80102177: 85 c0 test %eax,%eax +80102179: 75 07 jne 80102182 +8010217b: eb 4e jmp 801021cb +8010217d: 8d 76 00 lea 0x0(%esi),%esi +80102180: 89 d0 mov %edx,%eax +80102182: 8b 50 58 mov 0x58(%eax),%edx +80102185: 85 d2 test %edx,%edx +80102187: 75 f7 jne 80102180 +80102189: 83 c0 58 add $0x58,%eax + ; + *pp = b; +8010218c: 89 18 mov %ebx,(%eax) + + // Start disk if necessary. + if(idequeue == b) +8010218e: 39 1d 64 a5 10 80 cmp %ebx,0x8010a564 +80102194: 74 3c je 801021d2 + idestart(b); + + // Wait for request to finish. + while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ +80102196: 8b 03 mov (%ebx),%eax +80102198: 83 e0 06 and $0x6,%eax +8010219b: 83 f8 02 cmp $0x2,%eax +8010219e: 74 1a je 801021ba + sleep(b, &idelock); +801021a0: c7 44 24 04 80 a5 10 movl $0x8010a580,0x4(%esp) +801021a7: 80 +801021a8: 89 1c 24 mov %ebx,(%esp) +801021ab: e8 50 1a 00 00 call 80103c00 + while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ +801021b0: 8b 13 mov (%ebx),%edx +801021b2: 83 e2 06 and $0x6,%edx +801021b5: 83 fa 02 cmp $0x2,%edx +801021b8: 75 e6 jne 801021a0 + } + + + release(&idelock); +801021ba: c7 45 08 80 a5 10 80 movl $0x8010a580,0x8(%ebp) +} +801021c1: 83 c4 14 add $0x14,%esp +801021c4: 5b pop %ebx +801021c5: 5d pop %ebp + release(&idelock); +801021c6: e9 65 20 00 00 jmp 80104230 + for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue +801021cb: b8 64 a5 10 80 mov $0x8010a564,%eax +801021d0: eb ba jmp 8010218c + idestart(b); +801021d2: 89 d8 mov %ebx,%eax +801021d4: e8 67 fd ff ff call 80101f40 +801021d9: eb bb jmp 80102196 + panic("iderw: buf not locked"); +801021db: c7 04 24 0a 70 10 80 movl $0x8010700a,(%esp) +801021e2: e8 79 e1 ff ff call 80100360 + panic("iderw: ide disk 1 not present"); +801021e7: c7 04 24 35 70 10 80 movl $0x80107035,(%esp) +801021ee: e8 6d e1 ff ff call 80100360 + panic("iderw: nothing to do"); +801021f3: c7 04 24 20 70 10 80 movl $0x80107020,(%esp) +801021fa: e8 61 e1 ff ff call 80100360 +801021ff: 90 nop + +80102200 : + ioapic->data = data; +} + +void +ioapicinit(void) +{ +80102200: 55 push %ebp +80102201: 89 e5 mov %esp,%ebp +80102203: 56 push %esi +80102204: 53 push %ebx +80102205: 83 ec 10 sub $0x10,%esp + int i, id, maxintr; + + ioapic = (volatile struct ioapic*)IOAPIC; +80102208: c7 05 34 26 11 80 00 movl $0xfec00000,0x80112634 +8010220f: 00 c0 fe + ioapic->reg = reg; +80102212: c7 05 00 00 c0 fe 01 movl $0x1,0xfec00000 +80102219: 00 00 00 + return ioapic->data; +8010221c: 8b 15 34 26 11 80 mov 0x80112634,%edx +80102222: 8b 42 10 mov 0x10(%edx),%eax + ioapic->reg = reg; +80102225: c7 02 00 00 00 00 movl $0x0,(%edx) + return ioapic->data; +8010222b: 8b 1d 34 26 11 80 mov 0x80112634,%ebx + maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; + id = ioapicread(REG_ID) >> 24; + if(id != ioapicid) +80102231: 0f b6 15 60 27 11 80 movzbl 0x80112760,%edx + maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; +80102238: c1 e8 10 shr $0x10,%eax +8010223b: 0f b6 f0 movzbl %al,%esi + return ioapic->data; +8010223e: 8b 43 10 mov 0x10(%ebx),%eax + id = ioapicread(REG_ID) >> 24; +80102241: c1 e8 18 shr $0x18,%eax + if(id != ioapicid) +80102244: 39 c2 cmp %eax,%edx +80102246: 74 12 je 8010225a + cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); +80102248: c7 04 24 54 70 10 80 movl $0x80107054,(%esp) +8010224f: e8 fc e3 ff ff call 80100650 +80102254: 8b 1d 34 26 11 80 mov 0x80112634,%ebx +8010225a: ba 10 00 00 00 mov $0x10,%edx +8010225f: 31 c0 xor %eax,%eax +80102261: eb 07 jmp 8010226a +80102263: 90 nop +80102264: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80102268: 89 cb mov %ecx,%ebx + ioapic->reg = reg; +8010226a: 89 13 mov %edx,(%ebx) + ioapic->data = data; +8010226c: 8b 1d 34 26 11 80 mov 0x80112634,%ebx +80102272: 8d 48 20 lea 0x20(%eax),%ecx + + // Mark all interrupts edge-triggered, active high, disabled, + // and not routed to any CPUs. + for(i = 0; i <= maxintr; i++){ + ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); +80102275: 81 c9 00 00 01 00 or $0x10000,%ecx + for(i = 0; i <= maxintr; i++){ +8010227b: 83 c0 01 add $0x1,%eax + ioapic->data = data; +8010227e: 89 4b 10 mov %ecx,0x10(%ebx) +80102281: 8d 4a 01 lea 0x1(%edx),%ecx +80102284: 83 c2 02 add $0x2,%edx + ioapic->reg = reg; +80102287: 89 0b mov %ecx,(%ebx) + ioapic->data = data; +80102289: 8b 0d 34 26 11 80 mov 0x80112634,%ecx + for(i = 0; i <= maxintr; i++){ +8010228f: 39 c6 cmp %eax,%esi + ioapic->data = data; +80102291: c7 41 10 00 00 00 00 movl $0x0,0x10(%ecx) + for(i = 0; i <= maxintr; i++){ +80102298: 7d ce jge 80102268 + ioapicwrite(REG_TABLE+2*i+1, 0); + } +} +8010229a: 83 c4 10 add $0x10,%esp +8010229d: 5b pop %ebx +8010229e: 5e pop %esi +8010229f: 5d pop %ebp +801022a0: c3 ret +801022a1: eb 0d jmp 801022b0 +801022a3: 90 nop +801022a4: 90 nop +801022a5: 90 nop +801022a6: 90 nop +801022a7: 90 nop +801022a8: 90 nop +801022a9: 90 nop +801022aa: 90 nop +801022ab: 90 nop +801022ac: 90 nop +801022ad: 90 nop +801022ae: 90 nop +801022af: 90 nop + +801022b0 : + +void +ioapicenable(int irq, int cpunum) +{ +801022b0: 55 push %ebp +801022b1: 89 e5 mov %esp,%ebp +801022b3: 8b 55 08 mov 0x8(%ebp),%edx +801022b6: 53 push %ebx +801022b7: 8b 45 0c mov 0xc(%ebp),%eax + // Mark interrupt edge-triggered, active high, + // enabled, and routed to the given cpunum, + // which happens to be that cpu's APIC ID. + ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); +801022ba: 8d 5a 20 lea 0x20(%edx),%ebx +801022bd: 8d 4c 12 10 lea 0x10(%edx,%edx,1),%ecx + ioapic->reg = reg; +801022c1: 8b 15 34 26 11 80 mov 0x80112634,%edx + ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); +801022c7: c1 e0 18 shl $0x18,%eax + ioapic->reg = reg; +801022ca: 89 0a mov %ecx,(%edx) + ioapic->data = data; +801022cc: 8b 15 34 26 11 80 mov 0x80112634,%edx + ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); +801022d2: 83 c1 01 add $0x1,%ecx + ioapic->data = data; +801022d5: 89 5a 10 mov %ebx,0x10(%edx) + ioapic->reg = reg; +801022d8: 89 0a mov %ecx,(%edx) + ioapic->data = data; +801022da: 8b 15 34 26 11 80 mov 0x80112634,%edx +801022e0: 89 42 10 mov %eax,0x10(%edx) +} +801022e3: 5b pop %ebx +801022e4: 5d pop %ebp +801022e5: c3 ret +801022e6: 66 90 xchg %ax,%ax +801022e8: 66 90 xchg %ax,%ax +801022ea: 66 90 xchg %ax,%ax +801022ec: 66 90 xchg %ax,%ax +801022ee: 66 90 xchg %ax,%ax + +801022f0 : +// which normally should have been returned by a +// call to kalloc(). (The exception is when +// initializing the allocator; see kinit above.) +void +kfree(char *v) +{ +801022f0: 55 push %ebp +801022f1: 89 e5 mov %esp,%ebp +801022f3: 53 push %ebx +801022f4: 83 ec 14 sub $0x14,%esp +801022f7: 8b 5d 08 mov 0x8(%ebp),%ebx + struct run *r; + + if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) +801022fa: f7 c3 ff 0f 00 00 test $0xfff,%ebx +80102300: 75 7c jne 8010237e +80102302: 81 fb 14 59 11 80 cmp $0x80115914,%ebx +80102308: 72 74 jb 8010237e +8010230a: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax +80102310: 3d ff ff ff 0d cmp $0xdffffff,%eax +80102315: 77 67 ja 8010237e + panic("kfree"); + + // Fill with junk to catch dangling refs. + memset(v, 1, PGSIZE); +80102317: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) +8010231e: 00 +8010231f: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +80102326: 00 +80102327: 89 1c 24 mov %ebx,(%esp) +8010232a: e8 51 1f 00 00 call 80104280 + + if(kmem.use_lock) +8010232f: 8b 15 74 26 11 80 mov 0x80112674,%edx +80102335: 85 d2 test %edx,%edx +80102337: 75 37 jne 80102370 + acquire(&kmem.lock); + r = (struct run*)v; + r->next = kmem.freelist; +80102339: a1 78 26 11 80 mov 0x80112678,%eax +8010233e: 89 03 mov %eax,(%ebx) + kmem.freelist = r; + if(kmem.use_lock) +80102340: a1 74 26 11 80 mov 0x80112674,%eax + kmem.freelist = r; +80102345: 89 1d 78 26 11 80 mov %ebx,0x80112678 + if(kmem.use_lock) +8010234b: 85 c0 test %eax,%eax +8010234d: 75 09 jne 80102358 + release(&kmem.lock); +} +8010234f: 83 c4 14 add $0x14,%esp +80102352: 5b pop %ebx +80102353: 5d pop %ebp +80102354: c3 ret +80102355: 8d 76 00 lea 0x0(%esi),%esi + release(&kmem.lock); +80102358: c7 45 08 40 26 11 80 movl $0x80112640,0x8(%ebp) +} +8010235f: 83 c4 14 add $0x14,%esp +80102362: 5b pop %ebx +80102363: 5d pop %ebp + release(&kmem.lock); +80102364: e9 c7 1e 00 00 jmp 80104230 +80102369: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + acquire(&kmem.lock); +80102370: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) +80102377: e8 c4 1d 00 00 call 80104140 +8010237c: eb bb jmp 80102339 + panic("kfree"); +8010237e: c7 04 24 86 70 10 80 movl $0x80107086,(%esp) +80102385: e8 d6 df ff ff call 80100360 +8010238a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80102390 : +{ +80102390: 55 push %ebp +80102391: 89 e5 mov %esp,%ebp +80102393: 56 push %esi +80102394: 53 push %ebx +80102395: 83 ec 10 sub $0x10,%esp + p = (char*)PGROUNDUP((uint)vstart); +80102398: 8b 45 08 mov 0x8(%ebp),%eax +{ +8010239b: 8b 75 0c mov 0xc(%ebp),%esi + p = (char*)PGROUNDUP((uint)vstart); +8010239e: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx +801023a4: 81 e2 00 f0 ff ff and $0xfffff000,%edx + for(; p + PGSIZE <= (char*)vend; p += PGSIZE) +801023aa: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx +801023b0: 39 de cmp %ebx,%esi +801023b2: 73 08 jae 801023bc +801023b4: eb 18 jmp 801023ce +801023b6: 66 90 xchg %ax,%ax +801023b8: 89 da mov %ebx,%edx +801023ba: 89 c3 mov %eax,%ebx + kfree(p); +801023bc: 89 14 24 mov %edx,(%esp) +801023bf: e8 2c ff ff ff call 801022f0 + for(; p + PGSIZE <= (char*)vend; p += PGSIZE) +801023c4: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax +801023ca: 39 f0 cmp %esi,%eax +801023cc: 76 ea jbe 801023b8 +} +801023ce: 83 c4 10 add $0x10,%esp +801023d1: 5b pop %ebx +801023d2: 5e pop %esi +801023d3: 5d pop %ebp +801023d4: c3 ret +801023d5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801023d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +801023e0 : +{ +801023e0: 55 push %ebp +801023e1: 89 e5 mov %esp,%ebp +801023e3: 56 push %esi +801023e4: 53 push %ebx +801023e5: 83 ec 10 sub $0x10,%esp +801023e8: 8b 75 0c mov 0xc(%ebp),%esi + initlock(&kmem.lock, "kmem"); +801023eb: c7 44 24 04 8c 70 10 movl $0x8010708c,0x4(%esp) +801023f2: 80 +801023f3: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) +801023fa: e8 51 1c 00 00 call 80104050 + p = (char*)PGROUNDUP((uint)vstart); +801023ff: 8b 45 08 mov 0x8(%ebp),%eax + kmem.use_lock = 0; +80102402: c7 05 74 26 11 80 00 movl $0x0,0x80112674 +80102409: 00 00 00 + p = (char*)PGROUNDUP((uint)vstart); +8010240c: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx +80102412: 81 e2 00 f0 ff ff and $0xfffff000,%edx + for(; p + PGSIZE <= (char*)vend; p += PGSIZE) +80102418: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx +8010241e: 39 de cmp %ebx,%esi +80102420: 73 0a jae 8010242c +80102422: eb 1a jmp 8010243e +80102424: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80102428: 89 da mov %ebx,%edx +8010242a: 89 c3 mov %eax,%ebx + kfree(p); +8010242c: 89 14 24 mov %edx,(%esp) +8010242f: e8 bc fe ff ff call 801022f0 + for(; p + PGSIZE <= (char*)vend; p += PGSIZE) +80102434: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax +8010243a: 39 c6 cmp %eax,%esi +8010243c: 73 ea jae 80102428 +} +8010243e: 83 c4 10 add $0x10,%esp +80102441: 5b pop %ebx +80102442: 5e pop %esi +80102443: 5d pop %ebp +80102444: c3 ret +80102445: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80102449: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80102450 : +{ +80102450: 55 push %ebp +80102451: 89 e5 mov %esp,%ebp +80102453: 56 push %esi +80102454: 53 push %ebx +80102455: 83 ec 10 sub $0x10,%esp + p = (char*)PGROUNDUP((uint)vstart); +80102458: 8b 45 08 mov 0x8(%ebp),%eax +{ +8010245b: 8b 75 0c mov 0xc(%ebp),%esi + p = (char*)PGROUNDUP((uint)vstart); +8010245e: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx +80102464: 81 e2 00 f0 ff ff and $0xfffff000,%edx + for(; p + PGSIZE <= (char*)vend; p += PGSIZE) +8010246a: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx +80102470: 39 de cmp %ebx,%esi +80102472: 73 08 jae 8010247c +80102474: eb 18 jmp 8010248e +80102476: 66 90 xchg %ax,%ax +80102478: 89 da mov %ebx,%edx +8010247a: 89 c3 mov %eax,%ebx + kfree(p); +8010247c: 89 14 24 mov %edx,(%esp) +8010247f: e8 6c fe ff ff call 801022f0 + for(; p + PGSIZE <= (char*)vend; p += PGSIZE) +80102484: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax +8010248a: 39 c6 cmp %eax,%esi +8010248c: 73 ea jae 80102478 + kmem.use_lock = 1; +8010248e: c7 05 74 26 11 80 01 movl $0x1,0x80112674 +80102495: 00 00 00 +} +80102498: 83 c4 10 add $0x10,%esp +8010249b: 5b pop %ebx +8010249c: 5e pop %esi +8010249d: 5d pop %ebp +8010249e: c3 ret +8010249f: 90 nop + +801024a0 : +// Allocate one 4096-byte page of physical memory. +// Returns a pointer that the kernel can use. +// Returns 0 if the memory cannot be allocated. +char* +kalloc(void) +{ +801024a0: 55 push %ebp +801024a1: 89 e5 mov %esp,%ebp +801024a3: 53 push %ebx +801024a4: 83 ec 14 sub $0x14,%esp + struct run *r; + + if(kmem.use_lock) +801024a7: a1 74 26 11 80 mov 0x80112674,%eax +801024ac: 85 c0 test %eax,%eax +801024ae: 75 30 jne 801024e0 + acquire(&kmem.lock); + r = kmem.freelist; +801024b0: 8b 1d 78 26 11 80 mov 0x80112678,%ebx + if(r) +801024b6: 85 db test %ebx,%ebx +801024b8: 74 08 je 801024c2 + kmem.freelist = r->next; +801024ba: 8b 13 mov (%ebx),%edx +801024bc: 89 15 78 26 11 80 mov %edx,0x80112678 + if(kmem.use_lock) +801024c2: 85 c0 test %eax,%eax +801024c4: 74 0c je 801024d2 + release(&kmem.lock); +801024c6: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) +801024cd: e8 5e 1d 00 00 call 80104230 + return (char*)r; +} +801024d2: 83 c4 14 add $0x14,%esp +801024d5: 89 d8 mov %ebx,%eax +801024d7: 5b pop %ebx +801024d8: 5d pop %ebp +801024d9: c3 ret +801024da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + acquire(&kmem.lock); +801024e0: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) +801024e7: e8 54 1c 00 00 call 80104140 +801024ec: a1 74 26 11 80 mov 0x80112674,%eax +801024f1: eb bd jmp 801024b0 +801024f3: 66 90 xchg %ax,%ax +801024f5: 66 90 xchg %ax,%ax +801024f7: 66 90 xchg %ax,%ax +801024f9: 66 90 xchg %ax,%ax +801024fb: 66 90 xchg %ax,%ax +801024fd: 66 90 xchg %ax,%ax +801024ff: 90 nop + +80102500 : + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +80102500: ba 64 00 00 00 mov $0x64,%edx +80102505: ec in (%dx),%al + normalmap, shiftmap, ctlmap, ctlmap + }; + uint st, data, c; + + st = inb(KBSTATP); + if((st & KBS_DIB) == 0) +80102506: a8 01 test $0x1,%al +80102508: 0f 84 ba 00 00 00 je 801025c8 +8010250e: b2 60 mov $0x60,%dl +80102510: ec in (%dx),%al + return -1; + data = inb(KBDATAP); +80102511: 0f b6 c8 movzbl %al,%ecx + + if(data == 0xE0){ +80102514: 81 f9 e0 00 00 00 cmp $0xe0,%ecx +8010251a: 0f 84 88 00 00 00 je 801025a8 + shift |= E0ESC; + return 0; + } else if(data & 0x80){ +80102520: 84 c0 test %al,%al +80102522: 79 2c jns 80102550 + // Key released + data = (shift & E0ESC ? data : data & 0x7F); +80102524: 8b 15 b4 a5 10 80 mov 0x8010a5b4,%edx +8010252a: f6 c2 40 test $0x40,%dl +8010252d: 75 05 jne 80102534 +8010252f: 89 c1 mov %eax,%ecx +80102531: 83 e1 7f and $0x7f,%ecx + shift &= ~(shiftcode[data] | E0ESC); +80102534: 0f b6 81 c0 71 10 80 movzbl -0x7fef8e40(%ecx),%eax +8010253b: 83 c8 40 or $0x40,%eax +8010253e: 0f b6 c0 movzbl %al,%eax +80102541: f7 d0 not %eax +80102543: 21 d0 and %edx,%eax +80102545: a3 b4 a5 10 80 mov %eax,0x8010a5b4 + return 0; +8010254a: 31 c0 xor %eax,%eax +8010254c: c3 ret +8010254d: 8d 76 00 lea 0x0(%esi),%esi +{ +80102550: 55 push %ebp +80102551: 89 e5 mov %esp,%ebp +80102553: 53 push %ebx +80102554: 8b 1d b4 a5 10 80 mov 0x8010a5b4,%ebx + } else if(shift & E0ESC){ +8010255a: f6 c3 40 test $0x40,%bl +8010255d: 74 09 je 80102568 + // Last character was an E0 escape; or with 0x80 + data |= 0x80; +8010255f: 83 c8 80 or $0xffffff80,%eax + shift &= ~E0ESC; +80102562: 83 e3 bf and $0xffffffbf,%ebx + data |= 0x80; +80102565: 0f b6 c8 movzbl %al,%ecx + } + + shift |= shiftcode[data]; +80102568: 0f b6 91 c0 71 10 80 movzbl -0x7fef8e40(%ecx),%edx + shift ^= togglecode[data]; +8010256f: 0f b6 81 c0 70 10 80 movzbl -0x7fef8f40(%ecx),%eax + shift |= shiftcode[data]; +80102576: 09 da or %ebx,%edx + shift ^= togglecode[data]; +80102578: 31 c2 xor %eax,%edx + c = charcode[shift & (CTL | SHIFT)][data]; +8010257a: 89 d0 mov %edx,%eax +8010257c: 83 e0 03 and $0x3,%eax +8010257f: 8b 04 85 a0 70 10 80 mov -0x7fef8f60(,%eax,4),%eax + shift ^= togglecode[data]; +80102586: 89 15 b4 a5 10 80 mov %edx,0x8010a5b4 + if(shift & CAPSLOCK){ +8010258c: 83 e2 08 and $0x8,%edx + c = charcode[shift & (CTL | SHIFT)][data]; +8010258f: 0f b6 04 08 movzbl (%eax,%ecx,1),%eax + if(shift & CAPSLOCK){ +80102593: 74 0b je 801025a0 + if('a' <= c && c <= 'z') +80102595: 8d 50 9f lea -0x61(%eax),%edx +80102598: 83 fa 19 cmp $0x19,%edx +8010259b: 77 1b ja 801025b8 + c += 'A' - 'a'; +8010259d: 83 e8 20 sub $0x20,%eax + else if('A' <= c && c <= 'Z') + c += 'a' - 'A'; + } + return c; +} +801025a0: 5b pop %ebx +801025a1: 5d pop %ebp +801025a2: c3 ret +801025a3: 90 nop +801025a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + shift |= E0ESC; +801025a8: 83 0d b4 a5 10 80 40 orl $0x40,0x8010a5b4 + return 0; +801025af: 31 c0 xor %eax,%eax +801025b1: c3 ret +801025b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + else if('A' <= c && c <= 'Z') +801025b8: 8d 48 bf lea -0x41(%eax),%ecx + c += 'a' - 'A'; +801025bb: 8d 50 20 lea 0x20(%eax),%edx +801025be: 83 f9 19 cmp $0x19,%ecx +801025c1: 0f 46 c2 cmovbe %edx,%eax + return c; +801025c4: eb da jmp 801025a0 +801025c6: 66 90 xchg %ax,%ax + return -1; +801025c8: b8 ff ff ff ff mov $0xffffffff,%eax +801025cd: c3 ret +801025ce: 66 90 xchg %ax,%ax + +801025d0 : + +void +kbdintr(void) +{ +801025d0: 55 push %ebp +801025d1: 89 e5 mov %esp,%ebp +801025d3: 83 ec 18 sub $0x18,%esp + consoleintr(kbdgetc); +801025d6: c7 04 24 00 25 10 80 movl $0x80102500,(%esp) +801025dd: e8 ce e1 ff ff call 801007b0 +} +801025e2: c9 leave +801025e3: c3 ret +801025e4: 66 90 xchg %ax,%ax +801025e6: 66 90 xchg %ax,%ax +801025e8: 66 90 xchg %ax,%ax +801025ea: 66 90 xchg %ax,%ax +801025ec: 66 90 xchg %ax,%ax +801025ee: 66 90 xchg %ax,%ax + +801025f0 : + + return inb(CMOS_RETURN); +} + +static void fill_rtcdate(struct rtcdate *r) +{ +801025f0: 55 push %ebp +801025f1: 89 c1 mov %eax,%ecx +801025f3: 89 e5 mov %esp,%ebp + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +801025f5: ba 70 00 00 00 mov $0x70,%edx +801025fa: 53 push %ebx +801025fb: 31 c0 xor %eax,%eax +801025fd: ee out %al,(%dx) + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +801025fe: bb 71 00 00 00 mov $0x71,%ebx +80102603: 89 da mov %ebx,%edx +80102605: ec in (%dx),%al + return inb(CMOS_RETURN); +80102606: 0f b6 c0 movzbl %al,%eax + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +80102609: b2 70 mov $0x70,%dl +8010260b: 89 01 mov %eax,(%ecx) +8010260d: b8 02 00 00 00 mov $0x2,%eax +80102612: ee out %al,(%dx) + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +80102613: 89 da mov %ebx,%edx +80102615: ec in (%dx),%al +80102616: 0f b6 c0 movzbl %al,%eax + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +80102619: b2 70 mov $0x70,%dl +8010261b: 89 41 04 mov %eax,0x4(%ecx) +8010261e: b8 04 00 00 00 mov $0x4,%eax +80102623: ee out %al,(%dx) + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +80102624: 89 da mov %ebx,%edx +80102626: ec in (%dx),%al +80102627: 0f b6 c0 movzbl %al,%eax + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +8010262a: b2 70 mov $0x70,%dl +8010262c: 89 41 08 mov %eax,0x8(%ecx) +8010262f: b8 07 00 00 00 mov $0x7,%eax +80102634: ee out %al,(%dx) + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +80102635: 89 da mov %ebx,%edx +80102637: ec in (%dx),%al +80102638: 0f b6 c0 movzbl %al,%eax + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +8010263b: b2 70 mov $0x70,%dl +8010263d: 89 41 0c mov %eax,0xc(%ecx) +80102640: b8 08 00 00 00 mov $0x8,%eax +80102645: ee out %al,(%dx) + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +80102646: 89 da mov %ebx,%edx +80102648: ec in (%dx),%al +80102649: 0f b6 c0 movzbl %al,%eax + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +8010264c: b2 70 mov $0x70,%dl +8010264e: 89 41 10 mov %eax,0x10(%ecx) +80102651: b8 09 00 00 00 mov $0x9,%eax +80102656: ee out %al,(%dx) + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +80102657: 89 da mov %ebx,%edx +80102659: ec in (%dx),%al +8010265a: 0f b6 d8 movzbl %al,%ebx +8010265d: 89 59 14 mov %ebx,0x14(%ecx) + r->minute = cmos_read(MINS); + r->hour = cmos_read(HOURS); + r->day = cmos_read(DAY); + r->month = cmos_read(MONTH); + r->year = cmos_read(YEAR); +} +80102660: 5b pop %ebx +80102661: 5d pop %ebp +80102662: c3 ret +80102663: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80102669: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80102670 : + if(!lapic) +80102670: a1 7c 26 11 80 mov 0x8011267c,%eax +{ +80102675: 55 push %ebp +80102676: 89 e5 mov %esp,%ebp + if(!lapic) +80102678: 85 c0 test %eax,%eax +8010267a: 0f 84 c0 00 00 00 je 80102740 + lapic[index] = value; +80102680: c7 80 f0 00 00 00 3f movl $0x13f,0xf0(%eax) +80102687: 01 00 00 + lapic[ID]; // wait for write to finish, by reading +8010268a: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +8010268d: c7 80 e0 03 00 00 0b movl $0xb,0x3e0(%eax) +80102694: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +80102697: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +8010269a: c7 80 20 03 00 00 20 movl $0x20020,0x320(%eax) +801026a1: 00 02 00 + lapic[ID]; // wait for write to finish, by reading +801026a4: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +801026a7: c7 80 80 03 00 00 80 movl $0x989680,0x380(%eax) +801026ae: 96 98 00 + lapic[ID]; // wait for write to finish, by reading +801026b1: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +801026b4: c7 80 50 03 00 00 00 movl $0x10000,0x350(%eax) +801026bb: 00 01 00 + lapic[ID]; // wait for write to finish, by reading +801026be: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +801026c1: c7 80 60 03 00 00 00 movl $0x10000,0x360(%eax) +801026c8: 00 01 00 + lapic[ID]; // wait for write to finish, by reading +801026cb: 8b 50 20 mov 0x20(%eax),%edx + if(((lapic[VER]>>16) & 0xFF) >= 4) +801026ce: 8b 50 30 mov 0x30(%eax),%edx +801026d1: c1 ea 10 shr $0x10,%edx +801026d4: 80 fa 03 cmp $0x3,%dl +801026d7: 77 6f ja 80102748 + lapic[index] = value; +801026d9: c7 80 70 03 00 00 33 movl $0x33,0x370(%eax) +801026e0: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +801026e3: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +801026e6: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) +801026ed: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +801026f0: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +801026f3: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) +801026fa: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +801026fd: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80102700: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) +80102707: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +8010270a: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +8010270d: c7 80 10 03 00 00 00 movl $0x0,0x310(%eax) +80102714: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +80102717: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +8010271a: c7 80 00 03 00 00 00 movl $0x88500,0x300(%eax) +80102721: 85 08 00 + lapic[ID]; // wait for write to finish, by reading +80102724: 8b 50 20 mov 0x20(%eax),%edx +80102727: 90 nop + while(lapic[ICRLO] & DELIVS) +80102728: 8b 90 00 03 00 00 mov 0x300(%eax),%edx +8010272e: 80 e6 10 and $0x10,%dh +80102731: 75 f5 jne 80102728 + lapic[index] = value; +80102733: c7 80 80 00 00 00 00 movl $0x0,0x80(%eax) +8010273a: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +8010273d: 8b 40 20 mov 0x20(%eax),%eax +} +80102740: 5d pop %ebp +80102741: c3 ret +80102742: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + lapic[index] = value; +80102748: c7 80 40 03 00 00 00 movl $0x10000,0x340(%eax) +8010274f: 00 01 00 + lapic[ID]; // wait for write to finish, by reading +80102752: 8b 50 20 mov 0x20(%eax),%edx +80102755: eb 82 jmp 801026d9 +80102757: 89 f6 mov %esi,%esi +80102759: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80102760 : + if (!lapic) +80102760: a1 7c 26 11 80 mov 0x8011267c,%eax +{ +80102765: 55 push %ebp +80102766: 89 e5 mov %esp,%ebp + if (!lapic) +80102768: 85 c0 test %eax,%eax +8010276a: 74 0c je 80102778 + return lapic[ID] >> 24; +8010276c: 8b 40 20 mov 0x20(%eax),%eax +} +8010276f: 5d pop %ebp + return lapic[ID] >> 24; +80102770: c1 e8 18 shr $0x18,%eax +} +80102773: c3 ret +80102774: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return 0; +80102778: 31 c0 xor %eax,%eax +} +8010277a: 5d pop %ebp +8010277b: c3 ret +8010277c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80102780 : + if(lapic) +80102780: a1 7c 26 11 80 mov 0x8011267c,%eax +{ +80102785: 55 push %ebp +80102786: 89 e5 mov %esp,%ebp + if(lapic) +80102788: 85 c0 test %eax,%eax +8010278a: 74 0d je 80102799 + lapic[index] = value; +8010278c: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) +80102793: 00 00 00 + lapic[ID]; // wait for write to finish, by reading +80102796: 8b 40 20 mov 0x20(%eax),%eax +} +80102799: 5d pop %ebp +8010279a: c3 ret +8010279b: 90 nop +8010279c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +801027a0 : +{ +801027a0: 55 push %ebp +801027a1: 89 e5 mov %esp,%ebp +} +801027a3: 5d pop %ebp +801027a4: c3 ret +801027a5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801027a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +801027b0 : +{ +801027b0: 55 push %ebp + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +801027b1: ba 70 00 00 00 mov $0x70,%edx +801027b6: 89 e5 mov %esp,%ebp +801027b8: b8 0f 00 00 00 mov $0xf,%eax +801027bd: 53 push %ebx +801027be: 8b 4d 08 mov 0x8(%ebp),%ecx +801027c1: 8b 5d 0c mov 0xc(%ebp),%ebx +801027c4: ee out %al,(%dx) +801027c5: b8 0a 00 00 00 mov $0xa,%eax +801027ca: b2 71 mov $0x71,%dl +801027cc: ee out %al,(%dx) + wrv[0] = 0; +801027cd: 31 c0 xor %eax,%eax +801027cf: 66 a3 67 04 00 80 mov %ax,0x80000467 + wrv[1] = addr >> 4; +801027d5: 89 d8 mov %ebx,%eax +801027d7: c1 e8 04 shr $0x4,%eax +801027da: 66 a3 69 04 00 80 mov %ax,0x80000469 + lapic[index] = value; +801027e0: a1 7c 26 11 80 mov 0x8011267c,%eax + lapicw(ICRHI, apicid<<24); +801027e5: c1 e1 18 shl $0x18,%ecx + lapicw(ICRLO, STARTUP | (addr>>12)); +801027e8: c1 eb 0c shr $0xc,%ebx + lapic[index] = value; +801027eb: 89 88 10 03 00 00 mov %ecx,0x310(%eax) + lapic[ID]; // wait for write to finish, by reading +801027f1: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +801027f4: c7 80 00 03 00 00 00 movl $0xc500,0x300(%eax) +801027fb: c5 00 00 + lapic[ID]; // wait for write to finish, by reading +801027fe: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +80102801: c7 80 00 03 00 00 00 movl $0x8500,0x300(%eax) +80102808: 85 00 00 + lapic[ID]; // wait for write to finish, by reading +8010280b: 8b 50 20 mov 0x20(%eax),%edx + lapic[index] = value; +8010280e: 89 88 10 03 00 00 mov %ecx,0x310(%eax) + lapic[ID]; // wait for write to finish, by reading +80102814: 8b 50 20 mov 0x20(%eax),%edx + lapicw(ICRLO, STARTUP | (addr>>12)); +80102817: 89 da mov %ebx,%edx +80102819: 80 ce 06 or $0x6,%dh + lapic[index] = value; +8010281c: 89 90 00 03 00 00 mov %edx,0x300(%eax) + lapic[ID]; // wait for write to finish, by reading +80102822: 8b 58 20 mov 0x20(%eax),%ebx + lapic[index] = value; +80102825: 89 88 10 03 00 00 mov %ecx,0x310(%eax) + lapic[ID]; // wait for write to finish, by reading +8010282b: 8b 48 20 mov 0x20(%eax),%ecx + lapic[index] = value; +8010282e: 89 90 00 03 00 00 mov %edx,0x300(%eax) + lapic[ID]; // wait for write to finish, by reading +80102834: 8b 40 20 mov 0x20(%eax),%eax +} +80102837: 5b pop %ebx +80102838: 5d pop %ebp +80102839: c3 ret +8010283a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80102840 : + +// qemu seems to use 24-hour GWT and the values are BCD encoded +void cmostime(struct rtcdate *r) +{ +80102840: 55 push %ebp +80102841: ba 70 00 00 00 mov $0x70,%edx +80102846: 89 e5 mov %esp,%ebp +80102848: b8 0b 00 00 00 mov $0xb,%eax +8010284d: 57 push %edi +8010284e: 56 push %esi +8010284f: 53 push %ebx +80102850: 83 ec 4c sub $0x4c,%esp +80102853: ee out %al,(%dx) + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +80102854: b2 71 mov $0x71,%dl +80102856: ec in (%dx),%al +80102857: 88 45 b7 mov %al,-0x49(%ebp) +8010285a: 8d 5d b8 lea -0x48(%ebp),%ebx + struct rtcdate t1, t2; + int sb, bcd; + + sb = cmos_read(CMOS_STATB); + + bcd = (sb & (1 << 2)) == 0; +8010285d: 80 65 b7 04 andb $0x4,-0x49(%ebp) +80102861: 8d 7d d0 lea -0x30(%ebp),%edi +80102864: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +80102868: be 70 00 00 00 mov $0x70,%esi + + // make sure CMOS doesn't modify time while we read it + for(;;) { + fill_rtcdate(&t1); +8010286d: 89 d8 mov %ebx,%eax +8010286f: e8 7c fd ff ff call 801025f0 +80102874: b8 0a 00 00 00 mov $0xa,%eax +80102879: 89 f2 mov %esi,%edx +8010287b: ee out %al,(%dx) + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +8010287c: ba 71 00 00 00 mov $0x71,%edx +80102881: ec in (%dx),%al + if(cmos_read(CMOS_STATA) & CMOS_UIP) +80102882: 84 c0 test %al,%al +80102884: 78 e7 js 8010286d + continue; + fill_rtcdate(&t2); +80102886: 89 f8 mov %edi,%eax +80102888: e8 63 fd ff ff call 801025f0 + if(memcmp(&t1, &t2, sizeof(t1)) == 0) +8010288d: c7 44 24 08 18 00 00 movl $0x18,0x8(%esp) +80102894: 00 +80102895: 89 7c 24 04 mov %edi,0x4(%esp) +80102899: 89 1c 24 mov %ebx,(%esp) +8010289c: e8 2f 1a 00 00 call 801042d0 +801028a1: 85 c0 test %eax,%eax +801028a3: 75 c3 jne 80102868 + break; + } + + // convert + if(bcd) { +801028a5: 80 7d b7 00 cmpb $0x0,-0x49(%ebp) +801028a9: 75 78 jne 80102923 +#define CONV(x) (t1.x = ((t1.x >> 4) * 10) + (t1.x & 0xf)) + CONV(second); +801028ab: 8b 45 b8 mov -0x48(%ebp),%eax +801028ae: 89 c2 mov %eax,%edx +801028b0: 83 e0 0f and $0xf,%eax +801028b3: c1 ea 04 shr $0x4,%edx +801028b6: 8d 14 92 lea (%edx,%edx,4),%edx +801028b9: 8d 04 50 lea (%eax,%edx,2),%eax +801028bc: 89 45 b8 mov %eax,-0x48(%ebp) + CONV(minute); +801028bf: 8b 45 bc mov -0x44(%ebp),%eax +801028c2: 89 c2 mov %eax,%edx +801028c4: 83 e0 0f and $0xf,%eax +801028c7: c1 ea 04 shr $0x4,%edx +801028ca: 8d 14 92 lea (%edx,%edx,4),%edx +801028cd: 8d 04 50 lea (%eax,%edx,2),%eax +801028d0: 89 45 bc mov %eax,-0x44(%ebp) + CONV(hour ); +801028d3: 8b 45 c0 mov -0x40(%ebp),%eax +801028d6: 89 c2 mov %eax,%edx +801028d8: 83 e0 0f and $0xf,%eax +801028db: c1 ea 04 shr $0x4,%edx +801028de: 8d 14 92 lea (%edx,%edx,4),%edx +801028e1: 8d 04 50 lea (%eax,%edx,2),%eax +801028e4: 89 45 c0 mov %eax,-0x40(%ebp) + CONV(day ); +801028e7: 8b 45 c4 mov -0x3c(%ebp),%eax +801028ea: 89 c2 mov %eax,%edx +801028ec: 83 e0 0f and $0xf,%eax +801028ef: c1 ea 04 shr $0x4,%edx +801028f2: 8d 14 92 lea (%edx,%edx,4),%edx +801028f5: 8d 04 50 lea (%eax,%edx,2),%eax +801028f8: 89 45 c4 mov %eax,-0x3c(%ebp) + CONV(month ); +801028fb: 8b 45 c8 mov -0x38(%ebp),%eax +801028fe: 89 c2 mov %eax,%edx +80102900: 83 e0 0f and $0xf,%eax +80102903: c1 ea 04 shr $0x4,%edx +80102906: 8d 14 92 lea (%edx,%edx,4),%edx +80102909: 8d 04 50 lea (%eax,%edx,2),%eax +8010290c: 89 45 c8 mov %eax,-0x38(%ebp) + CONV(year ); +8010290f: 8b 45 cc mov -0x34(%ebp),%eax +80102912: 89 c2 mov %eax,%edx +80102914: 83 e0 0f and $0xf,%eax +80102917: c1 ea 04 shr $0x4,%edx +8010291a: 8d 14 92 lea (%edx,%edx,4),%edx +8010291d: 8d 04 50 lea (%eax,%edx,2),%eax +80102920: 89 45 cc mov %eax,-0x34(%ebp) +#undef CONV + } + + *r = t1; +80102923: 8b 4d 08 mov 0x8(%ebp),%ecx +80102926: 8b 45 b8 mov -0x48(%ebp),%eax +80102929: 89 01 mov %eax,(%ecx) +8010292b: 8b 45 bc mov -0x44(%ebp),%eax +8010292e: 89 41 04 mov %eax,0x4(%ecx) +80102931: 8b 45 c0 mov -0x40(%ebp),%eax +80102934: 89 41 08 mov %eax,0x8(%ecx) +80102937: 8b 45 c4 mov -0x3c(%ebp),%eax +8010293a: 89 41 0c mov %eax,0xc(%ecx) +8010293d: 8b 45 c8 mov -0x38(%ebp),%eax +80102940: 89 41 10 mov %eax,0x10(%ecx) +80102943: 8b 45 cc mov -0x34(%ebp),%eax +80102946: 89 41 14 mov %eax,0x14(%ecx) + r->year += 2000; +80102949: 81 41 14 d0 07 00 00 addl $0x7d0,0x14(%ecx) +} +80102950: 83 c4 4c add $0x4c,%esp +80102953: 5b pop %ebx +80102954: 5e pop %esi +80102955: 5f pop %edi +80102956: 5d pop %ebp +80102957: c3 ret +80102958: 66 90 xchg %ax,%ax +8010295a: 66 90 xchg %ax,%ax +8010295c: 66 90 xchg %ax,%ax +8010295e: 66 90 xchg %ax,%ax + +80102960 : +} + +// Copy committed blocks from log to their home location +static void +install_trans(void) +{ +80102960: 55 push %ebp +80102961: 89 e5 mov %esp,%ebp +80102963: 57 push %edi +80102964: 56 push %esi +80102965: 53 push %ebx + int tail; + + for (tail = 0; tail < log.lh.n; tail++) { +80102966: 31 db xor %ebx,%ebx +{ +80102968: 83 ec 1c sub $0x1c,%esp + for (tail = 0; tail < log.lh.n; tail++) { +8010296b: a1 c8 26 11 80 mov 0x801126c8,%eax +80102970: 85 c0 test %eax,%eax +80102972: 7e 78 jle 801029ec +80102974: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block +80102978: a1 b4 26 11 80 mov 0x801126b4,%eax +8010297d: 01 d8 add %ebx,%eax +8010297f: 83 c0 01 add $0x1,%eax +80102982: 89 44 24 04 mov %eax,0x4(%esp) +80102986: a1 c4 26 11 80 mov 0x801126c4,%eax +8010298b: 89 04 24 mov %eax,(%esp) +8010298e: e8 3d d7 ff ff call 801000d0 +80102993: 89 c7 mov %eax,%edi + struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst +80102995: 8b 04 9d cc 26 11 80 mov -0x7feed934(,%ebx,4),%eax + for (tail = 0; tail < log.lh.n; tail++) { +8010299c: 83 c3 01 add $0x1,%ebx + struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst +8010299f: 89 44 24 04 mov %eax,0x4(%esp) +801029a3: a1 c4 26 11 80 mov 0x801126c4,%eax +801029a8: 89 04 24 mov %eax,(%esp) +801029ab: e8 20 d7 ff ff call 801000d0 + memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst +801029b0: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) +801029b7: 00 + struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst +801029b8: 89 c6 mov %eax,%esi + memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst +801029ba: 8d 47 5c lea 0x5c(%edi),%eax +801029bd: 89 44 24 04 mov %eax,0x4(%esp) +801029c1: 8d 46 5c lea 0x5c(%esi),%eax +801029c4: 89 04 24 mov %eax,(%esp) +801029c7: e8 54 19 00 00 call 80104320 + bwrite(dbuf); // write dst to disk +801029cc: 89 34 24 mov %esi,(%esp) +801029cf: e8 cc d7 ff ff call 801001a0 + brelse(lbuf); +801029d4: 89 3c 24 mov %edi,(%esp) +801029d7: e8 04 d8 ff ff call 801001e0 + brelse(dbuf); +801029dc: 89 34 24 mov %esi,(%esp) +801029df: e8 fc d7 ff ff call 801001e0 + for (tail = 0; tail < log.lh.n; tail++) { +801029e4: 39 1d c8 26 11 80 cmp %ebx,0x801126c8 +801029ea: 7f 8c jg 80102978 + } +} +801029ec: 83 c4 1c add $0x1c,%esp +801029ef: 5b pop %ebx +801029f0: 5e pop %esi +801029f1: 5f pop %edi +801029f2: 5d pop %ebp +801029f3: c3 ret +801029f4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +801029fa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +80102a00 : +// Write in-memory log header to disk. +// This is the true point at which the +// current transaction commits. +static void +write_head(void) +{ +80102a00: 55 push %ebp +80102a01: 89 e5 mov %esp,%ebp +80102a03: 57 push %edi +80102a04: 56 push %esi +80102a05: 53 push %ebx +80102a06: 83 ec 1c sub $0x1c,%esp + struct buf *buf = bread(log.dev, log.start); +80102a09: a1 b4 26 11 80 mov 0x801126b4,%eax +80102a0e: 89 44 24 04 mov %eax,0x4(%esp) +80102a12: a1 c4 26 11 80 mov 0x801126c4,%eax +80102a17: 89 04 24 mov %eax,(%esp) +80102a1a: e8 b1 d6 ff ff call 801000d0 + struct logheader *hb = (struct logheader *) (buf->data); + int i; + hb->n = log.lh.n; +80102a1f: 8b 1d c8 26 11 80 mov 0x801126c8,%ebx + for (i = 0; i < log.lh.n; i++) { +80102a25: 31 d2 xor %edx,%edx +80102a27: 85 db test %ebx,%ebx + struct buf *buf = bread(log.dev, log.start); +80102a29: 89 c7 mov %eax,%edi + hb->n = log.lh.n; +80102a2b: 89 58 5c mov %ebx,0x5c(%eax) +80102a2e: 8d 70 5c lea 0x5c(%eax),%esi + for (i = 0; i < log.lh.n; i++) { +80102a31: 7e 17 jle 80102a4a +80102a33: 90 nop +80102a34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + hb->block[i] = log.lh.block[i]; +80102a38: 8b 0c 95 cc 26 11 80 mov -0x7feed934(,%edx,4),%ecx +80102a3f: 89 4c 96 04 mov %ecx,0x4(%esi,%edx,4) + for (i = 0; i < log.lh.n; i++) { +80102a43: 83 c2 01 add $0x1,%edx +80102a46: 39 da cmp %ebx,%edx +80102a48: 75 ee jne 80102a38 + } + bwrite(buf); +80102a4a: 89 3c 24 mov %edi,(%esp) +80102a4d: e8 4e d7 ff ff call 801001a0 + brelse(buf); +80102a52: 89 3c 24 mov %edi,(%esp) +80102a55: e8 86 d7 ff ff call 801001e0 +} +80102a5a: 83 c4 1c add $0x1c,%esp +80102a5d: 5b pop %ebx +80102a5e: 5e pop %esi +80102a5f: 5f pop %edi +80102a60: 5d pop %ebp +80102a61: c3 ret +80102a62: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80102a69: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80102a70 : +{ +80102a70: 55 push %ebp +80102a71: 89 e5 mov %esp,%ebp +80102a73: 56 push %esi +80102a74: 53 push %ebx +80102a75: 83 ec 30 sub $0x30,%esp +80102a78: 8b 5d 08 mov 0x8(%ebp),%ebx + initlock(&log.lock, "log"); +80102a7b: c7 44 24 04 c0 72 10 movl $0x801072c0,0x4(%esp) +80102a82: 80 +80102a83: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) +80102a8a: e8 c1 15 00 00 call 80104050 + readsb(dev, &sb); +80102a8f: 8d 45 dc lea -0x24(%ebp),%eax +80102a92: 89 44 24 04 mov %eax,0x4(%esp) +80102a96: 89 1c 24 mov %ebx,(%esp) +80102a99: e8 f2 e8 ff ff call 80101390 + log.start = sb.logstart; +80102a9e: 8b 45 ec mov -0x14(%ebp),%eax + log.size = sb.nlog; +80102aa1: 8b 55 e8 mov -0x18(%ebp),%edx + struct buf *buf = bread(log.dev, log.start); +80102aa4: 89 1c 24 mov %ebx,(%esp) + log.dev = dev; +80102aa7: 89 1d c4 26 11 80 mov %ebx,0x801126c4 + struct buf *buf = bread(log.dev, log.start); +80102aad: 89 44 24 04 mov %eax,0x4(%esp) + log.size = sb.nlog; +80102ab1: 89 15 b8 26 11 80 mov %edx,0x801126b8 + log.start = sb.logstart; +80102ab7: a3 b4 26 11 80 mov %eax,0x801126b4 + struct buf *buf = bread(log.dev, log.start); +80102abc: e8 0f d6 ff ff call 801000d0 + for (i = 0; i < log.lh.n; i++) { +80102ac1: 31 d2 xor %edx,%edx + log.lh.n = lh->n; +80102ac3: 8b 58 5c mov 0x5c(%eax),%ebx +80102ac6: 8d 70 5c lea 0x5c(%eax),%esi + for (i = 0; i < log.lh.n; i++) { +80102ac9: 85 db test %ebx,%ebx + log.lh.n = lh->n; +80102acb: 89 1d c8 26 11 80 mov %ebx,0x801126c8 + for (i = 0; i < log.lh.n; i++) { +80102ad1: 7e 17 jle 80102aea +80102ad3: 90 nop +80102ad4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + log.lh.block[i] = lh->block[i]; +80102ad8: 8b 4c 96 04 mov 0x4(%esi,%edx,4),%ecx +80102adc: 89 0c 95 cc 26 11 80 mov %ecx,-0x7feed934(,%edx,4) + for (i = 0; i < log.lh.n; i++) { +80102ae3: 83 c2 01 add $0x1,%edx +80102ae6: 39 da cmp %ebx,%edx +80102ae8: 75 ee jne 80102ad8 + brelse(buf); +80102aea: 89 04 24 mov %eax,(%esp) +80102aed: e8 ee d6 ff ff call 801001e0 + +static void +recover_from_log(void) +{ + read_head(); + install_trans(); // if committed, copy from log to disk +80102af2: e8 69 fe ff ff call 80102960 + log.lh.n = 0; +80102af7: c7 05 c8 26 11 80 00 movl $0x0,0x801126c8 +80102afe: 00 00 00 + write_head(); // clear the log +80102b01: e8 fa fe ff ff call 80102a00 +} +80102b06: 83 c4 30 add $0x30,%esp +80102b09: 5b pop %ebx +80102b0a: 5e pop %esi +80102b0b: 5d pop %ebp +80102b0c: c3 ret +80102b0d: 8d 76 00 lea 0x0(%esi),%esi + +80102b10 : +} + +// called at the start of each FS system call. +void +begin_op(void) +{ +80102b10: 55 push %ebp +80102b11: 89 e5 mov %esp,%ebp +80102b13: 83 ec 18 sub $0x18,%esp + acquire(&log.lock); +80102b16: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) +80102b1d: e8 1e 16 00 00 call 80104140 +80102b22: eb 18 jmp 80102b3c +80102b24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while(1){ + if(log.committing){ + sleep(&log, &log.lock); +80102b28: c7 44 24 04 80 26 11 movl $0x80112680,0x4(%esp) +80102b2f: 80 +80102b30: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) +80102b37: e8 c4 10 00 00 call 80103c00 + if(log.committing){ +80102b3c: a1 c0 26 11 80 mov 0x801126c0,%eax +80102b41: 85 c0 test %eax,%eax +80102b43: 75 e3 jne 80102b28 + } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ +80102b45: a1 bc 26 11 80 mov 0x801126bc,%eax +80102b4a: 8b 15 c8 26 11 80 mov 0x801126c8,%edx +80102b50: 83 c0 01 add $0x1,%eax +80102b53: 8d 0c 80 lea (%eax,%eax,4),%ecx +80102b56: 8d 14 4a lea (%edx,%ecx,2),%edx +80102b59: 83 fa 1e cmp $0x1e,%edx +80102b5c: 7f ca jg 80102b28 + // this op might exhaust log space; wait for commit. + sleep(&log, &log.lock); + } else { + log.outstanding += 1; + release(&log.lock); +80102b5e: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) + log.outstanding += 1; +80102b65: a3 bc 26 11 80 mov %eax,0x801126bc + release(&log.lock); +80102b6a: e8 c1 16 00 00 call 80104230 + break; + } + } +} +80102b6f: c9 leave +80102b70: c3 ret +80102b71: eb 0d jmp 80102b80 +80102b73: 90 nop +80102b74: 90 nop +80102b75: 90 nop +80102b76: 90 nop +80102b77: 90 nop +80102b78: 90 nop +80102b79: 90 nop +80102b7a: 90 nop +80102b7b: 90 nop +80102b7c: 90 nop +80102b7d: 90 nop +80102b7e: 90 nop +80102b7f: 90 nop + +80102b80 : + +// called at the end of each FS system call. +// commits if this was the last outstanding operation. +void +end_op(void) +{ +80102b80: 55 push %ebp +80102b81: 89 e5 mov %esp,%ebp +80102b83: 57 push %edi +80102b84: 56 push %esi +80102b85: 53 push %ebx +80102b86: 83 ec 1c sub $0x1c,%esp + int do_commit = 0; + + acquire(&log.lock); +80102b89: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) +80102b90: e8 ab 15 00 00 call 80104140 + log.outstanding -= 1; +80102b95: a1 bc 26 11 80 mov 0x801126bc,%eax + if(log.committing) +80102b9a: 8b 15 c0 26 11 80 mov 0x801126c0,%edx + log.outstanding -= 1; +80102ba0: 83 e8 01 sub $0x1,%eax + if(log.committing) +80102ba3: 85 d2 test %edx,%edx + log.outstanding -= 1; +80102ba5: a3 bc 26 11 80 mov %eax,0x801126bc + if(log.committing) +80102baa: 0f 85 f3 00 00 00 jne 80102ca3 + panic("log.committing"); + if(log.outstanding == 0){ +80102bb0: 85 c0 test %eax,%eax +80102bb2: 0f 85 cb 00 00 00 jne 80102c83 + // begin_op() may be waiting for log space, + // and decrementing log.outstanding has decreased + // the amount of reserved space. + wakeup(&log); + } + release(&log.lock); +80102bb8: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) +} + +static void +commit() +{ + if (log.lh.n > 0) { +80102bbf: 31 db xor %ebx,%ebx + log.committing = 1; +80102bc1: c7 05 c0 26 11 80 01 movl $0x1,0x801126c0 +80102bc8: 00 00 00 + release(&log.lock); +80102bcb: e8 60 16 00 00 call 80104230 + if (log.lh.n > 0) { +80102bd0: a1 c8 26 11 80 mov 0x801126c8,%eax +80102bd5: 85 c0 test %eax,%eax +80102bd7: 0f 8e 90 00 00 00 jle 80102c6d +80102bdd: 8d 76 00 lea 0x0(%esi),%esi + struct buf *to = bread(log.dev, log.start+tail+1); // log block +80102be0: a1 b4 26 11 80 mov 0x801126b4,%eax +80102be5: 01 d8 add %ebx,%eax +80102be7: 83 c0 01 add $0x1,%eax +80102bea: 89 44 24 04 mov %eax,0x4(%esp) +80102bee: a1 c4 26 11 80 mov 0x801126c4,%eax +80102bf3: 89 04 24 mov %eax,(%esp) +80102bf6: e8 d5 d4 ff ff call 801000d0 +80102bfb: 89 c6 mov %eax,%esi + struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block +80102bfd: 8b 04 9d cc 26 11 80 mov -0x7feed934(,%ebx,4),%eax + for (tail = 0; tail < log.lh.n; tail++) { +80102c04: 83 c3 01 add $0x1,%ebx + struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block +80102c07: 89 44 24 04 mov %eax,0x4(%esp) +80102c0b: a1 c4 26 11 80 mov 0x801126c4,%eax +80102c10: 89 04 24 mov %eax,(%esp) +80102c13: e8 b8 d4 ff ff call 801000d0 + memmove(to->data, from->data, BSIZE); +80102c18: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) +80102c1f: 00 + struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block +80102c20: 89 c7 mov %eax,%edi + memmove(to->data, from->data, BSIZE); +80102c22: 8d 40 5c lea 0x5c(%eax),%eax +80102c25: 89 44 24 04 mov %eax,0x4(%esp) +80102c29: 8d 46 5c lea 0x5c(%esi),%eax +80102c2c: 89 04 24 mov %eax,(%esp) +80102c2f: e8 ec 16 00 00 call 80104320 + bwrite(to); // write the log +80102c34: 89 34 24 mov %esi,(%esp) +80102c37: e8 64 d5 ff ff call 801001a0 + brelse(from); +80102c3c: 89 3c 24 mov %edi,(%esp) +80102c3f: e8 9c d5 ff ff call 801001e0 + brelse(to); +80102c44: 89 34 24 mov %esi,(%esp) +80102c47: e8 94 d5 ff ff call 801001e0 + for (tail = 0; tail < log.lh.n; tail++) { +80102c4c: 3b 1d c8 26 11 80 cmp 0x801126c8,%ebx +80102c52: 7c 8c jl 80102be0 + write_log(); // Write modified blocks from cache to log + write_head(); // Write header to disk -- the real commit +80102c54: e8 a7 fd ff ff call 80102a00 + install_trans(); // Now install writes to home locations +80102c59: e8 02 fd ff ff call 80102960 + log.lh.n = 0; +80102c5e: c7 05 c8 26 11 80 00 movl $0x0,0x801126c8 +80102c65: 00 00 00 + write_head(); // Erase the transaction from the log +80102c68: e8 93 fd ff ff call 80102a00 + acquire(&log.lock); +80102c6d: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) +80102c74: e8 c7 14 00 00 call 80104140 + log.committing = 0; +80102c79: c7 05 c0 26 11 80 00 movl $0x0,0x801126c0 +80102c80: 00 00 00 + wakeup(&log); +80102c83: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) +80102c8a: e8 01 11 00 00 call 80103d90 + release(&log.lock); +80102c8f: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) +80102c96: e8 95 15 00 00 call 80104230 +} +80102c9b: 83 c4 1c add $0x1c,%esp +80102c9e: 5b pop %ebx +80102c9f: 5e pop %esi +80102ca0: 5f pop %edi +80102ca1: 5d pop %ebp +80102ca2: c3 ret + panic("log.committing"); +80102ca3: c7 04 24 c4 72 10 80 movl $0x801072c4,(%esp) +80102caa: e8 b1 d6 ff ff call 80100360 +80102caf: 90 nop + +80102cb0 : +// modify bp->data[] +// log_write(bp) +// brelse(bp) +void +log_write(struct buf *b) +{ +80102cb0: 55 push %ebp +80102cb1: 89 e5 mov %esp,%ebp +80102cb3: 53 push %ebx +80102cb4: 83 ec 14 sub $0x14,%esp + int i; + + if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) +80102cb7: a1 c8 26 11 80 mov 0x801126c8,%eax +{ +80102cbc: 8b 5d 08 mov 0x8(%ebp),%ebx + if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) +80102cbf: 83 f8 1d cmp $0x1d,%eax +80102cc2: 0f 8f 98 00 00 00 jg 80102d60 +80102cc8: 8b 0d b8 26 11 80 mov 0x801126b8,%ecx +80102cce: 8d 51 ff lea -0x1(%ecx),%edx +80102cd1: 39 d0 cmp %edx,%eax +80102cd3: 0f 8d 87 00 00 00 jge 80102d60 + panic("too big a transaction"); + if (log.outstanding < 1) +80102cd9: a1 bc 26 11 80 mov 0x801126bc,%eax +80102cde: 85 c0 test %eax,%eax +80102ce0: 0f 8e 86 00 00 00 jle 80102d6c + panic("log_write outside of trans"); + + acquire(&log.lock); +80102ce6: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) +80102ced: e8 4e 14 00 00 call 80104140 + for (i = 0; i < log.lh.n; i++) { +80102cf2: 8b 15 c8 26 11 80 mov 0x801126c8,%edx +80102cf8: 83 fa 00 cmp $0x0,%edx +80102cfb: 7e 54 jle 80102d51 + if (log.lh.block[i] == b->blockno) // log absorbtion +80102cfd: 8b 4b 08 mov 0x8(%ebx),%ecx + for (i = 0; i < log.lh.n; i++) { +80102d00: 31 c0 xor %eax,%eax + if (log.lh.block[i] == b->blockno) // log absorbtion +80102d02: 39 0d cc 26 11 80 cmp %ecx,0x801126cc +80102d08: 75 0f jne 80102d19 +80102d0a: eb 3c jmp 80102d48 +80102d0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80102d10: 39 0c 85 cc 26 11 80 cmp %ecx,-0x7feed934(,%eax,4) +80102d17: 74 2f je 80102d48 + for (i = 0; i < log.lh.n; i++) { +80102d19: 83 c0 01 add $0x1,%eax +80102d1c: 39 d0 cmp %edx,%eax +80102d1e: 75 f0 jne 80102d10 + break; + } + log.lh.block[i] = b->blockno; +80102d20: 89 0c 95 cc 26 11 80 mov %ecx,-0x7feed934(,%edx,4) + if (i == log.lh.n) + log.lh.n++; +80102d27: 83 c2 01 add $0x1,%edx +80102d2a: 89 15 c8 26 11 80 mov %edx,0x801126c8 + b->flags |= B_DIRTY; // prevent eviction +80102d30: 83 0b 04 orl $0x4,(%ebx) + release(&log.lock); +80102d33: c7 45 08 80 26 11 80 movl $0x80112680,0x8(%ebp) +} +80102d3a: 83 c4 14 add $0x14,%esp +80102d3d: 5b pop %ebx +80102d3e: 5d pop %ebp + release(&log.lock); +80102d3f: e9 ec 14 00 00 jmp 80104230 +80102d44: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + log.lh.block[i] = b->blockno; +80102d48: 89 0c 85 cc 26 11 80 mov %ecx,-0x7feed934(,%eax,4) +80102d4f: eb df jmp 80102d30 +80102d51: 8b 43 08 mov 0x8(%ebx),%eax +80102d54: a3 cc 26 11 80 mov %eax,0x801126cc + if (i == log.lh.n) +80102d59: 75 d5 jne 80102d30 +80102d5b: eb ca jmp 80102d27 +80102d5d: 8d 76 00 lea 0x0(%esi),%esi + panic("too big a transaction"); +80102d60: c7 04 24 d3 72 10 80 movl $0x801072d3,(%esp) +80102d67: e8 f4 d5 ff ff call 80100360 + panic("log_write outside of trans"); +80102d6c: c7 04 24 e9 72 10 80 movl $0x801072e9,(%esp) +80102d73: e8 e8 d5 ff ff call 80100360 +80102d78: 66 90 xchg %ax,%ax +80102d7a: 66 90 xchg %ax,%ax +80102d7c: 66 90 xchg %ax,%ax +80102d7e: 66 90 xchg %ax,%ax + +80102d80 : +} + +// Common CPU setup code. +static void +mpmain(void) +{ +80102d80: 55 push %ebp +80102d81: 89 e5 mov %esp,%ebp +80102d83: 53 push %ebx +80102d84: 83 ec 14 sub $0x14,%esp + cprintf("cpu%d: starting %d\n", cpuid(), cpuid()); +80102d87: e8 f4 08 00 00 call 80103680 +80102d8c: 89 c3 mov %eax,%ebx +80102d8e: e8 ed 08 00 00 call 80103680 +80102d93: 89 5c 24 08 mov %ebx,0x8(%esp) +80102d97: c7 04 24 04 73 10 80 movl $0x80107304,(%esp) +80102d9e: 89 44 24 04 mov %eax,0x4(%esp) +80102da2: e8 a9 d8 ff ff call 80100650 + idtinit(); // load idt register +80102da7: e8 34 27 00 00 call 801054e0 + xchg(&(mycpu()->started), 1); // tell startothers() we're up +80102dac: e8 4f 08 00 00 call 80103600 +80102db1: 89 c2 mov %eax,%edx +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : +80102db3: b8 01 00 00 00 mov $0x1,%eax +80102db8: f0 87 82 a0 00 00 00 lock xchg %eax,0xa0(%edx) + scheduler(); // start running processes +80102dbf: e8 9c 0b 00 00 call 80103960 +80102dc4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80102dca: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +80102dd0 : +{ +80102dd0: 55 push %ebp +80102dd1: 89 e5 mov %esp,%ebp +80102dd3: 83 ec 08 sub $0x8,%esp + switchkvm(); +80102dd6: e8 55 38 00 00 call 80106630 + seginit(); +80102ddb: e8 90 37 00 00 call 80106570 + lapicinit(); +80102de0: e8 8b f8 ff ff call 80102670 + mpmain(); +80102de5: e8 96 ff ff ff call 80102d80 +80102dea: 66 90 xchg %ax,%ax +80102dec: 66 90 xchg %ax,%ax +80102dee: 66 90 xchg %ax,%ax + +80102df0
: +{ +80102df0: 55 push %ebp +80102df1: 89 e5 mov %esp,%ebp +80102df3: 53 push %ebx + // The linker has placed the image of entryother.S in + // _binary_entryother_start. + code = P2V(0x7000); + memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); + + for(c = cpus; c < cpus+ncpu; c++){ +80102df4: bb 80 27 11 80 mov $0x80112780,%ebx +{ +80102df9: 83 e4 f0 and $0xfffffff0,%esp +80102dfc: 83 ec 10 sub $0x10,%esp + kinit1(end, P2V(4*1024*1024)); // phys page allocator +80102dff: c7 44 24 04 00 00 40 movl $0x80400000,0x4(%esp) +80102e06: 80 +80102e07: c7 04 24 14 59 11 80 movl $0x80115914,(%esp) +80102e0e: e8 cd f5 ff ff call 801023e0 + kvmalloc(); // kernel page table +80102e13: e8 c8 3c 00 00 call 80106ae0 + mpinit(); // detect other processors +80102e18: e8 73 01 00 00 call 80102f90 +80102e1d: 8d 76 00 lea 0x0(%esi),%esi + lapicinit(); // interrupt controller +80102e20: e8 4b f8 ff ff call 80102670 + seginit(); // segment descriptors +80102e25: e8 46 37 00 00 call 80106570 + picinit(); // disable pic +80102e2a: e8 21 03 00 00 call 80103150 +80102e2f: 90 nop + ioapicinit(); // another interrupt controller +80102e30: e8 cb f3 ff ff call 80102200 + consoleinit(); // console hardware +80102e35: e8 16 db ff ff call 80100950 + uartinit(); // serial port +80102e3a: e8 51 2a 00 00 call 80105890 +80102e3f: 90 nop + pinit(); // process table +80102e40: e8 9b 07 00 00 call 801035e0 + shminit(); // shared memory +80102e45: e8 56 3f 00 00 call 80106da0 + tvinit(); // trap vectors +80102e4a: e8 f1 25 00 00 call 80105440 +80102e4f: 90 nop + binit(); // buffer cache +80102e50: e8 eb d1 ff ff call 80100040 + fileinit(); // file table +80102e55: e8 e6 de ff ff call 80100d40 + ideinit(); // disk +80102e5a: e8 a1 f1 ff ff call 80102000 + memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); +80102e5f: c7 44 24 08 8a 00 00 movl $0x8a,0x8(%esp) +80102e66: 00 +80102e67: c7 44 24 04 8c a4 10 movl $0x8010a48c,0x4(%esp) +80102e6e: 80 +80102e6f: c7 04 24 00 70 00 80 movl $0x80007000,(%esp) +80102e76: e8 a5 14 00 00 call 80104320 + for(c = cpus; c < cpus+ncpu; c++){ +80102e7b: 69 05 00 2d 11 80 b0 imul $0xb0,0x80112d00,%eax +80102e82: 00 00 00 +80102e85: 05 80 27 11 80 add $0x80112780,%eax +80102e8a: 39 d8 cmp %ebx,%eax +80102e8c: 76 65 jbe 80102ef3 +80102e8e: 66 90 xchg %ax,%ax + if(c == mycpu()) // We've started already. +80102e90: e8 6b 07 00 00 call 80103600 +80102e95: 39 d8 cmp %ebx,%eax +80102e97: 74 41 je 80102eda + continue; + + // Tell entryother.S what stack to use, where to enter, and what + // pgdir to use. We cannot use kpgdir yet, because the AP processor + // is running in low memory, so we use entrypgdir for the APs too. + stack = kalloc(); +80102e99: e8 02 f6 ff ff call 801024a0 + *(void**)(code-4) = stack + KSTACKSIZE; + *(void**)(code-8) = mpenter; +80102e9e: c7 05 f8 6f 00 80 d0 movl $0x80102dd0,0x80006ff8 +80102ea5: 2d 10 80 + *(int**)(code-12) = (void *) V2P(entrypgdir); +80102ea8: c7 05 f4 6f 00 80 00 movl $0x109000,0x80006ff4 +80102eaf: 90 10 00 + *(void**)(code-4) = stack + KSTACKSIZE; +80102eb2: 05 00 10 00 00 add $0x1000,%eax +80102eb7: a3 fc 6f 00 80 mov %eax,0x80006ffc + + lapicstartap(c->apicid, V2P(code)); +80102ebc: 0f b6 03 movzbl (%ebx),%eax +80102ebf: c7 44 24 04 00 70 00 movl $0x7000,0x4(%esp) +80102ec6: 00 +80102ec7: 89 04 24 mov %eax,(%esp) +80102eca: e8 e1 f8 ff ff call 801027b0 +80102ecf: 90 nop + + // wait for cpu to finish mpmain() + while(c->started == 0) +80102ed0: 8b 83 a0 00 00 00 mov 0xa0(%ebx),%eax +80102ed6: 85 c0 test %eax,%eax +80102ed8: 74 f6 je 80102ed0 + for(c = cpus; c < cpus+ncpu; c++){ +80102eda: 69 05 00 2d 11 80 b0 imul $0xb0,0x80112d00,%eax +80102ee1: 00 00 00 +80102ee4: 81 c3 b0 00 00 00 add $0xb0,%ebx +80102eea: 05 80 27 11 80 add $0x80112780,%eax +80102eef: 39 c3 cmp %eax,%ebx +80102ef1: 72 9d jb 80102e90 + kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers() +80102ef3: c7 44 24 04 00 00 00 movl $0x8e000000,0x4(%esp) +80102efa: 8e +80102efb: c7 04 24 00 00 40 80 movl $0x80400000,(%esp) +80102f02: e8 49 f5 ff ff call 80102450 + userinit(); // first user process +80102f07: e8 c4 07 00 00 call 801036d0 + mpmain(); // finish this processor's setup +80102f0c: e8 6f fe ff ff call 80102d80 +80102f11: 66 90 xchg %ax,%ax +80102f13: 66 90 xchg %ax,%ax +80102f15: 66 90 xchg %ax,%ax +80102f17: 66 90 xchg %ax,%ax +80102f19: 66 90 xchg %ax,%ax +80102f1b: 66 90 xchg %ax,%ax +80102f1d: 66 90 xchg %ax,%ax +80102f1f: 90 nop + +80102f20 : +} + +// Look for an MP structure in the len bytes at addr. +static struct mp* +mpsearch1(uint a, int len) +{ +80102f20: 55 push %ebp +80102f21: 89 e5 mov %esp,%ebp +80102f23: 56 push %esi + uchar *e, *p, *addr; + + addr = P2V(a); +80102f24: 8d b0 00 00 00 80 lea -0x80000000(%eax),%esi +{ +80102f2a: 53 push %ebx + e = addr+len; +80102f2b: 8d 1c 16 lea (%esi,%edx,1),%ebx +{ +80102f2e: 83 ec 10 sub $0x10,%esp + for(p = addr; p < e; p += sizeof(struct mp)) +80102f31: 39 de cmp %ebx,%esi +80102f33: 73 3c jae 80102f71 +80102f35: 8d 76 00 lea 0x0(%esi),%esi + if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) +80102f38: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) +80102f3f: 00 +80102f40: c7 44 24 04 18 73 10 movl $0x80107318,0x4(%esp) +80102f47: 80 +80102f48: 89 34 24 mov %esi,(%esp) +80102f4b: e8 80 13 00 00 call 801042d0 +80102f50: 85 c0 test %eax,%eax +80102f52: 75 16 jne 80102f6a +80102f54: 31 c9 xor %ecx,%ecx +80102f56: 31 d2 xor %edx,%edx + sum += addr[i]; +80102f58: 0f b6 04 16 movzbl (%esi,%edx,1),%eax + for(i=0; i + if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) +80102f66: 84 c9 test %cl,%cl +80102f68: 74 10 je 80102f7a + for(p = addr; p < e; p += sizeof(struct mp)) +80102f6a: 83 c6 10 add $0x10,%esi +80102f6d: 39 f3 cmp %esi,%ebx +80102f6f: 77 c7 ja 80102f38 + return (struct mp*)p; + return 0; +} +80102f71: 83 c4 10 add $0x10,%esp + return 0; +80102f74: 31 c0 xor %eax,%eax +} +80102f76: 5b pop %ebx +80102f77: 5e pop %esi +80102f78: 5d pop %ebp +80102f79: c3 ret +80102f7a: 83 c4 10 add $0x10,%esp +80102f7d: 89 f0 mov %esi,%eax +80102f7f: 5b pop %ebx +80102f80: 5e pop %esi +80102f81: 5d pop %ebp +80102f82: c3 ret +80102f83: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80102f89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80102f90 : + return conf; +} + +void +mpinit(void) +{ +80102f90: 55 push %ebp +80102f91: 89 e5 mov %esp,%ebp +80102f93: 57 push %edi +80102f94: 56 push %esi +80102f95: 53 push %ebx +80102f96: 83 ec 1c sub $0x1c,%esp + if((p = ((bda[0x0F]<<8)| bda[0x0E]) << 4)){ +80102f99: 0f b6 05 0f 04 00 80 movzbl 0x8000040f,%eax +80102fa0: 0f b6 15 0e 04 00 80 movzbl 0x8000040e,%edx +80102fa7: c1 e0 08 shl $0x8,%eax +80102faa: 09 d0 or %edx,%eax +80102fac: c1 e0 04 shl $0x4,%eax +80102faf: 85 c0 test %eax,%eax +80102fb1: 75 1b jne 80102fce + p = ((bda[0x14]<<8)|bda[0x13])*1024; +80102fb3: 0f b6 05 14 04 00 80 movzbl 0x80000414,%eax +80102fba: 0f b6 15 13 04 00 80 movzbl 0x80000413,%edx +80102fc1: c1 e0 08 shl $0x8,%eax +80102fc4: 09 d0 or %edx,%eax +80102fc6: c1 e0 0a shl $0xa,%eax + if((mp = mpsearch1(p-1024, 1024))) +80102fc9: 2d 00 04 00 00 sub $0x400,%eax + if((mp = mpsearch1(p, 1024))) +80102fce: ba 00 04 00 00 mov $0x400,%edx +80102fd3: e8 48 ff ff ff call 80102f20 +80102fd8: 85 c0 test %eax,%eax +80102fda: 89 c7 mov %eax,%edi +80102fdc: 0f 84 22 01 00 00 je 80103104 + if((mp = mpsearch()) == 0 || mp->physaddr == 0) +80102fe2: 8b 77 04 mov 0x4(%edi),%esi +80102fe5: 85 f6 test %esi,%esi +80102fe7: 0f 84 30 01 00 00 je 8010311d + conf = (struct mpconf*) P2V((uint) mp->physaddr); +80102fed: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax + if(memcmp(conf, "PCMP", 4) != 0) +80102ff3: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) +80102ffa: 00 +80102ffb: c7 44 24 04 1d 73 10 movl $0x8010731d,0x4(%esp) +80103002: 80 +80103003: 89 04 24 mov %eax,(%esp) + conf = (struct mpconf*) P2V((uint) mp->physaddr); +80103006: 89 45 e4 mov %eax,-0x1c(%ebp) + if(memcmp(conf, "PCMP", 4) != 0) +80103009: e8 c2 12 00 00 call 801042d0 +8010300e: 85 c0 test %eax,%eax +80103010: 0f 85 07 01 00 00 jne 8010311d + if(conf->version != 1 && conf->version != 4) +80103016: 0f b6 86 06 00 00 80 movzbl -0x7ffffffa(%esi),%eax +8010301d: 3c 04 cmp $0x4,%al +8010301f: 0f 85 0b 01 00 00 jne 80103130 + if(sum((uchar*)conf, conf->length) != 0) +80103025: 0f b7 86 04 00 00 80 movzwl -0x7ffffffc(%esi),%eax + for(i=0; i + sum = 0; +80103030: 31 c9 xor %ecx,%ecx + for(i=0; i + if(sum((uchar*)conf, conf->length) != 0) +80103049: 84 c9 test %cl,%cl +8010304b: 0f 85 cc 00 00 00 jne 8010311d + struct mp *mp; + struct mpconf *conf; + struct mpproc *proc; + struct mpioapic *ioapic; + + if((conf = mpconfig(&mp)) == 0) +80103051: 8b 45 e4 mov -0x1c(%ebp),%eax +80103054: 85 c0 test %eax,%eax +80103056: 0f 84 c1 00 00 00 je 8010311d + panic("Expect to run on an SMP"); + ismp = 1; + lapic = (uint*)conf->lapicaddr; +8010305c: 8b 86 24 00 00 80 mov -0x7fffffdc(%esi),%eax + ismp = 1; +80103062: bb 01 00 00 00 mov $0x1,%ebx + lapic = (uint*)conf->lapicaddr; +80103067: a3 7c 26 11 80 mov %eax,0x8011267c + for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p +80103084: 0f b6 08 movzbl (%eax),%ecx + switch(*p){ +80103087: 80 f9 04 cmp $0x4,%cl +8010308a: 77 74 ja 80103100 +8010308c: ff 24 8d 5c 73 10 80 jmp *-0x7fef8ca4(,%ecx,4) +80103093: 90 nop +80103094: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + p += sizeof(struct mpioapic); + continue; + case MPBUS: + case MPIOINTR: + case MPLINTR: + p += 8; +80103098: 83 c0 08 add $0x8,%eax + for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p + default: + ismp = 0; + break; + } + } + if(!ismp) +8010309f: 85 db test %ebx,%ebx +801030a1: 0f 84 93 00 00 00 je 8010313a + panic("Didn't find a suitable machine"); + + if(mp->imcrp){ +801030a7: 80 7f 0c 00 cmpb $0x0,0xc(%edi) +801030ab: 74 12 je 801030bf + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +801030ad: ba 22 00 00 00 mov $0x22,%edx +801030b2: b8 70 00 00 00 mov $0x70,%eax +801030b7: ee out %al,(%dx) + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +801030b8: b2 23 mov $0x23,%dl +801030ba: ec in (%dx),%al + // Bochs doesn't support IMCR, so this doesn't run on Bochs. + // But it would on real hardware. + outb(0x22, 0x70); // Select IMCR + outb(0x23, inb(0x23) | 1); // Mask external interrupts. +801030bb: 83 c8 01 or $0x1,%eax + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +801030be: ee out %al,(%dx) + } +} +801030bf: 83 c4 1c add $0x1c,%esp +801030c2: 5b pop %ebx +801030c3: 5e pop %esi +801030c4: 5f pop %edi +801030c5: 5d pop %ebp +801030c6: c3 ret +801030c7: 90 nop + if(ncpu < NCPU) { +801030c8: 8b 35 00 2d 11 80 mov 0x80112d00,%esi +801030ce: 83 fe 07 cmp $0x7,%esi +801030d1: 7f 17 jg 801030ea + cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu +801030d3: 0f b6 48 01 movzbl 0x1(%eax),%ecx +801030d7: 69 f6 b0 00 00 00 imul $0xb0,%esi,%esi + ncpu++; +801030dd: 83 05 00 2d 11 80 01 addl $0x1,0x80112d00 + cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu +801030e4: 88 8e 80 27 11 80 mov %cl,-0x7feed880(%esi) + p += sizeof(struct mpproc); +801030ea: 83 c0 14 add $0x14,%eax + continue; +801030ed: eb 91 jmp 80103080 +801030ef: 90 nop + ioapicid = ioapic->apicno; +801030f0: 0f b6 48 01 movzbl 0x1(%eax),%ecx + p += sizeof(struct mpioapic); +801030f4: 83 c0 08 add $0x8,%eax + ioapicid = ioapic->apicno; +801030f7: 88 0d 60 27 11 80 mov %cl,0x80112760 + continue; +801030fd: eb 81 jmp 80103080 +801030ff: 90 nop + ismp = 0; +80103100: 31 db xor %ebx,%ebx +80103102: eb 83 jmp 80103087 + return mpsearch1(0xF0000, 0x10000); +80103104: ba 00 00 01 00 mov $0x10000,%edx +80103109: b8 00 00 0f 00 mov $0xf0000,%eax +8010310e: e8 0d fe ff ff call 80102f20 + if((mp = mpsearch()) == 0 || mp->physaddr == 0) +80103113: 85 c0 test %eax,%eax + return mpsearch1(0xF0000, 0x10000); +80103115: 89 c7 mov %eax,%edi + if((mp = mpsearch()) == 0 || mp->physaddr == 0) +80103117: 0f 85 c5 fe ff ff jne 80102fe2 + panic("Expect to run on an SMP"); +8010311d: c7 04 24 22 73 10 80 movl $0x80107322,(%esp) +80103124: e8 37 d2 ff ff call 80100360 +80103129: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if(conf->version != 1 && conf->version != 4) +80103130: 3c 01 cmp $0x1,%al +80103132: 0f 84 ed fe ff ff je 80103025 +80103138: eb e3 jmp 8010311d + panic("Didn't find a suitable machine"); +8010313a: c7 04 24 3c 73 10 80 movl $0x8010733c,(%esp) +80103141: e8 1a d2 ff ff call 80100360 +80103146: 66 90 xchg %ax,%ax +80103148: 66 90 xchg %ax,%ax +8010314a: 66 90 xchg %ax,%ax +8010314c: 66 90 xchg %ax,%ax +8010314e: 66 90 xchg %ax,%ax + +80103150 : +#define IO_PIC2 0xA0 // Slave (IRQs 8-15) + +// Don't use the 8259A interrupt controllers. Xv6 assumes SMP hardware. +void +picinit(void) +{ +80103150: 55 push %ebp +80103151: ba 21 00 00 00 mov $0x21,%edx +80103156: 89 e5 mov %esp,%ebp +80103158: b8 ff ff ff ff mov $0xffffffff,%eax +8010315d: ee out %al,(%dx) +8010315e: b2 a1 mov $0xa1,%dl +80103160: ee out %al,(%dx) + // mask all interrupts + outb(IO_PIC1+1, 0xFF); + outb(IO_PIC2+1, 0xFF); +} +80103161: 5d pop %ebp +80103162: c3 ret +80103163: 66 90 xchg %ax,%ax +80103165: 66 90 xchg %ax,%ax +80103167: 66 90 xchg %ax,%ax +80103169: 66 90 xchg %ax,%ax +8010316b: 66 90 xchg %ax,%ax +8010316d: 66 90 xchg %ax,%ax +8010316f: 90 nop + +80103170 : + int writeopen; // write fd is still open +}; + +int +pipealloc(struct file **f0, struct file **f1) +{ +80103170: 55 push %ebp +80103171: 89 e5 mov %esp,%ebp +80103173: 57 push %edi +80103174: 56 push %esi +80103175: 53 push %ebx +80103176: 83 ec 1c sub $0x1c,%esp +80103179: 8b 75 08 mov 0x8(%ebp),%esi +8010317c: 8b 5d 0c mov 0xc(%ebp),%ebx + struct pipe *p; + + p = 0; + *f0 = *f1 = 0; +8010317f: c7 03 00 00 00 00 movl $0x0,(%ebx) +80103185: c7 06 00 00 00 00 movl $0x0,(%esi) + if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0) +8010318b: e8 d0 db ff ff call 80100d60 +80103190: 85 c0 test %eax,%eax +80103192: 89 06 mov %eax,(%esi) +80103194: 0f 84 a4 00 00 00 je 8010323e +8010319a: e8 c1 db ff ff call 80100d60 +8010319f: 85 c0 test %eax,%eax +801031a1: 89 03 mov %eax,(%ebx) +801031a3: 0f 84 87 00 00 00 je 80103230 + goto bad; + if((p = (struct pipe*)kalloc()) == 0) +801031a9: e8 f2 f2 ff ff call 801024a0 +801031ae: 85 c0 test %eax,%eax +801031b0: 89 c7 mov %eax,%edi +801031b2: 74 7c je 80103230 + goto bad; + p->readopen = 1; +801031b4: c7 80 3c 02 00 00 01 movl $0x1,0x23c(%eax) +801031bb: 00 00 00 + p->writeopen = 1; +801031be: c7 80 40 02 00 00 01 movl $0x1,0x240(%eax) +801031c5: 00 00 00 + p->nwrite = 0; +801031c8: c7 80 38 02 00 00 00 movl $0x0,0x238(%eax) +801031cf: 00 00 00 + p->nread = 0; +801031d2: c7 80 34 02 00 00 00 movl $0x0,0x234(%eax) +801031d9: 00 00 00 + initlock(&p->lock, "pipe"); +801031dc: 89 04 24 mov %eax,(%esp) +801031df: c7 44 24 04 70 73 10 movl $0x80107370,0x4(%esp) +801031e6: 80 +801031e7: e8 64 0e 00 00 call 80104050 + (*f0)->type = FD_PIPE; +801031ec: 8b 06 mov (%esi),%eax +801031ee: c7 00 01 00 00 00 movl $0x1,(%eax) + (*f0)->readable = 1; +801031f4: 8b 06 mov (%esi),%eax +801031f6: c6 40 08 01 movb $0x1,0x8(%eax) + (*f0)->writable = 0; +801031fa: 8b 06 mov (%esi),%eax +801031fc: c6 40 09 00 movb $0x0,0x9(%eax) + (*f0)->pipe = p; +80103200: 8b 06 mov (%esi),%eax +80103202: 89 78 0c mov %edi,0xc(%eax) + (*f1)->type = FD_PIPE; +80103205: 8b 03 mov (%ebx),%eax +80103207: c7 00 01 00 00 00 movl $0x1,(%eax) + (*f1)->readable = 0; +8010320d: 8b 03 mov (%ebx),%eax +8010320f: c6 40 08 00 movb $0x0,0x8(%eax) + (*f1)->writable = 1; +80103213: 8b 03 mov (%ebx),%eax +80103215: c6 40 09 01 movb $0x1,0x9(%eax) + (*f1)->pipe = p; +80103219: 8b 03 mov (%ebx),%eax + return 0; +8010321b: 31 db xor %ebx,%ebx + (*f1)->pipe = p; +8010321d: 89 78 0c mov %edi,0xc(%eax) + if(*f0) + fileclose(*f0); + if(*f1) + fileclose(*f1); + return -1; +} +80103220: 83 c4 1c add $0x1c,%esp +80103223: 89 d8 mov %ebx,%eax +80103225: 5b pop %ebx +80103226: 5e pop %esi +80103227: 5f pop %edi +80103228: 5d pop %ebp +80103229: c3 ret +8010322a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if(*f0) +80103230: 8b 06 mov (%esi),%eax +80103232: 85 c0 test %eax,%eax +80103234: 74 08 je 8010323e + fileclose(*f0); +80103236: 89 04 24 mov %eax,(%esp) +80103239: e8 e2 db ff ff call 80100e20 + if(*f1) +8010323e: 8b 03 mov (%ebx),%eax + return -1; +80103240: bb ff ff ff ff mov $0xffffffff,%ebx + if(*f1) +80103245: 85 c0 test %eax,%eax +80103247: 74 d7 je 80103220 + fileclose(*f1); +80103249: 89 04 24 mov %eax,(%esp) +8010324c: e8 cf db ff ff call 80100e20 +} +80103251: 83 c4 1c add $0x1c,%esp +80103254: 89 d8 mov %ebx,%eax +80103256: 5b pop %ebx +80103257: 5e pop %esi +80103258: 5f pop %edi +80103259: 5d pop %ebp +8010325a: c3 ret +8010325b: 90 nop +8010325c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80103260 : + +void +pipeclose(struct pipe *p, int writable) +{ +80103260: 55 push %ebp +80103261: 89 e5 mov %esp,%ebp +80103263: 56 push %esi +80103264: 53 push %ebx +80103265: 83 ec 10 sub $0x10,%esp +80103268: 8b 5d 08 mov 0x8(%ebp),%ebx +8010326b: 8b 75 0c mov 0xc(%ebp),%esi + acquire(&p->lock); +8010326e: 89 1c 24 mov %ebx,(%esp) +80103271: e8 ca 0e 00 00 call 80104140 + if(writable){ +80103276: 85 f6 test %esi,%esi +80103278: 74 3e je 801032b8 + p->writeopen = 0; + wakeup(&p->nread); +8010327a: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax + p->writeopen = 0; +80103280: c7 83 40 02 00 00 00 movl $0x0,0x240(%ebx) +80103287: 00 00 00 + wakeup(&p->nread); +8010328a: 89 04 24 mov %eax,(%esp) +8010328d: e8 fe 0a 00 00 call 80103d90 + } else { + p->readopen = 0; + wakeup(&p->nwrite); + } + if(p->readopen == 0 && p->writeopen == 0){ +80103292: 8b 93 3c 02 00 00 mov 0x23c(%ebx),%edx +80103298: 85 d2 test %edx,%edx +8010329a: 75 0a jne 801032a6 +8010329c: 8b 83 40 02 00 00 mov 0x240(%ebx),%eax +801032a2: 85 c0 test %eax,%eax +801032a4: 74 32 je 801032d8 + release(&p->lock); + kfree((char*)p); + } else + release(&p->lock); +801032a6: 89 5d 08 mov %ebx,0x8(%ebp) +} +801032a9: 83 c4 10 add $0x10,%esp +801032ac: 5b pop %ebx +801032ad: 5e pop %esi +801032ae: 5d pop %ebp + release(&p->lock); +801032af: e9 7c 0f 00 00 jmp 80104230 +801032b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + wakeup(&p->nwrite); +801032b8: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax + p->readopen = 0; +801032be: c7 83 3c 02 00 00 00 movl $0x0,0x23c(%ebx) +801032c5: 00 00 00 + wakeup(&p->nwrite); +801032c8: 89 04 24 mov %eax,(%esp) +801032cb: e8 c0 0a 00 00 call 80103d90 +801032d0: eb c0 jmp 80103292 +801032d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + release(&p->lock); +801032d8: 89 1c 24 mov %ebx,(%esp) +801032db: e8 50 0f 00 00 call 80104230 + kfree((char*)p); +801032e0: 89 5d 08 mov %ebx,0x8(%ebp) +} +801032e3: 83 c4 10 add $0x10,%esp +801032e6: 5b pop %ebx +801032e7: 5e pop %esi +801032e8: 5d pop %ebp + kfree((char*)p); +801032e9: e9 02 f0 ff ff jmp 801022f0 +801032ee: 66 90 xchg %ax,%ax + +801032f0 : + +//PAGEBREAK: 40 +int +pipewrite(struct pipe *p, char *addr, int n) +{ +801032f0: 55 push %ebp +801032f1: 89 e5 mov %esp,%ebp +801032f3: 57 push %edi +801032f4: 56 push %esi +801032f5: 53 push %ebx +801032f6: 83 ec 1c sub $0x1c,%esp +801032f9: 8b 5d 08 mov 0x8(%ebp),%ebx + int i; + + acquire(&p->lock); +801032fc: 89 1c 24 mov %ebx,(%esp) +801032ff: e8 3c 0e 00 00 call 80104140 + for(i = 0; i < n; i++){ +80103304: 8b 4d 10 mov 0x10(%ebp),%ecx +80103307: 85 c9 test %ecx,%ecx +80103309: 0f 8e b2 00 00 00 jle 801033c1 +8010330f: 8b 4d 0c mov 0xc(%ebp),%ecx + while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full + if(p->readopen == 0 || myproc()->killed){ + release(&p->lock); + return -1; + } + wakeup(&p->nread); +80103312: 8d bb 34 02 00 00 lea 0x234(%ebx),%edi +80103318: 8b 83 38 02 00 00 mov 0x238(%ebx),%eax + sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep +8010331e: 8d b3 38 02 00 00 lea 0x238(%ebx),%esi +80103324: 89 4d e4 mov %ecx,-0x1c(%ebp) +80103327: 03 4d 10 add 0x10(%ebp),%ecx +8010332a: 89 4d e0 mov %ecx,-0x20(%ebp) + while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full +8010332d: 8b 8b 34 02 00 00 mov 0x234(%ebx),%ecx +80103333: 81 c1 00 02 00 00 add $0x200,%ecx +80103339: 39 c8 cmp %ecx,%eax +8010333b: 74 38 je 80103375 +8010333d: eb 55 jmp 80103394 +8010333f: 90 nop + if(p->readopen == 0 || myproc()->killed){ +80103340: e8 5b 03 00 00 call 801036a0 +80103345: 8b 40 24 mov 0x24(%eax),%eax +80103348: 85 c0 test %eax,%eax +8010334a: 75 33 jne 8010337f + wakeup(&p->nread); +8010334c: 89 3c 24 mov %edi,(%esp) +8010334f: e8 3c 0a 00 00 call 80103d90 + sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep +80103354: 89 5c 24 04 mov %ebx,0x4(%esp) +80103358: 89 34 24 mov %esi,(%esp) +8010335b: e8 a0 08 00 00 call 80103c00 + while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full +80103360: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax +80103366: 8b 93 38 02 00 00 mov 0x238(%ebx),%edx +8010336c: 05 00 02 00 00 add $0x200,%eax +80103371: 39 c2 cmp %eax,%edx +80103373: 75 23 jne 80103398 + if(p->readopen == 0 || myproc()->killed){ +80103375: 8b 93 3c 02 00 00 mov 0x23c(%ebx),%edx +8010337b: 85 d2 test %edx,%edx +8010337d: 75 c1 jne 80103340 + release(&p->lock); +8010337f: 89 1c 24 mov %ebx,(%esp) +80103382: e8 a9 0e 00 00 call 80104230 + return -1; +80103387: b8 ff ff ff ff mov $0xffffffff,%eax + p->data[p->nwrite++ % PIPESIZE] = addr[i]; + } + wakeup(&p->nread); //DOC: pipewrite-wakeup1 + release(&p->lock); + return n; +} +8010338c: 83 c4 1c add $0x1c,%esp +8010338f: 5b pop %ebx +80103390: 5e pop %esi +80103391: 5f pop %edi +80103392: 5d pop %ebp +80103393: c3 ret + while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full +80103394: 89 c2 mov %eax,%edx +80103396: 66 90 xchg %ax,%ax + p->data[p->nwrite++ % PIPESIZE] = addr[i]; +80103398: 8b 4d e4 mov -0x1c(%ebp),%ecx +8010339b: 8d 42 01 lea 0x1(%edx),%eax +8010339e: 81 e2 ff 01 00 00 and $0x1ff,%edx +801033a4: 89 83 38 02 00 00 mov %eax,0x238(%ebx) +801033aa: 83 45 e4 01 addl $0x1,-0x1c(%ebp) +801033ae: 0f b6 09 movzbl (%ecx),%ecx +801033b1: 88 4c 13 34 mov %cl,0x34(%ebx,%edx,1) + for(i = 0; i < n; i++){ +801033b5: 8b 4d e4 mov -0x1c(%ebp),%ecx +801033b8: 3b 4d e0 cmp -0x20(%ebp),%ecx +801033bb: 0f 85 6c ff ff ff jne 8010332d + wakeup(&p->nread); //DOC: pipewrite-wakeup1 +801033c1: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax +801033c7: 89 04 24 mov %eax,(%esp) +801033ca: e8 c1 09 00 00 call 80103d90 + release(&p->lock); +801033cf: 89 1c 24 mov %ebx,(%esp) +801033d2: e8 59 0e 00 00 call 80104230 + return n; +801033d7: 8b 45 10 mov 0x10(%ebp),%eax +801033da: eb b0 jmp 8010338c +801033dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +801033e0 : + +int +piperead(struct pipe *p, char *addr, int n) +{ +801033e0: 55 push %ebp +801033e1: 89 e5 mov %esp,%ebp +801033e3: 57 push %edi +801033e4: 56 push %esi +801033e5: 53 push %ebx +801033e6: 83 ec 1c sub $0x1c,%esp +801033e9: 8b 75 08 mov 0x8(%ebp),%esi +801033ec: 8b 7d 0c mov 0xc(%ebp),%edi + int i; + + acquire(&p->lock); +801033ef: 89 34 24 mov %esi,(%esp) +801033f2: e8 49 0d 00 00 call 80104140 + while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty +801033f7: 8b 86 34 02 00 00 mov 0x234(%esi),%eax +801033fd: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax +80103403: 75 5b jne 80103460 +80103405: 8b 9e 40 02 00 00 mov 0x240(%esi),%ebx +8010340b: 85 db test %ebx,%ebx +8010340d: 74 51 je 80103460 + if(myproc()->killed){ + release(&p->lock); + return -1; + } + sleep(&p->nread, &p->lock); //DOC: piperead-sleep +8010340f: 8d 9e 34 02 00 00 lea 0x234(%esi),%ebx +80103415: eb 25 jmp 8010343c +80103417: 90 nop +80103418: 89 74 24 04 mov %esi,0x4(%esp) +8010341c: 89 1c 24 mov %ebx,(%esp) +8010341f: e8 dc 07 00 00 call 80103c00 + while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty +80103424: 8b 86 34 02 00 00 mov 0x234(%esi),%eax +8010342a: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax +80103430: 75 2e jne 80103460 +80103432: 8b 96 40 02 00 00 mov 0x240(%esi),%edx +80103438: 85 d2 test %edx,%edx +8010343a: 74 24 je 80103460 + if(myproc()->killed){ +8010343c: e8 5f 02 00 00 call 801036a0 +80103441: 8b 48 24 mov 0x24(%eax),%ecx +80103444: 85 c9 test %ecx,%ecx +80103446: 74 d0 je 80103418 + release(&p->lock); +80103448: 89 34 24 mov %esi,(%esp) +8010344b: e8 e0 0d 00 00 call 80104230 + addr[i] = p->data[p->nread++ % PIPESIZE]; + } + wakeup(&p->nwrite); //DOC: piperead-wakeup + release(&p->lock); + return i; +} +80103450: 83 c4 1c add $0x1c,%esp + return -1; +80103453: b8 ff ff ff ff mov $0xffffffff,%eax +} +80103458: 5b pop %ebx +80103459: 5e pop %esi +8010345a: 5f pop %edi +8010345b: 5d pop %ebp +8010345c: c3 ret +8010345d: 8d 76 00 lea 0x0(%esi),%esi + for(i = 0; i < n; i++){ //DOC: piperead-copy +80103460: 8b 55 10 mov 0x10(%ebp),%edx + if(p->nread == p->nwrite) +80103463: 31 db xor %ebx,%ebx + for(i = 0; i < n; i++){ //DOC: piperead-copy +80103465: 85 d2 test %edx,%edx +80103467: 7f 2b jg 80103494 +80103469: eb 31 jmp 8010349c +8010346b: 90 nop +8010346c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + addr[i] = p->data[p->nread++ % PIPESIZE]; +80103470: 8d 48 01 lea 0x1(%eax),%ecx +80103473: 25 ff 01 00 00 and $0x1ff,%eax +80103478: 89 8e 34 02 00 00 mov %ecx,0x234(%esi) +8010347e: 0f b6 44 06 34 movzbl 0x34(%esi,%eax,1),%eax +80103483: 88 04 1f mov %al,(%edi,%ebx,1) + for(i = 0; i < n; i++){ //DOC: piperead-copy +80103486: 83 c3 01 add $0x1,%ebx +80103489: 3b 5d 10 cmp 0x10(%ebp),%ebx +8010348c: 74 0e je 8010349c + if(p->nread == p->nwrite) +8010348e: 8b 86 34 02 00 00 mov 0x234(%esi),%eax +80103494: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax +8010349a: 75 d4 jne 80103470 + wakeup(&p->nwrite); //DOC: piperead-wakeup +8010349c: 8d 86 38 02 00 00 lea 0x238(%esi),%eax +801034a2: 89 04 24 mov %eax,(%esp) +801034a5: e8 e6 08 00 00 call 80103d90 + release(&p->lock); +801034aa: 89 34 24 mov %esi,(%esp) +801034ad: e8 7e 0d 00 00 call 80104230 +} +801034b2: 83 c4 1c add $0x1c,%esp + return i; +801034b5: 89 d8 mov %ebx,%eax +} +801034b7: 5b pop %ebx +801034b8: 5e pop %esi +801034b9: 5f pop %edi +801034ba: 5d pop %ebp +801034bb: c3 ret +801034bc: 66 90 xchg %ax,%ax +801034be: 66 90 xchg %ax,%ax + +801034c0 : +// If found, change state to EMBRYO and initialize +// state required to run in the kernel. +// Otherwise return 0. +static struct proc* +allocproc(void) +{ +801034c0: 55 push %ebp +801034c1: 89 e5 mov %esp,%ebp +801034c3: 53 push %ebx + struct proc *p; + char *sp; + + acquire(&ptable.lock); + + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) +801034c4: bb 54 2d 11 80 mov $0x80112d54,%ebx +{ +801034c9: 83 ec 14 sub $0x14,%esp + acquire(&ptable.lock); +801034cc: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +801034d3: e8 68 0c 00 00 call 80104140 +801034d8: eb 11 jmp 801034eb +801034da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) +801034e0: 83 eb 80 sub $0xffffff80,%ebx +801034e3: 81 fb 54 4d 11 80 cmp $0x80114d54,%ebx +801034e9: 74 7d je 80103568 + if(p->state == UNUSED) +801034eb: 8b 43 08 mov 0x8(%ebx),%eax +801034ee: 85 c0 test %eax,%eax +801034f0: 75 ee jne 801034e0 + release(&ptable.lock); + return 0; + +found: + p->state = EMBRYO; + p->pid = nextpid++; +801034f2: a1 04 a0 10 80 mov 0x8010a004,%eax + + release(&ptable.lock); +801034f7: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) + p->state = EMBRYO; +801034fe: c7 43 08 01 00 00 00 movl $0x1,0x8(%ebx) + p->pid = nextpid++; +80103505: 8d 50 01 lea 0x1(%eax),%edx +80103508: 89 15 04 a0 10 80 mov %edx,0x8010a004 +8010350e: 89 43 10 mov %eax,0x10(%ebx) + release(&ptable.lock); +80103511: e8 1a 0d 00 00 call 80104230 + + // Allocate kernel stack. + if((p->kstack = kalloc()) == 0){ +80103516: e8 85 ef ff ff call 801024a0 +8010351b: 85 c0 test %eax,%eax +8010351d: 89 43 0c mov %eax,0xc(%ebx) +80103520: 74 5a je 8010357c + return 0; + } + sp = p->kstack + KSTACKSIZE; + + // Leave room for trap frame. + sp -= sizeof *p->tf; +80103522: 8d 90 b4 0f 00 00 lea 0xfb4(%eax),%edx + // Set up new context to start executing at forkret, + // which returns to trapret. + sp -= 4; + *(uint*)sp = (uint)trapret; + + sp -= sizeof *p->context; +80103528: 05 9c 0f 00 00 add $0xf9c,%eax + sp -= sizeof *p->tf; +8010352d: 89 53 18 mov %edx,0x18(%ebx) + *(uint*)sp = (uint)trapret; +80103530: c7 40 14 35 54 10 80 movl $0x80105435,0x14(%eax) + p->context = (struct context*)sp; + memset(p->context, 0, sizeof *p->context); +80103537: c7 44 24 08 14 00 00 movl $0x14,0x8(%esp) +8010353e: 00 +8010353f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +80103546: 00 +80103547: 89 04 24 mov %eax,(%esp) + p->context = (struct context*)sp; +8010354a: 89 43 1c mov %eax,0x1c(%ebx) + memset(p->context, 0, sizeof *p->context); +8010354d: e8 2e 0d 00 00 call 80104280 + p->context->eip = (uint)forkret; +80103552: 8b 43 1c mov 0x1c(%ebx),%eax +80103555: c7 40 10 90 35 10 80 movl $0x80103590,0x10(%eax) + + return p; +8010355c: 89 d8 mov %ebx,%eax +} +8010355e: 83 c4 14 add $0x14,%esp +80103561: 5b pop %ebx +80103562: 5d pop %ebp +80103563: c3 ret +80103564: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + release(&ptable.lock); +80103568: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +8010356f: e8 bc 0c 00 00 call 80104230 +} +80103574: 83 c4 14 add $0x14,%esp + return 0; +80103577: 31 c0 xor %eax,%eax +} +80103579: 5b pop %ebx +8010357a: 5d pop %ebp +8010357b: c3 ret + p->state = UNUSED; +8010357c: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) + return 0; +80103583: eb d9 jmp 8010355e +80103585: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80103589: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80103590 : + +// A fork child's very first scheduling by scheduler() +// will swtch here. "Return" to user space. +void +forkret(void) +{ +80103590: 55 push %ebp +80103591: 89 e5 mov %esp,%ebp +80103593: 83 ec 18 sub $0x18,%esp + static int first = 1; + // Still holding ptable.lock from scheduler. + release(&ptable.lock); +80103596: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +8010359d: e8 8e 0c 00 00 call 80104230 + + if (first) { +801035a2: a1 00 a0 10 80 mov 0x8010a000,%eax +801035a7: 85 c0 test %eax,%eax +801035a9: 75 05 jne 801035b0 + iinit(ROOTDEV); + initlog(ROOTDEV); + } + + // Return to "caller", actually trapret (see allocproc). +} +801035ab: c9 leave +801035ac: c3 ret +801035ad: 8d 76 00 lea 0x0(%esi),%esi + iinit(ROOTDEV); +801035b0: c7 04 24 01 00 00 00 movl $0x1,(%esp) + first = 0; +801035b7: c7 05 00 a0 10 80 00 movl $0x0,0x8010a000 +801035be: 00 00 00 + iinit(ROOTDEV); +801035c1: e8 aa de ff ff call 80101470 + initlog(ROOTDEV); +801035c6: c7 04 24 01 00 00 00 movl $0x1,(%esp) +801035cd: e8 9e f4 ff ff call 80102a70 +} +801035d2: c9 leave +801035d3: c3 ret +801035d4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +801035da: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +801035e0 : +{ +801035e0: 55 push %ebp +801035e1: 89 e5 mov %esp,%ebp +801035e3: 83 ec 18 sub $0x18,%esp + initlock(&ptable.lock, "ptable"); +801035e6: c7 44 24 04 75 73 10 movl $0x80107375,0x4(%esp) +801035ed: 80 +801035ee: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +801035f5: e8 56 0a 00 00 call 80104050 +} +801035fa: c9 leave +801035fb: c3 ret +801035fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80103600 : +{ +80103600: 55 push %ebp +80103601: 89 e5 mov %esp,%ebp +80103603: 56 push %esi +80103604: 53 push %ebx +80103605: 83 ec 10 sub $0x10,%esp + asm volatile("pushfl; popl %0" : "=r" (eflags)); +80103608: 9c pushf +80103609: 58 pop %eax + if(readeflags()&FL_IF) +8010360a: f6 c4 02 test $0x2,%ah +8010360d: 75 57 jne 80103666 + apicid = lapicid(); +8010360f: e8 4c f1 ff ff call 80102760 + for (i = 0; i < ncpu; ++i) { +80103614: 8b 35 00 2d 11 80 mov 0x80112d00,%esi +8010361a: 85 f6 test %esi,%esi +8010361c: 7e 3c jle 8010365a + if (cpus[i].apicid == apicid) +8010361e: 0f b6 15 80 27 11 80 movzbl 0x80112780,%edx +80103625: 39 c2 cmp %eax,%edx +80103627: 74 2d je 80103656 +80103629: b9 30 28 11 80 mov $0x80112830,%ecx + for (i = 0; i < ncpu; ++i) { +8010362e: 31 d2 xor %edx,%edx +80103630: 83 c2 01 add $0x1,%edx +80103633: 39 f2 cmp %esi,%edx +80103635: 74 23 je 8010365a + if (cpus[i].apicid == apicid) +80103637: 0f b6 19 movzbl (%ecx),%ebx +8010363a: 81 c1 b0 00 00 00 add $0xb0,%ecx +80103640: 39 c3 cmp %eax,%ebx +80103642: 75 ec jne 80103630 + return &cpus[i]; +80103644: 69 c2 b0 00 00 00 imul $0xb0,%edx,%eax +} +8010364a: 83 c4 10 add $0x10,%esp +8010364d: 5b pop %ebx +8010364e: 5e pop %esi +8010364f: 5d pop %ebp + return &cpus[i]; +80103650: 05 80 27 11 80 add $0x80112780,%eax +} +80103655: c3 ret + for (i = 0; i < ncpu; ++i) { +80103656: 31 d2 xor %edx,%edx +80103658: eb ea jmp 80103644 + panic("unknown apicid\n"); +8010365a: c7 04 24 7c 73 10 80 movl $0x8010737c,(%esp) +80103661: e8 fa cc ff ff call 80100360 + panic("mycpu called with interrupts enabled\n"); +80103666: c7 04 24 58 74 10 80 movl $0x80107458,(%esp) +8010366d: e8 ee cc ff ff call 80100360 +80103672: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80103679: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80103680 : +cpuid() { +80103680: 55 push %ebp +80103681: 89 e5 mov %esp,%ebp +80103683: 83 ec 08 sub $0x8,%esp + return mycpu()-cpus; +80103686: e8 75 ff ff ff call 80103600 +} +8010368b: c9 leave + return mycpu()-cpus; +8010368c: 2d 80 27 11 80 sub $0x80112780,%eax +80103691: c1 f8 04 sar $0x4,%eax +80103694: 69 c0 a3 8b 2e ba imul $0xba2e8ba3,%eax,%eax +} +8010369a: c3 ret +8010369b: 90 nop +8010369c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +801036a0 : +myproc(void) { +801036a0: 55 push %ebp +801036a1: 89 e5 mov %esp,%ebp +801036a3: 53 push %ebx +801036a4: 83 ec 04 sub $0x4,%esp + pushcli(); +801036a7: e8 54 0a 00 00 call 80104100 + c = mycpu(); +801036ac: e8 4f ff ff ff call 80103600 + p = c->proc; +801036b1: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx + popcli(); +801036b7: e8 04 0b 00 00 call 801041c0 +} +801036bc: 83 c4 04 add $0x4,%esp +801036bf: 89 d8 mov %ebx,%eax +801036c1: 5b pop %ebx +801036c2: 5d pop %ebp +801036c3: c3 ret +801036c4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +801036ca: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +801036d0 : +{ +801036d0: 55 push %ebp +801036d1: 89 e5 mov %esp,%ebp +801036d3: 53 push %ebx +801036d4: 83 ec 14 sub $0x14,%esp + p = allocproc(); +801036d7: e8 e4 fd ff ff call 801034c0 +801036dc: 89 c3 mov %eax,%ebx + initproc = p; +801036de: a3 b8 a5 10 80 mov %eax,0x8010a5b8 + if((p->pgdir = setupkvm()) == 0) +801036e3: e8 68 33 00 00 call 80106a50 +801036e8: 85 c0 test %eax,%eax +801036ea: 89 43 04 mov %eax,0x4(%ebx) +801036ed: 0f 84 d4 00 00 00 je 801037c7 + inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size); +801036f3: 89 04 24 mov %eax,(%esp) +801036f6: c7 44 24 08 2c 00 00 movl $0x2c,0x8(%esp) +801036fd: 00 +801036fe: c7 44 24 04 60 a4 10 movl $0x8010a460,0x4(%esp) +80103705: 80 +80103706: e8 55 30 00 00 call 80106760 + p->sz = PGSIZE; +8010370b: c7 03 00 10 00 00 movl $0x1000,(%ebx) + memset(p->tf, 0, sizeof(*p->tf)); +80103711: c7 44 24 08 4c 00 00 movl $0x4c,0x8(%esp) +80103718: 00 +80103719: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +80103720: 00 +80103721: 8b 43 18 mov 0x18(%ebx),%eax +80103724: 89 04 24 mov %eax,(%esp) +80103727: e8 54 0b 00 00 call 80104280 + p->tf->cs = (SEG_UCODE << 3) | DPL_USER; +8010372c: 8b 43 18 mov 0x18(%ebx),%eax +8010372f: ba 1b 00 00 00 mov $0x1b,%edx + p->tf->ds = (SEG_UDATA << 3) | DPL_USER; +80103734: b9 23 00 00 00 mov $0x23,%ecx + p->tf->cs = (SEG_UCODE << 3) | DPL_USER; +80103739: 66 89 50 3c mov %dx,0x3c(%eax) + p->tf->ds = (SEG_UDATA << 3) | DPL_USER; +8010373d: 8b 43 18 mov 0x18(%ebx),%eax +80103740: 66 89 48 2c mov %cx,0x2c(%eax) + p->tf->es = p->tf->ds; +80103744: 8b 43 18 mov 0x18(%ebx),%eax +80103747: 0f b7 50 2c movzwl 0x2c(%eax),%edx +8010374b: 66 89 50 28 mov %dx,0x28(%eax) + p->tf->ss = p->tf->ds; +8010374f: 8b 43 18 mov 0x18(%ebx),%eax +80103752: 0f b7 50 2c movzwl 0x2c(%eax),%edx +80103756: 66 89 50 48 mov %dx,0x48(%eax) + p->tf->eflags = FL_IF; +8010375a: 8b 43 18 mov 0x18(%ebx),%eax +8010375d: c7 40 40 00 02 00 00 movl $0x200,0x40(%eax) + p->tf->esp = PGSIZE; +80103764: 8b 43 18 mov 0x18(%ebx),%eax +80103767: c7 40 44 00 10 00 00 movl $0x1000,0x44(%eax) + p->tf->eip = 0; // beginning of initcode.S +8010376e: 8b 43 18 mov 0x18(%ebx),%eax +80103771: c7 40 38 00 00 00 00 movl $0x0,0x38(%eax) + safestrcpy(p->name, "initcode", sizeof(p->name)); +80103778: 8d 43 6c lea 0x6c(%ebx),%eax +8010377b: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) +80103782: 00 +80103783: c7 44 24 04 a5 73 10 movl $0x801073a5,0x4(%esp) +8010378a: 80 +8010378b: 89 04 24 mov %eax,(%esp) +8010378e: e8 cd 0c 00 00 call 80104460 + p->cwd = namei("/"); +80103793: c7 04 24 ae 73 10 80 movl $0x801073ae,(%esp) +8010379a: e8 61 e7 ff ff call 80101f00 +8010379f: 89 43 68 mov %eax,0x68(%ebx) + acquire(&ptable.lock); +801037a2: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +801037a9: e8 92 09 00 00 call 80104140 + p->state = RUNNABLE; +801037ae: c7 43 08 03 00 00 00 movl $0x3,0x8(%ebx) + release(&ptable.lock); +801037b5: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +801037bc: e8 6f 0a 00 00 call 80104230 +} +801037c1: 83 c4 14 add $0x14,%esp +801037c4: 5b pop %ebx +801037c5: 5d pop %ebp +801037c6: c3 ret + panic("userinit: out of memory?"); +801037c7: c7 04 24 8c 73 10 80 movl $0x8010738c,(%esp) +801037ce: e8 8d cb ff ff call 80100360 +801037d3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +801037d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +801037e0 : +{ +801037e0: 55 push %ebp +801037e1: 89 e5 mov %esp,%ebp +801037e3: 56 push %esi +801037e4: 53 push %ebx +801037e5: 83 ec 10 sub $0x10,%esp +801037e8: 8b 75 08 mov 0x8(%ebp),%esi + struct proc *curproc = myproc(); +801037eb: e8 b0 fe ff ff call 801036a0 + if(n > 0){ +801037f0: 83 fe 00 cmp $0x0,%esi + struct proc *curproc = myproc(); +801037f3: 89 c3 mov %eax,%ebx + sz = curproc->sz; +801037f5: 8b 00 mov (%eax),%eax + if(n > 0){ +801037f7: 7e 2f jle 80103828 + if((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0) +801037f9: 01 c6 add %eax,%esi +801037fb: 89 74 24 08 mov %esi,0x8(%esp) +801037ff: 89 44 24 04 mov %eax,0x4(%esp) +80103803: 8b 43 04 mov 0x4(%ebx),%eax +80103806: 89 04 24 mov %eax,(%esp) +80103809: e8 92 30 00 00 call 801068a0 +8010380e: 85 c0 test %eax,%eax +80103810: 74 36 je 80103848 + curproc->sz = sz; +80103812: 89 03 mov %eax,(%ebx) + switchuvm(curproc); +80103814: 89 1c 24 mov %ebx,(%esp) +80103817: e8 34 2e 00 00 call 80106650 + return 0; +8010381c: 31 c0 xor %eax,%eax +} +8010381e: 83 c4 10 add $0x10,%esp +80103821: 5b pop %ebx +80103822: 5e pop %esi +80103823: 5d pop %ebp +80103824: c3 ret +80103825: 8d 76 00 lea 0x0(%esi),%esi + } else if(n < 0){ +80103828: 74 e8 je 80103812 + if((sz = deallocuvm(curproc->pgdir, sz, sz + n)) == 0) +8010382a: 01 c6 add %eax,%esi +8010382c: 89 74 24 08 mov %esi,0x8(%esp) +80103830: 89 44 24 04 mov %eax,0x4(%esp) +80103834: 8b 43 04 mov 0x4(%ebx),%eax +80103837: 89 04 24 mov %eax,(%esp) +8010383a: e8 71 31 00 00 call 801069b0 +8010383f: 85 c0 test %eax,%eax +80103841: 75 cf jne 80103812 +80103843: 90 nop +80103844: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; +80103848: b8 ff ff ff ff mov $0xffffffff,%eax +8010384d: eb cf jmp 8010381e +8010384f: 90 nop + +80103850 : +{ +80103850: 55 push %ebp +80103851: 89 e5 mov %esp,%ebp +80103853: 57 push %edi +80103854: 56 push %esi +80103855: 53 push %ebx +80103856: 83 ec 1c sub $0x1c,%esp + struct proc *curproc = myproc(); +80103859: e8 42 fe ff ff call 801036a0 +8010385e: 89 c3 mov %eax,%ebx + if((np = allocproc()) == 0){ +80103860: e8 5b fc ff ff call 801034c0 +80103865: 85 c0 test %eax,%eax +80103867: 89 c7 mov %eax,%edi +80103869: 89 45 e4 mov %eax,-0x1c(%ebp) +8010386c: 0f 84 c4 00 00 00 je 80103936 + if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz, curproc->num_pages)) == 0){ +80103872: 8b 43 7c mov 0x7c(%ebx),%eax +80103875: 89 44 24 08 mov %eax,0x8(%esp) +80103879: 8b 03 mov (%ebx),%eax +8010387b: 89 44 24 04 mov %eax,0x4(%esp) +8010387f: 8b 43 04 mov 0x4(%ebx),%eax +80103882: 89 04 24 mov %eax,(%esp) +80103885: e8 a6 32 00 00 call 80106b30 +8010388a: 85 c0 test %eax,%eax +8010388c: 89 47 04 mov %eax,0x4(%edi) +8010388f: 0f 84 a8 00 00 00 je 8010393d + np->sz = curproc->sz; +80103895: 8b 03 mov (%ebx),%eax +80103897: 8b 4d e4 mov -0x1c(%ebp),%ecx +8010389a: 89 01 mov %eax,(%ecx) + *np->tf = *curproc->tf; +8010389c: 8b 79 18 mov 0x18(%ecx),%edi +8010389f: 89 c8 mov %ecx,%eax + np->parent = curproc; +801038a1: 89 59 14 mov %ebx,0x14(%ecx) + *np->tf = *curproc->tf; +801038a4: 8b 73 18 mov 0x18(%ebx),%esi +801038a7: b9 13 00 00 00 mov $0x13,%ecx +801038ac: f3 a5 rep movsl %ds:(%esi),%es:(%edi) + for(i = 0; i < NOFILE; i++) +801038ae: 31 f6 xor %esi,%esi + np->tf->eax = 0; +801038b0: 8b 40 18 mov 0x18(%eax),%eax +801038b3: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax) +801038ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if(curproc->ofile[i]) +801038c0: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax +801038c4: 85 c0 test %eax,%eax +801038c6: 74 0f je 801038d7 + np->ofile[i] = filedup(curproc->ofile[i]); +801038c8: 89 04 24 mov %eax,(%esp) +801038cb: e8 00 d5 ff ff call 80100dd0 +801038d0: 8b 55 e4 mov -0x1c(%ebp),%edx +801038d3: 89 44 b2 28 mov %eax,0x28(%edx,%esi,4) + for(i = 0; i < NOFILE; i++) +801038d7: 83 c6 01 add $0x1,%esi +801038da: 83 fe 10 cmp $0x10,%esi +801038dd: 75 e1 jne 801038c0 + np->cwd = idup(curproc->cwd); +801038df: 8b 43 68 mov 0x68(%ebx),%eax + safestrcpy(np->name, curproc->name, sizeof(curproc->name)); +801038e2: 83 c3 6c add $0x6c,%ebx + np->cwd = idup(curproc->cwd); +801038e5: 89 04 24 mov %eax,(%esp) +801038e8: e8 93 dd ff ff call 80101680 +801038ed: 8b 7d e4 mov -0x1c(%ebp),%edi +801038f0: 89 47 68 mov %eax,0x68(%edi) + safestrcpy(np->name, curproc->name, sizeof(curproc->name)); +801038f3: 8d 47 6c lea 0x6c(%edi),%eax +801038f6: 89 5c 24 04 mov %ebx,0x4(%esp) +801038fa: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) +80103901: 00 +80103902: 89 04 24 mov %eax,(%esp) +80103905: e8 56 0b 00 00 call 80104460 + pid = np->pid; +8010390a: 8b 5f 10 mov 0x10(%edi),%ebx + acquire(&ptable.lock); +8010390d: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +80103914: e8 27 08 00 00 call 80104140 + np->state = RUNNABLE; +80103919: c7 47 08 03 00 00 00 movl $0x3,0x8(%edi) + release(&ptable.lock); +80103920: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +80103927: e8 04 09 00 00 call 80104230 + return pid; +8010392c: 89 d8 mov %ebx,%eax +} +8010392e: 83 c4 1c add $0x1c,%esp +80103931: 5b pop %ebx +80103932: 5e pop %esi +80103933: 5f pop %edi +80103934: 5d pop %ebp +80103935: c3 ret + return -1; +80103936: b8 ff ff ff ff mov $0xffffffff,%eax +8010393b: eb f1 jmp 8010392e + kfree(np->kstack); +8010393d: 8b 7d e4 mov -0x1c(%ebp),%edi +80103940: 8b 47 0c mov 0xc(%edi),%eax +80103943: 89 04 24 mov %eax,(%esp) +80103946: e8 a5 e9 ff ff call 801022f0 + return -1; +8010394b: b8 ff ff ff ff mov $0xffffffff,%eax + np->kstack = 0; +80103950: c7 47 0c 00 00 00 00 movl $0x0,0xc(%edi) + np->state = UNUSED; +80103957: c7 47 08 00 00 00 00 movl $0x0,0x8(%edi) + return -1; +8010395e: eb ce jmp 8010392e + +80103960 : +{ +80103960: 55 push %ebp +80103961: 89 e5 mov %esp,%ebp +80103963: 57 push %edi +80103964: 56 push %esi +80103965: 53 push %ebx +80103966: 83 ec 1c sub $0x1c,%esp + struct cpu *c = mycpu(); +80103969: e8 92 fc ff ff call 80103600 +8010396e: 89 c6 mov %eax,%esi + c->proc = 0; +80103970: c7 80 ac 00 00 00 00 movl $0x0,0xac(%eax) +80103977: 00 00 00 +8010397a: 8d 78 04 lea 0x4(%eax),%edi +8010397d: 8d 76 00 lea 0x0(%esi),%esi + asm volatile("sti"); +80103980: fb sti + acquire(&ptable.lock); +80103981: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ +80103988: bb 54 2d 11 80 mov $0x80112d54,%ebx + acquire(&ptable.lock); +8010398d: e8 ae 07 00 00 call 80104140 +80103992: eb 0f jmp 801039a3 +80103994: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ +80103998: 83 eb 80 sub $0xffffff80,%ebx +8010399b: 81 fb 54 4d 11 80 cmp $0x80114d54,%ebx +801039a1: 74 45 je 801039e8 + if(p->state != RUNNABLE) +801039a3: 83 7b 08 03 cmpl $0x3,0x8(%ebx) +801039a7: 75 ef jne 80103998 + c->proc = p; +801039a9: 89 9e ac 00 00 00 mov %ebx,0xac(%esi) + switchuvm(p); +801039af: 89 1c 24 mov %ebx,(%esp) + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ +801039b2: 83 eb 80 sub $0xffffff80,%ebx + switchuvm(p); +801039b5: e8 96 2c 00 00 call 80106650 + swtch(&(c->scheduler), p->context); +801039ba: 8b 43 9c mov -0x64(%ebx),%eax + p->state = RUNNING; +801039bd: c7 43 88 04 00 00 00 movl $0x4,-0x78(%ebx) + swtch(&(c->scheduler), p->context); +801039c4: 89 3c 24 mov %edi,(%esp) +801039c7: 89 44 24 04 mov %eax,0x4(%esp) +801039cb: e8 eb 0a 00 00 call 801044bb + switchkvm(); +801039d0: e8 5b 2c 00 00 call 80106630 + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ +801039d5: 81 fb 54 4d 11 80 cmp $0x80114d54,%ebx + c->proc = 0; +801039db: c7 86 ac 00 00 00 00 movl $0x0,0xac(%esi) +801039e2: 00 00 00 + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ +801039e5: 75 bc jne 801039a3 +801039e7: 90 nop + release(&ptable.lock); +801039e8: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +801039ef: e8 3c 08 00 00 call 80104230 + } +801039f4: eb 8a jmp 80103980 +801039f6: 8d 76 00 lea 0x0(%esi),%esi +801039f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80103a00 : +{ +80103a00: 55 push %ebp +80103a01: 89 e5 mov %esp,%ebp +80103a03: 56 push %esi +80103a04: 53 push %ebx +80103a05: 83 ec 10 sub $0x10,%esp + struct proc *p = myproc(); +80103a08: e8 93 fc ff ff call 801036a0 + if(!holding(&ptable.lock)) +80103a0d: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) + struct proc *p = myproc(); +80103a14: 89 c3 mov %eax,%ebx + if(!holding(&ptable.lock)) +80103a16: e8 b5 06 00 00 call 801040d0 +80103a1b: 85 c0 test %eax,%eax +80103a1d: 74 4f je 80103a6e + if(mycpu()->ncli != 1) +80103a1f: e8 dc fb ff ff call 80103600 +80103a24: 83 b8 a4 00 00 00 01 cmpl $0x1,0xa4(%eax) +80103a2b: 75 65 jne 80103a92 + if(p->state == RUNNING) +80103a2d: 83 7b 08 04 cmpl $0x4,0x8(%ebx) +80103a31: 74 53 je 80103a86 + asm volatile("pushfl; popl %0" : "=r" (eflags)); +80103a33: 9c pushf +80103a34: 58 pop %eax + if(readeflags()&FL_IF) +80103a35: f6 c4 02 test $0x2,%ah +80103a38: 75 40 jne 80103a7a + intena = mycpu()->intena; +80103a3a: e8 c1 fb ff ff call 80103600 + swtch(&p->context, mycpu()->scheduler); +80103a3f: 83 c3 1c add $0x1c,%ebx + intena = mycpu()->intena; +80103a42: 8b b0 a8 00 00 00 mov 0xa8(%eax),%esi + swtch(&p->context, mycpu()->scheduler); +80103a48: e8 b3 fb ff ff call 80103600 +80103a4d: 8b 40 04 mov 0x4(%eax),%eax +80103a50: 89 1c 24 mov %ebx,(%esp) +80103a53: 89 44 24 04 mov %eax,0x4(%esp) +80103a57: e8 5f 0a 00 00 call 801044bb + mycpu()->intena = intena; +80103a5c: e8 9f fb ff ff call 80103600 +80103a61: 89 b0 a8 00 00 00 mov %esi,0xa8(%eax) +} +80103a67: 83 c4 10 add $0x10,%esp +80103a6a: 5b pop %ebx +80103a6b: 5e pop %esi +80103a6c: 5d pop %ebp +80103a6d: c3 ret + panic("sched ptable.lock"); +80103a6e: c7 04 24 b0 73 10 80 movl $0x801073b0,(%esp) +80103a75: e8 e6 c8 ff ff call 80100360 + panic("sched interruptible"); +80103a7a: c7 04 24 dc 73 10 80 movl $0x801073dc,(%esp) +80103a81: e8 da c8 ff ff call 80100360 + panic("sched running"); +80103a86: c7 04 24 ce 73 10 80 movl $0x801073ce,(%esp) +80103a8d: e8 ce c8 ff ff call 80100360 + panic("sched locks"); +80103a92: c7 04 24 c2 73 10 80 movl $0x801073c2,(%esp) +80103a99: e8 c2 c8 ff ff call 80100360 +80103a9e: 66 90 xchg %ax,%ax + +80103aa0 : +{ +80103aa0: 55 push %ebp +80103aa1: 89 e5 mov %esp,%ebp +80103aa3: 56 push %esi + if(curproc == initproc) +80103aa4: 31 f6 xor %esi,%esi +{ +80103aa6: 53 push %ebx +80103aa7: 83 ec 10 sub $0x10,%esp + struct proc *curproc = myproc(); +80103aaa: e8 f1 fb ff ff call 801036a0 + if(curproc == initproc) +80103aaf: 3b 05 b8 a5 10 80 cmp 0x8010a5b8,%eax + struct proc *curproc = myproc(); +80103ab5: 89 c3 mov %eax,%ebx + if(curproc == initproc) +80103ab7: 0f 84 ea 00 00 00 je 80103ba7 +80103abd: 8d 76 00 lea 0x0(%esi),%esi + if(curproc->ofile[fd]){ +80103ac0: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax +80103ac4: 85 c0 test %eax,%eax +80103ac6: 74 10 je 80103ad8 + fileclose(curproc->ofile[fd]); +80103ac8: 89 04 24 mov %eax,(%esp) +80103acb: e8 50 d3 ff ff call 80100e20 + curproc->ofile[fd] = 0; +80103ad0: c7 44 b3 28 00 00 00 movl $0x0,0x28(%ebx,%esi,4) +80103ad7: 00 + for(fd = 0; fd < NOFILE; fd++){ +80103ad8: 83 c6 01 add $0x1,%esi +80103adb: 83 fe 10 cmp $0x10,%esi +80103ade: 75 e0 jne 80103ac0 + begin_op(); +80103ae0: e8 2b f0 ff ff call 80102b10 + iput(curproc->cwd); +80103ae5: 8b 43 68 mov 0x68(%ebx),%eax +80103ae8: 89 04 24 mov %eax,(%esp) +80103aeb: e8 e0 dc ff ff call 801017d0 + end_op(); +80103af0: e8 8b f0 ff ff call 80102b80 + curproc->cwd = 0; +80103af5: c7 43 68 00 00 00 00 movl $0x0,0x68(%ebx) + acquire(&ptable.lock); +80103afc: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +80103b03: e8 38 06 00 00 call 80104140 + wakeup1(curproc->parent); +80103b08: 8b 43 14 mov 0x14(%ebx),%eax +static void +wakeup1(void *chan) +{ + struct proc *p; + + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) +80103b0b: ba 54 2d 11 80 mov $0x80112d54,%edx +80103b10: eb 11 jmp 80103b23 +80103b12: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80103b18: 83 ea 80 sub $0xffffff80,%edx +80103b1b: 81 fa 54 4d 11 80 cmp $0x80114d54,%edx +80103b21: 74 1d je 80103b40 + if(p->state == SLEEPING && p->chan == chan) +80103b23: 83 7a 08 02 cmpl $0x2,0x8(%edx) +80103b27: 75 ef jne 80103b18 +80103b29: 3b 42 20 cmp 0x20(%edx),%eax +80103b2c: 75 ea jne 80103b18 + p->state = RUNNABLE; +80103b2e: c7 42 08 03 00 00 00 movl $0x3,0x8(%edx) + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) +80103b35: 83 ea 80 sub $0xffffff80,%edx +80103b38: 81 fa 54 4d 11 80 cmp $0x80114d54,%edx +80103b3e: 75 e3 jne 80103b23 + p->parent = initproc; +80103b40: a1 b8 a5 10 80 mov 0x8010a5b8,%eax +80103b45: b9 54 2d 11 80 mov $0x80112d54,%ecx +80103b4a: eb 0f jmp 80103b5b +80103b4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ +80103b50: 83 e9 80 sub $0xffffff80,%ecx +80103b53: 81 f9 54 4d 11 80 cmp $0x80114d54,%ecx +80103b59: 74 34 je 80103b8f + if(p->parent == curproc){ +80103b5b: 39 59 14 cmp %ebx,0x14(%ecx) +80103b5e: 75 f0 jne 80103b50 + if(p->state == ZOMBIE) +80103b60: 83 79 08 05 cmpl $0x5,0x8(%ecx) + p->parent = initproc; +80103b64: 89 41 14 mov %eax,0x14(%ecx) + if(p->state == ZOMBIE) +80103b67: 75 e7 jne 80103b50 +80103b69: ba 54 2d 11 80 mov $0x80112d54,%edx +80103b6e: eb 0b jmp 80103b7b + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) +80103b70: 83 ea 80 sub $0xffffff80,%edx +80103b73: 81 fa 54 4d 11 80 cmp $0x80114d54,%edx +80103b79: 74 d5 je 80103b50 + if(p->state == SLEEPING && p->chan == chan) +80103b7b: 83 7a 08 02 cmpl $0x2,0x8(%edx) +80103b7f: 75 ef jne 80103b70 +80103b81: 3b 42 20 cmp 0x20(%edx),%eax +80103b84: 75 ea jne 80103b70 + p->state = RUNNABLE; +80103b86: c7 42 08 03 00 00 00 movl $0x3,0x8(%edx) +80103b8d: eb e1 jmp 80103b70 + curproc->state = ZOMBIE; +80103b8f: c7 43 08 05 00 00 00 movl $0x5,0x8(%ebx) + sched(); +80103b96: e8 65 fe ff ff call 80103a00 + panic("zombie exit"); +80103b9b: c7 04 24 fd 73 10 80 movl $0x801073fd,(%esp) +80103ba2: e8 b9 c7 ff ff call 80100360 + panic("init exiting"); +80103ba7: c7 04 24 f0 73 10 80 movl $0x801073f0,(%esp) +80103bae: e8 ad c7 ff ff call 80100360 +80103bb3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80103bb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80103bc0 : +{ +80103bc0: 55 push %ebp +80103bc1: 89 e5 mov %esp,%ebp +80103bc3: 83 ec 18 sub $0x18,%esp + acquire(&ptable.lock); //DOC: yieldlock +80103bc6: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +80103bcd: e8 6e 05 00 00 call 80104140 + myproc()->state = RUNNABLE; +80103bd2: e8 c9 fa ff ff call 801036a0 +80103bd7: c7 40 08 03 00 00 00 movl $0x3,0x8(%eax) + sched(); +80103bde: e8 1d fe ff ff call 80103a00 + release(&ptable.lock); +80103be3: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +80103bea: e8 41 06 00 00 call 80104230 +} +80103bef: c9 leave +80103bf0: c3 ret +80103bf1: eb 0d jmp 80103c00 +80103bf3: 90 nop +80103bf4: 90 nop +80103bf5: 90 nop +80103bf6: 90 nop +80103bf7: 90 nop +80103bf8: 90 nop +80103bf9: 90 nop +80103bfa: 90 nop +80103bfb: 90 nop +80103bfc: 90 nop +80103bfd: 90 nop +80103bfe: 90 nop +80103bff: 90 nop + +80103c00 : +{ +80103c00: 55 push %ebp +80103c01: 89 e5 mov %esp,%ebp +80103c03: 57 push %edi +80103c04: 56 push %esi +80103c05: 53 push %ebx +80103c06: 83 ec 1c sub $0x1c,%esp +80103c09: 8b 7d 08 mov 0x8(%ebp),%edi +80103c0c: 8b 75 0c mov 0xc(%ebp),%esi + struct proc *p = myproc(); +80103c0f: e8 8c fa ff ff call 801036a0 + if(p == 0) +80103c14: 85 c0 test %eax,%eax + struct proc *p = myproc(); +80103c16: 89 c3 mov %eax,%ebx + if(p == 0) +80103c18: 0f 84 7c 00 00 00 je 80103c9a + if(lk == 0) +80103c1e: 85 f6 test %esi,%esi +80103c20: 74 6c je 80103c8e + if(lk != &ptable.lock){ //DOC: sleeplock0 +80103c22: 81 fe 20 2d 11 80 cmp $0x80112d20,%esi +80103c28: 74 46 je 80103c70 + acquire(&ptable.lock); //DOC: sleeplock1 +80103c2a: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +80103c31: e8 0a 05 00 00 call 80104140 + release(lk); +80103c36: 89 34 24 mov %esi,(%esp) +80103c39: e8 f2 05 00 00 call 80104230 + p->chan = chan; +80103c3e: 89 7b 20 mov %edi,0x20(%ebx) + p->state = SLEEPING; +80103c41: c7 43 08 02 00 00 00 movl $0x2,0x8(%ebx) + sched(); +80103c48: e8 b3 fd ff ff call 80103a00 + p->chan = 0; +80103c4d: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) + release(&ptable.lock); +80103c54: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +80103c5b: e8 d0 05 00 00 call 80104230 + acquire(lk); +80103c60: 89 75 08 mov %esi,0x8(%ebp) +} +80103c63: 83 c4 1c add $0x1c,%esp +80103c66: 5b pop %ebx +80103c67: 5e pop %esi +80103c68: 5f pop %edi +80103c69: 5d pop %ebp + acquire(lk); +80103c6a: e9 d1 04 00 00 jmp 80104140 +80103c6f: 90 nop + p->chan = chan; +80103c70: 89 78 20 mov %edi,0x20(%eax) + p->state = SLEEPING; +80103c73: c7 40 08 02 00 00 00 movl $0x2,0x8(%eax) + sched(); +80103c7a: e8 81 fd ff ff call 80103a00 + p->chan = 0; +80103c7f: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) +} +80103c86: 83 c4 1c add $0x1c,%esp +80103c89: 5b pop %ebx +80103c8a: 5e pop %esi +80103c8b: 5f pop %edi +80103c8c: 5d pop %ebp +80103c8d: c3 ret + panic("sleep without lk"); +80103c8e: c7 04 24 0f 74 10 80 movl $0x8010740f,(%esp) +80103c95: e8 c6 c6 ff ff call 80100360 + panic("sleep"); +80103c9a: c7 04 24 09 74 10 80 movl $0x80107409,(%esp) +80103ca1: e8 ba c6 ff ff call 80100360 +80103ca6: 8d 76 00 lea 0x0(%esi),%esi +80103ca9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80103cb0 : +{ +80103cb0: 55 push %ebp +80103cb1: 89 e5 mov %esp,%ebp +80103cb3: 56 push %esi +80103cb4: 53 push %ebx +80103cb5: 83 ec 10 sub $0x10,%esp + struct proc *curproc = myproc(); +80103cb8: e8 e3 f9 ff ff call 801036a0 + acquire(&ptable.lock); +80103cbd: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) + struct proc *curproc = myproc(); +80103cc4: 89 c6 mov %eax,%esi + acquire(&ptable.lock); +80103cc6: e8 75 04 00 00 call 80104140 + havekids = 0; +80103ccb: 31 c0 xor %eax,%eax + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ +80103ccd: bb 54 2d 11 80 mov $0x80112d54,%ebx +80103cd2: eb 0f jmp 80103ce3 +80103cd4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80103cd8: 83 eb 80 sub $0xffffff80,%ebx +80103cdb: 81 fb 54 4d 11 80 cmp $0x80114d54,%ebx +80103ce1: 74 1d je 80103d00 + if(p->parent != curproc) +80103ce3: 39 73 14 cmp %esi,0x14(%ebx) +80103ce6: 75 f0 jne 80103cd8 + if(p->state == ZOMBIE){ +80103ce8: 83 7b 08 05 cmpl $0x5,0x8(%ebx) +80103cec: 74 2f je 80103d1d + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ +80103cee: 83 eb 80 sub $0xffffff80,%ebx + havekids = 1; +80103cf1: b8 01 00 00 00 mov $0x1,%eax + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ +80103cf6: 81 fb 54 4d 11 80 cmp $0x80114d54,%ebx +80103cfc: 75 e5 jne 80103ce3 +80103cfe: 66 90 xchg %ax,%ax + if(!havekids || curproc->killed){ +80103d00: 85 c0 test %eax,%eax +80103d02: 74 6e je 80103d72 +80103d04: 8b 46 24 mov 0x24(%esi),%eax +80103d07: 85 c0 test %eax,%eax +80103d09: 75 67 jne 80103d72 + sleep(curproc, &ptable.lock); //DOC: wait-sleep +80103d0b: c7 44 24 04 20 2d 11 movl $0x80112d20,0x4(%esp) +80103d12: 80 +80103d13: 89 34 24 mov %esi,(%esp) +80103d16: e8 e5 fe ff ff call 80103c00 + } +80103d1b: eb ae jmp 80103ccb + kfree(p->kstack); +80103d1d: 8b 43 0c mov 0xc(%ebx),%eax + pid = p->pid; +80103d20: 8b 73 10 mov 0x10(%ebx),%esi + kfree(p->kstack); +80103d23: 89 04 24 mov %eax,(%esp) +80103d26: e8 c5 e5 ff ff call 801022f0 + freevm(p->pgdir); +80103d2b: 8b 43 04 mov 0x4(%ebx),%eax + p->kstack = 0; +80103d2e: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) + freevm(p->pgdir); +80103d35: 89 04 24 mov %eax,(%esp) +80103d38: e8 93 2c 00 00 call 801069d0 + release(&ptable.lock); +80103d3d: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) + p->pid = 0; +80103d44: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx) + p->parent = 0; +80103d4b: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) + p->name[0] = 0; +80103d52: c6 43 6c 00 movb $0x0,0x6c(%ebx) + p->killed = 0; +80103d56: c7 43 24 00 00 00 00 movl $0x0,0x24(%ebx) + p->state = UNUSED; +80103d5d: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) + release(&ptable.lock); +80103d64: e8 c7 04 00 00 call 80104230 +} +80103d69: 83 c4 10 add $0x10,%esp + return pid; +80103d6c: 89 f0 mov %esi,%eax +} +80103d6e: 5b pop %ebx +80103d6f: 5e pop %esi +80103d70: 5d pop %ebp +80103d71: c3 ret + release(&ptable.lock); +80103d72: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +80103d79: e8 b2 04 00 00 call 80104230 +} +80103d7e: 83 c4 10 add $0x10,%esp + return -1; +80103d81: b8 ff ff ff ff mov $0xffffffff,%eax +} +80103d86: 5b pop %ebx +80103d87: 5e pop %esi +80103d88: 5d pop %ebp +80103d89: c3 ret +80103d8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80103d90 : +} + +// Wake up all processes sleeping on chan. +void +wakeup(void *chan) +{ +80103d90: 55 push %ebp +80103d91: 89 e5 mov %esp,%ebp +80103d93: 53 push %ebx +80103d94: 83 ec 14 sub $0x14,%esp +80103d97: 8b 5d 08 mov 0x8(%ebp),%ebx + acquire(&ptable.lock); +80103d9a: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +80103da1: e8 9a 03 00 00 call 80104140 + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) +80103da6: b8 54 2d 11 80 mov $0x80112d54,%eax +80103dab: eb 0d jmp 80103dba +80103dad: 8d 76 00 lea 0x0(%esi),%esi +80103db0: 83 e8 80 sub $0xffffff80,%eax +80103db3: 3d 54 4d 11 80 cmp $0x80114d54,%eax +80103db8: 74 1e je 80103dd8 + if(p->state == SLEEPING && p->chan == chan) +80103dba: 83 78 08 02 cmpl $0x2,0x8(%eax) +80103dbe: 75 f0 jne 80103db0 +80103dc0: 3b 58 20 cmp 0x20(%eax),%ebx +80103dc3: 75 eb jne 80103db0 + p->state = RUNNABLE; +80103dc5: c7 40 08 03 00 00 00 movl $0x3,0x8(%eax) + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) +80103dcc: 83 e8 80 sub $0xffffff80,%eax +80103dcf: 3d 54 4d 11 80 cmp $0x80114d54,%eax +80103dd4: 75 e4 jne 80103dba +80103dd6: 66 90 xchg %ax,%ax + wakeup1(chan); + release(&ptable.lock); +80103dd8: c7 45 08 20 2d 11 80 movl $0x80112d20,0x8(%ebp) +} +80103ddf: 83 c4 14 add $0x14,%esp +80103de2: 5b pop %ebx +80103de3: 5d pop %ebp + release(&ptable.lock); +80103de4: e9 47 04 00 00 jmp 80104230 +80103de9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80103df0 : +// Kill the process with the given pid. +// Process won't exit until it returns +// to user space (see trap in trap.c). +int +kill(int pid) +{ +80103df0: 55 push %ebp +80103df1: 89 e5 mov %esp,%ebp +80103df3: 53 push %ebx +80103df4: 83 ec 14 sub $0x14,%esp +80103df7: 8b 5d 08 mov 0x8(%ebp),%ebx + struct proc *p; + + acquire(&ptable.lock); +80103dfa: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +80103e01: e8 3a 03 00 00 call 80104140 + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ +80103e06: b8 54 2d 11 80 mov $0x80112d54,%eax +80103e0b: eb 0d jmp 80103e1a +80103e0d: 8d 76 00 lea 0x0(%esi),%esi +80103e10: 83 e8 80 sub $0xffffff80,%eax +80103e13: 3d 54 4d 11 80 cmp $0x80114d54,%eax +80103e18: 74 36 je 80103e50 + if(p->pid == pid){ +80103e1a: 39 58 10 cmp %ebx,0x10(%eax) +80103e1d: 75 f1 jne 80103e10 + p->killed = 1; + // Wake process from sleep if necessary. + if(p->state == SLEEPING) +80103e1f: 83 78 08 02 cmpl $0x2,0x8(%eax) + p->killed = 1; +80103e23: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) + if(p->state == SLEEPING) +80103e2a: 74 14 je 80103e40 + p->state = RUNNABLE; + release(&ptable.lock); +80103e2c: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +80103e33: e8 f8 03 00 00 call 80104230 + return 0; + } + } + release(&ptable.lock); + return -1; +} +80103e38: 83 c4 14 add $0x14,%esp + return 0; +80103e3b: 31 c0 xor %eax,%eax +} +80103e3d: 5b pop %ebx +80103e3e: 5d pop %ebp +80103e3f: c3 ret + p->state = RUNNABLE; +80103e40: c7 40 08 03 00 00 00 movl $0x3,0x8(%eax) +80103e47: eb e3 jmp 80103e2c +80103e49: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + release(&ptable.lock); +80103e50: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) +80103e57: e8 d4 03 00 00 call 80104230 +} +80103e5c: 83 c4 14 add $0x14,%esp + return -1; +80103e5f: b8 ff ff ff ff mov $0xffffffff,%eax +} +80103e64: 5b pop %ebx +80103e65: 5d pop %ebp +80103e66: c3 ret +80103e67: 89 f6 mov %esi,%esi +80103e69: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80103e70 : +// Print a process listing to console. For debugging. +// Runs when user types ^P on console. +// No lock to avoid wedging a stuck machine further. +void +procdump(void) +{ +80103e70: 55 push %ebp +80103e71: 89 e5 mov %esp,%ebp +80103e73: 57 push %edi +80103e74: 56 push %esi +80103e75: 53 push %ebx +80103e76: bb c0 2d 11 80 mov $0x80112dc0,%ebx +80103e7b: 83 ec 4c sub $0x4c,%esp +80103e7e: 8d 75 e8 lea -0x18(%ebp),%esi +80103e81: eb 20 jmp 80103ea3 +80103e83: 90 nop +80103e84: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->state == SLEEPING){ + getcallerpcs((uint*)p->context->ebp+2, pc); + for(i=0; i<10 && pc[i] != 0; i++) + cprintf(" %p", pc[i]); + } + cprintf("\n"); +80103e88: c7 04 24 ed 75 10 80 movl $0x801075ed,(%esp) +80103e8f: e8 bc c7 ff ff call 80100650 +80103e94: 83 eb 80 sub $0xffffff80,%ebx + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ +80103e97: 81 fb c0 4d 11 80 cmp $0x80114dc0,%ebx +80103e9d: 0f 84 8d 00 00 00 je 80103f30 + if(p->state == UNUSED) +80103ea3: 8b 43 9c mov -0x64(%ebx),%eax +80103ea6: 85 c0 test %eax,%eax +80103ea8: 74 ea je 80103e94 + if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) +80103eaa: 83 f8 05 cmp $0x5,%eax + state = "???"; +80103ead: ba 20 74 10 80 mov $0x80107420,%edx + if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) +80103eb2: 77 11 ja 80103ec5 +80103eb4: 8b 14 85 80 74 10 80 mov -0x7fef8b80(,%eax,4),%edx + state = "???"; +80103ebb: b8 20 74 10 80 mov $0x80107420,%eax +80103ec0: 85 d2 test %edx,%edx +80103ec2: 0f 44 d0 cmove %eax,%edx + cprintf("%d %s %s", p->pid, state, p->name); +80103ec5: 8b 43 a4 mov -0x5c(%ebx),%eax +80103ec8: 89 5c 24 0c mov %ebx,0xc(%esp) +80103ecc: 89 54 24 08 mov %edx,0x8(%esp) +80103ed0: c7 04 24 24 74 10 80 movl $0x80107424,(%esp) +80103ed7: 89 44 24 04 mov %eax,0x4(%esp) +80103edb: e8 70 c7 ff ff call 80100650 + if(p->state == SLEEPING){ +80103ee0: 83 7b 9c 02 cmpl $0x2,-0x64(%ebx) +80103ee4: 75 a2 jne 80103e88 + getcallerpcs((uint*)p->context->ebp+2, pc); +80103ee6: 8d 45 c0 lea -0x40(%ebp),%eax +80103ee9: 89 44 24 04 mov %eax,0x4(%esp) +80103eed: 8b 43 b0 mov -0x50(%ebx),%eax +80103ef0: 8d 7d c0 lea -0x40(%ebp),%edi +80103ef3: 8b 40 0c mov 0xc(%eax),%eax +80103ef6: 83 c0 08 add $0x8,%eax +80103ef9: 89 04 24 mov %eax,(%esp) +80103efc: e8 6f 01 00 00 call 80104070 +80103f01: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + for(i=0; i<10 && pc[i] != 0; i++) +80103f08: 8b 17 mov (%edi),%edx +80103f0a: 85 d2 test %edx,%edx +80103f0c: 0f 84 76 ff ff ff je 80103e88 + cprintf(" %p", pc[i]); +80103f12: 89 54 24 04 mov %edx,0x4(%esp) +80103f16: 83 c7 04 add $0x4,%edi +80103f19: c7 04 24 61 6e 10 80 movl $0x80106e61,(%esp) +80103f20: e8 2b c7 ff ff call 80100650 + for(i=0; i<10 && pc[i] != 0; i++) +80103f25: 39 f7 cmp %esi,%edi +80103f27: 75 df jne 80103f08 +80103f29: e9 5a ff ff ff jmp 80103e88 +80103f2e: 66 90 xchg %ax,%ax + } +80103f30: 83 c4 4c add $0x4c,%esp +80103f33: 5b pop %ebx +80103f34: 5e pop %esi +80103f35: 5f pop %edi +80103f36: 5d pop %ebp +80103f37: c3 ret +80103f38: 66 90 xchg %ax,%ax +80103f3a: 66 90 xchg %ax,%ax +80103f3c: 66 90 xchg %ax,%ax +80103f3e: 66 90 xchg %ax,%ax + +80103f40 : +#include "spinlock.h" +#include "sleeplock.h" + +void +initsleeplock(struct sleeplock *lk, char *name) +{ +80103f40: 55 push %ebp +80103f41: 89 e5 mov %esp,%ebp +80103f43: 53 push %ebx +80103f44: 83 ec 14 sub $0x14,%esp +80103f47: 8b 5d 08 mov 0x8(%ebp),%ebx + initlock(&lk->lk, "sleep lock"); +80103f4a: c7 44 24 04 98 74 10 movl $0x80107498,0x4(%esp) +80103f51: 80 +80103f52: 8d 43 04 lea 0x4(%ebx),%eax +80103f55: 89 04 24 mov %eax,(%esp) +80103f58: e8 f3 00 00 00 call 80104050 + lk->name = name; +80103f5d: 8b 45 0c mov 0xc(%ebp),%eax + lk->locked = 0; +80103f60: c7 03 00 00 00 00 movl $0x0,(%ebx) + lk->pid = 0; +80103f66: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) + lk->name = name; +80103f6d: 89 43 38 mov %eax,0x38(%ebx) +} +80103f70: 83 c4 14 add $0x14,%esp +80103f73: 5b pop %ebx +80103f74: 5d pop %ebp +80103f75: c3 ret +80103f76: 8d 76 00 lea 0x0(%esi),%esi +80103f79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80103f80 : + +void +acquiresleep(struct sleeplock *lk) +{ +80103f80: 55 push %ebp +80103f81: 89 e5 mov %esp,%ebp +80103f83: 56 push %esi +80103f84: 53 push %ebx +80103f85: 83 ec 10 sub $0x10,%esp +80103f88: 8b 5d 08 mov 0x8(%ebp),%ebx + acquire(&lk->lk); +80103f8b: 8d 73 04 lea 0x4(%ebx),%esi +80103f8e: 89 34 24 mov %esi,(%esp) +80103f91: e8 aa 01 00 00 call 80104140 + while (lk->locked) { +80103f96: 8b 13 mov (%ebx),%edx +80103f98: 85 d2 test %edx,%edx +80103f9a: 74 16 je 80103fb2 +80103f9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + sleep(lk, &lk->lk); +80103fa0: 89 74 24 04 mov %esi,0x4(%esp) +80103fa4: 89 1c 24 mov %ebx,(%esp) +80103fa7: e8 54 fc ff ff call 80103c00 + while (lk->locked) { +80103fac: 8b 03 mov (%ebx),%eax +80103fae: 85 c0 test %eax,%eax +80103fb0: 75 ee jne 80103fa0 + } + lk->locked = 1; +80103fb2: c7 03 01 00 00 00 movl $0x1,(%ebx) + lk->pid = myproc()->pid; +80103fb8: e8 e3 f6 ff ff call 801036a0 +80103fbd: 8b 40 10 mov 0x10(%eax),%eax +80103fc0: 89 43 3c mov %eax,0x3c(%ebx) + release(&lk->lk); +80103fc3: 89 75 08 mov %esi,0x8(%ebp) +} +80103fc6: 83 c4 10 add $0x10,%esp +80103fc9: 5b pop %ebx +80103fca: 5e pop %esi +80103fcb: 5d pop %ebp + release(&lk->lk); +80103fcc: e9 5f 02 00 00 jmp 80104230 +80103fd1: eb 0d jmp 80103fe0 +80103fd3: 90 nop +80103fd4: 90 nop +80103fd5: 90 nop +80103fd6: 90 nop +80103fd7: 90 nop +80103fd8: 90 nop +80103fd9: 90 nop +80103fda: 90 nop +80103fdb: 90 nop +80103fdc: 90 nop +80103fdd: 90 nop +80103fde: 90 nop +80103fdf: 90 nop + +80103fe0 : + +void +releasesleep(struct sleeplock *lk) +{ +80103fe0: 55 push %ebp +80103fe1: 89 e5 mov %esp,%ebp +80103fe3: 56 push %esi +80103fe4: 53 push %ebx +80103fe5: 83 ec 10 sub $0x10,%esp +80103fe8: 8b 5d 08 mov 0x8(%ebp),%ebx + acquire(&lk->lk); +80103feb: 8d 73 04 lea 0x4(%ebx),%esi +80103fee: 89 34 24 mov %esi,(%esp) +80103ff1: e8 4a 01 00 00 call 80104140 + lk->locked = 0; +80103ff6: c7 03 00 00 00 00 movl $0x0,(%ebx) + lk->pid = 0; +80103ffc: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) + wakeup(lk); +80104003: 89 1c 24 mov %ebx,(%esp) +80104006: e8 85 fd ff ff call 80103d90 + release(&lk->lk); +8010400b: 89 75 08 mov %esi,0x8(%ebp) +} +8010400e: 83 c4 10 add $0x10,%esp +80104011: 5b pop %ebx +80104012: 5e pop %esi +80104013: 5d pop %ebp + release(&lk->lk); +80104014: e9 17 02 00 00 jmp 80104230 +80104019: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80104020 : + +int +holdingsleep(struct sleeplock *lk) +{ +80104020: 55 push %ebp +80104021: 89 e5 mov %esp,%ebp +80104023: 56 push %esi +80104024: 53 push %ebx +80104025: 83 ec 10 sub $0x10,%esp +80104028: 8b 5d 08 mov 0x8(%ebp),%ebx + int r; + + acquire(&lk->lk); +8010402b: 8d 73 04 lea 0x4(%ebx),%esi +8010402e: 89 34 24 mov %esi,(%esp) +80104031: e8 0a 01 00 00 call 80104140 + r = lk->locked; +80104036: 8b 1b mov (%ebx),%ebx + release(&lk->lk); +80104038: 89 34 24 mov %esi,(%esp) +8010403b: e8 f0 01 00 00 call 80104230 + return r; +} +80104040: 83 c4 10 add $0x10,%esp +80104043: 89 d8 mov %ebx,%eax +80104045: 5b pop %ebx +80104046: 5e pop %esi +80104047: 5d pop %ebp +80104048: c3 ret +80104049: 66 90 xchg %ax,%ax +8010404b: 66 90 xchg %ax,%ax +8010404d: 66 90 xchg %ax,%ax +8010404f: 90 nop + +80104050 : +#include "proc.h" +#include "spinlock.h" + +void +initlock(struct spinlock *lk, char *name) +{ +80104050: 55 push %ebp +80104051: 89 e5 mov %esp,%ebp +80104053: 8b 45 08 mov 0x8(%ebp),%eax + lk->name = name; +80104056: 8b 55 0c mov 0xc(%ebp),%edx + lk->locked = 0; +80104059: c7 00 00 00 00 00 movl $0x0,(%eax) + lk->name = name; +8010405f: 89 50 04 mov %edx,0x4(%eax) + lk->cpu = 0; +80104062: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) +} +80104069: 5d pop %ebp +8010406a: c3 ret +8010406b: 90 nop +8010406c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80104070 : +} + +// Record the current call stack in pcs[] by following the %ebp chain. +void +getcallerpcs(void *v, uint pcs[]) +{ +80104070: 55 push %ebp +80104071: 89 e5 mov %esp,%ebp + uint *ebp; + int i; + + ebp = (uint*)v - 2; +80104073: 8b 45 08 mov 0x8(%ebp),%eax +{ +80104076: 8b 4d 0c mov 0xc(%ebp),%ecx +80104079: 53 push %ebx + ebp = (uint*)v - 2; +8010407a: 8d 50 f8 lea -0x8(%eax),%edx + for(i = 0; i < 10; i++){ +8010407d: 31 c0 xor %eax,%eax +8010407f: 90 nop + if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) +80104080: 8d 9a 00 00 00 80 lea -0x80000000(%edx),%ebx +80104086: 81 fb fe ff ff 7f cmp $0x7ffffffe,%ebx +8010408c: 77 1a ja 801040a8 + break; + pcs[i] = ebp[1]; // saved %eip +8010408e: 8b 5a 04 mov 0x4(%edx),%ebx +80104091: 89 1c 81 mov %ebx,(%ecx,%eax,4) + for(i = 0; i < 10; i++){ +80104094: 83 c0 01 add $0x1,%eax + ebp = (uint*)ebp[0]; // saved %ebp +80104097: 8b 12 mov (%edx),%edx + for(i = 0; i < 10; i++){ +80104099: 83 f8 0a cmp $0xa,%eax +8010409c: 75 e2 jne 80104080 + } + for(; i < 10; i++) + pcs[i] = 0; +} +8010409e: 5b pop %ebx +8010409f: 5d pop %ebp +801040a0: c3 ret +801040a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + pcs[i] = 0; +801040a8: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) + for(; i < 10; i++) +801040af: 83 c0 01 add $0x1,%eax +801040b2: 83 f8 0a cmp $0xa,%eax +801040b5: 74 e7 je 8010409e + pcs[i] = 0; +801040b7: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) + for(; i < 10; i++) +801040be: 83 c0 01 add $0x1,%eax +801040c1: 83 f8 0a cmp $0xa,%eax +801040c4: 75 e2 jne 801040a8 +801040c6: eb d6 jmp 8010409e +801040c8: 90 nop +801040c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +801040d0 : + +// Check whether this cpu is holding the lock. +int +holding(struct spinlock *lock) +{ +801040d0: 55 push %ebp + return lock->locked && lock->cpu == mycpu(); +801040d1: 31 c0 xor %eax,%eax +{ +801040d3: 89 e5 mov %esp,%ebp +801040d5: 53 push %ebx +801040d6: 83 ec 04 sub $0x4,%esp +801040d9: 8b 55 08 mov 0x8(%ebp),%edx + return lock->locked && lock->cpu == mycpu(); +801040dc: 8b 0a mov (%edx),%ecx +801040de: 85 c9 test %ecx,%ecx +801040e0: 74 10 je 801040f2 +801040e2: 8b 5a 08 mov 0x8(%edx),%ebx +801040e5: e8 16 f5 ff ff call 80103600 +801040ea: 39 c3 cmp %eax,%ebx +801040ec: 0f 94 c0 sete %al +801040ef: 0f b6 c0 movzbl %al,%eax +} +801040f2: 83 c4 04 add $0x4,%esp +801040f5: 5b pop %ebx +801040f6: 5d pop %ebp +801040f7: c3 ret +801040f8: 90 nop +801040f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80104100 : +// it takes two popcli to undo two pushcli. Also, if interrupts +// are off, then pushcli, popcli leaves them off. + +void +pushcli(void) +{ +80104100: 55 push %ebp +80104101: 89 e5 mov %esp,%ebp +80104103: 53 push %ebx +80104104: 83 ec 04 sub $0x4,%esp +80104107: 9c pushf +80104108: 5b pop %ebx + asm volatile("cli"); +80104109: fa cli + int eflags; + + eflags = readeflags(); + cli(); + if(mycpu()->ncli == 0) +8010410a: e8 f1 f4 ff ff call 80103600 +8010410f: 8b 80 a4 00 00 00 mov 0xa4(%eax),%eax +80104115: 85 c0 test %eax,%eax +80104117: 75 11 jne 8010412a + mycpu()->intena = eflags & FL_IF; +80104119: e8 e2 f4 ff ff call 80103600 +8010411e: 81 e3 00 02 00 00 and $0x200,%ebx +80104124: 89 98 a8 00 00 00 mov %ebx,0xa8(%eax) + mycpu()->ncli += 1; +8010412a: e8 d1 f4 ff ff call 80103600 +8010412f: 83 80 a4 00 00 00 01 addl $0x1,0xa4(%eax) +} +80104136: 83 c4 04 add $0x4,%esp +80104139: 5b pop %ebx +8010413a: 5d pop %ebp +8010413b: c3 ret +8010413c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80104140 : +{ +80104140: 55 push %ebp +80104141: 89 e5 mov %esp,%ebp +80104143: 53 push %ebx +80104144: 83 ec 14 sub $0x14,%esp + pushcli(); // disable interrupts to avoid deadlock. +80104147: e8 b4 ff ff ff call 80104100 + if(holding(lk)) +8010414c: 8b 55 08 mov 0x8(%ebp),%edx + return lock->locked && lock->cpu == mycpu(); +8010414f: 8b 02 mov (%edx),%eax +80104151: 85 c0 test %eax,%eax +80104153: 75 43 jne 80104198 + asm volatile("lock; xchgl %0, %1" : +80104155: b9 01 00 00 00 mov $0x1,%ecx +8010415a: eb 07 jmp 80104163 +8010415c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80104160: 8b 55 08 mov 0x8(%ebp),%edx +80104163: 89 c8 mov %ecx,%eax +80104165: f0 87 02 lock xchg %eax,(%edx) + while(xchg(&lk->locked, 1) != 0) +80104168: 85 c0 test %eax,%eax +8010416a: 75 f4 jne 80104160 + __sync_synchronize(); +8010416c: 0f ae f0 mfence + lk->cpu = mycpu(); +8010416f: 8b 5d 08 mov 0x8(%ebp),%ebx +80104172: e8 89 f4 ff ff call 80103600 +80104177: 89 43 08 mov %eax,0x8(%ebx) + getcallerpcs(&lk, lk->pcs); +8010417a: 8b 45 08 mov 0x8(%ebp),%eax +8010417d: 83 c0 0c add $0xc,%eax +80104180: 89 44 24 04 mov %eax,0x4(%esp) +80104184: 8d 45 08 lea 0x8(%ebp),%eax +80104187: 89 04 24 mov %eax,(%esp) +8010418a: e8 e1 fe ff ff call 80104070 +} +8010418f: 83 c4 14 add $0x14,%esp +80104192: 5b pop %ebx +80104193: 5d pop %ebp +80104194: c3 ret +80104195: 8d 76 00 lea 0x0(%esi),%esi + return lock->locked && lock->cpu == mycpu(); +80104198: 8b 5a 08 mov 0x8(%edx),%ebx +8010419b: e8 60 f4 ff ff call 80103600 + if(holding(lk)) +801041a0: 39 c3 cmp %eax,%ebx +801041a2: 74 05 je 801041a9 +801041a4: 8b 55 08 mov 0x8(%ebp),%edx +801041a7: eb ac jmp 80104155 + panic("acquire"); +801041a9: c7 04 24 a3 74 10 80 movl $0x801074a3,(%esp) +801041b0: e8 ab c1 ff ff call 80100360 +801041b5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801041b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +801041c0 : + +void +popcli(void) +{ +801041c0: 55 push %ebp +801041c1: 89 e5 mov %esp,%ebp +801041c3: 83 ec 18 sub $0x18,%esp + asm volatile("pushfl; popl %0" : "=r" (eflags)); +801041c6: 9c pushf +801041c7: 58 pop %eax + if(readeflags()&FL_IF) +801041c8: f6 c4 02 test $0x2,%ah +801041cb: 75 49 jne 80104216 + panic("popcli - interruptible"); + if(--mycpu()->ncli < 0) +801041cd: e8 2e f4 ff ff call 80103600 +801041d2: 8b 88 a4 00 00 00 mov 0xa4(%eax),%ecx +801041d8: 8d 51 ff lea -0x1(%ecx),%edx +801041db: 85 d2 test %edx,%edx +801041dd: 89 90 a4 00 00 00 mov %edx,0xa4(%eax) +801041e3: 78 25 js 8010420a + panic("popcli"); + if(mycpu()->ncli == 0 && mycpu()->intena) +801041e5: e8 16 f4 ff ff call 80103600 +801041ea: 8b 90 a4 00 00 00 mov 0xa4(%eax),%edx +801041f0: 85 d2 test %edx,%edx +801041f2: 74 04 je 801041f8 + sti(); +} +801041f4: c9 leave +801041f5: c3 ret +801041f6: 66 90 xchg %ax,%ax + if(mycpu()->ncli == 0 && mycpu()->intena) +801041f8: e8 03 f4 ff ff call 80103600 +801041fd: 8b 80 a8 00 00 00 mov 0xa8(%eax),%eax +80104203: 85 c0 test %eax,%eax +80104205: 74 ed je 801041f4 + asm volatile("sti"); +80104207: fb sti +} +80104208: c9 leave +80104209: c3 ret + panic("popcli"); +8010420a: c7 04 24 c2 74 10 80 movl $0x801074c2,(%esp) +80104211: e8 4a c1 ff ff call 80100360 + panic("popcli - interruptible"); +80104216: c7 04 24 ab 74 10 80 movl $0x801074ab,(%esp) +8010421d: e8 3e c1 ff ff call 80100360 +80104222: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80104229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80104230 : +{ +80104230: 55 push %ebp +80104231: 89 e5 mov %esp,%ebp +80104233: 56 push %esi +80104234: 53 push %ebx +80104235: 83 ec 10 sub $0x10,%esp +80104238: 8b 5d 08 mov 0x8(%ebp),%ebx + return lock->locked && lock->cpu == mycpu(); +8010423b: 8b 03 mov (%ebx),%eax +8010423d: 85 c0 test %eax,%eax +8010423f: 75 0f jne 80104250 + panic("release"); +80104241: c7 04 24 c9 74 10 80 movl $0x801074c9,(%esp) +80104248: e8 13 c1 ff ff call 80100360 +8010424d: 8d 76 00 lea 0x0(%esi),%esi + return lock->locked && lock->cpu == mycpu(); +80104250: 8b 73 08 mov 0x8(%ebx),%esi +80104253: e8 a8 f3 ff ff call 80103600 + if(!holding(lk)) +80104258: 39 c6 cmp %eax,%esi +8010425a: 75 e5 jne 80104241 + lk->pcs[0] = 0; +8010425c: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) + lk->cpu = 0; +80104263: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) + __sync_synchronize(); +8010426a: 0f ae f0 mfence + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); +8010426d: c7 03 00 00 00 00 movl $0x0,(%ebx) +} +80104273: 83 c4 10 add $0x10,%esp +80104276: 5b pop %ebx +80104277: 5e pop %esi +80104278: 5d pop %ebp + popcli(); +80104279: e9 42 ff ff ff jmp 801041c0 +8010427e: 66 90 xchg %ax,%ax + +80104280 : +#include "types.h" +#include "x86.h" + +void* +memset(void *dst, int c, uint n) +{ +80104280: 55 push %ebp +80104281: 89 e5 mov %esp,%ebp +80104283: 8b 55 08 mov 0x8(%ebp),%edx +80104286: 57 push %edi +80104287: 8b 4d 10 mov 0x10(%ebp),%ecx +8010428a: 53 push %ebx + if ((int)dst%4 == 0 && n%4 == 0){ +8010428b: f6 c2 03 test $0x3,%dl +8010428e: 75 05 jne 80104295 +80104290: f6 c1 03 test $0x3,%cl +80104293: 74 13 je 801042a8 + asm volatile("cld; rep stosb" : +80104295: 89 d7 mov %edx,%edi +80104297: 8b 45 0c mov 0xc(%ebp),%eax +8010429a: fc cld +8010429b: f3 aa rep stos %al,%es:(%edi) + c &= 0xFF; + stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); + } else + stosb(dst, c, n); + return dst; +} +8010429d: 5b pop %ebx +8010429e: 89 d0 mov %edx,%eax +801042a0: 5f pop %edi +801042a1: 5d pop %ebp +801042a2: c3 ret +801042a3: 90 nop +801042a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + c &= 0xFF; +801042a8: 0f b6 7d 0c movzbl 0xc(%ebp),%edi + stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); +801042ac: c1 e9 02 shr $0x2,%ecx +801042af: 89 f8 mov %edi,%eax +801042b1: 89 fb mov %edi,%ebx +801042b3: c1 e0 18 shl $0x18,%eax +801042b6: c1 e3 10 shl $0x10,%ebx +801042b9: 09 d8 or %ebx,%eax +801042bb: 09 f8 or %edi,%eax +801042bd: c1 e7 08 shl $0x8,%edi +801042c0: 09 f8 or %edi,%eax + asm volatile("cld; rep stosl" : +801042c2: 89 d7 mov %edx,%edi +801042c4: fc cld +801042c5: f3 ab rep stos %eax,%es:(%edi) +} +801042c7: 5b pop %ebx +801042c8: 89 d0 mov %edx,%eax +801042ca: 5f pop %edi +801042cb: 5d pop %ebp +801042cc: c3 ret +801042cd: 8d 76 00 lea 0x0(%esi),%esi + +801042d0 : + +int +memcmp(const void *v1, const void *v2, uint n) +{ +801042d0: 55 push %ebp +801042d1: 89 e5 mov %esp,%ebp +801042d3: 8b 45 10 mov 0x10(%ebp),%eax +801042d6: 57 push %edi +801042d7: 56 push %esi +801042d8: 8b 75 0c mov 0xc(%ebp),%esi +801042db: 53 push %ebx +801042dc: 8b 5d 08 mov 0x8(%ebp),%ebx + const uchar *s1, *s2; + + s1 = v1; + s2 = v2; + while(n-- > 0){ +801042df: 85 c0 test %eax,%eax +801042e1: 8d 78 ff lea -0x1(%eax),%edi +801042e4: 74 26 je 8010430c + if(*s1 != *s2) +801042e6: 0f b6 03 movzbl (%ebx),%eax +801042e9: 31 d2 xor %edx,%edx +801042eb: 0f b6 0e movzbl (%esi),%ecx +801042ee: 38 c8 cmp %cl,%al +801042f0: 74 16 je 80104308 +801042f2: eb 24 jmp 80104318 +801042f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +801042f8: 0f b6 44 13 01 movzbl 0x1(%ebx,%edx,1),%eax +801042fd: 83 c2 01 add $0x1,%edx +80104300: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx +80104304: 38 c8 cmp %cl,%al +80104306: 75 10 jne 80104318 + while(n-- > 0){ +80104308: 39 fa cmp %edi,%edx +8010430a: 75 ec jne 801042f8 + return *s1 - *s2; + s1++, s2++; + } + + return 0; +} +8010430c: 5b pop %ebx + return 0; +8010430d: 31 c0 xor %eax,%eax +} +8010430f: 5e pop %esi +80104310: 5f pop %edi +80104311: 5d pop %ebp +80104312: c3 ret +80104313: 90 nop +80104314: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80104318: 5b pop %ebx + return *s1 - *s2; +80104319: 29 c8 sub %ecx,%eax +} +8010431b: 5e pop %esi +8010431c: 5f pop %edi +8010431d: 5d pop %ebp +8010431e: c3 ret +8010431f: 90 nop + +80104320 : + +void* +memmove(void *dst, const void *src, uint n) +{ +80104320: 55 push %ebp +80104321: 89 e5 mov %esp,%ebp +80104323: 57 push %edi +80104324: 8b 45 08 mov 0x8(%ebp),%eax +80104327: 56 push %esi +80104328: 8b 75 0c mov 0xc(%ebp),%esi +8010432b: 53 push %ebx +8010432c: 8b 5d 10 mov 0x10(%ebp),%ebx + const char *s; + char *d; + + s = src; + d = dst; + if(s < d && s + n > d){ +8010432f: 39 c6 cmp %eax,%esi +80104331: 73 35 jae 80104368 +80104333: 8d 0c 1e lea (%esi,%ebx,1),%ecx +80104336: 39 c8 cmp %ecx,%eax +80104338: 73 2e jae 80104368 + s += n; + d += n; + while(n-- > 0) +8010433a: 85 db test %ebx,%ebx + d += n; +8010433c: 8d 3c 18 lea (%eax,%ebx,1),%edi + while(n-- > 0) +8010433f: 8d 53 ff lea -0x1(%ebx),%edx +80104342: 74 1b je 8010435f +80104344: f7 db neg %ebx +80104346: 8d 34 19 lea (%ecx,%ebx,1),%esi +80104349: 01 fb add %edi,%ebx +8010434b: 90 nop +8010434c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *--d = *--s; +80104350: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx +80104354: 88 0c 13 mov %cl,(%ebx,%edx,1) + while(n-- > 0) +80104357: 83 ea 01 sub $0x1,%edx +8010435a: 83 fa ff cmp $0xffffffff,%edx +8010435d: 75 f1 jne 80104350 + } else + while(n-- > 0) + *d++ = *s++; + + return dst; +} +8010435f: 5b pop %ebx +80104360: 5e pop %esi +80104361: 5f pop %edi +80104362: 5d pop %ebp +80104363: c3 ret +80104364: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while(n-- > 0) +80104368: 31 d2 xor %edx,%edx +8010436a: 85 db test %ebx,%ebx +8010436c: 74 f1 je 8010435f +8010436e: 66 90 xchg %ax,%ax + *d++ = *s++; +80104370: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx +80104374: 88 0c 10 mov %cl,(%eax,%edx,1) +80104377: 83 c2 01 add $0x1,%edx + while(n-- > 0) +8010437a: 39 da cmp %ebx,%edx +8010437c: 75 f2 jne 80104370 +} +8010437e: 5b pop %ebx +8010437f: 5e pop %esi +80104380: 5f pop %edi +80104381: 5d pop %ebp +80104382: c3 ret +80104383: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80104389: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80104390 : + +// memcpy exists to placate GCC. Use memmove. +void* +memcpy(void *dst, const void *src, uint n) +{ +80104390: 55 push %ebp +80104391: 89 e5 mov %esp,%ebp + return memmove(dst, src, n); +} +80104393: 5d pop %ebp + return memmove(dst, src, n); +80104394: eb 8a jmp 80104320 +80104396: 8d 76 00 lea 0x0(%esi),%esi +80104399: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +801043a0 : + +int +strncmp(const char *p, const char *q, uint n) +{ +801043a0: 55 push %ebp +801043a1: 89 e5 mov %esp,%ebp +801043a3: 56 push %esi +801043a4: 8b 75 10 mov 0x10(%ebp),%esi +801043a7: 53 push %ebx +801043a8: 8b 4d 08 mov 0x8(%ebp),%ecx +801043ab: 8b 5d 0c mov 0xc(%ebp),%ebx + while(n > 0 && *p && *p == *q) +801043ae: 85 f6 test %esi,%esi +801043b0: 74 30 je 801043e2 +801043b2: 0f b6 01 movzbl (%ecx),%eax +801043b5: 84 c0 test %al,%al +801043b7: 74 2f je 801043e8 +801043b9: 0f b6 13 movzbl (%ebx),%edx +801043bc: 38 d0 cmp %dl,%al +801043be: 75 46 jne 80104406 +801043c0: 8d 51 01 lea 0x1(%ecx),%edx +801043c3: 01 ce add %ecx,%esi +801043c5: eb 14 jmp 801043db +801043c7: 90 nop +801043c8: 0f b6 02 movzbl (%edx),%eax +801043cb: 84 c0 test %al,%al +801043cd: 74 31 je 80104400 +801043cf: 0f b6 19 movzbl (%ecx),%ebx +801043d2: 83 c2 01 add $0x1,%edx +801043d5: 38 d8 cmp %bl,%al +801043d7: 75 17 jne 801043f0 + n--, p++, q++; +801043d9: 89 cb mov %ecx,%ebx + while(n > 0 && *p && *p == *q) +801043db: 39 f2 cmp %esi,%edx + n--, p++, q++; +801043dd: 8d 4b 01 lea 0x1(%ebx),%ecx + while(n > 0 && *p && *p == *q) +801043e0: 75 e6 jne 801043c8 + if(n == 0) + return 0; + return (uchar)*p - (uchar)*q; +} +801043e2: 5b pop %ebx + return 0; +801043e3: 31 c0 xor %eax,%eax +} +801043e5: 5e pop %esi +801043e6: 5d pop %ebp +801043e7: c3 ret +801043e8: 0f b6 1b movzbl (%ebx),%ebx + while(n > 0 && *p && *p == *q) +801043eb: 31 c0 xor %eax,%eax +801043ed: 8d 76 00 lea 0x0(%esi),%esi + return (uchar)*p - (uchar)*q; +801043f0: 0f b6 d3 movzbl %bl,%edx +801043f3: 29 d0 sub %edx,%eax +} +801043f5: 5b pop %ebx +801043f6: 5e pop %esi +801043f7: 5d pop %ebp +801043f8: c3 ret +801043f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80104400: 0f b6 5b 01 movzbl 0x1(%ebx),%ebx +80104404: eb ea jmp 801043f0 + while(n > 0 && *p && *p == *q) +80104406: 89 d3 mov %edx,%ebx +80104408: eb e6 jmp 801043f0 +8010440a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80104410 : + +char* +strncpy(char *s, const char *t, int n) +{ +80104410: 55 push %ebp +80104411: 89 e5 mov %esp,%ebp +80104413: 8b 45 08 mov 0x8(%ebp),%eax +80104416: 56 push %esi +80104417: 8b 4d 10 mov 0x10(%ebp),%ecx +8010441a: 53 push %ebx +8010441b: 8b 5d 0c mov 0xc(%ebp),%ebx + char *os; + + os = s; + while(n-- > 0 && (*s++ = *t++) != 0) +8010441e: 89 c2 mov %eax,%edx +80104420: eb 19 jmp 8010443b +80104422: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80104428: 83 c3 01 add $0x1,%ebx +8010442b: 0f b6 4b ff movzbl -0x1(%ebx),%ecx +8010442f: 83 c2 01 add $0x1,%edx +80104432: 84 c9 test %cl,%cl +80104434: 88 4a ff mov %cl,-0x1(%edx) +80104437: 74 09 je 80104442 +80104439: 89 f1 mov %esi,%ecx +8010443b: 85 c9 test %ecx,%ecx +8010443d: 8d 71 ff lea -0x1(%ecx),%esi +80104440: 7f e6 jg 80104428 + ; + while(n-- > 0) +80104442: 31 c9 xor %ecx,%ecx +80104444: 85 f6 test %esi,%esi +80104446: 7e 0f jle 80104457 + *s++ = 0; +80104448: c6 04 0a 00 movb $0x0,(%edx,%ecx,1) +8010444c: 89 f3 mov %esi,%ebx +8010444e: 83 c1 01 add $0x1,%ecx +80104451: 29 cb sub %ecx,%ebx + while(n-- > 0) +80104453: 85 db test %ebx,%ebx +80104455: 7f f1 jg 80104448 + return os; +} +80104457: 5b pop %ebx +80104458: 5e pop %esi +80104459: 5d pop %ebp +8010445a: c3 ret +8010445b: 90 nop +8010445c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80104460 : + +// Like strncpy but guaranteed to NUL-terminate. +char* +safestrcpy(char *s, const char *t, int n) +{ +80104460: 55 push %ebp +80104461: 89 e5 mov %esp,%ebp +80104463: 8b 4d 10 mov 0x10(%ebp),%ecx +80104466: 56 push %esi +80104467: 8b 45 08 mov 0x8(%ebp),%eax +8010446a: 53 push %ebx +8010446b: 8b 55 0c mov 0xc(%ebp),%edx + char *os; + + os = s; + if(n <= 0) +8010446e: 85 c9 test %ecx,%ecx +80104470: 7e 26 jle 80104498 +80104472: 8d 74 0a ff lea -0x1(%edx,%ecx,1),%esi +80104476: 89 c1 mov %eax,%ecx +80104478: eb 17 jmp 80104491 +8010447a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return os; + while(--n > 0 && (*s++ = *t++) != 0) +80104480: 83 c2 01 add $0x1,%edx +80104483: 0f b6 5a ff movzbl -0x1(%edx),%ebx +80104487: 83 c1 01 add $0x1,%ecx +8010448a: 84 db test %bl,%bl +8010448c: 88 59 ff mov %bl,-0x1(%ecx) +8010448f: 74 04 je 80104495 +80104491: 39 f2 cmp %esi,%edx +80104493: 75 eb jne 80104480 + ; + *s = 0; +80104495: c6 01 00 movb $0x0,(%ecx) + return os; +} +80104498: 5b pop %ebx +80104499: 5e pop %esi +8010449a: 5d pop %ebp +8010449b: c3 ret +8010449c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +801044a0 : + +int +strlen(const char *s) +{ +801044a0: 55 push %ebp + int n; + + for(n = 0; s[n]; n++) +801044a1: 31 c0 xor %eax,%eax +{ +801044a3: 89 e5 mov %esp,%ebp +801044a5: 8b 55 08 mov 0x8(%ebp),%edx + for(n = 0; s[n]; n++) +801044a8: 80 3a 00 cmpb $0x0,(%edx) +801044ab: 74 0c je 801044b9 +801044ad: 8d 76 00 lea 0x0(%esi),%esi +801044b0: 83 c0 01 add $0x1,%eax +801044b3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) +801044b7: 75 f7 jne 801044b0 + ; + return n; +} +801044b9: 5d pop %ebp +801044ba: c3 ret + +801044bb : +# Save current register context in old +# and then load register context from new. + +.globl swtch +swtch: + movl 4(%esp), %eax +801044bb: 8b 44 24 04 mov 0x4(%esp),%eax + movl 8(%esp), %edx +801044bf: 8b 54 24 08 mov 0x8(%esp),%edx + + # Save old callee-save registers + pushl %ebp +801044c3: 55 push %ebp + pushl %ebx +801044c4: 53 push %ebx + pushl %esi +801044c5: 56 push %esi + pushl %edi +801044c6: 57 push %edi + + # Switch stacks + movl %esp, (%eax) +801044c7: 89 20 mov %esp,(%eax) + movl %edx, %esp +801044c9: 89 d4 mov %edx,%esp + + # Load new callee-save registers + popl %edi +801044cb: 5f pop %edi + popl %esi +801044cc: 5e pop %esi + popl %ebx +801044cd: 5b pop %ebx + popl %ebp +801044ce: 5d pop %ebp + ret +801044cf: c3 ret + +801044d0 : +// to a saved program counter, and then the first argument. + +// Fetch the int at addr from the current process. +int +fetchint(uint addr, int *ip) +{ +801044d0: 55 push %ebp +801044d1: 89 e5 mov %esp,%ebp +801044d3: 8b 45 08 mov 0x8(%ebp),%eax + // ** changed range from sz to KERNBASE + if(addr >= KERNBASE|| addr+4 > KERNBASE ) +801044d6: 3d fc ff ff 7f cmp $0x7ffffffc,%eax +801044db: 77 0b ja 801044e8 + return -1; + + *ip = *(int*)(addr); +801044dd: 8b 10 mov (%eax),%edx +801044df: 8b 45 0c mov 0xc(%ebp),%eax +801044e2: 89 10 mov %edx,(%eax) + return 0; +801044e4: 31 c0 xor %eax,%eax +} +801044e6: 5d pop %ebp +801044e7: c3 ret + return -1; +801044e8: b8 ff ff ff ff mov $0xffffffff,%eax +} +801044ed: 5d pop %ebp +801044ee: c3 ret +801044ef: 90 nop + +801044f0 : +// Fetch the nul-terminated string at addr from the current process. +// Doesn't actually copy the string - just sets *pp to point at it. +// Returns length of string, not including nul. +int +fetchstr(uint addr, char **pp) +{ +801044f0: 55 push %ebp +801044f1: 89 e5 mov %esp,%ebp +801044f3: 53 push %ebx +801044f4: 83 ec 04 sub $0x4,%esp +801044f7: 8b 5d 08 mov 0x8(%ebp),%ebx + char *s, *ep; + struct proc *curproc = myproc(); +801044fa: e8 a1 f1 ff ff call 801036a0 + if(addr >= KERNBASE) +801044ff: 85 db test %ebx,%ebx +80104501: 78 26 js 80104529 + return -1; + *pp = (char*)addr; +80104503: 8b 4d 0c mov 0xc(%ebp),%ecx +80104506: 89 da mov %ebx,%edx +80104508: 89 19 mov %ebx,(%ecx) + ep = (char*)curproc->sz; +8010450a: 8b 00 mov (%eax),%eax + for(s = *pp; s < ep; s++){ +8010450c: 39 c3 cmp %eax,%ebx +8010450e: 73 19 jae 80104529 + if(*s == 0) +80104510: 80 3b 00 cmpb $0x0,(%ebx) +80104513: 75 0d jne 80104522 +80104515: eb 21 jmp 80104538 +80104517: 90 nop +80104518: 80 3a 00 cmpb $0x0,(%edx) +8010451b: 90 nop +8010451c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80104520: 74 16 je 80104538 + for(s = *pp; s < ep; s++){ +80104522: 83 c2 01 add $0x1,%edx +80104525: 39 d0 cmp %edx,%eax +80104527: 77 ef ja 80104518 + return s - *pp; + } + return -1; +} +80104529: 83 c4 04 add $0x4,%esp + return -1; +8010452c: b8 ff ff ff ff mov $0xffffffff,%eax +} +80104531: 5b pop %ebx +80104532: 5d pop %ebp +80104533: c3 ret +80104534: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80104538: 83 c4 04 add $0x4,%esp + return s - *pp; +8010453b: 89 d0 mov %edx,%eax +8010453d: 29 d8 sub %ebx,%eax +} +8010453f: 5b pop %ebx +80104540: 5d pop %ebp +80104541: c3 ret +80104542: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80104549: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80104550 : + +// Fetch the nth 32-bit system call argument. +int +argint(int n, int *ip) +{ +80104550: 55 push %ebp +80104551: 89 e5 mov %esp,%ebp +80104553: 83 ec 08 sub $0x8,%esp + return fetchint((myproc()->tf->esp) + 4 + 4*n, ip); +80104556: e8 45 f1 ff ff call 801036a0 +8010455b: 8b 55 08 mov 0x8(%ebp),%edx +8010455e: 8b 40 18 mov 0x18(%eax),%eax +80104561: 8b 40 44 mov 0x44(%eax),%eax +80104564: 8d 44 90 04 lea 0x4(%eax,%edx,4),%eax + if(addr >= KERNBASE|| addr+4 > KERNBASE ) +80104568: 3d fc ff ff 7f cmp $0x7ffffffc,%eax +8010456d: 77 11 ja 80104580 + *ip = *(int*)(addr); +8010456f: 8b 10 mov (%eax),%edx +80104571: 8b 45 0c mov 0xc(%ebp),%eax +80104574: 89 10 mov %edx,(%eax) + return 0; +80104576: 31 c0 xor %eax,%eax +} +80104578: c9 leave +80104579: c3 ret +8010457a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return -1; +80104580: b8 ff ff ff ff mov $0xffffffff,%eax +} +80104585: c9 leave +80104586: c3 ret +80104587: 89 f6 mov %esi,%esi +80104589: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80104590 : +// Fetch the nth word-sized system call argument as a pointer +// to a block of memory of size bytes. Check that the pointer +// lies within the process address space. +int +argptr(int n, char **pp, int size) +{ +80104590: 55 push %ebp +80104591: 89 e5 mov %esp,%ebp +80104593: 53 push %ebx +80104594: 83 ec 24 sub $0x24,%esp +80104597: 8b 5d 10 mov 0x10(%ebp),%ebx + int i; + + // ** changed range from sz to KERNBASE + if(argint(n, &i) < 0) +8010459a: 8d 45 f4 lea -0xc(%ebp),%eax +8010459d: 89 44 24 04 mov %eax,0x4(%esp) +801045a1: 8b 45 08 mov 0x8(%ebp),%eax +801045a4: 89 04 24 mov %eax,(%esp) +801045a7: e8 a4 ff ff ff call 80104550 +801045ac: 85 c0 test %eax,%eax +801045ae: 78 28 js 801045d8 + return -1; + if(size < 0 || (uint)i >= KERNBASE || (uint)i+size > KERNBASE) +801045b0: 85 db test %ebx,%ebx +801045b2: 78 24 js 801045d8 +801045b4: 8b 45 f4 mov -0xc(%ebp),%eax +801045b7: 85 c0 test %eax,%eax +801045b9: 78 1d js 801045d8 +801045bb: 01 c3 add %eax,%ebx +801045bd: 81 fb 00 00 00 80 cmp $0x80000000,%ebx +801045c3: 77 13 ja 801045d8 + return -1; + *pp = (char*)i; +801045c5: 8b 55 0c mov 0xc(%ebp),%edx +801045c8: 89 02 mov %eax,(%edx) + return 0; +801045ca: 31 c0 xor %eax,%eax +} +801045cc: 83 c4 24 add $0x24,%esp +801045cf: 5b pop %ebx +801045d0: 5d pop %ebp +801045d1: c3 ret +801045d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return -1; +801045d8: b8 ff ff ff ff mov $0xffffffff,%eax +801045dd: eb ed jmp 801045cc +801045df: 90 nop + +801045e0 : +// Check that the pointer is valid and the string is nul-terminated. +// (There is no shared writable memory, so the string can't change +// between this check and being used by the kernel.) +int +argstr(int n, char **pp) +{ +801045e0: 55 push %ebp +801045e1: 89 e5 mov %esp,%ebp +801045e3: 83 ec 28 sub $0x28,%esp + int addr; + if(argint(n, &addr) < 0) +801045e6: 8d 45 f4 lea -0xc(%ebp),%eax +801045e9: 89 44 24 04 mov %eax,0x4(%esp) +801045ed: 8b 45 08 mov 0x8(%ebp),%eax +801045f0: 89 04 24 mov %eax,(%esp) +801045f3: e8 58 ff ff ff call 80104550 +801045f8: 85 c0 test %eax,%eax +801045fa: 78 14 js 80104610 + return -1; + return fetchstr(addr, pp); +801045fc: 8b 45 0c mov 0xc(%ebp),%eax +801045ff: 89 44 24 04 mov %eax,0x4(%esp) +80104603: 8b 45 f4 mov -0xc(%ebp),%eax +80104606: 89 04 24 mov %eax,(%esp) +80104609: e8 e2 fe ff ff call 801044f0 +} +8010460e: c9 leave +8010460f: c3 ret + return -1; +80104610: b8 ff ff ff ff mov $0xffffffff,%eax +} +80104615: c9 leave +80104616: c3 ret +80104617: 89 f6 mov %esi,%esi +80104619: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80104620 : +[SYS_shm_close] sys_shm_close +}; + +void +syscall(void) +{ +80104620: 55 push %ebp +80104621: 89 e5 mov %esp,%ebp +80104623: 56 push %esi +80104624: 53 push %ebx +80104625: 83 ec 10 sub $0x10,%esp + int num; + struct proc *curproc = myproc(); +80104628: e8 73 f0 ff ff call 801036a0 + + num = curproc->tf->eax; +8010462d: 8b 70 18 mov 0x18(%eax),%esi + struct proc *curproc = myproc(); +80104630: 89 c3 mov %eax,%ebx + num = curproc->tf->eax; +80104632: 8b 46 1c mov 0x1c(%esi),%eax + if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { +80104635: 8d 50 ff lea -0x1(%eax),%edx +80104638: 83 fa 16 cmp $0x16,%edx +8010463b: 77 1b ja 80104658 +8010463d: 8b 14 85 00 75 10 80 mov -0x7fef8b00(,%eax,4),%edx +80104644: 85 d2 test %edx,%edx +80104646: 74 10 je 80104658 + curproc->tf->eax = syscalls[num](); +80104648: ff d2 call *%edx +8010464a: 89 46 1c mov %eax,0x1c(%esi) + } else { + cprintf("%d %s: unknown sys call %d\n", + curproc->pid, curproc->name, num); + curproc->tf->eax = -1; + } +} +8010464d: 83 c4 10 add $0x10,%esp +80104650: 5b pop %ebx +80104651: 5e pop %esi +80104652: 5d pop %ebp +80104653: c3 ret +80104654: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + cprintf("%d %s: unknown sys call %d\n", +80104658: 89 44 24 0c mov %eax,0xc(%esp) + curproc->pid, curproc->name, num); +8010465c: 8d 43 6c lea 0x6c(%ebx),%eax +8010465f: 89 44 24 08 mov %eax,0x8(%esp) + cprintf("%d %s: unknown sys call %d\n", +80104663: 8b 43 10 mov 0x10(%ebx),%eax +80104666: c7 04 24 d1 74 10 80 movl $0x801074d1,(%esp) +8010466d: 89 44 24 04 mov %eax,0x4(%esp) +80104671: e8 da bf ff ff call 80100650 + curproc->tf->eax = -1; +80104676: 8b 43 18 mov 0x18(%ebx),%eax +80104679: c7 40 1c ff ff ff ff movl $0xffffffff,0x1c(%eax) +} +80104680: 83 c4 10 add $0x10,%esp +80104683: 5b pop %ebx +80104684: 5e pop %esi +80104685: 5d pop %ebp +80104686: c3 ret +80104687: 66 90 xchg %ax,%ax +80104689: 66 90 xchg %ax,%ax +8010468b: 66 90 xchg %ax,%ax +8010468d: 66 90 xchg %ax,%ax +8010468f: 90 nop + +80104690 : + +// Allocate a file descriptor for the given file. +// Takes over file reference from caller on success. +static int +fdalloc(struct file *f) +{ +80104690: 55 push %ebp +80104691: 89 e5 mov %esp,%ebp +80104693: 53 push %ebx +80104694: 89 c3 mov %eax,%ebx +80104696: 83 ec 04 sub $0x4,%esp + int fd; + struct proc *curproc = myproc(); +80104699: e8 02 f0 ff ff call 801036a0 + + for(fd = 0; fd < NOFILE; fd++){ +8010469e: 31 d2 xor %edx,%edx + if(curproc->ofile[fd] == 0){ +801046a0: 8b 4c 90 28 mov 0x28(%eax,%edx,4),%ecx +801046a4: 85 c9 test %ecx,%ecx +801046a6: 74 18 je 801046c0 + for(fd = 0; fd < NOFILE; fd++){ +801046a8: 83 c2 01 add $0x1,%edx +801046ab: 83 fa 10 cmp $0x10,%edx +801046ae: 75 f0 jne 801046a0 + curproc->ofile[fd] = f; + return fd; + } + } + return -1; +} +801046b0: 83 c4 04 add $0x4,%esp + return -1; +801046b3: b8 ff ff ff ff mov $0xffffffff,%eax +} +801046b8: 5b pop %ebx +801046b9: 5d pop %ebp +801046ba: c3 ret +801046bb: 90 nop +801046bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + curproc->ofile[fd] = f; +801046c0: 89 5c 90 28 mov %ebx,0x28(%eax,%edx,4) +} +801046c4: 83 c4 04 add $0x4,%esp + return fd; +801046c7: 89 d0 mov %edx,%eax +} +801046c9: 5b pop %ebx +801046ca: 5d pop %ebp +801046cb: c3 ret +801046cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +801046d0 : + return -1; +} + +static struct inode* +create(char *path, short type, short major, short minor) +{ +801046d0: 55 push %ebp +801046d1: 89 e5 mov %esp,%ebp +801046d3: 57 push %edi +801046d4: 56 push %esi +801046d5: 53 push %ebx +801046d6: 83 ec 4c sub $0x4c,%esp +801046d9: 89 4d c0 mov %ecx,-0x40(%ebp) +801046dc: 8b 4d 08 mov 0x8(%ebp),%ecx + uint off; + struct inode *ip, *dp; + char name[DIRSIZ]; + + if((dp = nameiparent(path, name)) == 0) +801046df: 8d 5d da lea -0x26(%ebp),%ebx +801046e2: 89 5c 24 04 mov %ebx,0x4(%esp) +801046e6: 89 04 24 mov %eax,(%esp) +{ +801046e9: 89 55 c4 mov %edx,-0x3c(%ebp) +801046ec: 89 4d bc mov %ecx,-0x44(%ebp) + if((dp = nameiparent(path, name)) == 0) +801046ef: e8 2c d8 ff ff call 80101f20 +801046f4: 85 c0 test %eax,%eax +801046f6: 89 c7 mov %eax,%edi +801046f8: 0f 84 da 00 00 00 je 801047d8 + return 0; + ilock(dp); +801046fe: 89 04 24 mov %eax,(%esp) +80104701: e8 aa cf ff ff call 801016b0 + + if((ip = dirlookup(dp, name, &off)) != 0){ +80104706: 8d 45 d4 lea -0x2c(%ebp),%eax +80104709: 89 44 24 08 mov %eax,0x8(%esp) +8010470d: 89 5c 24 04 mov %ebx,0x4(%esp) +80104711: 89 3c 24 mov %edi,(%esp) +80104714: e8 a7 d4 ff ff call 80101bc0 +80104719: 85 c0 test %eax,%eax +8010471b: 89 c6 mov %eax,%esi +8010471d: 74 41 je 80104760 + iunlockput(dp); +8010471f: 89 3c 24 mov %edi,(%esp) +80104722: e8 e9 d1 ff ff call 80101910 + ilock(ip); +80104727: 89 34 24 mov %esi,(%esp) +8010472a: e8 81 cf ff ff call 801016b0 + if(type == T_FILE && ip->type == T_FILE) +8010472f: 66 83 7d c4 02 cmpw $0x2,-0x3c(%ebp) +80104734: 75 12 jne 80104748 +80104736: 66 83 7e 50 02 cmpw $0x2,0x50(%esi) +8010473b: 89 f0 mov %esi,%eax +8010473d: 75 09 jne 80104748 + panic("create: dirlink"); + + iunlockput(dp); + + return ip; +} +8010473f: 83 c4 4c add $0x4c,%esp +80104742: 5b pop %ebx +80104743: 5e pop %esi +80104744: 5f pop %edi +80104745: 5d pop %ebp +80104746: c3 ret +80104747: 90 nop + iunlockput(ip); +80104748: 89 34 24 mov %esi,(%esp) +8010474b: e8 c0 d1 ff ff call 80101910 +} +80104750: 83 c4 4c add $0x4c,%esp + return 0; +80104753: 31 c0 xor %eax,%eax +} +80104755: 5b pop %ebx +80104756: 5e pop %esi +80104757: 5f pop %edi +80104758: 5d pop %ebp +80104759: c3 ret +8010475a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if((ip = ialloc(dp->dev, type)) == 0) +80104760: 0f bf 45 c4 movswl -0x3c(%ebp),%eax +80104764: 89 44 24 04 mov %eax,0x4(%esp) +80104768: 8b 07 mov (%edi),%eax +8010476a: 89 04 24 mov %eax,(%esp) +8010476d: e8 ae cd ff ff call 80101520 +80104772: 85 c0 test %eax,%eax +80104774: 89 c6 mov %eax,%esi +80104776: 0f 84 bf 00 00 00 je 8010483b + ilock(ip); +8010477c: 89 04 24 mov %eax,(%esp) +8010477f: e8 2c cf ff ff call 801016b0 + ip->major = major; +80104784: 0f b7 45 c0 movzwl -0x40(%ebp),%eax +80104788: 66 89 46 52 mov %ax,0x52(%esi) + ip->minor = minor; +8010478c: 0f b7 45 bc movzwl -0x44(%ebp),%eax +80104790: 66 89 46 54 mov %ax,0x54(%esi) + ip->nlink = 1; +80104794: b8 01 00 00 00 mov $0x1,%eax +80104799: 66 89 46 56 mov %ax,0x56(%esi) + iupdate(ip); +8010479d: 89 34 24 mov %esi,(%esp) +801047a0: e8 4b ce ff ff call 801015f0 + if(type == T_DIR){ // Create . and .. entries. +801047a5: 66 83 7d c4 01 cmpw $0x1,-0x3c(%ebp) +801047aa: 74 34 je 801047e0 + if(dirlink(dp, name, ip->inum) < 0) +801047ac: 8b 46 04 mov 0x4(%esi),%eax +801047af: 89 5c 24 04 mov %ebx,0x4(%esp) +801047b3: 89 3c 24 mov %edi,(%esp) +801047b6: 89 44 24 08 mov %eax,0x8(%esp) +801047ba: e8 61 d6 ff ff call 80101e20 +801047bf: 85 c0 test %eax,%eax +801047c1: 78 6c js 8010482f + iunlockput(dp); +801047c3: 89 3c 24 mov %edi,(%esp) +801047c6: e8 45 d1 ff ff call 80101910 +} +801047cb: 83 c4 4c add $0x4c,%esp + return ip; +801047ce: 89 f0 mov %esi,%eax +} +801047d0: 5b pop %ebx +801047d1: 5e pop %esi +801047d2: 5f pop %edi +801047d3: 5d pop %ebp +801047d4: c3 ret +801047d5: 8d 76 00 lea 0x0(%esi),%esi + return 0; +801047d8: 31 c0 xor %eax,%eax +801047da: e9 60 ff ff ff jmp 8010473f +801047df: 90 nop + dp->nlink++; // for ".." +801047e0: 66 83 47 56 01 addw $0x1,0x56(%edi) + iupdate(dp); +801047e5: 89 3c 24 mov %edi,(%esp) +801047e8: e8 03 ce ff ff call 801015f0 + if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) +801047ed: 8b 46 04 mov 0x4(%esi),%eax +801047f0: c7 44 24 04 7c 75 10 movl $0x8010757c,0x4(%esp) +801047f7: 80 +801047f8: 89 34 24 mov %esi,(%esp) +801047fb: 89 44 24 08 mov %eax,0x8(%esp) +801047ff: e8 1c d6 ff ff call 80101e20 +80104804: 85 c0 test %eax,%eax +80104806: 78 1b js 80104823 +80104808: 8b 47 04 mov 0x4(%edi),%eax +8010480b: c7 44 24 04 7b 75 10 movl $0x8010757b,0x4(%esp) +80104812: 80 +80104813: 89 34 24 mov %esi,(%esp) +80104816: 89 44 24 08 mov %eax,0x8(%esp) +8010481a: e8 01 d6 ff ff call 80101e20 +8010481f: 85 c0 test %eax,%eax +80104821: 79 89 jns 801047ac + panic("create dots"); +80104823: c7 04 24 6f 75 10 80 movl $0x8010756f,(%esp) +8010482a: e8 31 bb ff ff call 80100360 + panic("create: dirlink"); +8010482f: c7 04 24 7e 75 10 80 movl $0x8010757e,(%esp) +80104836: e8 25 bb ff ff call 80100360 + panic("create: ialloc"); +8010483b: c7 04 24 60 75 10 80 movl $0x80107560,(%esp) +80104842: e8 19 bb ff ff call 80100360 +80104847: 89 f6 mov %esi,%esi +80104849: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80104850 : +argfd(int n, int *pfd, struct file **pf) +80104850: 55 push %ebp +80104851: 89 e5 mov %esp,%ebp +80104853: 56 push %esi +80104854: 89 c6 mov %eax,%esi +80104856: 53 push %ebx +80104857: 89 d3 mov %edx,%ebx +80104859: 83 ec 20 sub $0x20,%esp + if(argint(n, &fd) < 0) +8010485c: 8d 45 f4 lea -0xc(%ebp),%eax +8010485f: 89 44 24 04 mov %eax,0x4(%esp) +80104863: c7 04 24 00 00 00 00 movl $0x0,(%esp) +8010486a: e8 e1 fc ff ff call 80104550 +8010486f: 85 c0 test %eax,%eax +80104871: 78 2d js 801048a0 + if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0) +80104873: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) +80104877: 77 27 ja 801048a0 +80104879: e8 22 ee ff ff call 801036a0 +8010487e: 8b 55 f4 mov -0xc(%ebp),%edx +80104881: 8b 44 90 28 mov 0x28(%eax,%edx,4),%eax +80104885: 85 c0 test %eax,%eax +80104887: 74 17 je 801048a0 + if(pfd) +80104889: 85 f6 test %esi,%esi +8010488b: 74 02 je 8010488f + *pfd = fd; +8010488d: 89 16 mov %edx,(%esi) + if(pf) +8010488f: 85 db test %ebx,%ebx +80104891: 74 1d je 801048b0 + *pf = f; +80104893: 89 03 mov %eax,(%ebx) + return 0; +80104895: 31 c0 xor %eax,%eax +} +80104897: 83 c4 20 add $0x20,%esp +8010489a: 5b pop %ebx +8010489b: 5e pop %esi +8010489c: 5d pop %ebp +8010489d: c3 ret +8010489e: 66 90 xchg %ax,%ax +801048a0: 83 c4 20 add $0x20,%esp + return -1; +801048a3: b8 ff ff ff ff mov $0xffffffff,%eax +} +801048a8: 5b pop %ebx +801048a9: 5e pop %esi +801048aa: 5d pop %ebp +801048ab: c3 ret +801048ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return 0; +801048b0: 31 c0 xor %eax,%eax +801048b2: eb e3 jmp 80104897 +801048b4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +801048ba: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +801048c0 : +{ +801048c0: 55 push %ebp + if(argfd(0, 0, &f) < 0) +801048c1: 31 c0 xor %eax,%eax +{ +801048c3: 89 e5 mov %esp,%ebp +801048c5: 53 push %ebx +801048c6: 83 ec 24 sub $0x24,%esp + if(argfd(0, 0, &f) < 0) +801048c9: 8d 55 f4 lea -0xc(%ebp),%edx +801048cc: e8 7f ff ff ff call 80104850 +801048d1: 85 c0 test %eax,%eax +801048d3: 78 23 js 801048f8 + if((fd=fdalloc(f)) < 0) +801048d5: 8b 45 f4 mov -0xc(%ebp),%eax +801048d8: e8 b3 fd ff ff call 80104690 +801048dd: 85 c0 test %eax,%eax +801048df: 89 c3 mov %eax,%ebx +801048e1: 78 15 js 801048f8 + filedup(f); +801048e3: 8b 45 f4 mov -0xc(%ebp),%eax +801048e6: 89 04 24 mov %eax,(%esp) +801048e9: e8 e2 c4 ff ff call 80100dd0 + return fd; +801048ee: 89 d8 mov %ebx,%eax +} +801048f0: 83 c4 24 add $0x24,%esp +801048f3: 5b pop %ebx +801048f4: 5d pop %ebp +801048f5: c3 ret +801048f6: 66 90 xchg %ax,%ax + return -1; +801048f8: b8 ff ff ff ff mov $0xffffffff,%eax +801048fd: eb f1 jmp 801048f0 +801048ff: 90 nop + +80104900 : +{ +80104900: 55 push %ebp + if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) +80104901: 31 c0 xor %eax,%eax +{ +80104903: 89 e5 mov %esp,%ebp +80104905: 83 ec 28 sub $0x28,%esp + if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) +80104908: 8d 55 ec lea -0x14(%ebp),%edx +8010490b: e8 40 ff ff ff call 80104850 +80104910: 85 c0 test %eax,%eax +80104912: 78 54 js 80104968 +80104914: 8d 45 f0 lea -0x10(%ebp),%eax +80104917: 89 44 24 04 mov %eax,0x4(%esp) +8010491b: c7 04 24 02 00 00 00 movl $0x2,(%esp) +80104922: e8 29 fc ff ff call 80104550 +80104927: 85 c0 test %eax,%eax +80104929: 78 3d js 80104968 +8010492b: 8b 45 f0 mov -0x10(%ebp),%eax +8010492e: c7 04 24 01 00 00 00 movl $0x1,(%esp) +80104935: 89 44 24 08 mov %eax,0x8(%esp) +80104939: 8d 45 f4 lea -0xc(%ebp),%eax +8010493c: 89 44 24 04 mov %eax,0x4(%esp) +80104940: e8 4b fc ff ff call 80104590 +80104945: 85 c0 test %eax,%eax +80104947: 78 1f js 80104968 + return fileread(f, p, n); +80104949: 8b 45 f0 mov -0x10(%ebp),%eax +8010494c: 89 44 24 08 mov %eax,0x8(%esp) +80104950: 8b 45 f4 mov -0xc(%ebp),%eax +80104953: 89 44 24 04 mov %eax,0x4(%esp) +80104957: 8b 45 ec mov -0x14(%ebp),%eax +8010495a: 89 04 24 mov %eax,(%esp) +8010495d: e8 ce c5 ff ff call 80100f30 +} +80104962: c9 leave +80104963: c3 ret +80104964: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; +80104968: b8 ff ff ff ff mov $0xffffffff,%eax +} +8010496d: c9 leave +8010496e: c3 ret +8010496f: 90 nop + +80104970 : +{ +80104970: 55 push %ebp + if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) +80104971: 31 c0 xor %eax,%eax +{ +80104973: 89 e5 mov %esp,%ebp +80104975: 83 ec 28 sub $0x28,%esp + if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) +80104978: 8d 55 ec lea -0x14(%ebp),%edx +8010497b: e8 d0 fe ff ff call 80104850 +80104980: 85 c0 test %eax,%eax +80104982: 78 54 js 801049d8 +80104984: 8d 45 f0 lea -0x10(%ebp),%eax +80104987: 89 44 24 04 mov %eax,0x4(%esp) +8010498b: c7 04 24 02 00 00 00 movl $0x2,(%esp) +80104992: e8 b9 fb ff ff call 80104550 +80104997: 85 c0 test %eax,%eax +80104999: 78 3d js 801049d8 +8010499b: 8b 45 f0 mov -0x10(%ebp),%eax +8010499e: c7 04 24 01 00 00 00 movl $0x1,(%esp) +801049a5: 89 44 24 08 mov %eax,0x8(%esp) +801049a9: 8d 45 f4 lea -0xc(%ebp),%eax +801049ac: 89 44 24 04 mov %eax,0x4(%esp) +801049b0: e8 db fb ff ff call 80104590 +801049b5: 85 c0 test %eax,%eax +801049b7: 78 1f js 801049d8 + return filewrite(f, p, n); +801049b9: 8b 45 f0 mov -0x10(%ebp),%eax +801049bc: 89 44 24 08 mov %eax,0x8(%esp) +801049c0: 8b 45 f4 mov -0xc(%ebp),%eax +801049c3: 89 44 24 04 mov %eax,0x4(%esp) +801049c7: 8b 45 ec mov -0x14(%ebp),%eax +801049ca: 89 04 24 mov %eax,(%esp) +801049cd: e8 fe c5 ff ff call 80100fd0 +} +801049d2: c9 leave +801049d3: c3 ret +801049d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; +801049d8: b8 ff ff ff ff mov $0xffffffff,%eax +} +801049dd: c9 leave +801049de: c3 ret +801049df: 90 nop + +801049e0 : +{ +801049e0: 55 push %ebp +801049e1: 89 e5 mov %esp,%ebp +801049e3: 83 ec 28 sub $0x28,%esp + if(argfd(0, &fd, &f) < 0) +801049e6: 8d 55 f4 lea -0xc(%ebp),%edx +801049e9: 8d 45 f0 lea -0x10(%ebp),%eax +801049ec: e8 5f fe ff ff call 80104850 +801049f1: 85 c0 test %eax,%eax +801049f3: 78 23 js 80104a18 + myproc()->ofile[fd] = 0; +801049f5: e8 a6 ec ff ff call 801036a0 +801049fa: 8b 55 f0 mov -0x10(%ebp),%edx +801049fd: c7 44 90 28 00 00 00 movl $0x0,0x28(%eax,%edx,4) +80104a04: 00 + fileclose(f); +80104a05: 8b 45 f4 mov -0xc(%ebp),%eax +80104a08: 89 04 24 mov %eax,(%esp) +80104a0b: e8 10 c4 ff ff call 80100e20 + return 0; +80104a10: 31 c0 xor %eax,%eax +} +80104a12: c9 leave +80104a13: c3 ret +80104a14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; +80104a18: b8 ff ff ff ff mov $0xffffffff,%eax +} +80104a1d: c9 leave +80104a1e: c3 ret +80104a1f: 90 nop + +80104a20 : +{ +80104a20: 55 push %ebp + if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) +80104a21: 31 c0 xor %eax,%eax +{ +80104a23: 89 e5 mov %esp,%ebp +80104a25: 83 ec 28 sub $0x28,%esp + if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) +80104a28: 8d 55 f0 lea -0x10(%ebp),%edx +80104a2b: e8 20 fe ff ff call 80104850 +80104a30: 85 c0 test %eax,%eax +80104a32: 78 34 js 80104a68 +80104a34: 8d 45 f4 lea -0xc(%ebp),%eax +80104a37: c7 44 24 08 14 00 00 movl $0x14,0x8(%esp) +80104a3e: 00 +80104a3f: 89 44 24 04 mov %eax,0x4(%esp) +80104a43: c7 04 24 01 00 00 00 movl $0x1,(%esp) +80104a4a: e8 41 fb ff ff call 80104590 +80104a4f: 85 c0 test %eax,%eax +80104a51: 78 15 js 80104a68 + return filestat(f, st); +80104a53: 8b 45 f4 mov -0xc(%ebp),%eax +80104a56: 89 44 24 04 mov %eax,0x4(%esp) +80104a5a: 8b 45 f0 mov -0x10(%ebp),%eax +80104a5d: 89 04 24 mov %eax,(%esp) +80104a60: e8 7b c4 ff ff call 80100ee0 +} +80104a65: c9 leave +80104a66: c3 ret +80104a67: 90 nop + return -1; +80104a68: b8 ff ff ff ff mov $0xffffffff,%eax +} +80104a6d: c9 leave +80104a6e: c3 ret +80104a6f: 90 nop + +80104a70 : +{ +80104a70: 55 push %ebp +80104a71: 89 e5 mov %esp,%ebp +80104a73: 57 push %edi +80104a74: 56 push %esi +80104a75: 53 push %ebx +80104a76: 83 ec 3c sub $0x3c,%esp + if(argstr(0, &old) < 0 || argstr(1, &new) < 0) +80104a79: 8d 45 d4 lea -0x2c(%ebp),%eax +80104a7c: 89 44 24 04 mov %eax,0x4(%esp) +80104a80: c7 04 24 00 00 00 00 movl $0x0,(%esp) +80104a87: e8 54 fb ff ff call 801045e0 +80104a8c: 85 c0 test %eax,%eax +80104a8e: 0f 88 e6 00 00 00 js 80104b7a +80104a94: 8d 45 d0 lea -0x30(%ebp),%eax +80104a97: 89 44 24 04 mov %eax,0x4(%esp) +80104a9b: c7 04 24 01 00 00 00 movl $0x1,(%esp) +80104aa2: e8 39 fb ff ff call 801045e0 +80104aa7: 85 c0 test %eax,%eax +80104aa9: 0f 88 cb 00 00 00 js 80104b7a + begin_op(); +80104aaf: e8 5c e0 ff ff call 80102b10 + if((ip = namei(old)) == 0){ +80104ab4: 8b 45 d4 mov -0x2c(%ebp),%eax +80104ab7: 89 04 24 mov %eax,(%esp) +80104aba: e8 41 d4 ff ff call 80101f00 +80104abf: 85 c0 test %eax,%eax +80104ac1: 89 c3 mov %eax,%ebx +80104ac3: 0f 84 ac 00 00 00 je 80104b75 + ilock(ip); +80104ac9: 89 04 24 mov %eax,(%esp) +80104acc: e8 df cb ff ff call 801016b0 + if(ip->type == T_DIR){ +80104ad1: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) +80104ad6: 0f 84 91 00 00 00 je 80104b6d + ip->nlink++; +80104adc: 66 83 43 56 01 addw $0x1,0x56(%ebx) + if((dp = nameiparent(new, name)) == 0) +80104ae1: 8d 7d da lea -0x26(%ebp),%edi + iupdate(ip); +80104ae4: 89 1c 24 mov %ebx,(%esp) +80104ae7: e8 04 cb ff ff call 801015f0 + iunlock(ip); +80104aec: 89 1c 24 mov %ebx,(%esp) +80104aef: e8 9c cc ff ff call 80101790 + if((dp = nameiparent(new, name)) == 0) +80104af4: 8b 45 d0 mov -0x30(%ebp),%eax +80104af7: 89 7c 24 04 mov %edi,0x4(%esp) +80104afb: 89 04 24 mov %eax,(%esp) +80104afe: e8 1d d4 ff ff call 80101f20 +80104b03: 85 c0 test %eax,%eax +80104b05: 89 c6 mov %eax,%esi +80104b07: 74 4f je 80104b58 + ilock(dp); +80104b09: 89 04 24 mov %eax,(%esp) +80104b0c: e8 9f cb ff ff call 801016b0 + if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){ +80104b11: 8b 03 mov (%ebx),%eax +80104b13: 39 06 cmp %eax,(%esi) +80104b15: 75 39 jne 80104b50 +80104b17: 8b 43 04 mov 0x4(%ebx),%eax +80104b1a: 89 7c 24 04 mov %edi,0x4(%esp) +80104b1e: 89 34 24 mov %esi,(%esp) +80104b21: 89 44 24 08 mov %eax,0x8(%esp) +80104b25: e8 f6 d2 ff ff call 80101e20 +80104b2a: 85 c0 test %eax,%eax +80104b2c: 78 22 js 80104b50 + iunlockput(dp); +80104b2e: 89 34 24 mov %esi,(%esp) +80104b31: e8 da cd ff ff call 80101910 + iput(ip); +80104b36: 89 1c 24 mov %ebx,(%esp) +80104b39: e8 92 cc ff ff call 801017d0 + end_op(); +80104b3e: e8 3d e0 ff ff call 80102b80 +} +80104b43: 83 c4 3c add $0x3c,%esp + return 0; +80104b46: 31 c0 xor %eax,%eax +} +80104b48: 5b pop %ebx +80104b49: 5e pop %esi +80104b4a: 5f pop %edi +80104b4b: 5d pop %ebp +80104b4c: c3 ret +80104b4d: 8d 76 00 lea 0x0(%esi),%esi + iunlockput(dp); +80104b50: 89 34 24 mov %esi,(%esp) +80104b53: e8 b8 cd ff ff call 80101910 + ilock(ip); +80104b58: 89 1c 24 mov %ebx,(%esp) +80104b5b: e8 50 cb ff ff call 801016b0 + ip->nlink--; +80104b60: 66 83 6b 56 01 subw $0x1,0x56(%ebx) + iupdate(ip); +80104b65: 89 1c 24 mov %ebx,(%esp) +80104b68: e8 83 ca ff ff call 801015f0 + iunlockput(ip); +80104b6d: 89 1c 24 mov %ebx,(%esp) +80104b70: e8 9b cd ff ff call 80101910 + end_op(); +80104b75: e8 06 e0 ff ff call 80102b80 +} +80104b7a: 83 c4 3c add $0x3c,%esp + return -1; +80104b7d: b8 ff ff ff ff mov $0xffffffff,%eax +} +80104b82: 5b pop %ebx +80104b83: 5e pop %esi +80104b84: 5f pop %edi +80104b85: 5d pop %ebp +80104b86: c3 ret +80104b87: 89 f6 mov %esi,%esi +80104b89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80104b90 : +{ +80104b90: 55 push %ebp +80104b91: 89 e5 mov %esp,%ebp +80104b93: 57 push %edi +80104b94: 56 push %esi +80104b95: 53 push %ebx +80104b96: 83 ec 5c sub $0x5c,%esp + if(argstr(0, &path) < 0) +80104b99: 8d 45 c0 lea -0x40(%ebp),%eax +80104b9c: 89 44 24 04 mov %eax,0x4(%esp) +80104ba0: c7 04 24 00 00 00 00 movl $0x0,(%esp) +80104ba7: e8 34 fa ff ff call 801045e0 +80104bac: 85 c0 test %eax,%eax +80104bae: 0f 88 76 01 00 00 js 80104d2a + begin_op(); +80104bb4: e8 57 df ff ff call 80102b10 + if((dp = nameiparent(path, name)) == 0){ +80104bb9: 8b 45 c0 mov -0x40(%ebp),%eax +80104bbc: 8d 5d ca lea -0x36(%ebp),%ebx +80104bbf: 89 5c 24 04 mov %ebx,0x4(%esp) +80104bc3: 89 04 24 mov %eax,(%esp) +80104bc6: e8 55 d3 ff ff call 80101f20 +80104bcb: 85 c0 test %eax,%eax +80104bcd: 89 45 b4 mov %eax,-0x4c(%ebp) +80104bd0: 0f 84 4f 01 00 00 je 80104d25 + ilock(dp); +80104bd6: 8b 75 b4 mov -0x4c(%ebp),%esi +80104bd9: 89 34 24 mov %esi,(%esp) +80104bdc: e8 cf ca ff ff call 801016b0 + if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0) +80104be1: c7 44 24 04 7c 75 10 movl $0x8010757c,0x4(%esp) +80104be8: 80 +80104be9: 89 1c 24 mov %ebx,(%esp) +80104bec: e8 9f cf ff ff call 80101b90 +80104bf1: 85 c0 test %eax,%eax +80104bf3: 0f 84 21 01 00 00 je 80104d1a +80104bf9: c7 44 24 04 7b 75 10 movl $0x8010757b,0x4(%esp) +80104c00: 80 +80104c01: 89 1c 24 mov %ebx,(%esp) +80104c04: e8 87 cf ff ff call 80101b90 +80104c09: 85 c0 test %eax,%eax +80104c0b: 0f 84 09 01 00 00 je 80104d1a + if((ip = dirlookup(dp, name, &off)) == 0) +80104c11: 8d 45 c4 lea -0x3c(%ebp),%eax +80104c14: 89 5c 24 04 mov %ebx,0x4(%esp) +80104c18: 89 44 24 08 mov %eax,0x8(%esp) +80104c1c: 89 34 24 mov %esi,(%esp) +80104c1f: e8 9c cf ff ff call 80101bc0 +80104c24: 85 c0 test %eax,%eax +80104c26: 89 c3 mov %eax,%ebx +80104c28: 0f 84 ec 00 00 00 je 80104d1a + ilock(ip); +80104c2e: 89 04 24 mov %eax,(%esp) +80104c31: e8 7a ca ff ff call 801016b0 + if(ip->nlink < 1) +80104c36: 66 83 7b 56 00 cmpw $0x0,0x56(%ebx) +80104c3b: 0f 8e 24 01 00 00 jle 80104d65 + if(ip->type == T_DIR && !isdirempty(ip)){ +80104c41: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) +80104c46: 8d 75 d8 lea -0x28(%ebp),%esi +80104c49: 74 7d je 80104cc8 + memset(&de, 0, sizeof(de)); +80104c4b: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) +80104c52: 00 +80104c53: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +80104c5a: 00 +80104c5b: 89 34 24 mov %esi,(%esp) +80104c5e: e8 1d f6 ff ff call 80104280 + if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) +80104c63: 8b 45 c4 mov -0x3c(%ebp),%eax +80104c66: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) +80104c6d: 00 +80104c6e: 89 74 24 04 mov %esi,0x4(%esp) +80104c72: 89 44 24 08 mov %eax,0x8(%esp) +80104c76: 8b 45 b4 mov -0x4c(%ebp),%eax +80104c79: 89 04 24 mov %eax,(%esp) +80104c7c: e8 df cd ff ff call 80101a60 +80104c81: 83 f8 10 cmp $0x10,%eax +80104c84: 0f 85 cf 00 00 00 jne 80104d59 + if(ip->type == T_DIR){ +80104c8a: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) +80104c8f: 0f 84 a3 00 00 00 je 80104d38 + iunlockput(dp); +80104c95: 8b 45 b4 mov -0x4c(%ebp),%eax +80104c98: 89 04 24 mov %eax,(%esp) +80104c9b: e8 70 cc ff ff call 80101910 + ip->nlink--; +80104ca0: 66 83 6b 56 01 subw $0x1,0x56(%ebx) + iupdate(ip); +80104ca5: 89 1c 24 mov %ebx,(%esp) +80104ca8: e8 43 c9 ff ff call 801015f0 + iunlockput(ip); +80104cad: 89 1c 24 mov %ebx,(%esp) +80104cb0: e8 5b cc ff ff call 80101910 + end_op(); +80104cb5: e8 c6 de ff ff call 80102b80 +} +80104cba: 83 c4 5c add $0x5c,%esp + return 0; +80104cbd: 31 c0 xor %eax,%eax +} +80104cbf: 5b pop %ebx +80104cc0: 5e pop %esi +80104cc1: 5f pop %edi +80104cc2: 5d pop %ebp +80104cc3: c3 ret +80104cc4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + for(off=2*sizeof(de); offsize; off+=sizeof(de)){ +80104cc8: 83 7b 58 20 cmpl $0x20,0x58(%ebx) +80104ccc: 0f 86 79 ff ff ff jbe 80104c4b +80104cd2: bf 20 00 00 00 mov $0x20,%edi +80104cd7: eb 15 jmp 80104cee +80104cd9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80104ce0: 8d 57 10 lea 0x10(%edi),%edx +80104ce3: 3b 53 58 cmp 0x58(%ebx),%edx +80104ce6: 0f 83 5f ff ff ff jae 80104c4b +80104cec: 89 d7 mov %edx,%edi + if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) +80104cee: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) +80104cf5: 00 +80104cf6: 89 7c 24 08 mov %edi,0x8(%esp) +80104cfa: 89 74 24 04 mov %esi,0x4(%esp) +80104cfe: 89 1c 24 mov %ebx,(%esp) +80104d01: e8 5a cc ff ff call 80101960 +80104d06: 83 f8 10 cmp $0x10,%eax +80104d09: 75 42 jne 80104d4d + if(de.inum != 0) +80104d0b: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) +80104d10: 74 ce je 80104ce0 + iunlockput(ip); +80104d12: 89 1c 24 mov %ebx,(%esp) +80104d15: e8 f6 cb ff ff call 80101910 + iunlockput(dp); +80104d1a: 8b 45 b4 mov -0x4c(%ebp),%eax +80104d1d: 89 04 24 mov %eax,(%esp) +80104d20: e8 eb cb ff ff call 80101910 + end_op(); +80104d25: e8 56 de ff ff call 80102b80 +} +80104d2a: 83 c4 5c add $0x5c,%esp + return -1; +80104d2d: b8 ff ff ff ff mov $0xffffffff,%eax +} +80104d32: 5b pop %ebx +80104d33: 5e pop %esi +80104d34: 5f pop %edi +80104d35: 5d pop %ebp +80104d36: c3 ret +80104d37: 90 nop + dp->nlink--; +80104d38: 8b 45 b4 mov -0x4c(%ebp),%eax +80104d3b: 66 83 68 56 01 subw $0x1,0x56(%eax) + iupdate(dp); +80104d40: 89 04 24 mov %eax,(%esp) +80104d43: e8 a8 c8 ff ff call 801015f0 +80104d48: e9 48 ff ff ff jmp 80104c95 + panic("isdirempty: readi"); +80104d4d: c7 04 24 a0 75 10 80 movl $0x801075a0,(%esp) +80104d54: e8 07 b6 ff ff call 80100360 + panic("unlink: writei"); +80104d59: c7 04 24 b2 75 10 80 movl $0x801075b2,(%esp) +80104d60: e8 fb b5 ff ff call 80100360 + panic("unlink: nlink < 1"); +80104d65: c7 04 24 8e 75 10 80 movl $0x8010758e,(%esp) +80104d6c: e8 ef b5 ff ff call 80100360 +80104d71: eb 0d jmp 80104d80 +80104d73: 90 nop +80104d74: 90 nop +80104d75: 90 nop +80104d76: 90 nop +80104d77: 90 nop +80104d78: 90 nop +80104d79: 90 nop +80104d7a: 90 nop +80104d7b: 90 nop +80104d7c: 90 nop +80104d7d: 90 nop +80104d7e: 90 nop +80104d7f: 90 nop + +80104d80 : + +int +sys_open(void) +{ +80104d80: 55 push %ebp +80104d81: 89 e5 mov %esp,%ebp +80104d83: 57 push %edi +80104d84: 56 push %esi +80104d85: 53 push %ebx +80104d86: 83 ec 2c sub $0x2c,%esp + char *path; + int fd, omode; + struct file *f; + struct inode *ip; + + if(argstr(0, &path) < 0 || argint(1, &omode) < 0) +80104d89: 8d 45 e0 lea -0x20(%ebp),%eax +80104d8c: 89 44 24 04 mov %eax,0x4(%esp) +80104d90: c7 04 24 00 00 00 00 movl $0x0,(%esp) +80104d97: e8 44 f8 ff ff call 801045e0 +80104d9c: 85 c0 test %eax,%eax +80104d9e: 0f 88 d1 00 00 00 js 80104e75 +80104da4: 8d 45 e4 lea -0x1c(%ebp),%eax +80104da7: 89 44 24 04 mov %eax,0x4(%esp) +80104dab: c7 04 24 01 00 00 00 movl $0x1,(%esp) +80104db2: e8 99 f7 ff ff call 80104550 +80104db7: 85 c0 test %eax,%eax +80104db9: 0f 88 b6 00 00 00 js 80104e75 + return -1; + + begin_op(); +80104dbf: e8 4c dd ff ff call 80102b10 + + if(omode & O_CREATE){ +80104dc4: f6 45 e5 02 testb $0x2,-0x1b(%ebp) +80104dc8: 0f 85 82 00 00 00 jne 80104e50 + if(ip == 0){ + end_op(); + return -1; + } + } else { + if((ip = namei(path)) == 0){ +80104dce: 8b 45 e0 mov -0x20(%ebp),%eax +80104dd1: 89 04 24 mov %eax,(%esp) +80104dd4: e8 27 d1 ff ff call 80101f00 +80104dd9: 85 c0 test %eax,%eax +80104ddb: 89 c6 mov %eax,%esi +80104ddd: 0f 84 8d 00 00 00 je 80104e70 + end_op(); + return -1; + } + ilock(ip); +80104de3: 89 04 24 mov %eax,(%esp) +80104de6: e8 c5 c8 ff ff call 801016b0 + if(ip->type == T_DIR && omode != O_RDONLY){ +80104deb: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) +80104df0: 0f 84 92 00 00 00 je 80104e88 + end_op(); + return -1; + } + } + + if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ +80104df6: e8 65 bf ff ff call 80100d60 +80104dfb: 85 c0 test %eax,%eax +80104dfd: 89 c3 mov %eax,%ebx +80104dff: 0f 84 93 00 00 00 je 80104e98 +80104e05: e8 86 f8 ff ff call 80104690 +80104e0a: 85 c0 test %eax,%eax +80104e0c: 89 c7 mov %eax,%edi +80104e0e: 0f 88 94 00 00 00 js 80104ea8 + fileclose(f); + iunlockput(ip); + end_op(); + return -1; + } + iunlock(ip); +80104e14: 89 34 24 mov %esi,(%esp) +80104e17: e8 74 c9 ff ff call 80101790 + end_op(); +80104e1c: e8 5f dd ff ff call 80102b80 + + f->type = FD_INODE; +80104e21: c7 03 02 00 00 00 movl $0x2,(%ebx) + f->ip = ip; + f->off = 0; + f->readable = !(omode & O_WRONLY); +80104e27: 8b 45 e4 mov -0x1c(%ebp),%eax + f->ip = ip; +80104e2a: 89 73 10 mov %esi,0x10(%ebx) + f->off = 0; +80104e2d: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) + f->readable = !(omode & O_WRONLY); +80104e34: 89 c2 mov %eax,%edx +80104e36: 83 e2 01 and $0x1,%edx +80104e39: 83 f2 01 xor $0x1,%edx + f->writable = (omode & O_WRONLY) || (omode & O_RDWR); +80104e3c: a8 03 test $0x3,%al + f->readable = !(omode & O_WRONLY); +80104e3e: 88 53 08 mov %dl,0x8(%ebx) + return fd; +80104e41: 89 f8 mov %edi,%eax + f->writable = (omode & O_WRONLY) || (omode & O_RDWR); +80104e43: 0f 95 43 09 setne 0x9(%ebx) +} +80104e47: 83 c4 2c add $0x2c,%esp +80104e4a: 5b pop %ebx +80104e4b: 5e pop %esi +80104e4c: 5f pop %edi +80104e4d: 5d pop %ebp +80104e4e: c3 ret +80104e4f: 90 nop + ip = create(path, T_FILE, 0, 0); +80104e50: 8b 45 e0 mov -0x20(%ebp),%eax +80104e53: 31 c9 xor %ecx,%ecx +80104e55: ba 02 00 00 00 mov $0x2,%edx +80104e5a: c7 04 24 00 00 00 00 movl $0x0,(%esp) +80104e61: e8 6a f8 ff ff call 801046d0 + if(ip == 0){ +80104e66: 85 c0 test %eax,%eax + ip = create(path, T_FILE, 0, 0); +80104e68: 89 c6 mov %eax,%esi + if(ip == 0){ +80104e6a: 75 8a jne 80104df6 +80104e6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + end_op(); +80104e70: e8 0b dd ff ff call 80102b80 +} +80104e75: 83 c4 2c add $0x2c,%esp + return -1; +80104e78: b8 ff ff ff ff mov $0xffffffff,%eax +} +80104e7d: 5b pop %ebx +80104e7e: 5e pop %esi +80104e7f: 5f pop %edi +80104e80: 5d pop %ebp +80104e81: c3 ret +80104e82: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if(ip->type == T_DIR && omode != O_RDONLY){ +80104e88: 8b 45 e4 mov -0x1c(%ebp),%eax +80104e8b: 85 c0 test %eax,%eax +80104e8d: 0f 84 63 ff ff ff je 80104df6 +80104e93: 90 nop +80104e94: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + iunlockput(ip); +80104e98: 89 34 24 mov %esi,(%esp) +80104e9b: e8 70 ca ff ff call 80101910 +80104ea0: eb ce jmp 80104e70 +80104ea2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + fileclose(f); +80104ea8: 89 1c 24 mov %ebx,(%esp) +80104eab: e8 70 bf ff ff call 80100e20 +80104eb0: eb e6 jmp 80104e98 +80104eb2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80104eb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80104ec0 : + +int +sys_mkdir(void) +{ +80104ec0: 55 push %ebp +80104ec1: 89 e5 mov %esp,%ebp +80104ec3: 83 ec 28 sub $0x28,%esp + char *path; + struct inode *ip; + + begin_op(); +80104ec6: e8 45 dc ff ff call 80102b10 + if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){ +80104ecb: 8d 45 f4 lea -0xc(%ebp),%eax +80104ece: 89 44 24 04 mov %eax,0x4(%esp) +80104ed2: c7 04 24 00 00 00 00 movl $0x0,(%esp) +80104ed9: e8 02 f7 ff ff call 801045e0 +80104ede: 85 c0 test %eax,%eax +80104ee0: 78 2e js 80104f10 +80104ee2: 8b 45 f4 mov -0xc(%ebp),%eax +80104ee5: 31 c9 xor %ecx,%ecx +80104ee7: ba 01 00 00 00 mov $0x1,%edx +80104eec: c7 04 24 00 00 00 00 movl $0x0,(%esp) +80104ef3: e8 d8 f7 ff ff call 801046d0 +80104ef8: 85 c0 test %eax,%eax +80104efa: 74 14 je 80104f10 + end_op(); + return -1; + } + iunlockput(ip); +80104efc: 89 04 24 mov %eax,(%esp) +80104eff: e8 0c ca ff ff call 80101910 + end_op(); +80104f04: e8 77 dc ff ff call 80102b80 + return 0; +80104f09: 31 c0 xor %eax,%eax +} +80104f0b: c9 leave +80104f0c: c3 ret +80104f0d: 8d 76 00 lea 0x0(%esi),%esi + end_op(); +80104f10: e8 6b dc ff ff call 80102b80 + return -1; +80104f15: b8 ff ff ff ff mov $0xffffffff,%eax +} +80104f1a: c9 leave +80104f1b: c3 ret +80104f1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80104f20 : + +int +sys_mknod(void) +{ +80104f20: 55 push %ebp +80104f21: 89 e5 mov %esp,%ebp +80104f23: 83 ec 28 sub $0x28,%esp + struct inode *ip; + char *path; + int major, minor; + + begin_op(); +80104f26: e8 e5 db ff ff call 80102b10 + if((argstr(0, &path)) < 0 || +80104f2b: 8d 45 ec lea -0x14(%ebp),%eax +80104f2e: 89 44 24 04 mov %eax,0x4(%esp) +80104f32: c7 04 24 00 00 00 00 movl $0x0,(%esp) +80104f39: e8 a2 f6 ff ff call 801045e0 +80104f3e: 85 c0 test %eax,%eax +80104f40: 78 5e js 80104fa0 + argint(1, &major) < 0 || +80104f42: 8d 45 f0 lea -0x10(%ebp),%eax +80104f45: 89 44 24 04 mov %eax,0x4(%esp) +80104f49: c7 04 24 01 00 00 00 movl $0x1,(%esp) +80104f50: e8 fb f5 ff ff call 80104550 + if((argstr(0, &path)) < 0 || +80104f55: 85 c0 test %eax,%eax +80104f57: 78 47 js 80104fa0 + argint(2, &minor) < 0 || +80104f59: 8d 45 f4 lea -0xc(%ebp),%eax +80104f5c: 89 44 24 04 mov %eax,0x4(%esp) +80104f60: c7 04 24 02 00 00 00 movl $0x2,(%esp) +80104f67: e8 e4 f5 ff ff call 80104550 + argint(1, &major) < 0 || +80104f6c: 85 c0 test %eax,%eax +80104f6e: 78 30 js 80104fa0 + (ip = create(path, T_DEV, major, minor)) == 0){ +80104f70: 0f bf 45 f4 movswl -0xc(%ebp),%eax + argint(2, &minor) < 0 || +80104f74: ba 03 00 00 00 mov $0x3,%edx + (ip = create(path, T_DEV, major, minor)) == 0){ +80104f79: 0f bf 4d f0 movswl -0x10(%ebp),%ecx +80104f7d: 89 04 24 mov %eax,(%esp) + argint(2, &minor) < 0 || +80104f80: 8b 45 ec mov -0x14(%ebp),%eax +80104f83: e8 48 f7 ff ff call 801046d0 +80104f88: 85 c0 test %eax,%eax +80104f8a: 74 14 je 80104fa0 + end_op(); + return -1; + } + iunlockput(ip); +80104f8c: 89 04 24 mov %eax,(%esp) +80104f8f: e8 7c c9 ff ff call 80101910 + end_op(); +80104f94: e8 e7 db ff ff call 80102b80 + return 0; +80104f99: 31 c0 xor %eax,%eax +} +80104f9b: c9 leave +80104f9c: c3 ret +80104f9d: 8d 76 00 lea 0x0(%esi),%esi + end_op(); +80104fa0: e8 db db ff ff call 80102b80 + return -1; +80104fa5: b8 ff ff ff ff mov $0xffffffff,%eax +} +80104faa: c9 leave +80104fab: c3 ret +80104fac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80104fb0 : + +int +sys_chdir(void) +{ +80104fb0: 55 push %ebp +80104fb1: 89 e5 mov %esp,%ebp +80104fb3: 56 push %esi +80104fb4: 53 push %ebx +80104fb5: 83 ec 20 sub $0x20,%esp + char *path; + struct inode *ip; + struct proc *curproc = myproc(); +80104fb8: e8 e3 e6 ff ff call 801036a0 +80104fbd: 89 c6 mov %eax,%esi + + begin_op(); +80104fbf: e8 4c db ff ff call 80102b10 + if(argstr(0, &path) < 0 || (ip = namei(path)) == 0){ +80104fc4: 8d 45 f4 lea -0xc(%ebp),%eax +80104fc7: 89 44 24 04 mov %eax,0x4(%esp) +80104fcb: c7 04 24 00 00 00 00 movl $0x0,(%esp) +80104fd2: e8 09 f6 ff ff call 801045e0 +80104fd7: 85 c0 test %eax,%eax +80104fd9: 78 4a js 80105025 +80104fdb: 8b 45 f4 mov -0xc(%ebp),%eax +80104fde: 89 04 24 mov %eax,(%esp) +80104fe1: e8 1a cf ff ff call 80101f00 +80104fe6: 85 c0 test %eax,%eax +80104fe8: 89 c3 mov %eax,%ebx +80104fea: 74 39 je 80105025 + end_op(); + return -1; + } + ilock(ip); +80104fec: 89 04 24 mov %eax,(%esp) +80104fef: e8 bc c6 ff ff call 801016b0 + if(ip->type != T_DIR){ +80104ff4: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) + iunlockput(ip); +80104ff9: 89 1c 24 mov %ebx,(%esp) + if(ip->type != T_DIR){ +80104ffc: 75 22 jne 80105020 + end_op(); + return -1; + } + iunlock(ip); +80104ffe: e8 8d c7 ff ff call 80101790 + iput(curproc->cwd); +80105003: 8b 46 68 mov 0x68(%esi),%eax +80105006: 89 04 24 mov %eax,(%esp) +80105009: e8 c2 c7 ff ff call 801017d0 + end_op(); +8010500e: e8 6d db ff ff call 80102b80 + curproc->cwd = ip; + return 0; +80105013: 31 c0 xor %eax,%eax + curproc->cwd = ip; +80105015: 89 5e 68 mov %ebx,0x68(%esi) +} +80105018: 83 c4 20 add $0x20,%esp +8010501b: 5b pop %ebx +8010501c: 5e pop %esi +8010501d: 5d pop %ebp +8010501e: c3 ret +8010501f: 90 nop + iunlockput(ip); +80105020: e8 eb c8 ff ff call 80101910 + end_op(); +80105025: e8 56 db ff ff call 80102b80 +} +8010502a: 83 c4 20 add $0x20,%esp + return -1; +8010502d: b8 ff ff ff ff mov $0xffffffff,%eax +} +80105032: 5b pop %ebx +80105033: 5e pop %esi +80105034: 5d pop %ebp +80105035: c3 ret +80105036: 8d 76 00 lea 0x0(%esi),%esi +80105039: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80105040 : + +int +sys_exec(void) +{ +80105040: 55 push %ebp +80105041: 89 e5 mov %esp,%ebp +80105043: 57 push %edi +80105044: 56 push %esi +80105045: 53 push %ebx +80105046: 81 ec ac 00 00 00 sub $0xac,%esp + char *path, *argv[MAXARG]; + int i; + uint uargv, uarg; + + if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ +8010504c: 8d 85 5c ff ff ff lea -0xa4(%ebp),%eax +80105052: 89 44 24 04 mov %eax,0x4(%esp) +80105056: c7 04 24 00 00 00 00 movl $0x0,(%esp) +8010505d: e8 7e f5 ff ff call 801045e0 +80105062: 85 c0 test %eax,%eax +80105064: 0f 88 84 00 00 00 js 801050ee +8010506a: 8d 85 60 ff ff ff lea -0xa0(%ebp),%eax +80105070: 89 44 24 04 mov %eax,0x4(%esp) +80105074: c7 04 24 01 00 00 00 movl $0x1,(%esp) +8010507b: e8 d0 f4 ff ff call 80104550 +80105080: 85 c0 test %eax,%eax +80105082: 78 6a js 801050ee + return -1; + } + memset(argv, 0, sizeof(argv)); +80105084: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax + for(i=0;; i++){ +8010508a: 31 db xor %ebx,%ebx + memset(argv, 0, sizeof(argv)); +8010508c: c7 44 24 08 80 00 00 movl $0x80,0x8(%esp) +80105093: 00 +80105094: 8d b5 68 ff ff ff lea -0x98(%ebp),%esi +8010509a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +801050a1: 00 +801050a2: 8d bd 64 ff ff ff lea -0x9c(%ebp),%edi +801050a8: 89 04 24 mov %eax,(%esp) +801050ab: e8 d0 f1 ff ff call 80104280 + if(i >= NELEM(argv)) + return -1; + if(fetchint(uargv+4*i, (int*)&uarg) < 0) +801050b0: 8b 85 60 ff ff ff mov -0xa0(%ebp),%eax +801050b6: 89 7c 24 04 mov %edi,0x4(%esp) +801050ba: 8d 04 98 lea (%eax,%ebx,4),%eax +801050bd: 89 04 24 mov %eax,(%esp) +801050c0: e8 0b f4 ff ff call 801044d0 +801050c5: 85 c0 test %eax,%eax +801050c7: 78 25 js 801050ee + return -1; + if(uarg == 0){ +801050c9: 8b 85 64 ff ff ff mov -0x9c(%ebp),%eax +801050cf: 85 c0 test %eax,%eax +801050d1: 74 2d je 80105100 + argv[i] = 0; + break; + } + if(fetchstr(uarg, &argv[i]) < 0) +801050d3: 89 74 24 04 mov %esi,0x4(%esp) +801050d7: 89 04 24 mov %eax,(%esp) +801050da: e8 11 f4 ff ff call 801044f0 +801050df: 85 c0 test %eax,%eax +801050e1: 78 0b js 801050ee + for(i=0;; i++){ +801050e3: 83 c3 01 add $0x1,%ebx +801050e6: 83 c6 04 add $0x4,%esi + if(i >= NELEM(argv)) +801050e9: 83 fb 20 cmp $0x20,%ebx +801050ec: 75 c2 jne 801050b0 + return -1; + } + return exec(path, argv); +} +801050ee: 81 c4 ac 00 00 00 add $0xac,%esp + return -1; +801050f4: b8 ff ff ff ff mov $0xffffffff,%eax +} +801050f9: 5b pop %ebx +801050fa: 5e pop %esi +801050fb: 5f pop %edi +801050fc: 5d pop %ebp +801050fd: c3 ret +801050fe: 66 90 xchg %ax,%ax + return exec(path, argv); +80105100: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax +80105106: 89 44 24 04 mov %eax,0x4(%esp) +8010510a: 8b 85 5c ff ff ff mov -0xa4(%ebp),%eax + argv[i] = 0; +80105110: c7 84 9d 68 ff ff ff movl $0x0,-0x98(%ebp,%ebx,4) +80105117: 00 00 00 00 + return exec(path, argv); +8010511b: 89 04 24 mov %eax,(%esp) +8010511e: e8 7d b8 ff ff call 801009a0 +} +80105123: 81 c4 ac 00 00 00 add $0xac,%esp +80105129: 5b pop %ebx +8010512a: 5e pop %esi +8010512b: 5f pop %edi +8010512c: 5d pop %ebp +8010512d: c3 ret +8010512e: 66 90 xchg %ax,%ax + +80105130 : + +int +sys_pipe(void) +{ +80105130: 55 push %ebp +80105131: 89 e5 mov %esp,%ebp +80105133: 53 push %ebx +80105134: 83 ec 24 sub $0x24,%esp + int *fd; + struct file *rf, *wf; + int fd0, fd1; + + if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) +80105137: 8d 45 ec lea -0x14(%ebp),%eax +8010513a: c7 44 24 08 08 00 00 movl $0x8,0x8(%esp) +80105141: 00 +80105142: 89 44 24 04 mov %eax,0x4(%esp) +80105146: c7 04 24 00 00 00 00 movl $0x0,(%esp) +8010514d: e8 3e f4 ff ff call 80104590 +80105152: 85 c0 test %eax,%eax +80105154: 78 6d js 801051c3 + return -1; + if(pipealloc(&rf, &wf) < 0) +80105156: 8d 45 f4 lea -0xc(%ebp),%eax +80105159: 89 44 24 04 mov %eax,0x4(%esp) +8010515d: 8d 45 f0 lea -0x10(%ebp),%eax +80105160: 89 04 24 mov %eax,(%esp) +80105163: e8 08 e0 ff ff call 80103170 +80105168: 85 c0 test %eax,%eax +8010516a: 78 57 js 801051c3 + return -1; + fd0 = -1; + if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ +8010516c: 8b 45 f0 mov -0x10(%ebp),%eax +8010516f: e8 1c f5 ff ff call 80104690 +80105174: 85 c0 test %eax,%eax +80105176: 89 c3 mov %eax,%ebx +80105178: 78 33 js 801051ad +8010517a: 8b 45 f4 mov -0xc(%ebp),%eax +8010517d: e8 0e f5 ff ff call 80104690 +80105182: 85 c0 test %eax,%eax +80105184: 78 1a js 801051a0 + myproc()->ofile[fd0] = 0; + fileclose(rf); + fileclose(wf); + return -1; + } + fd[0] = fd0; +80105186: 8b 55 ec mov -0x14(%ebp),%edx +80105189: 89 1a mov %ebx,(%edx) + fd[1] = fd1; +8010518b: 8b 55 ec mov -0x14(%ebp),%edx +8010518e: 89 42 04 mov %eax,0x4(%edx) + return 0; +80105191: 83 c4 24 add $0x24,%esp + return 0; +80105194: 31 c0 xor %eax,%eax +80105196: 5b pop %ebx +80105197: 5d pop %ebp +80105198: c3 ret +80105199: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + myproc()->ofile[fd0] = 0; +801051a0: e8 fb e4 ff ff call 801036a0 +801051a5: c7 44 98 28 00 00 00 movl $0x0,0x28(%eax,%ebx,4) +801051ac: 00 + fileclose(rf); +801051ad: 8b 45 f0 mov -0x10(%ebp),%eax +801051b0: 89 04 24 mov %eax,(%esp) +801051b3: e8 68 bc ff ff call 80100e20 + fileclose(wf); +801051b8: 8b 45 f4 mov -0xc(%ebp),%eax +801051bb: 89 04 24 mov %eax,(%esp) +801051be: e8 5d bc ff ff call 80100e20 +801051c3: 83 c4 24 add $0x24,%esp + return -1; +801051c6: b8 ff ff ff ff mov $0xffffffff,%eax +801051cb: 5b pop %ebx +801051cc: 5d pop %ebp +801051cd: c3 ret +801051ce: 66 90 xchg %ax,%ax + +801051d0 : +#include "param.h" +#include "memlayout.h" +#include "mmu.h" +#include "proc.h" + +int sys_shm_open(void) { +801051d0: 55 push %ebp +801051d1: 89 e5 mov %esp,%ebp +801051d3: 83 ec 28 sub $0x28,%esp + int id; + char **pointer; + + if(argint(0, &id) < 0) +801051d6: 8d 45 f0 lea -0x10(%ebp),%eax +801051d9: 89 44 24 04 mov %eax,0x4(%esp) +801051dd: c7 04 24 00 00 00 00 movl $0x0,(%esp) +801051e4: e8 67 f3 ff ff call 80104550 +801051e9: 85 c0 test %eax,%eax +801051eb: 78 33 js 80105220 + return -1; + + if(argptr(1, (char **) (&pointer),4)<0) +801051ed: 8d 45 f4 lea -0xc(%ebp),%eax +801051f0: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) +801051f7: 00 +801051f8: 89 44 24 04 mov %eax,0x4(%esp) +801051fc: c7 04 24 01 00 00 00 movl $0x1,(%esp) +80105203: e8 88 f3 ff ff call 80104590 +80105208: 85 c0 test %eax,%eax +8010520a: 78 14 js 80105220 + return -1; + return shm_open(id, pointer); +8010520c: 8b 45 f4 mov -0xc(%ebp),%eax +8010520f: 89 44 24 04 mov %eax,0x4(%esp) +80105213: 8b 45 f0 mov -0x10(%ebp),%eax +80105216: 89 04 24 mov %eax,(%esp) +80105219: e8 e2 1b 00 00 call 80106e00 +} +8010521e: c9 leave +8010521f: c3 ret + return -1; +80105220: b8 ff ff ff ff mov $0xffffffff,%eax +} +80105225: c9 leave +80105226: c3 ret +80105227: 89 f6 mov %esi,%esi +80105229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80105230 : + +int sys_shm_close(void) { +80105230: 55 push %ebp +80105231: 89 e5 mov %esp,%ebp +80105233: 83 ec 28 sub $0x28,%esp + int id; + + if(argint(0, &id) < 0) +80105236: 8d 45 f4 lea -0xc(%ebp),%eax +80105239: 89 44 24 04 mov %eax,0x4(%esp) +8010523d: c7 04 24 00 00 00 00 movl $0x0,(%esp) +80105244: e8 07 f3 ff ff call 80104550 +80105249: 85 c0 test %eax,%eax +8010524b: 78 13 js 80105260 + return -1; + + + return shm_close(id); +8010524d: 8b 45 f4 mov -0xc(%ebp),%eax +80105250: 89 04 24 mov %eax,(%esp) +80105253: e8 b8 1b 00 00 call 80106e10 +} +80105258: c9 leave +80105259: c3 ret +8010525a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return -1; +80105260: b8 ff ff ff ff mov $0xffffffff,%eax +} +80105265: c9 leave +80105266: c3 ret +80105267: 89 f6 mov %esi,%esi +80105269: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80105270 : + +int +sys_fork(void) +{ +80105270: 55 push %ebp +80105271: 89 e5 mov %esp,%ebp + return fork(); +} +80105273: 5d pop %ebp + return fork(); +80105274: e9 d7 e5 ff ff jmp 80103850 +80105279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80105280 : + +int +sys_exit(void) +{ +80105280: 55 push %ebp +80105281: 89 e5 mov %esp,%ebp +80105283: 83 ec 08 sub $0x8,%esp + exit(); +80105286: e8 15 e8 ff ff call 80103aa0 + return 0; // not reached +} +8010528b: 31 c0 xor %eax,%eax +8010528d: c9 leave +8010528e: c3 ret +8010528f: 90 nop + +80105290 : + +int +sys_wait(void) +{ +80105290: 55 push %ebp +80105291: 89 e5 mov %esp,%ebp + return wait(); +} +80105293: 5d pop %ebp + return wait(); +80105294: e9 17 ea ff ff jmp 80103cb0 +80105299: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +801052a0 : + +int +sys_kill(void) +{ +801052a0: 55 push %ebp +801052a1: 89 e5 mov %esp,%ebp +801052a3: 83 ec 28 sub $0x28,%esp + int pid; + + if(argint(0, &pid) < 0) +801052a6: 8d 45 f4 lea -0xc(%ebp),%eax +801052a9: 89 44 24 04 mov %eax,0x4(%esp) +801052ad: c7 04 24 00 00 00 00 movl $0x0,(%esp) +801052b4: e8 97 f2 ff ff call 80104550 +801052b9: 85 c0 test %eax,%eax +801052bb: 78 13 js 801052d0 + return -1; + return kill(pid); +801052bd: 8b 45 f4 mov -0xc(%ebp),%eax +801052c0: 89 04 24 mov %eax,(%esp) +801052c3: e8 28 eb ff ff call 80103df0 +} +801052c8: c9 leave +801052c9: c3 ret +801052ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return -1; +801052d0: b8 ff ff ff ff mov $0xffffffff,%eax +} +801052d5: c9 leave +801052d6: c3 ret +801052d7: 89 f6 mov %esi,%esi +801052d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +801052e0 : + +int +sys_getpid(void) +{ +801052e0: 55 push %ebp +801052e1: 89 e5 mov %esp,%ebp +801052e3: 83 ec 08 sub $0x8,%esp + return myproc()->pid; +801052e6: e8 b5 e3 ff ff call 801036a0 +801052eb: 8b 40 10 mov 0x10(%eax),%eax +} +801052ee: c9 leave +801052ef: c3 ret + +801052f0 : + +int +sys_sbrk(void) +{ +801052f0: 55 push %ebp +801052f1: 89 e5 mov %esp,%ebp +801052f3: 53 push %ebx +801052f4: 83 ec 24 sub $0x24,%esp + int addr; + int n; + + if(argint(0, &n) < 0) +801052f7: 8d 45 f4 lea -0xc(%ebp),%eax +801052fa: 89 44 24 04 mov %eax,0x4(%esp) +801052fe: c7 04 24 00 00 00 00 movl $0x0,(%esp) +80105305: e8 46 f2 ff ff call 80104550 +8010530a: 85 c0 test %eax,%eax +8010530c: 78 22 js 80105330 + return -1; + addr = myproc()->sz; +8010530e: e8 8d e3 ff ff call 801036a0 + if(growproc(n) < 0) +80105313: 8b 55 f4 mov -0xc(%ebp),%edx + addr = myproc()->sz; +80105316: 8b 18 mov (%eax),%ebx + if(growproc(n) < 0) +80105318: 89 14 24 mov %edx,(%esp) +8010531b: e8 c0 e4 ff ff call 801037e0 +80105320: 85 c0 test %eax,%eax +80105322: 78 0c js 80105330 + return -1; + return addr; +80105324: 89 d8 mov %ebx,%eax +} +80105326: 83 c4 24 add $0x24,%esp +80105329: 5b pop %ebx +8010532a: 5d pop %ebp +8010532b: c3 ret +8010532c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; +80105330: b8 ff ff ff ff mov $0xffffffff,%eax +80105335: eb ef jmp 80105326 +80105337: 89 f6 mov %esi,%esi +80105339: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80105340 : + +int +sys_sleep(void) +{ +80105340: 55 push %ebp +80105341: 89 e5 mov %esp,%ebp +80105343: 53 push %ebx +80105344: 83 ec 24 sub $0x24,%esp + int n; + uint ticks0; + + if(argint(0, &n) < 0) +80105347: 8d 45 f4 lea -0xc(%ebp),%eax +8010534a: 89 44 24 04 mov %eax,0x4(%esp) +8010534e: c7 04 24 00 00 00 00 movl $0x0,(%esp) +80105355: e8 f6 f1 ff ff call 80104550 +8010535a: 85 c0 test %eax,%eax +8010535c: 78 7e js 801053dc + return -1; + acquire(&tickslock); +8010535e: c7 04 24 80 4d 11 80 movl $0x80114d80,(%esp) +80105365: e8 d6 ed ff ff call 80104140 + ticks0 = ticks; + while(ticks - ticks0 < n){ +8010536a: 8b 55 f4 mov -0xc(%ebp),%edx + ticks0 = ticks; +8010536d: 8b 1d c0 55 11 80 mov 0x801155c0,%ebx + while(ticks - ticks0 < n){ +80105373: 85 d2 test %edx,%edx +80105375: 75 29 jne 801053a0 +80105377: eb 4f jmp 801053c8 +80105379: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if(myproc()->killed){ + release(&tickslock); + return -1; + } + sleep(&ticks, &tickslock); +80105380: c7 44 24 04 80 4d 11 movl $0x80114d80,0x4(%esp) +80105387: 80 +80105388: c7 04 24 c0 55 11 80 movl $0x801155c0,(%esp) +8010538f: e8 6c e8 ff ff call 80103c00 + while(ticks - ticks0 < n){ +80105394: a1 c0 55 11 80 mov 0x801155c0,%eax +80105399: 29 d8 sub %ebx,%eax +8010539b: 3b 45 f4 cmp -0xc(%ebp),%eax +8010539e: 73 28 jae 801053c8 + if(myproc()->killed){ +801053a0: e8 fb e2 ff ff call 801036a0 +801053a5: 8b 40 24 mov 0x24(%eax),%eax +801053a8: 85 c0 test %eax,%eax +801053aa: 74 d4 je 80105380 + release(&tickslock); +801053ac: c7 04 24 80 4d 11 80 movl $0x80114d80,(%esp) +801053b3: e8 78 ee ff ff call 80104230 + return -1; +801053b8: b8 ff ff ff ff mov $0xffffffff,%eax + } + release(&tickslock); + return 0; +} +801053bd: 83 c4 24 add $0x24,%esp +801053c0: 5b pop %ebx +801053c1: 5d pop %ebp +801053c2: c3 ret +801053c3: 90 nop +801053c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + release(&tickslock); +801053c8: c7 04 24 80 4d 11 80 movl $0x80114d80,(%esp) +801053cf: e8 5c ee ff ff call 80104230 +} +801053d4: 83 c4 24 add $0x24,%esp + return 0; +801053d7: 31 c0 xor %eax,%eax +} +801053d9: 5b pop %ebx +801053da: 5d pop %ebp +801053db: c3 ret + return -1; +801053dc: b8 ff ff ff ff mov $0xffffffff,%eax +801053e1: eb da jmp 801053bd +801053e3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +801053e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +801053f0 : + +// return how many clock tick interrupts have occurred +// since start. +int +sys_uptime(void) +{ +801053f0: 55 push %ebp +801053f1: 89 e5 mov %esp,%ebp +801053f3: 53 push %ebx +801053f4: 83 ec 14 sub $0x14,%esp + uint xticks; + + acquire(&tickslock); +801053f7: c7 04 24 80 4d 11 80 movl $0x80114d80,(%esp) +801053fe: e8 3d ed ff ff call 80104140 + xticks = ticks; +80105403: 8b 1d c0 55 11 80 mov 0x801155c0,%ebx + release(&tickslock); +80105409: c7 04 24 80 4d 11 80 movl $0x80114d80,(%esp) +80105410: e8 1b ee ff ff call 80104230 + return xticks; +} +80105415: 83 c4 14 add $0x14,%esp +80105418: 89 d8 mov %ebx,%eax +8010541a: 5b pop %ebx +8010541b: 5d pop %ebp +8010541c: c3 ret + +8010541d : + + # vectors.S sends all traps here. +.globl alltraps +alltraps: + # Build trap frame. + pushl %ds +8010541d: 1e push %ds + pushl %es +8010541e: 06 push %es + pushl %fs +8010541f: 0f a0 push %fs + pushl %gs +80105421: 0f a8 push %gs + pushal +80105423: 60 pusha + + # Set up data segments. + movw $(SEG_KDATA<<3), %ax +80105424: 66 b8 10 00 mov $0x10,%ax + movw %ax, %ds +80105428: 8e d8 mov %eax,%ds + movw %ax, %es +8010542a: 8e c0 mov %eax,%es + + # Call trap(tf), where tf=%esp + pushl %esp +8010542c: 54 push %esp + call trap +8010542d: e8 de 00 00 00 call 80105510 + addl $4, %esp +80105432: 83 c4 04 add $0x4,%esp + +80105435 : + + # Return falls through to trapret... +.globl trapret +trapret: + popal +80105435: 61 popa + popl %gs +80105436: 0f a9 pop %gs + popl %fs +80105438: 0f a1 pop %fs + popl %es +8010543a: 07 pop %es + popl %ds +8010543b: 1f pop %ds + addl $0x8, %esp # trapno and errcode +8010543c: 83 c4 08 add $0x8,%esp + iret +8010543f: cf iret + +80105440 : +void +tvinit(void) +{ + int i; + + for(i = 0; i < 256; i++) +80105440: 31 c0 xor %eax,%eax +80105442: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); +80105448: 8b 14 85 08 a0 10 80 mov -0x7fef5ff8(,%eax,4),%edx +8010544f: b9 08 00 00 00 mov $0x8,%ecx +80105454: 66 89 0c c5 c2 4d 11 mov %cx,-0x7feeb23e(,%eax,8) +8010545b: 80 +8010545c: c6 04 c5 c4 4d 11 80 movb $0x0,-0x7feeb23c(,%eax,8) +80105463: 00 +80105464: c6 04 c5 c5 4d 11 80 movb $0x8e,-0x7feeb23b(,%eax,8) +8010546b: 8e +8010546c: 66 89 14 c5 c0 4d 11 mov %dx,-0x7feeb240(,%eax,8) +80105473: 80 +80105474: c1 ea 10 shr $0x10,%edx +80105477: 66 89 14 c5 c6 4d 11 mov %dx,-0x7feeb23a(,%eax,8) +8010547e: 80 + for(i = 0; i < 256; i++) +8010547f: 83 c0 01 add $0x1,%eax +80105482: 3d 00 01 00 00 cmp $0x100,%eax +80105487: 75 bf jne 80105448 +{ +80105489: 55 push %ebp + SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); +8010548a: ba 08 00 00 00 mov $0x8,%edx +{ +8010548f: 89 e5 mov %esp,%ebp +80105491: 83 ec 18 sub $0x18,%esp + SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); +80105494: a1 08 a1 10 80 mov 0x8010a108,%eax + + initlock(&tickslock, "time"); +80105499: c7 44 24 04 c1 75 10 movl $0x801075c1,0x4(%esp) +801054a0: 80 +801054a1: c7 04 24 80 4d 11 80 movl $0x80114d80,(%esp) + SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); +801054a8: 66 89 15 c2 4f 11 80 mov %dx,0x80114fc2 +801054af: 66 a3 c0 4f 11 80 mov %ax,0x80114fc0 +801054b5: c1 e8 10 shr $0x10,%eax +801054b8: c6 05 c4 4f 11 80 00 movb $0x0,0x80114fc4 +801054bf: c6 05 c5 4f 11 80 ef movb $0xef,0x80114fc5 +801054c6: 66 a3 c6 4f 11 80 mov %ax,0x80114fc6 + initlock(&tickslock, "time"); +801054cc: e8 7f eb ff ff call 80104050 +} +801054d1: c9 leave +801054d2: c3 ret +801054d3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +801054d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +801054e0 : + +void +idtinit(void) +{ +801054e0: 55 push %ebp + pd[0] = size-1; +801054e1: b8 ff 07 00 00 mov $0x7ff,%eax +801054e6: 89 e5 mov %esp,%ebp +801054e8: 83 ec 10 sub $0x10,%esp +801054eb: 66 89 45 fa mov %ax,-0x6(%ebp) + pd[1] = (uint)p; +801054ef: b8 c0 4d 11 80 mov $0x80114dc0,%eax +801054f4: 66 89 45 fc mov %ax,-0x4(%ebp) + pd[2] = (uint)p >> 16; +801054f8: c1 e8 10 shr $0x10,%eax +801054fb: 66 89 45 fe mov %ax,-0x2(%ebp) + asm volatile("lidt (%0)" : : "r" (pd)); +801054ff: 8d 45 fa lea -0x6(%ebp),%eax +80105502: 0f 01 18 lidtl (%eax) + lidt(idt, sizeof(idt)); +} +80105505: c9 leave +80105506: c3 ret +80105507: 89 f6 mov %esi,%esi +80105509: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80105510 : + +//PAGEBREAK: 41 +void +trap(struct trapframe *tf) +{ +80105510: 55 push %ebp +80105511: 89 e5 mov %esp,%ebp +80105513: 57 push %edi +80105514: 56 push %esi +80105515: 53 push %ebx +80105516: 83 ec 3c sub $0x3c,%esp +80105519: 8b 5d 08 mov 0x8(%ebp),%ebx + if(tf->trapno == T_SYSCALL){ +8010551c: 8b 43 30 mov 0x30(%ebx),%eax +8010551f: 83 f8 40 cmp $0x40,%eax +80105522: 0f 84 00 02 00 00 je 80105728 + if(myproc()->killed) + exit(); + return; + } + + switch(tf->trapno){ +80105528: 83 e8 0e sub $0xe,%eax +8010552b: 83 f8 31 cmp $0x31,%eax +8010552e: 77 08 ja 80105538 +80105530: ff 24 85 90 76 10 80 jmp *-0x7fef8970(,%eax,4) +80105537: 90 nop + cprintf("Page count increased to: %d \n", myproc()->num_pages); + break; + + //PAGEBREAK: 13 + default: + if(myproc() == 0 || (tf->cs&3) == 0){ +80105538: e8 63 e1 ff ff call 801036a0 +8010553d: 85 c0 test %eax,%eax +8010553f: 90 nop +80105540: 0f 84 92 02 00 00 je 801057d8 +80105546: f6 43 3c 03 testb $0x3,0x3c(%ebx) +8010554a: 0f 84 88 02 00 00 je 801057d8 + +static inline uint +rcr2(void) +{ + uint val; + asm volatile("movl %%cr2,%0" : "=r" (val)); +80105550: 0f 20 d1 mov %cr2,%ecx + cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", + tf->trapno, cpuid(), tf->eip, rcr2()); + panic("trap"); + } + // In user space, assume process misbehaved. + cprintf("pid %d %s: trap %d err %d on cpu %d " +80105553: 8b 53 38 mov 0x38(%ebx),%edx +80105556: 89 4d d8 mov %ecx,-0x28(%ebp) +80105559: 89 55 dc mov %edx,-0x24(%ebp) +8010555c: e8 1f e1 ff ff call 80103680 +80105561: 8b 73 30 mov 0x30(%ebx),%esi +80105564: 89 c7 mov %eax,%edi +80105566: 8b 43 34 mov 0x34(%ebx),%eax +80105569: 89 45 e4 mov %eax,-0x1c(%ebp) + "eip 0x%x addr 0x%x--kill proc\n", + myproc()->pid, myproc()->name, tf->trapno, +8010556c: e8 2f e1 ff ff call 801036a0 +80105571: 89 45 e0 mov %eax,-0x20(%ebp) +80105574: e8 27 e1 ff ff call 801036a0 + cprintf("pid %d %s: trap %d err %d on cpu %d " +80105579: 8b 55 dc mov -0x24(%ebp),%edx +8010557c: 89 74 24 0c mov %esi,0xc(%esp) + myproc()->pid, myproc()->name, tf->trapno, +80105580: 8b 75 e0 mov -0x20(%ebp),%esi + cprintf("pid %d %s: trap %d err %d on cpu %d " +80105583: 8b 4d d8 mov -0x28(%ebp),%ecx +80105586: 89 7c 24 14 mov %edi,0x14(%esp) +8010558a: 89 54 24 18 mov %edx,0x18(%esp) +8010558e: 8b 55 e4 mov -0x1c(%ebp),%edx + myproc()->pid, myproc()->name, tf->trapno, +80105591: 83 c6 6c add $0x6c,%esi + cprintf("pid %d %s: trap %d err %d on cpu %d " +80105594: 89 4c 24 1c mov %ecx,0x1c(%esp) + myproc()->pid, myproc()->name, tf->trapno, +80105598: 89 74 24 08 mov %esi,0x8(%esp) + cprintf("pid %d %s: trap %d err %d on cpu %d " +8010559c: 89 54 24 10 mov %edx,0x10(%esp) +801055a0: 8b 40 10 mov 0x10(%eax),%eax +801055a3: c7 04 24 4c 76 10 80 movl $0x8010764c,(%esp) +801055aa: 89 44 24 04 mov %eax,0x4(%esp) +801055ae: e8 9d b0 ff ff call 80100650 + tf->err, cpuid(), tf->eip, rcr2()); + myproc()->killed = 1; +801055b3: e8 e8 e0 ff ff call 801036a0 +801055b8: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) +801055bf: 90 nop + } + + // Force process exit if it has been killed and is in user space. + // (If it is still executing in the kernel, let it keep running + // until it gets to the regular system call return.) + if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) +801055c0: e8 db e0 ff ff call 801036a0 +801055c5: 85 c0 test %eax,%eax +801055c7: 74 0c je 801055d5 +801055c9: e8 d2 e0 ff ff call 801036a0 +801055ce: 8b 50 24 mov 0x24(%eax),%edx +801055d1: 85 d2 test %edx,%edx +801055d3: 75 4b jne 80105620 + exit(); + + // Force process to give up CPU on clock tick. + // If interrupts were on while locks held, would need to check nlock. + if(myproc() && myproc()->state == RUNNING && +801055d5: e8 c6 e0 ff ff call 801036a0 +801055da: 85 c0 test %eax,%eax +801055dc: 74 0d je 801055eb +801055de: 66 90 xchg %ax,%ax +801055e0: e8 bb e0 ff ff call 801036a0 +801055e5: 83 78 08 04 cmpl $0x4,0x8(%eax) +801055e9: 74 4d je 80105638 + tf->trapno == T_IRQ0+IRQ_TIMER) + yield(); + + // Check if the process has been killed since we yielded + if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) +801055eb: e8 b0 e0 ff ff call 801036a0 +801055f0: 85 c0 test %eax,%eax +801055f2: 74 1d je 80105611 +801055f4: e8 a7 e0 ff ff call 801036a0 +801055f9: 8b 40 24 mov 0x24(%eax),%eax +801055fc: 85 c0 test %eax,%eax +801055fe: 74 11 je 80105611 +80105600: 0f b7 43 3c movzwl 0x3c(%ebx),%eax +80105604: 83 e0 03 and $0x3,%eax +80105607: 66 83 f8 03 cmp $0x3,%ax +8010560b: 0f 84 48 01 00 00 je 80105759 + exit(); +} +80105611: 83 c4 3c add $0x3c,%esp +80105614: 5b pop %ebx +80105615: 5e pop %esi +80105616: 5f pop %edi +80105617: 5d pop %ebp +80105618: c3 ret +80105619: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) +80105620: 0f b7 43 3c movzwl 0x3c(%ebx),%eax +80105624: 83 e0 03 and $0x3,%eax +80105627: 66 83 f8 03 cmp $0x3,%ax +8010562b: 75 a8 jne 801055d5 + exit(); +8010562d: e8 6e e4 ff ff call 80103aa0 +80105632: eb a1 jmp 801055d5 +80105634: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(myproc() && myproc()->state == RUNNING && +80105638: 83 7b 30 20 cmpl $0x20,0x30(%ebx) +8010563c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80105640: 75 a9 jne 801055eb + yield(); +80105642: e8 79 e5 ff ff call 80103bc0 +80105647: eb a2 jmp 801055eb +80105649: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80105650: 0f 20 d6 mov %cr2,%esi + if(allocuvm(myproc()->pgdir, KERNBASE - (myproc()->num_pages * PGSIZE * 2), PGROUNDUP(rcr2())) == 0){ +80105653: e8 48 e0 ff ff call 801036a0 +80105658: 81 c6 ff 0f 00 00 add $0xfff,%esi +8010565e: 81 e6 00 f0 ff ff and $0xfffff000,%esi +80105664: 8b 40 7c mov 0x7c(%eax),%eax +80105667: f7 d8 neg %eax +80105669: c1 e0 0d shl $0xd,%eax +8010566c: 8d b8 00 00 00 80 lea -0x80000000(%eax),%edi +80105672: e8 29 e0 ff ff call 801036a0 +80105677: 89 74 24 08 mov %esi,0x8(%esp) +8010567b: 89 7c 24 04 mov %edi,0x4(%esp) +8010567f: 8b 40 04 mov 0x4(%eax),%eax +80105682: 89 04 24 mov %eax,(%esp) +80105685: e8 16 12 00 00 call 801068a0 +8010568a: 85 c0 test %eax,%eax +8010568c: 0f 85 d6 00 00 00 jne 80105768 + cprintf("PAGEFAULT\n"); +80105692: c7 04 24 c6 75 10 80 movl $0x801075c6,(%esp) +80105699: e8 b2 af ff ff call 80100650 + break; +8010569e: e9 1d ff ff ff jmp 801055c0 +801056a3: 90 nop +801056a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(cpuid() == 0){ +801056a8: e8 d3 df ff ff call 80103680 +801056ad: 85 c0 test %eax,%eax +801056af: 90 nop +801056b0: 0f 84 f2 00 00 00 je 801057a8 + lapiceoi(); +801056b6: e8 c5 d0 ff ff call 80102780 +801056bb: 90 nop +801056bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + break; +801056c0: e9 fb fe ff ff jmp 801055c0 +801056c5: 8d 76 00 lea 0x0(%esi),%esi +801056c8: 90 nop +801056c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + kbdintr(); +801056d0: e8 fb ce ff ff call 801025d0 + lapiceoi(); +801056d5: e8 a6 d0 ff ff call 80102780 + break; +801056da: e9 e1 fe ff ff jmp 801055c0 +801056df: 90 nop + uartintr(); +801056e0: e8 4b 02 00 00 call 80105930 + lapiceoi(); +801056e5: e8 96 d0 ff ff call 80102780 + break; +801056ea: e9 d1 fe ff ff jmp 801055c0 +801056ef: 90 nop + cprintf("cpu%d: spurious interrupt at %x:%x\n", +801056f0: 8b 7b 38 mov 0x38(%ebx),%edi +801056f3: 0f b7 73 3c movzwl 0x3c(%ebx),%esi +801056f7: e8 84 df ff ff call 80103680 +801056fc: c7 04 24 f4 75 10 80 movl $0x801075f4,(%esp) +80105703: 89 7c 24 0c mov %edi,0xc(%esp) +80105707: 89 74 24 08 mov %esi,0x8(%esp) +8010570b: 89 44 24 04 mov %eax,0x4(%esp) +8010570f: e8 3c af ff ff call 80100650 + lapiceoi(); +80105714: e8 67 d0 ff ff call 80102780 + break; +80105719: e9 a2 fe ff ff jmp 801055c0 +8010571e: 66 90 xchg %ax,%ax + ideintr(); +80105720: e8 5b c9 ff ff call 80102080 +80105725: eb 8f jmp 801056b6 +80105727: 90 nop +80105728: 90 nop +80105729: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if(myproc()->killed) +80105730: e8 6b df ff ff call 801036a0 +80105735: 8b 70 24 mov 0x24(%eax),%esi +80105738: 85 f6 test %esi,%esi +8010573a: 75 64 jne 801057a0 + myproc()->tf = tf; +8010573c: e8 5f df ff ff call 801036a0 +80105741: 89 58 18 mov %ebx,0x18(%eax) + syscall(); +80105744: e8 d7 ee ff ff call 80104620 + if(myproc()->killed) +80105749: e8 52 df ff ff call 801036a0 +8010574e: 8b 48 24 mov 0x24(%eax),%ecx +80105751: 85 c9 test %ecx,%ecx +80105753: 0f 84 b8 fe ff ff je 80105611 +} +80105759: 83 c4 3c add $0x3c,%esp +8010575c: 5b pop %ebx +8010575d: 5e pop %esi +8010575e: 5f pop %edi +8010575f: 5d pop %ebp + exit(); +80105760: e9 3b e3 ff ff jmp 80103aa0 +80105765: 8d 76 00 lea 0x0(%esi),%esi + myproc()->num_pages = myproc()->num_pages+ 1; +80105768: e8 33 df ff ff call 801036a0 +8010576d: 89 c6 mov %eax,%esi +8010576f: e8 2c df ff ff call 801036a0 +80105774: 8b 40 7c mov 0x7c(%eax),%eax +80105777: 83 c0 01 add $0x1,%eax +8010577a: 89 46 7c mov %eax,0x7c(%esi) + cprintf("Page count increased to: %d \n", myproc()->num_pages); +8010577d: e8 1e df ff ff call 801036a0 +80105782: 8b 40 7c mov 0x7c(%eax),%eax +80105785: c7 04 24 d1 75 10 80 movl $0x801075d1,(%esp) +8010578c: 89 44 24 04 mov %eax,0x4(%esp) +80105790: e8 bb ae ff ff call 80100650 + break; +80105795: e9 26 fe ff ff jmp 801055c0 +8010579a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + exit(); +801057a0: e8 fb e2 ff ff call 80103aa0 +801057a5: eb 95 jmp 8010573c +801057a7: 90 nop + acquire(&tickslock); +801057a8: c7 04 24 80 4d 11 80 movl $0x80114d80,(%esp) +801057af: e8 8c e9 ff ff call 80104140 + wakeup(&ticks); +801057b4: c7 04 24 c0 55 11 80 movl $0x801155c0,(%esp) + ticks++; +801057bb: 83 05 c0 55 11 80 01 addl $0x1,0x801155c0 + wakeup(&ticks); +801057c2: e8 c9 e5 ff ff call 80103d90 + release(&tickslock); +801057c7: c7 04 24 80 4d 11 80 movl $0x80114d80,(%esp) +801057ce: e8 5d ea ff ff call 80104230 +801057d3: e9 de fe ff ff jmp 801056b6 +801057d8: 0f 20 d7 mov %cr2,%edi + cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", +801057db: 8b 73 38 mov 0x38(%ebx),%esi +801057de: e8 9d de ff ff call 80103680 +801057e3: 89 7c 24 10 mov %edi,0x10(%esp) +801057e7: 89 74 24 0c mov %esi,0xc(%esp) +801057eb: 89 44 24 08 mov %eax,0x8(%esp) +801057ef: 8b 43 30 mov 0x30(%ebx),%eax +801057f2: c7 04 24 18 76 10 80 movl $0x80107618,(%esp) +801057f9: 89 44 24 04 mov %eax,0x4(%esp) +801057fd: e8 4e ae ff ff call 80100650 + panic("trap"); +80105802: c7 04 24 ef 75 10 80 movl $0x801075ef,(%esp) +80105809: e8 52 ab ff ff call 80100360 +8010580e: 66 90 xchg %ax,%ax + +80105810 : +} + +static int +uartgetc(void) +{ + if(!uart) +80105810: a1 bc a5 10 80 mov 0x8010a5bc,%eax +{ +80105815: 55 push %ebp +80105816: 89 e5 mov %esp,%ebp + if(!uart) +80105818: 85 c0 test %eax,%eax +8010581a: 74 14 je 80105830 + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +8010581c: ba fd 03 00 00 mov $0x3fd,%edx +80105821: ec in (%dx),%al + return -1; + if(!(inb(COM1+5) & 0x01)) +80105822: a8 01 test $0x1,%al +80105824: 74 0a je 80105830 +80105826: b2 f8 mov $0xf8,%dl +80105828: ec in (%dx),%al + return -1; + return inb(COM1+0); +80105829: 0f b6 c0 movzbl %al,%eax +} +8010582c: 5d pop %ebp +8010582d: c3 ret +8010582e: 66 90 xchg %ax,%ax + return -1; +80105830: b8 ff ff ff ff mov $0xffffffff,%eax +} +80105835: 5d pop %ebp +80105836: c3 ret +80105837: 89 f6 mov %esi,%esi +80105839: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80105840 : + if(!uart) +80105840: a1 bc a5 10 80 mov 0x8010a5bc,%eax +80105845: 85 c0 test %eax,%eax +80105847: 74 3f je 80105888 +{ +80105849: 55 push %ebp +8010584a: 89 e5 mov %esp,%ebp +8010584c: 56 push %esi +8010584d: be fd 03 00 00 mov $0x3fd,%esi +80105852: 53 push %ebx + if(!uart) +80105853: bb 80 00 00 00 mov $0x80,%ebx +{ +80105858: 83 ec 10 sub $0x10,%esp +8010585b: eb 14 jmp 80105871 +8010585d: 8d 76 00 lea 0x0(%esi),%esi + microdelay(10); +80105860: c7 04 24 0a 00 00 00 movl $0xa,(%esp) +80105867: e8 34 cf ff ff call 801027a0 + for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) +8010586c: 83 eb 01 sub $0x1,%ebx +8010586f: 74 07 je 80105878 +80105871: 89 f2 mov %esi,%edx +80105873: ec in (%dx),%al +80105874: a8 20 test $0x20,%al +80105876: 74 e8 je 80105860 + outb(COM1+0, c); +80105878: 0f b6 45 08 movzbl 0x8(%ebp),%eax + asm volatile("out %0,%1" : : "a" (data), "d" (port)); +8010587c: ba f8 03 00 00 mov $0x3f8,%edx +80105881: ee out %al,(%dx) +} +80105882: 83 c4 10 add $0x10,%esp +80105885: 5b pop %ebx +80105886: 5e pop %esi +80105887: 5d pop %ebp +80105888: f3 c3 repz ret +8010588a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80105890 : +{ +80105890: 55 push %ebp +80105891: 31 c9 xor %ecx,%ecx +80105893: 89 e5 mov %esp,%ebp +80105895: 89 c8 mov %ecx,%eax +80105897: 57 push %edi +80105898: bf fa 03 00 00 mov $0x3fa,%edi +8010589d: 56 push %esi +8010589e: 89 fa mov %edi,%edx +801058a0: 53 push %ebx +801058a1: 83 ec 1c sub $0x1c,%esp +801058a4: ee out %al,(%dx) +801058a5: be fb 03 00 00 mov $0x3fb,%esi +801058aa: b8 80 ff ff ff mov $0xffffff80,%eax +801058af: 89 f2 mov %esi,%edx +801058b1: ee out %al,(%dx) +801058b2: b8 0c 00 00 00 mov $0xc,%eax +801058b7: b2 f8 mov $0xf8,%dl +801058b9: ee out %al,(%dx) +801058ba: bb f9 03 00 00 mov $0x3f9,%ebx +801058bf: 89 c8 mov %ecx,%eax +801058c1: 89 da mov %ebx,%edx +801058c3: ee out %al,(%dx) +801058c4: b8 03 00 00 00 mov $0x3,%eax +801058c9: 89 f2 mov %esi,%edx +801058cb: ee out %al,(%dx) +801058cc: b2 fc mov $0xfc,%dl +801058ce: 89 c8 mov %ecx,%eax +801058d0: ee out %al,(%dx) +801058d1: b8 01 00 00 00 mov $0x1,%eax +801058d6: 89 da mov %ebx,%edx +801058d8: ee out %al,(%dx) + asm volatile("in %1,%0" : "=a" (data) : "d" (port)); +801058d9: b2 fd mov $0xfd,%dl +801058db: ec in (%dx),%al + if(inb(COM1+5) == 0xFF) +801058dc: 3c ff cmp $0xff,%al +801058de: 74 42 je 80105922 + uart = 1; +801058e0: c7 05 bc a5 10 80 01 movl $0x1,0x8010a5bc +801058e7: 00 00 00 +801058ea: 89 fa mov %edi,%edx +801058ec: ec in (%dx),%al +801058ed: b2 f8 mov $0xf8,%dl +801058ef: ec in (%dx),%al + ioapicenable(IRQ_COM1, 0); +801058f0: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +801058f7: 00 + for(p="xv6...\n"; *p; p++) +801058f8: bb 58 77 10 80 mov $0x80107758,%ebx + ioapicenable(IRQ_COM1, 0); +801058fd: c7 04 24 04 00 00 00 movl $0x4,(%esp) +80105904: e8 a7 c9 ff ff call 801022b0 + for(p="xv6...\n"; *p; p++) +80105909: b8 78 00 00 00 mov $0x78,%eax +8010590e: 66 90 xchg %ax,%ax + uartputc(*p); +80105910: 89 04 24 mov %eax,(%esp) + for(p="xv6...\n"; *p; p++) +80105913: 83 c3 01 add $0x1,%ebx + uartputc(*p); +80105916: e8 25 ff ff ff call 80105840 + for(p="xv6...\n"; *p; p++) +8010591b: 0f be 03 movsbl (%ebx),%eax +8010591e: 84 c0 test %al,%al +80105920: 75 ee jne 80105910 +} +80105922: 83 c4 1c add $0x1c,%esp +80105925: 5b pop %ebx +80105926: 5e pop %esi +80105927: 5f pop %edi +80105928: 5d pop %ebp +80105929: c3 ret +8010592a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80105930 : + +void +uartintr(void) +{ +80105930: 55 push %ebp +80105931: 89 e5 mov %esp,%ebp +80105933: 83 ec 18 sub $0x18,%esp + consoleintr(uartgetc); +80105936: c7 04 24 10 58 10 80 movl $0x80105810,(%esp) +8010593d: e8 6e ae ff ff call 801007b0 +} +80105942: c9 leave +80105943: c3 ret + +80105944 : +# generated by vectors.pl - do not edit +# handlers +.globl alltraps +.globl vector0 +vector0: + pushl $0 +80105944: 6a 00 push $0x0 + pushl $0 +80105946: 6a 00 push $0x0 + jmp alltraps +80105948: e9 d0 fa ff ff jmp 8010541d + +8010594d : +.globl vector1 +vector1: + pushl $0 +8010594d: 6a 00 push $0x0 + pushl $1 +8010594f: 6a 01 push $0x1 + jmp alltraps +80105951: e9 c7 fa ff ff jmp 8010541d + +80105956 : +.globl vector2 +vector2: + pushl $0 +80105956: 6a 00 push $0x0 + pushl $2 +80105958: 6a 02 push $0x2 + jmp alltraps +8010595a: e9 be fa ff ff jmp 8010541d + +8010595f : +.globl vector3 +vector3: + pushl $0 +8010595f: 6a 00 push $0x0 + pushl $3 +80105961: 6a 03 push $0x3 + jmp alltraps +80105963: e9 b5 fa ff ff jmp 8010541d + +80105968 : +.globl vector4 +vector4: + pushl $0 +80105968: 6a 00 push $0x0 + pushl $4 +8010596a: 6a 04 push $0x4 + jmp alltraps +8010596c: e9 ac fa ff ff jmp 8010541d + +80105971 : +.globl vector5 +vector5: + pushl $0 +80105971: 6a 00 push $0x0 + pushl $5 +80105973: 6a 05 push $0x5 + jmp alltraps +80105975: e9 a3 fa ff ff jmp 8010541d + +8010597a : +.globl vector6 +vector6: + pushl $0 +8010597a: 6a 00 push $0x0 + pushl $6 +8010597c: 6a 06 push $0x6 + jmp alltraps +8010597e: e9 9a fa ff ff jmp 8010541d + +80105983 : +.globl vector7 +vector7: + pushl $0 +80105983: 6a 00 push $0x0 + pushl $7 +80105985: 6a 07 push $0x7 + jmp alltraps +80105987: e9 91 fa ff ff jmp 8010541d + +8010598c : +.globl vector8 +vector8: + pushl $8 +8010598c: 6a 08 push $0x8 + jmp alltraps +8010598e: e9 8a fa ff ff jmp 8010541d + +80105993 : +.globl vector9 +vector9: + pushl $0 +80105993: 6a 00 push $0x0 + pushl $9 +80105995: 6a 09 push $0x9 + jmp alltraps +80105997: e9 81 fa ff ff jmp 8010541d + +8010599c : +.globl vector10 +vector10: + pushl $10 +8010599c: 6a 0a push $0xa + jmp alltraps +8010599e: e9 7a fa ff ff jmp 8010541d + +801059a3 : +.globl vector11 +vector11: + pushl $11 +801059a3: 6a 0b push $0xb + jmp alltraps +801059a5: e9 73 fa ff ff jmp 8010541d + +801059aa : +.globl vector12 +vector12: + pushl $12 +801059aa: 6a 0c push $0xc + jmp alltraps +801059ac: e9 6c fa ff ff jmp 8010541d + +801059b1 : +.globl vector13 +vector13: + pushl $13 +801059b1: 6a 0d push $0xd + jmp alltraps +801059b3: e9 65 fa ff ff jmp 8010541d + +801059b8 : +.globl vector14 +vector14: + pushl $14 +801059b8: 6a 0e push $0xe + jmp alltraps +801059ba: e9 5e fa ff ff jmp 8010541d + +801059bf : +.globl vector15 +vector15: + pushl $0 +801059bf: 6a 00 push $0x0 + pushl $15 +801059c1: 6a 0f push $0xf + jmp alltraps +801059c3: e9 55 fa ff ff jmp 8010541d + +801059c8 : +.globl vector16 +vector16: + pushl $0 +801059c8: 6a 00 push $0x0 + pushl $16 +801059ca: 6a 10 push $0x10 + jmp alltraps +801059cc: e9 4c fa ff ff jmp 8010541d + +801059d1 : +.globl vector17 +vector17: + pushl $17 +801059d1: 6a 11 push $0x11 + jmp alltraps +801059d3: e9 45 fa ff ff jmp 8010541d + +801059d8 : +.globl vector18 +vector18: + pushl $0 +801059d8: 6a 00 push $0x0 + pushl $18 +801059da: 6a 12 push $0x12 + jmp alltraps +801059dc: e9 3c fa ff ff jmp 8010541d + +801059e1 : +.globl vector19 +vector19: + pushl $0 +801059e1: 6a 00 push $0x0 + pushl $19 +801059e3: 6a 13 push $0x13 + jmp alltraps +801059e5: e9 33 fa ff ff jmp 8010541d + +801059ea : +.globl vector20 +vector20: + pushl $0 +801059ea: 6a 00 push $0x0 + pushl $20 +801059ec: 6a 14 push $0x14 + jmp alltraps +801059ee: e9 2a fa ff ff jmp 8010541d + +801059f3 : +.globl vector21 +vector21: + pushl $0 +801059f3: 6a 00 push $0x0 + pushl $21 +801059f5: 6a 15 push $0x15 + jmp alltraps +801059f7: e9 21 fa ff ff jmp 8010541d + +801059fc : +.globl vector22 +vector22: + pushl $0 +801059fc: 6a 00 push $0x0 + pushl $22 +801059fe: 6a 16 push $0x16 + jmp alltraps +80105a00: e9 18 fa ff ff jmp 8010541d + +80105a05 : +.globl vector23 +vector23: + pushl $0 +80105a05: 6a 00 push $0x0 + pushl $23 +80105a07: 6a 17 push $0x17 + jmp alltraps +80105a09: e9 0f fa ff ff jmp 8010541d + +80105a0e : +.globl vector24 +vector24: + pushl $0 +80105a0e: 6a 00 push $0x0 + pushl $24 +80105a10: 6a 18 push $0x18 + jmp alltraps +80105a12: e9 06 fa ff ff jmp 8010541d + +80105a17 : +.globl vector25 +vector25: + pushl $0 +80105a17: 6a 00 push $0x0 + pushl $25 +80105a19: 6a 19 push $0x19 + jmp alltraps +80105a1b: e9 fd f9 ff ff jmp 8010541d + +80105a20 : +.globl vector26 +vector26: + pushl $0 +80105a20: 6a 00 push $0x0 + pushl $26 +80105a22: 6a 1a push $0x1a + jmp alltraps +80105a24: e9 f4 f9 ff ff jmp 8010541d + +80105a29 : +.globl vector27 +vector27: + pushl $0 +80105a29: 6a 00 push $0x0 + pushl $27 +80105a2b: 6a 1b push $0x1b + jmp alltraps +80105a2d: e9 eb f9 ff ff jmp 8010541d + +80105a32 : +.globl vector28 +vector28: + pushl $0 +80105a32: 6a 00 push $0x0 + pushl $28 +80105a34: 6a 1c push $0x1c + jmp alltraps +80105a36: e9 e2 f9 ff ff jmp 8010541d + +80105a3b : +.globl vector29 +vector29: + pushl $0 +80105a3b: 6a 00 push $0x0 + pushl $29 +80105a3d: 6a 1d push $0x1d + jmp alltraps +80105a3f: e9 d9 f9 ff ff jmp 8010541d + +80105a44 : +.globl vector30 +vector30: + pushl $0 +80105a44: 6a 00 push $0x0 + pushl $30 +80105a46: 6a 1e push $0x1e + jmp alltraps +80105a48: e9 d0 f9 ff ff jmp 8010541d + +80105a4d : +.globl vector31 +vector31: + pushl $0 +80105a4d: 6a 00 push $0x0 + pushl $31 +80105a4f: 6a 1f push $0x1f + jmp alltraps +80105a51: e9 c7 f9 ff ff jmp 8010541d + +80105a56 : +.globl vector32 +vector32: + pushl $0 +80105a56: 6a 00 push $0x0 + pushl $32 +80105a58: 6a 20 push $0x20 + jmp alltraps +80105a5a: e9 be f9 ff ff jmp 8010541d + +80105a5f : +.globl vector33 +vector33: + pushl $0 +80105a5f: 6a 00 push $0x0 + pushl $33 +80105a61: 6a 21 push $0x21 + jmp alltraps +80105a63: e9 b5 f9 ff ff jmp 8010541d + +80105a68 : +.globl vector34 +vector34: + pushl $0 +80105a68: 6a 00 push $0x0 + pushl $34 +80105a6a: 6a 22 push $0x22 + jmp alltraps +80105a6c: e9 ac f9 ff ff jmp 8010541d + +80105a71 : +.globl vector35 +vector35: + pushl $0 +80105a71: 6a 00 push $0x0 + pushl $35 +80105a73: 6a 23 push $0x23 + jmp alltraps +80105a75: e9 a3 f9 ff ff jmp 8010541d + +80105a7a : +.globl vector36 +vector36: + pushl $0 +80105a7a: 6a 00 push $0x0 + pushl $36 +80105a7c: 6a 24 push $0x24 + jmp alltraps +80105a7e: e9 9a f9 ff ff jmp 8010541d + +80105a83 : +.globl vector37 +vector37: + pushl $0 +80105a83: 6a 00 push $0x0 + pushl $37 +80105a85: 6a 25 push $0x25 + jmp alltraps +80105a87: e9 91 f9 ff ff jmp 8010541d + +80105a8c : +.globl vector38 +vector38: + pushl $0 +80105a8c: 6a 00 push $0x0 + pushl $38 +80105a8e: 6a 26 push $0x26 + jmp alltraps +80105a90: e9 88 f9 ff ff jmp 8010541d + +80105a95 : +.globl vector39 +vector39: + pushl $0 +80105a95: 6a 00 push $0x0 + pushl $39 +80105a97: 6a 27 push $0x27 + jmp alltraps +80105a99: e9 7f f9 ff ff jmp 8010541d + +80105a9e : +.globl vector40 +vector40: + pushl $0 +80105a9e: 6a 00 push $0x0 + pushl $40 +80105aa0: 6a 28 push $0x28 + jmp alltraps +80105aa2: e9 76 f9 ff ff jmp 8010541d + +80105aa7 : +.globl vector41 +vector41: + pushl $0 +80105aa7: 6a 00 push $0x0 + pushl $41 +80105aa9: 6a 29 push $0x29 + jmp alltraps +80105aab: e9 6d f9 ff ff jmp 8010541d + +80105ab0 : +.globl vector42 +vector42: + pushl $0 +80105ab0: 6a 00 push $0x0 + pushl $42 +80105ab2: 6a 2a push $0x2a + jmp alltraps +80105ab4: e9 64 f9 ff ff jmp 8010541d + +80105ab9 : +.globl vector43 +vector43: + pushl $0 +80105ab9: 6a 00 push $0x0 + pushl $43 +80105abb: 6a 2b push $0x2b + jmp alltraps +80105abd: e9 5b f9 ff ff jmp 8010541d + +80105ac2 : +.globl vector44 +vector44: + pushl $0 +80105ac2: 6a 00 push $0x0 + pushl $44 +80105ac4: 6a 2c push $0x2c + jmp alltraps +80105ac6: e9 52 f9 ff ff jmp 8010541d + +80105acb : +.globl vector45 +vector45: + pushl $0 +80105acb: 6a 00 push $0x0 + pushl $45 +80105acd: 6a 2d push $0x2d + jmp alltraps +80105acf: e9 49 f9 ff ff jmp 8010541d + +80105ad4 : +.globl vector46 +vector46: + pushl $0 +80105ad4: 6a 00 push $0x0 + pushl $46 +80105ad6: 6a 2e push $0x2e + jmp alltraps +80105ad8: e9 40 f9 ff ff jmp 8010541d + +80105add : +.globl vector47 +vector47: + pushl $0 +80105add: 6a 00 push $0x0 + pushl $47 +80105adf: 6a 2f push $0x2f + jmp alltraps +80105ae1: e9 37 f9 ff ff jmp 8010541d + +80105ae6 : +.globl vector48 +vector48: + pushl $0 +80105ae6: 6a 00 push $0x0 + pushl $48 +80105ae8: 6a 30 push $0x30 + jmp alltraps +80105aea: e9 2e f9 ff ff jmp 8010541d + +80105aef : +.globl vector49 +vector49: + pushl $0 +80105aef: 6a 00 push $0x0 + pushl $49 +80105af1: 6a 31 push $0x31 + jmp alltraps +80105af3: e9 25 f9 ff ff jmp 8010541d + +80105af8 : +.globl vector50 +vector50: + pushl $0 +80105af8: 6a 00 push $0x0 + pushl $50 +80105afa: 6a 32 push $0x32 + jmp alltraps +80105afc: e9 1c f9 ff ff jmp 8010541d + +80105b01 : +.globl vector51 +vector51: + pushl $0 +80105b01: 6a 00 push $0x0 + pushl $51 +80105b03: 6a 33 push $0x33 + jmp alltraps +80105b05: e9 13 f9 ff ff jmp 8010541d + +80105b0a : +.globl vector52 +vector52: + pushl $0 +80105b0a: 6a 00 push $0x0 + pushl $52 +80105b0c: 6a 34 push $0x34 + jmp alltraps +80105b0e: e9 0a f9 ff ff jmp 8010541d + +80105b13 : +.globl vector53 +vector53: + pushl $0 +80105b13: 6a 00 push $0x0 + pushl $53 +80105b15: 6a 35 push $0x35 + jmp alltraps +80105b17: e9 01 f9 ff ff jmp 8010541d + +80105b1c : +.globl vector54 +vector54: + pushl $0 +80105b1c: 6a 00 push $0x0 + pushl $54 +80105b1e: 6a 36 push $0x36 + jmp alltraps +80105b20: e9 f8 f8 ff ff jmp 8010541d + +80105b25 : +.globl vector55 +vector55: + pushl $0 +80105b25: 6a 00 push $0x0 + pushl $55 +80105b27: 6a 37 push $0x37 + jmp alltraps +80105b29: e9 ef f8 ff ff jmp 8010541d + +80105b2e : +.globl vector56 +vector56: + pushl $0 +80105b2e: 6a 00 push $0x0 + pushl $56 +80105b30: 6a 38 push $0x38 + jmp alltraps +80105b32: e9 e6 f8 ff ff jmp 8010541d + +80105b37 : +.globl vector57 +vector57: + pushl $0 +80105b37: 6a 00 push $0x0 + pushl $57 +80105b39: 6a 39 push $0x39 + jmp alltraps +80105b3b: e9 dd f8 ff ff jmp 8010541d + +80105b40 : +.globl vector58 +vector58: + pushl $0 +80105b40: 6a 00 push $0x0 + pushl $58 +80105b42: 6a 3a push $0x3a + jmp alltraps +80105b44: e9 d4 f8 ff ff jmp 8010541d + +80105b49 : +.globl vector59 +vector59: + pushl $0 +80105b49: 6a 00 push $0x0 + pushl $59 +80105b4b: 6a 3b push $0x3b + jmp alltraps +80105b4d: e9 cb f8 ff ff jmp 8010541d + +80105b52 : +.globl vector60 +vector60: + pushl $0 +80105b52: 6a 00 push $0x0 + pushl $60 +80105b54: 6a 3c push $0x3c + jmp alltraps +80105b56: e9 c2 f8 ff ff jmp 8010541d + +80105b5b : +.globl vector61 +vector61: + pushl $0 +80105b5b: 6a 00 push $0x0 + pushl $61 +80105b5d: 6a 3d push $0x3d + jmp alltraps +80105b5f: e9 b9 f8 ff ff jmp 8010541d + +80105b64 : +.globl vector62 +vector62: + pushl $0 +80105b64: 6a 00 push $0x0 + pushl $62 +80105b66: 6a 3e push $0x3e + jmp alltraps +80105b68: e9 b0 f8 ff ff jmp 8010541d + +80105b6d : +.globl vector63 +vector63: + pushl $0 +80105b6d: 6a 00 push $0x0 + pushl $63 +80105b6f: 6a 3f push $0x3f + jmp alltraps +80105b71: e9 a7 f8 ff ff jmp 8010541d + +80105b76 : +.globl vector64 +vector64: + pushl $0 +80105b76: 6a 00 push $0x0 + pushl $64 +80105b78: 6a 40 push $0x40 + jmp alltraps +80105b7a: e9 9e f8 ff ff jmp 8010541d + +80105b7f : +.globl vector65 +vector65: + pushl $0 +80105b7f: 6a 00 push $0x0 + pushl $65 +80105b81: 6a 41 push $0x41 + jmp alltraps +80105b83: e9 95 f8 ff ff jmp 8010541d + +80105b88 : +.globl vector66 +vector66: + pushl $0 +80105b88: 6a 00 push $0x0 + pushl $66 +80105b8a: 6a 42 push $0x42 + jmp alltraps +80105b8c: e9 8c f8 ff ff jmp 8010541d + +80105b91 : +.globl vector67 +vector67: + pushl $0 +80105b91: 6a 00 push $0x0 + pushl $67 +80105b93: 6a 43 push $0x43 + jmp alltraps +80105b95: e9 83 f8 ff ff jmp 8010541d + +80105b9a : +.globl vector68 +vector68: + pushl $0 +80105b9a: 6a 00 push $0x0 + pushl $68 +80105b9c: 6a 44 push $0x44 + jmp alltraps +80105b9e: e9 7a f8 ff ff jmp 8010541d + +80105ba3 : +.globl vector69 +vector69: + pushl $0 +80105ba3: 6a 00 push $0x0 + pushl $69 +80105ba5: 6a 45 push $0x45 + jmp alltraps +80105ba7: e9 71 f8 ff ff jmp 8010541d + +80105bac : +.globl vector70 +vector70: + pushl $0 +80105bac: 6a 00 push $0x0 + pushl $70 +80105bae: 6a 46 push $0x46 + jmp alltraps +80105bb0: e9 68 f8 ff ff jmp 8010541d + +80105bb5 : +.globl vector71 +vector71: + pushl $0 +80105bb5: 6a 00 push $0x0 + pushl $71 +80105bb7: 6a 47 push $0x47 + jmp alltraps +80105bb9: e9 5f f8 ff ff jmp 8010541d + +80105bbe : +.globl vector72 +vector72: + pushl $0 +80105bbe: 6a 00 push $0x0 + pushl $72 +80105bc0: 6a 48 push $0x48 + jmp alltraps +80105bc2: e9 56 f8 ff ff jmp 8010541d + +80105bc7 : +.globl vector73 +vector73: + pushl $0 +80105bc7: 6a 00 push $0x0 + pushl $73 +80105bc9: 6a 49 push $0x49 + jmp alltraps +80105bcb: e9 4d f8 ff ff jmp 8010541d + +80105bd0 : +.globl vector74 +vector74: + pushl $0 +80105bd0: 6a 00 push $0x0 + pushl $74 +80105bd2: 6a 4a push $0x4a + jmp alltraps +80105bd4: e9 44 f8 ff ff jmp 8010541d + +80105bd9 : +.globl vector75 +vector75: + pushl $0 +80105bd9: 6a 00 push $0x0 + pushl $75 +80105bdb: 6a 4b push $0x4b + jmp alltraps +80105bdd: e9 3b f8 ff ff jmp 8010541d + +80105be2 : +.globl vector76 +vector76: + pushl $0 +80105be2: 6a 00 push $0x0 + pushl $76 +80105be4: 6a 4c push $0x4c + jmp alltraps +80105be6: e9 32 f8 ff ff jmp 8010541d + +80105beb : +.globl vector77 +vector77: + pushl $0 +80105beb: 6a 00 push $0x0 + pushl $77 +80105bed: 6a 4d push $0x4d + jmp alltraps +80105bef: e9 29 f8 ff ff jmp 8010541d + +80105bf4 : +.globl vector78 +vector78: + pushl $0 +80105bf4: 6a 00 push $0x0 + pushl $78 +80105bf6: 6a 4e push $0x4e + jmp alltraps +80105bf8: e9 20 f8 ff ff jmp 8010541d + +80105bfd : +.globl vector79 +vector79: + pushl $0 +80105bfd: 6a 00 push $0x0 + pushl $79 +80105bff: 6a 4f push $0x4f + jmp alltraps +80105c01: e9 17 f8 ff ff jmp 8010541d + +80105c06 : +.globl vector80 +vector80: + pushl $0 +80105c06: 6a 00 push $0x0 + pushl $80 +80105c08: 6a 50 push $0x50 + jmp alltraps +80105c0a: e9 0e f8 ff ff jmp 8010541d + +80105c0f : +.globl vector81 +vector81: + pushl $0 +80105c0f: 6a 00 push $0x0 + pushl $81 +80105c11: 6a 51 push $0x51 + jmp alltraps +80105c13: e9 05 f8 ff ff jmp 8010541d + +80105c18 : +.globl vector82 +vector82: + pushl $0 +80105c18: 6a 00 push $0x0 + pushl $82 +80105c1a: 6a 52 push $0x52 + jmp alltraps +80105c1c: e9 fc f7 ff ff jmp 8010541d + +80105c21 : +.globl vector83 +vector83: + pushl $0 +80105c21: 6a 00 push $0x0 + pushl $83 +80105c23: 6a 53 push $0x53 + jmp alltraps +80105c25: e9 f3 f7 ff ff jmp 8010541d + +80105c2a : +.globl vector84 +vector84: + pushl $0 +80105c2a: 6a 00 push $0x0 + pushl $84 +80105c2c: 6a 54 push $0x54 + jmp alltraps +80105c2e: e9 ea f7 ff ff jmp 8010541d + +80105c33 : +.globl vector85 +vector85: + pushl $0 +80105c33: 6a 00 push $0x0 + pushl $85 +80105c35: 6a 55 push $0x55 + jmp alltraps +80105c37: e9 e1 f7 ff ff jmp 8010541d + +80105c3c : +.globl vector86 +vector86: + pushl $0 +80105c3c: 6a 00 push $0x0 + pushl $86 +80105c3e: 6a 56 push $0x56 + jmp alltraps +80105c40: e9 d8 f7 ff ff jmp 8010541d + +80105c45 : +.globl vector87 +vector87: + pushl $0 +80105c45: 6a 00 push $0x0 + pushl $87 +80105c47: 6a 57 push $0x57 + jmp alltraps +80105c49: e9 cf f7 ff ff jmp 8010541d + +80105c4e : +.globl vector88 +vector88: + pushl $0 +80105c4e: 6a 00 push $0x0 + pushl $88 +80105c50: 6a 58 push $0x58 + jmp alltraps +80105c52: e9 c6 f7 ff ff jmp 8010541d + +80105c57 : +.globl vector89 +vector89: + pushl $0 +80105c57: 6a 00 push $0x0 + pushl $89 +80105c59: 6a 59 push $0x59 + jmp alltraps +80105c5b: e9 bd f7 ff ff jmp 8010541d + +80105c60 : +.globl vector90 +vector90: + pushl $0 +80105c60: 6a 00 push $0x0 + pushl $90 +80105c62: 6a 5a push $0x5a + jmp alltraps +80105c64: e9 b4 f7 ff ff jmp 8010541d + +80105c69 : +.globl vector91 +vector91: + pushl $0 +80105c69: 6a 00 push $0x0 + pushl $91 +80105c6b: 6a 5b push $0x5b + jmp alltraps +80105c6d: e9 ab f7 ff ff jmp 8010541d + +80105c72 : +.globl vector92 +vector92: + pushl $0 +80105c72: 6a 00 push $0x0 + pushl $92 +80105c74: 6a 5c push $0x5c + jmp alltraps +80105c76: e9 a2 f7 ff ff jmp 8010541d + +80105c7b : +.globl vector93 +vector93: + pushl $0 +80105c7b: 6a 00 push $0x0 + pushl $93 +80105c7d: 6a 5d push $0x5d + jmp alltraps +80105c7f: e9 99 f7 ff ff jmp 8010541d + +80105c84 : +.globl vector94 +vector94: + pushl $0 +80105c84: 6a 00 push $0x0 + pushl $94 +80105c86: 6a 5e push $0x5e + jmp alltraps +80105c88: e9 90 f7 ff ff jmp 8010541d + +80105c8d : +.globl vector95 +vector95: + pushl $0 +80105c8d: 6a 00 push $0x0 + pushl $95 +80105c8f: 6a 5f push $0x5f + jmp alltraps +80105c91: e9 87 f7 ff ff jmp 8010541d + +80105c96 : +.globl vector96 +vector96: + pushl $0 +80105c96: 6a 00 push $0x0 + pushl $96 +80105c98: 6a 60 push $0x60 + jmp alltraps +80105c9a: e9 7e f7 ff ff jmp 8010541d + +80105c9f : +.globl vector97 +vector97: + pushl $0 +80105c9f: 6a 00 push $0x0 + pushl $97 +80105ca1: 6a 61 push $0x61 + jmp alltraps +80105ca3: e9 75 f7 ff ff jmp 8010541d + +80105ca8 : +.globl vector98 +vector98: + pushl $0 +80105ca8: 6a 00 push $0x0 + pushl $98 +80105caa: 6a 62 push $0x62 + jmp alltraps +80105cac: e9 6c f7 ff ff jmp 8010541d + +80105cb1 : +.globl vector99 +vector99: + pushl $0 +80105cb1: 6a 00 push $0x0 + pushl $99 +80105cb3: 6a 63 push $0x63 + jmp alltraps +80105cb5: e9 63 f7 ff ff jmp 8010541d + +80105cba : +.globl vector100 +vector100: + pushl $0 +80105cba: 6a 00 push $0x0 + pushl $100 +80105cbc: 6a 64 push $0x64 + jmp alltraps +80105cbe: e9 5a f7 ff ff jmp 8010541d + +80105cc3 : +.globl vector101 +vector101: + pushl $0 +80105cc3: 6a 00 push $0x0 + pushl $101 +80105cc5: 6a 65 push $0x65 + jmp alltraps +80105cc7: e9 51 f7 ff ff jmp 8010541d + +80105ccc : +.globl vector102 +vector102: + pushl $0 +80105ccc: 6a 00 push $0x0 + pushl $102 +80105cce: 6a 66 push $0x66 + jmp alltraps +80105cd0: e9 48 f7 ff ff jmp 8010541d + +80105cd5 : +.globl vector103 +vector103: + pushl $0 +80105cd5: 6a 00 push $0x0 + pushl $103 +80105cd7: 6a 67 push $0x67 + jmp alltraps +80105cd9: e9 3f f7 ff ff jmp 8010541d + +80105cde : +.globl vector104 +vector104: + pushl $0 +80105cde: 6a 00 push $0x0 + pushl $104 +80105ce0: 6a 68 push $0x68 + jmp alltraps +80105ce2: e9 36 f7 ff ff jmp 8010541d + +80105ce7 : +.globl vector105 +vector105: + pushl $0 +80105ce7: 6a 00 push $0x0 + pushl $105 +80105ce9: 6a 69 push $0x69 + jmp alltraps +80105ceb: e9 2d f7 ff ff jmp 8010541d + +80105cf0 : +.globl vector106 +vector106: + pushl $0 +80105cf0: 6a 00 push $0x0 + pushl $106 +80105cf2: 6a 6a push $0x6a + jmp alltraps +80105cf4: e9 24 f7 ff ff jmp 8010541d + +80105cf9 : +.globl vector107 +vector107: + pushl $0 +80105cf9: 6a 00 push $0x0 + pushl $107 +80105cfb: 6a 6b push $0x6b + jmp alltraps +80105cfd: e9 1b f7 ff ff jmp 8010541d + +80105d02 : +.globl vector108 +vector108: + pushl $0 +80105d02: 6a 00 push $0x0 + pushl $108 +80105d04: 6a 6c push $0x6c + jmp alltraps +80105d06: e9 12 f7 ff ff jmp 8010541d + +80105d0b : +.globl vector109 +vector109: + pushl $0 +80105d0b: 6a 00 push $0x0 + pushl $109 +80105d0d: 6a 6d push $0x6d + jmp alltraps +80105d0f: e9 09 f7 ff ff jmp 8010541d + +80105d14 : +.globl vector110 +vector110: + pushl $0 +80105d14: 6a 00 push $0x0 + pushl $110 +80105d16: 6a 6e push $0x6e + jmp alltraps +80105d18: e9 00 f7 ff ff jmp 8010541d + +80105d1d : +.globl vector111 +vector111: + pushl $0 +80105d1d: 6a 00 push $0x0 + pushl $111 +80105d1f: 6a 6f push $0x6f + jmp alltraps +80105d21: e9 f7 f6 ff ff jmp 8010541d + +80105d26 : +.globl vector112 +vector112: + pushl $0 +80105d26: 6a 00 push $0x0 + pushl $112 +80105d28: 6a 70 push $0x70 + jmp alltraps +80105d2a: e9 ee f6 ff ff jmp 8010541d + +80105d2f : +.globl vector113 +vector113: + pushl $0 +80105d2f: 6a 00 push $0x0 + pushl $113 +80105d31: 6a 71 push $0x71 + jmp alltraps +80105d33: e9 e5 f6 ff ff jmp 8010541d + +80105d38 : +.globl vector114 +vector114: + pushl $0 +80105d38: 6a 00 push $0x0 + pushl $114 +80105d3a: 6a 72 push $0x72 + jmp alltraps +80105d3c: e9 dc f6 ff ff jmp 8010541d + +80105d41 : +.globl vector115 +vector115: + pushl $0 +80105d41: 6a 00 push $0x0 + pushl $115 +80105d43: 6a 73 push $0x73 + jmp alltraps +80105d45: e9 d3 f6 ff ff jmp 8010541d + +80105d4a : +.globl vector116 +vector116: + pushl $0 +80105d4a: 6a 00 push $0x0 + pushl $116 +80105d4c: 6a 74 push $0x74 + jmp alltraps +80105d4e: e9 ca f6 ff ff jmp 8010541d + +80105d53 : +.globl vector117 +vector117: + pushl $0 +80105d53: 6a 00 push $0x0 + pushl $117 +80105d55: 6a 75 push $0x75 + jmp alltraps +80105d57: e9 c1 f6 ff ff jmp 8010541d + +80105d5c : +.globl vector118 +vector118: + pushl $0 +80105d5c: 6a 00 push $0x0 + pushl $118 +80105d5e: 6a 76 push $0x76 + jmp alltraps +80105d60: e9 b8 f6 ff ff jmp 8010541d + +80105d65 : +.globl vector119 +vector119: + pushl $0 +80105d65: 6a 00 push $0x0 + pushl $119 +80105d67: 6a 77 push $0x77 + jmp alltraps +80105d69: e9 af f6 ff ff jmp 8010541d + +80105d6e : +.globl vector120 +vector120: + pushl $0 +80105d6e: 6a 00 push $0x0 + pushl $120 +80105d70: 6a 78 push $0x78 + jmp alltraps +80105d72: e9 a6 f6 ff ff jmp 8010541d + +80105d77 : +.globl vector121 +vector121: + pushl $0 +80105d77: 6a 00 push $0x0 + pushl $121 +80105d79: 6a 79 push $0x79 + jmp alltraps +80105d7b: e9 9d f6 ff ff jmp 8010541d + +80105d80 : +.globl vector122 +vector122: + pushl $0 +80105d80: 6a 00 push $0x0 + pushl $122 +80105d82: 6a 7a push $0x7a + jmp alltraps +80105d84: e9 94 f6 ff ff jmp 8010541d + +80105d89 : +.globl vector123 +vector123: + pushl $0 +80105d89: 6a 00 push $0x0 + pushl $123 +80105d8b: 6a 7b push $0x7b + jmp alltraps +80105d8d: e9 8b f6 ff ff jmp 8010541d + +80105d92 : +.globl vector124 +vector124: + pushl $0 +80105d92: 6a 00 push $0x0 + pushl $124 +80105d94: 6a 7c push $0x7c + jmp alltraps +80105d96: e9 82 f6 ff ff jmp 8010541d + +80105d9b : +.globl vector125 +vector125: + pushl $0 +80105d9b: 6a 00 push $0x0 + pushl $125 +80105d9d: 6a 7d push $0x7d + jmp alltraps +80105d9f: e9 79 f6 ff ff jmp 8010541d + +80105da4 : +.globl vector126 +vector126: + pushl $0 +80105da4: 6a 00 push $0x0 + pushl $126 +80105da6: 6a 7e push $0x7e + jmp alltraps +80105da8: e9 70 f6 ff ff jmp 8010541d + +80105dad : +.globl vector127 +vector127: + pushl $0 +80105dad: 6a 00 push $0x0 + pushl $127 +80105daf: 6a 7f push $0x7f + jmp alltraps +80105db1: e9 67 f6 ff ff jmp 8010541d + +80105db6 : +.globl vector128 +vector128: + pushl $0 +80105db6: 6a 00 push $0x0 + pushl $128 +80105db8: 68 80 00 00 00 push $0x80 + jmp alltraps +80105dbd: e9 5b f6 ff ff jmp 8010541d + +80105dc2 : +.globl vector129 +vector129: + pushl $0 +80105dc2: 6a 00 push $0x0 + pushl $129 +80105dc4: 68 81 00 00 00 push $0x81 + jmp alltraps +80105dc9: e9 4f f6 ff ff jmp 8010541d + +80105dce : +.globl vector130 +vector130: + pushl $0 +80105dce: 6a 00 push $0x0 + pushl $130 +80105dd0: 68 82 00 00 00 push $0x82 + jmp alltraps +80105dd5: e9 43 f6 ff ff jmp 8010541d + +80105dda : +.globl vector131 +vector131: + pushl $0 +80105dda: 6a 00 push $0x0 + pushl $131 +80105ddc: 68 83 00 00 00 push $0x83 + jmp alltraps +80105de1: e9 37 f6 ff ff jmp 8010541d + +80105de6 : +.globl vector132 +vector132: + pushl $0 +80105de6: 6a 00 push $0x0 + pushl $132 +80105de8: 68 84 00 00 00 push $0x84 + jmp alltraps +80105ded: e9 2b f6 ff ff jmp 8010541d + +80105df2 : +.globl vector133 +vector133: + pushl $0 +80105df2: 6a 00 push $0x0 + pushl $133 +80105df4: 68 85 00 00 00 push $0x85 + jmp alltraps +80105df9: e9 1f f6 ff ff jmp 8010541d + +80105dfe : +.globl vector134 +vector134: + pushl $0 +80105dfe: 6a 00 push $0x0 + pushl $134 +80105e00: 68 86 00 00 00 push $0x86 + jmp alltraps +80105e05: e9 13 f6 ff ff jmp 8010541d + +80105e0a : +.globl vector135 +vector135: + pushl $0 +80105e0a: 6a 00 push $0x0 + pushl $135 +80105e0c: 68 87 00 00 00 push $0x87 + jmp alltraps +80105e11: e9 07 f6 ff ff jmp 8010541d + +80105e16 : +.globl vector136 +vector136: + pushl $0 +80105e16: 6a 00 push $0x0 + pushl $136 +80105e18: 68 88 00 00 00 push $0x88 + jmp alltraps +80105e1d: e9 fb f5 ff ff jmp 8010541d + +80105e22 : +.globl vector137 +vector137: + pushl $0 +80105e22: 6a 00 push $0x0 + pushl $137 +80105e24: 68 89 00 00 00 push $0x89 + jmp alltraps +80105e29: e9 ef f5 ff ff jmp 8010541d + +80105e2e : +.globl vector138 +vector138: + pushl $0 +80105e2e: 6a 00 push $0x0 + pushl $138 +80105e30: 68 8a 00 00 00 push $0x8a + jmp alltraps +80105e35: e9 e3 f5 ff ff jmp 8010541d + +80105e3a : +.globl vector139 +vector139: + pushl $0 +80105e3a: 6a 00 push $0x0 + pushl $139 +80105e3c: 68 8b 00 00 00 push $0x8b + jmp alltraps +80105e41: e9 d7 f5 ff ff jmp 8010541d + +80105e46 : +.globl vector140 +vector140: + pushl $0 +80105e46: 6a 00 push $0x0 + pushl $140 +80105e48: 68 8c 00 00 00 push $0x8c + jmp alltraps +80105e4d: e9 cb f5 ff ff jmp 8010541d + +80105e52 : +.globl vector141 +vector141: + pushl $0 +80105e52: 6a 00 push $0x0 + pushl $141 +80105e54: 68 8d 00 00 00 push $0x8d + jmp alltraps +80105e59: e9 bf f5 ff ff jmp 8010541d + +80105e5e : +.globl vector142 +vector142: + pushl $0 +80105e5e: 6a 00 push $0x0 + pushl $142 +80105e60: 68 8e 00 00 00 push $0x8e + jmp alltraps +80105e65: e9 b3 f5 ff ff jmp 8010541d + +80105e6a : +.globl vector143 +vector143: + pushl $0 +80105e6a: 6a 00 push $0x0 + pushl $143 +80105e6c: 68 8f 00 00 00 push $0x8f + jmp alltraps +80105e71: e9 a7 f5 ff ff jmp 8010541d + +80105e76 : +.globl vector144 +vector144: + pushl $0 +80105e76: 6a 00 push $0x0 + pushl $144 +80105e78: 68 90 00 00 00 push $0x90 + jmp alltraps +80105e7d: e9 9b f5 ff ff jmp 8010541d + +80105e82 : +.globl vector145 +vector145: + pushl $0 +80105e82: 6a 00 push $0x0 + pushl $145 +80105e84: 68 91 00 00 00 push $0x91 + jmp alltraps +80105e89: e9 8f f5 ff ff jmp 8010541d + +80105e8e : +.globl vector146 +vector146: + pushl $0 +80105e8e: 6a 00 push $0x0 + pushl $146 +80105e90: 68 92 00 00 00 push $0x92 + jmp alltraps +80105e95: e9 83 f5 ff ff jmp 8010541d + +80105e9a : +.globl vector147 +vector147: + pushl $0 +80105e9a: 6a 00 push $0x0 + pushl $147 +80105e9c: 68 93 00 00 00 push $0x93 + jmp alltraps +80105ea1: e9 77 f5 ff ff jmp 8010541d + +80105ea6 : +.globl vector148 +vector148: + pushl $0 +80105ea6: 6a 00 push $0x0 + pushl $148 +80105ea8: 68 94 00 00 00 push $0x94 + jmp alltraps +80105ead: e9 6b f5 ff ff jmp 8010541d + +80105eb2 : +.globl vector149 +vector149: + pushl $0 +80105eb2: 6a 00 push $0x0 + pushl $149 +80105eb4: 68 95 00 00 00 push $0x95 + jmp alltraps +80105eb9: e9 5f f5 ff ff jmp 8010541d + +80105ebe : +.globl vector150 +vector150: + pushl $0 +80105ebe: 6a 00 push $0x0 + pushl $150 +80105ec0: 68 96 00 00 00 push $0x96 + jmp alltraps +80105ec5: e9 53 f5 ff ff jmp 8010541d + +80105eca : +.globl vector151 +vector151: + pushl $0 +80105eca: 6a 00 push $0x0 + pushl $151 +80105ecc: 68 97 00 00 00 push $0x97 + jmp alltraps +80105ed1: e9 47 f5 ff ff jmp 8010541d + +80105ed6 : +.globl vector152 +vector152: + pushl $0 +80105ed6: 6a 00 push $0x0 + pushl $152 +80105ed8: 68 98 00 00 00 push $0x98 + jmp alltraps +80105edd: e9 3b f5 ff ff jmp 8010541d + +80105ee2 : +.globl vector153 +vector153: + pushl $0 +80105ee2: 6a 00 push $0x0 + pushl $153 +80105ee4: 68 99 00 00 00 push $0x99 + jmp alltraps +80105ee9: e9 2f f5 ff ff jmp 8010541d + +80105eee : +.globl vector154 +vector154: + pushl $0 +80105eee: 6a 00 push $0x0 + pushl $154 +80105ef0: 68 9a 00 00 00 push $0x9a + jmp alltraps +80105ef5: e9 23 f5 ff ff jmp 8010541d + +80105efa : +.globl vector155 +vector155: + pushl $0 +80105efa: 6a 00 push $0x0 + pushl $155 +80105efc: 68 9b 00 00 00 push $0x9b + jmp alltraps +80105f01: e9 17 f5 ff ff jmp 8010541d + +80105f06 : +.globl vector156 +vector156: + pushl $0 +80105f06: 6a 00 push $0x0 + pushl $156 +80105f08: 68 9c 00 00 00 push $0x9c + jmp alltraps +80105f0d: e9 0b f5 ff ff jmp 8010541d + +80105f12 : +.globl vector157 +vector157: + pushl $0 +80105f12: 6a 00 push $0x0 + pushl $157 +80105f14: 68 9d 00 00 00 push $0x9d + jmp alltraps +80105f19: e9 ff f4 ff ff jmp 8010541d + +80105f1e : +.globl vector158 +vector158: + pushl $0 +80105f1e: 6a 00 push $0x0 + pushl $158 +80105f20: 68 9e 00 00 00 push $0x9e + jmp alltraps +80105f25: e9 f3 f4 ff ff jmp 8010541d + +80105f2a : +.globl vector159 +vector159: + pushl $0 +80105f2a: 6a 00 push $0x0 + pushl $159 +80105f2c: 68 9f 00 00 00 push $0x9f + jmp alltraps +80105f31: e9 e7 f4 ff ff jmp 8010541d + +80105f36 : +.globl vector160 +vector160: + pushl $0 +80105f36: 6a 00 push $0x0 + pushl $160 +80105f38: 68 a0 00 00 00 push $0xa0 + jmp alltraps +80105f3d: e9 db f4 ff ff jmp 8010541d + +80105f42 : +.globl vector161 +vector161: + pushl $0 +80105f42: 6a 00 push $0x0 + pushl $161 +80105f44: 68 a1 00 00 00 push $0xa1 + jmp alltraps +80105f49: e9 cf f4 ff ff jmp 8010541d + +80105f4e : +.globl vector162 +vector162: + pushl $0 +80105f4e: 6a 00 push $0x0 + pushl $162 +80105f50: 68 a2 00 00 00 push $0xa2 + jmp alltraps +80105f55: e9 c3 f4 ff ff jmp 8010541d + +80105f5a : +.globl vector163 +vector163: + pushl $0 +80105f5a: 6a 00 push $0x0 + pushl $163 +80105f5c: 68 a3 00 00 00 push $0xa3 + jmp alltraps +80105f61: e9 b7 f4 ff ff jmp 8010541d + +80105f66 : +.globl vector164 +vector164: + pushl $0 +80105f66: 6a 00 push $0x0 + pushl $164 +80105f68: 68 a4 00 00 00 push $0xa4 + jmp alltraps +80105f6d: e9 ab f4 ff ff jmp 8010541d + +80105f72 : +.globl vector165 +vector165: + pushl $0 +80105f72: 6a 00 push $0x0 + pushl $165 +80105f74: 68 a5 00 00 00 push $0xa5 + jmp alltraps +80105f79: e9 9f f4 ff ff jmp 8010541d + +80105f7e : +.globl vector166 +vector166: + pushl $0 +80105f7e: 6a 00 push $0x0 + pushl $166 +80105f80: 68 a6 00 00 00 push $0xa6 + jmp alltraps +80105f85: e9 93 f4 ff ff jmp 8010541d + +80105f8a : +.globl vector167 +vector167: + pushl $0 +80105f8a: 6a 00 push $0x0 + pushl $167 +80105f8c: 68 a7 00 00 00 push $0xa7 + jmp alltraps +80105f91: e9 87 f4 ff ff jmp 8010541d + +80105f96 : +.globl vector168 +vector168: + pushl $0 +80105f96: 6a 00 push $0x0 + pushl $168 +80105f98: 68 a8 00 00 00 push $0xa8 + jmp alltraps +80105f9d: e9 7b f4 ff ff jmp 8010541d + +80105fa2 : +.globl vector169 +vector169: + pushl $0 +80105fa2: 6a 00 push $0x0 + pushl $169 +80105fa4: 68 a9 00 00 00 push $0xa9 + jmp alltraps +80105fa9: e9 6f f4 ff ff jmp 8010541d + +80105fae : +.globl vector170 +vector170: + pushl $0 +80105fae: 6a 00 push $0x0 + pushl $170 +80105fb0: 68 aa 00 00 00 push $0xaa + jmp alltraps +80105fb5: e9 63 f4 ff ff jmp 8010541d + +80105fba : +.globl vector171 +vector171: + pushl $0 +80105fba: 6a 00 push $0x0 + pushl $171 +80105fbc: 68 ab 00 00 00 push $0xab + jmp alltraps +80105fc1: e9 57 f4 ff ff jmp 8010541d + +80105fc6 : +.globl vector172 +vector172: + pushl $0 +80105fc6: 6a 00 push $0x0 + pushl $172 +80105fc8: 68 ac 00 00 00 push $0xac + jmp alltraps +80105fcd: e9 4b f4 ff ff jmp 8010541d + +80105fd2 : +.globl vector173 +vector173: + pushl $0 +80105fd2: 6a 00 push $0x0 + pushl $173 +80105fd4: 68 ad 00 00 00 push $0xad + jmp alltraps +80105fd9: e9 3f f4 ff ff jmp 8010541d + +80105fde : +.globl vector174 +vector174: + pushl $0 +80105fde: 6a 00 push $0x0 + pushl $174 +80105fe0: 68 ae 00 00 00 push $0xae + jmp alltraps +80105fe5: e9 33 f4 ff ff jmp 8010541d + +80105fea : +.globl vector175 +vector175: + pushl $0 +80105fea: 6a 00 push $0x0 + pushl $175 +80105fec: 68 af 00 00 00 push $0xaf + jmp alltraps +80105ff1: e9 27 f4 ff ff jmp 8010541d + +80105ff6 : +.globl vector176 +vector176: + pushl $0 +80105ff6: 6a 00 push $0x0 + pushl $176 +80105ff8: 68 b0 00 00 00 push $0xb0 + jmp alltraps +80105ffd: e9 1b f4 ff ff jmp 8010541d + +80106002 : +.globl vector177 +vector177: + pushl $0 +80106002: 6a 00 push $0x0 + pushl $177 +80106004: 68 b1 00 00 00 push $0xb1 + jmp alltraps +80106009: e9 0f f4 ff ff jmp 8010541d + +8010600e : +.globl vector178 +vector178: + pushl $0 +8010600e: 6a 00 push $0x0 + pushl $178 +80106010: 68 b2 00 00 00 push $0xb2 + jmp alltraps +80106015: e9 03 f4 ff ff jmp 8010541d + +8010601a : +.globl vector179 +vector179: + pushl $0 +8010601a: 6a 00 push $0x0 + pushl $179 +8010601c: 68 b3 00 00 00 push $0xb3 + jmp alltraps +80106021: e9 f7 f3 ff ff jmp 8010541d + +80106026 : +.globl vector180 +vector180: + pushl $0 +80106026: 6a 00 push $0x0 + pushl $180 +80106028: 68 b4 00 00 00 push $0xb4 + jmp alltraps +8010602d: e9 eb f3 ff ff jmp 8010541d + +80106032 : +.globl vector181 +vector181: + pushl $0 +80106032: 6a 00 push $0x0 + pushl $181 +80106034: 68 b5 00 00 00 push $0xb5 + jmp alltraps +80106039: e9 df f3 ff ff jmp 8010541d + +8010603e : +.globl vector182 +vector182: + pushl $0 +8010603e: 6a 00 push $0x0 + pushl $182 +80106040: 68 b6 00 00 00 push $0xb6 + jmp alltraps +80106045: e9 d3 f3 ff ff jmp 8010541d + +8010604a : +.globl vector183 +vector183: + pushl $0 +8010604a: 6a 00 push $0x0 + pushl $183 +8010604c: 68 b7 00 00 00 push $0xb7 + jmp alltraps +80106051: e9 c7 f3 ff ff jmp 8010541d + +80106056 : +.globl vector184 +vector184: + pushl $0 +80106056: 6a 00 push $0x0 + pushl $184 +80106058: 68 b8 00 00 00 push $0xb8 + jmp alltraps +8010605d: e9 bb f3 ff ff jmp 8010541d + +80106062 : +.globl vector185 +vector185: + pushl $0 +80106062: 6a 00 push $0x0 + pushl $185 +80106064: 68 b9 00 00 00 push $0xb9 + jmp alltraps +80106069: e9 af f3 ff ff jmp 8010541d + +8010606e : +.globl vector186 +vector186: + pushl $0 +8010606e: 6a 00 push $0x0 + pushl $186 +80106070: 68 ba 00 00 00 push $0xba + jmp alltraps +80106075: e9 a3 f3 ff ff jmp 8010541d + +8010607a : +.globl vector187 +vector187: + pushl $0 +8010607a: 6a 00 push $0x0 + pushl $187 +8010607c: 68 bb 00 00 00 push $0xbb + jmp alltraps +80106081: e9 97 f3 ff ff jmp 8010541d + +80106086 : +.globl vector188 +vector188: + pushl $0 +80106086: 6a 00 push $0x0 + pushl $188 +80106088: 68 bc 00 00 00 push $0xbc + jmp alltraps +8010608d: e9 8b f3 ff ff jmp 8010541d + +80106092 : +.globl vector189 +vector189: + pushl $0 +80106092: 6a 00 push $0x0 + pushl $189 +80106094: 68 bd 00 00 00 push $0xbd + jmp alltraps +80106099: e9 7f f3 ff ff jmp 8010541d + +8010609e : +.globl vector190 +vector190: + pushl $0 +8010609e: 6a 00 push $0x0 + pushl $190 +801060a0: 68 be 00 00 00 push $0xbe + jmp alltraps +801060a5: e9 73 f3 ff ff jmp 8010541d + +801060aa : +.globl vector191 +vector191: + pushl $0 +801060aa: 6a 00 push $0x0 + pushl $191 +801060ac: 68 bf 00 00 00 push $0xbf + jmp alltraps +801060b1: e9 67 f3 ff ff jmp 8010541d + +801060b6 : +.globl vector192 +vector192: + pushl $0 +801060b6: 6a 00 push $0x0 + pushl $192 +801060b8: 68 c0 00 00 00 push $0xc0 + jmp alltraps +801060bd: e9 5b f3 ff ff jmp 8010541d + +801060c2 : +.globl vector193 +vector193: + pushl $0 +801060c2: 6a 00 push $0x0 + pushl $193 +801060c4: 68 c1 00 00 00 push $0xc1 + jmp alltraps +801060c9: e9 4f f3 ff ff jmp 8010541d + +801060ce : +.globl vector194 +vector194: + pushl $0 +801060ce: 6a 00 push $0x0 + pushl $194 +801060d0: 68 c2 00 00 00 push $0xc2 + jmp alltraps +801060d5: e9 43 f3 ff ff jmp 8010541d + +801060da : +.globl vector195 +vector195: + pushl $0 +801060da: 6a 00 push $0x0 + pushl $195 +801060dc: 68 c3 00 00 00 push $0xc3 + jmp alltraps +801060e1: e9 37 f3 ff ff jmp 8010541d + +801060e6 : +.globl vector196 +vector196: + pushl $0 +801060e6: 6a 00 push $0x0 + pushl $196 +801060e8: 68 c4 00 00 00 push $0xc4 + jmp alltraps +801060ed: e9 2b f3 ff ff jmp 8010541d + +801060f2 : +.globl vector197 +vector197: + pushl $0 +801060f2: 6a 00 push $0x0 + pushl $197 +801060f4: 68 c5 00 00 00 push $0xc5 + jmp alltraps +801060f9: e9 1f f3 ff ff jmp 8010541d + +801060fe : +.globl vector198 +vector198: + pushl $0 +801060fe: 6a 00 push $0x0 + pushl $198 +80106100: 68 c6 00 00 00 push $0xc6 + jmp alltraps +80106105: e9 13 f3 ff ff jmp 8010541d + +8010610a : +.globl vector199 +vector199: + pushl $0 +8010610a: 6a 00 push $0x0 + pushl $199 +8010610c: 68 c7 00 00 00 push $0xc7 + jmp alltraps +80106111: e9 07 f3 ff ff jmp 8010541d + +80106116 : +.globl vector200 +vector200: + pushl $0 +80106116: 6a 00 push $0x0 + pushl $200 +80106118: 68 c8 00 00 00 push $0xc8 + jmp alltraps +8010611d: e9 fb f2 ff ff jmp 8010541d + +80106122 : +.globl vector201 +vector201: + pushl $0 +80106122: 6a 00 push $0x0 + pushl $201 +80106124: 68 c9 00 00 00 push $0xc9 + jmp alltraps +80106129: e9 ef f2 ff ff jmp 8010541d + +8010612e : +.globl vector202 +vector202: + pushl $0 +8010612e: 6a 00 push $0x0 + pushl $202 +80106130: 68 ca 00 00 00 push $0xca + jmp alltraps +80106135: e9 e3 f2 ff ff jmp 8010541d + +8010613a : +.globl vector203 +vector203: + pushl $0 +8010613a: 6a 00 push $0x0 + pushl $203 +8010613c: 68 cb 00 00 00 push $0xcb + jmp alltraps +80106141: e9 d7 f2 ff ff jmp 8010541d + +80106146 : +.globl vector204 +vector204: + pushl $0 +80106146: 6a 00 push $0x0 + pushl $204 +80106148: 68 cc 00 00 00 push $0xcc + jmp alltraps +8010614d: e9 cb f2 ff ff jmp 8010541d + +80106152 : +.globl vector205 +vector205: + pushl $0 +80106152: 6a 00 push $0x0 + pushl $205 +80106154: 68 cd 00 00 00 push $0xcd + jmp alltraps +80106159: e9 bf f2 ff ff jmp 8010541d + +8010615e : +.globl vector206 +vector206: + pushl $0 +8010615e: 6a 00 push $0x0 + pushl $206 +80106160: 68 ce 00 00 00 push $0xce + jmp alltraps +80106165: e9 b3 f2 ff ff jmp 8010541d + +8010616a : +.globl vector207 +vector207: + pushl $0 +8010616a: 6a 00 push $0x0 + pushl $207 +8010616c: 68 cf 00 00 00 push $0xcf + jmp alltraps +80106171: e9 a7 f2 ff ff jmp 8010541d + +80106176 : +.globl vector208 +vector208: + pushl $0 +80106176: 6a 00 push $0x0 + pushl $208 +80106178: 68 d0 00 00 00 push $0xd0 + jmp alltraps +8010617d: e9 9b f2 ff ff jmp 8010541d + +80106182 : +.globl vector209 +vector209: + pushl $0 +80106182: 6a 00 push $0x0 + pushl $209 +80106184: 68 d1 00 00 00 push $0xd1 + jmp alltraps +80106189: e9 8f f2 ff ff jmp 8010541d + +8010618e : +.globl vector210 +vector210: + pushl $0 +8010618e: 6a 00 push $0x0 + pushl $210 +80106190: 68 d2 00 00 00 push $0xd2 + jmp alltraps +80106195: e9 83 f2 ff ff jmp 8010541d + +8010619a : +.globl vector211 +vector211: + pushl $0 +8010619a: 6a 00 push $0x0 + pushl $211 +8010619c: 68 d3 00 00 00 push $0xd3 + jmp alltraps +801061a1: e9 77 f2 ff ff jmp 8010541d + +801061a6 : +.globl vector212 +vector212: + pushl $0 +801061a6: 6a 00 push $0x0 + pushl $212 +801061a8: 68 d4 00 00 00 push $0xd4 + jmp alltraps +801061ad: e9 6b f2 ff ff jmp 8010541d + +801061b2 : +.globl vector213 +vector213: + pushl $0 +801061b2: 6a 00 push $0x0 + pushl $213 +801061b4: 68 d5 00 00 00 push $0xd5 + jmp alltraps +801061b9: e9 5f f2 ff ff jmp 8010541d + +801061be : +.globl vector214 +vector214: + pushl $0 +801061be: 6a 00 push $0x0 + pushl $214 +801061c0: 68 d6 00 00 00 push $0xd6 + jmp alltraps +801061c5: e9 53 f2 ff ff jmp 8010541d + +801061ca : +.globl vector215 +vector215: + pushl $0 +801061ca: 6a 00 push $0x0 + pushl $215 +801061cc: 68 d7 00 00 00 push $0xd7 + jmp alltraps +801061d1: e9 47 f2 ff ff jmp 8010541d + +801061d6 : +.globl vector216 +vector216: + pushl $0 +801061d6: 6a 00 push $0x0 + pushl $216 +801061d8: 68 d8 00 00 00 push $0xd8 + jmp alltraps +801061dd: e9 3b f2 ff ff jmp 8010541d + +801061e2 : +.globl vector217 +vector217: + pushl $0 +801061e2: 6a 00 push $0x0 + pushl $217 +801061e4: 68 d9 00 00 00 push $0xd9 + jmp alltraps +801061e9: e9 2f f2 ff ff jmp 8010541d + +801061ee : +.globl vector218 +vector218: + pushl $0 +801061ee: 6a 00 push $0x0 + pushl $218 +801061f0: 68 da 00 00 00 push $0xda + jmp alltraps +801061f5: e9 23 f2 ff ff jmp 8010541d + +801061fa : +.globl vector219 +vector219: + pushl $0 +801061fa: 6a 00 push $0x0 + pushl $219 +801061fc: 68 db 00 00 00 push $0xdb + jmp alltraps +80106201: e9 17 f2 ff ff jmp 8010541d + +80106206 : +.globl vector220 +vector220: + pushl $0 +80106206: 6a 00 push $0x0 + pushl $220 +80106208: 68 dc 00 00 00 push $0xdc + jmp alltraps +8010620d: e9 0b f2 ff ff jmp 8010541d + +80106212 : +.globl vector221 +vector221: + pushl $0 +80106212: 6a 00 push $0x0 + pushl $221 +80106214: 68 dd 00 00 00 push $0xdd + jmp alltraps +80106219: e9 ff f1 ff ff jmp 8010541d + +8010621e : +.globl vector222 +vector222: + pushl $0 +8010621e: 6a 00 push $0x0 + pushl $222 +80106220: 68 de 00 00 00 push $0xde + jmp alltraps +80106225: e9 f3 f1 ff ff jmp 8010541d + +8010622a : +.globl vector223 +vector223: + pushl $0 +8010622a: 6a 00 push $0x0 + pushl $223 +8010622c: 68 df 00 00 00 push $0xdf + jmp alltraps +80106231: e9 e7 f1 ff ff jmp 8010541d + +80106236 : +.globl vector224 +vector224: + pushl $0 +80106236: 6a 00 push $0x0 + pushl $224 +80106238: 68 e0 00 00 00 push $0xe0 + jmp alltraps +8010623d: e9 db f1 ff ff jmp 8010541d + +80106242 : +.globl vector225 +vector225: + pushl $0 +80106242: 6a 00 push $0x0 + pushl $225 +80106244: 68 e1 00 00 00 push $0xe1 + jmp alltraps +80106249: e9 cf f1 ff ff jmp 8010541d + +8010624e : +.globl vector226 +vector226: + pushl $0 +8010624e: 6a 00 push $0x0 + pushl $226 +80106250: 68 e2 00 00 00 push $0xe2 + jmp alltraps +80106255: e9 c3 f1 ff ff jmp 8010541d + +8010625a : +.globl vector227 +vector227: + pushl $0 +8010625a: 6a 00 push $0x0 + pushl $227 +8010625c: 68 e3 00 00 00 push $0xe3 + jmp alltraps +80106261: e9 b7 f1 ff ff jmp 8010541d + +80106266 : +.globl vector228 +vector228: + pushl $0 +80106266: 6a 00 push $0x0 + pushl $228 +80106268: 68 e4 00 00 00 push $0xe4 + jmp alltraps +8010626d: e9 ab f1 ff ff jmp 8010541d + +80106272 : +.globl vector229 +vector229: + pushl $0 +80106272: 6a 00 push $0x0 + pushl $229 +80106274: 68 e5 00 00 00 push $0xe5 + jmp alltraps +80106279: e9 9f f1 ff ff jmp 8010541d + +8010627e : +.globl vector230 +vector230: + pushl $0 +8010627e: 6a 00 push $0x0 + pushl $230 +80106280: 68 e6 00 00 00 push $0xe6 + jmp alltraps +80106285: e9 93 f1 ff ff jmp 8010541d + +8010628a : +.globl vector231 +vector231: + pushl $0 +8010628a: 6a 00 push $0x0 + pushl $231 +8010628c: 68 e7 00 00 00 push $0xe7 + jmp alltraps +80106291: e9 87 f1 ff ff jmp 8010541d + +80106296 : +.globl vector232 +vector232: + pushl $0 +80106296: 6a 00 push $0x0 + pushl $232 +80106298: 68 e8 00 00 00 push $0xe8 + jmp alltraps +8010629d: e9 7b f1 ff ff jmp 8010541d + +801062a2 : +.globl vector233 +vector233: + pushl $0 +801062a2: 6a 00 push $0x0 + pushl $233 +801062a4: 68 e9 00 00 00 push $0xe9 + jmp alltraps +801062a9: e9 6f f1 ff ff jmp 8010541d + +801062ae : +.globl vector234 +vector234: + pushl $0 +801062ae: 6a 00 push $0x0 + pushl $234 +801062b0: 68 ea 00 00 00 push $0xea + jmp alltraps +801062b5: e9 63 f1 ff ff jmp 8010541d + +801062ba : +.globl vector235 +vector235: + pushl $0 +801062ba: 6a 00 push $0x0 + pushl $235 +801062bc: 68 eb 00 00 00 push $0xeb + jmp alltraps +801062c1: e9 57 f1 ff ff jmp 8010541d + +801062c6 : +.globl vector236 +vector236: + pushl $0 +801062c6: 6a 00 push $0x0 + pushl $236 +801062c8: 68 ec 00 00 00 push $0xec + jmp alltraps +801062cd: e9 4b f1 ff ff jmp 8010541d + +801062d2 : +.globl vector237 +vector237: + pushl $0 +801062d2: 6a 00 push $0x0 + pushl $237 +801062d4: 68 ed 00 00 00 push $0xed + jmp alltraps +801062d9: e9 3f f1 ff ff jmp 8010541d + +801062de : +.globl vector238 +vector238: + pushl $0 +801062de: 6a 00 push $0x0 + pushl $238 +801062e0: 68 ee 00 00 00 push $0xee + jmp alltraps +801062e5: e9 33 f1 ff ff jmp 8010541d + +801062ea : +.globl vector239 +vector239: + pushl $0 +801062ea: 6a 00 push $0x0 + pushl $239 +801062ec: 68 ef 00 00 00 push $0xef + jmp alltraps +801062f1: e9 27 f1 ff ff jmp 8010541d + +801062f6 : +.globl vector240 +vector240: + pushl $0 +801062f6: 6a 00 push $0x0 + pushl $240 +801062f8: 68 f0 00 00 00 push $0xf0 + jmp alltraps +801062fd: e9 1b f1 ff ff jmp 8010541d + +80106302 : +.globl vector241 +vector241: + pushl $0 +80106302: 6a 00 push $0x0 + pushl $241 +80106304: 68 f1 00 00 00 push $0xf1 + jmp alltraps +80106309: e9 0f f1 ff ff jmp 8010541d + +8010630e : +.globl vector242 +vector242: + pushl $0 +8010630e: 6a 00 push $0x0 + pushl $242 +80106310: 68 f2 00 00 00 push $0xf2 + jmp alltraps +80106315: e9 03 f1 ff ff jmp 8010541d + +8010631a : +.globl vector243 +vector243: + pushl $0 +8010631a: 6a 00 push $0x0 + pushl $243 +8010631c: 68 f3 00 00 00 push $0xf3 + jmp alltraps +80106321: e9 f7 f0 ff ff jmp 8010541d + +80106326 : +.globl vector244 +vector244: + pushl $0 +80106326: 6a 00 push $0x0 + pushl $244 +80106328: 68 f4 00 00 00 push $0xf4 + jmp alltraps +8010632d: e9 eb f0 ff ff jmp 8010541d + +80106332 : +.globl vector245 +vector245: + pushl $0 +80106332: 6a 00 push $0x0 + pushl $245 +80106334: 68 f5 00 00 00 push $0xf5 + jmp alltraps +80106339: e9 df f0 ff ff jmp 8010541d + +8010633e : +.globl vector246 +vector246: + pushl $0 +8010633e: 6a 00 push $0x0 + pushl $246 +80106340: 68 f6 00 00 00 push $0xf6 + jmp alltraps +80106345: e9 d3 f0 ff ff jmp 8010541d + +8010634a : +.globl vector247 +vector247: + pushl $0 +8010634a: 6a 00 push $0x0 + pushl $247 +8010634c: 68 f7 00 00 00 push $0xf7 + jmp alltraps +80106351: e9 c7 f0 ff ff jmp 8010541d + +80106356 : +.globl vector248 +vector248: + pushl $0 +80106356: 6a 00 push $0x0 + pushl $248 +80106358: 68 f8 00 00 00 push $0xf8 + jmp alltraps +8010635d: e9 bb f0 ff ff jmp 8010541d + +80106362 : +.globl vector249 +vector249: + pushl $0 +80106362: 6a 00 push $0x0 + pushl $249 +80106364: 68 f9 00 00 00 push $0xf9 + jmp alltraps +80106369: e9 af f0 ff ff jmp 8010541d + +8010636e : +.globl vector250 +vector250: + pushl $0 +8010636e: 6a 00 push $0x0 + pushl $250 +80106370: 68 fa 00 00 00 push $0xfa + jmp alltraps +80106375: e9 a3 f0 ff ff jmp 8010541d + +8010637a : +.globl vector251 +vector251: + pushl $0 +8010637a: 6a 00 push $0x0 + pushl $251 +8010637c: 68 fb 00 00 00 push $0xfb + jmp alltraps +80106381: e9 97 f0 ff ff jmp 8010541d + +80106386 : +.globl vector252 +vector252: + pushl $0 +80106386: 6a 00 push $0x0 + pushl $252 +80106388: 68 fc 00 00 00 push $0xfc + jmp alltraps +8010638d: e9 8b f0 ff ff jmp 8010541d + +80106392 : +.globl vector253 +vector253: + pushl $0 +80106392: 6a 00 push $0x0 + pushl $253 +80106394: 68 fd 00 00 00 push $0xfd + jmp alltraps +80106399: e9 7f f0 ff ff jmp 8010541d + +8010639e : +.globl vector254 +vector254: + pushl $0 +8010639e: 6a 00 push $0x0 + pushl $254 +801063a0: 68 fe 00 00 00 push $0xfe + jmp alltraps +801063a5: e9 73 f0 ff ff jmp 8010541d + +801063aa : +.globl vector255 +vector255: + pushl $0 +801063aa: 6a 00 push $0x0 + pushl $255 +801063ac: 68 ff 00 00 00 push $0xff + jmp alltraps +801063b1: e9 67 f0 ff ff jmp 8010541d +801063b6: 66 90 xchg %ax,%ax +801063b8: 66 90 xchg %ax,%ax +801063ba: 66 90 xchg %ax,%ax +801063bc: 66 90 xchg %ax,%ax +801063be: 66 90 xchg %ax,%ax + +801063c0 : +// Return the address of the PTE in page table pgdir +// that corresponds to virtual address va. If alloc!=0, +// create any required page table pages. +static pte_t * +walkpgdir(pde_t *pgdir, const void *va, int alloc) +{ +801063c0: 55 push %ebp +801063c1: 89 e5 mov %esp,%ebp +801063c3: 57 push %edi +801063c4: 56 push %esi +801063c5: 89 d6 mov %edx,%esi + pde_t *pde; + pte_t *pgtab; + + pde = &pgdir[PDX(va)]; +801063c7: c1 ea 16 shr $0x16,%edx +{ +801063ca: 53 push %ebx + pde = &pgdir[PDX(va)]; +801063cb: 8d 3c 90 lea (%eax,%edx,4),%edi +{ +801063ce: 83 ec 1c sub $0x1c,%esp + if(*pde & PTE_P){ +801063d1: 8b 1f mov (%edi),%ebx +801063d3: f6 c3 01 test $0x1,%bl +801063d6: 74 28 je 80106400 + pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); +801063d8: 81 e3 00 f0 ff ff and $0xfffff000,%ebx +801063de: 81 c3 00 00 00 80 add $0x80000000,%ebx + // The permissions here are overly generous, but they can + // be further restricted by the permissions in the page table + // entries, if necessary. + *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; + } + return &pgtab[PTX(va)]; +801063e4: c1 ee 0a shr $0xa,%esi +} +801063e7: 83 c4 1c add $0x1c,%esp + return &pgtab[PTX(va)]; +801063ea: 89 f2 mov %esi,%edx +801063ec: 81 e2 fc 0f 00 00 and $0xffc,%edx +801063f2: 8d 04 13 lea (%ebx,%edx,1),%eax +} +801063f5: 5b pop %ebx +801063f6: 5e pop %esi +801063f7: 5f pop %edi +801063f8: 5d pop %ebp +801063f9: c3 ret +801063fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if(!alloc || (pgtab = (pte_t*)kalloc()) == 0) +80106400: 85 c9 test %ecx,%ecx +80106402: 74 34 je 80106438 +80106404: e8 97 c0 ff ff call 801024a0 +80106409: 85 c0 test %eax,%eax +8010640b: 89 c3 mov %eax,%ebx +8010640d: 74 29 je 80106438 + memset(pgtab, 0, PGSIZE); +8010640f: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) +80106416: 00 +80106417: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +8010641e: 00 +8010641f: 89 04 24 mov %eax,(%esp) +80106422: e8 59 de ff ff call 80104280 + *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; +80106427: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax +8010642d: 83 c8 07 or $0x7,%eax +80106430: 89 07 mov %eax,(%edi) +80106432: eb b0 jmp 801063e4 +80106434: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +} +80106438: 83 c4 1c add $0x1c,%esp + return 0; +8010643b: 31 c0 xor %eax,%eax +} +8010643d: 5b pop %ebx +8010643e: 5e pop %esi +8010643f: 5f pop %edi +80106440: 5d pop %ebp +80106441: c3 ret +80106442: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106449: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80106450 : +// Create PTEs for virtual addresses starting at va that refer to +// physical addresses starting at pa. va and size might not +// be page-aligned. +static int +mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) +{ +80106450: 55 push %ebp +80106451: 89 e5 mov %esp,%ebp +80106453: 57 push %edi +80106454: 56 push %esi +80106455: 53 push %ebx + char *a, *last; + pte_t *pte; + + a = (char*)PGROUNDDOWN((uint)va); +80106456: 89 d3 mov %edx,%ebx +{ +80106458: 83 ec 1c sub $0x1c,%esp +8010645b: 8b 7d 08 mov 0x8(%ebp),%edi + a = (char*)PGROUNDDOWN((uint)va); +8010645e: 81 e3 00 f0 ff ff and $0xfffff000,%ebx +{ +80106464: 89 45 e0 mov %eax,-0x20(%ebp) + last = (char*)PGROUNDDOWN(((uint)va) + size - 1); +80106467: 8d 44 0a ff lea -0x1(%edx,%ecx,1),%eax +8010646b: 89 45 e4 mov %eax,-0x1c(%ebp) + for(;;){ + if((pte = walkpgdir(pgdir, a, 1)) == 0) + return -1; + if(*pte & PTE_P) + panic("remap"); + *pte = pa | perm | PTE_P; +8010646e: 83 4d 0c 01 orl $0x1,0xc(%ebp) + last = (char*)PGROUNDDOWN(((uint)va) + size - 1); +80106472: 81 65 e4 00 f0 ff ff andl $0xfffff000,-0x1c(%ebp) +80106479: 29 df sub %ebx,%edi +8010647b: eb 18 jmp 80106495 +8010647d: 8d 76 00 lea 0x0(%esi),%esi + if(*pte & PTE_P) +80106480: f6 00 01 testb $0x1,(%eax) +80106483: 75 3d jne 801064c2 + *pte = pa | perm | PTE_P; +80106485: 0b 75 0c or 0xc(%ebp),%esi + if(a == last) +80106488: 3b 5d e4 cmp -0x1c(%ebp),%ebx + *pte = pa | perm | PTE_P; +8010648b: 89 30 mov %esi,(%eax) + if(a == last) +8010648d: 74 29 je 801064b8 + break; + a += PGSIZE; +8010648f: 81 c3 00 10 00 00 add $0x1000,%ebx + if((pte = walkpgdir(pgdir, a, 1)) == 0) +80106495: 8b 45 e0 mov -0x20(%ebp),%eax +80106498: b9 01 00 00 00 mov $0x1,%ecx +8010649d: 89 da mov %ebx,%edx +8010649f: 8d 34 3b lea (%ebx,%edi,1),%esi +801064a2: e8 19 ff ff ff call 801063c0 +801064a7: 85 c0 test %eax,%eax +801064a9: 75 d5 jne 80106480 + pa += PGSIZE; + } + return 0; +} +801064ab: 83 c4 1c add $0x1c,%esp + return -1; +801064ae: b8 ff ff ff ff mov $0xffffffff,%eax +} +801064b3: 5b pop %ebx +801064b4: 5e pop %esi +801064b5: 5f pop %edi +801064b6: 5d pop %ebp +801064b7: c3 ret +801064b8: 83 c4 1c add $0x1c,%esp + return 0; +801064bb: 31 c0 xor %eax,%eax +} +801064bd: 5b pop %ebx +801064be: 5e pop %esi +801064bf: 5f pop %edi +801064c0: 5d pop %ebp +801064c1: c3 ret + panic("remap"); +801064c2: c7 04 24 60 77 10 80 movl $0x80107760,(%esp) +801064c9: e8 92 9e ff ff call 80100360 +801064ce: 66 90 xchg %ax,%ax + +801064d0 : +// Deallocate user pages to bring the process size from oldsz to +// newsz. oldsz and newsz need not be page-aligned, nor does newsz +// need to be less than oldsz. oldsz can be larger than the actual +// process size. Returns the new process size. +int +deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) +801064d0: 55 push %ebp +801064d1: 89 e5 mov %esp,%ebp +801064d3: 57 push %edi +801064d4: 89 c7 mov %eax,%edi +801064d6: 56 push %esi +801064d7: 89 d6 mov %edx,%esi +801064d9: 53 push %ebx + uint a, pa; + + if(newsz >= oldsz) + return oldsz; + + a = PGROUNDUP(newsz); +801064da: 8d 99 ff 0f 00 00 lea 0xfff(%ecx),%ebx +deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) +801064e0: 83 ec 1c sub $0x1c,%esp + a = PGROUNDUP(newsz); +801064e3: 81 e3 00 f0 ff ff and $0xfffff000,%ebx + for(; a < oldsz; a += PGSIZE){ +801064e9: 39 d3 cmp %edx,%ebx +deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) +801064eb: 89 4d e0 mov %ecx,-0x20(%ebp) + for(; a < oldsz; a += PGSIZE){ +801064ee: 72 3b jb 8010652b +801064f0: eb 5e jmp 80106550 +801064f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + pte = walkpgdir(pgdir, (char*)a, 0); + if(!pte) + a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; + else if((*pte & PTE_P) != 0){ +801064f8: 8b 10 mov (%eax),%edx +801064fa: f6 c2 01 test $0x1,%dl +801064fd: 74 22 je 80106521 + pa = PTE_ADDR(*pte); + if(pa == 0) +801064ff: 81 e2 00 f0 ff ff and $0xfffff000,%edx +80106505: 74 54 je 8010655b + panic("kfree"); + char *v = P2V(pa); +80106507: 81 c2 00 00 00 80 add $0x80000000,%edx + kfree(v); +8010650d: 89 14 24 mov %edx,(%esp) +80106510: 89 45 e4 mov %eax,-0x1c(%ebp) +80106513: e8 d8 bd ff ff call 801022f0 + *pte = 0; +80106518: 8b 45 e4 mov -0x1c(%ebp),%eax +8010651b: c7 00 00 00 00 00 movl $0x0,(%eax) + for(; a < oldsz; a += PGSIZE){ +80106521: 81 c3 00 10 00 00 add $0x1000,%ebx +80106527: 39 f3 cmp %esi,%ebx +80106529: 73 25 jae 80106550 + pte = walkpgdir(pgdir, (char*)a, 0); +8010652b: 31 c9 xor %ecx,%ecx +8010652d: 89 da mov %ebx,%edx +8010652f: 89 f8 mov %edi,%eax +80106531: e8 8a fe ff ff call 801063c0 + if(!pte) +80106536: 85 c0 test %eax,%eax +80106538: 75 be jne 801064f8 + a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; +8010653a: 81 e3 00 00 c0 ff and $0xffc00000,%ebx +80106540: 81 c3 00 f0 3f 00 add $0x3ff000,%ebx + for(; a < oldsz; a += PGSIZE){ +80106546: 81 c3 00 10 00 00 add $0x1000,%ebx +8010654c: 39 f3 cmp %esi,%ebx +8010654e: 72 db jb 8010652b + } + } + return newsz; +} +80106550: 8b 45 e0 mov -0x20(%ebp),%eax +80106553: 83 c4 1c add $0x1c,%esp +80106556: 5b pop %ebx +80106557: 5e pop %esi +80106558: 5f pop %edi +80106559: 5d pop %ebp +8010655a: c3 ret + panic("kfree"); +8010655b: c7 04 24 86 70 10 80 movl $0x80107086,(%esp) +80106562: e8 f9 9d ff ff call 80100360 +80106567: 89 f6 mov %esi,%esi +80106569: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80106570 : +{ +80106570: 55 push %ebp +80106571: 89 e5 mov %esp,%ebp +80106573: 83 ec 18 sub $0x18,%esp + c = &cpus[cpuid()]; +80106576: e8 05 d1 ff ff call 80103680 + c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); +8010657b: 31 c9 xor %ecx,%ecx +8010657d: ba ff ff ff ff mov $0xffffffff,%edx + c = &cpus[cpuid()]; +80106582: 69 c0 b0 00 00 00 imul $0xb0,%eax,%eax +80106588: 05 80 27 11 80 add $0x80112780,%eax + c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); +8010658d: 66 89 50 78 mov %dx,0x78(%eax) + c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); +80106591: ba ff ff ff ff mov $0xffffffff,%edx + lgdt(c->gdt, sizeof(c->gdt)); +80106596: 83 c0 70 add $0x70,%eax + c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); +80106599: 66 89 48 0a mov %cx,0xa(%eax) + c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); +8010659d: 31 c9 xor %ecx,%ecx +8010659f: 66 89 50 10 mov %dx,0x10(%eax) + c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); +801065a3: ba ff ff ff ff mov $0xffffffff,%edx + c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); +801065a8: 66 89 48 12 mov %cx,0x12(%eax) + c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); +801065ac: 31 c9 xor %ecx,%ecx +801065ae: 66 89 50 18 mov %dx,0x18(%eax) + c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); +801065b2: ba ff ff ff ff mov $0xffffffff,%edx + c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); +801065b7: 66 89 48 1a mov %cx,0x1a(%eax) + c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); +801065bb: 31 c9 xor %ecx,%ecx + c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); +801065bd: c6 40 0d 9a movb $0x9a,0xd(%eax) +801065c1: c6 40 0e cf movb $0xcf,0xe(%eax) + c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); +801065c5: c6 40 15 92 movb $0x92,0x15(%eax) +801065c9: c6 40 16 cf movb $0xcf,0x16(%eax) + c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); +801065cd: c6 40 1d fa movb $0xfa,0x1d(%eax) +801065d1: c6 40 1e cf movb $0xcf,0x1e(%eax) + c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); +801065d5: c6 40 25 f2 movb $0xf2,0x25(%eax) +801065d9: c6 40 26 cf movb $0xcf,0x26(%eax) +801065dd: 66 89 50 20 mov %dx,0x20(%eax) + pd[0] = size-1; +801065e1: ba 2f 00 00 00 mov $0x2f,%edx + c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); +801065e6: c6 40 0c 00 movb $0x0,0xc(%eax) +801065ea: c6 40 0f 00 movb $0x0,0xf(%eax) + c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); +801065ee: c6 40 14 00 movb $0x0,0x14(%eax) +801065f2: c6 40 17 00 movb $0x0,0x17(%eax) + c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); +801065f6: c6 40 1c 00 movb $0x0,0x1c(%eax) +801065fa: c6 40 1f 00 movb $0x0,0x1f(%eax) + c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); +801065fe: 66 89 48 22 mov %cx,0x22(%eax) +80106602: c6 40 24 00 movb $0x0,0x24(%eax) +80106606: c6 40 27 00 movb $0x0,0x27(%eax) +8010660a: 66 89 55 f2 mov %dx,-0xe(%ebp) + pd[1] = (uint)p; +8010660e: 66 89 45 f4 mov %ax,-0xc(%ebp) + pd[2] = (uint)p >> 16; +80106612: c1 e8 10 shr $0x10,%eax +80106615: 66 89 45 f6 mov %ax,-0xa(%ebp) + asm volatile("lgdt (%0)" : : "r" (pd)); +80106619: 8d 45 f2 lea -0xe(%ebp),%eax +8010661c: 0f 01 10 lgdtl (%eax) +} +8010661f: c9 leave +80106620: c3 ret +80106621: eb 0d jmp 80106630 +80106623: 90 nop +80106624: 90 nop +80106625: 90 nop +80106626: 90 nop +80106627: 90 nop +80106628: 90 nop +80106629: 90 nop +8010662a: 90 nop +8010662b: 90 nop +8010662c: 90 nop +8010662d: 90 nop +8010662e: 90 nop +8010662f: 90 nop + +80106630 : + lcr3(V2P(kpgdir)); // switch to the kernel page table +80106630: a1 c4 55 11 80 mov 0x801155c4,%eax +{ +80106635: 55 push %ebp +80106636: 89 e5 mov %esp,%ebp + lcr3(V2P(kpgdir)); // switch to the kernel page table +80106638: 05 00 00 00 80 add $0x80000000,%eax +} + +static inline void +lcr3(uint val) +{ + asm volatile("movl %0,%%cr3" : : "r" (val)); +8010663d: 0f 22 d8 mov %eax,%cr3 +} +80106640: 5d pop %ebp +80106641: c3 ret +80106642: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106649: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80106650 : +{ +80106650: 55 push %ebp +80106651: 89 e5 mov %esp,%ebp +80106653: 57 push %edi +80106654: 56 push %esi +80106655: 53 push %ebx +80106656: 83 ec 1c sub $0x1c,%esp +80106659: 8b 75 08 mov 0x8(%ebp),%esi + if(p == 0) +8010665c: 85 f6 test %esi,%esi +8010665e: 0f 84 cd 00 00 00 je 80106731 + if(p->kstack == 0) +80106664: 8b 46 0c mov 0xc(%esi),%eax +80106667: 85 c0 test %eax,%eax +80106669: 0f 84 da 00 00 00 je 80106749 + if(p->pgdir == 0) +8010666f: 8b 7e 04 mov 0x4(%esi),%edi +80106672: 85 ff test %edi,%edi +80106674: 0f 84 c3 00 00 00 je 8010673d + pushcli(); +8010667a: e8 81 da ff ff call 80104100 + mycpu()->gdt[SEG_TSS] = SEG16(STS_T32A, &mycpu()->ts, +8010667f: e8 7c cf ff ff call 80103600 +80106684: 89 c3 mov %eax,%ebx +80106686: e8 75 cf ff ff call 80103600 +8010668b: 89 c7 mov %eax,%edi +8010668d: e8 6e cf ff ff call 80103600 +80106692: 83 c7 08 add $0x8,%edi +80106695: 89 45 e4 mov %eax,-0x1c(%ebp) +80106698: e8 63 cf ff ff call 80103600 +8010669d: 8b 4d e4 mov -0x1c(%ebp),%ecx +801066a0: ba 67 00 00 00 mov $0x67,%edx +801066a5: 66 89 93 98 00 00 00 mov %dx,0x98(%ebx) +801066ac: 66 89 bb 9a 00 00 00 mov %di,0x9a(%ebx) +801066b3: c6 83 9d 00 00 00 99 movb $0x99,0x9d(%ebx) +801066ba: 83 c1 08 add $0x8,%ecx +801066bd: c1 e9 10 shr $0x10,%ecx +801066c0: 83 c0 08 add $0x8,%eax +801066c3: c1 e8 18 shr $0x18,%eax +801066c6: 88 8b 9c 00 00 00 mov %cl,0x9c(%ebx) +801066cc: c6 83 9e 00 00 00 40 movb $0x40,0x9e(%ebx) +801066d3: 88 83 9f 00 00 00 mov %al,0x9f(%ebx) + mycpu()->ts.iomb = (ushort) 0xFFFF; +801066d9: bb ff ff ff ff mov $0xffffffff,%ebx + mycpu()->gdt[SEG_TSS].s = 0; +801066de: e8 1d cf ff ff call 80103600 +801066e3: 80 a0 9d 00 00 00 ef andb $0xef,0x9d(%eax) + mycpu()->ts.ss0 = SEG_KDATA << 3; +801066ea: e8 11 cf ff ff call 80103600 +801066ef: b9 10 00 00 00 mov $0x10,%ecx +801066f4: 66 89 48 10 mov %cx,0x10(%eax) + mycpu()->ts.esp0 = (uint)p->kstack + KSTACKSIZE; +801066f8: e8 03 cf ff ff call 80103600 +801066fd: 8b 56 0c mov 0xc(%esi),%edx +80106700: 8d 8a 00 10 00 00 lea 0x1000(%edx),%ecx +80106706: 89 48 0c mov %ecx,0xc(%eax) + mycpu()->ts.iomb = (ushort) 0xFFFF; +80106709: e8 f2 ce ff ff call 80103600 +8010670e: 66 89 58 6e mov %bx,0x6e(%eax) + asm volatile("ltr %0" : : "r" (sel)); +80106712: b8 28 00 00 00 mov $0x28,%eax +80106717: 0f 00 d8 ltr %ax + lcr3(V2P(p->pgdir)); // switch to process's address space +8010671a: 8b 46 04 mov 0x4(%esi),%eax +8010671d: 05 00 00 00 80 add $0x80000000,%eax + asm volatile("movl %0,%%cr3" : : "r" (val)); +80106722: 0f 22 d8 mov %eax,%cr3 +} +80106725: 83 c4 1c add $0x1c,%esp +80106728: 5b pop %ebx +80106729: 5e pop %esi +8010672a: 5f pop %edi +8010672b: 5d pop %ebp + popcli(); +8010672c: e9 8f da ff ff jmp 801041c0 + panic("switchuvm: no process"); +80106731: c7 04 24 66 77 10 80 movl $0x80107766,(%esp) +80106738: e8 23 9c ff ff call 80100360 + panic("switchuvm: no pgdir"); +8010673d: c7 04 24 91 77 10 80 movl $0x80107791,(%esp) +80106744: e8 17 9c ff ff call 80100360 + panic("switchuvm: no kstack"); +80106749: c7 04 24 7c 77 10 80 movl $0x8010777c,(%esp) +80106750: e8 0b 9c ff ff call 80100360 +80106755: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80106759: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80106760 : +{ +80106760: 55 push %ebp +80106761: 89 e5 mov %esp,%ebp +80106763: 57 push %edi +80106764: 56 push %esi +80106765: 53 push %ebx +80106766: 83 ec 1c sub $0x1c,%esp +80106769: 8b 75 10 mov 0x10(%ebp),%esi +8010676c: 8b 45 08 mov 0x8(%ebp),%eax +8010676f: 8b 7d 0c mov 0xc(%ebp),%edi + if(sz >= PGSIZE) +80106772: 81 fe ff 0f 00 00 cmp $0xfff,%esi +{ +80106778: 89 45 e4 mov %eax,-0x1c(%ebp) + if(sz >= PGSIZE) +8010677b: 77 54 ja 801067d1 + mem = kalloc(); +8010677d: e8 1e bd ff ff call 801024a0 + memset(mem, 0, PGSIZE); +80106782: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) +80106789: 00 +8010678a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +80106791: 00 + mem = kalloc(); +80106792: 89 c3 mov %eax,%ebx + memset(mem, 0, PGSIZE); +80106794: 89 04 24 mov %eax,(%esp) +80106797: e8 e4 da ff ff call 80104280 + mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U); +8010679c: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax +801067a2: b9 00 10 00 00 mov $0x1000,%ecx +801067a7: 89 04 24 mov %eax,(%esp) +801067aa: 8b 45 e4 mov -0x1c(%ebp),%eax +801067ad: 31 d2 xor %edx,%edx +801067af: c7 44 24 04 06 00 00 movl $0x6,0x4(%esp) +801067b6: 00 +801067b7: e8 94 fc ff ff call 80106450 + memmove(mem, init, sz); +801067bc: 89 75 10 mov %esi,0x10(%ebp) +801067bf: 89 7d 0c mov %edi,0xc(%ebp) +801067c2: 89 5d 08 mov %ebx,0x8(%ebp) +} +801067c5: 83 c4 1c add $0x1c,%esp +801067c8: 5b pop %ebx +801067c9: 5e pop %esi +801067ca: 5f pop %edi +801067cb: 5d pop %ebp + memmove(mem, init, sz); +801067cc: e9 4f db ff ff jmp 80104320 + panic("inituvm: more than a page"); +801067d1: c7 04 24 a5 77 10 80 movl $0x801077a5,(%esp) +801067d8: e8 83 9b ff ff call 80100360 +801067dd: 8d 76 00 lea 0x0(%esi),%esi + +801067e0 : +{ +801067e0: 55 push %ebp +801067e1: 89 e5 mov %esp,%ebp +801067e3: 57 push %edi +801067e4: 56 push %esi +801067e5: 53 push %ebx +801067e6: 83 ec 1c sub $0x1c,%esp + if((uint) addr % PGSIZE != 0) +801067e9: f7 45 0c ff 0f 00 00 testl $0xfff,0xc(%ebp) +801067f0: 0f 85 98 00 00 00 jne 8010688e + for(i = 0; i < sz; i += PGSIZE){ +801067f6: 8b 75 18 mov 0x18(%ebp),%esi +801067f9: 31 db xor %ebx,%ebx +801067fb: 85 f6 test %esi,%esi +801067fd: 75 1a jne 80106819 +801067ff: eb 77 jmp 80106878 +80106801: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +80106808: 81 c3 00 10 00 00 add $0x1000,%ebx +8010680e: 81 ee 00 10 00 00 sub $0x1000,%esi +80106814: 39 5d 18 cmp %ebx,0x18(%ebp) +80106817: 76 5f jbe 80106878 +80106819: 8b 55 0c mov 0xc(%ebp),%edx + if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) +8010681c: 31 c9 xor %ecx,%ecx +8010681e: 8b 45 08 mov 0x8(%ebp),%eax +80106821: 01 da add %ebx,%edx +80106823: e8 98 fb ff ff call 801063c0 +80106828: 85 c0 test %eax,%eax +8010682a: 74 56 je 80106882 + pa = PTE_ADDR(*pte); +8010682c: 8b 00 mov (%eax),%eax + n = PGSIZE; +8010682e: bf 00 10 00 00 mov $0x1000,%edi +80106833: 8b 4d 14 mov 0x14(%ebp),%ecx + pa = PTE_ADDR(*pte); +80106836: 25 00 f0 ff ff and $0xfffff000,%eax + n = PGSIZE; +8010683b: 81 fe 00 10 00 00 cmp $0x1000,%esi +80106841: 0f 42 fe cmovb %esi,%edi + if(readi(ip, P2V(pa), offset+i, n) != n) +80106844: 05 00 00 00 80 add $0x80000000,%eax +80106849: 89 44 24 04 mov %eax,0x4(%esp) +8010684d: 8b 45 10 mov 0x10(%ebp),%eax +80106850: 01 d9 add %ebx,%ecx +80106852: 89 7c 24 0c mov %edi,0xc(%esp) +80106856: 89 4c 24 08 mov %ecx,0x8(%esp) +8010685a: 89 04 24 mov %eax,(%esp) +8010685d: e8 fe b0 ff ff call 80101960 +80106862: 39 f8 cmp %edi,%eax +80106864: 74 a2 je 80106808 +} +80106866: 83 c4 1c add $0x1c,%esp + return -1; +80106869: b8 ff ff ff ff mov $0xffffffff,%eax +} +8010686e: 5b pop %ebx +8010686f: 5e pop %esi +80106870: 5f pop %edi +80106871: 5d pop %ebp +80106872: c3 ret +80106873: 90 nop +80106874: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80106878: 83 c4 1c add $0x1c,%esp + return 0; +8010687b: 31 c0 xor %eax,%eax +} +8010687d: 5b pop %ebx +8010687e: 5e pop %esi +8010687f: 5f pop %edi +80106880: 5d pop %ebp +80106881: c3 ret + panic("loaduvm: address should exist"); +80106882: c7 04 24 bf 77 10 80 movl $0x801077bf,(%esp) +80106889: e8 d2 9a ff ff call 80100360 + panic("loaduvm: addr must be page aligned"); +8010688e: c7 04 24 60 78 10 80 movl $0x80107860,(%esp) +80106895: e8 c6 9a ff ff call 80100360 +8010689a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +801068a0 : +{ +801068a0: 55 push %ebp +801068a1: 89 e5 mov %esp,%ebp +801068a3: 57 push %edi +801068a4: 56 push %esi +801068a5: 53 push %ebx +801068a6: 83 ec 1c sub $0x1c,%esp +801068a9: 8b 7d 10 mov 0x10(%ebp),%edi + if(newsz > KERNBASE) +801068ac: 81 ff 00 00 00 80 cmp $0x80000000,%edi +801068b2: 0f 87 88 00 00 00 ja 80106940 + if(newsz < oldsz) +801068b8: 3b 7d 0c cmp 0xc(%ebp),%edi + return oldsz; +801068bb: 8b 45 0c mov 0xc(%ebp),%eax + if(newsz < oldsz) +801068be: 0f 82 7e 00 00 00 jb 80106942 + a = PGROUNDUP(oldsz); +801068c4: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx +801068ca: 81 e3 00 f0 ff ff and $0xfffff000,%ebx + for(; a < newsz; a += PGSIZE){ +801068d0: 39 df cmp %ebx,%edi +801068d2: 77 4a ja 8010691e +801068d4: eb 7a jmp 80106950 +801068d6: 66 90 xchg %ax,%ax + memset(mem, 0, PGSIZE); +801068d8: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) +801068df: 00 +801068e0: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +801068e7: 00 +801068e8: 89 04 24 mov %eax,(%esp) +801068eb: e8 90 d9 ff ff call 80104280 + if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ +801068f0: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax +801068f6: b9 00 10 00 00 mov $0x1000,%ecx +801068fb: 89 04 24 mov %eax,(%esp) +801068fe: 8b 45 08 mov 0x8(%ebp),%eax +80106901: 89 da mov %ebx,%edx +80106903: c7 44 24 04 06 00 00 movl $0x6,0x4(%esp) +8010690a: 00 +8010690b: e8 40 fb ff ff call 80106450 +80106910: 85 c0 test %eax,%eax +80106912: 78 4c js 80106960 + for(; a < newsz; a += PGSIZE){ +80106914: 81 c3 00 10 00 00 add $0x1000,%ebx +8010691a: 39 df cmp %ebx,%edi +8010691c: 76 32 jbe 80106950 + mem = kalloc(); +8010691e: e8 7d bb ff ff call 801024a0 + if(mem == 0){ +80106923: 85 c0 test %eax,%eax + mem = kalloc(); +80106925: 89 c6 mov %eax,%esi + if(mem == 0){ +80106927: 75 af jne 801068d8 + cprintf("allocuvm out of memory\n"); +80106929: c7 04 24 dd 77 10 80 movl $0x801077dd,(%esp) +80106930: e8 1b 9d ff ff call 80100650 + if(newsz >= oldsz) +80106935: 3b 7d 0c cmp 0xc(%ebp),%edi +80106938: 77 56 ja 80106990 +8010693a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + return 0; +80106940: 31 c0 xor %eax,%eax +} +80106942: 83 c4 1c add $0x1c,%esp +80106945: 5b pop %ebx +80106946: 5e pop %esi +80106947: 5f pop %edi +80106948: 5d pop %ebp +80106949: c3 ret +8010694a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80106950: 83 c4 1c add $0x1c,%esp + return newsz; +80106953: 89 f8 mov %edi,%eax +} +80106955: 5b pop %ebx +80106956: 5e pop %esi +80106957: 5f pop %edi +80106958: 5d pop %ebp +80106959: c3 ret +8010695a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + cprintf("allocuvm out of memory (2)\n"); +80106960: c7 04 24 f5 77 10 80 movl $0x801077f5,(%esp) +80106967: e8 e4 9c ff ff call 80100650 + if(newsz >= oldsz) +8010696c: 3b 7d 0c cmp 0xc(%ebp),%edi +8010696f: 76 0d jbe 8010697e +80106971: 8b 4d 0c mov 0xc(%ebp),%ecx +80106974: 89 fa mov %edi,%edx +80106976: 8b 45 08 mov 0x8(%ebp),%eax +80106979: e8 52 fb ff ff call 801064d0 + kfree(mem); +8010697e: 89 34 24 mov %esi,(%esp) +80106981: e8 6a b9 ff ff call 801022f0 +} +80106986: 83 c4 1c add $0x1c,%esp + return 0; +80106989: 31 c0 xor %eax,%eax +} +8010698b: 5b pop %ebx +8010698c: 5e pop %esi +8010698d: 5f pop %edi +8010698e: 5d pop %ebp +8010698f: c3 ret +80106990: 8b 4d 0c mov 0xc(%ebp),%ecx +80106993: 89 fa mov %edi,%edx +80106995: 8b 45 08 mov 0x8(%ebp),%eax +80106998: e8 33 fb ff ff call 801064d0 + return 0; +8010699d: 31 c0 xor %eax,%eax +8010699f: eb a1 jmp 80106942 +801069a1: eb 0d jmp 801069b0 +801069a3: 90 nop +801069a4: 90 nop +801069a5: 90 nop +801069a6: 90 nop +801069a7: 90 nop +801069a8: 90 nop +801069a9: 90 nop +801069aa: 90 nop +801069ab: 90 nop +801069ac: 90 nop +801069ad: 90 nop +801069ae: 90 nop +801069af: 90 nop + +801069b0 : +{ +801069b0: 55 push %ebp +801069b1: 89 e5 mov %esp,%ebp +801069b3: 8b 55 0c mov 0xc(%ebp),%edx +801069b6: 8b 4d 10 mov 0x10(%ebp),%ecx +801069b9: 8b 45 08 mov 0x8(%ebp),%eax + if(newsz >= oldsz) +801069bc: 39 d1 cmp %edx,%ecx +801069be: 73 08 jae 801069c8 +} +801069c0: 5d pop %ebp +801069c1: e9 0a fb ff ff jmp 801064d0 +801069c6: 66 90 xchg %ax,%ax +801069c8: 89 d0 mov %edx,%eax +801069ca: 5d pop %ebp +801069cb: c3 ret +801069cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +801069d0 : + +// Free a page table and all the physical memory pages +// in the user part. +void +freevm(pde_t *pgdir) +{ +801069d0: 55 push %ebp +801069d1: 89 e5 mov %esp,%ebp +801069d3: 56 push %esi +801069d4: 53 push %ebx +801069d5: 83 ec 10 sub $0x10,%esp +801069d8: 8b 75 08 mov 0x8(%ebp),%esi + uint i; + + if(pgdir == 0) +801069db: 85 f6 test %esi,%esi +801069dd: 74 59 je 80106a38 +801069df: 31 c9 xor %ecx,%ecx +801069e1: ba 00 00 00 80 mov $0x80000000,%edx +801069e6: 89 f0 mov %esi,%eax + panic("freevm: no pgdir"); + deallocuvm(pgdir, KERNBASE, 0); + for(i = 0; i < NPDENTRIES; i++){ +801069e8: 31 db xor %ebx,%ebx +801069ea: e8 e1 fa ff ff call 801064d0 +801069ef: eb 12 jmp 80106a03 +801069f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +801069f8: 83 c3 01 add $0x1,%ebx +801069fb: 81 fb 00 04 00 00 cmp $0x400,%ebx +80106a01: 74 27 je 80106a2a + if(pgdir[i] & PTE_P){ +80106a03: 8b 14 9e mov (%esi,%ebx,4),%edx +80106a06: f6 c2 01 test $0x1,%dl +80106a09: 74 ed je 801069f8 + char * v = P2V(PTE_ADDR(pgdir[i])); +80106a0b: 81 e2 00 f0 ff ff and $0xfffff000,%edx + for(i = 0; i < NPDENTRIES; i++){ +80106a11: 83 c3 01 add $0x1,%ebx + char * v = P2V(PTE_ADDR(pgdir[i])); +80106a14: 81 c2 00 00 00 80 add $0x80000000,%edx + kfree(v); +80106a1a: 89 14 24 mov %edx,(%esp) +80106a1d: e8 ce b8 ff ff call 801022f0 + for(i = 0; i < NPDENTRIES; i++){ +80106a22: 81 fb 00 04 00 00 cmp $0x400,%ebx +80106a28: 75 d9 jne 80106a03 + } + } + kfree((char*)pgdir); +80106a2a: 89 75 08 mov %esi,0x8(%ebp) +} +80106a2d: 83 c4 10 add $0x10,%esp +80106a30: 5b pop %ebx +80106a31: 5e pop %esi +80106a32: 5d pop %ebp + kfree((char*)pgdir); +80106a33: e9 b8 b8 ff ff jmp 801022f0 + panic("freevm: no pgdir"); +80106a38: c7 04 24 11 78 10 80 movl $0x80107811,(%esp) +80106a3f: e8 1c 99 ff ff call 80100360 +80106a44: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80106a4a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +80106a50 : +{ +80106a50: 55 push %ebp +80106a51: 89 e5 mov %esp,%ebp +80106a53: 56 push %esi +80106a54: 53 push %ebx +80106a55: 83 ec 10 sub $0x10,%esp + if((pgdir = (pde_t*)kalloc()) == 0) +80106a58: e8 43 ba ff ff call 801024a0 +80106a5d: 85 c0 test %eax,%eax +80106a5f: 89 c6 mov %eax,%esi +80106a61: 74 6d je 80106ad0 + memset(pgdir, 0, PGSIZE); +80106a63: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) +80106a6a: 00 + for(k = kmap; k < &kmap[NELEM(kmap)]; k++) +80106a6b: bb 20 a4 10 80 mov $0x8010a420,%ebx + memset(pgdir, 0, PGSIZE); +80106a70: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +80106a77: 00 +80106a78: 89 04 24 mov %eax,(%esp) +80106a7b: e8 00 d8 ff ff call 80104280 + if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, +80106a80: 8b 53 0c mov 0xc(%ebx),%edx +80106a83: 8b 43 04 mov 0x4(%ebx),%eax +80106a86: 8b 4b 08 mov 0x8(%ebx),%ecx +80106a89: 89 54 24 04 mov %edx,0x4(%esp) +80106a8d: 8b 13 mov (%ebx),%edx +80106a8f: 89 04 24 mov %eax,(%esp) +80106a92: 29 c1 sub %eax,%ecx +80106a94: 89 f0 mov %esi,%eax +80106a96: e8 b5 f9 ff ff call 80106450 +80106a9b: 85 c0 test %eax,%eax +80106a9d: 78 19 js 80106ab8 + for(k = kmap; k < &kmap[NELEM(kmap)]; k++) +80106a9f: 83 c3 10 add $0x10,%ebx +80106aa2: 81 fb 60 a4 10 80 cmp $0x8010a460,%ebx +80106aa8: 72 d6 jb 80106a80 +80106aaa: 89 f0 mov %esi,%eax +} +80106aac: 83 c4 10 add $0x10,%esp +80106aaf: 5b pop %ebx +80106ab0: 5e pop %esi +80106ab1: 5d pop %ebp +80106ab2: c3 ret +80106ab3: 90 nop +80106ab4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + freevm(pgdir); +80106ab8: 89 34 24 mov %esi,(%esp) +80106abb: e8 10 ff ff ff call 801069d0 +} +80106ac0: 83 c4 10 add $0x10,%esp + return 0; +80106ac3: 31 c0 xor %eax,%eax +} +80106ac5: 5b pop %ebx +80106ac6: 5e pop %esi +80106ac7: 5d pop %ebp +80106ac8: c3 ret +80106ac9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; +80106ad0: 31 c0 xor %eax,%eax +80106ad2: eb d8 jmp 80106aac +80106ad4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80106ada: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +80106ae0 : +{ +80106ae0: 55 push %ebp +80106ae1: 89 e5 mov %esp,%ebp +80106ae3: 83 ec 08 sub $0x8,%esp + kpgdir = setupkvm(); +80106ae6: e8 65 ff ff ff call 80106a50 +80106aeb: a3 c4 55 11 80 mov %eax,0x801155c4 + lcr3(V2P(kpgdir)); // switch to the kernel page table +80106af0: 05 00 00 00 80 add $0x80000000,%eax +80106af5: 0f 22 d8 mov %eax,%cr3 +} +80106af8: c9 leave +80106af9: c3 ret +80106afa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +80106b00 : + +// Clear PTE_U on a page. Used to create an inaccessible +// page beneath the user stack. +void +clearpteu(pde_t *pgdir, char *uva) +{ +80106b00: 55 push %ebp + pte_t *pte; + + pte = walkpgdir(pgdir, uva, 0); +80106b01: 31 c9 xor %ecx,%ecx +{ +80106b03: 89 e5 mov %esp,%ebp +80106b05: 83 ec 18 sub $0x18,%esp + pte = walkpgdir(pgdir, uva, 0); +80106b08: 8b 55 0c mov 0xc(%ebp),%edx +80106b0b: 8b 45 08 mov 0x8(%ebp),%eax +80106b0e: e8 ad f8 ff ff call 801063c0 + if(pte == 0) +80106b13: 85 c0 test %eax,%eax +80106b15: 74 05 je 80106b1c + panic("clearpteu"); + *pte &= ~PTE_U; +80106b17: 83 20 fb andl $0xfffffffb,(%eax) +} +80106b1a: c9 leave +80106b1b: c3 ret + panic("clearpteu"); +80106b1c: c7 04 24 22 78 10 80 movl $0x80107822,(%esp) +80106b23: e8 38 98 ff ff call 80100360 +80106b28: 90 nop +80106b29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +80106b30 : +// of it for a child. + +// ** added unit arg +pde_t* +copyuvm(pde_t *pgdir, uint sz, uint num_pages) +{ +80106b30: 55 push %ebp +80106b31: 89 e5 mov %esp,%ebp +80106b33: 57 push %edi +80106b34: 56 push %esi +80106b35: 53 push %ebx +80106b36: 83 ec 2c sub $0x2c,%esp + pde_t *d; + pte_t *pte; + uint pa, i, flags; + char *mem; + + if((d = setupkvm()) == 0) +80106b39: e8 12 ff ff ff call 80106a50 +80106b3e: 85 c0 test %eax,%eax +80106b40: 89 45 e0 mov %eax,-0x20(%ebp) +80106b43: 0f 84 5f 01 00 00 je 80106ca8 + return 0; + for(i = 0; i < sz; i += PGSIZE){ +80106b49: 8b 45 0c mov 0xc(%ebp),%eax +80106b4c: 85 c0 test %eax,%eax +80106b4e: 0f 84 a4 00 00 00 je 80106bf8 +80106b54: 31 ff xor %edi,%edi +80106b56: eb 4c jmp 80106ba4 + panic("copyuvm: page not present"); + pa = PTE_ADDR(*pte); + flags = PTE_FLAGS(*pte); + if((mem = kalloc()) == 0) + goto bad; + memmove(mem, (char*)P2V(pa), PGSIZE); +80106b58: 81 c6 00 00 00 80 add $0x80000000,%esi +80106b5e: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) +80106b65: 00 +80106b66: 89 74 24 04 mov %esi,0x4(%esp) +80106b6a: 89 04 24 mov %eax,(%esp) +80106b6d: e8 ae d7 ff ff call 80104320 + if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) { +80106b72: 8b 45 e4 mov -0x1c(%ebp),%eax +80106b75: b9 00 10 00 00 mov $0x1000,%ecx +80106b7a: 89 fa mov %edi,%edx +80106b7c: 89 44 24 04 mov %eax,0x4(%esp) +80106b80: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax +80106b86: 89 04 24 mov %eax,(%esp) +80106b89: 8b 45 e0 mov -0x20(%ebp),%eax +80106b8c: e8 bf f8 ff ff call 80106450 +80106b91: 85 c0 test %eax,%eax +80106b93: 0f 88 f7 00 00 00 js 80106c90 + for(i = 0; i < sz; i += PGSIZE){ +80106b99: 81 c7 00 10 00 00 add $0x1000,%edi +80106b9f: 39 7d 0c cmp %edi,0xc(%ebp) +80106ba2: 76 54 jbe 80106bf8 + if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) +80106ba4: 8b 45 08 mov 0x8(%ebp),%eax +80106ba7: 31 c9 xor %ecx,%ecx +80106ba9: 89 fa mov %edi,%edx +80106bab: e8 10 f8 ff ff call 801063c0 +80106bb0: 85 c0 test %eax,%eax +80106bb2: 0f 84 03 01 00 00 je 80106cbb + if(!(*pte & PTE_P)) +80106bb8: 8b 00 mov (%eax),%eax +80106bba: a8 01 test $0x1,%al +80106bbc: 0f 84 ed 00 00 00 je 80106caf + pa = PTE_ADDR(*pte); +80106bc2: 89 c6 mov %eax,%esi + flags = PTE_FLAGS(*pte); +80106bc4: 25 ff 0f 00 00 and $0xfff,%eax +80106bc9: 89 45 e4 mov %eax,-0x1c(%ebp) + pa = PTE_ADDR(*pte); +80106bcc: 81 e6 00 f0 ff ff and $0xfffff000,%esi + if((mem = kalloc()) == 0) +80106bd2: e8 c9 b8 ff ff call 801024a0 +80106bd7: 85 c0 test %eax,%eax +80106bd9: 89 c3 mov %eax,%ebx +80106bdb: 0f 85 77 ff ff ff jne 80106b58 + } + + return d; + +bad: + freevm(d); +80106be1: 8b 45 e0 mov -0x20(%ebp),%eax +80106be4: 89 04 24 mov %eax,(%esp) +80106be7: e8 e4 fd ff ff call 801069d0 + return 0; +80106bec: 31 c0 xor %eax,%eax +} +80106bee: 83 c4 2c add $0x2c,%esp +80106bf1: 5b pop %ebx +80106bf2: 5e pop %esi +80106bf3: 5f pop %edi +80106bf4: 5d pop %ebp +80106bf5: c3 ret +80106bf6: 66 90 xchg %ax,%ax + for(i = KERNBASE - (num_pages * PGSIZE * 2); i < KERNBASE; i += PGSIZE){ +80106bf8: 8b 5d 10 mov 0x10(%ebp),%ebx +80106bfb: f7 db neg %ebx +80106bfd: c1 e3 0d shl $0xd,%ebx +80106c00: 81 c3 00 00 00 80 add $0x80000000,%ebx +80106c06: 79 4d jns 80106c55 +80106c08: e9 90 00 00 00 jmp 80106c9d +80106c0d: 8d 76 00 lea 0x0(%esi),%esi + memmove(mem, (char*)P2V(pa), PGSIZE); +80106c10: 81 c7 00 00 00 80 add $0x80000000,%edi +80106c16: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) +80106c1d: 00 +80106c1e: 89 7c 24 04 mov %edi,0x4(%esp) +80106c22: 89 04 24 mov %eax,(%esp) +80106c25: e8 f6 d6 ff ff call 80104320 + if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) +80106c2a: 8b 45 e4 mov -0x1c(%ebp),%eax +80106c2d: 8d 96 00 00 00 80 lea -0x80000000(%esi),%edx +80106c33: 89 14 24 mov %edx,(%esp) +80106c36: b9 00 10 00 00 mov $0x1000,%ecx +80106c3b: 89 da mov %ebx,%edx +80106c3d: 89 44 24 04 mov %eax,0x4(%esp) +80106c41: 8b 45 e0 mov -0x20(%ebp),%eax +80106c44: e8 07 f8 ff ff call 80106450 +80106c49: 85 c0 test %eax,%eax +80106c4b: 78 94 js 80106be1 + for(i = KERNBASE - (num_pages * PGSIZE * 2); i < KERNBASE; i += PGSIZE){ +80106c4d: 81 c3 00 10 00 00 add $0x1000,%ebx +80106c53: 78 48 js 80106c9d + if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) +80106c55: 8b 45 08 mov 0x8(%ebp),%eax +80106c58: 31 c9 xor %ecx,%ecx +80106c5a: 89 da mov %ebx,%edx +80106c5c: e8 5f f7 ff ff call 801063c0 +80106c61: 85 c0 test %eax,%eax +80106c63: 74 56 je 80106cbb + if(!(*pte & PTE_P)) +80106c65: 8b 30 mov (%eax),%esi +80106c67: f7 c6 01 00 00 00 test $0x1,%esi +80106c6d: 74 40 je 80106caf + pa = PTE_ADDR(*pte); +80106c6f: 89 f7 mov %esi,%edi + flags = PTE_FLAGS(*pte); +80106c71: 81 e6 ff 0f 00 00 and $0xfff,%esi +80106c77: 89 75 e4 mov %esi,-0x1c(%ebp) + pa = PTE_ADDR(*pte); +80106c7a: 81 e7 00 f0 ff ff and $0xfffff000,%edi + if((mem = kalloc()) == 0) +80106c80: e8 1b b8 ff ff call 801024a0 +80106c85: 85 c0 test %eax,%eax +80106c87: 89 c6 mov %eax,%esi +80106c89: 75 85 jne 80106c10 +80106c8b: e9 51 ff ff ff jmp 80106be1 + kfree(mem); +80106c90: 89 1c 24 mov %ebx,(%esp) +80106c93: e8 58 b6 ff ff call 801022f0 + goto bad; +80106c98: e9 44 ff ff ff jmp 80106be1 +80106c9d: 8b 45 e0 mov -0x20(%ebp),%eax +} +80106ca0: 83 c4 2c add $0x2c,%esp +80106ca3: 5b pop %ebx +80106ca4: 5e pop %esi +80106ca5: 5f pop %edi +80106ca6: 5d pop %ebp +80106ca7: c3 ret + return 0; +80106ca8: 31 c0 xor %eax,%eax +80106caa: e9 3f ff ff ff jmp 80106bee + panic("copyuvm: page not present"); +80106caf: c7 04 24 46 78 10 80 movl $0x80107846,(%esp) +80106cb6: e8 a5 96 ff ff call 80100360 + panic("copyuvm: pte should exist"); +80106cbb: c7 04 24 2c 78 10 80 movl $0x8010782c,(%esp) +80106cc2: e8 99 96 ff ff call 80100360 +80106cc7: 89 f6 mov %esi,%esi +80106cc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80106cd0 : + +//PAGEBREAK! +// Map user virtual address to kernel address. +char* +uva2ka(pde_t *pgdir, char *uva) +{ +80106cd0: 55 push %ebp + pte_t *pte; + + pte = walkpgdir(pgdir, uva, 0); +80106cd1: 31 c9 xor %ecx,%ecx +{ +80106cd3: 89 e5 mov %esp,%ebp +80106cd5: 83 ec 08 sub $0x8,%esp + pte = walkpgdir(pgdir, uva, 0); +80106cd8: 8b 55 0c mov 0xc(%ebp),%edx +80106cdb: 8b 45 08 mov 0x8(%ebp),%eax +80106cde: e8 dd f6 ff ff call 801063c0 + if((*pte & PTE_P) == 0) +80106ce3: 8b 00 mov (%eax),%eax +80106ce5: 89 c2 mov %eax,%edx +80106ce7: 83 e2 05 and $0x5,%edx + return 0; + if((*pte & PTE_U) == 0) +80106cea: 83 fa 05 cmp $0x5,%edx +80106ced: 75 11 jne 80106d00 + return 0; + return (char*)P2V(PTE_ADDR(*pte)); +80106cef: 25 00 f0 ff ff and $0xfffff000,%eax +80106cf4: 05 00 00 00 80 add $0x80000000,%eax +} +80106cf9: c9 leave +80106cfa: c3 ret +80106cfb: 90 nop +80106cfc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return 0; +80106d00: 31 c0 xor %eax,%eax +} +80106d02: c9 leave +80106d03: c3 ret +80106d04: 8d b6 00 00 00 00 lea 0x0(%esi),%esi +80106d0a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +80106d10 : +// Copy len bytes from p to user address va in page table pgdir. +// Most useful when pgdir is not the current page table. +// uva2ka ensures this only works for PTE_U pages. +int +copyout(pde_t *pgdir, uint va, void *p, uint len) +{ +80106d10: 55 push %ebp +80106d11: 89 e5 mov %esp,%ebp +80106d13: 57 push %edi +80106d14: 56 push %esi +80106d15: 53 push %ebx +80106d16: 83 ec 1c sub $0x1c,%esp +80106d19: 8b 5d 14 mov 0x14(%ebp),%ebx +80106d1c: 8b 4d 0c mov 0xc(%ebp),%ecx +80106d1f: 8b 7d 10 mov 0x10(%ebp),%edi + char *buf, *pa0; + uint n, va0; + + buf = (char*)p; + while(len > 0){ +80106d22: 85 db test %ebx,%ebx +80106d24: 75 3a jne 80106d60 +80106d26: eb 68 jmp 80106d90 + va0 = (uint)PGROUNDDOWN(va); + pa0 = uva2ka(pgdir, (char*)va0); + if(pa0 == 0) + return -1; + n = PGSIZE - (va - va0); +80106d28: 8b 4d e4 mov -0x1c(%ebp),%ecx +80106d2b: 89 f2 mov %esi,%edx + if(n > len) + n = len; + memmove(pa0 + (va - va0), buf, n); +80106d2d: 89 7c 24 04 mov %edi,0x4(%esp) + n = PGSIZE - (va - va0); +80106d31: 29 ca sub %ecx,%edx +80106d33: 81 c2 00 10 00 00 add $0x1000,%edx +80106d39: 39 da cmp %ebx,%edx +80106d3b: 0f 47 d3 cmova %ebx,%edx + memmove(pa0 + (va - va0), buf, n); +80106d3e: 29 f1 sub %esi,%ecx +80106d40: 01 c8 add %ecx,%eax +80106d42: 89 54 24 08 mov %edx,0x8(%esp) +80106d46: 89 04 24 mov %eax,(%esp) +80106d49: 89 55 e4 mov %edx,-0x1c(%ebp) +80106d4c: e8 cf d5 ff ff call 80104320 + len -= n; + buf += n; +80106d51: 8b 55 e4 mov -0x1c(%ebp),%edx + va = va0 + PGSIZE; +80106d54: 8d 8e 00 10 00 00 lea 0x1000(%esi),%ecx + buf += n; +80106d5a: 01 d7 add %edx,%edi + while(len > 0){ +80106d5c: 29 d3 sub %edx,%ebx +80106d5e: 74 30 je 80106d90 + pa0 = uva2ka(pgdir, (char*)va0); +80106d60: 8b 45 08 mov 0x8(%ebp),%eax + va0 = (uint)PGROUNDDOWN(va); +80106d63: 89 ce mov %ecx,%esi +80106d65: 81 e6 00 f0 ff ff and $0xfffff000,%esi + pa0 = uva2ka(pgdir, (char*)va0); +80106d6b: 89 74 24 04 mov %esi,0x4(%esp) + va0 = (uint)PGROUNDDOWN(va); +80106d6f: 89 4d e4 mov %ecx,-0x1c(%ebp) + pa0 = uva2ka(pgdir, (char*)va0); +80106d72: 89 04 24 mov %eax,(%esp) +80106d75: e8 56 ff ff ff call 80106cd0 + if(pa0 == 0) +80106d7a: 85 c0 test %eax,%eax +80106d7c: 75 aa jne 80106d28 + } + return 0; +} +80106d7e: 83 c4 1c add $0x1c,%esp + return -1; +80106d81: b8 ff ff ff ff mov $0xffffffff,%eax +} +80106d86: 5b pop %ebx +80106d87: 5e pop %esi +80106d88: 5f pop %edi +80106d89: 5d pop %ebp +80106d8a: c3 ret +80106d8b: 90 nop +80106d8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi +80106d90: 83 c4 1c add $0x1c,%esp + return 0; +80106d93: 31 c0 xor %eax,%eax +} +80106d95: 5b pop %ebx +80106d96: 5e pop %esi +80106d97: 5f pop %edi +80106d98: 5d pop %ebp +80106d99: c3 ret +80106d9a: 66 90 xchg %ax,%ax +80106d9c: 66 90 xchg %ax,%ax +80106d9e: 66 90 xchg %ax,%ax + +80106da0 : + char *frame; + int refcnt; + } shm_pages[64]; +} shm_table; + +void shminit() { +80106da0: 55 push %ebp +80106da1: 89 e5 mov %esp,%ebp +80106da3: 83 ec 18 sub $0x18,%esp + int i; + initlock(&(shm_table.lock), "SHM lock"); +80106da6: c7 44 24 04 84 78 10 movl $0x80107884,0x4(%esp) +80106dad: 80 +80106dae: c7 04 24 e0 55 11 80 movl $0x801155e0,(%esp) +80106db5: e8 96 d2 ff ff call 80104050 + acquire(&(shm_table.lock)); +80106dba: c7 04 24 e0 55 11 80 movl $0x801155e0,(%esp) +80106dc1: e8 7a d3 ff ff call 80104140 +80106dc6: b8 14 56 11 80 mov $0x80115614,%eax +80106dcb: 90 nop +80106dcc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + for (i = 0; i< 64; i++) { + shm_table.shm_pages[i].id =0; +80106dd0: c7 00 00 00 00 00 movl $0x0,(%eax) +80106dd6: 83 c0 0c add $0xc,%eax + shm_table.shm_pages[i].frame =0; +80106dd9: c7 40 f8 00 00 00 00 movl $0x0,-0x8(%eax) + shm_table.shm_pages[i].refcnt =0; +80106de0: c7 40 fc 00 00 00 00 movl $0x0,-0x4(%eax) + for (i = 0; i< 64; i++) { +80106de7: 3d 14 59 11 80 cmp $0x80115914,%eax +80106dec: 75 e2 jne 80106dd0 + } + release(&(shm_table.lock)); +80106dee: c7 04 24 e0 55 11 80 movl $0x801155e0,(%esp) +80106df5: e8 36 d4 ff ff call 80104230 +} +80106dfa: c9 leave +80106dfb: c3 ret +80106dfc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +80106e00 : + +int shm_open(int id, char **pointer) { +80106e00: 55 push %ebp + + + + +return 0; //added to remove compiler warning -- you should decide what to return +} +80106e01: 31 c0 xor %eax,%eax +int shm_open(int id, char **pointer) { +80106e03: 89 e5 mov %esp,%ebp +} +80106e05: 5d pop %ebp +80106e06: c3 ret +80106e07: 89 f6 mov %esi,%esi +80106e09: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +80106e10 : + + +int shm_close(int id) { +80106e10: 55 push %ebp + + + + +return 0; //added to remove compiler warning -- you should decide what to return +} +80106e11: 31 c0 xor %eax,%eax +int shm_close(int id) { +80106e13: 89 e5 mov %esp,%ebp +} +80106e15: 5d pop %ebp +80106e16: c3 ret diff --git a/kernel.sym b/kernel.sym new file mode 100644 index 00000000..21fe4929 --- /dev/null +++ b/kernel.sym @@ -0,0 +1,529 @@ +80100000 .text +80106e20 .rodata +8010788d .stab +8010788e .stabstr +80108000 .data +8010a520 .bss +00000000 .debug_line +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_aranges +00000000 .debug_loc +00000000 .debug_ranges +00000000 .debug_str +00000000 .comment +00000000 bio.c +00000000 console.c +8010a520 cons +8010a558 panicked +801003e0 consputc +80100570 printint +80106e90 digits.1855 +00000000 exec.c +00000000 file.c +00000000 fs.c +801010f0 balloc +80101210 iget +801012d0 bmap +801013e0 bfree +80101c80 namex +00000000 ide.c +80101f40 idestart +8010a580 idelock +8010a560 havedisk1 +8010a564 idequeue +00000000 ioapic.c +00000000 kalloc.c +00000000 kbd.c +8010a5b4 shift.1695 +801071c0 shiftcode +801070c0 togglecode +801070a0 charcode.1696 +80108200 normalmap +80108100 shiftmap +80108000 ctlmap +00000000 lapic.c +801025f0 fill_rtcdate +00000000 log.c +80102960 install_trans +80102a00 write_head +00000000 main.c +80102d80 mpmain +80102dd0 mpenter +00000000 mp.c +80102f20 mpsearch1 +00000000 picirq.c +00000000 pipe.c +00000000 proc.c +801034c0 allocproc +8010a000 first.1897 +8010a5b8 initproc +80107480 states.1923 +00000000 sleeplock.c +00000000 spinlock.c +00000000 string.c +00000000 syscall.c +80107500 syscalls +00000000 sysfile.c +80104690 fdalloc +801046d0 create +80104850 argfd.constprop.0 +00000000 sysproc.c +00000000 trap.c +00000000 uart.c +80105810 uartgetc +8010a5bc uart +00000000 vm.c +801063c0 walkpgdir +80106450 mappages +801064d0 deallocuvm.part.0 +8010a420 kmap +00000000 shm.c +80100270 consoleread +8010630e vector242 +80105d65 vector119 +8010000c entry +80105c45 vector87 +80105c3c vector86 +80104460 safestrcpy +801049e0 sys_close +8010637a vector251 +80105c69 vector91 +80105a5f vector33 +80105f4e vector162 +80103bc0 yield +80112680 log +80112640 kmem +801061b2 vector213 +80105d02 vector108 +80105890 uartinit +80105ab9 vector43 +80102780 lapiceoi +80105f72 vector165 +80106062 vector185 +80102200 ioapicinit +80105d41 vector115 +80100f30 fileread +80105d80 vector122 +801052f0 sys_sbrk +80112760 ioapicid +80105f06 vector156 +80106332 vector245 +80112634 ioapic +80106092 vector189 +80105983 vector7 +80105b5b vector61 +80105a0e vector24 +80105d1d vector111 +80106116 vector200 +80105b91 vector67 +80105e2e vector138 +80105bd0 vector74 +80103a00 sched +80104320 memmove +80105b37 vector57 +801051d0 sys_shm_open +80104620 syscall +801061be vector214 +80105cb1 vector99 +80103680 cpuid +80101a60 writei +80105e52 vector141 +80105270 sys_fork +8010b5c0 bcache +80105fc6 vector172 +80106e00 shm_open +80106302 vector241 +80104070 getcallerpcs +80104ec0 sys_mkdir +80106392 vector253 +8010595f vector3 +80105956 vector2 +80101b90 namecmp +8010625a vector227 +8010618e vector210 +801045e0 argstr +80106236 vector224 +80105aa7 vector41 +80100650 cprintf +80100dd0 filedup +80101f00 namei +801059f3 vector21 +80100040 binit +80106002 vector177 +80105d5c vector118 +80105bac vector70 +80105ba3 vector69 +801062d2 vector237 +80105b76 vector64 +80105a29 vector27 +80105de6 vector132 +8010606e vector186 +80104900 sys_read +801061e2 vector217 +801044d0 fetchint +80106a50 setupkvm +80104390 memcpy +801069d0 freevm +8010594d vector1 +8010600e vector178 +80105a8c vector38 +801022f0 kfree +801062de vector238 +80103600 mycpu +801017d0 iput +80105df2 vector133 +80105bc7 vector73 +80105e76 vector144 +8010639e vector254 +80101390 readsb +8010a004 nextpid +80114d60 last +80105cc3 vector101 +8010619a vector211 +80102f90 mpinit +80105fde vector174 +8010631a vector243 +80100d40 fileinit +80104050 initlock +80105db6 vector128 +80106d10 copyout +80105c0f vector81 +80103c00 sleep +801155e0 shm_table +801027a0 microdelay +801059b1 vector13 +80105b01 vector51 +801059c8 vector16 +8010ff20 input +801062f6 vector240 +80105b1c vector54 +801059e1 vector19 +80105c72 vector92 +80106326 vector244 +80101930 stati +80105e46 vector140 +801052a0 sys_kill +80105acb vector45 +80105bfd vector79 +80103260 pipeclose +80106272 vector229 +80105f1e vector158 +80104a20 sys_fstat +801005f0 consolewrite +80105a95 vector39 +80105f96 vector168 +80102b80 end_op +80105a71 vector35 +80105d2f vector113 +80102390 freerange +80105d9b vector125 +801068a0 allocuvm +80105435 trapret +801061d6 vector216 +80105b6d vector63 +80105a20 vector26 +801060c2 vector193 +80102670 lapicinit +801060e6 vector196 +80106182 vector209 +80105968 vector4 +80105fae vector170 +8010a5c0 stack +80105e16 vector136 +8010599c vector10 +8010615e vector206 +80101790 iunlock +80105340 sys_sleep +801063aa vector255 +80106032 vector181 +80105b49 vector59 +80105c33 vector85 +80105c2a vector84 +8010604a vector183 +80105f2a vector159 +801061a6 vector212 +80104a70 sys_link +80105add vector47 +80106266 vector228 +80105ab0 vector42 +80105d38 vector114 +80106cd0 uva2ka +80105fea vector175 +80105e6a vector143 +80100d60 filealloc +80103d90 wakeup +80105dce vector130 +8010633e vector246 +80105230 sys_shm_close +80105993 vector9 +80105e5e vector142 +80105cba vector100 +80106122 vector201 +80106b00 clearpteu +80114d64 top +801036a0 myproc +80105440 tvinit +80105b52 vector60 +80105a05 vector23 +80101680 idup +801062c6 vector236 +801025d0 kbdintr +80104d80 sys_open +8010628a vector231 +80105b88 vector66 +80105a3b vector29 +80101960 readi +80105e0a vector135 +801007b0 consoleintr +80103df0 kill +80105beb vector77 +80101520 ialloc +80106026 vector180 +801155c4 kpgdir +80106176 vector208 +80102840 cmostime +80105930 uartintr +80105ca8 vector98 +80105c9f vector97 +80105ff6 vector176 +801060ce vector194 +80105a56 vector32 +80115914 end +8010610a vector199 +80105dda vector131 +80106386 vector252 +80100fd0 filewrite +80105944 vector0 +80104550 argint +801009a0 exec +80105e82 vector145 +80104970 sys_write +80104230 release +801044f0 fetchstr +80105cf9 vector107 +80105a9e vector40 +80103cb0 wait +80105ccc vector102 +80109000 entrypgdir +0010000c _start +80105b2e vector56 +80105b9a vector68 +8010597a vector6 +8010a48c _binary_initcode_end +80100000 multiboot_header +80105dc2 vector129 +80103960 scheduler +80101bc0 dirlookup +801060f2 vector197 +80100e20 fileclose +80102b10 begin_op +80105ed6 vector152 +80114d68 bottom +80106ae0 kvmalloc +8010627e vector230 +801043a0 strncmp +80105a83 vector37 +80106152 vector205 +80105f42 vector161 +80114d80 tickslock +801032f0 pipewrite +80104410 strncpy +80105bb5 vector71 +80106b30 copyuvm +8010ffc0 ftable +80105f36 vector160 +80104590 argptr +801061ca vector215 +80105f12 vector157 +801048c0 sys_dup +80105d26 vector112 +80100360 panic +80103590 forkret +8010603e vector182 +801059aa vector12 +801042d0 memcmp +80102500 kbdgetc +80105d0b vector109 +801059ea vector20 +80103850 fork +80105b13 vector53 +801059d8 vector18 +0000008a _binary_entryother_size +80112780 cpus +80103fe0 releasesleep +80105c8d vector95 +801040d0 holding +801109c0 sb +80104140 acquire +8010624e vector226 +80106da0 shminit +80101f20 nameiparent +80105aef vector49 +80105ac2 vector44 +8011267c lapic +80105bf4 vector78 +8010541d alltraps +80105fd2 vector173 +80105d53 vector117 +80106e10 shm_close +80105c18 vector82 +8010621e vector222 +8010598c vector8 +80105eb2 vector149 +801015f0 iupdate +80108000 data +80104280 memset +80106296 vector232 +80102df0 main +80106630 switchkvm +80105cf0 vector106 +80106206 vector220 +80105c60 vector90 +80105f5a vector163 +801062ae vector234 +80102cb0 log_write +80103f80 acquiresleep +80104b90 sys_unlink +80105b64 vector62 +80105a17 vector25 +801060fe vector198 +80105d6e vector120 +8010a48c _binary_entryother_start +801023e0 kinit1 +80105af8 vector50 +801059bf vector15 +80105eca vector151 +80105c21 vector83 +80105c57 vector89 +80105c4e vector88 +80105510 trap +801053f0 sys_uptime +8010601a vector179 +80105a68 vector34 +80105ad4 vector46 +80105dfe vector134 +8010622a vector223 +80114dc0 idt +801061ee vector218 +801035e0 pinit +801069b0 deallocuvm +80106242 vector225 +80102760 lapicid +8010607a vector187 +801037e0 growproc +80104020 holdingsleep +80112d00 ncpu +80105a44 vector30 +801036d0 userinit +801000d0 bread +80105dad vector127 +801033e0 piperead +801155c0 ticks +801060b6 vector192 +80105f7e vector166 +80100950 consoleinit +80105be2 vector76 +80105bd9 vector75 +80102080 ideintr +801060da vector195 +80105ebe vector150 +80105b40 vector58 +80106356 vector248 +80105d89 vector123 +80105c96 vector96 +80105a4d vector31 +8010613a vector203 +80105e3a vector139 +80105ee2 vector153 +80105f66 vector164 +80103e70 procdump +80105d77 vector121 +80105840 uartputc +80105971 vector5 +80105f8a vector167 +80105efa vector155 +80106362 vector249 +801001e0 brelse +8010636e vector250 +80105d92 vector124 +80105d14 vector110 +80106146 vector204 +801016b0 ilock +80105040 sys_exec +80105e22 vector137 +8010a460 _binary_initcode_start +801044bb swtch +8010634a vector247 +801059fc vector22 +8010612e vector202 +80106570 seginit +80101910 iunlockput +80105bbe vector72 +80105b25 vector55 +80105da4 vector126 +80105b7f vector65 +80105a32 vector28 +8010a516 _binary_entryother_end +80105fa2 vector169 +801001a0 bwrite +801062a2 vector233 +801054e0 idtinit +80103aa0 exit +80105290 sys_wait +80105280 sys_exit +80101e20 dirlink +0000002c _binary_initcode_size +80105e9a vector147 +80103f40 initsleeplock +80102000 ideinit +801067e0 loaduvm +80105cde vector104 +80105d4a vector116 +80112d20 ptable +801022b0 ioapicenable +801041c0 popcli +8010a008 vectors +80105b0a vector52 +801059d1 vector17 +80106056 vector184 +801044a0 strlen +80105130 sys_pipe +80101470 iinit +80103150 picinit +8010616a vector207 +80106760 inituvm +8010609e vector190 +801062ea vector239 +80105c84 vector94 +80105c7b vector93 +80102a70 initlog +80106086 vector188 +80105ae6 vector48 +80102120 iderw +801061fa vector219 +80105ea6 vector148 +80106212 vector221 +801024a0 kalloc +80110960 devsw +801052e0 sys_getpid +80105c06 vector80 +80105fba vector171 +80105eee vector154 +80105a7a vector36 +80103170 pipealloc +801062ba vector235 +80105ce7 vector105 +80104fb0 sys_chdir +801109e0 icache +80105e8e vector146 +801060aa vector191 +80105cd5 vector103 +80104f20 sys_mknod +801027b0 lapicstartap +80106650 switchuvm +80104100 pushcli +80102450 kinit2 +801059a3 vector11 +801059b8 vector14 +80100ee0 filestat diff --git a/kill.asm b/kill.asm new file mode 100644 index 00000000..abb7b697 --- /dev/null +++ b/kill.asm @@ -0,0 +1,1222 @@ + +_kill: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: +#include "stat.h" +#include "user.h" + +int +main(int argc, char **argv) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 57 push %edi + 1004: 56 push %esi + 1005: 53 push %ebx + int i; + + if(argc < 2){ + 1006: bb 01 00 00 00 mov $0x1,%ebx +{ + 100b: 83 e4 f0 and $0xfffffff0,%esp + 100e: 83 ec 10 sub $0x10,%esp + 1011: 8b 75 08 mov 0x8(%ebp),%esi + 1014: 8b 7d 0c mov 0xc(%ebp),%edi + if(argc < 2){ + 1017: 83 fe 01 cmp $0x1,%esi + 101a: 7e 23 jle 103f + 101c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + printf(2, "usage: kill pid...\n"); + exit(); + } + for(i=1; i + 102e: 89 04 24 mov %eax,(%esp) + 1031: e8 7c 02 00 00 call 12b2 + for(i=1; i + exit(); + 103a: e8 43 02 00 00 call 1282 + printf(2, "usage: kill pid...\n"); + 103f: c7 44 24 04 81 17 00 movl $0x1781,0x4(%esp) + 1046: 00 + 1047: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 104e: e8 8d 03 00 00 call 13e0 + exit(); + 1053: e8 2a 02 00 00 call 1282 + 1058: 66 90 xchg %ax,%ax + 105a: 66 90 xchg %ax,%ax + 105c: 66 90 xchg %ax,%ax + 105e: 66 90 xchg %ax,%ax + +00001060 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1060: 55 push %ebp + 1061: 89 e5 mov %esp,%ebp + 1063: 8b 45 08 mov 0x8(%ebp),%eax + 1066: 8b 4d 0c mov 0xc(%ebp),%ecx + 1069: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 106a: 89 c2 mov %eax,%edx + 106c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1070: 83 c1 01 add $0x1,%ecx + 1073: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1077: 83 c2 01 add $0x1,%edx + 107a: 84 db test %bl,%bl + 107c: 88 5a ff mov %bl,-0x1(%edx) + 107f: 75 ef jne 1070 + ; + return os; +} + 1081: 5b pop %ebx + 1082: 5d pop %ebp + 1083: c3 ret + 1084: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 108a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001090 : + +int +strcmp(const char *p, const char *q) +{ + 1090: 55 push %ebp + 1091: 89 e5 mov %esp,%ebp + 1093: 8b 55 08 mov 0x8(%ebp),%edx + 1096: 53 push %ebx + 1097: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 109a: 0f b6 02 movzbl (%edx),%eax + 109d: 84 c0 test %al,%al + 109f: 74 2d je 10ce + 10a1: 0f b6 19 movzbl (%ecx),%ebx + 10a4: 38 d8 cmp %bl,%al + 10a6: 74 0e je 10b6 + 10a8: eb 2b jmp 10d5 + 10aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 10b0: 38 c8 cmp %cl,%al + 10b2: 75 15 jne 10c9 + p++, q++; + 10b4: 89 d9 mov %ebx,%ecx + 10b6: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 10b9: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 10bc: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 10bf: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 10c3: 84 c0 test %al,%al + 10c5: 75 e9 jne 10b0 + 10c7: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 10c9: 29 c8 sub %ecx,%eax +} + 10cb: 5b pop %ebx + 10cc: 5d pop %ebp + 10cd: c3 ret + 10ce: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 10d1: 31 c0 xor %eax,%eax + 10d3: eb f4 jmp 10c9 + 10d5: 0f b6 cb movzbl %bl,%ecx + 10d8: eb ef jmp 10c9 + 10da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +000010e0 : + +uint +strlen(char *s) +{ + 10e0: 55 push %ebp + 10e1: 89 e5 mov %esp,%ebp + 10e3: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 10e6: 80 39 00 cmpb $0x0,(%ecx) + 10e9: 74 12 je 10fd + 10eb: 31 d2 xor %edx,%edx + 10ed: 8d 76 00 lea 0x0(%esi),%esi + 10f0: 83 c2 01 add $0x1,%edx + 10f3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 10f7: 89 d0 mov %edx,%eax + 10f9: 75 f5 jne 10f0 + ; + return n; +} + 10fb: 5d pop %ebp + 10fc: c3 ret + for(n = 0; s[n]; n++) + 10fd: 31 c0 xor %eax,%eax +} + 10ff: 5d pop %ebp + 1100: c3 ret + 1101: eb 0d jmp 1110 + 1103: 90 nop + 1104: 90 nop + 1105: 90 nop + 1106: 90 nop + 1107: 90 nop + 1108: 90 nop + 1109: 90 nop + 110a: 90 nop + 110b: 90 nop + 110c: 90 nop + 110d: 90 nop + 110e: 90 nop + 110f: 90 nop + +00001110 : + +void* +memset(void *dst, int c, uint n) +{ + 1110: 55 push %ebp + 1111: 89 e5 mov %esp,%ebp + 1113: 8b 55 08 mov 0x8(%ebp),%edx + 1116: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 1117: 8b 4d 10 mov 0x10(%ebp),%ecx + 111a: 8b 45 0c mov 0xc(%ebp),%eax + 111d: 89 d7 mov %edx,%edi + 111f: fc cld + 1120: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1122: 89 d0 mov %edx,%eax + 1124: 5f pop %edi + 1125: 5d pop %ebp + 1126: c3 ret + 1127: 89 f6 mov %esi,%esi + 1129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001130 : + +char* +strchr(const char *s, char c) +{ + 1130: 55 push %ebp + 1131: 89 e5 mov %esp,%ebp + 1133: 8b 45 08 mov 0x8(%ebp),%eax + 1136: 53 push %ebx + 1137: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 113a: 0f b6 18 movzbl (%eax),%ebx + 113d: 84 db test %bl,%bl + 113f: 74 1d je 115e + if(*s == c) + 1141: 38 d3 cmp %dl,%bl + 1143: 89 d1 mov %edx,%ecx + 1145: 75 0d jne 1154 + 1147: eb 17 jmp 1160 + 1149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1150: 38 ca cmp %cl,%dl + 1152: 74 0c je 1160 + for(; *s; s++) + 1154: 83 c0 01 add $0x1,%eax + 1157: 0f b6 10 movzbl (%eax),%edx + 115a: 84 d2 test %dl,%dl + 115c: 75 f2 jne 1150 + return (char*)s; + return 0; + 115e: 31 c0 xor %eax,%eax +} + 1160: 5b pop %ebx + 1161: 5d pop %ebp + 1162: c3 ret + 1163: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001170 : + +char* +gets(char *buf, int max) +{ + 1170: 55 push %ebp + 1171: 89 e5 mov %esp,%ebp + 1173: 57 push %edi + 1174: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1175: 31 f6 xor %esi,%esi +{ + 1177: 53 push %ebx + 1178: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 117b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 117e: eb 31 jmp 11b1 + cc = read(0, &c, 1); + 1180: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1187: 00 + 1188: 89 7c 24 04 mov %edi,0x4(%esp) + 118c: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1193: e8 02 01 00 00 call 129a + if(cc < 1) + 1198: 85 c0 test %eax,%eax + 119a: 7e 1d jle 11b9 + break; + buf[i++] = c; + 119c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 11a0: 89 de mov %ebx,%esi + buf[i++] = c; + 11a2: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 11a5: 3c 0d cmp $0xd,%al + buf[i++] = c; + 11a7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 11ab: 74 0c je 11b9 + 11ad: 3c 0a cmp $0xa,%al + 11af: 74 08 je 11b9 + for(i=0; i+1 < max; ){ + 11b1: 8d 5e 01 lea 0x1(%esi),%ebx + 11b4: 3b 5d 0c cmp 0xc(%ebp),%ebx + 11b7: 7c c7 jl 1180 + break; + } + buf[i] = '\0'; + 11b9: 8b 45 08 mov 0x8(%ebp),%eax + 11bc: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 11c0: 83 c4 2c add $0x2c,%esp + 11c3: 5b pop %ebx + 11c4: 5e pop %esi + 11c5: 5f pop %edi + 11c6: 5d pop %ebp + 11c7: c3 ret + 11c8: 90 nop + 11c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000011d0 : + +int +stat(char *n, struct stat *st) +{ + 11d0: 55 push %ebp + 11d1: 89 e5 mov %esp,%ebp + 11d3: 56 push %esi + 11d4: 53 push %ebx + 11d5: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 11d8: 8b 45 08 mov 0x8(%ebp),%eax + 11db: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 11e2: 00 + 11e3: 89 04 24 mov %eax,(%esp) + 11e6: e8 d7 00 00 00 call 12c2 + if(fd < 0) + 11eb: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 11ed: 89 c3 mov %eax,%ebx + if(fd < 0) + 11ef: 78 27 js 1218 + return -1; + r = fstat(fd, st); + 11f1: 8b 45 0c mov 0xc(%ebp),%eax + 11f4: 89 1c 24 mov %ebx,(%esp) + 11f7: 89 44 24 04 mov %eax,0x4(%esp) + 11fb: e8 da 00 00 00 call 12da + close(fd); + 1200: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 1203: 89 c6 mov %eax,%esi + close(fd); + 1205: e8 a0 00 00 00 call 12aa + return r; + 120a: 89 f0 mov %esi,%eax +} + 120c: 83 c4 10 add $0x10,%esp + 120f: 5b pop %ebx + 1210: 5e pop %esi + 1211: 5d pop %ebp + 1212: c3 ret + 1213: 90 nop + 1214: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 1218: b8 ff ff ff ff mov $0xffffffff,%eax + 121d: eb ed jmp 120c + 121f: 90 nop + +00001220 : + +int +atoi(const char *s) +{ + 1220: 55 push %ebp + 1221: 89 e5 mov %esp,%ebp + 1223: 8b 4d 08 mov 0x8(%ebp),%ecx + 1226: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 1227: 0f be 11 movsbl (%ecx),%edx + 122a: 8d 42 d0 lea -0x30(%edx),%eax + 122d: 3c 09 cmp $0x9,%al + n = 0; + 122f: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 1234: 77 17 ja 124d + 1236: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 1238: 83 c1 01 add $0x1,%ecx + 123b: 8d 04 80 lea (%eax,%eax,4),%eax + 123e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1242: 0f be 11 movsbl (%ecx),%edx + 1245: 8d 5a d0 lea -0x30(%edx),%ebx + 1248: 80 fb 09 cmp $0x9,%bl + 124b: 76 eb jbe 1238 + return n; +} + 124d: 5b pop %ebx + 124e: 5d pop %ebp + 124f: c3 ret + +00001250 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1250: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1251: 31 d2 xor %edx,%edx +{ + 1253: 89 e5 mov %esp,%ebp + 1255: 56 push %esi + 1256: 8b 45 08 mov 0x8(%ebp),%eax + 1259: 53 push %ebx + 125a: 8b 5d 10 mov 0x10(%ebp),%ebx + 125d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1260: 85 db test %ebx,%ebx + 1262: 7e 12 jle 1276 + 1264: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1268: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 126c: 88 0c 10 mov %cl,(%eax,%edx,1) + 126f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1272: 39 da cmp %ebx,%edx + 1274: 75 f2 jne 1268 + return vdst; +} + 1276: 5b pop %ebx + 1277: 5e pop %esi + 1278: 5d pop %ebp + 1279: c3 ret + +0000127a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 127a: b8 01 00 00 00 mov $0x1,%eax + 127f: cd 40 int $0x40 + 1281: c3 ret + +00001282 : +SYSCALL(exit) + 1282: b8 02 00 00 00 mov $0x2,%eax + 1287: cd 40 int $0x40 + 1289: c3 ret + +0000128a : +SYSCALL(wait) + 128a: b8 03 00 00 00 mov $0x3,%eax + 128f: cd 40 int $0x40 + 1291: c3 ret + +00001292 : +SYSCALL(pipe) + 1292: b8 04 00 00 00 mov $0x4,%eax + 1297: cd 40 int $0x40 + 1299: c3 ret + +0000129a : +SYSCALL(read) + 129a: b8 05 00 00 00 mov $0x5,%eax + 129f: cd 40 int $0x40 + 12a1: c3 ret + +000012a2 : +SYSCALL(write) + 12a2: b8 10 00 00 00 mov $0x10,%eax + 12a7: cd 40 int $0x40 + 12a9: c3 ret + +000012aa : +SYSCALL(close) + 12aa: b8 15 00 00 00 mov $0x15,%eax + 12af: cd 40 int $0x40 + 12b1: c3 ret + +000012b2 : +SYSCALL(kill) + 12b2: b8 06 00 00 00 mov $0x6,%eax + 12b7: cd 40 int $0x40 + 12b9: c3 ret + +000012ba : +SYSCALL(exec) + 12ba: b8 07 00 00 00 mov $0x7,%eax + 12bf: cd 40 int $0x40 + 12c1: c3 ret + +000012c2 : +SYSCALL(open) + 12c2: b8 0f 00 00 00 mov $0xf,%eax + 12c7: cd 40 int $0x40 + 12c9: c3 ret + +000012ca : +SYSCALL(mknod) + 12ca: b8 11 00 00 00 mov $0x11,%eax + 12cf: cd 40 int $0x40 + 12d1: c3 ret + +000012d2 : +SYSCALL(unlink) + 12d2: b8 12 00 00 00 mov $0x12,%eax + 12d7: cd 40 int $0x40 + 12d9: c3 ret + +000012da : +SYSCALL(fstat) + 12da: b8 08 00 00 00 mov $0x8,%eax + 12df: cd 40 int $0x40 + 12e1: c3 ret + +000012e2 : +SYSCALL(link) + 12e2: b8 13 00 00 00 mov $0x13,%eax + 12e7: cd 40 int $0x40 + 12e9: c3 ret + +000012ea : +SYSCALL(mkdir) + 12ea: b8 14 00 00 00 mov $0x14,%eax + 12ef: cd 40 int $0x40 + 12f1: c3 ret + +000012f2 : +SYSCALL(chdir) + 12f2: b8 09 00 00 00 mov $0x9,%eax + 12f7: cd 40 int $0x40 + 12f9: c3 ret + +000012fa : +SYSCALL(dup) + 12fa: b8 0a 00 00 00 mov $0xa,%eax + 12ff: cd 40 int $0x40 + 1301: c3 ret + +00001302 : +SYSCALL(getpid) + 1302: b8 0b 00 00 00 mov $0xb,%eax + 1307: cd 40 int $0x40 + 1309: c3 ret + +0000130a : +SYSCALL(sbrk) + 130a: b8 0c 00 00 00 mov $0xc,%eax + 130f: cd 40 int $0x40 + 1311: c3 ret + +00001312 : +SYSCALL(sleep) + 1312: b8 0d 00 00 00 mov $0xd,%eax + 1317: cd 40 int $0x40 + 1319: c3 ret + +0000131a : +SYSCALL(uptime) + 131a: b8 0e 00 00 00 mov $0xe,%eax + 131f: cd 40 int $0x40 + 1321: c3 ret + +00001322 : +SYSCALL(shm_open) + 1322: b8 16 00 00 00 mov $0x16,%eax + 1327: cd 40 int $0x40 + 1329: c3 ret + +0000132a : +SYSCALL(shm_close) + 132a: b8 17 00 00 00 mov $0x17,%eax + 132f: cd 40 int $0x40 + 1331: c3 ret + 1332: 66 90 xchg %ax,%ax + 1334: 66 90 xchg %ax,%ax + 1336: 66 90 xchg %ax,%ax + 1338: 66 90 xchg %ax,%ax + 133a: 66 90 xchg %ax,%ax + 133c: 66 90 xchg %ax,%ax + 133e: 66 90 xchg %ax,%ax + +00001340 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 1340: 55 push %ebp + 1341: 89 e5 mov %esp,%ebp + 1343: 57 push %edi + 1344: 56 push %esi + 1345: 89 c6 mov %eax,%esi + 1347: 53 push %ebx + 1348: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 134b: 8b 5d 08 mov 0x8(%ebp),%ebx + 134e: 85 db test %ebx,%ebx + 1350: 74 09 je 135b + 1352: 89 d0 mov %edx,%eax + 1354: c1 e8 1f shr $0x1f,%eax + 1357: 84 c0 test %al,%al + 1359: 75 75 jne 13d0 + neg = 1; + x = -xx; + } else { + x = xx; + 135b: 89 d0 mov %edx,%eax + neg = 0; + 135d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1364: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1367: 31 ff xor %edi,%edi + 1369: 89 ce mov %ecx,%esi + 136b: 8d 5d d7 lea -0x29(%ebp),%ebx + 136e: eb 02 jmp 1372 + do{ + buf[i++] = digits[x % base]; + 1370: 89 cf mov %ecx,%edi + 1372: 31 d2 xor %edx,%edx + 1374: f7 f6 div %esi + 1376: 8d 4f 01 lea 0x1(%edi),%ecx + 1379: 0f b6 92 9c 17 00 00 movzbl 0x179c(%edx),%edx + }while((x /= base) != 0); + 1380: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 1382: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 1385: 75 e9 jne 1370 + if(neg) + 1387: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 138a: 89 c8 mov %ecx,%eax + 138c: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 138f: 85 d2 test %edx,%edx + 1391: 74 08 je 139b + buf[i++] = '-'; + 1393: 8d 4f 02 lea 0x2(%edi),%ecx + 1396: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 139b: 8d 79 ff lea -0x1(%ecx),%edi + 139e: 66 90 xchg %ax,%ax + 13a0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 13a5: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 13a8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 13af: 00 + 13b0: 89 5c 24 04 mov %ebx,0x4(%esp) + 13b4: 89 34 24 mov %esi,(%esp) + 13b7: 88 45 d7 mov %al,-0x29(%ebp) + 13ba: e8 e3 fe ff ff call 12a2 + while(--i >= 0) + 13bf: 83 ff ff cmp $0xffffffff,%edi + 13c2: 75 dc jne 13a0 + putc(fd, buf[i]); +} + 13c4: 83 c4 4c add $0x4c,%esp + 13c7: 5b pop %ebx + 13c8: 5e pop %esi + 13c9: 5f pop %edi + 13ca: 5d pop %ebp + 13cb: c3 ret + 13cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 13d0: 89 d0 mov %edx,%eax + 13d2: f7 d8 neg %eax + neg = 1; + 13d4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 13db: eb 87 jmp 1364 + 13dd: 8d 76 00 lea 0x0(%esi),%esi + +000013e0 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 13e0: 55 push %ebp + 13e1: 89 e5 mov %esp,%ebp + 13e3: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 13e4: 31 ff xor %edi,%edi +{ + 13e6: 56 push %esi + 13e7: 53 push %ebx + 13e8: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 13eb: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 13ee: 8d 45 10 lea 0x10(%ebp),%eax +{ + 13f1: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 13f4: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 13f7: 0f b6 13 movzbl (%ebx),%edx + 13fa: 83 c3 01 add $0x1,%ebx + 13fd: 84 d2 test %dl,%dl + 13ff: 75 39 jne 143a + 1401: e9 c2 00 00 00 jmp 14c8 + 1406: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 1408: 83 fa 25 cmp $0x25,%edx + 140b: 0f 84 bf 00 00 00 je 14d0 + write(fd, &c, 1); + 1411: 8d 45 e2 lea -0x1e(%ebp),%eax + 1414: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 141b: 00 + 141c: 89 44 24 04 mov %eax,0x4(%esp) + 1420: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 1423: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 1426: e8 77 fe ff ff call 12a2 + 142b: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 142e: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 1432: 84 d2 test %dl,%dl + 1434: 0f 84 8e 00 00 00 je 14c8 + if(state == 0){ + 143a: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 143c: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 143f: 74 c7 je 1408 + } + } else if(state == '%'){ + 1441: 83 ff 25 cmp $0x25,%edi + 1444: 75 e5 jne 142b + if(c == 'd'){ + 1446: 83 fa 64 cmp $0x64,%edx + 1449: 0f 84 31 01 00 00 je 1580 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 144f: 25 f7 00 00 00 and $0xf7,%eax + 1454: 83 f8 70 cmp $0x70,%eax + 1457: 0f 84 83 00 00 00 je 14e0 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 145d: 83 fa 73 cmp $0x73,%edx + 1460: 0f 84 a2 00 00 00 je 1508 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1466: 83 fa 63 cmp $0x63,%edx + 1469: 0f 84 35 01 00 00 je 15a4 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 146f: 83 fa 25 cmp $0x25,%edx + 1472: 0f 84 e0 00 00 00 je 1558 + write(fd, &c, 1); + 1478: 8d 45 e6 lea -0x1a(%ebp),%eax + 147b: 83 c3 01 add $0x1,%ebx + 147e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1485: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 1486: 31 ff xor %edi,%edi + write(fd, &c, 1); + 1488: 89 44 24 04 mov %eax,0x4(%esp) + 148c: 89 34 24 mov %esi,(%esp) + 148f: 89 55 d0 mov %edx,-0x30(%ebp) + 1492: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 1496: e8 07 fe ff ff call 12a2 + putc(fd, c); + 149b: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 149e: 8d 45 e7 lea -0x19(%ebp),%eax + 14a1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14a8: 00 + 14a9: 89 44 24 04 mov %eax,0x4(%esp) + 14ad: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 14b0: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 14b3: e8 ea fd ff ff call 12a2 + for(i = 0; fmt[i]; i++){ + 14b8: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 14bc: 84 d2 test %dl,%dl + 14be: 0f 85 76 ff ff ff jne 143a + 14c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 14c8: 83 c4 3c add $0x3c,%esp + 14cb: 5b pop %ebx + 14cc: 5e pop %esi + 14cd: 5f pop %edi + 14ce: 5d pop %ebp + 14cf: c3 ret + state = '%'; + 14d0: bf 25 00 00 00 mov $0x25,%edi + 14d5: e9 51 ff ff ff jmp 142b + 14da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 14e0: 8b 45 d4 mov -0x2c(%ebp),%eax + 14e3: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 14e8: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 14ea: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 14f1: 8b 10 mov (%eax),%edx + 14f3: 89 f0 mov %esi,%eax + 14f5: e8 46 fe ff ff call 1340 + ap++; + 14fa: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 14fe: e9 28 ff ff ff jmp 142b + 1503: 90 nop + 1504: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 1508: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 150b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 150f: 8b 38 mov (%eax),%edi + s = "(null)"; + 1511: b8 95 17 00 00 mov $0x1795,%eax + 1516: 85 ff test %edi,%edi + 1518: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 151b: 0f b6 07 movzbl (%edi),%eax + 151e: 84 c0 test %al,%al + 1520: 74 2a je 154c + 1522: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1528: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 152b: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 152e: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 1531: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1538: 00 + 1539: 89 44 24 04 mov %eax,0x4(%esp) + 153d: 89 34 24 mov %esi,(%esp) + 1540: e8 5d fd ff ff call 12a2 + while(*s != 0){ + 1545: 0f b6 07 movzbl (%edi),%eax + 1548: 84 c0 test %al,%al + 154a: 75 dc jne 1528 + state = 0; + 154c: 31 ff xor %edi,%edi + 154e: e9 d8 fe ff ff jmp 142b + 1553: 90 nop + 1554: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1558: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 155b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 155d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1564: 00 + 1565: 89 44 24 04 mov %eax,0x4(%esp) + 1569: 89 34 24 mov %esi,(%esp) + 156c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1570: e8 2d fd ff ff call 12a2 + 1575: e9 b1 fe ff ff jmp 142b + 157a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 1580: 8b 45 d4 mov -0x2c(%ebp),%eax + 1583: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 1588: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 158b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1592: 8b 10 mov (%eax),%edx + 1594: 89 f0 mov %esi,%eax + 1596: e8 a5 fd ff ff call 1340 + ap++; + 159b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 159f: e9 87 fe ff ff jmp 142b + putc(fd, *ap); + 15a4: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 15a7: 31 ff xor %edi,%edi + putc(fd, *ap); + 15a9: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 15ab: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 15b2: 00 + 15b3: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 15b6: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 15b9: 8d 45 e4 lea -0x1c(%ebp),%eax + 15bc: 89 44 24 04 mov %eax,0x4(%esp) + 15c0: e8 dd fc ff ff call 12a2 + ap++; + 15c5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15c9: e9 5d fe ff ff jmp 142b + 15ce: 66 90 xchg %ax,%ax + +000015d0 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 15d0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15d1: a1 58 1a 00 00 mov 0x1a58,%eax +{ + 15d6: 89 e5 mov %esp,%ebp + 15d8: 57 push %edi + 15d9: 56 push %esi + 15da: 53 push %ebx + 15db: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15de: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 15e0: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15e3: 39 d0 cmp %edx,%eax + 15e5: 72 11 jb 15f8 + 15e7: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15e8: 39 c8 cmp %ecx,%eax + 15ea: 72 04 jb 15f0 + 15ec: 39 ca cmp %ecx,%edx + 15ee: 72 10 jb 1600 + 15f0: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15f2: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15f4: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15f6: 73 f0 jae 15e8 + 15f8: 39 ca cmp %ecx,%edx + 15fa: 72 04 jb 1600 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15fc: 39 c8 cmp %ecx,%eax + 15fe: 72 f0 jb 15f0 + break; + if(bp + bp->s.size == p->s.ptr){ + 1600: 8b 73 fc mov -0x4(%ebx),%esi + 1603: 8d 3c f2 lea (%edx,%esi,8),%edi + 1606: 39 cf cmp %ecx,%edi + 1608: 74 1e je 1628 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 160a: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 160d: 8b 48 04 mov 0x4(%eax),%ecx + 1610: 8d 34 c8 lea (%eax,%ecx,8),%esi + 1613: 39 f2 cmp %esi,%edx + 1615: 74 28 je 163f + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 1617: 89 10 mov %edx,(%eax) + freep = p; + 1619: a3 58 1a 00 00 mov %eax,0x1a58 +} + 161e: 5b pop %ebx + 161f: 5e pop %esi + 1620: 5f pop %edi + 1621: 5d pop %ebp + 1622: c3 ret + 1623: 90 nop + 1624: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 1628: 03 71 04 add 0x4(%ecx),%esi + 162b: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 162e: 8b 08 mov (%eax),%ecx + 1630: 8b 09 mov (%ecx),%ecx + 1632: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 1635: 8b 48 04 mov 0x4(%eax),%ecx + 1638: 8d 34 c8 lea (%eax,%ecx,8),%esi + 163b: 39 f2 cmp %esi,%edx + 163d: 75 d8 jne 1617 + p->s.size += bp->s.size; + 163f: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 1642: a3 58 1a 00 00 mov %eax,0x1a58 + p->s.size += bp->s.size; + 1647: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 164a: 8b 53 f8 mov -0x8(%ebx),%edx + 164d: 89 10 mov %edx,(%eax) +} + 164f: 5b pop %ebx + 1650: 5e pop %esi + 1651: 5f pop %edi + 1652: 5d pop %ebp + 1653: c3 ret + 1654: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 165a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001660 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1660: 55 push %ebp + 1661: 89 e5 mov %esp,%ebp + 1663: 57 push %edi + 1664: 56 push %esi + 1665: 53 push %ebx + 1666: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1669: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 166c: 8b 1d 58 1a 00 00 mov 0x1a58,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1672: 8d 48 07 lea 0x7(%eax),%ecx + 1675: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1678: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 167a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 167d: 0f 84 9b 00 00 00 je 171e + 1683: 8b 13 mov (%ebx),%edx + 1685: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 1688: 39 fe cmp %edi,%esi + 168a: 76 64 jbe 16f0 + 168c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 1693: bb 00 80 00 00 mov $0x8000,%ebx + 1698: 89 45 e4 mov %eax,-0x1c(%ebp) + 169b: eb 0e jmp 16ab + 169d: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 16a0: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 16a2: 8b 78 04 mov 0x4(%eax),%edi + 16a5: 39 fe cmp %edi,%esi + 16a7: 76 4f jbe 16f8 + 16a9: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 16ab: 3b 15 58 1a 00 00 cmp 0x1a58,%edx + 16b1: 75 ed jne 16a0 + if(nu < 4096) + 16b3: 8b 45 e4 mov -0x1c(%ebp),%eax + 16b6: 81 fe 00 10 00 00 cmp $0x1000,%esi + 16bc: bf 00 10 00 00 mov $0x1000,%edi + 16c1: 0f 43 fe cmovae %esi,%edi + 16c4: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 16c7: 89 04 24 mov %eax,(%esp) + 16ca: e8 3b fc ff ff call 130a + if(p == (char*)-1) + 16cf: 83 f8 ff cmp $0xffffffff,%eax + 16d2: 74 18 je 16ec + hp->s.size = nu; + 16d4: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 16d7: 83 c0 08 add $0x8,%eax + 16da: 89 04 24 mov %eax,(%esp) + 16dd: e8 ee fe ff ff call 15d0 + return freep; + 16e2: 8b 15 58 1a 00 00 mov 0x1a58,%edx + if((p = morecore(nunits)) == 0) + 16e8: 85 d2 test %edx,%edx + 16ea: 75 b4 jne 16a0 + return 0; + 16ec: 31 c0 xor %eax,%eax + 16ee: eb 20 jmp 1710 + if(p->s.size >= nunits){ + 16f0: 89 d0 mov %edx,%eax + 16f2: 89 da mov %ebx,%edx + 16f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 16f8: 39 fe cmp %edi,%esi + 16fa: 74 1c je 1718 + p->s.size -= nunits; + 16fc: 29 f7 sub %esi,%edi + 16fe: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 1701: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 1704: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 1707: 89 15 58 1a 00 00 mov %edx,0x1a58 + return (void*)(p + 1); + 170d: 83 c0 08 add $0x8,%eax + } +} + 1710: 83 c4 1c add $0x1c,%esp + 1713: 5b pop %ebx + 1714: 5e pop %esi + 1715: 5f pop %edi + 1716: 5d pop %ebp + 1717: c3 ret + prevp->s.ptr = p->s.ptr; + 1718: 8b 08 mov (%eax),%ecx + 171a: 89 0a mov %ecx,(%edx) + 171c: eb e9 jmp 1707 + base.s.ptr = freep = prevp = &base; + 171e: c7 05 58 1a 00 00 5c movl $0x1a5c,0x1a58 + 1725: 1a 00 00 + base.s.size = 0; + 1728: ba 5c 1a 00 00 mov $0x1a5c,%edx + base.s.ptr = freep = prevp = &base; + 172d: c7 05 5c 1a 00 00 5c movl $0x1a5c,0x1a5c + 1734: 1a 00 00 + base.s.size = 0; + 1737: c7 05 60 1a 00 00 00 movl $0x0,0x1a60 + 173e: 00 00 00 + 1741: e9 46 ff ff ff jmp 168c + 1746: 66 90 xchg %ax,%ax + 1748: 66 90 xchg %ax,%ax + 174a: 66 90 xchg %ax,%ax + 174c: 66 90 xchg %ax,%ax + 174e: 66 90 xchg %ax,%ax + +00001750 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1750: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1751: b9 01 00 00 00 mov $0x1,%ecx + 1756: 89 e5 mov %esp,%ebp + 1758: 8b 55 08 mov 0x8(%ebp),%edx + 175b: 90 nop + 175c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1760: 89 c8 mov %ecx,%eax + 1762: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1765: 85 c0 test %eax,%eax + 1767: 75 f7 jne 1760 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1769: 0f ae f0 mfence +} + 176c: 5d pop %ebp + 176d: c3 ret + 176e: 66 90 xchg %ax,%ax + +00001770 : + +void urelease (struct uspinlock *lk) { + 1770: 55 push %ebp + 1771: 89 e5 mov %esp,%ebp + 1773: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1776: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1779: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 177f: 5d pop %ebp + 1780: c3 ret diff --git a/kill.d b/kill.d new file mode 100644 index 00000000..078f4f87 --- /dev/null +++ b/kill.d @@ -0,0 +1 @@ +kill.o: kill.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/kill.o b/kill.o new file mode 100644 index 00000000..ee4fafef Binary files /dev/null and b/kill.o differ diff --git a/kill.sym b/kill.sym new file mode 100644 index 00000000..a5cd1f4a --- /dev/null +++ b/kill.sym @@ -0,0 +1,62 @@ +00001000 .text +00001781 .rodata +000017b0 .eh_frame +00001a58 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 kill.c +00000000 ulib.c +00000000 printf.c +00001340 printint +0000179c digits.1359 +00000000 umalloc.c +00001a58 freep +00001a5c base +00000000 uspinlock.c +00001060 strcpy +000013e0 printf +00001250 memmove +000012ca mknod +00001322 shm_open +00001170 gets +00001302 getpid +00001660 malloc +00001312 sleep +00001292 pipe +000012a2 write +000012da fstat +000012b2 kill +000012f2 chdir +000012ba exec +0000128a wait +0000129a read +000012d2 unlink +00001750 uacquire +0000127a fork +0000130a sbrk +0000132a shm_close +0000131a uptime +00001a58 __bss_start +00001110 memset +00001000 main +00001090 strcmp +000012fa dup +000011d0 stat +00001a58 _edata +00001a64 _end +000012e2 link +00001282 exit +00001220 atoi +000010e0 strlen +000012c2 open +00001130 strchr +000012ea mkdir +000012aa close +00001770 urelease +000015d0 free diff --git a/lapic.d b/lapic.d new file mode 100644 index 00000000..6e623879 --- /dev/null +++ b/lapic.d @@ -0,0 +1,2 @@ +lapic.o: lapic.c /usr/include/stdc-predef.h param.h types.h defs.h date.h \ + memlayout.h traps.h mmu.h x86.h diff --git a/lapic.o b/lapic.o new file mode 100644 index 00000000..9fd8809d Binary files /dev/null and b/lapic.o differ diff --git a/ln.asm b/ln.asm new file mode 100644 index 00000000..9650cfe3 --- /dev/null +++ b/ln.asm @@ -0,0 +1,1216 @@ + +_ln: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: +#include "stat.h" +#include "user.h" + +int +main(int argc, char *argv[]) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 53 push %ebx + 1004: 83 e4 f0 and $0xfffffff0,%esp + 1007: 83 ec 10 sub $0x10,%esp + 100a: 8b 5d 0c mov 0xc(%ebp),%ebx + if(argc != 3){ + 100d: 83 7d 08 03 cmpl $0x3,0x8(%ebp) + 1011: 74 19 je 102c + printf(2, "Usage: ln old new\n"); + 1013: c7 44 24 04 91 17 00 movl $0x1791,0x4(%esp) + 101a: 00 + 101b: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 1022: e8 c9 03 00 00 call 13f0 + exit(); + 1027: e8 66 02 00 00 call 1292 + } + if(link(argv[1], argv[2]) < 0) + 102c: 8b 43 08 mov 0x8(%ebx),%eax + 102f: 89 44 24 04 mov %eax,0x4(%esp) + 1033: 8b 43 04 mov 0x4(%ebx),%eax + 1036: 89 04 24 mov %eax,(%esp) + 1039: e8 b4 02 00 00 call 12f2 + 103e: 85 c0 test %eax,%eax + 1040: 78 05 js 1047 + printf(2, "link %s %s: failed\n", argv[1], argv[2]); + exit(); + 1042: e8 4b 02 00 00 call 1292 + printf(2, "link %s %s: failed\n", argv[1], argv[2]); + 1047: 8b 43 08 mov 0x8(%ebx),%eax + 104a: 89 44 24 0c mov %eax,0xc(%esp) + 104e: 8b 43 04 mov 0x4(%ebx),%eax + 1051: c7 44 24 04 a4 17 00 movl $0x17a4,0x4(%esp) + 1058: 00 + 1059: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 1060: 89 44 24 08 mov %eax,0x8(%esp) + 1064: e8 87 03 00 00 call 13f0 + 1069: eb d7 jmp 1042 + 106b: 66 90 xchg %ax,%ax + 106d: 66 90 xchg %ax,%ax + 106f: 90 nop + +00001070 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1070: 55 push %ebp + 1071: 89 e5 mov %esp,%ebp + 1073: 8b 45 08 mov 0x8(%ebp),%eax + 1076: 8b 4d 0c mov 0xc(%ebp),%ecx + 1079: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 107a: 89 c2 mov %eax,%edx + 107c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1080: 83 c1 01 add $0x1,%ecx + 1083: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1087: 83 c2 01 add $0x1,%edx + 108a: 84 db test %bl,%bl + 108c: 88 5a ff mov %bl,-0x1(%edx) + 108f: 75 ef jne 1080 + ; + return os; +} + 1091: 5b pop %ebx + 1092: 5d pop %ebp + 1093: c3 ret + 1094: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 109a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +000010a0 : + +int +strcmp(const char *p, const char *q) +{ + 10a0: 55 push %ebp + 10a1: 89 e5 mov %esp,%ebp + 10a3: 8b 55 08 mov 0x8(%ebp),%edx + 10a6: 53 push %ebx + 10a7: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 10aa: 0f b6 02 movzbl (%edx),%eax + 10ad: 84 c0 test %al,%al + 10af: 74 2d je 10de + 10b1: 0f b6 19 movzbl (%ecx),%ebx + 10b4: 38 d8 cmp %bl,%al + 10b6: 74 0e je 10c6 + 10b8: eb 2b jmp 10e5 + 10ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 10c0: 38 c8 cmp %cl,%al + 10c2: 75 15 jne 10d9 + p++, q++; + 10c4: 89 d9 mov %ebx,%ecx + 10c6: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 10c9: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 10cc: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 10cf: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 10d3: 84 c0 test %al,%al + 10d5: 75 e9 jne 10c0 + 10d7: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 10d9: 29 c8 sub %ecx,%eax +} + 10db: 5b pop %ebx + 10dc: 5d pop %ebp + 10dd: c3 ret + 10de: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 10e1: 31 c0 xor %eax,%eax + 10e3: eb f4 jmp 10d9 + 10e5: 0f b6 cb movzbl %bl,%ecx + 10e8: eb ef jmp 10d9 + 10ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +000010f0 : + +uint +strlen(char *s) +{ + 10f0: 55 push %ebp + 10f1: 89 e5 mov %esp,%ebp + 10f3: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 10f6: 80 39 00 cmpb $0x0,(%ecx) + 10f9: 74 12 je 110d + 10fb: 31 d2 xor %edx,%edx + 10fd: 8d 76 00 lea 0x0(%esi),%esi + 1100: 83 c2 01 add $0x1,%edx + 1103: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 1107: 89 d0 mov %edx,%eax + 1109: 75 f5 jne 1100 + ; + return n; +} + 110b: 5d pop %ebp + 110c: c3 ret + for(n = 0; s[n]; n++) + 110d: 31 c0 xor %eax,%eax +} + 110f: 5d pop %ebp + 1110: c3 ret + 1111: eb 0d jmp 1120 + 1113: 90 nop + 1114: 90 nop + 1115: 90 nop + 1116: 90 nop + 1117: 90 nop + 1118: 90 nop + 1119: 90 nop + 111a: 90 nop + 111b: 90 nop + 111c: 90 nop + 111d: 90 nop + 111e: 90 nop + 111f: 90 nop + +00001120 : + +void* +memset(void *dst, int c, uint n) +{ + 1120: 55 push %ebp + 1121: 89 e5 mov %esp,%ebp + 1123: 8b 55 08 mov 0x8(%ebp),%edx + 1126: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 1127: 8b 4d 10 mov 0x10(%ebp),%ecx + 112a: 8b 45 0c mov 0xc(%ebp),%eax + 112d: 89 d7 mov %edx,%edi + 112f: fc cld + 1130: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1132: 89 d0 mov %edx,%eax + 1134: 5f pop %edi + 1135: 5d pop %ebp + 1136: c3 ret + 1137: 89 f6 mov %esi,%esi + 1139: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001140 : + +char* +strchr(const char *s, char c) +{ + 1140: 55 push %ebp + 1141: 89 e5 mov %esp,%ebp + 1143: 8b 45 08 mov 0x8(%ebp),%eax + 1146: 53 push %ebx + 1147: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 114a: 0f b6 18 movzbl (%eax),%ebx + 114d: 84 db test %bl,%bl + 114f: 74 1d je 116e + if(*s == c) + 1151: 38 d3 cmp %dl,%bl + 1153: 89 d1 mov %edx,%ecx + 1155: 75 0d jne 1164 + 1157: eb 17 jmp 1170 + 1159: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1160: 38 ca cmp %cl,%dl + 1162: 74 0c je 1170 + for(; *s; s++) + 1164: 83 c0 01 add $0x1,%eax + 1167: 0f b6 10 movzbl (%eax),%edx + 116a: 84 d2 test %dl,%dl + 116c: 75 f2 jne 1160 + return (char*)s; + return 0; + 116e: 31 c0 xor %eax,%eax +} + 1170: 5b pop %ebx + 1171: 5d pop %ebp + 1172: c3 ret + 1173: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1179: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001180 : + +char* +gets(char *buf, int max) +{ + 1180: 55 push %ebp + 1181: 89 e5 mov %esp,%ebp + 1183: 57 push %edi + 1184: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1185: 31 f6 xor %esi,%esi +{ + 1187: 53 push %ebx + 1188: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 118b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 118e: eb 31 jmp 11c1 + cc = read(0, &c, 1); + 1190: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1197: 00 + 1198: 89 7c 24 04 mov %edi,0x4(%esp) + 119c: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 11a3: e8 02 01 00 00 call 12aa + if(cc < 1) + 11a8: 85 c0 test %eax,%eax + 11aa: 7e 1d jle 11c9 + break; + buf[i++] = c; + 11ac: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 11b0: 89 de mov %ebx,%esi + buf[i++] = c; + 11b2: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 11b5: 3c 0d cmp $0xd,%al + buf[i++] = c; + 11b7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 11bb: 74 0c je 11c9 + 11bd: 3c 0a cmp $0xa,%al + 11bf: 74 08 je 11c9 + for(i=0; i+1 < max; ){ + 11c1: 8d 5e 01 lea 0x1(%esi),%ebx + 11c4: 3b 5d 0c cmp 0xc(%ebp),%ebx + 11c7: 7c c7 jl 1190 + break; + } + buf[i] = '\0'; + 11c9: 8b 45 08 mov 0x8(%ebp),%eax + 11cc: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 11d0: 83 c4 2c add $0x2c,%esp + 11d3: 5b pop %ebx + 11d4: 5e pop %esi + 11d5: 5f pop %edi + 11d6: 5d pop %ebp + 11d7: c3 ret + 11d8: 90 nop + 11d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000011e0 : + +int +stat(char *n, struct stat *st) +{ + 11e0: 55 push %ebp + 11e1: 89 e5 mov %esp,%ebp + 11e3: 56 push %esi + 11e4: 53 push %ebx + 11e5: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 11e8: 8b 45 08 mov 0x8(%ebp),%eax + 11eb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 11f2: 00 + 11f3: 89 04 24 mov %eax,(%esp) + 11f6: e8 d7 00 00 00 call 12d2 + if(fd < 0) + 11fb: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 11fd: 89 c3 mov %eax,%ebx + if(fd < 0) + 11ff: 78 27 js 1228 + return -1; + r = fstat(fd, st); + 1201: 8b 45 0c mov 0xc(%ebp),%eax + 1204: 89 1c 24 mov %ebx,(%esp) + 1207: 89 44 24 04 mov %eax,0x4(%esp) + 120b: e8 da 00 00 00 call 12ea + close(fd); + 1210: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 1213: 89 c6 mov %eax,%esi + close(fd); + 1215: e8 a0 00 00 00 call 12ba + return r; + 121a: 89 f0 mov %esi,%eax +} + 121c: 83 c4 10 add $0x10,%esp + 121f: 5b pop %ebx + 1220: 5e pop %esi + 1221: 5d pop %ebp + 1222: c3 ret + 1223: 90 nop + 1224: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 1228: b8 ff ff ff ff mov $0xffffffff,%eax + 122d: eb ed jmp 121c + 122f: 90 nop + +00001230 : + +int +atoi(const char *s) +{ + 1230: 55 push %ebp + 1231: 89 e5 mov %esp,%ebp + 1233: 8b 4d 08 mov 0x8(%ebp),%ecx + 1236: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 1237: 0f be 11 movsbl (%ecx),%edx + 123a: 8d 42 d0 lea -0x30(%edx),%eax + 123d: 3c 09 cmp $0x9,%al + n = 0; + 123f: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 1244: 77 17 ja 125d + 1246: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 1248: 83 c1 01 add $0x1,%ecx + 124b: 8d 04 80 lea (%eax,%eax,4),%eax + 124e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1252: 0f be 11 movsbl (%ecx),%edx + 1255: 8d 5a d0 lea -0x30(%edx),%ebx + 1258: 80 fb 09 cmp $0x9,%bl + 125b: 76 eb jbe 1248 + return n; +} + 125d: 5b pop %ebx + 125e: 5d pop %ebp + 125f: c3 ret + +00001260 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1260: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1261: 31 d2 xor %edx,%edx +{ + 1263: 89 e5 mov %esp,%ebp + 1265: 56 push %esi + 1266: 8b 45 08 mov 0x8(%ebp),%eax + 1269: 53 push %ebx + 126a: 8b 5d 10 mov 0x10(%ebp),%ebx + 126d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1270: 85 db test %ebx,%ebx + 1272: 7e 12 jle 1286 + 1274: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1278: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 127c: 88 0c 10 mov %cl,(%eax,%edx,1) + 127f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1282: 39 da cmp %ebx,%edx + 1284: 75 f2 jne 1278 + return vdst; +} + 1286: 5b pop %ebx + 1287: 5e pop %esi + 1288: 5d pop %ebp + 1289: c3 ret + +0000128a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 128a: b8 01 00 00 00 mov $0x1,%eax + 128f: cd 40 int $0x40 + 1291: c3 ret + +00001292 : +SYSCALL(exit) + 1292: b8 02 00 00 00 mov $0x2,%eax + 1297: cd 40 int $0x40 + 1299: c3 ret + +0000129a : +SYSCALL(wait) + 129a: b8 03 00 00 00 mov $0x3,%eax + 129f: cd 40 int $0x40 + 12a1: c3 ret + +000012a2 : +SYSCALL(pipe) + 12a2: b8 04 00 00 00 mov $0x4,%eax + 12a7: cd 40 int $0x40 + 12a9: c3 ret + +000012aa : +SYSCALL(read) + 12aa: b8 05 00 00 00 mov $0x5,%eax + 12af: cd 40 int $0x40 + 12b1: c3 ret + +000012b2 : +SYSCALL(write) + 12b2: b8 10 00 00 00 mov $0x10,%eax + 12b7: cd 40 int $0x40 + 12b9: c3 ret + +000012ba : +SYSCALL(close) + 12ba: b8 15 00 00 00 mov $0x15,%eax + 12bf: cd 40 int $0x40 + 12c1: c3 ret + +000012c2 : +SYSCALL(kill) + 12c2: b8 06 00 00 00 mov $0x6,%eax + 12c7: cd 40 int $0x40 + 12c9: c3 ret + +000012ca : +SYSCALL(exec) + 12ca: b8 07 00 00 00 mov $0x7,%eax + 12cf: cd 40 int $0x40 + 12d1: c3 ret + +000012d2 : +SYSCALL(open) + 12d2: b8 0f 00 00 00 mov $0xf,%eax + 12d7: cd 40 int $0x40 + 12d9: c3 ret + +000012da : +SYSCALL(mknod) + 12da: b8 11 00 00 00 mov $0x11,%eax + 12df: cd 40 int $0x40 + 12e1: c3 ret + +000012e2 : +SYSCALL(unlink) + 12e2: b8 12 00 00 00 mov $0x12,%eax + 12e7: cd 40 int $0x40 + 12e9: c3 ret + +000012ea : +SYSCALL(fstat) + 12ea: b8 08 00 00 00 mov $0x8,%eax + 12ef: cd 40 int $0x40 + 12f1: c3 ret + +000012f2 : +SYSCALL(link) + 12f2: b8 13 00 00 00 mov $0x13,%eax + 12f7: cd 40 int $0x40 + 12f9: c3 ret + +000012fa : +SYSCALL(mkdir) + 12fa: b8 14 00 00 00 mov $0x14,%eax + 12ff: cd 40 int $0x40 + 1301: c3 ret + +00001302 : +SYSCALL(chdir) + 1302: b8 09 00 00 00 mov $0x9,%eax + 1307: cd 40 int $0x40 + 1309: c3 ret + +0000130a : +SYSCALL(dup) + 130a: b8 0a 00 00 00 mov $0xa,%eax + 130f: cd 40 int $0x40 + 1311: c3 ret + +00001312 : +SYSCALL(getpid) + 1312: b8 0b 00 00 00 mov $0xb,%eax + 1317: cd 40 int $0x40 + 1319: c3 ret + +0000131a : +SYSCALL(sbrk) + 131a: b8 0c 00 00 00 mov $0xc,%eax + 131f: cd 40 int $0x40 + 1321: c3 ret + +00001322 : +SYSCALL(sleep) + 1322: b8 0d 00 00 00 mov $0xd,%eax + 1327: cd 40 int $0x40 + 1329: c3 ret + +0000132a : +SYSCALL(uptime) + 132a: b8 0e 00 00 00 mov $0xe,%eax + 132f: cd 40 int $0x40 + 1331: c3 ret + +00001332 : +SYSCALL(shm_open) + 1332: b8 16 00 00 00 mov $0x16,%eax + 1337: cd 40 int $0x40 + 1339: c3 ret + +0000133a : +SYSCALL(shm_close) + 133a: b8 17 00 00 00 mov $0x17,%eax + 133f: cd 40 int $0x40 + 1341: c3 ret + 1342: 66 90 xchg %ax,%ax + 1344: 66 90 xchg %ax,%ax + 1346: 66 90 xchg %ax,%ax + 1348: 66 90 xchg %ax,%ax + 134a: 66 90 xchg %ax,%ax + 134c: 66 90 xchg %ax,%ax + 134e: 66 90 xchg %ax,%ax + +00001350 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 1350: 55 push %ebp + 1351: 89 e5 mov %esp,%ebp + 1353: 57 push %edi + 1354: 56 push %esi + 1355: 89 c6 mov %eax,%esi + 1357: 53 push %ebx + 1358: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 135b: 8b 5d 08 mov 0x8(%ebp),%ebx + 135e: 85 db test %ebx,%ebx + 1360: 74 09 je 136b + 1362: 89 d0 mov %edx,%eax + 1364: c1 e8 1f shr $0x1f,%eax + 1367: 84 c0 test %al,%al + 1369: 75 75 jne 13e0 + neg = 1; + x = -xx; + } else { + x = xx; + 136b: 89 d0 mov %edx,%eax + neg = 0; + 136d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1374: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1377: 31 ff xor %edi,%edi + 1379: 89 ce mov %ecx,%esi + 137b: 8d 5d d7 lea -0x29(%ebp),%ebx + 137e: eb 02 jmp 1382 + do{ + buf[i++] = digits[x % base]; + 1380: 89 cf mov %ecx,%edi + 1382: 31 d2 xor %edx,%edx + 1384: f7 f6 div %esi + 1386: 8d 4f 01 lea 0x1(%edi),%ecx + 1389: 0f b6 92 bf 17 00 00 movzbl 0x17bf(%edx),%edx + }while((x /= base) != 0); + 1390: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 1392: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 1395: 75 e9 jne 1380 + if(neg) + 1397: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 139a: 89 c8 mov %ecx,%eax + 139c: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 139f: 85 d2 test %edx,%edx + 13a1: 74 08 je 13ab + buf[i++] = '-'; + 13a3: 8d 4f 02 lea 0x2(%edi),%ecx + 13a6: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 13ab: 8d 79 ff lea -0x1(%ecx),%edi + 13ae: 66 90 xchg %ax,%ax + 13b0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 13b5: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 13b8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 13bf: 00 + 13c0: 89 5c 24 04 mov %ebx,0x4(%esp) + 13c4: 89 34 24 mov %esi,(%esp) + 13c7: 88 45 d7 mov %al,-0x29(%ebp) + 13ca: e8 e3 fe ff ff call 12b2 + while(--i >= 0) + 13cf: 83 ff ff cmp $0xffffffff,%edi + 13d2: 75 dc jne 13b0 + putc(fd, buf[i]); +} + 13d4: 83 c4 4c add $0x4c,%esp + 13d7: 5b pop %ebx + 13d8: 5e pop %esi + 13d9: 5f pop %edi + 13da: 5d pop %ebp + 13db: c3 ret + 13dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 13e0: 89 d0 mov %edx,%eax + 13e2: f7 d8 neg %eax + neg = 1; + 13e4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 13eb: eb 87 jmp 1374 + 13ed: 8d 76 00 lea 0x0(%esi),%esi + +000013f0 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 13f0: 55 push %ebp + 13f1: 89 e5 mov %esp,%ebp + 13f3: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 13f4: 31 ff xor %edi,%edi +{ + 13f6: 56 push %esi + 13f7: 53 push %ebx + 13f8: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 13fb: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 13fe: 8d 45 10 lea 0x10(%ebp),%eax +{ + 1401: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 1404: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 1407: 0f b6 13 movzbl (%ebx),%edx + 140a: 83 c3 01 add $0x1,%ebx + 140d: 84 d2 test %dl,%dl + 140f: 75 39 jne 144a + 1411: e9 c2 00 00 00 jmp 14d8 + 1416: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 1418: 83 fa 25 cmp $0x25,%edx + 141b: 0f 84 bf 00 00 00 je 14e0 + write(fd, &c, 1); + 1421: 8d 45 e2 lea -0x1e(%ebp),%eax + 1424: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 142b: 00 + 142c: 89 44 24 04 mov %eax,0x4(%esp) + 1430: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 1433: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 1436: e8 77 fe ff ff call 12b2 + 143b: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 143e: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 1442: 84 d2 test %dl,%dl + 1444: 0f 84 8e 00 00 00 je 14d8 + if(state == 0){ + 144a: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 144c: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 144f: 74 c7 je 1418 + } + } else if(state == '%'){ + 1451: 83 ff 25 cmp $0x25,%edi + 1454: 75 e5 jne 143b + if(c == 'd'){ + 1456: 83 fa 64 cmp $0x64,%edx + 1459: 0f 84 31 01 00 00 je 1590 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 145f: 25 f7 00 00 00 and $0xf7,%eax + 1464: 83 f8 70 cmp $0x70,%eax + 1467: 0f 84 83 00 00 00 je 14f0 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 146d: 83 fa 73 cmp $0x73,%edx + 1470: 0f 84 a2 00 00 00 je 1518 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1476: 83 fa 63 cmp $0x63,%edx + 1479: 0f 84 35 01 00 00 je 15b4 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 147f: 83 fa 25 cmp $0x25,%edx + 1482: 0f 84 e0 00 00 00 je 1568 + write(fd, &c, 1); + 1488: 8d 45 e6 lea -0x1a(%ebp),%eax + 148b: 83 c3 01 add $0x1,%ebx + 148e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1495: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 1496: 31 ff xor %edi,%edi + write(fd, &c, 1); + 1498: 89 44 24 04 mov %eax,0x4(%esp) + 149c: 89 34 24 mov %esi,(%esp) + 149f: 89 55 d0 mov %edx,-0x30(%ebp) + 14a2: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 14a6: e8 07 fe ff ff call 12b2 + putc(fd, c); + 14ab: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 14ae: 8d 45 e7 lea -0x19(%ebp),%eax + 14b1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14b8: 00 + 14b9: 89 44 24 04 mov %eax,0x4(%esp) + 14bd: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 14c0: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 14c3: e8 ea fd ff ff call 12b2 + for(i = 0; fmt[i]; i++){ + 14c8: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 14cc: 84 d2 test %dl,%dl + 14ce: 0f 85 76 ff ff ff jne 144a + 14d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 14d8: 83 c4 3c add $0x3c,%esp + 14db: 5b pop %ebx + 14dc: 5e pop %esi + 14dd: 5f pop %edi + 14de: 5d pop %ebp + 14df: c3 ret + state = '%'; + 14e0: bf 25 00 00 00 mov $0x25,%edi + 14e5: e9 51 ff ff ff jmp 143b + 14ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 14f0: 8b 45 d4 mov -0x2c(%ebp),%eax + 14f3: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 14f8: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 14fa: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1501: 8b 10 mov (%eax),%edx + 1503: 89 f0 mov %esi,%eax + 1505: e8 46 fe ff ff call 1350 + ap++; + 150a: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 150e: e9 28 ff ff ff jmp 143b + 1513: 90 nop + 1514: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 1518: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 151b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 151f: 8b 38 mov (%eax),%edi + s = "(null)"; + 1521: b8 b8 17 00 00 mov $0x17b8,%eax + 1526: 85 ff test %edi,%edi + 1528: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 152b: 0f b6 07 movzbl (%edi),%eax + 152e: 84 c0 test %al,%al + 1530: 74 2a je 155c + 1532: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1538: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 153b: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 153e: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 1541: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1548: 00 + 1549: 89 44 24 04 mov %eax,0x4(%esp) + 154d: 89 34 24 mov %esi,(%esp) + 1550: e8 5d fd ff ff call 12b2 + while(*s != 0){ + 1555: 0f b6 07 movzbl (%edi),%eax + 1558: 84 c0 test %al,%al + 155a: 75 dc jne 1538 + state = 0; + 155c: 31 ff xor %edi,%edi + 155e: e9 d8 fe ff ff jmp 143b + 1563: 90 nop + 1564: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1568: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 156b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 156d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1574: 00 + 1575: 89 44 24 04 mov %eax,0x4(%esp) + 1579: 89 34 24 mov %esi,(%esp) + 157c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1580: e8 2d fd ff ff call 12b2 + 1585: e9 b1 fe ff ff jmp 143b + 158a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 1590: 8b 45 d4 mov -0x2c(%ebp),%eax + 1593: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 1598: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 159b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 15a2: 8b 10 mov (%eax),%edx + 15a4: 89 f0 mov %esi,%eax + 15a6: e8 a5 fd ff ff call 1350 + ap++; + 15ab: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15af: e9 87 fe ff ff jmp 143b + putc(fd, *ap); + 15b4: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 15b7: 31 ff xor %edi,%edi + putc(fd, *ap); + 15b9: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 15bb: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 15c2: 00 + 15c3: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 15c6: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 15c9: 8d 45 e4 lea -0x1c(%ebp),%eax + 15cc: 89 44 24 04 mov %eax,0x4(%esp) + 15d0: e8 dd fc ff ff call 12b2 + ap++; + 15d5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15d9: e9 5d fe ff ff jmp 143b + 15de: 66 90 xchg %ax,%ax + +000015e0 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 15e0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15e1: a1 74 1a 00 00 mov 0x1a74,%eax +{ + 15e6: 89 e5 mov %esp,%ebp + 15e8: 57 push %edi + 15e9: 56 push %esi + 15ea: 53 push %ebx + 15eb: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15ee: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 15f0: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15f3: 39 d0 cmp %edx,%eax + 15f5: 72 11 jb 1608 + 15f7: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15f8: 39 c8 cmp %ecx,%eax + 15fa: 72 04 jb 1600 + 15fc: 39 ca cmp %ecx,%edx + 15fe: 72 10 jb 1610 + 1600: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1602: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1604: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1606: 73 f0 jae 15f8 + 1608: 39 ca cmp %ecx,%edx + 160a: 72 04 jb 1610 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 160c: 39 c8 cmp %ecx,%eax + 160e: 72 f0 jb 1600 + break; + if(bp + bp->s.size == p->s.ptr){ + 1610: 8b 73 fc mov -0x4(%ebx),%esi + 1613: 8d 3c f2 lea (%edx,%esi,8),%edi + 1616: 39 cf cmp %ecx,%edi + 1618: 74 1e je 1638 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 161a: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 161d: 8b 48 04 mov 0x4(%eax),%ecx + 1620: 8d 34 c8 lea (%eax,%ecx,8),%esi + 1623: 39 f2 cmp %esi,%edx + 1625: 74 28 je 164f + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 1627: 89 10 mov %edx,(%eax) + freep = p; + 1629: a3 74 1a 00 00 mov %eax,0x1a74 +} + 162e: 5b pop %ebx + 162f: 5e pop %esi + 1630: 5f pop %edi + 1631: 5d pop %ebp + 1632: c3 ret + 1633: 90 nop + 1634: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 1638: 03 71 04 add 0x4(%ecx),%esi + 163b: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 163e: 8b 08 mov (%eax),%ecx + 1640: 8b 09 mov (%ecx),%ecx + 1642: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 1645: 8b 48 04 mov 0x4(%eax),%ecx + 1648: 8d 34 c8 lea (%eax,%ecx,8),%esi + 164b: 39 f2 cmp %esi,%edx + 164d: 75 d8 jne 1627 + p->s.size += bp->s.size; + 164f: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 1652: a3 74 1a 00 00 mov %eax,0x1a74 + p->s.size += bp->s.size; + 1657: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 165a: 8b 53 f8 mov -0x8(%ebx),%edx + 165d: 89 10 mov %edx,(%eax) +} + 165f: 5b pop %ebx + 1660: 5e pop %esi + 1661: 5f pop %edi + 1662: 5d pop %ebp + 1663: c3 ret + 1664: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 166a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001670 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1670: 55 push %ebp + 1671: 89 e5 mov %esp,%ebp + 1673: 57 push %edi + 1674: 56 push %esi + 1675: 53 push %ebx + 1676: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1679: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 167c: 8b 1d 74 1a 00 00 mov 0x1a74,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1682: 8d 48 07 lea 0x7(%eax),%ecx + 1685: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1688: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 168a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 168d: 0f 84 9b 00 00 00 je 172e + 1693: 8b 13 mov (%ebx),%edx + 1695: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 1698: 39 fe cmp %edi,%esi + 169a: 76 64 jbe 1700 + 169c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 16a3: bb 00 80 00 00 mov $0x8000,%ebx + 16a8: 89 45 e4 mov %eax,-0x1c(%ebp) + 16ab: eb 0e jmp 16bb + 16ad: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 16b0: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 16b2: 8b 78 04 mov 0x4(%eax),%edi + 16b5: 39 fe cmp %edi,%esi + 16b7: 76 4f jbe 1708 + 16b9: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 16bb: 3b 15 74 1a 00 00 cmp 0x1a74,%edx + 16c1: 75 ed jne 16b0 + if(nu < 4096) + 16c3: 8b 45 e4 mov -0x1c(%ebp),%eax + 16c6: 81 fe 00 10 00 00 cmp $0x1000,%esi + 16cc: bf 00 10 00 00 mov $0x1000,%edi + 16d1: 0f 43 fe cmovae %esi,%edi + 16d4: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 16d7: 89 04 24 mov %eax,(%esp) + 16da: e8 3b fc ff ff call 131a + if(p == (char*)-1) + 16df: 83 f8 ff cmp $0xffffffff,%eax + 16e2: 74 18 je 16fc + hp->s.size = nu; + 16e4: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 16e7: 83 c0 08 add $0x8,%eax + 16ea: 89 04 24 mov %eax,(%esp) + 16ed: e8 ee fe ff ff call 15e0 + return freep; + 16f2: 8b 15 74 1a 00 00 mov 0x1a74,%edx + if((p = morecore(nunits)) == 0) + 16f8: 85 d2 test %edx,%edx + 16fa: 75 b4 jne 16b0 + return 0; + 16fc: 31 c0 xor %eax,%eax + 16fe: eb 20 jmp 1720 + if(p->s.size >= nunits){ + 1700: 89 d0 mov %edx,%eax + 1702: 89 da mov %ebx,%edx + 1704: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 1708: 39 fe cmp %edi,%esi + 170a: 74 1c je 1728 + p->s.size -= nunits; + 170c: 29 f7 sub %esi,%edi + 170e: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 1711: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 1714: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 1717: 89 15 74 1a 00 00 mov %edx,0x1a74 + return (void*)(p + 1); + 171d: 83 c0 08 add $0x8,%eax + } +} + 1720: 83 c4 1c add $0x1c,%esp + 1723: 5b pop %ebx + 1724: 5e pop %esi + 1725: 5f pop %edi + 1726: 5d pop %ebp + 1727: c3 ret + prevp->s.ptr = p->s.ptr; + 1728: 8b 08 mov (%eax),%ecx + 172a: 89 0a mov %ecx,(%edx) + 172c: eb e9 jmp 1717 + base.s.ptr = freep = prevp = &base; + 172e: c7 05 74 1a 00 00 78 movl $0x1a78,0x1a74 + 1735: 1a 00 00 + base.s.size = 0; + 1738: ba 78 1a 00 00 mov $0x1a78,%edx + base.s.ptr = freep = prevp = &base; + 173d: c7 05 78 1a 00 00 78 movl $0x1a78,0x1a78 + 1744: 1a 00 00 + base.s.size = 0; + 1747: c7 05 7c 1a 00 00 00 movl $0x0,0x1a7c + 174e: 00 00 00 + 1751: e9 46 ff ff ff jmp 169c + 1756: 66 90 xchg %ax,%ax + 1758: 66 90 xchg %ax,%ax + 175a: 66 90 xchg %ax,%ax + 175c: 66 90 xchg %ax,%ax + 175e: 66 90 xchg %ax,%ax + +00001760 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1760: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1761: b9 01 00 00 00 mov $0x1,%ecx + 1766: 89 e5 mov %esp,%ebp + 1768: 8b 55 08 mov 0x8(%ebp),%edx + 176b: 90 nop + 176c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1770: 89 c8 mov %ecx,%eax + 1772: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1775: 85 c0 test %eax,%eax + 1777: 75 f7 jne 1770 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1779: 0f ae f0 mfence +} + 177c: 5d pop %ebp + 177d: c3 ret + 177e: 66 90 xchg %ax,%ax + +00001780 : + +void urelease (struct uspinlock *lk) { + 1780: 55 push %ebp + 1781: 89 e5 mov %esp,%ebp + 1783: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1786: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1789: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 178f: 5d pop %ebp + 1790: c3 ret diff --git a/ln.d b/ln.d new file mode 100644 index 00000000..6728be9e --- /dev/null +++ b/ln.d @@ -0,0 +1 @@ +ln.o: ln.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/ln.o b/ln.o new file mode 100644 index 00000000..4dd86fbd Binary files /dev/null and b/ln.o differ diff --git a/ln.sym b/ln.sym new file mode 100644 index 00000000..2f165787 --- /dev/null +++ b/ln.sym @@ -0,0 +1,62 @@ +00001000 .text +00001791 .rodata +000017d0 .eh_frame +00001a74 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 ln.c +00000000 ulib.c +00000000 printf.c +00001350 printint +000017bf digits.1359 +00000000 umalloc.c +00001a74 freep +00001a78 base +00000000 uspinlock.c +00001070 strcpy +000013f0 printf +00001260 memmove +000012da mknod +00001332 shm_open +00001180 gets +00001312 getpid +00001670 malloc +00001322 sleep +000012a2 pipe +000012b2 write +000012ea fstat +000012c2 kill +00001302 chdir +000012ca exec +0000129a wait +000012aa read +000012e2 unlink +00001760 uacquire +0000128a fork +0000131a sbrk +0000133a shm_close +0000132a uptime +00001a74 __bss_start +00001120 memset +00001000 main +000010a0 strcmp +0000130a dup +000011e0 stat +00001a74 _edata +00001a80 _end +000012f2 link +00001292 exit +00001230 atoi +000010f0 strlen +000012d2 open +00001140 strchr +000012fa mkdir +000012ba close +00001780 urelease +000015e0 free diff --git a/log.d b/log.d new file mode 100644 index 00000000..04c89301 --- /dev/null +++ b/log.d @@ -0,0 +1,2 @@ +log.o: log.c /usr/include/stdc-predef.h types.h defs.h param.h spinlock.h \ + sleeplock.h fs.h buf.h diff --git a/log.o b/log.o new file mode 100644 index 00000000..381c3d5c Binary files /dev/null and b/log.o differ diff --git a/ls.asm b/ls.asm new file mode 100644 index 00000000..1fed3e4c --- /dev/null +++ b/ls.asm @@ -0,0 +1,1467 @@ + +_ls: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: + close(fd); +} + +int +main(int argc, char *argv[]) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 57 push %edi + 1004: 56 push %esi + 1005: 53 push %ebx + int i; + + if(argc < 2){ + 1006: bb 01 00 00 00 mov $0x1,%ebx +{ + 100b: 83 e4 f0 and $0xfffffff0,%esp + 100e: 83 ec 10 sub $0x10,%esp + 1011: 8b 75 08 mov 0x8(%ebp),%esi + 1014: 8b 7d 0c mov 0xc(%ebp),%edi + if(argc < 2){ + 1017: 83 fe 01 cmp $0x1,%esi + 101a: 7e 1b jle 1037 + 101c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + ls("."); + exit(); + } + for(i=1; i + for(i=1; i + exit(); + 1032: e8 6b 05 00 00 call 15a2 + ls("."); + 1037: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp) + 103e: e8 ad 00 00 00 call 10f0 + exit(); + 1043: e8 5a 05 00 00 call 15a2 + 1048: 66 90 xchg %ax,%ax + 104a: 66 90 xchg %ax,%ax + 104c: 66 90 xchg %ax,%ax + 104e: 66 90 xchg %ax,%ax + +00001050 : +{ + 1050: 55 push %ebp + 1051: 89 e5 mov %esp,%ebp + 1053: 56 push %esi + 1054: 53 push %ebx + 1055: 83 ec 10 sub $0x10,%esp + 1058: 8b 5d 08 mov 0x8(%ebp),%ebx + for(p=path+strlen(path); p >= path && *p != '/'; p--) + 105b: 89 1c 24 mov %ebx,(%esp) + 105e: e8 9d 03 00 00 call 1400 + 1063: 01 d8 add %ebx,%eax + 1065: 73 10 jae 1077 + 1067: eb 13 jmp 107c + 1069: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1070: 83 e8 01 sub $0x1,%eax + 1073: 39 c3 cmp %eax,%ebx + 1075: 77 05 ja 107c + 1077: 80 38 2f cmpb $0x2f,(%eax) + 107a: 75 f4 jne 1070 + p++; + 107c: 8d 58 01 lea 0x1(%eax),%ebx + if(strlen(p) >= DIRSIZ) + 107f: 89 1c 24 mov %ebx,(%esp) + 1082: e8 79 03 00 00 call 1400 + 1087: 83 f8 0d cmp $0xd,%eax + 108a: 77 53 ja 10df + memmove(buf, p, strlen(p)); + 108c: 89 1c 24 mov %ebx,(%esp) + 108f: e8 6c 03 00 00 call 1400 + 1094: 89 5c 24 04 mov %ebx,0x4(%esp) + 1098: c7 04 24 14 1e 00 00 movl $0x1e14,(%esp) + 109f: 89 44 24 08 mov %eax,0x8(%esp) + 10a3: e8 c8 04 00 00 call 1570 + memset(buf+strlen(p), ' ', DIRSIZ-strlen(p)); + 10a8: 89 1c 24 mov %ebx,(%esp) + 10ab: e8 50 03 00 00 call 1400 + 10b0: 89 1c 24 mov %ebx,(%esp) + return buf; + 10b3: bb 14 1e 00 00 mov $0x1e14,%ebx + memset(buf+strlen(p), ' ', DIRSIZ-strlen(p)); + 10b8: 89 c6 mov %eax,%esi + 10ba: e8 41 03 00 00 call 1400 + 10bf: ba 0e 00 00 00 mov $0xe,%edx + 10c4: 29 f2 sub %esi,%edx + 10c6: 89 54 24 08 mov %edx,0x8(%esp) + 10ca: c7 44 24 04 20 00 00 movl $0x20,0x4(%esp) + 10d1: 00 + 10d2: 05 14 1e 00 00 add $0x1e14,%eax + 10d7: 89 04 24 mov %eax,(%esp) + 10da: e8 51 03 00 00 call 1430 +} + 10df: 83 c4 10 add $0x10,%esp + 10e2: 89 d8 mov %ebx,%eax + 10e4: 5b pop %ebx + 10e5: 5e pop %esi + 10e6: 5d pop %ebp + 10e7: c3 ret + 10e8: 90 nop + 10e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000010f0 : +{ + 10f0: 55 push %ebp + 10f1: 89 e5 mov %esp,%ebp + 10f3: 57 push %edi + 10f4: 56 push %esi + 10f5: 53 push %ebx + 10f6: 81 ec 6c 02 00 00 sub $0x26c,%esp + 10fc: 8b 7d 08 mov 0x8(%ebp),%edi + if((fd = open(path, 0)) < 0){ + 10ff: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1106: 00 + 1107: 89 3c 24 mov %edi,(%esp) + 110a: e8 d3 04 00 00 call 15e2 + 110f: 85 c0 test %eax,%eax + 1111: 89 c3 mov %eax,%ebx + 1113: 0f 88 c7 01 00 00 js 12e0 + if(fstat(fd, &st) < 0){ + 1119: 8d b5 d4 fd ff ff lea -0x22c(%ebp),%esi + 111f: 89 74 24 04 mov %esi,0x4(%esp) + 1123: 89 04 24 mov %eax,(%esp) + 1126: e8 cf 04 00 00 call 15fa + 112b: 85 c0 test %eax,%eax + 112d: 0f 88 f5 01 00 00 js 1328 + switch(st.type){ + 1133: 0f b7 85 d4 fd ff ff movzwl -0x22c(%ebp),%eax + 113a: 66 83 f8 01 cmp $0x1,%ax + 113e: 74 68 je 11a8 + 1140: 66 83 f8 02 cmp $0x2,%ax + 1144: 75 48 jne 118e + printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size); + 1146: 8b 95 e4 fd ff ff mov -0x21c(%ebp),%edx + 114c: 89 3c 24 mov %edi,(%esp) + 114f: 8b b5 dc fd ff ff mov -0x224(%ebp),%esi + 1155: 89 95 b4 fd ff ff mov %edx,-0x24c(%ebp) + 115b: e8 f0 fe ff ff call 1050 + 1160: 8b 95 b4 fd ff ff mov -0x24c(%ebp),%edx + 1166: 89 74 24 10 mov %esi,0x10(%esp) + 116a: c7 44 24 0c 02 00 00 movl $0x2,0xc(%esp) + 1171: 00 + 1172: c7 44 24 04 c9 1a 00 movl $0x1ac9,0x4(%esp) + 1179: 00 + 117a: 89 54 24 14 mov %edx,0x14(%esp) + 117e: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1185: 89 44 24 08 mov %eax,0x8(%esp) + 1189: e8 72 05 00 00 call 1700 + close(fd); + 118e: 89 1c 24 mov %ebx,(%esp) + 1191: e8 34 04 00 00 call 15ca +} + 1196: 81 c4 6c 02 00 00 add $0x26c,%esp + 119c: 5b pop %ebx + 119d: 5e pop %esi + 119e: 5f pop %edi + 119f: 5d pop %ebp + 11a0: c3 ret + 11a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){ + 11a8: 89 3c 24 mov %edi,(%esp) + 11ab: e8 50 02 00 00 call 1400 + 11b0: 83 c0 10 add $0x10,%eax + 11b3: 3d 00 02 00 00 cmp $0x200,%eax + 11b8: 0f 87 4a 01 00 00 ja 1308 + strcpy(buf, path); + 11be: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax + 11c4: 89 7c 24 04 mov %edi,0x4(%esp) + 11c8: 8d bd c4 fd ff ff lea -0x23c(%ebp),%edi + 11ce: 89 04 24 mov %eax,(%esp) + 11d1: e8 aa 01 00 00 call 1380 + p = buf+strlen(buf); + 11d6: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax + 11dc: 89 04 24 mov %eax,(%esp) + 11df: e8 1c 02 00 00 call 1400 + 11e4: 8d 8d e8 fd ff ff lea -0x218(%ebp),%ecx + 11ea: 01 c8 add %ecx,%eax + *p++ = '/'; + 11ec: 8d 48 01 lea 0x1(%eax),%ecx + p = buf+strlen(buf); + 11ef: 89 85 a8 fd ff ff mov %eax,-0x258(%ebp) + *p++ = '/'; + 11f5: 89 8d a4 fd ff ff mov %ecx,-0x25c(%ebp) + 11fb: c6 00 2f movb $0x2f,(%eax) + 11fe: 66 90 xchg %ax,%ax + while(read(fd, &de, sizeof(de)) == sizeof(de)){ + 1200: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) + 1207: 00 + 1208: 89 7c 24 04 mov %edi,0x4(%esp) + 120c: 89 1c 24 mov %ebx,(%esp) + 120f: e8 a6 03 00 00 call 15ba + 1214: 83 f8 10 cmp $0x10,%eax + 1217: 0f 85 71 ff ff ff jne 118e + if(de.inum == 0) + 121d: 66 83 bd c4 fd ff ff cmpw $0x0,-0x23c(%ebp) + 1224: 00 + 1225: 74 d9 je 1200 + memmove(p, de.name, DIRSIZ); + 1227: 8d 85 c6 fd ff ff lea -0x23a(%ebp),%eax + 122d: 89 44 24 04 mov %eax,0x4(%esp) + 1231: 8b 85 a4 fd ff ff mov -0x25c(%ebp),%eax + 1237: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) + 123e: 00 + 123f: 89 04 24 mov %eax,(%esp) + 1242: e8 29 03 00 00 call 1570 + p[DIRSIZ] = 0; + 1247: 8b 85 a8 fd ff ff mov -0x258(%ebp),%eax + 124d: c6 40 0f 00 movb $0x0,0xf(%eax) + if(stat(buf, &st) < 0){ + 1251: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax + 1257: 89 74 24 04 mov %esi,0x4(%esp) + 125b: 89 04 24 mov %eax,(%esp) + 125e: e8 8d 02 00 00 call 14f0 + 1263: 85 c0 test %eax,%eax + 1265: 0f 88 e5 00 00 00 js 1350 + printf(1, "%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size); + 126b: 0f bf 95 d4 fd ff ff movswl -0x22c(%ebp),%edx + 1272: 8b 8d e4 fd ff ff mov -0x21c(%ebp),%ecx + 1278: 8b 85 dc fd ff ff mov -0x224(%ebp),%eax + 127e: 89 95 b0 fd ff ff mov %edx,-0x250(%ebp) + 1284: 8d 95 e8 fd ff ff lea -0x218(%ebp),%edx + 128a: 89 14 24 mov %edx,(%esp) + 128d: 89 8d ac fd ff ff mov %ecx,-0x254(%ebp) + 1293: 89 85 b4 fd ff ff mov %eax,-0x24c(%ebp) + 1299: e8 b2 fd ff ff call 1050 + 129e: 8b 8d ac fd ff ff mov -0x254(%ebp),%ecx + 12a4: 8b 95 b0 fd ff ff mov -0x250(%ebp),%edx + 12aa: c7 44 24 04 c9 1a 00 movl $0x1ac9,0x4(%esp) + 12b1: 00 + 12b2: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 12b9: 89 4c 24 14 mov %ecx,0x14(%esp) + 12bd: 8b 8d b4 fd ff ff mov -0x24c(%ebp),%ecx + 12c3: 89 54 24 0c mov %edx,0xc(%esp) + 12c7: 89 44 24 08 mov %eax,0x8(%esp) + 12cb: 89 4c 24 10 mov %ecx,0x10(%esp) + 12cf: e8 2c 04 00 00 call 1700 + 12d4: e9 27 ff ff ff jmp 1200 + 12d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + printf(2, "ls: cannot open %s\n", path); + 12e0: 89 7c 24 08 mov %edi,0x8(%esp) + 12e4: c7 44 24 04 a1 1a 00 movl $0x1aa1,0x4(%esp) + 12eb: 00 + 12ec: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 12f3: e8 08 04 00 00 call 1700 +} + 12f8: 81 c4 6c 02 00 00 add $0x26c,%esp + 12fe: 5b pop %ebx + 12ff: 5e pop %esi + 1300: 5f pop %edi + 1301: 5d pop %ebp + 1302: c3 ret + 1303: 90 nop + 1304: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + printf(1, "ls: path too long\n"); + 1308: c7 44 24 04 d6 1a 00 movl $0x1ad6,0x4(%esp) + 130f: 00 + 1310: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1317: e8 e4 03 00 00 call 1700 + break; + 131c: e9 6d fe ff ff jmp 118e + 1321: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + printf(2, "ls: cannot stat %s\n", path); + 1328: 89 7c 24 08 mov %edi,0x8(%esp) + 132c: c7 44 24 04 b5 1a 00 movl $0x1ab5,0x4(%esp) + 1333: 00 + 1334: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 133b: e8 c0 03 00 00 call 1700 + close(fd); + 1340: 89 1c 24 mov %ebx,(%esp) + 1343: e8 82 02 00 00 call 15ca + return; + 1348: e9 49 fe ff ff jmp 1196 + 134d: 8d 76 00 lea 0x0(%esi),%esi + printf(1, "ls: cannot stat %s\n", buf); + 1350: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax + 1356: 89 44 24 08 mov %eax,0x8(%esp) + 135a: c7 44 24 04 b5 1a 00 movl $0x1ab5,0x4(%esp) + 1361: 00 + 1362: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1369: e8 92 03 00 00 call 1700 + continue; + 136e: e9 8d fe ff ff jmp 1200 + 1373: 66 90 xchg %ax,%ax + 1375: 66 90 xchg %ax,%ax + 1377: 66 90 xchg %ax,%ax + 1379: 66 90 xchg %ax,%ax + 137b: 66 90 xchg %ax,%ax + 137d: 66 90 xchg %ax,%ax + 137f: 90 nop + +00001380 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1380: 55 push %ebp + 1381: 89 e5 mov %esp,%ebp + 1383: 8b 45 08 mov 0x8(%ebp),%eax + 1386: 8b 4d 0c mov 0xc(%ebp),%ecx + 1389: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 138a: 89 c2 mov %eax,%edx + 138c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1390: 83 c1 01 add $0x1,%ecx + 1393: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1397: 83 c2 01 add $0x1,%edx + 139a: 84 db test %bl,%bl + 139c: 88 5a ff mov %bl,-0x1(%edx) + 139f: 75 ef jne 1390 + ; + return os; +} + 13a1: 5b pop %ebx + 13a2: 5d pop %ebp + 13a3: c3 ret + 13a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 13aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +000013b0 : + +int +strcmp(const char *p, const char *q) +{ + 13b0: 55 push %ebp + 13b1: 89 e5 mov %esp,%ebp + 13b3: 8b 55 08 mov 0x8(%ebp),%edx + 13b6: 53 push %ebx + 13b7: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 13ba: 0f b6 02 movzbl (%edx),%eax + 13bd: 84 c0 test %al,%al + 13bf: 74 2d je 13ee + 13c1: 0f b6 19 movzbl (%ecx),%ebx + 13c4: 38 d8 cmp %bl,%al + 13c6: 74 0e je 13d6 + 13c8: eb 2b jmp 13f5 + 13ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 13d0: 38 c8 cmp %cl,%al + 13d2: 75 15 jne 13e9 + p++, q++; + 13d4: 89 d9 mov %ebx,%ecx + 13d6: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 13d9: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 13dc: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 13df: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 13e3: 84 c0 test %al,%al + 13e5: 75 e9 jne 13d0 + 13e7: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 13e9: 29 c8 sub %ecx,%eax +} + 13eb: 5b pop %ebx + 13ec: 5d pop %ebp + 13ed: c3 ret + 13ee: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 13f1: 31 c0 xor %eax,%eax + 13f3: eb f4 jmp 13e9 + 13f5: 0f b6 cb movzbl %bl,%ecx + 13f8: eb ef jmp 13e9 + 13fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00001400 : + +uint +strlen(char *s) +{ + 1400: 55 push %ebp + 1401: 89 e5 mov %esp,%ebp + 1403: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 1406: 80 39 00 cmpb $0x0,(%ecx) + 1409: 74 12 je 141d + 140b: 31 d2 xor %edx,%edx + 140d: 8d 76 00 lea 0x0(%esi),%esi + 1410: 83 c2 01 add $0x1,%edx + 1413: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 1417: 89 d0 mov %edx,%eax + 1419: 75 f5 jne 1410 + ; + return n; +} + 141b: 5d pop %ebp + 141c: c3 ret + for(n = 0; s[n]; n++) + 141d: 31 c0 xor %eax,%eax +} + 141f: 5d pop %ebp + 1420: c3 ret + 1421: eb 0d jmp 1430 + 1423: 90 nop + 1424: 90 nop + 1425: 90 nop + 1426: 90 nop + 1427: 90 nop + 1428: 90 nop + 1429: 90 nop + 142a: 90 nop + 142b: 90 nop + 142c: 90 nop + 142d: 90 nop + 142e: 90 nop + 142f: 90 nop + +00001430 : + +void* +memset(void *dst, int c, uint n) +{ + 1430: 55 push %ebp + 1431: 89 e5 mov %esp,%ebp + 1433: 8b 55 08 mov 0x8(%ebp),%edx + 1436: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 1437: 8b 4d 10 mov 0x10(%ebp),%ecx + 143a: 8b 45 0c mov 0xc(%ebp),%eax + 143d: 89 d7 mov %edx,%edi + 143f: fc cld + 1440: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1442: 89 d0 mov %edx,%eax + 1444: 5f pop %edi + 1445: 5d pop %ebp + 1446: c3 ret + 1447: 89 f6 mov %esi,%esi + 1449: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001450 : + +char* +strchr(const char *s, char c) +{ + 1450: 55 push %ebp + 1451: 89 e5 mov %esp,%ebp + 1453: 8b 45 08 mov 0x8(%ebp),%eax + 1456: 53 push %ebx + 1457: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 145a: 0f b6 18 movzbl (%eax),%ebx + 145d: 84 db test %bl,%bl + 145f: 74 1d je 147e + if(*s == c) + 1461: 38 d3 cmp %dl,%bl + 1463: 89 d1 mov %edx,%ecx + 1465: 75 0d jne 1474 + 1467: eb 17 jmp 1480 + 1469: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1470: 38 ca cmp %cl,%dl + 1472: 74 0c je 1480 + for(; *s; s++) + 1474: 83 c0 01 add $0x1,%eax + 1477: 0f b6 10 movzbl (%eax),%edx + 147a: 84 d2 test %dl,%dl + 147c: 75 f2 jne 1470 + return (char*)s; + return 0; + 147e: 31 c0 xor %eax,%eax +} + 1480: 5b pop %ebx + 1481: 5d pop %ebp + 1482: c3 ret + 1483: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1489: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001490 : + +char* +gets(char *buf, int max) +{ + 1490: 55 push %ebp + 1491: 89 e5 mov %esp,%ebp + 1493: 57 push %edi + 1494: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1495: 31 f6 xor %esi,%esi +{ + 1497: 53 push %ebx + 1498: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 149b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 149e: eb 31 jmp 14d1 + cc = read(0, &c, 1); + 14a0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14a7: 00 + 14a8: 89 7c 24 04 mov %edi,0x4(%esp) + 14ac: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 14b3: e8 02 01 00 00 call 15ba + if(cc < 1) + 14b8: 85 c0 test %eax,%eax + 14ba: 7e 1d jle 14d9 + break; + buf[i++] = c; + 14bc: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 14c0: 89 de mov %ebx,%esi + buf[i++] = c; + 14c2: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 14c5: 3c 0d cmp $0xd,%al + buf[i++] = c; + 14c7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 14cb: 74 0c je 14d9 + 14cd: 3c 0a cmp $0xa,%al + 14cf: 74 08 je 14d9 + for(i=0; i+1 < max; ){ + 14d1: 8d 5e 01 lea 0x1(%esi),%ebx + 14d4: 3b 5d 0c cmp 0xc(%ebp),%ebx + 14d7: 7c c7 jl 14a0 + break; + } + buf[i] = '\0'; + 14d9: 8b 45 08 mov 0x8(%ebp),%eax + 14dc: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 14e0: 83 c4 2c add $0x2c,%esp + 14e3: 5b pop %ebx + 14e4: 5e pop %esi + 14e5: 5f pop %edi + 14e6: 5d pop %ebp + 14e7: c3 ret + 14e8: 90 nop + 14e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000014f0 : + +int +stat(char *n, struct stat *st) +{ + 14f0: 55 push %ebp + 14f1: 89 e5 mov %esp,%ebp + 14f3: 56 push %esi + 14f4: 53 push %ebx + 14f5: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 14f8: 8b 45 08 mov 0x8(%ebp),%eax + 14fb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1502: 00 + 1503: 89 04 24 mov %eax,(%esp) + 1506: e8 d7 00 00 00 call 15e2 + if(fd < 0) + 150b: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 150d: 89 c3 mov %eax,%ebx + if(fd < 0) + 150f: 78 27 js 1538 + return -1; + r = fstat(fd, st); + 1511: 8b 45 0c mov 0xc(%ebp),%eax + 1514: 89 1c 24 mov %ebx,(%esp) + 1517: 89 44 24 04 mov %eax,0x4(%esp) + 151b: e8 da 00 00 00 call 15fa + close(fd); + 1520: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 1523: 89 c6 mov %eax,%esi + close(fd); + 1525: e8 a0 00 00 00 call 15ca + return r; + 152a: 89 f0 mov %esi,%eax +} + 152c: 83 c4 10 add $0x10,%esp + 152f: 5b pop %ebx + 1530: 5e pop %esi + 1531: 5d pop %ebp + 1532: c3 ret + 1533: 90 nop + 1534: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 1538: b8 ff ff ff ff mov $0xffffffff,%eax + 153d: eb ed jmp 152c + 153f: 90 nop + +00001540 : + +int +atoi(const char *s) +{ + 1540: 55 push %ebp + 1541: 89 e5 mov %esp,%ebp + 1543: 8b 4d 08 mov 0x8(%ebp),%ecx + 1546: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 1547: 0f be 11 movsbl (%ecx),%edx + 154a: 8d 42 d0 lea -0x30(%edx),%eax + 154d: 3c 09 cmp $0x9,%al + n = 0; + 154f: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 1554: 77 17 ja 156d + 1556: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 1558: 83 c1 01 add $0x1,%ecx + 155b: 8d 04 80 lea (%eax,%eax,4),%eax + 155e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1562: 0f be 11 movsbl (%ecx),%edx + 1565: 8d 5a d0 lea -0x30(%edx),%ebx + 1568: 80 fb 09 cmp $0x9,%bl + 156b: 76 eb jbe 1558 + return n; +} + 156d: 5b pop %ebx + 156e: 5d pop %ebp + 156f: c3 ret + +00001570 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1570: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1571: 31 d2 xor %edx,%edx +{ + 1573: 89 e5 mov %esp,%ebp + 1575: 56 push %esi + 1576: 8b 45 08 mov 0x8(%ebp),%eax + 1579: 53 push %ebx + 157a: 8b 5d 10 mov 0x10(%ebp),%ebx + 157d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1580: 85 db test %ebx,%ebx + 1582: 7e 12 jle 1596 + 1584: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1588: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 158c: 88 0c 10 mov %cl,(%eax,%edx,1) + 158f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1592: 39 da cmp %ebx,%edx + 1594: 75 f2 jne 1588 + return vdst; +} + 1596: 5b pop %ebx + 1597: 5e pop %esi + 1598: 5d pop %ebp + 1599: c3 ret + +0000159a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 159a: b8 01 00 00 00 mov $0x1,%eax + 159f: cd 40 int $0x40 + 15a1: c3 ret + +000015a2 : +SYSCALL(exit) + 15a2: b8 02 00 00 00 mov $0x2,%eax + 15a7: cd 40 int $0x40 + 15a9: c3 ret + +000015aa : +SYSCALL(wait) + 15aa: b8 03 00 00 00 mov $0x3,%eax + 15af: cd 40 int $0x40 + 15b1: c3 ret + +000015b2 : +SYSCALL(pipe) + 15b2: b8 04 00 00 00 mov $0x4,%eax + 15b7: cd 40 int $0x40 + 15b9: c3 ret + +000015ba : +SYSCALL(read) + 15ba: b8 05 00 00 00 mov $0x5,%eax + 15bf: cd 40 int $0x40 + 15c1: c3 ret + +000015c2 : +SYSCALL(write) + 15c2: b8 10 00 00 00 mov $0x10,%eax + 15c7: cd 40 int $0x40 + 15c9: c3 ret + +000015ca : +SYSCALL(close) + 15ca: b8 15 00 00 00 mov $0x15,%eax + 15cf: cd 40 int $0x40 + 15d1: c3 ret + +000015d2 : +SYSCALL(kill) + 15d2: b8 06 00 00 00 mov $0x6,%eax + 15d7: cd 40 int $0x40 + 15d9: c3 ret + +000015da : +SYSCALL(exec) + 15da: b8 07 00 00 00 mov $0x7,%eax + 15df: cd 40 int $0x40 + 15e1: c3 ret + +000015e2 : +SYSCALL(open) + 15e2: b8 0f 00 00 00 mov $0xf,%eax + 15e7: cd 40 int $0x40 + 15e9: c3 ret + +000015ea : +SYSCALL(mknod) + 15ea: b8 11 00 00 00 mov $0x11,%eax + 15ef: cd 40 int $0x40 + 15f1: c3 ret + +000015f2 : +SYSCALL(unlink) + 15f2: b8 12 00 00 00 mov $0x12,%eax + 15f7: cd 40 int $0x40 + 15f9: c3 ret + +000015fa : +SYSCALL(fstat) + 15fa: b8 08 00 00 00 mov $0x8,%eax + 15ff: cd 40 int $0x40 + 1601: c3 ret + +00001602 : +SYSCALL(link) + 1602: b8 13 00 00 00 mov $0x13,%eax + 1607: cd 40 int $0x40 + 1609: c3 ret + +0000160a : +SYSCALL(mkdir) + 160a: b8 14 00 00 00 mov $0x14,%eax + 160f: cd 40 int $0x40 + 1611: c3 ret + +00001612 : +SYSCALL(chdir) + 1612: b8 09 00 00 00 mov $0x9,%eax + 1617: cd 40 int $0x40 + 1619: c3 ret + +0000161a : +SYSCALL(dup) + 161a: b8 0a 00 00 00 mov $0xa,%eax + 161f: cd 40 int $0x40 + 1621: c3 ret + +00001622 : +SYSCALL(getpid) + 1622: b8 0b 00 00 00 mov $0xb,%eax + 1627: cd 40 int $0x40 + 1629: c3 ret + +0000162a : +SYSCALL(sbrk) + 162a: b8 0c 00 00 00 mov $0xc,%eax + 162f: cd 40 int $0x40 + 1631: c3 ret + +00001632 : +SYSCALL(sleep) + 1632: b8 0d 00 00 00 mov $0xd,%eax + 1637: cd 40 int $0x40 + 1639: c3 ret + +0000163a : +SYSCALL(uptime) + 163a: b8 0e 00 00 00 mov $0xe,%eax + 163f: cd 40 int $0x40 + 1641: c3 ret + +00001642 : +SYSCALL(shm_open) + 1642: b8 16 00 00 00 mov $0x16,%eax + 1647: cd 40 int $0x40 + 1649: c3 ret + +0000164a : +SYSCALL(shm_close) + 164a: b8 17 00 00 00 mov $0x17,%eax + 164f: cd 40 int $0x40 + 1651: c3 ret + 1652: 66 90 xchg %ax,%ax + 1654: 66 90 xchg %ax,%ax + 1656: 66 90 xchg %ax,%ax + 1658: 66 90 xchg %ax,%ax + 165a: 66 90 xchg %ax,%ax + 165c: 66 90 xchg %ax,%ax + 165e: 66 90 xchg %ax,%ax + +00001660 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 1660: 55 push %ebp + 1661: 89 e5 mov %esp,%ebp + 1663: 57 push %edi + 1664: 56 push %esi + 1665: 89 c6 mov %eax,%esi + 1667: 53 push %ebx + 1668: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 166b: 8b 5d 08 mov 0x8(%ebp),%ebx + 166e: 85 db test %ebx,%ebx + 1670: 74 09 je 167b + 1672: 89 d0 mov %edx,%eax + 1674: c1 e8 1f shr $0x1f,%eax + 1677: 84 c0 test %al,%al + 1679: 75 75 jne 16f0 + neg = 1; + x = -xx; + } else { + x = xx; + 167b: 89 d0 mov %edx,%eax + neg = 0; + 167d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1684: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1687: 31 ff xor %edi,%edi + 1689: 89 ce mov %ecx,%esi + 168b: 8d 5d d7 lea -0x29(%ebp),%ebx + 168e: eb 02 jmp 1692 + do{ + buf[i++] = digits[x % base]; + 1690: 89 cf mov %ecx,%edi + 1692: 31 d2 xor %edx,%edx + 1694: f7 f6 div %esi + 1696: 8d 4f 01 lea 0x1(%edi),%ecx + 1699: 0f b6 92 f2 1a 00 00 movzbl 0x1af2(%edx),%edx + }while((x /= base) != 0); + 16a0: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 16a2: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 16a5: 75 e9 jne 1690 + if(neg) + 16a7: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 16aa: 89 c8 mov %ecx,%eax + 16ac: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 16af: 85 d2 test %edx,%edx + 16b1: 74 08 je 16bb + buf[i++] = '-'; + 16b3: 8d 4f 02 lea 0x2(%edi),%ecx + 16b6: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 16bb: 8d 79 ff lea -0x1(%ecx),%edi + 16be: 66 90 xchg %ax,%ax + 16c0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 16c5: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 16c8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 16cf: 00 + 16d0: 89 5c 24 04 mov %ebx,0x4(%esp) + 16d4: 89 34 24 mov %esi,(%esp) + 16d7: 88 45 d7 mov %al,-0x29(%ebp) + 16da: e8 e3 fe ff ff call 15c2 + while(--i >= 0) + 16df: 83 ff ff cmp $0xffffffff,%edi + 16e2: 75 dc jne 16c0 + putc(fd, buf[i]); +} + 16e4: 83 c4 4c add $0x4c,%esp + 16e7: 5b pop %ebx + 16e8: 5e pop %esi + 16e9: 5f pop %edi + 16ea: 5d pop %ebp + 16eb: c3 ret + 16ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 16f0: 89 d0 mov %edx,%eax + 16f2: f7 d8 neg %eax + neg = 1; + 16f4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 16fb: eb 87 jmp 1684 + 16fd: 8d 76 00 lea 0x0(%esi),%esi + +00001700 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 1700: 55 push %ebp + 1701: 89 e5 mov %esp,%ebp + 1703: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 1704: 31 ff xor %edi,%edi +{ + 1706: 56 push %esi + 1707: 53 push %ebx + 1708: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 170b: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 170e: 8d 45 10 lea 0x10(%ebp),%eax +{ + 1711: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 1714: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 1717: 0f b6 13 movzbl (%ebx),%edx + 171a: 83 c3 01 add $0x1,%ebx + 171d: 84 d2 test %dl,%dl + 171f: 75 39 jne 175a + 1721: e9 c2 00 00 00 jmp 17e8 + 1726: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 1728: 83 fa 25 cmp $0x25,%edx + 172b: 0f 84 bf 00 00 00 je 17f0 + write(fd, &c, 1); + 1731: 8d 45 e2 lea -0x1e(%ebp),%eax + 1734: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 173b: 00 + 173c: 89 44 24 04 mov %eax,0x4(%esp) + 1740: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 1743: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 1746: e8 77 fe ff ff call 15c2 + 174b: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 174e: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 1752: 84 d2 test %dl,%dl + 1754: 0f 84 8e 00 00 00 je 17e8 + if(state == 0){ + 175a: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 175c: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 175f: 74 c7 je 1728 + } + } else if(state == '%'){ + 1761: 83 ff 25 cmp $0x25,%edi + 1764: 75 e5 jne 174b + if(c == 'd'){ + 1766: 83 fa 64 cmp $0x64,%edx + 1769: 0f 84 31 01 00 00 je 18a0 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 176f: 25 f7 00 00 00 and $0xf7,%eax + 1774: 83 f8 70 cmp $0x70,%eax + 1777: 0f 84 83 00 00 00 je 1800 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 177d: 83 fa 73 cmp $0x73,%edx + 1780: 0f 84 a2 00 00 00 je 1828 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1786: 83 fa 63 cmp $0x63,%edx + 1789: 0f 84 35 01 00 00 je 18c4 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 178f: 83 fa 25 cmp $0x25,%edx + 1792: 0f 84 e0 00 00 00 je 1878 + write(fd, &c, 1); + 1798: 8d 45 e6 lea -0x1a(%ebp),%eax + 179b: 83 c3 01 add $0x1,%ebx + 179e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 17a5: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 17a6: 31 ff xor %edi,%edi + write(fd, &c, 1); + 17a8: 89 44 24 04 mov %eax,0x4(%esp) + 17ac: 89 34 24 mov %esi,(%esp) + 17af: 89 55 d0 mov %edx,-0x30(%ebp) + 17b2: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 17b6: e8 07 fe ff ff call 15c2 + putc(fd, c); + 17bb: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 17be: 8d 45 e7 lea -0x19(%ebp),%eax + 17c1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 17c8: 00 + 17c9: 89 44 24 04 mov %eax,0x4(%esp) + 17cd: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 17d0: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 17d3: e8 ea fd ff ff call 15c2 + for(i = 0; fmt[i]; i++){ + 17d8: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 17dc: 84 d2 test %dl,%dl + 17de: 0f 85 76 ff ff ff jne 175a + 17e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 17e8: 83 c4 3c add $0x3c,%esp + 17eb: 5b pop %ebx + 17ec: 5e pop %esi + 17ed: 5f pop %edi + 17ee: 5d pop %ebp + 17ef: c3 ret + state = '%'; + 17f0: bf 25 00 00 00 mov $0x25,%edi + 17f5: e9 51 ff ff ff jmp 174b + 17fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 1800: 8b 45 d4 mov -0x2c(%ebp),%eax + 1803: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 1808: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 180a: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1811: 8b 10 mov (%eax),%edx + 1813: 89 f0 mov %esi,%eax + 1815: e8 46 fe ff ff call 1660 + ap++; + 181a: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 181e: e9 28 ff ff ff jmp 174b + 1823: 90 nop + 1824: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 1828: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 182b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 182f: 8b 38 mov (%eax),%edi + s = "(null)"; + 1831: b8 eb 1a 00 00 mov $0x1aeb,%eax + 1836: 85 ff test %edi,%edi + 1838: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 183b: 0f b6 07 movzbl (%edi),%eax + 183e: 84 c0 test %al,%al + 1840: 74 2a je 186c + 1842: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1848: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 184b: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 184e: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 1851: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1858: 00 + 1859: 89 44 24 04 mov %eax,0x4(%esp) + 185d: 89 34 24 mov %esi,(%esp) + 1860: e8 5d fd ff ff call 15c2 + while(*s != 0){ + 1865: 0f b6 07 movzbl (%edi),%eax + 1868: 84 c0 test %al,%al + 186a: 75 dc jne 1848 + state = 0; + 186c: 31 ff xor %edi,%edi + 186e: e9 d8 fe ff ff jmp 174b + 1873: 90 nop + 1874: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1878: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 187b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 187d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1884: 00 + 1885: 89 44 24 04 mov %eax,0x4(%esp) + 1889: 89 34 24 mov %esi,(%esp) + 188c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1890: e8 2d fd ff ff call 15c2 + 1895: e9 b1 fe ff ff jmp 174b + 189a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 18a0: 8b 45 d4 mov -0x2c(%ebp),%eax + 18a3: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 18a8: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 18ab: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 18b2: 8b 10 mov (%eax),%edx + 18b4: 89 f0 mov %esi,%eax + 18b6: e8 a5 fd ff ff call 1660 + ap++; + 18bb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 18bf: e9 87 fe ff ff jmp 174b + putc(fd, *ap); + 18c4: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 18c7: 31 ff xor %edi,%edi + putc(fd, *ap); + 18c9: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 18cb: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 18d2: 00 + 18d3: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 18d6: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 18d9: 8d 45 e4 lea -0x1c(%ebp),%eax + 18dc: 89 44 24 04 mov %eax,0x4(%esp) + 18e0: e8 dd fc ff ff call 15c2 + ap++; + 18e5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 18e9: e9 5d fe ff ff jmp 174b + 18ee: 66 90 xchg %ax,%ax + +000018f0 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 18f0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 18f1: a1 24 1e 00 00 mov 0x1e24,%eax +{ + 18f6: 89 e5 mov %esp,%ebp + 18f8: 57 push %edi + 18f9: 56 push %esi + 18fa: 53 push %ebx + 18fb: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 18fe: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 1900: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1903: 39 d0 cmp %edx,%eax + 1905: 72 11 jb 1918 + 1907: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1908: 39 c8 cmp %ecx,%eax + 190a: 72 04 jb 1910 + 190c: 39 ca cmp %ecx,%edx + 190e: 72 10 jb 1920 + 1910: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1912: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1914: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1916: 73 f0 jae 1908 + 1918: 39 ca cmp %ecx,%edx + 191a: 72 04 jb 1920 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 191c: 39 c8 cmp %ecx,%eax + 191e: 72 f0 jb 1910 + break; + if(bp + bp->s.size == p->s.ptr){ + 1920: 8b 73 fc mov -0x4(%ebx),%esi + 1923: 8d 3c f2 lea (%edx,%esi,8),%edi + 1926: 39 cf cmp %ecx,%edi + 1928: 74 1e je 1948 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 192a: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 192d: 8b 48 04 mov 0x4(%eax),%ecx + 1930: 8d 34 c8 lea (%eax,%ecx,8),%esi + 1933: 39 f2 cmp %esi,%edx + 1935: 74 28 je 195f + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 1937: 89 10 mov %edx,(%eax) + freep = p; + 1939: a3 24 1e 00 00 mov %eax,0x1e24 +} + 193e: 5b pop %ebx + 193f: 5e pop %esi + 1940: 5f pop %edi + 1941: 5d pop %ebp + 1942: c3 ret + 1943: 90 nop + 1944: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 1948: 03 71 04 add 0x4(%ecx),%esi + 194b: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 194e: 8b 08 mov (%eax),%ecx + 1950: 8b 09 mov (%ecx),%ecx + 1952: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 1955: 8b 48 04 mov 0x4(%eax),%ecx + 1958: 8d 34 c8 lea (%eax,%ecx,8),%esi + 195b: 39 f2 cmp %esi,%edx + 195d: 75 d8 jne 1937 + p->s.size += bp->s.size; + 195f: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 1962: a3 24 1e 00 00 mov %eax,0x1e24 + p->s.size += bp->s.size; + 1967: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 196a: 8b 53 f8 mov -0x8(%ebx),%edx + 196d: 89 10 mov %edx,(%eax) +} + 196f: 5b pop %ebx + 1970: 5e pop %esi + 1971: 5f pop %edi + 1972: 5d pop %ebp + 1973: c3 ret + 1974: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 197a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001980 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1980: 55 push %ebp + 1981: 89 e5 mov %esp,%ebp + 1983: 57 push %edi + 1984: 56 push %esi + 1985: 53 push %ebx + 1986: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1989: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 198c: 8b 1d 24 1e 00 00 mov 0x1e24,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1992: 8d 48 07 lea 0x7(%eax),%ecx + 1995: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1998: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 199a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 199d: 0f 84 9b 00 00 00 je 1a3e + 19a3: 8b 13 mov (%ebx),%edx + 19a5: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 19a8: 39 fe cmp %edi,%esi + 19aa: 76 64 jbe 1a10 + 19ac: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 19b3: bb 00 80 00 00 mov $0x8000,%ebx + 19b8: 89 45 e4 mov %eax,-0x1c(%ebp) + 19bb: eb 0e jmp 19cb + 19bd: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 19c0: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 19c2: 8b 78 04 mov 0x4(%eax),%edi + 19c5: 39 fe cmp %edi,%esi + 19c7: 76 4f jbe 1a18 + 19c9: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 19cb: 3b 15 24 1e 00 00 cmp 0x1e24,%edx + 19d1: 75 ed jne 19c0 + if(nu < 4096) + 19d3: 8b 45 e4 mov -0x1c(%ebp),%eax + 19d6: 81 fe 00 10 00 00 cmp $0x1000,%esi + 19dc: bf 00 10 00 00 mov $0x1000,%edi + 19e1: 0f 43 fe cmovae %esi,%edi + 19e4: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 19e7: 89 04 24 mov %eax,(%esp) + 19ea: e8 3b fc ff ff call 162a + if(p == (char*)-1) + 19ef: 83 f8 ff cmp $0xffffffff,%eax + 19f2: 74 18 je 1a0c + hp->s.size = nu; + 19f4: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 19f7: 83 c0 08 add $0x8,%eax + 19fa: 89 04 24 mov %eax,(%esp) + 19fd: e8 ee fe ff ff call 18f0 + return freep; + 1a02: 8b 15 24 1e 00 00 mov 0x1e24,%edx + if((p = morecore(nunits)) == 0) + 1a08: 85 d2 test %edx,%edx + 1a0a: 75 b4 jne 19c0 + return 0; + 1a0c: 31 c0 xor %eax,%eax + 1a0e: eb 20 jmp 1a30 + if(p->s.size >= nunits){ + 1a10: 89 d0 mov %edx,%eax + 1a12: 89 da mov %ebx,%edx + 1a14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 1a18: 39 fe cmp %edi,%esi + 1a1a: 74 1c je 1a38 + p->s.size -= nunits; + 1a1c: 29 f7 sub %esi,%edi + 1a1e: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 1a21: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 1a24: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 1a27: 89 15 24 1e 00 00 mov %edx,0x1e24 + return (void*)(p + 1); + 1a2d: 83 c0 08 add $0x8,%eax + } +} + 1a30: 83 c4 1c add $0x1c,%esp + 1a33: 5b pop %ebx + 1a34: 5e pop %esi + 1a35: 5f pop %edi + 1a36: 5d pop %ebp + 1a37: c3 ret + prevp->s.ptr = p->s.ptr; + 1a38: 8b 08 mov (%eax),%ecx + 1a3a: 89 0a mov %ecx,(%edx) + 1a3c: eb e9 jmp 1a27 + base.s.ptr = freep = prevp = &base; + 1a3e: c7 05 24 1e 00 00 28 movl $0x1e28,0x1e24 + 1a45: 1e 00 00 + base.s.size = 0; + 1a48: ba 28 1e 00 00 mov $0x1e28,%edx + base.s.ptr = freep = prevp = &base; + 1a4d: c7 05 28 1e 00 00 28 movl $0x1e28,0x1e28 + 1a54: 1e 00 00 + base.s.size = 0; + 1a57: c7 05 2c 1e 00 00 00 movl $0x0,0x1e2c + 1a5e: 00 00 00 + 1a61: e9 46 ff ff ff jmp 19ac + 1a66: 66 90 xchg %ax,%ax + 1a68: 66 90 xchg %ax,%ax + 1a6a: 66 90 xchg %ax,%ax + 1a6c: 66 90 xchg %ax,%ax + 1a6e: 66 90 xchg %ax,%ax + +00001a70 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1a70: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1a71: b9 01 00 00 00 mov $0x1,%ecx + 1a76: 89 e5 mov %esp,%ebp + 1a78: 8b 55 08 mov 0x8(%ebp),%edx + 1a7b: 90 nop + 1a7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1a80: 89 c8 mov %ecx,%eax + 1a82: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1a85: 85 c0 test %eax,%eax + 1a87: 75 f7 jne 1a80 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1a89: 0f ae f0 mfence +} + 1a8c: 5d pop %ebp + 1a8d: c3 ret + 1a8e: 66 90 xchg %ax,%ax + +00001a90 : + +void urelease (struct uspinlock *lk) { + 1a90: 55 push %ebp + 1a91: 89 e5 mov %esp,%ebp + 1a93: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1a96: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1a99: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 1a9f: 5d pop %ebp + 1aa0: c3 ret diff --git a/ls.d b/ls.d new file mode 100644 index 00000000..a55b6d4d --- /dev/null +++ b/ls.d @@ -0,0 +1 @@ +ls.o: ls.c /usr/include/stdc-predef.h types.h stat.h user.h fs.h diff --git a/ls.o b/ls.o new file mode 100644 index 00000000..deaf642d Binary files /dev/null and b/ls.o differ diff --git a/ls.sym b/ls.sym new file mode 100644 index 00000000..fe75bf93 --- /dev/null +++ b/ls.sym @@ -0,0 +1,65 @@ +00001000 .text +00001aa1 .rodata +00001b04 .eh_frame +00001e14 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 ls.c +00001e14 buf.1370 +00000000 ulib.c +00000000 printf.c +00001660 printint +00001af2 digits.1359 +00000000 umalloc.c +00001e24 freep +00001e28 base +00000000 uspinlock.c +00001380 strcpy +00001050 fmtname +00001700 printf +00001570 memmove +000015ea mknod +00001642 shm_open +00001490 gets +00001622 getpid +00001980 malloc +00001632 sleep +000015b2 pipe +000015c2 write +000015fa fstat +000015d2 kill +00001612 chdir +000015da exec +000015aa wait +000015ba read +000015f2 unlink +00001a70 uacquire +0000159a fork +0000162a sbrk +0000164a shm_close +0000163a uptime +00001e14 __bss_start +00001430 memset +00001000 main +000013b0 strcmp +0000161a dup +000014f0 stat +00001e14 _edata +00001e30 _end +00001602 link +000010f0 ls +000015a2 exit +00001540 atoi +00001400 strlen +000015e2 open +00001450 strchr +0000160a mkdir +000015ca close +00001a90 urelease +000018f0 free diff --git a/main.d b/main.d new file mode 100644 index 00000000..354dab4e --- /dev/null +++ b/main.d @@ -0,0 +1,2 @@ +main.o: main.c /usr/include/stdc-predef.h types.h defs.h param.h \ + memlayout.h mmu.h proc.h x86.h diff --git a/main.o b/main.o new file mode 100644 index 00000000..c410e61b Binary files /dev/null and b/main.o differ diff --git a/memlayout.h b/memlayout.h index 70c1968e..2b4b0549 100644 --- a/memlayout.h +++ b/memlayout.h @@ -9,7 +9,7 @@ #define KERNLINK (KERNBASE+EXTMEM) // Address where kernel is linked #define V2P(a) (((uint) (a)) - KERNBASE) -#define P2V(a) (((void *) (a)) + KERNBASE) +#define P2V(a) (((void *) (a)) + KERNBASE) #define V2P_WO(x) ((x) - KERNBASE) // same as V2P, but without casts #define P2V_WO(x) ((x) + KERNBASE) // same as P2V, but without casts diff --git a/mkdir.asm b/mkdir.asm new file mode 100644 index 00000000..7d1d2590 --- /dev/null +++ b/mkdir.asm @@ -0,0 +1,1240 @@ + +_mkdir: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: +#include "stat.h" +#include "user.h" + +int +main(int argc, char *argv[]) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 57 push %edi + 1004: 56 push %esi + int i; + + if(argc < 2){ + 1005: be 01 00 00 00 mov $0x1,%esi +{ + 100a: 53 push %ebx + 100b: 83 e4 f0 and $0xfffffff0,%esp + 100e: 83 ec 10 sub $0x10,%esp + 1011: 8b 7d 08 mov 0x8(%ebp),%edi + 1014: 8b 45 0c mov 0xc(%ebp),%eax + if(argc < 2){ + 1017: 83 ff 01 cmp $0x1,%edi + 101a: 8d 58 04 lea 0x4(%eax),%ebx + 101d: 7e 3a jle 1059 + 101f: 90 nop + printf(2, "Usage: mkdir files...\n"); + exit(); + } + + for(i = 1; i < argc; i++){ + if(mkdir(argv[i]) < 0){ + 1020: 8b 03 mov (%ebx),%eax + 1022: 89 04 24 mov %eax,(%esp) + 1025: e8 e0 02 00 00 call 130a + 102a: 85 c0 test %eax,%eax + 102c: 78 0f js 103d + for(i = 1; i < argc; i++){ + 102e: 83 c6 01 add $0x1,%esi + 1031: 83 c3 04 add $0x4,%ebx + 1034: 39 fe cmp %edi,%esi + 1036: 75 e8 jne 1020 + printf(2, "mkdir: %s failed to create\n", argv[i]); + break; + } + } + + exit(); + 1038: e8 65 02 00 00 call 12a2 + printf(2, "mkdir: %s failed to create\n", argv[i]); + 103d: 8b 03 mov (%ebx),%eax + 103f: c7 44 24 04 b8 17 00 movl $0x17b8,0x4(%esp) + 1046: 00 + 1047: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 104e: 89 44 24 08 mov %eax,0x8(%esp) + 1052: e8 a9 03 00 00 call 1400 + break; + 1057: eb df jmp 1038 + printf(2, "Usage: mkdir files...\n"); + 1059: c7 44 24 04 a1 17 00 movl $0x17a1,0x4(%esp) + 1060: 00 + 1061: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 1068: e8 93 03 00 00 call 1400 + exit(); + 106d: e8 30 02 00 00 call 12a2 + 1072: 66 90 xchg %ax,%ax + 1074: 66 90 xchg %ax,%ax + 1076: 66 90 xchg %ax,%ax + 1078: 66 90 xchg %ax,%ax + 107a: 66 90 xchg %ax,%ax + 107c: 66 90 xchg %ax,%ax + 107e: 66 90 xchg %ax,%ax + +00001080 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1080: 55 push %ebp + 1081: 89 e5 mov %esp,%ebp + 1083: 8b 45 08 mov 0x8(%ebp),%eax + 1086: 8b 4d 0c mov 0xc(%ebp),%ecx + 1089: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 108a: 89 c2 mov %eax,%edx + 108c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1090: 83 c1 01 add $0x1,%ecx + 1093: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1097: 83 c2 01 add $0x1,%edx + 109a: 84 db test %bl,%bl + 109c: 88 5a ff mov %bl,-0x1(%edx) + 109f: 75 ef jne 1090 + ; + return os; +} + 10a1: 5b pop %ebx + 10a2: 5d pop %ebp + 10a3: c3 ret + 10a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 10aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +000010b0 : + +int +strcmp(const char *p, const char *q) +{ + 10b0: 55 push %ebp + 10b1: 89 e5 mov %esp,%ebp + 10b3: 8b 55 08 mov 0x8(%ebp),%edx + 10b6: 53 push %ebx + 10b7: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 10ba: 0f b6 02 movzbl (%edx),%eax + 10bd: 84 c0 test %al,%al + 10bf: 74 2d je 10ee + 10c1: 0f b6 19 movzbl (%ecx),%ebx + 10c4: 38 d8 cmp %bl,%al + 10c6: 74 0e je 10d6 + 10c8: eb 2b jmp 10f5 + 10ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 10d0: 38 c8 cmp %cl,%al + 10d2: 75 15 jne 10e9 + p++, q++; + 10d4: 89 d9 mov %ebx,%ecx + 10d6: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 10d9: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 10dc: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 10df: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 10e3: 84 c0 test %al,%al + 10e5: 75 e9 jne 10d0 + 10e7: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 10e9: 29 c8 sub %ecx,%eax +} + 10eb: 5b pop %ebx + 10ec: 5d pop %ebp + 10ed: c3 ret + 10ee: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 10f1: 31 c0 xor %eax,%eax + 10f3: eb f4 jmp 10e9 + 10f5: 0f b6 cb movzbl %bl,%ecx + 10f8: eb ef jmp 10e9 + 10fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00001100 : + +uint +strlen(char *s) +{ + 1100: 55 push %ebp + 1101: 89 e5 mov %esp,%ebp + 1103: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 1106: 80 39 00 cmpb $0x0,(%ecx) + 1109: 74 12 je 111d + 110b: 31 d2 xor %edx,%edx + 110d: 8d 76 00 lea 0x0(%esi),%esi + 1110: 83 c2 01 add $0x1,%edx + 1113: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 1117: 89 d0 mov %edx,%eax + 1119: 75 f5 jne 1110 + ; + return n; +} + 111b: 5d pop %ebp + 111c: c3 ret + for(n = 0; s[n]; n++) + 111d: 31 c0 xor %eax,%eax +} + 111f: 5d pop %ebp + 1120: c3 ret + 1121: eb 0d jmp 1130 + 1123: 90 nop + 1124: 90 nop + 1125: 90 nop + 1126: 90 nop + 1127: 90 nop + 1128: 90 nop + 1129: 90 nop + 112a: 90 nop + 112b: 90 nop + 112c: 90 nop + 112d: 90 nop + 112e: 90 nop + 112f: 90 nop + +00001130 : + +void* +memset(void *dst, int c, uint n) +{ + 1130: 55 push %ebp + 1131: 89 e5 mov %esp,%ebp + 1133: 8b 55 08 mov 0x8(%ebp),%edx + 1136: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 1137: 8b 4d 10 mov 0x10(%ebp),%ecx + 113a: 8b 45 0c mov 0xc(%ebp),%eax + 113d: 89 d7 mov %edx,%edi + 113f: fc cld + 1140: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1142: 89 d0 mov %edx,%eax + 1144: 5f pop %edi + 1145: 5d pop %ebp + 1146: c3 ret + 1147: 89 f6 mov %esi,%esi + 1149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001150 : + +char* +strchr(const char *s, char c) +{ + 1150: 55 push %ebp + 1151: 89 e5 mov %esp,%ebp + 1153: 8b 45 08 mov 0x8(%ebp),%eax + 1156: 53 push %ebx + 1157: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 115a: 0f b6 18 movzbl (%eax),%ebx + 115d: 84 db test %bl,%bl + 115f: 74 1d je 117e + if(*s == c) + 1161: 38 d3 cmp %dl,%bl + 1163: 89 d1 mov %edx,%ecx + 1165: 75 0d jne 1174 + 1167: eb 17 jmp 1180 + 1169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1170: 38 ca cmp %cl,%dl + 1172: 74 0c je 1180 + for(; *s; s++) + 1174: 83 c0 01 add $0x1,%eax + 1177: 0f b6 10 movzbl (%eax),%edx + 117a: 84 d2 test %dl,%dl + 117c: 75 f2 jne 1170 + return (char*)s; + return 0; + 117e: 31 c0 xor %eax,%eax +} + 1180: 5b pop %ebx + 1181: 5d pop %ebp + 1182: c3 ret + 1183: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1189: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001190 : + +char* +gets(char *buf, int max) +{ + 1190: 55 push %ebp + 1191: 89 e5 mov %esp,%ebp + 1193: 57 push %edi + 1194: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1195: 31 f6 xor %esi,%esi +{ + 1197: 53 push %ebx + 1198: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 119b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 119e: eb 31 jmp 11d1 + cc = read(0, &c, 1); + 11a0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 11a7: 00 + 11a8: 89 7c 24 04 mov %edi,0x4(%esp) + 11ac: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 11b3: e8 02 01 00 00 call 12ba + if(cc < 1) + 11b8: 85 c0 test %eax,%eax + 11ba: 7e 1d jle 11d9 + break; + buf[i++] = c; + 11bc: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 11c0: 89 de mov %ebx,%esi + buf[i++] = c; + 11c2: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 11c5: 3c 0d cmp $0xd,%al + buf[i++] = c; + 11c7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 11cb: 74 0c je 11d9 + 11cd: 3c 0a cmp $0xa,%al + 11cf: 74 08 je 11d9 + for(i=0; i+1 < max; ){ + 11d1: 8d 5e 01 lea 0x1(%esi),%ebx + 11d4: 3b 5d 0c cmp 0xc(%ebp),%ebx + 11d7: 7c c7 jl 11a0 + break; + } + buf[i] = '\0'; + 11d9: 8b 45 08 mov 0x8(%ebp),%eax + 11dc: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 11e0: 83 c4 2c add $0x2c,%esp + 11e3: 5b pop %ebx + 11e4: 5e pop %esi + 11e5: 5f pop %edi + 11e6: 5d pop %ebp + 11e7: c3 ret + 11e8: 90 nop + 11e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000011f0 : + +int +stat(char *n, struct stat *st) +{ + 11f0: 55 push %ebp + 11f1: 89 e5 mov %esp,%ebp + 11f3: 56 push %esi + 11f4: 53 push %ebx + 11f5: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 11f8: 8b 45 08 mov 0x8(%ebp),%eax + 11fb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1202: 00 + 1203: 89 04 24 mov %eax,(%esp) + 1206: e8 d7 00 00 00 call 12e2 + if(fd < 0) + 120b: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 120d: 89 c3 mov %eax,%ebx + if(fd < 0) + 120f: 78 27 js 1238 + return -1; + r = fstat(fd, st); + 1211: 8b 45 0c mov 0xc(%ebp),%eax + 1214: 89 1c 24 mov %ebx,(%esp) + 1217: 89 44 24 04 mov %eax,0x4(%esp) + 121b: e8 da 00 00 00 call 12fa + close(fd); + 1220: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 1223: 89 c6 mov %eax,%esi + close(fd); + 1225: e8 a0 00 00 00 call 12ca + return r; + 122a: 89 f0 mov %esi,%eax +} + 122c: 83 c4 10 add $0x10,%esp + 122f: 5b pop %ebx + 1230: 5e pop %esi + 1231: 5d pop %ebp + 1232: c3 ret + 1233: 90 nop + 1234: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 1238: b8 ff ff ff ff mov $0xffffffff,%eax + 123d: eb ed jmp 122c + 123f: 90 nop + +00001240 : + +int +atoi(const char *s) +{ + 1240: 55 push %ebp + 1241: 89 e5 mov %esp,%ebp + 1243: 8b 4d 08 mov 0x8(%ebp),%ecx + 1246: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 1247: 0f be 11 movsbl (%ecx),%edx + 124a: 8d 42 d0 lea -0x30(%edx),%eax + 124d: 3c 09 cmp $0x9,%al + n = 0; + 124f: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 1254: 77 17 ja 126d + 1256: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 1258: 83 c1 01 add $0x1,%ecx + 125b: 8d 04 80 lea (%eax,%eax,4),%eax + 125e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1262: 0f be 11 movsbl (%ecx),%edx + 1265: 8d 5a d0 lea -0x30(%edx),%ebx + 1268: 80 fb 09 cmp $0x9,%bl + 126b: 76 eb jbe 1258 + return n; +} + 126d: 5b pop %ebx + 126e: 5d pop %ebp + 126f: c3 ret + +00001270 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1270: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1271: 31 d2 xor %edx,%edx +{ + 1273: 89 e5 mov %esp,%ebp + 1275: 56 push %esi + 1276: 8b 45 08 mov 0x8(%ebp),%eax + 1279: 53 push %ebx + 127a: 8b 5d 10 mov 0x10(%ebp),%ebx + 127d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1280: 85 db test %ebx,%ebx + 1282: 7e 12 jle 1296 + 1284: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1288: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 128c: 88 0c 10 mov %cl,(%eax,%edx,1) + 128f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1292: 39 da cmp %ebx,%edx + 1294: 75 f2 jne 1288 + return vdst; +} + 1296: 5b pop %ebx + 1297: 5e pop %esi + 1298: 5d pop %ebp + 1299: c3 ret + +0000129a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 129a: b8 01 00 00 00 mov $0x1,%eax + 129f: cd 40 int $0x40 + 12a1: c3 ret + +000012a2 : +SYSCALL(exit) + 12a2: b8 02 00 00 00 mov $0x2,%eax + 12a7: cd 40 int $0x40 + 12a9: c3 ret + +000012aa : +SYSCALL(wait) + 12aa: b8 03 00 00 00 mov $0x3,%eax + 12af: cd 40 int $0x40 + 12b1: c3 ret + +000012b2 : +SYSCALL(pipe) + 12b2: b8 04 00 00 00 mov $0x4,%eax + 12b7: cd 40 int $0x40 + 12b9: c3 ret + +000012ba : +SYSCALL(read) + 12ba: b8 05 00 00 00 mov $0x5,%eax + 12bf: cd 40 int $0x40 + 12c1: c3 ret + +000012c2 : +SYSCALL(write) + 12c2: b8 10 00 00 00 mov $0x10,%eax + 12c7: cd 40 int $0x40 + 12c9: c3 ret + +000012ca : +SYSCALL(close) + 12ca: b8 15 00 00 00 mov $0x15,%eax + 12cf: cd 40 int $0x40 + 12d1: c3 ret + +000012d2 : +SYSCALL(kill) + 12d2: b8 06 00 00 00 mov $0x6,%eax + 12d7: cd 40 int $0x40 + 12d9: c3 ret + +000012da : +SYSCALL(exec) + 12da: b8 07 00 00 00 mov $0x7,%eax + 12df: cd 40 int $0x40 + 12e1: c3 ret + +000012e2 : +SYSCALL(open) + 12e2: b8 0f 00 00 00 mov $0xf,%eax + 12e7: cd 40 int $0x40 + 12e9: c3 ret + +000012ea : +SYSCALL(mknod) + 12ea: b8 11 00 00 00 mov $0x11,%eax + 12ef: cd 40 int $0x40 + 12f1: c3 ret + +000012f2 : +SYSCALL(unlink) + 12f2: b8 12 00 00 00 mov $0x12,%eax + 12f7: cd 40 int $0x40 + 12f9: c3 ret + +000012fa : +SYSCALL(fstat) + 12fa: b8 08 00 00 00 mov $0x8,%eax + 12ff: cd 40 int $0x40 + 1301: c3 ret + +00001302 : +SYSCALL(link) + 1302: b8 13 00 00 00 mov $0x13,%eax + 1307: cd 40 int $0x40 + 1309: c3 ret + +0000130a : +SYSCALL(mkdir) + 130a: b8 14 00 00 00 mov $0x14,%eax + 130f: cd 40 int $0x40 + 1311: c3 ret + +00001312 : +SYSCALL(chdir) + 1312: b8 09 00 00 00 mov $0x9,%eax + 1317: cd 40 int $0x40 + 1319: c3 ret + +0000131a : +SYSCALL(dup) + 131a: b8 0a 00 00 00 mov $0xa,%eax + 131f: cd 40 int $0x40 + 1321: c3 ret + +00001322 : +SYSCALL(getpid) + 1322: b8 0b 00 00 00 mov $0xb,%eax + 1327: cd 40 int $0x40 + 1329: c3 ret + +0000132a : +SYSCALL(sbrk) + 132a: b8 0c 00 00 00 mov $0xc,%eax + 132f: cd 40 int $0x40 + 1331: c3 ret + +00001332 : +SYSCALL(sleep) + 1332: b8 0d 00 00 00 mov $0xd,%eax + 1337: cd 40 int $0x40 + 1339: c3 ret + +0000133a : +SYSCALL(uptime) + 133a: b8 0e 00 00 00 mov $0xe,%eax + 133f: cd 40 int $0x40 + 1341: c3 ret + +00001342 : +SYSCALL(shm_open) + 1342: b8 16 00 00 00 mov $0x16,%eax + 1347: cd 40 int $0x40 + 1349: c3 ret + +0000134a : +SYSCALL(shm_close) + 134a: b8 17 00 00 00 mov $0x17,%eax + 134f: cd 40 int $0x40 + 1351: c3 ret + 1352: 66 90 xchg %ax,%ax + 1354: 66 90 xchg %ax,%ax + 1356: 66 90 xchg %ax,%ax + 1358: 66 90 xchg %ax,%ax + 135a: 66 90 xchg %ax,%ax + 135c: 66 90 xchg %ax,%ax + 135e: 66 90 xchg %ax,%ax + +00001360 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 1360: 55 push %ebp + 1361: 89 e5 mov %esp,%ebp + 1363: 57 push %edi + 1364: 56 push %esi + 1365: 89 c6 mov %eax,%esi + 1367: 53 push %ebx + 1368: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 136b: 8b 5d 08 mov 0x8(%ebp),%ebx + 136e: 85 db test %ebx,%ebx + 1370: 74 09 je 137b + 1372: 89 d0 mov %edx,%eax + 1374: c1 e8 1f shr $0x1f,%eax + 1377: 84 c0 test %al,%al + 1379: 75 75 jne 13f0 + neg = 1; + x = -xx; + } else { + x = xx; + 137b: 89 d0 mov %edx,%eax + neg = 0; + 137d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1384: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1387: 31 ff xor %edi,%edi + 1389: 89 ce mov %ecx,%esi + 138b: 8d 5d d7 lea -0x29(%ebp),%ebx + 138e: eb 02 jmp 1392 + do{ + buf[i++] = digits[x % base]; + 1390: 89 cf mov %ecx,%edi + 1392: 31 d2 xor %edx,%edx + 1394: f7 f6 div %esi + 1396: 8d 4f 01 lea 0x1(%edi),%ecx + 1399: 0f b6 92 db 17 00 00 movzbl 0x17db(%edx),%edx + }while((x /= base) != 0); + 13a0: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 13a2: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 13a5: 75 e9 jne 1390 + if(neg) + 13a7: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 13aa: 89 c8 mov %ecx,%eax + 13ac: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 13af: 85 d2 test %edx,%edx + 13b1: 74 08 je 13bb + buf[i++] = '-'; + 13b3: 8d 4f 02 lea 0x2(%edi),%ecx + 13b6: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 13bb: 8d 79 ff lea -0x1(%ecx),%edi + 13be: 66 90 xchg %ax,%ax + 13c0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 13c5: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 13c8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 13cf: 00 + 13d0: 89 5c 24 04 mov %ebx,0x4(%esp) + 13d4: 89 34 24 mov %esi,(%esp) + 13d7: 88 45 d7 mov %al,-0x29(%ebp) + 13da: e8 e3 fe ff ff call 12c2 + while(--i >= 0) + 13df: 83 ff ff cmp $0xffffffff,%edi + 13e2: 75 dc jne 13c0 + putc(fd, buf[i]); +} + 13e4: 83 c4 4c add $0x4c,%esp + 13e7: 5b pop %ebx + 13e8: 5e pop %esi + 13e9: 5f pop %edi + 13ea: 5d pop %ebp + 13eb: c3 ret + 13ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 13f0: 89 d0 mov %edx,%eax + 13f2: f7 d8 neg %eax + neg = 1; + 13f4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 13fb: eb 87 jmp 1384 + 13fd: 8d 76 00 lea 0x0(%esi),%esi + +00001400 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 1400: 55 push %ebp + 1401: 89 e5 mov %esp,%ebp + 1403: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 1404: 31 ff xor %edi,%edi +{ + 1406: 56 push %esi + 1407: 53 push %ebx + 1408: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 140b: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 140e: 8d 45 10 lea 0x10(%ebp),%eax +{ + 1411: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 1414: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 1417: 0f b6 13 movzbl (%ebx),%edx + 141a: 83 c3 01 add $0x1,%ebx + 141d: 84 d2 test %dl,%dl + 141f: 75 39 jne 145a + 1421: e9 c2 00 00 00 jmp 14e8 + 1426: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 1428: 83 fa 25 cmp $0x25,%edx + 142b: 0f 84 bf 00 00 00 je 14f0 + write(fd, &c, 1); + 1431: 8d 45 e2 lea -0x1e(%ebp),%eax + 1434: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 143b: 00 + 143c: 89 44 24 04 mov %eax,0x4(%esp) + 1440: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 1443: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 1446: e8 77 fe ff ff call 12c2 + 144b: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 144e: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 1452: 84 d2 test %dl,%dl + 1454: 0f 84 8e 00 00 00 je 14e8 + if(state == 0){ + 145a: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 145c: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 145f: 74 c7 je 1428 + } + } else if(state == '%'){ + 1461: 83 ff 25 cmp $0x25,%edi + 1464: 75 e5 jne 144b + if(c == 'd'){ + 1466: 83 fa 64 cmp $0x64,%edx + 1469: 0f 84 31 01 00 00 je 15a0 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 146f: 25 f7 00 00 00 and $0xf7,%eax + 1474: 83 f8 70 cmp $0x70,%eax + 1477: 0f 84 83 00 00 00 je 1500 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 147d: 83 fa 73 cmp $0x73,%edx + 1480: 0f 84 a2 00 00 00 je 1528 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1486: 83 fa 63 cmp $0x63,%edx + 1489: 0f 84 35 01 00 00 je 15c4 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 148f: 83 fa 25 cmp $0x25,%edx + 1492: 0f 84 e0 00 00 00 je 1578 + write(fd, &c, 1); + 1498: 8d 45 e6 lea -0x1a(%ebp),%eax + 149b: 83 c3 01 add $0x1,%ebx + 149e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14a5: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 14a6: 31 ff xor %edi,%edi + write(fd, &c, 1); + 14a8: 89 44 24 04 mov %eax,0x4(%esp) + 14ac: 89 34 24 mov %esi,(%esp) + 14af: 89 55 d0 mov %edx,-0x30(%ebp) + 14b2: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 14b6: e8 07 fe ff ff call 12c2 + putc(fd, c); + 14bb: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 14be: 8d 45 e7 lea -0x19(%ebp),%eax + 14c1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14c8: 00 + 14c9: 89 44 24 04 mov %eax,0x4(%esp) + 14cd: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 14d0: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 14d3: e8 ea fd ff ff call 12c2 + for(i = 0; fmt[i]; i++){ + 14d8: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 14dc: 84 d2 test %dl,%dl + 14de: 0f 85 76 ff ff ff jne 145a + 14e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 14e8: 83 c4 3c add $0x3c,%esp + 14eb: 5b pop %ebx + 14ec: 5e pop %esi + 14ed: 5f pop %edi + 14ee: 5d pop %ebp + 14ef: c3 ret + state = '%'; + 14f0: bf 25 00 00 00 mov $0x25,%edi + 14f5: e9 51 ff ff ff jmp 144b + 14fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 1500: 8b 45 d4 mov -0x2c(%ebp),%eax + 1503: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 1508: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 150a: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1511: 8b 10 mov (%eax),%edx + 1513: 89 f0 mov %esi,%eax + 1515: e8 46 fe ff ff call 1360 + ap++; + 151a: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 151e: e9 28 ff ff ff jmp 144b + 1523: 90 nop + 1524: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 1528: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 152b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 152f: 8b 38 mov (%eax),%edi + s = "(null)"; + 1531: b8 d4 17 00 00 mov $0x17d4,%eax + 1536: 85 ff test %edi,%edi + 1538: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 153b: 0f b6 07 movzbl (%edi),%eax + 153e: 84 c0 test %al,%al + 1540: 74 2a je 156c + 1542: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1548: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 154b: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 154e: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 1551: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1558: 00 + 1559: 89 44 24 04 mov %eax,0x4(%esp) + 155d: 89 34 24 mov %esi,(%esp) + 1560: e8 5d fd ff ff call 12c2 + while(*s != 0){ + 1565: 0f b6 07 movzbl (%edi),%eax + 1568: 84 c0 test %al,%al + 156a: 75 dc jne 1548 + state = 0; + 156c: 31 ff xor %edi,%edi + 156e: e9 d8 fe ff ff jmp 144b + 1573: 90 nop + 1574: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1578: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 157b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 157d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1584: 00 + 1585: 89 44 24 04 mov %eax,0x4(%esp) + 1589: 89 34 24 mov %esi,(%esp) + 158c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1590: e8 2d fd ff ff call 12c2 + 1595: e9 b1 fe ff ff jmp 144b + 159a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 15a0: 8b 45 d4 mov -0x2c(%ebp),%eax + 15a3: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 15a8: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 15ab: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 15b2: 8b 10 mov (%eax),%edx + 15b4: 89 f0 mov %esi,%eax + 15b6: e8 a5 fd ff ff call 1360 + ap++; + 15bb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15bf: e9 87 fe ff ff jmp 144b + putc(fd, *ap); + 15c4: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 15c7: 31 ff xor %edi,%edi + putc(fd, *ap); + 15c9: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 15cb: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 15d2: 00 + 15d3: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 15d6: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 15d9: 8d 45 e4 lea -0x1c(%ebp),%eax + 15dc: 89 44 24 04 mov %eax,0x4(%esp) + 15e0: e8 dd fc ff ff call 12c2 + ap++; + 15e5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15e9: e9 5d fe ff ff jmp 144b + 15ee: 66 90 xchg %ax,%ax + +000015f0 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 15f0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15f1: a1 98 1a 00 00 mov 0x1a98,%eax +{ + 15f6: 89 e5 mov %esp,%ebp + 15f8: 57 push %edi + 15f9: 56 push %esi + 15fa: 53 push %ebx + 15fb: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15fe: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 1600: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1603: 39 d0 cmp %edx,%eax + 1605: 72 11 jb 1618 + 1607: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1608: 39 c8 cmp %ecx,%eax + 160a: 72 04 jb 1610 + 160c: 39 ca cmp %ecx,%edx + 160e: 72 10 jb 1620 + 1610: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1612: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1614: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1616: 73 f0 jae 1608 + 1618: 39 ca cmp %ecx,%edx + 161a: 72 04 jb 1620 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 161c: 39 c8 cmp %ecx,%eax + 161e: 72 f0 jb 1610 + break; + if(bp + bp->s.size == p->s.ptr){ + 1620: 8b 73 fc mov -0x4(%ebx),%esi + 1623: 8d 3c f2 lea (%edx,%esi,8),%edi + 1626: 39 cf cmp %ecx,%edi + 1628: 74 1e je 1648 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 162a: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 162d: 8b 48 04 mov 0x4(%eax),%ecx + 1630: 8d 34 c8 lea (%eax,%ecx,8),%esi + 1633: 39 f2 cmp %esi,%edx + 1635: 74 28 je 165f + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 1637: 89 10 mov %edx,(%eax) + freep = p; + 1639: a3 98 1a 00 00 mov %eax,0x1a98 +} + 163e: 5b pop %ebx + 163f: 5e pop %esi + 1640: 5f pop %edi + 1641: 5d pop %ebp + 1642: c3 ret + 1643: 90 nop + 1644: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 1648: 03 71 04 add 0x4(%ecx),%esi + 164b: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 164e: 8b 08 mov (%eax),%ecx + 1650: 8b 09 mov (%ecx),%ecx + 1652: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 1655: 8b 48 04 mov 0x4(%eax),%ecx + 1658: 8d 34 c8 lea (%eax,%ecx,8),%esi + 165b: 39 f2 cmp %esi,%edx + 165d: 75 d8 jne 1637 + p->s.size += bp->s.size; + 165f: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 1662: a3 98 1a 00 00 mov %eax,0x1a98 + p->s.size += bp->s.size; + 1667: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 166a: 8b 53 f8 mov -0x8(%ebx),%edx + 166d: 89 10 mov %edx,(%eax) +} + 166f: 5b pop %ebx + 1670: 5e pop %esi + 1671: 5f pop %edi + 1672: 5d pop %ebp + 1673: c3 ret + 1674: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 167a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001680 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1680: 55 push %ebp + 1681: 89 e5 mov %esp,%ebp + 1683: 57 push %edi + 1684: 56 push %esi + 1685: 53 push %ebx + 1686: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1689: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 168c: 8b 1d 98 1a 00 00 mov 0x1a98,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1692: 8d 48 07 lea 0x7(%eax),%ecx + 1695: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1698: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 169a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 169d: 0f 84 9b 00 00 00 je 173e + 16a3: 8b 13 mov (%ebx),%edx + 16a5: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 16a8: 39 fe cmp %edi,%esi + 16aa: 76 64 jbe 1710 + 16ac: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 16b3: bb 00 80 00 00 mov $0x8000,%ebx + 16b8: 89 45 e4 mov %eax,-0x1c(%ebp) + 16bb: eb 0e jmp 16cb + 16bd: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 16c0: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 16c2: 8b 78 04 mov 0x4(%eax),%edi + 16c5: 39 fe cmp %edi,%esi + 16c7: 76 4f jbe 1718 + 16c9: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 16cb: 3b 15 98 1a 00 00 cmp 0x1a98,%edx + 16d1: 75 ed jne 16c0 + if(nu < 4096) + 16d3: 8b 45 e4 mov -0x1c(%ebp),%eax + 16d6: 81 fe 00 10 00 00 cmp $0x1000,%esi + 16dc: bf 00 10 00 00 mov $0x1000,%edi + 16e1: 0f 43 fe cmovae %esi,%edi + 16e4: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 16e7: 89 04 24 mov %eax,(%esp) + 16ea: e8 3b fc ff ff call 132a + if(p == (char*)-1) + 16ef: 83 f8 ff cmp $0xffffffff,%eax + 16f2: 74 18 je 170c + hp->s.size = nu; + 16f4: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 16f7: 83 c0 08 add $0x8,%eax + 16fa: 89 04 24 mov %eax,(%esp) + 16fd: e8 ee fe ff ff call 15f0 + return freep; + 1702: 8b 15 98 1a 00 00 mov 0x1a98,%edx + if((p = morecore(nunits)) == 0) + 1708: 85 d2 test %edx,%edx + 170a: 75 b4 jne 16c0 + return 0; + 170c: 31 c0 xor %eax,%eax + 170e: eb 20 jmp 1730 + if(p->s.size >= nunits){ + 1710: 89 d0 mov %edx,%eax + 1712: 89 da mov %ebx,%edx + 1714: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 1718: 39 fe cmp %edi,%esi + 171a: 74 1c je 1738 + p->s.size -= nunits; + 171c: 29 f7 sub %esi,%edi + 171e: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 1721: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 1724: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 1727: 89 15 98 1a 00 00 mov %edx,0x1a98 + return (void*)(p + 1); + 172d: 83 c0 08 add $0x8,%eax + } +} + 1730: 83 c4 1c add $0x1c,%esp + 1733: 5b pop %ebx + 1734: 5e pop %esi + 1735: 5f pop %edi + 1736: 5d pop %ebp + 1737: c3 ret + prevp->s.ptr = p->s.ptr; + 1738: 8b 08 mov (%eax),%ecx + 173a: 89 0a mov %ecx,(%edx) + 173c: eb e9 jmp 1727 + base.s.ptr = freep = prevp = &base; + 173e: c7 05 98 1a 00 00 9c movl $0x1a9c,0x1a98 + 1745: 1a 00 00 + base.s.size = 0; + 1748: ba 9c 1a 00 00 mov $0x1a9c,%edx + base.s.ptr = freep = prevp = &base; + 174d: c7 05 9c 1a 00 00 9c movl $0x1a9c,0x1a9c + 1754: 1a 00 00 + base.s.size = 0; + 1757: c7 05 a0 1a 00 00 00 movl $0x0,0x1aa0 + 175e: 00 00 00 + 1761: e9 46 ff ff ff jmp 16ac + 1766: 66 90 xchg %ax,%ax + 1768: 66 90 xchg %ax,%ax + 176a: 66 90 xchg %ax,%ax + 176c: 66 90 xchg %ax,%ax + 176e: 66 90 xchg %ax,%ax + +00001770 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1770: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1771: b9 01 00 00 00 mov $0x1,%ecx + 1776: 89 e5 mov %esp,%ebp + 1778: 8b 55 08 mov 0x8(%ebp),%edx + 177b: 90 nop + 177c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1780: 89 c8 mov %ecx,%eax + 1782: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1785: 85 c0 test %eax,%eax + 1787: 75 f7 jne 1780 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1789: 0f ae f0 mfence +} + 178c: 5d pop %ebp + 178d: c3 ret + 178e: 66 90 xchg %ax,%ax + +00001790 : + +void urelease (struct uspinlock *lk) { + 1790: 55 push %ebp + 1791: 89 e5 mov %esp,%ebp + 1793: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1796: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1799: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 179f: 5d pop %ebp + 17a0: c3 ret diff --git a/mkdir.d b/mkdir.d new file mode 100644 index 00000000..0c77808b --- /dev/null +++ b/mkdir.d @@ -0,0 +1 @@ +mkdir.o: mkdir.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/mkdir.o b/mkdir.o new file mode 100644 index 00000000..ab904d97 Binary files /dev/null and b/mkdir.o differ diff --git a/mkdir.sym b/mkdir.sym new file mode 100644 index 00000000..56d86396 --- /dev/null +++ b/mkdir.sym @@ -0,0 +1,62 @@ +00001000 .text +000017a1 .rodata +000017ec .eh_frame +00001a98 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 mkdir.c +00000000 ulib.c +00000000 printf.c +00001360 printint +000017db digits.1359 +00000000 umalloc.c +00001a98 freep +00001a9c base +00000000 uspinlock.c +00001080 strcpy +00001400 printf +00001270 memmove +000012ea mknod +00001342 shm_open +00001190 gets +00001322 getpid +00001680 malloc +00001332 sleep +000012b2 pipe +000012c2 write +000012fa fstat +000012d2 kill +00001312 chdir +000012da exec +000012aa wait +000012ba read +000012f2 unlink +00001770 uacquire +0000129a fork +0000132a sbrk +0000134a shm_close +0000133a uptime +00001a98 __bss_start +00001130 memset +00001000 main +000010b0 strcmp +0000131a dup +000011f0 stat +00001a98 _edata +00001aa4 _end +00001302 link +000012a2 exit +00001240 atoi +00001100 strlen +000012e2 open +00001150 strchr +0000130a mkdir +000012ca close +00001790 urelease +000015f0 free diff --git a/mkfs b/mkfs new file mode 100755 index 00000000..d5343935 Binary files /dev/null and b/mkfs differ diff --git a/mp.d b/mp.d new file mode 100644 index 00000000..0714441d --- /dev/null +++ b/mp.d @@ -0,0 +1,2 @@ +mp.o: mp.c /usr/include/stdc-predef.h types.h defs.h param.h memlayout.h \ + mp.h x86.h mmu.h proc.h diff --git a/mp.o b/mp.o new file mode 100644 index 00000000..92ae55b4 Binary files /dev/null and b/mp.o differ diff --git a/null.asm b/null.asm new file mode 100644 index 00000000..00713dea --- /dev/null +++ b/null.asm @@ -0,0 +1,1204 @@ + +_null: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: +#include "types.h" +#include "stat.h" +#include "user.h" + +int main(int argc, char *argv[]) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 83 e4 f0 and $0xfffffff0,%esp + 1006: 83 ec 10 sub $0x10,%esp +int *i = 0; + +(*i)++; + 1009: a1 00 00 00 00 mov 0x0,%eax + 100e: 83 c0 01 add $0x1,%eax + 1011: a3 00 00 00 00 mov %eax,0x0 + +printf(1,"Hi %d",*i); + 1016: 89 44 24 08 mov %eax,0x8(%esp) + 101a: c7 44 24 04 61 17 00 movl $0x1761,0x4(%esp) + 1021: 00 + 1022: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1029: e8 92 03 00 00 call 13c0 + +return 1; +} + 102e: b8 01 00 00 00 mov $0x1,%eax + 1033: c9 leave + 1034: c3 ret + 1035: 66 90 xchg %ax,%ax + 1037: 66 90 xchg %ax,%ax + 1039: 66 90 xchg %ax,%ax + 103b: 66 90 xchg %ax,%ax + 103d: 66 90 xchg %ax,%ax + 103f: 90 nop + +00001040 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1040: 55 push %ebp + 1041: 89 e5 mov %esp,%ebp + 1043: 8b 45 08 mov 0x8(%ebp),%eax + 1046: 8b 4d 0c mov 0xc(%ebp),%ecx + 1049: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 104a: 89 c2 mov %eax,%edx + 104c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1050: 83 c1 01 add $0x1,%ecx + 1053: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1057: 83 c2 01 add $0x1,%edx + 105a: 84 db test %bl,%bl + 105c: 88 5a ff mov %bl,-0x1(%edx) + 105f: 75 ef jne 1050 + ; + return os; +} + 1061: 5b pop %ebx + 1062: 5d pop %ebp + 1063: c3 ret + 1064: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 106a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001070 : + +int +strcmp(const char *p, const char *q) +{ + 1070: 55 push %ebp + 1071: 89 e5 mov %esp,%ebp + 1073: 8b 55 08 mov 0x8(%ebp),%edx + 1076: 53 push %ebx + 1077: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 107a: 0f b6 02 movzbl (%edx),%eax + 107d: 84 c0 test %al,%al + 107f: 74 2d je 10ae + 1081: 0f b6 19 movzbl (%ecx),%ebx + 1084: 38 d8 cmp %bl,%al + 1086: 74 0e je 1096 + 1088: eb 2b jmp 10b5 + 108a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1090: 38 c8 cmp %cl,%al + 1092: 75 15 jne 10a9 + p++, q++; + 1094: 89 d9 mov %ebx,%ecx + 1096: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 1099: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 109c: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 109f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 10a3: 84 c0 test %al,%al + 10a5: 75 e9 jne 1090 + 10a7: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 10a9: 29 c8 sub %ecx,%eax +} + 10ab: 5b pop %ebx + 10ac: 5d pop %ebp + 10ad: c3 ret + 10ae: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 10b1: 31 c0 xor %eax,%eax + 10b3: eb f4 jmp 10a9 + 10b5: 0f b6 cb movzbl %bl,%ecx + 10b8: eb ef jmp 10a9 + 10ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +000010c0 : + +uint +strlen(char *s) +{ + 10c0: 55 push %ebp + 10c1: 89 e5 mov %esp,%ebp + 10c3: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 10c6: 80 39 00 cmpb $0x0,(%ecx) + 10c9: 74 12 je 10dd + 10cb: 31 d2 xor %edx,%edx + 10cd: 8d 76 00 lea 0x0(%esi),%esi + 10d0: 83 c2 01 add $0x1,%edx + 10d3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 10d7: 89 d0 mov %edx,%eax + 10d9: 75 f5 jne 10d0 + ; + return n; +} + 10db: 5d pop %ebp + 10dc: c3 ret + for(n = 0; s[n]; n++) + 10dd: 31 c0 xor %eax,%eax +} + 10df: 5d pop %ebp + 10e0: c3 ret + 10e1: eb 0d jmp 10f0 + 10e3: 90 nop + 10e4: 90 nop + 10e5: 90 nop + 10e6: 90 nop + 10e7: 90 nop + 10e8: 90 nop + 10e9: 90 nop + 10ea: 90 nop + 10eb: 90 nop + 10ec: 90 nop + 10ed: 90 nop + 10ee: 90 nop + 10ef: 90 nop + +000010f0 : + +void* +memset(void *dst, int c, uint n) +{ + 10f0: 55 push %ebp + 10f1: 89 e5 mov %esp,%ebp + 10f3: 8b 55 08 mov 0x8(%ebp),%edx + 10f6: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 10f7: 8b 4d 10 mov 0x10(%ebp),%ecx + 10fa: 8b 45 0c mov 0xc(%ebp),%eax + 10fd: 89 d7 mov %edx,%edi + 10ff: fc cld + 1100: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1102: 89 d0 mov %edx,%eax + 1104: 5f pop %edi + 1105: 5d pop %ebp + 1106: c3 ret + 1107: 89 f6 mov %esi,%esi + 1109: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001110 : + +char* +strchr(const char *s, char c) +{ + 1110: 55 push %ebp + 1111: 89 e5 mov %esp,%ebp + 1113: 8b 45 08 mov 0x8(%ebp),%eax + 1116: 53 push %ebx + 1117: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 111a: 0f b6 18 movzbl (%eax),%ebx + 111d: 84 db test %bl,%bl + 111f: 74 1d je 113e + if(*s == c) + 1121: 38 d3 cmp %dl,%bl + 1123: 89 d1 mov %edx,%ecx + 1125: 75 0d jne 1134 + 1127: eb 17 jmp 1140 + 1129: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1130: 38 ca cmp %cl,%dl + 1132: 74 0c je 1140 + for(; *s; s++) + 1134: 83 c0 01 add $0x1,%eax + 1137: 0f b6 10 movzbl (%eax),%edx + 113a: 84 d2 test %dl,%dl + 113c: 75 f2 jne 1130 + return (char*)s; + return 0; + 113e: 31 c0 xor %eax,%eax +} + 1140: 5b pop %ebx + 1141: 5d pop %ebp + 1142: c3 ret + 1143: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001150 : + +char* +gets(char *buf, int max) +{ + 1150: 55 push %ebp + 1151: 89 e5 mov %esp,%ebp + 1153: 57 push %edi + 1154: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1155: 31 f6 xor %esi,%esi +{ + 1157: 53 push %ebx + 1158: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 115b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 115e: eb 31 jmp 1191 + cc = read(0, &c, 1); + 1160: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1167: 00 + 1168: 89 7c 24 04 mov %edi,0x4(%esp) + 116c: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1173: e8 02 01 00 00 call 127a + if(cc < 1) + 1178: 85 c0 test %eax,%eax + 117a: 7e 1d jle 1199 + break; + buf[i++] = c; + 117c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 1180: 89 de mov %ebx,%esi + buf[i++] = c; + 1182: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 1185: 3c 0d cmp $0xd,%al + buf[i++] = c; + 1187: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 118b: 74 0c je 1199 + 118d: 3c 0a cmp $0xa,%al + 118f: 74 08 je 1199 + for(i=0; i+1 < max; ){ + 1191: 8d 5e 01 lea 0x1(%esi),%ebx + 1194: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1197: 7c c7 jl 1160 + break; + } + buf[i] = '\0'; + 1199: 8b 45 08 mov 0x8(%ebp),%eax + 119c: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 11a0: 83 c4 2c add $0x2c,%esp + 11a3: 5b pop %ebx + 11a4: 5e pop %esi + 11a5: 5f pop %edi + 11a6: 5d pop %ebp + 11a7: c3 ret + 11a8: 90 nop + 11a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000011b0 : + +int +stat(char *n, struct stat *st) +{ + 11b0: 55 push %ebp + 11b1: 89 e5 mov %esp,%ebp + 11b3: 56 push %esi + 11b4: 53 push %ebx + 11b5: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 11b8: 8b 45 08 mov 0x8(%ebp),%eax + 11bb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 11c2: 00 + 11c3: 89 04 24 mov %eax,(%esp) + 11c6: e8 d7 00 00 00 call 12a2 + if(fd < 0) + 11cb: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 11cd: 89 c3 mov %eax,%ebx + if(fd < 0) + 11cf: 78 27 js 11f8 + return -1; + r = fstat(fd, st); + 11d1: 8b 45 0c mov 0xc(%ebp),%eax + 11d4: 89 1c 24 mov %ebx,(%esp) + 11d7: 89 44 24 04 mov %eax,0x4(%esp) + 11db: e8 da 00 00 00 call 12ba + close(fd); + 11e0: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 11e3: 89 c6 mov %eax,%esi + close(fd); + 11e5: e8 a0 00 00 00 call 128a + return r; + 11ea: 89 f0 mov %esi,%eax +} + 11ec: 83 c4 10 add $0x10,%esp + 11ef: 5b pop %ebx + 11f0: 5e pop %esi + 11f1: 5d pop %ebp + 11f2: c3 ret + 11f3: 90 nop + 11f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 11f8: b8 ff ff ff ff mov $0xffffffff,%eax + 11fd: eb ed jmp 11ec + 11ff: 90 nop + +00001200 : + +int +atoi(const char *s) +{ + 1200: 55 push %ebp + 1201: 89 e5 mov %esp,%ebp + 1203: 8b 4d 08 mov 0x8(%ebp),%ecx + 1206: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 1207: 0f be 11 movsbl (%ecx),%edx + 120a: 8d 42 d0 lea -0x30(%edx),%eax + 120d: 3c 09 cmp $0x9,%al + n = 0; + 120f: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 1214: 77 17 ja 122d + 1216: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 1218: 83 c1 01 add $0x1,%ecx + 121b: 8d 04 80 lea (%eax,%eax,4),%eax + 121e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1222: 0f be 11 movsbl (%ecx),%edx + 1225: 8d 5a d0 lea -0x30(%edx),%ebx + 1228: 80 fb 09 cmp $0x9,%bl + 122b: 76 eb jbe 1218 + return n; +} + 122d: 5b pop %ebx + 122e: 5d pop %ebp + 122f: c3 ret + +00001230 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1230: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1231: 31 d2 xor %edx,%edx +{ + 1233: 89 e5 mov %esp,%ebp + 1235: 56 push %esi + 1236: 8b 45 08 mov 0x8(%ebp),%eax + 1239: 53 push %ebx + 123a: 8b 5d 10 mov 0x10(%ebp),%ebx + 123d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1240: 85 db test %ebx,%ebx + 1242: 7e 12 jle 1256 + 1244: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1248: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 124c: 88 0c 10 mov %cl,(%eax,%edx,1) + 124f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1252: 39 da cmp %ebx,%edx + 1254: 75 f2 jne 1248 + return vdst; +} + 1256: 5b pop %ebx + 1257: 5e pop %esi + 1258: 5d pop %ebp + 1259: c3 ret + +0000125a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 125a: b8 01 00 00 00 mov $0x1,%eax + 125f: cd 40 int $0x40 + 1261: c3 ret + +00001262 : +SYSCALL(exit) + 1262: b8 02 00 00 00 mov $0x2,%eax + 1267: cd 40 int $0x40 + 1269: c3 ret + +0000126a : +SYSCALL(wait) + 126a: b8 03 00 00 00 mov $0x3,%eax + 126f: cd 40 int $0x40 + 1271: c3 ret + +00001272 : +SYSCALL(pipe) + 1272: b8 04 00 00 00 mov $0x4,%eax + 1277: cd 40 int $0x40 + 1279: c3 ret + +0000127a : +SYSCALL(read) + 127a: b8 05 00 00 00 mov $0x5,%eax + 127f: cd 40 int $0x40 + 1281: c3 ret + +00001282 : +SYSCALL(write) + 1282: b8 10 00 00 00 mov $0x10,%eax + 1287: cd 40 int $0x40 + 1289: c3 ret + +0000128a : +SYSCALL(close) + 128a: b8 15 00 00 00 mov $0x15,%eax + 128f: cd 40 int $0x40 + 1291: c3 ret + +00001292 : +SYSCALL(kill) + 1292: b8 06 00 00 00 mov $0x6,%eax + 1297: cd 40 int $0x40 + 1299: c3 ret + +0000129a : +SYSCALL(exec) + 129a: b8 07 00 00 00 mov $0x7,%eax + 129f: cd 40 int $0x40 + 12a1: c3 ret + +000012a2 : +SYSCALL(open) + 12a2: b8 0f 00 00 00 mov $0xf,%eax + 12a7: cd 40 int $0x40 + 12a9: c3 ret + +000012aa : +SYSCALL(mknod) + 12aa: b8 11 00 00 00 mov $0x11,%eax + 12af: cd 40 int $0x40 + 12b1: c3 ret + +000012b2 : +SYSCALL(unlink) + 12b2: b8 12 00 00 00 mov $0x12,%eax + 12b7: cd 40 int $0x40 + 12b9: c3 ret + +000012ba : +SYSCALL(fstat) + 12ba: b8 08 00 00 00 mov $0x8,%eax + 12bf: cd 40 int $0x40 + 12c1: c3 ret + +000012c2 : +SYSCALL(link) + 12c2: b8 13 00 00 00 mov $0x13,%eax + 12c7: cd 40 int $0x40 + 12c9: c3 ret + +000012ca : +SYSCALL(mkdir) + 12ca: b8 14 00 00 00 mov $0x14,%eax + 12cf: cd 40 int $0x40 + 12d1: c3 ret + +000012d2 : +SYSCALL(chdir) + 12d2: b8 09 00 00 00 mov $0x9,%eax + 12d7: cd 40 int $0x40 + 12d9: c3 ret + +000012da : +SYSCALL(dup) + 12da: b8 0a 00 00 00 mov $0xa,%eax + 12df: cd 40 int $0x40 + 12e1: c3 ret + +000012e2 : +SYSCALL(getpid) + 12e2: b8 0b 00 00 00 mov $0xb,%eax + 12e7: cd 40 int $0x40 + 12e9: c3 ret + +000012ea : +SYSCALL(sbrk) + 12ea: b8 0c 00 00 00 mov $0xc,%eax + 12ef: cd 40 int $0x40 + 12f1: c3 ret + +000012f2 : +SYSCALL(sleep) + 12f2: b8 0d 00 00 00 mov $0xd,%eax + 12f7: cd 40 int $0x40 + 12f9: c3 ret + +000012fa : +SYSCALL(uptime) + 12fa: b8 0e 00 00 00 mov $0xe,%eax + 12ff: cd 40 int $0x40 + 1301: c3 ret + +00001302 : +SYSCALL(shm_open) + 1302: b8 16 00 00 00 mov $0x16,%eax + 1307: cd 40 int $0x40 + 1309: c3 ret + +0000130a : +SYSCALL(shm_close) + 130a: b8 17 00 00 00 mov $0x17,%eax + 130f: cd 40 int $0x40 + 1311: c3 ret + 1312: 66 90 xchg %ax,%ax + 1314: 66 90 xchg %ax,%ax + 1316: 66 90 xchg %ax,%ax + 1318: 66 90 xchg %ax,%ax + 131a: 66 90 xchg %ax,%ax + 131c: 66 90 xchg %ax,%ax + 131e: 66 90 xchg %ax,%ax + +00001320 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 1320: 55 push %ebp + 1321: 89 e5 mov %esp,%ebp + 1323: 57 push %edi + 1324: 56 push %esi + 1325: 89 c6 mov %eax,%esi + 1327: 53 push %ebx + 1328: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 132b: 8b 5d 08 mov 0x8(%ebp),%ebx + 132e: 85 db test %ebx,%ebx + 1330: 74 09 je 133b + 1332: 89 d0 mov %edx,%eax + 1334: c1 e8 1f shr $0x1f,%eax + 1337: 84 c0 test %al,%al + 1339: 75 75 jne 13b0 + neg = 1; + x = -xx; + } else { + x = xx; + 133b: 89 d0 mov %edx,%eax + neg = 0; + 133d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1344: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1347: 31 ff xor %edi,%edi + 1349: 89 ce mov %ecx,%esi + 134b: 8d 5d d7 lea -0x29(%ebp),%ebx + 134e: eb 02 jmp 1352 + do{ + buf[i++] = digits[x % base]; + 1350: 89 cf mov %ecx,%edi + 1352: 31 d2 xor %edx,%edx + 1354: f7 f6 div %esi + 1356: 8d 4f 01 lea 0x1(%edi),%ecx + 1359: 0f b6 92 6e 17 00 00 movzbl 0x176e(%edx),%edx + }while((x /= base) != 0); + 1360: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 1362: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 1365: 75 e9 jne 1350 + if(neg) + 1367: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 136a: 89 c8 mov %ecx,%eax + 136c: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 136f: 85 d2 test %edx,%edx + 1371: 74 08 je 137b + buf[i++] = '-'; + 1373: 8d 4f 02 lea 0x2(%edi),%ecx + 1376: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 137b: 8d 79 ff lea -0x1(%ecx),%edi + 137e: 66 90 xchg %ax,%ax + 1380: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 1385: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 1388: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 138f: 00 + 1390: 89 5c 24 04 mov %ebx,0x4(%esp) + 1394: 89 34 24 mov %esi,(%esp) + 1397: 88 45 d7 mov %al,-0x29(%ebp) + 139a: e8 e3 fe ff ff call 1282 + while(--i >= 0) + 139f: 83 ff ff cmp $0xffffffff,%edi + 13a2: 75 dc jne 1380 + putc(fd, buf[i]); +} + 13a4: 83 c4 4c add $0x4c,%esp + 13a7: 5b pop %ebx + 13a8: 5e pop %esi + 13a9: 5f pop %edi + 13aa: 5d pop %ebp + 13ab: c3 ret + 13ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 13b0: 89 d0 mov %edx,%eax + 13b2: f7 d8 neg %eax + neg = 1; + 13b4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 13bb: eb 87 jmp 1344 + 13bd: 8d 76 00 lea 0x0(%esi),%esi + +000013c0 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 13c0: 55 push %ebp + 13c1: 89 e5 mov %esp,%ebp + 13c3: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 13c4: 31 ff xor %edi,%edi +{ + 13c6: 56 push %esi + 13c7: 53 push %ebx + 13c8: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 13cb: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 13ce: 8d 45 10 lea 0x10(%ebp),%eax +{ + 13d1: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 13d4: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 13d7: 0f b6 13 movzbl (%ebx),%edx + 13da: 83 c3 01 add $0x1,%ebx + 13dd: 84 d2 test %dl,%dl + 13df: 75 39 jne 141a + 13e1: e9 c2 00 00 00 jmp 14a8 + 13e6: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 13e8: 83 fa 25 cmp $0x25,%edx + 13eb: 0f 84 bf 00 00 00 je 14b0 + write(fd, &c, 1); + 13f1: 8d 45 e2 lea -0x1e(%ebp),%eax + 13f4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 13fb: 00 + 13fc: 89 44 24 04 mov %eax,0x4(%esp) + 1400: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 1403: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 1406: e8 77 fe ff ff call 1282 + 140b: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 140e: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 1412: 84 d2 test %dl,%dl + 1414: 0f 84 8e 00 00 00 je 14a8 + if(state == 0){ + 141a: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 141c: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 141f: 74 c7 je 13e8 + } + } else if(state == '%'){ + 1421: 83 ff 25 cmp $0x25,%edi + 1424: 75 e5 jne 140b + if(c == 'd'){ + 1426: 83 fa 64 cmp $0x64,%edx + 1429: 0f 84 31 01 00 00 je 1560 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 142f: 25 f7 00 00 00 and $0xf7,%eax + 1434: 83 f8 70 cmp $0x70,%eax + 1437: 0f 84 83 00 00 00 je 14c0 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 143d: 83 fa 73 cmp $0x73,%edx + 1440: 0f 84 a2 00 00 00 je 14e8 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1446: 83 fa 63 cmp $0x63,%edx + 1449: 0f 84 35 01 00 00 je 1584 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 144f: 83 fa 25 cmp $0x25,%edx + 1452: 0f 84 e0 00 00 00 je 1538 + write(fd, &c, 1); + 1458: 8d 45 e6 lea -0x1a(%ebp),%eax + 145b: 83 c3 01 add $0x1,%ebx + 145e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1465: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 1466: 31 ff xor %edi,%edi + write(fd, &c, 1); + 1468: 89 44 24 04 mov %eax,0x4(%esp) + 146c: 89 34 24 mov %esi,(%esp) + 146f: 89 55 d0 mov %edx,-0x30(%ebp) + 1472: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 1476: e8 07 fe ff ff call 1282 + putc(fd, c); + 147b: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 147e: 8d 45 e7 lea -0x19(%ebp),%eax + 1481: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1488: 00 + 1489: 89 44 24 04 mov %eax,0x4(%esp) + 148d: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 1490: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 1493: e8 ea fd ff ff call 1282 + for(i = 0; fmt[i]; i++){ + 1498: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 149c: 84 d2 test %dl,%dl + 149e: 0f 85 76 ff ff ff jne 141a + 14a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 14a8: 83 c4 3c add $0x3c,%esp + 14ab: 5b pop %ebx + 14ac: 5e pop %esi + 14ad: 5f pop %edi + 14ae: 5d pop %ebp + 14af: c3 ret + state = '%'; + 14b0: bf 25 00 00 00 mov $0x25,%edi + 14b5: e9 51 ff ff ff jmp 140b + 14ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 14c0: 8b 45 d4 mov -0x2c(%ebp),%eax + 14c3: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 14c8: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 14ca: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 14d1: 8b 10 mov (%eax),%edx + 14d3: 89 f0 mov %esi,%eax + 14d5: e8 46 fe ff ff call 1320 + ap++; + 14da: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 14de: e9 28 ff ff ff jmp 140b + 14e3: 90 nop + 14e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 14e8: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 14eb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 14ef: 8b 38 mov (%eax),%edi + s = "(null)"; + 14f1: b8 67 17 00 00 mov $0x1767,%eax + 14f6: 85 ff test %edi,%edi + 14f8: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 14fb: 0f b6 07 movzbl (%edi),%eax + 14fe: 84 c0 test %al,%al + 1500: 74 2a je 152c + 1502: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1508: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 150b: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 150e: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 1511: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1518: 00 + 1519: 89 44 24 04 mov %eax,0x4(%esp) + 151d: 89 34 24 mov %esi,(%esp) + 1520: e8 5d fd ff ff call 1282 + while(*s != 0){ + 1525: 0f b6 07 movzbl (%edi),%eax + 1528: 84 c0 test %al,%al + 152a: 75 dc jne 1508 + state = 0; + 152c: 31 ff xor %edi,%edi + 152e: e9 d8 fe ff ff jmp 140b + 1533: 90 nop + 1534: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1538: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 153b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 153d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1544: 00 + 1545: 89 44 24 04 mov %eax,0x4(%esp) + 1549: 89 34 24 mov %esi,(%esp) + 154c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1550: e8 2d fd ff ff call 1282 + 1555: e9 b1 fe ff ff jmp 140b + 155a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 1560: 8b 45 d4 mov -0x2c(%ebp),%eax + 1563: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 1568: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 156b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1572: 8b 10 mov (%eax),%edx + 1574: 89 f0 mov %esi,%eax + 1576: e8 a5 fd ff ff call 1320 + ap++; + 157b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 157f: e9 87 fe ff ff jmp 140b + putc(fd, *ap); + 1584: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 1587: 31 ff xor %edi,%edi + putc(fd, *ap); + 1589: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 158b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1592: 00 + 1593: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 1596: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 1599: 8d 45 e4 lea -0x1c(%ebp),%eax + 159c: 89 44 24 04 mov %eax,0x4(%esp) + 15a0: e8 dd fc ff ff call 1282 + ap++; + 15a5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15a9: e9 5d fe ff ff jmp 140b + 15ae: 66 90 xchg %ax,%ax + +000015b0 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 15b0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15b1: a1 28 1a 00 00 mov 0x1a28,%eax +{ + 15b6: 89 e5 mov %esp,%ebp + 15b8: 57 push %edi + 15b9: 56 push %esi + 15ba: 53 push %ebx + 15bb: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15be: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 15c0: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15c3: 39 d0 cmp %edx,%eax + 15c5: 72 11 jb 15d8 + 15c7: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15c8: 39 c8 cmp %ecx,%eax + 15ca: 72 04 jb 15d0 + 15cc: 39 ca cmp %ecx,%edx + 15ce: 72 10 jb 15e0 + 15d0: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15d2: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15d4: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15d6: 73 f0 jae 15c8 + 15d8: 39 ca cmp %ecx,%edx + 15da: 72 04 jb 15e0 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15dc: 39 c8 cmp %ecx,%eax + 15de: 72 f0 jb 15d0 + break; + if(bp + bp->s.size == p->s.ptr){ + 15e0: 8b 73 fc mov -0x4(%ebx),%esi + 15e3: 8d 3c f2 lea (%edx,%esi,8),%edi + 15e6: 39 cf cmp %ecx,%edi + 15e8: 74 1e je 1608 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 15ea: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 15ed: 8b 48 04 mov 0x4(%eax),%ecx + 15f0: 8d 34 c8 lea (%eax,%ecx,8),%esi + 15f3: 39 f2 cmp %esi,%edx + 15f5: 74 28 je 161f + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 15f7: 89 10 mov %edx,(%eax) + freep = p; + 15f9: a3 28 1a 00 00 mov %eax,0x1a28 +} + 15fe: 5b pop %ebx + 15ff: 5e pop %esi + 1600: 5f pop %edi + 1601: 5d pop %ebp + 1602: c3 ret + 1603: 90 nop + 1604: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 1608: 03 71 04 add 0x4(%ecx),%esi + 160b: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 160e: 8b 08 mov (%eax),%ecx + 1610: 8b 09 mov (%ecx),%ecx + 1612: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 1615: 8b 48 04 mov 0x4(%eax),%ecx + 1618: 8d 34 c8 lea (%eax,%ecx,8),%esi + 161b: 39 f2 cmp %esi,%edx + 161d: 75 d8 jne 15f7 + p->s.size += bp->s.size; + 161f: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 1622: a3 28 1a 00 00 mov %eax,0x1a28 + p->s.size += bp->s.size; + 1627: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 162a: 8b 53 f8 mov -0x8(%ebx),%edx + 162d: 89 10 mov %edx,(%eax) +} + 162f: 5b pop %ebx + 1630: 5e pop %esi + 1631: 5f pop %edi + 1632: 5d pop %ebp + 1633: c3 ret + 1634: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 163a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001640 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1640: 55 push %ebp + 1641: 89 e5 mov %esp,%ebp + 1643: 57 push %edi + 1644: 56 push %esi + 1645: 53 push %ebx + 1646: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1649: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 164c: 8b 1d 28 1a 00 00 mov 0x1a28,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1652: 8d 48 07 lea 0x7(%eax),%ecx + 1655: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1658: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 165a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 165d: 0f 84 9b 00 00 00 je 16fe + 1663: 8b 13 mov (%ebx),%edx + 1665: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 1668: 39 fe cmp %edi,%esi + 166a: 76 64 jbe 16d0 + 166c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 1673: bb 00 80 00 00 mov $0x8000,%ebx + 1678: 89 45 e4 mov %eax,-0x1c(%ebp) + 167b: eb 0e jmp 168b + 167d: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 1680: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 1682: 8b 78 04 mov 0x4(%eax),%edi + 1685: 39 fe cmp %edi,%esi + 1687: 76 4f jbe 16d8 + 1689: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 168b: 3b 15 28 1a 00 00 cmp 0x1a28,%edx + 1691: 75 ed jne 1680 + if(nu < 4096) + 1693: 8b 45 e4 mov -0x1c(%ebp),%eax + 1696: 81 fe 00 10 00 00 cmp $0x1000,%esi + 169c: bf 00 10 00 00 mov $0x1000,%edi + 16a1: 0f 43 fe cmovae %esi,%edi + 16a4: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 16a7: 89 04 24 mov %eax,(%esp) + 16aa: e8 3b fc ff ff call 12ea + if(p == (char*)-1) + 16af: 83 f8 ff cmp $0xffffffff,%eax + 16b2: 74 18 je 16cc + hp->s.size = nu; + 16b4: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 16b7: 83 c0 08 add $0x8,%eax + 16ba: 89 04 24 mov %eax,(%esp) + 16bd: e8 ee fe ff ff call 15b0 + return freep; + 16c2: 8b 15 28 1a 00 00 mov 0x1a28,%edx + if((p = morecore(nunits)) == 0) + 16c8: 85 d2 test %edx,%edx + 16ca: 75 b4 jne 1680 + return 0; + 16cc: 31 c0 xor %eax,%eax + 16ce: eb 20 jmp 16f0 + if(p->s.size >= nunits){ + 16d0: 89 d0 mov %edx,%eax + 16d2: 89 da mov %ebx,%edx + 16d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 16d8: 39 fe cmp %edi,%esi + 16da: 74 1c je 16f8 + p->s.size -= nunits; + 16dc: 29 f7 sub %esi,%edi + 16de: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 16e1: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 16e4: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 16e7: 89 15 28 1a 00 00 mov %edx,0x1a28 + return (void*)(p + 1); + 16ed: 83 c0 08 add $0x8,%eax + } +} + 16f0: 83 c4 1c add $0x1c,%esp + 16f3: 5b pop %ebx + 16f4: 5e pop %esi + 16f5: 5f pop %edi + 16f6: 5d pop %ebp + 16f7: c3 ret + prevp->s.ptr = p->s.ptr; + 16f8: 8b 08 mov (%eax),%ecx + 16fa: 89 0a mov %ecx,(%edx) + 16fc: eb e9 jmp 16e7 + base.s.ptr = freep = prevp = &base; + 16fe: c7 05 28 1a 00 00 2c movl $0x1a2c,0x1a28 + 1705: 1a 00 00 + base.s.size = 0; + 1708: ba 2c 1a 00 00 mov $0x1a2c,%edx + base.s.ptr = freep = prevp = &base; + 170d: c7 05 2c 1a 00 00 2c movl $0x1a2c,0x1a2c + 1714: 1a 00 00 + base.s.size = 0; + 1717: c7 05 30 1a 00 00 00 movl $0x0,0x1a30 + 171e: 00 00 00 + 1721: e9 46 ff ff ff jmp 166c + 1726: 66 90 xchg %ax,%ax + 1728: 66 90 xchg %ax,%ax + 172a: 66 90 xchg %ax,%ax + 172c: 66 90 xchg %ax,%ax + 172e: 66 90 xchg %ax,%ax + +00001730 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1730: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1731: b9 01 00 00 00 mov $0x1,%ecx + 1736: 89 e5 mov %esp,%ebp + 1738: 8b 55 08 mov 0x8(%ebp),%edx + 173b: 90 nop + 173c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1740: 89 c8 mov %ecx,%eax + 1742: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1745: 85 c0 test %eax,%eax + 1747: 75 f7 jne 1740 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1749: 0f ae f0 mfence +} + 174c: 5d pop %ebp + 174d: c3 ret + 174e: 66 90 xchg %ax,%ax + +00001750 : + +void urelease (struct uspinlock *lk) { + 1750: 55 push %ebp + 1751: 89 e5 mov %esp,%ebp + 1753: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1756: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1759: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 175f: 5d pop %ebp + 1760: c3 ret diff --git a/null.d b/null.d new file mode 100644 index 00000000..ce6ff044 --- /dev/null +++ b/null.d @@ -0,0 +1 @@ +null.o: null.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/null.o b/null.o new file mode 100644 index 00000000..ff34dacd Binary files /dev/null and b/null.o differ diff --git a/null.sym b/null.sym new file mode 100644 index 00000000..a2fd4de7 --- /dev/null +++ b/null.sym @@ -0,0 +1,62 @@ +00001000 .text +00001761 .rodata +00001780 .eh_frame +00001a28 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 null.c +00000000 ulib.c +00000000 printf.c +00001320 printint +0000176e digits.1359 +00000000 umalloc.c +00001a28 freep +00001a2c base +00000000 uspinlock.c +00001040 strcpy +000013c0 printf +00001230 memmove +000012aa mknod +00001302 shm_open +00001150 gets +000012e2 getpid +00001640 malloc +000012f2 sleep +00001272 pipe +00001282 write +000012ba fstat +00001292 kill +000012d2 chdir +0000129a exec +0000126a wait +0000127a read +000012b2 unlink +00001730 uacquire +0000125a fork +000012ea sbrk +0000130a shm_close +000012fa uptime +00001a28 __bss_start +000010f0 memset +00001000 main +00001070 strcmp +000012da dup +000011b0 stat +00001a28 _edata +00001a34 _end +000012c2 link +00001262 exit +00001200 atoi +000010c0 strlen +000012a2 open +00001110 strchr +000012ca mkdir +0000128a close +00001750 urelease +000015b0 free diff --git a/picirq.d b/picirq.d new file mode 100644 index 00000000..5233e7ed --- /dev/null +++ b/picirq.d @@ -0,0 +1 @@ +picirq.o: picirq.c /usr/include/stdc-predef.h types.h x86.h traps.h diff --git a/picirq.o b/picirq.o new file mode 100644 index 00000000..44f306c4 Binary files /dev/null and b/picirq.o differ diff --git a/pipe.d b/pipe.d new file mode 100644 index 00000000..3d0eac9a --- /dev/null +++ b/pipe.d @@ -0,0 +1,2 @@ +pipe.o: pipe.c /usr/include/stdc-predef.h types.h defs.h param.h mmu.h \ + proc.h fs.h spinlock.h sleeplock.h file.h diff --git a/pipe.o b/pipe.o new file mode 100644 index 00000000..235856f6 Binary files /dev/null and b/pipe.o differ diff --git a/printf.d b/printf.d new file mode 100644 index 00000000..ddd3a8d9 --- /dev/null +++ b/printf.d @@ -0,0 +1 @@ +printf.o: printf.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/printf.o b/printf.o new file mode 100644 index 00000000..ac66253b Binary files /dev/null and b/printf.o differ diff --git a/proc.c b/proc.c index 806b1b18..7b2c1a5b 100644 --- a/proc.c +++ b/proc.c @@ -138,7 +138,6 @@ userinit(void) p->tf->eflags = FL_IF; p->tf->esp = PGSIZE; p->tf->eip = 0; // beginning of initcode.S - safestrcpy(p->name, "initcode", sizeof(p->name)); p->cwd = namei("/"); @@ -190,7 +189,8 @@ fork(void) } // Copy process state from proc. - if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz)) == 0){ + // ** changed the param to take in num_pages here + if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz, curproc->num_pages)) == 0){ kfree(np->kstack); np->kstack = 0; np->state = UNUSED; @@ -531,4 +531,4 @@ procdump(void) } cprintf("\n"); } -} +} \ No newline at end of file diff --git a/proc.d b/proc.d new file mode 100644 index 00000000..9396fefc --- /dev/null +++ b/proc.d @@ -0,0 +1,2 @@ +proc.o: proc.c /usr/include/stdc-predef.h types.h defs.h param.h \ + memlayout.h mmu.h x86.h proc.h spinlock.h diff --git a/proc.h b/proc.h index 16471141..5afab719 100644 --- a/proc.h +++ b/proc.h @@ -37,9 +37,9 @@ enum procstate { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE }; // Per-process state struct proc { uint sz; // Size of process memory (bytes) - pde_t* pgdir; // Page table - char *kstack; // Bottom of kernel stack for this process - enum procstate state; // Process state + pde_t* pgdir; // Page t of kernel stack for this process + enum procstate state; // Proceable + char *kstack; // Bottomss state int pid; // Process ID struct proc *parent; // Parent process struct trapframe *tf; // Trap frame for current syscall @@ -49,6 +49,7 @@ struct proc { struct file *ofile[NOFILE]; // Open files struct inode *cwd; // Current directory char name[16]; // Process name (debugging) + uint num_pages; // ** Added number of pages }; // Process memory is laid out contiguously, low addresses first: diff --git a/proc.o b/proc.o new file mode 100644 index 00000000..4fb73dba Binary files /dev/null and b/proc.o differ diff --git a/rm.asm b/rm.asm new file mode 100644 index 00000000..b3df9985 --- /dev/null +++ b/rm.asm @@ -0,0 +1,1240 @@ + +_rm: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: +#include "stat.h" +#include "user.h" + +int +main(int argc, char *argv[]) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 57 push %edi + 1004: 56 push %esi + int i; + + if(argc < 2){ + 1005: be 01 00 00 00 mov $0x1,%esi +{ + 100a: 53 push %ebx + 100b: 83 e4 f0 and $0xfffffff0,%esp + 100e: 83 ec 10 sub $0x10,%esp + 1011: 8b 7d 08 mov 0x8(%ebp),%edi + 1014: 8b 45 0c mov 0xc(%ebp),%eax + if(argc < 2){ + 1017: 83 ff 01 cmp $0x1,%edi + 101a: 8d 58 04 lea 0x4(%eax),%ebx + 101d: 7e 3a jle 1059 + 101f: 90 nop + printf(2, "Usage: rm files...\n"); + exit(); + } + + for(i = 1; i < argc; i++){ + if(unlink(argv[i]) < 0){ + 1020: 8b 03 mov (%ebx),%eax + 1022: 89 04 24 mov %eax,(%esp) + 1025: e8 c8 02 00 00 call 12f2 + 102a: 85 c0 test %eax,%eax + 102c: 78 0f js 103d + for(i = 1; i < argc; i++){ + 102e: 83 c6 01 add $0x1,%esi + 1031: 83 c3 04 add $0x4,%ebx + 1034: 39 fe cmp %edi,%esi + 1036: 75 e8 jne 1020 + printf(2, "rm: %s failed to delete\n", argv[i]); + break; + } + } + + exit(); + 1038: e8 65 02 00 00 call 12a2 + printf(2, "rm: %s failed to delete\n", argv[i]); + 103d: 8b 03 mov (%ebx),%eax + 103f: c7 44 24 04 b5 17 00 movl $0x17b5,0x4(%esp) + 1046: 00 + 1047: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 104e: 89 44 24 08 mov %eax,0x8(%esp) + 1052: e8 a9 03 00 00 call 1400 + break; + 1057: eb df jmp 1038 + printf(2, "Usage: rm files...\n"); + 1059: c7 44 24 04 a1 17 00 movl $0x17a1,0x4(%esp) + 1060: 00 + 1061: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 1068: e8 93 03 00 00 call 1400 + exit(); + 106d: e8 30 02 00 00 call 12a2 + 1072: 66 90 xchg %ax,%ax + 1074: 66 90 xchg %ax,%ax + 1076: 66 90 xchg %ax,%ax + 1078: 66 90 xchg %ax,%ax + 107a: 66 90 xchg %ax,%ax + 107c: 66 90 xchg %ax,%ax + 107e: 66 90 xchg %ax,%ax + +00001080 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1080: 55 push %ebp + 1081: 89 e5 mov %esp,%ebp + 1083: 8b 45 08 mov 0x8(%ebp),%eax + 1086: 8b 4d 0c mov 0xc(%ebp),%ecx + 1089: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 108a: 89 c2 mov %eax,%edx + 108c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1090: 83 c1 01 add $0x1,%ecx + 1093: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1097: 83 c2 01 add $0x1,%edx + 109a: 84 db test %bl,%bl + 109c: 88 5a ff mov %bl,-0x1(%edx) + 109f: 75 ef jne 1090 + ; + return os; +} + 10a1: 5b pop %ebx + 10a2: 5d pop %ebp + 10a3: c3 ret + 10a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 10aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +000010b0 : + +int +strcmp(const char *p, const char *q) +{ + 10b0: 55 push %ebp + 10b1: 89 e5 mov %esp,%ebp + 10b3: 8b 55 08 mov 0x8(%ebp),%edx + 10b6: 53 push %ebx + 10b7: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 10ba: 0f b6 02 movzbl (%edx),%eax + 10bd: 84 c0 test %al,%al + 10bf: 74 2d je 10ee + 10c1: 0f b6 19 movzbl (%ecx),%ebx + 10c4: 38 d8 cmp %bl,%al + 10c6: 74 0e je 10d6 + 10c8: eb 2b jmp 10f5 + 10ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 10d0: 38 c8 cmp %cl,%al + 10d2: 75 15 jne 10e9 + p++, q++; + 10d4: 89 d9 mov %ebx,%ecx + 10d6: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 10d9: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 10dc: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 10df: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 10e3: 84 c0 test %al,%al + 10e5: 75 e9 jne 10d0 + 10e7: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 10e9: 29 c8 sub %ecx,%eax +} + 10eb: 5b pop %ebx + 10ec: 5d pop %ebp + 10ed: c3 ret + 10ee: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 10f1: 31 c0 xor %eax,%eax + 10f3: eb f4 jmp 10e9 + 10f5: 0f b6 cb movzbl %bl,%ecx + 10f8: eb ef jmp 10e9 + 10fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00001100 : + +uint +strlen(char *s) +{ + 1100: 55 push %ebp + 1101: 89 e5 mov %esp,%ebp + 1103: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 1106: 80 39 00 cmpb $0x0,(%ecx) + 1109: 74 12 je 111d + 110b: 31 d2 xor %edx,%edx + 110d: 8d 76 00 lea 0x0(%esi),%esi + 1110: 83 c2 01 add $0x1,%edx + 1113: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 1117: 89 d0 mov %edx,%eax + 1119: 75 f5 jne 1110 + ; + return n; +} + 111b: 5d pop %ebp + 111c: c3 ret + for(n = 0; s[n]; n++) + 111d: 31 c0 xor %eax,%eax +} + 111f: 5d pop %ebp + 1120: c3 ret + 1121: eb 0d jmp 1130 + 1123: 90 nop + 1124: 90 nop + 1125: 90 nop + 1126: 90 nop + 1127: 90 nop + 1128: 90 nop + 1129: 90 nop + 112a: 90 nop + 112b: 90 nop + 112c: 90 nop + 112d: 90 nop + 112e: 90 nop + 112f: 90 nop + +00001130 : + +void* +memset(void *dst, int c, uint n) +{ + 1130: 55 push %ebp + 1131: 89 e5 mov %esp,%ebp + 1133: 8b 55 08 mov 0x8(%ebp),%edx + 1136: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 1137: 8b 4d 10 mov 0x10(%ebp),%ecx + 113a: 8b 45 0c mov 0xc(%ebp),%eax + 113d: 89 d7 mov %edx,%edi + 113f: fc cld + 1140: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1142: 89 d0 mov %edx,%eax + 1144: 5f pop %edi + 1145: 5d pop %ebp + 1146: c3 ret + 1147: 89 f6 mov %esi,%esi + 1149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001150 : + +char* +strchr(const char *s, char c) +{ + 1150: 55 push %ebp + 1151: 89 e5 mov %esp,%ebp + 1153: 8b 45 08 mov 0x8(%ebp),%eax + 1156: 53 push %ebx + 1157: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 115a: 0f b6 18 movzbl (%eax),%ebx + 115d: 84 db test %bl,%bl + 115f: 74 1d je 117e + if(*s == c) + 1161: 38 d3 cmp %dl,%bl + 1163: 89 d1 mov %edx,%ecx + 1165: 75 0d jne 1174 + 1167: eb 17 jmp 1180 + 1169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1170: 38 ca cmp %cl,%dl + 1172: 74 0c je 1180 + for(; *s; s++) + 1174: 83 c0 01 add $0x1,%eax + 1177: 0f b6 10 movzbl (%eax),%edx + 117a: 84 d2 test %dl,%dl + 117c: 75 f2 jne 1170 + return (char*)s; + return 0; + 117e: 31 c0 xor %eax,%eax +} + 1180: 5b pop %ebx + 1181: 5d pop %ebp + 1182: c3 ret + 1183: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1189: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001190 : + +char* +gets(char *buf, int max) +{ + 1190: 55 push %ebp + 1191: 89 e5 mov %esp,%ebp + 1193: 57 push %edi + 1194: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1195: 31 f6 xor %esi,%esi +{ + 1197: 53 push %ebx + 1198: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 119b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 119e: eb 31 jmp 11d1 + cc = read(0, &c, 1); + 11a0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 11a7: 00 + 11a8: 89 7c 24 04 mov %edi,0x4(%esp) + 11ac: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 11b3: e8 02 01 00 00 call 12ba + if(cc < 1) + 11b8: 85 c0 test %eax,%eax + 11ba: 7e 1d jle 11d9 + break; + buf[i++] = c; + 11bc: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 11c0: 89 de mov %ebx,%esi + buf[i++] = c; + 11c2: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 11c5: 3c 0d cmp $0xd,%al + buf[i++] = c; + 11c7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 11cb: 74 0c je 11d9 + 11cd: 3c 0a cmp $0xa,%al + 11cf: 74 08 je 11d9 + for(i=0; i+1 < max; ){ + 11d1: 8d 5e 01 lea 0x1(%esi),%ebx + 11d4: 3b 5d 0c cmp 0xc(%ebp),%ebx + 11d7: 7c c7 jl 11a0 + break; + } + buf[i] = '\0'; + 11d9: 8b 45 08 mov 0x8(%ebp),%eax + 11dc: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 11e0: 83 c4 2c add $0x2c,%esp + 11e3: 5b pop %ebx + 11e4: 5e pop %esi + 11e5: 5f pop %edi + 11e6: 5d pop %ebp + 11e7: c3 ret + 11e8: 90 nop + 11e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000011f0 : + +int +stat(char *n, struct stat *st) +{ + 11f0: 55 push %ebp + 11f1: 89 e5 mov %esp,%ebp + 11f3: 56 push %esi + 11f4: 53 push %ebx + 11f5: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 11f8: 8b 45 08 mov 0x8(%ebp),%eax + 11fb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1202: 00 + 1203: 89 04 24 mov %eax,(%esp) + 1206: e8 d7 00 00 00 call 12e2 + if(fd < 0) + 120b: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 120d: 89 c3 mov %eax,%ebx + if(fd < 0) + 120f: 78 27 js 1238 + return -1; + r = fstat(fd, st); + 1211: 8b 45 0c mov 0xc(%ebp),%eax + 1214: 89 1c 24 mov %ebx,(%esp) + 1217: 89 44 24 04 mov %eax,0x4(%esp) + 121b: e8 da 00 00 00 call 12fa + close(fd); + 1220: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 1223: 89 c6 mov %eax,%esi + close(fd); + 1225: e8 a0 00 00 00 call 12ca + return r; + 122a: 89 f0 mov %esi,%eax +} + 122c: 83 c4 10 add $0x10,%esp + 122f: 5b pop %ebx + 1230: 5e pop %esi + 1231: 5d pop %ebp + 1232: c3 ret + 1233: 90 nop + 1234: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 1238: b8 ff ff ff ff mov $0xffffffff,%eax + 123d: eb ed jmp 122c + 123f: 90 nop + +00001240 : + +int +atoi(const char *s) +{ + 1240: 55 push %ebp + 1241: 89 e5 mov %esp,%ebp + 1243: 8b 4d 08 mov 0x8(%ebp),%ecx + 1246: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 1247: 0f be 11 movsbl (%ecx),%edx + 124a: 8d 42 d0 lea -0x30(%edx),%eax + 124d: 3c 09 cmp $0x9,%al + n = 0; + 124f: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 1254: 77 17 ja 126d + 1256: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 1258: 83 c1 01 add $0x1,%ecx + 125b: 8d 04 80 lea (%eax,%eax,4),%eax + 125e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1262: 0f be 11 movsbl (%ecx),%edx + 1265: 8d 5a d0 lea -0x30(%edx),%ebx + 1268: 80 fb 09 cmp $0x9,%bl + 126b: 76 eb jbe 1258 + return n; +} + 126d: 5b pop %ebx + 126e: 5d pop %ebp + 126f: c3 ret + +00001270 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1270: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1271: 31 d2 xor %edx,%edx +{ + 1273: 89 e5 mov %esp,%ebp + 1275: 56 push %esi + 1276: 8b 45 08 mov 0x8(%ebp),%eax + 1279: 53 push %ebx + 127a: 8b 5d 10 mov 0x10(%ebp),%ebx + 127d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1280: 85 db test %ebx,%ebx + 1282: 7e 12 jle 1296 + 1284: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1288: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 128c: 88 0c 10 mov %cl,(%eax,%edx,1) + 128f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1292: 39 da cmp %ebx,%edx + 1294: 75 f2 jne 1288 + return vdst; +} + 1296: 5b pop %ebx + 1297: 5e pop %esi + 1298: 5d pop %ebp + 1299: c3 ret + +0000129a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 129a: b8 01 00 00 00 mov $0x1,%eax + 129f: cd 40 int $0x40 + 12a1: c3 ret + +000012a2 : +SYSCALL(exit) + 12a2: b8 02 00 00 00 mov $0x2,%eax + 12a7: cd 40 int $0x40 + 12a9: c3 ret + +000012aa : +SYSCALL(wait) + 12aa: b8 03 00 00 00 mov $0x3,%eax + 12af: cd 40 int $0x40 + 12b1: c3 ret + +000012b2 : +SYSCALL(pipe) + 12b2: b8 04 00 00 00 mov $0x4,%eax + 12b7: cd 40 int $0x40 + 12b9: c3 ret + +000012ba : +SYSCALL(read) + 12ba: b8 05 00 00 00 mov $0x5,%eax + 12bf: cd 40 int $0x40 + 12c1: c3 ret + +000012c2 : +SYSCALL(write) + 12c2: b8 10 00 00 00 mov $0x10,%eax + 12c7: cd 40 int $0x40 + 12c9: c3 ret + +000012ca : +SYSCALL(close) + 12ca: b8 15 00 00 00 mov $0x15,%eax + 12cf: cd 40 int $0x40 + 12d1: c3 ret + +000012d2 : +SYSCALL(kill) + 12d2: b8 06 00 00 00 mov $0x6,%eax + 12d7: cd 40 int $0x40 + 12d9: c3 ret + +000012da : +SYSCALL(exec) + 12da: b8 07 00 00 00 mov $0x7,%eax + 12df: cd 40 int $0x40 + 12e1: c3 ret + +000012e2 : +SYSCALL(open) + 12e2: b8 0f 00 00 00 mov $0xf,%eax + 12e7: cd 40 int $0x40 + 12e9: c3 ret + +000012ea : +SYSCALL(mknod) + 12ea: b8 11 00 00 00 mov $0x11,%eax + 12ef: cd 40 int $0x40 + 12f1: c3 ret + +000012f2 : +SYSCALL(unlink) + 12f2: b8 12 00 00 00 mov $0x12,%eax + 12f7: cd 40 int $0x40 + 12f9: c3 ret + +000012fa : +SYSCALL(fstat) + 12fa: b8 08 00 00 00 mov $0x8,%eax + 12ff: cd 40 int $0x40 + 1301: c3 ret + +00001302 : +SYSCALL(link) + 1302: b8 13 00 00 00 mov $0x13,%eax + 1307: cd 40 int $0x40 + 1309: c3 ret + +0000130a : +SYSCALL(mkdir) + 130a: b8 14 00 00 00 mov $0x14,%eax + 130f: cd 40 int $0x40 + 1311: c3 ret + +00001312 : +SYSCALL(chdir) + 1312: b8 09 00 00 00 mov $0x9,%eax + 1317: cd 40 int $0x40 + 1319: c3 ret + +0000131a : +SYSCALL(dup) + 131a: b8 0a 00 00 00 mov $0xa,%eax + 131f: cd 40 int $0x40 + 1321: c3 ret + +00001322 : +SYSCALL(getpid) + 1322: b8 0b 00 00 00 mov $0xb,%eax + 1327: cd 40 int $0x40 + 1329: c3 ret + +0000132a : +SYSCALL(sbrk) + 132a: b8 0c 00 00 00 mov $0xc,%eax + 132f: cd 40 int $0x40 + 1331: c3 ret + +00001332 : +SYSCALL(sleep) + 1332: b8 0d 00 00 00 mov $0xd,%eax + 1337: cd 40 int $0x40 + 1339: c3 ret + +0000133a : +SYSCALL(uptime) + 133a: b8 0e 00 00 00 mov $0xe,%eax + 133f: cd 40 int $0x40 + 1341: c3 ret + +00001342 : +SYSCALL(shm_open) + 1342: b8 16 00 00 00 mov $0x16,%eax + 1347: cd 40 int $0x40 + 1349: c3 ret + +0000134a : +SYSCALL(shm_close) + 134a: b8 17 00 00 00 mov $0x17,%eax + 134f: cd 40 int $0x40 + 1351: c3 ret + 1352: 66 90 xchg %ax,%ax + 1354: 66 90 xchg %ax,%ax + 1356: 66 90 xchg %ax,%ax + 1358: 66 90 xchg %ax,%ax + 135a: 66 90 xchg %ax,%ax + 135c: 66 90 xchg %ax,%ax + 135e: 66 90 xchg %ax,%ax + +00001360 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 1360: 55 push %ebp + 1361: 89 e5 mov %esp,%ebp + 1363: 57 push %edi + 1364: 56 push %esi + 1365: 89 c6 mov %eax,%esi + 1367: 53 push %ebx + 1368: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 136b: 8b 5d 08 mov 0x8(%ebp),%ebx + 136e: 85 db test %ebx,%ebx + 1370: 74 09 je 137b + 1372: 89 d0 mov %edx,%eax + 1374: c1 e8 1f shr $0x1f,%eax + 1377: 84 c0 test %al,%al + 1379: 75 75 jne 13f0 + neg = 1; + x = -xx; + } else { + x = xx; + 137b: 89 d0 mov %edx,%eax + neg = 0; + 137d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1384: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1387: 31 ff xor %edi,%edi + 1389: 89 ce mov %ecx,%esi + 138b: 8d 5d d7 lea -0x29(%ebp),%ebx + 138e: eb 02 jmp 1392 + do{ + buf[i++] = digits[x % base]; + 1390: 89 cf mov %ecx,%edi + 1392: 31 d2 xor %edx,%edx + 1394: f7 f6 div %esi + 1396: 8d 4f 01 lea 0x1(%edi),%ecx + 1399: 0f b6 92 d5 17 00 00 movzbl 0x17d5(%edx),%edx + }while((x /= base) != 0); + 13a0: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 13a2: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 13a5: 75 e9 jne 1390 + if(neg) + 13a7: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 13aa: 89 c8 mov %ecx,%eax + 13ac: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 13af: 85 d2 test %edx,%edx + 13b1: 74 08 je 13bb + buf[i++] = '-'; + 13b3: 8d 4f 02 lea 0x2(%edi),%ecx + 13b6: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 13bb: 8d 79 ff lea -0x1(%ecx),%edi + 13be: 66 90 xchg %ax,%ax + 13c0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 13c5: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 13c8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 13cf: 00 + 13d0: 89 5c 24 04 mov %ebx,0x4(%esp) + 13d4: 89 34 24 mov %esi,(%esp) + 13d7: 88 45 d7 mov %al,-0x29(%ebp) + 13da: e8 e3 fe ff ff call 12c2 + while(--i >= 0) + 13df: 83 ff ff cmp $0xffffffff,%edi + 13e2: 75 dc jne 13c0 + putc(fd, buf[i]); +} + 13e4: 83 c4 4c add $0x4c,%esp + 13e7: 5b pop %ebx + 13e8: 5e pop %esi + 13e9: 5f pop %edi + 13ea: 5d pop %ebp + 13eb: c3 ret + 13ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 13f0: 89 d0 mov %edx,%eax + 13f2: f7 d8 neg %eax + neg = 1; + 13f4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 13fb: eb 87 jmp 1384 + 13fd: 8d 76 00 lea 0x0(%esi),%esi + +00001400 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 1400: 55 push %ebp + 1401: 89 e5 mov %esp,%ebp + 1403: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 1404: 31 ff xor %edi,%edi +{ + 1406: 56 push %esi + 1407: 53 push %ebx + 1408: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 140b: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 140e: 8d 45 10 lea 0x10(%ebp),%eax +{ + 1411: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 1414: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 1417: 0f b6 13 movzbl (%ebx),%edx + 141a: 83 c3 01 add $0x1,%ebx + 141d: 84 d2 test %dl,%dl + 141f: 75 39 jne 145a + 1421: e9 c2 00 00 00 jmp 14e8 + 1426: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 1428: 83 fa 25 cmp $0x25,%edx + 142b: 0f 84 bf 00 00 00 je 14f0 + write(fd, &c, 1); + 1431: 8d 45 e2 lea -0x1e(%ebp),%eax + 1434: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 143b: 00 + 143c: 89 44 24 04 mov %eax,0x4(%esp) + 1440: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 1443: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 1446: e8 77 fe ff ff call 12c2 + 144b: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 144e: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 1452: 84 d2 test %dl,%dl + 1454: 0f 84 8e 00 00 00 je 14e8 + if(state == 0){ + 145a: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 145c: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 145f: 74 c7 je 1428 + } + } else if(state == '%'){ + 1461: 83 ff 25 cmp $0x25,%edi + 1464: 75 e5 jne 144b + if(c == 'd'){ + 1466: 83 fa 64 cmp $0x64,%edx + 1469: 0f 84 31 01 00 00 je 15a0 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 146f: 25 f7 00 00 00 and $0xf7,%eax + 1474: 83 f8 70 cmp $0x70,%eax + 1477: 0f 84 83 00 00 00 je 1500 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 147d: 83 fa 73 cmp $0x73,%edx + 1480: 0f 84 a2 00 00 00 je 1528 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1486: 83 fa 63 cmp $0x63,%edx + 1489: 0f 84 35 01 00 00 je 15c4 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 148f: 83 fa 25 cmp $0x25,%edx + 1492: 0f 84 e0 00 00 00 je 1578 + write(fd, &c, 1); + 1498: 8d 45 e6 lea -0x1a(%ebp),%eax + 149b: 83 c3 01 add $0x1,%ebx + 149e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14a5: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 14a6: 31 ff xor %edi,%edi + write(fd, &c, 1); + 14a8: 89 44 24 04 mov %eax,0x4(%esp) + 14ac: 89 34 24 mov %esi,(%esp) + 14af: 89 55 d0 mov %edx,-0x30(%ebp) + 14b2: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 14b6: e8 07 fe ff ff call 12c2 + putc(fd, c); + 14bb: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 14be: 8d 45 e7 lea -0x19(%ebp),%eax + 14c1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14c8: 00 + 14c9: 89 44 24 04 mov %eax,0x4(%esp) + 14cd: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 14d0: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 14d3: e8 ea fd ff ff call 12c2 + for(i = 0; fmt[i]; i++){ + 14d8: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 14dc: 84 d2 test %dl,%dl + 14de: 0f 85 76 ff ff ff jne 145a + 14e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 14e8: 83 c4 3c add $0x3c,%esp + 14eb: 5b pop %ebx + 14ec: 5e pop %esi + 14ed: 5f pop %edi + 14ee: 5d pop %ebp + 14ef: c3 ret + state = '%'; + 14f0: bf 25 00 00 00 mov $0x25,%edi + 14f5: e9 51 ff ff ff jmp 144b + 14fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 1500: 8b 45 d4 mov -0x2c(%ebp),%eax + 1503: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 1508: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 150a: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1511: 8b 10 mov (%eax),%edx + 1513: 89 f0 mov %esi,%eax + 1515: e8 46 fe ff ff call 1360 + ap++; + 151a: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 151e: e9 28 ff ff ff jmp 144b + 1523: 90 nop + 1524: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 1528: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 152b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 152f: 8b 38 mov (%eax),%edi + s = "(null)"; + 1531: b8 ce 17 00 00 mov $0x17ce,%eax + 1536: 85 ff test %edi,%edi + 1538: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 153b: 0f b6 07 movzbl (%edi),%eax + 153e: 84 c0 test %al,%al + 1540: 74 2a je 156c + 1542: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1548: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 154b: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 154e: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 1551: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1558: 00 + 1559: 89 44 24 04 mov %eax,0x4(%esp) + 155d: 89 34 24 mov %esi,(%esp) + 1560: e8 5d fd ff ff call 12c2 + while(*s != 0){ + 1565: 0f b6 07 movzbl (%edi),%eax + 1568: 84 c0 test %al,%al + 156a: 75 dc jne 1548 + state = 0; + 156c: 31 ff xor %edi,%edi + 156e: e9 d8 fe ff ff jmp 144b + 1573: 90 nop + 1574: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1578: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 157b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 157d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1584: 00 + 1585: 89 44 24 04 mov %eax,0x4(%esp) + 1589: 89 34 24 mov %esi,(%esp) + 158c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1590: e8 2d fd ff ff call 12c2 + 1595: e9 b1 fe ff ff jmp 144b + 159a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 15a0: 8b 45 d4 mov -0x2c(%ebp),%eax + 15a3: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 15a8: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 15ab: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 15b2: 8b 10 mov (%eax),%edx + 15b4: 89 f0 mov %esi,%eax + 15b6: e8 a5 fd ff ff call 1360 + ap++; + 15bb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15bf: e9 87 fe ff ff jmp 144b + putc(fd, *ap); + 15c4: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 15c7: 31 ff xor %edi,%edi + putc(fd, *ap); + 15c9: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 15cb: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 15d2: 00 + 15d3: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 15d6: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 15d9: 8d 45 e4 lea -0x1c(%ebp),%eax + 15dc: 89 44 24 04 mov %eax,0x4(%esp) + 15e0: e8 dd fc ff ff call 12c2 + ap++; + 15e5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15e9: e9 5d fe ff ff jmp 144b + 15ee: 66 90 xchg %ax,%ax + +000015f0 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 15f0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15f1: a1 94 1a 00 00 mov 0x1a94,%eax +{ + 15f6: 89 e5 mov %esp,%ebp + 15f8: 57 push %edi + 15f9: 56 push %esi + 15fa: 53 push %ebx + 15fb: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15fe: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 1600: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1603: 39 d0 cmp %edx,%eax + 1605: 72 11 jb 1618 + 1607: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1608: 39 c8 cmp %ecx,%eax + 160a: 72 04 jb 1610 + 160c: 39 ca cmp %ecx,%edx + 160e: 72 10 jb 1620 + 1610: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1612: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1614: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1616: 73 f0 jae 1608 + 1618: 39 ca cmp %ecx,%edx + 161a: 72 04 jb 1620 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 161c: 39 c8 cmp %ecx,%eax + 161e: 72 f0 jb 1610 + break; + if(bp + bp->s.size == p->s.ptr){ + 1620: 8b 73 fc mov -0x4(%ebx),%esi + 1623: 8d 3c f2 lea (%edx,%esi,8),%edi + 1626: 39 cf cmp %ecx,%edi + 1628: 74 1e je 1648 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 162a: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 162d: 8b 48 04 mov 0x4(%eax),%ecx + 1630: 8d 34 c8 lea (%eax,%ecx,8),%esi + 1633: 39 f2 cmp %esi,%edx + 1635: 74 28 je 165f + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 1637: 89 10 mov %edx,(%eax) + freep = p; + 1639: a3 94 1a 00 00 mov %eax,0x1a94 +} + 163e: 5b pop %ebx + 163f: 5e pop %esi + 1640: 5f pop %edi + 1641: 5d pop %ebp + 1642: c3 ret + 1643: 90 nop + 1644: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 1648: 03 71 04 add 0x4(%ecx),%esi + 164b: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 164e: 8b 08 mov (%eax),%ecx + 1650: 8b 09 mov (%ecx),%ecx + 1652: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 1655: 8b 48 04 mov 0x4(%eax),%ecx + 1658: 8d 34 c8 lea (%eax,%ecx,8),%esi + 165b: 39 f2 cmp %esi,%edx + 165d: 75 d8 jne 1637 + p->s.size += bp->s.size; + 165f: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 1662: a3 94 1a 00 00 mov %eax,0x1a94 + p->s.size += bp->s.size; + 1667: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 166a: 8b 53 f8 mov -0x8(%ebx),%edx + 166d: 89 10 mov %edx,(%eax) +} + 166f: 5b pop %ebx + 1670: 5e pop %esi + 1671: 5f pop %edi + 1672: 5d pop %ebp + 1673: c3 ret + 1674: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 167a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001680 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1680: 55 push %ebp + 1681: 89 e5 mov %esp,%ebp + 1683: 57 push %edi + 1684: 56 push %esi + 1685: 53 push %ebx + 1686: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1689: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 168c: 8b 1d 94 1a 00 00 mov 0x1a94,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1692: 8d 48 07 lea 0x7(%eax),%ecx + 1695: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1698: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 169a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 169d: 0f 84 9b 00 00 00 je 173e + 16a3: 8b 13 mov (%ebx),%edx + 16a5: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 16a8: 39 fe cmp %edi,%esi + 16aa: 76 64 jbe 1710 + 16ac: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 16b3: bb 00 80 00 00 mov $0x8000,%ebx + 16b8: 89 45 e4 mov %eax,-0x1c(%ebp) + 16bb: eb 0e jmp 16cb + 16bd: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 16c0: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 16c2: 8b 78 04 mov 0x4(%eax),%edi + 16c5: 39 fe cmp %edi,%esi + 16c7: 76 4f jbe 1718 + 16c9: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 16cb: 3b 15 94 1a 00 00 cmp 0x1a94,%edx + 16d1: 75 ed jne 16c0 + if(nu < 4096) + 16d3: 8b 45 e4 mov -0x1c(%ebp),%eax + 16d6: 81 fe 00 10 00 00 cmp $0x1000,%esi + 16dc: bf 00 10 00 00 mov $0x1000,%edi + 16e1: 0f 43 fe cmovae %esi,%edi + 16e4: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 16e7: 89 04 24 mov %eax,(%esp) + 16ea: e8 3b fc ff ff call 132a + if(p == (char*)-1) + 16ef: 83 f8 ff cmp $0xffffffff,%eax + 16f2: 74 18 je 170c + hp->s.size = nu; + 16f4: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 16f7: 83 c0 08 add $0x8,%eax + 16fa: 89 04 24 mov %eax,(%esp) + 16fd: e8 ee fe ff ff call 15f0 + return freep; + 1702: 8b 15 94 1a 00 00 mov 0x1a94,%edx + if((p = morecore(nunits)) == 0) + 1708: 85 d2 test %edx,%edx + 170a: 75 b4 jne 16c0 + return 0; + 170c: 31 c0 xor %eax,%eax + 170e: eb 20 jmp 1730 + if(p->s.size >= nunits){ + 1710: 89 d0 mov %edx,%eax + 1712: 89 da mov %ebx,%edx + 1714: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 1718: 39 fe cmp %edi,%esi + 171a: 74 1c je 1738 + p->s.size -= nunits; + 171c: 29 f7 sub %esi,%edi + 171e: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 1721: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 1724: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 1727: 89 15 94 1a 00 00 mov %edx,0x1a94 + return (void*)(p + 1); + 172d: 83 c0 08 add $0x8,%eax + } +} + 1730: 83 c4 1c add $0x1c,%esp + 1733: 5b pop %ebx + 1734: 5e pop %esi + 1735: 5f pop %edi + 1736: 5d pop %ebp + 1737: c3 ret + prevp->s.ptr = p->s.ptr; + 1738: 8b 08 mov (%eax),%ecx + 173a: 89 0a mov %ecx,(%edx) + 173c: eb e9 jmp 1727 + base.s.ptr = freep = prevp = &base; + 173e: c7 05 94 1a 00 00 98 movl $0x1a98,0x1a94 + 1745: 1a 00 00 + base.s.size = 0; + 1748: ba 98 1a 00 00 mov $0x1a98,%edx + base.s.ptr = freep = prevp = &base; + 174d: c7 05 98 1a 00 00 98 movl $0x1a98,0x1a98 + 1754: 1a 00 00 + base.s.size = 0; + 1757: c7 05 9c 1a 00 00 00 movl $0x0,0x1a9c + 175e: 00 00 00 + 1761: e9 46 ff ff ff jmp 16ac + 1766: 66 90 xchg %ax,%ax + 1768: 66 90 xchg %ax,%ax + 176a: 66 90 xchg %ax,%ax + 176c: 66 90 xchg %ax,%ax + 176e: 66 90 xchg %ax,%ax + +00001770 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1770: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1771: b9 01 00 00 00 mov $0x1,%ecx + 1776: 89 e5 mov %esp,%ebp + 1778: 8b 55 08 mov 0x8(%ebp),%edx + 177b: 90 nop + 177c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1780: 89 c8 mov %ecx,%eax + 1782: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1785: 85 c0 test %eax,%eax + 1787: 75 f7 jne 1780 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1789: 0f ae f0 mfence +} + 178c: 5d pop %ebp + 178d: c3 ret + 178e: 66 90 xchg %ax,%ax + +00001790 : + +void urelease (struct uspinlock *lk) { + 1790: 55 push %ebp + 1791: 89 e5 mov %esp,%ebp + 1793: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1796: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1799: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 179f: 5d pop %ebp + 17a0: c3 ret diff --git a/rm.d b/rm.d new file mode 100644 index 00000000..ba50b6b4 --- /dev/null +++ b/rm.d @@ -0,0 +1 @@ +rm.o: rm.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/rm.o b/rm.o new file mode 100644 index 00000000..70d9463c Binary files /dev/null and b/rm.o differ diff --git a/rm.sym b/rm.sym new file mode 100644 index 00000000..3c09268e --- /dev/null +++ b/rm.sym @@ -0,0 +1,62 @@ +00001000 .text +000017a1 .rodata +000017e8 .eh_frame +00001a94 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 rm.c +00000000 ulib.c +00000000 printf.c +00001360 printint +000017d5 digits.1359 +00000000 umalloc.c +00001a94 freep +00001a98 base +00000000 uspinlock.c +00001080 strcpy +00001400 printf +00001270 memmove +000012ea mknod +00001342 shm_open +00001190 gets +00001322 getpid +00001680 malloc +00001332 sleep +000012b2 pipe +000012c2 write +000012fa fstat +000012d2 kill +00001312 chdir +000012da exec +000012aa wait +000012ba read +000012f2 unlink +00001770 uacquire +0000129a fork +0000132a sbrk +0000134a shm_close +0000133a uptime +00001a94 __bss_start +00001130 memset +00001000 main +000010b0 strcmp +0000131a dup +000011f0 stat +00001a94 _edata +00001aa0 _end +00001302 link +000012a2 exit +00001240 atoi +00001100 strlen +000012e2 open +00001150 strchr +0000130a mkdir +000012ca close +00001790 urelease +000015f0 free diff --git a/sh.asm b/sh.asm new file mode 100644 index 00000000..495f3ee0 --- /dev/null +++ b/sh.asm @@ -0,0 +1,2570 @@ + +_sh: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: + return 0; +} + +int +main(void) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 83 e4 f0 and $0xfffffff0,%esp + 1006: 83 ec 10 sub $0x10,%esp + static char buf[100]; + int fd; + + // Ensure that three file descriptors are open. + while((fd = open("console", O_RDWR)) >= 0){ + 1009: eb 0e jmp 1019 + 100b: 90 nop + 100c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(fd >= 3){ + 1010: 83 f8 02 cmp $0x2,%eax + 1013: 0f 8f cd 00 00 00 jg 10e6 + while((fd = open("console", O_RDWR)) >= 0){ + 1019: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) + 1020: 00 + 1021: c7 04 24 85 23 00 00 movl $0x2385,(%esp) + 1028: e8 f5 0d 00 00 call 1e22 + 102d: 85 c0 test %eax,%eax + 102f: 79 df jns 1010 + 1031: eb 23 jmp 1056 + 1033: 90 nop + 1034: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } + + // Read and run input commands. + while(getcmd(buf, sizeof(buf)) >= 0){ + if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ + 1038: 80 3d c2 29 00 00 20 cmpb $0x20,0x29c2 + 103f: 90 nop + 1040: 74 60 je 10a2 + 1042: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + buf[strlen(buf)-1] = 0; // chop \n + if(chdir(buf+3) < 0) + printf(2, "cannot cd %s\n", buf+3); + continue; + } + if(fork1() == 0) + 1048: e8 43 01 00 00 call 1190 + 104d: 85 c0 test %eax,%eax + 104f: 74 38 je 1089 + runcmd(parsecmd(buf)); + wait(); + 1051: e8 94 0d 00 00 call 1dea + while(getcmd(buf, sizeof(buf)) >= 0){ + 1056: c7 44 24 04 64 00 00 movl $0x64,0x4(%esp) + 105d: 00 + 105e: c7 04 24 c0 29 00 00 movl $0x29c0,(%esp) + 1065: e8 96 00 00 00 call 1100 + 106a: 85 c0 test %eax,%eax + 106c: 78 2f js 109d + if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ + 106e: 80 3d c0 29 00 00 63 cmpb $0x63,0x29c0 + 1075: 75 d1 jne 1048 + 1077: 80 3d c1 29 00 00 64 cmpb $0x64,0x29c1 + 107e: 74 b8 je 1038 + if(fork1() == 0) + 1080: e8 0b 01 00 00 call 1190 + 1085: 85 c0 test %eax,%eax + 1087: 75 c8 jne 1051 + runcmd(parsecmd(buf)); + 1089: c7 04 24 c0 29 00 00 movl $0x29c0,(%esp) + 1090: e8 ab 0a 00 00 call 1b40 + 1095: 89 04 24 mov %eax,(%esp) + 1098: e8 13 01 00 00 call 11b0 + } + exit(); + 109d: e8 40 0d 00 00 call 1de2 + buf[strlen(buf)-1] = 0; // chop \n + 10a2: c7 04 24 c0 29 00 00 movl $0x29c0,(%esp) + 10a9: e8 92 0b 00 00 call 1c40 + if(chdir(buf+3) < 0) + 10ae: c7 04 24 c3 29 00 00 movl $0x29c3,(%esp) + buf[strlen(buf)-1] = 0; // chop \n + 10b5: c6 80 bf 29 00 00 00 movb $0x0,0x29bf(%eax) + if(chdir(buf+3) < 0) + 10bc: e8 91 0d 00 00 call 1e52 + 10c1: 85 c0 test %eax,%eax + 10c3: 79 91 jns 1056 + printf(2, "cannot cd %s\n", buf+3); + 10c5: c7 44 24 08 c3 29 00 movl $0x29c3,0x8(%esp) + 10cc: 00 + 10cd: c7 44 24 04 8d 23 00 movl $0x238d,0x4(%esp) + 10d4: 00 + 10d5: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 10dc: e8 5f 0e 00 00 call 1f40 + 10e1: e9 70 ff ff ff jmp 1056 + close(fd); + 10e6: 89 04 24 mov %eax,(%esp) + 10e9: e8 1c 0d 00 00 call 1e0a + 10ee: 66 90 xchg %ax,%ax + break; + 10f0: e9 61 ff ff ff jmp 1056 + 10f5: 66 90 xchg %ax,%ax + 10f7: 66 90 xchg %ax,%ax + 10f9: 66 90 xchg %ax,%ax + 10fb: 66 90 xchg %ax,%ax + 10fd: 66 90 xchg %ax,%ax + 10ff: 90 nop + +00001100 : +{ + 1100: 55 push %ebp + 1101: 89 e5 mov %esp,%ebp + 1103: 56 push %esi + 1104: 53 push %ebx + 1105: 83 ec 10 sub $0x10,%esp + 1108: 8b 5d 08 mov 0x8(%ebp),%ebx + 110b: 8b 75 0c mov 0xc(%ebp),%esi + printf(2, "$ "); + 110e: c7 44 24 04 e4 22 00 movl $0x22e4,0x4(%esp) + 1115: 00 + 1116: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 111d: e8 1e 0e 00 00 call 1f40 + memset(buf, 0, nbuf); + 1122: 89 74 24 08 mov %esi,0x8(%esp) + 1126: 89 1c 24 mov %ebx,(%esp) + 1129: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1130: 00 + 1131: e8 3a 0b 00 00 call 1c70 + gets(buf, nbuf); + 1136: 89 74 24 04 mov %esi,0x4(%esp) + 113a: 89 1c 24 mov %ebx,(%esp) + 113d: e8 8e 0b 00 00 call 1cd0 + if(buf[0] == 0) // EOF + 1142: 31 c0 xor %eax,%eax + 1144: 80 3b 00 cmpb $0x0,(%ebx) + 1147: 0f 94 c0 sete %al +} + 114a: 83 c4 10 add $0x10,%esp + 114d: 5b pop %ebx + if(buf[0] == 0) // EOF + 114e: f7 d8 neg %eax +} + 1150: 5e pop %esi + 1151: 5d pop %ebp + 1152: c3 ret + 1153: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1159: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001160 : +} + +void +panic(char *s) +{ + 1160: 55 push %ebp + 1161: 89 e5 mov %esp,%ebp + 1163: 83 ec 18 sub $0x18,%esp + printf(2, "%s\n", s); + 1166: 8b 45 08 mov 0x8(%ebp),%eax + 1169: c7 44 24 04 81 23 00 movl $0x2381,0x4(%esp) + 1170: 00 + 1171: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 1178: 89 44 24 08 mov %eax,0x8(%esp) + 117c: e8 bf 0d 00 00 call 1f40 + exit(); + 1181: e8 5c 0c 00 00 call 1de2 + 1186: 8d 76 00 lea 0x0(%esi),%esi + 1189: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001190 : +} + +int +fork1(void) +{ + 1190: 55 push %ebp + 1191: 89 e5 mov %esp,%ebp + 1193: 83 ec 18 sub $0x18,%esp + int pid; + + pid = fork(); + 1196: e8 3f 0c 00 00 call 1dda + if(pid == -1) + 119b: 83 f8 ff cmp $0xffffffff,%eax + 119e: 74 02 je 11a2 + panic("fork"); + return pid; +} + 11a0: c9 leave + 11a1: c3 ret + panic("fork"); + 11a2: c7 04 24 e7 22 00 00 movl $0x22e7,(%esp) + 11a9: e8 b2 ff ff ff call 1160 + 11ae: 66 90 xchg %ax,%ax + +000011b0 : +{ + 11b0: 55 push %ebp + 11b1: 89 e5 mov %esp,%ebp + 11b3: 53 push %ebx + 11b4: 83 ec 24 sub $0x24,%esp + 11b7: 8b 5d 08 mov 0x8(%ebp),%ebx + if(cmd == 0) + 11ba: 85 db test %ebx,%ebx + 11bc: 74 5f je 121d + switch(cmd->type){ + 11be: 83 3b 05 cmpl $0x5,(%ebx) + 11c1: 0f 87 e7 00 00 00 ja 12ae + 11c7: 8b 03 mov (%ebx),%eax + 11c9: ff 24 85 9c 23 00 00 jmp *0x239c(,%eax,4) + if(pipe(p) < 0) + 11d0: 8d 45 f0 lea -0x10(%ebp),%eax + 11d3: 89 04 24 mov %eax,(%esp) + 11d6: e8 17 0c 00 00 call 1df2 + 11db: 85 c0 test %eax,%eax + 11dd: 0f 88 d7 00 00 00 js 12ba + if(fork1() == 0){ + 11e3: e8 a8 ff ff ff call 1190 + 11e8: 85 c0 test %eax,%eax + 11ea: 0f 84 2e 01 00 00 je 131e + if(fork1() == 0){ + 11f0: e8 9b ff ff ff call 1190 + 11f5: 85 c0 test %eax,%eax + 11f7: 0f 84 e9 00 00 00 je 12e6 + close(p[0]); + 11fd: 8b 45 f0 mov -0x10(%ebp),%eax + 1200: 89 04 24 mov %eax,(%esp) + 1203: e8 02 0c 00 00 call 1e0a + close(p[1]); + 1208: 8b 45 f4 mov -0xc(%ebp),%eax + 120b: 89 04 24 mov %eax,(%esp) + 120e: e8 f7 0b 00 00 call 1e0a + wait(); + 1213: e8 d2 0b 00 00 call 1dea + wait(); + 1218: e8 cd 0b 00 00 call 1dea + 121d: 8d 76 00 lea 0x0(%esi),%esi + exit(); + 1220: e8 bd 0b 00 00 call 1de2 + if(fork1() == 0) + 1225: e8 66 ff ff ff call 1190 + 122a: 85 c0 test %eax,%eax + 122c: 75 ef jne 121d + 122e: 66 90 xchg %ax,%ax + 1230: eb 71 jmp 12a3 + if(ecmd->argv[0] == 0) + 1232: 8b 43 04 mov 0x4(%ebx),%eax + 1235: 85 c0 test %eax,%eax + 1237: 74 e4 je 121d + exec(ecmd->argv[0], ecmd->argv); + 1239: 8d 53 04 lea 0x4(%ebx),%edx + 123c: 89 54 24 04 mov %edx,0x4(%esp) + 1240: 89 04 24 mov %eax,(%esp) + 1243: e8 d2 0b 00 00 call 1e1a + printf(2, "exec %s failed\n", ecmd->argv[0]); + 1248: 8b 43 04 mov 0x4(%ebx),%eax + 124b: c7 44 24 04 f3 22 00 movl $0x22f3,0x4(%esp) + 1252: 00 + 1253: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 125a: 89 44 24 08 mov %eax,0x8(%esp) + 125e: e8 dd 0c 00 00 call 1f40 + break; + 1263: eb b8 jmp 121d + if(fork1() == 0) + 1265: e8 26 ff ff ff call 1190 + 126a: 85 c0 test %eax,%eax + 126c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1270: 74 31 je 12a3 + wait(); + 1272: e8 73 0b 00 00 call 1dea + runcmd(lcmd->right); + 1277: 8b 43 08 mov 0x8(%ebx),%eax + 127a: 89 04 24 mov %eax,(%esp) + 127d: e8 2e ff ff ff call 11b0 + close(rcmd->fd); + 1282: 8b 43 14 mov 0x14(%ebx),%eax + 1285: 89 04 24 mov %eax,(%esp) + 1288: e8 7d 0b 00 00 call 1e0a + if(open(rcmd->file, rcmd->mode) < 0){ + 128d: 8b 43 10 mov 0x10(%ebx),%eax + 1290: 89 44 24 04 mov %eax,0x4(%esp) + 1294: 8b 43 08 mov 0x8(%ebx),%eax + 1297: 89 04 24 mov %eax,(%esp) + 129a: e8 83 0b 00 00 call 1e22 + 129f: 85 c0 test %eax,%eax + 12a1: 78 23 js 12c6 + runcmd(bcmd->cmd); + 12a3: 8b 43 04 mov 0x4(%ebx),%eax + 12a6: 89 04 24 mov %eax,(%esp) + 12a9: e8 02 ff ff ff call 11b0 + panic("runcmd"); + 12ae: c7 04 24 ec 22 00 00 movl $0x22ec,(%esp) + 12b5: e8 a6 fe ff ff call 1160 + panic("pipe"); + 12ba: c7 04 24 13 23 00 00 movl $0x2313,(%esp) + 12c1: e8 9a fe ff ff call 1160 + printf(2, "open %s failed\n", rcmd->file); + 12c6: 8b 43 08 mov 0x8(%ebx),%eax + 12c9: c7 44 24 04 03 23 00 movl $0x2303,0x4(%esp) + 12d0: 00 + 12d1: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 12d8: 89 44 24 08 mov %eax,0x8(%esp) + 12dc: e8 5f 0c 00 00 call 1f40 + 12e1: e9 37 ff ff ff jmp 121d + close(0); + 12e6: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 12ed: e8 18 0b 00 00 call 1e0a + dup(p[0]); + 12f2: 8b 45 f0 mov -0x10(%ebp),%eax + 12f5: 89 04 24 mov %eax,(%esp) + 12f8: e8 5d 0b 00 00 call 1e5a + close(p[0]); + 12fd: 8b 45 f0 mov -0x10(%ebp),%eax + 1300: 89 04 24 mov %eax,(%esp) + 1303: e8 02 0b 00 00 call 1e0a + close(p[1]); + 1308: 8b 45 f4 mov -0xc(%ebp),%eax + 130b: 89 04 24 mov %eax,(%esp) + 130e: e8 f7 0a 00 00 call 1e0a + runcmd(pcmd->right); + 1313: 8b 43 08 mov 0x8(%ebx),%eax + 1316: 89 04 24 mov %eax,(%esp) + 1319: e8 92 fe ff ff call 11b0 + close(1); + 131e: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1325: e8 e0 0a 00 00 call 1e0a + dup(p[1]); + 132a: 8b 45 f4 mov -0xc(%ebp),%eax + 132d: 89 04 24 mov %eax,(%esp) + 1330: e8 25 0b 00 00 call 1e5a + close(p[0]); + 1335: 8b 45 f0 mov -0x10(%ebp),%eax + 1338: 89 04 24 mov %eax,(%esp) + 133b: e8 ca 0a 00 00 call 1e0a + close(p[1]); + 1340: 8b 45 f4 mov -0xc(%ebp),%eax + 1343: 89 04 24 mov %eax,(%esp) + 1346: e8 bf 0a 00 00 call 1e0a + runcmd(pcmd->left); + 134b: 8b 43 04 mov 0x4(%ebx),%eax + 134e: 89 04 24 mov %eax,(%esp) + 1351: e8 5a fe ff ff call 11b0 + 1356: 8d 76 00 lea 0x0(%esi),%esi + 1359: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001360 : +//PAGEBREAK! +// Constructors + +struct cmd* +execcmd(void) +{ + 1360: 55 push %ebp + 1361: 89 e5 mov %esp,%ebp + 1363: 53 push %ebx + 1364: 83 ec 14 sub $0x14,%esp + struct execcmd *cmd; + + cmd = malloc(sizeof(*cmd)); + 1367: c7 04 24 54 00 00 00 movl $0x54,(%esp) + 136e: e8 4d 0e 00 00 call 21c0 + memset(cmd, 0, sizeof(*cmd)); + 1373: c7 44 24 08 54 00 00 movl $0x54,0x8(%esp) + 137a: 00 + 137b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1382: 00 + cmd = malloc(sizeof(*cmd)); + 1383: 89 c3 mov %eax,%ebx + memset(cmd, 0, sizeof(*cmd)); + 1385: 89 04 24 mov %eax,(%esp) + 1388: e8 e3 08 00 00 call 1c70 + cmd->type = EXEC; + return (struct cmd*)cmd; +} + 138d: 89 d8 mov %ebx,%eax + cmd->type = EXEC; + 138f: c7 03 01 00 00 00 movl $0x1,(%ebx) +} + 1395: 83 c4 14 add $0x14,%esp + 1398: 5b pop %ebx + 1399: 5d pop %ebp + 139a: c3 ret + 139b: 90 nop + 139c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000013a0 : + +struct cmd* +redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd) +{ + 13a0: 55 push %ebp + 13a1: 89 e5 mov %esp,%ebp + 13a3: 53 push %ebx + 13a4: 83 ec 14 sub $0x14,%esp + struct redircmd *cmd; + + cmd = malloc(sizeof(*cmd)); + 13a7: c7 04 24 18 00 00 00 movl $0x18,(%esp) + 13ae: e8 0d 0e 00 00 call 21c0 + memset(cmd, 0, sizeof(*cmd)); + 13b3: c7 44 24 08 18 00 00 movl $0x18,0x8(%esp) + 13ba: 00 + 13bb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 13c2: 00 + 13c3: 89 04 24 mov %eax,(%esp) + cmd = malloc(sizeof(*cmd)); + 13c6: 89 c3 mov %eax,%ebx + memset(cmd, 0, sizeof(*cmd)); + 13c8: e8 a3 08 00 00 call 1c70 + cmd->type = REDIR; + cmd->cmd = subcmd; + 13cd: 8b 45 08 mov 0x8(%ebp),%eax + cmd->type = REDIR; + 13d0: c7 03 02 00 00 00 movl $0x2,(%ebx) + cmd->cmd = subcmd; + 13d6: 89 43 04 mov %eax,0x4(%ebx) + cmd->file = file; + 13d9: 8b 45 0c mov 0xc(%ebp),%eax + 13dc: 89 43 08 mov %eax,0x8(%ebx) + cmd->efile = efile; + 13df: 8b 45 10 mov 0x10(%ebp),%eax + 13e2: 89 43 0c mov %eax,0xc(%ebx) + cmd->mode = mode; + 13e5: 8b 45 14 mov 0x14(%ebp),%eax + 13e8: 89 43 10 mov %eax,0x10(%ebx) + cmd->fd = fd; + 13eb: 8b 45 18 mov 0x18(%ebp),%eax + 13ee: 89 43 14 mov %eax,0x14(%ebx) + return (struct cmd*)cmd; +} + 13f1: 83 c4 14 add $0x14,%esp + 13f4: 89 d8 mov %ebx,%eax + 13f6: 5b pop %ebx + 13f7: 5d pop %ebp + 13f8: c3 ret + 13f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001400 : + +struct cmd* +pipecmd(struct cmd *left, struct cmd *right) +{ + 1400: 55 push %ebp + 1401: 89 e5 mov %esp,%ebp + 1403: 53 push %ebx + 1404: 83 ec 14 sub $0x14,%esp + struct pipecmd *cmd; + + cmd = malloc(sizeof(*cmd)); + 1407: c7 04 24 0c 00 00 00 movl $0xc,(%esp) + 140e: e8 ad 0d 00 00 call 21c0 + memset(cmd, 0, sizeof(*cmd)); + 1413: c7 44 24 08 0c 00 00 movl $0xc,0x8(%esp) + 141a: 00 + 141b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1422: 00 + 1423: 89 04 24 mov %eax,(%esp) + cmd = malloc(sizeof(*cmd)); + 1426: 89 c3 mov %eax,%ebx + memset(cmd, 0, sizeof(*cmd)); + 1428: e8 43 08 00 00 call 1c70 + cmd->type = PIPE; + cmd->left = left; + 142d: 8b 45 08 mov 0x8(%ebp),%eax + cmd->type = PIPE; + 1430: c7 03 03 00 00 00 movl $0x3,(%ebx) + cmd->left = left; + 1436: 89 43 04 mov %eax,0x4(%ebx) + cmd->right = right; + 1439: 8b 45 0c mov 0xc(%ebp),%eax + 143c: 89 43 08 mov %eax,0x8(%ebx) + return (struct cmd*)cmd; +} + 143f: 83 c4 14 add $0x14,%esp + 1442: 89 d8 mov %ebx,%eax + 1444: 5b pop %ebx + 1445: 5d pop %ebp + 1446: c3 ret + 1447: 89 f6 mov %esi,%esi + 1449: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001450 : + +struct cmd* +listcmd(struct cmd *left, struct cmd *right) +{ + 1450: 55 push %ebp + 1451: 89 e5 mov %esp,%ebp + 1453: 53 push %ebx + 1454: 83 ec 14 sub $0x14,%esp + struct listcmd *cmd; + + cmd = malloc(sizeof(*cmd)); + 1457: c7 04 24 0c 00 00 00 movl $0xc,(%esp) + 145e: e8 5d 0d 00 00 call 21c0 + memset(cmd, 0, sizeof(*cmd)); + 1463: c7 44 24 08 0c 00 00 movl $0xc,0x8(%esp) + 146a: 00 + 146b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1472: 00 + 1473: 89 04 24 mov %eax,(%esp) + cmd = malloc(sizeof(*cmd)); + 1476: 89 c3 mov %eax,%ebx + memset(cmd, 0, sizeof(*cmd)); + 1478: e8 f3 07 00 00 call 1c70 + cmd->type = LIST; + cmd->left = left; + 147d: 8b 45 08 mov 0x8(%ebp),%eax + cmd->type = LIST; + 1480: c7 03 04 00 00 00 movl $0x4,(%ebx) + cmd->left = left; + 1486: 89 43 04 mov %eax,0x4(%ebx) + cmd->right = right; + 1489: 8b 45 0c mov 0xc(%ebp),%eax + 148c: 89 43 08 mov %eax,0x8(%ebx) + return (struct cmd*)cmd; +} + 148f: 83 c4 14 add $0x14,%esp + 1492: 89 d8 mov %ebx,%eax + 1494: 5b pop %ebx + 1495: 5d pop %ebp + 1496: c3 ret + 1497: 89 f6 mov %esi,%esi + 1499: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +000014a0 : + +struct cmd* +backcmd(struct cmd *subcmd) +{ + 14a0: 55 push %ebp + 14a1: 89 e5 mov %esp,%ebp + 14a3: 53 push %ebx + 14a4: 83 ec 14 sub $0x14,%esp + struct backcmd *cmd; + + cmd = malloc(sizeof(*cmd)); + 14a7: c7 04 24 08 00 00 00 movl $0x8,(%esp) + 14ae: e8 0d 0d 00 00 call 21c0 + memset(cmd, 0, sizeof(*cmd)); + 14b3: c7 44 24 08 08 00 00 movl $0x8,0x8(%esp) + 14ba: 00 + 14bb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 14c2: 00 + 14c3: 89 04 24 mov %eax,(%esp) + cmd = malloc(sizeof(*cmd)); + 14c6: 89 c3 mov %eax,%ebx + memset(cmd, 0, sizeof(*cmd)); + 14c8: e8 a3 07 00 00 call 1c70 + cmd->type = BACK; + cmd->cmd = subcmd; + 14cd: 8b 45 08 mov 0x8(%ebp),%eax + cmd->type = BACK; + 14d0: c7 03 05 00 00 00 movl $0x5,(%ebx) + cmd->cmd = subcmd; + 14d6: 89 43 04 mov %eax,0x4(%ebx) + return (struct cmd*)cmd; +} + 14d9: 83 c4 14 add $0x14,%esp + 14dc: 89 d8 mov %ebx,%eax + 14de: 5b pop %ebx + 14df: 5d pop %ebp + 14e0: c3 ret + 14e1: eb 0d jmp 14f0 + 14e3: 90 nop + 14e4: 90 nop + 14e5: 90 nop + 14e6: 90 nop + 14e7: 90 nop + 14e8: 90 nop + 14e9: 90 nop + 14ea: 90 nop + 14eb: 90 nop + 14ec: 90 nop + 14ed: 90 nop + 14ee: 90 nop + 14ef: 90 nop + +000014f0 : +char whitespace[] = " \t\r\n\v"; +char symbols[] = "<|>&;()"; + +int +gettoken(char **ps, char *es, char **q, char **eq) +{ + 14f0: 55 push %ebp + 14f1: 89 e5 mov %esp,%ebp + 14f3: 57 push %edi + 14f4: 56 push %esi + 14f5: 53 push %ebx + 14f6: 83 ec 1c sub $0x1c,%esp + char *s; + int ret; + + s = *ps; + 14f9: 8b 45 08 mov 0x8(%ebp),%eax +{ + 14fc: 8b 5d 0c mov 0xc(%ebp),%ebx + 14ff: 8b 75 10 mov 0x10(%ebp),%esi + s = *ps; + 1502: 8b 38 mov (%eax),%edi + while(s < es && strchr(whitespace, *s)) + 1504: 39 df cmp %ebx,%edi + 1506: 72 0f jb 1517 + 1508: eb 24 jmp 152e + 150a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + s++; + 1510: 83 c7 01 add $0x1,%edi + while(s < es && strchr(whitespace, *s)) + 1513: 39 df cmp %ebx,%edi + 1515: 74 17 je 152e + 1517: 0f be 07 movsbl (%edi),%eax + 151a: c7 04 24 ac 29 00 00 movl $0x29ac,(%esp) + 1521: 89 44 24 04 mov %eax,0x4(%esp) + 1525: e8 66 07 00 00 call 1c90 + 152a: 85 c0 test %eax,%eax + 152c: 75 e2 jne 1510 + if(q) + 152e: 85 f6 test %esi,%esi + 1530: 74 02 je 1534 + *q = s; + 1532: 89 3e mov %edi,(%esi) + ret = *s; + 1534: 0f b6 0f movzbl (%edi),%ecx + 1537: 0f be f1 movsbl %cl,%esi + switch(*s){ + 153a: 80 f9 29 cmp $0x29,%cl + ret = *s; + 153d: 89 f0 mov %esi,%eax + switch(*s){ + 153f: 7f 4f jg 1590 + 1541: 80 f9 28 cmp $0x28,%cl + 1544: 7d 55 jge 159b + 1546: 84 c9 test %cl,%cl + 1548: 0f 85 ca 00 00 00 jne 1618 + ret = 'a'; + while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s)) + s++; + break; + } + if(eq) + 154e: 8b 45 14 mov 0x14(%ebp),%eax + 1551: 85 c0 test %eax,%eax + 1553: 74 05 je 155a + *eq = s; + 1555: 8b 45 14 mov 0x14(%ebp),%eax + 1558: 89 38 mov %edi,(%eax) + + while(s < es && strchr(whitespace, *s)) + 155a: 39 df cmp %ebx,%edi + 155c: 72 09 jb 1567 + 155e: eb 1e jmp 157e + s++; + 1560: 83 c7 01 add $0x1,%edi + while(s < es && strchr(whitespace, *s)) + 1563: 39 df cmp %ebx,%edi + 1565: 74 17 je 157e + 1567: 0f be 07 movsbl (%edi),%eax + 156a: c7 04 24 ac 29 00 00 movl $0x29ac,(%esp) + 1571: 89 44 24 04 mov %eax,0x4(%esp) + 1575: e8 16 07 00 00 call 1c90 + 157a: 85 c0 test %eax,%eax + 157c: 75 e2 jne 1560 + *ps = s; + 157e: 8b 45 08 mov 0x8(%ebp),%eax + 1581: 89 38 mov %edi,(%eax) + return ret; +} + 1583: 83 c4 1c add $0x1c,%esp + 1586: 89 f0 mov %esi,%eax + 1588: 5b pop %ebx + 1589: 5e pop %esi + 158a: 5f pop %edi + 158b: 5d pop %ebp + 158c: c3 ret + 158d: 8d 76 00 lea 0x0(%esi),%esi + switch(*s){ + 1590: 80 f9 3e cmp $0x3e,%cl + 1593: 75 0b jne 15a0 + if(*s == '>'){ + 1595: 80 7f 01 3e cmpb $0x3e,0x1(%edi) + 1599: 74 6d je 1608 + s++; + 159b: 83 c7 01 add $0x1,%edi + 159e: eb ae jmp 154e + switch(*s){ + 15a0: 7f 56 jg 15f8 + 15a2: 83 e9 3b sub $0x3b,%ecx + 15a5: 80 f9 01 cmp $0x1,%cl + 15a8: 76 f1 jbe 159b + while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s)) + 15aa: 39 fb cmp %edi,%ebx + 15ac: 77 2b ja 15d9 + 15ae: 66 90 xchg %ax,%ax + 15b0: eb 3b jmp 15ed + 15b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 15b8: 0f be 07 movsbl (%edi),%eax + 15bb: c7 04 24 a4 29 00 00 movl $0x29a4,(%esp) + 15c2: 89 44 24 04 mov %eax,0x4(%esp) + 15c6: e8 c5 06 00 00 call 1c90 + 15cb: 85 c0 test %eax,%eax + 15cd: 75 1e jne 15ed + s++; + 15cf: 83 c7 01 add $0x1,%edi + while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s)) + 15d2: 39 df cmp %ebx,%edi + 15d4: 74 17 je 15ed + 15d6: 0f be 07 movsbl (%edi),%eax + 15d9: 89 44 24 04 mov %eax,0x4(%esp) + 15dd: c7 04 24 ac 29 00 00 movl $0x29ac,(%esp) + 15e4: e8 a7 06 00 00 call 1c90 + 15e9: 85 c0 test %eax,%eax + 15eb: 74 cb je 15b8 + ret = 'a'; + 15ed: be 61 00 00 00 mov $0x61,%esi + 15f2: e9 57 ff ff ff jmp 154e + 15f7: 90 nop + switch(*s){ + 15f8: 80 f9 7c cmp $0x7c,%cl + 15fb: 74 9e je 159b + 15fd: 8d 76 00 lea 0x0(%esi),%esi + 1600: eb a8 jmp 15aa + 1602: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + s++; + 1608: 83 c7 02 add $0x2,%edi + ret = '+'; + 160b: be 2b 00 00 00 mov $0x2b,%esi + 1610: e9 39 ff ff ff jmp 154e + 1615: 8d 76 00 lea 0x0(%esi),%esi + switch(*s){ + 1618: 80 f9 26 cmp $0x26,%cl + 161b: 75 8d jne 15aa + 161d: e9 79 ff ff ff jmp 159b + 1622: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1629: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001630 : + +int +peek(char **ps, char *es, char *toks) +{ + 1630: 55 push %ebp + 1631: 89 e5 mov %esp,%ebp + 1633: 57 push %edi + 1634: 56 push %esi + 1635: 53 push %ebx + 1636: 83 ec 1c sub $0x1c,%esp + 1639: 8b 7d 08 mov 0x8(%ebp),%edi + 163c: 8b 75 0c mov 0xc(%ebp),%esi + char *s; + + s = *ps; + 163f: 8b 1f mov (%edi),%ebx + while(s < es && strchr(whitespace, *s)) + 1641: 39 f3 cmp %esi,%ebx + 1643: 72 0a jb 164f + 1645: eb 1f jmp 1666 + 1647: 90 nop + s++; + 1648: 83 c3 01 add $0x1,%ebx + while(s < es && strchr(whitespace, *s)) + 164b: 39 f3 cmp %esi,%ebx + 164d: 74 17 je 1666 + 164f: 0f be 03 movsbl (%ebx),%eax + 1652: c7 04 24 ac 29 00 00 movl $0x29ac,(%esp) + 1659: 89 44 24 04 mov %eax,0x4(%esp) + 165d: e8 2e 06 00 00 call 1c90 + 1662: 85 c0 test %eax,%eax + 1664: 75 e2 jne 1648 + *ps = s; + 1666: 89 1f mov %ebx,(%edi) + return *s && strchr(toks, *s); + 1668: 0f be 13 movsbl (%ebx),%edx + 166b: 31 c0 xor %eax,%eax + 166d: 84 d2 test %dl,%dl + 166f: 74 17 je 1688 + 1671: 8b 45 10 mov 0x10(%ebp),%eax + 1674: 89 54 24 04 mov %edx,0x4(%esp) + 1678: 89 04 24 mov %eax,(%esp) + 167b: e8 10 06 00 00 call 1c90 + 1680: 85 c0 test %eax,%eax + 1682: 0f 95 c0 setne %al + 1685: 0f b6 c0 movzbl %al,%eax +} + 1688: 83 c4 1c add $0x1c,%esp + 168b: 5b pop %ebx + 168c: 5e pop %esi + 168d: 5f pop %edi + 168e: 5d pop %ebp + 168f: c3 ret + +00001690 : + return cmd; +} + +struct cmd* +parseredirs(struct cmd *cmd, char **ps, char *es) +{ + 1690: 55 push %ebp + 1691: 89 e5 mov %esp,%ebp + 1693: 57 push %edi + 1694: 56 push %esi + 1695: 53 push %ebx + 1696: 83 ec 3c sub $0x3c,%esp + 1699: 8b 75 0c mov 0xc(%ebp),%esi + 169c: 8b 5d 10 mov 0x10(%ebp),%ebx + 169f: 90 nop + int tok; + char *q, *eq; + + while(peek(ps, es, "<>")){ + 16a0: c7 44 24 08 35 23 00 movl $0x2335,0x8(%esp) + 16a7: 00 + 16a8: 89 5c 24 04 mov %ebx,0x4(%esp) + 16ac: 89 34 24 mov %esi,(%esp) + 16af: e8 7c ff ff ff call 1630 + 16b4: 85 c0 test %eax,%eax + 16b6: 0f 84 9c 00 00 00 je 1758 + tok = gettoken(ps, es, 0, 0); + 16bc: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) + 16c3: 00 + 16c4: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) + 16cb: 00 + 16cc: 89 5c 24 04 mov %ebx,0x4(%esp) + 16d0: 89 34 24 mov %esi,(%esp) + 16d3: e8 18 fe ff ff call 14f0 + if(gettoken(ps, es, &q, &eq) != 'a') + 16d8: 89 5c 24 04 mov %ebx,0x4(%esp) + 16dc: 89 34 24 mov %esi,(%esp) + tok = gettoken(ps, es, 0, 0); + 16df: 89 c7 mov %eax,%edi + if(gettoken(ps, es, &q, &eq) != 'a') + 16e1: 8d 45 e4 lea -0x1c(%ebp),%eax + 16e4: 89 44 24 0c mov %eax,0xc(%esp) + 16e8: 8d 45 e0 lea -0x20(%ebp),%eax + 16eb: 89 44 24 08 mov %eax,0x8(%esp) + 16ef: e8 fc fd ff ff call 14f0 + 16f4: 83 f8 61 cmp $0x61,%eax + 16f7: 75 6a jne 1763 + panic("missing file for redirection"); + switch(tok){ + 16f9: 83 ff 3c cmp $0x3c,%edi + 16fc: 74 42 je 1740 + 16fe: 83 ff 3e cmp $0x3e,%edi + 1701: 74 05 je 1708 + 1703: 83 ff 2b cmp $0x2b,%edi + 1706: 75 98 jne 16a0 + break; + case '>': + cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1); + break; + case '+': // >> + cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1); + 1708: c7 44 24 10 01 00 00 movl $0x1,0x10(%esp) + 170f: 00 + 1710: c7 44 24 0c 01 02 00 movl $0x201,0xc(%esp) + 1717: 00 + 1718: 8b 45 e4 mov -0x1c(%ebp),%eax + 171b: 89 44 24 08 mov %eax,0x8(%esp) + 171f: 8b 45 e0 mov -0x20(%ebp),%eax + 1722: 89 44 24 04 mov %eax,0x4(%esp) + 1726: 8b 45 08 mov 0x8(%ebp),%eax + 1729: 89 04 24 mov %eax,(%esp) + 172c: e8 6f fc ff ff call 13a0 + 1731: 89 45 08 mov %eax,0x8(%ebp) + break; + 1734: e9 67 ff ff ff jmp 16a0 + 1739: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + cmd = redircmd(cmd, q, eq, O_RDONLY, 0); + 1740: c7 44 24 10 00 00 00 movl $0x0,0x10(%esp) + 1747: 00 + 1748: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) + 174f: 00 + 1750: eb c6 jmp 1718 + 1752: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + } + } + return cmd; +} + 1758: 8b 45 08 mov 0x8(%ebp),%eax + 175b: 83 c4 3c add $0x3c,%esp + 175e: 5b pop %ebx + 175f: 5e pop %esi + 1760: 5f pop %edi + 1761: 5d pop %ebp + 1762: c3 ret + panic("missing file for redirection"); + 1763: c7 04 24 18 23 00 00 movl $0x2318,(%esp) + 176a: e8 f1 f9 ff ff call 1160 + 176f: 90 nop + +00001770 : + return cmd; +} + +struct cmd* +parseexec(char **ps, char *es) +{ + 1770: 55 push %ebp + 1771: 89 e5 mov %esp,%ebp + 1773: 57 push %edi + 1774: 56 push %esi + 1775: 53 push %ebx + 1776: 83 ec 3c sub $0x3c,%esp + 1779: 8b 75 08 mov 0x8(%ebp),%esi + 177c: 8b 7d 0c mov 0xc(%ebp),%edi + char *q, *eq; + int tok, argc; + struct execcmd *cmd; + struct cmd *ret; + + if(peek(ps, es, "(")) + 177f: c7 44 24 08 38 23 00 movl $0x2338,0x8(%esp) + 1786: 00 + 1787: 89 34 24 mov %esi,(%esp) + 178a: 89 7c 24 04 mov %edi,0x4(%esp) + 178e: e8 9d fe ff ff call 1630 + 1793: 85 c0 test %eax,%eax + 1795: 0f 85 a5 00 00 00 jne 1840 + return parseblock(ps, es); + + ret = execcmd(); + 179b: e8 c0 fb ff ff call 1360 + cmd = (struct execcmd*)ret; + + argc = 0; + ret = parseredirs(ret, ps, es); + 17a0: 89 7c 24 08 mov %edi,0x8(%esp) + 17a4: 89 74 24 04 mov %esi,0x4(%esp) + 17a8: 89 04 24 mov %eax,(%esp) + ret = execcmd(); + 17ab: 89 c3 mov %eax,%ebx + 17ad: 89 45 cc mov %eax,-0x34(%ebp) + ret = parseredirs(ret, ps, es); + 17b0: e8 db fe ff ff call 1690 + argc = 0; + 17b5: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) + ret = parseredirs(ret, ps, es); + 17bc: 89 45 d0 mov %eax,-0x30(%ebp) + while(!peek(ps, es, "|)&;")){ + 17bf: eb 1d jmp 17de + 17c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + cmd->argv[argc] = q; + cmd->eargv[argc] = eq; + argc++; + if(argc >= MAXARGS) + panic("too many args"); + ret = parseredirs(ret, ps, es); + 17c8: 8b 45 d0 mov -0x30(%ebp),%eax + 17cb: 89 7c 24 08 mov %edi,0x8(%esp) + 17cf: 89 74 24 04 mov %esi,0x4(%esp) + 17d3: 89 04 24 mov %eax,(%esp) + 17d6: e8 b5 fe ff ff call 1690 + 17db: 89 45 d0 mov %eax,-0x30(%ebp) + while(!peek(ps, es, "|)&;")){ + 17de: c7 44 24 08 4f 23 00 movl $0x234f,0x8(%esp) + 17e5: 00 + 17e6: 89 7c 24 04 mov %edi,0x4(%esp) + 17ea: 89 34 24 mov %esi,(%esp) + 17ed: e8 3e fe ff ff call 1630 + 17f2: 85 c0 test %eax,%eax + 17f4: 75 62 jne 1858 + if((tok=gettoken(ps, es, &q, &eq)) == 0) + 17f6: 8d 45 e4 lea -0x1c(%ebp),%eax + 17f9: 89 44 24 0c mov %eax,0xc(%esp) + 17fd: 8d 45 e0 lea -0x20(%ebp),%eax + 1800: 89 44 24 08 mov %eax,0x8(%esp) + 1804: 89 7c 24 04 mov %edi,0x4(%esp) + 1808: 89 34 24 mov %esi,(%esp) + 180b: e8 e0 fc ff ff call 14f0 + 1810: 85 c0 test %eax,%eax + 1812: 74 44 je 1858 + if(tok != 'a') + 1814: 83 f8 61 cmp $0x61,%eax + 1817: 75 61 jne 187a + cmd->argv[argc] = q; + 1819: 8b 45 e0 mov -0x20(%ebp),%eax + 181c: 83 c3 04 add $0x4,%ebx + argc++; + 181f: 83 45 d4 01 addl $0x1,-0x2c(%ebp) + cmd->argv[argc] = q; + 1823: 89 03 mov %eax,(%ebx) + cmd->eargv[argc] = eq; + 1825: 8b 45 e4 mov -0x1c(%ebp),%eax + 1828: 89 43 28 mov %eax,0x28(%ebx) + if(argc >= MAXARGS) + 182b: 83 7d d4 0a cmpl $0xa,-0x2c(%ebp) + 182f: 75 97 jne 17c8 + panic("too many args"); + 1831: c7 04 24 41 23 00 00 movl $0x2341,(%esp) + 1838: e8 23 f9 ff ff call 1160 + 183d: 8d 76 00 lea 0x0(%esi),%esi + return parseblock(ps, es); + 1840: 89 7c 24 04 mov %edi,0x4(%esp) + 1844: 89 34 24 mov %esi,(%esp) + 1847: e8 84 01 00 00 call 19d0 + } + cmd->argv[argc] = 0; + cmd->eargv[argc] = 0; + return ret; +} + 184c: 83 c4 3c add $0x3c,%esp + 184f: 5b pop %ebx + 1850: 5e pop %esi + 1851: 5f pop %edi + 1852: 5d pop %ebp + 1853: c3 ret + 1854: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1858: 8b 45 cc mov -0x34(%ebp),%eax + 185b: 8b 55 d4 mov -0x2c(%ebp),%edx + 185e: 8d 04 90 lea (%eax,%edx,4),%eax + cmd->argv[argc] = 0; + 1861: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) + cmd->eargv[argc] = 0; + 1868: c7 40 2c 00 00 00 00 movl $0x0,0x2c(%eax) + return ret; + 186f: 8b 45 d0 mov -0x30(%ebp),%eax +} + 1872: 83 c4 3c add $0x3c,%esp + 1875: 5b pop %ebx + 1876: 5e pop %esi + 1877: 5f pop %edi + 1878: 5d pop %ebp + 1879: c3 ret + panic("syntax"); + 187a: c7 04 24 3a 23 00 00 movl $0x233a,(%esp) + 1881: e8 da f8 ff ff call 1160 + 1886: 8d 76 00 lea 0x0(%esi),%esi + 1889: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001890 : +{ + 1890: 55 push %ebp + 1891: 89 e5 mov %esp,%ebp + 1893: 57 push %edi + 1894: 56 push %esi + 1895: 53 push %ebx + 1896: 83 ec 1c sub $0x1c,%esp + 1899: 8b 5d 08 mov 0x8(%ebp),%ebx + 189c: 8b 75 0c mov 0xc(%ebp),%esi + cmd = parseexec(ps, es); + 189f: 89 1c 24 mov %ebx,(%esp) + 18a2: 89 74 24 04 mov %esi,0x4(%esp) + 18a6: e8 c5 fe ff ff call 1770 + if(peek(ps, es, "|")){ + 18ab: c7 44 24 08 54 23 00 movl $0x2354,0x8(%esp) + 18b2: 00 + 18b3: 89 74 24 04 mov %esi,0x4(%esp) + 18b7: 89 1c 24 mov %ebx,(%esp) + cmd = parseexec(ps, es); + 18ba: 89 c7 mov %eax,%edi + if(peek(ps, es, "|")){ + 18bc: e8 6f fd ff ff call 1630 + 18c1: 85 c0 test %eax,%eax + 18c3: 75 0b jne 18d0 +} + 18c5: 83 c4 1c add $0x1c,%esp + 18c8: 89 f8 mov %edi,%eax + 18ca: 5b pop %ebx + 18cb: 5e pop %esi + 18cc: 5f pop %edi + 18cd: 5d pop %ebp + 18ce: c3 ret + 18cf: 90 nop + gettoken(ps, es, 0, 0); + 18d0: 89 74 24 04 mov %esi,0x4(%esp) + 18d4: 89 1c 24 mov %ebx,(%esp) + 18d7: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) + 18de: 00 + 18df: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) + 18e6: 00 + 18e7: e8 04 fc ff ff call 14f0 + cmd = pipecmd(cmd, parsepipe(ps, es)); + 18ec: 89 74 24 04 mov %esi,0x4(%esp) + 18f0: 89 1c 24 mov %ebx,(%esp) + 18f3: e8 98 ff ff ff call 1890 + 18f8: 89 7d 08 mov %edi,0x8(%ebp) + 18fb: 89 45 0c mov %eax,0xc(%ebp) +} + 18fe: 83 c4 1c add $0x1c,%esp + 1901: 5b pop %ebx + 1902: 5e pop %esi + 1903: 5f pop %edi + 1904: 5d pop %ebp + cmd = pipecmd(cmd, parsepipe(ps, es)); + 1905: e9 f6 fa ff ff jmp 1400 + 190a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00001910 : +{ + 1910: 55 push %ebp + 1911: 89 e5 mov %esp,%ebp + 1913: 57 push %edi + 1914: 56 push %esi + 1915: 53 push %ebx + 1916: 83 ec 1c sub $0x1c,%esp + 1919: 8b 5d 08 mov 0x8(%ebp),%ebx + 191c: 8b 75 0c mov 0xc(%ebp),%esi + cmd = parsepipe(ps, es); + 191f: 89 1c 24 mov %ebx,(%esp) + 1922: 89 74 24 04 mov %esi,0x4(%esp) + 1926: e8 65 ff ff ff call 1890 + 192b: 89 c7 mov %eax,%edi + while(peek(ps, es, "&")){ + 192d: eb 27 jmp 1956 + 192f: 90 nop + gettoken(ps, es, 0, 0); + 1930: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) + 1937: 00 + 1938: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) + 193f: 00 + 1940: 89 74 24 04 mov %esi,0x4(%esp) + 1944: 89 1c 24 mov %ebx,(%esp) + 1947: e8 a4 fb ff ff call 14f0 + cmd = backcmd(cmd); + 194c: 89 3c 24 mov %edi,(%esp) + 194f: e8 4c fb ff ff call 14a0 + 1954: 89 c7 mov %eax,%edi + while(peek(ps, es, "&")){ + 1956: c7 44 24 08 56 23 00 movl $0x2356,0x8(%esp) + 195d: 00 + 195e: 89 74 24 04 mov %esi,0x4(%esp) + 1962: 89 1c 24 mov %ebx,(%esp) + 1965: e8 c6 fc ff ff call 1630 + 196a: 85 c0 test %eax,%eax + 196c: 75 c2 jne 1930 + if(peek(ps, es, ";")){ + 196e: c7 44 24 08 52 23 00 movl $0x2352,0x8(%esp) + 1975: 00 + 1976: 89 74 24 04 mov %esi,0x4(%esp) + 197a: 89 1c 24 mov %ebx,(%esp) + 197d: e8 ae fc ff ff call 1630 + 1982: 85 c0 test %eax,%eax + 1984: 75 0a jne 1990 +} + 1986: 83 c4 1c add $0x1c,%esp + 1989: 89 f8 mov %edi,%eax + 198b: 5b pop %ebx + 198c: 5e pop %esi + 198d: 5f pop %edi + 198e: 5d pop %ebp + 198f: c3 ret + gettoken(ps, es, 0, 0); + 1990: 89 74 24 04 mov %esi,0x4(%esp) + 1994: 89 1c 24 mov %ebx,(%esp) + 1997: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) + 199e: 00 + 199f: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) + 19a6: 00 + 19a7: e8 44 fb ff ff call 14f0 + cmd = listcmd(cmd, parseline(ps, es)); + 19ac: 89 74 24 04 mov %esi,0x4(%esp) + 19b0: 89 1c 24 mov %ebx,(%esp) + 19b3: e8 58 ff ff ff call 1910 + 19b8: 89 7d 08 mov %edi,0x8(%ebp) + 19bb: 89 45 0c mov %eax,0xc(%ebp) +} + 19be: 83 c4 1c add $0x1c,%esp + 19c1: 5b pop %ebx + 19c2: 5e pop %esi + 19c3: 5f pop %edi + 19c4: 5d pop %ebp + cmd = listcmd(cmd, parseline(ps, es)); + 19c5: e9 86 fa ff ff jmp 1450 + 19ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +000019d0 : +{ + 19d0: 55 push %ebp + 19d1: 89 e5 mov %esp,%ebp + 19d3: 57 push %edi + 19d4: 56 push %esi + 19d5: 53 push %ebx + 19d6: 83 ec 1c sub $0x1c,%esp + 19d9: 8b 5d 08 mov 0x8(%ebp),%ebx + 19dc: 8b 75 0c mov 0xc(%ebp),%esi + if(!peek(ps, es, "(")) + 19df: c7 44 24 08 38 23 00 movl $0x2338,0x8(%esp) + 19e6: 00 + 19e7: 89 1c 24 mov %ebx,(%esp) + 19ea: 89 74 24 04 mov %esi,0x4(%esp) + 19ee: e8 3d fc ff ff call 1630 + 19f3: 85 c0 test %eax,%eax + 19f5: 74 76 je 1a6d + gettoken(ps, es, 0, 0); + 19f7: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) + 19fe: 00 + 19ff: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) + 1a06: 00 + 1a07: 89 74 24 04 mov %esi,0x4(%esp) + 1a0b: 89 1c 24 mov %ebx,(%esp) + 1a0e: e8 dd fa ff ff call 14f0 + cmd = parseline(ps, es); + 1a13: 89 74 24 04 mov %esi,0x4(%esp) + 1a17: 89 1c 24 mov %ebx,(%esp) + 1a1a: e8 f1 fe ff ff call 1910 + if(!peek(ps, es, ")")) + 1a1f: c7 44 24 08 74 23 00 movl $0x2374,0x8(%esp) + 1a26: 00 + 1a27: 89 74 24 04 mov %esi,0x4(%esp) + 1a2b: 89 1c 24 mov %ebx,(%esp) + cmd = parseline(ps, es); + 1a2e: 89 c7 mov %eax,%edi + if(!peek(ps, es, ")")) + 1a30: e8 fb fb ff ff call 1630 + 1a35: 85 c0 test %eax,%eax + 1a37: 74 40 je 1a79 + gettoken(ps, es, 0, 0); + 1a39: 89 74 24 04 mov %esi,0x4(%esp) + 1a3d: 89 1c 24 mov %ebx,(%esp) + 1a40: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) + 1a47: 00 + 1a48: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) + 1a4f: 00 + 1a50: e8 9b fa ff ff call 14f0 + cmd = parseredirs(cmd, ps, es); + 1a55: 89 74 24 08 mov %esi,0x8(%esp) + 1a59: 89 5c 24 04 mov %ebx,0x4(%esp) + 1a5d: 89 3c 24 mov %edi,(%esp) + 1a60: e8 2b fc ff ff call 1690 +} + 1a65: 83 c4 1c add $0x1c,%esp + 1a68: 5b pop %ebx + 1a69: 5e pop %esi + 1a6a: 5f pop %edi + 1a6b: 5d pop %ebp + 1a6c: c3 ret + panic("parseblock"); + 1a6d: c7 04 24 58 23 00 00 movl $0x2358,(%esp) + 1a74: e8 e7 f6 ff ff call 1160 + panic("syntax - missing )"); + 1a79: c7 04 24 63 23 00 00 movl $0x2363,(%esp) + 1a80: e8 db f6 ff ff call 1160 + 1a85: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1a89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001a90 : + +// NUL-terminate all the counted strings. +struct cmd* +nulterminate(struct cmd *cmd) +{ + 1a90: 55 push %ebp + 1a91: 89 e5 mov %esp,%ebp + 1a93: 53 push %ebx + 1a94: 83 ec 14 sub $0x14,%esp + 1a97: 8b 5d 08 mov 0x8(%ebp),%ebx + struct execcmd *ecmd; + struct listcmd *lcmd; + struct pipecmd *pcmd; + struct redircmd *rcmd; + + if(cmd == 0) + 1a9a: 85 db test %ebx,%ebx + 1a9c: 0f 84 8e 00 00 00 je 1b30 + return 0; + + switch(cmd->type){ + 1aa2: 83 3b 05 cmpl $0x5,(%ebx) + 1aa5: 77 49 ja 1af0 + 1aa7: 8b 03 mov (%ebx),%eax + 1aa9: ff 24 85 b4 23 00 00 jmp *0x23b4(,%eax,4) + nulterminate(pcmd->right); + break; + + case LIST: + lcmd = (struct listcmd*)cmd; + nulterminate(lcmd->left); + 1ab0: 8b 43 04 mov 0x4(%ebx),%eax + 1ab3: 89 04 24 mov %eax,(%esp) + 1ab6: e8 d5 ff ff ff call 1a90 + nulterminate(lcmd->right); + 1abb: 8b 43 08 mov 0x8(%ebx),%eax + 1abe: 89 04 24 mov %eax,(%esp) + 1ac1: e8 ca ff ff ff call 1a90 + break; + 1ac6: 89 d8 mov %ebx,%eax + bcmd = (struct backcmd*)cmd; + nulterminate(bcmd->cmd); + break; + } + return cmd; +} + 1ac8: 83 c4 14 add $0x14,%esp + 1acb: 5b pop %ebx + 1acc: 5d pop %ebp + 1acd: c3 ret + 1ace: 66 90 xchg %ax,%ax + for(i=0; ecmd->argv[i]; i++) + 1ad0: 8b 4b 04 mov 0x4(%ebx),%ecx + 1ad3: 89 d8 mov %ebx,%eax + 1ad5: 85 c9 test %ecx,%ecx + 1ad7: 74 17 je 1af0 + 1ad9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + *ecmd->eargv[i] = 0; + 1ae0: 8b 50 2c mov 0x2c(%eax),%edx + 1ae3: 83 c0 04 add $0x4,%eax + 1ae6: c6 02 00 movb $0x0,(%edx) + for(i=0; ecmd->argv[i]; i++) + 1ae9: 8b 50 04 mov 0x4(%eax),%edx + 1aec: 85 d2 test %edx,%edx + 1aee: 75 f0 jne 1ae0 +} + 1af0: 83 c4 14 add $0x14,%esp + switch(cmd->type){ + 1af3: 89 d8 mov %ebx,%eax +} + 1af5: 5b pop %ebx + 1af6: 5d pop %ebp + 1af7: c3 ret + nulterminate(bcmd->cmd); + 1af8: 8b 43 04 mov 0x4(%ebx),%eax + 1afb: 89 04 24 mov %eax,(%esp) + 1afe: e8 8d ff ff ff call 1a90 +} + 1b03: 83 c4 14 add $0x14,%esp + break; + 1b06: 89 d8 mov %ebx,%eax +} + 1b08: 5b pop %ebx + 1b09: 5d pop %ebp + 1b0a: c3 ret + 1b0b: 90 nop + 1b0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + nulterminate(rcmd->cmd); + 1b10: 8b 43 04 mov 0x4(%ebx),%eax + 1b13: 89 04 24 mov %eax,(%esp) + 1b16: e8 75 ff ff ff call 1a90 + *rcmd->efile = 0; + 1b1b: 8b 43 0c mov 0xc(%ebx),%eax + 1b1e: c6 00 00 movb $0x0,(%eax) +} + 1b21: 83 c4 14 add $0x14,%esp + break; + 1b24: 89 d8 mov %ebx,%eax +} + 1b26: 5b pop %ebx + 1b27: 5d pop %ebp + 1b28: c3 ret + 1b29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + return 0; + 1b30: 31 c0 xor %eax,%eax + 1b32: eb 94 jmp 1ac8 + 1b34: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1b3a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001b40 : +{ + 1b40: 55 push %ebp + 1b41: 89 e5 mov %esp,%ebp + 1b43: 56 push %esi + 1b44: 53 push %ebx + 1b45: 83 ec 10 sub $0x10,%esp + es = s + strlen(s); + 1b48: 8b 5d 08 mov 0x8(%ebp),%ebx + 1b4b: 89 1c 24 mov %ebx,(%esp) + 1b4e: e8 ed 00 00 00 call 1c40 + 1b53: 01 c3 add %eax,%ebx + cmd = parseline(&s, es); + 1b55: 8d 45 08 lea 0x8(%ebp),%eax + 1b58: 89 5c 24 04 mov %ebx,0x4(%esp) + 1b5c: 89 04 24 mov %eax,(%esp) + 1b5f: e8 ac fd ff ff call 1910 + peek(&s, es, ""); + 1b64: c7 44 24 08 02 23 00 movl $0x2302,0x8(%esp) + 1b6b: 00 + 1b6c: 89 5c 24 04 mov %ebx,0x4(%esp) + cmd = parseline(&s, es); + 1b70: 89 c6 mov %eax,%esi + peek(&s, es, ""); + 1b72: 8d 45 08 lea 0x8(%ebp),%eax + 1b75: 89 04 24 mov %eax,(%esp) + 1b78: e8 b3 fa ff ff call 1630 + if(s != es){ + 1b7d: 8b 45 08 mov 0x8(%ebp),%eax + 1b80: 39 d8 cmp %ebx,%eax + 1b82: 75 11 jne 1b95 + nulterminate(cmd); + 1b84: 89 34 24 mov %esi,(%esp) + 1b87: e8 04 ff ff ff call 1a90 +} + 1b8c: 83 c4 10 add $0x10,%esp + 1b8f: 89 f0 mov %esi,%eax + 1b91: 5b pop %ebx + 1b92: 5e pop %esi + 1b93: 5d pop %ebp + 1b94: c3 ret + printf(2, "leftovers: %s\n", s); + 1b95: 89 44 24 08 mov %eax,0x8(%esp) + 1b99: c7 44 24 04 76 23 00 movl $0x2376,0x4(%esp) + 1ba0: 00 + 1ba1: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 1ba8: e8 93 03 00 00 call 1f40 + panic("syntax"); + 1bad: c7 04 24 3a 23 00 00 movl $0x233a,(%esp) + 1bb4: e8 a7 f5 ff ff call 1160 + 1bb9: 66 90 xchg %ax,%ax + 1bbb: 66 90 xchg %ax,%ax + 1bbd: 66 90 xchg %ax,%ax + 1bbf: 90 nop + +00001bc0 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1bc0: 55 push %ebp + 1bc1: 89 e5 mov %esp,%ebp + 1bc3: 8b 45 08 mov 0x8(%ebp),%eax + 1bc6: 8b 4d 0c mov 0xc(%ebp),%ecx + 1bc9: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 1bca: 89 c2 mov %eax,%edx + 1bcc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1bd0: 83 c1 01 add $0x1,%ecx + 1bd3: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1bd7: 83 c2 01 add $0x1,%edx + 1bda: 84 db test %bl,%bl + 1bdc: 88 5a ff mov %bl,-0x1(%edx) + 1bdf: 75 ef jne 1bd0 + ; + return os; +} + 1be1: 5b pop %ebx + 1be2: 5d pop %ebp + 1be3: c3 ret + 1be4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1bea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001bf0 : + +int +strcmp(const char *p, const char *q) +{ + 1bf0: 55 push %ebp + 1bf1: 89 e5 mov %esp,%ebp + 1bf3: 8b 55 08 mov 0x8(%ebp),%edx + 1bf6: 53 push %ebx + 1bf7: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 1bfa: 0f b6 02 movzbl (%edx),%eax + 1bfd: 84 c0 test %al,%al + 1bff: 74 2d je 1c2e + 1c01: 0f b6 19 movzbl (%ecx),%ebx + 1c04: 38 d8 cmp %bl,%al + 1c06: 74 0e je 1c16 + 1c08: eb 2b jmp 1c35 + 1c0a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1c10: 38 c8 cmp %cl,%al + 1c12: 75 15 jne 1c29 + p++, q++; + 1c14: 89 d9 mov %ebx,%ecx + 1c16: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 1c19: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 1c1c: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 1c1f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 1c23: 84 c0 test %al,%al + 1c25: 75 e9 jne 1c10 + 1c27: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 1c29: 29 c8 sub %ecx,%eax +} + 1c2b: 5b pop %ebx + 1c2c: 5d pop %ebp + 1c2d: c3 ret + 1c2e: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 1c31: 31 c0 xor %eax,%eax + 1c33: eb f4 jmp 1c29 + 1c35: 0f b6 cb movzbl %bl,%ecx + 1c38: eb ef jmp 1c29 + 1c3a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00001c40 : + +uint +strlen(char *s) +{ + 1c40: 55 push %ebp + 1c41: 89 e5 mov %esp,%ebp + 1c43: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 1c46: 80 39 00 cmpb $0x0,(%ecx) + 1c49: 74 12 je 1c5d + 1c4b: 31 d2 xor %edx,%edx + 1c4d: 8d 76 00 lea 0x0(%esi),%esi + 1c50: 83 c2 01 add $0x1,%edx + 1c53: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 1c57: 89 d0 mov %edx,%eax + 1c59: 75 f5 jne 1c50 + ; + return n; +} + 1c5b: 5d pop %ebp + 1c5c: c3 ret + for(n = 0; s[n]; n++) + 1c5d: 31 c0 xor %eax,%eax +} + 1c5f: 5d pop %ebp + 1c60: c3 ret + 1c61: eb 0d jmp 1c70 + 1c63: 90 nop + 1c64: 90 nop + 1c65: 90 nop + 1c66: 90 nop + 1c67: 90 nop + 1c68: 90 nop + 1c69: 90 nop + 1c6a: 90 nop + 1c6b: 90 nop + 1c6c: 90 nop + 1c6d: 90 nop + 1c6e: 90 nop + 1c6f: 90 nop + +00001c70 : + +void* +memset(void *dst, int c, uint n) +{ + 1c70: 55 push %ebp + 1c71: 89 e5 mov %esp,%ebp + 1c73: 8b 55 08 mov 0x8(%ebp),%edx + 1c76: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 1c77: 8b 4d 10 mov 0x10(%ebp),%ecx + 1c7a: 8b 45 0c mov 0xc(%ebp),%eax + 1c7d: 89 d7 mov %edx,%edi + 1c7f: fc cld + 1c80: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1c82: 89 d0 mov %edx,%eax + 1c84: 5f pop %edi + 1c85: 5d pop %ebp + 1c86: c3 ret + 1c87: 89 f6 mov %esi,%esi + 1c89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001c90 : + +char* +strchr(const char *s, char c) +{ + 1c90: 55 push %ebp + 1c91: 89 e5 mov %esp,%ebp + 1c93: 8b 45 08 mov 0x8(%ebp),%eax + 1c96: 53 push %ebx + 1c97: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 1c9a: 0f b6 18 movzbl (%eax),%ebx + 1c9d: 84 db test %bl,%bl + 1c9f: 74 1d je 1cbe + if(*s == c) + 1ca1: 38 d3 cmp %dl,%bl + 1ca3: 89 d1 mov %edx,%ecx + 1ca5: 75 0d jne 1cb4 + 1ca7: eb 17 jmp 1cc0 + 1ca9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1cb0: 38 ca cmp %cl,%dl + 1cb2: 74 0c je 1cc0 + for(; *s; s++) + 1cb4: 83 c0 01 add $0x1,%eax + 1cb7: 0f b6 10 movzbl (%eax),%edx + 1cba: 84 d2 test %dl,%dl + 1cbc: 75 f2 jne 1cb0 + return (char*)s; + return 0; + 1cbe: 31 c0 xor %eax,%eax +} + 1cc0: 5b pop %ebx + 1cc1: 5d pop %ebp + 1cc2: c3 ret + 1cc3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1cc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001cd0 : + +char* +gets(char *buf, int max) +{ + 1cd0: 55 push %ebp + 1cd1: 89 e5 mov %esp,%ebp + 1cd3: 57 push %edi + 1cd4: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1cd5: 31 f6 xor %esi,%esi +{ + 1cd7: 53 push %ebx + 1cd8: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 1cdb: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 1cde: eb 31 jmp 1d11 + cc = read(0, &c, 1); + 1ce0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1ce7: 00 + 1ce8: 89 7c 24 04 mov %edi,0x4(%esp) + 1cec: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1cf3: e8 02 01 00 00 call 1dfa + if(cc < 1) + 1cf8: 85 c0 test %eax,%eax + 1cfa: 7e 1d jle 1d19 + break; + buf[i++] = c; + 1cfc: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 1d00: 89 de mov %ebx,%esi + buf[i++] = c; + 1d02: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 1d05: 3c 0d cmp $0xd,%al + buf[i++] = c; + 1d07: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 1d0b: 74 0c je 1d19 + 1d0d: 3c 0a cmp $0xa,%al + 1d0f: 74 08 je 1d19 + for(i=0; i+1 < max; ){ + 1d11: 8d 5e 01 lea 0x1(%esi),%ebx + 1d14: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1d17: 7c c7 jl 1ce0 + break; + } + buf[i] = '\0'; + 1d19: 8b 45 08 mov 0x8(%ebp),%eax + 1d1c: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1d20: 83 c4 2c add $0x2c,%esp + 1d23: 5b pop %ebx + 1d24: 5e pop %esi + 1d25: 5f pop %edi + 1d26: 5d pop %ebp + 1d27: c3 ret + 1d28: 90 nop + 1d29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001d30 : + +int +stat(char *n, struct stat *st) +{ + 1d30: 55 push %ebp + 1d31: 89 e5 mov %esp,%ebp + 1d33: 56 push %esi + 1d34: 53 push %ebx + 1d35: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 1d38: 8b 45 08 mov 0x8(%ebp),%eax + 1d3b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1d42: 00 + 1d43: 89 04 24 mov %eax,(%esp) + 1d46: e8 d7 00 00 00 call 1e22 + if(fd < 0) + 1d4b: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 1d4d: 89 c3 mov %eax,%ebx + if(fd < 0) + 1d4f: 78 27 js 1d78 + return -1; + r = fstat(fd, st); + 1d51: 8b 45 0c mov 0xc(%ebp),%eax + 1d54: 89 1c 24 mov %ebx,(%esp) + 1d57: 89 44 24 04 mov %eax,0x4(%esp) + 1d5b: e8 da 00 00 00 call 1e3a + close(fd); + 1d60: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 1d63: 89 c6 mov %eax,%esi + close(fd); + 1d65: e8 a0 00 00 00 call 1e0a + return r; + 1d6a: 89 f0 mov %esi,%eax +} + 1d6c: 83 c4 10 add $0x10,%esp + 1d6f: 5b pop %ebx + 1d70: 5e pop %esi + 1d71: 5d pop %ebp + 1d72: c3 ret + 1d73: 90 nop + 1d74: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 1d78: b8 ff ff ff ff mov $0xffffffff,%eax + 1d7d: eb ed jmp 1d6c + 1d7f: 90 nop + +00001d80 : + +int +atoi(const char *s) +{ + 1d80: 55 push %ebp + 1d81: 89 e5 mov %esp,%ebp + 1d83: 8b 4d 08 mov 0x8(%ebp),%ecx + 1d86: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 1d87: 0f be 11 movsbl (%ecx),%edx + 1d8a: 8d 42 d0 lea -0x30(%edx),%eax + 1d8d: 3c 09 cmp $0x9,%al + n = 0; + 1d8f: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 1d94: 77 17 ja 1dad + 1d96: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 1d98: 83 c1 01 add $0x1,%ecx + 1d9b: 8d 04 80 lea (%eax,%eax,4),%eax + 1d9e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1da2: 0f be 11 movsbl (%ecx),%edx + 1da5: 8d 5a d0 lea -0x30(%edx),%ebx + 1da8: 80 fb 09 cmp $0x9,%bl + 1dab: 76 eb jbe 1d98 + return n; +} + 1dad: 5b pop %ebx + 1dae: 5d pop %ebp + 1daf: c3 ret + +00001db0 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1db0: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1db1: 31 d2 xor %edx,%edx +{ + 1db3: 89 e5 mov %esp,%ebp + 1db5: 56 push %esi + 1db6: 8b 45 08 mov 0x8(%ebp),%eax + 1db9: 53 push %ebx + 1dba: 8b 5d 10 mov 0x10(%ebp),%ebx + 1dbd: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1dc0: 85 db test %ebx,%ebx + 1dc2: 7e 12 jle 1dd6 + 1dc4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1dc8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 1dcc: 88 0c 10 mov %cl,(%eax,%edx,1) + 1dcf: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1dd2: 39 da cmp %ebx,%edx + 1dd4: 75 f2 jne 1dc8 + return vdst; +} + 1dd6: 5b pop %ebx + 1dd7: 5e pop %esi + 1dd8: 5d pop %ebp + 1dd9: c3 ret + +00001dda : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 1dda: b8 01 00 00 00 mov $0x1,%eax + 1ddf: cd 40 int $0x40 + 1de1: c3 ret + +00001de2 : +SYSCALL(exit) + 1de2: b8 02 00 00 00 mov $0x2,%eax + 1de7: cd 40 int $0x40 + 1de9: c3 ret + +00001dea : +SYSCALL(wait) + 1dea: b8 03 00 00 00 mov $0x3,%eax + 1def: cd 40 int $0x40 + 1df1: c3 ret + +00001df2 : +SYSCALL(pipe) + 1df2: b8 04 00 00 00 mov $0x4,%eax + 1df7: cd 40 int $0x40 + 1df9: c3 ret + +00001dfa : +SYSCALL(read) + 1dfa: b8 05 00 00 00 mov $0x5,%eax + 1dff: cd 40 int $0x40 + 1e01: c3 ret + +00001e02 : +SYSCALL(write) + 1e02: b8 10 00 00 00 mov $0x10,%eax + 1e07: cd 40 int $0x40 + 1e09: c3 ret + +00001e0a : +SYSCALL(close) + 1e0a: b8 15 00 00 00 mov $0x15,%eax + 1e0f: cd 40 int $0x40 + 1e11: c3 ret + +00001e12 : +SYSCALL(kill) + 1e12: b8 06 00 00 00 mov $0x6,%eax + 1e17: cd 40 int $0x40 + 1e19: c3 ret + +00001e1a : +SYSCALL(exec) + 1e1a: b8 07 00 00 00 mov $0x7,%eax + 1e1f: cd 40 int $0x40 + 1e21: c3 ret + +00001e22 : +SYSCALL(open) + 1e22: b8 0f 00 00 00 mov $0xf,%eax + 1e27: cd 40 int $0x40 + 1e29: c3 ret + +00001e2a : +SYSCALL(mknod) + 1e2a: b8 11 00 00 00 mov $0x11,%eax + 1e2f: cd 40 int $0x40 + 1e31: c3 ret + +00001e32 : +SYSCALL(unlink) + 1e32: b8 12 00 00 00 mov $0x12,%eax + 1e37: cd 40 int $0x40 + 1e39: c3 ret + +00001e3a : +SYSCALL(fstat) + 1e3a: b8 08 00 00 00 mov $0x8,%eax + 1e3f: cd 40 int $0x40 + 1e41: c3 ret + +00001e42 : +SYSCALL(link) + 1e42: b8 13 00 00 00 mov $0x13,%eax + 1e47: cd 40 int $0x40 + 1e49: c3 ret + +00001e4a : +SYSCALL(mkdir) + 1e4a: b8 14 00 00 00 mov $0x14,%eax + 1e4f: cd 40 int $0x40 + 1e51: c3 ret + +00001e52 : +SYSCALL(chdir) + 1e52: b8 09 00 00 00 mov $0x9,%eax + 1e57: cd 40 int $0x40 + 1e59: c3 ret + +00001e5a : +SYSCALL(dup) + 1e5a: b8 0a 00 00 00 mov $0xa,%eax + 1e5f: cd 40 int $0x40 + 1e61: c3 ret + +00001e62 : +SYSCALL(getpid) + 1e62: b8 0b 00 00 00 mov $0xb,%eax + 1e67: cd 40 int $0x40 + 1e69: c3 ret + +00001e6a : +SYSCALL(sbrk) + 1e6a: b8 0c 00 00 00 mov $0xc,%eax + 1e6f: cd 40 int $0x40 + 1e71: c3 ret + +00001e72 : +SYSCALL(sleep) + 1e72: b8 0d 00 00 00 mov $0xd,%eax + 1e77: cd 40 int $0x40 + 1e79: c3 ret + +00001e7a : +SYSCALL(uptime) + 1e7a: b8 0e 00 00 00 mov $0xe,%eax + 1e7f: cd 40 int $0x40 + 1e81: c3 ret + +00001e82 : +SYSCALL(shm_open) + 1e82: b8 16 00 00 00 mov $0x16,%eax + 1e87: cd 40 int $0x40 + 1e89: c3 ret + +00001e8a : +SYSCALL(shm_close) + 1e8a: b8 17 00 00 00 mov $0x17,%eax + 1e8f: cd 40 int $0x40 + 1e91: c3 ret + 1e92: 66 90 xchg %ax,%ax + 1e94: 66 90 xchg %ax,%ax + 1e96: 66 90 xchg %ax,%ax + 1e98: 66 90 xchg %ax,%ax + 1e9a: 66 90 xchg %ax,%ax + 1e9c: 66 90 xchg %ax,%ax + 1e9e: 66 90 xchg %ax,%ax + +00001ea0 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 1ea0: 55 push %ebp + 1ea1: 89 e5 mov %esp,%ebp + 1ea3: 57 push %edi + 1ea4: 56 push %esi + 1ea5: 89 c6 mov %eax,%esi + 1ea7: 53 push %ebx + 1ea8: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 1eab: 8b 5d 08 mov 0x8(%ebp),%ebx + 1eae: 85 db test %ebx,%ebx + 1eb0: 74 09 je 1ebb + 1eb2: 89 d0 mov %edx,%eax + 1eb4: c1 e8 1f shr $0x1f,%eax + 1eb7: 84 c0 test %al,%al + 1eb9: 75 75 jne 1f30 + neg = 1; + x = -xx; + } else { + x = xx; + 1ebb: 89 d0 mov %edx,%eax + neg = 0; + 1ebd: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1ec4: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1ec7: 31 ff xor %edi,%edi + 1ec9: 89 ce mov %ecx,%esi + 1ecb: 8d 5d d7 lea -0x29(%ebp),%ebx + 1ece: eb 02 jmp 1ed2 + do{ + buf[i++] = digits[x % base]; + 1ed0: 89 cf mov %ecx,%edi + 1ed2: 31 d2 xor %edx,%edx + 1ed4: f7 f6 div %esi + 1ed6: 8d 4f 01 lea 0x1(%edi),%ecx + 1ed9: 0f b6 92 d3 23 00 00 movzbl 0x23d3(%edx),%edx + }while((x /= base) != 0); + 1ee0: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 1ee2: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 1ee5: 75 e9 jne 1ed0 + if(neg) + 1ee7: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 1eea: 89 c8 mov %ecx,%eax + 1eec: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 1eef: 85 d2 test %edx,%edx + 1ef1: 74 08 je 1efb + buf[i++] = '-'; + 1ef3: 8d 4f 02 lea 0x2(%edi),%ecx + 1ef6: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 1efb: 8d 79 ff lea -0x1(%ecx),%edi + 1efe: 66 90 xchg %ax,%ax + 1f00: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 1f05: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 1f08: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1f0f: 00 + 1f10: 89 5c 24 04 mov %ebx,0x4(%esp) + 1f14: 89 34 24 mov %esi,(%esp) + 1f17: 88 45 d7 mov %al,-0x29(%ebp) + 1f1a: e8 e3 fe ff ff call 1e02 + while(--i >= 0) + 1f1f: 83 ff ff cmp $0xffffffff,%edi + 1f22: 75 dc jne 1f00 + putc(fd, buf[i]); +} + 1f24: 83 c4 4c add $0x4c,%esp + 1f27: 5b pop %ebx + 1f28: 5e pop %esi + 1f29: 5f pop %edi + 1f2a: 5d pop %ebp + 1f2b: c3 ret + 1f2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 1f30: 89 d0 mov %edx,%eax + 1f32: f7 d8 neg %eax + neg = 1; + 1f34: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 1f3b: eb 87 jmp 1ec4 + 1f3d: 8d 76 00 lea 0x0(%esi),%esi + +00001f40 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 1f40: 55 push %ebp + 1f41: 89 e5 mov %esp,%ebp + 1f43: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 1f44: 31 ff xor %edi,%edi +{ + 1f46: 56 push %esi + 1f47: 53 push %ebx + 1f48: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 1f4b: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 1f4e: 8d 45 10 lea 0x10(%ebp),%eax +{ + 1f51: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 1f54: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 1f57: 0f b6 13 movzbl (%ebx),%edx + 1f5a: 83 c3 01 add $0x1,%ebx + 1f5d: 84 d2 test %dl,%dl + 1f5f: 75 39 jne 1f9a + 1f61: e9 c2 00 00 00 jmp 2028 + 1f66: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 1f68: 83 fa 25 cmp $0x25,%edx + 1f6b: 0f 84 bf 00 00 00 je 2030 + write(fd, &c, 1); + 1f71: 8d 45 e2 lea -0x1e(%ebp),%eax + 1f74: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1f7b: 00 + 1f7c: 89 44 24 04 mov %eax,0x4(%esp) + 1f80: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 1f83: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 1f86: e8 77 fe ff ff call 1e02 + 1f8b: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 1f8e: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 1f92: 84 d2 test %dl,%dl + 1f94: 0f 84 8e 00 00 00 je 2028 + if(state == 0){ + 1f9a: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 1f9c: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 1f9f: 74 c7 je 1f68 + } + } else if(state == '%'){ + 1fa1: 83 ff 25 cmp $0x25,%edi + 1fa4: 75 e5 jne 1f8b + if(c == 'd'){ + 1fa6: 83 fa 64 cmp $0x64,%edx + 1fa9: 0f 84 31 01 00 00 je 20e0 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 1faf: 25 f7 00 00 00 and $0xf7,%eax + 1fb4: 83 f8 70 cmp $0x70,%eax + 1fb7: 0f 84 83 00 00 00 je 2040 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 1fbd: 83 fa 73 cmp $0x73,%edx + 1fc0: 0f 84 a2 00 00 00 je 2068 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1fc6: 83 fa 63 cmp $0x63,%edx + 1fc9: 0f 84 35 01 00 00 je 2104 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 1fcf: 83 fa 25 cmp $0x25,%edx + 1fd2: 0f 84 e0 00 00 00 je 20b8 + write(fd, &c, 1); + 1fd8: 8d 45 e6 lea -0x1a(%ebp),%eax + 1fdb: 83 c3 01 add $0x1,%ebx + 1fde: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1fe5: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 1fe6: 31 ff xor %edi,%edi + write(fd, &c, 1); + 1fe8: 89 44 24 04 mov %eax,0x4(%esp) + 1fec: 89 34 24 mov %esi,(%esp) + 1fef: 89 55 d0 mov %edx,-0x30(%ebp) + 1ff2: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 1ff6: e8 07 fe ff ff call 1e02 + putc(fd, c); + 1ffb: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 1ffe: 8d 45 e7 lea -0x19(%ebp),%eax + 2001: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 2008: 00 + 2009: 89 44 24 04 mov %eax,0x4(%esp) + 200d: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 2010: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 2013: e8 ea fd ff ff call 1e02 + for(i = 0; fmt[i]; i++){ + 2018: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 201c: 84 d2 test %dl,%dl + 201e: 0f 85 76 ff ff ff jne 1f9a + 2024: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 2028: 83 c4 3c add $0x3c,%esp + 202b: 5b pop %ebx + 202c: 5e pop %esi + 202d: 5f pop %edi + 202e: 5d pop %ebp + 202f: c3 ret + state = '%'; + 2030: bf 25 00 00 00 mov $0x25,%edi + 2035: e9 51 ff ff ff jmp 1f8b + 203a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 2040: 8b 45 d4 mov -0x2c(%ebp),%eax + 2043: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 2048: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 204a: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 2051: 8b 10 mov (%eax),%edx + 2053: 89 f0 mov %esi,%eax + 2055: e8 46 fe ff ff call 1ea0 + ap++; + 205a: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 205e: e9 28 ff ff ff jmp 1f8b + 2063: 90 nop + 2064: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 2068: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 206b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 206f: 8b 38 mov (%eax),%edi + s = "(null)"; + 2071: b8 cc 23 00 00 mov $0x23cc,%eax + 2076: 85 ff test %edi,%edi + 2078: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 207b: 0f b6 07 movzbl (%edi),%eax + 207e: 84 c0 test %al,%al + 2080: 74 2a je 20ac + 2082: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 2088: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 208b: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 208e: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 2091: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 2098: 00 + 2099: 89 44 24 04 mov %eax,0x4(%esp) + 209d: 89 34 24 mov %esi,(%esp) + 20a0: e8 5d fd ff ff call 1e02 + while(*s != 0){ + 20a5: 0f b6 07 movzbl (%edi),%eax + 20a8: 84 c0 test %al,%al + 20aa: 75 dc jne 2088 + state = 0; + 20ac: 31 ff xor %edi,%edi + 20ae: e9 d8 fe ff ff jmp 1f8b + 20b3: 90 nop + 20b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 20b8: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 20bb: 31 ff xor %edi,%edi + write(fd, &c, 1); + 20bd: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 20c4: 00 + 20c5: 89 44 24 04 mov %eax,0x4(%esp) + 20c9: 89 34 24 mov %esi,(%esp) + 20cc: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 20d0: e8 2d fd ff ff call 1e02 + 20d5: e9 b1 fe ff ff jmp 1f8b + 20da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 20e0: 8b 45 d4 mov -0x2c(%ebp),%eax + 20e3: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 20e8: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 20eb: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 20f2: 8b 10 mov (%eax),%edx + 20f4: 89 f0 mov %esi,%eax + 20f6: e8 a5 fd ff ff call 1ea0 + ap++; + 20fb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 20ff: e9 87 fe ff ff jmp 1f8b + putc(fd, *ap); + 2104: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 2107: 31 ff xor %edi,%edi + putc(fd, *ap); + 2109: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 210b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 2112: 00 + 2113: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 2116: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 2119: 8d 45 e4 lea -0x1c(%ebp),%eax + 211c: 89 44 24 04 mov %eax,0x4(%esp) + 2120: e8 dd fc ff ff call 1e02 + ap++; + 2125: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 2129: e9 5d fe ff ff jmp 1f8b + 212e: 66 90 xchg %ax,%ax + +00002130 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 2130: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 2131: a1 24 2a 00 00 mov 0x2a24,%eax +{ + 2136: 89 e5 mov %esp,%ebp + 2138: 57 push %edi + 2139: 56 push %esi + 213a: 53 push %ebx + 213b: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 213e: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 2140: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 2143: 39 d0 cmp %edx,%eax + 2145: 72 11 jb 2158 + 2147: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 2148: 39 c8 cmp %ecx,%eax + 214a: 72 04 jb 2150 + 214c: 39 ca cmp %ecx,%edx + 214e: 72 10 jb 2160 + 2150: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 2152: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 2154: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 2156: 73 f0 jae 2148 + 2158: 39 ca cmp %ecx,%edx + 215a: 72 04 jb 2160 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 215c: 39 c8 cmp %ecx,%eax + 215e: 72 f0 jb 2150 + break; + if(bp + bp->s.size == p->s.ptr){ + 2160: 8b 73 fc mov -0x4(%ebx),%esi + 2163: 8d 3c f2 lea (%edx,%esi,8),%edi + 2166: 39 cf cmp %ecx,%edi + 2168: 74 1e je 2188 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 216a: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 216d: 8b 48 04 mov 0x4(%eax),%ecx + 2170: 8d 34 c8 lea (%eax,%ecx,8),%esi + 2173: 39 f2 cmp %esi,%edx + 2175: 74 28 je 219f + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 2177: 89 10 mov %edx,(%eax) + freep = p; + 2179: a3 24 2a 00 00 mov %eax,0x2a24 +} + 217e: 5b pop %ebx + 217f: 5e pop %esi + 2180: 5f pop %edi + 2181: 5d pop %ebp + 2182: c3 ret + 2183: 90 nop + 2184: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 2188: 03 71 04 add 0x4(%ecx),%esi + 218b: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 218e: 8b 08 mov (%eax),%ecx + 2190: 8b 09 mov (%ecx),%ecx + 2192: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 2195: 8b 48 04 mov 0x4(%eax),%ecx + 2198: 8d 34 c8 lea (%eax,%ecx,8),%esi + 219b: 39 f2 cmp %esi,%edx + 219d: 75 d8 jne 2177 + p->s.size += bp->s.size; + 219f: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 21a2: a3 24 2a 00 00 mov %eax,0x2a24 + p->s.size += bp->s.size; + 21a7: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 21aa: 8b 53 f8 mov -0x8(%ebx),%edx + 21ad: 89 10 mov %edx,(%eax) +} + 21af: 5b pop %ebx + 21b0: 5e pop %esi + 21b1: 5f pop %edi + 21b2: 5d pop %ebp + 21b3: c3 ret + 21b4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 21ba: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +000021c0 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 21c0: 55 push %ebp + 21c1: 89 e5 mov %esp,%ebp + 21c3: 57 push %edi + 21c4: 56 push %esi + 21c5: 53 push %ebx + 21c6: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 21c9: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 21cc: 8b 1d 24 2a 00 00 mov 0x2a24,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 21d2: 8d 48 07 lea 0x7(%eax),%ecx + 21d5: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 21d8: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 21da: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 21dd: 0f 84 9b 00 00 00 je 227e + 21e3: 8b 13 mov (%ebx),%edx + 21e5: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 21e8: 39 fe cmp %edi,%esi + 21ea: 76 64 jbe 2250 + 21ec: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 21f3: bb 00 80 00 00 mov $0x8000,%ebx + 21f8: 89 45 e4 mov %eax,-0x1c(%ebp) + 21fb: eb 0e jmp 220b + 21fd: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 2200: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 2202: 8b 78 04 mov 0x4(%eax),%edi + 2205: 39 fe cmp %edi,%esi + 2207: 76 4f jbe 2258 + 2209: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 220b: 3b 15 24 2a 00 00 cmp 0x2a24,%edx + 2211: 75 ed jne 2200 + if(nu < 4096) + 2213: 8b 45 e4 mov -0x1c(%ebp),%eax + 2216: 81 fe 00 10 00 00 cmp $0x1000,%esi + 221c: bf 00 10 00 00 mov $0x1000,%edi + 2221: 0f 43 fe cmovae %esi,%edi + 2224: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 2227: 89 04 24 mov %eax,(%esp) + 222a: e8 3b fc ff ff call 1e6a + if(p == (char*)-1) + 222f: 83 f8 ff cmp $0xffffffff,%eax + 2232: 74 18 je 224c + hp->s.size = nu; + 2234: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 2237: 83 c0 08 add $0x8,%eax + 223a: 89 04 24 mov %eax,(%esp) + 223d: e8 ee fe ff ff call 2130 + return freep; + 2242: 8b 15 24 2a 00 00 mov 0x2a24,%edx + if((p = morecore(nunits)) == 0) + 2248: 85 d2 test %edx,%edx + 224a: 75 b4 jne 2200 + return 0; + 224c: 31 c0 xor %eax,%eax + 224e: eb 20 jmp 2270 + if(p->s.size >= nunits){ + 2250: 89 d0 mov %edx,%eax + 2252: 89 da mov %ebx,%edx + 2254: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 2258: 39 fe cmp %edi,%esi + 225a: 74 1c je 2278 + p->s.size -= nunits; + 225c: 29 f7 sub %esi,%edi + 225e: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 2261: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 2264: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 2267: 89 15 24 2a 00 00 mov %edx,0x2a24 + return (void*)(p + 1); + 226d: 83 c0 08 add $0x8,%eax + } +} + 2270: 83 c4 1c add $0x1c,%esp + 2273: 5b pop %ebx + 2274: 5e pop %esi + 2275: 5f pop %edi + 2276: 5d pop %ebp + 2277: c3 ret + prevp->s.ptr = p->s.ptr; + 2278: 8b 08 mov (%eax),%ecx + 227a: 89 0a mov %ecx,(%edx) + 227c: eb e9 jmp 2267 + base.s.ptr = freep = prevp = &base; + 227e: c7 05 24 2a 00 00 28 movl $0x2a28,0x2a24 + 2285: 2a 00 00 + base.s.size = 0; + 2288: ba 28 2a 00 00 mov $0x2a28,%edx + base.s.ptr = freep = prevp = &base; + 228d: c7 05 28 2a 00 00 28 movl $0x2a28,0x2a28 + 2294: 2a 00 00 + base.s.size = 0; + 2297: c7 05 2c 2a 00 00 00 movl $0x0,0x2a2c + 229e: 00 00 00 + 22a1: e9 46 ff ff ff jmp 21ec + 22a6: 66 90 xchg %ax,%ax + 22a8: 66 90 xchg %ax,%ax + 22aa: 66 90 xchg %ax,%ax + 22ac: 66 90 xchg %ax,%ax + 22ae: 66 90 xchg %ax,%ax + +000022b0 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 22b0: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 22b1: b9 01 00 00 00 mov $0x1,%ecx + 22b6: 89 e5 mov %esp,%ebp + 22b8: 8b 55 08 mov 0x8(%ebp),%edx + 22bb: 90 nop + 22bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 22c0: 89 c8 mov %ecx,%eax + 22c2: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 22c5: 85 c0 test %eax,%eax + 22c7: 75 f7 jne 22c0 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 22c9: 0f ae f0 mfence +} + 22cc: 5d pop %ebp + 22cd: c3 ret + 22ce: 66 90 xchg %ax,%ax + +000022d0 : + +void urelease (struct uspinlock *lk) { + 22d0: 55 push %ebp + 22d1: 89 e5 mov %esp,%ebp + 22d3: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 22d6: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 22d9: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 22df: 5d pop %ebp + 22e0: c3 ret diff --git a/sh.d b/sh.d new file mode 100644 index 00000000..51ddf2d9 --- /dev/null +++ b/sh.d @@ -0,0 +1 @@ +sh.o: sh.c /usr/include/stdc-predef.h types.h user.h fcntl.h diff --git a/sh.o b/sh.o new file mode 100644 index 00000000..7b5b23c4 Binary files /dev/null and b/sh.o differ diff --git a/sh.sym b/sh.sym new file mode 100644 index 00000000..bca42bbc --- /dev/null +++ b/sh.sym @@ -0,0 +1,84 @@ +00001000 .text +000022e4 .rodata +000023e4 .eh_frame +000029a4 .data +000029c0 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 sh.c +000029c0 buf.1397 +00000000 ulib.c +00000000 printf.c +00001ea0 printint +000023d3 digits.1359 +00000000 umalloc.c +00002a24 freep +00002a28 base +00000000 uspinlock.c +00001bc0 strcpy +00001f40 printf +00001db0 memmove +00001e2a mknod +00001360 execcmd +00001e82 shm_open +00001cd0 gets +00001e62 getpid +00001890 parsepipe +00001b40 parsecmd +000014a0 backcmd +00001630 peek +00001690 parseredirs +000014f0 gettoken +000021c0 malloc +00001e72 sleep +000029ac whitespace +00001190 fork1 +00001a90 nulterminate +00001df2 pipe +00001100 getcmd +00001e02 write +00001e3a fstat +00001e12 kill +00001e52 chdir +00001910 parseline +000011b0 runcmd +000019d0 parseblock +00001e1a exec +00001dea wait +000029a4 symbols +00001dfa read +00001770 parseexec +00001e32 unlink +000022b0 uacquire +00001160 panic +00001dda fork +00001e6a sbrk +00001e8a shm_close +00001e7a uptime +000029b2 __bss_start +00001c70 memset +00001000 main +00001bf0 strcmp +00001e5a dup +00001400 pipecmd +000013a0 redircmd +00001d30 stat +000029b2 _edata +00002a30 _end +00001e42 link +00001de2 exit +00001d80 atoi +00001c40 strlen +00001e22 open +00001c90 strchr +00001e4a mkdir +00001e0a close +000022d0 urelease +00001450 listcmd +00002130 free diff --git a/shm.d b/shm.d new file mode 100644 index 00000000..5981dc11 --- /dev/null +++ b/shm.d @@ -0,0 +1,2 @@ +shm.o: shm.c /usr/include/stdc-predef.h param.h types.h defs.h x86.h \ + memlayout.h mmu.h proc.h spinlock.h diff --git a/shm.o b/shm.o new file mode 100644 index 00000000..efa4e223 Binary files /dev/null and b/shm.o differ diff --git a/shm_cnt.asm b/shm_cnt.asm new file mode 100644 index 00000000..0e7225e6 --- /dev/null +++ b/shm_cnt.asm @@ -0,0 +1,1289 @@ + +_shm_cnt: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: + struct uspinlock lock; + int cnt; +}; + +int main(int argc, char *argv[]) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 57 push %edi +//which we can now use but will be shared between the two processes + +shm_open(1,(char **)&counter); + +// printf(1,"%s returned successfully from shm_open with counter %x\n", pid? "Child": "Parent", counter); + for(i = 0; i < 10000; i++) + 1004: 31 ff xor %edi,%edi +{ + 1006: 56 push %esi + 1007: 53 push %ebx + uacquire(&(counter->lock)); + counter->cnt++; + urelease(&(counter->lock)); + +//print something because we are curious and to give a chance to switch process + if(i%1000 == 0) + 1008: bb d3 4d 62 10 mov $0x10624dd3,%ebx +{ + 100d: 83 e4 f0 and $0xfffffff0,%esp + 1010: 83 ec 30 sub $0x30,%esp + pid=fork(); + 1013: e8 12 03 00 00 call 132a + sleep(1); + 1018: c7 04 24 01 00 00 00 movl $0x1,(%esp) + pid=fork(); + 101f: 89 c6 mov %eax,%esi + sleep(1); + 1021: e8 9c 03 00 00 call 13c2 +shm_open(1,(char **)&counter); + 1026: 8d 44 24 2c lea 0x2c(%esp),%eax + 102a: 89 44 24 04 mov %eax,0x4(%esp) + 102e: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1035: e8 98 03 00 00 call 13d2 + 103a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + uacquire(&(counter->lock)); + 1040: 8b 44 24 2c mov 0x2c(%esp),%eax + 1044: 89 04 24 mov %eax,(%esp) + 1047: e8 b4 07 00 00 call 1800 + counter->cnt++; + 104c: 8b 44 24 2c mov 0x2c(%esp),%eax + 1050: 83 40 04 01 addl $0x1,0x4(%eax) + urelease(&(counter->lock)); + 1054: 89 04 24 mov %eax,(%esp) + 1057: e8 c4 07 00 00 call 1820 + if(i%1000 == 0) + 105c: 89 f8 mov %edi,%eax + 105e: f7 eb imul %ebx + 1060: 89 f8 mov %edi,%eax + 1062: c1 f8 1f sar $0x1f,%eax + 1065: c1 fa 06 sar $0x6,%edx + 1068: 29 c2 sub %eax,%edx + 106a: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx + 1070: 39 d7 cmp %edx,%edi + 1072: 75 3e jne 10b2 + printf(1,"Counter in %s is %d at address %x\n",pid? "Parent" : "Child", counter->cnt, counter); + 1074: 8b 54 24 2c mov 0x2c(%esp),%edx + 1078: b8 3b 18 00 00 mov $0x183b,%eax + 107d: 85 f6 test %esi,%esi + 107f: 8b 4a 04 mov 0x4(%edx),%ecx + 1082: 89 54 24 10 mov %edx,0x10(%esp) + 1086: c7 44 24 04 74 18 00 movl $0x1874,0x4(%esp) + 108d: 00 + 108e: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1095: 89 4c 24 1c mov %ecx,0x1c(%esp) + 1099: b9 34 18 00 00 mov $0x1834,%ecx + 109e: 0f 45 c1 cmovne %ecx,%eax + 10a1: 8b 4c 24 1c mov 0x1c(%esp),%ecx + 10a5: 89 44 24 08 mov %eax,0x8(%esp) + 10a9: 89 4c 24 0c mov %ecx,0xc(%esp) + 10ad: e8 de 03 00 00 call 1490 + for(i = 0; i < 10000; i++) + 10b2: 83 c7 01 add $0x1,%edi + 10b5: 81 ff 10 27 00 00 cmp $0x2710,%edi + 10bb: 75 83 jne 1040 +} + + if(pid) + { + printf(1,"Counter in parent is %d\n",counter->cnt); + 10bd: 8b 44 24 2c mov 0x2c(%esp),%eax + if(pid) + 10c1: 85 f6 test %esi,%esi + printf(1,"Counter in parent is %d\n",counter->cnt); + 10c3: 8b 40 04 mov 0x4(%eax),%eax + 10c6: 89 44 24 08 mov %eax,0x8(%esp) + if(pid) + 10ca: 74 2a je 10f6 + printf(1,"Counter in parent is %d\n",counter->cnt); + 10cc: c7 44 24 04 41 18 00 movl $0x1841,0x4(%esp) + 10d3: 00 + 10d4: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 10db: e8 b0 03 00 00 call 1490 + wait(); + 10e0: e8 55 02 00 00 call 133a + } else + printf(1,"Counter in child is %d\n\n",counter->cnt); + +//shm_close: first process will just detach, next one will free up the shm_table entry (but for now not the page) + shm_close(1); + 10e5: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 10ec: e8 e9 02 00 00 call 13da + exit(); + 10f1: e8 3c 02 00 00 call 1332 + printf(1,"Counter in child is %d\n\n",counter->cnt); + 10f6: c7 44 24 04 5a 18 00 movl $0x185a,0x4(%esp) + 10fd: 00 + 10fe: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1105: e8 86 03 00 00 call 1490 + 110a: eb d9 jmp 10e5 + 110c: 66 90 xchg %ax,%ax + 110e: 66 90 xchg %ax,%ax + +00001110 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1110: 55 push %ebp + 1111: 89 e5 mov %esp,%ebp + 1113: 8b 45 08 mov 0x8(%ebp),%eax + 1116: 8b 4d 0c mov 0xc(%ebp),%ecx + 1119: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 111a: 89 c2 mov %eax,%edx + 111c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1120: 83 c1 01 add $0x1,%ecx + 1123: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1127: 83 c2 01 add $0x1,%edx + 112a: 84 db test %bl,%bl + 112c: 88 5a ff mov %bl,-0x1(%edx) + 112f: 75 ef jne 1120 + ; + return os; +} + 1131: 5b pop %ebx + 1132: 5d pop %ebp + 1133: c3 ret + 1134: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 113a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001140 : + +int +strcmp(const char *p, const char *q) +{ + 1140: 55 push %ebp + 1141: 89 e5 mov %esp,%ebp + 1143: 8b 55 08 mov 0x8(%ebp),%edx + 1146: 53 push %ebx + 1147: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 114a: 0f b6 02 movzbl (%edx),%eax + 114d: 84 c0 test %al,%al + 114f: 74 2d je 117e + 1151: 0f b6 19 movzbl (%ecx),%ebx + 1154: 38 d8 cmp %bl,%al + 1156: 74 0e je 1166 + 1158: eb 2b jmp 1185 + 115a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1160: 38 c8 cmp %cl,%al + 1162: 75 15 jne 1179 + p++, q++; + 1164: 89 d9 mov %ebx,%ecx + 1166: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 1169: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 116c: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 116f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 1173: 84 c0 test %al,%al + 1175: 75 e9 jne 1160 + 1177: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 1179: 29 c8 sub %ecx,%eax +} + 117b: 5b pop %ebx + 117c: 5d pop %ebp + 117d: c3 ret + 117e: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 1181: 31 c0 xor %eax,%eax + 1183: eb f4 jmp 1179 + 1185: 0f b6 cb movzbl %bl,%ecx + 1188: eb ef jmp 1179 + 118a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00001190 : + +uint +strlen(char *s) +{ + 1190: 55 push %ebp + 1191: 89 e5 mov %esp,%ebp + 1193: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 1196: 80 39 00 cmpb $0x0,(%ecx) + 1199: 74 12 je 11ad + 119b: 31 d2 xor %edx,%edx + 119d: 8d 76 00 lea 0x0(%esi),%esi + 11a0: 83 c2 01 add $0x1,%edx + 11a3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 11a7: 89 d0 mov %edx,%eax + 11a9: 75 f5 jne 11a0 + ; + return n; +} + 11ab: 5d pop %ebp + 11ac: c3 ret + for(n = 0; s[n]; n++) + 11ad: 31 c0 xor %eax,%eax +} + 11af: 5d pop %ebp + 11b0: c3 ret + 11b1: eb 0d jmp 11c0 + 11b3: 90 nop + 11b4: 90 nop + 11b5: 90 nop + 11b6: 90 nop + 11b7: 90 nop + 11b8: 90 nop + 11b9: 90 nop + 11ba: 90 nop + 11bb: 90 nop + 11bc: 90 nop + 11bd: 90 nop + 11be: 90 nop + 11bf: 90 nop + +000011c0 : + +void* +memset(void *dst, int c, uint n) +{ + 11c0: 55 push %ebp + 11c1: 89 e5 mov %esp,%ebp + 11c3: 8b 55 08 mov 0x8(%ebp),%edx + 11c6: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 11c7: 8b 4d 10 mov 0x10(%ebp),%ecx + 11ca: 8b 45 0c mov 0xc(%ebp),%eax + 11cd: 89 d7 mov %edx,%edi + 11cf: fc cld + 11d0: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 11d2: 89 d0 mov %edx,%eax + 11d4: 5f pop %edi + 11d5: 5d pop %ebp + 11d6: c3 ret + 11d7: 89 f6 mov %esi,%esi + 11d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +000011e0 : + +char* +strchr(const char *s, char c) +{ + 11e0: 55 push %ebp + 11e1: 89 e5 mov %esp,%ebp + 11e3: 8b 45 08 mov 0x8(%ebp),%eax + 11e6: 53 push %ebx + 11e7: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 11ea: 0f b6 18 movzbl (%eax),%ebx + 11ed: 84 db test %bl,%bl + 11ef: 74 1d je 120e + if(*s == c) + 11f1: 38 d3 cmp %dl,%bl + 11f3: 89 d1 mov %edx,%ecx + 11f5: 75 0d jne 1204 + 11f7: eb 17 jmp 1210 + 11f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1200: 38 ca cmp %cl,%dl + 1202: 74 0c je 1210 + for(; *s; s++) + 1204: 83 c0 01 add $0x1,%eax + 1207: 0f b6 10 movzbl (%eax),%edx + 120a: 84 d2 test %dl,%dl + 120c: 75 f2 jne 1200 + return (char*)s; + return 0; + 120e: 31 c0 xor %eax,%eax +} + 1210: 5b pop %ebx + 1211: 5d pop %ebp + 1212: c3 ret + 1213: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001220 : + +char* +gets(char *buf, int max) +{ + 1220: 55 push %ebp + 1221: 89 e5 mov %esp,%ebp + 1223: 57 push %edi + 1224: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1225: 31 f6 xor %esi,%esi +{ + 1227: 53 push %ebx + 1228: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 122b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 122e: eb 31 jmp 1261 + cc = read(0, &c, 1); + 1230: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1237: 00 + 1238: 89 7c 24 04 mov %edi,0x4(%esp) + 123c: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1243: e8 02 01 00 00 call 134a + if(cc < 1) + 1248: 85 c0 test %eax,%eax + 124a: 7e 1d jle 1269 + break; + buf[i++] = c; + 124c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 1250: 89 de mov %ebx,%esi + buf[i++] = c; + 1252: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 1255: 3c 0d cmp $0xd,%al + buf[i++] = c; + 1257: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 125b: 74 0c je 1269 + 125d: 3c 0a cmp $0xa,%al + 125f: 74 08 je 1269 + for(i=0; i+1 < max; ){ + 1261: 8d 5e 01 lea 0x1(%esi),%ebx + 1264: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1267: 7c c7 jl 1230 + break; + } + buf[i] = '\0'; + 1269: 8b 45 08 mov 0x8(%ebp),%eax + 126c: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1270: 83 c4 2c add $0x2c,%esp + 1273: 5b pop %ebx + 1274: 5e pop %esi + 1275: 5f pop %edi + 1276: 5d pop %ebp + 1277: c3 ret + 1278: 90 nop + 1279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001280 : + +int +stat(char *n, struct stat *st) +{ + 1280: 55 push %ebp + 1281: 89 e5 mov %esp,%ebp + 1283: 56 push %esi + 1284: 53 push %ebx + 1285: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 1288: 8b 45 08 mov 0x8(%ebp),%eax + 128b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1292: 00 + 1293: 89 04 24 mov %eax,(%esp) + 1296: e8 d7 00 00 00 call 1372 + if(fd < 0) + 129b: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 129d: 89 c3 mov %eax,%ebx + if(fd < 0) + 129f: 78 27 js 12c8 + return -1; + r = fstat(fd, st); + 12a1: 8b 45 0c mov 0xc(%ebp),%eax + 12a4: 89 1c 24 mov %ebx,(%esp) + 12a7: 89 44 24 04 mov %eax,0x4(%esp) + 12ab: e8 da 00 00 00 call 138a + close(fd); + 12b0: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 12b3: 89 c6 mov %eax,%esi + close(fd); + 12b5: e8 a0 00 00 00 call 135a + return r; + 12ba: 89 f0 mov %esi,%eax +} + 12bc: 83 c4 10 add $0x10,%esp + 12bf: 5b pop %ebx + 12c0: 5e pop %esi + 12c1: 5d pop %ebp + 12c2: c3 ret + 12c3: 90 nop + 12c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 12c8: b8 ff ff ff ff mov $0xffffffff,%eax + 12cd: eb ed jmp 12bc + 12cf: 90 nop + +000012d0 : + +int +atoi(const char *s) +{ + 12d0: 55 push %ebp + 12d1: 89 e5 mov %esp,%ebp + 12d3: 8b 4d 08 mov 0x8(%ebp),%ecx + 12d6: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 12d7: 0f be 11 movsbl (%ecx),%edx + 12da: 8d 42 d0 lea -0x30(%edx),%eax + 12dd: 3c 09 cmp $0x9,%al + n = 0; + 12df: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 12e4: 77 17 ja 12fd + 12e6: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 12e8: 83 c1 01 add $0x1,%ecx + 12eb: 8d 04 80 lea (%eax,%eax,4),%eax + 12ee: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 12f2: 0f be 11 movsbl (%ecx),%edx + 12f5: 8d 5a d0 lea -0x30(%edx),%ebx + 12f8: 80 fb 09 cmp $0x9,%bl + 12fb: 76 eb jbe 12e8 + return n; +} + 12fd: 5b pop %ebx + 12fe: 5d pop %ebp + 12ff: c3 ret + +00001300 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1300: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1301: 31 d2 xor %edx,%edx +{ + 1303: 89 e5 mov %esp,%ebp + 1305: 56 push %esi + 1306: 8b 45 08 mov 0x8(%ebp),%eax + 1309: 53 push %ebx + 130a: 8b 5d 10 mov 0x10(%ebp),%ebx + 130d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1310: 85 db test %ebx,%ebx + 1312: 7e 12 jle 1326 + 1314: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1318: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 131c: 88 0c 10 mov %cl,(%eax,%edx,1) + 131f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1322: 39 da cmp %ebx,%edx + 1324: 75 f2 jne 1318 + return vdst; +} + 1326: 5b pop %ebx + 1327: 5e pop %esi + 1328: 5d pop %ebp + 1329: c3 ret + +0000132a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 132a: b8 01 00 00 00 mov $0x1,%eax + 132f: cd 40 int $0x40 + 1331: c3 ret + +00001332 : +SYSCALL(exit) + 1332: b8 02 00 00 00 mov $0x2,%eax + 1337: cd 40 int $0x40 + 1339: c3 ret + +0000133a : +SYSCALL(wait) + 133a: b8 03 00 00 00 mov $0x3,%eax + 133f: cd 40 int $0x40 + 1341: c3 ret + +00001342 : +SYSCALL(pipe) + 1342: b8 04 00 00 00 mov $0x4,%eax + 1347: cd 40 int $0x40 + 1349: c3 ret + +0000134a : +SYSCALL(read) + 134a: b8 05 00 00 00 mov $0x5,%eax + 134f: cd 40 int $0x40 + 1351: c3 ret + +00001352 : +SYSCALL(write) + 1352: b8 10 00 00 00 mov $0x10,%eax + 1357: cd 40 int $0x40 + 1359: c3 ret + +0000135a : +SYSCALL(close) + 135a: b8 15 00 00 00 mov $0x15,%eax + 135f: cd 40 int $0x40 + 1361: c3 ret + +00001362 : +SYSCALL(kill) + 1362: b8 06 00 00 00 mov $0x6,%eax + 1367: cd 40 int $0x40 + 1369: c3 ret + +0000136a : +SYSCALL(exec) + 136a: b8 07 00 00 00 mov $0x7,%eax + 136f: cd 40 int $0x40 + 1371: c3 ret + +00001372 : +SYSCALL(open) + 1372: b8 0f 00 00 00 mov $0xf,%eax + 1377: cd 40 int $0x40 + 1379: c3 ret + +0000137a : +SYSCALL(mknod) + 137a: b8 11 00 00 00 mov $0x11,%eax + 137f: cd 40 int $0x40 + 1381: c3 ret + +00001382 : +SYSCALL(unlink) + 1382: b8 12 00 00 00 mov $0x12,%eax + 1387: cd 40 int $0x40 + 1389: c3 ret + +0000138a : +SYSCALL(fstat) + 138a: b8 08 00 00 00 mov $0x8,%eax + 138f: cd 40 int $0x40 + 1391: c3 ret + +00001392 : +SYSCALL(link) + 1392: b8 13 00 00 00 mov $0x13,%eax + 1397: cd 40 int $0x40 + 1399: c3 ret + +0000139a : +SYSCALL(mkdir) + 139a: b8 14 00 00 00 mov $0x14,%eax + 139f: cd 40 int $0x40 + 13a1: c3 ret + +000013a2 : +SYSCALL(chdir) + 13a2: b8 09 00 00 00 mov $0x9,%eax + 13a7: cd 40 int $0x40 + 13a9: c3 ret + +000013aa : +SYSCALL(dup) + 13aa: b8 0a 00 00 00 mov $0xa,%eax + 13af: cd 40 int $0x40 + 13b1: c3 ret + +000013b2 : +SYSCALL(getpid) + 13b2: b8 0b 00 00 00 mov $0xb,%eax + 13b7: cd 40 int $0x40 + 13b9: c3 ret + +000013ba : +SYSCALL(sbrk) + 13ba: b8 0c 00 00 00 mov $0xc,%eax + 13bf: cd 40 int $0x40 + 13c1: c3 ret + +000013c2 : +SYSCALL(sleep) + 13c2: b8 0d 00 00 00 mov $0xd,%eax + 13c7: cd 40 int $0x40 + 13c9: c3 ret + +000013ca : +SYSCALL(uptime) + 13ca: b8 0e 00 00 00 mov $0xe,%eax + 13cf: cd 40 int $0x40 + 13d1: c3 ret + +000013d2 : +SYSCALL(shm_open) + 13d2: b8 16 00 00 00 mov $0x16,%eax + 13d7: cd 40 int $0x40 + 13d9: c3 ret + +000013da : +SYSCALL(shm_close) + 13da: b8 17 00 00 00 mov $0x17,%eax + 13df: cd 40 int $0x40 + 13e1: c3 ret + 13e2: 66 90 xchg %ax,%ax + 13e4: 66 90 xchg %ax,%ax + 13e6: 66 90 xchg %ax,%ax + 13e8: 66 90 xchg %ax,%ax + 13ea: 66 90 xchg %ax,%ax + 13ec: 66 90 xchg %ax,%ax + 13ee: 66 90 xchg %ax,%ax + +000013f0 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 13f0: 55 push %ebp + 13f1: 89 e5 mov %esp,%ebp + 13f3: 57 push %edi + 13f4: 56 push %esi + 13f5: 89 c6 mov %eax,%esi + 13f7: 53 push %ebx + 13f8: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 13fb: 8b 5d 08 mov 0x8(%ebp),%ebx + 13fe: 85 db test %ebx,%ebx + 1400: 74 09 je 140b + 1402: 89 d0 mov %edx,%eax + 1404: c1 e8 1f shr $0x1f,%eax + 1407: 84 c0 test %al,%al + 1409: 75 75 jne 1480 + neg = 1; + x = -xx; + } else { + x = xx; + 140b: 89 d0 mov %edx,%eax + neg = 0; + 140d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1414: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1417: 31 ff xor %edi,%edi + 1419: 89 ce mov %ecx,%esi + 141b: 8d 5d d7 lea -0x29(%ebp),%ebx + 141e: eb 02 jmp 1422 + do{ + buf[i++] = digits[x % base]; + 1420: 89 cf mov %ecx,%edi + 1422: 31 d2 xor %edx,%edx + 1424: f7 f6 div %esi + 1426: 8d 4f 01 lea 0x1(%edi),%ecx + 1429: 0f b6 92 9f 18 00 00 movzbl 0x189f(%edx),%edx + }while((x /= base) != 0); + 1430: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 1432: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 1435: 75 e9 jne 1420 + if(neg) + 1437: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 143a: 89 c8 mov %ecx,%eax + 143c: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 143f: 85 d2 test %edx,%edx + 1441: 74 08 je 144b + buf[i++] = '-'; + 1443: 8d 4f 02 lea 0x2(%edi),%ecx + 1446: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 144b: 8d 79 ff lea -0x1(%ecx),%edi + 144e: 66 90 xchg %ax,%ax + 1450: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 1455: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 1458: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 145f: 00 + 1460: 89 5c 24 04 mov %ebx,0x4(%esp) + 1464: 89 34 24 mov %esi,(%esp) + 1467: 88 45 d7 mov %al,-0x29(%ebp) + 146a: e8 e3 fe ff ff call 1352 + while(--i >= 0) + 146f: 83 ff ff cmp $0xffffffff,%edi + 1472: 75 dc jne 1450 + putc(fd, buf[i]); +} + 1474: 83 c4 4c add $0x4c,%esp + 1477: 5b pop %ebx + 1478: 5e pop %esi + 1479: 5f pop %edi + 147a: 5d pop %ebp + 147b: c3 ret + 147c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 1480: 89 d0 mov %edx,%eax + 1482: f7 d8 neg %eax + neg = 1; + 1484: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 148b: eb 87 jmp 1414 + 148d: 8d 76 00 lea 0x0(%esi),%esi + +00001490 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 1490: 55 push %ebp + 1491: 89 e5 mov %esp,%ebp + 1493: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 1494: 31 ff xor %edi,%edi +{ + 1496: 56 push %esi + 1497: 53 push %ebx + 1498: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 149b: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 149e: 8d 45 10 lea 0x10(%ebp),%eax +{ + 14a1: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 14a4: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 14a7: 0f b6 13 movzbl (%ebx),%edx + 14aa: 83 c3 01 add $0x1,%ebx + 14ad: 84 d2 test %dl,%dl + 14af: 75 39 jne 14ea + 14b1: e9 c2 00 00 00 jmp 1578 + 14b6: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 14b8: 83 fa 25 cmp $0x25,%edx + 14bb: 0f 84 bf 00 00 00 je 1580 + write(fd, &c, 1); + 14c1: 8d 45 e2 lea -0x1e(%ebp),%eax + 14c4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14cb: 00 + 14cc: 89 44 24 04 mov %eax,0x4(%esp) + 14d0: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 14d3: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 14d6: e8 77 fe ff ff call 1352 + 14db: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 14de: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 14e2: 84 d2 test %dl,%dl + 14e4: 0f 84 8e 00 00 00 je 1578 + if(state == 0){ + 14ea: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 14ec: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 14ef: 74 c7 je 14b8 + } + } else if(state == '%'){ + 14f1: 83 ff 25 cmp $0x25,%edi + 14f4: 75 e5 jne 14db + if(c == 'd'){ + 14f6: 83 fa 64 cmp $0x64,%edx + 14f9: 0f 84 31 01 00 00 je 1630 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 14ff: 25 f7 00 00 00 and $0xf7,%eax + 1504: 83 f8 70 cmp $0x70,%eax + 1507: 0f 84 83 00 00 00 je 1590 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 150d: 83 fa 73 cmp $0x73,%edx + 1510: 0f 84 a2 00 00 00 je 15b8 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1516: 83 fa 63 cmp $0x63,%edx + 1519: 0f 84 35 01 00 00 je 1654 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 151f: 83 fa 25 cmp $0x25,%edx + 1522: 0f 84 e0 00 00 00 je 1608 + write(fd, &c, 1); + 1528: 8d 45 e6 lea -0x1a(%ebp),%eax + 152b: 83 c3 01 add $0x1,%ebx + 152e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1535: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 1536: 31 ff xor %edi,%edi + write(fd, &c, 1); + 1538: 89 44 24 04 mov %eax,0x4(%esp) + 153c: 89 34 24 mov %esi,(%esp) + 153f: 89 55 d0 mov %edx,-0x30(%ebp) + 1542: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 1546: e8 07 fe ff ff call 1352 + putc(fd, c); + 154b: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 154e: 8d 45 e7 lea -0x19(%ebp),%eax + 1551: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1558: 00 + 1559: 89 44 24 04 mov %eax,0x4(%esp) + 155d: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 1560: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 1563: e8 ea fd ff ff call 1352 + for(i = 0; fmt[i]; i++){ + 1568: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 156c: 84 d2 test %dl,%dl + 156e: 0f 85 76 ff ff ff jne 14ea + 1574: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 1578: 83 c4 3c add $0x3c,%esp + 157b: 5b pop %ebx + 157c: 5e pop %esi + 157d: 5f pop %edi + 157e: 5d pop %ebp + 157f: c3 ret + state = '%'; + 1580: bf 25 00 00 00 mov $0x25,%edi + 1585: e9 51 ff ff ff jmp 14db + 158a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 1590: 8b 45 d4 mov -0x2c(%ebp),%eax + 1593: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 1598: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 159a: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 15a1: 8b 10 mov (%eax),%edx + 15a3: 89 f0 mov %esi,%eax + 15a5: e8 46 fe ff ff call 13f0 + ap++; + 15aa: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15ae: e9 28 ff ff ff jmp 14db + 15b3: 90 nop + 15b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 15b8: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 15bb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 15bf: 8b 38 mov (%eax),%edi + s = "(null)"; + 15c1: b8 98 18 00 00 mov $0x1898,%eax + 15c6: 85 ff test %edi,%edi + 15c8: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 15cb: 0f b6 07 movzbl (%edi),%eax + 15ce: 84 c0 test %al,%al + 15d0: 74 2a je 15fc + 15d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 15d8: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 15db: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 15de: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 15e1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 15e8: 00 + 15e9: 89 44 24 04 mov %eax,0x4(%esp) + 15ed: 89 34 24 mov %esi,(%esp) + 15f0: e8 5d fd ff ff call 1352 + while(*s != 0){ + 15f5: 0f b6 07 movzbl (%edi),%eax + 15f8: 84 c0 test %al,%al + 15fa: 75 dc jne 15d8 + state = 0; + 15fc: 31 ff xor %edi,%edi + 15fe: e9 d8 fe ff ff jmp 14db + 1603: 90 nop + 1604: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1608: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 160b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 160d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1614: 00 + 1615: 89 44 24 04 mov %eax,0x4(%esp) + 1619: 89 34 24 mov %esi,(%esp) + 161c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1620: e8 2d fd ff ff call 1352 + 1625: e9 b1 fe ff ff jmp 14db + 162a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 1630: 8b 45 d4 mov -0x2c(%ebp),%eax + 1633: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 1638: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 163b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1642: 8b 10 mov (%eax),%edx + 1644: 89 f0 mov %esi,%eax + 1646: e8 a5 fd ff ff call 13f0 + ap++; + 164b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 164f: e9 87 fe ff ff jmp 14db + putc(fd, *ap); + 1654: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 1657: 31 ff xor %edi,%edi + putc(fd, *ap); + 1659: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 165b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1662: 00 + 1663: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 1666: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 1669: 8d 45 e4 lea -0x1c(%ebp),%eax + 166c: 89 44 24 04 mov %eax,0x4(%esp) + 1670: e8 dd fc ff ff call 1352 + ap++; + 1675: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 1679: e9 5d fe ff ff jmp 14db + 167e: 66 90 xchg %ax,%ax + +00001680 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 1680: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1681: a1 5c 1b 00 00 mov 0x1b5c,%eax +{ + 1686: 89 e5 mov %esp,%ebp + 1688: 57 push %edi + 1689: 56 push %esi + 168a: 53 push %ebx + 168b: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 168e: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 1690: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1693: 39 d0 cmp %edx,%eax + 1695: 72 11 jb 16a8 + 1697: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1698: 39 c8 cmp %ecx,%eax + 169a: 72 04 jb 16a0 + 169c: 39 ca cmp %ecx,%edx + 169e: 72 10 jb 16b0 + 16a0: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 16a2: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 16a4: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 16a6: 73 f0 jae 1698 + 16a8: 39 ca cmp %ecx,%edx + 16aa: 72 04 jb 16b0 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 16ac: 39 c8 cmp %ecx,%eax + 16ae: 72 f0 jb 16a0 + break; + if(bp + bp->s.size == p->s.ptr){ + 16b0: 8b 73 fc mov -0x4(%ebx),%esi + 16b3: 8d 3c f2 lea (%edx,%esi,8),%edi + 16b6: 39 cf cmp %ecx,%edi + 16b8: 74 1e je 16d8 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 16ba: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 16bd: 8b 48 04 mov 0x4(%eax),%ecx + 16c0: 8d 34 c8 lea (%eax,%ecx,8),%esi + 16c3: 39 f2 cmp %esi,%edx + 16c5: 74 28 je 16ef + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 16c7: 89 10 mov %edx,(%eax) + freep = p; + 16c9: a3 5c 1b 00 00 mov %eax,0x1b5c +} + 16ce: 5b pop %ebx + 16cf: 5e pop %esi + 16d0: 5f pop %edi + 16d1: 5d pop %ebp + 16d2: c3 ret + 16d3: 90 nop + 16d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 16d8: 03 71 04 add 0x4(%ecx),%esi + 16db: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 16de: 8b 08 mov (%eax),%ecx + 16e0: 8b 09 mov (%ecx),%ecx + 16e2: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 16e5: 8b 48 04 mov 0x4(%eax),%ecx + 16e8: 8d 34 c8 lea (%eax,%ecx,8),%esi + 16eb: 39 f2 cmp %esi,%edx + 16ed: 75 d8 jne 16c7 + p->s.size += bp->s.size; + 16ef: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 16f2: a3 5c 1b 00 00 mov %eax,0x1b5c + p->s.size += bp->s.size; + 16f7: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 16fa: 8b 53 f8 mov -0x8(%ebx),%edx + 16fd: 89 10 mov %edx,(%eax) +} + 16ff: 5b pop %ebx + 1700: 5e pop %esi + 1701: 5f pop %edi + 1702: 5d pop %ebp + 1703: c3 ret + 1704: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 170a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001710 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1710: 55 push %ebp + 1711: 89 e5 mov %esp,%ebp + 1713: 57 push %edi + 1714: 56 push %esi + 1715: 53 push %ebx + 1716: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1719: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 171c: 8b 1d 5c 1b 00 00 mov 0x1b5c,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1722: 8d 48 07 lea 0x7(%eax),%ecx + 1725: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1728: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 172a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 172d: 0f 84 9b 00 00 00 je 17ce + 1733: 8b 13 mov (%ebx),%edx + 1735: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 1738: 39 fe cmp %edi,%esi + 173a: 76 64 jbe 17a0 + 173c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 1743: bb 00 80 00 00 mov $0x8000,%ebx + 1748: 89 45 e4 mov %eax,-0x1c(%ebp) + 174b: eb 0e jmp 175b + 174d: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 1750: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 1752: 8b 78 04 mov 0x4(%eax),%edi + 1755: 39 fe cmp %edi,%esi + 1757: 76 4f jbe 17a8 + 1759: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 175b: 3b 15 5c 1b 00 00 cmp 0x1b5c,%edx + 1761: 75 ed jne 1750 + if(nu < 4096) + 1763: 8b 45 e4 mov -0x1c(%ebp),%eax + 1766: 81 fe 00 10 00 00 cmp $0x1000,%esi + 176c: bf 00 10 00 00 mov $0x1000,%edi + 1771: 0f 43 fe cmovae %esi,%edi + 1774: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 1777: 89 04 24 mov %eax,(%esp) + 177a: e8 3b fc ff ff call 13ba + if(p == (char*)-1) + 177f: 83 f8 ff cmp $0xffffffff,%eax + 1782: 74 18 je 179c + hp->s.size = nu; + 1784: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 1787: 83 c0 08 add $0x8,%eax + 178a: 89 04 24 mov %eax,(%esp) + 178d: e8 ee fe ff ff call 1680 + return freep; + 1792: 8b 15 5c 1b 00 00 mov 0x1b5c,%edx + if((p = morecore(nunits)) == 0) + 1798: 85 d2 test %edx,%edx + 179a: 75 b4 jne 1750 + return 0; + 179c: 31 c0 xor %eax,%eax + 179e: eb 20 jmp 17c0 + if(p->s.size >= nunits){ + 17a0: 89 d0 mov %edx,%eax + 17a2: 89 da mov %ebx,%edx + 17a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 17a8: 39 fe cmp %edi,%esi + 17aa: 74 1c je 17c8 + p->s.size -= nunits; + 17ac: 29 f7 sub %esi,%edi + 17ae: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 17b1: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 17b4: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 17b7: 89 15 5c 1b 00 00 mov %edx,0x1b5c + return (void*)(p + 1); + 17bd: 83 c0 08 add $0x8,%eax + } +} + 17c0: 83 c4 1c add $0x1c,%esp + 17c3: 5b pop %ebx + 17c4: 5e pop %esi + 17c5: 5f pop %edi + 17c6: 5d pop %ebp + 17c7: c3 ret + prevp->s.ptr = p->s.ptr; + 17c8: 8b 08 mov (%eax),%ecx + 17ca: 89 0a mov %ecx,(%edx) + 17cc: eb e9 jmp 17b7 + base.s.ptr = freep = prevp = &base; + 17ce: c7 05 5c 1b 00 00 60 movl $0x1b60,0x1b5c + 17d5: 1b 00 00 + base.s.size = 0; + 17d8: ba 60 1b 00 00 mov $0x1b60,%edx + base.s.ptr = freep = prevp = &base; + 17dd: c7 05 60 1b 00 00 60 movl $0x1b60,0x1b60 + 17e4: 1b 00 00 + base.s.size = 0; + 17e7: c7 05 64 1b 00 00 00 movl $0x0,0x1b64 + 17ee: 00 00 00 + 17f1: e9 46 ff ff ff jmp 173c + 17f6: 66 90 xchg %ax,%ax + 17f8: 66 90 xchg %ax,%ax + 17fa: 66 90 xchg %ax,%ax + 17fc: 66 90 xchg %ax,%ax + 17fe: 66 90 xchg %ax,%ax + +00001800 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1800: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1801: b9 01 00 00 00 mov $0x1,%ecx + 1806: 89 e5 mov %esp,%ebp + 1808: 8b 55 08 mov 0x8(%ebp),%edx + 180b: 90 nop + 180c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1810: 89 c8 mov %ecx,%eax + 1812: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1815: 85 c0 test %eax,%eax + 1817: 75 f7 jne 1810 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1819: 0f ae f0 mfence +} + 181c: 5d pop %ebp + 181d: c3 ret + 181e: 66 90 xchg %ax,%ax + +00001820 : + +void urelease (struct uspinlock *lk) { + 1820: 55 push %ebp + 1821: 89 e5 mov %esp,%ebp + 1823: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1826: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1829: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 182f: 5d pop %ebp + 1830: c3 ret diff --git a/shm_cnt.d b/shm_cnt.d new file mode 100644 index 00000000..2c6a1541 --- /dev/null +++ b/shm_cnt.d @@ -0,0 +1,2 @@ +shm_cnt.o: shm_cnt.c /usr/include/stdc-predef.h types.h stat.h user.h \ + uspinlock.h diff --git a/shm_cnt.o b/shm_cnt.o new file mode 100644 index 00000000..4b20dd5c Binary files /dev/null and b/shm_cnt.o differ diff --git a/shm_cnt.sym b/shm_cnt.sym new file mode 100644 index 00000000..7a7eed8a --- /dev/null +++ b/shm_cnt.sym @@ -0,0 +1,62 @@ +00001000 .text +00001834 .rodata +000018b0 .eh_frame +00001b5c .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 shm_cnt.c +00000000 ulib.c +00000000 printf.c +000013f0 printint +0000189f digits.1359 +00000000 umalloc.c +00001b5c freep +00001b60 base +00000000 uspinlock.c +00001110 strcpy +00001490 printf +00001300 memmove +0000137a mknod +000013d2 shm_open +00001220 gets +000013b2 getpid +00001710 malloc +000013c2 sleep +00001342 pipe +00001352 write +0000138a fstat +00001362 kill +000013a2 chdir +0000136a exec +0000133a wait +0000134a read +00001382 unlink +00001800 uacquire +0000132a fork +000013ba sbrk +000013da shm_close +000013ca uptime +00001b5c __bss_start +000011c0 memset +00001000 main +00001140 strcmp +000013aa dup +00001280 stat +00001b5c _edata +00001b68 _end +00001392 link +00001332 exit +000012d0 atoi +00001190 strlen +00001372 open +000011e0 strchr +0000139a mkdir +0000135a close +00001820 urelease +00001680 free diff --git a/sleeplock.d b/sleeplock.d new file mode 100644 index 00000000..e50551ae --- /dev/null +++ b/sleeplock.d @@ -0,0 +1,2 @@ +sleeplock.o: sleeplock.c /usr/include/stdc-predef.h types.h defs.h \ + param.h x86.h memlayout.h mmu.h proc.h spinlock.h sleeplock.h diff --git a/sleeplock.o b/sleeplock.o new file mode 100644 index 00000000..cbf64502 Binary files /dev/null and b/sleeplock.o differ diff --git a/spinlock.d b/spinlock.d new file mode 100644 index 00000000..9f709526 --- /dev/null +++ b/spinlock.d @@ -0,0 +1,2 @@ +spinlock.o: spinlock.c /usr/include/stdc-predef.h types.h defs.h param.h \ + x86.h memlayout.h mmu.h proc.h spinlock.h diff --git a/spinlock.o b/spinlock.o new file mode 100644 index 00000000..4b8bedd5 Binary files /dev/null and b/spinlock.o differ diff --git a/stressfs.asm b/stressfs.asm new file mode 100644 index 00000000..674ff866 --- /dev/null +++ b/stressfs.asm @@ -0,0 +1,1309 @@ + +_stressfs: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: +#include "fs.h" +#include "fcntl.h" + +int +main(int argc, char *argv[]) +{ + 1000: 55 push %ebp + int fd, i; + char path[] = "stressfs0"; + 1001: b8 30 00 00 00 mov $0x30,%eax +{ + 1006: 89 e5 mov %esp,%ebp + 1008: 57 push %edi + 1009: 56 push %esi + 100a: 53 push %ebx + char data[512]; + + printf(1, "stressfs starting\n"); + memset(data, 'a', sizeof(data)); + + for(i = 0; i < 4; i++) + 100b: 31 db xor %ebx,%ebx +{ + 100d: 83 e4 f0 and $0xfffffff0,%esp + 1010: 81 ec 20 02 00 00 sub $0x220,%esp + printf(1, "stressfs starting\n"); + 1016: c7 44 24 04 61 18 00 movl $0x1861,0x4(%esp) + 101d: 00 + memset(data, 'a', sizeof(data)); + 101e: 8d 74 24 20 lea 0x20(%esp),%esi + printf(1, "stressfs starting\n"); + 1022: c7 04 24 01 00 00 00 movl $0x1,(%esp) + char path[] = "stressfs0"; + 1029: 66 89 44 24 1e mov %ax,0x1e(%esp) + 102e: c7 44 24 16 73 74 72 movl $0x65727473,0x16(%esp) + 1035: 65 + 1036: c7 44 24 1a 73 73 66 movl $0x73667373,0x1a(%esp) + 103d: 73 + printf(1, "stressfs starting\n"); + 103e: e8 7d 04 00 00 call 14c0 + memset(data, 'a', sizeof(data)); + 1043: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) + 104a: 00 + 104b: c7 44 24 04 61 00 00 movl $0x61,0x4(%esp) + 1052: 00 + 1053: 89 34 24 mov %esi,(%esp) + 1056: e8 95 01 00 00 call 11f0 + if(fork() > 0) + 105b: e8 fa 02 00 00 call 135a + 1060: 85 c0 test %eax,%eax + 1062: 0f 8f c3 00 00 00 jg 112b + for(i = 0; i < 4; i++) + 1068: 83 c3 01 add $0x1,%ebx + 106b: 83 fb 04 cmp $0x4,%ebx + 106e: 75 eb jne 105b + 1070: bf 04 00 00 00 mov $0x4,%edi + break; + + printf(1, "write %d\n", i); + 1075: 89 5c 24 08 mov %ebx,0x8(%esp) + + path[8] += i; + fd = open(path, O_CREATE | O_RDWR); + 1079: bb 14 00 00 00 mov $0x14,%ebx + printf(1, "write %d\n", i); + 107e: c7 44 24 04 74 18 00 movl $0x1874,0x4(%esp) + 1085: 00 + 1086: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 108d: e8 2e 04 00 00 call 14c0 + path[8] += i; + 1092: 89 f8 mov %edi,%eax + 1094: 00 44 24 1e add %al,0x1e(%esp) + fd = open(path, O_CREATE | O_RDWR); + 1098: 8d 44 24 16 lea 0x16(%esp),%eax + 109c: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 10a3: 00 + 10a4: 89 04 24 mov %eax,(%esp) + 10a7: e8 f6 02 00 00 call 13a2 + 10ac: 89 c7 mov %eax,%edi + 10ae: 66 90 xchg %ax,%ax + for(i = 0; i < 20; i++) +// printf(fd, "%d\n", i); + write(fd, data, sizeof(data)); + 10b0: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) + 10b7: 00 + 10b8: 89 74 24 04 mov %esi,0x4(%esp) + 10bc: 89 3c 24 mov %edi,(%esp) + 10bf: e8 be 02 00 00 call 1382 + for(i = 0; i < 20; i++) + 10c4: 83 eb 01 sub $0x1,%ebx + 10c7: 75 e7 jne 10b0 + close(fd); + 10c9: 89 3c 24 mov %edi,(%esp) + + printf(1, "read\n"); + + fd = open(path, O_RDONLY); + 10cc: bb 14 00 00 00 mov $0x14,%ebx + close(fd); + 10d1: e8 b4 02 00 00 call 138a + printf(1, "read\n"); + 10d6: c7 44 24 04 7e 18 00 movl $0x187e,0x4(%esp) + 10dd: 00 + 10de: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 10e5: e8 d6 03 00 00 call 14c0 + fd = open(path, O_RDONLY); + 10ea: 8d 44 24 16 lea 0x16(%esp),%eax + 10ee: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 10f5: 00 + 10f6: 89 04 24 mov %eax,(%esp) + 10f9: e8 a4 02 00 00 call 13a2 + 10fe: 89 c7 mov %eax,%edi + for (i = 0; i < 20; i++) + read(fd, data, sizeof(data)); + 1100: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) + 1107: 00 + 1108: 89 74 24 04 mov %esi,0x4(%esp) + 110c: 89 3c 24 mov %edi,(%esp) + 110f: e8 66 02 00 00 call 137a + for (i = 0; i < 20; i++) + 1114: 83 eb 01 sub $0x1,%ebx + 1117: 75 e7 jne 1100 + close(fd); + 1119: 89 3c 24 mov %edi,(%esp) + 111c: e8 69 02 00 00 call 138a + + wait(); + 1121: e8 44 02 00 00 call 136a + + exit(); + 1126: e8 37 02 00 00 call 1362 + 112b: 89 df mov %ebx,%edi + 112d: 8d 76 00 lea 0x0(%esi),%esi + 1130: e9 40 ff ff ff jmp 1075 + 1135: 66 90 xchg %ax,%ax + 1137: 66 90 xchg %ax,%ax + 1139: 66 90 xchg %ax,%ax + 113b: 66 90 xchg %ax,%ax + 113d: 66 90 xchg %ax,%ax + 113f: 90 nop + +00001140 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1140: 55 push %ebp + 1141: 89 e5 mov %esp,%ebp + 1143: 8b 45 08 mov 0x8(%ebp),%eax + 1146: 8b 4d 0c mov 0xc(%ebp),%ecx + 1149: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 114a: 89 c2 mov %eax,%edx + 114c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1150: 83 c1 01 add $0x1,%ecx + 1153: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1157: 83 c2 01 add $0x1,%edx + 115a: 84 db test %bl,%bl + 115c: 88 5a ff mov %bl,-0x1(%edx) + 115f: 75 ef jne 1150 + ; + return os; +} + 1161: 5b pop %ebx + 1162: 5d pop %ebp + 1163: c3 ret + 1164: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 116a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001170 : + +int +strcmp(const char *p, const char *q) +{ + 1170: 55 push %ebp + 1171: 89 e5 mov %esp,%ebp + 1173: 8b 55 08 mov 0x8(%ebp),%edx + 1176: 53 push %ebx + 1177: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 117a: 0f b6 02 movzbl (%edx),%eax + 117d: 84 c0 test %al,%al + 117f: 74 2d je 11ae + 1181: 0f b6 19 movzbl (%ecx),%ebx + 1184: 38 d8 cmp %bl,%al + 1186: 74 0e je 1196 + 1188: eb 2b jmp 11b5 + 118a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1190: 38 c8 cmp %cl,%al + 1192: 75 15 jne 11a9 + p++, q++; + 1194: 89 d9 mov %ebx,%ecx + 1196: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 1199: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 119c: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 119f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 11a3: 84 c0 test %al,%al + 11a5: 75 e9 jne 1190 + 11a7: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 11a9: 29 c8 sub %ecx,%eax +} + 11ab: 5b pop %ebx + 11ac: 5d pop %ebp + 11ad: c3 ret + 11ae: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 11b1: 31 c0 xor %eax,%eax + 11b3: eb f4 jmp 11a9 + 11b5: 0f b6 cb movzbl %bl,%ecx + 11b8: eb ef jmp 11a9 + 11ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +000011c0 : + +uint +strlen(char *s) +{ + 11c0: 55 push %ebp + 11c1: 89 e5 mov %esp,%ebp + 11c3: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 11c6: 80 39 00 cmpb $0x0,(%ecx) + 11c9: 74 12 je 11dd + 11cb: 31 d2 xor %edx,%edx + 11cd: 8d 76 00 lea 0x0(%esi),%esi + 11d0: 83 c2 01 add $0x1,%edx + 11d3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 11d7: 89 d0 mov %edx,%eax + 11d9: 75 f5 jne 11d0 + ; + return n; +} + 11db: 5d pop %ebp + 11dc: c3 ret + for(n = 0; s[n]; n++) + 11dd: 31 c0 xor %eax,%eax +} + 11df: 5d pop %ebp + 11e0: c3 ret + 11e1: eb 0d jmp 11f0 + 11e3: 90 nop + 11e4: 90 nop + 11e5: 90 nop + 11e6: 90 nop + 11e7: 90 nop + 11e8: 90 nop + 11e9: 90 nop + 11ea: 90 nop + 11eb: 90 nop + 11ec: 90 nop + 11ed: 90 nop + 11ee: 90 nop + 11ef: 90 nop + +000011f0 : + +void* +memset(void *dst, int c, uint n) +{ + 11f0: 55 push %ebp + 11f1: 89 e5 mov %esp,%ebp + 11f3: 8b 55 08 mov 0x8(%ebp),%edx + 11f6: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 11f7: 8b 4d 10 mov 0x10(%ebp),%ecx + 11fa: 8b 45 0c mov 0xc(%ebp),%eax + 11fd: 89 d7 mov %edx,%edi + 11ff: fc cld + 1200: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1202: 89 d0 mov %edx,%eax + 1204: 5f pop %edi + 1205: 5d pop %ebp + 1206: c3 ret + 1207: 89 f6 mov %esi,%esi + 1209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001210 : + +char* +strchr(const char *s, char c) +{ + 1210: 55 push %ebp + 1211: 89 e5 mov %esp,%ebp + 1213: 8b 45 08 mov 0x8(%ebp),%eax + 1216: 53 push %ebx + 1217: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 121a: 0f b6 18 movzbl (%eax),%ebx + 121d: 84 db test %bl,%bl + 121f: 74 1d je 123e + if(*s == c) + 1221: 38 d3 cmp %dl,%bl + 1223: 89 d1 mov %edx,%ecx + 1225: 75 0d jne 1234 + 1227: eb 17 jmp 1240 + 1229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1230: 38 ca cmp %cl,%dl + 1232: 74 0c je 1240 + for(; *s; s++) + 1234: 83 c0 01 add $0x1,%eax + 1237: 0f b6 10 movzbl (%eax),%edx + 123a: 84 d2 test %dl,%dl + 123c: 75 f2 jne 1230 + return (char*)s; + return 0; + 123e: 31 c0 xor %eax,%eax +} + 1240: 5b pop %ebx + 1241: 5d pop %ebp + 1242: c3 ret + 1243: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001250 : + +char* +gets(char *buf, int max) +{ + 1250: 55 push %ebp + 1251: 89 e5 mov %esp,%ebp + 1253: 57 push %edi + 1254: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1255: 31 f6 xor %esi,%esi +{ + 1257: 53 push %ebx + 1258: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 125b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 125e: eb 31 jmp 1291 + cc = read(0, &c, 1); + 1260: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1267: 00 + 1268: 89 7c 24 04 mov %edi,0x4(%esp) + 126c: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1273: e8 02 01 00 00 call 137a + if(cc < 1) + 1278: 85 c0 test %eax,%eax + 127a: 7e 1d jle 1299 + break; + buf[i++] = c; + 127c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 1280: 89 de mov %ebx,%esi + buf[i++] = c; + 1282: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 1285: 3c 0d cmp $0xd,%al + buf[i++] = c; + 1287: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 128b: 74 0c je 1299 + 128d: 3c 0a cmp $0xa,%al + 128f: 74 08 je 1299 + for(i=0; i+1 < max; ){ + 1291: 8d 5e 01 lea 0x1(%esi),%ebx + 1294: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1297: 7c c7 jl 1260 + break; + } + buf[i] = '\0'; + 1299: 8b 45 08 mov 0x8(%ebp),%eax + 129c: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 12a0: 83 c4 2c add $0x2c,%esp + 12a3: 5b pop %ebx + 12a4: 5e pop %esi + 12a5: 5f pop %edi + 12a6: 5d pop %ebp + 12a7: c3 ret + 12a8: 90 nop + 12a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000012b0 : + +int +stat(char *n, struct stat *st) +{ + 12b0: 55 push %ebp + 12b1: 89 e5 mov %esp,%ebp + 12b3: 56 push %esi + 12b4: 53 push %ebx + 12b5: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 12b8: 8b 45 08 mov 0x8(%ebp),%eax + 12bb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 12c2: 00 + 12c3: 89 04 24 mov %eax,(%esp) + 12c6: e8 d7 00 00 00 call 13a2 + if(fd < 0) + 12cb: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 12cd: 89 c3 mov %eax,%ebx + if(fd < 0) + 12cf: 78 27 js 12f8 + return -1; + r = fstat(fd, st); + 12d1: 8b 45 0c mov 0xc(%ebp),%eax + 12d4: 89 1c 24 mov %ebx,(%esp) + 12d7: 89 44 24 04 mov %eax,0x4(%esp) + 12db: e8 da 00 00 00 call 13ba + close(fd); + 12e0: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 12e3: 89 c6 mov %eax,%esi + close(fd); + 12e5: e8 a0 00 00 00 call 138a + return r; + 12ea: 89 f0 mov %esi,%eax +} + 12ec: 83 c4 10 add $0x10,%esp + 12ef: 5b pop %ebx + 12f0: 5e pop %esi + 12f1: 5d pop %ebp + 12f2: c3 ret + 12f3: 90 nop + 12f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 12f8: b8 ff ff ff ff mov $0xffffffff,%eax + 12fd: eb ed jmp 12ec + 12ff: 90 nop + +00001300 : + +int +atoi(const char *s) +{ + 1300: 55 push %ebp + 1301: 89 e5 mov %esp,%ebp + 1303: 8b 4d 08 mov 0x8(%ebp),%ecx + 1306: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 1307: 0f be 11 movsbl (%ecx),%edx + 130a: 8d 42 d0 lea -0x30(%edx),%eax + 130d: 3c 09 cmp $0x9,%al + n = 0; + 130f: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 1314: 77 17 ja 132d + 1316: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 1318: 83 c1 01 add $0x1,%ecx + 131b: 8d 04 80 lea (%eax,%eax,4),%eax + 131e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1322: 0f be 11 movsbl (%ecx),%edx + 1325: 8d 5a d0 lea -0x30(%edx),%ebx + 1328: 80 fb 09 cmp $0x9,%bl + 132b: 76 eb jbe 1318 + return n; +} + 132d: 5b pop %ebx + 132e: 5d pop %ebp + 132f: c3 ret + +00001330 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1330: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1331: 31 d2 xor %edx,%edx +{ + 1333: 89 e5 mov %esp,%ebp + 1335: 56 push %esi + 1336: 8b 45 08 mov 0x8(%ebp),%eax + 1339: 53 push %ebx + 133a: 8b 5d 10 mov 0x10(%ebp),%ebx + 133d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1340: 85 db test %ebx,%ebx + 1342: 7e 12 jle 1356 + 1344: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1348: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 134c: 88 0c 10 mov %cl,(%eax,%edx,1) + 134f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1352: 39 da cmp %ebx,%edx + 1354: 75 f2 jne 1348 + return vdst; +} + 1356: 5b pop %ebx + 1357: 5e pop %esi + 1358: 5d pop %ebp + 1359: c3 ret + +0000135a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 135a: b8 01 00 00 00 mov $0x1,%eax + 135f: cd 40 int $0x40 + 1361: c3 ret + +00001362 : +SYSCALL(exit) + 1362: b8 02 00 00 00 mov $0x2,%eax + 1367: cd 40 int $0x40 + 1369: c3 ret + +0000136a : +SYSCALL(wait) + 136a: b8 03 00 00 00 mov $0x3,%eax + 136f: cd 40 int $0x40 + 1371: c3 ret + +00001372 : +SYSCALL(pipe) + 1372: b8 04 00 00 00 mov $0x4,%eax + 1377: cd 40 int $0x40 + 1379: c3 ret + +0000137a : +SYSCALL(read) + 137a: b8 05 00 00 00 mov $0x5,%eax + 137f: cd 40 int $0x40 + 1381: c3 ret + +00001382 : +SYSCALL(write) + 1382: b8 10 00 00 00 mov $0x10,%eax + 1387: cd 40 int $0x40 + 1389: c3 ret + +0000138a : +SYSCALL(close) + 138a: b8 15 00 00 00 mov $0x15,%eax + 138f: cd 40 int $0x40 + 1391: c3 ret + +00001392 : +SYSCALL(kill) + 1392: b8 06 00 00 00 mov $0x6,%eax + 1397: cd 40 int $0x40 + 1399: c3 ret + +0000139a : +SYSCALL(exec) + 139a: b8 07 00 00 00 mov $0x7,%eax + 139f: cd 40 int $0x40 + 13a1: c3 ret + +000013a2 : +SYSCALL(open) + 13a2: b8 0f 00 00 00 mov $0xf,%eax + 13a7: cd 40 int $0x40 + 13a9: c3 ret + +000013aa : +SYSCALL(mknod) + 13aa: b8 11 00 00 00 mov $0x11,%eax + 13af: cd 40 int $0x40 + 13b1: c3 ret + +000013b2 : +SYSCALL(unlink) + 13b2: b8 12 00 00 00 mov $0x12,%eax + 13b7: cd 40 int $0x40 + 13b9: c3 ret + +000013ba : +SYSCALL(fstat) + 13ba: b8 08 00 00 00 mov $0x8,%eax + 13bf: cd 40 int $0x40 + 13c1: c3 ret + +000013c2 : +SYSCALL(link) + 13c2: b8 13 00 00 00 mov $0x13,%eax + 13c7: cd 40 int $0x40 + 13c9: c3 ret + +000013ca : +SYSCALL(mkdir) + 13ca: b8 14 00 00 00 mov $0x14,%eax + 13cf: cd 40 int $0x40 + 13d1: c3 ret + +000013d2 : +SYSCALL(chdir) + 13d2: b8 09 00 00 00 mov $0x9,%eax + 13d7: cd 40 int $0x40 + 13d9: c3 ret + +000013da : +SYSCALL(dup) + 13da: b8 0a 00 00 00 mov $0xa,%eax + 13df: cd 40 int $0x40 + 13e1: c3 ret + +000013e2 : +SYSCALL(getpid) + 13e2: b8 0b 00 00 00 mov $0xb,%eax + 13e7: cd 40 int $0x40 + 13e9: c3 ret + +000013ea : +SYSCALL(sbrk) + 13ea: b8 0c 00 00 00 mov $0xc,%eax + 13ef: cd 40 int $0x40 + 13f1: c3 ret + +000013f2 : +SYSCALL(sleep) + 13f2: b8 0d 00 00 00 mov $0xd,%eax + 13f7: cd 40 int $0x40 + 13f9: c3 ret + +000013fa : +SYSCALL(uptime) + 13fa: b8 0e 00 00 00 mov $0xe,%eax + 13ff: cd 40 int $0x40 + 1401: c3 ret + +00001402 : +SYSCALL(shm_open) + 1402: b8 16 00 00 00 mov $0x16,%eax + 1407: cd 40 int $0x40 + 1409: c3 ret + +0000140a : +SYSCALL(shm_close) + 140a: b8 17 00 00 00 mov $0x17,%eax + 140f: cd 40 int $0x40 + 1411: c3 ret + 1412: 66 90 xchg %ax,%ax + 1414: 66 90 xchg %ax,%ax + 1416: 66 90 xchg %ax,%ax + 1418: 66 90 xchg %ax,%ax + 141a: 66 90 xchg %ax,%ax + 141c: 66 90 xchg %ax,%ax + 141e: 66 90 xchg %ax,%ax + +00001420 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 1420: 55 push %ebp + 1421: 89 e5 mov %esp,%ebp + 1423: 57 push %edi + 1424: 56 push %esi + 1425: 89 c6 mov %eax,%esi + 1427: 53 push %ebx + 1428: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 142b: 8b 5d 08 mov 0x8(%ebp),%ebx + 142e: 85 db test %ebx,%ebx + 1430: 74 09 je 143b + 1432: 89 d0 mov %edx,%eax + 1434: c1 e8 1f shr $0x1f,%eax + 1437: 84 c0 test %al,%al + 1439: 75 75 jne 14b0 + neg = 1; + x = -xx; + } else { + x = xx; + 143b: 89 d0 mov %edx,%eax + neg = 0; + 143d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1444: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1447: 31 ff xor %edi,%edi + 1449: 89 ce mov %ecx,%esi + 144b: 8d 5d d7 lea -0x29(%ebp),%ebx + 144e: eb 02 jmp 1452 + do{ + buf[i++] = digits[x % base]; + 1450: 89 cf mov %ecx,%edi + 1452: 31 d2 xor %edx,%edx + 1454: f7 f6 div %esi + 1456: 8d 4f 01 lea 0x1(%edi),%ecx + 1459: 0f b6 92 8b 18 00 00 movzbl 0x188b(%edx),%edx + }while((x /= base) != 0); + 1460: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 1462: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 1465: 75 e9 jne 1450 + if(neg) + 1467: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 146a: 89 c8 mov %ecx,%eax + 146c: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 146f: 85 d2 test %edx,%edx + 1471: 74 08 je 147b + buf[i++] = '-'; + 1473: 8d 4f 02 lea 0x2(%edi),%ecx + 1476: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 147b: 8d 79 ff lea -0x1(%ecx),%edi + 147e: 66 90 xchg %ax,%ax + 1480: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 1485: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 1488: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 148f: 00 + 1490: 89 5c 24 04 mov %ebx,0x4(%esp) + 1494: 89 34 24 mov %esi,(%esp) + 1497: 88 45 d7 mov %al,-0x29(%ebp) + 149a: e8 e3 fe ff ff call 1382 + while(--i >= 0) + 149f: 83 ff ff cmp $0xffffffff,%edi + 14a2: 75 dc jne 1480 + putc(fd, buf[i]); +} + 14a4: 83 c4 4c add $0x4c,%esp + 14a7: 5b pop %ebx + 14a8: 5e pop %esi + 14a9: 5f pop %edi + 14aa: 5d pop %ebp + 14ab: c3 ret + 14ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 14b0: 89 d0 mov %edx,%eax + 14b2: f7 d8 neg %eax + neg = 1; + 14b4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 14bb: eb 87 jmp 1444 + 14bd: 8d 76 00 lea 0x0(%esi),%esi + +000014c0 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 14c0: 55 push %ebp + 14c1: 89 e5 mov %esp,%ebp + 14c3: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 14c4: 31 ff xor %edi,%edi +{ + 14c6: 56 push %esi + 14c7: 53 push %ebx + 14c8: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 14cb: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 14ce: 8d 45 10 lea 0x10(%ebp),%eax +{ + 14d1: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 14d4: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 14d7: 0f b6 13 movzbl (%ebx),%edx + 14da: 83 c3 01 add $0x1,%ebx + 14dd: 84 d2 test %dl,%dl + 14df: 75 39 jne 151a + 14e1: e9 c2 00 00 00 jmp 15a8 + 14e6: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 14e8: 83 fa 25 cmp $0x25,%edx + 14eb: 0f 84 bf 00 00 00 je 15b0 + write(fd, &c, 1); + 14f1: 8d 45 e2 lea -0x1e(%ebp),%eax + 14f4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14fb: 00 + 14fc: 89 44 24 04 mov %eax,0x4(%esp) + 1500: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 1503: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 1506: e8 77 fe ff ff call 1382 + 150b: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 150e: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 1512: 84 d2 test %dl,%dl + 1514: 0f 84 8e 00 00 00 je 15a8 + if(state == 0){ + 151a: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 151c: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 151f: 74 c7 je 14e8 + } + } else if(state == '%'){ + 1521: 83 ff 25 cmp $0x25,%edi + 1524: 75 e5 jne 150b + if(c == 'd'){ + 1526: 83 fa 64 cmp $0x64,%edx + 1529: 0f 84 31 01 00 00 je 1660 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 152f: 25 f7 00 00 00 and $0xf7,%eax + 1534: 83 f8 70 cmp $0x70,%eax + 1537: 0f 84 83 00 00 00 je 15c0 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 153d: 83 fa 73 cmp $0x73,%edx + 1540: 0f 84 a2 00 00 00 je 15e8 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1546: 83 fa 63 cmp $0x63,%edx + 1549: 0f 84 35 01 00 00 je 1684 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 154f: 83 fa 25 cmp $0x25,%edx + 1552: 0f 84 e0 00 00 00 je 1638 + write(fd, &c, 1); + 1558: 8d 45 e6 lea -0x1a(%ebp),%eax + 155b: 83 c3 01 add $0x1,%ebx + 155e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1565: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 1566: 31 ff xor %edi,%edi + write(fd, &c, 1); + 1568: 89 44 24 04 mov %eax,0x4(%esp) + 156c: 89 34 24 mov %esi,(%esp) + 156f: 89 55 d0 mov %edx,-0x30(%ebp) + 1572: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 1576: e8 07 fe ff ff call 1382 + putc(fd, c); + 157b: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 157e: 8d 45 e7 lea -0x19(%ebp),%eax + 1581: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1588: 00 + 1589: 89 44 24 04 mov %eax,0x4(%esp) + 158d: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 1590: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 1593: e8 ea fd ff ff call 1382 + for(i = 0; fmt[i]; i++){ + 1598: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 159c: 84 d2 test %dl,%dl + 159e: 0f 85 76 ff ff ff jne 151a + 15a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 15a8: 83 c4 3c add $0x3c,%esp + 15ab: 5b pop %ebx + 15ac: 5e pop %esi + 15ad: 5f pop %edi + 15ae: 5d pop %ebp + 15af: c3 ret + state = '%'; + 15b0: bf 25 00 00 00 mov $0x25,%edi + 15b5: e9 51 ff ff ff jmp 150b + 15ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 15c0: 8b 45 d4 mov -0x2c(%ebp),%eax + 15c3: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 15c8: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 15ca: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 15d1: 8b 10 mov (%eax),%edx + 15d3: 89 f0 mov %esi,%eax + 15d5: e8 46 fe ff ff call 1420 + ap++; + 15da: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 15de: e9 28 ff ff ff jmp 150b + 15e3: 90 nop + 15e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 15e8: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 15eb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 15ef: 8b 38 mov (%eax),%edi + s = "(null)"; + 15f1: b8 84 18 00 00 mov $0x1884,%eax + 15f6: 85 ff test %edi,%edi + 15f8: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 15fb: 0f b6 07 movzbl (%edi),%eax + 15fe: 84 c0 test %al,%al + 1600: 74 2a je 162c + 1602: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1608: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 160b: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 160e: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 1611: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1618: 00 + 1619: 89 44 24 04 mov %eax,0x4(%esp) + 161d: 89 34 24 mov %esi,(%esp) + 1620: e8 5d fd ff ff call 1382 + while(*s != 0){ + 1625: 0f b6 07 movzbl (%edi),%eax + 1628: 84 c0 test %al,%al + 162a: 75 dc jne 1608 + state = 0; + 162c: 31 ff xor %edi,%edi + 162e: e9 d8 fe ff ff jmp 150b + 1633: 90 nop + 1634: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1638: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 163b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 163d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1644: 00 + 1645: 89 44 24 04 mov %eax,0x4(%esp) + 1649: 89 34 24 mov %esi,(%esp) + 164c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1650: e8 2d fd ff ff call 1382 + 1655: e9 b1 fe ff ff jmp 150b + 165a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 1660: 8b 45 d4 mov -0x2c(%ebp),%eax + 1663: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 1668: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 166b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1672: 8b 10 mov (%eax),%edx + 1674: 89 f0 mov %esi,%eax + 1676: e8 a5 fd ff ff call 1420 + ap++; + 167b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 167f: e9 87 fe ff ff jmp 150b + putc(fd, *ap); + 1684: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 1687: 31 ff xor %edi,%edi + putc(fd, *ap); + 1689: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 168b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1692: 00 + 1693: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 1696: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 1699: 8d 45 e4 lea -0x1c(%ebp),%eax + 169c: 89 44 24 04 mov %eax,0x4(%esp) + 16a0: e8 dd fc ff ff call 1382 + ap++; + 16a5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 16a9: e9 5d fe ff ff jmp 150b + 16ae: 66 90 xchg %ax,%ax + +000016b0 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 16b0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 16b1: a1 44 1b 00 00 mov 0x1b44,%eax +{ + 16b6: 89 e5 mov %esp,%ebp + 16b8: 57 push %edi + 16b9: 56 push %esi + 16ba: 53 push %ebx + 16bb: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 16be: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 16c0: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 16c3: 39 d0 cmp %edx,%eax + 16c5: 72 11 jb 16d8 + 16c7: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 16c8: 39 c8 cmp %ecx,%eax + 16ca: 72 04 jb 16d0 + 16cc: 39 ca cmp %ecx,%edx + 16ce: 72 10 jb 16e0 + 16d0: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 16d2: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 16d4: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 16d6: 73 f0 jae 16c8 + 16d8: 39 ca cmp %ecx,%edx + 16da: 72 04 jb 16e0 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 16dc: 39 c8 cmp %ecx,%eax + 16de: 72 f0 jb 16d0 + break; + if(bp + bp->s.size == p->s.ptr){ + 16e0: 8b 73 fc mov -0x4(%ebx),%esi + 16e3: 8d 3c f2 lea (%edx,%esi,8),%edi + 16e6: 39 cf cmp %ecx,%edi + 16e8: 74 1e je 1708 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 16ea: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 16ed: 8b 48 04 mov 0x4(%eax),%ecx + 16f0: 8d 34 c8 lea (%eax,%ecx,8),%esi + 16f3: 39 f2 cmp %esi,%edx + 16f5: 74 28 je 171f + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 16f7: 89 10 mov %edx,(%eax) + freep = p; + 16f9: a3 44 1b 00 00 mov %eax,0x1b44 +} + 16fe: 5b pop %ebx + 16ff: 5e pop %esi + 1700: 5f pop %edi + 1701: 5d pop %ebp + 1702: c3 ret + 1703: 90 nop + 1704: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 1708: 03 71 04 add 0x4(%ecx),%esi + 170b: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 170e: 8b 08 mov (%eax),%ecx + 1710: 8b 09 mov (%ecx),%ecx + 1712: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 1715: 8b 48 04 mov 0x4(%eax),%ecx + 1718: 8d 34 c8 lea (%eax,%ecx,8),%esi + 171b: 39 f2 cmp %esi,%edx + 171d: 75 d8 jne 16f7 + p->s.size += bp->s.size; + 171f: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 1722: a3 44 1b 00 00 mov %eax,0x1b44 + p->s.size += bp->s.size; + 1727: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 172a: 8b 53 f8 mov -0x8(%ebx),%edx + 172d: 89 10 mov %edx,(%eax) +} + 172f: 5b pop %ebx + 1730: 5e pop %esi + 1731: 5f pop %edi + 1732: 5d pop %ebp + 1733: c3 ret + 1734: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 173a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001740 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1740: 55 push %ebp + 1741: 89 e5 mov %esp,%ebp + 1743: 57 push %edi + 1744: 56 push %esi + 1745: 53 push %ebx + 1746: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1749: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 174c: 8b 1d 44 1b 00 00 mov 0x1b44,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1752: 8d 48 07 lea 0x7(%eax),%ecx + 1755: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1758: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 175a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 175d: 0f 84 9b 00 00 00 je 17fe + 1763: 8b 13 mov (%ebx),%edx + 1765: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 1768: 39 fe cmp %edi,%esi + 176a: 76 64 jbe 17d0 + 176c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 1773: bb 00 80 00 00 mov $0x8000,%ebx + 1778: 89 45 e4 mov %eax,-0x1c(%ebp) + 177b: eb 0e jmp 178b + 177d: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 1780: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 1782: 8b 78 04 mov 0x4(%eax),%edi + 1785: 39 fe cmp %edi,%esi + 1787: 76 4f jbe 17d8 + 1789: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 178b: 3b 15 44 1b 00 00 cmp 0x1b44,%edx + 1791: 75 ed jne 1780 + if(nu < 4096) + 1793: 8b 45 e4 mov -0x1c(%ebp),%eax + 1796: 81 fe 00 10 00 00 cmp $0x1000,%esi + 179c: bf 00 10 00 00 mov $0x1000,%edi + 17a1: 0f 43 fe cmovae %esi,%edi + 17a4: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 17a7: 89 04 24 mov %eax,(%esp) + 17aa: e8 3b fc ff ff call 13ea + if(p == (char*)-1) + 17af: 83 f8 ff cmp $0xffffffff,%eax + 17b2: 74 18 je 17cc + hp->s.size = nu; + 17b4: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 17b7: 83 c0 08 add $0x8,%eax + 17ba: 89 04 24 mov %eax,(%esp) + 17bd: e8 ee fe ff ff call 16b0 + return freep; + 17c2: 8b 15 44 1b 00 00 mov 0x1b44,%edx + if((p = morecore(nunits)) == 0) + 17c8: 85 d2 test %edx,%edx + 17ca: 75 b4 jne 1780 + return 0; + 17cc: 31 c0 xor %eax,%eax + 17ce: eb 20 jmp 17f0 + if(p->s.size >= nunits){ + 17d0: 89 d0 mov %edx,%eax + 17d2: 89 da mov %ebx,%edx + 17d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 17d8: 39 fe cmp %edi,%esi + 17da: 74 1c je 17f8 + p->s.size -= nunits; + 17dc: 29 f7 sub %esi,%edi + 17de: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 17e1: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 17e4: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 17e7: 89 15 44 1b 00 00 mov %edx,0x1b44 + return (void*)(p + 1); + 17ed: 83 c0 08 add $0x8,%eax + } +} + 17f0: 83 c4 1c add $0x1c,%esp + 17f3: 5b pop %ebx + 17f4: 5e pop %esi + 17f5: 5f pop %edi + 17f6: 5d pop %ebp + 17f7: c3 ret + prevp->s.ptr = p->s.ptr; + 17f8: 8b 08 mov (%eax),%ecx + 17fa: 89 0a mov %ecx,(%edx) + 17fc: eb e9 jmp 17e7 + base.s.ptr = freep = prevp = &base; + 17fe: c7 05 44 1b 00 00 48 movl $0x1b48,0x1b44 + 1805: 1b 00 00 + base.s.size = 0; + 1808: ba 48 1b 00 00 mov $0x1b48,%edx + base.s.ptr = freep = prevp = &base; + 180d: c7 05 48 1b 00 00 48 movl $0x1b48,0x1b48 + 1814: 1b 00 00 + base.s.size = 0; + 1817: c7 05 4c 1b 00 00 00 movl $0x0,0x1b4c + 181e: 00 00 00 + 1821: e9 46 ff ff ff jmp 176c + 1826: 66 90 xchg %ax,%ax + 1828: 66 90 xchg %ax,%ax + 182a: 66 90 xchg %ax,%ax + 182c: 66 90 xchg %ax,%ax + 182e: 66 90 xchg %ax,%ax + +00001830 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1830: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1831: b9 01 00 00 00 mov $0x1,%ecx + 1836: 89 e5 mov %esp,%ebp + 1838: 8b 55 08 mov 0x8(%ebp),%edx + 183b: 90 nop + 183c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1840: 89 c8 mov %ecx,%eax + 1842: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1845: 85 c0 test %eax,%eax + 1847: 75 f7 jne 1840 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1849: 0f ae f0 mfence +} + 184c: 5d pop %ebp + 184d: c3 ret + 184e: 66 90 xchg %ax,%ax + +00001850 : + +void urelease (struct uspinlock *lk) { + 1850: 55 push %ebp + 1851: 89 e5 mov %esp,%ebp + 1853: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1856: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1859: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 185f: 5d pop %ebp + 1860: c3 ret diff --git a/stressfs.d b/stressfs.d new file mode 100644 index 00000000..7d5de54b --- /dev/null +++ b/stressfs.d @@ -0,0 +1,2 @@ +stressfs.o: stressfs.c /usr/include/stdc-predef.h types.h stat.h user.h \ + fs.h fcntl.h diff --git a/stressfs.o b/stressfs.o new file mode 100644 index 00000000..da9e5139 Binary files /dev/null and b/stressfs.o differ diff --git a/stressfs.sym b/stressfs.sym new file mode 100644 index 00000000..5f079295 --- /dev/null +++ b/stressfs.sym @@ -0,0 +1,62 @@ +00001000 .text +00001861 .rodata +0000189c .eh_frame +00001b44 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 stressfs.c +00000000 ulib.c +00000000 printf.c +00001420 printint +0000188b digits.1359 +00000000 umalloc.c +00001b44 freep +00001b48 base +00000000 uspinlock.c +00001140 strcpy +000014c0 printf +00001330 memmove +000013aa mknod +00001402 shm_open +00001250 gets +000013e2 getpid +00001740 malloc +000013f2 sleep +00001372 pipe +00001382 write +000013ba fstat +00001392 kill +000013d2 chdir +0000139a exec +0000136a wait +0000137a read +000013b2 unlink +00001830 uacquire +0000135a fork +000013ea sbrk +0000140a shm_close +000013fa uptime +00001b44 __bss_start +000011f0 memset +00001000 main +00001170 strcmp +000013da dup +000012b0 stat +00001b44 _edata +00001b50 _end +000013c2 link +00001362 exit +00001300 atoi +000011c0 strlen +000013a2 open +00001210 strchr +000013ca mkdir +0000138a close +00001850 urelease +000016b0 free diff --git a/string.d b/string.d new file mode 100644 index 00000000..68931ed4 --- /dev/null +++ b/string.d @@ -0,0 +1 @@ +string.o: string.c /usr/include/stdc-predef.h types.h x86.h diff --git a/string.o b/string.o new file mode 100644 index 00000000..91fa1ca7 Binary files /dev/null and b/string.o differ diff --git a/swtch.o b/swtch.o new file mode 100644 index 00000000..d5770abb Binary files /dev/null and b/swtch.o differ diff --git a/syscall.c b/syscall.c index 94ef3c95..0ef07d01 100644 --- a/syscall.c +++ b/syscall.c @@ -17,10 +17,10 @@ int fetchint(uint addr, int *ip) { - struct proc *curproc = myproc(); - - if(addr >= curproc->sz || addr+4 > curproc->sz) + // ** changed range from sz to KERNBASE + if(addr >= KERNBASE|| addr+4 > KERNBASE ) return -1; + *ip = *(int*)(addr); return 0; } @@ -33,8 +33,7 @@ fetchstr(uint addr, char **pp) { char *s, *ep; struct proc *curproc = myproc(); - - if(addr >= curproc->sz) + if(addr >= KERNBASE) return -1; *pp = (char*)addr; ep = (char*)curproc->sz; @@ -59,11 +58,11 @@ int argptr(int n, char **pp, int size) { int i; - struct proc *curproc = myproc(); - + + // ** changed range from sz to KERNBASE if(argint(n, &i) < 0) return -1; - if(size < 0 || (uint)i >= curproc->sz || (uint)i+size > curproc->sz) + if(size < 0 || (uint)i >= KERNBASE || (uint)i+size > KERNBASE) return -1; *pp = (char*)i; return 0; diff --git a/syscall.d b/syscall.d new file mode 100644 index 00000000..4649283d --- /dev/null +++ b/syscall.d @@ -0,0 +1,2 @@ +syscall.o: syscall.c /usr/include/stdc-predef.h types.h defs.h param.h \ + memlayout.h mmu.h proc.h x86.h syscall.h diff --git a/syscall.o b/syscall.o new file mode 100644 index 00000000..7bd071d9 Binary files /dev/null and b/syscall.o differ diff --git a/sysfile.c b/sysfile.c index 87e508b2..2cb9bf45 100644 --- a/sysfile.c +++ b/sysfile.c @@ -442,4 +442,4 @@ sys_pipe(void) fd[0] = fd0; fd[1] = fd1; return 0; -} +} \ No newline at end of file diff --git a/sysfile.d b/sysfile.d new file mode 100644 index 00000000..74f1a207 --- /dev/null +++ b/sysfile.d @@ -0,0 +1,2 @@ +sysfile.o: sysfile.c /usr/include/stdc-predef.h types.h defs.h param.h \ + stat.h mmu.h proc.h fs.h spinlock.h sleeplock.h file.h fcntl.h diff --git a/sysfile.o b/sysfile.o new file mode 100644 index 00000000..1dedd99a Binary files /dev/null and b/sysfile.o differ diff --git a/sysproc.d b/sysproc.d new file mode 100644 index 00000000..2f26f0c3 --- /dev/null +++ b/sysproc.d @@ -0,0 +1,2 @@ +sysproc.o: sysproc.c /usr/include/stdc-predef.h types.h x86.h defs.h \ + date.h param.h memlayout.h mmu.h proc.h diff --git a/sysproc.o b/sysproc.o new file mode 100644 index 00000000..8b154b59 Binary files /dev/null and b/sysproc.o differ diff --git a/trap.c b/trap.c index 41c66ebf..d3122f3d 100644 --- a/trap.c +++ b/trap.c @@ -13,6 +13,9 @@ struct gatedesc idt[256]; extern uint vectors[]; // in vectors.S: array of 256 entry pointers struct spinlock tickslock; uint ticks; +uint last; +uint bottom; +uint top; void tvinit(void) @@ -77,6 +80,15 @@ trap(struct trapframe *tf) cpuid(), tf->cs, tf->eip); lapiceoi(); break; + // ** Added a case for page fault + case T_PGFLT: ; + if(allocuvm(myproc()->pgdir, KERNBASE - (myproc()->num_pages * PGSIZE * 2), PGROUNDUP(rcr2())) == 0){ + cprintf("PAGEFAULT\n"); + break; + } + myproc()->num_pages = myproc()->num_pages+ 1; + cprintf("Page count increased to: %d \n", myproc()->num_pages); + break; //PAGEBREAK: 13 default: diff --git a/trap.d b/trap.d new file mode 100644 index 00000000..c48ab899 --- /dev/null +++ b/trap.d @@ -0,0 +1,2 @@ +trap.o: trap.c /usr/include/stdc-predef.h types.h defs.h param.h \ + memlayout.h mmu.h proc.h x86.h traps.h spinlock.h diff --git a/trap.o b/trap.o new file mode 100644 index 00000000..d59fb62c Binary files /dev/null and b/trap.o differ diff --git a/trapasm.o b/trapasm.o new file mode 100644 index 00000000..c1077920 Binary files /dev/null and b/trapasm.o differ diff --git a/uart.d b/uart.d new file mode 100644 index 00000000..d156629d --- /dev/null +++ b/uart.d @@ -0,0 +1,2 @@ +uart.o: uart.c /usr/include/stdc-predef.h types.h defs.h param.h traps.h \ + spinlock.h sleeplock.h fs.h file.h mmu.h proc.h x86.h diff --git a/uart.o b/uart.o new file mode 100644 index 00000000..b22c47b3 Binary files /dev/null and b/uart.o differ diff --git a/ulib.d b/ulib.d new file mode 100644 index 00000000..61f575ef --- /dev/null +++ b/ulib.d @@ -0,0 +1,2 @@ +ulib.o: ulib.c /usr/include/stdc-predef.h types.h stat.h fcntl.h user.h \ + x86.h diff --git a/ulib.o b/ulib.o new file mode 100644 index 00000000..2ee03533 Binary files /dev/null and b/ulib.o differ diff --git a/umalloc.d b/umalloc.d new file mode 100644 index 00000000..cc1d1524 --- /dev/null +++ b/umalloc.d @@ -0,0 +1,2 @@ +umalloc.o: umalloc.c /usr/include/stdc-predef.h types.h stat.h user.h \ + param.h diff --git a/umalloc.o b/umalloc.o new file mode 100644 index 00000000..2e366d1b Binary files /dev/null and b/umalloc.o differ diff --git a/usertests.asm b/usertests.asm new file mode 100644 index 00000000..0313aa9f --- /dev/null +++ b/usertests.asm @@ -0,0 +1,6298 @@ + +_usertests: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: + return randstate; +} + +int +main(int argc, char *argv[]) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 83 e4 f0 and $0xfffffff0,%esp + 1006: 83 ec 10 sub $0x10,%esp + printf(1, "usertests starting\n"); + 1009: c7 44 24 04 92 61 00 movl $0x6192,0x4(%esp) + 1010: 00 + 1011: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1018: e8 e3 3d 00 00 call 4e00 + + if(open("usertests.ran", 0) >= 0){ + 101d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1024: 00 + 1025: c7 04 24 a6 61 00 00 movl $0x61a6,(%esp) + 102c: e8 b1 3c 00 00 call 4ce2 + 1031: 85 c0 test %eax,%eax + 1033: 78 19 js 104e + printf(1, "already ran user tests -- rebuild fs.img\n"); + 1035: c7 44 24 04 10 69 00 movl $0x6910,0x4(%esp) + 103c: 00 + 103d: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1044: e8 b7 3d 00 00 call 4e00 + exit(); + 1049: e8 54 3c 00 00 call 4ca2 + } + close(open("usertests.ran", O_CREATE)); + 104e: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) + 1055: 00 + 1056: c7 04 24 a6 61 00 00 movl $0x61a6,(%esp) + 105d: e8 80 3c 00 00 call 4ce2 + 1062: 89 04 24 mov %eax,(%esp) + 1065: e8 60 3c 00 00 call 4cca + + argptest(); + 106a: e8 71 39 00 00 call 49e0 + createdelete(); + 106f: e8 9c 12 00 00 call 2310 + linkunlink(); + 1074: e8 27 1c 00 00 call 2ca0 + concreate(); + 1079: e8 02 19 00 00 call 2980 + 107e: 66 90 xchg %ax,%ax + fourfiles(); + 1080: e8 7b 10 00 00 call 2100 + sharedfd(); + 1085: e8 96 0e 00 00 call 1f20 + + bigargtest(); + 108a: e8 c1 35 00 00 call 4650 + 108f: 90 nop + bigwrite(); + 1090: e8 fb 25 00 00 call 3690 + bigargtest(); + 1095: e8 b6 35 00 00 call 4650 + bsstest(); + 109a: e8 31 35 00 00 call 45d0 + 109f: 90 nop + sbrktest(); + 10a0: e8 0b 30 00 00 call 40b0 + validatetest(); + 10a5: e8 76 34 00 00 call 4520 + + opentest(); + 10aa: e8 61 03 00 00 call 1410 + 10af: 90 nop + writetest(); + 10b0: e8 fb 03 00 00 call 14b0 + writetest1(); + 10b5: e8 06 06 00 00 call 16c0 + createtest(); + 10ba: e8 f1 07 00 00 call 18b0 + 10bf: 90 nop + + openiputtest(); + 10c0: e8 3b 02 00 00 call 1300 + exitiputtest(); + 10c5: e8 46 01 00 00 call 1210 + iputtest(); + 10ca: e8 61 00 00 00 call 1130 + 10cf: 90 nop + + mem(); + 10d0: e8 6b 0d 00 00 call 1e40 + pipe1(); + 10d5: e8 b6 09 00 00 call 1a90 + preempt(); + 10da: e8 71 0b 00 00 call 1c50 + 10df: 90 nop + exitwait(); + 10e0: e8 cb 0c 00 00 call 1db0 + + rmdot(); + 10e5: e8 06 2a 00 00 call 3af0 + fourteen(); + 10ea: e8 a1 28 00 00 call 3990 + 10ef: 90 nop + bigfile(); + 10f0: e8 9b 26 00 00 call 3790 + subdir(); + 10f5: e8 06 1e 00 00 call 2f00 + linktest(); + 10fa: e8 21 16 00 00 call 2720 + 10ff: 90 nop + unlinkread(); + 1100: e8 4b 14 00 00 call 2550 + dirfile(); + 1105: e8 76 2b 00 00 call 3c80 + iref(); + 110a: e8 b1 2d 00 00 call 3ec0 + 110f: 90 nop + forktest(); + 1110: e8 cb 2e 00 00 call 3fe0 + bigdir(); // slow + 1115: e8 96 1c 00 00 call 2db0 + + uio(); + 111a: e8 41 38 00 00 call 4960 + 111f: 90 nop + + exectest(); + 1120: e8 1b 09 00 00 call 1a40 + + exit(); + 1125: e8 78 3b 00 00 call 4ca2 + 112a: 66 90 xchg %ax,%ax + 112c: 66 90 xchg %ax,%ax + 112e: 66 90 xchg %ax,%ax + +00001130 : +{ + 1130: 55 push %ebp + 1131: 89 e5 mov %esp,%ebp + 1133: 83 ec 18 sub $0x18,%esp + printf(stdout, "iput test\n"); + 1136: a1 60 72 00 00 mov 0x7260,%eax + 113b: c7 44 24 04 38 52 00 movl $0x5238,0x4(%esp) + 1142: 00 + 1143: 89 04 24 mov %eax,(%esp) + 1146: e8 b5 3c 00 00 call 4e00 + if(mkdir("iputdir") < 0){ + 114b: c7 04 24 cb 51 00 00 movl $0x51cb,(%esp) + 1152: e8 b3 3b 00 00 call 4d0a + 1157: 85 c0 test %eax,%eax + 1159: 78 4b js 11a6 + if(chdir("iputdir") < 0){ + 115b: c7 04 24 cb 51 00 00 movl $0x51cb,(%esp) + 1162: e8 ab 3b 00 00 call 4d12 + 1167: 85 c0 test %eax,%eax + 1169: 0f 88 85 00 00 00 js 11f4 + if(unlink("../iputdir") < 0){ + 116f: c7 04 24 c8 51 00 00 movl $0x51c8,(%esp) + 1176: e8 77 3b 00 00 call 4cf2 + 117b: 85 c0 test %eax,%eax + 117d: 78 5b js 11da + if(chdir("/") < 0){ + 117f: c7 04 24 ed 51 00 00 movl $0x51ed,(%esp) + 1186: e8 87 3b 00 00 call 4d12 + 118b: 85 c0 test %eax,%eax + 118d: 78 31 js 11c0 + printf(stdout, "iput test ok\n"); + 118f: a1 60 72 00 00 mov 0x7260,%eax + 1194: c7 44 24 04 70 52 00 movl $0x5270,0x4(%esp) + 119b: 00 + 119c: 89 04 24 mov %eax,(%esp) + 119f: e8 5c 3c 00 00 call 4e00 +} + 11a4: c9 leave + 11a5: c3 ret + printf(stdout, "mkdir failed\n"); + 11a6: a1 60 72 00 00 mov 0x7260,%eax + 11ab: c7 44 24 04 a4 51 00 movl $0x51a4,0x4(%esp) + 11b2: 00 + 11b3: 89 04 24 mov %eax,(%esp) + 11b6: e8 45 3c 00 00 call 4e00 + exit(); + 11bb: e8 e2 3a 00 00 call 4ca2 + printf(stdout, "chdir / failed\n"); + 11c0: a1 60 72 00 00 mov 0x7260,%eax + 11c5: c7 44 24 04 ef 51 00 movl $0x51ef,0x4(%esp) + 11cc: 00 + 11cd: 89 04 24 mov %eax,(%esp) + 11d0: e8 2b 3c 00 00 call 4e00 + exit(); + 11d5: e8 c8 3a 00 00 call 4ca2 + printf(stdout, "unlink ../iputdir failed\n"); + 11da: a1 60 72 00 00 mov 0x7260,%eax + 11df: c7 44 24 04 d3 51 00 movl $0x51d3,0x4(%esp) + 11e6: 00 + 11e7: 89 04 24 mov %eax,(%esp) + 11ea: e8 11 3c 00 00 call 4e00 + exit(); + 11ef: e8 ae 3a 00 00 call 4ca2 + printf(stdout, "chdir iputdir failed\n"); + 11f4: a1 60 72 00 00 mov 0x7260,%eax + 11f9: c7 44 24 04 b2 51 00 movl $0x51b2,0x4(%esp) + 1200: 00 + 1201: 89 04 24 mov %eax,(%esp) + 1204: e8 f7 3b 00 00 call 4e00 + exit(); + 1209: e8 94 3a 00 00 call 4ca2 + 120e: 66 90 xchg %ax,%ax + +00001210 : +{ + 1210: 55 push %ebp + 1211: 89 e5 mov %esp,%ebp + 1213: 83 ec 18 sub $0x18,%esp + printf(stdout, "exitiput test\n"); + 1216: a1 60 72 00 00 mov 0x7260,%eax + 121b: c7 44 24 04 ff 51 00 movl $0x51ff,0x4(%esp) + 1222: 00 + 1223: 89 04 24 mov %eax,(%esp) + 1226: e8 d5 3b 00 00 call 4e00 + pid = fork(); + 122b: e8 6a 3a 00 00 call 4c9a + if(pid < 0){ + 1230: 85 c0 test %eax,%eax + 1232: 78 76 js 12aa + if(pid == 0){ + 1234: 75 3a jne 1270 + if(mkdir("iputdir") < 0){ + 1236: c7 04 24 cb 51 00 00 movl $0x51cb,(%esp) + 123d: e8 c8 3a 00 00 call 4d0a + 1242: 85 c0 test %eax,%eax + 1244: 0f 88 94 00 00 00 js 12de + if(chdir("iputdir") < 0){ + 124a: c7 04 24 cb 51 00 00 movl $0x51cb,(%esp) + 1251: e8 bc 3a 00 00 call 4d12 + 1256: 85 c0 test %eax,%eax + 1258: 78 6a js 12c4 + if(unlink("../iputdir") < 0){ + 125a: c7 04 24 c8 51 00 00 movl $0x51c8,(%esp) + 1261: e8 8c 3a 00 00 call 4cf2 + 1266: 85 c0 test %eax,%eax + 1268: 78 26 js 1290 + exit(); + 126a: e8 33 3a 00 00 call 4ca2 + 126f: 90 nop + wait(); + 1270: e8 35 3a 00 00 call 4caa + printf(stdout, "exitiput test ok\n"); + 1275: a1 60 72 00 00 mov 0x7260,%eax + 127a: c7 44 24 04 22 52 00 movl $0x5222,0x4(%esp) + 1281: 00 + 1282: 89 04 24 mov %eax,(%esp) + 1285: e8 76 3b 00 00 call 4e00 +} + 128a: c9 leave + 128b: c3 ret + 128c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + printf(stdout, "unlink ../iputdir failed\n"); + 1290: a1 60 72 00 00 mov 0x7260,%eax + 1295: c7 44 24 04 d3 51 00 movl $0x51d3,0x4(%esp) + 129c: 00 + 129d: 89 04 24 mov %eax,(%esp) + 12a0: e8 5b 3b 00 00 call 4e00 + exit(); + 12a5: e8 f8 39 00 00 call 4ca2 + printf(stdout, "fork failed\n"); + 12aa: a1 60 72 00 00 mov 0x7260,%eax + 12af: c7 44 24 04 e5 60 00 movl $0x60e5,0x4(%esp) + 12b6: 00 + 12b7: 89 04 24 mov %eax,(%esp) + 12ba: e8 41 3b 00 00 call 4e00 + exit(); + 12bf: e8 de 39 00 00 call 4ca2 + printf(stdout, "child chdir failed\n"); + 12c4: a1 60 72 00 00 mov 0x7260,%eax + 12c9: c7 44 24 04 0e 52 00 movl $0x520e,0x4(%esp) + 12d0: 00 + 12d1: 89 04 24 mov %eax,(%esp) + 12d4: e8 27 3b 00 00 call 4e00 + exit(); + 12d9: e8 c4 39 00 00 call 4ca2 + printf(stdout, "mkdir failed\n"); + 12de: a1 60 72 00 00 mov 0x7260,%eax + 12e3: c7 44 24 04 a4 51 00 movl $0x51a4,0x4(%esp) + 12ea: 00 + 12eb: 89 04 24 mov %eax,(%esp) + 12ee: e8 0d 3b 00 00 call 4e00 + exit(); + 12f3: e8 aa 39 00 00 call 4ca2 + 12f8: 90 nop + 12f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001300 : +{ + 1300: 55 push %ebp + 1301: 89 e5 mov %esp,%ebp + 1303: 83 ec 18 sub $0x18,%esp + printf(stdout, "openiput test\n"); + 1306: a1 60 72 00 00 mov 0x7260,%eax + 130b: c7 44 24 04 34 52 00 movl $0x5234,0x4(%esp) + 1312: 00 + 1313: 89 04 24 mov %eax,(%esp) + 1316: e8 e5 3a 00 00 call 4e00 + if(mkdir("oidir") < 0){ + 131b: c7 04 24 43 52 00 00 movl $0x5243,(%esp) + 1322: e8 e3 39 00 00 call 4d0a + 1327: 85 c0 test %eax,%eax + 1329: 0f 88 9e 00 00 00 js 13cd + pid = fork(); + 132f: e8 66 39 00 00 call 4c9a + if(pid < 0){ + 1334: 85 c0 test %eax,%eax + 1336: 0f 88 ab 00 00 00 js 13e7 + 133c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(pid == 0){ + 1340: 75 36 jne 1378 + int fd = open("oidir", O_RDWR); + 1342: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) + 1349: 00 + 134a: c7 04 24 43 52 00 00 movl $0x5243,(%esp) + 1351: e8 8c 39 00 00 call 4ce2 + if(fd >= 0){ + 1356: 85 c0 test %eax,%eax + 1358: 78 6e js 13c8 + printf(stdout, "open directory for write succeeded\n"); + 135a: a1 60 72 00 00 mov 0x7260,%eax + 135f: c7 44 24 04 c8 61 00 movl $0x61c8,0x4(%esp) + 1366: 00 + 1367: 89 04 24 mov %eax,(%esp) + 136a: e8 91 3a 00 00 call 4e00 + exit(); + 136f: e8 2e 39 00 00 call 4ca2 + 1374: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + sleep(1); + 1378: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 137f: e8 ae 39 00 00 call 4d32 + if(unlink("oidir") != 0){ + 1384: c7 04 24 43 52 00 00 movl $0x5243,(%esp) + 138b: e8 62 39 00 00 call 4cf2 + 1390: 85 c0 test %eax,%eax + 1392: 75 1c jne 13b0 + wait(); + 1394: e8 11 39 00 00 call 4caa + printf(stdout, "openiput test ok\n"); + 1399: a1 60 72 00 00 mov 0x7260,%eax + 139e: c7 44 24 04 6c 52 00 movl $0x526c,0x4(%esp) + 13a5: 00 + 13a6: 89 04 24 mov %eax,(%esp) + 13a9: e8 52 3a 00 00 call 4e00 +} + 13ae: c9 leave + 13af: c3 ret + printf(stdout, "unlink failed\n"); + 13b0: a1 60 72 00 00 mov 0x7260,%eax + 13b5: c7 44 24 04 5d 52 00 movl $0x525d,0x4(%esp) + 13bc: 00 + 13bd: 89 04 24 mov %eax,(%esp) + 13c0: e8 3b 3a 00 00 call 4e00 + 13c5: 8d 76 00 lea 0x0(%esi),%esi + exit(); + 13c8: e8 d5 38 00 00 call 4ca2 + printf(stdout, "mkdir oidir failed\n"); + 13cd: a1 60 72 00 00 mov 0x7260,%eax + 13d2: c7 44 24 04 49 52 00 movl $0x5249,0x4(%esp) + 13d9: 00 + 13da: 89 04 24 mov %eax,(%esp) + 13dd: e8 1e 3a 00 00 call 4e00 + exit(); + 13e2: e8 bb 38 00 00 call 4ca2 + printf(stdout, "fork failed\n"); + 13e7: a1 60 72 00 00 mov 0x7260,%eax + 13ec: c7 44 24 04 e5 60 00 movl $0x60e5,0x4(%esp) + 13f3: 00 + 13f4: 89 04 24 mov %eax,(%esp) + 13f7: e8 04 3a 00 00 call 4e00 + exit(); + 13fc: e8 a1 38 00 00 call 4ca2 + 1401: eb 0d jmp 1410 + 1403: 90 nop + 1404: 90 nop + 1405: 90 nop + 1406: 90 nop + 1407: 90 nop + 1408: 90 nop + 1409: 90 nop + 140a: 90 nop + 140b: 90 nop + 140c: 90 nop + 140d: 90 nop + 140e: 90 nop + 140f: 90 nop + +00001410 : +{ + 1410: 55 push %ebp + 1411: 89 e5 mov %esp,%ebp + 1413: 83 ec 18 sub $0x18,%esp + printf(stdout, "open test\n"); + 1416: a1 60 72 00 00 mov 0x7260,%eax + 141b: c7 44 24 04 7e 52 00 movl $0x527e,0x4(%esp) + 1422: 00 + 1423: 89 04 24 mov %eax,(%esp) + 1426: e8 d5 39 00 00 call 4e00 + fd = open("echo", 0); + 142b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1432: 00 + 1433: c7 04 24 89 52 00 00 movl $0x5289,(%esp) + 143a: e8 a3 38 00 00 call 4ce2 + if(fd < 0){ + 143f: 85 c0 test %eax,%eax + 1441: 78 37 js 147a + close(fd); + 1443: 89 04 24 mov %eax,(%esp) + 1446: e8 7f 38 00 00 call 4cca + fd = open("doesnotexist", 0); + 144b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1452: 00 + 1453: c7 04 24 a1 52 00 00 movl $0x52a1,(%esp) + 145a: e8 83 38 00 00 call 4ce2 + if(fd >= 0){ + 145f: 85 c0 test %eax,%eax + 1461: 79 31 jns 1494 + printf(stdout, "open test ok\n"); + 1463: a1 60 72 00 00 mov 0x7260,%eax + 1468: c7 44 24 04 cc 52 00 movl $0x52cc,0x4(%esp) + 146f: 00 + 1470: 89 04 24 mov %eax,(%esp) + 1473: e8 88 39 00 00 call 4e00 +} + 1478: c9 leave + 1479: c3 ret + printf(stdout, "open echo failed!\n"); + 147a: a1 60 72 00 00 mov 0x7260,%eax + 147f: c7 44 24 04 8e 52 00 movl $0x528e,0x4(%esp) + 1486: 00 + 1487: 89 04 24 mov %eax,(%esp) + 148a: e8 71 39 00 00 call 4e00 + exit(); + 148f: e8 0e 38 00 00 call 4ca2 + printf(stdout, "open doesnotexist succeeded!\n"); + 1494: a1 60 72 00 00 mov 0x7260,%eax + 1499: c7 44 24 04 ae 52 00 movl $0x52ae,0x4(%esp) + 14a0: 00 + 14a1: 89 04 24 mov %eax,(%esp) + 14a4: e8 57 39 00 00 call 4e00 + exit(); + 14a9: e8 f4 37 00 00 call 4ca2 + 14ae: 66 90 xchg %ax,%ax + +000014b0 : +{ + 14b0: 55 push %ebp + 14b1: 89 e5 mov %esp,%ebp + 14b3: 56 push %esi + 14b4: 53 push %ebx + 14b5: 83 ec 10 sub $0x10,%esp + printf(stdout, "small file test\n"); + 14b8: a1 60 72 00 00 mov 0x7260,%eax + 14bd: c7 44 24 04 da 52 00 movl $0x52da,0x4(%esp) + 14c4: 00 + 14c5: 89 04 24 mov %eax,(%esp) + 14c8: e8 33 39 00 00 call 4e00 + fd = open("small", O_CREATE|O_RDWR); + 14cd: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 14d4: 00 + 14d5: c7 04 24 eb 52 00 00 movl $0x52eb,(%esp) + 14dc: e8 01 38 00 00 call 4ce2 + if(fd >= 0){ + 14e1: 85 c0 test %eax,%eax + fd = open("small", O_CREATE|O_RDWR); + 14e3: 89 c6 mov %eax,%esi + if(fd >= 0){ + 14e5: 0f 88 b1 01 00 00 js 169c + printf(stdout, "creat small succeeded; ok\n"); + 14eb: a1 60 72 00 00 mov 0x7260,%eax + for(i = 0; i < 100; i++){ + 14f0: 31 db xor %ebx,%ebx + printf(stdout, "creat small succeeded; ok\n"); + 14f2: c7 44 24 04 f1 52 00 movl $0x52f1,0x4(%esp) + 14f9: 00 + 14fa: 89 04 24 mov %eax,(%esp) + 14fd: e8 fe 38 00 00 call 4e00 + 1502: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if(write(fd, "aaaaaaaaaa", 10) != 10){ + 1508: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) + 150f: 00 + 1510: c7 44 24 04 28 53 00 movl $0x5328,0x4(%esp) + 1517: 00 + 1518: 89 34 24 mov %esi,(%esp) + 151b: e8 a2 37 00 00 call 4cc2 + 1520: 83 f8 0a cmp $0xa,%eax + 1523: 0f 85 e9 00 00 00 jne 1612 + if(write(fd, "bbbbbbbbbb", 10) != 10){ + 1529: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) + 1530: 00 + 1531: c7 44 24 04 33 53 00 movl $0x5333,0x4(%esp) + 1538: 00 + 1539: 89 34 24 mov %esi,(%esp) + 153c: e8 81 37 00 00 call 4cc2 + 1541: 83 f8 0a cmp $0xa,%eax + 1544: 0f 85 e6 00 00 00 jne 1630 + for(i = 0; i < 100; i++){ + 154a: 83 c3 01 add $0x1,%ebx + 154d: 83 fb 64 cmp $0x64,%ebx + 1550: 75 b6 jne 1508 + printf(stdout, "writes ok\n"); + 1552: a1 60 72 00 00 mov 0x7260,%eax + 1557: c7 44 24 04 3e 53 00 movl $0x533e,0x4(%esp) + 155e: 00 + 155f: 89 04 24 mov %eax,(%esp) + 1562: e8 99 38 00 00 call 4e00 + close(fd); + 1567: 89 34 24 mov %esi,(%esp) + 156a: e8 5b 37 00 00 call 4cca + fd = open("small", O_RDONLY); + 156f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1576: 00 + 1577: c7 04 24 eb 52 00 00 movl $0x52eb,(%esp) + 157e: e8 5f 37 00 00 call 4ce2 + if(fd >= 0){ + 1583: 85 c0 test %eax,%eax + fd = open("small", O_RDONLY); + 1585: 89 c3 mov %eax,%ebx + if(fd >= 0){ + 1587: 0f 88 c1 00 00 00 js 164e + printf(stdout, "open small succeeded ok\n"); + 158d: a1 60 72 00 00 mov 0x7260,%eax + 1592: c7 44 24 04 49 53 00 movl $0x5349,0x4(%esp) + 1599: 00 + 159a: 89 04 24 mov %eax,(%esp) + 159d: e8 5e 38 00 00 call 4e00 + i = read(fd, buf, 2000); + 15a2: c7 44 24 08 d0 07 00 movl $0x7d0,0x8(%esp) + 15a9: 00 + 15aa: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 15b1: 00 + 15b2: 89 1c 24 mov %ebx,(%esp) + 15b5: e8 00 37 00 00 call 4cba + if(i == 2000){ + 15ba: 3d d0 07 00 00 cmp $0x7d0,%eax + 15bf: 0f 85 a3 00 00 00 jne 1668 + printf(stdout, "read succeeded ok\n"); + 15c5: a1 60 72 00 00 mov 0x7260,%eax + 15ca: c7 44 24 04 7d 53 00 movl $0x537d,0x4(%esp) + 15d1: 00 + 15d2: 89 04 24 mov %eax,(%esp) + 15d5: e8 26 38 00 00 call 4e00 + close(fd); + 15da: 89 1c 24 mov %ebx,(%esp) + 15dd: e8 e8 36 00 00 call 4cca + if(unlink("small") < 0){ + 15e2: c7 04 24 eb 52 00 00 movl $0x52eb,(%esp) + 15e9: e8 04 37 00 00 call 4cf2 + 15ee: 85 c0 test %eax,%eax + 15f0: 0f 88 8c 00 00 00 js 1682 + printf(stdout, "small file test ok\n"); + 15f6: a1 60 72 00 00 mov 0x7260,%eax + 15fb: c7 44 24 04 a5 53 00 movl $0x53a5,0x4(%esp) + 1602: 00 + 1603: 89 04 24 mov %eax,(%esp) + 1606: e8 f5 37 00 00 call 4e00 +} + 160b: 83 c4 10 add $0x10,%esp + 160e: 5b pop %ebx + 160f: 5e pop %esi + 1610: 5d pop %ebp + 1611: c3 ret + printf(stdout, "error: write aa %d new file failed\n", i); + 1612: a1 60 72 00 00 mov 0x7260,%eax + 1617: 89 5c 24 08 mov %ebx,0x8(%esp) + 161b: c7 44 24 04 ec 61 00 movl $0x61ec,0x4(%esp) + 1622: 00 + 1623: 89 04 24 mov %eax,(%esp) + 1626: e8 d5 37 00 00 call 4e00 + exit(); + 162b: e8 72 36 00 00 call 4ca2 + printf(stdout, "error: write bb %d new file failed\n", i); + 1630: a1 60 72 00 00 mov 0x7260,%eax + 1635: 89 5c 24 08 mov %ebx,0x8(%esp) + 1639: c7 44 24 04 10 62 00 movl $0x6210,0x4(%esp) + 1640: 00 + 1641: 89 04 24 mov %eax,(%esp) + 1644: e8 b7 37 00 00 call 4e00 + exit(); + 1649: e8 54 36 00 00 call 4ca2 + printf(stdout, "error: open small failed!\n"); + 164e: a1 60 72 00 00 mov 0x7260,%eax + 1653: c7 44 24 04 62 53 00 movl $0x5362,0x4(%esp) + 165a: 00 + 165b: 89 04 24 mov %eax,(%esp) + 165e: e8 9d 37 00 00 call 4e00 + exit(); + 1663: e8 3a 36 00 00 call 4ca2 + printf(stdout, "read failed\n"); + 1668: a1 60 72 00 00 mov 0x7260,%eax + 166d: c7 44 24 04 a9 56 00 movl $0x56a9,0x4(%esp) + 1674: 00 + 1675: 89 04 24 mov %eax,(%esp) + 1678: e8 83 37 00 00 call 4e00 + exit(); + 167d: e8 20 36 00 00 call 4ca2 + printf(stdout, "unlink small failed\n"); + 1682: a1 60 72 00 00 mov 0x7260,%eax + 1687: c7 44 24 04 90 53 00 movl $0x5390,0x4(%esp) + 168e: 00 + 168f: 89 04 24 mov %eax,(%esp) + 1692: e8 69 37 00 00 call 4e00 + exit(); + 1697: e8 06 36 00 00 call 4ca2 + printf(stdout, "error: creat small failed!\n"); + 169c: a1 60 72 00 00 mov 0x7260,%eax + 16a1: c7 44 24 04 0c 53 00 movl $0x530c,0x4(%esp) + 16a8: 00 + 16a9: 89 04 24 mov %eax,(%esp) + 16ac: e8 4f 37 00 00 call 4e00 + exit(); + 16b1: e8 ec 35 00 00 call 4ca2 + 16b6: 8d 76 00 lea 0x0(%esi),%esi + 16b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +000016c0 : +{ + 16c0: 55 push %ebp + 16c1: 89 e5 mov %esp,%ebp + 16c3: 56 push %esi + 16c4: 53 push %ebx + 16c5: 83 ec 10 sub $0x10,%esp + printf(stdout, "big files test\n"); + 16c8: a1 60 72 00 00 mov 0x7260,%eax + 16cd: c7 44 24 04 b9 53 00 movl $0x53b9,0x4(%esp) + 16d4: 00 + 16d5: 89 04 24 mov %eax,(%esp) + 16d8: e8 23 37 00 00 call 4e00 + fd = open("big", O_CREATE|O_RDWR); + 16dd: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 16e4: 00 + 16e5: c7 04 24 33 54 00 00 movl $0x5433,(%esp) + 16ec: e8 f1 35 00 00 call 4ce2 + if(fd < 0){ + 16f1: 85 c0 test %eax,%eax + fd = open("big", O_CREATE|O_RDWR); + 16f3: 89 c6 mov %eax,%esi + if(fd < 0){ + 16f5: 0f 88 7a 01 00 00 js 1875 + 16fb: 31 db xor %ebx,%ebx + 16fd: 8d 76 00 lea 0x0(%esi),%esi + if(write(fd, buf, 512) != 512){ + 1700: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) + 1707: 00 + 1708: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 170f: 00 + 1710: 89 34 24 mov %esi,(%esp) + ((int*)buf)[0] = i; + 1713: 89 1d 40 9a 00 00 mov %ebx,0x9a40 + if(write(fd, buf, 512) != 512){ + 1719: e8 a4 35 00 00 call 4cc2 + 171e: 3d 00 02 00 00 cmp $0x200,%eax + 1723: 0f 85 b2 00 00 00 jne 17db + for(i = 0; i < MAXFILE; i++){ + 1729: 83 c3 01 add $0x1,%ebx + 172c: 81 fb 8c 00 00 00 cmp $0x8c,%ebx + 1732: 75 cc jne 1700 + close(fd); + 1734: 89 34 24 mov %esi,(%esp) + 1737: e8 8e 35 00 00 call 4cca + fd = open("big", O_RDONLY); + 173c: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1743: 00 + 1744: c7 04 24 33 54 00 00 movl $0x5433,(%esp) + 174b: e8 92 35 00 00 call 4ce2 + if(fd < 0){ + 1750: 85 c0 test %eax,%eax + fd = open("big", O_RDONLY); + 1752: 89 c6 mov %eax,%esi + if(fd < 0){ + 1754: 0f 88 01 01 00 00 js 185b + 175a: 31 db xor %ebx,%ebx + 175c: eb 1d jmp 177b + 175e: 66 90 xchg %ax,%ax + } else if(i != 512){ + 1760: 3d 00 02 00 00 cmp $0x200,%eax + 1765: 0f 85 b0 00 00 00 jne 181b + if(((int*)buf)[0] != n){ + 176b: a1 40 9a 00 00 mov 0x9a40,%eax + 1770: 39 d8 cmp %ebx,%eax + 1772: 0f 85 81 00 00 00 jne 17f9 + n++; + 1778: 83 c3 01 add $0x1,%ebx + i = read(fd, buf, 512); + 177b: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) + 1782: 00 + 1783: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 178a: 00 + 178b: 89 34 24 mov %esi,(%esp) + 178e: e8 27 35 00 00 call 4cba + if(i == 0){ + 1793: 85 c0 test %eax,%eax + 1795: 75 c9 jne 1760 + if(n == MAXFILE - 1){ + 1797: 81 fb 8b 00 00 00 cmp $0x8b,%ebx + 179d: 0f 84 96 00 00 00 je 1839 + close(fd); + 17a3: 89 34 24 mov %esi,(%esp) + 17a6: e8 1f 35 00 00 call 4cca + if(unlink("big") < 0){ + 17ab: c7 04 24 33 54 00 00 movl $0x5433,(%esp) + 17b2: e8 3b 35 00 00 call 4cf2 + 17b7: 85 c0 test %eax,%eax + 17b9: 0f 88 d0 00 00 00 js 188f + printf(stdout, "big files ok\n"); + 17bf: a1 60 72 00 00 mov 0x7260,%eax + 17c4: c7 44 24 04 5a 54 00 movl $0x545a,0x4(%esp) + 17cb: 00 + 17cc: 89 04 24 mov %eax,(%esp) + 17cf: e8 2c 36 00 00 call 4e00 +} + 17d4: 83 c4 10 add $0x10,%esp + 17d7: 5b pop %ebx + 17d8: 5e pop %esi + 17d9: 5d pop %ebp + 17da: c3 ret + printf(stdout, "error: write big file failed\n", i); + 17db: a1 60 72 00 00 mov 0x7260,%eax + 17e0: 89 5c 24 08 mov %ebx,0x8(%esp) + 17e4: c7 44 24 04 e3 53 00 movl $0x53e3,0x4(%esp) + 17eb: 00 + 17ec: 89 04 24 mov %eax,(%esp) + 17ef: e8 0c 36 00 00 call 4e00 + exit(); + 17f4: e8 a9 34 00 00 call 4ca2 + printf(stdout, "read content of block %d is %d\n", + 17f9: 89 44 24 0c mov %eax,0xc(%esp) + 17fd: a1 60 72 00 00 mov 0x7260,%eax + 1802: 89 5c 24 08 mov %ebx,0x8(%esp) + 1806: c7 44 24 04 34 62 00 movl $0x6234,0x4(%esp) + 180d: 00 + 180e: 89 04 24 mov %eax,(%esp) + 1811: e8 ea 35 00 00 call 4e00 + exit(); + 1816: e8 87 34 00 00 call 4ca2 + printf(stdout, "read failed %d\n", i); + 181b: 89 44 24 08 mov %eax,0x8(%esp) + 181f: a1 60 72 00 00 mov 0x7260,%eax + 1824: c7 44 24 04 37 54 00 movl $0x5437,0x4(%esp) + 182b: 00 + 182c: 89 04 24 mov %eax,(%esp) + 182f: e8 cc 35 00 00 call 4e00 + exit(); + 1834: e8 69 34 00 00 call 4ca2 + printf(stdout, "read only %d blocks from big", n); + 1839: a1 60 72 00 00 mov 0x7260,%eax + 183e: c7 44 24 08 8b 00 00 movl $0x8b,0x8(%esp) + 1845: 00 + 1846: c7 44 24 04 1a 54 00 movl $0x541a,0x4(%esp) + 184d: 00 + 184e: 89 04 24 mov %eax,(%esp) + 1851: e8 aa 35 00 00 call 4e00 + exit(); + 1856: e8 47 34 00 00 call 4ca2 + printf(stdout, "error: open big failed!\n"); + 185b: a1 60 72 00 00 mov 0x7260,%eax + 1860: c7 44 24 04 01 54 00 movl $0x5401,0x4(%esp) + 1867: 00 + 1868: 89 04 24 mov %eax,(%esp) + 186b: e8 90 35 00 00 call 4e00 + exit(); + 1870: e8 2d 34 00 00 call 4ca2 + printf(stdout, "error: creat big failed!\n"); + 1875: a1 60 72 00 00 mov 0x7260,%eax + 187a: c7 44 24 04 c9 53 00 movl $0x53c9,0x4(%esp) + 1881: 00 + 1882: 89 04 24 mov %eax,(%esp) + 1885: e8 76 35 00 00 call 4e00 + exit(); + 188a: e8 13 34 00 00 call 4ca2 + printf(stdout, "unlink big failed\n"); + 188f: a1 60 72 00 00 mov 0x7260,%eax + 1894: c7 44 24 04 47 54 00 movl $0x5447,0x4(%esp) + 189b: 00 + 189c: 89 04 24 mov %eax,(%esp) + 189f: e8 5c 35 00 00 call 4e00 + exit(); + 18a4: e8 f9 33 00 00 call 4ca2 + 18a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000018b0 : +{ + 18b0: 55 push %ebp + 18b1: 89 e5 mov %esp,%ebp + 18b3: 53 push %ebx + name[2] = '\0'; + 18b4: bb 30 00 00 00 mov $0x30,%ebx +{ + 18b9: 83 ec 14 sub $0x14,%esp + printf(stdout, "many creates, followed by unlink test\n"); + 18bc: a1 60 72 00 00 mov 0x7260,%eax + 18c1: c7 44 24 04 54 62 00 movl $0x6254,0x4(%esp) + 18c8: 00 + 18c9: 89 04 24 mov %eax,(%esp) + 18cc: e8 2f 35 00 00 call 4e00 + name[0] = 'a'; + 18d1: c6 05 40 ba 00 00 61 movb $0x61,0xba40 + name[2] = '\0'; + 18d8: c6 05 42 ba 00 00 00 movb $0x0,0xba42 + 18df: 90 nop + fd = open(name, O_CREATE|O_RDWR); + 18e0: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 18e7: 00 + 18e8: c7 04 24 40 ba 00 00 movl $0xba40,(%esp) + name[1] = '0' + i; + 18ef: 88 1d 41 ba 00 00 mov %bl,0xba41 + 18f5: 83 c3 01 add $0x1,%ebx + fd = open(name, O_CREATE|O_RDWR); + 18f8: e8 e5 33 00 00 call 4ce2 + close(fd); + 18fd: 89 04 24 mov %eax,(%esp) + 1900: e8 c5 33 00 00 call 4cca + for(i = 0; i < 52; i++){ + 1905: 80 fb 64 cmp $0x64,%bl + 1908: 75 d6 jne 18e0 + name[0] = 'a'; + 190a: c6 05 40 ba 00 00 61 movb $0x61,0xba40 + name[2] = '\0'; + 1911: bb 30 00 00 00 mov $0x30,%ebx + 1916: c6 05 42 ba 00 00 00 movb $0x0,0xba42 + 191d: 8d 76 00 lea 0x0(%esi),%esi + name[1] = '0' + i; + 1920: 88 1d 41 ba 00 00 mov %bl,0xba41 + 1926: 83 c3 01 add $0x1,%ebx + unlink(name); + 1929: c7 04 24 40 ba 00 00 movl $0xba40,(%esp) + 1930: e8 bd 33 00 00 call 4cf2 + for(i = 0; i < 52; i++){ + 1935: 80 fb 64 cmp $0x64,%bl + 1938: 75 e6 jne 1920 + printf(stdout, "many creates, followed by unlink; ok\n"); + 193a: a1 60 72 00 00 mov 0x7260,%eax + 193f: c7 44 24 04 7c 62 00 movl $0x627c,0x4(%esp) + 1946: 00 + 1947: 89 04 24 mov %eax,(%esp) + 194a: e8 b1 34 00 00 call 4e00 +} + 194f: 83 c4 14 add $0x14,%esp + 1952: 5b pop %ebx + 1953: 5d pop %ebp + 1954: c3 ret + 1955: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1959: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001960 : +{ + 1960: 55 push %ebp + 1961: 89 e5 mov %esp,%ebp + 1963: 83 ec 18 sub $0x18,%esp + printf(stdout, "mkdir test\n"); + 1966: a1 60 72 00 00 mov 0x7260,%eax + 196b: c7 44 24 04 68 54 00 movl $0x5468,0x4(%esp) + 1972: 00 + 1973: 89 04 24 mov %eax,(%esp) + 1976: e8 85 34 00 00 call 4e00 + if(mkdir("dir0") < 0){ + 197b: c7 04 24 74 54 00 00 movl $0x5474,(%esp) + 1982: e8 83 33 00 00 call 4d0a + 1987: 85 c0 test %eax,%eax + 1989: 78 4b js 19d6 + if(chdir("dir0") < 0){ + 198b: c7 04 24 74 54 00 00 movl $0x5474,(%esp) + 1992: e8 7b 33 00 00 call 4d12 + 1997: 85 c0 test %eax,%eax + 1999: 0f 88 85 00 00 00 js 1a24 + if(chdir("..") < 0){ + 199f: c7 04 24 19 5a 00 00 movl $0x5a19,(%esp) + 19a6: e8 67 33 00 00 call 4d12 + 19ab: 85 c0 test %eax,%eax + 19ad: 78 5b js 1a0a + if(unlink("dir0") < 0){ + 19af: c7 04 24 74 54 00 00 movl $0x5474,(%esp) + 19b6: e8 37 33 00 00 call 4cf2 + 19bb: 85 c0 test %eax,%eax + 19bd: 78 31 js 19f0 + printf(stdout, "mkdir test ok\n"); + 19bf: a1 60 72 00 00 mov 0x7260,%eax + 19c4: c7 44 24 04 b1 54 00 movl $0x54b1,0x4(%esp) + 19cb: 00 + 19cc: 89 04 24 mov %eax,(%esp) + 19cf: e8 2c 34 00 00 call 4e00 +} + 19d4: c9 leave + 19d5: c3 ret + printf(stdout, "mkdir failed\n"); + 19d6: a1 60 72 00 00 mov 0x7260,%eax + 19db: c7 44 24 04 a4 51 00 movl $0x51a4,0x4(%esp) + 19e2: 00 + 19e3: 89 04 24 mov %eax,(%esp) + 19e6: e8 15 34 00 00 call 4e00 + exit(); + 19eb: e8 b2 32 00 00 call 4ca2 + printf(stdout, "unlink dir0 failed\n"); + 19f0: a1 60 72 00 00 mov 0x7260,%eax + 19f5: c7 44 24 04 9d 54 00 movl $0x549d,0x4(%esp) + 19fc: 00 + 19fd: 89 04 24 mov %eax,(%esp) + 1a00: e8 fb 33 00 00 call 4e00 + exit(); + 1a05: e8 98 32 00 00 call 4ca2 + printf(stdout, "chdir .. failed\n"); + 1a0a: a1 60 72 00 00 mov 0x7260,%eax + 1a0f: c7 44 24 04 8c 54 00 movl $0x548c,0x4(%esp) + 1a16: 00 + 1a17: 89 04 24 mov %eax,(%esp) + 1a1a: e8 e1 33 00 00 call 4e00 + exit(); + 1a1f: e8 7e 32 00 00 call 4ca2 + printf(stdout, "chdir dir0 failed\n"); + 1a24: a1 60 72 00 00 mov 0x7260,%eax + 1a29: c7 44 24 04 79 54 00 movl $0x5479,0x4(%esp) + 1a30: 00 + 1a31: 89 04 24 mov %eax,(%esp) + 1a34: e8 c7 33 00 00 call 4e00 + exit(); + 1a39: e8 64 32 00 00 call 4ca2 + 1a3e: 66 90 xchg %ax,%ax + +00001a40 : +{ + 1a40: 55 push %ebp + 1a41: 89 e5 mov %esp,%ebp + 1a43: 83 ec 18 sub $0x18,%esp + printf(stdout, "exec test\n"); + 1a46: a1 60 72 00 00 mov 0x7260,%eax + 1a4b: c7 44 24 04 c0 54 00 movl $0x54c0,0x4(%esp) + 1a52: 00 + 1a53: 89 04 24 mov %eax,(%esp) + 1a56: e8 a5 33 00 00 call 4e00 + if(exec("echo", echoargv) < 0){ + 1a5b: c7 44 24 04 64 72 00 movl $0x7264,0x4(%esp) + 1a62: 00 + 1a63: c7 04 24 89 52 00 00 movl $0x5289,(%esp) + 1a6a: e8 6b 32 00 00 call 4cda + 1a6f: 85 c0 test %eax,%eax + 1a71: 78 02 js 1a75 +} + 1a73: c9 leave + 1a74: c3 ret + printf(stdout, "exec echo failed\n"); + 1a75: a1 60 72 00 00 mov 0x7260,%eax + 1a7a: c7 44 24 04 cb 54 00 movl $0x54cb,0x4(%esp) + 1a81: 00 + 1a82: 89 04 24 mov %eax,(%esp) + 1a85: e8 76 33 00 00 call 4e00 + exit(); + 1a8a: e8 13 32 00 00 call 4ca2 + 1a8f: 90 nop + +00001a90 : +{ + 1a90: 55 push %ebp + 1a91: 89 e5 mov %esp,%ebp + 1a93: 57 push %edi + 1a94: 56 push %esi + 1a95: 53 push %ebx + 1a96: 83 ec 2c sub $0x2c,%esp + if(pipe(fds) != 0){ + 1a99: 8d 45 e0 lea -0x20(%ebp),%eax + 1a9c: 89 04 24 mov %eax,(%esp) + 1a9f: e8 0e 32 00 00 call 4cb2 + 1aa4: 85 c0 test %eax,%eax + 1aa6: 0f 85 4e 01 00 00 jne 1bfa + pid = fork(); + 1aac: e8 e9 31 00 00 call 4c9a + if(pid == 0){ + 1ab1: 83 f8 00 cmp $0x0,%eax + 1ab4: 0f 84 93 00 00 00 je 1b4d + } else if(pid > 0){ + 1aba: 0f 8e 53 01 00 00 jle 1c13 + close(fds[1]); + 1ac0: 8b 45 e4 mov -0x1c(%ebp),%eax + cc = 1; + 1ac3: bf 01 00 00 00 mov $0x1,%edi + seq = 0; + 1ac8: 31 db xor %ebx,%ebx + close(fds[1]); + 1aca: 89 04 24 mov %eax,(%esp) + 1acd: e8 f8 31 00 00 call 4cca + total = 0; + 1ad2: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) + while((n = read(fds[0], buf, cc)) > 0){ + 1ad9: 8b 45 e0 mov -0x20(%ebp),%eax + 1adc: 89 7c 24 08 mov %edi,0x8(%esp) + 1ae0: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 1ae7: 00 + 1ae8: 89 04 24 mov %eax,(%esp) + 1aeb: e8 ca 31 00 00 call 4cba + 1af0: 85 c0 test %eax,%eax + 1af2: 0f 8e b3 00 00 00 jle 1bab + 1af8: 89 d9 mov %ebx,%ecx + 1afa: 8d 34 03 lea (%ebx,%eax,1),%esi + 1afd: f7 d9 neg %ecx + 1aff: eb 09 jmp 1b0a + 1b01: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if((buf[i] & 0xff) != (seq++ & 0xff)){ + 1b08: 89 d3 mov %edx,%ebx + 1b0a: 38 9c 0b 40 9a 00 00 cmp %bl,0x9a40(%ebx,%ecx,1) + 1b11: 8d 53 01 lea 0x1(%ebx),%edx + 1b14: 75 1b jne 1b31 + for(i = 0; i < n; i++){ + 1b16: 39 f2 cmp %esi,%edx + 1b18: 75 ee jne 1b08 + cc = cc * 2; + 1b1a: 01 ff add %edi,%edi + if((buf[i] & 0xff) != (seq++ & 0xff)){ + 1b1c: 89 f3 mov %esi,%ebx + total += n; + 1b1e: 01 45 d4 add %eax,-0x2c(%ebp) + cc = sizeof(buf); + 1b21: 81 ff 01 20 00 00 cmp $0x2001,%edi + 1b27: b8 00 20 00 00 mov $0x2000,%eax + 1b2c: 0f 43 f8 cmovae %eax,%edi + 1b2f: eb a8 jmp 1ad9 + printf(1, "pipe1 oops 2\n"); + 1b31: c7 44 24 04 fa 54 00 movl $0x54fa,0x4(%esp) + 1b38: 00 + 1b39: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1b40: e8 bb 32 00 00 call 4e00 +} + 1b45: 83 c4 2c add $0x2c,%esp + 1b48: 5b pop %ebx + 1b49: 5e pop %esi + 1b4a: 5f pop %edi + 1b4b: 5d pop %ebp + 1b4c: c3 ret + close(fds[0]); + 1b4d: 8b 45 e0 mov -0x20(%ebp),%eax + seq = 0; + 1b50: 31 f6 xor %esi,%esi + close(fds[0]); + 1b52: 89 04 24 mov %eax,(%esp) + 1b55: e8 70 31 00 00 call 4cca + 1b5a: 89 f0 mov %esi,%eax +{ + 1b5c: 89 f3 mov %esi,%ebx + 1b5e: 8d 96 09 04 00 00 lea 0x409(%esi),%edx + 1b64: f7 d8 neg %eax + 1b66: 66 90 xchg %ax,%ax + buf[i] = seq++; + 1b68: 88 9c 18 40 9a 00 00 mov %bl,0x9a40(%eax,%ebx,1) + 1b6f: 83 c3 01 add $0x1,%ebx + for(i = 0; i < 1033; i++) + 1b72: 39 d3 cmp %edx,%ebx + 1b74: 75 f2 jne 1b68 + if(write(fds[1], buf, 1033) != 1033){ + 1b76: 8b 45 e4 mov -0x1c(%ebp),%eax + 1b79: 89 de mov %ebx,%esi + 1b7b: c7 44 24 08 09 04 00 movl $0x409,0x8(%esp) + 1b82: 00 + 1b83: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 1b8a: 00 + 1b8b: 89 04 24 mov %eax,(%esp) + 1b8e: e8 2f 31 00 00 call 4cc2 + 1b93: 3d 09 04 00 00 cmp $0x409,%eax + 1b98: 0f 85 8e 00 00 00 jne 1c2c + for(n = 0; n < 5; n++){ + 1b9e: 81 fb 2d 14 00 00 cmp $0x142d,%ebx + 1ba4: 75 b4 jne 1b5a + exit(); + 1ba6: e8 f7 30 00 00 call 4ca2 + if(total != 5 * 1033){ + 1bab: 81 7d d4 2d 14 00 00 cmpl $0x142d,-0x2c(%ebp) + 1bb2: 75 29 jne 1bdd + close(fds[0]); + 1bb4: 8b 45 e0 mov -0x20(%ebp),%eax + 1bb7: 89 04 24 mov %eax,(%esp) + 1bba: e8 0b 31 00 00 call 4cca + wait(); + 1bbf: e8 e6 30 00 00 call 4caa + printf(1, "pipe1 ok\n"); + 1bc4: c7 44 24 04 1f 55 00 movl $0x551f,0x4(%esp) + 1bcb: 00 + 1bcc: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1bd3: e8 28 32 00 00 call 4e00 + 1bd8: e9 68 ff ff ff jmp 1b45 + printf(1, "pipe1 oops 3 total %d\n", total); + 1bdd: 8b 45 d4 mov -0x2c(%ebp),%eax + 1be0: c7 44 24 04 08 55 00 movl $0x5508,0x4(%esp) + 1be7: 00 + 1be8: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1bef: 89 44 24 08 mov %eax,0x8(%esp) + 1bf3: e8 08 32 00 00 call 4e00 + 1bf8: eb ac jmp 1ba6 + printf(1, "pipe() failed\n"); + 1bfa: c7 44 24 04 dd 54 00 movl $0x54dd,0x4(%esp) + 1c01: 00 + 1c02: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1c09: e8 f2 31 00 00 call 4e00 + exit(); + 1c0e: e8 8f 30 00 00 call 4ca2 + printf(1, "fork() failed\n"); + 1c13: c7 44 24 04 29 55 00 movl $0x5529,0x4(%esp) + 1c1a: 00 + 1c1b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1c22: e8 d9 31 00 00 call 4e00 + exit(); + 1c27: e8 76 30 00 00 call 4ca2 + printf(1, "pipe1 oops 1\n"); + 1c2c: c7 44 24 04 ec 54 00 movl $0x54ec,0x4(%esp) + 1c33: 00 + 1c34: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1c3b: e8 c0 31 00 00 call 4e00 + exit(); + 1c40: e8 5d 30 00 00 call 4ca2 + 1c45: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1c49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001c50 : +{ + 1c50: 55 push %ebp + 1c51: 89 e5 mov %esp,%ebp + 1c53: 57 push %edi + 1c54: 56 push %esi + 1c55: 53 push %ebx + 1c56: 83 ec 2c sub $0x2c,%esp + printf(1, "preempt: "); + 1c59: c7 44 24 04 38 55 00 movl $0x5538,0x4(%esp) + 1c60: 00 + 1c61: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1c68: e8 93 31 00 00 call 4e00 + pid1 = fork(); + 1c6d: e8 28 30 00 00 call 4c9a + if(pid1 == 0) + 1c72: 85 c0 test %eax,%eax + pid1 = fork(); + 1c74: 89 c7 mov %eax,%edi + if(pid1 == 0) + 1c76: 75 02 jne 1c7a + 1c78: eb fe jmp 1c78 + 1c7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + pid2 = fork(); + 1c80: e8 15 30 00 00 call 4c9a + if(pid2 == 0) + 1c85: 85 c0 test %eax,%eax + pid2 = fork(); + 1c87: 89 c6 mov %eax,%esi + if(pid2 == 0) + 1c89: 75 02 jne 1c8d + 1c8b: eb fe jmp 1c8b + pipe(pfds); + 1c8d: 8d 45 e0 lea -0x20(%ebp),%eax + 1c90: 89 04 24 mov %eax,(%esp) + 1c93: e8 1a 30 00 00 call 4cb2 + pid3 = fork(); + 1c98: e8 fd 2f 00 00 call 4c9a + if(pid3 == 0){ + 1c9d: 85 c0 test %eax,%eax + pid3 = fork(); + 1c9f: 89 c3 mov %eax,%ebx + if(pid3 == 0){ + 1ca1: 75 4c jne 1cef + close(pfds[0]); + 1ca3: 8b 45 e0 mov -0x20(%ebp),%eax + 1ca6: 89 04 24 mov %eax,(%esp) + 1ca9: e8 1c 30 00 00 call 4cca + if(write(pfds[1], "x", 1) != 1) + 1cae: 8b 45 e4 mov -0x1c(%ebp),%eax + 1cb1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1cb8: 00 + 1cb9: c7 44 24 04 fd 5a 00 movl $0x5afd,0x4(%esp) + 1cc0: 00 + 1cc1: 89 04 24 mov %eax,(%esp) + 1cc4: e8 f9 2f 00 00 call 4cc2 + 1cc9: 83 f8 01 cmp $0x1,%eax + 1ccc: 74 14 je 1ce2 + printf(1, "preempt write error"); + 1cce: c7 44 24 04 42 55 00 movl $0x5542,0x4(%esp) + 1cd5: 00 + 1cd6: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1cdd: e8 1e 31 00 00 call 4e00 + close(pfds[1]); + 1ce2: 8b 45 e4 mov -0x1c(%ebp),%eax + 1ce5: 89 04 24 mov %eax,(%esp) + 1ce8: e8 dd 2f 00 00 call 4cca + 1ced: eb fe jmp 1ced + close(pfds[1]); + 1cef: 8b 45 e4 mov -0x1c(%ebp),%eax + 1cf2: 89 04 24 mov %eax,(%esp) + 1cf5: e8 d0 2f 00 00 call 4cca + if(read(pfds[0], buf, sizeof(buf)) != 1){ + 1cfa: 8b 45 e0 mov -0x20(%ebp),%eax + 1cfd: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) + 1d04: 00 + 1d05: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 1d0c: 00 + 1d0d: 89 04 24 mov %eax,(%esp) + 1d10: e8 a5 2f 00 00 call 4cba + 1d15: 83 f8 01 cmp $0x1,%eax + 1d18: 74 1c je 1d36 + printf(1, "preempt read error"); + 1d1a: c7 44 24 04 56 55 00 movl $0x5556,0x4(%esp) + 1d21: 00 + 1d22: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1d29: e8 d2 30 00 00 call 4e00 +} + 1d2e: 83 c4 2c add $0x2c,%esp + 1d31: 5b pop %ebx + 1d32: 5e pop %esi + 1d33: 5f pop %edi + 1d34: 5d pop %ebp + 1d35: c3 ret + close(pfds[0]); + 1d36: 8b 45 e0 mov -0x20(%ebp),%eax + 1d39: 89 04 24 mov %eax,(%esp) + 1d3c: e8 89 2f 00 00 call 4cca + printf(1, "kill... "); + 1d41: c7 44 24 04 69 55 00 movl $0x5569,0x4(%esp) + 1d48: 00 + 1d49: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1d50: e8 ab 30 00 00 call 4e00 + kill(pid1); + 1d55: 89 3c 24 mov %edi,(%esp) + 1d58: e8 75 2f 00 00 call 4cd2 + kill(pid2); + 1d5d: 89 34 24 mov %esi,(%esp) + 1d60: e8 6d 2f 00 00 call 4cd2 + kill(pid3); + 1d65: 89 1c 24 mov %ebx,(%esp) + 1d68: e8 65 2f 00 00 call 4cd2 + printf(1, "wait... "); + 1d6d: c7 44 24 04 72 55 00 movl $0x5572,0x4(%esp) + 1d74: 00 + 1d75: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1d7c: e8 7f 30 00 00 call 4e00 + wait(); + 1d81: e8 24 2f 00 00 call 4caa + wait(); + 1d86: e8 1f 2f 00 00 call 4caa + 1d8b: 90 nop + 1d8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + wait(); + 1d90: e8 15 2f 00 00 call 4caa + printf(1, "preempt ok\n"); + 1d95: c7 44 24 04 7b 55 00 movl $0x557b,0x4(%esp) + 1d9c: 00 + 1d9d: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1da4: e8 57 30 00 00 call 4e00 + 1da9: eb 83 jmp 1d2e + 1dab: 90 nop + 1dac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00001db0 : +{ + 1db0: 55 push %ebp + 1db1: 89 e5 mov %esp,%ebp + 1db3: 56 push %esi + 1db4: be 64 00 00 00 mov $0x64,%esi + 1db9: 53 push %ebx + 1dba: 83 ec 10 sub $0x10,%esp + 1dbd: eb 13 jmp 1dd2 + 1dbf: 90 nop + if(pid){ + 1dc0: 74 71 je 1e33 + if(wait() != pid){ + 1dc2: e8 e3 2e 00 00 call 4caa + 1dc7: 39 d8 cmp %ebx,%eax + 1dc9: 75 2d jne 1df8 + for(i = 0; i < 100; i++){ + 1dcb: 83 ee 01 sub $0x1,%esi + 1dce: 66 90 xchg %ax,%ax + 1dd0: 74 46 je 1e18 + pid = fork(); + 1dd2: e8 c3 2e 00 00 call 4c9a + if(pid < 0){ + 1dd7: 85 c0 test %eax,%eax + pid = fork(); + 1dd9: 89 c3 mov %eax,%ebx + if(pid < 0){ + 1ddb: 79 e3 jns 1dc0 + printf(1, "fork failed\n"); + 1ddd: c7 44 24 04 e5 60 00 movl $0x60e5,0x4(%esp) + 1de4: 00 + 1de5: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1dec: e8 0f 30 00 00 call 4e00 +} + 1df1: 83 c4 10 add $0x10,%esp + 1df4: 5b pop %ebx + 1df5: 5e pop %esi + 1df6: 5d pop %ebp + 1df7: c3 ret + printf(1, "wait wrong pid\n"); + 1df8: c7 44 24 04 87 55 00 movl $0x5587,0x4(%esp) + 1dff: 00 + 1e00: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1e07: e8 f4 2f 00 00 call 4e00 +} + 1e0c: 83 c4 10 add $0x10,%esp + 1e0f: 5b pop %ebx + 1e10: 5e pop %esi + 1e11: 5d pop %ebp + 1e12: c3 ret + 1e13: 90 nop + 1e14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + printf(1, "exitwait ok\n"); + 1e18: c7 44 24 04 97 55 00 movl $0x5597,0x4(%esp) + 1e1f: 00 + 1e20: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1e27: e8 d4 2f 00 00 call 4e00 +} + 1e2c: 83 c4 10 add $0x10,%esp + 1e2f: 5b pop %ebx + 1e30: 5e pop %esi + 1e31: 5d pop %ebp + 1e32: c3 ret + exit(); + 1e33: e8 6a 2e 00 00 call 4ca2 + 1e38: 90 nop + 1e39: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001e40 : +{ + 1e40: 55 push %ebp + 1e41: 89 e5 mov %esp,%ebp + 1e43: 57 push %edi + 1e44: 56 push %esi + 1e45: 53 push %ebx + 1e46: 83 ec 1c sub $0x1c,%esp + printf(1, "mem test\n"); + 1e49: c7 44 24 04 a4 55 00 movl $0x55a4,0x4(%esp) + 1e50: 00 + 1e51: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1e58: e8 a3 2f 00 00 call 4e00 + ppid = getpid(); + 1e5d: e8 c0 2e 00 00 call 4d22 + 1e62: 89 c6 mov %eax,%esi + if((pid = fork()) == 0){ + 1e64: e8 31 2e 00 00 call 4c9a + 1e69: 85 c0 test %eax,%eax + 1e6b: 75 73 jne 1ee0 + 1e6d: 31 db xor %ebx,%ebx + 1e6f: 90 nop + 1e70: eb 0a jmp 1e7c + 1e72: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + *(char**)m2 = m1; + 1e78: 89 18 mov %ebx,(%eax) + 1e7a: 89 c3 mov %eax,%ebx + while((m2 = malloc(10001)) != 0){ + 1e7c: c7 04 24 11 27 00 00 movl $0x2711,(%esp) + 1e83: e8 f8 31 00 00 call 5080 + 1e88: 85 c0 test %eax,%eax + 1e8a: 75 ec jne 1e78 + while(m1){ + 1e8c: 85 db test %ebx,%ebx + 1e8e: 75 0a jne 1e9a + 1e90: eb 16 jmp 1ea8 + 1e92: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + m1 = m2; + 1e98: 89 fb mov %edi,%ebx + m2 = *(char**)m1; + 1e9a: 8b 3b mov (%ebx),%edi + free(m1); + 1e9c: 89 1c 24 mov %ebx,(%esp) + 1e9f: e8 4c 31 00 00 call 4ff0 + while(m1){ + 1ea4: 85 ff test %edi,%edi + 1ea6: 75 f0 jne 1e98 + m1 = malloc(1024*20); + 1ea8: c7 04 24 00 50 00 00 movl $0x5000,(%esp) + 1eaf: e8 cc 31 00 00 call 5080 + if(m1 == 0){ + 1eb4: 85 c0 test %eax,%eax + 1eb6: 74 38 je 1ef0 + free(m1); + 1eb8: 89 04 24 mov %eax,(%esp) + 1ebb: e8 30 31 00 00 call 4ff0 + printf(1, "mem ok\n"); + 1ec0: c7 44 24 04 c8 55 00 movl $0x55c8,0x4(%esp) + 1ec7: 00 + 1ec8: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1ecf: e8 2c 2f 00 00 call 4e00 + exit(); + 1ed4: e8 c9 2d 00 00 call 4ca2 + 1ed9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi +} + 1ee0: 83 c4 1c add $0x1c,%esp + 1ee3: 5b pop %ebx + 1ee4: 5e pop %esi + 1ee5: 5f pop %edi + 1ee6: 5d pop %ebp + wait(); + 1ee7: e9 be 2d 00 00 jmp 4caa + 1eec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + printf(1, "couldn't allocate mem?!!\n"); + 1ef0: c7 44 24 04 ae 55 00 movl $0x55ae,0x4(%esp) + 1ef7: 00 + 1ef8: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1eff: e8 fc 2e 00 00 call 4e00 + kill(ppid); + 1f04: 89 34 24 mov %esi,(%esp) + 1f07: e8 c6 2d 00 00 call 4cd2 + exit(); + 1f0c: e8 91 2d 00 00 call 4ca2 + 1f11: eb 0d jmp 1f20 + 1f13: 90 nop + 1f14: 90 nop + 1f15: 90 nop + 1f16: 90 nop + 1f17: 90 nop + 1f18: 90 nop + 1f19: 90 nop + 1f1a: 90 nop + 1f1b: 90 nop + 1f1c: 90 nop + 1f1d: 90 nop + 1f1e: 90 nop + 1f1f: 90 nop + +00001f20 : +{ + 1f20: 55 push %ebp + 1f21: 89 e5 mov %esp,%ebp + 1f23: 57 push %edi + 1f24: 56 push %esi + 1f25: 53 push %ebx + 1f26: 83 ec 3c sub $0x3c,%esp + printf(1, "sharedfd test\n"); + 1f29: c7 44 24 04 d0 55 00 movl $0x55d0,0x4(%esp) + 1f30: 00 + 1f31: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1f38: e8 c3 2e 00 00 call 4e00 + unlink("sharedfd"); + 1f3d: c7 04 24 df 55 00 00 movl $0x55df,(%esp) + 1f44: e8 a9 2d 00 00 call 4cf2 + fd = open("sharedfd", O_CREATE|O_RDWR); + 1f49: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 1f50: 00 + 1f51: c7 04 24 df 55 00 00 movl $0x55df,(%esp) + 1f58: e8 85 2d 00 00 call 4ce2 + if(fd < 0){ + 1f5d: 85 c0 test %eax,%eax + fd = open("sharedfd", O_CREATE|O_RDWR); + 1f5f: 89 c7 mov %eax,%edi + if(fd < 0){ + 1f61: 0f 88 40 01 00 00 js 20a7 + pid = fork(); + 1f67: e8 2e 2d 00 00 call 4c9a + memset(buf, pid==0?'c':'p', sizeof(buf)); + 1f6c: 8d 75 de lea -0x22(%ebp),%esi + 1f6f: bb e8 03 00 00 mov $0x3e8,%ebx + 1f74: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) + 1f7b: 00 + 1f7c: 89 34 24 mov %esi,(%esp) + 1f7f: 83 f8 01 cmp $0x1,%eax + pid = fork(); + 1f82: 89 45 d4 mov %eax,-0x2c(%ebp) + memset(buf, pid==0?'c':'p', sizeof(buf)); + 1f85: 19 c0 sbb %eax,%eax + 1f87: 83 e0 f3 and $0xfffffff3,%eax + 1f8a: 83 c0 70 add $0x70,%eax + 1f8d: 89 44 24 04 mov %eax,0x4(%esp) + 1f91: e8 9a 2b 00 00 call 4b30 + 1f96: eb 05 jmp 1f9d + for(i = 0; i < 1000; i++){ + 1f98: 83 eb 01 sub $0x1,%ebx + 1f9b: 74 2d je 1fca + if(write(fd, buf, sizeof(buf)) != sizeof(buf)){ + 1f9d: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) + 1fa4: 00 + 1fa5: 89 74 24 04 mov %esi,0x4(%esp) + 1fa9: 89 3c 24 mov %edi,(%esp) + 1fac: e8 11 2d 00 00 call 4cc2 + 1fb1: 83 f8 0a cmp $0xa,%eax + 1fb4: 74 e2 je 1f98 + printf(1, "fstests: write sharedfd failed\n"); + 1fb6: c7 44 24 04 d0 62 00 movl $0x62d0,0x4(%esp) + 1fbd: 00 + 1fbe: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1fc5: e8 36 2e 00 00 call 4e00 + if(pid == 0) + 1fca: 8b 45 d4 mov -0x2c(%ebp),%eax + 1fcd: 85 c0 test %eax,%eax + 1fcf: 0f 84 26 01 00 00 je 20fb + wait(); + 1fd5: e8 d0 2c 00 00 call 4caa + close(fd); + 1fda: 89 3c 24 mov %edi,(%esp) + 1fdd: e8 e8 2c 00 00 call 4cca + fd = open("sharedfd", 0); + 1fe2: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1fe9: 00 + 1fea: c7 04 24 df 55 00 00 movl $0x55df,(%esp) + 1ff1: e8 ec 2c 00 00 call 4ce2 + if(fd < 0){ + 1ff6: 85 c0 test %eax,%eax + fd = open("sharedfd", 0); + 1ff8: 89 45 d0 mov %eax,-0x30(%ebp) + if(fd < 0){ + 1ffb: 0f 88 c2 00 00 00 js 20c3 + 2001: 31 d2 xor %edx,%edx + 2003: 31 db xor %ebx,%ebx + 2005: 8d 7d e8 lea -0x18(%ebp),%edi + 2008: 89 55 d4 mov %edx,-0x2c(%ebp) + 200b: 90 nop + 200c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while((n = read(fd, buf, sizeof(buf))) > 0){ + 2010: 8b 45 d0 mov -0x30(%ebp),%eax + 2013: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) + 201a: 00 + 201b: 89 74 24 04 mov %esi,0x4(%esp) + 201f: 89 04 24 mov %eax,(%esp) + 2022: e8 93 2c 00 00 call 4cba + 2027: 85 c0 test %eax,%eax + 2029: 7e 36 jle 2061 + 202b: 89 f0 mov %esi,%eax + 202d: 8b 55 d4 mov -0x2c(%ebp),%edx + 2030: eb 18 jmp 204a + 2032: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + np++; + 2038: 80 f9 70 cmp $0x70,%cl + 203b: 0f 94 c1 sete %cl + 203e: 83 c0 01 add $0x1,%eax + 2041: 0f b6 c9 movzbl %cl,%ecx + 2044: 01 cb add %ecx,%ebx + for(i = 0; i < sizeof(buf); i++){ + 2046: 39 f8 cmp %edi,%eax + 2048: 74 12 je 205c + if(buf[i] == 'c') + 204a: 0f b6 08 movzbl (%eax),%ecx + 204d: 80 f9 63 cmp $0x63,%cl + 2050: 75 e6 jne 2038 + 2052: 83 c0 01 add $0x1,%eax + nc++; + 2055: 83 c2 01 add $0x1,%edx + for(i = 0; i < sizeof(buf); i++){ + 2058: 39 f8 cmp %edi,%eax + 205a: 75 ee jne 204a + 205c: 89 55 d4 mov %edx,-0x2c(%ebp) + 205f: eb af jmp 2010 + close(fd); + 2061: 8b 45 d0 mov -0x30(%ebp),%eax + 2064: 89 04 24 mov %eax,(%esp) + 2067: e8 5e 2c 00 00 call 4cca + unlink("sharedfd"); + 206c: c7 04 24 df 55 00 00 movl $0x55df,(%esp) + 2073: e8 7a 2c 00 00 call 4cf2 + if(nc == 10000 && np == 10000){ + 2078: 81 fb 10 27 00 00 cmp $0x2710,%ebx + 207e: 8b 55 d4 mov -0x2c(%ebp),%edx + 2081: 75 5c jne 20df + 2083: 81 fa 10 27 00 00 cmp $0x2710,%edx + 2089: 75 54 jne 20df + printf(1, "sharedfd ok\n"); + 208b: c7 44 24 04 e8 55 00 movl $0x55e8,0x4(%esp) + 2092: 00 + 2093: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 209a: e8 61 2d 00 00 call 4e00 +} + 209f: 83 c4 3c add $0x3c,%esp + 20a2: 5b pop %ebx + 20a3: 5e pop %esi + 20a4: 5f pop %edi + 20a5: 5d pop %ebp + 20a6: c3 ret + printf(1, "fstests: cannot open sharedfd for writing"); + 20a7: c7 44 24 04 a4 62 00 movl $0x62a4,0x4(%esp) + 20ae: 00 + 20af: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 20b6: e8 45 2d 00 00 call 4e00 +} + 20bb: 83 c4 3c add $0x3c,%esp + 20be: 5b pop %ebx + 20bf: 5e pop %esi + 20c0: 5f pop %edi + 20c1: 5d pop %ebp + 20c2: c3 ret + printf(1, "fstests: cannot open sharedfd for reading\n"); + 20c3: c7 44 24 04 f0 62 00 movl $0x62f0,0x4(%esp) + 20ca: 00 + 20cb: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 20d2: e8 29 2d 00 00 call 4e00 +} + 20d7: 83 c4 3c add $0x3c,%esp + 20da: 5b pop %ebx + 20db: 5e pop %esi + 20dc: 5f pop %edi + 20dd: 5d pop %ebp + 20de: c3 ret + printf(1, "sharedfd oops %d %d\n", nc, np); + 20df: 89 5c 24 0c mov %ebx,0xc(%esp) + 20e3: 89 54 24 08 mov %edx,0x8(%esp) + 20e7: c7 44 24 04 f5 55 00 movl $0x55f5,0x4(%esp) + 20ee: 00 + 20ef: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 20f6: e8 05 2d 00 00 call 4e00 + exit(); + 20fb: e8 a2 2b 00 00 call 4ca2 + +00002100 : +{ + 2100: 55 push %ebp + 2101: 89 e5 mov %esp,%ebp + 2103: 57 push %edi + 2104: 56 push %esi + printf(1, "fourfiles test\n"); + 2105: be 0a 56 00 00 mov $0x560a,%esi +{ + 210a: 53 push %ebx + for(pi = 0; pi < 4; pi++){ + 210b: 31 db xor %ebx,%ebx +{ + 210d: 83 ec 2c sub $0x2c,%esp + printf(1, "fourfiles test\n"); + 2110: c7 44 24 04 10 56 00 movl $0x5610,0x4(%esp) + 2117: 00 + 2118: c7 04 24 01 00 00 00 movl $0x1,(%esp) + char *names[] = { "f0", "f1", "f2", "f3" }; + 211f: c7 45 d8 0a 56 00 00 movl $0x560a,-0x28(%ebp) + 2126: c7 45 dc 53 57 00 00 movl $0x5753,-0x24(%ebp) + 212d: c7 45 e0 57 57 00 00 movl $0x5757,-0x20(%ebp) + 2134: c7 45 e4 0d 56 00 00 movl $0x560d,-0x1c(%ebp) + printf(1, "fourfiles test\n"); + 213b: e8 c0 2c 00 00 call 4e00 + unlink(fname); + 2140: 89 34 24 mov %esi,(%esp) + 2143: e8 aa 2b 00 00 call 4cf2 + pid = fork(); + 2148: e8 4d 2b 00 00 call 4c9a + if(pid < 0){ + 214d: 85 c0 test %eax,%eax + 214f: 0f 88 89 01 00 00 js 22de + if(pid == 0){ + 2155: 0f 84 e4 00 00 00 je 223f + for(pi = 0; pi < 4; pi++){ + 215b: 83 c3 01 add $0x1,%ebx + 215e: 83 fb 04 cmp $0x4,%ebx + 2161: 74 06 je 2169 + 2163: 8b 74 9d d8 mov -0x28(%ebp,%ebx,4),%esi + 2167: eb d7 jmp 2140 + wait(); + 2169: e8 3c 2b 00 00 call 4caa + 216e: bf 30 00 00 00 mov $0x30,%edi + 2173: e8 32 2b 00 00 call 4caa + 2178: e8 2d 2b 00 00 call 4caa + 217d: e8 28 2b 00 00 call 4caa + 2182: c7 45 d4 0a 56 00 00 movl $0x560a,-0x2c(%ebp) + fd = open(fname, 0); + 2189: 8b 45 d4 mov -0x2c(%ebp),%eax + total = 0; + 218c: 31 db xor %ebx,%ebx + fd = open(fname, 0); + 218e: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 2195: 00 + 2196: 89 04 24 mov %eax,(%esp) + 2199: e8 44 2b 00 00 call 4ce2 + 219e: 89 c6 mov %eax,%esi + while((n = read(fd, buf, sizeof(buf))) > 0){ + 21a0: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) + 21a7: 00 + 21a8: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 21af: 00 + 21b0: 89 34 24 mov %esi,(%esp) + 21b3: e8 02 2b 00 00 call 4cba + 21b8: 85 c0 test %eax,%eax + 21ba: 7e 1a jle 21d6 + 21bc: 31 d2 xor %edx,%edx + 21be: 66 90 xchg %ax,%ax + if(buf[j] != '0'+i){ + 21c0: 0f be 8a 40 9a 00 00 movsbl 0x9a40(%edx),%ecx + 21c7: 39 cf cmp %ecx,%edi + 21c9: 75 5b jne 2226 + for(j = 0; j < n; j++){ + 21cb: 83 c2 01 add $0x1,%edx + 21ce: 39 c2 cmp %eax,%edx + 21d0: 75 ee jne 21c0 + total += n; + 21d2: 01 d3 add %edx,%ebx + 21d4: eb ca jmp 21a0 + close(fd); + 21d6: 89 34 24 mov %esi,(%esp) + 21d9: e8 ec 2a 00 00 call 4cca + if(total != 12*500){ + 21de: 81 fb 70 17 00 00 cmp $0x1770,%ebx + 21e4: 0f 85 d7 00 00 00 jne 22c1 + unlink(fname); + 21ea: 8b 45 d4 mov -0x2c(%ebp),%eax + 21ed: 89 04 24 mov %eax,(%esp) + 21f0: e8 fd 2a 00 00 call 4cf2 + for(i = 0; i < 2; i++){ + 21f5: 83 ff 31 cmp $0x31,%edi + 21f8: 75 1c jne 2216 + printf(1, "fourfiles ok\n"); + 21fa: c7 44 24 04 4e 56 00 movl $0x564e,0x4(%esp) + 2201: 00 + 2202: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2209: e8 f2 2b 00 00 call 4e00 +} + 220e: 83 c4 2c add $0x2c,%esp + 2211: 5b pop %ebx + 2212: 5e pop %esi + 2213: 5f pop %edi + 2214: 5d pop %ebp + 2215: c3 ret + 2216: 8b 45 dc mov -0x24(%ebp),%eax + 2219: bf 31 00 00 00 mov $0x31,%edi + 221e: 89 45 d4 mov %eax,-0x2c(%ebp) + 2221: e9 63 ff ff ff jmp 2189 + printf(1, "wrong char\n"); + 2226: c7 44 24 04 31 56 00 movl $0x5631,0x4(%esp) + 222d: 00 + 222e: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2235: e8 c6 2b 00 00 call 4e00 + exit(); + 223a: e8 63 2a 00 00 call 4ca2 + fd = open(fname, O_CREATE | O_RDWR); + 223f: 89 34 24 mov %esi,(%esp) + 2242: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 2249: 00 + 224a: e8 93 2a 00 00 call 4ce2 + if(fd < 0){ + 224f: 85 c0 test %eax,%eax + fd = open(fname, O_CREATE | O_RDWR); + 2251: 89 c6 mov %eax,%esi + if(fd < 0){ + 2253: 0f 88 9e 00 00 00 js 22f7 + memset(buf, '0'+pi, 512); + 2259: 83 c3 30 add $0x30,%ebx + 225c: 89 5c 24 04 mov %ebx,0x4(%esp) + 2260: bb 0c 00 00 00 mov $0xc,%ebx + 2265: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) + 226c: 00 + 226d: c7 04 24 40 9a 00 00 movl $0x9a40,(%esp) + 2274: e8 b7 28 00 00 call 4b30 + 2279: eb 0a jmp 2285 + 227b: 90 nop + 227c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + for(i = 0; i < 12; i++){ + 2280: 83 eb 01 sub $0x1,%ebx + 2283: 74 b5 je 223a + if((n = write(fd, buf, 500)) != 500){ + 2285: c7 44 24 08 f4 01 00 movl $0x1f4,0x8(%esp) + 228c: 00 + 228d: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 2294: 00 + 2295: 89 34 24 mov %esi,(%esp) + 2298: e8 25 2a 00 00 call 4cc2 + 229d: 3d f4 01 00 00 cmp $0x1f4,%eax + 22a2: 74 dc je 2280 + printf(1, "write failed %d\n", n); + 22a4: 89 44 24 08 mov %eax,0x8(%esp) + 22a8: c7 44 24 04 20 56 00 movl $0x5620,0x4(%esp) + 22af: 00 + 22b0: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 22b7: e8 44 2b 00 00 call 4e00 + exit(); + 22bc: e8 e1 29 00 00 call 4ca2 + printf(1, "wrong length %d\n", total); + 22c1: 89 5c 24 08 mov %ebx,0x8(%esp) + 22c5: c7 44 24 04 3d 56 00 movl $0x563d,0x4(%esp) + 22cc: 00 + 22cd: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 22d4: e8 27 2b 00 00 call 4e00 + exit(); + 22d9: e8 c4 29 00 00 call 4ca2 + printf(1, "fork failed\n"); + 22de: c7 44 24 04 e5 60 00 movl $0x60e5,0x4(%esp) + 22e5: 00 + 22e6: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 22ed: e8 0e 2b 00 00 call 4e00 + exit(); + 22f2: e8 ab 29 00 00 call 4ca2 + printf(1, "create failed\n"); + 22f7: c7 44 24 04 ab 58 00 movl $0x58ab,0x4(%esp) + 22fe: 00 + 22ff: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2306: e8 f5 2a 00 00 call 4e00 + exit(); + 230b: e8 92 29 00 00 call 4ca2 + +00002310 : +{ + 2310: 55 push %ebp + 2311: 89 e5 mov %esp,%ebp + 2313: 57 push %edi + 2314: 56 push %esi + 2315: 53 push %ebx + for(pi = 0; pi < 4; pi++){ + 2316: 31 db xor %ebx,%ebx +{ + 2318: 83 ec 4c sub $0x4c,%esp + printf(1, "createdelete test\n"); + 231b: c7 44 24 04 5c 56 00 movl $0x565c,0x4(%esp) + 2322: 00 + 2323: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 232a: e8 d1 2a 00 00 call 4e00 + pid = fork(); + 232f: e8 66 29 00 00 call 4c9a + if(pid < 0){ + 2334: 85 c0 test %eax,%eax + 2336: 0f 88 d2 01 00 00 js 250e + 233c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(pid == 0){ + 2340: 0f 84 14 01 00 00 je 245a + for(pi = 0; pi < 4; pi++){ + 2346: 83 c3 01 add $0x1,%ebx + 2349: 83 fb 04 cmp $0x4,%ebx + 234c: 75 e1 jne 232f + 234e: 66 90 xchg %ax,%ax + wait(); + 2350: e8 55 29 00 00 call 4caa + for(i = 0; i < N; i++){ + 2355: 31 f6 xor %esi,%esi + wait(); + 2357: e8 4e 29 00 00 call 4caa + 235c: 8d 7d c8 lea -0x38(%ebp),%edi + 235f: e8 46 29 00 00 call 4caa + 2364: e8 41 29 00 00 call 4caa + name[0] = name[1] = name[2] = 0; + 2369: c6 45 ca 00 movb $0x0,-0x36(%ebp) + 236d: 8d 76 00 lea 0x0(%esi),%esi + 2370: 85 f6 test %esi,%esi + name[2] = '\0'; + 2372: bb 70 00 00 00 mov $0x70,%ebx + 2377: 8d 46 30 lea 0x30(%esi),%eax + 237a: 0f 94 45 c7 sete -0x39(%ebp) + 237e: 83 fe 09 cmp $0x9,%esi + 2381: 88 45 c6 mov %al,-0x3a(%ebp) + 2384: 0f 9f c0 setg %al + 2387: 08 45 c7 or %al,-0x39(%ebp) + 238a: 8d 46 ff lea -0x1(%esi),%eax + 238d: 89 45 c0 mov %eax,-0x40(%ebp) + name[1] = '0' + i; + 2390: 0f b6 45 c6 movzbl -0x3a(%ebp),%eax + fd = open(name, 0); + 2394: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 239b: 00 + 239c: 89 3c 24 mov %edi,(%esp) + name[0] = 'p' + pi; + 239f: 88 5d c8 mov %bl,-0x38(%ebp) + name[1] = '0' + i; + 23a2: 88 45 c9 mov %al,-0x37(%ebp) + fd = open(name, 0); + 23a5: e8 38 29 00 00 call 4ce2 + if((i == 0 || i >= N/2) && fd < 0){ + 23aa: 80 7d c7 00 cmpb $0x0,-0x39(%ebp) + 23ae: 0f 84 84 00 00 00 je 2438 + 23b4: 85 c0 test %eax,%eax + 23b6: 0f 88 1c 01 00 00 js 24d8 + } else if((i >= 1 && i < N/2) && fd >= 0){ + 23bc: 83 7d c0 08 cmpl $0x8,-0x40(%ebp) + 23c0: 0f 86 61 01 00 00 jbe 2527 + close(fd); + 23c6: 89 04 24 mov %eax,(%esp) + 23c9: 83 c3 01 add $0x1,%ebx + 23cc: e8 f9 28 00 00 call 4cca + for(pi = 0; pi < 4; pi++){ + 23d1: 80 fb 74 cmp $0x74,%bl + 23d4: 75 ba jne 2390 + for(i = 0; i < N; i++){ + 23d6: 83 c6 01 add $0x1,%esi + 23d9: 83 fe 14 cmp $0x14,%esi + 23dc: 75 92 jne 2370 + 23de: be 70 00 00 00 mov $0x70,%esi + 23e3: 90 nop + 23e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 23e8: 8d 46 c0 lea -0x40(%esi),%eax + 23eb: bb 04 00 00 00 mov $0x4,%ebx + 23f0: 88 45 c7 mov %al,-0x39(%ebp) + name[0] = 'p' + i; + 23f3: 89 f0 mov %esi,%eax + 23f5: 88 45 c8 mov %al,-0x38(%ebp) + name[1] = '0' + i; + 23f8: 0f b6 45 c7 movzbl -0x39(%ebp),%eax + unlink(name); + 23fc: 89 3c 24 mov %edi,(%esp) + name[1] = '0' + i; + 23ff: 88 45 c9 mov %al,-0x37(%ebp) + unlink(name); + 2402: e8 eb 28 00 00 call 4cf2 + for(pi = 0; pi < 4; pi++){ + 2407: 83 eb 01 sub $0x1,%ebx + 240a: 75 e7 jne 23f3 + 240c: 83 c6 01 add $0x1,%esi + for(i = 0; i < N; i++){ + 240f: 89 f0 mov %esi,%eax + 2411: 3c 84 cmp $0x84,%al + 2413: 75 d3 jne 23e8 + printf(1, "createdelete ok\n"); + 2415: c7 44 24 04 6f 56 00 movl $0x566f,0x4(%esp) + 241c: 00 + 241d: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2424: e8 d7 29 00 00 call 4e00 +} + 2429: 83 c4 4c add $0x4c,%esp + 242c: 5b pop %ebx + 242d: 5e pop %esi + 242e: 5f pop %edi + 242f: 5d pop %ebp + 2430: c3 ret + 2431: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + } else if((i >= 1 && i < N/2) && fd >= 0){ + 2438: 85 c0 test %eax,%eax + 243a: 0f 89 e7 00 00 00 jns 2527 + 2440: 83 c3 01 add $0x1,%ebx + for(pi = 0; pi < 4; pi++){ + 2443: 80 fb 74 cmp $0x74,%bl + 2446: 0f 85 44 ff ff ff jne 2390 + for(i = 0; i < N; i++){ + 244c: 83 c6 01 add $0x1,%esi + 244f: 83 fe 14 cmp $0x14,%esi + 2452: 0f 85 18 ff ff ff jne 2370 + 2458: eb 84 jmp 23de + name[0] = 'p' + pi; + 245a: 83 c3 70 add $0x70,%ebx + name[2] = '\0'; + 245d: be 01 00 00 00 mov $0x1,%esi + name[0] = 'p' + pi; + 2462: 88 5d c8 mov %bl,-0x38(%ebp) + 2465: 8d 7d c8 lea -0x38(%ebp),%edi + name[2] = '\0'; + 2468: 31 db xor %ebx,%ebx + 246a: c6 45 ca 00 movb $0x0,-0x36(%ebp) + 246e: eb 0b jmp 247b + for(i = 0; i < N; i++){ + 2470: 83 fe 14 cmp $0x14,%esi + 2473: 74 7b je 24f0 + 2475: 83 c3 01 add $0x1,%ebx + 2478: 83 c6 01 add $0x1,%esi + 247b: 8d 43 30 lea 0x30(%ebx),%eax + fd = open(name, O_CREATE | O_RDWR); + 247e: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 2485: 00 + 2486: 89 3c 24 mov %edi,(%esp) + 2489: 88 45 c9 mov %al,-0x37(%ebp) + 248c: e8 51 28 00 00 call 4ce2 + if(fd < 0){ + 2491: 85 c0 test %eax,%eax + 2493: 78 60 js 24f5 + close(fd); + 2495: 89 04 24 mov %eax,(%esp) + 2498: e8 2d 28 00 00 call 4cca + if(i > 0 && (i % 2 ) == 0){ + 249d: 85 db test %ebx,%ebx + 249f: 74 d4 je 2475 + 24a1: f6 c3 01 test $0x1,%bl + 24a4: 75 ca jne 2470 + name[1] = '0' + (i / 2); + 24a6: 89 d8 mov %ebx,%eax + 24a8: d1 f8 sar %eax + 24aa: 83 c0 30 add $0x30,%eax + if(unlink(name) < 0){ + 24ad: 89 3c 24 mov %edi,(%esp) + name[1] = '0' + (i / 2); + 24b0: 88 45 c9 mov %al,-0x37(%ebp) + if(unlink(name) < 0){ + 24b3: e8 3a 28 00 00 call 4cf2 + 24b8: 85 c0 test %eax,%eax + 24ba: 79 b4 jns 2470 + printf(1, "unlink failed\n"); + 24bc: c7 44 24 04 5d 52 00 movl $0x525d,0x4(%esp) + 24c3: 00 + 24c4: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 24cb: e8 30 29 00 00 call 4e00 + exit(); + 24d0: e8 cd 27 00 00 call 4ca2 + 24d5: 8d 76 00 lea 0x0(%esi),%esi + printf(1, "oops createdelete %s didn't exist\n", name); + 24d8: 89 7c 24 08 mov %edi,0x8(%esp) + 24dc: c7 44 24 04 1c 63 00 movl $0x631c,0x4(%esp) + 24e3: 00 + 24e4: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 24eb: e8 10 29 00 00 call 4e00 + exit(); + 24f0: e8 ad 27 00 00 call 4ca2 + printf(1, "create failed\n"); + 24f5: c7 44 24 04 ab 58 00 movl $0x58ab,0x4(%esp) + 24fc: 00 + 24fd: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2504: e8 f7 28 00 00 call 4e00 + exit(); + 2509: e8 94 27 00 00 call 4ca2 + printf(1, "fork failed\n"); + 250e: c7 44 24 04 e5 60 00 movl $0x60e5,0x4(%esp) + 2515: 00 + 2516: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 251d: e8 de 28 00 00 call 4e00 + exit(); + 2522: e8 7b 27 00 00 call 4ca2 + printf(1, "oops createdelete %s did exist\n", name); + 2527: 89 7c 24 08 mov %edi,0x8(%esp) + 252b: c7 44 24 04 40 63 00 movl $0x6340,0x4(%esp) + 2532: 00 + 2533: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 253a: e8 c1 28 00 00 call 4e00 + exit(); + 253f: e8 5e 27 00 00 call 4ca2 + 2544: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 254a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00002550 : +{ + 2550: 55 push %ebp + 2551: 89 e5 mov %esp,%ebp + 2553: 56 push %esi + 2554: 53 push %ebx + 2555: 83 ec 10 sub $0x10,%esp + printf(1, "unlinkread test\n"); + 2558: c7 44 24 04 80 56 00 movl $0x5680,0x4(%esp) + 255f: 00 + 2560: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2567: e8 94 28 00 00 call 4e00 + fd = open("unlinkread", O_CREATE | O_RDWR); + 256c: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 2573: 00 + 2574: c7 04 24 91 56 00 00 movl $0x5691,(%esp) + 257b: e8 62 27 00 00 call 4ce2 + if(fd < 0){ + 2580: 85 c0 test %eax,%eax + fd = open("unlinkread", O_CREATE | O_RDWR); + 2582: 89 c3 mov %eax,%ebx + if(fd < 0){ + 2584: 0f 88 fe 00 00 00 js 2688 + write(fd, "hello", 5); + 258a: c7 44 24 08 05 00 00 movl $0x5,0x8(%esp) + 2591: 00 + 2592: c7 44 24 04 b6 56 00 movl $0x56b6,0x4(%esp) + 2599: 00 + 259a: 89 04 24 mov %eax,(%esp) + 259d: e8 20 27 00 00 call 4cc2 + close(fd); + 25a2: 89 1c 24 mov %ebx,(%esp) + 25a5: e8 20 27 00 00 call 4cca + fd = open("unlinkread", O_RDWR); + 25aa: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) + 25b1: 00 + 25b2: c7 04 24 91 56 00 00 movl $0x5691,(%esp) + 25b9: e8 24 27 00 00 call 4ce2 + if(fd < 0){ + 25be: 85 c0 test %eax,%eax + fd = open("unlinkread", O_RDWR); + 25c0: 89 c3 mov %eax,%ebx + if(fd < 0){ + 25c2: 0f 88 3d 01 00 00 js 2705 + if(unlink("unlinkread") != 0){ + 25c8: c7 04 24 91 56 00 00 movl $0x5691,(%esp) + 25cf: e8 1e 27 00 00 call 4cf2 + 25d4: 85 c0 test %eax,%eax + 25d6: 0f 85 10 01 00 00 jne 26ec + fd1 = open("unlinkread", O_CREATE | O_RDWR); + 25dc: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 25e3: 00 + 25e4: c7 04 24 91 56 00 00 movl $0x5691,(%esp) + 25eb: e8 f2 26 00 00 call 4ce2 + write(fd1, "yyy", 3); + 25f0: c7 44 24 08 03 00 00 movl $0x3,0x8(%esp) + 25f7: 00 + 25f8: c7 44 24 04 ee 56 00 movl $0x56ee,0x4(%esp) + 25ff: 00 + fd1 = open("unlinkread", O_CREATE | O_RDWR); + 2600: 89 c6 mov %eax,%esi + write(fd1, "yyy", 3); + 2602: 89 04 24 mov %eax,(%esp) + 2605: e8 b8 26 00 00 call 4cc2 + close(fd1); + 260a: 89 34 24 mov %esi,(%esp) + 260d: e8 b8 26 00 00 call 4cca + if(read(fd, buf, sizeof(buf)) != 5){ + 2612: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) + 2619: 00 + 261a: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 2621: 00 + 2622: 89 1c 24 mov %ebx,(%esp) + 2625: e8 90 26 00 00 call 4cba + 262a: 83 f8 05 cmp $0x5,%eax + 262d: 0f 85 a0 00 00 00 jne 26d3 + if(buf[0] != 'h'){ + 2633: 80 3d 40 9a 00 00 68 cmpb $0x68,0x9a40 + 263a: 75 7e jne 26ba + if(write(fd, buf, 10) != 10){ + 263c: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) + 2643: 00 + 2644: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 264b: 00 + 264c: 89 1c 24 mov %ebx,(%esp) + 264f: e8 6e 26 00 00 call 4cc2 + 2654: 83 f8 0a cmp $0xa,%eax + 2657: 75 48 jne 26a1 + close(fd); + 2659: 89 1c 24 mov %ebx,(%esp) + 265c: e8 69 26 00 00 call 4cca + unlink("unlinkread"); + 2661: c7 04 24 91 56 00 00 movl $0x5691,(%esp) + 2668: e8 85 26 00 00 call 4cf2 + printf(1, "unlinkread ok\n"); + 266d: c7 44 24 04 39 57 00 movl $0x5739,0x4(%esp) + 2674: 00 + 2675: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 267c: e8 7f 27 00 00 call 4e00 +} + 2681: 83 c4 10 add $0x10,%esp + 2684: 5b pop %ebx + 2685: 5e pop %esi + 2686: 5d pop %ebp + 2687: c3 ret + printf(1, "create unlinkread failed\n"); + 2688: c7 44 24 04 9c 56 00 movl $0x569c,0x4(%esp) + 268f: 00 + 2690: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2697: e8 64 27 00 00 call 4e00 + exit(); + 269c: e8 01 26 00 00 call 4ca2 + printf(1, "unlinkread write failed\n"); + 26a1: c7 44 24 04 20 57 00 movl $0x5720,0x4(%esp) + 26a8: 00 + 26a9: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 26b0: e8 4b 27 00 00 call 4e00 + exit(); + 26b5: e8 e8 25 00 00 call 4ca2 + printf(1, "unlinkread wrong data\n"); + 26ba: c7 44 24 04 09 57 00 movl $0x5709,0x4(%esp) + 26c1: 00 + 26c2: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 26c9: e8 32 27 00 00 call 4e00 + exit(); + 26ce: e8 cf 25 00 00 call 4ca2 + printf(1, "unlinkread read failed"); + 26d3: c7 44 24 04 f2 56 00 movl $0x56f2,0x4(%esp) + 26da: 00 + 26db: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 26e2: e8 19 27 00 00 call 4e00 + exit(); + 26e7: e8 b6 25 00 00 call 4ca2 + printf(1, "unlink unlinkread failed\n"); + 26ec: c7 44 24 04 d4 56 00 movl $0x56d4,0x4(%esp) + 26f3: 00 + 26f4: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 26fb: e8 00 27 00 00 call 4e00 + exit(); + 2700: e8 9d 25 00 00 call 4ca2 + printf(1, "open unlinkread failed\n"); + 2705: c7 44 24 04 bc 56 00 movl $0x56bc,0x4(%esp) + 270c: 00 + 270d: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2714: e8 e7 26 00 00 call 4e00 + exit(); + 2719: e8 84 25 00 00 call 4ca2 + 271e: 66 90 xchg %ax,%ax + +00002720 : +{ + 2720: 55 push %ebp + 2721: 89 e5 mov %esp,%ebp + 2723: 53 push %ebx + 2724: 83 ec 14 sub $0x14,%esp + printf(1, "linktest\n"); + 2727: c7 44 24 04 48 57 00 movl $0x5748,0x4(%esp) + 272e: 00 + 272f: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2736: e8 c5 26 00 00 call 4e00 + unlink("lf1"); + 273b: c7 04 24 52 57 00 00 movl $0x5752,(%esp) + 2742: e8 ab 25 00 00 call 4cf2 + unlink("lf2"); + 2747: c7 04 24 56 57 00 00 movl $0x5756,(%esp) + 274e: e8 9f 25 00 00 call 4cf2 + fd = open("lf1", O_CREATE|O_RDWR); + 2753: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 275a: 00 + 275b: c7 04 24 52 57 00 00 movl $0x5752,(%esp) + 2762: e8 7b 25 00 00 call 4ce2 + if(fd < 0){ + 2767: 85 c0 test %eax,%eax + fd = open("lf1", O_CREATE|O_RDWR); + 2769: 89 c3 mov %eax,%ebx + if(fd < 0){ + 276b: 0f 88 26 01 00 00 js 2897 + if(write(fd, "hello", 5) != 5){ + 2771: c7 44 24 08 05 00 00 movl $0x5,0x8(%esp) + 2778: 00 + 2779: c7 44 24 04 b6 56 00 movl $0x56b6,0x4(%esp) + 2780: 00 + 2781: 89 04 24 mov %eax,(%esp) + 2784: e8 39 25 00 00 call 4cc2 + 2789: 83 f8 05 cmp $0x5,%eax + 278c: 0f 85 cd 01 00 00 jne 295f + close(fd); + 2792: 89 1c 24 mov %ebx,(%esp) + 2795: e8 30 25 00 00 call 4cca + if(link("lf1", "lf2") < 0){ + 279a: c7 44 24 04 56 57 00 movl $0x5756,0x4(%esp) + 27a1: 00 + 27a2: c7 04 24 52 57 00 00 movl $0x5752,(%esp) + 27a9: e8 54 25 00 00 call 4d02 + 27ae: 85 c0 test %eax,%eax + 27b0: 0f 88 90 01 00 00 js 2946 + unlink("lf1"); + 27b6: c7 04 24 52 57 00 00 movl $0x5752,(%esp) + 27bd: e8 30 25 00 00 call 4cf2 + if(open("lf1", 0) >= 0){ + 27c2: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 27c9: 00 + 27ca: c7 04 24 52 57 00 00 movl $0x5752,(%esp) + 27d1: e8 0c 25 00 00 call 4ce2 + 27d6: 85 c0 test %eax,%eax + 27d8: 0f 89 4f 01 00 00 jns 292d + fd = open("lf2", 0); + 27de: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 27e5: 00 + 27e6: c7 04 24 56 57 00 00 movl $0x5756,(%esp) + 27ed: e8 f0 24 00 00 call 4ce2 + if(fd < 0){ + 27f2: 85 c0 test %eax,%eax + fd = open("lf2", 0); + 27f4: 89 c3 mov %eax,%ebx + if(fd < 0){ + 27f6: 0f 88 18 01 00 00 js 2914 + if(read(fd, buf, sizeof(buf)) != 5){ + 27fc: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) + 2803: 00 + 2804: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 280b: 00 + 280c: 89 04 24 mov %eax,(%esp) + 280f: e8 a6 24 00 00 call 4cba + 2814: 83 f8 05 cmp $0x5,%eax + 2817: 0f 85 de 00 00 00 jne 28fb + close(fd); + 281d: 89 1c 24 mov %ebx,(%esp) + 2820: e8 a5 24 00 00 call 4cca + if(link("lf2", "lf2") >= 0){ + 2825: c7 44 24 04 56 57 00 movl $0x5756,0x4(%esp) + 282c: 00 + 282d: c7 04 24 56 57 00 00 movl $0x5756,(%esp) + 2834: e8 c9 24 00 00 call 4d02 + 2839: 85 c0 test %eax,%eax + 283b: 0f 89 a1 00 00 00 jns 28e2 + unlink("lf2"); + 2841: c7 04 24 56 57 00 00 movl $0x5756,(%esp) + 2848: e8 a5 24 00 00 call 4cf2 + if(link("lf2", "lf1") >= 0){ + 284d: c7 44 24 04 52 57 00 movl $0x5752,0x4(%esp) + 2854: 00 + 2855: c7 04 24 56 57 00 00 movl $0x5756,(%esp) + 285c: e8 a1 24 00 00 call 4d02 + 2861: 85 c0 test %eax,%eax + 2863: 79 64 jns 28c9 + if(link(".", "lf1") >= 0){ + 2865: c7 44 24 04 52 57 00 movl $0x5752,0x4(%esp) + 286c: 00 + 286d: c7 04 24 1a 5a 00 00 movl $0x5a1a,(%esp) + 2874: e8 89 24 00 00 call 4d02 + 2879: 85 c0 test %eax,%eax + 287b: 79 33 jns 28b0 + printf(1, "linktest ok\n"); + 287d: c7 44 24 04 f0 57 00 movl $0x57f0,0x4(%esp) + 2884: 00 + 2885: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 288c: e8 6f 25 00 00 call 4e00 +} + 2891: 83 c4 14 add $0x14,%esp + 2894: 5b pop %ebx + 2895: 5d pop %ebp + 2896: c3 ret + printf(1, "create lf1 failed\n"); + 2897: c7 44 24 04 5a 57 00 movl $0x575a,0x4(%esp) + 289e: 00 + 289f: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 28a6: e8 55 25 00 00 call 4e00 + exit(); + 28ab: e8 f2 23 00 00 call 4ca2 + printf(1, "link . lf1 succeeded! oops\n"); + 28b0: c7 44 24 04 d4 57 00 movl $0x57d4,0x4(%esp) + 28b7: 00 + 28b8: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 28bf: e8 3c 25 00 00 call 4e00 + exit(); + 28c4: e8 d9 23 00 00 call 4ca2 + printf(1, "link non-existant succeeded! oops\n"); + 28c9: c7 44 24 04 88 63 00 movl $0x6388,0x4(%esp) + 28d0: 00 + 28d1: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 28d8: e8 23 25 00 00 call 4e00 + exit(); + 28dd: e8 c0 23 00 00 call 4ca2 + printf(1, "link lf2 lf2 succeeded! oops\n"); + 28e2: c7 44 24 04 b6 57 00 movl $0x57b6,0x4(%esp) + 28e9: 00 + 28ea: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 28f1: e8 0a 25 00 00 call 4e00 + exit(); + 28f6: e8 a7 23 00 00 call 4ca2 + printf(1, "read lf2 failed\n"); + 28fb: c7 44 24 04 a5 57 00 movl $0x57a5,0x4(%esp) + 2902: 00 + 2903: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 290a: e8 f1 24 00 00 call 4e00 + exit(); + 290f: e8 8e 23 00 00 call 4ca2 + printf(1, "open lf2 failed\n"); + 2914: c7 44 24 04 94 57 00 movl $0x5794,0x4(%esp) + 291b: 00 + 291c: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2923: e8 d8 24 00 00 call 4e00 + exit(); + 2928: e8 75 23 00 00 call 4ca2 + printf(1, "unlinked lf1 but it is still there!\n"); + 292d: c7 44 24 04 60 63 00 movl $0x6360,0x4(%esp) + 2934: 00 + 2935: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 293c: e8 bf 24 00 00 call 4e00 + exit(); + 2941: e8 5c 23 00 00 call 4ca2 + printf(1, "link lf1 lf2 failed\n"); + 2946: c7 44 24 04 7f 57 00 movl $0x577f,0x4(%esp) + 294d: 00 + 294e: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2955: e8 a6 24 00 00 call 4e00 + exit(); + 295a: e8 43 23 00 00 call 4ca2 + printf(1, "write lf1 failed\n"); + 295f: c7 44 24 04 6d 57 00 movl $0x576d,0x4(%esp) + 2966: 00 + 2967: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 296e: e8 8d 24 00 00 call 4e00 + exit(); + 2973: e8 2a 23 00 00 call 4ca2 + 2978: 90 nop + 2979: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00002980 : +{ + 2980: 55 push %ebp + 2981: 89 e5 mov %esp,%ebp + 2983: 57 push %edi + 2984: 56 push %esi + for(i = 0; i < 40; i++){ + 2985: 31 f6 xor %esi,%esi +{ + 2987: 53 push %ebx + 2988: 83 ec 5c sub $0x5c,%esp + printf(1, "concreate test\n"); + 298b: c7 44 24 04 fd 57 00 movl $0x57fd,0x4(%esp) + 2992: 00 + 2993: 8d 5d ad lea -0x53(%ebp),%ebx + 2996: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 299d: e8 5e 24 00 00 call 4e00 + file[0] = 'C'; + 29a2: c6 45 ad 43 movb $0x43,-0x53(%ebp) + file[2] = '\0'; + 29a6: c6 45 af 00 movb $0x0,-0x51(%ebp) + 29aa: eb 4f jmp 29fb + 29ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(pid && (i % 3) == 1){ + 29b0: b8 56 55 55 55 mov $0x55555556,%eax + 29b5: 89 f1 mov %esi,%ecx + 29b7: f7 ee imul %esi + 29b9: 89 f0 mov %esi,%eax + 29bb: c1 f8 1f sar $0x1f,%eax + 29be: 29 c2 sub %eax,%edx + 29c0: 8d 04 52 lea (%edx,%edx,2),%eax + 29c3: 29 c1 sub %eax,%ecx + 29c5: 83 f9 01 cmp $0x1,%ecx + 29c8: 74 7e je 2a48 + fd = open(file, O_CREATE | O_RDWR); + 29ca: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 29d1: 00 + 29d2: 89 1c 24 mov %ebx,(%esp) + 29d5: e8 08 23 00 00 call 4ce2 + if(fd < 0){ + 29da: 85 c0 test %eax,%eax + 29dc: 0f 88 43 02 00 00 js 2c25 + close(fd); + 29e2: 89 04 24 mov %eax,(%esp) + 29e5: e8 e0 22 00 00 call 4cca + if(pid == 0) + 29ea: 85 ff test %edi,%edi + 29ec: 74 52 je 2a40 + for(i = 0; i < 40; i++){ + 29ee: 83 c6 01 add $0x1,%esi + wait(); + 29f1: e8 b4 22 00 00 call 4caa + for(i = 0; i < 40; i++){ + 29f6: 83 fe 28 cmp $0x28,%esi + 29f9: 74 6d je 2a68 + 29fb: 8d 46 30 lea 0x30(%esi),%eax + unlink(file); + 29fe: 89 1c 24 mov %ebx,(%esp) + 2a01: 88 45 ae mov %al,-0x52(%ebp) + 2a04: e8 e9 22 00 00 call 4cf2 + pid = fork(); + 2a09: e8 8c 22 00 00 call 4c9a + if(pid && (i % 3) == 1){ + 2a0e: 85 c0 test %eax,%eax + pid = fork(); + 2a10: 89 c7 mov %eax,%edi + if(pid && (i % 3) == 1){ + 2a12: 75 9c jne 29b0 + } else if(pid == 0 && (i % 5) == 1){ + 2a14: b8 67 66 66 66 mov $0x66666667,%eax + 2a19: 89 f1 mov %esi,%ecx + 2a1b: f7 ee imul %esi + 2a1d: 89 f0 mov %esi,%eax + 2a1f: c1 f8 1f sar $0x1f,%eax + 2a22: d1 fa sar %edx + 2a24: 29 c2 sub %eax,%edx + 2a26: 8d 04 92 lea (%edx,%edx,4),%eax + 2a29: 29 c1 sub %eax,%ecx + 2a2b: 83 f9 01 cmp $0x1,%ecx + 2a2e: 75 9a jne 29ca + link("C0", file); + 2a30: 89 5c 24 04 mov %ebx,0x4(%esp) + 2a34: c7 04 24 0d 58 00 00 movl $0x580d,(%esp) + 2a3b: e8 c2 22 00 00 call 4d02 + exit(); + 2a40: e8 5d 22 00 00 call 4ca2 + 2a45: 8d 76 00 lea 0x0(%esi),%esi + link("C0", file); + 2a48: 89 5c 24 04 mov %ebx,0x4(%esp) + for(i = 0; i < 40; i++){ + 2a4c: 83 c6 01 add $0x1,%esi + link("C0", file); + 2a4f: c7 04 24 0d 58 00 00 movl $0x580d,(%esp) + 2a56: e8 a7 22 00 00 call 4d02 + wait(); + 2a5b: e8 4a 22 00 00 call 4caa + for(i = 0; i < 40; i++){ + 2a60: 83 fe 28 cmp $0x28,%esi + 2a63: 75 96 jne 29fb + 2a65: 8d 76 00 lea 0x0(%esi),%esi + memset(fa, 0, sizeof(fa)); + 2a68: 8d 45 c0 lea -0x40(%ebp),%eax + 2a6b: c7 44 24 08 28 00 00 movl $0x28,0x8(%esp) + 2a72: 00 + 2a73: 8d 7d b0 lea -0x50(%ebp),%edi + 2a76: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 2a7d: 00 + 2a7e: 89 04 24 mov %eax,(%esp) + 2a81: e8 aa 20 00 00 call 4b30 + fd = open(".", 0); + 2a86: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 2a8d: 00 + 2a8e: c7 04 24 1a 5a 00 00 movl $0x5a1a,(%esp) + 2a95: e8 48 22 00 00 call 4ce2 + n = 0; + 2a9a: c7 45 a4 00 00 00 00 movl $0x0,-0x5c(%ebp) + fd = open(".", 0); + 2aa1: 89 c6 mov %eax,%esi + 2aa3: 90 nop + 2aa4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while(read(fd, &de, sizeof(de)) > 0){ + 2aa8: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) + 2aaf: 00 + 2ab0: 89 7c 24 04 mov %edi,0x4(%esp) + 2ab4: 89 34 24 mov %esi,(%esp) + 2ab7: e8 fe 21 00 00 call 4cba + 2abc: 85 c0 test %eax,%eax + 2abe: 7e 40 jle 2b00 + if(de.inum == 0) + 2ac0: 66 83 7d b0 00 cmpw $0x0,-0x50(%ebp) + 2ac5: 74 e1 je 2aa8 + if(de.name[0] == 'C' && de.name[2] == '\0'){ + 2ac7: 80 7d b2 43 cmpb $0x43,-0x4e(%ebp) + 2acb: 75 db jne 2aa8 + 2acd: 80 7d b4 00 cmpb $0x0,-0x4c(%ebp) + 2ad1: 75 d5 jne 2aa8 + i = de.name[1] - '0'; + 2ad3: 0f be 45 b3 movsbl -0x4d(%ebp),%eax + 2ad7: 83 e8 30 sub $0x30,%eax + if(i < 0 || i >= sizeof(fa)){ + 2ada: 83 f8 27 cmp $0x27,%eax + 2add: 0f 87 5f 01 00 00 ja 2c42 + if(fa[i]){ + 2ae3: 80 7c 05 c0 00 cmpb $0x0,-0x40(%ebp,%eax,1) + 2ae8: 0f 85 8d 01 00 00 jne 2c7b + fa[i] = 1; + 2aee: c6 44 05 c0 01 movb $0x1,-0x40(%ebp,%eax,1) + n++; + 2af3: 83 45 a4 01 addl $0x1,-0x5c(%ebp) + 2af7: eb af jmp 2aa8 + 2af9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + close(fd); + 2b00: 89 34 24 mov %esi,(%esp) + 2b03: e8 c2 21 00 00 call 4cca + if(n != 40){ + 2b08: 83 7d a4 28 cmpl $0x28,-0x5c(%ebp) + 2b0c: 0f 85 50 01 00 00 jne 2c62 + 2b12: 31 f6 xor %esi,%esi + 2b14: eb 7f jmp 2b95 + 2b16: 66 90 xchg %ax,%ax + ((i % 3) == 1 && pid != 0)){ + 2b18: 85 ff test %edi,%edi + 2b1a: 0f 84 ae 00 00 00 je 2bce + close(open(file, 0)); + 2b20: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 2b27: 00 + 2b28: 89 1c 24 mov %ebx,(%esp) + 2b2b: e8 b2 21 00 00 call 4ce2 + 2b30: 89 04 24 mov %eax,(%esp) + 2b33: e8 92 21 00 00 call 4cca + close(open(file, 0)); + 2b38: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 2b3f: 00 + 2b40: 89 1c 24 mov %ebx,(%esp) + 2b43: e8 9a 21 00 00 call 4ce2 + 2b48: 89 04 24 mov %eax,(%esp) + 2b4b: e8 7a 21 00 00 call 4cca + close(open(file, 0)); + 2b50: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 2b57: 00 + 2b58: 89 1c 24 mov %ebx,(%esp) + 2b5b: e8 82 21 00 00 call 4ce2 + 2b60: 89 04 24 mov %eax,(%esp) + 2b63: e8 62 21 00 00 call 4cca + close(open(file, 0)); + 2b68: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 2b6f: 00 + 2b70: 89 1c 24 mov %ebx,(%esp) + 2b73: e8 6a 21 00 00 call 4ce2 + 2b78: 89 04 24 mov %eax,(%esp) + 2b7b: e8 4a 21 00 00 call 4cca + if(pid == 0) + 2b80: 85 ff test %edi,%edi + 2b82: 0f 84 b8 fe ff ff je 2a40 + for(i = 0; i < 40; i++){ + 2b88: 83 c6 01 add $0x1,%esi + wait(); + 2b8b: e8 1a 21 00 00 call 4caa + for(i = 0; i < 40; i++){ + 2b90: 83 fe 28 cmp $0x28,%esi + 2b93: 74 5b je 2bf0 + 2b95: 8d 46 30 lea 0x30(%esi),%eax + 2b98: 88 45 ae mov %al,-0x52(%ebp) + pid = fork(); + 2b9b: e8 fa 20 00 00 call 4c9a + if(pid < 0){ + 2ba0: 85 c0 test %eax,%eax + pid = fork(); + 2ba2: 89 c7 mov %eax,%edi + if(pid < 0){ + 2ba4: 78 66 js 2c0c + if(((i % 3) == 0 && pid == 0) || + 2ba6: b8 56 55 55 55 mov $0x55555556,%eax + 2bab: f7 ee imul %esi + 2bad: 89 f0 mov %esi,%eax + 2baf: c1 f8 1f sar $0x1f,%eax + 2bb2: 29 c2 sub %eax,%edx + 2bb4: 8d 04 52 lea (%edx,%edx,2),%eax + 2bb7: 89 f2 mov %esi,%edx + 2bb9: 29 c2 sub %eax,%edx + 2bbb: 89 d0 mov %edx,%eax + 2bbd: 09 f8 or %edi,%eax + 2bbf: 0f 84 5b ff ff ff je 2b20 + 2bc5: 83 fa 01 cmp $0x1,%edx + 2bc8: 0f 84 4a ff ff ff je 2b18 + unlink(file); + 2bce: 89 1c 24 mov %ebx,(%esp) + 2bd1: e8 1c 21 00 00 call 4cf2 + unlink(file); + 2bd6: 89 1c 24 mov %ebx,(%esp) + 2bd9: e8 14 21 00 00 call 4cf2 + unlink(file); + 2bde: 89 1c 24 mov %ebx,(%esp) + 2be1: e8 0c 21 00 00 call 4cf2 + unlink(file); + 2be6: 89 1c 24 mov %ebx,(%esp) + 2be9: e8 04 21 00 00 call 4cf2 + 2bee: eb 90 jmp 2b80 + printf(1, "concreate ok\n"); + 2bf0: c7 44 24 04 62 58 00 movl $0x5862,0x4(%esp) + 2bf7: 00 + 2bf8: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2bff: e8 fc 21 00 00 call 4e00 +} + 2c04: 83 c4 5c add $0x5c,%esp + 2c07: 5b pop %ebx + 2c08: 5e pop %esi + 2c09: 5f pop %edi + 2c0a: 5d pop %ebp + 2c0b: c3 ret + printf(1, "fork failed\n"); + 2c0c: c7 44 24 04 e5 60 00 movl $0x60e5,0x4(%esp) + 2c13: 00 + 2c14: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2c1b: e8 e0 21 00 00 call 4e00 + exit(); + 2c20: e8 7d 20 00 00 call 4ca2 + printf(1, "concreate create %s failed\n", file); + 2c25: 89 5c 24 08 mov %ebx,0x8(%esp) + 2c29: c7 44 24 04 10 58 00 movl $0x5810,0x4(%esp) + 2c30: 00 + 2c31: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2c38: e8 c3 21 00 00 call 4e00 + exit(); + 2c3d: e8 60 20 00 00 call 4ca2 + printf(1, "concreate weird file %s\n", de.name); + 2c42: 8d 45 b2 lea -0x4e(%ebp),%eax + 2c45: 89 44 24 08 mov %eax,0x8(%esp) + 2c49: c7 44 24 04 2c 58 00 movl $0x582c,0x4(%esp) + 2c50: 00 + 2c51: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2c58: e8 a3 21 00 00 call 4e00 + 2c5d: e9 de fd ff ff jmp 2a40 + printf(1, "concreate not enough files in directory listing\n"); + 2c62: c7 44 24 04 ac 63 00 movl $0x63ac,0x4(%esp) + 2c69: 00 + 2c6a: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2c71: e8 8a 21 00 00 call 4e00 + exit(); + 2c76: e8 27 20 00 00 call 4ca2 + printf(1, "concreate duplicate file %s\n", de.name); + 2c7b: 8d 45 b2 lea -0x4e(%ebp),%eax + 2c7e: 89 44 24 08 mov %eax,0x8(%esp) + 2c82: c7 44 24 04 45 58 00 movl $0x5845,0x4(%esp) + 2c89: 00 + 2c8a: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2c91: e8 6a 21 00 00 call 4e00 + exit(); + 2c96: e8 07 20 00 00 call 4ca2 + 2c9b: 90 nop + 2c9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +00002ca0 : +{ + 2ca0: 55 push %ebp + 2ca1: 89 e5 mov %esp,%ebp + 2ca3: 57 push %edi + 2ca4: 56 push %esi + 2ca5: 53 push %ebx + 2ca6: 83 ec 1c sub $0x1c,%esp + printf(1, "linkunlink test\n"); + 2ca9: c7 44 24 04 70 58 00 movl $0x5870,0x4(%esp) + 2cb0: 00 + 2cb1: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2cb8: e8 43 21 00 00 call 4e00 + unlink("x"); + 2cbd: c7 04 24 fd 5a 00 00 movl $0x5afd,(%esp) + 2cc4: e8 29 20 00 00 call 4cf2 + pid = fork(); + 2cc9: e8 cc 1f 00 00 call 4c9a + if(pid < 0){ + 2cce: 85 c0 test %eax,%eax + pid = fork(); + 2cd0: 89 45 e4 mov %eax,-0x1c(%ebp) + if(pid < 0){ + 2cd3: 0f 88 b8 00 00 00 js 2d91 + unsigned int x = (pid ? 1 : 97); + 2cd9: 83 7d e4 01 cmpl $0x1,-0x1c(%ebp) + 2cdd: bb 64 00 00 00 mov $0x64,%ebx + if((x % 3) == 0){ + 2ce2: be ab aa aa aa mov $0xaaaaaaab,%esi + unsigned int x = (pid ? 1 : 97); + 2ce7: 19 ff sbb %edi,%edi + 2ce9: 83 e7 60 and $0x60,%edi + 2cec: 83 c7 01 add $0x1,%edi + 2cef: eb 1d jmp 2d0e + 2cf1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + } else if((x % 3) == 1){ + 2cf8: 83 fa 01 cmp $0x1,%edx + 2cfb: 74 7b je 2d78 + unlink("x"); + 2cfd: c7 04 24 fd 5a 00 00 movl $0x5afd,(%esp) + 2d04: e8 e9 1f 00 00 call 4cf2 + for(i = 0; i < 100; i++){ + 2d09: 83 eb 01 sub $0x1,%ebx + 2d0c: 74 3c je 2d4a + x = x * 1103515245 + 12345; + 2d0e: 69 cf 6d 4e c6 41 imul $0x41c64e6d,%edi,%ecx + 2d14: 8d b9 39 30 00 00 lea 0x3039(%ecx),%edi + if((x % 3) == 0){ + 2d1a: 89 f8 mov %edi,%eax + 2d1c: f7 e6 mul %esi + 2d1e: d1 ea shr %edx + 2d20: 8d 04 52 lea (%edx,%edx,2),%eax + 2d23: 89 fa mov %edi,%edx + 2d25: 29 c2 sub %eax,%edx + 2d27: 75 cf jne 2cf8 + close(open("x", O_RDWR | O_CREATE)); + 2d29: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 2d30: 00 + 2d31: c7 04 24 fd 5a 00 00 movl $0x5afd,(%esp) + 2d38: e8 a5 1f 00 00 call 4ce2 + 2d3d: 89 04 24 mov %eax,(%esp) + 2d40: e8 85 1f 00 00 call 4cca + for(i = 0; i < 100; i++){ + 2d45: 83 eb 01 sub $0x1,%ebx + 2d48: 75 c4 jne 2d0e + if(pid) + 2d4a: 8b 45 e4 mov -0x1c(%ebp),%eax + 2d4d: 85 c0 test %eax,%eax + 2d4f: 74 59 je 2daa + wait(); + 2d51: e8 54 1f 00 00 call 4caa + printf(1, "linkunlink ok\n"); + 2d56: c7 44 24 04 85 58 00 movl $0x5885,0x4(%esp) + 2d5d: 00 + 2d5e: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2d65: e8 96 20 00 00 call 4e00 +} + 2d6a: 83 c4 1c add $0x1c,%esp + 2d6d: 5b pop %ebx + 2d6e: 5e pop %esi + 2d6f: 5f pop %edi + 2d70: 5d pop %ebp + 2d71: c3 ret + 2d72: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + link("cat", "x"); + 2d78: c7 44 24 04 fd 5a 00 movl $0x5afd,0x4(%esp) + 2d7f: 00 + 2d80: c7 04 24 81 58 00 00 movl $0x5881,(%esp) + 2d87: e8 76 1f 00 00 call 4d02 + 2d8c: e9 78 ff ff ff jmp 2d09 + printf(1, "fork failed\n"); + 2d91: c7 44 24 04 e5 60 00 movl $0x60e5,0x4(%esp) + 2d98: 00 + 2d99: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2da0: e8 5b 20 00 00 call 4e00 + exit(); + 2da5: e8 f8 1e 00 00 call 4ca2 + exit(); + 2daa: e8 f3 1e 00 00 call 4ca2 + 2daf: 90 nop + +00002db0 : +{ + 2db0: 55 push %ebp + 2db1: 89 e5 mov %esp,%ebp + 2db3: 56 push %esi + 2db4: 53 push %ebx + 2db5: 83 ec 20 sub $0x20,%esp + printf(1, "bigdir test\n"); + 2db8: c7 44 24 04 94 58 00 movl $0x5894,0x4(%esp) + 2dbf: 00 + 2dc0: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2dc7: e8 34 20 00 00 call 4e00 + unlink("bd"); + 2dcc: c7 04 24 a1 58 00 00 movl $0x58a1,(%esp) + 2dd3: e8 1a 1f 00 00 call 4cf2 + fd = open("bd", O_CREATE); + 2dd8: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) + 2ddf: 00 + 2de0: c7 04 24 a1 58 00 00 movl $0x58a1,(%esp) + 2de7: e8 f6 1e 00 00 call 4ce2 + if(fd < 0){ + 2dec: 85 c0 test %eax,%eax + 2dee: 0f 88 e6 00 00 00 js 2eda + close(fd); + 2df4: 89 04 24 mov %eax,(%esp) + for(i = 0; i < 500; i++){ + 2df7: 31 db xor %ebx,%ebx + close(fd); + 2df9: e8 cc 1e 00 00 call 4cca + 2dfe: 8d 75 ee lea -0x12(%ebp),%esi + 2e01: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + name[1] = '0' + (i / 64); + 2e08: 89 d8 mov %ebx,%eax + 2e0a: c1 f8 06 sar $0x6,%eax + 2e0d: 83 c0 30 add $0x30,%eax + 2e10: 88 45 ef mov %al,-0x11(%ebp) + name[2] = '0' + (i % 64); + 2e13: 89 d8 mov %ebx,%eax + 2e15: 83 e0 3f and $0x3f,%eax + 2e18: 83 c0 30 add $0x30,%eax + if(link("bd", name) != 0){ + 2e1b: 89 74 24 04 mov %esi,0x4(%esp) + 2e1f: c7 04 24 a1 58 00 00 movl $0x58a1,(%esp) + name[0] = 'x'; + 2e26: c6 45 ee 78 movb $0x78,-0x12(%ebp) + name[2] = '0' + (i % 64); + 2e2a: 88 45 f0 mov %al,-0x10(%ebp) + name[3] = '\0'; + 2e2d: c6 45 f1 00 movb $0x0,-0xf(%ebp) + if(link("bd", name) != 0){ + 2e31: e8 cc 1e 00 00 call 4d02 + 2e36: 85 c0 test %eax,%eax + 2e38: 75 6e jne 2ea8 + for(i = 0; i < 500; i++){ + 2e3a: 83 c3 01 add $0x1,%ebx + 2e3d: 81 fb f4 01 00 00 cmp $0x1f4,%ebx + 2e43: 75 c3 jne 2e08 + unlink("bd"); + 2e45: c7 04 24 a1 58 00 00 movl $0x58a1,(%esp) + for(i = 0; i < 500; i++){ + 2e4c: 66 31 db xor %bx,%bx + unlink("bd"); + 2e4f: e8 9e 1e 00 00 call 4cf2 + 2e54: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + name[1] = '0' + (i / 64); + 2e58: 89 d8 mov %ebx,%eax + 2e5a: c1 f8 06 sar $0x6,%eax + 2e5d: 83 c0 30 add $0x30,%eax + 2e60: 88 45 ef mov %al,-0x11(%ebp) + name[2] = '0' + (i % 64); + 2e63: 89 d8 mov %ebx,%eax + 2e65: 83 e0 3f and $0x3f,%eax + 2e68: 83 c0 30 add $0x30,%eax + if(unlink(name) != 0){ + 2e6b: 89 34 24 mov %esi,(%esp) + name[0] = 'x'; + 2e6e: c6 45 ee 78 movb $0x78,-0x12(%ebp) + name[2] = '0' + (i % 64); + 2e72: 88 45 f0 mov %al,-0x10(%ebp) + name[3] = '\0'; + 2e75: c6 45 f1 00 movb $0x0,-0xf(%ebp) + if(unlink(name) != 0){ + 2e79: e8 74 1e 00 00 call 4cf2 + 2e7e: 85 c0 test %eax,%eax + 2e80: 75 3f jne 2ec1 + for(i = 0; i < 500; i++){ + 2e82: 83 c3 01 add $0x1,%ebx + 2e85: 81 fb f4 01 00 00 cmp $0x1f4,%ebx + 2e8b: 75 cb jne 2e58 + printf(1, "bigdir ok\n"); + 2e8d: c7 44 24 04 e3 58 00 movl $0x58e3,0x4(%esp) + 2e94: 00 + 2e95: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2e9c: e8 5f 1f 00 00 call 4e00 +} + 2ea1: 83 c4 20 add $0x20,%esp + 2ea4: 5b pop %ebx + 2ea5: 5e pop %esi + 2ea6: 5d pop %ebp + 2ea7: c3 ret + printf(1, "bigdir link failed\n"); + 2ea8: c7 44 24 04 ba 58 00 movl $0x58ba,0x4(%esp) + 2eaf: 00 + 2eb0: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2eb7: e8 44 1f 00 00 call 4e00 + exit(); + 2ebc: e8 e1 1d 00 00 call 4ca2 + printf(1, "bigdir unlink failed"); + 2ec1: c7 44 24 04 ce 58 00 movl $0x58ce,0x4(%esp) + 2ec8: 00 + 2ec9: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2ed0: e8 2b 1f 00 00 call 4e00 + exit(); + 2ed5: e8 c8 1d 00 00 call 4ca2 + printf(1, "bigdir create failed\n"); + 2eda: c7 44 24 04 a4 58 00 movl $0x58a4,0x4(%esp) + 2ee1: 00 + 2ee2: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2ee9: e8 12 1f 00 00 call 4e00 + exit(); + 2eee: e8 af 1d 00 00 call 4ca2 + 2ef3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 2ef9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00002f00 : +{ + 2f00: 55 push %ebp + 2f01: 89 e5 mov %esp,%ebp + 2f03: 53 push %ebx + 2f04: 83 ec 14 sub $0x14,%esp + printf(1, "subdir test\n"); + 2f07: c7 44 24 04 ee 58 00 movl $0x58ee,0x4(%esp) + 2f0e: 00 + 2f0f: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 2f16: e8 e5 1e 00 00 call 4e00 + unlink("ff"); + 2f1b: c7 04 24 77 59 00 00 movl $0x5977,(%esp) + 2f22: e8 cb 1d 00 00 call 4cf2 + if(mkdir("dd") != 0){ + 2f27: c7 04 24 14 5a 00 00 movl $0x5a14,(%esp) + 2f2e: e8 d7 1d 00 00 call 4d0a + 2f33: 85 c0 test %eax,%eax + 2f35: 0f 85 07 06 00 00 jne 3542 + fd = open("dd/ff", O_CREATE | O_RDWR); + 2f3b: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 2f42: 00 + 2f43: c7 04 24 4d 59 00 00 movl $0x594d,(%esp) + 2f4a: e8 93 1d 00 00 call 4ce2 + if(fd < 0){ + 2f4f: 85 c0 test %eax,%eax + fd = open("dd/ff", O_CREATE | O_RDWR); + 2f51: 89 c3 mov %eax,%ebx + if(fd < 0){ + 2f53: 0f 88 d0 05 00 00 js 3529 + write(fd, "ff", 2); + 2f59: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp) + 2f60: 00 + 2f61: c7 44 24 04 77 59 00 movl $0x5977,0x4(%esp) + 2f68: 00 + 2f69: 89 04 24 mov %eax,(%esp) + 2f6c: e8 51 1d 00 00 call 4cc2 + close(fd); + 2f71: 89 1c 24 mov %ebx,(%esp) + 2f74: e8 51 1d 00 00 call 4cca + if(unlink("dd") >= 0){ + 2f79: c7 04 24 14 5a 00 00 movl $0x5a14,(%esp) + 2f80: e8 6d 1d 00 00 call 4cf2 + 2f85: 85 c0 test %eax,%eax + 2f87: 0f 89 83 05 00 00 jns 3510 + if(mkdir("/dd/dd") != 0){ + 2f8d: c7 04 24 28 59 00 00 movl $0x5928,(%esp) + 2f94: e8 71 1d 00 00 call 4d0a + 2f99: 85 c0 test %eax,%eax + 2f9b: 0f 85 56 05 00 00 jne 34f7 + fd = open("dd/dd/ff", O_CREATE | O_RDWR); + 2fa1: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 2fa8: 00 + 2fa9: c7 04 24 4a 59 00 00 movl $0x594a,(%esp) + 2fb0: e8 2d 1d 00 00 call 4ce2 + if(fd < 0){ + 2fb5: 85 c0 test %eax,%eax + fd = open("dd/dd/ff", O_CREATE | O_RDWR); + 2fb7: 89 c3 mov %eax,%ebx + if(fd < 0){ + 2fb9: 0f 88 25 04 00 00 js 33e4 + write(fd, "FF", 2); + 2fbf: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp) + 2fc6: 00 + 2fc7: c7 44 24 04 6b 59 00 movl $0x596b,0x4(%esp) + 2fce: 00 + 2fcf: 89 04 24 mov %eax,(%esp) + 2fd2: e8 eb 1c 00 00 call 4cc2 + close(fd); + 2fd7: 89 1c 24 mov %ebx,(%esp) + 2fda: e8 eb 1c 00 00 call 4cca + fd = open("dd/dd/../ff", 0); + 2fdf: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 2fe6: 00 + 2fe7: c7 04 24 6e 59 00 00 movl $0x596e,(%esp) + 2fee: e8 ef 1c 00 00 call 4ce2 + if(fd < 0){ + 2ff3: 85 c0 test %eax,%eax + fd = open("dd/dd/../ff", 0); + 2ff5: 89 c3 mov %eax,%ebx + if(fd < 0){ + 2ff7: 0f 88 ce 03 00 00 js 33cb + cc = read(fd, buf, sizeof(buf)); + 2ffd: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) + 3004: 00 + 3005: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 300c: 00 + 300d: 89 04 24 mov %eax,(%esp) + 3010: e8 a5 1c 00 00 call 4cba + if(cc != 2 || buf[0] != 'f'){ + 3015: 83 f8 02 cmp $0x2,%eax + 3018: 0f 85 fe 02 00 00 jne 331c + 301e: 80 3d 40 9a 00 00 66 cmpb $0x66,0x9a40 + 3025: 0f 85 f1 02 00 00 jne 331c + close(fd); + 302b: 89 1c 24 mov %ebx,(%esp) + 302e: e8 97 1c 00 00 call 4cca + if(link("dd/dd/ff", "dd/dd/ffff") != 0){ + 3033: c7 44 24 04 ae 59 00 movl $0x59ae,0x4(%esp) + 303a: 00 + 303b: c7 04 24 4a 59 00 00 movl $0x594a,(%esp) + 3042: e8 bb 1c 00 00 call 4d02 + 3047: 85 c0 test %eax,%eax + 3049: 0f 85 c7 03 00 00 jne 3416 + if(unlink("dd/dd/ff") != 0){ + 304f: c7 04 24 4a 59 00 00 movl $0x594a,(%esp) + 3056: e8 97 1c 00 00 call 4cf2 + 305b: 85 c0 test %eax,%eax + 305d: 0f 85 eb 02 00 00 jne 334e + if(open("dd/dd/ff", O_RDONLY) >= 0){ + 3063: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 306a: 00 + 306b: c7 04 24 4a 59 00 00 movl $0x594a,(%esp) + 3072: e8 6b 1c 00 00 call 4ce2 + 3077: 85 c0 test %eax,%eax + 3079: 0f 89 5f 04 00 00 jns 34de + if(chdir("dd") != 0){ + 307f: c7 04 24 14 5a 00 00 movl $0x5a14,(%esp) + 3086: e8 87 1c 00 00 call 4d12 + 308b: 85 c0 test %eax,%eax + 308d: 0f 85 32 04 00 00 jne 34c5 + if(chdir("dd/../../dd") != 0){ + 3093: c7 04 24 e2 59 00 00 movl $0x59e2,(%esp) + 309a: e8 73 1c 00 00 call 4d12 + 309f: 85 c0 test %eax,%eax + 30a1: 0f 85 8e 02 00 00 jne 3335 + if(chdir("dd/../../../dd") != 0){ + 30a7: c7 04 24 08 5a 00 00 movl $0x5a08,(%esp) + 30ae: e8 5f 1c 00 00 call 4d12 + 30b3: 85 c0 test %eax,%eax + 30b5: 0f 85 7a 02 00 00 jne 3335 + if(chdir("./..") != 0){ + 30bb: c7 04 24 17 5a 00 00 movl $0x5a17,(%esp) + 30c2: e8 4b 1c 00 00 call 4d12 + 30c7: 85 c0 test %eax,%eax + 30c9: 0f 85 2e 03 00 00 jne 33fd + fd = open("dd/dd/ffff", 0); + 30cf: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 30d6: 00 + 30d7: c7 04 24 ae 59 00 00 movl $0x59ae,(%esp) + 30de: e8 ff 1b 00 00 call 4ce2 + if(fd < 0){ + 30e3: 85 c0 test %eax,%eax + fd = open("dd/dd/ffff", 0); + 30e5: 89 c3 mov %eax,%ebx + if(fd < 0){ + 30e7: 0f 88 81 05 00 00 js 366e + if(read(fd, buf, sizeof(buf)) != 2){ + 30ed: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) + 30f4: 00 + 30f5: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 30fc: 00 + 30fd: 89 04 24 mov %eax,(%esp) + 3100: e8 b5 1b 00 00 call 4cba + 3105: 83 f8 02 cmp $0x2,%eax + 3108: 0f 85 47 05 00 00 jne 3655 + close(fd); + 310e: 89 1c 24 mov %ebx,(%esp) + 3111: e8 b4 1b 00 00 call 4cca + if(open("dd/dd/ff", O_RDONLY) >= 0){ + 3116: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 311d: 00 + 311e: c7 04 24 4a 59 00 00 movl $0x594a,(%esp) + 3125: e8 b8 1b 00 00 call 4ce2 + 312a: 85 c0 test %eax,%eax + 312c: 0f 89 4e 02 00 00 jns 3380 + if(open("dd/ff/ff", O_CREATE|O_RDWR) >= 0){ + 3132: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 3139: 00 + 313a: c7 04 24 62 5a 00 00 movl $0x5a62,(%esp) + 3141: e8 9c 1b 00 00 call 4ce2 + 3146: 85 c0 test %eax,%eax + 3148: 0f 89 19 02 00 00 jns 3367 + if(open("dd/xx/ff", O_CREATE|O_RDWR) >= 0){ + 314e: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 3155: 00 + 3156: c7 04 24 87 5a 00 00 movl $0x5a87,(%esp) + 315d: e8 80 1b 00 00 call 4ce2 + 3162: 85 c0 test %eax,%eax + 3164: 0f 89 42 03 00 00 jns 34ac + if(open("dd", O_CREATE) >= 0){ + 316a: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) + 3171: 00 + 3172: c7 04 24 14 5a 00 00 movl $0x5a14,(%esp) + 3179: e8 64 1b 00 00 call 4ce2 + 317e: 85 c0 test %eax,%eax + 3180: 0f 89 0d 03 00 00 jns 3493 + if(open("dd", O_RDWR) >= 0){ + 3186: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) + 318d: 00 + 318e: c7 04 24 14 5a 00 00 movl $0x5a14,(%esp) + 3195: e8 48 1b 00 00 call 4ce2 + 319a: 85 c0 test %eax,%eax + 319c: 0f 89 d8 02 00 00 jns 347a + if(open("dd", O_WRONLY) >= 0){ + 31a2: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) + 31a9: 00 + 31aa: c7 04 24 14 5a 00 00 movl $0x5a14,(%esp) + 31b1: e8 2c 1b 00 00 call 4ce2 + 31b6: 85 c0 test %eax,%eax + 31b8: 0f 89 a3 02 00 00 jns 3461 + if(link("dd/ff/ff", "dd/dd/xx") == 0){ + 31be: c7 44 24 04 f6 5a 00 movl $0x5af6,0x4(%esp) + 31c5: 00 + 31c6: c7 04 24 62 5a 00 00 movl $0x5a62,(%esp) + 31cd: e8 30 1b 00 00 call 4d02 + 31d2: 85 c0 test %eax,%eax + 31d4: 0f 84 6e 02 00 00 je 3448 + if(link("dd/xx/ff", "dd/dd/xx") == 0){ + 31da: c7 44 24 04 f6 5a 00 movl $0x5af6,0x4(%esp) + 31e1: 00 + 31e2: c7 04 24 87 5a 00 00 movl $0x5a87,(%esp) + 31e9: e8 14 1b 00 00 call 4d02 + 31ee: 85 c0 test %eax,%eax + 31f0: 0f 84 39 02 00 00 je 342f + if(link("dd/ff", "dd/dd/ffff") == 0){ + 31f6: c7 44 24 04 ae 59 00 movl $0x59ae,0x4(%esp) + 31fd: 00 + 31fe: c7 04 24 4d 59 00 00 movl $0x594d,(%esp) + 3205: e8 f8 1a 00 00 call 4d02 + 320a: 85 c0 test %eax,%eax + 320c: 0f 84 a0 01 00 00 je 33b2 + if(mkdir("dd/ff/ff") == 0){ + 3212: c7 04 24 62 5a 00 00 movl $0x5a62,(%esp) + 3219: e8 ec 1a 00 00 call 4d0a + 321e: 85 c0 test %eax,%eax + 3220: 0f 84 73 01 00 00 je 3399 + if(mkdir("dd/xx/ff") == 0){ + 3226: c7 04 24 87 5a 00 00 movl $0x5a87,(%esp) + 322d: e8 d8 1a 00 00 call 4d0a + 3232: 85 c0 test %eax,%eax + 3234: 0f 84 02 04 00 00 je 363c + if(mkdir("dd/dd/ffff") == 0){ + 323a: c7 04 24 ae 59 00 00 movl $0x59ae,(%esp) + 3241: e8 c4 1a 00 00 call 4d0a + 3246: 85 c0 test %eax,%eax + 3248: 0f 84 d5 03 00 00 je 3623 + if(unlink("dd/xx/ff") == 0){ + 324e: c7 04 24 87 5a 00 00 movl $0x5a87,(%esp) + 3255: e8 98 1a 00 00 call 4cf2 + 325a: 85 c0 test %eax,%eax + 325c: 0f 84 a8 03 00 00 je 360a + if(unlink("dd/ff/ff") == 0){ + 3262: c7 04 24 62 5a 00 00 movl $0x5a62,(%esp) + 3269: e8 84 1a 00 00 call 4cf2 + 326e: 85 c0 test %eax,%eax + 3270: 0f 84 7b 03 00 00 je 35f1 + if(chdir("dd/ff") == 0){ + 3276: c7 04 24 4d 59 00 00 movl $0x594d,(%esp) + 327d: e8 90 1a 00 00 call 4d12 + 3282: 85 c0 test %eax,%eax + 3284: 0f 84 4e 03 00 00 je 35d8 + if(chdir("dd/xx") == 0){ + 328a: c7 04 24 f9 5a 00 00 movl $0x5af9,(%esp) + 3291: e8 7c 1a 00 00 call 4d12 + 3296: 85 c0 test %eax,%eax + 3298: 0f 84 21 03 00 00 je 35bf + if(unlink("dd/dd/ffff") != 0){ + 329e: c7 04 24 ae 59 00 00 movl $0x59ae,(%esp) + 32a5: e8 48 1a 00 00 call 4cf2 + 32aa: 85 c0 test %eax,%eax + 32ac: 0f 85 9c 00 00 00 jne 334e + if(unlink("dd/ff") != 0){ + 32b2: c7 04 24 4d 59 00 00 movl $0x594d,(%esp) + 32b9: e8 34 1a 00 00 call 4cf2 + 32be: 85 c0 test %eax,%eax + 32c0: 0f 85 e0 02 00 00 jne 35a6 + if(unlink("dd") == 0){ + 32c6: c7 04 24 14 5a 00 00 movl $0x5a14,(%esp) + 32cd: e8 20 1a 00 00 call 4cf2 + 32d2: 85 c0 test %eax,%eax + 32d4: 0f 84 b3 02 00 00 je 358d + if(unlink("dd/dd") < 0){ + 32da: c7 04 24 29 59 00 00 movl $0x5929,(%esp) + 32e1: e8 0c 1a 00 00 call 4cf2 + 32e6: 85 c0 test %eax,%eax + 32e8: 0f 88 86 02 00 00 js 3574 + if(unlink("dd") < 0){ + 32ee: c7 04 24 14 5a 00 00 movl $0x5a14,(%esp) + 32f5: e8 f8 19 00 00 call 4cf2 + 32fa: 85 c0 test %eax,%eax + 32fc: 0f 88 59 02 00 00 js 355b + printf(1, "subdir ok\n"); + 3302: c7 44 24 04 f6 5b 00 movl $0x5bf6,0x4(%esp) + 3309: 00 + 330a: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3311: e8 ea 1a 00 00 call 4e00 +} + 3316: 83 c4 14 add $0x14,%esp + 3319: 5b pop %ebx + 331a: 5d pop %ebp + 331b: c3 ret + printf(1, "dd/dd/../ff wrong content\n"); + 331c: c7 44 24 04 93 59 00 movl $0x5993,0x4(%esp) + 3323: 00 + 3324: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 332b: e8 d0 1a 00 00 call 4e00 + exit(); + 3330: e8 6d 19 00 00 call 4ca2 + printf(1, "chdir dd/../../dd failed\n"); + 3335: c7 44 24 04 ee 59 00 movl $0x59ee,0x4(%esp) + 333c: 00 + 333d: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3344: e8 b7 1a 00 00 call 4e00 + exit(); + 3349: e8 54 19 00 00 call 4ca2 + printf(1, "unlink dd/dd/ff failed\n"); + 334e: c7 44 24 04 b9 59 00 movl $0x59b9,0x4(%esp) + 3355: 00 + 3356: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 335d: e8 9e 1a 00 00 call 4e00 + exit(); + 3362: e8 3b 19 00 00 call 4ca2 + printf(1, "create dd/ff/ff succeeded!\n"); + 3367: c7 44 24 04 6b 5a 00 movl $0x5a6b,0x4(%esp) + 336e: 00 + 336f: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3376: e8 85 1a 00 00 call 4e00 + exit(); + 337b: e8 22 19 00 00 call 4ca2 + printf(1, "open (unlinked) dd/dd/ff succeeded!\n"); + 3380: c7 44 24 04 50 64 00 movl $0x6450,0x4(%esp) + 3387: 00 + 3388: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 338f: e8 6c 1a 00 00 call 4e00 + exit(); + 3394: e8 09 19 00 00 call 4ca2 + printf(1, "mkdir dd/ff/ff succeeded!\n"); + 3399: c7 44 24 04 ff 5a 00 movl $0x5aff,0x4(%esp) + 33a0: 00 + 33a1: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 33a8: e8 53 1a 00 00 call 4e00 + exit(); + 33ad: e8 f0 18 00 00 call 4ca2 + printf(1, "link dd/ff dd/dd/ffff succeeded!\n"); + 33b2: c7 44 24 04 c0 64 00 movl $0x64c0,0x4(%esp) + 33b9: 00 + 33ba: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 33c1: e8 3a 1a 00 00 call 4e00 + exit(); + 33c6: e8 d7 18 00 00 call 4ca2 + printf(1, "open dd/dd/../ff failed\n"); + 33cb: c7 44 24 04 7a 59 00 movl $0x597a,0x4(%esp) + 33d2: 00 + 33d3: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 33da: e8 21 1a 00 00 call 4e00 + exit(); + 33df: e8 be 18 00 00 call 4ca2 + printf(1, "create dd/dd/ff failed\n"); + 33e4: c7 44 24 04 53 59 00 movl $0x5953,0x4(%esp) + 33eb: 00 + 33ec: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 33f3: e8 08 1a 00 00 call 4e00 + exit(); + 33f8: e8 a5 18 00 00 call 4ca2 + printf(1, "chdir ./.. failed\n"); + 33fd: c7 44 24 04 1c 5a 00 movl $0x5a1c,0x4(%esp) + 3404: 00 + 3405: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 340c: e8 ef 19 00 00 call 4e00 + exit(); + 3411: e8 8c 18 00 00 call 4ca2 + printf(1, "link dd/dd/ff dd/dd/ffff failed\n"); + 3416: c7 44 24 04 08 64 00 movl $0x6408,0x4(%esp) + 341d: 00 + 341e: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3425: e8 d6 19 00 00 call 4e00 + exit(); + 342a: e8 73 18 00 00 call 4ca2 + printf(1, "link dd/xx/ff dd/dd/xx succeeded!\n"); + 342f: c7 44 24 04 9c 64 00 movl $0x649c,0x4(%esp) + 3436: 00 + 3437: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 343e: e8 bd 19 00 00 call 4e00 + exit(); + 3443: e8 5a 18 00 00 call 4ca2 + printf(1, "link dd/ff/ff dd/dd/xx succeeded!\n"); + 3448: c7 44 24 04 78 64 00 movl $0x6478,0x4(%esp) + 344f: 00 + 3450: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3457: e8 a4 19 00 00 call 4e00 + exit(); + 345c: e8 41 18 00 00 call 4ca2 + printf(1, "open dd wronly succeeded!\n"); + 3461: c7 44 24 04 db 5a 00 movl $0x5adb,0x4(%esp) + 3468: 00 + 3469: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3470: e8 8b 19 00 00 call 4e00 + exit(); + 3475: e8 28 18 00 00 call 4ca2 + printf(1, "open dd rdwr succeeded!\n"); + 347a: c7 44 24 04 c2 5a 00 movl $0x5ac2,0x4(%esp) + 3481: 00 + 3482: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3489: e8 72 19 00 00 call 4e00 + exit(); + 348e: e8 0f 18 00 00 call 4ca2 + printf(1, "create dd succeeded!\n"); + 3493: c7 44 24 04 ac 5a 00 movl $0x5aac,0x4(%esp) + 349a: 00 + 349b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 34a2: e8 59 19 00 00 call 4e00 + exit(); + 34a7: e8 f6 17 00 00 call 4ca2 + printf(1, "create dd/xx/ff succeeded!\n"); + 34ac: c7 44 24 04 90 5a 00 movl $0x5a90,0x4(%esp) + 34b3: 00 + 34b4: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 34bb: e8 40 19 00 00 call 4e00 + exit(); + 34c0: e8 dd 17 00 00 call 4ca2 + printf(1, "chdir dd failed\n"); + 34c5: c7 44 24 04 d1 59 00 movl $0x59d1,0x4(%esp) + 34cc: 00 + 34cd: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 34d4: e8 27 19 00 00 call 4e00 + exit(); + 34d9: e8 c4 17 00 00 call 4ca2 + printf(1, "open (unlinked) dd/dd/ff succeeded\n"); + 34de: c7 44 24 04 2c 64 00 movl $0x642c,0x4(%esp) + 34e5: 00 + 34e6: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 34ed: e8 0e 19 00 00 call 4e00 + exit(); + 34f2: e8 ab 17 00 00 call 4ca2 + printf(1, "subdir mkdir dd/dd failed\n"); + 34f7: c7 44 24 04 2f 59 00 movl $0x592f,0x4(%esp) + 34fe: 00 + 34ff: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3506: e8 f5 18 00 00 call 4e00 + exit(); + 350b: e8 92 17 00 00 call 4ca2 + printf(1, "unlink dd (non-empty dir) succeeded!\n"); + 3510: c7 44 24 04 e0 63 00 movl $0x63e0,0x4(%esp) + 3517: 00 + 3518: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 351f: e8 dc 18 00 00 call 4e00 + exit(); + 3524: e8 79 17 00 00 call 4ca2 + printf(1, "create dd/ff failed\n"); + 3529: c7 44 24 04 13 59 00 movl $0x5913,0x4(%esp) + 3530: 00 + 3531: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3538: e8 c3 18 00 00 call 4e00 + exit(); + 353d: e8 60 17 00 00 call 4ca2 + printf(1, "subdir mkdir dd failed\n"); + 3542: c7 44 24 04 fb 58 00 movl $0x58fb,0x4(%esp) + 3549: 00 + 354a: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3551: e8 aa 18 00 00 call 4e00 + exit(); + 3556: e8 47 17 00 00 call 4ca2 + printf(1, "unlink dd failed\n"); + 355b: c7 44 24 04 e4 5b 00 movl $0x5be4,0x4(%esp) + 3562: 00 + 3563: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 356a: e8 91 18 00 00 call 4e00 + exit(); + 356f: e8 2e 17 00 00 call 4ca2 + printf(1, "unlink dd/dd failed\n"); + 3574: c7 44 24 04 cf 5b 00 movl $0x5bcf,0x4(%esp) + 357b: 00 + 357c: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3583: e8 78 18 00 00 call 4e00 + exit(); + 3588: e8 15 17 00 00 call 4ca2 + printf(1, "unlink non-empty dd succeeded!\n"); + 358d: c7 44 24 04 e4 64 00 movl $0x64e4,0x4(%esp) + 3594: 00 + 3595: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 359c: e8 5f 18 00 00 call 4e00 + exit(); + 35a1: e8 fc 16 00 00 call 4ca2 + printf(1, "unlink dd/ff failed\n"); + 35a6: c7 44 24 04 ba 5b 00 movl $0x5bba,0x4(%esp) + 35ad: 00 + 35ae: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 35b5: e8 46 18 00 00 call 4e00 + exit(); + 35ba: e8 e3 16 00 00 call 4ca2 + printf(1, "chdir dd/xx succeeded!\n"); + 35bf: c7 44 24 04 a2 5b 00 movl $0x5ba2,0x4(%esp) + 35c6: 00 + 35c7: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 35ce: e8 2d 18 00 00 call 4e00 + exit(); + 35d3: e8 ca 16 00 00 call 4ca2 + printf(1, "chdir dd/ff succeeded!\n"); + 35d8: c7 44 24 04 8a 5b 00 movl $0x5b8a,0x4(%esp) + 35df: 00 + 35e0: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 35e7: e8 14 18 00 00 call 4e00 + exit(); + 35ec: e8 b1 16 00 00 call 4ca2 + printf(1, "unlink dd/ff/ff succeeded!\n"); + 35f1: c7 44 24 04 6e 5b 00 movl $0x5b6e,0x4(%esp) + 35f8: 00 + 35f9: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3600: e8 fb 17 00 00 call 4e00 + exit(); + 3605: e8 98 16 00 00 call 4ca2 + printf(1, "unlink dd/xx/ff succeeded!\n"); + 360a: c7 44 24 04 52 5b 00 movl $0x5b52,0x4(%esp) + 3611: 00 + 3612: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3619: e8 e2 17 00 00 call 4e00 + exit(); + 361e: e8 7f 16 00 00 call 4ca2 + printf(1, "mkdir dd/dd/ffff succeeded!\n"); + 3623: c7 44 24 04 35 5b 00 movl $0x5b35,0x4(%esp) + 362a: 00 + 362b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3632: e8 c9 17 00 00 call 4e00 + exit(); + 3637: e8 66 16 00 00 call 4ca2 + printf(1, "mkdir dd/xx/ff succeeded!\n"); + 363c: c7 44 24 04 1a 5b 00 movl $0x5b1a,0x4(%esp) + 3643: 00 + 3644: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 364b: e8 b0 17 00 00 call 4e00 + exit(); + 3650: e8 4d 16 00 00 call 4ca2 + printf(1, "read dd/dd/ffff wrong len\n"); + 3655: c7 44 24 04 47 5a 00 movl $0x5a47,0x4(%esp) + 365c: 00 + 365d: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3664: e8 97 17 00 00 call 4e00 + exit(); + 3669: e8 34 16 00 00 call 4ca2 + printf(1, "open dd/dd/ffff failed\n"); + 366e: c7 44 24 04 2f 5a 00 movl $0x5a2f,0x4(%esp) + 3675: 00 + 3676: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 367d: e8 7e 17 00 00 call 4e00 + exit(); + 3682: e8 1b 16 00 00 call 4ca2 + 3687: 89 f6 mov %esi,%esi + 3689: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00003690 : +{ + 3690: 55 push %ebp + 3691: 89 e5 mov %esp,%ebp + 3693: 56 push %esi + 3694: 53 push %ebx + for(sz = 499; sz < 12*512; sz += 471){ + 3695: bb f3 01 00 00 mov $0x1f3,%ebx +{ + 369a: 83 ec 10 sub $0x10,%esp + printf(1, "bigwrite test\n"); + 369d: c7 44 24 04 01 5c 00 movl $0x5c01,0x4(%esp) + 36a4: 00 + 36a5: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 36ac: e8 4f 17 00 00 call 4e00 + unlink("bigwrite"); + 36b1: c7 04 24 10 5c 00 00 movl $0x5c10,(%esp) + 36b8: e8 35 16 00 00 call 4cf2 + 36bd: 8d 76 00 lea 0x0(%esi),%esi + fd = open("bigwrite", O_CREATE | O_RDWR); + 36c0: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 36c7: 00 + 36c8: c7 04 24 10 5c 00 00 movl $0x5c10,(%esp) + 36cf: e8 0e 16 00 00 call 4ce2 + if(fd < 0){ + 36d4: 85 c0 test %eax,%eax + fd = open("bigwrite", O_CREATE | O_RDWR); + 36d6: 89 c6 mov %eax,%esi + if(fd < 0){ + 36d8: 0f 88 8e 00 00 00 js 376c + int cc = write(fd, buf, sz); + 36de: 89 5c 24 08 mov %ebx,0x8(%esp) + 36e2: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 36e9: 00 + 36ea: 89 04 24 mov %eax,(%esp) + 36ed: e8 d0 15 00 00 call 4cc2 + if(cc != sz){ + 36f2: 39 d8 cmp %ebx,%eax + 36f4: 75 55 jne 374b + int cc = write(fd, buf, sz); + 36f6: 89 5c 24 08 mov %ebx,0x8(%esp) + 36fa: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 3701: 00 + 3702: 89 34 24 mov %esi,(%esp) + 3705: e8 b8 15 00 00 call 4cc2 + if(cc != sz){ + 370a: 39 c3 cmp %eax,%ebx + 370c: 75 3d jne 374b + close(fd); + 370e: 89 34 24 mov %esi,(%esp) + for(sz = 499; sz < 12*512; sz += 471){ + 3711: 81 c3 d7 01 00 00 add $0x1d7,%ebx + close(fd); + 3717: e8 ae 15 00 00 call 4cca + unlink("bigwrite"); + 371c: c7 04 24 10 5c 00 00 movl $0x5c10,(%esp) + 3723: e8 ca 15 00 00 call 4cf2 + for(sz = 499; sz < 12*512; sz += 471){ + 3728: 81 fb 07 18 00 00 cmp $0x1807,%ebx + 372e: 75 90 jne 36c0 + printf(1, "bigwrite ok\n"); + 3730: c7 44 24 04 43 5c 00 movl $0x5c43,0x4(%esp) + 3737: 00 + 3738: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 373f: e8 bc 16 00 00 call 4e00 +} + 3744: 83 c4 10 add $0x10,%esp + 3747: 5b pop %ebx + 3748: 5e pop %esi + 3749: 5d pop %ebp + 374a: c3 ret + printf(1, "write(%d) ret %d\n", sz, cc); + 374b: 89 44 24 0c mov %eax,0xc(%esp) + 374f: 89 5c 24 08 mov %ebx,0x8(%esp) + 3753: c7 44 24 04 31 5c 00 movl $0x5c31,0x4(%esp) + 375a: 00 + 375b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3762: e8 99 16 00 00 call 4e00 + exit(); + 3767: e8 36 15 00 00 call 4ca2 + printf(1, "cannot create bigwrite\n"); + 376c: c7 44 24 04 19 5c 00 movl $0x5c19,0x4(%esp) + 3773: 00 + 3774: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 377b: e8 80 16 00 00 call 4e00 + exit(); + 3780: e8 1d 15 00 00 call 4ca2 + 3785: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 3789: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00003790 : +{ + 3790: 55 push %ebp + 3791: 89 e5 mov %esp,%ebp + 3793: 57 push %edi + 3794: 56 push %esi + 3795: 53 push %ebx + 3796: 83 ec 1c sub $0x1c,%esp + printf(1, "bigfile test\n"); + 3799: c7 44 24 04 50 5c 00 movl $0x5c50,0x4(%esp) + 37a0: 00 + 37a1: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 37a8: e8 53 16 00 00 call 4e00 + unlink("bigfile"); + 37ad: c7 04 24 6c 5c 00 00 movl $0x5c6c,(%esp) + 37b4: e8 39 15 00 00 call 4cf2 + fd = open("bigfile", O_CREATE | O_RDWR); + 37b9: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 37c0: 00 + 37c1: c7 04 24 6c 5c 00 00 movl $0x5c6c,(%esp) + 37c8: e8 15 15 00 00 call 4ce2 + if(fd < 0){ + 37cd: 85 c0 test %eax,%eax + fd = open("bigfile", O_CREATE | O_RDWR); + 37cf: 89 c6 mov %eax,%esi + if(fd < 0){ + 37d1: 0f 88 7f 01 00 00 js 3956 + 37d7: 31 db xor %ebx,%ebx + 37d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + memset(buf, i, 600); + 37e0: c7 44 24 08 58 02 00 movl $0x258,0x8(%esp) + 37e7: 00 + 37e8: 89 5c 24 04 mov %ebx,0x4(%esp) + 37ec: c7 04 24 40 9a 00 00 movl $0x9a40,(%esp) + 37f3: e8 38 13 00 00 call 4b30 + if(write(fd, buf, 600) != 600){ + 37f8: c7 44 24 08 58 02 00 movl $0x258,0x8(%esp) + 37ff: 00 + 3800: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 3807: 00 + 3808: 89 34 24 mov %esi,(%esp) + 380b: e8 b2 14 00 00 call 4cc2 + 3810: 3d 58 02 00 00 cmp $0x258,%eax + 3815: 0f 85 09 01 00 00 jne 3924 + for(i = 0; i < 20; i++){ + 381b: 83 c3 01 add $0x1,%ebx + 381e: 83 fb 14 cmp $0x14,%ebx + 3821: 75 bd jne 37e0 + close(fd); + 3823: 89 34 24 mov %esi,(%esp) + 3826: e8 9f 14 00 00 call 4cca + fd = open("bigfile", 0); + 382b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 3832: 00 + 3833: c7 04 24 6c 5c 00 00 movl $0x5c6c,(%esp) + 383a: e8 a3 14 00 00 call 4ce2 + if(fd < 0){ + 383f: 85 c0 test %eax,%eax + fd = open("bigfile", 0); + 3841: 89 c6 mov %eax,%esi + if(fd < 0){ + 3843: 0f 88 f4 00 00 00 js 393d + 3849: 31 db xor %ebx,%ebx + 384b: 31 ff xor %edi,%edi + 384d: eb 2f jmp 387e + 384f: 90 nop + if(cc != 300){ + 3850: 3d 2c 01 00 00 cmp $0x12c,%eax + 3855: 0f 85 97 00 00 00 jne 38f2 + if(buf[0] != i/2 || buf[299] != i/2){ + 385b: 0f be 05 40 9a 00 00 movsbl 0x9a40,%eax + 3862: 89 fa mov %edi,%edx + 3864: d1 fa sar %edx + 3866: 39 d0 cmp %edx,%eax + 3868: 75 6f jne 38d9 + 386a: 0f be 15 6b 9b 00 00 movsbl 0x9b6b,%edx + 3871: 39 d0 cmp %edx,%eax + 3873: 75 64 jne 38d9 + total += cc; + 3875: 81 c3 2c 01 00 00 add $0x12c,%ebx + for(i = 0; ; i++){ + 387b: 83 c7 01 add $0x1,%edi + cc = read(fd, buf, 300); + 387e: c7 44 24 08 2c 01 00 movl $0x12c,0x8(%esp) + 3885: 00 + 3886: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 388d: 00 + 388e: 89 34 24 mov %esi,(%esp) + 3891: e8 24 14 00 00 call 4cba + if(cc < 0){ + 3896: 85 c0 test %eax,%eax + 3898: 78 71 js 390b + if(cc == 0) + 389a: 75 b4 jne 3850 + close(fd); + 389c: 89 34 24 mov %esi,(%esp) + 389f: 90 nop + 38a0: e8 25 14 00 00 call 4cca + if(total != 20*600){ + 38a5: 81 fb e0 2e 00 00 cmp $0x2ee0,%ebx + 38ab: 0f 85 be 00 00 00 jne 396f + unlink("bigfile"); + 38b1: c7 04 24 6c 5c 00 00 movl $0x5c6c,(%esp) + 38b8: e8 35 14 00 00 call 4cf2 + printf(1, "bigfile test ok\n"); + 38bd: c7 44 24 04 fb 5c 00 movl $0x5cfb,0x4(%esp) + 38c4: 00 + 38c5: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 38cc: e8 2f 15 00 00 call 4e00 +} + 38d1: 83 c4 1c add $0x1c,%esp + 38d4: 5b pop %ebx + 38d5: 5e pop %esi + 38d6: 5f pop %edi + 38d7: 5d pop %ebp + 38d8: c3 ret + printf(1, "read bigfile wrong data\n"); + 38d9: c7 44 24 04 c8 5c 00 movl $0x5cc8,0x4(%esp) + 38e0: 00 + 38e1: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 38e8: e8 13 15 00 00 call 4e00 + exit(); + 38ed: e8 b0 13 00 00 call 4ca2 + printf(1, "short read bigfile\n"); + 38f2: c7 44 24 04 b4 5c 00 movl $0x5cb4,0x4(%esp) + 38f9: 00 + 38fa: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3901: e8 fa 14 00 00 call 4e00 + exit(); + 3906: e8 97 13 00 00 call 4ca2 + printf(1, "read bigfile failed\n"); + 390b: c7 44 24 04 9f 5c 00 movl $0x5c9f,0x4(%esp) + 3912: 00 + 3913: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 391a: e8 e1 14 00 00 call 4e00 + exit(); + 391f: e8 7e 13 00 00 call 4ca2 + printf(1, "write bigfile failed\n"); + 3924: c7 44 24 04 74 5c 00 movl $0x5c74,0x4(%esp) + 392b: 00 + 392c: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3933: e8 c8 14 00 00 call 4e00 + exit(); + 3938: e8 65 13 00 00 call 4ca2 + printf(1, "cannot open bigfile\n"); + 393d: c7 44 24 04 8a 5c 00 movl $0x5c8a,0x4(%esp) + 3944: 00 + 3945: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 394c: e8 af 14 00 00 call 4e00 + exit(); + 3951: e8 4c 13 00 00 call 4ca2 + printf(1, "cannot create bigfile"); + 3956: c7 44 24 04 5e 5c 00 movl $0x5c5e,0x4(%esp) + 395d: 00 + 395e: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3965: e8 96 14 00 00 call 4e00 + exit(); + 396a: e8 33 13 00 00 call 4ca2 + printf(1, "read bigfile wrong total\n"); + 396f: c7 44 24 04 e1 5c 00 movl $0x5ce1,0x4(%esp) + 3976: 00 + 3977: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 397e: e8 7d 14 00 00 call 4e00 + exit(); + 3983: e8 1a 13 00 00 call 4ca2 + 3988: 90 nop + 3989: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00003990 : +{ + 3990: 55 push %ebp + 3991: 89 e5 mov %esp,%ebp + 3993: 83 ec 18 sub $0x18,%esp + printf(1, "fourteen test\n"); + 3996: c7 44 24 04 0c 5d 00 movl $0x5d0c,0x4(%esp) + 399d: 00 + 399e: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 39a5: e8 56 14 00 00 call 4e00 + if(mkdir("12345678901234") != 0){ + 39aa: c7 04 24 47 5d 00 00 movl $0x5d47,(%esp) + 39b1: e8 54 13 00 00 call 4d0a + 39b6: 85 c0 test %eax,%eax + 39b8: 0f 85 92 00 00 00 jne 3a50 + if(mkdir("12345678901234/123456789012345") != 0){ + 39be: c7 04 24 04 65 00 00 movl $0x6504,(%esp) + 39c5: e8 40 13 00 00 call 4d0a + 39ca: 85 c0 test %eax,%eax + 39cc: 0f 85 fb 00 00 00 jne 3acd + fd = open("123456789012345/123456789012345/123456789012345", O_CREATE); + 39d2: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) + 39d9: 00 + 39da: c7 04 24 54 65 00 00 movl $0x6554,(%esp) + 39e1: e8 fc 12 00 00 call 4ce2 + if(fd < 0){ + 39e6: 85 c0 test %eax,%eax + 39e8: 0f 88 c6 00 00 00 js 3ab4 + close(fd); + 39ee: 89 04 24 mov %eax,(%esp) + 39f1: e8 d4 12 00 00 call 4cca + fd = open("12345678901234/12345678901234/12345678901234", 0); + 39f6: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 39fd: 00 + 39fe: c7 04 24 c4 65 00 00 movl $0x65c4,(%esp) + 3a05: e8 d8 12 00 00 call 4ce2 + if(fd < 0){ + 3a0a: 85 c0 test %eax,%eax + 3a0c: 0f 88 89 00 00 00 js 3a9b + close(fd); + 3a12: 89 04 24 mov %eax,(%esp) + 3a15: e8 b0 12 00 00 call 4cca + if(mkdir("12345678901234/12345678901234") == 0){ + 3a1a: c7 04 24 38 5d 00 00 movl $0x5d38,(%esp) + 3a21: e8 e4 12 00 00 call 4d0a + 3a26: 85 c0 test %eax,%eax + 3a28: 74 58 je 3a82 + if(mkdir("123456789012345/12345678901234") == 0){ + 3a2a: c7 04 24 60 66 00 00 movl $0x6660,(%esp) + 3a31: e8 d4 12 00 00 call 4d0a + 3a36: 85 c0 test %eax,%eax + 3a38: 74 2f je 3a69 + printf(1, "fourteen ok\n"); + 3a3a: c7 44 24 04 56 5d 00 movl $0x5d56,0x4(%esp) + 3a41: 00 + 3a42: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3a49: e8 b2 13 00 00 call 4e00 +} + 3a4e: c9 leave + 3a4f: c3 ret + printf(1, "mkdir 12345678901234 failed\n"); + 3a50: c7 44 24 04 1b 5d 00 movl $0x5d1b,0x4(%esp) + 3a57: 00 + 3a58: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3a5f: e8 9c 13 00 00 call 4e00 + exit(); + 3a64: e8 39 12 00 00 call 4ca2 + printf(1, "mkdir 12345678901234/123456789012345 succeeded!\n"); + 3a69: c7 44 24 04 80 66 00 movl $0x6680,0x4(%esp) + 3a70: 00 + 3a71: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3a78: e8 83 13 00 00 call 4e00 + exit(); + 3a7d: e8 20 12 00 00 call 4ca2 + printf(1, "mkdir 12345678901234/12345678901234 succeeded!\n"); + 3a82: c7 44 24 04 30 66 00 movl $0x6630,0x4(%esp) + 3a89: 00 + 3a8a: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3a91: e8 6a 13 00 00 call 4e00 + exit(); + 3a96: e8 07 12 00 00 call 4ca2 + printf(1, "open 12345678901234/12345678901234/12345678901234 failed\n"); + 3a9b: c7 44 24 04 f4 65 00 movl $0x65f4,0x4(%esp) + 3aa2: 00 + 3aa3: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3aaa: e8 51 13 00 00 call 4e00 + exit(); + 3aaf: e8 ee 11 00 00 call 4ca2 + printf(1, "create 123456789012345/123456789012345/123456789012345 failed\n"); + 3ab4: c7 44 24 04 84 65 00 movl $0x6584,0x4(%esp) + 3abb: 00 + 3abc: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3ac3: e8 38 13 00 00 call 4e00 + exit(); + 3ac8: e8 d5 11 00 00 call 4ca2 + printf(1, "mkdir 12345678901234/123456789012345 failed\n"); + 3acd: c7 44 24 04 24 65 00 movl $0x6524,0x4(%esp) + 3ad4: 00 + 3ad5: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3adc: e8 1f 13 00 00 call 4e00 + exit(); + 3ae1: e8 bc 11 00 00 call 4ca2 + 3ae6: 8d 76 00 lea 0x0(%esi),%esi + 3ae9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00003af0 : +{ + 3af0: 55 push %ebp + 3af1: 89 e5 mov %esp,%ebp + 3af3: 83 ec 18 sub $0x18,%esp + printf(1, "rmdot test\n"); + 3af6: c7 44 24 04 63 5d 00 movl $0x5d63,0x4(%esp) + 3afd: 00 + 3afe: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3b05: e8 f6 12 00 00 call 4e00 + if(mkdir("dots") != 0){ + 3b0a: c7 04 24 6f 5d 00 00 movl $0x5d6f,(%esp) + 3b11: e8 f4 11 00 00 call 4d0a + 3b16: 85 c0 test %eax,%eax + 3b18: 0f 85 9a 00 00 00 jne 3bb8 + if(chdir("dots") != 0){ + 3b1e: c7 04 24 6f 5d 00 00 movl $0x5d6f,(%esp) + 3b25: e8 e8 11 00 00 call 4d12 + 3b2a: 85 c0 test %eax,%eax + 3b2c: 0f 85 35 01 00 00 jne 3c67 + if(unlink(".") == 0){ + 3b32: c7 04 24 1a 5a 00 00 movl $0x5a1a,(%esp) + 3b39: e8 b4 11 00 00 call 4cf2 + 3b3e: 85 c0 test %eax,%eax + 3b40: 0f 84 08 01 00 00 je 3c4e + if(unlink("..") == 0){ + 3b46: c7 04 24 19 5a 00 00 movl $0x5a19,(%esp) + 3b4d: e8 a0 11 00 00 call 4cf2 + 3b52: 85 c0 test %eax,%eax + 3b54: 0f 84 db 00 00 00 je 3c35 + if(chdir("/") != 0){ + 3b5a: c7 04 24 ed 51 00 00 movl $0x51ed,(%esp) + 3b61: e8 ac 11 00 00 call 4d12 + 3b66: 85 c0 test %eax,%eax + 3b68: 0f 85 ae 00 00 00 jne 3c1c + if(unlink("dots/.") == 0){ + 3b6e: c7 04 24 b7 5d 00 00 movl $0x5db7,(%esp) + 3b75: e8 78 11 00 00 call 4cf2 + 3b7a: 85 c0 test %eax,%eax + 3b7c: 0f 84 81 00 00 00 je 3c03 + if(unlink("dots/..") == 0){ + 3b82: c7 04 24 d5 5d 00 00 movl $0x5dd5,(%esp) + 3b89: e8 64 11 00 00 call 4cf2 + 3b8e: 85 c0 test %eax,%eax + 3b90: 74 58 je 3bea + if(unlink("dots") != 0){ + 3b92: c7 04 24 6f 5d 00 00 movl $0x5d6f,(%esp) + 3b99: e8 54 11 00 00 call 4cf2 + 3b9e: 85 c0 test %eax,%eax + 3ba0: 75 2f jne 3bd1 + printf(1, "rmdot ok\n"); + 3ba2: c7 44 24 04 0a 5e 00 movl $0x5e0a,0x4(%esp) + 3ba9: 00 + 3baa: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3bb1: e8 4a 12 00 00 call 4e00 +} + 3bb6: c9 leave + 3bb7: c3 ret + printf(1, "mkdir dots failed\n"); + 3bb8: c7 44 24 04 74 5d 00 movl $0x5d74,0x4(%esp) + 3bbf: 00 + 3bc0: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3bc7: e8 34 12 00 00 call 4e00 + exit(); + 3bcc: e8 d1 10 00 00 call 4ca2 + printf(1, "unlink dots failed!\n"); + 3bd1: c7 44 24 04 f5 5d 00 movl $0x5df5,0x4(%esp) + 3bd8: 00 + 3bd9: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3be0: e8 1b 12 00 00 call 4e00 + exit(); + 3be5: e8 b8 10 00 00 call 4ca2 + printf(1, "unlink dots/.. worked!\n"); + 3bea: c7 44 24 04 dd 5d 00 movl $0x5ddd,0x4(%esp) + 3bf1: 00 + 3bf2: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3bf9: e8 02 12 00 00 call 4e00 + exit(); + 3bfe: e8 9f 10 00 00 call 4ca2 + printf(1, "unlink dots/. worked!\n"); + 3c03: c7 44 24 04 be 5d 00 movl $0x5dbe,0x4(%esp) + 3c0a: 00 + 3c0b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3c12: e8 e9 11 00 00 call 4e00 + exit(); + 3c17: e8 86 10 00 00 call 4ca2 + printf(1, "chdir / failed\n"); + 3c1c: c7 44 24 04 ef 51 00 movl $0x51ef,0x4(%esp) + 3c23: 00 + 3c24: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3c2b: e8 d0 11 00 00 call 4e00 + exit(); + 3c30: e8 6d 10 00 00 call 4ca2 + printf(1, "rm .. worked!\n"); + 3c35: c7 44 24 04 a8 5d 00 movl $0x5da8,0x4(%esp) + 3c3c: 00 + 3c3d: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3c44: e8 b7 11 00 00 call 4e00 + exit(); + 3c49: e8 54 10 00 00 call 4ca2 + printf(1, "rm . worked!\n"); + 3c4e: c7 44 24 04 9a 5d 00 movl $0x5d9a,0x4(%esp) + 3c55: 00 + 3c56: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3c5d: e8 9e 11 00 00 call 4e00 + exit(); + 3c62: e8 3b 10 00 00 call 4ca2 + printf(1, "chdir dots failed\n"); + 3c67: c7 44 24 04 87 5d 00 movl $0x5d87,0x4(%esp) + 3c6e: 00 + 3c6f: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3c76: e8 85 11 00 00 call 4e00 + exit(); + 3c7b: e8 22 10 00 00 call 4ca2 + +00003c80 : +{ + 3c80: 55 push %ebp + 3c81: 89 e5 mov %esp,%ebp + 3c83: 53 push %ebx + 3c84: 83 ec 14 sub $0x14,%esp + printf(1, "dir vs file\n"); + 3c87: c7 44 24 04 14 5e 00 movl $0x5e14,0x4(%esp) + 3c8e: 00 + 3c8f: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3c96: e8 65 11 00 00 call 4e00 + fd = open("dirfile", O_CREATE); + 3c9b: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) + 3ca2: 00 + 3ca3: c7 04 24 21 5e 00 00 movl $0x5e21,(%esp) + 3caa: e8 33 10 00 00 call 4ce2 + if(fd < 0){ + 3caf: 85 c0 test %eax,%eax + 3cb1: 0f 88 4e 01 00 00 js 3e05 + close(fd); + 3cb7: 89 04 24 mov %eax,(%esp) + 3cba: e8 0b 10 00 00 call 4cca + if(chdir("dirfile") == 0){ + 3cbf: c7 04 24 21 5e 00 00 movl $0x5e21,(%esp) + 3cc6: e8 47 10 00 00 call 4d12 + 3ccb: 85 c0 test %eax,%eax + 3ccd: 0f 84 19 01 00 00 je 3dec + fd = open("dirfile/xx", 0); + 3cd3: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 3cda: 00 + 3cdb: c7 04 24 5a 5e 00 00 movl $0x5e5a,(%esp) + 3ce2: e8 fb 0f 00 00 call 4ce2 + if(fd >= 0){ + 3ce7: 85 c0 test %eax,%eax + 3ce9: 0f 89 e4 00 00 00 jns 3dd3 + fd = open("dirfile/xx", O_CREATE); + 3cef: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) + 3cf6: 00 + 3cf7: c7 04 24 5a 5e 00 00 movl $0x5e5a,(%esp) + 3cfe: e8 df 0f 00 00 call 4ce2 + if(fd >= 0){ + 3d03: 85 c0 test %eax,%eax + 3d05: 0f 89 c8 00 00 00 jns 3dd3 + if(mkdir("dirfile/xx") == 0){ + 3d0b: c7 04 24 5a 5e 00 00 movl $0x5e5a,(%esp) + 3d12: e8 f3 0f 00 00 call 4d0a + 3d17: 85 c0 test %eax,%eax + 3d19: 0f 84 7c 01 00 00 je 3e9b + if(unlink("dirfile/xx") == 0){ + 3d1f: c7 04 24 5a 5e 00 00 movl $0x5e5a,(%esp) + 3d26: e8 c7 0f 00 00 call 4cf2 + 3d2b: 85 c0 test %eax,%eax + 3d2d: 0f 84 4f 01 00 00 je 3e82 + if(link("README", "dirfile/xx") == 0){ + 3d33: c7 44 24 04 5a 5e 00 movl $0x5e5a,0x4(%esp) + 3d3a: 00 + 3d3b: c7 04 24 be 5e 00 00 movl $0x5ebe,(%esp) + 3d42: e8 bb 0f 00 00 call 4d02 + 3d47: 85 c0 test %eax,%eax + 3d49: 0f 84 1a 01 00 00 je 3e69 + if(unlink("dirfile") != 0){ + 3d4f: c7 04 24 21 5e 00 00 movl $0x5e21,(%esp) + 3d56: e8 97 0f 00 00 call 4cf2 + 3d5b: 85 c0 test %eax,%eax + 3d5d: 0f 85 ed 00 00 00 jne 3e50 + fd = open(".", O_RDWR); + 3d63: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) + 3d6a: 00 + 3d6b: c7 04 24 1a 5a 00 00 movl $0x5a1a,(%esp) + 3d72: e8 6b 0f 00 00 call 4ce2 + if(fd >= 0){ + 3d77: 85 c0 test %eax,%eax + 3d79: 0f 89 b8 00 00 00 jns 3e37 + fd = open(".", 0); + 3d7f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 3d86: 00 + 3d87: c7 04 24 1a 5a 00 00 movl $0x5a1a,(%esp) + 3d8e: e8 4f 0f 00 00 call 4ce2 + if(write(fd, "x", 1) > 0){ + 3d93: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 3d9a: 00 + 3d9b: c7 44 24 04 fd 5a 00 movl $0x5afd,0x4(%esp) + 3da2: 00 + 3da3: 89 04 24 mov %eax,(%esp) + fd = open(".", 0); + 3da6: 89 c3 mov %eax,%ebx + if(write(fd, "x", 1) > 0){ + 3da8: e8 15 0f 00 00 call 4cc2 + 3dad: 85 c0 test %eax,%eax + 3daf: 7f 6d jg 3e1e + close(fd); + 3db1: 89 1c 24 mov %ebx,(%esp) + 3db4: e8 11 0f 00 00 call 4cca + printf(1, "dir vs file OK\n"); + 3db9: c7 44 24 04 f1 5e 00 movl $0x5ef1,0x4(%esp) + 3dc0: 00 + 3dc1: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3dc8: e8 33 10 00 00 call 4e00 +} + 3dcd: 83 c4 14 add $0x14,%esp + 3dd0: 5b pop %ebx + 3dd1: 5d pop %ebp + 3dd2: c3 ret + printf(1, "create dirfile/xx succeeded!\n"); + 3dd3: c7 44 24 04 65 5e 00 movl $0x5e65,0x4(%esp) + 3dda: 00 + 3ddb: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3de2: e8 19 10 00 00 call 4e00 + exit(); + 3de7: e8 b6 0e 00 00 call 4ca2 + printf(1, "chdir dirfile succeeded!\n"); + 3dec: c7 44 24 04 40 5e 00 movl $0x5e40,0x4(%esp) + 3df3: 00 + 3df4: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3dfb: e8 00 10 00 00 call 4e00 + exit(); + 3e00: e8 9d 0e 00 00 call 4ca2 + printf(1, "create dirfile failed\n"); + 3e05: c7 44 24 04 29 5e 00 movl $0x5e29,0x4(%esp) + 3e0c: 00 + 3e0d: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3e14: e8 e7 0f 00 00 call 4e00 + exit(); + 3e19: e8 84 0e 00 00 call 4ca2 + printf(1, "write . succeeded!\n"); + 3e1e: c7 44 24 04 dd 5e 00 movl $0x5edd,0x4(%esp) + 3e25: 00 + 3e26: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3e2d: e8 ce 0f 00 00 call 4e00 + exit(); + 3e32: e8 6b 0e 00 00 call 4ca2 + printf(1, "open . for writing succeeded!\n"); + 3e37: c7 44 24 04 d4 66 00 movl $0x66d4,0x4(%esp) + 3e3e: 00 + 3e3f: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3e46: e8 b5 0f 00 00 call 4e00 + exit(); + 3e4b: e8 52 0e 00 00 call 4ca2 + printf(1, "unlink dirfile failed!\n"); + 3e50: c7 44 24 04 c5 5e 00 movl $0x5ec5,0x4(%esp) + 3e57: 00 + 3e58: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3e5f: e8 9c 0f 00 00 call 4e00 + exit(); + 3e64: e8 39 0e 00 00 call 4ca2 + printf(1, "link to dirfile/xx succeeded!\n"); + 3e69: c7 44 24 04 b4 66 00 movl $0x66b4,0x4(%esp) + 3e70: 00 + 3e71: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3e78: e8 83 0f 00 00 call 4e00 + exit(); + 3e7d: e8 20 0e 00 00 call 4ca2 + printf(1, "unlink dirfile/xx succeeded!\n"); + 3e82: c7 44 24 04 a0 5e 00 movl $0x5ea0,0x4(%esp) + 3e89: 00 + 3e8a: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3e91: e8 6a 0f 00 00 call 4e00 + exit(); + 3e96: e8 07 0e 00 00 call 4ca2 + printf(1, "mkdir dirfile/xx succeeded!\n"); + 3e9b: c7 44 24 04 83 5e 00 movl $0x5e83,0x4(%esp) + 3ea2: 00 + 3ea3: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3eaa: e8 51 0f 00 00 call 4e00 + exit(); + 3eaf: e8 ee 0d 00 00 call 4ca2 + 3eb4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 3eba: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00003ec0 : +{ + 3ec0: 55 push %ebp + 3ec1: 89 e5 mov %esp,%ebp + 3ec3: 53 push %ebx + printf(1, "empty file name\n"); + 3ec4: bb 33 00 00 00 mov $0x33,%ebx +{ + 3ec9: 83 ec 14 sub $0x14,%esp + printf(1, "empty file name\n"); + 3ecc: c7 44 24 04 01 5f 00 movl $0x5f01,0x4(%esp) + 3ed3: 00 + 3ed4: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3edb: e8 20 0f 00 00 call 4e00 + if(mkdir("irefd") != 0){ + 3ee0: c7 04 24 12 5f 00 00 movl $0x5f12,(%esp) + 3ee7: e8 1e 0e 00 00 call 4d0a + 3eec: 85 c0 test %eax,%eax + 3eee: 0f 85 af 00 00 00 jne 3fa3 + if(chdir("irefd") != 0){ + 3ef4: c7 04 24 12 5f 00 00 movl $0x5f12,(%esp) + 3efb: e8 12 0e 00 00 call 4d12 + 3f00: 85 c0 test %eax,%eax + 3f02: 0f 85 b4 00 00 00 jne 3fbc + mkdir(""); + 3f08: c7 04 24 c7 55 00 00 movl $0x55c7,(%esp) + 3f0f: e8 f6 0d 00 00 call 4d0a + link("README", ""); + 3f14: c7 44 24 04 c7 55 00 movl $0x55c7,0x4(%esp) + 3f1b: 00 + 3f1c: c7 04 24 be 5e 00 00 movl $0x5ebe,(%esp) + 3f23: e8 da 0d 00 00 call 4d02 + fd = open("", O_CREATE); + 3f28: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) + 3f2f: 00 + 3f30: c7 04 24 c7 55 00 00 movl $0x55c7,(%esp) + 3f37: e8 a6 0d 00 00 call 4ce2 + if(fd >= 0) + 3f3c: 85 c0 test %eax,%eax + 3f3e: 78 08 js 3f48 + close(fd); + 3f40: 89 04 24 mov %eax,(%esp) + 3f43: e8 82 0d 00 00 call 4cca + fd = open("xx", O_CREATE); + 3f48: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) + 3f4f: 00 + 3f50: c7 04 24 fc 5a 00 00 movl $0x5afc,(%esp) + 3f57: e8 86 0d 00 00 call 4ce2 + if(fd >= 0) + 3f5c: 85 c0 test %eax,%eax + 3f5e: 78 08 js 3f68 + close(fd); + 3f60: 89 04 24 mov %eax,(%esp) + 3f63: e8 62 0d 00 00 call 4cca + unlink("xx"); + 3f68: c7 04 24 fc 5a 00 00 movl $0x5afc,(%esp) + 3f6f: e8 7e 0d 00 00 call 4cf2 + for(i = 0; i < 50 + 1; i++){ + 3f74: 83 eb 01 sub $0x1,%ebx + 3f77: 0f 85 63 ff ff ff jne 3ee0 + chdir("/"); + 3f7d: c7 04 24 ed 51 00 00 movl $0x51ed,(%esp) + 3f84: e8 89 0d 00 00 call 4d12 + printf(1, "empty file name OK\n"); + 3f89: c7 44 24 04 40 5f 00 movl $0x5f40,0x4(%esp) + 3f90: 00 + 3f91: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3f98: e8 63 0e 00 00 call 4e00 +} + 3f9d: 83 c4 14 add $0x14,%esp + 3fa0: 5b pop %ebx + 3fa1: 5d pop %ebp + 3fa2: c3 ret + printf(1, "mkdir irefd failed\n"); + 3fa3: c7 44 24 04 18 5f 00 movl $0x5f18,0x4(%esp) + 3faa: 00 + 3fab: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3fb2: e8 49 0e 00 00 call 4e00 + exit(); + 3fb7: e8 e6 0c 00 00 call 4ca2 + printf(1, "chdir irefd failed\n"); + 3fbc: c7 44 24 04 2c 5f 00 movl $0x5f2c,0x4(%esp) + 3fc3: 00 + 3fc4: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3fcb: e8 30 0e 00 00 call 4e00 + exit(); + 3fd0: e8 cd 0c 00 00 call 4ca2 + 3fd5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 3fd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00003fe0 : +{ + 3fe0: 55 push %ebp + 3fe1: 89 e5 mov %esp,%ebp + 3fe3: 53 push %ebx + for(n=0; n<1000; n++){ + 3fe4: 31 db xor %ebx,%ebx +{ + 3fe6: 83 ec 14 sub $0x14,%esp + printf(1, "fork test\n"); + 3fe9: c7 44 24 04 54 5f 00 movl $0x5f54,0x4(%esp) + 3ff0: 00 + 3ff1: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 3ff8: e8 03 0e 00 00 call 4e00 + 3ffd: eb 13 jmp 4012 + 3fff: 90 nop + if(pid == 0) + 4000: 0f 84 87 00 00 00 je 408d + for(n=0; n<1000; n++){ + 4006: 83 c3 01 add $0x1,%ebx + 4009: 81 fb e8 03 00 00 cmp $0x3e8,%ebx + 400f: 90 nop + 4010: 74 4e je 4060 + pid = fork(); + 4012: e8 83 0c 00 00 call 4c9a + if(pid < 0) + 4017: 85 c0 test %eax,%eax + 4019: 79 e5 jns 4000 + for(; n > 0; n--){ + 401b: 85 db test %ebx,%ebx + 401d: 8d 76 00 lea 0x0(%esi),%esi + 4020: 74 15 je 4037 + 4022: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + if(wait() < 0){ + 4028: e8 7d 0c 00 00 call 4caa + 402d: 85 c0 test %eax,%eax + 402f: 90 nop + 4030: 78 47 js 4079 + for(; n > 0; n--){ + 4032: 83 eb 01 sub $0x1,%ebx + 4035: 75 f1 jne 4028 + if(wait() != -1){ + 4037: e8 6e 0c 00 00 call 4caa + 403c: 83 f8 ff cmp $0xffffffff,%eax + 403f: 90 nop + 4040: 75 50 jne 4092 + printf(1, "fork test OK\n"); + 4042: c7 44 24 04 86 5f 00 movl $0x5f86,0x4(%esp) + 4049: 00 + 404a: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 4051: e8 aa 0d 00 00 call 4e00 +} + 4056: 83 c4 14 add $0x14,%esp + 4059: 5b pop %ebx + 405a: 5d pop %ebp + 405b: c3 ret + 405c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + printf(1, "fork claimed to work 1000 times!\n"); + 4060: c7 44 24 04 f4 66 00 movl $0x66f4,0x4(%esp) + 4067: 00 + 4068: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 406f: e8 8c 0d 00 00 call 4e00 + exit(); + 4074: e8 29 0c 00 00 call 4ca2 + printf(1, "wait stopped early\n"); + 4079: c7 44 24 04 5f 5f 00 movl $0x5f5f,0x4(%esp) + 4080: 00 + 4081: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 4088: e8 73 0d 00 00 call 4e00 + exit(); + 408d: e8 10 0c 00 00 call 4ca2 + printf(1, "wait got too many\n"); + 4092: c7 44 24 04 73 5f 00 movl $0x5f73,0x4(%esp) + 4099: 00 + 409a: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 40a1: e8 5a 0d 00 00 call 4e00 + exit(); + 40a6: e8 f7 0b 00 00 call 4ca2 + 40ab: 90 nop + 40ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + +000040b0 : +{ + 40b0: 55 push %ebp + 40b1: 89 e5 mov %esp,%ebp + 40b3: 57 push %edi + 40b4: 56 push %esi + for(i = 0; i < 5000; i++){ + 40b5: 31 f6 xor %esi,%esi +{ + 40b7: 53 push %ebx + 40b8: 83 ec 6c sub $0x6c,%esp + printf(stdout, "sbrk test\n"); + 40bb: a1 60 72 00 00 mov 0x7260,%eax + 40c0: c7 44 24 04 94 5f 00 movl $0x5f94,0x4(%esp) + 40c7: 00 + 40c8: 89 04 24 mov %eax,(%esp) + 40cb: e8 30 0d 00 00 call 4e00 + oldbrk = sbrk(0); + 40d0: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 40d7: e8 4e 0c 00 00 call 4d2a + a = sbrk(0); + 40dc: c7 04 24 00 00 00 00 movl $0x0,(%esp) + oldbrk = sbrk(0); + 40e3: 89 45 a4 mov %eax,-0x5c(%ebp) + a = sbrk(0); + 40e6: e8 3f 0c 00 00 call 4d2a + 40eb: 89 c3 mov %eax,%ebx + 40ed: 8d 76 00 lea 0x0(%esi),%esi + b = sbrk(1); + 40f0: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 40f7: e8 2e 0c 00 00 call 4d2a + if(b != a){ + 40fc: 39 d8 cmp %ebx,%eax + b = sbrk(1); + 40fe: 89 c7 mov %eax,%edi + if(b != a){ + 4100: 0f 85 78 02 00 00 jne 437e + for(i = 0; i < 5000; i++){ + 4106: 83 c6 01 add $0x1,%esi + a = b + 1; + 4109: 83 c3 01 add $0x1,%ebx + *b = 1; + 410c: c6 43 ff 01 movb $0x1,-0x1(%ebx) + for(i = 0; i < 5000; i++){ + 4110: 81 fe 88 13 00 00 cmp $0x1388,%esi + 4116: 75 d8 jne 40f0 + pid = fork(); + 4118: e8 7d 0b 00 00 call 4c9a + if(pid < 0){ + 411d: 85 c0 test %eax,%eax + pid = fork(); + 411f: 89 c3 mov %eax,%ebx + if(pid < 0){ + 4121: 0f 88 c5 03 00 00 js 44ec + c = sbrk(1); + 4127: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 412e: e8 f7 0b 00 00 call 4d2a + c = sbrk(1); + 4133: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 413a: e8 eb 0b 00 00 call 4d2a + if(c != a + 1){ + 413f: 8d 57 02 lea 0x2(%edi),%edx + 4142: 39 d0 cmp %edx,%eax + 4144: 0f 85 88 03 00 00 jne 44d2 + if(pid == 0) + 414a: 85 db test %ebx,%ebx + 414c: 0f 84 7b 03 00 00 je 44cd + wait(); + 4152: e8 53 0b 00 00 call 4caa + a = sbrk(0); + 4157: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 415e: e8 c7 0b 00 00 call 4d2a + amt = (BIG) - (uint)a; + 4163: ba 00 00 40 06 mov $0x6400000,%edx + 4168: 29 c2 sub %eax,%edx + a = sbrk(0); + 416a: 89 c3 mov %eax,%ebx + p = sbrk(amt); + 416c: 89 14 24 mov %edx,(%esp) + 416f: e8 b6 0b 00 00 call 4d2a + if (p != a) { + 4174: 39 d8 cmp %ebx,%eax + 4176: 0f 85 3c 03 00 00 jne 44b8 + *lastaddr = 99; + 417c: c6 05 ff ff 3f 06 63 movb $0x63,0x63fffff + a = sbrk(0); + 4183: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 418a: e8 9b 0b 00 00 call 4d2a + c = sbrk(-4096); + 418f: c7 04 24 00 f0 ff ff movl $0xfffff000,(%esp) + a = sbrk(0); + 4196: 89 c3 mov %eax,%ebx + c = sbrk(-4096); + 4198: e8 8d 0b 00 00 call 4d2a + if(c == (char*)0xffffffff){ + 419d: 83 f8 ff cmp $0xffffffff,%eax + 41a0: 0f 84 f8 02 00 00 je 449e + c = sbrk(0); + 41a6: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 41ad: e8 78 0b 00 00 call 4d2a + if(c != a - 4096){ + 41b2: 8d 93 00 f0 ff ff lea -0x1000(%ebx),%edx + 41b8: 39 d0 cmp %edx,%eax + 41ba: 0f 85 bc 02 00 00 jne 447c + a = sbrk(0); + 41c0: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 41c7: e8 5e 0b 00 00 call 4d2a + c = sbrk(4096); + 41cc: c7 04 24 00 10 00 00 movl $0x1000,(%esp) + a = sbrk(0); + 41d3: 89 c6 mov %eax,%esi + c = sbrk(4096); + 41d5: e8 50 0b 00 00 call 4d2a + if(c != a || sbrk(0) != a + 4096){ + 41da: 39 f0 cmp %esi,%eax + c = sbrk(4096); + 41dc: 89 c3 mov %eax,%ebx + if(c != a || sbrk(0) != a + 4096){ + 41de: 0f 85 76 02 00 00 jne 445a + 41e4: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 41eb: e8 3a 0b 00 00 call 4d2a + 41f0: 8d 93 00 10 00 00 lea 0x1000(%ebx),%edx + 41f6: 39 d0 cmp %edx,%eax + 41f8: 0f 85 5c 02 00 00 jne 445a + if(*lastaddr == 99){ + 41fe: 80 3d ff ff 3f 06 63 cmpb $0x63,0x63fffff + 4205: 0f 84 35 02 00 00 je 4440 + a = sbrk(0); + 420b: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 4212: e8 13 0b 00 00 call 4d2a + c = sbrk(-(sbrk(0) - oldbrk)); + 4217: c7 04 24 00 00 00 00 movl $0x0,(%esp) + a = sbrk(0); + 421e: 89 c3 mov %eax,%ebx + c = sbrk(-(sbrk(0) - oldbrk)); + 4220: e8 05 0b 00 00 call 4d2a + 4225: 8b 4d a4 mov -0x5c(%ebp),%ecx + 4228: 29 c1 sub %eax,%ecx + 422a: 89 0c 24 mov %ecx,(%esp) + 422d: e8 f8 0a 00 00 call 4d2a + if(c != a){ + 4232: 39 d8 cmp %ebx,%eax + 4234: 0f 85 e4 01 00 00 jne 441e + 423a: bb 00 00 00 80 mov $0x80000000,%ebx + 423f: 90 nop + ppid = getpid(); + 4240: e8 dd 0a 00 00 call 4d22 + 4245: 89 c6 mov %eax,%esi + pid = fork(); + 4247: e8 4e 0a 00 00 call 4c9a + if(pid < 0){ + 424c: 85 c0 test %eax,%eax + 424e: 0f 88 b0 01 00 00 js 4404 + if(pid == 0){ + 4254: 0f 84 7d 01 00 00 je 43d7 + for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ + 425a: 81 c3 50 c3 00 00 add $0xc350,%ebx + wait(); + 4260: e8 45 0a 00 00 call 4caa + for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ + 4265: 81 fb 80 84 1e 80 cmp $0x801e8480,%ebx + 426b: 75 d3 jne 4240 + if(pipe(fds) != 0){ + 426d: 8d 45 b8 lea -0x48(%ebp),%eax + 4270: 89 04 24 mov %eax,(%esp) + 4273: e8 3a 0a 00 00 call 4cb2 + 4278: 85 c0 test %eax,%eax + 427a: 0f 85 3e 01 00 00 jne 43be + 4280: 8d 5d e8 lea -0x18(%ebp),%ebx + 4283: 8d 75 c0 lea -0x40(%ebp),%esi + read(fds[0], &scratch, 1); + 4286: 8d 7d b7 lea -0x49(%ebp),%edi + if((pids[i] = fork()) == 0){ + 4289: e8 0c 0a 00 00 call 4c9a + 428e: 85 c0 test %eax,%eax + 4290: 89 06 mov %eax,(%esi) + 4292: 0f 84 9f 00 00 00 je 4337 + if(pids[i] != -1) + 4298: 83 f8 ff cmp $0xffffffff,%eax + 429b: 74 17 je 42b4 + read(fds[0], &scratch, 1); + 429d: 8b 45 b8 mov -0x48(%ebp),%eax + 42a0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 42a7: 00 + 42a8: 89 7c 24 04 mov %edi,0x4(%esp) + 42ac: 89 04 24 mov %eax,(%esp) + 42af: e8 06 0a 00 00 call 4cba + 42b4: 83 c6 04 add $0x4,%esi + for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ + 42b7: 39 de cmp %ebx,%esi + 42b9: 75 ce jne 4289 + c = sbrk(4096); + 42bb: c7 04 24 00 10 00 00 movl $0x1000,(%esp) + 42c2: 8d 75 c0 lea -0x40(%ebp),%esi + 42c5: e8 60 0a 00 00 call 4d2a + 42ca: 89 c7 mov %eax,%edi + if(pids[i] == -1) + 42cc: 8b 06 mov (%esi),%eax + 42ce: 83 f8 ff cmp $0xffffffff,%eax + 42d1: 74 0d je 42e0 + kill(pids[i]); + 42d3: 89 04 24 mov %eax,(%esp) + 42d6: e8 f7 09 00 00 call 4cd2 + wait(); + 42db: e8 ca 09 00 00 call 4caa + 42e0: 83 c6 04 add $0x4,%esi + for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ + 42e3: 39 f3 cmp %esi,%ebx + 42e5: 75 e5 jne 42cc + if(c == (char*)0xffffffff){ + 42e7: 83 ff ff cmp $0xffffffff,%edi + 42ea: 0f 84 b4 00 00 00 je 43a4 + if(sbrk(0) > oldbrk) + 42f0: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 42f7: e8 2e 0a 00 00 call 4d2a + 42fc: 39 45 a4 cmp %eax,-0x5c(%ebp) + 42ff: 73 19 jae 431a + sbrk(-(sbrk(0) - oldbrk)); + 4301: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 4308: e8 1d 0a 00 00 call 4d2a + 430d: 8b 7d a4 mov -0x5c(%ebp),%edi + 4310: 29 c7 sub %eax,%edi + 4312: 89 3c 24 mov %edi,(%esp) + 4315: e8 10 0a 00 00 call 4d2a + printf(stdout, "sbrk test OK\n"); + 431a: a1 60 72 00 00 mov 0x7260,%eax + 431f: c7 44 24 04 3c 60 00 movl $0x603c,0x4(%esp) + 4326: 00 + 4327: 89 04 24 mov %eax,(%esp) + 432a: e8 d1 0a 00 00 call 4e00 +} + 432f: 83 c4 6c add $0x6c,%esp + 4332: 5b pop %ebx + 4333: 5e pop %esi + 4334: 5f pop %edi + 4335: 5d pop %ebp + 4336: c3 ret + sbrk(BIG - (uint)sbrk(0)); + 4337: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 433e: e8 e7 09 00 00 call 4d2a + 4343: ba 00 00 40 06 mov $0x6400000,%edx + 4348: 29 c2 sub %eax,%edx + 434a: 89 14 24 mov %edx,(%esp) + 434d: e8 d8 09 00 00 call 4d2a + write(fds[1], "x", 1); + 4352: 8b 45 bc mov -0x44(%ebp),%eax + 4355: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 435c: 00 + 435d: c7 44 24 04 fd 5a 00 movl $0x5afd,0x4(%esp) + 4364: 00 + 4365: 89 04 24 mov %eax,(%esp) + 4368: e8 55 09 00 00 call 4cc2 + 436d: 8d 76 00 lea 0x0(%esi),%esi + for(;;) sleep(1000); + 4370: c7 04 24 e8 03 00 00 movl $0x3e8,(%esp) + 4377: e8 b6 09 00 00 call 4d32 + 437c: eb f2 jmp 4370 + printf(stdout, "sbrk test failed %d %x %x\n", i, a, b); + 437e: 89 44 24 10 mov %eax,0x10(%esp) + 4382: a1 60 72 00 00 mov 0x7260,%eax + 4387: 89 5c 24 0c mov %ebx,0xc(%esp) + 438b: 89 74 24 08 mov %esi,0x8(%esp) + 438f: c7 44 24 04 9f 5f 00 movl $0x5f9f,0x4(%esp) + 4396: 00 + 4397: 89 04 24 mov %eax,(%esp) + 439a: e8 61 0a 00 00 call 4e00 + exit(); + 439f: e8 fe 08 00 00 call 4ca2 + printf(stdout, "failed sbrk leaked memory\n"); + 43a4: a1 60 72 00 00 mov 0x7260,%eax + 43a9: c7 44 24 04 21 60 00 movl $0x6021,0x4(%esp) + 43b0: 00 + 43b1: 89 04 24 mov %eax,(%esp) + 43b4: e8 47 0a 00 00 call 4e00 + exit(); + 43b9: e8 e4 08 00 00 call 4ca2 + printf(1, "pipe() failed\n"); + 43be: c7 44 24 04 dd 54 00 movl $0x54dd,0x4(%esp) + 43c5: 00 + 43c6: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 43cd: e8 2e 0a 00 00 call 4e00 + exit(); + 43d2: e8 cb 08 00 00 call 4ca2 + printf(stdout, "oops could read %x = %x\n", a, *a); + 43d7: 0f be 03 movsbl (%ebx),%eax + 43da: 89 5c 24 08 mov %ebx,0x8(%esp) + 43de: c7 44 24 04 08 60 00 movl $0x6008,0x4(%esp) + 43e5: 00 + 43e6: 89 44 24 0c mov %eax,0xc(%esp) + 43ea: a1 60 72 00 00 mov 0x7260,%eax + 43ef: 89 04 24 mov %eax,(%esp) + 43f2: e8 09 0a 00 00 call 4e00 + kill(ppid); + 43f7: 89 34 24 mov %esi,(%esp) + 43fa: e8 d3 08 00 00 call 4cd2 + exit(); + 43ff: e8 9e 08 00 00 call 4ca2 + printf(stdout, "fork failed\n"); + 4404: a1 60 72 00 00 mov 0x7260,%eax + 4409: c7 44 24 04 e5 60 00 movl $0x60e5,0x4(%esp) + 4410: 00 + 4411: 89 04 24 mov %eax,(%esp) + 4414: e8 e7 09 00 00 call 4e00 + exit(); + 4419: e8 84 08 00 00 call 4ca2 + printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c); + 441e: 89 44 24 0c mov %eax,0xc(%esp) + 4422: a1 60 72 00 00 mov 0x7260,%eax + 4427: 89 5c 24 08 mov %ebx,0x8(%esp) + 442b: c7 44 24 04 e8 67 00 movl $0x67e8,0x4(%esp) + 4432: 00 + 4433: 89 04 24 mov %eax,(%esp) + 4436: e8 c5 09 00 00 call 4e00 + exit(); + 443b: e8 62 08 00 00 call 4ca2 + printf(stdout, "sbrk de-allocation didn't really deallocate\n"); + 4440: a1 60 72 00 00 mov 0x7260,%eax + 4445: c7 44 24 04 b8 67 00 movl $0x67b8,0x4(%esp) + 444c: 00 + 444d: 89 04 24 mov %eax,(%esp) + 4450: e8 ab 09 00 00 call 4e00 + exit(); + 4455: e8 48 08 00 00 call 4ca2 + printf(stdout, "sbrk re-allocation failed, a %x c %x\n", a, c); + 445a: a1 60 72 00 00 mov 0x7260,%eax + 445f: 89 5c 24 0c mov %ebx,0xc(%esp) + 4463: 89 74 24 08 mov %esi,0x8(%esp) + 4467: c7 44 24 04 90 67 00 movl $0x6790,0x4(%esp) + 446e: 00 + 446f: 89 04 24 mov %eax,(%esp) + 4472: e8 89 09 00 00 call 4e00 + exit(); + 4477: e8 26 08 00 00 call 4ca2 + printf(stdout, "sbrk deallocation produced wrong address, a %x c %x\n", a, c); + 447c: 89 44 24 0c mov %eax,0xc(%esp) + 4480: a1 60 72 00 00 mov 0x7260,%eax + 4485: 89 5c 24 08 mov %ebx,0x8(%esp) + 4489: c7 44 24 04 58 67 00 movl $0x6758,0x4(%esp) + 4490: 00 + 4491: 89 04 24 mov %eax,(%esp) + 4494: e8 67 09 00 00 call 4e00 + exit(); + 4499: e8 04 08 00 00 call 4ca2 + printf(stdout, "sbrk could not deallocate\n"); + 449e: a1 60 72 00 00 mov 0x7260,%eax + 44a3: c7 44 24 04 ed 5f 00 movl $0x5fed,0x4(%esp) + 44aa: 00 + 44ab: 89 04 24 mov %eax,(%esp) + 44ae: e8 4d 09 00 00 call 4e00 + exit(); + 44b3: e8 ea 07 00 00 call 4ca2 + printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n"); + 44b8: a1 60 72 00 00 mov 0x7260,%eax + 44bd: c7 44 24 04 18 67 00 movl $0x6718,0x4(%esp) + 44c4: 00 + 44c5: 89 04 24 mov %eax,(%esp) + 44c8: e8 33 09 00 00 call 4e00 + exit(); + 44cd: e8 d0 07 00 00 call 4ca2 + printf(stdout, "sbrk test failed post-fork\n"); + 44d2: a1 60 72 00 00 mov 0x7260,%eax + 44d7: c7 44 24 04 d1 5f 00 movl $0x5fd1,0x4(%esp) + 44de: 00 + 44df: 89 04 24 mov %eax,(%esp) + 44e2: e8 19 09 00 00 call 4e00 + exit(); + 44e7: e8 b6 07 00 00 call 4ca2 + printf(stdout, "sbrk test fork failed\n"); + 44ec: a1 60 72 00 00 mov 0x7260,%eax + 44f1: c7 44 24 04 ba 5f 00 movl $0x5fba,0x4(%esp) + 44f8: 00 + 44f9: 89 04 24 mov %eax,(%esp) + 44fc: e8 ff 08 00 00 call 4e00 + exit(); + 4501: e8 9c 07 00 00 call 4ca2 + 4506: 8d 76 00 lea 0x0(%esi),%esi + 4509: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00004510 : +{ + 4510: 55 push %ebp + 4511: 89 e5 mov %esp,%ebp +} + 4513: 5d pop %ebp + 4514: c3 ret + 4515: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 4519: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00004520 : +{ + 4520: 55 push %ebp + 4521: 89 e5 mov %esp,%ebp + 4523: 56 push %esi + 4524: 53 push %ebx + for(p = 0; p <= (uint)hi; p += 4096){ + 4525: 31 db xor %ebx,%ebx +{ + 4527: 83 ec 10 sub $0x10,%esp + printf(stdout, "validate test\n"); + 452a: a1 60 72 00 00 mov 0x7260,%eax + 452f: c7 44 24 04 4a 60 00 movl $0x604a,0x4(%esp) + 4536: 00 + 4537: 89 04 24 mov %eax,(%esp) + 453a: e8 c1 08 00 00 call 4e00 + 453f: 90 nop + if((pid = fork()) == 0){ + 4540: e8 55 07 00 00 call 4c9a + 4545: 85 c0 test %eax,%eax + 4547: 89 c6 mov %eax,%esi + 4549: 74 79 je 45c4 + sleep(0); + 454b: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 4552: e8 db 07 00 00 call 4d32 + sleep(0); + 4557: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 455e: e8 cf 07 00 00 call 4d32 + kill(pid); + 4563: 89 34 24 mov %esi,(%esp) + 4566: e8 67 07 00 00 call 4cd2 + wait(); + 456b: e8 3a 07 00 00 call 4caa + if(link("nosuchfile", (char*)p) != -1){ + 4570: 89 5c 24 04 mov %ebx,0x4(%esp) + 4574: c7 04 24 59 60 00 00 movl $0x6059,(%esp) + 457b: e8 82 07 00 00 call 4d02 + 4580: 83 f8 ff cmp $0xffffffff,%eax + 4583: 75 2a jne 45af + for(p = 0; p <= (uint)hi; p += 4096){ + 4585: 81 c3 00 10 00 00 add $0x1000,%ebx + 458b: 81 fb 00 40 11 00 cmp $0x114000,%ebx + 4591: 75 ad jne 4540 + printf(stdout, "validate ok\n"); + 4593: a1 60 72 00 00 mov 0x7260,%eax + 4598: c7 44 24 04 7d 60 00 movl $0x607d,0x4(%esp) + 459f: 00 + 45a0: 89 04 24 mov %eax,(%esp) + 45a3: e8 58 08 00 00 call 4e00 +} + 45a8: 83 c4 10 add $0x10,%esp + 45ab: 5b pop %ebx + 45ac: 5e pop %esi + 45ad: 5d pop %ebp + 45ae: c3 ret + printf(stdout, "link should not succeed\n"); + 45af: a1 60 72 00 00 mov 0x7260,%eax + 45b4: c7 44 24 04 64 60 00 movl $0x6064,0x4(%esp) + 45bb: 00 + 45bc: 89 04 24 mov %eax,(%esp) + 45bf: e8 3c 08 00 00 call 4e00 + exit(); + 45c4: e8 d9 06 00 00 call 4ca2 + 45c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000045d0 : +{ + 45d0: 55 push %ebp + 45d1: 89 e5 mov %esp,%ebp + 45d3: 83 ec 18 sub $0x18,%esp + printf(stdout, "bss test\n"); + 45d6: a1 60 72 00 00 mov 0x7260,%eax + 45db: c7 44 24 04 8a 60 00 movl $0x608a,0x4(%esp) + 45e2: 00 + 45e3: 89 04 24 mov %eax,(%esp) + 45e6: e8 15 08 00 00 call 4e00 + if(uninit[i] != '\0'){ + 45eb: 80 3d 20 73 00 00 00 cmpb $0x0,0x7320 + 45f2: 75 36 jne 462a + for(i = 0; i < sizeof(uninit); i++){ + 45f4: b8 01 00 00 00 mov $0x1,%eax + 45f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + if(uninit[i] != '\0'){ + 4600: 80 b8 20 73 00 00 00 cmpb $0x0,0x7320(%eax) + 4607: 75 21 jne 462a + for(i = 0; i < sizeof(uninit); i++){ + 4609: 83 c0 01 add $0x1,%eax + 460c: 3d 10 27 00 00 cmp $0x2710,%eax + 4611: 75 ed jne 4600 + printf(stdout, "bss test ok\n"); + 4613: a1 60 72 00 00 mov 0x7260,%eax + 4618: c7 44 24 04 a5 60 00 movl $0x60a5,0x4(%esp) + 461f: 00 + 4620: 89 04 24 mov %eax,(%esp) + 4623: e8 d8 07 00 00 call 4e00 +} + 4628: c9 leave + 4629: c3 ret + printf(stdout, "bss test failed\n"); + 462a: a1 60 72 00 00 mov 0x7260,%eax + 462f: c7 44 24 04 94 60 00 movl $0x6094,0x4(%esp) + 4636: 00 + 4637: 89 04 24 mov %eax,(%esp) + 463a: e8 c1 07 00 00 call 4e00 + exit(); + 463f: e8 5e 06 00 00 call 4ca2 + 4644: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 464a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00004650 : +{ + 4650: 55 push %ebp + 4651: 89 e5 mov %esp,%ebp + 4653: 83 ec 18 sub $0x18,%esp + unlink("bigarg-ok"); + 4656: c7 04 24 b2 60 00 00 movl $0x60b2,(%esp) + 465d: e8 90 06 00 00 call 4cf2 + pid = fork(); + 4662: e8 33 06 00 00 call 4c9a + if(pid == 0){ + 4667: 85 c0 test %eax,%eax + 4669: 74 45 je 46b0 + 466b: 90 nop + 466c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } else if(pid < 0){ + 4670: 0f 88 d0 00 00 00 js 4746 + wait(); + 4676: e8 2f 06 00 00 call 4caa + fd = open("bigarg-ok", 0); + 467b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 4682: 00 + 4683: c7 04 24 b2 60 00 00 movl $0x60b2,(%esp) + 468a: e8 53 06 00 00 call 4ce2 + if(fd < 0){ + 468f: 85 c0 test %eax,%eax + 4691: 0f 88 95 00 00 00 js 472c + close(fd); + 4697: 89 04 24 mov %eax,(%esp) + 469a: e8 2b 06 00 00 call 4cca + unlink("bigarg-ok"); + 469f: c7 04 24 b2 60 00 00 movl $0x60b2,(%esp) + 46a6: e8 47 06 00 00 call 4cf2 +} + 46ab: c9 leave + 46ac: c3 ret + 46ad: 8d 76 00 lea 0x0(%esi),%esi + args[i] = "bigargs test: failed\n "; + 46b0: c7 04 85 80 72 00 00 movl $0x680c,0x7280(,%eax,4) + 46b7: 0c 68 00 00 + for(i = 0; i < MAXARG-1; i++) + 46bb: 83 c0 01 add $0x1,%eax + 46be: 83 f8 1f cmp $0x1f,%eax + 46c1: 75 ed jne 46b0 + printf(stdout, "bigarg test\n"); + 46c3: a1 60 72 00 00 mov 0x7260,%eax + 46c8: c7 44 24 04 bc 60 00 movl $0x60bc,0x4(%esp) + 46cf: 00 + args[MAXARG-1] = 0; + 46d0: c7 05 fc 72 00 00 00 movl $0x0,0x72fc + 46d7: 00 00 00 + printf(stdout, "bigarg test\n"); + 46da: 89 04 24 mov %eax,(%esp) + 46dd: e8 1e 07 00 00 call 4e00 + exec("echo", args); + 46e2: c7 44 24 04 80 72 00 movl $0x7280,0x4(%esp) + 46e9: 00 + 46ea: c7 04 24 89 52 00 00 movl $0x5289,(%esp) + 46f1: e8 e4 05 00 00 call 4cda + printf(stdout, "bigarg test ok\n"); + 46f6: a1 60 72 00 00 mov 0x7260,%eax + 46fb: c7 44 24 04 c9 60 00 movl $0x60c9,0x4(%esp) + 4702: 00 + 4703: 89 04 24 mov %eax,(%esp) + 4706: e8 f5 06 00 00 call 4e00 + fd = open("bigarg-ok", O_CREATE); + 470b: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) + 4712: 00 + 4713: c7 04 24 b2 60 00 00 movl $0x60b2,(%esp) + 471a: e8 c3 05 00 00 call 4ce2 + close(fd); + 471f: 89 04 24 mov %eax,(%esp) + 4722: e8 a3 05 00 00 call 4cca + exit(); + 4727: e8 76 05 00 00 call 4ca2 + printf(stdout, "bigarg test failed!\n"); + 472c: a1 60 72 00 00 mov 0x7260,%eax + 4731: c7 44 24 04 f2 60 00 movl $0x60f2,0x4(%esp) + 4738: 00 + 4739: 89 04 24 mov %eax,(%esp) + 473c: e8 bf 06 00 00 call 4e00 + exit(); + 4741: e8 5c 05 00 00 call 4ca2 + printf(stdout, "bigargtest: fork failed\n"); + 4746: a1 60 72 00 00 mov 0x7260,%eax + 474b: c7 44 24 04 d9 60 00 movl $0x60d9,0x4(%esp) + 4752: 00 + 4753: 89 04 24 mov %eax,(%esp) + 4756: e8 a5 06 00 00 call 4e00 + exit(); + 475b: e8 42 05 00 00 call 4ca2 + +00004760 : +{ + 4760: 55 push %ebp + 4761: 89 e5 mov %esp,%ebp + 4763: 57 push %edi + 4764: 56 push %esi + 4765: 53 push %ebx + for(nfiles = 0; ; nfiles++){ + 4766: 31 db xor %ebx,%ebx +{ + 4768: 83 ec 5c sub $0x5c,%esp + printf(1, "fsfull test\n"); + 476b: c7 44 24 04 07 61 00 movl $0x6107,0x4(%esp) + 4772: 00 + 4773: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 477a: e8 81 06 00 00 call 4e00 + 477f: 90 nop + name[1] = '0' + nfiles / 1000; + 4780: b8 d3 4d 62 10 mov $0x10624dd3,%eax + 4785: 89 d9 mov %ebx,%ecx + 4787: f7 eb imul %ebx + name[2] = '0' + (nfiles % 1000) / 100; + 4789: 89 de mov %ebx,%esi + name[1] = '0' + nfiles / 1000; + 478b: c1 f9 1f sar $0x1f,%ecx + name[3] = '0' + (nfiles % 100) / 10; + 478e: 89 df mov %ebx,%edi + printf(1, "writing %s\n", name); + 4790: c7 44 24 04 14 61 00 movl $0x6114,0x4(%esp) + 4797: 00 + 4798: c7 04 24 01 00 00 00 movl $0x1,(%esp) + name[1] = '0' + nfiles / 1000; + 479f: c1 fa 06 sar $0x6,%edx + 47a2: 29 ca sub %ecx,%edx + 47a4: 8d 42 30 lea 0x30(%edx),%eax + name[2] = '0' + (nfiles % 1000) / 100; + 47a7: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx + name[1] = '0' + nfiles / 1000; + 47ad: 88 45 a9 mov %al,-0x57(%ebp) + name[2] = '0' + (nfiles % 1000) / 100; + 47b0: b8 1f 85 eb 51 mov $0x51eb851f,%eax + name[0] = 'f'; + 47b5: c6 45 a8 66 movb $0x66,-0x58(%ebp) + name[5] = '\0'; + 47b9: c6 45 ad 00 movb $0x0,-0x53(%ebp) + name[2] = '0' + (nfiles % 1000) / 100; + 47bd: 29 d6 sub %edx,%esi + 47bf: f7 ee imul %esi + name[3] = '0' + (nfiles % 100) / 10; + 47c1: b8 1f 85 eb 51 mov $0x51eb851f,%eax + name[2] = '0' + (nfiles % 1000) / 100; + 47c6: c1 fe 1f sar $0x1f,%esi + 47c9: c1 fa 05 sar $0x5,%edx + 47cc: 29 f2 sub %esi,%edx + name[3] = '0' + (nfiles % 100) / 10; + 47ce: be 67 66 66 66 mov $0x66666667,%esi + name[2] = '0' + (nfiles % 1000) / 100; + 47d3: 83 c2 30 add $0x30,%edx + 47d6: 88 55 aa mov %dl,-0x56(%ebp) + name[3] = '0' + (nfiles % 100) / 10; + 47d9: f7 eb imul %ebx + 47db: c1 fa 05 sar $0x5,%edx + 47de: 29 ca sub %ecx,%edx + 47e0: 6b d2 64 imul $0x64,%edx,%edx + 47e3: 29 d7 sub %edx,%edi + 47e5: 89 f8 mov %edi,%eax + 47e7: f7 ee imul %esi + name[4] = '0' + (nfiles % 10); + 47e9: 89 d8 mov %ebx,%eax + name[3] = '0' + (nfiles % 100) / 10; + 47eb: c1 ff 1f sar $0x1f,%edi + 47ee: c1 fa 02 sar $0x2,%edx + 47f1: 29 fa sub %edi,%edx + 47f3: 83 c2 30 add $0x30,%edx + 47f6: 88 55 ab mov %dl,-0x55(%ebp) + name[4] = '0' + (nfiles % 10); + 47f9: f7 ee imul %esi + 47fb: c1 fa 02 sar $0x2,%edx + 47fe: 29 ca sub %ecx,%edx + 4800: 89 d9 mov %ebx,%ecx + 4802: 8d 04 92 lea (%edx,%edx,4),%eax + 4805: 01 c0 add %eax,%eax + 4807: 29 c1 sub %eax,%ecx + 4809: 89 c8 mov %ecx,%eax + 480b: 83 c0 30 add $0x30,%eax + 480e: 88 45 ac mov %al,-0x54(%ebp) + printf(1, "writing %s\n", name); + 4811: 8d 45 a8 lea -0x58(%ebp),%eax + 4814: 89 44 24 08 mov %eax,0x8(%esp) + 4818: e8 e3 05 00 00 call 4e00 + int fd = open(name, O_CREATE|O_RDWR); + 481d: 8d 45 a8 lea -0x58(%ebp),%eax + 4820: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) + 4827: 00 + 4828: 89 04 24 mov %eax,(%esp) + 482b: e8 b2 04 00 00 call 4ce2 + if(fd < 0){ + 4830: 85 c0 test %eax,%eax + int fd = open(name, O_CREATE|O_RDWR); + 4832: 89 c7 mov %eax,%edi + if(fd < 0){ + 4834: 78 57 js 488d + 4836: 31 f6 xor %esi,%esi + 4838: eb 08 jmp 4842 + 483a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + total += cc; + 4840: 01 c6 add %eax,%esi + int cc = write(fd, buf, 512); + 4842: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) + 4849: 00 + 484a: c7 44 24 04 40 9a 00 movl $0x9a40,0x4(%esp) + 4851: 00 + 4852: 89 3c 24 mov %edi,(%esp) + 4855: e8 68 04 00 00 call 4cc2 + if(cc < 512) + 485a: 3d ff 01 00 00 cmp $0x1ff,%eax + 485f: 7f df jg 4840 + printf(1, "wrote %d bytes\n", total); + 4861: 89 74 24 08 mov %esi,0x8(%esp) + 4865: c7 44 24 04 30 61 00 movl $0x6130,0x4(%esp) + 486c: 00 + 486d: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 4874: e8 87 05 00 00 call 4e00 + close(fd); + 4879: 89 3c 24 mov %edi,(%esp) + 487c: e8 49 04 00 00 call 4cca + if(total == 0) + 4881: 85 f6 test %esi,%esi + 4883: 74 23 je 48a8 + for(nfiles = 0; ; nfiles++){ + 4885: 83 c3 01 add $0x1,%ebx + } + 4888: e9 f3 fe ff ff jmp 4780 + printf(1, "open %s failed\n", name); + 488d: 8d 45 a8 lea -0x58(%ebp),%eax + 4890: 89 44 24 08 mov %eax,0x8(%esp) + 4894: c7 44 24 04 20 61 00 movl $0x6120,0x4(%esp) + 489b: 00 + 489c: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 48a3: e8 58 05 00 00 call 4e00 + name[1] = '0' + nfiles / 1000; + 48a8: b8 d3 4d 62 10 mov $0x10624dd3,%eax + 48ad: 89 d9 mov %ebx,%ecx + 48af: f7 eb imul %ebx + name[2] = '0' + (nfiles % 1000) / 100; + 48b1: 89 de mov %ebx,%esi + name[1] = '0' + nfiles / 1000; + 48b3: c1 f9 1f sar $0x1f,%ecx + name[3] = '0' + (nfiles % 100) / 10; + 48b6: 89 df mov %ebx,%edi + name[0] = 'f'; + 48b8: c6 45 a8 66 movb $0x66,-0x58(%ebp) + name[5] = '\0'; + 48bc: c6 45 ad 00 movb $0x0,-0x53(%ebp) + name[1] = '0' + nfiles / 1000; + 48c0: c1 fa 06 sar $0x6,%edx + 48c3: 29 ca sub %ecx,%edx + 48c5: 8d 42 30 lea 0x30(%edx),%eax + name[2] = '0' + (nfiles % 1000) / 100; + 48c8: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx + name[1] = '0' + nfiles / 1000; + 48ce: 88 45 a9 mov %al,-0x57(%ebp) + name[2] = '0' + (nfiles % 1000) / 100; + 48d1: b8 1f 85 eb 51 mov $0x51eb851f,%eax + 48d6: 29 d6 sub %edx,%esi + 48d8: f7 ee imul %esi + name[3] = '0' + (nfiles % 100) / 10; + 48da: b8 1f 85 eb 51 mov $0x51eb851f,%eax + name[2] = '0' + (nfiles % 1000) / 100; + 48df: c1 fe 1f sar $0x1f,%esi + 48e2: c1 fa 05 sar $0x5,%edx + 48e5: 29 f2 sub %esi,%edx + name[3] = '0' + (nfiles % 100) / 10; + 48e7: be 67 66 66 66 mov $0x66666667,%esi + name[2] = '0' + (nfiles % 1000) / 100; + 48ec: 83 c2 30 add $0x30,%edx + 48ef: 88 55 aa mov %dl,-0x56(%ebp) + name[3] = '0' + (nfiles % 100) / 10; + 48f2: f7 eb imul %ebx + 48f4: c1 fa 05 sar $0x5,%edx + 48f7: 29 ca sub %ecx,%edx + 48f9: 6b d2 64 imul $0x64,%edx,%edx + 48fc: 29 d7 sub %edx,%edi + 48fe: 89 f8 mov %edi,%eax + 4900: f7 ee imul %esi + name[4] = '0' + (nfiles % 10); + 4902: 89 d8 mov %ebx,%eax + name[3] = '0' + (nfiles % 100) / 10; + 4904: c1 ff 1f sar $0x1f,%edi + 4907: c1 fa 02 sar $0x2,%edx + 490a: 29 fa sub %edi,%edx + 490c: 83 c2 30 add $0x30,%edx + 490f: 88 55 ab mov %dl,-0x55(%ebp) + name[4] = '0' + (nfiles % 10); + 4912: f7 ee imul %esi + 4914: c1 fa 02 sar $0x2,%edx + 4917: 29 ca sub %ecx,%edx + 4919: 89 d9 mov %ebx,%ecx + 491b: 8d 04 92 lea (%edx,%edx,4),%eax + nfiles--; + 491e: 83 eb 01 sub $0x1,%ebx + name[4] = '0' + (nfiles % 10); + 4921: 01 c0 add %eax,%eax + 4923: 29 c1 sub %eax,%ecx + 4925: 89 c8 mov %ecx,%eax + 4927: 83 c0 30 add $0x30,%eax + 492a: 88 45 ac mov %al,-0x54(%ebp) + unlink(name); + 492d: 8d 45 a8 lea -0x58(%ebp),%eax + 4930: 89 04 24 mov %eax,(%esp) + 4933: e8 ba 03 00 00 call 4cf2 + while(nfiles >= 0){ + 4938: 83 fb ff cmp $0xffffffff,%ebx + 493b: 0f 85 67 ff ff ff jne 48a8 + printf(1, "fsfull test finished\n"); + 4941: c7 44 24 04 40 61 00 movl $0x6140,0x4(%esp) + 4948: 00 + 4949: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 4950: e8 ab 04 00 00 call 4e00 +} + 4955: 83 c4 5c add $0x5c,%esp + 4958: 5b pop %ebx + 4959: 5e pop %esi + 495a: 5f pop %edi + 495b: 5d pop %ebp + 495c: c3 ret + 495d: 8d 76 00 lea 0x0(%esi),%esi + +00004960 : +{ + 4960: 55 push %ebp + 4961: 89 e5 mov %esp,%ebp + 4963: 83 ec 18 sub $0x18,%esp + printf(1, "uio test\n"); + 4966: c7 44 24 04 56 61 00 movl $0x6156,0x4(%esp) + 496d: 00 + 496e: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 4975: e8 86 04 00 00 call 4e00 + pid = fork(); + 497a: e8 1b 03 00 00 call 4c9a + if(pid == 0){ + 497f: 85 c0 test %eax,%eax + 4981: 74 1d je 49a0 + } else if(pid < 0){ + 4983: 78 42 js 49c7 + wait(); + 4985: e8 20 03 00 00 call 4caa + printf(1, "uio test done\n"); + 498a: c7 44 24 04 60 61 00 movl $0x6160,0x4(%esp) + 4991: 00 + 4992: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 4999: e8 62 04 00 00 call 4e00 +} + 499e: c9 leave + 499f: c3 ret + asm volatile("outb %0,%1"::"a"(val), "d" (port)); + 49a0: ba 70 00 00 00 mov $0x70,%edx + 49a5: b8 09 00 00 00 mov $0x9,%eax + 49aa: ee out %al,(%dx) + asm volatile("inb %1,%0" : "=a" (val) : "d" (port)); + 49ab: b2 71 mov $0x71,%dl + 49ad: ec in (%dx),%al + printf(1, "uio: uio succeeded; test FAILED\n"); + 49ae: c7 44 24 04 ec 68 00 movl $0x68ec,0x4(%esp) + 49b5: 00 + 49b6: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 49bd: e8 3e 04 00 00 call 4e00 + exit(); + 49c2: e8 db 02 00 00 call 4ca2 + printf (1, "fork failed\n"); + 49c7: c7 44 24 04 e5 60 00 movl $0x60e5,0x4(%esp) + 49ce: 00 + 49cf: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 49d6: e8 25 04 00 00 call 4e00 + exit(); + 49db: e8 c2 02 00 00 call 4ca2 + +000049e0 : +{ + 49e0: 55 push %ebp + 49e1: 89 e5 mov %esp,%ebp + 49e3: 53 push %ebx + 49e4: 83 ec 14 sub $0x14,%esp + fd = open("init", O_RDONLY); + 49e7: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 49ee: 00 + 49ef: c7 04 24 6f 61 00 00 movl $0x616f,(%esp) + 49f6: e8 e7 02 00 00 call 4ce2 + if (fd < 0) { + 49fb: 85 c0 test %eax,%eax + fd = open("init", O_RDONLY); + 49fd: 89 c3 mov %eax,%ebx + if (fd < 0) { + 49ff: 78 45 js 4a46 + read(fd, sbrk(0) - 1, -1); + 4a01: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 4a08: e8 1d 03 00 00 call 4d2a + 4a0d: 89 1c 24 mov %ebx,(%esp) + 4a10: c7 44 24 08 ff ff ff movl $0xffffffff,0x8(%esp) + 4a17: ff + 4a18: 83 e8 01 sub $0x1,%eax + 4a1b: 89 44 24 04 mov %eax,0x4(%esp) + 4a1f: e8 96 02 00 00 call 4cba + close(fd); + 4a24: 89 1c 24 mov %ebx,(%esp) + 4a27: e8 9e 02 00 00 call 4cca + printf(1, "arg test passed\n"); + 4a2c: c7 44 24 04 81 61 00 movl $0x6181,0x4(%esp) + 4a33: 00 + 4a34: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 4a3b: e8 c0 03 00 00 call 4e00 +} + 4a40: 83 c4 14 add $0x14,%esp + 4a43: 5b pop %ebx + 4a44: 5d pop %ebp + 4a45: c3 ret + printf(2, "open failed\n"); + 4a46: c7 44 24 04 74 61 00 movl $0x6174,0x4(%esp) + 4a4d: 00 + 4a4e: c7 04 24 02 00 00 00 movl $0x2,(%esp) + 4a55: e8 a6 03 00 00 call 4e00 + exit(); + 4a5a: e8 43 02 00 00 call 4ca2 + 4a5f: 90 nop + +00004a60 : + randstate = randstate * 1664525 + 1013904223; + 4a60: 69 05 5c 72 00 00 0d imul $0x19660d,0x725c,%eax + 4a67: 66 19 00 +{ + 4a6a: 55 push %ebp + 4a6b: 89 e5 mov %esp,%ebp +} + 4a6d: 5d pop %ebp + randstate = randstate * 1664525 + 1013904223; + 4a6e: 05 5f f3 6e 3c add $0x3c6ef35f,%eax + 4a73: a3 5c 72 00 00 mov %eax,0x725c +} + 4a78: c3 ret + 4a79: 66 90 xchg %ax,%ax + 4a7b: 66 90 xchg %ax,%ax + 4a7d: 66 90 xchg %ax,%ax + 4a7f: 90 nop + +00004a80 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 4a80: 55 push %ebp + 4a81: 89 e5 mov %esp,%ebp + 4a83: 8b 45 08 mov 0x8(%ebp),%eax + 4a86: 8b 4d 0c mov 0xc(%ebp),%ecx + 4a89: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 4a8a: 89 c2 mov %eax,%edx + 4a8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 4a90: 83 c1 01 add $0x1,%ecx + 4a93: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 4a97: 83 c2 01 add $0x1,%edx + 4a9a: 84 db test %bl,%bl + 4a9c: 88 5a ff mov %bl,-0x1(%edx) + 4a9f: 75 ef jne 4a90 + ; + return os; +} + 4aa1: 5b pop %ebx + 4aa2: 5d pop %ebp + 4aa3: c3 ret + 4aa4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 4aaa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00004ab0 : + +int +strcmp(const char *p, const char *q) +{ + 4ab0: 55 push %ebp + 4ab1: 89 e5 mov %esp,%ebp + 4ab3: 8b 55 08 mov 0x8(%ebp),%edx + 4ab6: 53 push %ebx + 4ab7: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 4aba: 0f b6 02 movzbl (%edx),%eax + 4abd: 84 c0 test %al,%al + 4abf: 74 2d je 4aee + 4ac1: 0f b6 19 movzbl (%ecx),%ebx + 4ac4: 38 d8 cmp %bl,%al + 4ac6: 74 0e je 4ad6 + 4ac8: eb 2b jmp 4af5 + 4aca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 4ad0: 38 c8 cmp %cl,%al + 4ad2: 75 15 jne 4ae9 + p++, q++; + 4ad4: 89 d9 mov %ebx,%ecx + 4ad6: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 4ad9: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 4adc: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 4adf: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 4ae3: 84 c0 test %al,%al + 4ae5: 75 e9 jne 4ad0 + 4ae7: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 4ae9: 29 c8 sub %ecx,%eax +} + 4aeb: 5b pop %ebx + 4aec: 5d pop %ebp + 4aed: c3 ret + 4aee: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 4af1: 31 c0 xor %eax,%eax + 4af3: eb f4 jmp 4ae9 + 4af5: 0f b6 cb movzbl %bl,%ecx + 4af8: eb ef jmp 4ae9 + 4afa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00004b00 : + +uint +strlen(char *s) +{ + 4b00: 55 push %ebp + 4b01: 89 e5 mov %esp,%ebp + 4b03: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 4b06: 80 39 00 cmpb $0x0,(%ecx) + 4b09: 74 12 je 4b1d + 4b0b: 31 d2 xor %edx,%edx + 4b0d: 8d 76 00 lea 0x0(%esi),%esi + 4b10: 83 c2 01 add $0x1,%edx + 4b13: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 4b17: 89 d0 mov %edx,%eax + 4b19: 75 f5 jne 4b10 + ; + return n; +} + 4b1b: 5d pop %ebp + 4b1c: c3 ret + for(n = 0; s[n]; n++) + 4b1d: 31 c0 xor %eax,%eax +} + 4b1f: 5d pop %ebp + 4b20: c3 ret + 4b21: eb 0d jmp 4b30 + 4b23: 90 nop + 4b24: 90 nop + 4b25: 90 nop + 4b26: 90 nop + 4b27: 90 nop + 4b28: 90 nop + 4b29: 90 nop + 4b2a: 90 nop + 4b2b: 90 nop + 4b2c: 90 nop + 4b2d: 90 nop + 4b2e: 90 nop + 4b2f: 90 nop + +00004b30 : + +void* +memset(void *dst, int c, uint n) +{ + 4b30: 55 push %ebp + 4b31: 89 e5 mov %esp,%ebp + 4b33: 8b 55 08 mov 0x8(%ebp),%edx + 4b36: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 4b37: 8b 4d 10 mov 0x10(%ebp),%ecx + 4b3a: 8b 45 0c mov 0xc(%ebp),%eax + 4b3d: 89 d7 mov %edx,%edi + 4b3f: fc cld + 4b40: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 4b42: 89 d0 mov %edx,%eax + 4b44: 5f pop %edi + 4b45: 5d pop %ebp + 4b46: c3 ret + 4b47: 89 f6 mov %esi,%esi + 4b49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00004b50 : + +char* +strchr(const char *s, char c) +{ + 4b50: 55 push %ebp + 4b51: 89 e5 mov %esp,%ebp + 4b53: 8b 45 08 mov 0x8(%ebp),%eax + 4b56: 53 push %ebx + 4b57: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 4b5a: 0f b6 18 movzbl (%eax),%ebx + 4b5d: 84 db test %bl,%bl + 4b5f: 74 1d je 4b7e + if(*s == c) + 4b61: 38 d3 cmp %dl,%bl + 4b63: 89 d1 mov %edx,%ecx + 4b65: 75 0d jne 4b74 + 4b67: eb 17 jmp 4b80 + 4b69: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 4b70: 38 ca cmp %cl,%dl + 4b72: 74 0c je 4b80 + for(; *s; s++) + 4b74: 83 c0 01 add $0x1,%eax + 4b77: 0f b6 10 movzbl (%eax),%edx + 4b7a: 84 d2 test %dl,%dl + 4b7c: 75 f2 jne 4b70 + return (char*)s; + return 0; + 4b7e: 31 c0 xor %eax,%eax +} + 4b80: 5b pop %ebx + 4b81: 5d pop %ebp + 4b82: c3 ret + 4b83: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 4b89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00004b90 : + +char* +gets(char *buf, int max) +{ + 4b90: 55 push %ebp + 4b91: 89 e5 mov %esp,%ebp + 4b93: 57 push %edi + 4b94: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 4b95: 31 f6 xor %esi,%esi +{ + 4b97: 53 push %ebx + 4b98: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 4b9b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 4b9e: eb 31 jmp 4bd1 + cc = read(0, &c, 1); + 4ba0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 4ba7: 00 + 4ba8: 89 7c 24 04 mov %edi,0x4(%esp) + 4bac: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 4bb3: e8 02 01 00 00 call 4cba + if(cc < 1) + 4bb8: 85 c0 test %eax,%eax + 4bba: 7e 1d jle 4bd9 + break; + buf[i++] = c; + 4bbc: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 4bc0: 89 de mov %ebx,%esi + buf[i++] = c; + 4bc2: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 4bc5: 3c 0d cmp $0xd,%al + buf[i++] = c; + 4bc7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 4bcb: 74 0c je 4bd9 + 4bcd: 3c 0a cmp $0xa,%al + 4bcf: 74 08 je 4bd9 + for(i=0; i+1 < max; ){ + 4bd1: 8d 5e 01 lea 0x1(%esi),%ebx + 4bd4: 3b 5d 0c cmp 0xc(%ebp),%ebx + 4bd7: 7c c7 jl 4ba0 + break; + } + buf[i] = '\0'; + 4bd9: 8b 45 08 mov 0x8(%ebp),%eax + 4bdc: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 4be0: 83 c4 2c add $0x2c,%esp + 4be3: 5b pop %ebx + 4be4: 5e pop %esi + 4be5: 5f pop %edi + 4be6: 5d pop %ebp + 4be7: c3 ret + 4be8: 90 nop + 4be9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00004bf0 : + +int +stat(char *n, struct stat *st) +{ + 4bf0: 55 push %ebp + 4bf1: 89 e5 mov %esp,%ebp + 4bf3: 56 push %esi + 4bf4: 53 push %ebx + 4bf5: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 4bf8: 8b 45 08 mov 0x8(%ebp),%eax + 4bfb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 4c02: 00 + 4c03: 89 04 24 mov %eax,(%esp) + 4c06: e8 d7 00 00 00 call 4ce2 + if(fd < 0) + 4c0b: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 4c0d: 89 c3 mov %eax,%ebx + if(fd < 0) + 4c0f: 78 27 js 4c38 + return -1; + r = fstat(fd, st); + 4c11: 8b 45 0c mov 0xc(%ebp),%eax + 4c14: 89 1c 24 mov %ebx,(%esp) + 4c17: 89 44 24 04 mov %eax,0x4(%esp) + 4c1b: e8 da 00 00 00 call 4cfa + close(fd); + 4c20: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 4c23: 89 c6 mov %eax,%esi + close(fd); + 4c25: e8 a0 00 00 00 call 4cca + return r; + 4c2a: 89 f0 mov %esi,%eax +} + 4c2c: 83 c4 10 add $0x10,%esp + 4c2f: 5b pop %ebx + 4c30: 5e pop %esi + 4c31: 5d pop %ebp + 4c32: c3 ret + 4c33: 90 nop + 4c34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 4c38: b8 ff ff ff ff mov $0xffffffff,%eax + 4c3d: eb ed jmp 4c2c + 4c3f: 90 nop + +00004c40 : + +int +atoi(const char *s) +{ + 4c40: 55 push %ebp + 4c41: 89 e5 mov %esp,%ebp + 4c43: 8b 4d 08 mov 0x8(%ebp),%ecx + 4c46: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 4c47: 0f be 11 movsbl (%ecx),%edx + 4c4a: 8d 42 d0 lea -0x30(%edx),%eax + 4c4d: 3c 09 cmp $0x9,%al + n = 0; + 4c4f: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 4c54: 77 17 ja 4c6d + 4c56: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 4c58: 83 c1 01 add $0x1,%ecx + 4c5b: 8d 04 80 lea (%eax,%eax,4),%eax + 4c5e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 4c62: 0f be 11 movsbl (%ecx),%edx + 4c65: 8d 5a d0 lea -0x30(%edx),%ebx + 4c68: 80 fb 09 cmp $0x9,%bl + 4c6b: 76 eb jbe 4c58 + return n; +} + 4c6d: 5b pop %ebx + 4c6e: 5d pop %ebp + 4c6f: c3 ret + +00004c70 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 4c70: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 4c71: 31 d2 xor %edx,%edx +{ + 4c73: 89 e5 mov %esp,%ebp + 4c75: 56 push %esi + 4c76: 8b 45 08 mov 0x8(%ebp),%eax + 4c79: 53 push %ebx + 4c7a: 8b 5d 10 mov 0x10(%ebp),%ebx + 4c7d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 4c80: 85 db test %ebx,%ebx + 4c82: 7e 12 jle 4c96 + 4c84: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 4c88: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 4c8c: 88 0c 10 mov %cl,(%eax,%edx,1) + 4c8f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 4c92: 39 da cmp %ebx,%edx + 4c94: 75 f2 jne 4c88 + return vdst; +} + 4c96: 5b pop %ebx + 4c97: 5e pop %esi + 4c98: 5d pop %ebp + 4c99: c3 ret + +00004c9a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 4c9a: b8 01 00 00 00 mov $0x1,%eax + 4c9f: cd 40 int $0x40 + 4ca1: c3 ret + +00004ca2 : +SYSCALL(exit) + 4ca2: b8 02 00 00 00 mov $0x2,%eax + 4ca7: cd 40 int $0x40 + 4ca9: c3 ret + +00004caa : +SYSCALL(wait) + 4caa: b8 03 00 00 00 mov $0x3,%eax + 4caf: cd 40 int $0x40 + 4cb1: c3 ret + +00004cb2 : +SYSCALL(pipe) + 4cb2: b8 04 00 00 00 mov $0x4,%eax + 4cb7: cd 40 int $0x40 + 4cb9: c3 ret + +00004cba : +SYSCALL(read) + 4cba: b8 05 00 00 00 mov $0x5,%eax + 4cbf: cd 40 int $0x40 + 4cc1: c3 ret + +00004cc2 : +SYSCALL(write) + 4cc2: b8 10 00 00 00 mov $0x10,%eax + 4cc7: cd 40 int $0x40 + 4cc9: c3 ret + +00004cca : +SYSCALL(close) + 4cca: b8 15 00 00 00 mov $0x15,%eax + 4ccf: cd 40 int $0x40 + 4cd1: c3 ret + +00004cd2 : +SYSCALL(kill) + 4cd2: b8 06 00 00 00 mov $0x6,%eax + 4cd7: cd 40 int $0x40 + 4cd9: c3 ret + +00004cda : +SYSCALL(exec) + 4cda: b8 07 00 00 00 mov $0x7,%eax + 4cdf: cd 40 int $0x40 + 4ce1: c3 ret + +00004ce2 : +SYSCALL(open) + 4ce2: b8 0f 00 00 00 mov $0xf,%eax + 4ce7: cd 40 int $0x40 + 4ce9: c3 ret + +00004cea : +SYSCALL(mknod) + 4cea: b8 11 00 00 00 mov $0x11,%eax + 4cef: cd 40 int $0x40 + 4cf1: c3 ret + +00004cf2 : +SYSCALL(unlink) + 4cf2: b8 12 00 00 00 mov $0x12,%eax + 4cf7: cd 40 int $0x40 + 4cf9: c3 ret + +00004cfa : +SYSCALL(fstat) + 4cfa: b8 08 00 00 00 mov $0x8,%eax + 4cff: cd 40 int $0x40 + 4d01: c3 ret + +00004d02 : +SYSCALL(link) + 4d02: b8 13 00 00 00 mov $0x13,%eax + 4d07: cd 40 int $0x40 + 4d09: c3 ret + +00004d0a : +SYSCALL(mkdir) + 4d0a: b8 14 00 00 00 mov $0x14,%eax + 4d0f: cd 40 int $0x40 + 4d11: c3 ret + +00004d12 : +SYSCALL(chdir) + 4d12: b8 09 00 00 00 mov $0x9,%eax + 4d17: cd 40 int $0x40 + 4d19: c3 ret + +00004d1a : +SYSCALL(dup) + 4d1a: b8 0a 00 00 00 mov $0xa,%eax + 4d1f: cd 40 int $0x40 + 4d21: c3 ret + +00004d22 : +SYSCALL(getpid) + 4d22: b8 0b 00 00 00 mov $0xb,%eax + 4d27: cd 40 int $0x40 + 4d29: c3 ret + +00004d2a : +SYSCALL(sbrk) + 4d2a: b8 0c 00 00 00 mov $0xc,%eax + 4d2f: cd 40 int $0x40 + 4d31: c3 ret + +00004d32 : +SYSCALL(sleep) + 4d32: b8 0d 00 00 00 mov $0xd,%eax + 4d37: cd 40 int $0x40 + 4d39: c3 ret + +00004d3a : +SYSCALL(uptime) + 4d3a: b8 0e 00 00 00 mov $0xe,%eax + 4d3f: cd 40 int $0x40 + 4d41: c3 ret + +00004d42 : +SYSCALL(shm_open) + 4d42: b8 16 00 00 00 mov $0x16,%eax + 4d47: cd 40 int $0x40 + 4d49: c3 ret + +00004d4a : +SYSCALL(shm_close) + 4d4a: b8 17 00 00 00 mov $0x17,%eax + 4d4f: cd 40 int $0x40 + 4d51: c3 ret + 4d52: 66 90 xchg %ax,%ax + 4d54: 66 90 xchg %ax,%ax + 4d56: 66 90 xchg %ax,%ax + 4d58: 66 90 xchg %ax,%ax + 4d5a: 66 90 xchg %ax,%ax + 4d5c: 66 90 xchg %ax,%ax + 4d5e: 66 90 xchg %ax,%ax + +00004d60 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 4d60: 55 push %ebp + 4d61: 89 e5 mov %esp,%ebp + 4d63: 57 push %edi + 4d64: 56 push %esi + 4d65: 89 c6 mov %eax,%esi + 4d67: 53 push %ebx + 4d68: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 4d6b: 8b 5d 08 mov 0x8(%ebp),%ebx + 4d6e: 85 db test %ebx,%ebx + 4d70: 74 09 je 4d7b + 4d72: 89 d0 mov %edx,%eax + 4d74: c1 e8 1f shr $0x1f,%eax + 4d77: 84 c0 test %al,%al + 4d79: 75 75 jne 4df0 + neg = 1; + x = -xx; + } else { + x = xx; + 4d7b: 89 d0 mov %edx,%eax + neg = 0; + 4d7d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 4d84: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 4d87: 31 ff xor %edi,%edi + 4d89: 89 ce mov %ecx,%esi + 4d8b: 8d 5d d7 lea -0x29(%ebp),%ebx + 4d8e: eb 02 jmp 4d92 + do{ + buf[i++] = digits[x % base]; + 4d90: 89 cf mov %ecx,%edi + 4d92: 31 d2 xor %edx,%edx + 4d94: f7 f6 div %esi + 4d96: 8d 4f 01 lea 0x1(%edi),%ecx + 4d99: 0f b6 92 43 69 00 00 movzbl 0x6943(%edx),%edx + }while((x /= base) != 0); + 4da0: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 4da2: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 4da5: 75 e9 jne 4d90 + if(neg) + 4da7: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 4daa: 89 c8 mov %ecx,%eax + 4dac: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 4daf: 85 d2 test %edx,%edx + 4db1: 74 08 je 4dbb + buf[i++] = '-'; + 4db3: 8d 4f 02 lea 0x2(%edi),%ecx + 4db6: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 4dbb: 8d 79 ff lea -0x1(%ecx),%edi + 4dbe: 66 90 xchg %ax,%ax + 4dc0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 4dc5: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 4dc8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 4dcf: 00 + 4dd0: 89 5c 24 04 mov %ebx,0x4(%esp) + 4dd4: 89 34 24 mov %esi,(%esp) + 4dd7: 88 45 d7 mov %al,-0x29(%ebp) + 4dda: e8 e3 fe ff ff call 4cc2 + while(--i >= 0) + 4ddf: 83 ff ff cmp $0xffffffff,%edi + 4de2: 75 dc jne 4dc0 + putc(fd, buf[i]); +} + 4de4: 83 c4 4c add $0x4c,%esp + 4de7: 5b pop %ebx + 4de8: 5e pop %esi + 4de9: 5f pop %edi + 4dea: 5d pop %ebp + 4deb: c3 ret + 4dec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 4df0: 89 d0 mov %edx,%eax + 4df2: f7 d8 neg %eax + neg = 1; + 4df4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 4dfb: eb 87 jmp 4d84 + 4dfd: 8d 76 00 lea 0x0(%esi),%esi + +00004e00 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 4e00: 55 push %ebp + 4e01: 89 e5 mov %esp,%ebp + 4e03: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 4e04: 31 ff xor %edi,%edi +{ + 4e06: 56 push %esi + 4e07: 53 push %ebx + 4e08: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 4e0b: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 4e0e: 8d 45 10 lea 0x10(%ebp),%eax +{ + 4e11: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 4e14: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 4e17: 0f b6 13 movzbl (%ebx),%edx + 4e1a: 83 c3 01 add $0x1,%ebx + 4e1d: 84 d2 test %dl,%dl + 4e1f: 75 39 jne 4e5a + 4e21: e9 c2 00 00 00 jmp 4ee8 + 4e26: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 4e28: 83 fa 25 cmp $0x25,%edx + 4e2b: 0f 84 bf 00 00 00 je 4ef0 + write(fd, &c, 1); + 4e31: 8d 45 e2 lea -0x1e(%ebp),%eax + 4e34: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 4e3b: 00 + 4e3c: 89 44 24 04 mov %eax,0x4(%esp) + 4e40: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 4e43: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 4e46: e8 77 fe ff ff call 4cc2 + 4e4b: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 4e4e: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 4e52: 84 d2 test %dl,%dl + 4e54: 0f 84 8e 00 00 00 je 4ee8 + if(state == 0){ + 4e5a: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 4e5c: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 4e5f: 74 c7 je 4e28 + } + } else if(state == '%'){ + 4e61: 83 ff 25 cmp $0x25,%edi + 4e64: 75 e5 jne 4e4b + if(c == 'd'){ + 4e66: 83 fa 64 cmp $0x64,%edx + 4e69: 0f 84 31 01 00 00 je 4fa0 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 4e6f: 25 f7 00 00 00 and $0xf7,%eax + 4e74: 83 f8 70 cmp $0x70,%eax + 4e77: 0f 84 83 00 00 00 je 4f00 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 4e7d: 83 fa 73 cmp $0x73,%edx + 4e80: 0f 84 a2 00 00 00 je 4f28 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 4e86: 83 fa 63 cmp $0x63,%edx + 4e89: 0f 84 35 01 00 00 je 4fc4 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 4e8f: 83 fa 25 cmp $0x25,%edx + 4e92: 0f 84 e0 00 00 00 je 4f78 + write(fd, &c, 1); + 4e98: 8d 45 e6 lea -0x1a(%ebp),%eax + 4e9b: 83 c3 01 add $0x1,%ebx + 4e9e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 4ea5: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 4ea6: 31 ff xor %edi,%edi + write(fd, &c, 1); + 4ea8: 89 44 24 04 mov %eax,0x4(%esp) + 4eac: 89 34 24 mov %esi,(%esp) + 4eaf: 89 55 d0 mov %edx,-0x30(%ebp) + 4eb2: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 4eb6: e8 07 fe ff ff call 4cc2 + putc(fd, c); + 4ebb: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 4ebe: 8d 45 e7 lea -0x19(%ebp),%eax + 4ec1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 4ec8: 00 + 4ec9: 89 44 24 04 mov %eax,0x4(%esp) + 4ecd: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 4ed0: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 4ed3: e8 ea fd ff ff call 4cc2 + for(i = 0; fmt[i]; i++){ + 4ed8: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 4edc: 84 d2 test %dl,%dl + 4ede: 0f 85 76 ff ff ff jne 4e5a + 4ee4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 4ee8: 83 c4 3c add $0x3c,%esp + 4eeb: 5b pop %ebx + 4eec: 5e pop %esi + 4eed: 5f pop %edi + 4eee: 5d pop %ebp + 4eef: c3 ret + state = '%'; + 4ef0: bf 25 00 00 00 mov $0x25,%edi + 4ef5: e9 51 ff ff ff jmp 4e4b + 4efa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 4f00: 8b 45 d4 mov -0x2c(%ebp),%eax + 4f03: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 4f08: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 4f0a: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 4f11: 8b 10 mov (%eax),%edx + 4f13: 89 f0 mov %esi,%eax + 4f15: e8 46 fe ff ff call 4d60 + ap++; + 4f1a: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 4f1e: e9 28 ff ff ff jmp 4e4b + 4f23: 90 nop + 4f24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 4f28: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 4f2b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 4f2f: 8b 38 mov (%eax),%edi + s = "(null)"; + 4f31: b8 3c 69 00 00 mov $0x693c,%eax + 4f36: 85 ff test %edi,%edi + 4f38: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 4f3b: 0f b6 07 movzbl (%edi),%eax + 4f3e: 84 c0 test %al,%al + 4f40: 74 2a je 4f6c + 4f42: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 4f48: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 4f4b: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 4f4e: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 4f51: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 4f58: 00 + 4f59: 89 44 24 04 mov %eax,0x4(%esp) + 4f5d: 89 34 24 mov %esi,(%esp) + 4f60: e8 5d fd ff ff call 4cc2 + while(*s != 0){ + 4f65: 0f b6 07 movzbl (%edi),%eax + 4f68: 84 c0 test %al,%al + 4f6a: 75 dc jne 4f48 + state = 0; + 4f6c: 31 ff xor %edi,%edi + 4f6e: e9 d8 fe ff ff jmp 4e4b + 4f73: 90 nop + 4f74: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 4f78: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 4f7b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 4f7d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 4f84: 00 + 4f85: 89 44 24 04 mov %eax,0x4(%esp) + 4f89: 89 34 24 mov %esi,(%esp) + 4f8c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 4f90: e8 2d fd ff ff call 4cc2 + 4f95: e9 b1 fe ff ff jmp 4e4b + 4f9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 4fa0: 8b 45 d4 mov -0x2c(%ebp),%eax + 4fa3: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 4fa8: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 4fab: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 4fb2: 8b 10 mov (%eax),%edx + 4fb4: 89 f0 mov %esi,%eax + 4fb6: e8 a5 fd ff ff call 4d60 + ap++; + 4fbb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 4fbf: e9 87 fe ff ff jmp 4e4b + putc(fd, *ap); + 4fc4: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 4fc7: 31 ff xor %edi,%edi + putc(fd, *ap); + 4fc9: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 4fcb: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 4fd2: 00 + 4fd3: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 4fd6: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 4fd9: 8d 45 e4 lea -0x1c(%ebp),%eax + 4fdc: 89 44 24 04 mov %eax,0x4(%esp) + 4fe0: e8 dd fc ff ff call 4cc2 + ap++; + 4fe5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 4fe9: e9 5d fe ff ff jmp 4e4b + 4fee: 66 90 xchg %ax,%ax + +00004ff0 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 4ff0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 4ff1: a1 00 73 00 00 mov 0x7300,%eax +{ + 4ff6: 89 e5 mov %esp,%ebp + 4ff8: 57 push %edi + 4ff9: 56 push %esi + 4ffa: 53 push %ebx + 4ffb: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 4ffe: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 5000: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 5003: 39 d0 cmp %edx,%eax + 5005: 72 11 jb 5018 + 5007: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 5008: 39 c8 cmp %ecx,%eax + 500a: 72 04 jb 5010 + 500c: 39 ca cmp %ecx,%edx + 500e: 72 10 jb 5020 + 5010: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 5012: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 5014: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 5016: 73 f0 jae 5008 + 5018: 39 ca cmp %ecx,%edx + 501a: 72 04 jb 5020 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 501c: 39 c8 cmp %ecx,%eax + 501e: 72 f0 jb 5010 + break; + if(bp + bp->s.size == p->s.ptr){ + 5020: 8b 73 fc mov -0x4(%ebx),%esi + 5023: 8d 3c f2 lea (%edx,%esi,8),%edi + 5026: 39 cf cmp %ecx,%edi + 5028: 74 1e je 5048 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 502a: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 502d: 8b 48 04 mov 0x4(%eax),%ecx + 5030: 8d 34 c8 lea (%eax,%ecx,8),%esi + 5033: 39 f2 cmp %esi,%edx + 5035: 74 28 je 505f + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 5037: 89 10 mov %edx,(%eax) + freep = p; + 5039: a3 00 73 00 00 mov %eax,0x7300 +} + 503e: 5b pop %ebx + 503f: 5e pop %esi + 5040: 5f pop %edi + 5041: 5d pop %ebp + 5042: c3 ret + 5043: 90 nop + 5044: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 5048: 03 71 04 add 0x4(%ecx),%esi + 504b: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 504e: 8b 08 mov (%eax),%ecx + 5050: 8b 09 mov (%ecx),%ecx + 5052: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 5055: 8b 48 04 mov 0x4(%eax),%ecx + 5058: 8d 34 c8 lea (%eax,%ecx,8),%esi + 505b: 39 f2 cmp %esi,%edx + 505d: 75 d8 jne 5037 + p->s.size += bp->s.size; + 505f: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 5062: a3 00 73 00 00 mov %eax,0x7300 + p->s.size += bp->s.size; + 5067: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 506a: 8b 53 f8 mov -0x8(%ebx),%edx + 506d: 89 10 mov %edx,(%eax) +} + 506f: 5b pop %ebx + 5070: 5e pop %esi + 5071: 5f pop %edi + 5072: 5d pop %ebp + 5073: c3 ret + 5074: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 507a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00005080 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 5080: 55 push %ebp + 5081: 89 e5 mov %esp,%ebp + 5083: 57 push %edi + 5084: 56 push %esi + 5085: 53 push %ebx + 5086: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 5089: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 508c: 8b 1d 00 73 00 00 mov 0x7300,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 5092: 8d 48 07 lea 0x7(%eax),%ecx + 5095: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 5098: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 509a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 509d: 0f 84 9b 00 00 00 je 513e + 50a3: 8b 13 mov (%ebx),%edx + 50a5: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 50a8: 39 fe cmp %edi,%esi + 50aa: 76 64 jbe 5110 + 50ac: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 50b3: bb 00 80 00 00 mov $0x8000,%ebx + 50b8: 89 45 e4 mov %eax,-0x1c(%ebp) + 50bb: eb 0e jmp 50cb + 50bd: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 50c0: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 50c2: 8b 78 04 mov 0x4(%eax),%edi + 50c5: 39 fe cmp %edi,%esi + 50c7: 76 4f jbe 5118 + 50c9: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 50cb: 3b 15 00 73 00 00 cmp 0x7300,%edx + 50d1: 75 ed jne 50c0 + if(nu < 4096) + 50d3: 8b 45 e4 mov -0x1c(%ebp),%eax + 50d6: 81 fe 00 10 00 00 cmp $0x1000,%esi + 50dc: bf 00 10 00 00 mov $0x1000,%edi + 50e1: 0f 43 fe cmovae %esi,%edi + 50e4: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 50e7: 89 04 24 mov %eax,(%esp) + 50ea: e8 3b fc ff ff call 4d2a + if(p == (char*)-1) + 50ef: 83 f8 ff cmp $0xffffffff,%eax + 50f2: 74 18 je 510c + hp->s.size = nu; + 50f4: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 50f7: 83 c0 08 add $0x8,%eax + 50fa: 89 04 24 mov %eax,(%esp) + 50fd: e8 ee fe ff ff call 4ff0 + return freep; + 5102: 8b 15 00 73 00 00 mov 0x7300,%edx + if((p = morecore(nunits)) == 0) + 5108: 85 d2 test %edx,%edx + 510a: 75 b4 jne 50c0 + return 0; + 510c: 31 c0 xor %eax,%eax + 510e: eb 20 jmp 5130 + if(p->s.size >= nunits){ + 5110: 89 d0 mov %edx,%eax + 5112: 89 da mov %ebx,%edx + 5114: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 5118: 39 fe cmp %edi,%esi + 511a: 74 1c je 5138 + p->s.size -= nunits; + 511c: 29 f7 sub %esi,%edi + 511e: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 5121: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 5124: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 5127: 89 15 00 73 00 00 mov %edx,0x7300 + return (void*)(p + 1); + 512d: 83 c0 08 add $0x8,%eax + } +} + 5130: 83 c4 1c add $0x1c,%esp + 5133: 5b pop %ebx + 5134: 5e pop %esi + 5135: 5f pop %edi + 5136: 5d pop %ebp + 5137: c3 ret + prevp->s.ptr = p->s.ptr; + 5138: 8b 08 mov (%eax),%ecx + 513a: 89 0a mov %ecx,(%edx) + 513c: eb e9 jmp 5127 + base.s.ptr = freep = prevp = &base; + 513e: c7 05 00 73 00 00 04 movl $0x7304,0x7300 + 5145: 73 00 00 + base.s.size = 0; + 5148: ba 04 73 00 00 mov $0x7304,%edx + base.s.ptr = freep = prevp = &base; + 514d: c7 05 04 73 00 00 04 movl $0x7304,0x7304 + 5154: 73 00 00 + base.s.size = 0; + 5157: c7 05 08 73 00 00 00 movl $0x0,0x7308 + 515e: 00 00 00 + 5161: e9 46 ff ff ff jmp 50ac + 5166: 66 90 xchg %ax,%ax + 5168: 66 90 xchg %ax,%ax + 516a: 66 90 xchg %ax,%ax + 516c: 66 90 xchg %ax,%ax + 516e: 66 90 xchg %ax,%ax + +00005170 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 5170: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 5171: b9 01 00 00 00 mov $0x1,%ecx + 5176: 89 e5 mov %esp,%ebp + 5178: 8b 55 08 mov 0x8(%ebp),%edx + 517b: 90 nop + 517c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 5180: 89 c8 mov %ecx,%eax + 5182: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 5185: 85 c0 test %eax,%eax + 5187: 75 f7 jne 5180 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 5189: 0f ae f0 mfence +} + 518c: 5d pop %ebp + 518d: c3 ret + 518e: 66 90 xchg %ax,%ax + +00005190 : + +void urelease (struct uspinlock *lk) { + 5190: 55 push %ebp + 5191: 89 e5 mov %esp,%ebp + 5193: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 5196: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 5199: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 519f: 5d pop %ebp + 51a0: c3 ret diff --git a/usertests.d b/usertests.d new file mode 100644 index 00000000..a4933d35 --- /dev/null +++ b/usertests.d @@ -0,0 +1,2 @@ +usertests.o: usertests.c /usr/include/stdc-predef.h param.h types.h \ + stat.h user.h fs.h fcntl.h syscall.h traps.h memlayout.h diff --git a/usertests.o b/usertests.o new file mode 100644 index 00000000..90d81b4a Binary files /dev/null and b/usertests.o differ diff --git a/usertests.sym b/usertests.sym new file mode 100644 index 00000000..01544043 --- /dev/null +++ b/usertests.sym @@ -0,0 +1,108 @@ +00001000 .text +000051a4 .rodata +00006954 .eh_frame +0000725c .data +00007280 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 usertests.c +00007280 args.1723 +00000000 ulib.c +00000000 printf.c +00004d60 printint +00006943 digits.1359 +00000000 umalloc.c +00007300 freep +00007304 base +00000000 uspinlock.c +00004a80 strcpy +00001db0 exitwait +00004e00 printf +00007260 stdout +00004650 bigargtest +00004c70 memmove +00001300 openiputtest +00004cea mknod +00004d42 shm_open +00004b90 gets +00004d22 getpid +00001a90 pipe1 +00003ec0 iref +00005080 malloc +00004d32 sleep +00001210 exitiputtest +00004760 fsfull +00002db0 bigdir +00003fe0 forktest +000016c0 writetest1 +00003690 bigwrite +00001f20 sharedfd +0000725c randstate +00004cb2 pipe +00007320 uninit +00003c80 dirfile +00004cc2 write +000045d0 bsstest +00007264 echoargv +00004cfa fstat +00004cd2 kill +00004520 validatetest +00003af0 rmdot +00004d12 chdir +00001a40 exectest +00004cda exec +00004caa wait +00004a60 rand +00004cba read +00001c50 preempt +00004cf2 unlink +000049e0 argptest +00005170 uacquire +00001e40 mem +00004c9a fork +00004d2a sbrk +00004d4a shm_close +00004d3a uptime +00007278 __bss_start +00004b30 memset +000018b0 createtest +00001000 main +00002310 createdelete +00004ab0 strcmp +000014b0 writetest +00004d1a dup +000040b0 sbrktest +00001410 opentest +00002f00 subdir +00004960 uio +00002720 linktest +00009a40 buf +00001960 dirtest +00001130 iputtest +00004bf0 stat +00003790 bigfile +00007278 _edata +0000ba44 _end +00002550 unlinkread +00004d02 link +00004ca2 exit +00004c40 atoi +00002ca0 linkunlink +0000ba40 name +00004b00 strlen +00004ce2 open +00004b50 strchr +00002980 concreate +00003990 fourteen +00004510 validateint +00002100 fourfiles +00004d0a mkdir +00004cca close +00005190 urelease +00004ff0 free diff --git a/uspinlock.d b/uspinlock.d new file mode 100644 index 00000000..23a956c5 --- /dev/null +++ b/uspinlock.d @@ -0,0 +1,2 @@ +uspinlock.o: uspinlock.c /usr/include/stdc-predef.h types.h uspinlock.h \ + x86.h diff --git a/uspinlock.o b/uspinlock.o new file mode 100644 index 00000000..f0ab14c6 Binary files /dev/null and b/uspinlock.o differ diff --git a/usys.o b/usys.o new file mode 100644 index 00000000..d55b1634 Binary files /dev/null and b/usys.o differ diff --git a/vectors.S b/vectors.S new file mode 100644 index 00000000..9e4041ab --- /dev/null +++ b/vectors.S @@ -0,0 +1,1537 @@ +# generated by vectors.pl - do not edit +# handlers +.globl alltraps +.globl vector0 +vector0: + pushl $0 + pushl $0 + jmp alltraps +.globl vector1 +vector1: + pushl $0 + pushl $1 + jmp alltraps +.globl vector2 +vector2: + pushl $0 + pushl $2 + jmp alltraps +.globl vector3 +vector3: + pushl $0 + pushl $3 + jmp alltraps +.globl vector4 +vector4: + pushl $0 + pushl $4 + jmp alltraps +.globl vector5 +vector5: + pushl $0 + pushl $5 + jmp alltraps +.globl vector6 +vector6: + pushl $0 + pushl $6 + jmp alltraps +.globl vector7 +vector7: + pushl $0 + pushl $7 + jmp alltraps +.globl vector8 +vector8: + pushl $8 + jmp alltraps +.globl vector9 +vector9: + pushl $0 + pushl $9 + jmp alltraps +.globl vector10 +vector10: + pushl $10 + jmp alltraps +.globl vector11 +vector11: + pushl $11 + jmp alltraps +.globl vector12 +vector12: + pushl $12 + jmp alltraps +.globl vector13 +vector13: + pushl $13 + jmp alltraps +.globl vector14 +vector14: + pushl $14 + jmp alltraps +.globl vector15 +vector15: + pushl $0 + pushl $15 + jmp alltraps +.globl vector16 +vector16: + pushl $0 + pushl $16 + jmp alltraps +.globl vector17 +vector17: + pushl $17 + jmp alltraps +.globl vector18 +vector18: + pushl $0 + pushl $18 + jmp alltraps +.globl vector19 +vector19: + pushl $0 + pushl $19 + jmp alltraps +.globl vector20 +vector20: + pushl $0 + pushl $20 + jmp alltraps +.globl vector21 +vector21: + pushl $0 + pushl $21 + jmp alltraps +.globl vector22 +vector22: + pushl $0 + pushl $22 + jmp alltraps +.globl vector23 +vector23: + pushl $0 + pushl $23 + jmp alltraps +.globl vector24 +vector24: + pushl $0 + pushl $24 + jmp alltraps +.globl vector25 +vector25: + pushl $0 + pushl $25 + jmp alltraps +.globl vector26 +vector26: + pushl $0 + pushl $26 + jmp alltraps +.globl vector27 +vector27: + pushl $0 + pushl $27 + jmp alltraps +.globl vector28 +vector28: + pushl $0 + pushl $28 + jmp alltraps +.globl vector29 +vector29: + pushl $0 + pushl $29 + jmp alltraps +.globl vector30 +vector30: + pushl $0 + pushl $30 + jmp alltraps +.globl vector31 +vector31: + pushl $0 + pushl $31 + jmp alltraps +.globl vector32 +vector32: + pushl $0 + pushl $32 + jmp alltraps +.globl vector33 +vector33: + pushl $0 + pushl $33 + jmp alltraps +.globl vector34 +vector34: + pushl $0 + pushl $34 + jmp alltraps +.globl vector35 +vector35: + pushl $0 + pushl $35 + jmp alltraps +.globl vector36 +vector36: + pushl $0 + pushl $36 + jmp alltraps +.globl vector37 +vector37: + pushl $0 + pushl $37 + jmp alltraps +.globl vector38 +vector38: + pushl $0 + pushl $38 + jmp alltraps +.globl vector39 +vector39: + pushl $0 + pushl $39 + jmp alltraps +.globl vector40 +vector40: + pushl $0 + pushl $40 + jmp alltraps +.globl vector41 +vector41: + pushl $0 + pushl $41 + jmp alltraps +.globl vector42 +vector42: + pushl $0 + pushl $42 + jmp alltraps +.globl vector43 +vector43: + pushl $0 + pushl $43 + jmp alltraps +.globl vector44 +vector44: + pushl $0 + pushl $44 + jmp alltraps +.globl vector45 +vector45: + pushl $0 + pushl $45 + jmp alltraps +.globl vector46 +vector46: + pushl $0 + pushl $46 + jmp alltraps +.globl vector47 +vector47: + pushl $0 + pushl $47 + jmp alltraps +.globl vector48 +vector48: + pushl $0 + pushl $48 + jmp alltraps +.globl vector49 +vector49: + pushl $0 + pushl $49 + jmp alltraps +.globl vector50 +vector50: + pushl $0 + pushl $50 + jmp alltraps +.globl vector51 +vector51: + pushl $0 + pushl $51 + jmp alltraps +.globl vector52 +vector52: + pushl $0 + pushl $52 + jmp alltraps +.globl vector53 +vector53: + pushl $0 + pushl $53 + jmp alltraps +.globl vector54 +vector54: + pushl $0 + pushl $54 + jmp alltraps +.globl vector55 +vector55: + pushl $0 + pushl $55 + jmp alltraps +.globl vector56 +vector56: + pushl $0 + pushl $56 + jmp alltraps +.globl vector57 +vector57: + pushl $0 + pushl $57 + jmp alltraps +.globl vector58 +vector58: + pushl $0 + pushl $58 + jmp alltraps +.globl vector59 +vector59: + pushl $0 + pushl $59 + jmp alltraps +.globl vector60 +vector60: + pushl $0 + pushl $60 + jmp alltraps +.globl vector61 +vector61: + pushl $0 + pushl $61 + jmp alltraps +.globl vector62 +vector62: + pushl $0 + pushl $62 + jmp alltraps +.globl vector63 +vector63: + pushl $0 + pushl $63 + jmp alltraps +.globl vector64 +vector64: + pushl $0 + pushl $64 + jmp alltraps +.globl vector65 +vector65: + pushl $0 + pushl $65 + jmp alltraps +.globl vector66 +vector66: + pushl $0 + pushl $66 + jmp alltraps +.globl vector67 +vector67: + pushl $0 + pushl $67 + jmp alltraps +.globl vector68 +vector68: + pushl $0 + pushl $68 + jmp alltraps +.globl vector69 +vector69: + pushl $0 + pushl $69 + jmp alltraps +.globl vector70 +vector70: + pushl $0 + pushl $70 + jmp alltraps +.globl vector71 +vector71: + pushl $0 + pushl $71 + jmp alltraps +.globl vector72 +vector72: + pushl $0 + pushl $72 + jmp alltraps +.globl vector73 +vector73: + pushl $0 + pushl $73 + jmp alltraps +.globl vector74 +vector74: + pushl $0 + pushl $74 + jmp alltraps +.globl vector75 +vector75: + pushl $0 + pushl $75 + jmp alltraps +.globl vector76 +vector76: + pushl $0 + pushl $76 + jmp alltraps +.globl vector77 +vector77: + pushl $0 + pushl $77 + jmp alltraps +.globl vector78 +vector78: + pushl $0 + pushl $78 + jmp alltraps +.globl vector79 +vector79: + pushl $0 + pushl $79 + jmp alltraps +.globl vector80 +vector80: + pushl $0 + pushl $80 + jmp alltraps +.globl vector81 +vector81: + pushl $0 + pushl $81 + jmp alltraps +.globl vector82 +vector82: + pushl $0 + pushl $82 + jmp alltraps +.globl vector83 +vector83: + pushl $0 + pushl $83 + jmp alltraps +.globl vector84 +vector84: + pushl $0 + pushl $84 + jmp alltraps +.globl vector85 +vector85: + pushl $0 + pushl $85 + jmp alltraps +.globl vector86 +vector86: + pushl $0 + pushl $86 + jmp alltraps +.globl vector87 +vector87: + pushl $0 + pushl $87 + jmp alltraps +.globl vector88 +vector88: + pushl $0 + pushl $88 + jmp alltraps +.globl vector89 +vector89: + pushl $0 + pushl $89 + jmp alltraps +.globl vector90 +vector90: + pushl $0 + pushl $90 + jmp alltraps +.globl vector91 +vector91: + pushl $0 + pushl $91 + jmp alltraps +.globl vector92 +vector92: + pushl $0 + pushl $92 + jmp alltraps +.globl vector93 +vector93: + pushl $0 + pushl $93 + jmp alltraps +.globl vector94 +vector94: + pushl $0 + pushl $94 + jmp alltraps +.globl vector95 +vector95: + pushl $0 + pushl $95 + jmp alltraps +.globl vector96 +vector96: + pushl $0 + pushl $96 + jmp alltraps +.globl vector97 +vector97: + pushl $0 + pushl $97 + jmp alltraps +.globl vector98 +vector98: + pushl $0 + pushl $98 + jmp alltraps +.globl vector99 +vector99: + pushl $0 + pushl $99 + jmp alltraps +.globl vector100 +vector100: + pushl $0 + pushl $100 + jmp alltraps +.globl vector101 +vector101: + pushl $0 + pushl $101 + jmp alltraps +.globl vector102 +vector102: + pushl $0 + pushl $102 + jmp alltraps +.globl vector103 +vector103: + pushl $0 + pushl $103 + jmp alltraps +.globl vector104 +vector104: + pushl $0 + pushl $104 + jmp alltraps +.globl vector105 +vector105: + pushl $0 + pushl $105 + jmp alltraps +.globl vector106 +vector106: + pushl $0 + pushl $106 + jmp alltraps +.globl vector107 +vector107: + pushl $0 + pushl $107 + jmp alltraps +.globl vector108 +vector108: + pushl $0 + pushl $108 + jmp alltraps +.globl vector109 +vector109: + pushl $0 + pushl $109 + jmp alltraps +.globl vector110 +vector110: + pushl $0 + pushl $110 + jmp alltraps +.globl vector111 +vector111: + pushl $0 + pushl $111 + jmp alltraps +.globl vector112 +vector112: + pushl $0 + pushl $112 + jmp alltraps +.globl vector113 +vector113: + pushl $0 + pushl $113 + jmp alltraps +.globl vector114 +vector114: + pushl $0 + pushl $114 + jmp alltraps +.globl vector115 +vector115: + pushl $0 + pushl $115 + jmp alltraps +.globl vector116 +vector116: + pushl $0 + pushl $116 + jmp alltraps +.globl vector117 +vector117: + pushl $0 + pushl $117 + jmp alltraps +.globl vector118 +vector118: + pushl $0 + pushl $118 + jmp alltraps +.globl vector119 +vector119: + pushl $0 + pushl $119 + jmp alltraps +.globl vector120 +vector120: + pushl $0 + pushl $120 + jmp alltraps +.globl vector121 +vector121: + pushl $0 + pushl $121 + jmp alltraps +.globl vector122 +vector122: + pushl $0 + pushl $122 + jmp alltraps +.globl vector123 +vector123: + pushl $0 + pushl $123 + jmp alltraps +.globl vector124 +vector124: + pushl $0 + pushl $124 + jmp alltraps +.globl vector125 +vector125: + pushl $0 + pushl $125 + jmp alltraps +.globl vector126 +vector126: + pushl $0 + pushl $126 + jmp alltraps +.globl vector127 +vector127: + pushl $0 + pushl $127 + jmp alltraps +.globl vector128 +vector128: + pushl $0 + pushl $128 + jmp alltraps +.globl vector129 +vector129: + pushl $0 + pushl $129 + jmp alltraps +.globl vector130 +vector130: + pushl $0 + pushl $130 + jmp alltraps +.globl vector131 +vector131: + pushl $0 + pushl $131 + jmp alltraps +.globl vector132 +vector132: + pushl $0 + pushl $132 + jmp alltraps +.globl vector133 +vector133: + pushl $0 + pushl $133 + jmp alltraps +.globl vector134 +vector134: + pushl $0 + pushl $134 + jmp alltraps +.globl vector135 +vector135: + pushl $0 + pushl $135 + jmp alltraps +.globl vector136 +vector136: + pushl $0 + pushl $136 + jmp alltraps +.globl vector137 +vector137: + pushl $0 + pushl $137 + jmp alltraps +.globl vector138 +vector138: + pushl $0 + pushl $138 + jmp alltraps +.globl vector139 +vector139: + pushl $0 + pushl $139 + jmp alltraps +.globl vector140 +vector140: + pushl $0 + pushl $140 + jmp alltraps +.globl vector141 +vector141: + pushl $0 + pushl $141 + jmp alltraps +.globl vector142 +vector142: + pushl $0 + pushl $142 + jmp alltraps +.globl vector143 +vector143: + pushl $0 + pushl $143 + jmp alltraps +.globl vector144 +vector144: + pushl $0 + pushl $144 + jmp alltraps +.globl vector145 +vector145: + pushl $0 + pushl $145 + jmp alltraps +.globl vector146 +vector146: + pushl $0 + pushl $146 + jmp alltraps +.globl vector147 +vector147: + pushl $0 + pushl $147 + jmp alltraps +.globl vector148 +vector148: + pushl $0 + pushl $148 + jmp alltraps +.globl vector149 +vector149: + pushl $0 + pushl $149 + jmp alltraps +.globl vector150 +vector150: + pushl $0 + pushl $150 + jmp alltraps +.globl vector151 +vector151: + pushl $0 + pushl $151 + jmp alltraps +.globl vector152 +vector152: + pushl $0 + pushl $152 + jmp alltraps +.globl vector153 +vector153: + pushl $0 + pushl $153 + jmp alltraps +.globl vector154 +vector154: + pushl $0 + pushl $154 + jmp alltraps +.globl vector155 +vector155: + pushl $0 + pushl $155 + jmp alltraps +.globl vector156 +vector156: + pushl $0 + pushl $156 + jmp alltraps +.globl vector157 +vector157: + pushl $0 + pushl $157 + jmp alltraps +.globl vector158 +vector158: + pushl $0 + pushl $158 + jmp alltraps +.globl vector159 +vector159: + pushl $0 + pushl $159 + jmp alltraps +.globl vector160 +vector160: + pushl $0 + pushl $160 + jmp alltraps +.globl vector161 +vector161: + pushl $0 + pushl $161 + jmp alltraps +.globl vector162 +vector162: + pushl $0 + pushl $162 + jmp alltraps +.globl vector163 +vector163: + pushl $0 + pushl $163 + jmp alltraps +.globl vector164 +vector164: + pushl $0 + pushl $164 + jmp alltraps +.globl vector165 +vector165: + pushl $0 + pushl $165 + jmp alltraps +.globl vector166 +vector166: + pushl $0 + pushl $166 + jmp alltraps +.globl vector167 +vector167: + pushl $0 + pushl $167 + jmp alltraps +.globl vector168 +vector168: + pushl $0 + pushl $168 + jmp alltraps +.globl vector169 +vector169: + pushl $0 + pushl $169 + jmp alltraps +.globl vector170 +vector170: + pushl $0 + pushl $170 + jmp alltraps +.globl vector171 +vector171: + pushl $0 + pushl $171 + jmp alltraps +.globl vector172 +vector172: + pushl $0 + pushl $172 + jmp alltraps +.globl vector173 +vector173: + pushl $0 + pushl $173 + jmp alltraps +.globl vector174 +vector174: + pushl $0 + pushl $174 + jmp alltraps +.globl vector175 +vector175: + pushl $0 + pushl $175 + jmp alltraps +.globl vector176 +vector176: + pushl $0 + pushl $176 + jmp alltraps +.globl vector177 +vector177: + pushl $0 + pushl $177 + jmp alltraps +.globl vector178 +vector178: + pushl $0 + pushl $178 + jmp alltraps +.globl vector179 +vector179: + pushl $0 + pushl $179 + jmp alltraps +.globl vector180 +vector180: + pushl $0 + pushl $180 + jmp alltraps +.globl vector181 +vector181: + pushl $0 + pushl $181 + jmp alltraps +.globl vector182 +vector182: + pushl $0 + pushl $182 + jmp alltraps +.globl vector183 +vector183: + pushl $0 + pushl $183 + jmp alltraps +.globl vector184 +vector184: + pushl $0 + pushl $184 + jmp alltraps +.globl vector185 +vector185: + pushl $0 + pushl $185 + jmp alltraps +.globl vector186 +vector186: + pushl $0 + pushl $186 + jmp alltraps +.globl vector187 +vector187: + pushl $0 + pushl $187 + jmp alltraps +.globl vector188 +vector188: + pushl $0 + pushl $188 + jmp alltraps +.globl vector189 +vector189: + pushl $0 + pushl $189 + jmp alltraps +.globl vector190 +vector190: + pushl $0 + pushl $190 + jmp alltraps +.globl vector191 +vector191: + pushl $0 + pushl $191 + jmp alltraps +.globl vector192 +vector192: + pushl $0 + pushl $192 + jmp alltraps +.globl vector193 +vector193: + pushl $0 + pushl $193 + jmp alltraps +.globl vector194 +vector194: + pushl $0 + pushl $194 + jmp alltraps +.globl vector195 +vector195: + pushl $0 + pushl $195 + jmp alltraps +.globl vector196 +vector196: + pushl $0 + pushl $196 + jmp alltraps +.globl vector197 +vector197: + pushl $0 + pushl $197 + jmp alltraps +.globl vector198 +vector198: + pushl $0 + pushl $198 + jmp alltraps +.globl vector199 +vector199: + pushl $0 + pushl $199 + jmp alltraps +.globl vector200 +vector200: + pushl $0 + pushl $200 + jmp alltraps +.globl vector201 +vector201: + pushl $0 + pushl $201 + jmp alltraps +.globl vector202 +vector202: + pushl $0 + pushl $202 + jmp alltraps +.globl vector203 +vector203: + pushl $0 + pushl $203 + jmp alltraps +.globl vector204 +vector204: + pushl $0 + pushl $204 + jmp alltraps +.globl vector205 +vector205: + pushl $0 + pushl $205 + jmp alltraps +.globl vector206 +vector206: + pushl $0 + pushl $206 + jmp alltraps +.globl vector207 +vector207: + pushl $0 + pushl $207 + jmp alltraps +.globl vector208 +vector208: + pushl $0 + pushl $208 + jmp alltraps +.globl vector209 +vector209: + pushl $0 + pushl $209 + jmp alltraps +.globl vector210 +vector210: + pushl $0 + pushl $210 + jmp alltraps +.globl vector211 +vector211: + pushl $0 + pushl $211 + jmp alltraps +.globl vector212 +vector212: + pushl $0 + pushl $212 + jmp alltraps +.globl vector213 +vector213: + pushl $0 + pushl $213 + jmp alltraps +.globl vector214 +vector214: + pushl $0 + pushl $214 + jmp alltraps +.globl vector215 +vector215: + pushl $0 + pushl $215 + jmp alltraps +.globl vector216 +vector216: + pushl $0 + pushl $216 + jmp alltraps +.globl vector217 +vector217: + pushl $0 + pushl $217 + jmp alltraps +.globl vector218 +vector218: + pushl $0 + pushl $218 + jmp alltraps +.globl vector219 +vector219: + pushl $0 + pushl $219 + jmp alltraps +.globl vector220 +vector220: + pushl $0 + pushl $220 + jmp alltraps +.globl vector221 +vector221: + pushl $0 + pushl $221 + jmp alltraps +.globl vector222 +vector222: + pushl $0 + pushl $222 + jmp alltraps +.globl vector223 +vector223: + pushl $0 + pushl $223 + jmp alltraps +.globl vector224 +vector224: + pushl $0 + pushl $224 + jmp alltraps +.globl vector225 +vector225: + pushl $0 + pushl $225 + jmp alltraps +.globl vector226 +vector226: + pushl $0 + pushl $226 + jmp alltraps +.globl vector227 +vector227: + pushl $0 + pushl $227 + jmp alltraps +.globl vector228 +vector228: + pushl $0 + pushl $228 + jmp alltraps +.globl vector229 +vector229: + pushl $0 + pushl $229 + jmp alltraps +.globl vector230 +vector230: + pushl $0 + pushl $230 + jmp alltraps +.globl vector231 +vector231: + pushl $0 + pushl $231 + jmp alltraps +.globl vector232 +vector232: + pushl $0 + pushl $232 + jmp alltraps +.globl vector233 +vector233: + pushl $0 + pushl $233 + jmp alltraps +.globl vector234 +vector234: + pushl $0 + pushl $234 + jmp alltraps +.globl vector235 +vector235: + pushl $0 + pushl $235 + jmp alltraps +.globl vector236 +vector236: + pushl $0 + pushl $236 + jmp alltraps +.globl vector237 +vector237: + pushl $0 + pushl $237 + jmp alltraps +.globl vector238 +vector238: + pushl $0 + pushl $238 + jmp alltraps +.globl vector239 +vector239: + pushl $0 + pushl $239 + jmp alltraps +.globl vector240 +vector240: + pushl $0 + pushl $240 + jmp alltraps +.globl vector241 +vector241: + pushl $0 + pushl $241 + jmp alltraps +.globl vector242 +vector242: + pushl $0 + pushl $242 + jmp alltraps +.globl vector243 +vector243: + pushl $0 + pushl $243 + jmp alltraps +.globl vector244 +vector244: + pushl $0 + pushl $244 + jmp alltraps +.globl vector245 +vector245: + pushl $0 + pushl $245 + jmp alltraps +.globl vector246 +vector246: + pushl $0 + pushl $246 + jmp alltraps +.globl vector247 +vector247: + pushl $0 + pushl $247 + jmp alltraps +.globl vector248 +vector248: + pushl $0 + pushl $248 + jmp alltraps +.globl vector249 +vector249: + pushl $0 + pushl $249 + jmp alltraps +.globl vector250 +vector250: + pushl $0 + pushl $250 + jmp alltraps +.globl vector251 +vector251: + pushl $0 + pushl $251 + jmp alltraps +.globl vector252 +vector252: + pushl $0 + pushl $252 + jmp alltraps +.globl vector253 +vector253: + pushl $0 + pushl $253 + jmp alltraps +.globl vector254 +vector254: + pushl $0 + pushl $254 + jmp alltraps +.globl vector255 +vector255: + pushl $0 + pushl $255 + jmp alltraps + +# vector table +.data +.globl vectors +vectors: + .long vector0 + .long vector1 + .long vector2 + .long vector3 + .long vector4 + .long vector5 + .long vector6 + .long vector7 + .long vector8 + .long vector9 + .long vector10 + .long vector11 + .long vector12 + .long vector13 + .long vector14 + .long vector15 + .long vector16 + .long vector17 + .long vector18 + .long vector19 + .long vector20 + .long vector21 + .long vector22 + .long vector23 + .long vector24 + .long vector25 + .long vector26 + .long vector27 + .long vector28 + .long vector29 + .long vector30 + .long vector31 + .long vector32 + .long vector33 + .long vector34 + .long vector35 + .long vector36 + .long vector37 + .long vector38 + .long vector39 + .long vector40 + .long vector41 + .long vector42 + .long vector43 + .long vector44 + .long vector45 + .long vector46 + .long vector47 + .long vector48 + .long vector49 + .long vector50 + .long vector51 + .long vector52 + .long vector53 + .long vector54 + .long vector55 + .long vector56 + .long vector57 + .long vector58 + .long vector59 + .long vector60 + .long vector61 + .long vector62 + .long vector63 + .long vector64 + .long vector65 + .long vector66 + .long vector67 + .long vector68 + .long vector69 + .long vector70 + .long vector71 + .long vector72 + .long vector73 + .long vector74 + .long vector75 + .long vector76 + .long vector77 + .long vector78 + .long vector79 + .long vector80 + .long vector81 + .long vector82 + .long vector83 + .long vector84 + .long vector85 + .long vector86 + .long vector87 + .long vector88 + .long vector89 + .long vector90 + .long vector91 + .long vector92 + .long vector93 + .long vector94 + .long vector95 + .long vector96 + .long vector97 + .long vector98 + .long vector99 + .long vector100 + .long vector101 + .long vector102 + .long vector103 + .long vector104 + .long vector105 + .long vector106 + .long vector107 + .long vector108 + .long vector109 + .long vector110 + .long vector111 + .long vector112 + .long vector113 + .long vector114 + .long vector115 + .long vector116 + .long vector117 + .long vector118 + .long vector119 + .long vector120 + .long vector121 + .long vector122 + .long vector123 + .long vector124 + .long vector125 + .long vector126 + .long vector127 + .long vector128 + .long vector129 + .long vector130 + .long vector131 + .long vector132 + .long vector133 + .long vector134 + .long vector135 + .long vector136 + .long vector137 + .long vector138 + .long vector139 + .long vector140 + .long vector141 + .long vector142 + .long vector143 + .long vector144 + .long vector145 + .long vector146 + .long vector147 + .long vector148 + .long vector149 + .long vector150 + .long vector151 + .long vector152 + .long vector153 + .long vector154 + .long vector155 + .long vector156 + .long vector157 + .long vector158 + .long vector159 + .long vector160 + .long vector161 + .long vector162 + .long vector163 + .long vector164 + .long vector165 + .long vector166 + .long vector167 + .long vector168 + .long vector169 + .long vector170 + .long vector171 + .long vector172 + .long vector173 + .long vector174 + .long vector175 + .long vector176 + .long vector177 + .long vector178 + .long vector179 + .long vector180 + .long vector181 + .long vector182 + .long vector183 + .long vector184 + .long vector185 + .long vector186 + .long vector187 + .long vector188 + .long vector189 + .long vector190 + .long vector191 + .long vector192 + .long vector193 + .long vector194 + .long vector195 + .long vector196 + .long vector197 + .long vector198 + .long vector199 + .long vector200 + .long vector201 + .long vector202 + .long vector203 + .long vector204 + .long vector205 + .long vector206 + .long vector207 + .long vector208 + .long vector209 + .long vector210 + .long vector211 + .long vector212 + .long vector213 + .long vector214 + .long vector215 + .long vector216 + .long vector217 + .long vector218 + .long vector219 + .long vector220 + .long vector221 + .long vector222 + .long vector223 + .long vector224 + .long vector225 + .long vector226 + .long vector227 + .long vector228 + .long vector229 + .long vector230 + .long vector231 + .long vector232 + .long vector233 + .long vector234 + .long vector235 + .long vector236 + .long vector237 + .long vector238 + .long vector239 + .long vector240 + .long vector241 + .long vector242 + .long vector243 + .long vector244 + .long vector245 + .long vector246 + .long vector247 + .long vector248 + .long vector249 + .long vector250 + .long vector251 + .long vector252 + .long vector253 + .long vector254 + .long vector255 diff --git a/vectors.o b/vectors.o new file mode 100644 index 00000000..0562d200 Binary files /dev/null and b/vectors.o differ diff --git a/vm.c b/vm.c index f623aa3c..80c61ce5 100644 --- a/vm.c +++ b/vm.c @@ -57,7 +57,7 @@ walkpgdir(pde_t *pgdir, const void *va, int alloc) // Create PTEs for virtual addresses starting at va that refer to // physical addresses starting at pa. va and size might not // be page-aligned. -int +static int mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) { char *a, *last; @@ -224,7 +224,7 @@ allocuvm(pde_t *pgdir, uint oldsz, uint newsz) char *mem; uint a; - if(newsz >= KERNBASE) + if(newsz > KERNBASE) return 0; if(newsz < oldsz) return oldsz; @@ -312,8 +312,10 @@ clearpteu(pde_t *pgdir, char *uva) // Given a parent process's page table, create a copy // of it for a child. + +// ** added unit arg pde_t* -copyuvm(pde_t *pgdir, uint sz) +copyuvm(pde_t *pgdir, uint sz, uint num_pages) { pde_t *d; pte_t *pte; @@ -323,6 +325,23 @@ copyuvm(pde_t *pgdir, uint sz) if((d = setupkvm()) == 0) return 0; for(i = 0; i < sz; i += PGSIZE){ + if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) + panic("copyuvm: pte should exist"); + if(!(*pte & PTE_P)) + panic("copyuvm: page not present"); + pa = PTE_ADDR(*pte); + flags = PTE_FLAGS(*pte); + if((mem = kalloc()) == 0) + goto bad; + memmove(mem, (char*)P2V(pa), PGSIZE); + if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) { + kfree(mem); + goto bad; + } + } + + // ** Added a for loop to keep track of the stack similar to the for loop above it + for(i = KERNBASE - (num_pages * PGSIZE * 2); i < KERNBASE; i += PGSIZE){ if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) panic("copyuvm: pte should exist"); if(!(*pte & PTE_P)) @@ -335,6 +354,7 @@ copyuvm(pde_t *pgdir, uint sz) if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) goto bad; } + return d; bad: diff --git a/vm.d b/vm.d new file mode 100644 index 00000000..51631b19 --- /dev/null +++ b/vm.d @@ -0,0 +1,2 @@ +vm.o: vm.c /usr/include/stdc-predef.h param.h types.h defs.h x86.h \ + memlayout.h mmu.h proc.h elf.h diff --git a/vm.o b/vm.o new file mode 100644 index 00000000..78c559ea Binary files /dev/null and b/vm.o differ diff --git a/wc.asm b/wc.asm new file mode 100644 index 00000000..34b877e7 --- /dev/null +++ b/wc.asm @@ -0,0 +1,1356 @@ + +_wc: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: + printf(1, "%d %d %d %s\n", l, w, c, name); +} + +int +main(int argc, char *argv[]) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 57 push %edi + 1004: 56 push %esi + int fd, i; + + if(argc <= 1){ + 1005: be 01 00 00 00 mov $0x1,%esi +{ + 100a: 53 push %ebx + 100b: 83 e4 f0 and $0xfffffff0,%esp + 100e: 83 ec 10 sub $0x10,%esp + 1011: 8b 45 0c mov 0xc(%ebp),%eax + if(argc <= 1){ + 1014: 83 7d 08 01 cmpl $0x1,0x8(%ebp) + 1018: 8d 58 04 lea 0x4(%eax),%ebx + 101b: 7e 60 jle 107d + 101d: 8d 76 00 lea 0x0(%esi),%esi + wc(0, ""); + exit(); + } + + for(i = 1; i < argc; i++){ + if((fd = open(argv[i], 0)) < 0){ + 1020: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1027: 00 + 1028: 8b 03 mov (%ebx),%eax + 102a: 89 04 24 mov %eax,(%esp) + 102d: e8 c0 03 00 00 call 13f2 + 1032: 85 c0 test %eax,%eax + 1034: 89 c7 mov %eax,%edi + 1036: 78 26 js 105e + printf(1, "wc: cannot open %s\n", argv[i]); + exit(); + } + wc(fd, argv[i]); + 1038: 8b 13 mov (%ebx),%edx + for(i = 1; i < argc; i++){ + 103a: 83 c6 01 add $0x1,%esi + 103d: 83 c3 04 add $0x4,%ebx + wc(fd, argv[i]); + 1040: 89 04 24 mov %eax,(%esp) + 1043: 89 54 24 04 mov %edx,0x4(%esp) + 1047: e8 54 00 00 00 call 10a0 + close(fd); + 104c: 89 3c 24 mov %edi,(%esp) + 104f: e8 86 03 00 00 call 13da + for(i = 1; i < argc; i++){ + 1054: 3b 75 08 cmp 0x8(%ebp),%esi + 1057: 75 c7 jne 1020 + } + exit(); + 1059: e8 54 03 00 00 call 13b2 + printf(1, "wc: cannot open %s\n", argv[i]); + 105e: 8b 03 mov (%ebx),%eax + 1060: c7 44 24 04 d4 18 00 movl $0x18d4,0x4(%esp) + 1067: 00 + 1068: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 106f: 89 44 24 08 mov %eax,0x8(%esp) + 1073: e8 98 04 00 00 call 1510 + exit(); + 1078: e8 35 03 00 00 call 13b2 + wc(0, ""); + 107d: c7 44 24 04 c6 18 00 movl $0x18c6,0x4(%esp) + 1084: 00 + 1085: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 108c: e8 0f 00 00 00 call 10a0 + exit(); + 1091: e8 1c 03 00 00 call 13b2 + 1096: 66 90 xchg %ax,%ax + 1098: 66 90 xchg %ax,%ax + 109a: 66 90 xchg %ax,%ax + 109c: 66 90 xchg %ax,%ax + 109e: 66 90 xchg %ax,%ax + +000010a0 : +{ + 10a0: 55 push %ebp + 10a1: 89 e5 mov %esp,%ebp + 10a3: 57 push %edi + 10a4: 56 push %esi + inword = 0; + 10a5: 31 f6 xor %esi,%esi +{ + 10a7: 53 push %ebx + l = w = c = 0; + 10a8: 31 db xor %ebx,%ebx +{ + 10aa: 83 ec 3c sub $0x3c,%esp + l = w = c = 0; + 10ad: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) + 10b4: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) + 10bb: 90 nop + 10bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + while((n = read(fd, buf, sizeof(buf))) > 0){ + 10c0: 8b 45 08 mov 0x8(%ebp),%eax + 10c3: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) + 10ca: 00 + 10cb: c7 44 24 04 00 1c 00 movl $0x1c00,0x4(%esp) + 10d2: 00 + 10d3: 89 04 24 mov %eax,(%esp) + 10d6: e8 ef 02 00 00 call 13ca + 10db: 83 f8 00 cmp $0x0,%eax + 10de: 89 45 e4 mov %eax,-0x1c(%ebp) + 10e1: 7e 54 jle 1137 + 10e3: 31 ff xor %edi,%edi + 10e5: eb 0b jmp 10f2 + 10e7: 90 nop + inword = 0; + 10e8: 31 f6 xor %esi,%esi + for(i=0; i + if(buf[i] == '\n') + 10f2: 0f be 87 00 1c 00 00 movsbl 0x1c00(%edi),%eax + l++; + 10f9: 31 c9 xor %ecx,%ecx + if(strchr(" \r\t\n\v", buf[i])) + 10fb: c7 04 24 b1 18 00 00 movl $0x18b1,(%esp) + l++; + 1102: 3c 0a cmp $0xa,%al + 1104: 0f 94 c1 sete %cl + if(strchr(" \r\t\n\v", buf[i])) + 1107: 89 44 24 04 mov %eax,0x4(%esp) + l++; + 110b: 01 cb add %ecx,%ebx + if(strchr(" \r\t\n\v", buf[i])) + 110d: e8 4e 01 00 00 call 1260 + 1112: 85 c0 test %eax,%eax + 1114: 75 d2 jne 10e8 + else if(!inword){ + 1116: 85 f6 test %esi,%esi + 1118: 75 16 jne 1130 + w++; + 111a: 83 45 e0 01 addl $0x1,-0x20(%ebp) + for(i=0; i + 112a: 01 7d dc add %edi,-0x24(%ebp) + 112d: eb 91 jmp 10c0 + 112f: 90 nop + 1130: be 01 00 00 00 mov $0x1,%esi + 1135: eb b3 jmp 10ea + if(n < 0){ + 1137: 75 35 jne 116e + printf(1, "%d %d %d %s\n", l, w, c, name); + 1139: 8b 45 0c mov 0xc(%ebp),%eax + 113c: 89 5c 24 08 mov %ebx,0x8(%esp) + 1140: c7 44 24 04 c7 18 00 movl $0x18c7,0x4(%esp) + 1147: 00 + 1148: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 114f: 89 44 24 14 mov %eax,0x14(%esp) + 1153: 8b 45 dc mov -0x24(%ebp),%eax + 1156: 89 44 24 10 mov %eax,0x10(%esp) + 115a: 8b 45 e0 mov -0x20(%ebp),%eax + 115d: 89 44 24 0c mov %eax,0xc(%esp) + 1161: e8 aa 03 00 00 call 1510 +} + 1166: 83 c4 3c add $0x3c,%esp + 1169: 5b pop %ebx + 116a: 5e pop %esi + 116b: 5f pop %edi + 116c: 5d pop %ebp + 116d: c3 ret + printf(1, "wc: read error\n"); + 116e: c7 44 24 04 b7 18 00 movl $0x18b7,0x4(%esp) + 1175: 00 + 1176: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 117d: e8 8e 03 00 00 call 1510 + exit(); + 1182: e8 2b 02 00 00 call 13b2 + 1187: 66 90 xchg %ax,%ax + 1189: 66 90 xchg %ax,%ax + 118b: 66 90 xchg %ax,%ax + 118d: 66 90 xchg %ax,%ax + 118f: 90 nop + +00001190 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1190: 55 push %ebp + 1191: 89 e5 mov %esp,%ebp + 1193: 8b 45 08 mov 0x8(%ebp),%eax + 1196: 8b 4d 0c mov 0xc(%ebp),%ecx + 1199: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 119a: 89 c2 mov %eax,%edx + 119c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 11a0: 83 c1 01 add $0x1,%ecx + 11a3: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 11a7: 83 c2 01 add $0x1,%edx + 11aa: 84 db test %bl,%bl + 11ac: 88 5a ff mov %bl,-0x1(%edx) + 11af: 75 ef jne 11a0 + ; + return os; +} + 11b1: 5b pop %ebx + 11b2: 5d pop %ebp + 11b3: c3 ret + 11b4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 11ba: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +000011c0 : + +int +strcmp(const char *p, const char *q) +{ + 11c0: 55 push %ebp + 11c1: 89 e5 mov %esp,%ebp + 11c3: 8b 55 08 mov 0x8(%ebp),%edx + 11c6: 53 push %ebx + 11c7: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 11ca: 0f b6 02 movzbl (%edx),%eax + 11cd: 84 c0 test %al,%al + 11cf: 74 2d je 11fe + 11d1: 0f b6 19 movzbl (%ecx),%ebx + 11d4: 38 d8 cmp %bl,%al + 11d6: 74 0e je 11e6 + 11d8: eb 2b jmp 1205 + 11da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 11e0: 38 c8 cmp %cl,%al + 11e2: 75 15 jne 11f9 + p++, q++; + 11e4: 89 d9 mov %ebx,%ecx + 11e6: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 11e9: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 11ec: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 11ef: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 11f3: 84 c0 test %al,%al + 11f5: 75 e9 jne 11e0 + 11f7: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 11f9: 29 c8 sub %ecx,%eax +} + 11fb: 5b pop %ebx + 11fc: 5d pop %ebp + 11fd: c3 ret + 11fe: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 1201: 31 c0 xor %eax,%eax + 1203: eb f4 jmp 11f9 + 1205: 0f b6 cb movzbl %bl,%ecx + 1208: eb ef jmp 11f9 + 120a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +00001210 : + +uint +strlen(char *s) +{ + 1210: 55 push %ebp + 1211: 89 e5 mov %esp,%ebp + 1213: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 1216: 80 39 00 cmpb $0x0,(%ecx) + 1219: 74 12 je 122d + 121b: 31 d2 xor %edx,%edx + 121d: 8d 76 00 lea 0x0(%esi),%esi + 1220: 83 c2 01 add $0x1,%edx + 1223: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 1227: 89 d0 mov %edx,%eax + 1229: 75 f5 jne 1220 + ; + return n; +} + 122b: 5d pop %ebp + 122c: c3 ret + for(n = 0; s[n]; n++) + 122d: 31 c0 xor %eax,%eax +} + 122f: 5d pop %ebp + 1230: c3 ret + 1231: eb 0d jmp 1240 + 1233: 90 nop + 1234: 90 nop + 1235: 90 nop + 1236: 90 nop + 1237: 90 nop + 1238: 90 nop + 1239: 90 nop + 123a: 90 nop + 123b: 90 nop + 123c: 90 nop + 123d: 90 nop + 123e: 90 nop + 123f: 90 nop + +00001240 : + +void* +memset(void *dst, int c, uint n) +{ + 1240: 55 push %ebp + 1241: 89 e5 mov %esp,%ebp + 1243: 8b 55 08 mov 0x8(%ebp),%edx + 1246: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 1247: 8b 4d 10 mov 0x10(%ebp),%ecx + 124a: 8b 45 0c mov 0xc(%ebp),%eax + 124d: 89 d7 mov %edx,%edi + 124f: fc cld + 1250: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 1252: 89 d0 mov %edx,%eax + 1254: 5f pop %edi + 1255: 5d pop %ebp + 1256: c3 ret + 1257: 89 f6 mov %esi,%esi + 1259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001260 : + +char* +strchr(const char *s, char c) +{ + 1260: 55 push %ebp + 1261: 89 e5 mov %esp,%ebp + 1263: 8b 45 08 mov 0x8(%ebp),%eax + 1266: 53 push %ebx + 1267: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 126a: 0f b6 18 movzbl (%eax),%ebx + 126d: 84 db test %bl,%bl + 126f: 74 1d je 128e + if(*s == c) + 1271: 38 d3 cmp %dl,%bl + 1273: 89 d1 mov %edx,%ecx + 1275: 75 0d jne 1284 + 1277: eb 17 jmp 1290 + 1279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1280: 38 ca cmp %cl,%dl + 1282: 74 0c je 1290 + for(; *s; s++) + 1284: 83 c0 01 add $0x1,%eax + 1287: 0f b6 10 movzbl (%eax),%edx + 128a: 84 d2 test %dl,%dl + 128c: 75 f2 jne 1280 + return (char*)s; + return 0; + 128e: 31 c0 xor %eax,%eax +} + 1290: 5b pop %ebx + 1291: 5d pop %ebp + 1292: c3 ret + 1293: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1299: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +000012a0 : + +char* +gets(char *buf, int max) +{ + 12a0: 55 push %ebp + 12a1: 89 e5 mov %esp,%ebp + 12a3: 57 push %edi + 12a4: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 12a5: 31 f6 xor %esi,%esi +{ + 12a7: 53 push %ebx + 12a8: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 12ab: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 12ae: eb 31 jmp 12e1 + cc = read(0, &c, 1); + 12b0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 12b7: 00 + 12b8: 89 7c 24 04 mov %edi,0x4(%esp) + 12bc: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 12c3: e8 02 01 00 00 call 13ca + if(cc < 1) + 12c8: 85 c0 test %eax,%eax + 12ca: 7e 1d jle 12e9 + break; + buf[i++] = c; + 12cc: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 12d0: 89 de mov %ebx,%esi + buf[i++] = c; + 12d2: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 12d5: 3c 0d cmp $0xd,%al + buf[i++] = c; + 12d7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 12db: 74 0c je 12e9 + 12dd: 3c 0a cmp $0xa,%al + 12df: 74 08 je 12e9 + for(i=0; i+1 < max; ){ + 12e1: 8d 5e 01 lea 0x1(%esi),%ebx + 12e4: 3b 5d 0c cmp 0xc(%ebp),%ebx + 12e7: 7c c7 jl 12b0 + break; + } + buf[i] = '\0'; + 12e9: 8b 45 08 mov 0x8(%ebp),%eax + 12ec: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 12f0: 83 c4 2c add $0x2c,%esp + 12f3: 5b pop %ebx + 12f4: 5e pop %esi + 12f5: 5f pop %edi + 12f6: 5d pop %ebp + 12f7: c3 ret + 12f8: 90 nop + 12f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +00001300 : + +int +stat(char *n, struct stat *st) +{ + 1300: 55 push %ebp + 1301: 89 e5 mov %esp,%ebp + 1303: 56 push %esi + 1304: 53 push %ebx + 1305: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 1308: 8b 45 08 mov 0x8(%ebp),%eax + 130b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 1312: 00 + 1313: 89 04 24 mov %eax,(%esp) + 1316: e8 d7 00 00 00 call 13f2 + if(fd < 0) + 131b: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 131d: 89 c3 mov %eax,%ebx + if(fd < 0) + 131f: 78 27 js 1348 + return -1; + r = fstat(fd, st); + 1321: 8b 45 0c mov 0xc(%ebp),%eax + 1324: 89 1c 24 mov %ebx,(%esp) + 1327: 89 44 24 04 mov %eax,0x4(%esp) + 132b: e8 da 00 00 00 call 140a + close(fd); + 1330: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 1333: 89 c6 mov %eax,%esi + close(fd); + 1335: e8 a0 00 00 00 call 13da + return r; + 133a: 89 f0 mov %esi,%eax +} + 133c: 83 c4 10 add $0x10,%esp + 133f: 5b pop %ebx + 1340: 5e pop %esi + 1341: 5d pop %ebp + 1342: c3 ret + 1343: 90 nop + 1344: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 1348: b8 ff ff ff ff mov $0xffffffff,%eax + 134d: eb ed jmp 133c + 134f: 90 nop + +00001350 : + +int +atoi(const char *s) +{ + 1350: 55 push %ebp + 1351: 89 e5 mov %esp,%ebp + 1353: 8b 4d 08 mov 0x8(%ebp),%ecx + 1356: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 1357: 0f be 11 movsbl (%ecx),%edx + 135a: 8d 42 d0 lea -0x30(%edx),%eax + 135d: 3c 09 cmp $0x9,%al + n = 0; + 135f: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 1364: 77 17 ja 137d + 1366: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 1368: 83 c1 01 add $0x1,%ecx + 136b: 8d 04 80 lea (%eax,%eax,4),%eax + 136e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1372: 0f be 11 movsbl (%ecx),%edx + 1375: 8d 5a d0 lea -0x30(%edx),%ebx + 1378: 80 fb 09 cmp $0x9,%bl + 137b: 76 eb jbe 1368 + return n; +} + 137d: 5b pop %ebx + 137e: 5d pop %ebp + 137f: c3 ret + +00001380 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1380: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1381: 31 d2 xor %edx,%edx +{ + 1383: 89 e5 mov %esp,%ebp + 1385: 56 push %esi + 1386: 8b 45 08 mov 0x8(%ebp),%eax + 1389: 53 push %ebx + 138a: 8b 5d 10 mov 0x10(%ebp),%ebx + 138d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1390: 85 db test %ebx,%ebx + 1392: 7e 12 jle 13a6 + 1394: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1398: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 139c: 88 0c 10 mov %cl,(%eax,%edx,1) + 139f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 13a2: 39 da cmp %ebx,%edx + 13a4: 75 f2 jne 1398 + return vdst; +} + 13a6: 5b pop %ebx + 13a7: 5e pop %esi + 13a8: 5d pop %ebp + 13a9: c3 ret + +000013aa : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 13aa: b8 01 00 00 00 mov $0x1,%eax + 13af: cd 40 int $0x40 + 13b1: c3 ret + +000013b2 : +SYSCALL(exit) + 13b2: b8 02 00 00 00 mov $0x2,%eax + 13b7: cd 40 int $0x40 + 13b9: c3 ret + +000013ba : +SYSCALL(wait) + 13ba: b8 03 00 00 00 mov $0x3,%eax + 13bf: cd 40 int $0x40 + 13c1: c3 ret + +000013c2 : +SYSCALL(pipe) + 13c2: b8 04 00 00 00 mov $0x4,%eax + 13c7: cd 40 int $0x40 + 13c9: c3 ret + +000013ca : +SYSCALL(read) + 13ca: b8 05 00 00 00 mov $0x5,%eax + 13cf: cd 40 int $0x40 + 13d1: c3 ret + +000013d2 : +SYSCALL(write) + 13d2: b8 10 00 00 00 mov $0x10,%eax + 13d7: cd 40 int $0x40 + 13d9: c3 ret + +000013da : +SYSCALL(close) + 13da: b8 15 00 00 00 mov $0x15,%eax + 13df: cd 40 int $0x40 + 13e1: c3 ret + +000013e2 : +SYSCALL(kill) + 13e2: b8 06 00 00 00 mov $0x6,%eax + 13e7: cd 40 int $0x40 + 13e9: c3 ret + +000013ea : +SYSCALL(exec) + 13ea: b8 07 00 00 00 mov $0x7,%eax + 13ef: cd 40 int $0x40 + 13f1: c3 ret + +000013f2 : +SYSCALL(open) + 13f2: b8 0f 00 00 00 mov $0xf,%eax + 13f7: cd 40 int $0x40 + 13f9: c3 ret + +000013fa : +SYSCALL(mknod) + 13fa: b8 11 00 00 00 mov $0x11,%eax + 13ff: cd 40 int $0x40 + 1401: c3 ret + +00001402 : +SYSCALL(unlink) + 1402: b8 12 00 00 00 mov $0x12,%eax + 1407: cd 40 int $0x40 + 1409: c3 ret + +0000140a : +SYSCALL(fstat) + 140a: b8 08 00 00 00 mov $0x8,%eax + 140f: cd 40 int $0x40 + 1411: c3 ret + +00001412 : +SYSCALL(link) + 1412: b8 13 00 00 00 mov $0x13,%eax + 1417: cd 40 int $0x40 + 1419: c3 ret + +0000141a : +SYSCALL(mkdir) + 141a: b8 14 00 00 00 mov $0x14,%eax + 141f: cd 40 int $0x40 + 1421: c3 ret + +00001422 : +SYSCALL(chdir) + 1422: b8 09 00 00 00 mov $0x9,%eax + 1427: cd 40 int $0x40 + 1429: c3 ret + +0000142a : +SYSCALL(dup) + 142a: b8 0a 00 00 00 mov $0xa,%eax + 142f: cd 40 int $0x40 + 1431: c3 ret + +00001432 : +SYSCALL(getpid) + 1432: b8 0b 00 00 00 mov $0xb,%eax + 1437: cd 40 int $0x40 + 1439: c3 ret + +0000143a : +SYSCALL(sbrk) + 143a: b8 0c 00 00 00 mov $0xc,%eax + 143f: cd 40 int $0x40 + 1441: c3 ret + +00001442 : +SYSCALL(sleep) + 1442: b8 0d 00 00 00 mov $0xd,%eax + 1447: cd 40 int $0x40 + 1449: c3 ret + +0000144a : +SYSCALL(uptime) + 144a: b8 0e 00 00 00 mov $0xe,%eax + 144f: cd 40 int $0x40 + 1451: c3 ret + +00001452 : +SYSCALL(shm_open) + 1452: b8 16 00 00 00 mov $0x16,%eax + 1457: cd 40 int $0x40 + 1459: c3 ret + +0000145a : +SYSCALL(shm_close) + 145a: b8 17 00 00 00 mov $0x17,%eax + 145f: cd 40 int $0x40 + 1461: c3 ret + 1462: 66 90 xchg %ax,%ax + 1464: 66 90 xchg %ax,%ax + 1466: 66 90 xchg %ax,%ax + 1468: 66 90 xchg %ax,%ax + 146a: 66 90 xchg %ax,%ax + 146c: 66 90 xchg %ax,%ax + 146e: 66 90 xchg %ax,%ax + +00001470 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 1470: 55 push %ebp + 1471: 89 e5 mov %esp,%ebp + 1473: 57 push %edi + 1474: 56 push %esi + 1475: 89 c6 mov %eax,%esi + 1477: 53 push %ebx + 1478: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 147b: 8b 5d 08 mov 0x8(%ebp),%ebx + 147e: 85 db test %ebx,%ebx + 1480: 74 09 je 148b + 1482: 89 d0 mov %edx,%eax + 1484: c1 e8 1f shr $0x1f,%eax + 1487: 84 c0 test %al,%al + 1489: 75 75 jne 1500 + neg = 1; + x = -xx; + } else { + x = xx; + 148b: 89 d0 mov %edx,%eax + neg = 0; + 148d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1494: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1497: 31 ff xor %edi,%edi + 1499: 89 ce mov %ecx,%esi + 149b: 8d 5d d7 lea -0x29(%ebp),%ebx + 149e: eb 02 jmp 14a2 + do{ + buf[i++] = digits[x % base]; + 14a0: 89 cf mov %ecx,%edi + 14a2: 31 d2 xor %edx,%edx + 14a4: f7 f6 div %esi + 14a6: 8d 4f 01 lea 0x1(%edi),%ecx + 14a9: 0f b6 92 ef 18 00 00 movzbl 0x18ef(%edx),%edx + }while((x /= base) != 0); + 14b0: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 14b2: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 14b5: 75 e9 jne 14a0 + if(neg) + 14b7: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 14ba: 89 c8 mov %ecx,%eax + 14bc: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 14bf: 85 d2 test %edx,%edx + 14c1: 74 08 je 14cb + buf[i++] = '-'; + 14c3: 8d 4f 02 lea 0x2(%edi),%ecx + 14c6: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 14cb: 8d 79 ff lea -0x1(%ecx),%edi + 14ce: 66 90 xchg %ax,%ax + 14d0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 14d5: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 14d8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 14df: 00 + 14e0: 89 5c 24 04 mov %ebx,0x4(%esp) + 14e4: 89 34 24 mov %esi,(%esp) + 14e7: 88 45 d7 mov %al,-0x29(%ebp) + 14ea: e8 e3 fe ff ff call 13d2 + while(--i >= 0) + 14ef: 83 ff ff cmp $0xffffffff,%edi + 14f2: 75 dc jne 14d0 + putc(fd, buf[i]); +} + 14f4: 83 c4 4c add $0x4c,%esp + 14f7: 5b pop %ebx + 14f8: 5e pop %esi + 14f9: 5f pop %edi + 14fa: 5d pop %ebp + 14fb: c3 ret + 14fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 1500: 89 d0 mov %edx,%eax + 1502: f7 d8 neg %eax + neg = 1; + 1504: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 150b: eb 87 jmp 1494 + 150d: 8d 76 00 lea 0x0(%esi),%esi + +00001510 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 1510: 55 push %ebp + 1511: 89 e5 mov %esp,%ebp + 1513: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 1514: 31 ff xor %edi,%edi +{ + 1516: 56 push %esi + 1517: 53 push %ebx + 1518: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 151b: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 151e: 8d 45 10 lea 0x10(%ebp),%eax +{ + 1521: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 1524: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 1527: 0f b6 13 movzbl (%ebx),%edx + 152a: 83 c3 01 add $0x1,%ebx + 152d: 84 d2 test %dl,%dl + 152f: 75 39 jne 156a + 1531: e9 c2 00 00 00 jmp 15f8 + 1536: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 1538: 83 fa 25 cmp $0x25,%edx + 153b: 0f 84 bf 00 00 00 je 1600 + write(fd, &c, 1); + 1541: 8d 45 e2 lea -0x1e(%ebp),%eax + 1544: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 154b: 00 + 154c: 89 44 24 04 mov %eax,0x4(%esp) + 1550: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 1553: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 1556: e8 77 fe ff ff call 13d2 + 155b: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 155e: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 1562: 84 d2 test %dl,%dl + 1564: 0f 84 8e 00 00 00 je 15f8 + if(state == 0){ + 156a: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 156c: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 156f: 74 c7 je 1538 + } + } else if(state == '%'){ + 1571: 83 ff 25 cmp $0x25,%edi + 1574: 75 e5 jne 155b + if(c == 'd'){ + 1576: 83 fa 64 cmp $0x64,%edx + 1579: 0f 84 31 01 00 00 je 16b0 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 157f: 25 f7 00 00 00 and $0xf7,%eax + 1584: 83 f8 70 cmp $0x70,%eax + 1587: 0f 84 83 00 00 00 je 1610 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 158d: 83 fa 73 cmp $0x73,%edx + 1590: 0f 84 a2 00 00 00 je 1638 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1596: 83 fa 63 cmp $0x63,%edx + 1599: 0f 84 35 01 00 00 je 16d4 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 159f: 83 fa 25 cmp $0x25,%edx + 15a2: 0f 84 e0 00 00 00 je 1688 + write(fd, &c, 1); + 15a8: 8d 45 e6 lea -0x1a(%ebp),%eax + 15ab: 83 c3 01 add $0x1,%ebx + 15ae: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 15b5: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 15b6: 31 ff xor %edi,%edi + write(fd, &c, 1); + 15b8: 89 44 24 04 mov %eax,0x4(%esp) + 15bc: 89 34 24 mov %esi,(%esp) + 15bf: 89 55 d0 mov %edx,-0x30(%ebp) + 15c2: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 15c6: e8 07 fe ff ff call 13d2 + putc(fd, c); + 15cb: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 15ce: 8d 45 e7 lea -0x19(%ebp),%eax + 15d1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 15d8: 00 + 15d9: 89 44 24 04 mov %eax,0x4(%esp) + 15dd: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 15e0: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 15e3: e8 ea fd ff ff call 13d2 + for(i = 0; fmt[i]; i++){ + 15e8: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 15ec: 84 d2 test %dl,%dl + 15ee: 0f 85 76 ff ff ff jne 156a + 15f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 15f8: 83 c4 3c add $0x3c,%esp + 15fb: 5b pop %ebx + 15fc: 5e pop %esi + 15fd: 5f pop %edi + 15fe: 5d pop %ebp + 15ff: c3 ret + state = '%'; + 1600: bf 25 00 00 00 mov $0x25,%edi + 1605: e9 51 ff ff ff jmp 155b + 160a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 1610: 8b 45 d4 mov -0x2c(%ebp),%eax + 1613: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 1618: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 161a: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1621: 8b 10 mov (%eax),%edx + 1623: 89 f0 mov %esi,%eax + 1625: e8 46 fe ff ff call 1470 + ap++; + 162a: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 162e: e9 28 ff ff ff jmp 155b + 1633: 90 nop + 1634: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 1638: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 163b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 163f: 8b 38 mov (%eax),%edi + s = "(null)"; + 1641: b8 e8 18 00 00 mov $0x18e8,%eax + 1646: 85 ff test %edi,%edi + 1648: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 164b: 0f b6 07 movzbl (%edi),%eax + 164e: 84 c0 test %al,%al + 1650: 74 2a je 167c + 1652: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1658: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 165b: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 165e: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 1661: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1668: 00 + 1669: 89 44 24 04 mov %eax,0x4(%esp) + 166d: 89 34 24 mov %esi,(%esp) + 1670: e8 5d fd ff ff call 13d2 + while(*s != 0){ + 1675: 0f b6 07 movzbl (%edi),%eax + 1678: 84 c0 test %al,%al + 167a: 75 dc jne 1658 + state = 0; + 167c: 31 ff xor %edi,%edi + 167e: e9 d8 fe ff ff jmp 155b + 1683: 90 nop + 1684: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1688: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 168b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 168d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1694: 00 + 1695: 89 44 24 04 mov %eax,0x4(%esp) + 1699: 89 34 24 mov %esi,(%esp) + 169c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 16a0: e8 2d fd ff ff call 13d2 + 16a5: e9 b1 fe ff ff jmp 155b + 16aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 16b0: 8b 45 d4 mov -0x2c(%ebp),%eax + 16b3: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 16b8: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 16bb: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 16c2: 8b 10 mov (%eax),%edx + 16c4: 89 f0 mov %esi,%eax + 16c6: e8 a5 fd ff ff call 1470 + ap++; + 16cb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 16cf: e9 87 fe ff ff jmp 155b + putc(fd, *ap); + 16d4: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 16d7: 31 ff xor %edi,%edi + putc(fd, *ap); + 16d9: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 16db: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 16e2: 00 + 16e3: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 16e6: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 16e9: 8d 45 e4 lea -0x1c(%ebp),%eax + 16ec: 89 44 24 04 mov %eax,0x4(%esp) + 16f0: e8 dd fc ff ff call 13d2 + ap++; + 16f5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 16f9: e9 5d fe ff ff jmp 155b + 16fe: 66 90 xchg %ax,%ax + +00001700 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 1700: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1701: a1 e0 1b 00 00 mov 0x1be0,%eax +{ + 1706: 89 e5 mov %esp,%ebp + 1708: 57 push %edi + 1709: 56 push %esi + 170a: 53 push %ebx + 170b: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 170e: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 1710: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1713: 39 d0 cmp %edx,%eax + 1715: 72 11 jb 1728 + 1717: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1718: 39 c8 cmp %ecx,%eax + 171a: 72 04 jb 1720 + 171c: 39 ca cmp %ecx,%edx + 171e: 72 10 jb 1730 + 1720: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1722: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 1724: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 1726: 73 f0 jae 1718 + 1728: 39 ca cmp %ecx,%edx + 172a: 72 04 jb 1730 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 172c: 39 c8 cmp %ecx,%eax + 172e: 72 f0 jb 1720 + break; + if(bp + bp->s.size == p->s.ptr){ + 1730: 8b 73 fc mov -0x4(%ebx),%esi + 1733: 8d 3c f2 lea (%edx,%esi,8),%edi + 1736: 39 cf cmp %ecx,%edi + 1738: 74 1e je 1758 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 173a: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 173d: 8b 48 04 mov 0x4(%eax),%ecx + 1740: 8d 34 c8 lea (%eax,%ecx,8),%esi + 1743: 39 f2 cmp %esi,%edx + 1745: 74 28 je 176f + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 1747: 89 10 mov %edx,(%eax) + freep = p; + 1749: a3 e0 1b 00 00 mov %eax,0x1be0 +} + 174e: 5b pop %ebx + 174f: 5e pop %esi + 1750: 5f pop %edi + 1751: 5d pop %ebp + 1752: c3 ret + 1753: 90 nop + 1754: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 1758: 03 71 04 add 0x4(%ecx),%esi + 175b: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 175e: 8b 08 mov (%eax),%ecx + 1760: 8b 09 mov (%ecx),%ecx + 1762: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 1765: 8b 48 04 mov 0x4(%eax),%ecx + 1768: 8d 34 c8 lea (%eax,%ecx,8),%esi + 176b: 39 f2 cmp %esi,%edx + 176d: 75 d8 jne 1747 + p->s.size += bp->s.size; + 176f: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 1772: a3 e0 1b 00 00 mov %eax,0x1be0 + p->s.size += bp->s.size; + 1777: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 177a: 8b 53 f8 mov -0x8(%ebx),%edx + 177d: 89 10 mov %edx,(%eax) +} + 177f: 5b pop %ebx + 1780: 5e pop %esi + 1781: 5f pop %edi + 1782: 5d pop %ebp + 1783: c3 ret + 1784: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 178a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001790 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1790: 55 push %ebp + 1791: 89 e5 mov %esp,%ebp + 1793: 57 push %edi + 1794: 56 push %esi + 1795: 53 push %ebx + 1796: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1799: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 179c: 8b 1d e0 1b 00 00 mov 0x1be0,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 17a2: 8d 48 07 lea 0x7(%eax),%ecx + 17a5: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 17a8: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 17aa: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 17ad: 0f 84 9b 00 00 00 je 184e + 17b3: 8b 13 mov (%ebx),%edx + 17b5: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 17b8: 39 fe cmp %edi,%esi + 17ba: 76 64 jbe 1820 + 17bc: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 17c3: bb 00 80 00 00 mov $0x8000,%ebx + 17c8: 89 45 e4 mov %eax,-0x1c(%ebp) + 17cb: eb 0e jmp 17db + 17cd: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 17d0: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 17d2: 8b 78 04 mov 0x4(%eax),%edi + 17d5: 39 fe cmp %edi,%esi + 17d7: 76 4f jbe 1828 + 17d9: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 17db: 3b 15 e0 1b 00 00 cmp 0x1be0,%edx + 17e1: 75 ed jne 17d0 + if(nu < 4096) + 17e3: 8b 45 e4 mov -0x1c(%ebp),%eax + 17e6: 81 fe 00 10 00 00 cmp $0x1000,%esi + 17ec: bf 00 10 00 00 mov $0x1000,%edi + 17f1: 0f 43 fe cmovae %esi,%edi + 17f4: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 17f7: 89 04 24 mov %eax,(%esp) + 17fa: e8 3b fc ff ff call 143a + if(p == (char*)-1) + 17ff: 83 f8 ff cmp $0xffffffff,%eax + 1802: 74 18 je 181c + hp->s.size = nu; + 1804: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 1807: 83 c0 08 add $0x8,%eax + 180a: 89 04 24 mov %eax,(%esp) + 180d: e8 ee fe ff ff call 1700 + return freep; + 1812: 8b 15 e0 1b 00 00 mov 0x1be0,%edx + if((p = morecore(nunits)) == 0) + 1818: 85 d2 test %edx,%edx + 181a: 75 b4 jne 17d0 + return 0; + 181c: 31 c0 xor %eax,%eax + 181e: eb 20 jmp 1840 + if(p->s.size >= nunits){ + 1820: 89 d0 mov %edx,%eax + 1822: 89 da mov %ebx,%edx + 1824: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 1828: 39 fe cmp %edi,%esi + 182a: 74 1c je 1848 + p->s.size -= nunits; + 182c: 29 f7 sub %esi,%edi + 182e: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 1831: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 1834: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 1837: 89 15 e0 1b 00 00 mov %edx,0x1be0 + return (void*)(p + 1); + 183d: 83 c0 08 add $0x8,%eax + } +} + 1840: 83 c4 1c add $0x1c,%esp + 1843: 5b pop %ebx + 1844: 5e pop %esi + 1845: 5f pop %edi + 1846: 5d pop %ebp + 1847: c3 ret + prevp->s.ptr = p->s.ptr; + 1848: 8b 08 mov (%eax),%ecx + 184a: 89 0a mov %ecx,(%edx) + 184c: eb e9 jmp 1837 + base.s.ptr = freep = prevp = &base; + 184e: c7 05 e0 1b 00 00 e4 movl $0x1be4,0x1be0 + 1855: 1b 00 00 + base.s.size = 0; + 1858: ba e4 1b 00 00 mov $0x1be4,%edx + base.s.ptr = freep = prevp = &base; + 185d: c7 05 e4 1b 00 00 e4 movl $0x1be4,0x1be4 + 1864: 1b 00 00 + base.s.size = 0; + 1867: c7 05 e8 1b 00 00 00 movl $0x0,0x1be8 + 186e: 00 00 00 + 1871: e9 46 ff ff ff jmp 17bc + 1876: 66 90 xchg %ax,%ax + 1878: 66 90 xchg %ax,%ax + 187a: 66 90 xchg %ax,%ax + 187c: 66 90 xchg %ax,%ax + 187e: 66 90 xchg %ax,%ax + +00001880 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1880: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1881: b9 01 00 00 00 mov $0x1,%ecx + 1886: 89 e5 mov %esp,%ebp + 1888: 8b 55 08 mov 0x8(%ebp),%edx + 188b: 90 nop + 188c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1890: 89 c8 mov %ecx,%eax + 1892: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1895: 85 c0 test %eax,%eax + 1897: 75 f7 jne 1890 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1899: 0f ae f0 mfence +} + 189c: 5d pop %ebp + 189d: c3 ret + 189e: 66 90 xchg %ax,%ax + +000018a0 : + +void urelease (struct uspinlock *lk) { + 18a0: 55 push %ebp + 18a1: 89 e5 mov %esp,%ebp + 18a3: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 18a6: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 18a9: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 18af: 5d pop %ebp + 18b0: c3 ret diff --git a/wc.d b/wc.d new file mode 100644 index 00000000..6adc4989 --- /dev/null +++ b/wc.d @@ -0,0 +1 @@ +wc.o: wc.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/wc.o b/wc.o new file mode 100644 index 00000000..80461e1a Binary files /dev/null and b/wc.o differ diff --git a/wc.sym b/wc.sym new file mode 100644 index 00000000..00eca909 --- /dev/null +++ b/wc.sym @@ -0,0 +1,64 @@ +00001000 .text +000018b1 .rodata +00001900 .eh_frame +00001be0 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 wc.c +00000000 ulib.c +00000000 printf.c +00001470 printint +000018ef digits.1359 +00000000 umalloc.c +00001be0 freep +00001be4 base +00000000 uspinlock.c +00001190 strcpy +00001510 printf +00001380 memmove +000013fa mknod +00001452 shm_open +000012a0 gets +00001432 getpid +00001790 malloc +00001442 sleep +000013c2 pipe +000013d2 write +0000140a fstat +000013e2 kill +00001422 chdir +000013ea exec +000013ba wait +000013ca read +00001402 unlink +000010a0 wc +00001880 uacquire +000013aa fork +0000143a sbrk +0000145a shm_close +0000144a uptime +00001bdc __bss_start +00001240 memset +00001000 main +000011c0 strcmp +0000142a dup +00001c00 buf +00001300 stat +00001bdc _edata +00001e00 _end +00001412 link +000013b2 exit +00001350 atoi +00001210 strlen +000013f2 open +00001260 strchr +0000141a mkdir +000013da close +000018a0 urelease +00001700 free diff --git a/xv6.img b/xv6.img new file mode 100644 index 00000000..d1ce89a0 Binary files /dev/null and b/xv6.img differ diff --git a/zombie.asm b/zombie.asm new file mode 100644 index 00000000..0da4de6a --- /dev/null +++ b/zombie.asm @@ -0,0 +1,1195 @@ + +_zombie: file format elf32-i386 + + +Disassembly of section .text: + +00001000
: +#include "stat.h" +#include "user.h" + +int +main(void) +{ + 1000: 55 push %ebp + 1001: 89 e5 mov %esp,%ebp + 1003: 83 e4 f0 and $0xfffffff0,%esp + 1006: 83 ec 10 sub $0x10,%esp + if(fork() > 0) + 1009: e8 3c 02 00 00 call 124a + 100e: 85 c0 test %eax,%eax + 1010: 7e 0c jle 101e + sleep(5); // Let child exit before parent. + 1012: c7 04 24 05 00 00 00 movl $0x5,(%esp) + 1019: e8 c4 02 00 00 call 12e2 + exit(); + 101e: e8 2f 02 00 00 call 1252 + 1023: 66 90 xchg %ax,%ax + 1025: 66 90 xchg %ax,%ax + 1027: 66 90 xchg %ax,%ax + 1029: 66 90 xchg %ax,%ax + 102b: 66 90 xchg %ax,%ax + 102d: 66 90 xchg %ax,%ax + 102f: 90 nop + +00001030 : +#include "user.h" +#include "x86.h" + +char* +strcpy(char *s, char *t) +{ + 1030: 55 push %ebp + 1031: 89 e5 mov %esp,%ebp + 1033: 8b 45 08 mov 0x8(%ebp),%eax + 1036: 8b 4d 0c mov 0xc(%ebp),%ecx + 1039: 53 push %ebx + char *os; + + os = s; + while((*s++ = *t++) != 0) + 103a: 89 c2 mov %eax,%edx + 103c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1040: 83 c1 01 add $0x1,%ecx + 1043: 0f b6 59 ff movzbl -0x1(%ecx),%ebx + 1047: 83 c2 01 add $0x1,%edx + 104a: 84 db test %bl,%bl + 104c: 88 5a ff mov %bl,-0x1(%edx) + 104f: 75 ef jne 1040 + ; + return os; +} + 1051: 5b pop %ebx + 1052: 5d pop %ebp + 1053: c3 ret + 1054: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 105a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001060 : + +int +strcmp(const char *p, const char *q) +{ + 1060: 55 push %ebp + 1061: 89 e5 mov %esp,%ebp + 1063: 8b 55 08 mov 0x8(%ebp),%edx + 1066: 53 push %ebx + 1067: 8b 4d 0c mov 0xc(%ebp),%ecx + while(*p && *p == *q) + 106a: 0f b6 02 movzbl (%edx),%eax + 106d: 84 c0 test %al,%al + 106f: 74 2d je 109e + 1071: 0f b6 19 movzbl (%ecx),%ebx + 1074: 38 d8 cmp %bl,%al + 1076: 74 0e je 1086 + 1078: eb 2b jmp 10a5 + 107a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1080: 38 c8 cmp %cl,%al + 1082: 75 15 jne 1099 + p++, q++; + 1084: 89 d9 mov %ebx,%ecx + 1086: 83 c2 01 add $0x1,%edx + while(*p && *p == *q) + 1089: 0f b6 02 movzbl (%edx),%eax + p++, q++; + 108c: 8d 59 01 lea 0x1(%ecx),%ebx + while(*p && *p == *q) + 108f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx + 1093: 84 c0 test %al,%al + 1095: 75 e9 jne 1080 + 1097: 31 c0 xor %eax,%eax + return (uchar)*p - (uchar)*q; + 1099: 29 c8 sub %ecx,%eax +} + 109b: 5b pop %ebx + 109c: 5d pop %ebp + 109d: c3 ret + 109e: 0f b6 09 movzbl (%ecx),%ecx + while(*p && *p == *q) + 10a1: 31 c0 xor %eax,%eax + 10a3: eb f4 jmp 1099 + 10a5: 0f b6 cb movzbl %bl,%ecx + 10a8: eb ef jmp 1099 + 10aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + +000010b0 : + +uint +strlen(char *s) +{ + 10b0: 55 push %ebp + 10b1: 89 e5 mov %esp,%ebp + 10b3: 8b 4d 08 mov 0x8(%ebp),%ecx + int n; + + for(n = 0; s[n]; n++) + 10b6: 80 39 00 cmpb $0x0,(%ecx) + 10b9: 74 12 je 10cd + 10bb: 31 d2 xor %edx,%edx + 10bd: 8d 76 00 lea 0x0(%esi),%esi + 10c0: 83 c2 01 add $0x1,%edx + 10c3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) + 10c7: 89 d0 mov %edx,%eax + 10c9: 75 f5 jne 10c0 + ; + return n; +} + 10cb: 5d pop %ebp + 10cc: c3 ret + for(n = 0; s[n]; n++) + 10cd: 31 c0 xor %eax,%eax +} + 10cf: 5d pop %ebp + 10d0: c3 ret + 10d1: eb 0d jmp 10e0 + 10d3: 90 nop + 10d4: 90 nop + 10d5: 90 nop + 10d6: 90 nop + 10d7: 90 nop + 10d8: 90 nop + 10d9: 90 nop + 10da: 90 nop + 10db: 90 nop + 10dc: 90 nop + 10dd: 90 nop + 10de: 90 nop + 10df: 90 nop + +000010e0 : + +void* +memset(void *dst, int c, uint n) +{ + 10e0: 55 push %ebp + 10e1: 89 e5 mov %esp,%ebp + 10e3: 8b 55 08 mov 0x8(%ebp),%edx + 10e6: 57 push %edi +} + +static inline void +stosb(void *addr, int data, int cnt) +{ + asm volatile("cld; rep stosb" : + 10e7: 8b 4d 10 mov 0x10(%ebp),%ecx + 10ea: 8b 45 0c mov 0xc(%ebp),%eax + 10ed: 89 d7 mov %edx,%edi + 10ef: fc cld + 10f0: f3 aa rep stos %al,%es:(%edi) + stosb(dst, c, n); + return dst; +} + 10f2: 89 d0 mov %edx,%eax + 10f4: 5f pop %edi + 10f5: 5d pop %ebp + 10f6: c3 ret + 10f7: 89 f6 mov %esi,%esi + 10f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001100 : + +char* +strchr(const char *s, char c) +{ + 1100: 55 push %ebp + 1101: 89 e5 mov %esp,%ebp + 1103: 8b 45 08 mov 0x8(%ebp),%eax + 1106: 53 push %ebx + 1107: 8b 55 0c mov 0xc(%ebp),%edx + for(; *s; s++) + 110a: 0f b6 18 movzbl (%eax),%ebx + 110d: 84 db test %bl,%bl + 110f: 74 1d je 112e + if(*s == c) + 1111: 38 d3 cmp %dl,%bl + 1113: 89 d1 mov %edx,%ecx + 1115: 75 0d jne 1124 + 1117: eb 17 jmp 1130 + 1119: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 1120: 38 ca cmp %cl,%dl + 1122: 74 0c je 1130 + for(; *s; s++) + 1124: 83 c0 01 add $0x1,%eax + 1127: 0f b6 10 movzbl (%eax),%edx + 112a: 84 d2 test %dl,%dl + 112c: 75 f2 jne 1120 + return (char*)s; + return 0; + 112e: 31 c0 xor %eax,%eax +} + 1130: 5b pop %ebx + 1131: 5d pop %ebp + 1132: c3 ret + 1133: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 1139: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +00001140 : + +char* +gets(char *buf, int max) +{ + 1140: 55 push %ebp + 1141: 89 e5 mov %esp,%ebp + 1143: 57 push %edi + 1144: 56 push %esi + int i, cc; + char c; + + for(i=0; i+1 < max; ){ + 1145: 31 f6 xor %esi,%esi +{ + 1147: 53 push %ebx + 1148: 83 ec 2c sub $0x2c,%esp + cc = read(0, &c, 1); + 114b: 8d 7d e7 lea -0x19(%ebp),%edi + for(i=0; i+1 < max; ){ + 114e: eb 31 jmp 1181 + cc = read(0, &c, 1); + 1150: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1157: 00 + 1158: 89 7c 24 04 mov %edi,0x4(%esp) + 115c: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 1163: e8 02 01 00 00 call 126a + if(cc < 1) + 1168: 85 c0 test %eax,%eax + 116a: 7e 1d jle 1189 + break; + buf[i++] = c; + 116c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax + for(i=0; i+1 < max; ){ + 1170: 89 de mov %ebx,%esi + buf[i++] = c; + 1172: 8b 55 08 mov 0x8(%ebp),%edx + if(c == '\n' || c == '\r') + 1175: 3c 0d cmp $0xd,%al + buf[i++] = c; + 1177: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) + if(c == '\n' || c == '\r') + 117b: 74 0c je 1189 + 117d: 3c 0a cmp $0xa,%al + 117f: 74 08 je 1189 + for(i=0; i+1 < max; ){ + 1181: 8d 5e 01 lea 0x1(%esi),%ebx + 1184: 3b 5d 0c cmp 0xc(%ebp),%ebx + 1187: 7c c7 jl 1150 + break; + } + buf[i] = '\0'; + 1189: 8b 45 08 mov 0x8(%ebp),%eax + 118c: c6 04 30 00 movb $0x0,(%eax,%esi,1) + return buf; +} + 1190: 83 c4 2c add $0x2c,%esp + 1193: 5b pop %ebx + 1194: 5e pop %esi + 1195: 5f pop %edi + 1196: 5d pop %ebp + 1197: c3 ret + 1198: 90 nop + 1199: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +000011a0 : + +int +stat(char *n, struct stat *st) +{ + 11a0: 55 push %ebp + 11a1: 89 e5 mov %esp,%ebp + 11a3: 56 push %esi + 11a4: 53 push %ebx + 11a5: 83 ec 10 sub $0x10,%esp + int fd; + int r; + + fd = open(n, O_RDONLY); + 11a8: 8b 45 08 mov 0x8(%ebp),%eax + 11ab: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) + 11b2: 00 + 11b3: 89 04 24 mov %eax,(%esp) + 11b6: e8 d7 00 00 00 call 1292 + if(fd < 0) + 11bb: 85 c0 test %eax,%eax + fd = open(n, O_RDONLY); + 11bd: 89 c3 mov %eax,%ebx + if(fd < 0) + 11bf: 78 27 js 11e8 + return -1; + r = fstat(fd, st); + 11c1: 8b 45 0c mov 0xc(%ebp),%eax + 11c4: 89 1c 24 mov %ebx,(%esp) + 11c7: 89 44 24 04 mov %eax,0x4(%esp) + 11cb: e8 da 00 00 00 call 12aa + close(fd); + 11d0: 89 1c 24 mov %ebx,(%esp) + r = fstat(fd, st); + 11d3: 89 c6 mov %eax,%esi + close(fd); + 11d5: e8 a0 00 00 00 call 127a + return r; + 11da: 89 f0 mov %esi,%eax +} + 11dc: 83 c4 10 add $0x10,%esp + 11df: 5b pop %ebx + 11e0: 5e pop %esi + 11e1: 5d pop %ebp + 11e2: c3 ret + 11e3: 90 nop + 11e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + return -1; + 11e8: b8 ff ff ff ff mov $0xffffffff,%eax + 11ed: eb ed jmp 11dc + 11ef: 90 nop + +000011f0 : + +int +atoi(const char *s) +{ + 11f0: 55 push %ebp + 11f1: 89 e5 mov %esp,%ebp + 11f3: 8b 4d 08 mov 0x8(%ebp),%ecx + 11f6: 53 push %ebx + int n; + + n = 0; + while('0' <= *s && *s <= '9') + 11f7: 0f be 11 movsbl (%ecx),%edx + 11fa: 8d 42 d0 lea -0x30(%edx),%eax + 11fd: 3c 09 cmp $0x9,%al + n = 0; + 11ff: b8 00 00 00 00 mov $0x0,%eax + while('0' <= *s && *s <= '9') + 1204: 77 17 ja 121d + 1206: 66 90 xchg %ax,%ax + n = n*10 + *s++ - '0'; + 1208: 83 c1 01 add $0x1,%ecx + 120b: 8d 04 80 lea (%eax,%eax,4),%eax + 120e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax + while('0' <= *s && *s <= '9') + 1212: 0f be 11 movsbl (%ecx),%edx + 1215: 8d 5a d0 lea -0x30(%edx),%ebx + 1218: 80 fb 09 cmp $0x9,%bl + 121b: 76 eb jbe 1208 + return n; +} + 121d: 5b pop %ebx + 121e: 5d pop %ebp + 121f: c3 ret + +00001220 : + +void* +memmove(void *vdst, void *vsrc, int n) +{ + 1220: 55 push %ebp + char *dst, *src; + + dst = vdst; + src = vsrc; + while(n-- > 0) + 1221: 31 d2 xor %edx,%edx +{ + 1223: 89 e5 mov %esp,%ebp + 1225: 56 push %esi + 1226: 8b 45 08 mov 0x8(%ebp),%eax + 1229: 53 push %ebx + 122a: 8b 5d 10 mov 0x10(%ebp),%ebx + 122d: 8b 75 0c mov 0xc(%ebp),%esi + while(n-- > 0) + 1230: 85 db test %ebx,%ebx + 1232: 7e 12 jle 1246 + 1234: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + *dst++ = *src++; + 1238: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx + 123c: 88 0c 10 mov %cl,(%eax,%edx,1) + 123f: 83 c2 01 add $0x1,%edx + while(n-- > 0) + 1242: 39 da cmp %ebx,%edx + 1244: 75 f2 jne 1238 + return vdst; +} + 1246: 5b pop %ebx + 1247: 5e pop %esi + 1248: 5d pop %ebp + 1249: c3 ret + +0000124a : + name: \ + movl $SYS_ ## name, %eax; \ + int $T_SYSCALL; \ + ret + +SYSCALL(fork) + 124a: b8 01 00 00 00 mov $0x1,%eax + 124f: cd 40 int $0x40 + 1251: c3 ret + +00001252 : +SYSCALL(exit) + 1252: b8 02 00 00 00 mov $0x2,%eax + 1257: cd 40 int $0x40 + 1259: c3 ret + +0000125a : +SYSCALL(wait) + 125a: b8 03 00 00 00 mov $0x3,%eax + 125f: cd 40 int $0x40 + 1261: c3 ret + +00001262 : +SYSCALL(pipe) + 1262: b8 04 00 00 00 mov $0x4,%eax + 1267: cd 40 int $0x40 + 1269: c3 ret + +0000126a : +SYSCALL(read) + 126a: b8 05 00 00 00 mov $0x5,%eax + 126f: cd 40 int $0x40 + 1271: c3 ret + +00001272 : +SYSCALL(write) + 1272: b8 10 00 00 00 mov $0x10,%eax + 1277: cd 40 int $0x40 + 1279: c3 ret + +0000127a : +SYSCALL(close) + 127a: b8 15 00 00 00 mov $0x15,%eax + 127f: cd 40 int $0x40 + 1281: c3 ret + +00001282 : +SYSCALL(kill) + 1282: b8 06 00 00 00 mov $0x6,%eax + 1287: cd 40 int $0x40 + 1289: c3 ret + +0000128a : +SYSCALL(exec) + 128a: b8 07 00 00 00 mov $0x7,%eax + 128f: cd 40 int $0x40 + 1291: c3 ret + +00001292 : +SYSCALL(open) + 1292: b8 0f 00 00 00 mov $0xf,%eax + 1297: cd 40 int $0x40 + 1299: c3 ret + +0000129a : +SYSCALL(mknod) + 129a: b8 11 00 00 00 mov $0x11,%eax + 129f: cd 40 int $0x40 + 12a1: c3 ret + +000012a2 : +SYSCALL(unlink) + 12a2: b8 12 00 00 00 mov $0x12,%eax + 12a7: cd 40 int $0x40 + 12a9: c3 ret + +000012aa : +SYSCALL(fstat) + 12aa: b8 08 00 00 00 mov $0x8,%eax + 12af: cd 40 int $0x40 + 12b1: c3 ret + +000012b2 : +SYSCALL(link) + 12b2: b8 13 00 00 00 mov $0x13,%eax + 12b7: cd 40 int $0x40 + 12b9: c3 ret + +000012ba : +SYSCALL(mkdir) + 12ba: b8 14 00 00 00 mov $0x14,%eax + 12bf: cd 40 int $0x40 + 12c1: c3 ret + +000012c2 : +SYSCALL(chdir) + 12c2: b8 09 00 00 00 mov $0x9,%eax + 12c7: cd 40 int $0x40 + 12c9: c3 ret + +000012ca : +SYSCALL(dup) + 12ca: b8 0a 00 00 00 mov $0xa,%eax + 12cf: cd 40 int $0x40 + 12d1: c3 ret + +000012d2 : +SYSCALL(getpid) + 12d2: b8 0b 00 00 00 mov $0xb,%eax + 12d7: cd 40 int $0x40 + 12d9: c3 ret + +000012da : +SYSCALL(sbrk) + 12da: b8 0c 00 00 00 mov $0xc,%eax + 12df: cd 40 int $0x40 + 12e1: c3 ret + +000012e2 : +SYSCALL(sleep) + 12e2: b8 0d 00 00 00 mov $0xd,%eax + 12e7: cd 40 int $0x40 + 12e9: c3 ret + +000012ea : +SYSCALL(uptime) + 12ea: b8 0e 00 00 00 mov $0xe,%eax + 12ef: cd 40 int $0x40 + 12f1: c3 ret + +000012f2 : +SYSCALL(shm_open) + 12f2: b8 16 00 00 00 mov $0x16,%eax + 12f7: cd 40 int $0x40 + 12f9: c3 ret + +000012fa : +SYSCALL(shm_close) + 12fa: b8 17 00 00 00 mov $0x17,%eax + 12ff: cd 40 int $0x40 + 1301: c3 ret + 1302: 66 90 xchg %ax,%ax + 1304: 66 90 xchg %ax,%ax + 1306: 66 90 xchg %ax,%ax + 1308: 66 90 xchg %ax,%ax + 130a: 66 90 xchg %ax,%ax + 130c: 66 90 xchg %ax,%ax + 130e: 66 90 xchg %ax,%ax + +00001310 : + write(fd, &c, 1); +} + +static void +printint(int fd, int xx, int base, int sgn) +{ + 1310: 55 push %ebp + 1311: 89 e5 mov %esp,%ebp + 1313: 57 push %edi + 1314: 56 push %esi + 1315: 89 c6 mov %eax,%esi + 1317: 53 push %ebx + 1318: 83 ec 4c sub $0x4c,%esp + char buf[16]; + int i, neg; + uint x; + + neg = 0; + if(sgn && xx < 0){ + 131b: 8b 5d 08 mov 0x8(%ebp),%ebx + 131e: 85 db test %ebx,%ebx + 1320: 74 09 je 132b + 1322: 89 d0 mov %edx,%eax + 1324: c1 e8 1f shr $0x1f,%eax + 1327: 84 c0 test %al,%al + 1329: 75 75 jne 13a0 + neg = 1; + x = -xx; + } else { + x = xx; + 132b: 89 d0 mov %edx,%eax + neg = 0; + 132d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) + 1334: 89 75 c0 mov %esi,-0x40(%ebp) + } + + i = 0; + 1337: 31 ff xor %edi,%edi + 1339: 89 ce mov %ecx,%esi + 133b: 8d 5d d7 lea -0x29(%ebp),%ebx + 133e: eb 02 jmp 1342 + do{ + buf[i++] = digits[x % base]; + 1340: 89 cf mov %ecx,%edi + 1342: 31 d2 xor %edx,%edx + 1344: f7 f6 div %esi + 1346: 8d 4f 01 lea 0x1(%edi),%ecx + 1349: 0f b6 92 58 17 00 00 movzbl 0x1758(%edx),%edx + }while((x /= base) != 0); + 1350: 85 c0 test %eax,%eax + buf[i++] = digits[x % base]; + 1352: 88 14 0b mov %dl,(%ebx,%ecx,1) + }while((x /= base) != 0); + 1355: 75 e9 jne 1340 + if(neg) + 1357: 8b 55 c4 mov -0x3c(%ebp),%edx + buf[i++] = digits[x % base]; + 135a: 89 c8 mov %ecx,%eax + 135c: 8b 75 c0 mov -0x40(%ebp),%esi + if(neg) + 135f: 85 d2 test %edx,%edx + 1361: 74 08 je 136b + buf[i++] = '-'; + 1363: 8d 4f 02 lea 0x2(%edi),%ecx + 1366: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) + + while(--i >= 0) + 136b: 8d 79 ff lea -0x1(%ecx),%edi + 136e: 66 90 xchg %ax,%ax + 1370: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax + 1375: 83 ef 01 sub $0x1,%edi + write(fd, &c, 1); + 1378: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 137f: 00 + 1380: 89 5c 24 04 mov %ebx,0x4(%esp) + 1384: 89 34 24 mov %esi,(%esp) + 1387: 88 45 d7 mov %al,-0x29(%ebp) + 138a: e8 e3 fe ff ff call 1272 + while(--i >= 0) + 138f: 83 ff ff cmp $0xffffffff,%edi + 1392: 75 dc jne 1370 + putc(fd, buf[i]); +} + 1394: 83 c4 4c add $0x4c,%esp + 1397: 5b pop %ebx + 1398: 5e pop %esi + 1399: 5f pop %edi + 139a: 5d pop %ebp + 139b: c3 ret + 139c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + x = -xx; + 13a0: 89 d0 mov %edx,%eax + 13a2: f7 d8 neg %eax + neg = 1; + 13a4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) + 13ab: eb 87 jmp 1334 + 13ad: 8d 76 00 lea 0x0(%esi),%esi + +000013b0 : + +// Print to the given fd. Only understands %d, %x, %p, %s. +void +printf(int fd, char *fmt, ...) +{ + 13b0: 55 push %ebp + 13b1: 89 e5 mov %esp,%ebp + 13b3: 57 push %edi + char *s; + int c, i, state; + uint *ap; + + state = 0; + 13b4: 31 ff xor %edi,%edi +{ + 13b6: 56 push %esi + 13b7: 53 push %ebx + 13b8: 83 ec 3c sub $0x3c,%esp + ap = (uint*)(void*)&fmt + 1; + for(i = 0; fmt[i]; i++){ + 13bb: 8b 5d 0c mov 0xc(%ebp),%ebx + ap = (uint*)(void*)&fmt + 1; + 13be: 8d 45 10 lea 0x10(%ebp),%eax +{ + 13c1: 8b 75 08 mov 0x8(%ebp),%esi + ap = (uint*)(void*)&fmt + 1; + 13c4: 89 45 d4 mov %eax,-0x2c(%ebp) + for(i = 0; fmt[i]; i++){ + 13c7: 0f b6 13 movzbl (%ebx),%edx + 13ca: 83 c3 01 add $0x1,%ebx + 13cd: 84 d2 test %dl,%dl + 13cf: 75 39 jne 140a + 13d1: e9 c2 00 00 00 jmp 1498 + 13d6: 66 90 xchg %ax,%ax + c = fmt[i] & 0xff; + if(state == 0){ + if(c == '%'){ + 13d8: 83 fa 25 cmp $0x25,%edx + 13db: 0f 84 bf 00 00 00 je 14a0 + write(fd, &c, 1); + 13e1: 8d 45 e2 lea -0x1e(%ebp),%eax + 13e4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 13eb: 00 + 13ec: 89 44 24 04 mov %eax,0x4(%esp) + 13f0: 89 34 24 mov %esi,(%esp) + state = '%'; + } else { + putc(fd, c); + 13f3: 88 55 e2 mov %dl,-0x1e(%ebp) + write(fd, &c, 1); + 13f6: e8 77 fe ff ff call 1272 + 13fb: 83 c3 01 add $0x1,%ebx + for(i = 0; fmt[i]; i++){ + 13fe: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 1402: 84 d2 test %dl,%dl + 1404: 0f 84 8e 00 00 00 je 1498 + if(state == 0){ + 140a: 85 ff test %edi,%edi + c = fmt[i] & 0xff; + 140c: 0f be c2 movsbl %dl,%eax + if(state == 0){ + 140f: 74 c7 je 13d8 + } + } else if(state == '%'){ + 1411: 83 ff 25 cmp $0x25,%edi + 1414: 75 e5 jne 13fb + if(c == 'd'){ + 1416: 83 fa 64 cmp $0x64,%edx + 1419: 0f 84 31 01 00 00 je 1550 + printint(fd, *ap, 10, 1); + ap++; + } else if(c == 'x' || c == 'p'){ + 141f: 25 f7 00 00 00 and $0xf7,%eax + 1424: 83 f8 70 cmp $0x70,%eax + 1427: 0f 84 83 00 00 00 je 14b0 + printint(fd, *ap, 16, 0); + ap++; + } else if(c == 's'){ + 142d: 83 fa 73 cmp $0x73,%edx + 1430: 0f 84 a2 00 00 00 je 14d8 + s = "(null)"; + while(*s != 0){ + putc(fd, *s); + s++; + } + } else if(c == 'c'){ + 1436: 83 fa 63 cmp $0x63,%edx + 1439: 0f 84 35 01 00 00 je 1574 + putc(fd, *ap); + ap++; + } else if(c == '%'){ + 143f: 83 fa 25 cmp $0x25,%edx + 1442: 0f 84 e0 00 00 00 je 1528 + write(fd, &c, 1); + 1448: 8d 45 e6 lea -0x1a(%ebp),%eax + 144b: 83 c3 01 add $0x1,%ebx + 144e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1455: 00 + } else { + // Unknown % sequence. Print it to draw attention. + putc(fd, '%'); + putc(fd, c); + } + state = 0; + 1456: 31 ff xor %edi,%edi + write(fd, &c, 1); + 1458: 89 44 24 04 mov %eax,0x4(%esp) + 145c: 89 34 24 mov %esi,(%esp) + 145f: 89 55 d0 mov %edx,-0x30(%ebp) + 1462: c6 45 e6 25 movb $0x25,-0x1a(%ebp) + 1466: e8 07 fe ff ff call 1272 + putc(fd, c); + 146b: 8b 55 d0 mov -0x30(%ebp),%edx + write(fd, &c, 1); + 146e: 8d 45 e7 lea -0x19(%ebp),%eax + 1471: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1478: 00 + 1479: 89 44 24 04 mov %eax,0x4(%esp) + 147d: 89 34 24 mov %esi,(%esp) + putc(fd, c); + 1480: 88 55 e7 mov %dl,-0x19(%ebp) + write(fd, &c, 1); + 1483: e8 ea fd ff ff call 1272 + for(i = 0; fmt[i]; i++){ + 1488: 0f b6 53 ff movzbl -0x1(%ebx),%edx + 148c: 84 d2 test %dl,%dl + 148e: 0f 85 76 ff ff ff jne 140a + 1494: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + } + } +} + 1498: 83 c4 3c add $0x3c,%esp + 149b: 5b pop %ebx + 149c: 5e pop %esi + 149d: 5f pop %edi + 149e: 5d pop %ebp + 149f: c3 ret + state = '%'; + 14a0: bf 25 00 00 00 mov $0x25,%edi + 14a5: e9 51 ff ff ff jmp 13fb + 14aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 16, 0); + 14b0: 8b 45 d4 mov -0x2c(%ebp),%eax + 14b3: b9 10 00 00 00 mov $0x10,%ecx + state = 0; + 14b8: 31 ff xor %edi,%edi + printint(fd, *ap, 16, 0); + 14ba: c7 04 24 00 00 00 00 movl $0x0,(%esp) + 14c1: 8b 10 mov (%eax),%edx + 14c3: 89 f0 mov %esi,%eax + 14c5: e8 46 fe ff ff call 1310 + ap++; + 14ca: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 14ce: e9 28 ff ff ff jmp 13fb + 14d3: 90 nop + 14d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + s = (char*)*ap; + 14d8: 8b 45 d4 mov -0x2c(%ebp),%eax + ap++; + 14db: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + s = (char*)*ap; + 14df: 8b 38 mov (%eax),%edi + s = "(null)"; + 14e1: b8 51 17 00 00 mov $0x1751,%eax + 14e6: 85 ff test %edi,%edi + 14e8: 0f 44 f8 cmove %eax,%edi + while(*s != 0){ + 14eb: 0f b6 07 movzbl (%edi),%eax + 14ee: 84 c0 test %al,%al + 14f0: 74 2a je 151c + 14f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 14f8: 88 45 e3 mov %al,-0x1d(%ebp) + write(fd, &c, 1); + 14fb: 8d 45 e3 lea -0x1d(%ebp),%eax + s++; + 14fe: 83 c7 01 add $0x1,%edi + write(fd, &c, 1); + 1501: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1508: 00 + 1509: 89 44 24 04 mov %eax,0x4(%esp) + 150d: 89 34 24 mov %esi,(%esp) + 1510: e8 5d fd ff ff call 1272 + while(*s != 0){ + 1515: 0f b6 07 movzbl (%edi),%eax + 1518: 84 c0 test %al,%al + 151a: 75 dc jne 14f8 + state = 0; + 151c: 31 ff xor %edi,%edi + 151e: e9 d8 fe ff ff jmp 13fb + 1523: 90 nop + 1524: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + write(fd, &c, 1); + 1528: 8d 45 e5 lea -0x1b(%ebp),%eax + state = 0; + 152b: 31 ff xor %edi,%edi + write(fd, &c, 1); + 152d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1534: 00 + 1535: 89 44 24 04 mov %eax,0x4(%esp) + 1539: 89 34 24 mov %esi,(%esp) + 153c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) + 1540: e8 2d fd ff ff call 1272 + 1545: e9 b1 fe ff ff jmp 13fb + 154a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + printint(fd, *ap, 10, 1); + 1550: 8b 45 d4 mov -0x2c(%ebp),%eax + 1553: b9 0a 00 00 00 mov $0xa,%ecx + state = 0; + 1558: 66 31 ff xor %di,%di + printint(fd, *ap, 10, 1); + 155b: c7 04 24 01 00 00 00 movl $0x1,(%esp) + 1562: 8b 10 mov (%eax),%edx + 1564: 89 f0 mov %esi,%eax + 1566: e8 a5 fd ff ff call 1310 + ap++; + 156b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 156f: e9 87 fe ff ff jmp 13fb + putc(fd, *ap); + 1574: 8b 45 d4 mov -0x2c(%ebp),%eax + state = 0; + 1577: 31 ff xor %edi,%edi + putc(fd, *ap); + 1579: 8b 00 mov (%eax),%eax + write(fd, &c, 1); + 157b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) + 1582: 00 + 1583: 89 34 24 mov %esi,(%esp) + putc(fd, *ap); + 1586: 88 45 e4 mov %al,-0x1c(%ebp) + write(fd, &c, 1); + 1589: 8d 45 e4 lea -0x1c(%ebp),%eax + 158c: 89 44 24 04 mov %eax,0x4(%esp) + 1590: e8 dd fc ff ff call 1272 + ap++; + 1595: 83 45 d4 04 addl $0x4,-0x2c(%ebp) + 1599: e9 5d fe ff ff jmp 13fb + 159e: 66 90 xchg %ax,%ax + +000015a0 : +static Header base; +static Header *freep; + +void +free(void *ap) +{ + 15a0: 55 push %ebp + Header *bp, *p; + + bp = (Header*)ap - 1; + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15a1: a1 10 1a 00 00 mov 0x1a10,%eax +{ + 15a6: 89 e5 mov %esp,%ebp + 15a8: 57 push %edi + 15a9: 56 push %esi + 15aa: 53 push %ebx + 15ab: 8b 5d 08 mov 0x8(%ebp),%ebx + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15ae: 8b 08 mov (%eax),%ecx + bp = (Header*)ap - 1; + 15b0: 8d 53 f8 lea -0x8(%ebx),%edx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15b3: 39 d0 cmp %edx,%eax + 15b5: 72 11 jb 15c8 + 15b7: 90 nop + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15b8: 39 c8 cmp %ecx,%eax + 15ba: 72 04 jb 15c0 + 15bc: 39 ca cmp %ecx,%edx + 15be: 72 10 jb 15d0 + 15c0: 89 c8 mov %ecx,%eax + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15c2: 39 d0 cmp %edx,%eax + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15c4: 8b 08 mov (%eax),%ecx + for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + 15c6: 73 f0 jae 15b8 + 15c8: 39 ca cmp %ecx,%edx + 15ca: 72 04 jb 15d0 + if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + 15cc: 39 c8 cmp %ecx,%eax + 15ce: 72 f0 jb 15c0 + break; + if(bp + bp->s.size == p->s.ptr){ + 15d0: 8b 73 fc mov -0x4(%ebx),%esi + 15d3: 8d 3c f2 lea (%edx,%esi,8),%edi + 15d6: 39 cf cmp %ecx,%edi + 15d8: 74 1e je 15f8 + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else + bp->s.ptr = p->s.ptr; + 15da: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 15dd: 8b 48 04 mov 0x4(%eax),%ecx + 15e0: 8d 34 c8 lea (%eax,%ecx,8),%esi + 15e3: 39 f2 cmp %esi,%edx + 15e5: 74 28 je 160f + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else + p->s.ptr = bp; + 15e7: 89 10 mov %edx,(%eax) + freep = p; + 15e9: a3 10 1a 00 00 mov %eax,0x1a10 +} + 15ee: 5b pop %ebx + 15ef: 5e pop %esi + 15f0: 5f pop %edi + 15f1: 5d pop %ebp + 15f2: c3 ret + 15f3: 90 nop + 15f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + bp->s.size += p->s.ptr->s.size; + 15f8: 03 71 04 add 0x4(%ecx),%esi + 15fb: 89 73 fc mov %esi,-0x4(%ebx) + bp->s.ptr = p->s.ptr->s.ptr; + 15fe: 8b 08 mov (%eax),%ecx + 1600: 8b 09 mov (%ecx),%ecx + 1602: 89 4b f8 mov %ecx,-0x8(%ebx) + if(p + p->s.size == bp){ + 1605: 8b 48 04 mov 0x4(%eax),%ecx + 1608: 8d 34 c8 lea (%eax,%ecx,8),%esi + 160b: 39 f2 cmp %esi,%edx + 160d: 75 d8 jne 15e7 + p->s.size += bp->s.size; + 160f: 03 4b fc add -0x4(%ebx),%ecx + freep = p; + 1612: a3 10 1a 00 00 mov %eax,0x1a10 + p->s.size += bp->s.size; + 1617: 89 48 04 mov %ecx,0x4(%eax) + p->s.ptr = bp->s.ptr; + 161a: 8b 53 f8 mov -0x8(%ebx),%edx + 161d: 89 10 mov %edx,(%eax) +} + 161f: 5b pop %ebx + 1620: 5e pop %esi + 1621: 5f pop %edi + 1622: 5d pop %ebp + 1623: c3 ret + 1624: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 162a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi + +00001630 : + return freep; +} + +void* +malloc(uint nbytes) +{ + 1630: 55 push %ebp + 1631: 89 e5 mov %esp,%ebp + 1633: 57 push %edi + 1634: 56 push %esi + 1635: 53 push %ebx + 1636: 83 ec 1c sub $0x1c,%esp + Header *p, *prevp; + uint nunits; + + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1639: 8b 45 08 mov 0x8(%ebp),%eax + if((prevp = freep) == 0){ + 163c: 8b 1d 10 1a 00 00 mov 0x1a10,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 1642: 8d 48 07 lea 0x7(%eax),%ecx + 1645: c1 e9 03 shr $0x3,%ecx + if((prevp = freep) == 0){ + 1648: 85 db test %ebx,%ebx + nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; + 164a: 8d 71 01 lea 0x1(%ecx),%esi + if((prevp = freep) == 0){ + 164d: 0f 84 9b 00 00 00 je 16ee + 1653: 8b 13 mov (%ebx),%edx + 1655: 8b 7a 04 mov 0x4(%edx),%edi + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + if(p->s.size >= nunits){ + 1658: 39 fe cmp %edi,%esi + 165a: 76 64 jbe 16c0 + 165c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax + if(nu < 4096) + 1663: bb 00 80 00 00 mov $0x8000,%ebx + 1668: 89 45 e4 mov %eax,-0x1c(%ebp) + 166b: eb 0e jmp 167b + 166d: 8d 76 00 lea 0x0(%esi),%esi + for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ + 1670: 8b 02 mov (%edx),%eax + if(p->s.size >= nunits){ + 1672: 8b 78 04 mov 0x4(%eax),%edi + 1675: 39 fe cmp %edi,%esi + 1677: 76 4f jbe 16c8 + 1679: 89 c2 mov %eax,%edx + p->s.size = nunits; + } + freep = prevp; + return (void*)(p + 1); + } + if(p == freep) + 167b: 3b 15 10 1a 00 00 cmp 0x1a10,%edx + 1681: 75 ed jne 1670 + if(nu < 4096) + 1683: 8b 45 e4 mov -0x1c(%ebp),%eax + 1686: 81 fe 00 10 00 00 cmp $0x1000,%esi + 168c: bf 00 10 00 00 mov $0x1000,%edi + 1691: 0f 43 fe cmovae %esi,%edi + 1694: 0f 42 c3 cmovb %ebx,%eax + p = sbrk(nu * sizeof(Header)); + 1697: 89 04 24 mov %eax,(%esp) + 169a: e8 3b fc ff ff call 12da + if(p == (char*)-1) + 169f: 83 f8 ff cmp $0xffffffff,%eax + 16a2: 74 18 je 16bc + hp->s.size = nu; + 16a4: 89 78 04 mov %edi,0x4(%eax) + free((void*)(hp + 1)); + 16a7: 83 c0 08 add $0x8,%eax + 16aa: 89 04 24 mov %eax,(%esp) + 16ad: e8 ee fe ff ff call 15a0 + return freep; + 16b2: 8b 15 10 1a 00 00 mov 0x1a10,%edx + if((p = morecore(nunits)) == 0) + 16b8: 85 d2 test %edx,%edx + 16ba: 75 b4 jne 1670 + return 0; + 16bc: 31 c0 xor %eax,%eax + 16be: eb 20 jmp 16e0 + if(p->s.size >= nunits){ + 16c0: 89 d0 mov %edx,%eax + 16c2: 89 da mov %ebx,%edx + 16c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + if(p->s.size == nunits) + 16c8: 39 fe cmp %edi,%esi + 16ca: 74 1c je 16e8 + p->s.size -= nunits; + 16cc: 29 f7 sub %esi,%edi + 16ce: 89 78 04 mov %edi,0x4(%eax) + p += p->s.size; + 16d1: 8d 04 f8 lea (%eax,%edi,8),%eax + p->s.size = nunits; + 16d4: 89 70 04 mov %esi,0x4(%eax) + freep = prevp; + 16d7: 89 15 10 1a 00 00 mov %edx,0x1a10 + return (void*)(p + 1); + 16dd: 83 c0 08 add $0x8,%eax + } +} + 16e0: 83 c4 1c add $0x1c,%esp + 16e3: 5b pop %ebx + 16e4: 5e pop %esi + 16e5: 5f pop %edi + 16e6: 5d pop %ebp + 16e7: c3 ret + prevp->s.ptr = p->s.ptr; + 16e8: 8b 08 mov (%eax),%ecx + 16ea: 89 0a mov %ecx,(%edx) + 16ec: eb e9 jmp 16d7 + base.s.ptr = freep = prevp = &base; + 16ee: c7 05 10 1a 00 00 14 movl $0x1a14,0x1a10 + 16f5: 1a 00 00 + base.s.size = 0; + 16f8: ba 14 1a 00 00 mov $0x1a14,%edx + base.s.ptr = freep = prevp = &base; + 16fd: c7 05 14 1a 00 00 14 movl $0x1a14,0x1a14 + 1704: 1a 00 00 + base.s.size = 0; + 1707: c7 05 18 1a 00 00 00 movl $0x0,0x1a18 + 170e: 00 00 00 + 1711: e9 46 ff ff ff jmp 165c + 1716: 66 90 xchg %ax,%ax + 1718: 66 90 xchg %ax,%ax + 171a: 66 90 xchg %ax,%ax + 171c: 66 90 xchg %ax,%ax + 171e: 66 90 xchg %ax,%ax + +00001720 : +#include "uspinlock.h" +#include "x86.h" + +void +uacquire(struct uspinlock *lk) +{ + 1720: 55 push %ebp +xchg(volatile uint *addr, uint newval) +{ + uint result; + + // The + in "+m" denotes a read-modify-write operand. + asm volatile("lock; xchgl %0, %1" : + 1721: b9 01 00 00 00 mov $0x1,%ecx + 1726: 89 e5 mov %esp,%ebp + 1728: 8b 55 08 mov 0x8(%ebp),%edx + 172b: 90 nop + 172c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi + 1730: 89 c8 mov %ecx,%eax + 1732: f0 87 02 lock xchg %eax,(%edx) + // The xchg is atomic. + while(xchg(&lk->locked, 1) != 0) + 1735: 85 c0 test %eax,%eax + 1737: 75 f7 jne 1730 + ; + + // Tell the C compiler and the processor to not move loads or stores + // past this point, to ensure that the critical section's memory + // references happen after the lock is acquired. + __sync_synchronize(); + 1739: 0f ae f0 mfence +} + 173c: 5d pop %ebp + 173d: c3 ret + 173e: 66 90 xchg %ax,%ax + +00001740 : + +void urelease (struct uspinlock *lk) { + 1740: 55 push %ebp + 1741: 89 e5 mov %esp,%ebp + 1743: 8b 45 08 mov 0x8(%ebp),%eax + __sync_synchronize(); + 1746: 0f ae f0 mfence + + // Release the lock, equivalent to lk->locked = 0. + // This code can't use a C assignment, since it might + // not be atomic. A real OS would use C atomics here. + asm volatile("movl $0, %0" : "+m" (lk->locked) : ); + 1749: c7 00 00 00 00 00 movl $0x0,(%eax) +} + 174f: 5d pop %ebp + 1750: c3 ret diff --git a/zombie.d b/zombie.d new file mode 100644 index 00000000..c3e36f5d --- /dev/null +++ b/zombie.d @@ -0,0 +1 @@ +zombie.o: zombie.c /usr/include/stdc-predef.h types.h stat.h user.h diff --git a/zombie.o b/zombie.o new file mode 100644 index 00000000..74b85a8c Binary files /dev/null and b/zombie.o differ diff --git a/zombie.sym b/zombie.sym new file mode 100644 index 00000000..527ba727 --- /dev/null +++ b/zombie.sym @@ -0,0 +1,62 @@ +00001000 .text +00001751 .rodata +0000176c .eh_frame +00001a10 .bss +00000000 .comment +00000000 .debug_aranges +00000000 .debug_info +00000000 .debug_abbrev +00000000 .debug_line +00000000 .debug_str +00000000 .debug_loc +00000000 .debug_ranges +00000000 zombie.c +00000000 ulib.c +00000000 printf.c +00001310 printint +00001758 digits.1359 +00000000 umalloc.c +00001a10 freep +00001a14 base +00000000 uspinlock.c +00001030 strcpy +000013b0 printf +00001220 memmove +0000129a mknod +000012f2 shm_open +00001140 gets +000012d2 getpid +00001630 malloc +000012e2 sleep +00001262 pipe +00001272 write +000012aa fstat +00001282 kill +000012c2 chdir +0000128a exec +0000125a wait +0000126a read +000012a2 unlink +00001720 uacquire +0000124a fork +000012da sbrk +000012fa shm_close +000012ea uptime +00001a10 __bss_start +000010e0 memset +00001000 main +00001060 strcmp +000012ca dup +000011a0 stat +00001a10 _edata +00001a1c _end +000012b2 link +00001252 exit +000011f0 atoi +000010b0 strlen +00001292 open +00001100 strchr +000012ba mkdir +0000127a close +00001740 urelease +000015a0 free