diff --git a/a b/a index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..63fc8131d563e4c067404cb42d39eb293952bd51 100644 --- a/a +++ b/a @@ -0,0 +1 @@ +xxxx diff --git a/labcodes/lab4/bin/bootblock b/labcodes/lab4/bin/bootblock index 40f63c1c8bb0874605091a60424d9ce59ee6bb12..b04b04f58b3af9b64903fdd9b677a794735388c2 100644 Binary files a/labcodes/lab4/bin/bootblock and b/labcodes/lab4/bin/bootblock differ diff --git a/labcodes/lab4/bin/kernel b/labcodes/lab4/bin/kernel index d01bdeb2dcabee05745742d79cadf0e073e42226..286a333b933de9fd0829a8e1944fb6b3d57b4b97 100755 Binary files a/labcodes/lab4/bin/kernel and b/labcodes/lab4/bin/kernel differ diff --git a/labcodes/lab4/bin/sign b/labcodes/lab4/bin/sign index a131d5ea568dbf0862ed398723697503736c82ce..42a27bf95f081270bf22da9916b8fc244e61a79d 100755 Binary files a/labcodes/lab4/bin/sign and b/labcodes/lab4/bin/sign differ diff --git a/labcodes/lab4/bin/swap.img b/labcodes/lab4/bin/swap.img index 52e65dd21c3fc2924229516cb140503b22ee21fb..bf651b8e69916869c89e167a24aae9aa54814b68 100644 Binary files a/labcodes/lab4/bin/swap.img and b/labcodes/lab4/bin/swap.img differ diff --git a/labcodes/lab4/bin/ucore.img b/labcodes/lab4/bin/ucore.img index 5516ba382c543a743058eb7d3851a01e1973f019..a01eea2c6c0768ba04cfff52a8ee6a6f707309d7 100644 Binary files a/labcodes/lab4/bin/ucore.img and b/labcodes/lab4/bin/ucore.img differ diff --git a/labcodes/lab4/kern/init/init.c b/labcodes/lab4/kern/init/init.c index c58bfc3ae0d757f786be6d7621e64c6ed310643a..e6fad960c873aa37f69ec42a00043efefb51a8b7 100644 --- a/labcodes/lab4/kern/init/init.c +++ b/labcodes/lab4/kern/init/init.c @@ -39,6 +39,7 @@ kern_init(void) { idt_init(); // init interrupt descriptor table初始化中断描述符表 vmm_init(); // init virtual memory management 初始化虚拟内存管理 + proc_init(); // init process table ide_init(); // init ide devices初始化IDE设备 diff --git a/labcodes/lab4/kern/mm/vmm.c b/labcodes/lab4/kern/mm/vmm.c index ab1a580868ee52fe7f6ab4d4a45a96991f96ab9d..5068210a26f413cbf64008771b49f937f3e61e34 100644 --- a/labcodes/lab4/kern/mm/vmm.c +++ b/labcodes/lab4/kern/mm/vmm.c @@ -7,6 +7,7 @@ #include #include #include +#include /* vmm design include two parts: mm_struct (mm) & vma_struct (vma) @@ -230,10 +231,12 @@ mm_destroy(struct mm_struct *mm) { // 从列表中删除当前虚拟内存区域的项 list_del(le); // 释放虚拟内存区域结构的内存 - kfree(le2vma(le, list_link),sizeof(struct vma_struct)); //kfree vma + kfree(le2vma(le, list_link)); + //kfree(le2vma(le, list_link), sizeof(struct vma_struct)); //kfree vma } // 释放内存管理结构本身的内存 - kfree(mm, sizeof(struct mm_struct)); //kfree mm + kfree(mm); //kfree mm + //kfree(mm, sizeof(struct mm_struct)); //kfree mm // 将指针设置为NULL,表示该结构已被销毁 mm=NULL; } @@ -267,7 +270,7 @@ check_vmm(void) { // 检查页面故障处理的正确性 check_pgfault(); // 确保在检查过程中免费页面数量未发生变化,表明内存管理操作是正确的 - //assert(nr_free_pages_store == nr_free_pages()); + // assert(nr_free_pages_store == nr_free_pages()); // 如果所有检查都通过,输出成功信息 cprintf("check_vmm() succeeded.\n"); } @@ -341,7 +344,7 @@ check_vma_struct(void) { mm_destroy(mm);// 销毁 mm 结构 // 确保释放的页面数量与初始记录一致 - //assert(nr_free_pages_store == nr_free_pages()); + // assert(nr_free_pages_store == nr_free_pages()); // 输出成功信息 cprintf("check_vma_struct() succeeded!\n"); } diff --git a/labcodes/lab4/kern/process/proc.c b/labcodes/lab4/kern/process/proc.c index 8c733e0cac908efb9d98250d1a222913c8b4fff3..602e0adb68d8acd8859f44138461e8ecb51032dc 100644 --- a/labcodes/lab4/kern/process/proc.c +++ b/labcodes/lab4/kern/process/proc.c @@ -451,7 +451,7 @@ do_fork(uint32_t clone_flags, uintptr_t stack, struct trapframe *tf) { proc->pid = get_pid(); //将新进程插入到进程列表 hash_proc(proc); - list_add(&proc_init, &(proc->list_link)); + list_add(&proc_list, &(proc->list_link)); nr_process ++; } diff --git a/labcodes/lab4/kern/schedule/sched.c b/labcodes/lab4/kern/schedule/sched.c index 8c8c1a8e3b2a18c2a22da9fe0bda74a633e3081d..ce26778392dbb29f746201c957cc1cd428089c09 100644 --- a/labcodes/lab4/kern/schedule/sched.c +++ b/labcodes/lab4/kern/schedule/sched.c @@ -10,32 +10,54 @@ wakeup_proc(struct proc_struct *proc) { proc->state = PROC_RUNNABLE; } + +/** + * schedule是操作系统中的调度函数,用于选择下一个要执行的进程并进行上下文切换。 + * 该函数首先检查当前进程是否需要重新调度,然后在进程列表中查找处于可运行状态的进程。 + * 如果找到可运行的进程,则选择该进程作为下一个要执行的进程,并进行上下文切换。 + * 如果没有找到可运行的进程,则选择空闲进程作为下一个要执行的进程。 + * 最后,恢复中断状态并退出调度函数。 + */ void schedule(void) { + // 保存中断状态标志 bool intr_flag; + // 定义指向进程列表项的指针 list_entry_t *le, *last; + // 定义下一个要执行的进程指针,并初始化为NULL struct proc_struct *next = NULL; + // 保存当前中断状态,并禁止中断 local_intr_save(intr_flag); { + // 标记当前进程不需要重新调度 current->need_resched = 0; + // 确定进程列表的最后一个元素 last = (current == idleproc) ? &proc_list : &(current->list_link); + // 从最后一个元素开始遍历进程列表 le = last; do { + // 如果不是进程列表的末尾,则继续查找下一个可运行的进程 if ((le = list_next(le)) != &proc_list) { + // 获取当前列表项对应的进程结构体 next = le2proc(le, list_link); + // 如果进程处于可运行状态,则停止查找 if (next->state == PROC_RUNNABLE) { break; } } } while (le != last); + // 如果没有找到可运行的进程,则选择空闲进程作为下一个要执行的进程 if (next == NULL || next->state != PROC_RUNNABLE) { next = idleproc; } + // 增加下一个要执行的进程的运行次数 next->runs ++; + // 如果下一个要执行的进程不是当前进程,则进行上下文切换 if (next != current) { proc_run(next); } } + // 恢复中断状态 local_intr_restore(intr_flag); } diff --git a/labcodes/lab4/obj/boot/bootasm.o b/labcodes/lab4/obj/boot/bootasm.o index 8f8a448c0f997893757f9c6a96de6cb78775ba73..7b1911f5c2049a66aab2b810c8e93993b657831f 100644 Binary files a/labcodes/lab4/obj/boot/bootasm.o and b/labcodes/lab4/obj/boot/bootasm.o differ diff --git a/labcodes/lab4/obj/boot/bootmain.o b/labcodes/lab4/obj/boot/bootmain.o index 64af7b5485295bcbc822af93d8632b9cd908fc6a..3a99b75e24b4ea24223abc9fefacc213f54c34bb 100644 Binary files a/labcodes/lab4/obj/boot/bootmain.o and b/labcodes/lab4/obj/boot/bootmain.o differ diff --git a/labcodes/lab4/obj/bootblock.asm b/labcodes/lab4/obj/bootblock.asm index 1d73162c42ce46408d47d0e9107bdeaab6de42dc..046327af8dd3e182ecd5c039c5c7a214bdd87bff 100644 --- a/labcodes/lab4/obj/bootblock.asm +++ b/labcodes/lab4/obj/bootblock.asm @@ -150,7 +150,7 @@ protcseg: #定义标签 protcseg,表示保护模式下的代码段开始。 movl $start, %esp 7c80: bc 00 7c 00 00 mov $0x7c00,%esp call bootmain - 7c85: e8 9f 00 00 00 call 7d29 + 7c85: e8 a1 00 00 00 call 7d2b 00007c8a : @@ -171,187 +171,191 @@ readseg(uintptr_t va, uint32_t count, uint32_t offset) { 7c8c: 55 push %ebp 7c8d: 89 e5 mov %esp,%ebp 7c8f: 57 push %edi - 7c90: 56 push %esi - 7c91: 89 c6 mov %eax,%esi - 7c93: 53 push %ebx uintptr_t end_va = va + count; //计算结束虚拟地址 end_va - 7c94: 01 d0 add %edx,%eax -readseg(uintptr_t va, uint32_t count, uint32_t offset) { - 7c96: 83 ec 08 sub $0x8,%esp -static inline void invlpg(void *addr) __attribute__((always_inline)); - -static inline uint8_t -inb(uint16_t port) { - uint8_t data; - asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); - 7c99: bb f7 01 00 00 mov $0x1f7,%ebx - uintptr_t end_va = va + count; //计算结束虚拟地址 end_va - 7c9e: 89 45 ec mov %eax,-0x14(%ebp) + 7c90: 8d 3c 10 lea (%eax,%edx,1),%edi // round down to sector boundary 将虚拟地址 va 调整到扇区边界,确保从正确的地址读取数据。 va -= offset % SECTSIZE; - 7ca1: 89 c8 mov %ecx,%eax + 7c93: 89 ca mov %ecx,%edx +readseg(uintptr_t va, uint32_t count, uint32_t offset) { + 7c95: 56 push %esi + va -= offset % SECTSIZE; + 7c96: 81 e2 ff 01 00 00 and $0x1ff,%edx // translate from bytes to sectors; kernel starts at sector 1 //将偏移量 offset 转换为扇区号 secno,因为内核镜像从第二个扇区(编号为1)开始存储。 uint32_t secno = (offset / SECTSIZE) + 1; - 7ca3: c1 e9 09 shr $0x9,%ecx + 7c9c: c1 e9 09 shr $0x9,%ecx va -= offset % SECTSIZE; - 7ca6: 25 ff 01 00 00 and $0x1ff,%eax - 7cab: 29 c6 sub %eax,%esi + 7c9f: 29 d0 sub %edx,%eax +readseg(uintptr_t va, uint32_t count, uint32_t offset) { + 7ca1: 53 push %ebx + va -= offset % SECTSIZE; + 7ca2: 89 c6 mov %eax,%esi + uint32_t secno = (offset / SECTSIZE) + 1; + 7ca4: 8d 41 01 lea 0x1(%ecx),%eax +readseg(uintptr_t va, uint32_t count, uint32_t offset) { + 7ca7: 83 ec 08 sub $0x8,%esp + uintptr_t end_va = va + count; //计算结束虚拟地址 end_va + 7caa: 89 7d ec mov %edi,-0x14(%ebp) +static inline void invlpg(void *addr) __attribute__((always_inline)); + +static inline uint8_t +inb(uint16_t port) { + uint8_t data; + asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); + 7cad: bb f7 01 00 00 mov $0x1f7,%ebx uint32_t secno = (offset / SECTSIZE) + 1; - 7cad: 8d 41 01 lea 0x1(%ecx),%eax - 7cb0: 89 45 f0 mov %eax,-0x10(%ebp) + 7cb2: 89 45 f0 mov %eax,-0x10(%ebp) // 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. //循环读取数据,直到读取到结束虚拟地址 end_va。 //每次调用 readsect() 读取一个扇区的数据到指定的虚拟地址。 for (; va < end_va; va += SECTSIZE, secno ++) { - 7cb3: 3b 75 ec cmp -0x14(%ebp),%esi - 7cb6: 73 6a jae 7d22 - 7cb8: 89 da mov %ebx,%edx - 7cba: ec in (%dx),%al + 7cb5: 3b 75 ec cmp -0x14(%ebp),%esi + 7cb8: 73 6a jae 7d24 + 7cba: 89 da mov %ebx,%edx + 7cbc: ec in (%dx),%al while ((inb(0x1F7) & 0xC0) != 0x40) - 7cbb: 24 c0 and $0xc0,%al - 7cbd: 3c 40 cmp $0x40,%al - 7cbf: 75 f7 jne 7cb8 + 7cbd: 24 c0 and $0xc0,%al + 7cbf: 3c 40 cmp $0x40,%al + 7cc1: 75 f7 jne 7cba : "memory", "cc"); } static inline void outb(uint16_t port, uint8_t data) { asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); - 7cc1: ba f2 01 00 00 mov $0x1f2,%edx - 7cc6: b0 01 mov $0x1,%al - 7cc8: ee out %al,(%dx) - 7cc9: ba f3 01 00 00 mov $0x1f3,%edx - 7cce: 8a 45 f0 mov -0x10(%ebp),%al - 7cd1: ee out %al,(%dx) + 7cc3: ba f2 01 00 00 mov $0x1f2,%edx + 7cc8: b0 01 mov $0x1,%al + 7cca: ee out %al,(%dx) + 7ccb: ba f3 01 00 00 mov $0x1f3,%edx + 7cd0: 8a 45 f0 mov -0x10(%ebp),%al + 7cd3: ee out %al,(%dx) outb(0x1F4, (secno >> 8) & 0xFF); - 7cd2: 8b 45 f0 mov -0x10(%ebp),%eax - 7cd5: ba f4 01 00 00 mov $0x1f4,%edx - 7cda: c1 e8 08 shr $0x8,%eax - 7cdd: ee out %al,(%dx) + 7cd4: 8b 45 f0 mov -0x10(%ebp),%eax + 7cd7: ba f4 01 00 00 mov $0x1f4,%edx + 7cdc: c1 e8 08 shr $0x8,%eax + 7cdf: ee out %al,(%dx) outb(0x1F5, (secno >> 16) & 0xFF); - 7cde: 8b 45 f0 mov -0x10(%ebp),%eax - 7ce1: ba f5 01 00 00 mov $0x1f5,%edx - 7ce6: c1 e8 10 shr $0x10,%eax - 7ce9: ee out %al,(%dx) + 7ce0: 8b 45 f0 mov -0x10(%ebp),%eax + 7ce3: ba f5 01 00 00 mov $0x1f5,%edx + 7ce8: c1 e8 10 shr $0x10,%eax + 7ceb: ee out %al,(%dx) outb(0x1F6, ((secno >> 24) & 0xF) | 0xE0); - 7cea: 8b 45 f0 mov -0x10(%ebp),%eax - 7ced: ba f6 01 00 00 mov $0x1f6,%edx - 7cf2: c1 e8 18 shr $0x18,%eax - 7cf5: 24 0f and $0xf,%al - 7cf7: 0c e0 or $0xe0,%al - 7cf9: ee out %al,(%dx) - 7cfa: b0 20 mov $0x20,%al - 7cfc: 89 da mov %ebx,%edx - 7cfe: ee out %al,(%dx) + 7cec: 8b 45 f0 mov -0x10(%ebp),%eax + 7cef: ba f6 01 00 00 mov $0x1f6,%edx + 7cf4: c1 e8 18 shr $0x18,%eax + 7cf7: 24 0f and $0xf,%al + 7cf9: 0c e0 or $0xe0,%al + 7cfb: ee out %al,(%dx) + 7cfc: b0 20 mov $0x20,%al + 7cfe: 89 da mov %ebx,%edx + 7d00: ee out %al,(%dx) asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); - 7cff: 89 da mov %ebx,%edx - 7d01: ec in (%dx),%al + 7d01: 89 da mov %ebx,%edx + 7d03: ec in (%dx),%al while ((inb(0x1F7) & 0xC0) != 0x40) - 7d02: 24 c0 and $0xc0,%al - 7d04: 3c 40 cmp $0x40,%al - 7d06: 75 f7 jne 7cff + 7d04: 24 c0 and $0xc0,%al + 7d06: 3c 40 cmp $0x40,%al + 7d08: 75 f7 jne 7d01 asm volatile ( - 7d08: 89 f7 mov %esi,%edi - 7d0a: b9 80 00 00 00 mov $0x80,%ecx - 7d0f: ba f0 01 00 00 mov $0x1f0,%edx - 7d14: fc cld - 7d15: f2 6d repnz insl (%dx),%es:(%edi) + 7d0a: 89 f7 mov %esi,%edi + 7d0c: b9 80 00 00 00 mov $0x80,%ecx + 7d11: ba f0 01 00 00 mov $0x1f0,%edx + 7d16: fc cld + 7d17: f2 6d repnz insl (%dx),%es:(%edi) for (; va < end_va; va += SECTSIZE, secno ++) { - 7d17: ff 45 f0 incl -0x10(%ebp) - 7d1a: 81 c6 00 02 00 00 add $0x200,%esi - 7d20: eb 91 jmp 7cb3 + 7d19: ff 45 f0 incl -0x10(%ebp) + 7d1c: 81 c6 00 02 00 00 add $0x200,%esi + 7d22: eb 91 jmp 7cb5 readsect((void *)va, secno); } } - 7d22: 58 pop %eax - 7d23: 5a pop %edx - 7d24: 5b pop %ebx - 7d25: 5e pop %esi - 7d26: 5f pop %edi - 7d27: 5d pop %ebp - 7d28: c3 ret + 7d24: 58 pop %eax + 7d25: 5a pop %edx + 7d26: 5b pop %ebx + 7d27: 5e pop %esi + 7d28: 5f pop %edi + 7d29: 5d pop %ebp + 7d2a: c3 ret -00007d29 : +00007d2b : /* bootmain - the entry of bootloader */ //bootmain() 函数是引导加载程序的入口点。 void bootmain(void) { - 7d29: f3 0f 1e fb endbr32 - 7d2d: 55 push %ebp + 7d2b: 55 push %ebp // read the 1st page off disk //从磁盘读取前8个扇区(4096字节)到 ELFHDR 指向的内存地址,准备解析ELF头。 readseg((uintptr_t)ELFHDR, SECTSIZE * 8, 0); - 7d2e: 31 c9 xor %ecx,%ecx + 7d2c: 31 c9 xor %ecx,%ecx bootmain(void) { - 7d30: 89 e5 mov %esp,%ebp + 7d2e: 89 e5 mov %esp,%ebp readseg((uintptr_t)ELFHDR, SECTSIZE * 8, 0); - 7d32: ba 00 10 00 00 mov $0x1000,%edx + 7d30: ba 00 10 00 00 mov $0x1000,%edx bootmain(void) { - 7d37: 56 push %esi + 7d35: 56 push %esi readseg((uintptr_t)ELFHDR, SECTSIZE * 8, 0); - 7d38: b8 00 00 01 00 mov $0x10000,%eax + 7d36: b8 00 00 01 00 mov $0x10000,%eax bootmain(void) { - 7d3d: 53 push %ebx + 7d3b: 53 push %ebx readseg((uintptr_t)ELFHDR, SECTSIZE * 8, 0); - 7d3e: e8 49 ff ff ff call 7c8c + 7d3c: e8 4b ff ff ff call 7c8c // is this a valid ELF? //检查读取的ELF头部的魔数(magic number)是否有效。如果无效,跳转到 bad 标签处理。 if (ELFHDR->e_magic != ELF_MAGIC) { - 7d43: 81 3d 00 00 01 00 7f cmpl $0x464c457f,0x10000 - 7d4a: 45 4c 46 - 7d4d: 75 3f jne 7d8e + 7d41: 81 3d 00 00 01 00 7f cmpl $0x464c457f,0x10000 + 7d48: 45 4c 46 + 7d4b: 75 3f jne 7d8c //定义指针 ph 和 eph,分别指向程序头和程序头的结束位置。 struct proghdr *ph, *eph; // load each program segment (ignores ph flags) //将程序头的起始地址设置为 ELFHDR 中的 e_phoff 偏移,并计算结束位置 eph。 ph = (struct proghdr *)((uintptr_t)ELFHDR + ELFHDR->e_phoff); - 7d4f: a1 1c 00 01 00 mov 0x1001c,%eax + 7d4d: a1 1c 00 01 00 mov 0x1001c,%eax eph = ph + ELFHDR->e_phnum; - 7d54: 0f b7 35 2c 00 01 00 movzwl 0x1002c,%esi + 7d52: 0f b7 35 2c 00 01 00 movzwl 0x1002c,%esi ph = (struct proghdr *)((uintptr_t)ELFHDR + ELFHDR->e_phoff); - 7d5b: 8d 98 00 00 01 00 lea 0x10000(%eax),%ebx + 7d59: 8d 98 00 00 01 00 lea 0x10000(%eax),%ebx eph = ph + ELFHDR->e_phnum; - 7d61: c1 e6 05 shl $0x5,%esi - 7d64: 01 de add %ebx,%esi + 7d5f: c1 e6 05 shl $0x5,%esi + 7d62: 01 de add %ebx,%esi //循环读取每个程序段的数据,调用 readseg() 将内核程序段加载到内存指定地址。 for (; ph < eph; ph ++) { - 7d66: 39 f3 cmp %esi,%ebx - 7d68: 73 18 jae 7d82 + 7d64: 39 f3 cmp %esi,%ebx + 7d66: 73 18 jae 7d80 readseg(ph->p_va & 0xFFFFFF, ph->p_memsz, ph->p_offset); - 7d6a: 8b 43 08 mov 0x8(%ebx),%eax + 7d68: 8b 43 08 mov 0x8(%ebx),%eax for (; ph < eph; ph ++) { - 7d6d: 83 c3 20 add $0x20,%ebx + 7d6b: 83 c3 20 add $0x20,%ebx readseg(ph->p_va & 0xFFFFFF, ph->p_memsz, ph->p_offset); - 7d70: 8b 4b e4 mov -0x1c(%ebx),%ecx - 7d73: 8b 53 f4 mov -0xc(%ebx),%edx - 7d76: 25 ff ff ff 00 and $0xffffff,%eax - 7d7b: e8 0c ff ff ff call 7c8c - 7d80: eb e4 jmp 7d66 + 7d6e: 8b 4b e4 mov -0x1c(%ebx),%ecx + 7d71: 8b 53 f4 mov -0xc(%ebx),%edx + 7d74: 25 ff ff ff 00 and $0xffffff,%eax + 7d79: e8 0e ff ff ff call 7c8c + 7d7e: eb e4 jmp 7d64 } // call the entry point from the ELF header // note: does not return //从ELF头部获取内核的入口点,调用该入口函数,注意此调用不会返回。 ((void (*)(void))(ELFHDR->e_entry & 0xFFFFFF))(); - 7d82: a1 18 00 01 00 mov 0x10018,%eax - 7d87: 25 ff ff ff 00 and $0xffffff,%eax - 7d8c: ff d0 call *%eax + 7d80: a1 18 00 01 00 mov 0x10018,%eax + 7d85: 25 ff ff ff 00 and $0xffffff,%eax + 7d8a: ff d0 call *%eax } static inline void outw(uint16_t port, uint16_t data) { asm volatile ("outw %0, %1" :: "a" (data), "d" (port) : "memory"); - 7d8e: ba 00 8a ff ff mov $0xffff8a00,%edx - 7d93: 89 d0 mov %edx,%eax - 7d95: 66 ef out %ax,(%dx) - 7d97: b8 00 8e ff ff mov $0xffff8e00,%eax - 7d9c: 66 ef out %ax,(%dx) - 7d9e: eb fe jmp 7d9e + 7d8c: ba 00 8a ff ff mov $0xffff8a00,%edx + 7d91: 89 d0 mov %edx,%eax + 7d93: 66 ef out %ax,(%dx) + 7d95: b8 00 8e ff ff mov $0xffff8e00,%eax + 7d9a: 66 ef out %ax,(%dx) + 7d9c: eb fe jmp 7d9c diff --git a/labcodes/lab4/obj/bootblock.o b/labcodes/lab4/obj/bootblock.o index 18e8e5058556bf66778777bc8e8d2188dfa9156a..23a8eeb064084d2830271d44071f788e41ab6512 100755 Binary files a/labcodes/lab4/obj/bootblock.o and b/labcodes/lab4/obj/bootblock.o differ diff --git a/labcodes/lab4/obj/bootblock.out b/labcodes/lab4/obj/bootblock.out index e6ffe0c5784d2d67e0a91f02154a0beaad57f71a..4bbb6755d2289c820b5c874c4ecdfe0a93460849 100755 Binary files a/labcodes/lab4/obj/bootblock.out and b/labcodes/lab4/obj/bootblock.out differ diff --git a/labcodes/lab4/obj/kern/debug/kdebug.o b/labcodes/lab4/obj/kern/debug/kdebug.o index 9231a864af4e59e76614dab169ca46f9d1778f1d..f31d934ae957860b65b5cd56231804fb083be26a 100644 Binary files a/labcodes/lab4/obj/kern/debug/kdebug.o and b/labcodes/lab4/obj/kern/debug/kdebug.o differ diff --git a/labcodes/lab4/obj/kern/debug/kmonitor.o b/labcodes/lab4/obj/kern/debug/kmonitor.o index 89c17c86b4b9c172282c0dabd232c4d3719b8187..c017d8b574656587ef3fa54b8fb2a3eefa687c2e 100644 Binary files a/labcodes/lab4/obj/kern/debug/kmonitor.o and b/labcodes/lab4/obj/kern/debug/kmonitor.o differ diff --git a/labcodes/lab4/obj/kern/debug/panic.o b/labcodes/lab4/obj/kern/debug/panic.o index 4791b78341c018be20ae656663c86a7abb8e887f..b96eab54e3e8c064ff8fbc46dcf963bc98851cd9 100644 Binary files a/labcodes/lab4/obj/kern/debug/panic.o and b/labcodes/lab4/obj/kern/debug/panic.o differ diff --git a/labcodes/lab4/obj/kern/driver/clock.o b/labcodes/lab4/obj/kern/driver/clock.o index 17da8afcbd466e7d425533d036210c423e570899..621e9a16d966fcd3554e8567fa51fcae9eeb6ffb 100644 Binary files a/labcodes/lab4/obj/kern/driver/clock.o and b/labcodes/lab4/obj/kern/driver/clock.o differ diff --git a/labcodes/lab4/obj/kern/driver/console.o b/labcodes/lab4/obj/kern/driver/console.o index 41dc36d23a10d2107a709f88d675e432183de0a7..a99691ff3cde0d772f1625450f95aa3d06250c1c 100644 Binary files a/labcodes/lab4/obj/kern/driver/console.o and b/labcodes/lab4/obj/kern/driver/console.o differ diff --git a/labcodes/lab4/obj/kern/driver/ide.o b/labcodes/lab4/obj/kern/driver/ide.o index 12b2bc28e6cbc93b7a2a2e427c5714c91363dacb..ff1525f333f8d9f6f585ebfa29a2c7dd9ee8d1c5 100644 Binary files a/labcodes/lab4/obj/kern/driver/ide.o and b/labcodes/lab4/obj/kern/driver/ide.o differ diff --git a/labcodes/lab4/obj/kern/driver/intr.o b/labcodes/lab4/obj/kern/driver/intr.o index df743ea23b26a20b94a30d7549815fe064ffaf8f..ae30eda041cbc61fe690d88a4c1694d2a98aa496 100644 Binary files a/labcodes/lab4/obj/kern/driver/intr.o and b/labcodes/lab4/obj/kern/driver/intr.o differ diff --git a/labcodes/lab4/obj/kern/driver/picirq.o b/labcodes/lab4/obj/kern/driver/picirq.o index a2caebd3a44619e22e2afa42c224cfbd1b3a3fdc..ace5347e92cc594c1b60313b8f6615275b5e4439 100644 Binary files a/labcodes/lab4/obj/kern/driver/picirq.o and b/labcodes/lab4/obj/kern/driver/picirq.o differ diff --git a/labcodes/lab4/obj/kern/fs/swapfs.o b/labcodes/lab4/obj/kern/fs/swapfs.o index ff3aacff1f9c1b775921fdc336829425ebe4c152..84a5ff48b24bc17ed0e47036337e6f07816cfb0a 100644 Binary files a/labcodes/lab4/obj/kern/fs/swapfs.o and b/labcodes/lab4/obj/kern/fs/swapfs.o differ diff --git a/labcodes/lab4/obj/kern/init/entry.o b/labcodes/lab4/obj/kern/init/entry.o index 130bd6c8e99777bf0f5be88ff2b2322c8ee4aaa1..7f9c411f5b7fec353d17dbff232bf0bf7e6ddefe 100644 Binary files a/labcodes/lab4/obj/kern/init/entry.o and b/labcodes/lab4/obj/kern/init/entry.o differ diff --git a/labcodes/lab4/obj/kern/init/init.o b/labcodes/lab4/obj/kern/init/init.o index 5adc1c3196e7c07732f3e4e29e209440143d9204..de8ec0fc174289dc44e8a1447996002241632063 100644 Binary files a/labcodes/lab4/obj/kern/init/init.o and b/labcodes/lab4/obj/kern/init/init.o differ diff --git a/labcodes/lab4/obj/kern/libs/readline.o b/labcodes/lab4/obj/kern/libs/readline.o index 2c22bf30fc60afcbf8a229ea99dfbca64de7ec58..ff86b2d49d90136bac3939da6bc1486807bd25d6 100644 Binary files a/labcodes/lab4/obj/kern/libs/readline.o and b/labcodes/lab4/obj/kern/libs/readline.o differ diff --git a/labcodes/lab4/obj/kern/libs/stdio.o b/labcodes/lab4/obj/kern/libs/stdio.o index 2bd0affc0efe446387b6c7f64fe20d52e8b46491..11b8d8ca228c5be48a85dacc97347b50c7b57379 100644 Binary files a/labcodes/lab4/obj/kern/libs/stdio.o and b/labcodes/lab4/obj/kern/libs/stdio.o differ diff --git a/labcodes/lab4/obj/kern/mm/default_pmm.o b/labcodes/lab4/obj/kern/mm/default_pmm.o index 2dc1a8afee266592fabafb2f1e18daf507b0bc58..a6a6fe79569dbc15ec6946a0f83b02b045821909 100644 Binary files a/labcodes/lab4/obj/kern/mm/default_pmm.o and b/labcodes/lab4/obj/kern/mm/default_pmm.o differ diff --git a/labcodes/lab4/obj/kern/mm/kmalloc.o b/labcodes/lab4/obj/kern/mm/kmalloc.o index 14f1c6f1c963b8fcd35be0de76737a49a2f1e83b..038c99f4b93896575913b01e8235a7d7b6b1263c 100644 Binary files a/labcodes/lab4/obj/kern/mm/kmalloc.o and b/labcodes/lab4/obj/kern/mm/kmalloc.o differ diff --git a/labcodes/lab4/obj/kern/mm/pmm.o b/labcodes/lab4/obj/kern/mm/pmm.o index b46d54976f95ee6f85ebdf6d35fa40acfafff72d..8019126489f18c0a6481d2c80bc4a42f8aa76bb3 100644 Binary files a/labcodes/lab4/obj/kern/mm/pmm.o and b/labcodes/lab4/obj/kern/mm/pmm.o differ diff --git a/labcodes/lab4/obj/kern/mm/swap.o b/labcodes/lab4/obj/kern/mm/swap.o index 354960ef4f56787753b24d7b7c5a22200d50f9de..018e7478df10b03832156de214e059c971836350 100644 Binary files a/labcodes/lab4/obj/kern/mm/swap.o and b/labcodes/lab4/obj/kern/mm/swap.o differ diff --git a/labcodes/lab4/obj/kern/mm/swap_fifo.o b/labcodes/lab4/obj/kern/mm/swap_fifo.o index 286b04fc13843783fc9bacc838c05e320d92af28..a74f2ae56b7b78d0d1ac0581968e3826e975bb08 100644 Binary files a/labcodes/lab4/obj/kern/mm/swap_fifo.o and b/labcodes/lab4/obj/kern/mm/swap_fifo.o differ diff --git a/labcodes/lab4/obj/kern/mm/vmm.d b/labcodes/lab4/obj/kern/mm/vmm.d index 76e91d773abeb5b0d0c6af29642aaca4d6ee9bba..3f60b7190e3b0963717e3e5169f47dd3bbde7adc 100644 --- a/labcodes/lab4/obj/kern/mm/vmm.d +++ b/labcodes/lab4/obj/kern/mm/vmm.d @@ -2,4 +2,4 @@ obj/kern/mm/vmm.o obj/kern/mm/vmm.d: kern/mm/vmm.c kern/mm/vmm.h \ libs/defs.h libs/list.h kern/mm/memlayout.h libs/atomic.h \ kern/sync/sync.h libs/x86.h kern/driver/intr.h kern/mm/mmu.h \ libs/string.h kern/debug/assert.h libs/stdio.h libs/stdarg.h \ - libs/error.h kern/mm/pmm.h kern/mm/swap.h + libs/error.h kern/mm/pmm.h kern/mm/swap.h kern/mm/kmalloc.h diff --git a/labcodes/lab4/obj/kern/mm/vmm.o b/labcodes/lab4/obj/kern/mm/vmm.o index ae49d1ec11e65d88423b8da2f34006afb56e99a2..0374518653d206609f36f53dcfd0c81fb583274f 100644 Binary files a/labcodes/lab4/obj/kern/mm/vmm.o and b/labcodes/lab4/obj/kern/mm/vmm.o differ diff --git a/labcodes/lab4/obj/kern/process/entry.o b/labcodes/lab4/obj/kern/process/entry.o index 058d76d977eee646efb46cbc4594a0d9565a6b91..994eb4947d7c8a625894bed8f205a7eaff886ad9 100644 Binary files a/labcodes/lab4/obj/kern/process/entry.o and b/labcodes/lab4/obj/kern/process/entry.o differ diff --git a/labcodes/lab4/obj/kern/process/proc.o b/labcodes/lab4/obj/kern/process/proc.o index 3e3a68726672eb1b94da12ac2a6c1eabfbfeedc9..1fcac14f9191fd664b90f2df4d5d0c59bac21a7e 100644 Binary files a/labcodes/lab4/obj/kern/process/proc.o and b/labcodes/lab4/obj/kern/process/proc.o differ diff --git a/labcodes/lab4/obj/kern/process/switch.o b/labcodes/lab4/obj/kern/process/switch.o index c16237dfe6c7ebd51f3fc60b468ace98649f6f32..6070d88d605394acdbcbdc20e1bef445b1b8a72c 100644 Binary files a/labcodes/lab4/obj/kern/process/switch.o and b/labcodes/lab4/obj/kern/process/switch.o differ diff --git a/labcodes/lab4/obj/kern/schedule/sched.o b/labcodes/lab4/obj/kern/schedule/sched.o index e4550c2a0260440ea44a00cbd636e59ed383f697..40195c513685e7d3fc0b72b7255c331af20a73a9 100644 Binary files a/labcodes/lab4/obj/kern/schedule/sched.o and b/labcodes/lab4/obj/kern/schedule/sched.o differ diff --git a/labcodes/lab4/obj/kern/trap/trap.o b/labcodes/lab4/obj/kern/trap/trap.o index bccf11f87a93498c9d1949fcbb2a8e3c497c9e38..fd575bf936a817d7f83177174d8b3ac9feb95d74 100644 Binary files a/labcodes/lab4/obj/kern/trap/trap.o and b/labcodes/lab4/obj/kern/trap/trap.o differ diff --git a/labcodes/lab4/obj/kern/trap/trapentry.o b/labcodes/lab4/obj/kern/trap/trapentry.o index 8b1ed42087e9f24928515b40c8a7ac95eef4cf93..ae27ff1ff5ba7982756322232c4fe08e7ceabd50 100644 Binary files a/labcodes/lab4/obj/kern/trap/trapentry.o and b/labcodes/lab4/obj/kern/trap/trapentry.o differ diff --git a/labcodes/lab4/obj/kern/trap/vectors.o b/labcodes/lab4/obj/kern/trap/vectors.o index 5e5c9c4495fcc0dafe7c8886baa156725aac9dec..ff0a26e00263eb4a7eeba015c654c2d388c370bd 100644 Binary files a/labcodes/lab4/obj/kern/trap/vectors.o and b/labcodes/lab4/obj/kern/trap/vectors.o differ diff --git a/labcodes/lab4/obj/kernel.asm b/labcodes/lab4/obj/kernel.asm index 5ddb2156956a935930b58cce2c516385c2bb86d2..5c75fb8df4bc85ed5e193dc14d9f60b1e66d077e 100644 --- a/labcodes/lab4/obj/kernel.asm +++ b/labcodes/lab4/obj/kernel.asm @@ -67,19516 +67,19466 @@ static void lab1_switch_test(void); int kern_init(void) { -c0100036: f3 0f 1e fb endbr32 -c010003a: 55 push %ebp -c010003b: 89 e5 mov %esp,%ebp -c010003d: 83 ec 28 sub $0x28,%esp +c0100036: 55 push %ebp +c0100037: 89 e5 mov %esp,%ebp +c0100039: 83 ec 28 sub $0x28,%esp extern char edata[], end[]; //声明外部变量 edata 和 end memset(edata, 0, end - edata); // 将数据段清零 -c0100040: b8 b8 e1 12 c0 mov $0xc012e1b8,%eax -c0100045: 2d 00 b0 12 c0 sub $0xc012b000,%eax -c010004a: 89 44 24 08 mov %eax,0x8(%esp) -c010004e: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0100055: 00 -c0100056: c7 04 24 00 b0 12 c0 movl $0xc012b000,(%esp) -c010005d: e8 f2 98 00 00 call c0109954 +c010003c: b8 b4 e1 12 c0 mov $0xc012e1b4,%eax +c0100041: 2d 00 b0 12 c0 sub $0xc012b000,%eax +c0100046: 89 44 24 08 mov %eax,0x8(%esp) +c010004a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0100051: 00 +c0100052: c7 04 24 00 b0 12 c0 movl $0xc012b000,(%esp) +c0100059: e8 86 9e 00 00 call c0109ee4 cons_init(); // init the console 初始化控制台 -c0100062: e8 1a 1e 00 00 call c0101e81 +c010005e: e8 54 15 00 00 call c01015b7 const char *message = "(THU.CST) os is loading ..."; -c0100067: c7 45 f4 a0 a2 10 c0 movl $0xc010a2a0,-0xc(%ebp) +c0100063: c7 45 f4 80 a0 10 c0 movl $0xc010a080,-0xc(%ebp) cprintf("%s\n\n", message);// 将消息输出到控制台 -c010006e: 8b 45 f4 mov -0xc(%ebp),%eax -c0100071: 89 44 24 04 mov %eax,0x4(%esp) -c0100075: c7 04 24 bc a2 10 c0 movl $0xc010a2bc,(%esp) -c010007c: e8 56 02 00 00 call c01002d7 +c010006a: 8b 45 f4 mov -0xc(%ebp),%eax +c010006d: 89 44 24 04 mov %eax,0x4(%esp) +c0100071: c7 04 24 9c a0 10 c0 movl $0xc010a09c,(%esp) +c0100078: e8 fb 02 00 00 call c0100378 print_kerninfo();// 输出内核信息的函数 -c0100081: e8 14 09 00 00 call c010099a +c010007d: e8 19 08 00 00 call c010089b grade_backtrace(); //调用回溯函数,通常用于调试,显示函数调用栈。 -c0100086: e8 a7 00 00 00 call c0100132 +c0100082: e8 a7 00 00 00 call c010012e pmm_init(); // init physical memory management初始化物理内存管理 -c010008b: e8 aa 3c 00 00 call c0103d3a +c0100087: e8 1d 55 00 00 call c01055a9 pic_init(); // init interrupt controller初始化可编程中断控制器 -c0100090: e8 67 1f 00 00 call c0101ffc +c010008c: e8 04 1f 00 00 call c0101f95 idt_init(); // init interrupt descriptor table初始化中断描述符表 -c0100095: e8 e7 20 00 00 call c0102181 +c0100091: e8 68 20 00 00 call c01020fe vmm_init(); // init virtual memory management 初始化虚拟内存管理 -c010009a: e8 15 58 00 00 call c01058b4 +c0100096: e8 5a 7c 00 00 call c0107cf5 + + proc_init(); // init process table +c010009b: e8 3e 90 00 00 call c01090de ide_init(); // init ide devices初始化IDE设备 -c010009f: e8 12 0d 00 00 call c0100db6 +c01000a0: e8 4c 16 00 00 call c01016f1 swap_init(); // init swap 初始化交换分区 -c01000a4: e8 74 69 00 00 call c0106a1d +c01000a5: e8 44 67 00 00 call c01067ee clock_init(); // init clock interrupt 初始化时钟中断 -c01000a9: e8 1a 15 00 00 call c01015c8 +c01000aa: e8 67 0c 00 00 call c0100d16 intr_enable(); // enable irq interrupt -c01000ae: e8 95 20 00 00 call c0102148 +c01000af: e8 3f 1e 00 00 call c0101ef3 //LAB1: CAHLLENGE 1 If you try to do it, uncomment lab1_switch_test() // user/kernel mode switch test //lab1_switch_test(); - cpu_idle(); // run idle process -c01000b3: e8 e5 93 00 00 call c010949d + cpu_idle(); // run idle process 运行空闲进程 +c01000b4: e8 e6 91 00 00 call c010929f -c01000b8 : +c01000b9 : } //不进行内联的回溯函数,调用 mon_backtrace 显示当前的调用栈。 void __attribute__((noinline)) grade_backtrace2(int arg0, int arg1, int arg2, int arg3) { -c01000b8: f3 0f 1e fb endbr32 -c01000bc: 55 push %ebp -c01000bd: 89 e5 mov %esp,%ebp -c01000bf: 83 ec 18 sub $0x18,%esp +c01000b9: 55 push %ebp +c01000ba: 89 e5 mov %esp,%ebp +c01000bc: 83 ec 18 sub $0x18,%esp mon_backtrace(0, NULL, NULL); -c01000c2: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c01000c9: 00 -c01000ca: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c01000d1: 00 -c01000d2: c7 04 24 00 00 00 00 movl $0x0,(%esp) -c01000d9: e8 65 0c 00 00 call c0100d43 -} -c01000de: 90 nop -c01000df: c9 leave -c01000e0: c3 ret - -c01000e1 : +c01000bf: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c01000c6: 00 +c01000c7: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c01000ce: 00 +c01000cf: c7 04 24 00 00 00 00 movl $0x0,(%esp) +c01000d6: e8 56 0b 00 00 call c0100c31 +} +c01000db: 90 nop +c01000dc: 89 ec mov %ebp,%esp +c01000de: 5d pop %ebp +c01000df: c3 ret + +c01000e0 : //不进行内联的回溯函数,传递参数到 grade_backtrace2 void __attribute__((noinline)) grade_backtrace1(int arg0, int arg1) { -c01000e1: f3 0f 1e fb endbr32 -c01000e5: 55 push %ebp -c01000e6: 89 e5 mov %esp,%ebp -c01000e8: 53 push %ebx -c01000e9: 83 ec 14 sub $0x14,%esp +c01000e0: 55 push %ebp +c01000e1: 89 e5 mov %esp,%ebp +c01000e3: 83 ec 18 sub $0x18,%esp +c01000e6: 89 5d fc mov %ebx,-0x4(%ebp) grade_backtrace2(arg0, (int)&arg0, arg1, (int)&arg1); -c01000ec: 8d 4d 0c lea 0xc(%ebp),%ecx -c01000ef: 8b 55 0c mov 0xc(%ebp),%edx -c01000f2: 8d 5d 08 lea 0x8(%ebp),%ebx -c01000f5: 8b 45 08 mov 0x8(%ebp),%eax -c01000f8: 89 4c 24 0c mov %ecx,0xc(%esp) -c01000fc: 89 54 24 08 mov %edx,0x8(%esp) -c0100100: 89 5c 24 04 mov %ebx,0x4(%esp) -c0100104: 89 04 24 mov %eax,(%esp) -c0100107: e8 ac ff ff ff call c01000b8 -} -c010010c: 90 nop -c010010d: 83 c4 14 add $0x14,%esp -c0100110: 5b pop %ebx -c0100111: 5d pop %ebp -c0100112: c3 ret - -c0100113 : +c01000e9: 8d 4d 0c lea 0xc(%ebp),%ecx +c01000ec: 8b 55 0c mov 0xc(%ebp),%edx +c01000ef: 8d 5d 08 lea 0x8(%ebp),%ebx +c01000f2: 8b 45 08 mov 0x8(%ebp),%eax +c01000f5: 89 4c 24 0c mov %ecx,0xc(%esp) +c01000f9: 89 54 24 08 mov %edx,0x8(%esp) +c01000fd: 89 5c 24 04 mov %ebx,0x4(%esp) +c0100101: 89 04 24 mov %eax,(%esp) +c0100104: e8 b0 ff ff ff call c01000b9 +} +c0100109: 90 nop +c010010a: 8b 5d fc mov -0x4(%ebp),%ebx +c010010d: 89 ec mov %ebp,%esp +c010010f: 5d pop %ebp +c0100110: c3 ret + +c0100111 : //不进行内联的回溯函数,传递参数到 grade_backtrace1 void __attribute__((noinline)) grade_backtrace0(int arg0, int arg1, int arg2) { -c0100113: f3 0f 1e fb endbr32 -c0100117: 55 push %ebp -c0100118: 89 e5 mov %esp,%ebp -c010011a: 83 ec 18 sub $0x18,%esp +c0100111: 55 push %ebp +c0100112: 89 e5 mov %esp,%ebp +c0100114: 83 ec 18 sub $0x18,%esp grade_backtrace1(arg0, arg2); -c010011d: 8b 45 10 mov 0x10(%ebp),%eax -c0100120: 89 44 24 04 mov %eax,0x4(%esp) -c0100124: 8b 45 08 mov 0x8(%ebp),%eax -c0100127: 89 04 24 mov %eax,(%esp) -c010012a: e8 b2 ff ff ff call c01000e1 -} -c010012f: 90 nop -c0100130: c9 leave -c0100131: c3 ret - -c0100132 : +c0100117: 8b 45 10 mov 0x10(%ebp),%eax +c010011a: 89 44 24 04 mov %eax,0x4(%esp) +c010011e: 8b 45 08 mov 0x8(%ebp),%eax +c0100121: 89 04 24 mov %eax,(%esp) +c0100124: e8 b7 ff ff ff call c01000e0 +} +c0100129: 90 nop +c010012a: 89 ec mov %ebp,%esp +c010012c: 5d pop %ebp +c010012d: c3 ret + +c010012e : //触发回溯的起始点,传递初始化函数地址。 void grade_backtrace(void) { -c0100132: f3 0f 1e fb endbr32 -c0100136: 55 push %ebp -c0100137: 89 e5 mov %esp,%ebp -c0100139: 83 ec 18 sub $0x18,%esp +c010012e: 55 push %ebp +c010012f: 89 e5 mov %esp,%ebp +c0100131: 83 ec 18 sub $0x18,%esp grade_backtrace0(0, (int)kern_init, 0xffff0000); -c010013c: b8 36 00 10 c0 mov $0xc0100036,%eax -c0100141: c7 44 24 08 00 00 ff movl $0xffff0000,0x8(%esp) -c0100148: ff -c0100149: 89 44 24 04 mov %eax,0x4(%esp) -c010014d: c7 04 24 00 00 00 00 movl $0x0,(%esp) -c0100154: e8 ba ff ff ff call c0100113 -} -c0100159: 90 nop -c010015a: c9 leave -c010015b: c3 ret - -c010015c : +c0100134: b8 36 00 10 c0 mov $0xc0100036,%eax +c0100139: c7 44 24 08 00 00 ff movl $0xffff0000,0x8(%esp) +c0100140: ff +c0100141: 89 44 24 04 mov %eax,0x4(%esp) +c0100145: c7 04 24 00 00 00 00 movl $0x0,(%esp) +c010014c: e8 c0 ff ff ff call c0100111 +} +c0100151: 90 nop +c0100152: 89 ec mov %ebp,%esp +c0100154: 5d pop %ebp +c0100155: c3 ret + +c0100156 : //打印当前的段寄存器状态。 static void lab1_print_cur_status(void) { -c010015c: f3 0f 1e fb endbr32 -c0100160: 55 push %ebp -c0100161: 89 e5 mov %esp,%ebp -c0100163: 83 ec 28 sub $0x28,%esp +c0100156: 55 push %ebp +c0100157: 89 e5 mov %esp,%ebp +c0100159: 83 ec 28 sub $0x28,%esp static int round = 0; uint16_t reg1, reg2, reg3, reg4; //嵌入汇编代码,确保编译器不优化这些代码。 asm volatile ( -c0100166: 8c 4d f6 mov %cs,-0xa(%ebp) -c0100169: 8c 5d f4 mov %ds,-0xc(%ebp) -c010016c: 8c 45 f2 mov %es,-0xe(%ebp) -c010016f: 8c 55 f0 mov %ss,-0x10(%ebp) +c010015c: 8c 4d f6 mov %cs,-0xa(%ebp) +c010015f: 8c 5d f4 mov %ds,-0xc(%ebp) +c0100162: 8c 45 f2 mov %es,-0xe(%ebp) +c0100165: 8c 55 f0 mov %ss,-0x10(%ebp) "mov %%cs, %0;"// 将当前代码段寄存器的值移动到 reg1 "mov %%ds, %1;" "mov %%es, %2;" "mov %%ss, %3;" : "=m"(reg1), "=m"(reg2), "=m"(reg3), "=m"(reg4)); cprintf("%d: @ring %d\n", round, reg1 & 3);//打印当前的 round、权限级(ring)和各段寄存器的值。 -c0100172: 0f b7 45 f6 movzwl -0xa(%ebp),%eax -c0100176: 83 e0 03 and $0x3,%eax -c0100179: 89 c2 mov %eax,%edx -c010017b: a1 00 b0 12 c0 mov 0xc012b000,%eax -c0100180: 89 54 24 08 mov %edx,0x8(%esp) -c0100184: 89 44 24 04 mov %eax,0x4(%esp) -c0100188: c7 04 24 c1 a2 10 c0 movl $0xc010a2c1,(%esp) -c010018f: e8 43 01 00 00 call c01002d7 +c0100168: 0f b7 45 f6 movzwl -0xa(%ebp),%eax +c010016c: 83 e0 03 and $0x3,%eax +c010016f: 89 c2 mov %eax,%edx +c0100171: a1 00 b0 12 c0 mov 0xc012b000,%eax +c0100176: 89 54 24 08 mov %edx,0x8(%esp) +c010017a: 89 44 24 04 mov %eax,0x4(%esp) +c010017e: c7 04 24 a1 a0 10 c0 movl $0xc010a0a1,(%esp) +c0100185: e8 ee 01 00 00 call c0100378 cprintf("%d: cs = %x\n", round, reg1); -c0100194: 0f b7 45 f6 movzwl -0xa(%ebp),%eax -c0100198: 89 c2 mov %eax,%edx -c010019a: a1 00 b0 12 c0 mov 0xc012b000,%eax -c010019f: 89 54 24 08 mov %edx,0x8(%esp) -c01001a3: 89 44 24 04 mov %eax,0x4(%esp) -c01001a7: c7 04 24 cf a2 10 c0 movl $0xc010a2cf,(%esp) -c01001ae: e8 24 01 00 00 call c01002d7 +c010018a: 0f b7 45 f6 movzwl -0xa(%ebp),%eax +c010018e: 89 c2 mov %eax,%edx +c0100190: a1 00 b0 12 c0 mov 0xc012b000,%eax +c0100195: 89 54 24 08 mov %edx,0x8(%esp) +c0100199: 89 44 24 04 mov %eax,0x4(%esp) +c010019d: c7 04 24 af a0 10 c0 movl $0xc010a0af,(%esp) +c01001a4: e8 cf 01 00 00 call c0100378 cprintf("%d: ds = %x\n", round, reg2); -c01001b3: 0f b7 45 f4 movzwl -0xc(%ebp),%eax -c01001b7: 89 c2 mov %eax,%edx -c01001b9: a1 00 b0 12 c0 mov 0xc012b000,%eax -c01001be: 89 54 24 08 mov %edx,0x8(%esp) -c01001c2: 89 44 24 04 mov %eax,0x4(%esp) -c01001c6: c7 04 24 dd a2 10 c0 movl $0xc010a2dd,(%esp) -c01001cd: e8 05 01 00 00 call c01002d7 +c01001a9: 0f b7 45 f4 movzwl -0xc(%ebp),%eax +c01001ad: 89 c2 mov %eax,%edx +c01001af: a1 00 b0 12 c0 mov 0xc012b000,%eax +c01001b4: 89 54 24 08 mov %edx,0x8(%esp) +c01001b8: 89 44 24 04 mov %eax,0x4(%esp) +c01001bc: c7 04 24 bd a0 10 c0 movl $0xc010a0bd,(%esp) +c01001c3: e8 b0 01 00 00 call c0100378 cprintf("%d: es = %x\n", round, reg3); -c01001d2: 0f b7 45 f2 movzwl -0xe(%ebp),%eax -c01001d6: 89 c2 mov %eax,%edx -c01001d8: a1 00 b0 12 c0 mov 0xc012b000,%eax -c01001dd: 89 54 24 08 mov %edx,0x8(%esp) -c01001e1: 89 44 24 04 mov %eax,0x4(%esp) -c01001e5: c7 04 24 eb a2 10 c0 movl $0xc010a2eb,(%esp) -c01001ec: e8 e6 00 00 00 call c01002d7 +c01001c8: 0f b7 45 f2 movzwl -0xe(%ebp),%eax +c01001cc: 89 c2 mov %eax,%edx +c01001ce: a1 00 b0 12 c0 mov 0xc012b000,%eax +c01001d3: 89 54 24 08 mov %edx,0x8(%esp) +c01001d7: 89 44 24 04 mov %eax,0x4(%esp) +c01001db: c7 04 24 cb a0 10 c0 movl $0xc010a0cb,(%esp) +c01001e2: e8 91 01 00 00 call c0100378 cprintf("%d: ss = %x\n", round, reg4); -c01001f1: 0f b7 45 f0 movzwl -0x10(%ebp),%eax -c01001f5: 89 c2 mov %eax,%edx -c01001f7: a1 00 b0 12 c0 mov 0xc012b000,%eax -c01001fc: 89 54 24 08 mov %edx,0x8(%esp) -c0100200: 89 44 24 04 mov %eax,0x4(%esp) -c0100204: c7 04 24 f9 a2 10 c0 movl $0xc010a2f9,(%esp) -c010020b: e8 c7 00 00 00 call c01002d7 +c01001e7: 0f b7 45 f0 movzwl -0x10(%ebp),%eax +c01001eb: 89 c2 mov %eax,%edx +c01001ed: a1 00 b0 12 c0 mov 0xc012b000,%eax +c01001f2: 89 54 24 08 mov %edx,0x8(%esp) +c01001f6: 89 44 24 04 mov %eax,0x4(%esp) +c01001fa: c7 04 24 d9 a0 10 c0 movl $0xc010a0d9,(%esp) +c0100201: e8 72 01 00 00 call c0100378 round ++;//将 round 增加1,以便每次调用时记录状态。 -c0100210: a1 00 b0 12 c0 mov 0xc012b000,%eax -c0100215: 40 inc %eax -c0100216: a3 00 b0 12 c0 mov %eax,0xc012b000 +c0100206: a1 00 b0 12 c0 mov 0xc012b000,%eax +c010020b: 40 inc %eax +c010020c: a3 00 b0 12 c0 mov %eax,0xc012b000 } -c010021b: 90 nop -c010021c: c9 leave -c010021d: c3 ret +c0100211: 90 nop +c0100212: 89 ec mov %ebp,%esp +c0100214: 5d pop %ebp +c0100215: c3 ret -c010021e : +c0100216 : static void lab1_switch_to_user(void) { -c010021e: f3 0f 1e fb endbr32 -c0100222: 55 push %ebp -c0100223: 89 e5 mov %esp,%ebp +c0100216: 55 push %ebp +c0100217: 89 e5 mov %esp,%ebp // 从内核模式切换到用户模式 //LAB1 CHALLENGE 1 : TODO asm volatile ( -c0100225: 83 ec 08 sub $0x8,%esp -c0100228: cd 78 int $0x78 -c010022a: 89 ec mov %ebp,%esp +c0100219: 83 ec 08 sub $0x8,%esp +c010021c: cd 78 int $0x78 +c010021e: 89 ec mov %ebp,%esp "int %0 \n"//通过触发一个中断,将控制权转移到内核,切换到用户模式。 "movl %%ebp, %%esp"// 将基指针(EBP)值移动到堆栈指针(ESP),恢复堆栈指针。 : : "i"(T_SWITCH_TOU)//T_SWITCH_TOU是一个常量,表示切换到用户态的中断号。传入常量 T_SWITCH_TOU ); } -c010022c: 90 nop -c010022d: 5d pop %ebp -c010022e: c3 ret +c0100220: 90 nop +c0100221: 5d pop %ebp +c0100222: c3 ret -c010022f : +c0100223 : static void lab1_switch_to_kernel(void) { -c010022f: f3 0f 1e fb endbr32 -c0100233: 55 push %ebp -c0100234: 89 e5 mov %esp,%ebp +c0100223: 55 push %ebp +c0100224: 89 e5 mov %esp,%ebp // 从用户模式切换到内核模式 //LAB1 CHALLENGE 1 : TODO asm volatile ( -c0100236: cd 79 int $0x79 -c0100238: 89 ec mov %ebp,%esp +c0100226: cd 79 int $0x79 +c0100228: 89 ec mov %ebp,%esp "int %0 \n"// 同样触发中断,这里用的是 T_SWITCH_TOK,从用户态切换回内核态。 "movl %%ebp, %%esp \n"//恢复堆栈指针 : : "i"(T_SWITCH_TOK)//传入常量 T_SWITCH_TOU ); } -c010023a: 90 nop -c010023b: 5d pop %ebp -c010023c: c3 ret +c010022a: 90 nop +c010022b: 5d pop %ebp +c010022c: c3 ret -c010023d : +c010022d : //测试用户模式和内核模式切换。 //调用 lab1_print_cur_status 打印当前状态,进行模式切换,然后再次打印状态。 static void lab1_switch_test(void) { -c010023d: f3 0f 1e fb endbr32 -c0100241: 55 push %ebp -c0100242: 89 e5 mov %esp,%ebp -c0100244: 83 ec 18 sub $0x18,%esp +c010022d: 55 push %ebp +c010022e: 89 e5 mov %esp,%ebp +c0100230: 83 ec 18 sub $0x18,%esp lab1_print_cur_status(); -c0100247: e8 10 ff ff ff call c010015c +c0100233: e8 1e ff ff ff call c0100156 cprintf("+++ switch to user mode +++\n"); -c010024c: c7 04 24 08 a3 10 c0 movl $0xc010a308,(%esp) -c0100253: e8 7f 00 00 00 call c01002d7 +c0100238: c7 04 24 e8 a0 10 c0 movl $0xc010a0e8,(%esp) +c010023f: e8 34 01 00 00 call c0100378 lab1_switch_to_user(); -c0100258: e8 c1 ff ff ff call c010021e +c0100244: e8 cd ff ff ff call c0100216 lab1_print_cur_status(); -c010025d: e8 fa fe ff ff call c010015c +c0100249: e8 08 ff ff ff call c0100156 cprintf("+++ switch to kernel mode +++\n"); -c0100262: c7 04 24 28 a3 10 c0 movl $0xc010a328,(%esp) -c0100269: e8 69 00 00 00 call c01002d7 +c010024e: c7 04 24 08 a1 10 c0 movl $0xc010a108,(%esp) +c0100255: e8 1e 01 00 00 call c0100378 lab1_switch_to_kernel(); -c010026e: e8 bc ff ff ff call c010022f +c010025a: e8 c4 ff ff ff call c0100223 lab1_print_cur_status(); -c0100273: e8 e4 fe ff ff call c010015c +c010025f: e8 f2 fe ff ff call c0100156 +} +c0100264: 90 nop +c0100265: 89 ec mov %ebp,%esp +c0100267: 5d pop %ebp +c0100268: c3 ret + +c0100269 : + * The readline() function returns the text of the line read. If some errors + * are happened, NULL is returned. The return value is a global variable, + * thus it should be copied before it is used. + * */ +char * +readline(const char *prompt) { +c0100269: 55 push %ebp +c010026a: 89 e5 mov %esp,%ebp +c010026c: 83 ec 28 sub $0x28,%esp + if (prompt != NULL) { +c010026f: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0100273: 74 13 je c0100288 + cprintf("%s", prompt); +c0100275: 8b 45 08 mov 0x8(%ebp),%eax +c0100278: 89 44 24 04 mov %eax,0x4(%esp) +c010027c: c7 04 24 27 a1 10 c0 movl $0xc010a127,(%esp) +c0100283: e8 f0 00 00 00 call c0100378 + } + int i = 0, c; +c0100288: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) + while (1) { + c = getchar(); +c010028f: e8 73 01 00 00 call c0100407 +c0100294: 89 45 f0 mov %eax,-0x10(%ebp) + if (c < 0) { +c0100297: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c010029b: 79 07 jns c01002a4 + return NULL; +c010029d: b8 00 00 00 00 mov $0x0,%eax +c01002a2: eb 78 jmp c010031c + } + else if (c >= ' ' && i < BUFSIZE - 1) { +c01002a4: 83 7d f0 1f cmpl $0x1f,-0x10(%ebp) +c01002a8: 7e 28 jle c01002d2 +c01002aa: 81 7d f4 fe 03 00 00 cmpl $0x3fe,-0xc(%ebp) +c01002b1: 7f 1f jg c01002d2 + cputchar(c); +c01002b3: 8b 45 f0 mov -0x10(%ebp),%eax +c01002b6: 89 04 24 mov %eax,(%esp) +c01002b9: e8 e2 00 00 00 call c01003a0 + buf[i ++] = c; +c01002be: 8b 45 f4 mov -0xc(%ebp),%eax +c01002c1: 8d 50 01 lea 0x1(%eax),%edx +c01002c4: 89 55 f4 mov %edx,-0xc(%ebp) +c01002c7: 8b 55 f0 mov -0x10(%ebp),%edx +c01002ca: 88 90 20 b0 12 c0 mov %dl,-0x3fed4fe0(%eax) +c01002d0: eb 45 jmp c0100317 + } + else if (c == '\b' && i > 0) { +c01002d2: 83 7d f0 08 cmpl $0x8,-0x10(%ebp) +c01002d6: 75 16 jne c01002ee +c01002d8: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c01002dc: 7e 10 jle c01002ee + cputchar(c); +c01002de: 8b 45 f0 mov -0x10(%ebp),%eax +c01002e1: 89 04 24 mov %eax,(%esp) +c01002e4: e8 b7 00 00 00 call c01003a0 + i --; +c01002e9: ff 4d f4 decl -0xc(%ebp) +c01002ec: eb 29 jmp c0100317 + } + else if (c == '\n' || c == '\r') { +c01002ee: 83 7d f0 0a cmpl $0xa,-0x10(%ebp) +c01002f2: 74 06 je c01002fa +c01002f4: 83 7d f0 0d cmpl $0xd,-0x10(%ebp) +c01002f8: 75 95 jne c010028f + cputchar(c); +c01002fa: 8b 45 f0 mov -0x10(%ebp),%eax +c01002fd: 89 04 24 mov %eax,(%esp) +c0100300: e8 9b 00 00 00 call c01003a0 + buf[i] = '\0'; +c0100305: 8b 45 f4 mov -0xc(%ebp),%eax +c0100308: 05 20 b0 12 c0 add $0xc012b020,%eax +c010030d: c6 00 00 movb $0x0,(%eax) + return buf; +c0100310: b8 20 b0 12 c0 mov $0xc012b020,%eax +c0100315: eb 05 jmp c010031c + c = getchar(); +c0100317: e9 73 ff ff ff jmp c010028f + } + } } -c0100278: 90 nop -c0100279: c9 leave -c010027a: c3 ret +c010031c: 89 ec mov %ebp,%esp +c010031e: 5d pop %ebp +c010031f: c3 ret -c010027b : +c0100320 : /* * * cputch - writes a single character @c to stdout, and it will * increace the value of counter pointed by @cnt. * */ static void cputch(int c, int *cnt) { -c010027b: f3 0f 1e fb endbr32 -c010027f: 55 push %ebp -c0100280: 89 e5 mov %esp,%ebp -c0100282: 83 ec 18 sub $0x18,%esp +c0100320: 55 push %ebp +c0100321: 89 e5 mov %esp,%ebp +c0100323: 83 ec 18 sub $0x18,%esp cons_putc(c); -c0100285: 8b 45 08 mov 0x8(%ebp),%eax -c0100288: 89 04 24 mov %eax,(%esp) -c010028b: e8 22 1c 00 00 call c0101eb2 +c0100326: 8b 45 08 mov 0x8(%ebp),%eax +c0100329: 89 04 24 mov %eax,(%esp) +c010032c: e8 b5 12 00 00 call c01015e6 (*cnt) ++; -c0100290: 8b 45 0c mov 0xc(%ebp),%eax -c0100293: 8b 00 mov (%eax),%eax -c0100295: 8d 50 01 lea 0x1(%eax),%edx -c0100298: 8b 45 0c mov 0xc(%ebp),%eax -c010029b: 89 10 mov %edx,(%eax) -} -c010029d: 90 nop -c010029e: c9 leave -c010029f: c3 ret - -c01002a0 : +c0100331: 8b 45 0c mov 0xc(%ebp),%eax +c0100334: 8b 00 mov (%eax),%eax +c0100336: 8d 50 01 lea 0x1(%eax),%edx +c0100339: 8b 45 0c mov 0xc(%ebp),%eax +c010033c: 89 10 mov %edx,(%eax) +} +c010033e: 90 nop +c010033f: 89 ec mov %ebp,%esp +c0100341: 5d pop %ebp +c0100342: c3 ret + +c0100343 : * * Call this function if you are already dealing with a va_list. * Or you probably want cprintf() instead. * */ int vcprintf(const char *fmt, va_list ap) { -c01002a0: f3 0f 1e fb endbr32 -c01002a4: 55 push %ebp -c01002a5: 89 e5 mov %esp,%ebp -c01002a7: 83 ec 28 sub $0x28,%esp +c0100343: 55 push %ebp +c0100344: 89 e5 mov %esp,%ebp +c0100346: 83 ec 28 sub $0x28,%esp int cnt = 0; -c01002aa: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c0100349: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) vprintfmt((void*)cputch, &cnt, fmt, ap); -c01002b1: 8b 45 0c mov 0xc(%ebp),%eax -c01002b4: 89 44 24 0c mov %eax,0xc(%esp) -c01002b8: 8b 45 08 mov 0x8(%ebp),%eax -c01002bb: 89 44 24 08 mov %eax,0x8(%esp) -c01002bf: 8d 45 f4 lea -0xc(%ebp),%eax -c01002c2: 89 44 24 04 mov %eax,0x4(%esp) -c01002c6: c7 04 24 7b 02 10 c0 movl $0xc010027b,(%esp) -c01002cd: e8 ee 99 00 00 call c0109cc0 +c0100350: 8b 45 0c mov 0xc(%ebp),%eax +c0100353: 89 44 24 0c mov %eax,0xc(%esp) +c0100357: 8b 45 08 mov 0x8(%ebp),%eax +c010035a: 89 44 24 08 mov %eax,0x8(%esp) +c010035e: 8d 45 f4 lea -0xc(%ebp),%eax +c0100361: 89 44 24 04 mov %eax,0x4(%esp) +c0100365: c7 04 24 20 03 10 c0 movl $0xc0100320,(%esp) +c010036c: e8 c6 92 00 00 call c0109637 return cnt; -c01002d2: 8b 45 f4 mov -0xc(%ebp),%eax +c0100371: 8b 45 f4 mov -0xc(%ebp),%eax } -c01002d5: c9 leave -c01002d6: c3 ret +c0100374: 89 ec mov %ebp,%esp +c0100376: 5d pop %ebp +c0100377: c3 ret -c01002d7 : +c0100378 : * * The return value is the number of characters which would be * written to stdout. * */ int cprintf(const char *fmt, ...) { -c01002d7: f3 0f 1e fb endbr32 -c01002db: 55 push %ebp -c01002dc: 89 e5 mov %esp,%ebp -c01002de: 83 ec 28 sub $0x28,%esp +c0100378: 55 push %ebp +c0100379: 89 e5 mov %esp,%ebp +c010037b: 83 ec 28 sub $0x28,%esp va_list ap; int cnt; va_start(ap, fmt); -c01002e1: 8d 45 0c lea 0xc(%ebp),%eax -c01002e4: 89 45 f0 mov %eax,-0x10(%ebp) +c010037e: 8d 45 0c lea 0xc(%ebp),%eax +c0100381: 89 45 f0 mov %eax,-0x10(%ebp) cnt = vcprintf(fmt, ap); -c01002e7: 8b 45 f0 mov -0x10(%ebp),%eax -c01002ea: 89 44 24 04 mov %eax,0x4(%esp) -c01002ee: 8b 45 08 mov 0x8(%ebp),%eax -c01002f1: 89 04 24 mov %eax,(%esp) -c01002f4: e8 a7 ff ff ff call c01002a0 -c01002f9: 89 45 f4 mov %eax,-0xc(%ebp) +c0100384: 8b 45 f0 mov -0x10(%ebp),%eax +c0100387: 89 44 24 04 mov %eax,0x4(%esp) +c010038b: 8b 45 08 mov 0x8(%ebp),%eax +c010038e: 89 04 24 mov %eax,(%esp) +c0100391: e8 ad ff ff ff call c0100343 +c0100396: 89 45 f4 mov %eax,-0xc(%ebp) va_end(ap); return cnt; -c01002fc: 8b 45 f4 mov -0xc(%ebp),%eax +c0100399: 8b 45 f4 mov -0xc(%ebp),%eax } -c01002ff: c9 leave -c0100300: c3 ret +c010039c: 89 ec mov %ebp,%esp +c010039e: 5d pop %ebp +c010039f: c3 ret -c0100301 : +c01003a0 : /* cputchar - writes a single character to stdout */ void cputchar(int c) { -c0100301: f3 0f 1e fb endbr32 -c0100305: 55 push %ebp -c0100306: 89 e5 mov %esp,%ebp -c0100308: 83 ec 18 sub $0x18,%esp +c01003a0: 55 push %ebp +c01003a1: 89 e5 mov %esp,%ebp +c01003a3: 83 ec 18 sub $0x18,%esp cons_putc(c); -c010030b: 8b 45 08 mov 0x8(%ebp),%eax -c010030e: 89 04 24 mov %eax,(%esp) -c0100311: e8 9c 1b 00 00 call c0101eb2 +c01003a6: 8b 45 08 mov 0x8(%ebp),%eax +c01003a9: 89 04 24 mov %eax,(%esp) +c01003ac: e8 35 12 00 00 call c01015e6 } -c0100316: 90 nop -c0100317: c9 leave -c0100318: c3 ret +c01003b1: 90 nop +c01003b2: 89 ec mov %ebp,%esp +c01003b4: 5d pop %ebp +c01003b5: c3 ret -c0100319 : +c01003b6 : /* * * cputs- writes the string pointed by @str to stdout and * appends a newline character. * */ int cputs(const char *str) { -c0100319: f3 0f 1e fb endbr32 -c010031d: 55 push %ebp -c010031e: 89 e5 mov %esp,%ebp -c0100320: 83 ec 28 sub $0x28,%esp +c01003b6: 55 push %ebp +c01003b7: 89 e5 mov %esp,%ebp +c01003b9: 83 ec 28 sub $0x28,%esp int cnt = 0; -c0100323: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) +c01003bc: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) char c; while ((c = *str ++) != '\0') { -c010032a: eb 13 jmp c010033f +c01003c3: eb 13 jmp c01003d8 cputch(c, &cnt); -c010032c: 0f be 45 f7 movsbl -0x9(%ebp),%eax -c0100330: 8d 55 f0 lea -0x10(%ebp),%edx -c0100333: 89 54 24 04 mov %edx,0x4(%esp) -c0100337: 89 04 24 mov %eax,(%esp) -c010033a: e8 3c ff ff ff call c010027b +c01003c5: 0f be 45 f7 movsbl -0x9(%ebp),%eax +c01003c9: 8d 55 f0 lea -0x10(%ebp),%edx +c01003cc: 89 54 24 04 mov %edx,0x4(%esp) +c01003d0: 89 04 24 mov %eax,(%esp) +c01003d3: e8 48 ff ff ff call c0100320 while ((c = *str ++) != '\0') { -c010033f: 8b 45 08 mov 0x8(%ebp),%eax -c0100342: 8d 50 01 lea 0x1(%eax),%edx -c0100345: 89 55 08 mov %edx,0x8(%ebp) -c0100348: 0f b6 00 movzbl (%eax),%eax -c010034b: 88 45 f7 mov %al,-0x9(%ebp) -c010034e: 80 7d f7 00 cmpb $0x0,-0x9(%ebp) -c0100352: 75 d8 jne c010032c +c01003d8: 8b 45 08 mov 0x8(%ebp),%eax +c01003db: 8d 50 01 lea 0x1(%eax),%edx +c01003de: 89 55 08 mov %edx,0x8(%ebp) +c01003e1: 0f b6 00 movzbl (%eax),%eax +c01003e4: 88 45 f7 mov %al,-0x9(%ebp) +c01003e7: 80 7d f7 00 cmpb $0x0,-0x9(%ebp) +c01003eb: 75 d8 jne c01003c5 } cputch('\n', &cnt); -c0100354: 8d 45 f0 lea -0x10(%ebp),%eax -c0100357: 89 44 24 04 mov %eax,0x4(%esp) -c010035b: c7 04 24 0a 00 00 00 movl $0xa,(%esp) -c0100362: e8 14 ff ff ff call c010027b +c01003ed: 8d 45 f0 lea -0x10(%ebp),%eax +c01003f0: 89 44 24 04 mov %eax,0x4(%esp) +c01003f4: c7 04 24 0a 00 00 00 movl $0xa,(%esp) +c01003fb: e8 20 ff ff ff call c0100320 return cnt; -c0100367: 8b 45 f0 mov -0x10(%ebp),%eax +c0100400: 8b 45 f0 mov -0x10(%ebp),%eax } -c010036a: c9 leave -c010036b: c3 ret +c0100403: 89 ec mov %ebp,%esp +c0100405: 5d pop %ebp +c0100406: c3 ret -c010036c : +c0100407 : /* getchar - reads a single non-zero character from stdin */ int getchar(void) { -c010036c: f3 0f 1e fb endbr32 -c0100370: 55 push %ebp -c0100371: 89 e5 mov %esp,%ebp -c0100373: 83 ec 18 sub $0x18,%esp +c0100407: 55 push %ebp +c0100408: 89 e5 mov %esp,%ebp +c010040a: 83 ec 18 sub $0x18,%esp int c; while ((c = cons_getc()) == 0) -c0100376: 90 nop -c0100377: e8 77 1b 00 00 call c0101ef3 -c010037c: 89 45 f4 mov %eax,-0xc(%ebp) -c010037f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0100383: 74 f2 je c0100377 +c010040d: 90 nop +c010040e: e8 12 12 00 00 call c0101625 +c0100413: 89 45 f4 mov %eax,-0xc(%ebp) +c0100416: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c010041a: 74 f2 je c010040e /* do nothing */; return c; -c0100385: 8b 45 f4 mov -0xc(%ebp),%eax -} -c0100388: c9 leave -c0100389: c3 ret - -c010038a : - * The readline() function returns the text of the line read. If some errors - * are happened, NULL is returned. The return value is a global variable, - * thus it should be copied before it is used. - * */ -char * -readline(const char *prompt) { -c010038a: f3 0f 1e fb endbr32 -c010038e: 55 push %ebp -c010038f: 89 e5 mov %esp,%ebp -c0100391: 83 ec 28 sub $0x28,%esp - if (prompt != NULL) { -c0100394: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c0100398: 74 13 je c01003ad - cprintf("%s", prompt); -c010039a: 8b 45 08 mov 0x8(%ebp),%eax -c010039d: 89 44 24 04 mov %eax,0x4(%esp) -c01003a1: c7 04 24 47 a3 10 c0 movl $0xc010a347,(%esp) -c01003a8: e8 2a ff ff ff call c01002d7 - } - int i = 0, c; -c01003ad: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) - while (1) { - c = getchar(); -c01003b4: e8 b3 ff ff ff call c010036c -c01003b9: 89 45 f0 mov %eax,-0x10(%ebp) - if (c < 0) { -c01003bc: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c01003c0: 79 07 jns c01003c9 - return NULL; -c01003c2: b8 00 00 00 00 mov $0x0,%eax -c01003c7: eb 78 jmp c0100441 - } - else if (c >= ' ' && i < BUFSIZE - 1) { -c01003c9: 83 7d f0 1f cmpl $0x1f,-0x10(%ebp) -c01003cd: 7e 28 jle c01003f7 -c01003cf: 81 7d f4 fe 03 00 00 cmpl $0x3fe,-0xc(%ebp) -c01003d6: 7f 1f jg c01003f7 - cputchar(c); -c01003d8: 8b 45 f0 mov -0x10(%ebp),%eax -c01003db: 89 04 24 mov %eax,(%esp) -c01003de: e8 1e ff ff ff call c0100301 - buf[i ++] = c; -c01003e3: 8b 45 f4 mov -0xc(%ebp),%eax -c01003e6: 8d 50 01 lea 0x1(%eax),%edx -c01003e9: 89 55 f4 mov %edx,-0xc(%ebp) -c01003ec: 8b 55 f0 mov -0x10(%ebp),%edx -c01003ef: 88 90 20 b0 12 c0 mov %dl,-0x3fed4fe0(%eax) -c01003f5: eb 45 jmp c010043c - } - else if (c == '\b' && i > 0) { -c01003f7: 83 7d f0 08 cmpl $0x8,-0x10(%ebp) -c01003fb: 75 16 jne c0100413 -c01003fd: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0100401: 7e 10 jle c0100413 - cputchar(c); -c0100403: 8b 45 f0 mov -0x10(%ebp),%eax -c0100406: 89 04 24 mov %eax,(%esp) -c0100409: e8 f3 fe ff ff call c0100301 - i --; -c010040e: ff 4d f4 decl -0xc(%ebp) -c0100411: eb 29 jmp c010043c - } - else if (c == '\n' || c == '\r') { -c0100413: 83 7d f0 0a cmpl $0xa,-0x10(%ebp) -c0100417: 74 06 je c010041f -c0100419: 83 7d f0 0d cmpl $0xd,-0x10(%ebp) -c010041d: 75 95 jne c01003b4 - cputchar(c); -c010041f: 8b 45 f0 mov -0x10(%ebp),%eax -c0100422: 89 04 24 mov %eax,(%esp) -c0100425: e8 d7 fe ff ff call c0100301 - buf[i] = '\0'; -c010042a: 8b 45 f4 mov -0xc(%ebp),%eax -c010042d: 05 20 b0 12 c0 add $0xc012b020,%eax -c0100432: c6 00 00 movb $0x0,(%eax) - return buf; -c0100435: b8 20 b0 12 c0 mov $0xc012b020,%eax -c010043a: eb 05 jmp c0100441 - c = getchar(); -c010043c: e9 73 ff ff ff jmp c01003b4 - } - } -} -c0100441: c9 leave -c0100442: c3 ret - -c0100443 <__panic>: -/* * - * __panic - __panic is called on unresolvable fatal errors. it prints - * "panic: 'message'", and then enters the kernel monitor. - * */ -void -__panic(const char *file, int line, const char *fmt, ...) { -c0100443: f3 0f 1e fb endbr32 -c0100447: 55 push %ebp -c0100448: 89 e5 mov %esp,%ebp -c010044a: 83 ec 28 sub $0x28,%esp - if (is_panic) { -c010044d: a1 20 b4 12 c0 mov 0xc012b420,%eax -c0100452: 85 c0 test %eax,%eax -c0100454: 75 5b jne c01004b1 <__panic+0x6e> - goto panic_dead; - } - is_panic = 1; -c0100456: c7 05 20 b4 12 c0 01 movl $0x1,0xc012b420 -c010045d: 00 00 00 - - // print the 'message' - va_list ap; - va_start(ap, fmt); -c0100460: 8d 45 14 lea 0x14(%ebp),%eax -c0100463: 89 45 f4 mov %eax,-0xc(%ebp) - cprintf("kernel panic at %s:%d:\n ", file, line); -c0100466: 8b 45 0c mov 0xc(%ebp),%eax -c0100469: 89 44 24 08 mov %eax,0x8(%esp) -c010046d: 8b 45 08 mov 0x8(%ebp),%eax -c0100470: 89 44 24 04 mov %eax,0x4(%esp) -c0100474: c7 04 24 4a a3 10 c0 movl $0xc010a34a,(%esp) -c010047b: e8 57 fe ff ff call c01002d7 - vcprintf(fmt, ap); -c0100480: 8b 45 f4 mov -0xc(%ebp),%eax -c0100483: 89 44 24 04 mov %eax,0x4(%esp) -c0100487: 8b 45 10 mov 0x10(%ebp),%eax -c010048a: 89 04 24 mov %eax,(%esp) -c010048d: e8 0e fe ff ff call c01002a0 - cprintf("\n"); -c0100492: c7 04 24 66 a3 10 c0 movl $0xc010a366,(%esp) -c0100499: e8 39 fe ff ff call c01002d7 - - cprintf("stack trackback:\n"); -c010049e: c7 04 24 68 a3 10 c0 movl $0xc010a368,(%esp) -c01004a5: e8 2d fe ff ff call c01002d7 - print_stackframe(); -c01004aa: e8 3d 06 00 00 call c0100aec -c01004af: eb 01 jmp c01004b2 <__panic+0x6f> - goto panic_dead; -c01004b1: 90 nop - - va_end(ap); - -panic_dead: - intr_disable(); -c01004b2: e8 9d 1c 00 00 call c0102154 - while (1) { - kmonitor(NULL); -c01004b7: c7 04 24 00 00 00 00 movl $0x0,(%esp) -c01004be: e8 a7 07 00 00 call c0100c6a -c01004c3: eb f2 jmp c01004b7 <__panic+0x74> - -c01004c5 <__warn>: - } -} - -/* __warn - like panic, but don't */ -void -__warn(const char *file, int line, const char *fmt, ...) { -c01004c5: f3 0f 1e fb endbr32 -c01004c9: 55 push %ebp -c01004ca: 89 e5 mov %esp,%ebp -c01004cc: 83 ec 28 sub $0x28,%esp - va_list ap; - va_start(ap, fmt); -c01004cf: 8d 45 14 lea 0x14(%ebp),%eax -c01004d2: 89 45 f4 mov %eax,-0xc(%ebp) - cprintf("kernel warning at %s:%d:\n ", file, line); -c01004d5: 8b 45 0c mov 0xc(%ebp),%eax -c01004d8: 89 44 24 08 mov %eax,0x8(%esp) -c01004dc: 8b 45 08 mov 0x8(%ebp),%eax -c01004df: 89 44 24 04 mov %eax,0x4(%esp) -c01004e3: c7 04 24 7a a3 10 c0 movl $0xc010a37a,(%esp) -c01004ea: e8 e8 fd ff ff call c01002d7 - vcprintf(fmt, ap); -c01004ef: 8b 45 f4 mov -0xc(%ebp),%eax -c01004f2: 89 44 24 04 mov %eax,0x4(%esp) -c01004f6: 8b 45 10 mov 0x10(%ebp),%eax -c01004f9: 89 04 24 mov %eax,(%esp) -c01004fc: e8 9f fd ff ff call c01002a0 - cprintf("\n"); -c0100501: c7 04 24 66 a3 10 c0 movl $0xc010a366,(%esp) -c0100508: e8 ca fd ff ff call c01002d7 - va_end(ap); +c010041c: 8b 45 f4 mov -0xc(%ebp),%eax } -c010050d: 90 nop -c010050e: c9 leave -c010050f: c3 ret +c010041f: 89 ec mov %ebp,%esp +c0100421: 5d pop %ebp +c0100422: c3 ret -c0100510 : - -bool -is_kernel_panic(void) { -c0100510: f3 0f 1e fb endbr32 -c0100514: 55 push %ebp -c0100515: 89 e5 mov %esp,%ebp - return is_panic; -c0100517: a1 20 b4 12 c0 mov 0xc012b420,%eax -} -c010051c: 5d pop %ebp -c010051d: c3 ret - -c010051e : +c0100423 : * stab_binsearch(stabs, &left, &right, N_SO, 0xf0100184); * will exit setting left = 118, right = 554. * */ static void stab_binsearch(const struct stab *stabs, int *region_left, int *region_right, int type, uintptr_t addr) { -c010051e: f3 0f 1e fb endbr32 -c0100522: 55 push %ebp -c0100523: 89 e5 mov %esp,%ebp -c0100525: 83 ec 20 sub $0x20,%esp +c0100423: 55 push %ebp +c0100424: 89 e5 mov %esp,%ebp +c0100426: 83 ec 20 sub $0x20,%esp int l = *region_left, r = *region_right, any_matches = 0; -c0100528: 8b 45 0c mov 0xc(%ebp),%eax -c010052b: 8b 00 mov (%eax),%eax -c010052d: 89 45 fc mov %eax,-0x4(%ebp) -c0100530: 8b 45 10 mov 0x10(%ebp),%eax -c0100533: 8b 00 mov (%eax),%eax -c0100535: 89 45 f8 mov %eax,-0x8(%ebp) -c0100538: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c0100429: 8b 45 0c mov 0xc(%ebp),%eax +c010042c: 8b 00 mov (%eax),%eax +c010042e: 89 45 fc mov %eax,-0x4(%ebp) +c0100431: 8b 45 10 mov 0x10(%ebp),%eax +c0100434: 8b 00 mov (%eax),%eax +c0100436: 89 45 f8 mov %eax,-0x8(%ebp) +c0100439: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) while (l <= r) { -c010053f: e9 ca 00 00 00 jmp c010060e +c0100440: e9 ca 00 00 00 jmp c010050f int true_m = (l + r) / 2, m = true_m; -c0100544: 8b 55 fc mov -0x4(%ebp),%edx -c0100547: 8b 45 f8 mov -0x8(%ebp),%eax -c010054a: 01 d0 add %edx,%eax -c010054c: 89 c2 mov %eax,%edx -c010054e: c1 ea 1f shr $0x1f,%edx -c0100551: 01 d0 add %edx,%eax -c0100553: d1 f8 sar %eax -c0100555: 89 45 ec mov %eax,-0x14(%ebp) -c0100558: 8b 45 ec mov -0x14(%ebp),%eax -c010055b: 89 45 f0 mov %eax,-0x10(%ebp) +c0100445: 8b 55 fc mov -0x4(%ebp),%edx +c0100448: 8b 45 f8 mov -0x8(%ebp),%eax +c010044b: 01 d0 add %edx,%eax +c010044d: 89 c2 mov %eax,%edx +c010044f: c1 ea 1f shr $0x1f,%edx +c0100452: 01 d0 add %edx,%eax +c0100454: d1 f8 sar %eax +c0100456: 89 45 ec mov %eax,-0x14(%ebp) +c0100459: 8b 45 ec mov -0x14(%ebp),%eax +c010045c: 89 45 f0 mov %eax,-0x10(%ebp) // search for earliest stab with right type while (m >= l && stabs[m].n_type != type) { -c010055e: eb 03 jmp c0100563 +c010045f: eb 03 jmp c0100464 m --; -c0100560: ff 4d f0 decl -0x10(%ebp) +c0100461: ff 4d f0 decl -0x10(%ebp) while (m >= l && stabs[m].n_type != type) { -c0100563: 8b 45 f0 mov -0x10(%ebp),%eax -c0100566: 3b 45 fc cmp -0x4(%ebp),%eax -c0100569: 7c 1f jl c010058a -c010056b: 8b 55 f0 mov -0x10(%ebp),%edx -c010056e: 89 d0 mov %edx,%eax -c0100570: 01 c0 add %eax,%eax -c0100572: 01 d0 add %edx,%eax -c0100574: c1 e0 02 shl $0x2,%eax -c0100577: 89 c2 mov %eax,%edx -c0100579: 8b 45 08 mov 0x8(%ebp),%eax -c010057c: 01 d0 add %edx,%eax -c010057e: 0f b6 40 04 movzbl 0x4(%eax),%eax -c0100582: 0f b6 c0 movzbl %al,%eax -c0100585: 39 45 14 cmp %eax,0x14(%ebp) -c0100588: 75 d6 jne c0100560 +c0100464: 8b 45 f0 mov -0x10(%ebp),%eax +c0100467: 3b 45 fc cmp -0x4(%ebp),%eax +c010046a: 7c 1f jl c010048b +c010046c: 8b 55 f0 mov -0x10(%ebp),%edx +c010046f: 89 d0 mov %edx,%eax +c0100471: 01 c0 add %eax,%eax +c0100473: 01 d0 add %edx,%eax +c0100475: c1 e0 02 shl $0x2,%eax +c0100478: 89 c2 mov %eax,%edx +c010047a: 8b 45 08 mov 0x8(%ebp),%eax +c010047d: 01 d0 add %edx,%eax +c010047f: 0f b6 40 04 movzbl 0x4(%eax),%eax +c0100483: 0f b6 c0 movzbl %al,%eax +c0100486: 39 45 14 cmp %eax,0x14(%ebp) +c0100489: 75 d6 jne c0100461 } if (m < l) { // no match in [l, m] -c010058a: 8b 45 f0 mov -0x10(%ebp),%eax -c010058d: 3b 45 fc cmp -0x4(%ebp),%eax -c0100590: 7d 09 jge c010059b +c010048b: 8b 45 f0 mov -0x10(%ebp),%eax +c010048e: 3b 45 fc cmp -0x4(%ebp),%eax +c0100491: 7d 09 jge c010049c l = true_m + 1; -c0100592: 8b 45 ec mov -0x14(%ebp),%eax -c0100595: 40 inc %eax -c0100596: 89 45 fc mov %eax,-0x4(%ebp) +c0100493: 8b 45 ec mov -0x14(%ebp),%eax +c0100496: 40 inc %eax +c0100497: 89 45 fc mov %eax,-0x4(%ebp) continue; -c0100599: eb 73 jmp c010060e +c010049a: eb 73 jmp c010050f } // actual binary search any_matches = 1; -c010059b: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp) +c010049c: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp) if (stabs[m].n_value < addr) { -c01005a2: 8b 55 f0 mov -0x10(%ebp),%edx -c01005a5: 89 d0 mov %edx,%eax -c01005a7: 01 c0 add %eax,%eax -c01005a9: 01 d0 add %edx,%eax -c01005ab: c1 e0 02 shl $0x2,%eax -c01005ae: 89 c2 mov %eax,%edx -c01005b0: 8b 45 08 mov 0x8(%ebp),%eax -c01005b3: 01 d0 add %edx,%eax -c01005b5: 8b 40 08 mov 0x8(%eax),%eax -c01005b8: 39 45 18 cmp %eax,0x18(%ebp) -c01005bb: 76 11 jbe c01005ce +c01004a3: 8b 55 f0 mov -0x10(%ebp),%edx +c01004a6: 89 d0 mov %edx,%eax +c01004a8: 01 c0 add %eax,%eax +c01004aa: 01 d0 add %edx,%eax +c01004ac: c1 e0 02 shl $0x2,%eax +c01004af: 89 c2 mov %eax,%edx +c01004b1: 8b 45 08 mov 0x8(%ebp),%eax +c01004b4: 01 d0 add %edx,%eax +c01004b6: 8b 40 08 mov 0x8(%eax),%eax +c01004b9: 39 45 18 cmp %eax,0x18(%ebp) +c01004bc: 76 11 jbe c01004cf *region_left = m; -c01005bd: 8b 45 0c mov 0xc(%ebp),%eax -c01005c0: 8b 55 f0 mov -0x10(%ebp),%edx -c01005c3: 89 10 mov %edx,(%eax) +c01004be: 8b 45 0c mov 0xc(%ebp),%eax +c01004c1: 8b 55 f0 mov -0x10(%ebp),%edx +c01004c4: 89 10 mov %edx,(%eax) l = true_m + 1; -c01005c5: 8b 45 ec mov -0x14(%ebp),%eax -c01005c8: 40 inc %eax -c01005c9: 89 45 fc mov %eax,-0x4(%ebp) -c01005cc: eb 40 jmp c010060e +c01004c6: 8b 45 ec mov -0x14(%ebp),%eax +c01004c9: 40 inc %eax +c01004ca: 89 45 fc mov %eax,-0x4(%ebp) +c01004cd: eb 40 jmp c010050f } else if (stabs[m].n_value > addr) { -c01005ce: 8b 55 f0 mov -0x10(%ebp),%edx -c01005d1: 89 d0 mov %edx,%eax -c01005d3: 01 c0 add %eax,%eax -c01005d5: 01 d0 add %edx,%eax -c01005d7: c1 e0 02 shl $0x2,%eax -c01005da: 89 c2 mov %eax,%edx -c01005dc: 8b 45 08 mov 0x8(%ebp),%eax -c01005df: 01 d0 add %edx,%eax -c01005e1: 8b 40 08 mov 0x8(%eax),%eax -c01005e4: 39 45 18 cmp %eax,0x18(%ebp) -c01005e7: 73 14 jae c01005fd +c01004cf: 8b 55 f0 mov -0x10(%ebp),%edx +c01004d2: 89 d0 mov %edx,%eax +c01004d4: 01 c0 add %eax,%eax +c01004d6: 01 d0 add %edx,%eax +c01004d8: c1 e0 02 shl $0x2,%eax +c01004db: 89 c2 mov %eax,%edx +c01004dd: 8b 45 08 mov 0x8(%ebp),%eax +c01004e0: 01 d0 add %edx,%eax +c01004e2: 8b 40 08 mov 0x8(%eax),%eax +c01004e5: 39 45 18 cmp %eax,0x18(%ebp) +c01004e8: 73 14 jae c01004fe *region_right = m - 1; -c01005e9: 8b 45 f0 mov -0x10(%ebp),%eax -c01005ec: 8d 50 ff lea -0x1(%eax),%edx -c01005ef: 8b 45 10 mov 0x10(%ebp),%eax -c01005f2: 89 10 mov %edx,(%eax) +c01004ea: 8b 45 f0 mov -0x10(%ebp),%eax +c01004ed: 8d 50 ff lea -0x1(%eax),%edx +c01004f0: 8b 45 10 mov 0x10(%ebp),%eax +c01004f3: 89 10 mov %edx,(%eax) r = m - 1; -c01005f4: 8b 45 f0 mov -0x10(%ebp),%eax -c01005f7: 48 dec %eax -c01005f8: 89 45 f8 mov %eax,-0x8(%ebp) -c01005fb: eb 11 jmp c010060e +c01004f5: 8b 45 f0 mov -0x10(%ebp),%eax +c01004f8: 48 dec %eax +c01004f9: 89 45 f8 mov %eax,-0x8(%ebp) +c01004fc: eb 11 jmp c010050f } else { // exact match for 'addr', but continue loop to find // *region_right *region_left = m; -c01005fd: 8b 45 0c mov 0xc(%ebp),%eax -c0100600: 8b 55 f0 mov -0x10(%ebp),%edx -c0100603: 89 10 mov %edx,(%eax) +c01004fe: 8b 45 0c mov 0xc(%ebp),%eax +c0100501: 8b 55 f0 mov -0x10(%ebp),%edx +c0100504: 89 10 mov %edx,(%eax) l = m; -c0100605: 8b 45 f0 mov -0x10(%ebp),%eax -c0100608: 89 45 fc mov %eax,-0x4(%ebp) +c0100506: 8b 45 f0 mov -0x10(%ebp),%eax +c0100509: 89 45 fc mov %eax,-0x4(%ebp) addr ++; -c010060b: ff 45 18 incl 0x18(%ebp) +c010050c: ff 45 18 incl 0x18(%ebp) while (l <= r) { -c010060e: 8b 45 fc mov -0x4(%ebp),%eax -c0100611: 3b 45 f8 cmp -0x8(%ebp),%eax -c0100614: 0f 8e 2a ff ff ff jle c0100544 +c010050f: 8b 45 fc mov -0x4(%ebp),%eax +c0100512: 3b 45 f8 cmp -0x8(%ebp),%eax +c0100515: 0f 8e 2a ff ff ff jle c0100445 } } if (!any_matches) { -c010061a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c010061e: 75 0f jne c010062f +c010051b: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c010051f: 75 0f jne c0100530 *region_right = *region_left - 1; -c0100620: 8b 45 0c mov 0xc(%ebp),%eax -c0100623: 8b 00 mov (%eax),%eax -c0100625: 8d 50 ff lea -0x1(%eax),%edx -c0100628: 8b 45 10 mov 0x10(%ebp),%eax -c010062b: 89 10 mov %edx,(%eax) +c0100521: 8b 45 0c mov 0xc(%ebp),%eax +c0100524: 8b 00 mov (%eax),%eax +c0100526: 8d 50 ff lea -0x1(%eax),%edx +c0100529: 8b 45 10 mov 0x10(%ebp),%eax +c010052c: 89 10 mov %edx,(%eax) l = *region_right; for (; l > *region_left && stabs[l].n_type != type; l --) /* do nothing */; *region_left = l; } } -c010062d: eb 3e jmp c010066d +c010052e: eb 3e jmp c010056e l = *region_right; -c010062f: 8b 45 10 mov 0x10(%ebp),%eax -c0100632: 8b 00 mov (%eax),%eax -c0100634: 89 45 fc mov %eax,-0x4(%ebp) +c0100530: 8b 45 10 mov 0x10(%ebp),%eax +c0100533: 8b 00 mov (%eax),%eax +c0100535: 89 45 fc mov %eax,-0x4(%ebp) for (; l > *region_left && stabs[l].n_type != type; l --) -c0100637: eb 03 jmp c010063c -c0100639: ff 4d fc decl -0x4(%ebp) -c010063c: 8b 45 0c mov 0xc(%ebp),%eax -c010063f: 8b 00 mov (%eax),%eax -c0100641: 39 45 fc cmp %eax,-0x4(%ebp) -c0100644: 7e 1f jle c0100665 -c0100646: 8b 55 fc mov -0x4(%ebp),%edx -c0100649: 89 d0 mov %edx,%eax -c010064b: 01 c0 add %eax,%eax -c010064d: 01 d0 add %edx,%eax -c010064f: c1 e0 02 shl $0x2,%eax -c0100652: 89 c2 mov %eax,%edx -c0100654: 8b 45 08 mov 0x8(%ebp),%eax -c0100657: 01 d0 add %edx,%eax -c0100659: 0f b6 40 04 movzbl 0x4(%eax),%eax -c010065d: 0f b6 c0 movzbl %al,%eax -c0100660: 39 45 14 cmp %eax,0x14(%ebp) -c0100663: 75 d4 jne c0100639 +c0100538: eb 03 jmp c010053d +c010053a: ff 4d fc decl -0x4(%ebp) +c010053d: 8b 45 0c mov 0xc(%ebp),%eax +c0100540: 8b 00 mov (%eax),%eax +c0100542: 39 45 fc cmp %eax,-0x4(%ebp) +c0100545: 7e 1f jle c0100566 +c0100547: 8b 55 fc mov -0x4(%ebp),%edx +c010054a: 89 d0 mov %edx,%eax +c010054c: 01 c0 add %eax,%eax +c010054e: 01 d0 add %edx,%eax +c0100550: c1 e0 02 shl $0x2,%eax +c0100553: 89 c2 mov %eax,%edx +c0100555: 8b 45 08 mov 0x8(%ebp),%eax +c0100558: 01 d0 add %edx,%eax +c010055a: 0f b6 40 04 movzbl 0x4(%eax),%eax +c010055e: 0f b6 c0 movzbl %al,%eax +c0100561: 39 45 14 cmp %eax,0x14(%ebp) +c0100564: 75 d4 jne c010053a *region_left = l; -c0100665: 8b 45 0c mov 0xc(%ebp),%eax -c0100668: 8b 55 fc mov -0x4(%ebp),%edx -c010066b: 89 10 mov %edx,(%eax) +c0100566: 8b 45 0c mov 0xc(%ebp),%eax +c0100569: 8b 55 fc mov -0x4(%ebp),%edx +c010056c: 89 10 mov %edx,(%eax) } -c010066d: 90 nop -c010066e: c9 leave -c010066f: c3 ret +c010056e: 90 nop +c010056f: 89 ec mov %ebp,%esp +c0100571: 5d pop %ebp +c0100572: c3 ret -c0100670 : +c0100573 : * the specified instruction address, @addr. Returns 0 if information * was found, and negative if not. But even if it returns negative it * has stored some information into '*info'. * */ int debuginfo_eip(uintptr_t addr, struct eipdebuginfo *info) { -c0100670: f3 0f 1e fb endbr32 -c0100674: 55 push %ebp -c0100675: 89 e5 mov %esp,%ebp -c0100677: 83 ec 58 sub $0x58,%esp +c0100573: 55 push %ebp +c0100574: 89 e5 mov %esp,%ebp +c0100576: 83 ec 58 sub $0x58,%esp const struct stab *stabs, *stab_end; const char *stabstr, *stabstr_end; info->eip_file = ""; -c010067a: 8b 45 0c mov 0xc(%ebp),%eax -c010067d: c7 00 98 a3 10 c0 movl $0xc010a398,(%eax) +c0100579: 8b 45 0c mov 0xc(%ebp),%eax +c010057c: c7 00 2c a1 10 c0 movl $0xc010a12c,(%eax) info->eip_line = 0; -c0100683: 8b 45 0c mov 0xc(%ebp),%eax -c0100686: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) +c0100582: 8b 45 0c mov 0xc(%ebp),%eax +c0100585: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) info->eip_fn_name = ""; -c010068d: 8b 45 0c mov 0xc(%ebp),%eax -c0100690: c7 40 08 98 a3 10 c0 movl $0xc010a398,0x8(%eax) +c010058c: 8b 45 0c mov 0xc(%ebp),%eax +c010058f: c7 40 08 2c a1 10 c0 movl $0xc010a12c,0x8(%eax) info->eip_fn_namelen = 9; -c0100697: 8b 45 0c mov 0xc(%ebp),%eax -c010069a: c7 40 0c 09 00 00 00 movl $0x9,0xc(%eax) +c0100596: 8b 45 0c mov 0xc(%ebp),%eax +c0100599: c7 40 0c 09 00 00 00 movl $0x9,0xc(%eax) info->eip_fn_addr = addr; -c01006a1: 8b 45 0c mov 0xc(%ebp),%eax -c01006a4: 8b 55 08 mov 0x8(%ebp),%edx -c01006a7: 89 50 10 mov %edx,0x10(%eax) +c01005a0: 8b 45 0c mov 0xc(%ebp),%eax +c01005a3: 8b 55 08 mov 0x8(%ebp),%edx +c01005a6: 89 50 10 mov %edx,0x10(%eax) info->eip_fn_narg = 0; -c01006aa: 8b 45 0c mov 0xc(%ebp),%eax -c01006ad: c7 40 14 00 00 00 00 movl $0x0,0x14(%eax) +c01005a9: 8b 45 0c mov 0xc(%ebp),%eax +c01005ac: c7 40 14 00 00 00 00 movl $0x0,0x14(%eax) stabs = __STAB_BEGIN__; -c01006b4: c7 45 f4 dc c5 10 c0 movl $0xc010c5dc,-0xc(%ebp) +c01005b3: c7 45 f4 b8 c3 10 c0 movl $0xc010c3b8,-0xc(%ebp) stab_end = __STAB_END__; -c01006bb: c7 45 f0 4c 0f 12 c0 movl $0xc0120f4c,-0x10(%ebp) +c01005ba: c7 45 f0 24 f0 11 c0 movl $0xc011f024,-0x10(%ebp) stabstr = __STABSTR_BEGIN__; -c01006c2: c7 45 ec 4d 0f 12 c0 movl $0xc0120f4d,-0x14(%ebp) +c01005c1: c7 45 ec 25 f0 11 c0 movl $0xc011f025,-0x14(%ebp) stabstr_end = __STABSTR_END__; -c01006c9: c7 45 e8 48 58 12 c0 movl $0xc0125848,-0x18(%ebp) +c01005c8: c7 45 e8 b4 54 12 c0 movl $0xc01254b4,-0x18(%ebp) // String table validity checks if (stabstr_end <= stabstr || stabstr_end[-1] != 0) { -c01006d0: 8b 45 e8 mov -0x18(%ebp),%eax -c01006d3: 3b 45 ec cmp -0x14(%ebp),%eax -c01006d6: 76 0b jbe c01006e3 -c01006d8: 8b 45 e8 mov -0x18(%ebp),%eax -c01006db: 48 dec %eax -c01006dc: 0f b6 00 movzbl (%eax),%eax -c01006df: 84 c0 test %al,%al -c01006e1: 74 0a je c01006ed +c01005cf: 8b 45 e8 mov -0x18(%ebp),%eax +c01005d2: 3b 45 ec cmp -0x14(%ebp),%eax +c01005d5: 76 0b jbe c01005e2 +c01005d7: 8b 45 e8 mov -0x18(%ebp),%eax +c01005da: 48 dec %eax +c01005db: 0f b6 00 movzbl (%eax),%eax +c01005de: 84 c0 test %al,%al +c01005e0: 74 0a je c01005ec return -1; -c01006e3: b8 ff ff ff ff mov $0xffffffff,%eax -c01006e8: e9 ab 02 00 00 jmp c0100998 +c01005e2: b8 ff ff ff ff mov $0xffffffff,%eax +c01005e7: e9 ab 02 00 00 jmp c0100897 // 'eip'. First, we find the basic source file containing 'eip'. // Then, we look in that source file for the function. Then we look // for the line number. // Search the entire set of stabs for the source file (type N_SO). int lfile = 0, rfile = (stab_end - stabs) - 1; -c01006ed: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) -c01006f4: 8b 45 f0 mov -0x10(%ebp),%eax -c01006f7: 2b 45 f4 sub -0xc(%ebp),%eax -c01006fa: c1 f8 02 sar $0x2,%eax -c01006fd: 69 c0 ab aa aa aa imul $0xaaaaaaab,%eax,%eax -c0100703: 48 dec %eax -c0100704: 89 45 e0 mov %eax,-0x20(%ebp) +c01005ec: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) +c01005f3: 8b 45 f0 mov -0x10(%ebp),%eax +c01005f6: 2b 45 f4 sub -0xc(%ebp),%eax +c01005f9: c1 f8 02 sar $0x2,%eax +c01005fc: 69 c0 ab aa aa aa imul $0xaaaaaaab,%eax,%eax +c0100602: 48 dec %eax +c0100603: 89 45 e0 mov %eax,-0x20(%ebp) stab_binsearch(stabs, &lfile, &rfile, N_SO, addr); -c0100707: 8b 45 08 mov 0x8(%ebp),%eax -c010070a: 89 44 24 10 mov %eax,0x10(%esp) -c010070e: c7 44 24 0c 64 00 00 movl $0x64,0xc(%esp) -c0100715: 00 -c0100716: 8d 45 e0 lea -0x20(%ebp),%eax -c0100719: 89 44 24 08 mov %eax,0x8(%esp) -c010071d: 8d 45 e4 lea -0x1c(%ebp),%eax -c0100720: 89 44 24 04 mov %eax,0x4(%esp) -c0100724: 8b 45 f4 mov -0xc(%ebp),%eax -c0100727: 89 04 24 mov %eax,(%esp) -c010072a: e8 ef fd ff ff call c010051e +c0100606: 8b 45 08 mov 0x8(%ebp),%eax +c0100609: 89 44 24 10 mov %eax,0x10(%esp) +c010060d: c7 44 24 0c 64 00 00 movl $0x64,0xc(%esp) +c0100614: 00 +c0100615: 8d 45 e0 lea -0x20(%ebp),%eax +c0100618: 89 44 24 08 mov %eax,0x8(%esp) +c010061c: 8d 45 e4 lea -0x1c(%ebp),%eax +c010061f: 89 44 24 04 mov %eax,0x4(%esp) +c0100623: 8b 45 f4 mov -0xc(%ebp),%eax +c0100626: 89 04 24 mov %eax,(%esp) +c0100629: e8 f5 fd ff ff call c0100423 if (lfile == 0) -c010072f: 8b 45 e4 mov -0x1c(%ebp),%eax -c0100732: 85 c0 test %eax,%eax -c0100734: 75 0a jne c0100740 +c010062e: 8b 45 e4 mov -0x1c(%ebp),%eax +c0100631: 85 c0 test %eax,%eax +c0100633: 75 0a jne c010063f return -1; -c0100736: b8 ff ff ff ff mov $0xffffffff,%eax -c010073b: e9 58 02 00 00 jmp c0100998 +c0100635: b8 ff ff ff ff mov $0xffffffff,%eax +c010063a: e9 58 02 00 00 jmp c0100897 // Search within that file's stabs for the function definition // (N_FUN). int lfun = lfile, rfun = rfile; -c0100740: 8b 45 e4 mov -0x1c(%ebp),%eax -c0100743: 89 45 dc mov %eax,-0x24(%ebp) -c0100746: 8b 45 e0 mov -0x20(%ebp),%eax -c0100749: 89 45 d8 mov %eax,-0x28(%ebp) +c010063f: 8b 45 e4 mov -0x1c(%ebp),%eax +c0100642: 89 45 dc mov %eax,-0x24(%ebp) +c0100645: 8b 45 e0 mov -0x20(%ebp),%eax +c0100648: 89 45 d8 mov %eax,-0x28(%ebp) int lline, rline; stab_binsearch(stabs, &lfun, &rfun, N_FUN, addr); -c010074c: 8b 45 08 mov 0x8(%ebp),%eax -c010074f: 89 44 24 10 mov %eax,0x10(%esp) -c0100753: c7 44 24 0c 24 00 00 movl $0x24,0xc(%esp) -c010075a: 00 -c010075b: 8d 45 d8 lea -0x28(%ebp),%eax -c010075e: 89 44 24 08 mov %eax,0x8(%esp) -c0100762: 8d 45 dc lea -0x24(%ebp),%eax -c0100765: 89 44 24 04 mov %eax,0x4(%esp) -c0100769: 8b 45 f4 mov -0xc(%ebp),%eax -c010076c: 89 04 24 mov %eax,(%esp) -c010076f: e8 aa fd ff ff call c010051e +c010064b: 8b 45 08 mov 0x8(%ebp),%eax +c010064e: 89 44 24 10 mov %eax,0x10(%esp) +c0100652: c7 44 24 0c 24 00 00 movl $0x24,0xc(%esp) +c0100659: 00 +c010065a: 8d 45 d8 lea -0x28(%ebp),%eax +c010065d: 89 44 24 08 mov %eax,0x8(%esp) +c0100661: 8d 45 dc lea -0x24(%ebp),%eax +c0100664: 89 44 24 04 mov %eax,0x4(%esp) +c0100668: 8b 45 f4 mov -0xc(%ebp),%eax +c010066b: 89 04 24 mov %eax,(%esp) +c010066e: e8 b0 fd ff ff call c0100423 if (lfun <= rfun) { -c0100774: 8b 55 dc mov -0x24(%ebp),%edx -c0100777: 8b 45 d8 mov -0x28(%ebp),%eax -c010077a: 39 c2 cmp %eax,%edx -c010077c: 7f 78 jg c01007f6 +c0100673: 8b 55 dc mov -0x24(%ebp),%edx +c0100676: 8b 45 d8 mov -0x28(%ebp),%eax +c0100679: 39 c2 cmp %eax,%edx +c010067b: 7f 78 jg c01006f5 // stabs[lfun] points to the function name // in the string table, but check bounds just in case. if (stabs[lfun].n_strx < stabstr_end - stabstr) { -c010077e: 8b 45 dc mov -0x24(%ebp),%eax -c0100781: 89 c2 mov %eax,%edx -c0100783: 89 d0 mov %edx,%eax -c0100785: 01 c0 add %eax,%eax -c0100787: 01 d0 add %edx,%eax -c0100789: c1 e0 02 shl $0x2,%eax -c010078c: 89 c2 mov %eax,%edx -c010078e: 8b 45 f4 mov -0xc(%ebp),%eax -c0100791: 01 d0 add %edx,%eax -c0100793: 8b 10 mov (%eax),%edx -c0100795: 8b 45 e8 mov -0x18(%ebp),%eax -c0100798: 2b 45 ec sub -0x14(%ebp),%eax -c010079b: 39 c2 cmp %eax,%edx -c010079d: 73 22 jae c01007c1 +c010067d: 8b 45 dc mov -0x24(%ebp),%eax +c0100680: 89 c2 mov %eax,%edx +c0100682: 89 d0 mov %edx,%eax +c0100684: 01 c0 add %eax,%eax +c0100686: 01 d0 add %edx,%eax +c0100688: c1 e0 02 shl $0x2,%eax +c010068b: 89 c2 mov %eax,%edx +c010068d: 8b 45 f4 mov -0xc(%ebp),%eax +c0100690: 01 d0 add %edx,%eax +c0100692: 8b 10 mov (%eax),%edx +c0100694: 8b 45 e8 mov -0x18(%ebp),%eax +c0100697: 2b 45 ec sub -0x14(%ebp),%eax +c010069a: 39 c2 cmp %eax,%edx +c010069c: 73 22 jae c01006c0 info->eip_fn_name = stabstr + stabs[lfun].n_strx; -c010079f: 8b 45 dc mov -0x24(%ebp),%eax -c01007a2: 89 c2 mov %eax,%edx -c01007a4: 89 d0 mov %edx,%eax -c01007a6: 01 c0 add %eax,%eax -c01007a8: 01 d0 add %edx,%eax -c01007aa: c1 e0 02 shl $0x2,%eax -c01007ad: 89 c2 mov %eax,%edx -c01007af: 8b 45 f4 mov -0xc(%ebp),%eax -c01007b2: 01 d0 add %edx,%eax -c01007b4: 8b 10 mov (%eax),%edx -c01007b6: 8b 45 ec mov -0x14(%ebp),%eax -c01007b9: 01 c2 add %eax,%edx -c01007bb: 8b 45 0c mov 0xc(%ebp),%eax -c01007be: 89 50 08 mov %edx,0x8(%eax) +c010069e: 8b 45 dc mov -0x24(%ebp),%eax +c01006a1: 89 c2 mov %eax,%edx +c01006a3: 89 d0 mov %edx,%eax +c01006a5: 01 c0 add %eax,%eax +c01006a7: 01 d0 add %edx,%eax +c01006a9: c1 e0 02 shl $0x2,%eax +c01006ac: 89 c2 mov %eax,%edx +c01006ae: 8b 45 f4 mov -0xc(%ebp),%eax +c01006b1: 01 d0 add %edx,%eax +c01006b3: 8b 10 mov (%eax),%edx +c01006b5: 8b 45 ec mov -0x14(%ebp),%eax +c01006b8: 01 c2 add %eax,%edx +c01006ba: 8b 45 0c mov 0xc(%ebp),%eax +c01006bd: 89 50 08 mov %edx,0x8(%eax) } info->eip_fn_addr = stabs[lfun].n_value; -c01007c1: 8b 45 dc mov -0x24(%ebp),%eax -c01007c4: 89 c2 mov %eax,%edx -c01007c6: 89 d0 mov %edx,%eax -c01007c8: 01 c0 add %eax,%eax -c01007ca: 01 d0 add %edx,%eax -c01007cc: c1 e0 02 shl $0x2,%eax -c01007cf: 89 c2 mov %eax,%edx -c01007d1: 8b 45 f4 mov -0xc(%ebp),%eax -c01007d4: 01 d0 add %edx,%eax -c01007d6: 8b 50 08 mov 0x8(%eax),%edx -c01007d9: 8b 45 0c mov 0xc(%ebp),%eax -c01007dc: 89 50 10 mov %edx,0x10(%eax) +c01006c0: 8b 45 dc mov -0x24(%ebp),%eax +c01006c3: 89 c2 mov %eax,%edx +c01006c5: 89 d0 mov %edx,%eax +c01006c7: 01 c0 add %eax,%eax +c01006c9: 01 d0 add %edx,%eax +c01006cb: c1 e0 02 shl $0x2,%eax +c01006ce: 89 c2 mov %eax,%edx +c01006d0: 8b 45 f4 mov -0xc(%ebp),%eax +c01006d3: 01 d0 add %edx,%eax +c01006d5: 8b 50 08 mov 0x8(%eax),%edx +c01006d8: 8b 45 0c mov 0xc(%ebp),%eax +c01006db: 89 50 10 mov %edx,0x10(%eax) addr -= info->eip_fn_addr; -c01007df: 8b 45 0c mov 0xc(%ebp),%eax -c01007e2: 8b 40 10 mov 0x10(%eax),%eax -c01007e5: 29 45 08 sub %eax,0x8(%ebp) +c01006de: 8b 45 0c mov 0xc(%ebp),%eax +c01006e1: 8b 40 10 mov 0x10(%eax),%eax +c01006e4: 29 45 08 sub %eax,0x8(%ebp) // Search within the function definition for the line number. lline = lfun; -c01007e8: 8b 45 dc mov -0x24(%ebp),%eax -c01007eb: 89 45 d4 mov %eax,-0x2c(%ebp) +c01006e7: 8b 45 dc mov -0x24(%ebp),%eax +c01006ea: 89 45 d4 mov %eax,-0x2c(%ebp) rline = rfun; -c01007ee: 8b 45 d8 mov -0x28(%ebp),%eax -c01007f1: 89 45 d0 mov %eax,-0x30(%ebp) -c01007f4: eb 15 jmp c010080b +c01006ed: 8b 45 d8 mov -0x28(%ebp),%eax +c01006f0: 89 45 d0 mov %eax,-0x30(%ebp) +c01006f3: eb 15 jmp c010070a } else { // Couldn't find function stab! Maybe we're in an assembly // file. Search the whole file for the line number. info->eip_fn_addr = addr; -c01007f6: 8b 45 0c mov 0xc(%ebp),%eax -c01007f9: 8b 55 08 mov 0x8(%ebp),%edx -c01007fc: 89 50 10 mov %edx,0x10(%eax) +c01006f5: 8b 45 0c mov 0xc(%ebp),%eax +c01006f8: 8b 55 08 mov 0x8(%ebp),%edx +c01006fb: 89 50 10 mov %edx,0x10(%eax) lline = lfile; -c01007ff: 8b 45 e4 mov -0x1c(%ebp),%eax -c0100802: 89 45 d4 mov %eax,-0x2c(%ebp) +c01006fe: 8b 45 e4 mov -0x1c(%ebp),%eax +c0100701: 89 45 d4 mov %eax,-0x2c(%ebp) rline = rfile; -c0100805: 8b 45 e0 mov -0x20(%ebp),%eax -c0100808: 89 45 d0 mov %eax,-0x30(%ebp) +c0100704: 8b 45 e0 mov -0x20(%ebp),%eax +c0100707: 89 45 d0 mov %eax,-0x30(%ebp) } info->eip_fn_namelen = strfind(info->eip_fn_name, ':') - info->eip_fn_name; -c010080b: 8b 45 0c mov 0xc(%ebp),%eax -c010080e: 8b 40 08 mov 0x8(%eax),%eax -c0100811: c7 44 24 04 3a 00 00 movl $0x3a,0x4(%esp) -c0100818: 00 -c0100819: 89 04 24 mov %eax,(%esp) -c010081c: e8 a7 8f 00 00 call c01097c8 -c0100821: 8b 55 0c mov 0xc(%ebp),%edx -c0100824: 8b 52 08 mov 0x8(%edx),%edx -c0100827: 29 d0 sub %edx,%eax -c0100829: 89 c2 mov %eax,%edx -c010082b: 8b 45 0c mov 0xc(%ebp),%eax -c010082e: 89 50 0c mov %edx,0xc(%eax) +c010070a: 8b 45 0c mov 0xc(%ebp),%eax +c010070d: 8b 40 08 mov 0x8(%eax),%eax +c0100710: c7 44 24 04 3a 00 00 movl $0x3a,0x4(%esp) +c0100717: 00 +c0100718: 89 04 24 mov %eax,(%esp) +c010071b: e8 3c 96 00 00 call c0109d5c +c0100720: 8b 55 0c mov 0xc(%ebp),%edx +c0100723: 8b 4a 08 mov 0x8(%edx),%ecx +c0100726: 29 c8 sub %ecx,%eax +c0100728: 89 c2 mov %eax,%edx +c010072a: 8b 45 0c mov 0xc(%ebp),%eax +c010072d: 89 50 0c mov %edx,0xc(%eax) // Search within [lline, rline] for the line number stab. // If found, set info->eip_line to the right line number. // If not found, return -1. stab_binsearch(stabs, &lline, &rline, N_SLINE, addr); -c0100831: 8b 45 08 mov 0x8(%ebp),%eax -c0100834: 89 44 24 10 mov %eax,0x10(%esp) -c0100838: c7 44 24 0c 44 00 00 movl $0x44,0xc(%esp) -c010083f: 00 -c0100840: 8d 45 d0 lea -0x30(%ebp),%eax -c0100843: 89 44 24 08 mov %eax,0x8(%esp) -c0100847: 8d 45 d4 lea -0x2c(%ebp),%eax -c010084a: 89 44 24 04 mov %eax,0x4(%esp) -c010084e: 8b 45 f4 mov -0xc(%ebp),%eax -c0100851: 89 04 24 mov %eax,(%esp) -c0100854: e8 c5 fc ff ff call c010051e +c0100730: 8b 45 08 mov 0x8(%ebp),%eax +c0100733: 89 44 24 10 mov %eax,0x10(%esp) +c0100737: c7 44 24 0c 44 00 00 movl $0x44,0xc(%esp) +c010073e: 00 +c010073f: 8d 45 d0 lea -0x30(%ebp),%eax +c0100742: 89 44 24 08 mov %eax,0x8(%esp) +c0100746: 8d 45 d4 lea -0x2c(%ebp),%eax +c0100749: 89 44 24 04 mov %eax,0x4(%esp) +c010074d: 8b 45 f4 mov -0xc(%ebp),%eax +c0100750: 89 04 24 mov %eax,(%esp) +c0100753: e8 cb fc ff ff call c0100423 if (lline <= rline) { -c0100859: 8b 55 d4 mov -0x2c(%ebp),%edx -c010085c: 8b 45 d0 mov -0x30(%ebp),%eax -c010085f: 39 c2 cmp %eax,%edx -c0100861: 7f 23 jg c0100886 +c0100758: 8b 55 d4 mov -0x2c(%ebp),%edx +c010075b: 8b 45 d0 mov -0x30(%ebp),%eax +c010075e: 39 c2 cmp %eax,%edx +c0100760: 7f 23 jg c0100785 info->eip_line = stabs[rline].n_desc; -c0100863: 8b 45 d0 mov -0x30(%ebp),%eax -c0100866: 89 c2 mov %eax,%edx -c0100868: 89 d0 mov %edx,%eax -c010086a: 01 c0 add %eax,%eax -c010086c: 01 d0 add %edx,%eax -c010086e: c1 e0 02 shl $0x2,%eax -c0100871: 89 c2 mov %eax,%edx -c0100873: 8b 45 f4 mov -0xc(%ebp),%eax -c0100876: 01 d0 add %edx,%eax -c0100878: 0f b7 40 06 movzwl 0x6(%eax),%eax -c010087c: 89 c2 mov %eax,%edx -c010087e: 8b 45 0c mov 0xc(%ebp),%eax -c0100881: 89 50 04 mov %edx,0x4(%eax) +c0100762: 8b 45 d0 mov -0x30(%ebp),%eax +c0100765: 89 c2 mov %eax,%edx +c0100767: 89 d0 mov %edx,%eax +c0100769: 01 c0 add %eax,%eax +c010076b: 01 d0 add %edx,%eax +c010076d: c1 e0 02 shl $0x2,%eax +c0100770: 89 c2 mov %eax,%edx +c0100772: 8b 45 f4 mov -0xc(%ebp),%eax +c0100775: 01 d0 add %edx,%eax +c0100777: 0f b7 40 06 movzwl 0x6(%eax),%eax +c010077b: 89 c2 mov %eax,%edx +c010077d: 8b 45 0c mov 0xc(%ebp),%eax +c0100780: 89 50 04 mov %edx,0x4(%eax) // Search backwards from the line number for the relevant filename stab. // We can't just use the "lfile" stab because inlined functions // can interpolate code from a different file! // Such included source files use the N_SOL stab type. while (lline >= lfile -c0100884: eb 11 jmp c0100897 +c0100783: eb 11 jmp c0100796 return -1; -c0100886: b8 ff ff ff ff mov $0xffffffff,%eax -c010088b: e9 08 01 00 00 jmp c0100998 +c0100785: b8 ff ff ff ff mov $0xffffffff,%eax +c010078a: e9 08 01 00 00 jmp c0100897 && stabs[lline].n_type != N_SOL && (stabs[lline].n_type != N_SO || !stabs[lline].n_value)) { lline --; -c0100890: 8b 45 d4 mov -0x2c(%ebp),%eax -c0100893: 48 dec %eax -c0100894: 89 45 d4 mov %eax,-0x2c(%ebp) +c010078f: 8b 45 d4 mov -0x2c(%ebp),%eax +c0100792: 48 dec %eax +c0100793: 89 45 d4 mov %eax,-0x2c(%ebp) while (lline >= lfile -c0100897: 8b 55 d4 mov -0x2c(%ebp),%edx -c010089a: 8b 45 e4 mov -0x1c(%ebp),%eax -c010089d: 39 c2 cmp %eax,%edx -c010089f: 7c 56 jl c01008f7 +c0100796: 8b 55 d4 mov -0x2c(%ebp),%edx +c0100799: 8b 45 e4 mov -0x1c(%ebp),%eax + && (stabs[lline].n_type != N_SO || !stabs[lline].n_value)) { +c010079c: 39 c2 cmp %eax,%edx +c010079e: 7c 56 jl c01007f6 && stabs[lline].n_type != N_SOL -c01008a1: 8b 45 d4 mov -0x2c(%ebp),%eax -c01008a4: 89 c2 mov %eax,%edx -c01008a6: 89 d0 mov %edx,%eax -c01008a8: 01 c0 add %eax,%eax -c01008aa: 01 d0 add %edx,%eax -c01008ac: c1 e0 02 shl $0x2,%eax -c01008af: 89 c2 mov %eax,%edx -c01008b1: 8b 45 f4 mov -0xc(%ebp),%eax -c01008b4: 01 d0 add %edx,%eax -c01008b6: 0f b6 40 04 movzbl 0x4(%eax),%eax -c01008ba: 3c 84 cmp $0x84,%al -c01008bc: 74 39 je c01008f7 +c01007a0: 8b 45 d4 mov -0x2c(%ebp),%eax +c01007a3: 89 c2 mov %eax,%edx +c01007a5: 89 d0 mov %edx,%eax +c01007a7: 01 c0 add %eax,%eax +c01007a9: 01 d0 add %edx,%eax +c01007ab: c1 e0 02 shl $0x2,%eax +c01007ae: 89 c2 mov %eax,%edx +c01007b0: 8b 45 f4 mov -0xc(%ebp),%eax +c01007b3: 01 d0 add %edx,%eax +c01007b5: 0f b6 40 04 movzbl 0x4(%eax),%eax +c01007b9: 3c 84 cmp $0x84,%al +c01007bb: 74 39 je c01007f6 && (stabs[lline].n_type != N_SO || !stabs[lline].n_value)) { -c01008be: 8b 45 d4 mov -0x2c(%ebp),%eax -c01008c1: 89 c2 mov %eax,%edx -c01008c3: 89 d0 mov %edx,%eax -c01008c5: 01 c0 add %eax,%eax -c01008c7: 01 d0 add %edx,%eax -c01008c9: c1 e0 02 shl $0x2,%eax -c01008cc: 89 c2 mov %eax,%edx -c01008ce: 8b 45 f4 mov -0xc(%ebp),%eax -c01008d1: 01 d0 add %edx,%eax -c01008d3: 0f b6 40 04 movzbl 0x4(%eax),%eax -c01008d7: 3c 64 cmp $0x64,%al -c01008d9: 75 b5 jne c0100890 -c01008db: 8b 45 d4 mov -0x2c(%ebp),%eax -c01008de: 89 c2 mov %eax,%edx -c01008e0: 89 d0 mov %edx,%eax -c01008e2: 01 c0 add %eax,%eax -c01008e4: 01 d0 add %edx,%eax -c01008e6: c1 e0 02 shl $0x2,%eax -c01008e9: 89 c2 mov %eax,%edx -c01008eb: 8b 45 f4 mov -0xc(%ebp),%eax -c01008ee: 01 d0 add %edx,%eax -c01008f0: 8b 40 08 mov 0x8(%eax),%eax -c01008f3: 85 c0 test %eax,%eax -c01008f5: 74 99 je c0100890 +c01007bd: 8b 45 d4 mov -0x2c(%ebp),%eax +c01007c0: 89 c2 mov %eax,%edx +c01007c2: 89 d0 mov %edx,%eax +c01007c4: 01 c0 add %eax,%eax +c01007c6: 01 d0 add %edx,%eax +c01007c8: c1 e0 02 shl $0x2,%eax +c01007cb: 89 c2 mov %eax,%edx +c01007cd: 8b 45 f4 mov -0xc(%ebp),%eax +c01007d0: 01 d0 add %edx,%eax +c01007d2: 0f b6 40 04 movzbl 0x4(%eax),%eax +c01007d6: 3c 64 cmp $0x64,%al +c01007d8: 75 b5 jne c010078f +c01007da: 8b 45 d4 mov -0x2c(%ebp),%eax +c01007dd: 89 c2 mov %eax,%edx +c01007df: 89 d0 mov %edx,%eax +c01007e1: 01 c0 add %eax,%eax +c01007e3: 01 d0 add %edx,%eax +c01007e5: c1 e0 02 shl $0x2,%eax +c01007e8: 89 c2 mov %eax,%edx +c01007ea: 8b 45 f4 mov -0xc(%ebp),%eax +c01007ed: 01 d0 add %edx,%eax +c01007ef: 8b 40 08 mov 0x8(%eax),%eax +c01007f2: 85 c0 test %eax,%eax +c01007f4: 74 99 je c010078f } if (lline >= lfile && stabs[lline].n_strx < stabstr_end - stabstr) { -c01008f7: 8b 55 d4 mov -0x2c(%ebp),%edx -c01008fa: 8b 45 e4 mov -0x1c(%ebp),%eax -c01008fd: 39 c2 cmp %eax,%edx -c01008ff: 7c 42 jl c0100943 -c0100901: 8b 45 d4 mov -0x2c(%ebp),%eax -c0100904: 89 c2 mov %eax,%edx -c0100906: 89 d0 mov %edx,%eax -c0100908: 01 c0 add %eax,%eax -c010090a: 01 d0 add %edx,%eax -c010090c: c1 e0 02 shl $0x2,%eax -c010090f: 89 c2 mov %eax,%edx -c0100911: 8b 45 f4 mov -0xc(%ebp),%eax -c0100914: 01 d0 add %edx,%eax -c0100916: 8b 10 mov (%eax),%edx -c0100918: 8b 45 e8 mov -0x18(%ebp),%eax -c010091b: 2b 45 ec sub -0x14(%ebp),%eax -c010091e: 39 c2 cmp %eax,%edx -c0100920: 73 21 jae c0100943 +c01007f6: 8b 55 d4 mov -0x2c(%ebp),%edx +c01007f9: 8b 45 e4 mov -0x1c(%ebp),%eax +c01007fc: 39 c2 cmp %eax,%edx +c01007fe: 7c 42 jl c0100842 +c0100800: 8b 45 d4 mov -0x2c(%ebp),%eax +c0100803: 89 c2 mov %eax,%edx +c0100805: 89 d0 mov %edx,%eax +c0100807: 01 c0 add %eax,%eax +c0100809: 01 d0 add %edx,%eax +c010080b: c1 e0 02 shl $0x2,%eax +c010080e: 89 c2 mov %eax,%edx +c0100810: 8b 45 f4 mov -0xc(%ebp),%eax +c0100813: 01 d0 add %edx,%eax +c0100815: 8b 10 mov (%eax),%edx +c0100817: 8b 45 e8 mov -0x18(%ebp),%eax +c010081a: 2b 45 ec sub -0x14(%ebp),%eax +c010081d: 39 c2 cmp %eax,%edx +c010081f: 73 21 jae c0100842 info->eip_file = stabstr + stabs[lline].n_strx; -c0100922: 8b 45 d4 mov -0x2c(%ebp),%eax -c0100925: 89 c2 mov %eax,%edx -c0100927: 89 d0 mov %edx,%eax -c0100929: 01 c0 add %eax,%eax -c010092b: 01 d0 add %edx,%eax -c010092d: c1 e0 02 shl $0x2,%eax -c0100930: 89 c2 mov %eax,%edx -c0100932: 8b 45 f4 mov -0xc(%ebp),%eax -c0100935: 01 d0 add %edx,%eax -c0100937: 8b 10 mov (%eax),%edx -c0100939: 8b 45 ec mov -0x14(%ebp),%eax -c010093c: 01 c2 add %eax,%edx -c010093e: 8b 45 0c mov 0xc(%ebp),%eax -c0100941: 89 10 mov %edx,(%eax) +c0100821: 8b 45 d4 mov -0x2c(%ebp),%eax +c0100824: 89 c2 mov %eax,%edx +c0100826: 89 d0 mov %edx,%eax +c0100828: 01 c0 add %eax,%eax +c010082a: 01 d0 add %edx,%eax +c010082c: c1 e0 02 shl $0x2,%eax +c010082f: 89 c2 mov %eax,%edx +c0100831: 8b 45 f4 mov -0xc(%ebp),%eax +c0100834: 01 d0 add %edx,%eax +c0100836: 8b 10 mov (%eax),%edx +c0100838: 8b 45 ec mov -0x14(%ebp),%eax +c010083b: 01 c2 add %eax,%edx +c010083d: 8b 45 0c mov 0xc(%ebp),%eax +c0100840: 89 10 mov %edx,(%eax) } // Set eip_fn_narg to the number of arguments taken by the function, // or 0 if there was no containing function. if (lfun < rfun) { -c0100943: 8b 55 dc mov -0x24(%ebp),%edx -c0100946: 8b 45 d8 mov -0x28(%ebp),%eax -c0100949: 39 c2 cmp %eax,%edx -c010094b: 7d 46 jge c0100993 +c0100842: 8b 55 dc mov -0x24(%ebp),%edx +c0100845: 8b 45 d8 mov -0x28(%ebp),%eax +c0100848: 39 c2 cmp %eax,%edx +c010084a: 7d 46 jge c0100892 for (lline = lfun + 1; -c010094d: 8b 45 dc mov -0x24(%ebp),%eax -c0100950: 40 inc %eax -c0100951: 89 45 d4 mov %eax,-0x2c(%ebp) -c0100954: eb 16 jmp c010096c +c010084c: 8b 45 dc mov -0x24(%ebp),%eax +c010084f: 40 inc %eax +c0100850: 89 45 d4 mov %eax,-0x2c(%ebp) +c0100853: eb 16 jmp c010086b lline < rfun && stabs[lline].n_type == N_PSYM; lline ++) { info->eip_fn_narg ++; -c0100956: 8b 45 0c mov 0xc(%ebp),%eax -c0100959: 8b 40 14 mov 0x14(%eax),%eax -c010095c: 8d 50 01 lea 0x1(%eax),%edx -c010095f: 8b 45 0c mov 0xc(%ebp),%eax -c0100962: 89 50 14 mov %edx,0x14(%eax) +c0100855: 8b 45 0c mov 0xc(%ebp),%eax +c0100858: 8b 40 14 mov 0x14(%eax),%eax +c010085b: 8d 50 01 lea 0x1(%eax),%edx +c010085e: 8b 45 0c mov 0xc(%ebp),%eax +c0100861: 89 50 14 mov %edx,0x14(%eax) lline ++) { -c0100965: 8b 45 d4 mov -0x2c(%ebp),%eax -c0100968: 40 inc %eax -c0100969: 89 45 d4 mov %eax,-0x2c(%ebp) - lline < rfun && stabs[lline].n_type == N_PSYM; -c010096c: 8b 55 d4 mov -0x2c(%ebp),%edx -c010096f: 8b 45 d8 mov -0x28(%ebp),%eax - for (lline = lfun + 1; -c0100972: 39 c2 cmp %eax,%edx -c0100974: 7d 1d jge c0100993 +c0100864: 8b 45 d4 mov -0x2c(%ebp),%eax +c0100867: 40 inc %eax +c0100868: 89 45 d4 mov %eax,-0x2c(%ebp) lline < rfun && stabs[lline].n_type == N_PSYM; -c0100976: 8b 45 d4 mov -0x2c(%ebp),%eax -c0100979: 89 c2 mov %eax,%edx -c010097b: 89 d0 mov %edx,%eax -c010097d: 01 c0 add %eax,%eax -c010097f: 01 d0 add %edx,%eax -c0100981: c1 e0 02 shl $0x2,%eax -c0100984: 89 c2 mov %eax,%edx -c0100986: 8b 45 f4 mov -0xc(%ebp),%eax -c0100989: 01 d0 add %edx,%eax -c010098b: 0f b6 40 04 movzbl 0x4(%eax),%eax -c010098f: 3c a0 cmp $0xa0,%al -c0100991: 74 c3 je c0100956 +c010086b: 8b 55 d4 mov -0x2c(%ebp),%edx +c010086e: 8b 45 d8 mov -0x28(%ebp),%eax +c0100871: 39 c2 cmp %eax,%edx +c0100873: 7d 1d jge c0100892 +c0100875: 8b 45 d4 mov -0x2c(%ebp),%eax +c0100878: 89 c2 mov %eax,%edx +c010087a: 89 d0 mov %edx,%eax +c010087c: 01 c0 add %eax,%eax +c010087e: 01 d0 add %edx,%eax +c0100880: c1 e0 02 shl $0x2,%eax +c0100883: 89 c2 mov %eax,%edx +c0100885: 8b 45 f4 mov -0xc(%ebp),%eax +c0100888: 01 d0 add %edx,%eax +c010088a: 0f b6 40 04 movzbl 0x4(%eax),%eax +c010088e: 3c a0 cmp $0xa0,%al +c0100890: 74 c3 je c0100855 } } return 0; -c0100993: b8 00 00 00 00 mov $0x0,%eax +c0100892: b8 00 00 00 00 mov $0x0,%eax } -c0100998: c9 leave -c0100999: c3 ret +c0100897: 89 ec mov %ebp,%esp +c0100899: 5d pop %ebp +c010089a: c3 ret -c010099a : +c010089b : * print_kerninfo - print the information about kernel, including the location * of kernel entry, the start addresses of data and text segements, the start * address of free memory and how many memory that kernel has used. * */ void print_kerninfo(void) { -c010099a: f3 0f 1e fb endbr32 -c010099e: 55 push %ebp -c010099f: 89 e5 mov %esp,%ebp -c01009a1: 83 ec 18 sub $0x18,%esp +c010089b: 55 push %ebp +c010089c: 89 e5 mov %esp,%ebp +c010089e: 83 ec 18 sub $0x18,%esp extern char etext[], edata[], end[], kern_init[]; cprintf("Special kernel symbols:\n"); -c01009a4: c7 04 24 a2 a3 10 c0 movl $0xc010a3a2,(%esp) -c01009ab: e8 27 f9 ff ff call c01002d7 +c01008a1: c7 04 24 36 a1 10 c0 movl $0xc010a136,(%esp) +c01008a8: e8 cb fa ff ff call c0100378 cprintf(" entry 0x%08x (phys)\n", kern_init); -c01009b0: c7 44 24 04 36 00 10 movl $0xc0100036,0x4(%esp) -c01009b7: c0 -c01009b8: c7 04 24 bb a3 10 c0 movl $0xc010a3bb,(%esp) -c01009bf: e8 13 f9 ff ff call c01002d7 +c01008ad: c7 44 24 04 36 00 10 movl $0xc0100036,0x4(%esp) +c01008b4: c0 +c01008b5: c7 04 24 4f a1 10 c0 movl $0xc010a14f,(%esp) +c01008bc: e8 b7 fa ff ff call c0100378 cprintf(" etext 0x%08x (phys)\n", etext); -c01009c4: c7 44 24 04 81 a2 10 movl $0xc010a281,0x4(%esp) -c01009cb: c0 -c01009cc: c7 04 24 d3 a3 10 c0 movl $0xc010a3d3,(%esp) -c01009d3: e8 ff f8 ff ff call c01002d7 +c01008c1: c7 44 24 04 70 a0 10 movl $0xc010a070,0x4(%esp) +c01008c8: c0 +c01008c9: c7 04 24 67 a1 10 c0 movl $0xc010a167,(%esp) +c01008d0: e8 a3 fa ff ff call c0100378 cprintf(" edata 0x%08x (phys)\n", edata); -c01009d8: c7 44 24 04 00 b0 12 movl $0xc012b000,0x4(%esp) -c01009df: c0 -c01009e0: c7 04 24 eb a3 10 c0 movl $0xc010a3eb,(%esp) -c01009e7: e8 eb f8 ff ff call c01002d7 +c01008d5: c7 44 24 04 00 b0 12 movl $0xc012b000,0x4(%esp) +c01008dc: c0 +c01008dd: c7 04 24 7f a1 10 c0 movl $0xc010a17f,(%esp) +c01008e4: e8 8f fa ff ff call c0100378 cprintf(" end 0x%08x (phys)\n", end); -c01009ec: c7 44 24 04 b8 e1 12 movl $0xc012e1b8,0x4(%esp) -c01009f3: c0 -c01009f4: c7 04 24 03 a4 10 c0 movl $0xc010a403,(%esp) -c01009fb: e8 d7 f8 ff ff call c01002d7 +c01008e9: c7 44 24 04 b4 e1 12 movl $0xc012e1b4,0x4(%esp) +c01008f0: c0 +c01008f1: c7 04 24 97 a1 10 c0 movl $0xc010a197,(%esp) +c01008f8: e8 7b fa ff ff call c0100378 cprintf("Kernel executable memory footprint: %dKB\n", (end - kern_init + 1023)/1024); -c0100a00: b8 b8 e1 12 c0 mov $0xc012e1b8,%eax -c0100a05: 2d 36 00 10 c0 sub $0xc0100036,%eax -c0100a0a: 05 ff 03 00 00 add $0x3ff,%eax -c0100a0f: 8d 90 ff 03 00 00 lea 0x3ff(%eax),%edx -c0100a15: 85 c0 test %eax,%eax -c0100a17: 0f 48 c2 cmovs %edx,%eax -c0100a1a: c1 f8 0a sar $0xa,%eax -c0100a1d: 89 44 24 04 mov %eax,0x4(%esp) -c0100a21: c7 04 24 1c a4 10 c0 movl $0xc010a41c,(%esp) -c0100a28: e8 aa f8 ff ff call c01002d7 -} -c0100a2d: 90 nop -c0100a2e: c9 leave -c0100a2f: c3 ret - -c0100a30 : +c01008fd: b8 b4 e1 12 c0 mov $0xc012e1b4,%eax +c0100902: 2d 36 00 10 c0 sub $0xc0100036,%eax +c0100907: 05 ff 03 00 00 add $0x3ff,%eax +c010090c: 8d 90 ff 03 00 00 lea 0x3ff(%eax),%edx +c0100912: 85 c0 test %eax,%eax +c0100914: 0f 48 c2 cmovs %edx,%eax +c0100917: c1 f8 0a sar $0xa,%eax +c010091a: 89 44 24 04 mov %eax,0x4(%esp) +c010091e: c7 04 24 b0 a1 10 c0 movl $0xc010a1b0,(%esp) +c0100925: e8 4e fa ff ff call c0100378 +} +c010092a: 90 nop +c010092b: 89 ec mov %ebp,%esp +c010092d: 5d pop %ebp +c010092e: c3 ret + +c010092f : /* * * print_debuginfo - read and print the stat information for the address @eip, * and info.eip_fn_addr should be the first address of the related function. * */ void print_debuginfo(uintptr_t eip) { -c0100a30: f3 0f 1e fb endbr32 -c0100a34: 55 push %ebp -c0100a35: 89 e5 mov %esp,%ebp -c0100a37: 81 ec 48 01 00 00 sub $0x148,%esp +c010092f: 55 push %ebp +c0100930: 89 e5 mov %esp,%ebp +c0100932: 81 ec 48 01 00 00 sub $0x148,%esp struct eipdebuginfo info; if (debuginfo_eip(eip, &info) != 0) { -c0100a3d: 8d 45 dc lea -0x24(%ebp),%eax -c0100a40: 89 44 24 04 mov %eax,0x4(%esp) -c0100a44: 8b 45 08 mov 0x8(%ebp),%eax -c0100a47: 89 04 24 mov %eax,(%esp) -c0100a4a: e8 21 fc ff ff call c0100670 -c0100a4f: 85 c0 test %eax,%eax -c0100a51: 74 15 je c0100a68 +c0100938: 8d 45 dc lea -0x24(%ebp),%eax +c010093b: 89 44 24 04 mov %eax,0x4(%esp) +c010093f: 8b 45 08 mov 0x8(%ebp),%eax +c0100942: 89 04 24 mov %eax,(%esp) +c0100945: e8 29 fc ff ff call c0100573 +c010094a: 85 c0 test %eax,%eax +c010094c: 74 15 je c0100963 cprintf(" : -- 0x%08x --\n", eip); -c0100a53: 8b 45 08 mov 0x8(%ebp),%eax -c0100a56: 89 44 24 04 mov %eax,0x4(%esp) -c0100a5a: c7 04 24 46 a4 10 c0 movl $0xc010a446,(%esp) -c0100a61: e8 71 f8 ff ff call c01002d7 +c010094e: 8b 45 08 mov 0x8(%ebp),%eax +c0100951: 89 44 24 04 mov %eax,0x4(%esp) +c0100955: c7 04 24 da a1 10 c0 movl $0xc010a1da,(%esp) +c010095c: e8 17 fa ff ff call c0100378 } fnname[j] = '\0'; cprintf(" %s:%d: %s+%d\n", info.eip_file, info.eip_line, fnname, eip - info.eip_fn_addr); } } -c0100a66: eb 6c jmp c0100ad4 +c0100961: eb 6c jmp c01009cf for (j = 0; j < info.eip_fn_namelen; j ++) { -c0100a68: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -c0100a6f: eb 1b jmp c0100a8c +c0100963: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c010096a: eb 1b jmp c0100987 fnname[j] = info.eip_fn_name[j]; -c0100a71: 8b 55 e4 mov -0x1c(%ebp),%edx -c0100a74: 8b 45 f4 mov -0xc(%ebp),%eax -c0100a77: 01 d0 add %edx,%eax -c0100a79: 0f b6 10 movzbl (%eax),%edx -c0100a7c: 8d 8d dc fe ff ff lea -0x124(%ebp),%ecx -c0100a82: 8b 45 f4 mov -0xc(%ebp),%eax -c0100a85: 01 c8 add %ecx,%eax -c0100a87: 88 10 mov %dl,(%eax) +c010096c: 8b 55 e4 mov -0x1c(%ebp),%edx +c010096f: 8b 45 f4 mov -0xc(%ebp),%eax +c0100972: 01 d0 add %edx,%eax +c0100974: 0f b6 10 movzbl (%eax),%edx +c0100977: 8d 8d dc fe ff ff lea -0x124(%ebp),%ecx +c010097d: 8b 45 f4 mov -0xc(%ebp),%eax +c0100980: 01 c8 add %ecx,%eax +c0100982: 88 10 mov %dl,(%eax) for (j = 0; j < info.eip_fn_namelen; j ++) { -c0100a89: ff 45 f4 incl -0xc(%ebp) -c0100a8c: 8b 45 e8 mov -0x18(%ebp),%eax -c0100a8f: 39 45 f4 cmp %eax,-0xc(%ebp) -c0100a92: 7c dd jl c0100a71 +c0100984: ff 45 f4 incl -0xc(%ebp) +c0100987: 8b 45 e8 mov -0x18(%ebp),%eax +c010098a: 39 45 f4 cmp %eax,-0xc(%ebp) +c010098d: 7c dd jl c010096c fnname[j] = '\0'; -c0100a94: 8d 95 dc fe ff ff lea -0x124(%ebp),%edx -c0100a9a: 8b 45 f4 mov -0xc(%ebp),%eax -c0100a9d: 01 d0 add %edx,%eax -c0100a9f: c6 00 00 movb $0x0,(%eax) +c010098f: 8d 95 dc fe ff ff lea -0x124(%ebp),%edx +c0100995: 8b 45 f4 mov -0xc(%ebp),%eax +c0100998: 01 d0 add %edx,%eax +c010099a: c6 00 00 movb $0x0,(%eax) fnname, eip - info.eip_fn_addr); -c0100aa2: 8b 45 ec mov -0x14(%ebp),%eax +c010099d: 8b 55 ec mov -0x14(%ebp),%edx cprintf(" %s:%d: %s+%d\n", info.eip_file, info.eip_line, -c0100aa5: 8b 55 08 mov 0x8(%ebp),%edx -c0100aa8: 89 d1 mov %edx,%ecx -c0100aaa: 29 c1 sub %eax,%ecx -c0100aac: 8b 55 e0 mov -0x20(%ebp),%edx -c0100aaf: 8b 45 dc mov -0x24(%ebp),%eax -c0100ab2: 89 4c 24 10 mov %ecx,0x10(%esp) -c0100ab6: 8d 8d dc fe ff ff lea -0x124(%ebp),%ecx -c0100abc: 89 4c 24 0c mov %ecx,0xc(%esp) -c0100ac0: 89 54 24 08 mov %edx,0x8(%esp) -c0100ac4: 89 44 24 04 mov %eax,0x4(%esp) -c0100ac8: c7 04 24 62 a4 10 c0 movl $0xc010a462,(%esp) -c0100acf: e8 03 f8 ff ff call c01002d7 -} -c0100ad4: 90 nop -c0100ad5: c9 leave -c0100ad6: c3 ret - -c0100ad7 : +c01009a0: 8b 45 08 mov 0x8(%ebp),%eax +c01009a3: 29 d0 sub %edx,%eax +c01009a5: 89 c1 mov %eax,%ecx +c01009a7: 8b 55 e0 mov -0x20(%ebp),%edx +c01009aa: 8b 45 dc mov -0x24(%ebp),%eax +c01009ad: 89 4c 24 10 mov %ecx,0x10(%esp) +c01009b1: 8d 8d dc fe ff ff lea -0x124(%ebp),%ecx +c01009b7: 89 4c 24 0c mov %ecx,0xc(%esp) +c01009bb: 89 54 24 08 mov %edx,0x8(%esp) +c01009bf: 89 44 24 04 mov %eax,0x4(%esp) +c01009c3: c7 04 24 f6 a1 10 c0 movl $0xc010a1f6,(%esp) +c01009ca: e8 a9 f9 ff ff call c0100378 +} +c01009cf: 90 nop +c01009d0: 89 ec mov %ebp,%esp +c01009d2: 5d pop %ebp +c01009d3: c3 ret + +c01009d4 : static __noinline uint32_t read_eip(void) { -c0100ad7: f3 0f 1e fb endbr32 -c0100adb: 55 push %ebp -c0100adc: 89 e5 mov %esp,%ebp -c0100ade: 83 ec 10 sub $0x10,%esp +c01009d4: 55 push %ebp +c01009d5: 89 e5 mov %esp,%ebp +c01009d7: 83 ec 10 sub $0x10,%esp uint32_t eip; asm volatile("movl 4(%%ebp), %0" : "=r" (eip)); -c0100ae1: 8b 45 04 mov 0x4(%ebp),%eax -c0100ae4: 89 45 fc mov %eax,-0x4(%ebp) +c01009da: 8b 45 04 mov 0x4(%ebp),%eax +c01009dd: 89 45 fc mov %eax,-0x4(%ebp) return eip; -c0100ae7: 8b 45 fc mov -0x4(%ebp),%eax +c01009e0: 8b 45 fc mov -0x4(%ebp),%eax } -c0100aea: c9 leave -c0100aeb: c3 ret +c01009e3: 89 ec mov %ebp,%esp +c01009e5: 5d pop %ebp +c01009e6: c3 ret -c0100aec : +c01009e7 : * * Note that, the length of ebp-chain is limited. In boot/bootasm.S, before jumping * to the kernel entry, the value of ebp has been set to zero, that's the boundary. * */ void print_stackframe(void) { -c0100aec: f3 0f 1e fb endbr32 -c0100af0: 55 push %ebp -c0100af1: 89 e5 mov %esp,%ebp +c01009e7: 55 push %ebp +c01009e8: 89 e5 mov %esp,%ebp * (3.4) call print_debuginfo(eip-1) to print the C calling function name and line number, etc. * (3.5) popup a calling stackframe * NOTICE: the calling funciton's return addr eip = ss:[ebp+4] * the calling funciton's ebp = ss:[ebp] */ } -c0100af3: 90 nop -c0100af4: 5d pop %ebp -c0100af5: c3 ret +c01009ea: 90 nop +c01009eb: 5d pop %ebp +c01009ec: c3 ret -c0100af6 : +c01009ed : #define MAXARGS 16 #define WHITESPACE " \t\n\r" /* parse - parse the command buffer into whitespace-separated arguments */ static int parse(char *buf, char **argv) { -c0100af6: f3 0f 1e fb endbr32 -c0100afa: 55 push %ebp -c0100afb: 89 e5 mov %esp,%ebp -c0100afd: 83 ec 28 sub $0x28,%esp +c01009ed: 55 push %ebp +c01009ee: 89 e5 mov %esp,%ebp +c01009f0: 83 ec 28 sub $0x28,%esp int argc = 0; -c0100b00: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c01009f3: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) while (1) { // find global whitespace while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) { -c0100b07: eb 0c jmp c0100b15 +c01009fa: eb 0c jmp c0100a08 *buf ++ = '\0'; -c0100b09: 8b 45 08 mov 0x8(%ebp),%eax -c0100b0c: 8d 50 01 lea 0x1(%eax),%edx -c0100b0f: 89 55 08 mov %edx,0x8(%ebp) -c0100b12: c6 00 00 movb $0x0,(%eax) +c01009fc: 8b 45 08 mov 0x8(%ebp),%eax +c01009ff: 8d 50 01 lea 0x1(%eax),%edx +c0100a02: 89 55 08 mov %edx,0x8(%ebp) +c0100a05: c6 00 00 movb $0x0,(%eax) while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) { -c0100b15: 8b 45 08 mov 0x8(%ebp),%eax -c0100b18: 0f b6 00 movzbl (%eax),%eax -c0100b1b: 84 c0 test %al,%al -c0100b1d: 74 1d je c0100b3c -c0100b1f: 8b 45 08 mov 0x8(%ebp),%eax -c0100b22: 0f b6 00 movzbl (%eax),%eax -c0100b25: 0f be c0 movsbl %al,%eax -c0100b28: 89 44 24 04 mov %eax,0x4(%esp) -c0100b2c: c7 04 24 f4 a4 10 c0 movl $0xc010a4f4,(%esp) -c0100b33: e8 5a 8c 00 00 call c0109792 -c0100b38: 85 c0 test %eax,%eax -c0100b3a: 75 cd jne c0100b09 +c0100a08: 8b 45 08 mov 0x8(%ebp),%eax +c0100a0b: 0f b6 00 movzbl (%eax),%eax +c0100a0e: 84 c0 test %al,%al +c0100a10: 74 1d je c0100a2f +c0100a12: 8b 45 08 mov 0x8(%ebp),%eax +c0100a15: 0f b6 00 movzbl (%eax),%eax +c0100a18: 0f be c0 movsbl %al,%eax +c0100a1b: 89 44 24 04 mov %eax,0x4(%esp) +c0100a1f: c7 04 24 88 a2 10 c0 movl $0xc010a288,(%esp) +c0100a26: e8 fd 92 00 00 call c0109d28 +c0100a2b: 85 c0 test %eax,%eax +c0100a2d: 75 cd jne c01009fc } if (*buf == '\0') { -c0100b3c: 8b 45 08 mov 0x8(%ebp),%eax -c0100b3f: 0f b6 00 movzbl (%eax),%eax -c0100b42: 84 c0 test %al,%al -c0100b44: 74 65 je c0100bab +c0100a2f: 8b 45 08 mov 0x8(%ebp),%eax +c0100a32: 0f b6 00 movzbl (%eax),%eax +c0100a35: 84 c0 test %al,%al +c0100a37: 74 65 je c0100a9e break; } // save and scan past next arg if (argc == MAXARGS - 1) { -c0100b46: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) -c0100b4a: 75 14 jne c0100b60 +c0100a39: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) +c0100a3d: 75 14 jne c0100a53 cprintf("Too many arguments (max %d).\n", MAXARGS); -c0100b4c: c7 44 24 04 10 00 00 movl $0x10,0x4(%esp) -c0100b53: 00 -c0100b54: c7 04 24 f9 a4 10 c0 movl $0xc010a4f9,(%esp) -c0100b5b: e8 77 f7 ff ff call c01002d7 +c0100a3f: c7 44 24 04 10 00 00 movl $0x10,0x4(%esp) +c0100a46: 00 +c0100a47: c7 04 24 8d a2 10 c0 movl $0xc010a28d,(%esp) +c0100a4e: e8 25 f9 ff ff call c0100378 } argv[argc ++] = buf; -c0100b60: 8b 45 f4 mov -0xc(%ebp),%eax -c0100b63: 8d 50 01 lea 0x1(%eax),%edx -c0100b66: 89 55 f4 mov %edx,-0xc(%ebp) -c0100b69: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx -c0100b70: 8b 45 0c mov 0xc(%ebp),%eax -c0100b73: 01 c2 add %eax,%edx -c0100b75: 8b 45 08 mov 0x8(%ebp),%eax -c0100b78: 89 02 mov %eax,(%edx) +c0100a53: 8b 45 f4 mov -0xc(%ebp),%eax +c0100a56: 8d 50 01 lea 0x1(%eax),%edx +c0100a59: 89 55 f4 mov %edx,-0xc(%ebp) +c0100a5c: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx +c0100a63: 8b 45 0c mov 0xc(%ebp),%eax +c0100a66: 01 c2 add %eax,%edx +c0100a68: 8b 45 08 mov 0x8(%ebp),%eax +c0100a6b: 89 02 mov %eax,(%edx) while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) { -c0100b7a: eb 03 jmp c0100b7f +c0100a6d: eb 03 jmp c0100a72 buf ++; -c0100b7c: ff 45 08 incl 0x8(%ebp) +c0100a6f: ff 45 08 incl 0x8(%ebp) while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) { -c0100b7f: 8b 45 08 mov 0x8(%ebp),%eax -c0100b82: 0f b6 00 movzbl (%eax),%eax -c0100b85: 84 c0 test %al,%al -c0100b87: 74 8c je c0100b15 -c0100b89: 8b 45 08 mov 0x8(%ebp),%eax -c0100b8c: 0f b6 00 movzbl (%eax),%eax -c0100b8f: 0f be c0 movsbl %al,%eax -c0100b92: 89 44 24 04 mov %eax,0x4(%esp) -c0100b96: c7 04 24 f4 a4 10 c0 movl $0xc010a4f4,(%esp) -c0100b9d: e8 f0 8b 00 00 call c0109792 -c0100ba2: 85 c0 test %eax,%eax -c0100ba4: 74 d6 je c0100b7c +c0100a72: 8b 45 08 mov 0x8(%ebp),%eax +c0100a75: 0f b6 00 movzbl (%eax),%eax +c0100a78: 84 c0 test %al,%al +c0100a7a: 74 8c je c0100a08 +c0100a7c: 8b 45 08 mov 0x8(%ebp),%eax +c0100a7f: 0f b6 00 movzbl (%eax),%eax +c0100a82: 0f be c0 movsbl %al,%eax +c0100a85: 89 44 24 04 mov %eax,0x4(%esp) +c0100a89: c7 04 24 88 a2 10 c0 movl $0xc010a288,(%esp) +c0100a90: e8 93 92 00 00 call c0109d28 +c0100a95: 85 c0 test %eax,%eax +c0100a97: 74 d6 je c0100a6f while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) { -c0100ba6: e9 6a ff ff ff jmp c0100b15 +c0100a99: e9 6a ff ff ff jmp c0100a08 break; -c0100bab: 90 nop +c0100a9e: 90 nop } } return argc; -c0100bac: 8b 45 f4 mov -0xc(%ebp),%eax +c0100a9f: 8b 45 f4 mov -0xc(%ebp),%eax } -c0100baf: c9 leave -c0100bb0: c3 ret +c0100aa2: 89 ec mov %ebp,%esp +c0100aa4: 5d pop %ebp +c0100aa5: c3 ret -c0100bb1 : +c0100aa6 : /* * * runcmd - parse the input string, split it into separated arguments * and then lookup and invoke some related commands/ * */ static int runcmd(char *buf, struct trapframe *tf) { -c0100bb1: f3 0f 1e fb endbr32 -c0100bb5: 55 push %ebp -c0100bb6: 89 e5 mov %esp,%ebp -c0100bb8: 53 push %ebx -c0100bb9: 83 ec 64 sub $0x64,%esp +c0100aa6: 55 push %ebp +c0100aa7: 89 e5 mov %esp,%ebp +c0100aa9: 83 ec 68 sub $0x68,%esp +c0100aac: 89 5d fc mov %ebx,-0x4(%ebp) char *argv[MAXARGS]; int argc = parse(buf, argv); -c0100bbc: 8d 45 b0 lea -0x50(%ebp),%eax -c0100bbf: 89 44 24 04 mov %eax,0x4(%esp) -c0100bc3: 8b 45 08 mov 0x8(%ebp),%eax -c0100bc6: 89 04 24 mov %eax,(%esp) -c0100bc9: e8 28 ff ff ff call c0100af6 -c0100bce: 89 45 f0 mov %eax,-0x10(%ebp) +c0100aaf: 8d 45 b0 lea -0x50(%ebp),%eax +c0100ab2: 89 44 24 04 mov %eax,0x4(%esp) +c0100ab6: 8b 45 08 mov 0x8(%ebp),%eax +c0100ab9: 89 04 24 mov %eax,(%esp) +c0100abc: e8 2c ff ff ff call c01009ed +c0100ac1: 89 45 f0 mov %eax,-0x10(%ebp) if (argc == 0) { -c0100bd1: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c0100bd5: 75 0a jne c0100be1 +c0100ac4: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c0100ac8: 75 0a jne c0100ad4 return 0; -c0100bd7: b8 00 00 00 00 mov $0x0,%eax -c0100bdc: e9 83 00 00 00 jmp c0100c64 +c0100aca: b8 00 00 00 00 mov $0x0,%eax +c0100acf: e9 83 00 00 00 jmp c0100b57 } int i; for (i = 0; i < NCOMMANDS; i ++) { -c0100be1: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -c0100be8: eb 5a jmp c0100c44 +c0100ad4: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c0100adb: eb 5a jmp c0100b37 if (strcmp(commands[i].name, argv[0]) == 0) { -c0100bea: 8b 4d b0 mov -0x50(%ebp),%ecx -c0100bed: 8b 55 f4 mov -0xc(%ebp),%edx -c0100bf0: 89 d0 mov %edx,%eax -c0100bf2: 01 c0 add %eax,%eax -c0100bf4: 01 d0 add %edx,%eax -c0100bf6: c1 e0 02 shl $0x2,%eax -c0100bf9: 05 00 80 12 c0 add $0xc0128000,%eax -c0100bfe: 8b 00 mov (%eax),%eax -c0100c00: 89 4c 24 04 mov %ecx,0x4(%esp) -c0100c04: 89 04 24 mov %eax,(%esp) -c0100c07: e8 e2 8a 00 00 call c01096ee -c0100c0c: 85 c0 test %eax,%eax -c0100c0e: 75 31 jne c0100c41 +c0100add: 8b 55 b0 mov -0x50(%ebp),%edx +c0100ae0: 8b 4d f4 mov -0xc(%ebp),%ecx +c0100ae3: 89 c8 mov %ecx,%eax +c0100ae5: 01 c0 add %eax,%eax +c0100ae7: 01 c8 add %ecx,%eax +c0100ae9: c1 e0 02 shl $0x2,%eax +c0100aec: 05 00 80 12 c0 add $0xc0128000,%eax +c0100af1: 8b 00 mov (%eax),%eax +c0100af3: 89 54 24 04 mov %edx,0x4(%esp) +c0100af7: 89 04 24 mov %eax,(%esp) +c0100afa: e8 8d 91 00 00 call c0109c8c +c0100aff: 85 c0 test %eax,%eax +c0100b01: 75 31 jne c0100b34 return commands[i].func(argc - 1, argv + 1, tf); -c0100c10: 8b 55 f4 mov -0xc(%ebp),%edx -c0100c13: 89 d0 mov %edx,%eax -c0100c15: 01 c0 add %eax,%eax -c0100c17: 01 d0 add %edx,%eax -c0100c19: c1 e0 02 shl $0x2,%eax -c0100c1c: 05 08 80 12 c0 add $0xc0128008,%eax -c0100c21: 8b 10 mov (%eax),%edx -c0100c23: 8d 45 b0 lea -0x50(%ebp),%eax -c0100c26: 83 c0 04 add $0x4,%eax -c0100c29: 8b 4d f0 mov -0x10(%ebp),%ecx -c0100c2c: 8d 59 ff lea -0x1(%ecx),%ebx -c0100c2f: 8b 4d 0c mov 0xc(%ebp),%ecx -c0100c32: 89 4c 24 08 mov %ecx,0x8(%esp) -c0100c36: 89 44 24 04 mov %eax,0x4(%esp) -c0100c3a: 89 1c 24 mov %ebx,(%esp) -c0100c3d: ff d2 call *%edx -c0100c3f: eb 23 jmp c0100c64 +c0100b03: 8b 55 f4 mov -0xc(%ebp),%edx +c0100b06: 89 d0 mov %edx,%eax +c0100b08: 01 c0 add %eax,%eax +c0100b0a: 01 d0 add %edx,%eax +c0100b0c: c1 e0 02 shl $0x2,%eax +c0100b0f: 05 08 80 12 c0 add $0xc0128008,%eax +c0100b14: 8b 10 mov (%eax),%edx +c0100b16: 8d 45 b0 lea -0x50(%ebp),%eax +c0100b19: 83 c0 04 add $0x4,%eax +c0100b1c: 8b 4d f0 mov -0x10(%ebp),%ecx +c0100b1f: 8d 59 ff lea -0x1(%ecx),%ebx +c0100b22: 8b 4d 0c mov 0xc(%ebp),%ecx +c0100b25: 89 4c 24 08 mov %ecx,0x8(%esp) +c0100b29: 89 44 24 04 mov %eax,0x4(%esp) +c0100b2d: 89 1c 24 mov %ebx,(%esp) +c0100b30: ff d2 call *%edx +c0100b32: eb 23 jmp c0100b57 for (i = 0; i < NCOMMANDS; i ++) { -c0100c41: ff 45 f4 incl -0xc(%ebp) -c0100c44: 8b 45 f4 mov -0xc(%ebp),%eax -c0100c47: 83 f8 02 cmp $0x2,%eax -c0100c4a: 76 9e jbe c0100bea +c0100b34: ff 45 f4 incl -0xc(%ebp) +c0100b37: 8b 45 f4 mov -0xc(%ebp),%eax +c0100b3a: 83 f8 02 cmp $0x2,%eax +c0100b3d: 76 9e jbe c0100add } } cprintf("Unknown command '%s'\n", argv[0]); -c0100c4c: 8b 45 b0 mov -0x50(%ebp),%eax -c0100c4f: 89 44 24 04 mov %eax,0x4(%esp) -c0100c53: c7 04 24 17 a5 10 c0 movl $0xc010a517,(%esp) -c0100c5a: e8 78 f6 ff ff call c01002d7 +c0100b3f: 8b 45 b0 mov -0x50(%ebp),%eax +c0100b42: 89 44 24 04 mov %eax,0x4(%esp) +c0100b46: c7 04 24 ab a2 10 c0 movl $0xc010a2ab,(%esp) +c0100b4d: e8 26 f8 ff ff call c0100378 return 0; -c0100c5f: b8 00 00 00 00 mov $0x0,%eax +c0100b52: b8 00 00 00 00 mov $0x0,%eax } -c0100c64: 83 c4 64 add $0x64,%esp -c0100c67: 5b pop %ebx -c0100c68: 5d pop %ebp -c0100c69: c3 ret +c0100b57: 8b 5d fc mov -0x4(%ebp),%ebx +c0100b5a: 89 ec mov %ebp,%esp +c0100b5c: 5d pop %ebp +c0100b5d: c3 ret -c0100c6a : +c0100b5e : /***** Implementations of basic kernel monitor commands *****/ void kmonitor(struct trapframe *tf) { -c0100c6a: f3 0f 1e fb endbr32 -c0100c6e: 55 push %ebp -c0100c6f: 89 e5 mov %esp,%ebp -c0100c71: 83 ec 28 sub $0x28,%esp +c0100b5e: 55 push %ebp +c0100b5f: 89 e5 mov %esp,%ebp +c0100b61: 83 ec 28 sub $0x28,%esp cprintf("Welcome to the kernel debug monitor!!\n"); -c0100c74: c7 04 24 30 a5 10 c0 movl $0xc010a530,(%esp) -c0100c7b: e8 57 f6 ff ff call c01002d7 +c0100b64: c7 04 24 c4 a2 10 c0 movl $0xc010a2c4,(%esp) +c0100b6b: e8 08 f8 ff ff call c0100378 cprintf("Type 'help' for a list of commands.\n"); -c0100c80: c7 04 24 58 a5 10 c0 movl $0xc010a558,(%esp) -c0100c87: e8 4b f6 ff ff call c01002d7 +c0100b70: c7 04 24 ec a2 10 c0 movl $0xc010a2ec,(%esp) +c0100b77: e8 fc f7 ff ff call c0100378 if (tf != NULL) { -c0100c8c: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c0100c90: 74 0b je c0100c9d +c0100b7c: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0100b80: 74 0b je c0100b8d print_trapframe(tf); -c0100c92: 8b 45 08 mov 0x8(%ebp),%eax -c0100c95: 89 04 24 mov %eax,(%esp) -c0100c98: e8 a9 16 00 00 call c0102346 +c0100b82: 8b 45 08 mov 0x8(%ebp),%eax +c0100b85: 89 04 24 mov %eax,(%esp) +c0100b88: e8 2c 17 00 00 call c01022b9 } char *buf; while (1) { if ((buf = readline("K> ")) != NULL) { -c0100c9d: c7 04 24 7d a5 10 c0 movl $0xc010a57d,(%esp) -c0100ca4: e8 e1 f6 ff ff call c010038a -c0100ca9: 89 45 f4 mov %eax,-0xc(%ebp) -c0100cac: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0100cb0: 74 eb je c0100c9d +c0100b8d: c7 04 24 11 a3 10 c0 movl $0xc010a311,(%esp) +c0100b94: e8 d0 f6 ff ff call c0100269 +c0100b99: 89 45 f4 mov %eax,-0xc(%ebp) +c0100b9c: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0100ba0: 74 eb je c0100b8d if (runcmd(buf, tf) < 0) { -c0100cb2: 8b 45 08 mov 0x8(%ebp),%eax -c0100cb5: 89 44 24 04 mov %eax,0x4(%esp) -c0100cb9: 8b 45 f4 mov -0xc(%ebp),%eax -c0100cbc: 89 04 24 mov %eax,(%esp) -c0100cbf: e8 ed fe ff ff call c0100bb1 -c0100cc4: 85 c0 test %eax,%eax -c0100cc6: 78 02 js c0100cca +c0100ba2: 8b 45 08 mov 0x8(%ebp),%eax +c0100ba5: 89 44 24 04 mov %eax,0x4(%esp) +c0100ba9: 8b 45 f4 mov -0xc(%ebp),%eax +c0100bac: 89 04 24 mov %eax,(%esp) +c0100baf: e8 f2 fe ff ff call c0100aa6 +c0100bb4: 85 c0 test %eax,%eax +c0100bb6: 78 02 js c0100bba if ((buf = readline("K> ")) != NULL) { -c0100cc8: eb d3 jmp c0100c9d +c0100bb8: eb d3 jmp c0100b8d break; -c0100cca: 90 nop +c0100bba: 90 nop } } } } -c0100ccb: 90 nop -c0100ccc: c9 leave -c0100ccd: c3 ret +c0100bbb: 90 nop +c0100bbc: 89 ec mov %ebp,%esp +c0100bbe: 5d pop %ebp +c0100bbf: c3 ret -c0100cce : +c0100bc0 : /* mon_help - print the information about mon_* functions */ int mon_help(int argc, char **argv, struct trapframe *tf) { -c0100cce: f3 0f 1e fb endbr32 -c0100cd2: 55 push %ebp -c0100cd3: 89 e5 mov %esp,%ebp -c0100cd5: 83 ec 28 sub $0x28,%esp +c0100bc0: 55 push %ebp +c0100bc1: 89 e5 mov %esp,%ebp +c0100bc3: 83 ec 28 sub $0x28,%esp int i; for (i = 0; i < NCOMMANDS; i ++) { -c0100cd8: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -c0100cdf: eb 3d jmp c0100d1e +c0100bc6: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c0100bcd: eb 3d jmp c0100c0c cprintf("%s - %s\n", commands[i].name, commands[i].desc); -c0100ce1: 8b 55 f4 mov -0xc(%ebp),%edx -c0100ce4: 89 d0 mov %edx,%eax -c0100ce6: 01 c0 add %eax,%eax -c0100ce8: 01 d0 add %edx,%eax -c0100cea: c1 e0 02 shl $0x2,%eax -c0100ced: 05 04 80 12 c0 add $0xc0128004,%eax -c0100cf2: 8b 08 mov (%eax),%ecx -c0100cf4: 8b 55 f4 mov -0xc(%ebp),%edx -c0100cf7: 89 d0 mov %edx,%eax -c0100cf9: 01 c0 add %eax,%eax -c0100cfb: 01 d0 add %edx,%eax -c0100cfd: c1 e0 02 shl $0x2,%eax -c0100d00: 05 00 80 12 c0 add $0xc0128000,%eax -c0100d05: 8b 00 mov (%eax),%eax -c0100d07: 89 4c 24 08 mov %ecx,0x8(%esp) -c0100d0b: 89 44 24 04 mov %eax,0x4(%esp) -c0100d0f: c7 04 24 81 a5 10 c0 movl $0xc010a581,(%esp) -c0100d16: e8 bc f5 ff ff call c01002d7 +c0100bcf: 8b 55 f4 mov -0xc(%ebp),%edx +c0100bd2: 89 d0 mov %edx,%eax +c0100bd4: 01 c0 add %eax,%eax +c0100bd6: 01 d0 add %edx,%eax +c0100bd8: c1 e0 02 shl $0x2,%eax +c0100bdb: 05 04 80 12 c0 add $0xc0128004,%eax +c0100be0: 8b 10 mov (%eax),%edx +c0100be2: 8b 4d f4 mov -0xc(%ebp),%ecx +c0100be5: 89 c8 mov %ecx,%eax +c0100be7: 01 c0 add %eax,%eax +c0100be9: 01 c8 add %ecx,%eax +c0100beb: c1 e0 02 shl $0x2,%eax +c0100bee: 05 00 80 12 c0 add $0xc0128000,%eax +c0100bf3: 8b 00 mov (%eax),%eax +c0100bf5: 89 54 24 08 mov %edx,0x8(%esp) +c0100bf9: 89 44 24 04 mov %eax,0x4(%esp) +c0100bfd: c7 04 24 15 a3 10 c0 movl $0xc010a315,(%esp) +c0100c04: e8 6f f7 ff ff call c0100378 for (i = 0; i < NCOMMANDS; i ++) { -c0100d1b: ff 45 f4 incl -0xc(%ebp) -c0100d1e: 8b 45 f4 mov -0xc(%ebp),%eax -c0100d21: 83 f8 02 cmp $0x2,%eax -c0100d24: 76 bb jbe c0100ce1 +c0100c09: ff 45 f4 incl -0xc(%ebp) +c0100c0c: 8b 45 f4 mov -0xc(%ebp),%eax +c0100c0f: 83 f8 02 cmp $0x2,%eax +c0100c12: 76 bb jbe c0100bcf } return 0; -c0100d26: b8 00 00 00 00 mov $0x0,%eax +c0100c14: b8 00 00 00 00 mov $0x0,%eax } -c0100d2b: c9 leave -c0100d2c: c3 ret +c0100c19: 89 ec mov %ebp,%esp +c0100c1b: 5d pop %ebp +c0100c1c: c3 ret -c0100d2d : +c0100c1d : /* * * mon_kerninfo - call print_kerninfo in kern/debug/kdebug.c to * print the memory occupancy in kernel. * */ int mon_kerninfo(int argc, char **argv, struct trapframe *tf) { -c0100d2d: f3 0f 1e fb endbr32 -c0100d31: 55 push %ebp -c0100d32: 89 e5 mov %esp,%ebp -c0100d34: 83 ec 08 sub $0x8,%esp +c0100c1d: 55 push %ebp +c0100c1e: 89 e5 mov %esp,%ebp +c0100c20: 83 ec 08 sub $0x8,%esp print_kerninfo(); -c0100d37: e8 5e fc ff ff call c010099a +c0100c23: e8 73 fc ff ff call c010089b return 0; -c0100d3c: b8 00 00 00 00 mov $0x0,%eax +c0100c28: b8 00 00 00 00 mov $0x0,%eax } -c0100d41: c9 leave -c0100d42: c3 ret +c0100c2d: 89 ec mov %ebp,%esp +c0100c2f: 5d pop %ebp +c0100c30: c3 ret -c0100d43 : +c0100c31 : /* * * mon_backtrace - call print_stackframe in kern/debug/kdebug.c to * print a backtrace of the stack. * */ int mon_backtrace(int argc, char **argv, struct trapframe *tf) { -c0100d43: f3 0f 1e fb endbr32 -c0100d47: 55 push %ebp -c0100d48: 89 e5 mov %esp,%ebp -c0100d4a: 83 ec 08 sub $0x8,%esp +c0100c31: 55 push %ebp +c0100c32: 89 e5 mov %esp,%ebp +c0100c34: 83 ec 08 sub $0x8,%esp print_stackframe(); -c0100d4d: e8 9a fd ff ff call c0100aec +c0100c37: e8 ab fd ff ff call c01009e7 return 0; -c0100d52: b8 00 00 00 00 mov $0x0,%eax +c0100c3c: b8 00 00 00 00 mov $0x0,%eax } -c0100d57: c9 leave -c0100d58: c3 ret +c0100c41: 89 ec mov %ebp,%esp +c0100c43: 5d pop %ebp +c0100c44: c3 ret -c0100d59 : - unsigned int size; // Size in Sectors - unsigned char model[41]; // Model in String -} ide_devices[MAX_IDE]; +c0100c45 <__panic>: +/* * + * __panic - __panic is called on unresolvable fatal errors. it prints + * "panic: 'message'", and then enters the kernel monitor. + * */ +void +__panic(const char *file, int line, const char *fmt, ...) { +c0100c45: 55 push %ebp +c0100c46: 89 e5 mov %esp,%ebp +c0100c48: 83 ec 28 sub $0x28,%esp + if (is_panic) { +c0100c4b: a1 20 b4 12 c0 mov 0xc012b420,%eax +c0100c50: 85 c0 test %eax,%eax +c0100c52: 75 5b jne c0100caf <__panic+0x6a> + goto panic_dead; + } + is_panic = 1; +c0100c54: c7 05 20 b4 12 c0 01 movl $0x1,0xc012b420 +c0100c5b: 00 00 00 -static int -ide_wait_ready(unsigned short iobase, bool check_error) { -c0100d59: f3 0f 1e fb endbr32 -c0100d5d: 55 push %ebp -c0100d5e: 89 e5 mov %esp,%ebp -c0100d60: 83 ec 14 sub $0x14,%esp -c0100d63: 8b 45 08 mov 0x8(%ebp),%eax -c0100d66: 66 89 45 ec mov %ax,-0x14(%ebp) - int r; - while ((r = inb(iobase + ISA_STATUS)) & IDE_BSY) -c0100d6a: 90 nop -c0100d6b: 8b 45 ec mov -0x14(%ebp),%eax -c0100d6e: 83 c0 07 add $0x7,%eax -c0100d71: 0f b7 c0 movzwl %ax,%eax -c0100d74: 66 89 45 fa mov %ax,-0x6(%ebp) -static inline void invlpg(void *addr) __attribute__((always_inline)); - -static inline uint8_t -inb(uint16_t port) { - uint8_t data; - asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); -c0100d78: 0f b7 45 fa movzwl -0x6(%ebp),%eax -c0100d7c: 89 c2 mov %eax,%edx -c0100d7e: ec in (%dx),%al -c0100d7f: 88 45 f9 mov %al,-0x7(%ebp) - return data; -c0100d82: 0f b6 45 f9 movzbl -0x7(%ebp),%eax -c0100d86: 0f b6 c0 movzbl %al,%eax -c0100d89: 89 45 fc mov %eax,-0x4(%ebp) -c0100d8c: 8b 45 fc mov -0x4(%ebp),%eax -c0100d8f: 25 80 00 00 00 and $0x80,%eax -c0100d94: 85 c0 test %eax,%eax -c0100d96: 75 d3 jne c0100d6b - /* nothing */; - if (check_error && (r & (IDE_DF | IDE_ERR)) != 0) { -c0100d98: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) -c0100d9c: 74 11 je c0100daf -c0100d9e: 8b 45 fc mov -0x4(%ebp),%eax -c0100da1: 83 e0 21 and $0x21,%eax -c0100da4: 85 c0 test %eax,%eax -c0100da6: 74 07 je c0100daf - return -1; -c0100da8: b8 ff ff ff ff mov $0xffffffff,%eax -c0100dad: eb 05 jmp c0100db4 + // print the 'message' + va_list ap; + va_start(ap, fmt); +c0100c5e: 8d 45 14 lea 0x14(%ebp),%eax +c0100c61: 89 45 f4 mov %eax,-0xc(%ebp) + cprintf("kernel panic at %s:%d:\n ", file, line); +c0100c64: 8b 45 0c mov 0xc(%ebp),%eax +c0100c67: 89 44 24 08 mov %eax,0x8(%esp) +c0100c6b: 8b 45 08 mov 0x8(%ebp),%eax +c0100c6e: 89 44 24 04 mov %eax,0x4(%esp) +c0100c72: c7 04 24 1e a3 10 c0 movl $0xc010a31e,(%esp) +c0100c79: e8 fa f6 ff ff call c0100378 + vcprintf(fmt, ap); +c0100c7e: 8b 45 f4 mov -0xc(%ebp),%eax +c0100c81: 89 44 24 04 mov %eax,0x4(%esp) +c0100c85: 8b 45 10 mov 0x10(%ebp),%eax +c0100c88: 89 04 24 mov %eax,(%esp) +c0100c8b: e8 b3 f6 ff ff call c0100343 + cprintf("\n"); +c0100c90: c7 04 24 3a a3 10 c0 movl $0xc010a33a,(%esp) +c0100c97: e8 dc f6 ff ff call c0100378 + + cprintf("stack trackback:\n"); +c0100c9c: c7 04 24 3c a3 10 c0 movl $0xc010a33c,(%esp) +c0100ca3: e8 d0 f6 ff ff call c0100378 + print_stackframe(); +c0100ca8: e8 3a fd ff ff call c01009e7 +c0100cad: eb 01 jmp c0100cb0 <__panic+0x6b> + goto panic_dead; +c0100caf: 90 nop + + va_end(ap); + +panic_dead: + intr_disable(); +c0100cb0: e8 46 12 00 00 call c0101efb + while (1) { + kmonitor(NULL); +c0100cb5: c7 04 24 00 00 00 00 movl $0x0,(%esp) +c0100cbc: e8 9d fe ff ff call c0100b5e +c0100cc1: eb f2 jmp c0100cb5 <__panic+0x70> + +c0100cc3 <__warn>: } - return 0; -c0100daf: b8 00 00 00 00 mov $0x0,%eax } -c0100db4: c9 leave -c0100db5: c3 ret - -c0100db6 : +/* __warn - like panic, but don't */ void -ide_init(void) { -c0100db6: f3 0f 1e fb endbr32 -c0100dba: 55 push %ebp -c0100dbb: 89 e5 mov %esp,%ebp -c0100dbd: 57 push %edi -c0100dbe: 53 push %ebx -c0100dbf: 81 ec 50 02 00 00 sub $0x250,%esp - static_assert((SECTSIZE % 4) == 0); - unsigned short ideno, iobase; - for (ideno = 0; ideno < MAX_IDE; ideno ++) { -c0100dc5: 66 c7 45 f6 00 00 movw $0x0,-0xa(%ebp) -c0100dcb: e9 bd 02 00 00 jmp c010108d - /* assume that no device here */ - ide_devices[ideno].valid = 0; -c0100dd0: 0f b7 55 f6 movzwl -0xa(%ebp),%edx -c0100dd4: 89 d0 mov %edx,%eax -c0100dd6: c1 e0 03 shl $0x3,%eax -c0100dd9: 29 d0 sub %edx,%eax -c0100ddb: c1 e0 03 shl $0x3,%eax -c0100dde: 05 40 b4 12 c0 add $0xc012b440,%eax -c0100de3: c6 00 00 movb $0x0,(%eax) +__warn(const char *file, int line, const char *fmt, ...) { +c0100cc3: 55 push %ebp +c0100cc4: 89 e5 mov %esp,%ebp +c0100cc6: 83 ec 28 sub $0x28,%esp + va_list ap; + va_start(ap, fmt); +c0100cc9: 8d 45 14 lea 0x14(%ebp),%eax +c0100ccc: 89 45 f4 mov %eax,-0xc(%ebp) + cprintf("kernel warning at %s:%d:\n ", file, line); +c0100ccf: 8b 45 0c mov 0xc(%ebp),%eax +c0100cd2: 89 44 24 08 mov %eax,0x8(%esp) +c0100cd6: 8b 45 08 mov 0x8(%ebp),%eax +c0100cd9: 89 44 24 04 mov %eax,0x4(%esp) +c0100cdd: c7 04 24 4e a3 10 c0 movl $0xc010a34e,(%esp) +c0100ce4: e8 8f f6 ff ff call c0100378 + vcprintf(fmt, ap); +c0100ce9: 8b 45 f4 mov -0xc(%ebp),%eax +c0100cec: 89 44 24 04 mov %eax,0x4(%esp) +c0100cf0: 8b 45 10 mov 0x10(%ebp),%eax +c0100cf3: 89 04 24 mov %eax,(%esp) +c0100cf6: e8 48 f6 ff ff call c0100343 + cprintf("\n"); +c0100cfb: c7 04 24 3a a3 10 c0 movl $0xc010a33a,(%esp) +c0100d02: e8 71 f6 ff ff call c0100378 + va_end(ap); +} +c0100d07: 90 nop +c0100d08: 89 ec mov %ebp,%esp +c0100d0a: 5d pop %ebp +c0100d0b: c3 ret - iobase = IO_BASE(ideno); -c0100de6: 0f b7 45 f6 movzwl -0xa(%ebp),%eax -c0100dea: d1 e8 shr %eax -c0100dec: 0f b7 c0 movzwl %ax,%eax -c0100def: 8b 04 85 8c a5 10 c0 mov -0x3fef5a74(,%eax,4),%eax -c0100df6: 66 89 45 ea mov %ax,-0x16(%ebp) +c0100d0c : - /* wait device ready */ - ide_wait_ready(iobase, 0); -c0100dfa: 0f b7 45 ea movzwl -0x16(%ebp),%eax -c0100dfe: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0100e05: 00 -c0100e06: 89 04 24 mov %eax,(%esp) -c0100e09: e8 4b ff ff ff call c0100d59 +bool +is_kernel_panic(void) { +c0100d0c: 55 push %ebp +c0100d0d: 89 e5 mov %esp,%ebp + return is_panic; +c0100d0f: a1 20 b4 12 c0 mov 0xc012b420,%eax +} +c0100d14: 5d pop %ebp +c0100d15: c3 ret - /* step1: select drive */ - outb(iobase + ISA_SDH, 0xE0 | ((ideno & 1) << 4)); -c0100e0e: 0f b7 45 f6 movzwl -0xa(%ebp),%eax -c0100e12: c1 e0 04 shl $0x4,%eax -c0100e15: 24 10 and $0x10,%al -c0100e17: 0c e0 or $0xe0,%al -c0100e19: 0f b6 c0 movzbl %al,%eax -c0100e1c: 0f b7 55 ea movzwl -0x16(%ebp),%edx -c0100e20: 83 c2 06 add $0x6,%edx -c0100e23: 0f b7 d2 movzwl %dx,%edx -c0100e26: 66 89 55 ca mov %dx,-0x36(%ebp) -c0100e2a: 88 45 c9 mov %al,-0x37(%ebp) +c0100d16 : +/* * + * clock_init - initialize 8253 clock to interrupt 100 times per second, + * and then enable IRQ_TIMER. + * */ +void +clock_init(void) { +c0100d16: 55 push %ebp +c0100d17: 89 e5 mov %esp,%ebp +c0100d19: 83 ec 28 sub $0x28,%esp +c0100d1c: 66 c7 45 ee 43 00 movw $0x43,-0x12(%ebp) +c0100d22: c6 45 ed 34 movb $0x34,-0x13(%ebp) : "memory", "cc"); } static inline void outb(uint16_t port, uint8_t data) { asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0100e2d: 0f b6 45 c9 movzbl -0x37(%ebp),%eax -c0100e31: 0f b7 55 ca movzwl -0x36(%ebp),%edx -c0100e35: ee out %al,(%dx) +c0100d26: 0f b6 45 ed movzbl -0x13(%ebp),%eax +c0100d2a: 0f b7 55 ee movzwl -0x12(%ebp),%edx +c0100d2e: ee out %al,(%dx) } -c0100e36: 90 nop - ide_wait_ready(iobase, 0); -c0100e37: 0f b7 45 ea movzwl -0x16(%ebp),%eax -c0100e3b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0100e42: 00 -c0100e43: 89 04 24 mov %eax,(%esp) -c0100e46: e8 0e ff ff ff call c0100d59 - - /* step2: send ATA identify command */ - outb(iobase + ISA_COMMAND, IDE_CMD_IDENTIFY); -c0100e4b: 0f b7 45 ea movzwl -0x16(%ebp),%eax -c0100e4f: 83 c0 07 add $0x7,%eax -c0100e52: 0f b7 c0 movzwl %ax,%eax -c0100e55: 66 89 45 ce mov %ax,-0x32(%ebp) -c0100e59: c6 45 cd ec movb $0xec,-0x33(%ebp) +c0100d2f: 90 nop +c0100d30: 66 c7 45 f2 40 00 movw $0x40,-0xe(%ebp) +c0100d36: c6 45 f1 9c movb $0x9c,-0xf(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0100e5d: 0f b6 45 cd movzbl -0x33(%ebp),%eax -c0100e61: 0f b7 55 ce movzwl -0x32(%ebp),%edx -c0100e65: ee out %al,(%dx) +c0100d3a: 0f b6 45 f1 movzbl -0xf(%ebp),%eax +c0100d3e: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c0100d42: ee out %al,(%dx) } -c0100e66: 90 nop - ide_wait_ready(iobase, 0); -c0100e67: 0f b7 45 ea movzwl -0x16(%ebp),%eax -c0100e6b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0100e72: 00 -c0100e73: 89 04 24 mov %eax,(%esp) -c0100e76: e8 de fe ff ff call c0100d59 +c0100d43: 90 nop +c0100d44: 66 c7 45 f6 40 00 movw $0x40,-0xa(%ebp) +c0100d4a: c6 45 f5 2e movb $0x2e,-0xb(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0100d4e: 0f b6 45 f5 movzbl -0xb(%ebp),%eax +c0100d52: 0f b7 55 f6 movzwl -0xa(%ebp),%edx +c0100d56: ee out %al,(%dx) +} +c0100d57: 90 nop + outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); + outb(IO_TIMER1, TIMER_DIV(100) % 256); + outb(IO_TIMER1, TIMER_DIV(100) / 256); - /* step3: polling */ - if (inb(iobase + ISA_STATUS) == 0 || ide_wait_ready(iobase, 1) != 0) { -c0100e7b: 0f b7 45 ea movzwl -0x16(%ebp),%eax -c0100e7f: 83 c0 07 add $0x7,%eax -c0100e82: 0f b7 c0 movzwl %ax,%eax -c0100e85: 66 89 45 d2 mov %ax,-0x2e(%ebp) - asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); -c0100e89: 0f b7 45 d2 movzwl -0x2e(%ebp),%eax -c0100e8d: 89 c2 mov %eax,%edx -c0100e8f: ec in (%dx),%al -c0100e90: 88 45 d1 mov %al,-0x2f(%ebp) - return data; -c0100e93: 0f b6 45 d1 movzbl -0x2f(%ebp),%eax -c0100e97: 84 c0 test %al,%al -c0100e99: 0f 84 e4 01 00 00 je c0101083 -c0100e9f: 0f b7 45 ea movzwl -0x16(%ebp),%eax -c0100ea3: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0100eaa: 00 -c0100eab: 89 04 24 mov %eax,(%esp) -c0100eae: e8 a6 fe ff ff call c0100d59 -c0100eb3: 85 c0 test %eax,%eax -c0100eb5: 0f 85 c8 01 00 00 jne c0101083 - continue ; - } + // initialize time counter 'ticks' to zero + ticks = 0; +c0100d58: c7 05 24 b4 12 c0 00 movl $0x0,0xc012b424 +c0100d5f: 00 00 00 - /* device is ok */ - ide_devices[ideno].valid = 1; -c0100ebb: 0f b7 55 f6 movzwl -0xa(%ebp),%edx -c0100ebf: 89 d0 mov %edx,%eax -c0100ec1: c1 e0 03 shl $0x3,%eax -c0100ec4: 29 d0 sub %edx,%eax -c0100ec6: c1 e0 03 shl $0x3,%eax -c0100ec9: 05 40 b4 12 c0 add $0xc012b440,%eax -c0100ece: c6 00 01 movb $0x1,(%eax) + cprintf("++ setup timer interrupts\n"); +c0100d62: c7 04 24 6c a3 10 c0 movl $0xc010a36c,(%esp) +c0100d69: e8 0a f6 ff ff call c0100378 + pic_enable(IRQ_TIMER); +c0100d6e: c7 04 24 00 00 00 00 movl $0x0,(%esp) +c0100d75: e8 e6 11 00 00 call c0101f60 +} +c0100d7a: 90 nop +c0100d7b: 89 ec mov %ebp,%esp +c0100d7d: 5d pop %ebp +c0100d7e: c3 ret - /* read identification space of the device */ - unsigned int buffer[128]; - insl(iobase + ISA_DATA, buffer, sizeof(buffer) / sizeof(unsigned int)); -c0100ed1: 0f b7 45 ea movzwl -0x16(%ebp),%eax -c0100ed5: 89 45 c4 mov %eax,-0x3c(%ebp) -c0100ed8: 8d 85 bc fd ff ff lea -0x244(%ebp),%eax -c0100ede: 89 45 c0 mov %eax,-0x40(%ebp) -c0100ee1: c7 45 bc 80 00 00 00 movl $0x80,-0x44(%ebp) - asm volatile ( -c0100ee8: 8b 55 c4 mov -0x3c(%ebp),%edx -c0100eeb: 8b 4d c0 mov -0x40(%ebp),%ecx -c0100eee: 8b 45 bc mov -0x44(%ebp),%eax -c0100ef1: 89 cb mov %ecx,%ebx -c0100ef3: 89 df mov %ebx,%edi -c0100ef5: 89 c1 mov %eax,%ecx -c0100ef7: fc cld -c0100ef8: f2 6d repnz insl (%dx),%es:(%edi) -c0100efa: 89 c8 mov %ecx,%eax -c0100efc: 89 fb mov %edi,%ebx -c0100efe: 89 5d c0 mov %ebx,-0x40(%ebp) -c0100f01: 89 45 bc mov %eax,-0x44(%ebp) -} -c0100f04: 90 nop +c0100d7f <__intr_save>: +#include +#include +#include - unsigned char *ident = (unsigned char *)buffer; -c0100f05: 8d 85 bc fd ff ff lea -0x244(%ebp),%eax -c0100f0b: 89 45 e4 mov %eax,-0x1c(%ebp) - unsigned int sectors; - unsigned int cmdsets = *(unsigned int *)(ident + IDE_IDENT_CMDSETS); -c0100f0e: 8b 45 e4 mov -0x1c(%ebp),%eax -c0100f11: 8b 80 a4 00 00 00 mov 0xa4(%eax),%eax -c0100f17: 89 45 e0 mov %eax,-0x20(%ebp) - /* device use 48-bits or 28-bits addressing */ - if (cmdsets & (1 << 26)) { -c0100f1a: 8b 45 e0 mov -0x20(%ebp),%eax -c0100f1d: 25 00 00 00 04 and $0x4000000,%eax -c0100f22: 85 c0 test %eax,%eax -c0100f24: 74 0e je c0100f34 - sectors = *(unsigned int *)(ident + IDE_IDENT_MAX_LBA_EXT); -c0100f26: 8b 45 e4 mov -0x1c(%ebp),%eax -c0100f29: 8b 80 c8 00 00 00 mov 0xc8(%eax),%eax -c0100f2f: 89 45 f0 mov %eax,-0x10(%ebp) -c0100f32: eb 09 jmp c0100f3d - } - else { - sectors = *(unsigned int *)(ident + IDE_IDENT_MAX_LBA); -c0100f34: 8b 45 e4 mov -0x1c(%ebp),%eax -c0100f37: 8b 40 78 mov 0x78(%eax),%eax -c0100f3a: 89 45 f0 mov %eax,-0x10(%ebp) - } - ide_devices[ideno].sets = cmdsets; -c0100f3d: 0f b7 55 f6 movzwl -0xa(%ebp),%edx -c0100f41: 89 d0 mov %edx,%eax -c0100f43: c1 e0 03 shl $0x3,%eax -c0100f46: 29 d0 sub %edx,%eax -c0100f48: c1 e0 03 shl $0x3,%eax -c0100f4b: 8d 90 44 b4 12 c0 lea -0x3fed4bbc(%eax),%edx -c0100f51: 8b 45 e0 mov -0x20(%ebp),%eax -c0100f54: 89 02 mov %eax,(%edx) - ide_devices[ideno].size = sectors; -c0100f56: 0f b7 55 f6 movzwl -0xa(%ebp),%edx -c0100f5a: 89 d0 mov %edx,%eax -c0100f5c: c1 e0 03 shl $0x3,%eax -c0100f5f: 29 d0 sub %edx,%eax -c0100f61: c1 e0 03 shl $0x3,%eax -c0100f64: 8d 90 48 b4 12 c0 lea -0x3fed4bb8(%eax),%edx -c0100f6a: 8b 45 f0 mov -0x10(%ebp),%eax -c0100f6d: 89 02 mov %eax,(%edx) +static inline bool +__intr_save(void) { +c0100d7f: 55 push %ebp +c0100d80: 89 e5 mov %esp,%ebp +c0100d82: 83 ec 18 sub $0x18,%esp +} - /* check if supports LBA */ - assert((*(unsigned short *)(ident + IDE_IDENT_CAPABILITIES) & 0x200) != 0); -c0100f6f: 8b 45 e4 mov -0x1c(%ebp),%eax -c0100f72: 83 c0 62 add $0x62,%eax -c0100f75: 0f b7 00 movzwl (%eax),%eax -c0100f78: 25 00 02 00 00 and $0x200,%eax -c0100f7d: 85 c0 test %eax,%eax -c0100f7f: 75 24 jne c0100fa5 -c0100f81: c7 44 24 0c 94 a5 10 movl $0xc010a594,0xc(%esp) -c0100f88: c0 -c0100f89: c7 44 24 08 d7 a5 10 movl $0xc010a5d7,0x8(%esp) -c0100f90: c0 -c0100f91: c7 44 24 04 7d 00 00 movl $0x7d,0x4(%esp) -c0100f98: 00 -c0100f99: c7 04 24 ec a5 10 c0 movl $0xc010a5ec,(%esp) -c0100fa0: e8 9e f4 ff ff call c0100443 <__panic> +static inline uint32_t +read_eflags(void) { + uint32_t eflags; + asm volatile ("pushfl; popl %0" : "=r" (eflags)); +c0100d85: 9c pushf +c0100d86: 58 pop %eax +c0100d87: 89 45 f4 mov %eax,-0xc(%ebp) + return eflags; +c0100d8a: 8b 45 f4 mov -0xc(%ebp),%eax + if (read_eflags() & FL_IF) { +c0100d8d: 25 00 02 00 00 and $0x200,%eax +c0100d92: 85 c0 test %eax,%eax +c0100d94: 74 0c je c0100da2 <__intr_save+0x23> + intr_disable(); +c0100d96: e8 60 11 00 00 call c0101efb + return 1; +c0100d9b: b8 01 00 00 00 mov $0x1,%eax +c0100da0: eb 05 jmp c0100da7 <__intr_save+0x28> + } + return 0; +c0100da2: b8 00 00 00 00 mov $0x0,%eax +} +c0100da7: 89 ec mov %ebp,%esp +c0100da9: 5d pop %ebp +c0100daa: c3 ret - unsigned char *model = ide_devices[ideno].model, *data = ident + IDE_IDENT_MODEL; -c0100fa5: 0f b7 55 f6 movzwl -0xa(%ebp),%edx -c0100fa9: 89 d0 mov %edx,%eax -c0100fab: c1 e0 03 shl $0x3,%eax -c0100fae: 29 d0 sub %edx,%eax -c0100fb0: c1 e0 03 shl $0x3,%eax -c0100fb3: 05 40 b4 12 c0 add $0xc012b440,%eax -c0100fb8: 83 c0 0c add $0xc,%eax -c0100fbb: 89 45 dc mov %eax,-0x24(%ebp) -c0100fbe: 8b 45 e4 mov -0x1c(%ebp),%eax -c0100fc1: 83 c0 36 add $0x36,%eax -c0100fc4: 89 45 d8 mov %eax,-0x28(%ebp) - unsigned int i, length = 40; -c0100fc7: c7 45 d4 28 00 00 00 movl $0x28,-0x2c(%ebp) - for (i = 0; i < length; i += 2) { -c0100fce: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) -c0100fd5: eb 34 jmp c010100b - model[i] = data[i + 1], model[i + 1] = data[i]; -c0100fd7: 8b 45 ec mov -0x14(%ebp),%eax -c0100fda: 8d 50 01 lea 0x1(%eax),%edx -c0100fdd: 8b 45 d8 mov -0x28(%ebp),%eax -c0100fe0: 01 c2 add %eax,%edx -c0100fe2: 8b 4d dc mov -0x24(%ebp),%ecx -c0100fe5: 8b 45 ec mov -0x14(%ebp),%eax -c0100fe8: 01 c8 add %ecx,%eax -c0100fea: 0f b6 12 movzbl (%edx),%edx -c0100fed: 88 10 mov %dl,(%eax) -c0100fef: 8b 55 d8 mov -0x28(%ebp),%edx -c0100ff2: 8b 45 ec mov -0x14(%ebp),%eax -c0100ff5: 01 c2 add %eax,%edx -c0100ff7: 8b 45 ec mov -0x14(%ebp),%eax -c0100ffa: 8d 48 01 lea 0x1(%eax),%ecx -c0100ffd: 8b 45 dc mov -0x24(%ebp),%eax -c0101000: 01 c8 add %ecx,%eax -c0101002: 0f b6 12 movzbl (%edx),%edx -c0101005: 88 10 mov %dl,(%eax) - for (i = 0; i < length; i += 2) { -c0101007: 83 45 ec 02 addl $0x2,-0x14(%ebp) -c010100b: 8b 45 ec mov -0x14(%ebp),%eax -c010100e: 3b 45 d4 cmp -0x2c(%ebp),%eax -c0101011: 72 c4 jb c0100fd7 - } - do { - model[i] = '\0'; -c0101013: 8b 55 dc mov -0x24(%ebp),%edx -c0101016: 8b 45 ec mov -0x14(%ebp),%eax -c0101019: 01 d0 add %edx,%eax -c010101b: c6 00 00 movb $0x0,(%eax) - } while (i -- > 0 && model[i] == ' '); -c010101e: 8b 45 ec mov -0x14(%ebp),%eax -c0101021: 8d 50 ff lea -0x1(%eax),%edx -c0101024: 89 55 ec mov %edx,-0x14(%ebp) -c0101027: 85 c0 test %eax,%eax -c0101029: 74 0f je c010103a -c010102b: 8b 55 dc mov -0x24(%ebp),%edx -c010102e: 8b 45 ec mov -0x14(%ebp),%eax -c0101031: 01 d0 add %edx,%eax -c0101033: 0f b6 00 movzbl (%eax),%eax -c0101036: 3c 20 cmp $0x20,%al -c0101038: 74 d9 je c0101013 - - cprintf("ide %d: %10u(sectors), '%s'.\n", ideno, ide_devices[ideno].size, ide_devices[ideno].model); -c010103a: 0f b7 55 f6 movzwl -0xa(%ebp),%edx -c010103e: 89 d0 mov %edx,%eax -c0101040: c1 e0 03 shl $0x3,%eax -c0101043: 29 d0 sub %edx,%eax -c0101045: c1 e0 03 shl $0x3,%eax -c0101048: 05 40 b4 12 c0 add $0xc012b440,%eax -c010104d: 8d 48 0c lea 0xc(%eax),%ecx -c0101050: 0f b7 55 f6 movzwl -0xa(%ebp),%edx -c0101054: 89 d0 mov %edx,%eax -c0101056: c1 e0 03 shl $0x3,%eax -c0101059: 29 d0 sub %edx,%eax -c010105b: c1 e0 03 shl $0x3,%eax -c010105e: 05 48 b4 12 c0 add $0xc012b448,%eax -c0101063: 8b 10 mov (%eax),%edx -c0101065: 0f b7 45 f6 movzwl -0xa(%ebp),%eax -c0101069: 89 4c 24 0c mov %ecx,0xc(%esp) -c010106d: 89 54 24 08 mov %edx,0x8(%esp) -c0101071: 89 44 24 04 mov %eax,0x4(%esp) -c0101075: c7 04 24 fe a5 10 c0 movl $0xc010a5fe,(%esp) -c010107c: e8 56 f2 ff ff call c01002d7 -c0101081: eb 01 jmp c0101084 - continue ; -c0101083: 90 nop - for (ideno = 0; ideno < MAX_IDE; ideno ++) { -c0101084: 0f b7 45 f6 movzwl -0xa(%ebp),%eax -c0101088: 40 inc %eax -c0101089: 66 89 45 f6 mov %ax,-0xa(%ebp) -c010108d: 0f b7 45 f6 movzwl -0xa(%ebp),%eax -c0101091: 83 f8 03 cmp $0x3,%eax -c0101094: 0f 86 36 fd ff ff jbe c0100dd0 - } - - // enable ide interrupt - pic_enable(IRQ_IDE1); -c010109a: c7 04 24 0e 00 00 00 movl $0xe,(%esp) -c01010a1: e8 1f 0f 00 00 call c0101fc5 - pic_enable(IRQ_IDE2); -c01010a6: c7 04 24 0f 00 00 00 movl $0xf,(%esp) -c01010ad: e8 13 0f 00 00 call c0101fc5 -} -c01010b2: 90 nop -c01010b3: 81 c4 50 02 00 00 add $0x250,%esp -c01010b9: 5b pop %ebx -c01010ba: 5f pop %edi -c01010bb: 5d pop %ebp -c01010bc: c3 ret - -c01010bd : - -bool -ide_device_valid(unsigned short ideno) { -c01010bd: f3 0f 1e fb endbr32 -c01010c1: 55 push %ebp -c01010c2: 89 e5 mov %esp,%ebp -c01010c4: 83 ec 04 sub $0x4,%esp -c01010c7: 8b 45 08 mov 0x8(%ebp),%eax -c01010ca: 66 89 45 fc mov %ax,-0x4(%ebp) - return VALID_IDE(ideno); -c01010ce: 0f b7 45 fc movzwl -0x4(%ebp),%eax -c01010d2: 83 f8 03 cmp $0x3,%eax -c01010d5: 77 21 ja c01010f8 -c01010d7: 0f b7 55 fc movzwl -0x4(%ebp),%edx -c01010db: 89 d0 mov %edx,%eax -c01010dd: c1 e0 03 shl $0x3,%eax -c01010e0: 29 d0 sub %edx,%eax -c01010e2: c1 e0 03 shl $0x3,%eax -c01010e5: 05 40 b4 12 c0 add $0xc012b440,%eax -c01010ea: 0f b6 00 movzbl (%eax),%eax -c01010ed: 84 c0 test %al,%al -c01010ef: 74 07 je c01010f8 -c01010f1: b8 01 00 00 00 mov $0x1,%eax -c01010f6: eb 05 jmp c01010fd -c01010f8: b8 00 00 00 00 mov $0x0,%eax -} -c01010fd: c9 leave -c01010fe: c3 ret - -c01010ff : - -size_t -ide_device_size(unsigned short ideno) { -c01010ff: f3 0f 1e fb endbr32 -c0101103: 55 push %ebp -c0101104: 89 e5 mov %esp,%ebp -c0101106: 83 ec 08 sub $0x8,%esp -c0101109: 8b 45 08 mov 0x8(%ebp),%eax -c010110c: 66 89 45 fc mov %ax,-0x4(%ebp) - if (ide_device_valid(ideno)) { -c0101110: 0f b7 45 fc movzwl -0x4(%ebp),%eax -c0101114: 89 04 24 mov %eax,(%esp) -c0101117: e8 a1 ff ff ff call c01010bd -c010111c: 85 c0 test %eax,%eax -c010111e: 74 17 je c0101137 - return ide_devices[ideno].size; -c0101120: 0f b7 55 fc movzwl -0x4(%ebp),%edx -c0101124: 89 d0 mov %edx,%eax -c0101126: c1 e0 03 shl $0x3,%eax -c0101129: 29 d0 sub %edx,%eax -c010112b: c1 e0 03 shl $0x3,%eax -c010112e: 05 48 b4 12 c0 add $0xc012b448,%eax -c0101133: 8b 00 mov (%eax),%eax -c0101135: eb 05 jmp c010113c - } - return 0; -c0101137: b8 00 00 00 00 mov $0x0,%eax -} -c010113c: c9 leave -c010113d: c3 ret - -c010113e : - -int -ide_read_secs(unsigned short ideno, uint32_t secno, void *dst, size_t nsecs) { -c010113e: f3 0f 1e fb endbr32 -c0101142: 55 push %ebp -c0101143: 89 e5 mov %esp,%ebp -c0101145: 57 push %edi -c0101146: 53 push %ebx -c0101147: 83 ec 50 sub $0x50,%esp -c010114a: 8b 45 08 mov 0x8(%ebp),%eax -c010114d: 66 89 45 c4 mov %ax,-0x3c(%ebp) - assert(nsecs <= MAX_NSECS && VALID_IDE(ideno)); -c0101151: 81 7d 14 80 00 00 00 cmpl $0x80,0x14(%ebp) -c0101158: 77 23 ja c010117d -c010115a: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax -c010115e: 83 f8 03 cmp $0x3,%eax -c0101161: 77 1a ja c010117d -c0101163: 0f b7 55 c4 movzwl -0x3c(%ebp),%edx -c0101167: 89 d0 mov %edx,%eax -c0101169: c1 e0 03 shl $0x3,%eax -c010116c: 29 d0 sub %edx,%eax -c010116e: c1 e0 03 shl $0x3,%eax -c0101171: 05 40 b4 12 c0 add $0xc012b440,%eax -c0101176: 0f b6 00 movzbl (%eax),%eax -c0101179: 84 c0 test %al,%al -c010117b: 75 24 jne c01011a1 -c010117d: c7 44 24 0c 1c a6 10 movl $0xc010a61c,0xc(%esp) -c0101184: c0 -c0101185: c7 44 24 08 d7 a5 10 movl $0xc010a5d7,0x8(%esp) -c010118c: c0 -c010118d: c7 44 24 04 9f 00 00 movl $0x9f,0x4(%esp) -c0101194: 00 -c0101195: c7 04 24 ec a5 10 c0 movl $0xc010a5ec,(%esp) -c010119c: e8 a2 f2 ff ff call c0100443 <__panic> - assert(secno < MAX_DISK_NSECS && secno + nsecs <= MAX_DISK_NSECS); -c01011a1: 81 7d 0c ff ff ff 0f cmpl $0xfffffff,0xc(%ebp) -c01011a8: 77 0f ja c01011b9 -c01011aa: 8b 55 0c mov 0xc(%ebp),%edx -c01011ad: 8b 45 14 mov 0x14(%ebp),%eax -c01011b0: 01 d0 add %edx,%eax -c01011b2: 3d 00 00 00 10 cmp $0x10000000,%eax -c01011b7: 76 24 jbe c01011dd -c01011b9: c7 44 24 0c 44 a6 10 movl $0xc010a644,0xc(%esp) -c01011c0: c0 -c01011c1: c7 44 24 08 d7 a5 10 movl $0xc010a5d7,0x8(%esp) -c01011c8: c0 -c01011c9: c7 44 24 04 a0 00 00 movl $0xa0,0x4(%esp) -c01011d0: 00 -c01011d1: c7 04 24 ec a5 10 c0 movl $0xc010a5ec,(%esp) -c01011d8: e8 66 f2 ff ff call c0100443 <__panic> - unsigned short iobase = IO_BASE(ideno), ioctrl = IO_CTRL(ideno); -c01011dd: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax -c01011e1: d1 e8 shr %eax -c01011e3: 0f b7 c0 movzwl %ax,%eax -c01011e6: 8b 04 85 8c a5 10 c0 mov -0x3fef5a74(,%eax,4),%eax -c01011ed: 66 89 45 f2 mov %ax,-0xe(%ebp) -c01011f1: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax -c01011f5: d1 e8 shr %eax -c01011f7: 0f b7 c0 movzwl %ax,%eax -c01011fa: 0f b7 04 85 8e a5 10 movzwl -0x3fef5a72(,%eax,4),%eax -c0101201: c0 -c0101202: 66 89 45 f0 mov %ax,-0x10(%ebp) - - ide_wait_ready(iobase, 0); -c0101206: 0f b7 45 f2 movzwl -0xe(%ebp),%eax -c010120a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0101211: 00 -c0101212: 89 04 24 mov %eax,(%esp) -c0101215: e8 3f fb ff ff call c0100d59 - - // generate interrupt - outb(ioctrl + ISA_CTRL, 0); -c010121a: 8b 45 f0 mov -0x10(%ebp),%eax -c010121d: 83 c0 02 add $0x2,%eax -c0101220: 0f b7 c0 movzwl %ax,%eax -c0101223: 66 89 45 d6 mov %ax,-0x2a(%ebp) -c0101227: c6 45 d5 00 movb $0x0,-0x2b(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010122b: 0f b6 45 d5 movzbl -0x2b(%ebp),%eax -c010122f: 0f b7 55 d6 movzwl -0x2a(%ebp),%edx -c0101233: ee out %al,(%dx) -} -c0101234: 90 nop - outb(iobase + ISA_SECCNT, nsecs); -c0101235: 8b 45 14 mov 0x14(%ebp),%eax -c0101238: 0f b6 c0 movzbl %al,%eax -c010123b: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c010123f: 83 c2 02 add $0x2,%edx -c0101242: 0f b7 d2 movzwl %dx,%edx -c0101245: 66 89 55 da mov %dx,-0x26(%ebp) -c0101249: 88 45 d9 mov %al,-0x27(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010124c: 0f b6 45 d9 movzbl -0x27(%ebp),%eax -c0101250: 0f b7 55 da movzwl -0x26(%ebp),%edx -c0101254: ee out %al,(%dx) -} -c0101255: 90 nop - outb(iobase + ISA_SECTOR, secno & 0xFF); -c0101256: 8b 45 0c mov 0xc(%ebp),%eax -c0101259: 0f b6 c0 movzbl %al,%eax -c010125c: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c0101260: 83 c2 03 add $0x3,%edx -c0101263: 0f b7 d2 movzwl %dx,%edx -c0101266: 66 89 55 de mov %dx,-0x22(%ebp) -c010126a: 88 45 dd mov %al,-0x23(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010126d: 0f b6 45 dd movzbl -0x23(%ebp),%eax -c0101271: 0f b7 55 de movzwl -0x22(%ebp),%edx -c0101275: ee out %al,(%dx) -} -c0101276: 90 nop - outb(iobase + ISA_CYL_LO, (secno >> 8) & 0xFF); -c0101277: 8b 45 0c mov 0xc(%ebp),%eax -c010127a: c1 e8 08 shr $0x8,%eax -c010127d: 0f b6 c0 movzbl %al,%eax -c0101280: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c0101284: 83 c2 04 add $0x4,%edx -c0101287: 0f b7 d2 movzwl %dx,%edx -c010128a: 66 89 55 e2 mov %dx,-0x1e(%ebp) -c010128e: 88 45 e1 mov %al,-0x1f(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101291: 0f b6 45 e1 movzbl -0x1f(%ebp),%eax -c0101295: 0f b7 55 e2 movzwl -0x1e(%ebp),%edx -c0101299: ee out %al,(%dx) -} -c010129a: 90 nop - outb(iobase + ISA_CYL_HI, (secno >> 16) & 0xFF); -c010129b: 8b 45 0c mov 0xc(%ebp),%eax -c010129e: c1 e8 10 shr $0x10,%eax -c01012a1: 0f b6 c0 movzbl %al,%eax -c01012a4: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c01012a8: 83 c2 05 add $0x5,%edx -c01012ab: 0f b7 d2 movzwl %dx,%edx -c01012ae: 66 89 55 e6 mov %dx,-0x1a(%ebp) -c01012b2: 88 45 e5 mov %al,-0x1b(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01012b5: 0f b6 45 e5 movzbl -0x1b(%ebp),%eax -c01012b9: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx -c01012bd: ee out %al,(%dx) -} -c01012be: 90 nop - outb(iobase + ISA_SDH, 0xE0 | ((ideno & 1) << 4) | ((secno >> 24) & 0xF)); -c01012bf: 8b 45 c4 mov -0x3c(%ebp),%eax -c01012c2: c0 e0 04 shl $0x4,%al -c01012c5: 24 10 and $0x10,%al -c01012c7: 88 c2 mov %al,%dl -c01012c9: 8b 45 0c mov 0xc(%ebp),%eax -c01012cc: c1 e8 18 shr $0x18,%eax -c01012cf: 24 0f and $0xf,%al -c01012d1: 08 d0 or %dl,%al -c01012d3: 0c e0 or $0xe0,%al -c01012d5: 0f b6 c0 movzbl %al,%eax -c01012d8: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c01012dc: 83 c2 06 add $0x6,%edx -c01012df: 0f b7 d2 movzwl %dx,%edx -c01012e2: 66 89 55 ea mov %dx,-0x16(%ebp) -c01012e6: 88 45 e9 mov %al,-0x17(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01012e9: 0f b6 45 e9 movzbl -0x17(%ebp),%eax -c01012ed: 0f b7 55 ea movzwl -0x16(%ebp),%edx -c01012f1: ee out %al,(%dx) -} -c01012f2: 90 nop - outb(iobase + ISA_COMMAND, IDE_CMD_READ); -c01012f3: 0f b7 45 f2 movzwl -0xe(%ebp),%eax -c01012f7: 83 c0 07 add $0x7,%eax -c01012fa: 0f b7 c0 movzwl %ax,%eax -c01012fd: 66 89 45 ee mov %ax,-0x12(%ebp) -c0101301: c6 45 ed 20 movb $0x20,-0x13(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101305: 0f b6 45 ed movzbl -0x13(%ebp),%eax -c0101309: 0f b7 55 ee movzwl -0x12(%ebp),%edx -c010130d: ee out %al,(%dx) -} -c010130e: 90 nop - - int ret = 0; -c010130f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) - for (; nsecs > 0; nsecs --, dst += SECTSIZE) { -c0101316: eb 58 jmp c0101370 - if ((ret = ide_wait_ready(iobase, 1)) != 0) { -c0101318: 0f b7 45 f2 movzwl -0xe(%ebp),%eax -c010131c: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0101323: 00 -c0101324: 89 04 24 mov %eax,(%esp) -c0101327: e8 2d fa ff ff call c0100d59 -c010132c: 89 45 f4 mov %eax,-0xc(%ebp) -c010132f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0101333: 75 43 jne c0101378 - goto out; - } - insl(iobase, dst, SECTSIZE / sizeof(uint32_t)); -c0101335: 0f b7 45 f2 movzwl -0xe(%ebp),%eax -c0101339: 89 45 d0 mov %eax,-0x30(%ebp) -c010133c: 8b 45 10 mov 0x10(%ebp),%eax -c010133f: 89 45 cc mov %eax,-0x34(%ebp) -c0101342: c7 45 c8 80 00 00 00 movl $0x80,-0x38(%ebp) - asm volatile ( -c0101349: 8b 55 d0 mov -0x30(%ebp),%edx -c010134c: 8b 4d cc mov -0x34(%ebp),%ecx -c010134f: 8b 45 c8 mov -0x38(%ebp),%eax -c0101352: 89 cb mov %ecx,%ebx -c0101354: 89 df mov %ebx,%edi -c0101356: 89 c1 mov %eax,%ecx -c0101358: fc cld -c0101359: f2 6d repnz insl (%dx),%es:(%edi) -c010135b: 89 c8 mov %ecx,%eax -c010135d: 89 fb mov %edi,%ebx -c010135f: 89 5d cc mov %ebx,-0x34(%ebp) -c0101362: 89 45 c8 mov %eax,-0x38(%ebp) -} -c0101365: 90 nop - for (; nsecs > 0; nsecs --, dst += SECTSIZE) { -c0101366: ff 4d 14 decl 0x14(%ebp) -c0101369: 81 45 10 00 02 00 00 addl $0x200,0x10(%ebp) -c0101370: 83 7d 14 00 cmpl $0x0,0x14(%ebp) -c0101374: 75 a2 jne c0101318 - } - -out: -c0101376: eb 01 jmp c0101379 - goto out; -c0101378: 90 nop - return ret; -c0101379: 8b 45 f4 mov -0xc(%ebp),%eax -} -c010137c: 83 c4 50 add $0x50,%esp -c010137f: 5b pop %ebx -c0101380: 5f pop %edi -c0101381: 5d pop %ebp -c0101382: c3 ret - -c0101383 : - -int -ide_write_secs(unsigned short ideno, uint32_t secno, const void *src, size_t nsecs) { -c0101383: f3 0f 1e fb endbr32 -c0101387: 55 push %ebp -c0101388: 89 e5 mov %esp,%ebp -c010138a: 56 push %esi -c010138b: 53 push %ebx -c010138c: 83 ec 50 sub $0x50,%esp -c010138f: 8b 45 08 mov 0x8(%ebp),%eax -c0101392: 66 89 45 c4 mov %ax,-0x3c(%ebp) - assert(nsecs <= MAX_NSECS && VALID_IDE(ideno)); -c0101396: 81 7d 14 80 00 00 00 cmpl $0x80,0x14(%ebp) -c010139d: 77 23 ja c01013c2 -c010139f: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax -c01013a3: 83 f8 03 cmp $0x3,%eax -c01013a6: 77 1a ja c01013c2 -c01013a8: 0f b7 55 c4 movzwl -0x3c(%ebp),%edx -c01013ac: 89 d0 mov %edx,%eax -c01013ae: c1 e0 03 shl $0x3,%eax -c01013b1: 29 d0 sub %edx,%eax -c01013b3: c1 e0 03 shl $0x3,%eax -c01013b6: 05 40 b4 12 c0 add $0xc012b440,%eax -c01013bb: 0f b6 00 movzbl (%eax),%eax -c01013be: 84 c0 test %al,%al -c01013c0: 75 24 jne c01013e6 -c01013c2: c7 44 24 0c 1c a6 10 movl $0xc010a61c,0xc(%esp) -c01013c9: c0 -c01013ca: c7 44 24 08 d7 a5 10 movl $0xc010a5d7,0x8(%esp) -c01013d1: c0 -c01013d2: c7 44 24 04 bc 00 00 movl $0xbc,0x4(%esp) -c01013d9: 00 -c01013da: c7 04 24 ec a5 10 c0 movl $0xc010a5ec,(%esp) -c01013e1: e8 5d f0 ff ff call c0100443 <__panic> - assert(secno < MAX_DISK_NSECS && secno + nsecs <= MAX_DISK_NSECS); -c01013e6: 81 7d 0c ff ff ff 0f cmpl $0xfffffff,0xc(%ebp) -c01013ed: 77 0f ja c01013fe -c01013ef: 8b 55 0c mov 0xc(%ebp),%edx -c01013f2: 8b 45 14 mov 0x14(%ebp),%eax -c01013f5: 01 d0 add %edx,%eax -c01013f7: 3d 00 00 00 10 cmp $0x10000000,%eax -c01013fc: 76 24 jbe c0101422 -c01013fe: c7 44 24 0c 44 a6 10 movl $0xc010a644,0xc(%esp) -c0101405: c0 -c0101406: c7 44 24 08 d7 a5 10 movl $0xc010a5d7,0x8(%esp) -c010140d: c0 -c010140e: c7 44 24 04 bd 00 00 movl $0xbd,0x4(%esp) -c0101415: 00 -c0101416: c7 04 24 ec a5 10 c0 movl $0xc010a5ec,(%esp) -c010141d: e8 21 f0 ff ff call c0100443 <__panic> - unsigned short iobase = IO_BASE(ideno), ioctrl = IO_CTRL(ideno); -c0101422: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax -c0101426: d1 e8 shr %eax -c0101428: 0f b7 c0 movzwl %ax,%eax -c010142b: 8b 04 85 8c a5 10 c0 mov -0x3fef5a74(,%eax,4),%eax -c0101432: 66 89 45 f2 mov %ax,-0xe(%ebp) -c0101436: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax -c010143a: d1 e8 shr %eax -c010143c: 0f b7 c0 movzwl %ax,%eax -c010143f: 0f b7 04 85 8e a5 10 movzwl -0x3fef5a72(,%eax,4),%eax -c0101446: c0 -c0101447: 66 89 45 f0 mov %ax,-0x10(%ebp) - - ide_wait_ready(iobase, 0); -c010144b: 0f b7 45 f2 movzwl -0xe(%ebp),%eax -c010144f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0101456: 00 -c0101457: 89 04 24 mov %eax,(%esp) -c010145a: e8 fa f8 ff ff call c0100d59 - - // generate interrupt - outb(ioctrl + ISA_CTRL, 0); -c010145f: 8b 45 f0 mov -0x10(%ebp),%eax -c0101462: 83 c0 02 add $0x2,%eax -c0101465: 0f b7 c0 movzwl %ax,%eax -c0101468: 66 89 45 d6 mov %ax,-0x2a(%ebp) -c010146c: c6 45 d5 00 movb $0x0,-0x2b(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101470: 0f b6 45 d5 movzbl -0x2b(%ebp),%eax -c0101474: 0f b7 55 d6 movzwl -0x2a(%ebp),%edx -c0101478: ee out %al,(%dx) -} -c0101479: 90 nop - outb(iobase + ISA_SECCNT, nsecs); -c010147a: 8b 45 14 mov 0x14(%ebp),%eax -c010147d: 0f b6 c0 movzbl %al,%eax -c0101480: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c0101484: 83 c2 02 add $0x2,%edx -c0101487: 0f b7 d2 movzwl %dx,%edx -c010148a: 66 89 55 da mov %dx,-0x26(%ebp) -c010148e: 88 45 d9 mov %al,-0x27(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101491: 0f b6 45 d9 movzbl -0x27(%ebp),%eax -c0101495: 0f b7 55 da movzwl -0x26(%ebp),%edx -c0101499: ee out %al,(%dx) -} -c010149a: 90 nop - outb(iobase + ISA_SECTOR, secno & 0xFF); -c010149b: 8b 45 0c mov 0xc(%ebp),%eax -c010149e: 0f b6 c0 movzbl %al,%eax -c01014a1: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c01014a5: 83 c2 03 add $0x3,%edx -c01014a8: 0f b7 d2 movzwl %dx,%edx -c01014ab: 66 89 55 de mov %dx,-0x22(%ebp) -c01014af: 88 45 dd mov %al,-0x23(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01014b2: 0f b6 45 dd movzbl -0x23(%ebp),%eax -c01014b6: 0f b7 55 de movzwl -0x22(%ebp),%edx -c01014ba: ee out %al,(%dx) -} -c01014bb: 90 nop - outb(iobase + ISA_CYL_LO, (secno >> 8) & 0xFF); -c01014bc: 8b 45 0c mov 0xc(%ebp),%eax -c01014bf: c1 e8 08 shr $0x8,%eax -c01014c2: 0f b6 c0 movzbl %al,%eax -c01014c5: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c01014c9: 83 c2 04 add $0x4,%edx -c01014cc: 0f b7 d2 movzwl %dx,%edx -c01014cf: 66 89 55 e2 mov %dx,-0x1e(%ebp) -c01014d3: 88 45 e1 mov %al,-0x1f(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01014d6: 0f b6 45 e1 movzbl -0x1f(%ebp),%eax -c01014da: 0f b7 55 e2 movzwl -0x1e(%ebp),%edx -c01014de: ee out %al,(%dx) -} -c01014df: 90 nop - outb(iobase + ISA_CYL_HI, (secno >> 16) & 0xFF); -c01014e0: 8b 45 0c mov 0xc(%ebp),%eax -c01014e3: c1 e8 10 shr $0x10,%eax -c01014e6: 0f b6 c0 movzbl %al,%eax -c01014e9: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c01014ed: 83 c2 05 add $0x5,%edx -c01014f0: 0f b7 d2 movzwl %dx,%edx -c01014f3: 66 89 55 e6 mov %dx,-0x1a(%ebp) -c01014f7: 88 45 e5 mov %al,-0x1b(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01014fa: 0f b6 45 e5 movzbl -0x1b(%ebp),%eax -c01014fe: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx -c0101502: ee out %al,(%dx) -} -c0101503: 90 nop - outb(iobase + ISA_SDH, 0xE0 | ((ideno & 1) << 4) | ((secno >> 24) & 0xF)); -c0101504: 8b 45 c4 mov -0x3c(%ebp),%eax -c0101507: c0 e0 04 shl $0x4,%al -c010150a: 24 10 and $0x10,%al -c010150c: 88 c2 mov %al,%dl -c010150e: 8b 45 0c mov 0xc(%ebp),%eax -c0101511: c1 e8 18 shr $0x18,%eax -c0101514: 24 0f and $0xf,%al -c0101516: 08 d0 or %dl,%al -c0101518: 0c e0 or $0xe0,%al -c010151a: 0f b6 c0 movzbl %al,%eax -c010151d: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c0101521: 83 c2 06 add $0x6,%edx -c0101524: 0f b7 d2 movzwl %dx,%edx -c0101527: 66 89 55 ea mov %dx,-0x16(%ebp) -c010152b: 88 45 e9 mov %al,-0x17(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010152e: 0f b6 45 e9 movzbl -0x17(%ebp),%eax -c0101532: 0f b7 55 ea movzwl -0x16(%ebp),%edx -c0101536: ee out %al,(%dx) -} -c0101537: 90 nop - outb(iobase + ISA_COMMAND, IDE_CMD_WRITE); -c0101538: 0f b7 45 f2 movzwl -0xe(%ebp),%eax -c010153c: 83 c0 07 add $0x7,%eax -c010153f: 0f b7 c0 movzwl %ax,%eax -c0101542: 66 89 45 ee mov %ax,-0x12(%ebp) -c0101546: c6 45 ed 30 movb $0x30,-0x13(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010154a: 0f b6 45 ed movzbl -0x13(%ebp),%eax -c010154e: 0f b7 55 ee movzwl -0x12(%ebp),%edx -c0101552: ee out %al,(%dx) -} -c0101553: 90 nop - - int ret = 0; -c0101554: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) - for (; nsecs > 0; nsecs --, src += SECTSIZE) { -c010155b: eb 58 jmp c01015b5 - if ((ret = ide_wait_ready(iobase, 1)) != 0) { -c010155d: 0f b7 45 f2 movzwl -0xe(%ebp),%eax -c0101561: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0101568: 00 -c0101569: 89 04 24 mov %eax,(%esp) -c010156c: e8 e8 f7 ff ff call c0100d59 -c0101571: 89 45 f4 mov %eax,-0xc(%ebp) -c0101574: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0101578: 75 43 jne c01015bd - goto out; - } - outsl(iobase, src, SECTSIZE / sizeof(uint32_t)); -c010157a: 0f b7 45 f2 movzwl -0xe(%ebp),%eax -c010157e: 89 45 d0 mov %eax,-0x30(%ebp) -c0101581: 8b 45 10 mov 0x10(%ebp),%eax -c0101584: 89 45 cc mov %eax,-0x34(%ebp) -c0101587: c7 45 c8 80 00 00 00 movl $0x80,-0x38(%ebp) - asm volatile ("outw %0, %1" :: "a" (data), "d" (port) : "memory"); -} - -static inline void -outsl(uint32_t port, const void *addr, int cnt) { - asm volatile ( -c010158e: 8b 55 d0 mov -0x30(%ebp),%edx -c0101591: 8b 4d cc mov -0x34(%ebp),%ecx -c0101594: 8b 45 c8 mov -0x38(%ebp),%eax -c0101597: 89 cb mov %ecx,%ebx -c0101599: 89 de mov %ebx,%esi -c010159b: 89 c1 mov %eax,%ecx -c010159d: fc cld -c010159e: f2 6f repnz outsl %ds:(%esi),(%dx) -c01015a0: 89 c8 mov %ecx,%eax -c01015a2: 89 f3 mov %esi,%ebx -c01015a4: 89 5d cc mov %ebx,-0x34(%ebp) -c01015a7: 89 45 c8 mov %eax,-0x38(%ebp) - "cld;" - "repne; outsl;" - : "=S" (addr), "=c" (cnt) - : "d" (port), "0" (addr), "1" (cnt) - : "memory", "cc"); -} -c01015aa: 90 nop - for (; nsecs > 0; nsecs --, src += SECTSIZE) { -c01015ab: ff 4d 14 decl 0x14(%ebp) -c01015ae: 81 45 10 00 02 00 00 addl $0x200,0x10(%ebp) -c01015b5: 83 7d 14 00 cmpl $0x0,0x14(%ebp) -c01015b9: 75 a2 jne c010155d - } - -out: -c01015bb: eb 01 jmp c01015be - goto out; -c01015bd: 90 nop - return ret; -c01015be: 8b 45 f4 mov -0xc(%ebp),%eax -} -c01015c1: 83 c4 50 add $0x50,%esp -c01015c4: 5b pop %ebx -c01015c5: 5e pop %esi -c01015c6: 5d pop %ebp -c01015c7: c3 ret - -c01015c8 : -/* * - * clock_init - initialize 8253 clock to interrupt 100 times per second, - * and then enable IRQ_TIMER. - * */ -void -clock_init(void) { -c01015c8: f3 0f 1e fb endbr32 -c01015cc: 55 push %ebp -c01015cd: 89 e5 mov %esp,%ebp -c01015cf: 83 ec 28 sub $0x28,%esp -c01015d2: 66 c7 45 ee 43 00 movw $0x43,-0x12(%ebp) -c01015d8: c6 45 ed 34 movb $0x34,-0x13(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01015dc: 0f b6 45 ed movzbl -0x13(%ebp),%eax -c01015e0: 0f b7 55 ee movzwl -0x12(%ebp),%edx -c01015e4: ee out %al,(%dx) -} -c01015e5: 90 nop -c01015e6: 66 c7 45 f2 40 00 movw $0x40,-0xe(%ebp) -c01015ec: c6 45 f1 9c movb $0x9c,-0xf(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01015f0: 0f b6 45 f1 movzbl -0xf(%ebp),%eax -c01015f4: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c01015f8: ee out %al,(%dx) -} -c01015f9: 90 nop -c01015fa: 66 c7 45 f6 40 00 movw $0x40,-0xa(%ebp) -c0101600: c6 45 f5 2e movb $0x2e,-0xb(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101604: 0f b6 45 f5 movzbl -0xb(%ebp),%eax -c0101608: 0f b7 55 f6 movzwl -0xa(%ebp),%edx -c010160c: ee out %al,(%dx) -} -c010160d: 90 nop - outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); - outb(IO_TIMER1, TIMER_DIV(100) % 256); - outb(IO_TIMER1, TIMER_DIV(100) / 256); - - // initialize time counter 'ticks' to zero - ticks = 0; -c010160e: c7 05 54 e0 12 c0 00 movl $0x0,0xc012e054 -c0101615: 00 00 00 - - cprintf("++ setup timer interrupts\n"); -c0101618: c7 04 24 7e a6 10 c0 movl $0xc010a67e,(%esp) -c010161f: e8 b3 ec ff ff call c01002d7 - pic_enable(IRQ_TIMER); -c0101624: c7 04 24 00 00 00 00 movl $0x0,(%esp) -c010162b: e8 95 09 00 00 call c0101fc5 -} -c0101630: 90 nop -c0101631: c9 leave -c0101632: c3 ret - -c0101633 <__intr_save>: -#include -#include -#include - -static inline bool -__intr_save(void) { -c0101633: 55 push %ebp -c0101634: 89 e5 mov %esp,%ebp -c0101636: 83 ec 18 sub $0x18,%esp -} - -static inline uint32_t -read_eflags(void) { - uint32_t eflags; - asm volatile ("pushfl; popl %0" : "=r" (eflags)); -c0101639: 9c pushf -c010163a: 58 pop %eax -c010163b: 89 45 f4 mov %eax,-0xc(%ebp) - return eflags; -c010163e: 8b 45 f4 mov -0xc(%ebp),%eax - if (read_eflags() & FL_IF) { -c0101641: 25 00 02 00 00 and $0x200,%eax -c0101646: 85 c0 test %eax,%eax -c0101648: 74 0c je c0101656 <__intr_save+0x23> - intr_disable(); -c010164a: e8 05 0b 00 00 call c0102154 - return 1; -c010164f: b8 01 00 00 00 mov $0x1,%eax -c0101654: eb 05 jmp c010165b <__intr_save+0x28> - } - return 0; -c0101656: b8 00 00 00 00 mov $0x0,%eax -} -c010165b: c9 leave -c010165c: c3 ret - -c010165d <__intr_restore>: +c0100dab <__intr_restore>: static inline void __intr_restore(bool flag) { -c010165d: 55 push %ebp -c010165e: 89 e5 mov %esp,%ebp -c0101660: 83 ec 08 sub $0x8,%esp +c0100dab: 55 push %ebp +c0100dac: 89 e5 mov %esp,%ebp +c0100dae: 83 ec 08 sub $0x8,%esp if (flag) { -c0101663: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c0101667: 74 05 je c010166e <__intr_restore+0x11> +c0100db1: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0100db5: 74 05 je c0100dbc <__intr_restore+0x11> intr_enable(); -c0101669: e8 da 0a 00 00 call c0102148 +c0100db7: e8 37 11 00 00 call c0101ef3 } } -c010166e: 90 nop -c010166f: c9 leave -c0101670: c3 ret +c0100dbc: 90 nop +c0100dbd: 89 ec mov %ebp,%esp +c0100dbf: 5d pop %ebp +c0100dc0: c3 ret -c0101671 : +c0100dc1 : #include #include /* stupid I/O delay routine necessitated by historical PC design flaws */ static void delay(void) { -c0101671: f3 0f 1e fb endbr32 -c0101675: 55 push %ebp -c0101676: 89 e5 mov %esp,%ebp -c0101678: 83 ec 10 sub $0x10,%esp -c010167b: 66 c7 45 f2 84 00 movw $0x84,-0xe(%ebp) +c0100dc1: 55 push %ebp +c0100dc2: 89 e5 mov %esp,%ebp +c0100dc4: 83 ec 10 sub $0x10,%esp +c0100dc7: 66 c7 45 f2 84 00 movw $0x84,-0xe(%ebp) asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); -c0101681: 0f b7 45 f2 movzwl -0xe(%ebp),%eax -c0101685: 89 c2 mov %eax,%edx -c0101687: ec in (%dx),%al -c0101688: 88 45 f1 mov %al,-0xf(%ebp) -c010168b: 66 c7 45 f6 84 00 movw $0x84,-0xa(%ebp) -c0101691: 0f b7 45 f6 movzwl -0xa(%ebp),%eax -c0101695: 89 c2 mov %eax,%edx -c0101697: ec in (%dx),%al -c0101698: 88 45 f5 mov %al,-0xb(%ebp) -c010169b: 66 c7 45 fa 84 00 movw $0x84,-0x6(%ebp) -c01016a1: 0f b7 45 fa movzwl -0x6(%ebp),%eax -c01016a5: 89 c2 mov %eax,%edx -c01016a7: ec in (%dx),%al -c01016a8: 88 45 f9 mov %al,-0x7(%ebp) -c01016ab: 66 c7 45 fe 84 00 movw $0x84,-0x2(%ebp) -c01016b1: 0f b7 45 fe movzwl -0x2(%ebp),%eax -c01016b5: 89 c2 mov %eax,%edx -c01016b7: ec in (%dx),%al -c01016b8: 88 45 fd mov %al,-0x3(%ebp) +c0100dcd: 0f b7 45 f2 movzwl -0xe(%ebp),%eax +c0100dd1: 89 c2 mov %eax,%edx +c0100dd3: ec in (%dx),%al +c0100dd4: 88 45 f1 mov %al,-0xf(%ebp) +c0100dd7: 66 c7 45 f6 84 00 movw $0x84,-0xa(%ebp) +c0100ddd: 0f b7 45 f6 movzwl -0xa(%ebp),%eax +c0100de1: 89 c2 mov %eax,%edx +c0100de3: ec in (%dx),%al +c0100de4: 88 45 f5 mov %al,-0xb(%ebp) +c0100de7: 66 c7 45 fa 84 00 movw $0x84,-0x6(%ebp) +c0100ded: 0f b7 45 fa movzwl -0x6(%ebp),%eax +c0100df1: 89 c2 mov %eax,%edx +c0100df3: ec in (%dx),%al +c0100df4: 88 45 f9 mov %al,-0x7(%ebp) +c0100df7: 66 c7 45 fe 84 00 movw $0x84,-0x2(%ebp) +c0100dfd: 0f b7 45 fe movzwl -0x2(%ebp),%eax +c0100e01: 89 c2 mov %eax,%edx +c0100e03: ec in (%dx),%al +c0100e04: 88 45 fd mov %al,-0x3(%ebp) inb(0x84); inb(0x84); inb(0x84); inb(0x84); } -c01016bb: 90 nop -c01016bc: c9 leave -c01016bd: c3 ret +c0100e07: 90 nop +c0100e08: 89 ec mov %ebp,%esp +c0100e0a: 5d pop %ebp +c0100e0b: c3 ret -c01016be : +c0100e0c : static uint16_t addr_6845; /* TEXT-mode CGA/VGA display output */ static void cga_init(void) { -c01016be: f3 0f 1e fb endbr32 -c01016c2: 55 push %ebp -c01016c3: 89 e5 mov %esp,%ebp -c01016c5: 83 ec 20 sub $0x20,%esp +c0100e0c: 55 push %ebp +c0100e0d: 89 e5 mov %esp,%ebp +c0100e0f: 83 ec 20 sub $0x20,%esp volatile uint16_t *cp = (uint16_t *)(CGA_BUF + KERNBASE); -c01016c8: c7 45 fc 00 80 0b c0 movl $0xc00b8000,-0x4(%ebp) +c0100e12: c7 45 fc 00 80 0b c0 movl $0xc00b8000,-0x4(%ebp) uint16_t was = *cp; -c01016cf: 8b 45 fc mov -0x4(%ebp),%eax -c01016d2: 0f b7 00 movzwl (%eax),%eax -c01016d5: 66 89 45 fa mov %ax,-0x6(%ebp) +c0100e19: 8b 45 fc mov -0x4(%ebp),%eax +c0100e1c: 0f b7 00 movzwl (%eax),%eax +c0100e1f: 66 89 45 fa mov %ax,-0x6(%ebp) *cp = (uint16_t) 0xA55A; -c01016d9: 8b 45 fc mov -0x4(%ebp),%eax -c01016dc: 66 c7 00 5a a5 movw $0xa55a,(%eax) +c0100e23: 8b 45 fc mov -0x4(%ebp),%eax +c0100e26: 66 c7 00 5a a5 movw $0xa55a,(%eax) if (*cp != 0xA55A) { -c01016e1: 8b 45 fc mov -0x4(%ebp),%eax -c01016e4: 0f b7 00 movzwl (%eax),%eax -c01016e7: 0f b7 c0 movzwl %ax,%eax -c01016ea: 3d 5a a5 00 00 cmp $0xa55a,%eax -c01016ef: 74 12 je c0101703 +c0100e2b: 8b 45 fc mov -0x4(%ebp),%eax +c0100e2e: 0f b7 00 movzwl (%eax),%eax +c0100e31: 0f b7 c0 movzwl %ax,%eax +c0100e34: 3d 5a a5 00 00 cmp $0xa55a,%eax +c0100e39: 74 12 je c0100e4d cp = (uint16_t*)(MONO_BUF + KERNBASE); -c01016f1: c7 45 fc 00 00 0b c0 movl $0xc00b0000,-0x4(%ebp) +c0100e3b: c7 45 fc 00 00 0b c0 movl $0xc00b0000,-0x4(%ebp) addr_6845 = MONO_BASE; -c01016f8: 66 c7 05 26 b5 12 c0 movw $0x3b4,0xc012b526 -c01016ff: b4 03 -c0101701: eb 13 jmp c0101716 +c0100e42: 66 c7 05 46 b4 12 c0 movw $0x3b4,0xc012b446 +c0100e49: b4 03 +c0100e4b: eb 13 jmp c0100e60 } else { *cp = was; -c0101703: 8b 45 fc mov -0x4(%ebp),%eax -c0101706: 0f b7 55 fa movzwl -0x6(%ebp),%edx -c010170a: 66 89 10 mov %dx,(%eax) +c0100e4d: 8b 45 fc mov -0x4(%ebp),%eax +c0100e50: 0f b7 55 fa movzwl -0x6(%ebp),%edx +c0100e54: 66 89 10 mov %dx,(%eax) addr_6845 = CGA_BASE; -c010170d: 66 c7 05 26 b5 12 c0 movw $0x3d4,0xc012b526 -c0101714: d4 03 +c0100e57: 66 c7 05 46 b4 12 c0 movw $0x3d4,0xc012b446 +c0100e5e: d4 03 } // Extract cursor location uint32_t pos; outb(addr_6845, 14); -c0101716: 0f b7 05 26 b5 12 c0 movzwl 0xc012b526,%eax -c010171d: 66 89 45 e6 mov %ax,-0x1a(%ebp) -c0101721: c6 45 e5 0e movb $0xe,-0x1b(%ebp) +c0100e60: 0f b7 05 46 b4 12 c0 movzwl 0xc012b446,%eax +c0100e67: 66 89 45 e6 mov %ax,-0x1a(%ebp) +c0100e6b: c6 45 e5 0e movb $0xe,-0x1b(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101725: 0f b6 45 e5 movzbl -0x1b(%ebp),%eax -c0101729: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx -c010172d: ee out %al,(%dx) +c0100e6f: 0f b6 45 e5 movzbl -0x1b(%ebp),%eax +c0100e73: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx +c0100e77: ee out %al,(%dx) } -c010172e: 90 nop +c0100e78: 90 nop pos = inb(addr_6845 + 1) << 8; -c010172f: 0f b7 05 26 b5 12 c0 movzwl 0xc012b526,%eax -c0101736: 40 inc %eax -c0101737: 0f b7 c0 movzwl %ax,%eax -c010173a: 66 89 45 ea mov %ax,-0x16(%ebp) +c0100e79: 0f b7 05 46 b4 12 c0 movzwl 0xc012b446,%eax +c0100e80: 40 inc %eax +c0100e81: 0f b7 c0 movzwl %ax,%eax +c0100e84: 66 89 45 ea mov %ax,-0x16(%ebp) asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); -c010173e: 0f b7 45 ea movzwl -0x16(%ebp),%eax -c0101742: 89 c2 mov %eax,%edx -c0101744: ec in (%dx),%al -c0101745: 88 45 e9 mov %al,-0x17(%ebp) +c0100e88: 0f b7 45 ea movzwl -0x16(%ebp),%eax +c0100e8c: 89 c2 mov %eax,%edx +c0100e8e: ec in (%dx),%al +c0100e8f: 88 45 e9 mov %al,-0x17(%ebp) return data; -c0101748: 0f b6 45 e9 movzbl -0x17(%ebp),%eax -c010174c: 0f b6 c0 movzbl %al,%eax -c010174f: c1 e0 08 shl $0x8,%eax -c0101752: 89 45 f4 mov %eax,-0xc(%ebp) +c0100e92: 0f b6 45 e9 movzbl -0x17(%ebp),%eax +c0100e96: 0f b6 c0 movzbl %al,%eax +c0100e99: c1 e0 08 shl $0x8,%eax +c0100e9c: 89 45 f4 mov %eax,-0xc(%ebp) outb(addr_6845, 15); -c0101755: 0f b7 05 26 b5 12 c0 movzwl 0xc012b526,%eax -c010175c: 66 89 45 ee mov %ax,-0x12(%ebp) -c0101760: c6 45 ed 0f movb $0xf,-0x13(%ebp) +c0100e9f: 0f b7 05 46 b4 12 c0 movzwl 0xc012b446,%eax +c0100ea6: 66 89 45 ee mov %ax,-0x12(%ebp) +c0100eaa: c6 45 ed 0f movb $0xf,-0x13(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101764: 0f b6 45 ed movzbl -0x13(%ebp),%eax -c0101768: 0f b7 55 ee movzwl -0x12(%ebp),%edx -c010176c: ee out %al,(%dx) +c0100eae: 0f b6 45 ed movzbl -0x13(%ebp),%eax +c0100eb2: 0f b7 55 ee movzwl -0x12(%ebp),%edx +c0100eb6: ee out %al,(%dx) } -c010176d: 90 nop +c0100eb7: 90 nop pos |= inb(addr_6845 + 1); -c010176e: 0f b7 05 26 b5 12 c0 movzwl 0xc012b526,%eax -c0101775: 40 inc %eax -c0101776: 0f b7 c0 movzwl %ax,%eax -c0101779: 66 89 45 f2 mov %ax,-0xe(%ebp) +c0100eb8: 0f b7 05 46 b4 12 c0 movzwl 0xc012b446,%eax +c0100ebf: 40 inc %eax +c0100ec0: 0f b7 c0 movzwl %ax,%eax +c0100ec3: 66 89 45 f2 mov %ax,-0xe(%ebp) asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); -c010177d: 0f b7 45 f2 movzwl -0xe(%ebp),%eax -c0101781: 89 c2 mov %eax,%edx -c0101783: ec in (%dx),%al -c0101784: 88 45 f1 mov %al,-0xf(%ebp) +c0100ec7: 0f b7 45 f2 movzwl -0xe(%ebp),%eax +c0100ecb: 89 c2 mov %eax,%edx +c0100ecd: ec in (%dx),%al +c0100ece: 88 45 f1 mov %al,-0xf(%ebp) return data; -c0101787: 0f b6 45 f1 movzbl -0xf(%ebp),%eax -c010178b: 0f b6 c0 movzbl %al,%eax -c010178e: 09 45 f4 or %eax,-0xc(%ebp) +c0100ed1: 0f b6 45 f1 movzbl -0xf(%ebp),%eax +c0100ed5: 0f b6 c0 movzbl %al,%eax +c0100ed8: 09 45 f4 or %eax,-0xc(%ebp) crt_buf = (uint16_t*) cp; -c0101791: 8b 45 fc mov -0x4(%ebp),%eax -c0101794: a3 20 b5 12 c0 mov %eax,0xc012b520 +c0100edb: 8b 45 fc mov -0x4(%ebp),%eax +c0100ede: a3 40 b4 12 c0 mov %eax,0xc012b440 crt_pos = pos; -c0101799: 8b 45 f4 mov -0xc(%ebp),%eax -c010179c: 0f b7 c0 movzwl %ax,%eax -c010179f: 66 a3 24 b5 12 c0 mov %ax,0xc012b524 +c0100ee3: 8b 45 f4 mov -0xc(%ebp),%eax +c0100ee6: 0f b7 c0 movzwl %ax,%eax +c0100ee9: 66 a3 44 b4 12 c0 mov %ax,0xc012b444 } -c01017a5: 90 nop -c01017a6: c9 leave -c01017a7: c3 ret +c0100eef: 90 nop +c0100ef0: 89 ec mov %ebp,%esp +c0100ef2: 5d pop %ebp +c0100ef3: c3 ret -c01017a8 : +c0100ef4 : static bool serial_exists = 0; static void serial_init(void) { -c01017a8: f3 0f 1e fb endbr32 -c01017ac: 55 push %ebp -c01017ad: 89 e5 mov %esp,%ebp -c01017af: 83 ec 48 sub $0x48,%esp -c01017b2: 66 c7 45 d2 fa 03 movw $0x3fa,-0x2e(%ebp) -c01017b8: c6 45 d1 00 movb $0x0,-0x2f(%ebp) +c0100ef4: 55 push %ebp +c0100ef5: 89 e5 mov %esp,%ebp +c0100ef7: 83 ec 48 sub $0x48,%esp +c0100efa: 66 c7 45 d2 fa 03 movw $0x3fa,-0x2e(%ebp) +c0100f00: c6 45 d1 00 movb $0x0,-0x2f(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01017bc: 0f b6 45 d1 movzbl -0x2f(%ebp),%eax -c01017c0: 0f b7 55 d2 movzwl -0x2e(%ebp),%edx -c01017c4: ee out %al,(%dx) +c0100f04: 0f b6 45 d1 movzbl -0x2f(%ebp),%eax +c0100f08: 0f b7 55 d2 movzwl -0x2e(%ebp),%edx +c0100f0c: ee out %al,(%dx) } -c01017c5: 90 nop -c01017c6: 66 c7 45 d6 fb 03 movw $0x3fb,-0x2a(%ebp) -c01017cc: c6 45 d5 80 movb $0x80,-0x2b(%ebp) +c0100f0d: 90 nop +c0100f0e: 66 c7 45 d6 fb 03 movw $0x3fb,-0x2a(%ebp) +c0100f14: c6 45 d5 80 movb $0x80,-0x2b(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01017d0: 0f b6 45 d5 movzbl -0x2b(%ebp),%eax -c01017d4: 0f b7 55 d6 movzwl -0x2a(%ebp),%edx -c01017d8: ee out %al,(%dx) +c0100f18: 0f b6 45 d5 movzbl -0x2b(%ebp),%eax +c0100f1c: 0f b7 55 d6 movzwl -0x2a(%ebp),%edx +c0100f20: ee out %al,(%dx) } -c01017d9: 90 nop -c01017da: 66 c7 45 da f8 03 movw $0x3f8,-0x26(%ebp) -c01017e0: c6 45 d9 0c movb $0xc,-0x27(%ebp) +c0100f21: 90 nop +c0100f22: 66 c7 45 da f8 03 movw $0x3f8,-0x26(%ebp) +c0100f28: c6 45 d9 0c movb $0xc,-0x27(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01017e4: 0f b6 45 d9 movzbl -0x27(%ebp),%eax -c01017e8: 0f b7 55 da movzwl -0x26(%ebp),%edx -c01017ec: ee out %al,(%dx) +c0100f2c: 0f b6 45 d9 movzbl -0x27(%ebp),%eax +c0100f30: 0f b7 55 da movzwl -0x26(%ebp),%edx +c0100f34: ee out %al,(%dx) } -c01017ed: 90 nop -c01017ee: 66 c7 45 de f9 03 movw $0x3f9,-0x22(%ebp) -c01017f4: c6 45 dd 00 movb $0x0,-0x23(%ebp) +c0100f35: 90 nop +c0100f36: 66 c7 45 de f9 03 movw $0x3f9,-0x22(%ebp) +c0100f3c: c6 45 dd 00 movb $0x0,-0x23(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01017f8: 0f b6 45 dd movzbl -0x23(%ebp),%eax -c01017fc: 0f b7 55 de movzwl -0x22(%ebp),%edx -c0101800: ee out %al,(%dx) +c0100f40: 0f b6 45 dd movzbl -0x23(%ebp),%eax +c0100f44: 0f b7 55 de movzwl -0x22(%ebp),%edx +c0100f48: ee out %al,(%dx) } -c0101801: 90 nop -c0101802: 66 c7 45 e2 fb 03 movw $0x3fb,-0x1e(%ebp) -c0101808: c6 45 e1 03 movb $0x3,-0x1f(%ebp) +c0100f49: 90 nop +c0100f4a: 66 c7 45 e2 fb 03 movw $0x3fb,-0x1e(%ebp) +c0100f50: c6 45 e1 03 movb $0x3,-0x1f(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010180c: 0f b6 45 e1 movzbl -0x1f(%ebp),%eax -c0101810: 0f b7 55 e2 movzwl -0x1e(%ebp),%edx -c0101814: ee out %al,(%dx) +c0100f54: 0f b6 45 e1 movzbl -0x1f(%ebp),%eax +c0100f58: 0f b7 55 e2 movzwl -0x1e(%ebp),%edx +c0100f5c: ee out %al,(%dx) } -c0101815: 90 nop -c0101816: 66 c7 45 e6 fc 03 movw $0x3fc,-0x1a(%ebp) -c010181c: c6 45 e5 00 movb $0x0,-0x1b(%ebp) +c0100f5d: 90 nop +c0100f5e: 66 c7 45 e6 fc 03 movw $0x3fc,-0x1a(%ebp) +c0100f64: c6 45 e5 00 movb $0x0,-0x1b(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101820: 0f b6 45 e5 movzbl -0x1b(%ebp),%eax -c0101824: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx -c0101828: ee out %al,(%dx) +c0100f68: 0f b6 45 e5 movzbl -0x1b(%ebp),%eax +c0100f6c: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx +c0100f70: ee out %al,(%dx) } -c0101829: 90 nop -c010182a: 66 c7 45 ea f9 03 movw $0x3f9,-0x16(%ebp) -c0101830: c6 45 e9 01 movb $0x1,-0x17(%ebp) +c0100f71: 90 nop +c0100f72: 66 c7 45 ea f9 03 movw $0x3f9,-0x16(%ebp) +c0100f78: c6 45 e9 01 movb $0x1,-0x17(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101834: 0f b6 45 e9 movzbl -0x17(%ebp),%eax -c0101838: 0f b7 55 ea movzwl -0x16(%ebp),%edx -c010183c: ee out %al,(%dx) +c0100f7c: 0f b6 45 e9 movzbl -0x17(%ebp),%eax +c0100f80: 0f b7 55 ea movzwl -0x16(%ebp),%edx +c0100f84: ee out %al,(%dx) } -c010183d: 90 nop -c010183e: 66 c7 45 ee fd 03 movw $0x3fd,-0x12(%ebp) +c0100f85: 90 nop +c0100f86: 66 c7 45 ee fd 03 movw $0x3fd,-0x12(%ebp) asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); -c0101844: 0f b7 45 ee movzwl -0x12(%ebp),%eax -c0101848: 89 c2 mov %eax,%edx -c010184a: ec in (%dx),%al -c010184b: 88 45 ed mov %al,-0x13(%ebp) +c0100f8c: 0f b7 45 ee movzwl -0x12(%ebp),%eax +c0100f90: 89 c2 mov %eax,%edx +c0100f92: ec in (%dx),%al +c0100f93: 88 45 ed mov %al,-0x13(%ebp) return data; -c010184e: 0f b6 45 ed movzbl -0x13(%ebp),%eax +c0100f96: 0f b6 45 ed movzbl -0x13(%ebp),%eax // Enable rcv interrupts outb(COM1 + COM_IER, COM_IER_RDI); // Clear any preexisting overrun indications and interrupts // Serial port doesn't exist if COM_LSR returns 0xFF serial_exists = (inb(COM1 + COM_LSR) != 0xFF); -c0101852: 3c ff cmp $0xff,%al -c0101854: 0f 95 c0 setne %al -c0101857: 0f b6 c0 movzbl %al,%eax -c010185a: a3 28 b5 12 c0 mov %eax,0xc012b528 -c010185f: 66 c7 45 f2 fa 03 movw $0x3fa,-0xe(%ebp) +c0100f9a: 3c ff cmp $0xff,%al +c0100f9c: 0f 95 c0 setne %al +c0100f9f: 0f b6 c0 movzbl %al,%eax +c0100fa2: a3 48 b4 12 c0 mov %eax,0xc012b448 +c0100fa7: 66 c7 45 f2 fa 03 movw $0x3fa,-0xe(%ebp) asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); -c0101865: 0f b7 45 f2 movzwl -0xe(%ebp),%eax -c0101869: 89 c2 mov %eax,%edx -c010186b: ec in (%dx),%al -c010186c: 88 45 f1 mov %al,-0xf(%ebp) -c010186f: 66 c7 45 f6 f8 03 movw $0x3f8,-0xa(%ebp) -c0101875: 0f b7 45 f6 movzwl -0xa(%ebp),%eax -c0101879: 89 c2 mov %eax,%edx -c010187b: ec in (%dx),%al -c010187c: 88 45 f5 mov %al,-0xb(%ebp) +c0100fad: 0f b7 45 f2 movzwl -0xe(%ebp),%eax +c0100fb1: 89 c2 mov %eax,%edx +c0100fb3: ec in (%dx),%al +c0100fb4: 88 45 f1 mov %al,-0xf(%ebp) +c0100fb7: 66 c7 45 f6 f8 03 movw $0x3f8,-0xa(%ebp) +c0100fbd: 0f b7 45 f6 movzwl -0xa(%ebp),%eax +c0100fc1: 89 c2 mov %eax,%edx +c0100fc3: ec in (%dx),%al +c0100fc4: 88 45 f5 mov %al,-0xb(%ebp) (void) inb(COM1+COM_IIR); (void) inb(COM1+COM_RX); if (serial_exists) { -c010187f: a1 28 b5 12 c0 mov 0xc012b528,%eax -c0101884: 85 c0 test %eax,%eax -c0101886: 74 0c je c0101894 +c0100fc7: a1 48 b4 12 c0 mov 0xc012b448,%eax +c0100fcc: 85 c0 test %eax,%eax +c0100fce: 74 0c je c0100fdc pic_enable(IRQ_COM1); -c0101888: c7 04 24 04 00 00 00 movl $0x4,(%esp) -c010188f: e8 31 07 00 00 call c0101fc5 +c0100fd0: c7 04 24 04 00 00 00 movl $0x4,(%esp) +c0100fd7: e8 84 0f 00 00 call c0101f60 } } -c0101894: 90 nop -c0101895: c9 leave -c0101896: c3 ret +c0100fdc: 90 nop +c0100fdd: 89 ec mov %ebp,%esp +c0100fdf: 5d pop %ebp +c0100fe0: c3 ret -c0101897 : +c0100fe1 : static void lpt_putc_sub(int c) { -c0101897: f3 0f 1e fb endbr32 -c010189b: 55 push %ebp -c010189c: 89 e5 mov %esp,%ebp -c010189e: 83 ec 20 sub $0x20,%esp +c0100fe1: 55 push %ebp +c0100fe2: 89 e5 mov %esp,%ebp +c0100fe4: 83 ec 20 sub $0x20,%esp int i; for (i = 0; !(inb(LPTPORT + 1) & 0x80) && i < 12800; i ++) { -c01018a1: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) -c01018a8: eb 08 jmp c01018b2 +c0100fe7: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) +c0100fee: eb 08 jmp c0100ff8 delay(); -c01018aa: e8 c2 fd ff ff call c0101671 +c0100ff0: e8 cc fd ff ff call c0100dc1 for (i = 0; !(inb(LPTPORT + 1) & 0x80) && i < 12800; i ++) { -c01018af: ff 45 fc incl -0x4(%ebp) -c01018b2: 66 c7 45 fa 79 03 movw $0x379,-0x6(%ebp) -c01018b8: 0f b7 45 fa movzwl -0x6(%ebp),%eax -c01018bc: 89 c2 mov %eax,%edx -c01018be: ec in (%dx),%al -c01018bf: 88 45 f9 mov %al,-0x7(%ebp) +c0100ff5: ff 45 fc incl -0x4(%ebp) +c0100ff8: 66 c7 45 fa 79 03 movw $0x379,-0x6(%ebp) +c0100ffe: 0f b7 45 fa movzwl -0x6(%ebp),%eax +c0101002: 89 c2 mov %eax,%edx +c0101004: ec in (%dx),%al +c0101005: 88 45 f9 mov %al,-0x7(%ebp) return data; -c01018c2: 0f b6 45 f9 movzbl -0x7(%ebp),%eax -c01018c6: 84 c0 test %al,%al -c01018c8: 78 09 js c01018d3 -c01018ca: 81 7d fc ff 31 00 00 cmpl $0x31ff,-0x4(%ebp) -c01018d1: 7e d7 jle c01018aa +c0101008: 0f b6 45 f9 movzbl -0x7(%ebp),%eax +c010100c: 84 c0 test %al,%al +c010100e: 78 09 js c0101019 +c0101010: 81 7d fc ff 31 00 00 cmpl $0x31ff,-0x4(%ebp) +c0101017: 7e d7 jle c0100ff0 } outb(LPTPORT + 0, c); -c01018d3: 8b 45 08 mov 0x8(%ebp),%eax -c01018d6: 0f b6 c0 movzbl %al,%eax -c01018d9: 66 c7 45 ee 78 03 movw $0x378,-0x12(%ebp) -c01018df: 88 45 ed mov %al,-0x13(%ebp) +c0101019: 8b 45 08 mov 0x8(%ebp),%eax +c010101c: 0f b6 c0 movzbl %al,%eax +c010101f: 66 c7 45 ee 78 03 movw $0x378,-0x12(%ebp) +c0101025: 88 45 ed mov %al,-0x13(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01018e2: 0f b6 45 ed movzbl -0x13(%ebp),%eax -c01018e6: 0f b7 55 ee movzwl -0x12(%ebp),%edx -c01018ea: ee out %al,(%dx) +c0101028: 0f b6 45 ed movzbl -0x13(%ebp),%eax +c010102c: 0f b7 55 ee movzwl -0x12(%ebp),%edx +c0101030: ee out %al,(%dx) } -c01018eb: 90 nop -c01018ec: 66 c7 45 f2 7a 03 movw $0x37a,-0xe(%ebp) -c01018f2: c6 45 f1 0d movb $0xd,-0xf(%ebp) +c0101031: 90 nop +c0101032: 66 c7 45 f2 7a 03 movw $0x37a,-0xe(%ebp) +c0101038: c6 45 f1 0d movb $0xd,-0xf(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01018f6: 0f b6 45 f1 movzbl -0xf(%ebp),%eax -c01018fa: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c01018fe: ee out %al,(%dx) +c010103c: 0f b6 45 f1 movzbl -0xf(%ebp),%eax +c0101040: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c0101044: ee out %al,(%dx) } -c01018ff: 90 nop -c0101900: 66 c7 45 f6 7a 03 movw $0x37a,-0xa(%ebp) -c0101906: c6 45 f5 08 movb $0x8,-0xb(%ebp) +c0101045: 90 nop +c0101046: 66 c7 45 f6 7a 03 movw $0x37a,-0xa(%ebp) +c010104c: c6 45 f5 08 movb $0x8,-0xb(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010190a: 0f b6 45 f5 movzbl -0xb(%ebp),%eax -c010190e: 0f b7 55 f6 movzwl -0xa(%ebp),%edx -c0101912: ee out %al,(%dx) +c0101050: 0f b6 45 f5 movzbl -0xb(%ebp),%eax +c0101054: 0f b7 55 f6 movzwl -0xa(%ebp),%edx +c0101058: ee out %al,(%dx) } -c0101913: 90 nop +c0101059: 90 nop outb(LPTPORT + 2, 0x08 | 0x04 | 0x01); outb(LPTPORT + 2, 0x08); } -c0101914: 90 nop -c0101915: c9 leave -c0101916: c3 ret +c010105a: 90 nop +c010105b: 89 ec mov %ebp,%esp +c010105d: 5d pop %ebp +c010105e: c3 ret -c0101917 : +c010105f : /* lpt_putc - copy console output to parallel port */ static void lpt_putc(int c) { -c0101917: f3 0f 1e fb endbr32 -c010191b: 55 push %ebp -c010191c: 89 e5 mov %esp,%ebp -c010191e: 83 ec 04 sub $0x4,%esp +c010105f: 55 push %ebp +c0101060: 89 e5 mov %esp,%ebp +c0101062: 83 ec 04 sub $0x4,%esp if (c != '\b') { -c0101921: 83 7d 08 08 cmpl $0x8,0x8(%ebp) -c0101925: 74 0d je c0101934 +c0101065: 83 7d 08 08 cmpl $0x8,0x8(%ebp) +c0101069: 74 0d je c0101078 lpt_putc_sub(c); -c0101927: 8b 45 08 mov 0x8(%ebp),%eax -c010192a: 89 04 24 mov %eax,(%esp) -c010192d: e8 65 ff ff ff call c0101897 +c010106b: 8b 45 08 mov 0x8(%ebp),%eax +c010106e: 89 04 24 mov %eax,(%esp) +c0101071: e8 6b ff ff ff call c0100fe1 else { lpt_putc_sub('\b'); lpt_putc_sub(' '); lpt_putc_sub('\b'); } } -c0101932: eb 24 jmp c0101958 +c0101076: eb 24 jmp c010109c lpt_putc_sub('\b'); -c0101934: c7 04 24 08 00 00 00 movl $0x8,(%esp) -c010193b: e8 57 ff ff ff call c0101897 +c0101078: c7 04 24 08 00 00 00 movl $0x8,(%esp) +c010107f: e8 5d ff ff ff call c0100fe1 lpt_putc_sub(' '); -c0101940: c7 04 24 20 00 00 00 movl $0x20,(%esp) -c0101947: e8 4b ff ff ff call c0101897 +c0101084: c7 04 24 20 00 00 00 movl $0x20,(%esp) +c010108b: e8 51 ff ff ff call c0100fe1 lpt_putc_sub('\b'); -c010194c: c7 04 24 08 00 00 00 movl $0x8,(%esp) -c0101953: e8 3f ff ff ff call c0101897 +c0101090: c7 04 24 08 00 00 00 movl $0x8,(%esp) +c0101097: e8 45 ff ff ff call c0100fe1 } -c0101958: 90 nop -c0101959: c9 leave -c010195a: c3 ret +c010109c: 90 nop +c010109d: 89 ec mov %ebp,%esp +c010109f: 5d pop %ebp +c01010a0: c3 ret -c010195b : +c01010a1 : /* cga_putc - print character to console */ static void cga_putc(int c) { -c010195b: f3 0f 1e fb endbr32 -c010195f: 55 push %ebp -c0101960: 89 e5 mov %esp,%ebp -c0101962: 53 push %ebx -c0101963: 83 ec 34 sub $0x34,%esp +c01010a1: 55 push %ebp +c01010a2: 89 e5 mov %esp,%ebp +c01010a4: 83 ec 38 sub $0x38,%esp +c01010a7: 89 5d fc mov %ebx,-0x4(%ebp) // set black on white if (!(c & ~0xFF)) { -c0101966: 8b 45 08 mov 0x8(%ebp),%eax -c0101969: 25 00 ff ff ff and $0xffffff00,%eax -c010196e: 85 c0 test %eax,%eax -c0101970: 75 07 jne c0101979 +c01010aa: 8b 45 08 mov 0x8(%ebp),%eax +c01010ad: 25 00 ff ff ff and $0xffffff00,%eax +c01010b2: 85 c0 test %eax,%eax +c01010b4: 75 07 jne c01010bd c |= 0x0700; -c0101972: 81 4d 08 00 07 00 00 orl $0x700,0x8(%ebp) +c01010b6: 81 4d 08 00 07 00 00 orl $0x700,0x8(%ebp) } switch (c & 0xff) { -c0101979: 8b 45 08 mov 0x8(%ebp),%eax -c010197c: 0f b6 c0 movzbl %al,%eax -c010197f: 83 f8 0d cmp $0xd,%eax -c0101982: 74 72 je c01019f6 -c0101984: 83 f8 0d cmp $0xd,%eax -c0101987: 0f 8f a3 00 00 00 jg c0101a30 -c010198d: 83 f8 08 cmp $0x8,%eax -c0101990: 74 0a je c010199c -c0101992: 83 f8 0a cmp $0xa,%eax -c0101995: 74 4c je c01019e3 -c0101997: e9 94 00 00 00 jmp c0101a30 +c01010bd: 8b 45 08 mov 0x8(%ebp),%eax +c01010c0: 0f b6 c0 movzbl %al,%eax +c01010c3: 83 f8 0d cmp $0xd,%eax +c01010c6: 74 72 je c010113a +c01010c8: 83 f8 0d cmp $0xd,%eax +c01010cb: 0f 8f a3 00 00 00 jg c0101174 +c01010d1: 83 f8 08 cmp $0x8,%eax +c01010d4: 74 0a je c01010e0 +c01010d6: 83 f8 0a cmp $0xa,%eax +c01010d9: 74 4c je c0101127 +c01010db: e9 94 00 00 00 jmp c0101174 case '\b': if (crt_pos > 0) { -c010199c: 0f b7 05 24 b5 12 c0 movzwl 0xc012b524,%eax -c01019a3: 85 c0 test %eax,%eax -c01019a5: 0f 84 af 00 00 00 je c0101a5a +c01010e0: 0f b7 05 44 b4 12 c0 movzwl 0xc012b444,%eax +c01010e7: 85 c0 test %eax,%eax +c01010e9: 0f 84 af 00 00 00 je c010119e crt_pos --; -c01019ab: 0f b7 05 24 b5 12 c0 movzwl 0xc012b524,%eax -c01019b2: 48 dec %eax -c01019b3: 0f b7 c0 movzwl %ax,%eax -c01019b6: 66 a3 24 b5 12 c0 mov %ax,0xc012b524 +c01010ef: 0f b7 05 44 b4 12 c0 movzwl 0xc012b444,%eax +c01010f6: 48 dec %eax +c01010f7: 0f b7 c0 movzwl %ax,%eax +c01010fa: 66 a3 44 b4 12 c0 mov %ax,0xc012b444 crt_buf[crt_pos] = (c & ~0xff) | ' '; -c01019bc: 8b 45 08 mov 0x8(%ebp),%eax -c01019bf: 98 cwtl -c01019c0: 25 00 ff ff ff and $0xffffff00,%eax -c01019c5: 98 cwtl -c01019c6: 83 c8 20 or $0x20,%eax -c01019c9: 98 cwtl -c01019ca: 8b 15 20 b5 12 c0 mov 0xc012b520,%edx -c01019d0: 0f b7 0d 24 b5 12 c0 movzwl 0xc012b524,%ecx -c01019d7: 01 c9 add %ecx,%ecx -c01019d9: 01 ca add %ecx,%edx -c01019db: 0f b7 c0 movzwl %ax,%eax -c01019de: 66 89 02 mov %ax,(%edx) +c0101100: 8b 45 08 mov 0x8(%ebp),%eax +c0101103: 98 cwtl +c0101104: 25 00 ff ff ff and $0xffffff00,%eax +c0101109: 98 cwtl +c010110a: 83 c8 20 or $0x20,%eax +c010110d: 98 cwtl +c010110e: 8b 0d 40 b4 12 c0 mov 0xc012b440,%ecx +c0101114: 0f b7 15 44 b4 12 c0 movzwl 0xc012b444,%edx +c010111b: 01 d2 add %edx,%edx +c010111d: 01 ca add %ecx,%edx +c010111f: 0f b7 c0 movzwl %ax,%eax +c0101122: 66 89 02 mov %ax,(%edx) } break; -c01019e1: eb 77 jmp c0101a5a +c0101125: eb 77 jmp c010119e case '\n': crt_pos += CRT_COLS; -c01019e3: 0f b7 05 24 b5 12 c0 movzwl 0xc012b524,%eax -c01019ea: 83 c0 50 add $0x50,%eax -c01019ed: 0f b7 c0 movzwl %ax,%eax -c01019f0: 66 a3 24 b5 12 c0 mov %ax,0xc012b524 +c0101127: 0f b7 05 44 b4 12 c0 movzwl 0xc012b444,%eax +c010112e: 83 c0 50 add $0x50,%eax +c0101131: 0f b7 c0 movzwl %ax,%eax +c0101134: 66 a3 44 b4 12 c0 mov %ax,0xc012b444 case '\r': crt_pos -= (crt_pos % CRT_COLS); -c01019f6: 0f b7 1d 24 b5 12 c0 movzwl 0xc012b524,%ebx -c01019fd: 0f b7 0d 24 b5 12 c0 movzwl 0xc012b524,%ecx -c0101a04: ba cd cc cc cc mov $0xcccccccd,%edx -c0101a09: 89 c8 mov %ecx,%eax -c0101a0b: f7 e2 mul %edx -c0101a0d: c1 ea 06 shr $0x6,%edx -c0101a10: 89 d0 mov %edx,%eax -c0101a12: c1 e0 02 shl $0x2,%eax -c0101a15: 01 d0 add %edx,%eax -c0101a17: c1 e0 04 shl $0x4,%eax -c0101a1a: 29 c1 sub %eax,%ecx -c0101a1c: 89 c8 mov %ecx,%eax -c0101a1e: 0f b7 c0 movzwl %ax,%eax -c0101a21: 29 c3 sub %eax,%ebx -c0101a23: 89 d8 mov %ebx,%eax -c0101a25: 0f b7 c0 movzwl %ax,%eax -c0101a28: 66 a3 24 b5 12 c0 mov %ax,0xc012b524 +c010113a: 0f b7 1d 44 b4 12 c0 movzwl 0xc012b444,%ebx +c0101141: 0f b7 0d 44 b4 12 c0 movzwl 0xc012b444,%ecx +c0101148: ba cd cc cc cc mov $0xcccccccd,%edx +c010114d: 89 c8 mov %ecx,%eax +c010114f: f7 e2 mul %edx +c0101151: c1 ea 06 shr $0x6,%edx +c0101154: 89 d0 mov %edx,%eax +c0101156: c1 e0 02 shl $0x2,%eax +c0101159: 01 d0 add %edx,%eax +c010115b: c1 e0 04 shl $0x4,%eax +c010115e: 29 c1 sub %eax,%ecx +c0101160: 89 ca mov %ecx,%edx +c0101162: 0f b7 d2 movzwl %dx,%edx +c0101165: 89 d8 mov %ebx,%eax +c0101167: 29 d0 sub %edx,%eax +c0101169: 0f b7 c0 movzwl %ax,%eax +c010116c: 66 a3 44 b4 12 c0 mov %ax,0xc012b444 break; -c0101a2e: eb 2b jmp c0101a5b +c0101172: eb 2b jmp c010119f default: crt_buf[crt_pos ++] = c; // write the character -c0101a30: 8b 0d 20 b5 12 c0 mov 0xc012b520,%ecx -c0101a36: 0f b7 05 24 b5 12 c0 movzwl 0xc012b524,%eax -c0101a3d: 8d 50 01 lea 0x1(%eax),%edx -c0101a40: 0f b7 d2 movzwl %dx,%edx -c0101a43: 66 89 15 24 b5 12 c0 mov %dx,0xc012b524 -c0101a4a: 01 c0 add %eax,%eax -c0101a4c: 8d 14 01 lea (%ecx,%eax,1),%edx -c0101a4f: 8b 45 08 mov 0x8(%ebp),%eax -c0101a52: 0f b7 c0 movzwl %ax,%eax -c0101a55: 66 89 02 mov %ax,(%edx) +c0101174: 8b 0d 40 b4 12 c0 mov 0xc012b440,%ecx +c010117a: 0f b7 05 44 b4 12 c0 movzwl 0xc012b444,%eax +c0101181: 8d 50 01 lea 0x1(%eax),%edx +c0101184: 0f b7 d2 movzwl %dx,%edx +c0101187: 66 89 15 44 b4 12 c0 mov %dx,0xc012b444 +c010118e: 01 c0 add %eax,%eax +c0101190: 8d 14 01 lea (%ecx,%eax,1),%edx +c0101193: 8b 45 08 mov 0x8(%ebp),%eax +c0101196: 0f b7 c0 movzwl %ax,%eax +c0101199: 66 89 02 mov %ax,(%edx) break; -c0101a58: eb 01 jmp c0101a5b +c010119c: eb 01 jmp c010119f break; -c0101a5a: 90 nop +c010119e: 90 nop } // What is the purpose of this? if (crt_pos >= CRT_SIZE) { -c0101a5b: 0f b7 05 24 b5 12 c0 movzwl 0xc012b524,%eax -c0101a62: 3d cf 07 00 00 cmp $0x7cf,%eax -c0101a67: 76 5d jbe c0101ac6 +c010119f: 0f b7 05 44 b4 12 c0 movzwl 0xc012b444,%eax +c01011a6: 3d cf 07 00 00 cmp $0x7cf,%eax +c01011ab: 76 5e jbe c010120b int i; memmove(crt_buf, crt_buf + CRT_COLS, (CRT_SIZE - CRT_COLS) * sizeof(uint16_t)); -c0101a69: a1 20 b5 12 c0 mov 0xc012b520,%eax -c0101a6e: 8d 90 a0 00 00 00 lea 0xa0(%eax),%edx -c0101a74: a1 20 b5 12 c0 mov 0xc012b520,%eax -c0101a79: c7 44 24 08 00 0f 00 movl $0xf00,0x8(%esp) -c0101a80: 00 -c0101a81: 89 54 24 04 mov %edx,0x4(%esp) -c0101a85: 89 04 24 mov %eax,(%esp) -c0101a88: e8 0a 7f 00 00 call c0109997 +c01011ad: a1 40 b4 12 c0 mov 0xc012b440,%eax +c01011b2: 8d 90 a0 00 00 00 lea 0xa0(%eax),%edx +c01011b8: a1 40 b4 12 c0 mov 0xc012b440,%eax +c01011bd: c7 44 24 08 00 0f 00 movl $0xf00,0x8(%esp) +c01011c4: 00 +c01011c5: 89 54 24 04 mov %edx,0x4(%esp) +c01011c9: 89 04 24 mov %eax,(%esp) +c01011cc: e8 55 8d 00 00 call c0109f26 for (i = CRT_SIZE - CRT_COLS; i < CRT_SIZE; i ++) { -c0101a8d: c7 45 f4 80 07 00 00 movl $0x780,-0xc(%ebp) -c0101a94: eb 14 jmp c0101aaa +c01011d1: c7 45 f4 80 07 00 00 movl $0x780,-0xc(%ebp) +c01011d8: eb 15 jmp c01011ef crt_buf[i] = 0x0700 | ' '; -c0101a96: a1 20 b5 12 c0 mov 0xc012b520,%eax -c0101a9b: 8b 55 f4 mov -0xc(%ebp),%edx -c0101a9e: 01 d2 add %edx,%edx -c0101aa0: 01 d0 add %edx,%eax -c0101aa2: 66 c7 00 20 07 movw $0x720,(%eax) +c01011da: 8b 15 40 b4 12 c0 mov 0xc012b440,%edx +c01011e0: 8b 45 f4 mov -0xc(%ebp),%eax +c01011e3: 01 c0 add %eax,%eax +c01011e5: 01 d0 add %edx,%eax +c01011e7: 66 c7 00 20 07 movw $0x720,(%eax) for (i = CRT_SIZE - CRT_COLS; i < CRT_SIZE; i ++) { -c0101aa7: ff 45 f4 incl -0xc(%ebp) -c0101aaa: 81 7d f4 cf 07 00 00 cmpl $0x7cf,-0xc(%ebp) -c0101ab1: 7e e3 jle c0101a96 +c01011ec: ff 45 f4 incl -0xc(%ebp) +c01011ef: 81 7d f4 cf 07 00 00 cmpl $0x7cf,-0xc(%ebp) +c01011f6: 7e e2 jle c01011da } crt_pos -= CRT_COLS; -c0101ab3: 0f b7 05 24 b5 12 c0 movzwl 0xc012b524,%eax -c0101aba: 83 e8 50 sub $0x50,%eax -c0101abd: 0f b7 c0 movzwl %ax,%eax -c0101ac0: 66 a3 24 b5 12 c0 mov %ax,0xc012b524 +c01011f8: 0f b7 05 44 b4 12 c0 movzwl 0xc012b444,%eax +c01011ff: 83 e8 50 sub $0x50,%eax +c0101202: 0f b7 c0 movzwl %ax,%eax +c0101205: 66 a3 44 b4 12 c0 mov %ax,0xc012b444 } // move that little blinky thing outb(addr_6845, 14); -c0101ac6: 0f b7 05 26 b5 12 c0 movzwl 0xc012b526,%eax -c0101acd: 66 89 45 e6 mov %ax,-0x1a(%ebp) -c0101ad1: c6 45 e5 0e movb $0xe,-0x1b(%ebp) +c010120b: 0f b7 05 46 b4 12 c0 movzwl 0xc012b446,%eax +c0101212: 66 89 45 e6 mov %ax,-0x1a(%ebp) +c0101216: c6 45 e5 0e movb $0xe,-0x1b(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101ad5: 0f b6 45 e5 movzbl -0x1b(%ebp),%eax -c0101ad9: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx -c0101add: ee out %al,(%dx) +c010121a: 0f b6 45 e5 movzbl -0x1b(%ebp),%eax +c010121e: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx +c0101222: ee out %al,(%dx) } -c0101ade: 90 nop +c0101223: 90 nop outb(addr_6845 + 1, crt_pos >> 8); -c0101adf: 0f b7 05 24 b5 12 c0 movzwl 0xc012b524,%eax -c0101ae6: c1 e8 08 shr $0x8,%eax -c0101ae9: 0f b7 c0 movzwl %ax,%eax -c0101aec: 0f b6 c0 movzbl %al,%eax -c0101aef: 0f b7 15 26 b5 12 c0 movzwl 0xc012b526,%edx -c0101af6: 42 inc %edx -c0101af7: 0f b7 d2 movzwl %dx,%edx -c0101afa: 66 89 55 ea mov %dx,-0x16(%ebp) -c0101afe: 88 45 e9 mov %al,-0x17(%ebp) +c0101224: 0f b7 05 44 b4 12 c0 movzwl 0xc012b444,%eax +c010122b: c1 e8 08 shr $0x8,%eax +c010122e: 0f b7 c0 movzwl %ax,%eax +c0101231: 0f b6 c0 movzbl %al,%eax +c0101234: 0f b7 15 46 b4 12 c0 movzwl 0xc012b446,%edx +c010123b: 42 inc %edx +c010123c: 0f b7 d2 movzwl %dx,%edx +c010123f: 66 89 55 ea mov %dx,-0x16(%ebp) +c0101243: 88 45 e9 mov %al,-0x17(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101b01: 0f b6 45 e9 movzbl -0x17(%ebp),%eax -c0101b05: 0f b7 55 ea movzwl -0x16(%ebp),%edx -c0101b09: ee out %al,(%dx) +c0101246: 0f b6 45 e9 movzbl -0x17(%ebp),%eax +c010124a: 0f b7 55 ea movzwl -0x16(%ebp),%edx +c010124e: ee out %al,(%dx) } -c0101b0a: 90 nop +c010124f: 90 nop outb(addr_6845, 15); -c0101b0b: 0f b7 05 26 b5 12 c0 movzwl 0xc012b526,%eax -c0101b12: 66 89 45 ee mov %ax,-0x12(%ebp) -c0101b16: c6 45 ed 0f movb $0xf,-0x13(%ebp) +c0101250: 0f b7 05 46 b4 12 c0 movzwl 0xc012b446,%eax +c0101257: 66 89 45 ee mov %ax,-0x12(%ebp) +c010125b: c6 45 ed 0f movb $0xf,-0x13(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101b1a: 0f b6 45 ed movzbl -0x13(%ebp),%eax -c0101b1e: 0f b7 55 ee movzwl -0x12(%ebp),%edx -c0101b22: ee out %al,(%dx) +c010125f: 0f b6 45 ed movzbl -0x13(%ebp),%eax +c0101263: 0f b7 55 ee movzwl -0x12(%ebp),%edx +c0101267: ee out %al,(%dx) } -c0101b23: 90 nop +c0101268: 90 nop outb(addr_6845 + 1, crt_pos); -c0101b24: 0f b7 05 24 b5 12 c0 movzwl 0xc012b524,%eax -c0101b2b: 0f b6 c0 movzbl %al,%eax -c0101b2e: 0f b7 15 26 b5 12 c0 movzwl 0xc012b526,%edx -c0101b35: 42 inc %edx -c0101b36: 0f b7 d2 movzwl %dx,%edx -c0101b39: 66 89 55 f2 mov %dx,-0xe(%ebp) -c0101b3d: 88 45 f1 mov %al,-0xf(%ebp) +c0101269: 0f b7 05 44 b4 12 c0 movzwl 0xc012b444,%eax +c0101270: 0f b6 c0 movzbl %al,%eax +c0101273: 0f b7 15 46 b4 12 c0 movzwl 0xc012b446,%edx +c010127a: 42 inc %edx +c010127b: 0f b7 d2 movzwl %dx,%edx +c010127e: 66 89 55 f2 mov %dx,-0xe(%ebp) +c0101282: 88 45 f1 mov %al,-0xf(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101b40: 0f b6 45 f1 movzbl -0xf(%ebp),%eax -c0101b44: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c0101b48: ee out %al,(%dx) +c0101285: 0f b6 45 f1 movzbl -0xf(%ebp),%eax +c0101289: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c010128d: ee out %al,(%dx) } -c0101b49: 90 nop +c010128e: 90 nop } -c0101b4a: 90 nop -c0101b4b: 83 c4 34 add $0x34,%esp -c0101b4e: 5b pop %ebx -c0101b4f: 5d pop %ebp -c0101b50: c3 ret +c010128f: 90 nop +c0101290: 8b 5d fc mov -0x4(%ebp),%ebx +c0101293: 89 ec mov %ebp,%esp +c0101295: 5d pop %ebp +c0101296: c3 ret -c0101b51 : +c0101297 : static void serial_putc_sub(int c) { -c0101b51: f3 0f 1e fb endbr32 -c0101b55: 55 push %ebp -c0101b56: 89 e5 mov %esp,%ebp -c0101b58: 83 ec 10 sub $0x10,%esp +c0101297: 55 push %ebp +c0101298: 89 e5 mov %esp,%ebp +c010129a: 83 ec 10 sub $0x10,%esp int i; for (i = 0; !(inb(COM1 + COM_LSR) & COM_LSR_TXRDY) && i < 12800; i ++) { -c0101b5b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) -c0101b62: eb 08 jmp c0101b6c +c010129d: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) +c01012a4: eb 08 jmp c01012ae delay(); -c0101b64: e8 08 fb ff ff call c0101671 +c01012a6: e8 16 fb ff ff call c0100dc1 for (i = 0; !(inb(COM1 + COM_LSR) & COM_LSR_TXRDY) && i < 12800; i ++) { -c0101b69: ff 45 fc incl -0x4(%ebp) -c0101b6c: 66 c7 45 fa fd 03 movw $0x3fd,-0x6(%ebp) +c01012ab: ff 45 fc incl -0x4(%ebp) +c01012ae: 66 c7 45 fa fd 03 movw $0x3fd,-0x6(%ebp) asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); -c0101b72: 0f b7 45 fa movzwl -0x6(%ebp),%eax -c0101b76: 89 c2 mov %eax,%edx -c0101b78: ec in (%dx),%al -c0101b79: 88 45 f9 mov %al,-0x7(%ebp) +c01012b4: 0f b7 45 fa movzwl -0x6(%ebp),%eax +c01012b8: 89 c2 mov %eax,%edx +c01012ba: ec in (%dx),%al +c01012bb: 88 45 f9 mov %al,-0x7(%ebp) return data; -c0101b7c: 0f b6 45 f9 movzbl -0x7(%ebp),%eax -c0101b80: 0f b6 c0 movzbl %al,%eax -c0101b83: 83 e0 20 and $0x20,%eax -c0101b86: 85 c0 test %eax,%eax -c0101b88: 75 09 jne c0101b93 -c0101b8a: 81 7d fc ff 31 00 00 cmpl $0x31ff,-0x4(%ebp) -c0101b91: 7e d1 jle c0101b64 +c01012be: 0f b6 45 f9 movzbl -0x7(%ebp),%eax +c01012c2: 0f b6 c0 movzbl %al,%eax +c01012c5: 83 e0 20 and $0x20,%eax +c01012c8: 85 c0 test %eax,%eax +c01012ca: 75 09 jne c01012d5 +c01012cc: 81 7d fc ff 31 00 00 cmpl $0x31ff,-0x4(%ebp) +c01012d3: 7e d1 jle c01012a6 } outb(COM1 + COM_TX, c); -c0101b93: 8b 45 08 mov 0x8(%ebp),%eax -c0101b96: 0f b6 c0 movzbl %al,%eax -c0101b99: 66 c7 45 f6 f8 03 movw $0x3f8,-0xa(%ebp) -c0101b9f: 88 45 f5 mov %al,-0xb(%ebp) +c01012d5: 8b 45 08 mov 0x8(%ebp),%eax +c01012d8: 0f b6 c0 movzbl %al,%eax +c01012db: 66 c7 45 f6 f8 03 movw $0x3f8,-0xa(%ebp) +c01012e1: 88 45 f5 mov %al,-0xb(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101ba2: 0f b6 45 f5 movzbl -0xb(%ebp),%eax -c0101ba6: 0f b7 55 f6 movzwl -0xa(%ebp),%edx -c0101baa: ee out %al,(%dx) +c01012e4: 0f b6 45 f5 movzbl -0xb(%ebp),%eax +c01012e8: 0f b7 55 f6 movzwl -0xa(%ebp),%edx +c01012ec: ee out %al,(%dx) } -c0101bab: 90 nop +c01012ed: 90 nop } -c0101bac: 90 nop -c0101bad: c9 leave -c0101bae: c3 ret +c01012ee: 90 nop +c01012ef: 89 ec mov %ebp,%esp +c01012f1: 5d pop %ebp +c01012f2: c3 ret -c0101baf : +c01012f3 : /* serial_putc - print character to serial port */ static void serial_putc(int c) { -c0101baf: f3 0f 1e fb endbr32 -c0101bb3: 55 push %ebp -c0101bb4: 89 e5 mov %esp,%ebp -c0101bb6: 83 ec 04 sub $0x4,%esp +c01012f3: 55 push %ebp +c01012f4: 89 e5 mov %esp,%ebp +c01012f6: 83 ec 04 sub $0x4,%esp if (c != '\b') { -c0101bb9: 83 7d 08 08 cmpl $0x8,0x8(%ebp) -c0101bbd: 74 0d je c0101bcc +c01012f9: 83 7d 08 08 cmpl $0x8,0x8(%ebp) +c01012fd: 74 0d je c010130c serial_putc_sub(c); -c0101bbf: 8b 45 08 mov 0x8(%ebp),%eax -c0101bc2: 89 04 24 mov %eax,(%esp) -c0101bc5: e8 87 ff ff ff call c0101b51 +c01012ff: 8b 45 08 mov 0x8(%ebp),%eax +c0101302: 89 04 24 mov %eax,(%esp) +c0101305: e8 8d ff ff ff call c0101297 else { serial_putc_sub('\b'); serial_putc_sub(' '); serial_putc_sub('\b'); } } -c0101bca: eb 24 jmp c0101bf0 +c010130a: eb 24 jmp c0101330 serial_putc_sub('\b'); -c0101bcc: c7 04 24 08 00 00 00 movl $0x8,(%esp) -c0101bd3: e8 79 ff ff ff call c0101b51 +c010130c: c7 04 24 08 00 00 00 movl $0x8,(%esp) +c0101313: e8 7f ff ff ff call c0101297 serial_putc_sub(' '); -c0101bd8: c7 04 24 20 00 00 00 movl $0x20,(%esp) -c0101bdf: e8 6d ff ff ff call c0101b51 +c0101318: c7 04 24 20 00 00 00 movl $0x20,(%esp) +c010131f: e8 73 ff ff ff call c0101297 serial_putc_sub('\b'); -c0101be4: c7 04 24 08 00 00 00 movl $0x8,(%esp) -c0101beb: e8 61 ff ff ff call c0101b51 +c0101324: c7 04 24 08 00 00 00 movl $0x8,(%esp) +c010132b: e8 67 ff ff ff call c0101297 } -c0101bf0: 90 nop -c0101bf1: c9 leave -c0101bf2: c3 ret +c0101330: 90 nop +c0101331: 89 ec mov %ebp,%esp +c0101333: 5d pop %ebp +c0101334: c3 ret -c0101bf3 : +c0101335 : /* * * cons_intr - called by device interrupt routines to feed input * characters into the circular console input buffer. * */ static void cons_intr(int (*proc)(void)) { -c0101bf3: f3 0f 1e fb endbr32 -c0101bf7: 55 push %ebp -c0101bf8: 89 e5 mov %esp,%ebp -c0101bfa: 83 ec 18 sub $0x18,%esp +c0101335: 55 push %ebp +c0101336: 89 e5 mov %esp,%ebp +c0101338: 83 ec 18 sub $0x18,%esp int c; while ((c = (*proc)()) != -1) { -c0101bfd: eb 33 jmp c0101c32 +c010133b: eb 33 jmp c0101370 if (c != 0) { -c0101bff: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0101c03: 74 2d je c0101c32 +c010133d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0101341: 74 2d je c0101370 cons.buf[cons.wpos ++] = c; -c0101c05: a1 44 b7 12 c0 mov 0xc012b744,%eax -c0101c0a: 8d 50 01 lea 0x1(%eax),%edx -c0101c0d: 89 15 44 b7 12 c0 mov %edx,0xc012b744 -c0101c13: 8b 55 f4 mov -0xc(%ebp),%edx -c0101c16: 88 90 40 b5 12 c0 mov %dl,-0x3fed4ac0(%eax) +c0101343: a1 64 b6 12 c0 mov 0xc012b664,%eax +c0101348: 8d 50 01 lea 0x1(%eax),%edx +c010134b: 89 15 64 b6 12 c0 mov %edx,0xc012b664 +c0101351: 8b 55 f4 mov -0xc(%ebp),%edx +c0101354: 88 90 60 b4 12 c0 mov %dl,-0x3fed4ba0(%eax) if (cons.wpos == CONSBUFSIZE) { -c0101c1c: a1 44 b7 12 c0 mov 0xc012b744,%eax -c0101c21: 3d 00 02 00 00 cmp $0x200,%eax -c0101c26: 75 0a jne c0101c32 +c010135a: a1 64 b6 12 c0 mov 0xc012b664,%eax +c010135f: 3d 00 02 00 00 cmp $0x200,%eax +c0101364: 75 0a jne c0101370 cons.wpos = 0; -c0101c28: c7 05 44 b7 12 c0 00 movl $0x0,0xc012b744 -c0101c2f: 00 00 00 +c0101366: c7 05 64 b6 12 c0 00 movl $0x0,0xc012b664 +c010136d: 00 00 00 while ((c = (*proc)()) != -1) { -c0101c32: 8b 45 08 mov 0x8(%ebp),%eax -c0101c35: ff d0 call *%eax -c0101c37: 89 45 f4 mov %eax,-0xc(%ebp) -c0101c3a: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) -c0101c3e: 75 bf jne c0101bff +c0101370: 8b 45 08 mov 0x8(%ebp),%eax +c0101373: ff d0 call *%eax +c0101375: 89 45 f4 mov %eax,-0xc(%ebp) +c0101378: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) +c010137c: 75 bf jne c010133d } } } } -c0101c40: 90 nop -c0101c41: 90 nop -c0101c42: c9 leave -c0101c43: c3 ret +c010137e: 90 nop +c010137f: 90 nop +c0101380: 89 ec mov %ebp,%esp +c0101382: 5d pop %ebp +c0101383: c3 ret -c0101c44 : +c0101384 : /* serial_proc_data - get data from serial port */ static int serial_proc_data(void) { -c0101c44: f3 0f 1e fb endbr32 -c0101c48: 55 push %ebp -c0101c49: 89 e5 mov %esp,%ebp -c0101c4b: 83 ec 10 sub $0x10,%esp -c0101c4e: 66 c7 45 fa fd 03 movw $0x3fd,-0x6(%ebp) +c0101384: 55 push %ebp +c0101385: 89 e5 mov %esp,%ebp +c0101387: 83 ec 10 sub $0x10,%esp +c010138a: 66 c7 45 fa fd 03 movw $0x3fd,-0x6(%ebp) asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); -c0101c54: 0f b7 45 fa movzwl -0x6(%ebp),%eax -c0101c58: 89 c2 mov %eax,%edx -c0101c5a: ec in (%dx),%al -c0101c5b: 88 45 f9 mov %al,-0x7(%ebp) +c0101390: 0f b7 45 fa movzwl -0x6(%ebp),%eax +c0101394: 89 c2 mov %eax,%edx +c0101396: ec in (%dx),%al +c0101397: 88 45 f9 mov %al,-0x7(%ebp) return data; -c0101c5e: 0f b6 45 f9 movzbl -0x7(%ebp),%eax +c010139a: 0f b6 45 f9 movzbl -0x7(%ebp),%eax if (!(inb(COM1 + COM_LSR) & COM_LSR_DATA)) { -c0101c62: 0f b6 c0 movzbl %al,%eax -c0101c65: 83 e0 01 and $0x1,%eax -c0101c68: 85 c0 test %eax,%eax -c0101c6a: 75 07 jne c0101c73 +c010139e: 0f b6 c0 movzbl %al,%eax +c01013a1: 83 e0 01 and $0x1,%eax +c01013a4: 85 c0 test %eax,%eax +c01013a6: 75 07 jne c01013af return -1; -c0101c6c: b8 ff ff ff ff mov $0xffffffff,%eax -c0101c71: eb 2a jmp c0101c9d -c0101c73: 66 c7 45 f6 f8 03 movw $0x3f8,-0xa(%ebp) +c01013a8: b8 ff ff ff ff mov $0xffffffff,%eax +c01013ad: eb 2a jmp c01013d9 +c01013af: 66 c7 45 f6 f8 03 movw $0x3f8,-0xa(%ebp) asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); -c0101c79: 0f b7 45 f6 movzwl -0xa(%ebp),%eax -c0101c7d: 89 c2 mov %eax,%edx -c0101c7f: ec in (%dx),%al -c0101c80: 88 45 f5 mov %al,-0xb(%ebp) +c01013b5: 0f b7 45 f6 movzwl -0xa(%ebp),%eax +c01013b9: 89 c2 mov %eax,%edx +c01013bb: ec in (%dx),%al +c01013bc: 88 45 f5 mov %al,-0xb(%ebp) return data; -c0101c83: 0f b6 45 f5 movzbl -0xb(%ebp),%eax +c01013bf: 0f b6 45 f5 movzbl -0xb(%ebp),%eax } int c = inb(COM1 + COM_RX); -c0101c87: 0f b6 c0 movzbl %al,%eax -c0101c8a: 89 45 fc mov %eax,-0x4(%ebp) +c01013c3: 0f b6 c0 movzbl %al,%eax +c01013c6: 89 45 fc mov %eax,-0x4(%ebp) if (c == 127) { -c0101c8d: 83 7d fc 7f cmpl $0x7f,-0x4(%ebp) -c0101c91: 75 07 jne c0101c9a +c01013c9: 83 7d fc 7f cmpl $0x7f,-0x4(%ebp) +c01013cd: 75 07 jne c01013d6 c = '\b'; -c0101c93: c7 45 fc 08 00 00 00 movl $0x8,-0x4(%ebp) +c01013cf: c7 45 fc 08 00 00 00 movl $0x8,-0x4(%ebp) } return c; -c0101c9a: 8b 45 fc mov -0x4(%ebp),%eax +c01013d6: 8b 45 fc mov -0x4(%ebp),%eax } -c0101c9d: c9 leave -c0101c9e: c3 ret +c01013d9: 89 ec mov %ebp,%esp +c01013db: 5d pop %ebp +c01013dc: c3 ret -c0101c9f : +c01013dd : /* serial_intr - try to feed input characters from serial port */ void serial_intr(void) { -c0101c9f: f3 0f 1e fb endbr32 -c0101ca3: 55 push %ebp -c0101ca4: 89 e5 mov %esp,%ebp -c0101ca6: 83 ec 18 sub $0x18,%esp +c01013dd: 55 push %ebp +c01013de: 89 e5 mov %esp,%ebp +c01013e0: 83 ec 18 sub $0x18,%esp if (serial_exists) { -c0101ca9: a1 28 b5 12 c0 mov 0xc012b528,%eax -c0101cae: 85 c0 test %eax,%eax -c0101cb0: 74 0c je c0101cbe +c01013e3: a1 48 b4 12 c0 mov 0xc012b448,%eax +c01013e8: 85 c0 test %eax,%eax +c01013ea: 74 0c je c01013f8 cons_intr(serial_proc_data); -c0101cb2: c7 04 24 44 1c 10 c0 movl $0xc0101c44,(%esp) -c0101cb9: e8 35 ff ff ff call c0101bf3 +c01013ec: c7 04 24 84 13 10 c0 movl $0xc0101384,(%esp) +c01013f3: e8 3d ff ff ff call c0101335 } } -c0101cbe: 90 nop -c0101cbf: c9 leave -c0101cc0: c3 ret +c01013f8: 90 nop +c01013f9: 89 ec mov %ebp,%esp +c01013fb: 5d pop %ebp +c01013fc: c3 ret -c0101cc1 : +c01013fd : * * The kbd_proc_data() function gets data from the keyboard. * If we finish a character, return it, else 0. And return -1 if no data. * */ static int kbd_proc_data(void) { -c0101cc1: f3 0f 1e fb endbr32 -c0101cc5: 55 push %ebp -c0101cc6: 89 e5 mov %esp,%ebp -c0101cc8: 83 ec 38 sub $0x38,%esp -c0101ccb: 66 c7 45 f0 64 00 movw $0x64,-0x10(%ebp) +c01013fd: 55 push %ebp +c01013fe: 89 e5 mov %esp,%ebp +c0101400: 83 ec 38 sub $0x38,%esp +c0101403: 66 c7 45 f0 64 00 movw $0x64,-0x10(%ebp) asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); -c0101cd1: 8b 45 f0 mov -0x10(%ebp),%eax -c0101cd4: 89 c2 mov %eax,%edx -c0101cd6: ec in (%dx),%al -c0101cd7: 88 45 ef mov %al,-0x11(%ebp) +c0101409: 8b 45 f0 mov -0x10(%ebp),%eax +c010140c: 89 c2 mov %eax,%edx +c010140e: ec in (%dx),%al +c010140f: 88 45 ef mov %al,-0x11(%ebp) return data; -c0101cda: 0f b6 45 ef movzbl -0x11(%ebp),%eax +c0101412: 0f b6 45 ef movzbl -0x11(%ebp),%eax int c; uint8_t data; static uint32_t shift; if ((inb(KBSTATP) & KBS_DIB) == 0) { -c0101cde: 0f b6 c0 movzbl %al,%eax -c0101ce1: 83 e0 01 and $0x1,%eax -c0101ce4: 85 c0 test %eax,%eax -c0101ce6: 75 0a jne c0101cf2 +c0101416: 0f b6 c0 movzbl %al,%eax +c0101419: 83 e0 01 and $0x1,%eax +c010141c: 85 c0 test %eax,%eax +c010141e: 75 0a jne c010142a return -1; -c0101ce8: b8 ff ff ff ff mov $0xffffffff,%eax -c0101ced: e9 56 01 00 00 jmp c0101e48 -c0101cf2: 66 c7 45 ec 60 00 movw $0x60,-0x14(%ebp) +c0101420: b8 ff ff ff ff mov $0xffffffff,%eax +c0101425: e9 56 01 00 00 jmp c0101580 +c010142a: 66 c7 45 ec 60 00 movw $0x60,-0x14(%ebp) asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); -c0101cf8: 8b 45 ec mov -0x14(%ebp),%eax -c0101cfb: 89 c2 mov %eax,%edx -c0101cfd: ec in (%dx),%al -c0101cfe: 88 45 eb mov %al,-0x15(%ebp) +c0101430: 8b 45 ec mov -0x14(%ebp),%eax +c0101433: 89 c2 mov %eax,%edx +c0101435: ec in (%dx),%al +c0101436: 88 45 eb mov %al,-0x15(%ebp) return data; -c0101d01: 0f b6 45 eb movzbl -0x15(%ebp),%eax +c0101439: 0f b6 45 eb movzbl -0x15(%ebp),%eax } data = inb(KBDATAP); -c0101d05: 88 45 f3 mov %al,-0xd(%ebp) +c010143d: 88 45 f3 mov %al,-0xd(%ebp) if (data == 0xE0) { -c0101d08: 80 7d f3 e0 cmpb $0xe0,-0xd(%ebp) -c0101d0c: 75 17 jne c0101d25 +c0101440: 80 7d f3 e0 cmpb $0xe0,-0xd(%ebp) +c0101444: 75 17 jne c010145d // E0 escape character shift |= E0ESC; -c0101d0e: a1 48 b7 12 c0 mov 0xc012b748,%eax -c0101d13: 83 c8 40 or $0x40,%eax -c0101d16: a3 48 b7 12 c0 mov %eax,0xc012b748 +c0101446: a1 68 b6 12 c0 mov 0xc012b668,%eax +c010144b: 83 c8 40 or $0x40,%eax +c010144e: a3 68 b6 12 c0 mov %eax,0xc012b668 return 0; -c0101d1b: b8 00 00 00 00 mov $0x0,%eax -c0101d20: e9 23 01 00 00 jmp c0101e48 +c0101453: b8 00 00 00 00 mov $0x0,%eax +c0101458: e9 23 01 00 00 jmp c0101580 } else if (data & 0x80) { -c0101d25: 0f b6 45 f3 movzbl -0xd(%ebp),%eax -c0101d29: 84 c0 test %al,%al -c0101d2b: 79 45 jns c0101d72 +c010145d: 0f b6 45 f3 movzbl -0xd(%ebp),%eax +c0101461: 84 c0 test %al,%al +c0101463: 79 45 jns c01014aa // Key released data = (shift & E0ESC ? data : data & 0x7F); -c0101d2d: a1 48 b7 12 c0 mov 0xc012b748,%eax -c0101d32: 83 e0 40 and $0x40,%eax -c0101d35: 85 c0 test %eax,%eax -c0101d37: 75 08 jne c0101d41 -c0101d39: 0f b6 45 f3 movzbl -0xd(%ebp),%eax -c0101d3d: 24 7f and $0x7f,%al -c0101d3f: eb 04 jmp c0101d45 -c0101d41: 0f b6 45 f3 movzbl -0xd(%ebp),%eax -c0101d45: 88 45 f3 mov %al,-0xd(%ebp) +c0101465: a1 68 b6 12 c0 mov 0xc012b668,%eax +c010146a: 83 e0 40 and $0x40,%eax +c010146d: 85 c0 test %eax,%eax +c010146f: 75 08 jne c0101479 +c0101471: 0f b6 45 f3 movzbl -0xd(%ebp),%eax +c0101475: 24 7f and $0x7f,%al +c0101477: eb 04 jmp c010147d +c0101479: 0f b6 45 f3 movzbl -0xd(%ebp),%eax +c010147d: 88 45 f3 mov %al,-0xd(%ebp) shift &= ~(shiftcode[data] | E0ESC); -c0101d48: 0f b6 45 f3 movzbl -0xd(%ebp),%eax -c0101d4c: 0f b6 80 40 80 12 c0 movzbl -0x3fed7fc0(%eax),%eax -c0101d53: 0c 40 or $0x40,%al -c0101d55: 0f b6 c0 movzbl %al,%eax -c0101d58: f7 d0 not %eax -c0101d5a: 89 c2 mov %eax,%edx -c0101d5c: a1 48 b7 12 c0 mov 0xc012b748,%eax -c0101d61: 21 d0 and %edx,%eax -c0101d63: a3 48 b7 12 c0 mov %eax,0xc012b748 +c0101480: 0f b6 45 f3 movzbl -0xd(%ebp),%eax +c0101484: 0f b6 80 40 80 12 c0 movzbl -0x3fed7fc0(%eax),%eax +c010148b: 0c 40 or $0x40,%al +c010148d: 0f b6 c0 movzbl %al,%eax +c0101490: f7 d0 not %eax +c0101492: 89 c2 mov %eax,%edx +c0101494: a1 68 b6 12 c0 mov 0xc012b668,%eax +c0101499: 21 d0 and %edx,%eax +c010149b: a3 68 b6 12 c0 mov %eax,0xc012b668 return 0; -c0101d68: b8 00 00 00 00 mov $0x0,%eax -c0101d6d: e9 d6 00 00 00 jmp c0101e48 +c01014a0: b8 00 00 00 00 mov $0x0,%eax +c01014a5: e9 d6 00 00 00 jmp c0101580 } else if (shift & E0ESC) { -c0101d72: a1 48 b7 12 c0 mov 0xc012b748,%eax -c0101d77: 83 e0 40 and $0x40,%eax -c0101d7a: 85 c0 test %eax,%eax -c0101d7c: 74 11 je c0101d8f +c01014aa: a1 68 b6 12 c0 mov 0xc012b668,%eax +c01014af: 83 e0 40 and $0x40,%eax +c01014b2: 85 c0 test %eax,%eax +c01014b4: 74 11 je c01014c7 // Last character was an E0 escape; or with 0x80 data |= 0x80; -c0101d7e: 80 4d f3 80 orb $0x80,-0xd(%ebp) +c01014b6: 80 4d f3 80 orb $0x80,-0xd(%ebp) shift &= ~E0ESC; -c0101d82: a1 48 b7 12 c0 mov 0xc012b748,%eax -c0101d87: 83 e0 bf and $0xffffffbf,%eax -c0101d8a: a3 48 b7 12 c0 mov %eax,0xc012b748 +c01014ba: a1 68 b6 12 c0 mov 0xc012b668,%eax +c01014bf: 83 e0 bf and $0xffffffbf,%eax +c01014c2: a3 68 b6 12 c0 mov %eax,0xc012b668 } shift |= shiftcode[data]; -c0101d8f: 0f b6 45 f3 movzbl -0xd(%ebp),%eax -c0101d93: 0f b6 80 40 80 12 c0 movzbl -0x3fed7fc0(%eax),%eax -c0101d9a: 0f b6 d0 movzbl %al,%edx -c0101d9d: a1 48 b7 12 c0 mov 0xc012b748,%eax -c0101da2: 09 d0 or %edx,%eax -c0101da4: a3 48 b7 12 c0 mov %eax,0xc012b748 +c01014c7: 0f b6 45 f3 movzbl -0xd(%ebp),%eax +c01014cb: 0f b6 80 40 80 12 c0 movzbl -0x3fed7fc0(%eax),%eax +c01014d2: 0f b6 d0 movzbl %al,%edx +c01014d5: a1 68 b6 12 c0 mov 0xc012b668,%eax +c01014da: 09 d0 or %edx,%eax +c01014dc: a3 68 b6 12 c0 mov %eax,0xc012b668 shift ^= togglecode[data]; -c0101da9: 0f b6 45 f3 movzbl -0xd(%ebp),%eax -c0101dad: 0f b6 80 40 81 12 c0 movzbl -0x3fed7ec0(%eax),%eax -c0101db4: 0f b6 d0 movzbl %al,%edx -c0101db7: a1 48 b7 12 c0 mov 0xc012b748,%eax -c0101dbc: 31 d0 xor %edx,%eax -c0101dbe: a3 48 b7 12 c0 mov %eax,0xc012b748 +c01014e1: 0f b6 45 f3 movzbl -0xd(%ebp),%eax +c01014e5: 0f b6 80 40 81 12 c0 movzbl -0x3fed7ec0(%eax),%eax +c01014ec: 0f b6 d0 movzbl %al,%edx +c01014ef: a1 68 b6 12 c0 mov 0xc012b668,%eax +c01014f4: 31 d0 xor %edx,%eax +c01014f6: a3 68 b6 12 c0 mov %eax,0xc012b668 c = charcode[shift & (CTL | SHIFT)][data]; -c0101dc3: a1 48 b7 12 c0 mov 0xc012b748,%eax -c0101dc8: 83 e0 03 and $0x3,%eax -c0101dcb: 8b 14 85 40 85 12 c0 mov -0x3fed7ac0(,%eax,4),%edx -c0101dd2: 0f b6 45 f3 movzbl -0xd(%ebp),%eax -c0101dd6: 01 d0 add %edx,%eax -c0101dd8: 0f b6 00 movzbl (%eax),%eax -c0101ddb: 0f b6 c0 movzbl %al,%eax -c0101dde: 89 45 f4 mov %eax,-0xc(%ebp) +c01014fb: a1 68 b6 12 c0 mov 0xc012b668,%eax +c0101500: 83 e0 03 and $0x3,%eax +c0101503: 8b 14 85 40 85 12 c0 mov -0x3fed7ac0(,%eax,4),%edx +c010150a: 0f b6 45 f3 movzbl -0xd(%ebp),%eax +c010150e: 01 d0 add %edx,%eax +c0101510: 0f b6 00 movzbl (%eax),%eax +c0101513: 0f b6 c0 movzbl %al,%eax +c0101516: 89 45 f4 mov %eax,-0xc(%ebp) if (shift & CAPSLOCK) { -c0101de1: a1 48 b7 12 c0 mov 0xc012b748,%eax -c0101de6: 83 e0 08 and $0x8,%eax -c0101de9: 85 c0 test %eax,%eax -c0101deb: 74 22 je c0101e0f +c0101519: a1 68 b6 12 c0 mov 0xc012b668,%eax +c010151e: 83 e0 08 and $0x8,%eax +c0101521: 85 c0 test %eax,%eax +c0101523: 74 22 je c0101547 if ('a' <= c && c <= 'z') -c0101ded: 83 7d f4 60 cmpl $0x60,-0xc(%ebp) -c0101df1: 7e 0c jle c0101dff -c0101df3: 83 7d f4 7a cmpl $0x7a,-0xc(%ebp) -c0101df7: 7f 06 jg c0101dff +c0101525: 83 7d f4 60 cmpl $0x60,-0xc(%ebp) +c0101529: 7e 0c jle c0101537 +c010152b: 83 7d f4 7a cmpl $0x7a,-0xc(%ebp) +c010152f: 7f 06 jg c0101537 c += 'A' - 'a'; -c0101df9: 83 6d f4 20 subl $0x20,-0xc(%ebp) -c0101dfd: eb 10 jmp c0101e0f +c0101531: 83 6d f4 20 subl $0x20,-0xc(%ebp) +c0101535: eb 10 jmp c0101547 else if ('A' <= c && c <= 'Z') -c0101dff: 83 7d f4 40 cmpl $0x40,-0xc(%ebp) -c0101e03: 7e 0a jle c0101e0f -c0101e05: 83 7d f4 5a cmpl $0x5a,-0xc(%ebp) -c0101e09: 7f 04 jg c0101e0f +c0101537: 83 7d f4 40 cmpl $0x40,-0xc(%ebp) +c010153b: 7e 0a jle c0101547 +c010153d: 83 7d f4 5a cmpl $0x5a,-0xc(%ebp) +c0101541: 7f 04 jg c0101547 c += 'a' - 'A'; -c0101e0b: 83 45 f4 20 addl $0x20,-0xc(%ebp) +c0101543: 83 45 f4 20 addl $0x20,-0xc(%ebp) } // Process special keys // Ctrl-Alt-Del: reboot if (!(~shift & (CTL | ALT)) && c == KEY_DEL) { -c0101e0f: a1 48 b7 12 c0 mov 0xc012b748,%eax -c0101e14: f7 d0 not %eax -c0101e16: 83 e0 06 and $0x6,%eax -c0101e19: 85 c0 test %eax,%eax -c0101e1b: 75 28 jne c0101e45 -c0101e1d: 81 7d f4 e9 00 00 00 cmpl $0xe9,-0xc(%ebp) -c0101e24: 75 1f jne c0101e45 +c0101547: a1 68 b6 12 c0 mov 0xc012b668,%eax +c010154c: f7 d0 not %eax +c010154e: 83 e0 06 and $0x6,%eax +c0101551: 85 c0 test %eax,%eax +c0101553: 75 28 jne c010157d +c0101555: 81 7d f4 e9 00 00 00 cmpl $0xe9,-0xc(%ebp) +c010155c: 75 1f jne c010157d cprintf("Rebooting!\n"); -c0101e26: c7 04 24 99 a6 10 c0 movl $0xc010a699,(%esp) -c0101e2d: e8 a5 e4 ff ff call c01002d7 -c0101e32: 66 c7 45 e8 92 00 movw $0x92,-0x18(%ebp) -c0101e38: c6 45 e7 03 movb $0x3,-0x19(%ebp) +c010155e: c7 04 24 87 a3 10 c0 movl $0xc010a387,(%esp) +c0101565: e8 0e ee ff ff call c0100378 +c010156a: 66 c7 45 e8 92 00 movw $0x92,-0x18(%ebp) +c0101570: c6 45 e7 03 movb $0x3,-0x19(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101e3c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax -c0101e40: 8b 55 e8 mov -0x18(%ebp),%edx -c0101e43: ee out %al,(%dx) +c0101574: 0f b6 45 e7 movzbl -0x19(%ebp),%eax +c0101578: 8b 55 e8 mov -0x18(%ebp),%edx +c010157b: ee out %al,(%dx) } -c0101e44: 90 nop +c010157c: 90 nop outb(0x92, 0x3); // courtesy of Chris Frost } return c; -c0101e45: 8b 45 f4 mov -0xc(%ebp),%eax +c010157d: 8b 45 f4 mov -0xc(%ebp),%eax } -c0101e48: c9 leave -c0101e49: c3 ret +c0101580: 89 ec mov %ebp,%esp +c0101582: 5d pop %ebp +c0101583: c3 ret -c0101e4a : +c0101584 : /* kbd_intr - try to feed input characters from keyboard */ static void kbd_intr(void) { -c0101e4a: f3 0f 1e fb endbr32 -c0101e4e: 55 push %ebp -c0101e4f: 89 e5 mov %esp,%ebp -c0101e51: 83 ec 18 sub $0x18,%esp +c0101584: 55 push %ebp +c0101585: 89 e5 mov %esp,%ebp +c0101587: 83 ec 18 sub $0x18,%esp cons_intr(kbd_proc_data); -c0101e54: c7 04 24 c1 1c 10 c0 movl $0xc0101cc1,(%esp) -c0101e5b: e8 93 fd ff ff call c0101bf3 +c010158a: c7 04 24 fd 13 10 c0 movl $0xc01013fd,(%esp) +c0101591: e8 9f fd ff ff call c0101335 } -c0101e60: 90 nop -c0101e61: c9 leave -c0101e62: c3 ret +c0101596: 90 nop +c0101597: 89 ec mov %ebp,%esp +c0101599: 5d pop %ebp +c010159a: c3 ret -c0101e63 : +c010159b : static void kbd_init(void) { -c0101e63: f3 0f 1e fb endbr32 -c0101e67: 55 push %ebp -c0101e68: 89 e5 mov %esp,%ebp -c0101e6a: 83 ec 18 sub $0x18,%esp +c010159b: 55 push %ebp +c010159c: 89 e5 mov %esp,%ebp +c010159e: 83 ec 18 sub $0x18,%esp // drain the kbd buffer kbd_intr(); -c0101e6d: e8 d8 ff ff ff call c0101e4a +c01015a1: e8 de ff ff ff call c0101584 pic_enable(IRQ_KBD); -c0101e72: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0101e79: e8 47 01 00 00 call c0101fc5 +c01015a6: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c01015ad: e8 ae 09 00 00 call c0101f60 } -c0101e7e: 90 nop -c0101e7f: c9 leave -c0101e80: c3 ret +c01015b2: 90 nop +c01015b3: 89 ec mov %ebp,%esp +c01015b5: 5d pop %ebp +c01015b6: c3 ret -c0101e81 : +c01015b7 : /* cons_init - initializes the console devices */ void cons_init(void) { -c0101e81: f3 0f 1e fb endbr32 -c0101e85: 55 push %ebp -c0101e86: 89 e5 mov %esp,%ebp -c0101e88: 83 ec 18 sub $0x18,%esp +c01015b7: 55 push %ebp +c01015b8: 89 e5 mov %esp,%ebp +c01015ba: 83 ec 18 sub $0x18,%esp cga_init(); -c0101e8b: e8 2e f8 ff ff call c01016be +c01015bd: e8 4a f8 ff ff call c0100e0c serial_init(); -c0101e90: e8 13 f9 ff ff call c01017a8 +c01015c2: e8 2d f9 ff ff call c0100ef4 kbd_init(); -c0101e95: e8 c9 ff ff ff call c0101e63 +c01015c7: e8 cf ff ff ff call c010159b if (!serial_exists) { -c0101e9a: a1 28 b5 12 c0 mov 0xc012b528,%eax -c0101e9f: 85 c0 test %eax,%eax -c0101ea1: 75 0c jne c0101eaf +c01015cc: a1 48 b4 12 c0 mov 0xc012b448,%eax +c01015d1: 85 c0 test %eax,%eax +c01015d3: 75 0c jne c01015e1 cprintf("serial port does not exist!!\n"); -c0101ea3: c7 04 24 a5 a6 10 c0 movl $0xc010a6a5,(%esp) -c0101eaa: e8 28 e4 ff ff call c01002d7 +c01015d5: c7 04 24 93 a3 10 c0 movl $0xc010a393,(%esp) +c01015dc: e8 97 ed ff ff call c0100378 } } -c0101eaf: 90 nop -c0101eb0: c9 leave -c0101eb1: c3 ret +c01015e1: 90 nop +c01015e2: 89 ec mov %ebp,%esp +c01015e4: 5d pop %ebp +c01015e5: c3 ret -c0101eb2 : +c01015e6 : /* cons_putc - print a single character @c to console devices */ void cons_putc(int c) { -c0101eb2: f3 0f 1e fb endbr32 -c0101eb6: 55 push %ebp -c0101eb7: 89 e5 mov %esp,%ebp -c0101eb9: 83 ec 28 sub $0x28,%esp +c01015e6: 55 push %ebp +c01015e7: 89 e5 mov %esp,%ebp +c01015e9: 83 ec 28 sub $0x28,%esp bool intr_flag; local_intr_save(intr_flag); -c0101ebc: e8 72 f7 ff ff call c0101633 <__intr_save> -c0101ec1: 89 45 f4 mov %eax,-0xc(%ebp) +c01015ec: e8 8e f7 ff ff call c0100d7f <__intr_save> +c01015f1: 89 45 f4 mov %eax,-0xc(%ebp) { lpt_putc(c); -c0101ec4: 8b 45 08 mov 0x8(%ebp),%eax -c0101ec7: 89 04 24 mov %eax,(%esp) -c0101eca: e8 48 fa ff ff call c0101917 +c01015f4: 8b 45 08 mov 0x8(%ebp),%eax +c01015f7: 89 04 24 mov %eax,(%esp) +c01015fa: e8 60 fa ff ff call c010105f cga_putc(c); -c0101ecf: 8b 45 08 mov 0x8(%ebp),%eax -c0101ed2: 89 04 24 mov %eax,(%esp) -c0101ed5: e8 81 fa ff ff call c010195b +c01015ff: 8b 45 08 mov 0x8(%ebp),%eax +c0101602: 89 04 24 mov %eax,(%esp) +c0101605: e8 97 fa ff ff call c01010a1 serial_putc(c); -c0101eda: 8b 45 08 mov 0x8(%ebp),%eax -c0101edd: 89 04 24 mov %eax,(%esp) -c0101ee0: e8 ca fc ff ff call c0101baf +c010160a: 8b 45 08 mov 0x8(%ebp),%eax +c010160d: 89 04 24 mov %eax,(%esp) +c0101610: e8 de fc ff ff call c01012f3 } local_intr_restore(intr_flag); -c0101ee5: 8b 45 f4 mov -0xc(%ebp),%eax -c0101ee8: 89 04 24 mov %eax,(%esp) -c0101eeb: e8 6d f7 ff ff call c010165d <__intr_restore> +c0101615: 8b 45 f4 mov -0xc(%ebp),%eax +c0101618: 89 04 24 mov %eax,(%esp) +c010161b: e8 8b f7 ff ff call c0100dab <__intr_restore> } -c0101ef0: 90 nop -c0101ef1: c9 leave -c0101ef2: c3 ret +c0101620: 90 nop +c0101621: 89 ec mov %ebp,%esp +c0101623: 5d pop %ebp +c0101624: c3 ret -c0101ef3 : +c0101625 : /* * * cons_getc - return the next input character from console, * or 0 if none waiting. * */ int cons_getc(void) { -c0101ef3: f3 0f 1e fb endbr32 -c0101ef7: 55 push %ebp -c0101ef8: 89 e5 mov %esp,%ebp -c0101efa: 83 ec 28 sub $0x28,%esp +c0101625: 55 push %ebp +c0101626: 89 e5 mov %esp,%ebp +c0101628: 83 ec 28 sub $0x28,%esp int c = 0; -c0101efd: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c010162b: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) bool intr_flag; local_intr_save(intr_flag); -c0101f04: e8 2a f7 ff ff call c0101633 <__intr_save> -c0101f09: 89 45 f0 mov %eax,-0x10(%ebp) +c0101632: e8 48 f7 ff ff call c0100d7f <__intr_save> +c0101637: 89 45 f0 mov %eax,-0x10(%ebp) { // poll for any pending input characters, // so that this function works even when interrupts are disabled // (e.g., when called from the kernel monitor). serial_intr(); -c0101f0c: e8 8e fd ff ff call c0101c9f +c010163a: e8 9e fd ff ff call c01013dd kbd_intr(); -c0101f11: e8 34 ff ff ff call c0101e4a +c010163f: e8 40 ff ff ff call c0101584 // grab the next character from the input buffer. if (cons.rpos != cons.wpos) { -c0101f16: 8b 15 40 b7 12 c0 mov 0xc012b740,%edx -c0101f1c: a1 44 b7 12 c0 mov 0xc012b744,%eax -c0101f21: 39 c2 cmp %eax,%edx -c0101f23: 74 31 je c0101f56 +c0101644: 8b 15 60 b6 12 c0 mov 0xc012b660,%edx +c010164a: a1 64 b6 12 c0 mov 0xc012b664,%eax +c010164f: 39 c2 cmp %eax,%edx +c0101651: 74 31 je c0101684 c = cons.buf[cons.rpos ++]; -c0101f25: a1 40 b7 12 c0 mov 0xc012b740,%eax -c0101f2a: 8d 50 01 lea 0x1(%eax),%edx -c0101f2d: 89 15 40 b7 12 c0 mov %edx,0xc012b740 -c0101f33: 0f b6 80 40 b5 12 c0 movzbl -0x3fed4ac0(%eax),%eax -c0101f3a: 0f b6 c0 movzbl %al,%eax -c0101f3d: 89 45 f4 mov %eax,-0xc(%ebp) +c0101653: a1 60 b6 12 c0 mov 0xc012b660,%eax +c0101658: 8d 50 01 lea 0x1(%eax),%edx +c010165b: 89 15 60 b6 12 c0 mov %edx,0xc012b660 +c0101661: 0f b6 80 60 b4 12 c0 movzbl -0x3fed4ba0(%eax),%eax +c0101668: 0f b6 c0 movzbl %al,%eax +c010166b: 89 45 f4 mov %eax,-0xc(%ebp) if (cons.rpos == CONSBUFSIZE) { -c0101f40: a1 40 b7 12 c0 mov 0xc012b740,%eax -c0101f45: 3d 00 02 00 00 cmp $0x200,%eax -c0101f4a: 75 0a jne c0101f56 +c010166e: a1 60 b6 12 c0 mov 0xc012b660,%eax +c0101673: 3d 00 02 00 00 cmp $0x200,%eax +c0101678: 75 0a jne c0101684 cons.rpos = 0; -c0101f4c: c7 05 40 b7 12 c0 00 movl $0x0,0xc012b740 -c0101f53: 00 00 00 +c010167a: c7 05 60 b6 12 c0 00 movl $0x0,0xc012b660 +c0101681: 00 00 00 } } } local_intr_restore(intr_flag); -c0101f56: 8b 45 f0 mov -0x10(%ebp),%eax -c0101f59: 89 04 24 mov %eax,(%esp) -c0101f5c: e8 fc f6 ff ff call c010165d <__intr_restore> +c0101684: 8b 45 f0 mov -0x10(%ebp),%eax +c0101687: 89 04 24 mov %eax,(%esp) +c010168a: e8 1c f7 ff ff call c0100dab <__intr_restore> return c; -c0101f61: 8b 45 f4 mov -0xc(%ebp),%eax +c010168f: 8b 45 f4 mov -0xc(%ebp),%eax } -c0101f64: c9 leave -c0101f65: c3 ret +c0101692: 89 ec mov %ebp,%esp +c0101694: 5d pop %ebp +c0101695: c3 ret -c0101f66 : -// Initial IRQ mask has interrupt 2 enabled (for slave 8259A). -static uint16_t irq_mask = 0xFFFF & ~(1 << IRQ_SLAVE); -static bool did_init = 0; +c0101696 : + unsigned int size; // Size in Sectors + unsigned char model[41]; // Model in String +} ide_devices[MAX_IDE]; -static void -pic_setmask(uint16_t mask) { -c0101f66: f3 0f 1e fb endbr32 -c0101f6a: 55 push %ebp -c0101f6b: 89 e5 mov %esp,%ebp -c0101f6d: 83 ec 14 sub $0x14,%esp -c0101f70: 8b 45 08 mov 0x8(%ebp),%eax -c0101f73: 66 89 45 ec mov %ax,-0x14(%ebp) - irq_mask = mask; -c0101f77: 8b 45 ec mov -0x14(%ebp),%eax -c0101f7a: 66 a3 50 85 12 c0 mov %ax,0xc0128550 - if (did_init) { -c0101f80: a1 4c b7 12 c0 mov 0xc012b74c,%eax -c0101f85: 85 c0 test %eax,%eax -c0101f87: 74 39 je c0101fc2 - outb(IO_PIC1 + 1, mask); -c0101f89: 8b 45 ec mov -0x14(%ebp),%eax -c0101f8c: 0f b6 c0 movzbl %al,%eax -c0101f8f: 66 c7 45 fa 21 00 movw $0x21,-0x6(%ebp) -c0101f95: 88 45 f9 mov %al,-0x7(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101f98: 0f b6 45 f9 movzbl -0x7(%ebp),%eax -c0101f9c: 0f b7 55 fa movzwl -0x6(%ebp),%edx -c0101fa0: ee out %al,(%dx) -} -c0101fa1: 90 nop - outb(IO_PIC2 + 1, mask >> 8); -c0101fa2: 0f b7 45 ec movzwl -0x14(%ebp),%eax -c0101fa6: c1 e8 08 shr $0x8,%eax -c0101fa9: 0f b7 c0 movzwl %ax,%eax -c0101fac: 0f b6 c0 movzbl %al,%eax -c0101faf: 66 c7 45 fe a1 00 movw $0xa1,-0x2(%ebp) -c0101fb5: 88 45 fd mov %al,-0x3(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0101fb8: 0f b6 45 fd movzbl -0x3(%ebp),%eax -c0101fbc: 0f b7 55 fe movzwl -0x2(%ebp),%edx -c0101fc0: ee out %al,(%dx) -} -c0101fc1: 90 nop +static int +ide_wait_ready(unsigned short iobase, bool check_error) { +c0101696: 55 push %ebp +c0101697: 89 e5 mov %esp,%ebp +c0101699: 83 ec 14 sub $0x14,%esp +c010169c: 8b 45 08 mov 0x8(%ebp),%eax +c010169f: 66 89 45 ec mov %ax,-0x14(%ebp) + int r; + while ((r = inb(iobase + ISA_STATUS)) & IDE_BSY) +c01016a3: 90 nop +c01016a4: 8b 45 ec mov -0x14(%ebp),%eax +c01016a7: 83 c0 07 add $0x7,%eax +c01016aa: 0f b7 c0 movzwl %ax,%eax +c01016ad: 66 89 45 fa mov %ax,-0x6(%ebp) + asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); +c01016b1: 0f b7 45 fa movzwl -0x6(%ebp),%eax +c01016b5: 89 c2 mov %eax,%edx +c01016b7: ec in (%dx),%al +c01016b8: 88 45 f9 mov %al,-0x7(%ebp) + return data; +c01016bb: 0f b6 45 f9 movzbl -0x7(%ebp),%eax +c01016bf: 0f b6 c0 movzbl %al,%eax +c01016c2: 89 45 fc mov %eax,-0x4(%ebp) +c01016c5: 8b 45 fc mov -0x4(%ebp),%eax +c01016c8: 25 80 00 00 00 and $0x80,%eax +c01016cd: 85 c0 test %eax,%eax +c01016cf: 75 d3 jne c01016a4 + /* nothing */; + if (check_error && (r & (IDE_DF | IDE_ERR)) != 0) { +c01016d1: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) +c01016d5: 74 11 je c01016e8 +c01016d7: 8b 45 fc mov -0x4(%ebp),%eax +c01016da: 83 e0 21 and $0x21,%eax +c01016dd: 85 c0 test %eax,%eax +c01016df: 74 07 je c01016e8 + return -1; +c01016e1: b8 ff ff ff ff mov $0xffffffff,%eax +c01016e6: eb 05 jmp c01016ed } + return 0; +c01016e8: b8 00 00 00 00 mov $0x0,%eax } -c0101fc2: 90 nop -c0101fc3: c9 leave -c0101fc4: c3 ret +c01016ed: 89 ec mov %ebp,%esp +c01016ef: 5d pop %ebp +c01016f0: c3 ret -c0101fc5 : +c01016f1 : void -pic_enable(unsigned int irq) { -c0101fc5: f3 0f 1e fb endbr32 -c0101fc9: 55 push %ebp -c0101fca: 89 e5 mov %esp,%ebp -c0101fcc: 83 ec 04 sub $0x4,%esp - pic_setmask(irq_mask & ~(1 << irq)); -c0101fcf: 8b 45 08 mov 0x8(%ebp),%eax -c0101fd2: ba 01 00 00 00 mov $0x1,%edx -c0101fd7: 88 c1 mov %al,%cl -c0101fd9: d3 e2 shl %cl,%edx -c0101fdb: 89 d0 mov %edx,%eax -c0101fdd: 98 cwtl -c0101fde: f7 d0 not %eax -c0101fe0: 0f bf d0 movswl %ax,%edx -c0101fe3: 0f b7 05 50 85 12 c0 movzwl 0xc0128550,%eax -c0101fea: 98 cwtl -c0101feb: 21 d0 and %edx,%eax -c0101fed: 98 cwtl -c0101fee: 0f b7 c0 movzwl %ax,%eax -c0101ff1: 89 04 24 mov %eax,(%esp) -c0101ff4: e8 6d ff ff ff call c0101f66 -} -c0101ff9: 90 nop -c0101ffa: c9 leave -c0101ffb: c3 ret - -c0101ffc : +ide_init(void) { +c01016f1: 55 push %ebp +c01016f2: 89 e5 mov %esp,%ebp +c01016f4: 57 push %edi +c01016f5: 53 push %ebx +c01016f6: 81 ec 50 02 00 00 sub $0x250,%esp + static_assert((SECTSIZE % 4) == 0); + unsigned short ideno, iobase; + for (ideno = 0; ideno < MAX_IDE; ideno ++) { +c01016fc: 66 c7 45 f6 00 00 movw $0x0,-0xa(%ebp) +c0101702: e9 bd 02 00 00 jmp c01019c4 + /* assume that no device here */ + ide_devices[ideno].valid = 0; +c0101707: 0f b7 55 f6 movzwl -0xa(%ebp),%edx +c010170b: 89 d0 mov %edx,%eax +c010170d: c1 e0 03 shl $0x3,%eax +c0101710: 29 d0 sub %edx,%eax +c0101712: c1 e0 03 shl $0x3,%eax +c0101715: 05 80 b6 12 c0 add $0xc012b680,%eax +c010171a: c6 00 00 movb $0x0,(%eax) -/* pic_init - initialize the 8259A interrupt controllers */ -void -pic_init(void) { -c0101ffc: f3 0f 1e fb endbr32 -c0102000: 55 push %ebp -c0102001: 89 e5 mov %esp,%ebp -c0102003: 83 ec 44 sub $0x44,%esp - did_init = 1; -c0102006: c7 05 4c b7 12 c0 01 movl $0x1,0xc012b74c -c010200d: 00 00 00 -c0102010: 66 c7 45 ca 21 00 movw $0x21,-0x36(%ebp) -c0102016: c6 45 c9 ff movb $0xff,-0x37(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010201a: 0f b6 45 c9 movzbl -0x37(%ebp),%eax -c010201e: 0f b7 55 ca movzwl -0x36(%ebp),%edx -c0102022: ee out %al,(%dx) -} -c0102023: 90 nop -c0102024: 66 c7 45 ce a1 00 movw $0xa1,-0x32(%ebp) -c010202a: c6 45 cd ff movb $0xff,-0x33(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010202e: 0f b6 45 cd movzbl -0x33(%ebp),%eax -c0102032: 0f b7 55 ce movzwl -0x32(%ebp),%edx -c0102036: ee out %al,(%dx) -} -c0102037: 90 nop -c0102038: 66 c7 45 d2 20 00 movw $0x20,-0x2e(%ebp) -c010203e: c6 45 d1 11 movb $0x11,-0x2f(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0102042: 0f b6 45 d1 movzbl -0x2f(%ebp),%eax -c0102046: 0f b7 55 d2 movzwl -0x2e(%ebp),%edx -c010204a: ee out %al,(%dx) -} -c010204b: 90 nop -c010204c: 66 c7 45 d6 21 00 movw $0x21,-0x2a(%ebp) -c0102052: c6 45 d5 20 movb $0x20,-0x2b(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0102056: 0f b6 45 d5 movzbl -0x2b(%ebp),%eax -c010205a: 0f b7 55 d6 movzwl -0x2a(%ebp),%edx -c010205e: ee out %al,(%dx) -} -c010205f: 90 nop -c0102060: 66 c7 45 da 21 00 movw $0x21,-0x26(%ebp) -c0102066: c6 45 d9 04 movb $0x4,-0x27(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010206a: 0f b6 45 d9 movzbl -0x27(%ebp),%eax -c010206e: 0f b7 55 da movzwl -0x26(%ebp),%edx -c0102072: ee out %al,(%dx) -} -c0102073: 90 nop -c0102074: 66 c7 45 de 21 00 movw $0x21,-0x22(%ebp) -c010207a: c6 45 dd 03 movb $0x3,-0x23(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010207e: 0f b6 45 dd movzbl -0x23(%ebp),%eax -c0102082: 0f b7 55 de movzwl -0x22(%ebp),%edx -c0102086: ee out %al,(%dx) -} -c0102087: 90 nop -c0102088: 66 c7 45 e2 a0 00 movw $0xa0,-0x1e(%ebp) -c010208e: c6 45 e1 11 movb $0x11,-0x1f(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c0102092: 0f b6 45 e1 movzbl -0x1f(%ebp),%eax -c0102096: 0f b7 55 e2 movzwl -0x1e(%ebp),%edx -c010209a: ee out %al,(%dx) -} -c010209b: 90 nop -c010209c: 66 c7 45 e6 a1 00 movw $0xa1,-0x1a(%ebp) -c01020a2: c6 45 e5 28 movb $0x28,-0x1b(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01020a6: 0f b6 45 e5 movzbl -0x1b(%ebp),%eax -c01020aa: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx -c01020ae: ee out %al,(%dx) -} -c01020af: 90 nop -c01020b0: 66 c7 45 ea a1 00 movw $0xa1,-0x16(%ebp) -c01020b6: c6 45 e9 02 movb $0x2,-0x17(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01020ba: 0f b6 45 e9 movzbl -0x17(%ebp),%eax -c01020be: 0f b7 55 ea movzwl -0x16(%ebp),%edx -c01020c2: ee out %al,(%dx) -} -c01020c3: 90 nop -c01020c4: 66 c7 45 ee a1 00 movw $0xa1,-0x12(%ebp) -c01020ca: c6 45 ed 03 movb $0x3,-0x13(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01020ce: 0f b6 45 ed movzbl -0x13(%ebp),%eax -c01020d2: 0f b7 55 ee movzwl -0x12(%ebp),%edx -c01020d6: ee out %al,(%dx) -} -c01020d7: 90 nop -c01020d8: 66 c7 45 f2 20 00 movw $0x20,-0xe(%ebp) -c01020de: c6 45 f1 68 movb $0x68,-0xf(%ebp) - asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01020e2: 0f b6 45 f1 movzbl -0xf(%ebp),%eax -c01020e6: 0f b7 55 f2 movzwl -0xe(%ebp),%edx -c01020ea: ee out %al,(%dx) -} -c01020eb: 90 nop -c01020ec: 66 c7 45 f6 20 00 movw $0x20,-0xa(%ebp) -c01020f2: c6 45 f5 0a movb $0xa,-0xb(%ebp) + iobase = IO_BASE(ideno); +c010171d: 0f b7 45 f6 movzwl -0xa(%ebp),%eax +c0101721: d1 e8 shr %eax +c0101723: 0f b7 c0 movzwl %ax,%eax +c0101726: 8b 04 85 b4 a3 10 c0 mov -0x3fef5c4c(,%eax,4),%eax +c010172d: 66 89 45 ea mov %ax,-0x16(%ebp) + + /* wait device ready */ + ide_wait_ready(iobase, 0); +c0101731: 0f b7 45 ea movzwl -0x16(%ebp),%eax +c0101735: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c010173c: 00 +c010173d: 89 04 24 mov %eax,(%esp) +c0101740: e8 51 ff ff ff call c0101696 + + /* step1: select drive */ + outb(iobase + ISA_SDH, 0xE0 | ((ideno & 1) << 4)); +c0101745: 0f b7 45 f6 movzwl -0xa(%ebp),%eax +c0101749: c1 e0 04 shl $0x4,%eax +c010174c: 24 10 and $0x10,%al +c010174e: 0c e0 or $0xe0,%al +c0101750: 0f b6 c0 movzbl %al,%eax +c0101753: 0f b7 55 ea movzwl -0x16(%ebp),%edx +c0101757: 83 c2 06 add $0x6,%edx +c010175a: 0f b7 d2 movzwl %dx,%edx +c010175d: 66 89 55 ca mov %dx,-0x36(%ebp) +c0101761: 88 45 c9 mov %al,-0x37(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c01020f6: 0f b6 45 f5 movzbl -0xb(%ebp),%eax -c01020fa: 0f b7 55 f6 movzwl -0xa(%ebp),%edx -c01020fe: ee out %al,(%dx) +c0101764: 0f b6 45 c9 movzbl -0x37(%ebp),%eax +c0101768: 0f b7 55 ca movzwl -0x36(%ebp),%edx +c010176c: ee out %al,(%dx) } -c01020ff: 90 nop -c0102100: 66 c7 45 fa a0 00 movw $0xa0,-0x6(%ebp) -c0102106: c6 45 f9 68 movb $0x68,-0x7(%ebp) +c010176d: 90 nop + ide_wait_ready(iobase, 0); +c010176e: 0f b7 45 ea movzwl -0x16(%ebp),%eax +c0101772: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0101779: 00 +c010177a: 89 04 24 mov %eax,(%esp) +c010177d: e8 14 ff ff ff call c0101696 + + /* step2: send ATA identify command */ + outb(iobase + ISA_COMMAND, IDE_CMD_IDENTIFY); +c0101782: 0f b7 45 ea movzwl -0x16(%ebp),%eax +c0101786: 83 c0 07 add $0x7,%eax +c0101789: 0f b7 c0 movzwl %ax,%eax +c010178c: 66 89 45 ce mov %ax,-0x32(%ebp) +c0101790: c6 45 cd ec movb $0xec,-0x33(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010210a: 0f b6 45 f9 movzbl -0x7(%ebp),%eax -c010210e: 0f b7 55 fa movzwl -0x6(%ebp),%edx -c0102112: ee out %al,(%dx) +c0101794: 0f b6 45 cd movzbl -0x33(%ebp),%eax +c0101798: 0f b7 55 ce movzwl -0x32(%ebp),%edx +c010179c: ee out %al,(%dx) } -c0102113: 90 nop -c0102114: 66 c7 45 fe a0 00 movw $0xa0,-0x2(%ebp) -c010211a: c6 45 fd 0a movb $0xa,-0x3(%ebp) +c010179d: 90 nop + ide_wait_ready(iobase, 0); +c010179e: 0f b7 45 ea movzwl -0x16(%ebp),%eax +c01017a2: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c01017a9: 00 +c01017aa: 89 04 24 mov %eax,(%esp) +c01017ad: e8 e4 fe ff ff call c0101696 + + /* step3: polling */ + if (inb(iobase + ISA_STATUS) == 0 || ide_wait_ready(iobase, 1) != 0) { +c01017b2: 0f b7 45 ea movzwl -0x16(%ebp),%eax +c01017b6: 83 c0 07 add $0x7,%eax +c01017b9: 0f b7 c0 movzwl %ax,%eax +c01017bc: 66 89 45 d2 mov %ax,-0x2e(%ebp) + asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory"); +c01017c0: 0f b7 45 d2 movzwl -0x2e(%ebp),%eax +c01017c4: 89 c2 mov %eax,%edx +c01017c6: ec in (%dx),%al +c01017c7: 88 45 d1 mov %al,-0x2f(%ebp) + return data; +c01017ca: 0f b6 45 d1 movzbl -0x2f(%ebp),%eax +c01017ce: 84 c0 test %al,%al +c01017d0: 0f 84 e4 01 00 00 je c01019ba +c01017d6: 0f b7 45 ea movzwl -0x16(%ebp),%eax +c01017da: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c01017e1: 00 +c01017e2: 89 04 24 mov %eax,(%esp) +c01017e5: e8 ac fe ff ff call c0101696 +c01017ea: 85 c0 test %eax,%eax +c01017ec: 0f 85 c8 01 00 00 jne c01019ba + continue ; + } + + /* device is ok */ + ide_devices[ideno].valid = 1; +c01017f2: 0f b7 55 f6 movzwl -0xa(%ebp),%edx +c01017f6: 89 d0 mov %edx,%eax +c01017f8: c1 e0 03 shl $0x3,%eax +c01017fb: 29 d0 sub %edx,%eax +c01017fd: c1 e0 03 shl $0x3,%eax +c0101800: 05 80 b6 12 c0 add $0xc012b680,%eax +c0101805: c6 00 01 movb $0x1,(%eax) + + /* read identification space of the device */ + unsigned int buffer[128]; + insl(iobase + ISA_DATA, buffer, sizeof(buffer) / sizeof(unsigned int)); +c0101808: 0f b7 45 ea movzwl -0x16(%ebp),%eax +c010180c: 89 45 c4 mov %eax,-0x3c(%ebp) +c010180f: 8d 85 bc fd ff ff lea -0x244(%ebp),%eax +c0101815: 89 45 c0 mov %eax,-0x40(%ebp) +c0101818: c7 45 bc 80 00 00 00 movl $0x80,-0x44(%ebp) + asm volatile ( +c010181f: 8b 55 c4 mov -0x3c(%ebp),%edx +c0101822: 8b 4d c0 mov -0x40(%ebp),%ecx +c0101825: 8b 45 bc mov -0x44(%ebp),%eax +c0101828: 89 cb mov %ecx,%ebx +c010182a: 89 df mov %ebx,%edi +c010182c: 89 c1 mov %eax,%ecx +c010182e: fc cld +c010182f: f2 6d repnz insl (%dx),%es:(%edi) +c0101831: 89 c8 mov %ecx,%eax +c0101833: 89 fb mov %edi,%ebx +c0101835: 89 5d c0 mov %ebx,-0x40(%ebp) +c0101838: 89 45 bc mov %eax,-0x44(%ebp) +} +c010183b: 90 nop + + unsigned char *ident = (unsigned char *)buffer; +c010183c: 8d 85 bc fd ff ff lea -0x244(%ebp),%eax +c0101842: 89 45 e4 mov %eax,-0x1c(%ebp) + unsigned int sectors; + unsigned int cmdsets = *(unsigned int *)(ident + IDE_IDENT_CMDSETS); +c0101845: 8b 45 e4 mov -0x1c(%ebp),%eax +c0101848: 8b 80 a4 00 00 00 mov 0xa4(%eax),%eax +c010184e: 89 45 e0 mov %eax,-0x20(%ebp) + /* device use 48-bits or 28-bits addressing */ + if (cmdsets & (1 << 26)) { +c0101851: 8b 45 e0 mov -0x20(%ebp),%eax +c0101854: 25 00 00 00 04 and $0x4000000,%eax +c0101859: 85 c0 test %eax,%eax +c010185b: 74 0e je c010186b + sectors = *(unsigned int *)(ident + IDE_IDENT_MAX_LBA_EXT); +c010185d: 8b 45 e4 mov -0x1c(%ebp),%eax +c0101860: 8b 80 c8 00 00 00 mov 0xc8(%eax),%eax +c0101866: 89 45 f0 mov %eax,-0x10(%ebp) +c0101869: eb 09 jmp c0101874 + } + else { + sectors = *(unsigned int *)(ident + IDE_IDENT_MAX_LBA); +c010186b: 8b 45 e4 mov -0x1c(%ebp),%eax +c010186e: 8b 40 78 mov 0x78(%eax),%eax +c0101871: 89 45 f0 mov %eax,-0x10(%ebp) + } + ide_devices[ideno].sets = cmdsets; +c0101874: 0f b7 55 f6 movzwl -0xa(%ebp),%edx +c0101878: 89 d0 mov %edx,%eax +c010187a: c1 e0 03 shl $0x3,%eax +c010187d: 29 d0 sub %edx,%eax +c010187f: c1 e0 03 shl $0x3,%eax +c0101882: 8d 90 84 b6 12 c0 lea -0x3fed497c(%eax),%edx +c0101888: 8b 45 e0 mov -0x20(%ebp),%eax +c010188b: 89 02 mov %eax,(%edx) + ide_devices[ideno].size = sectors; +c010188d: 0f b7 55 f6 movzwl -0xa(%ebp),%edx +c0101891: 89 d0 mov %edx,%eax +c0101893: c1 e0 03 shl $0x3,%eax +c0101896: 29 d0 sub %edx,%eax +c0101898: c1 e0 03 shl $0x3,%eax +c010189b: 8d 90 88 b6 12 c0 lea -0x3fed4978(%eax),%edx +c01018a1: 8b 45 f0 mov -0x10(%ebp),%eax +c01018a4: 89 02 mov %eax,(%edx) + + /* check if supports LBA */ + assert((*(unsigned short *)(ident + IDE_IDENT_CAPABILITIES) & 0x200) != 0); +c01018a6: 8b 45 e4 mov -0x1c(%ebp),%eax +c01018a9: 83 c0 62 add $0x62,%eax +c01018ac: 0f b7 00 movzwl (%eax),%eax +c01018af: 25 00 02 00 00 and $0x200,%eax +c01018b4: 85 c0 test %eax,%eax +c01018b6: 75 24 jne c01018dc +c01018b8: c7 44 24 0c bc a3 10 movl $0xc010a3bc,0xc(%esp) +c01018bf: c0 +c01018c0: c7 44 24 08 ff a3 10 movl $0xc010a3ff,0x8(%esp) +c01018c7: c0 +c01018c8: c7 44 24 04 7d 00 00 movl $0x7d,0x4(%esp) +c01018cf: 00 +c01018d0: c7 04 24 14 a4 10 c0 movl $0xc010a414,(%esp) +c01018d7: e8 69 f3 ff ff call c0100c45 <__panic> + + unsigned char *model = ide_devices[ideno].model, *data = ident + IDE_IDENT_MODEL; +c01018dc: 0f b7 55 f6 movzwl -0xa(%ebp),%edx +c01018e0: 89 d0 mov %edx,%eax +c01018e2: c1 e0 03 shl $0x3,%eax +c01018e5: 29 d0 sub %edx,%eax +c01018e7: c1 e0 03 shl $0x3,%eax +c01018ea: 05 80 b6 12 c0 add $0xc012b680,%eax +c01018ef: 83 c0 0c add $0xc,%eax +c01018f2: 89 45 dc mov %eax,-0x24(%ebp) +c01018f5: 8b 45 e4 mov -0x1c(%ebp),%eax +c01018f8: 83 c0 36 add $0x36,%eax +c01018fb: 89 45 d8 mov %eax,-0x28(%ebp) + unsigned int i, length = 40; +c01018fe: c7 45 d4 28 00 00 00 movl $0x28,-0x2c(%ebp) + for (i = 0; i < length; i += 2) { +c0101905: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) +c010190c: eb 34 jmp c0101942 + model[i] = data[i + 1], model[i + 1] = data[i]; +c010190e: 8b 45 ec mov -0x14(%ebp),%eax +c0101911: 8d 50 01 lea 0x1(%eax),%edx +c0101914: 8b 45 d8 mov -0x28(%ebp),%eax +c0101917: 01 c2 add %eax,%edx +c0101919: 8b 4d dc mov -0x24(%ebp),%ecx +c010191c: 8b 45 ec mov -0x14(%ebp),%eax +c010191f: 01 c8 add %ecx,%eax +c0101921: 0f b6 12 movzbl (%edx),%edx +c0101924: 88 10 mov %dl,(%eax) +c0101926: 8b 55 d8 mov -0x28(%ebp),%edx +c0101929: 8b 45 ec mov -0x14(%ebp),%eax +c010192c: 01 c2 add %eax,%edx +c010192e: 8b 45 ec mov -0x14(%ebp),%eax +c0101931: 8d 48 01 lea 0x1(%eax),%ecx +c0101934: 8b 45 dc mov -0x24(%ebp),%eax +c0101937: 01 c8 add %ecx,%eax +c0101939: 0f b6 12 movzbl (%edx),%edx +c010193c: 88 10 mov %dl,(%eax) + for (i = 0; i < length; i += 2) { +c010193e: 83 45 ec 02 addl $0x2,-0x14(%ebp) +c0101942: 8b 45 ec mov -0x14(%ebp),%eax +c0101945: 3b 45 d4 cmp -0x2c(%ebp),%eax +c0101948: 72 c4 jb c010190e + } + do { + model[i] = '\0'; +c010194a: 8b 55 dc mov -0x24(%ebp),%edx +c010194d: 8b 45 ec mov -0x14(%ebp),%eax +c0101950: 01 d0 add %edx,%eax +c0101952: c6 00 00 movb $0x0,(%eax) + } while (i -- > 0 && model[i] == ' '); +c0101955: 8b 45 ec mov -0x14(%ebp),%eax +c0101958: 8d 50 ff lea -0x1(%eax),%edx +c010195b: 89 55 ec mov %edx,-0x14(%ebp) +c010195e: 85 c0 test %eax,%eax +c0101960: 74 0f je c0101971 +c0101962: 8b 55 dc mov -0x24(%ebp),%edx +c0101965: 8b 45 ec mov -0x14(%ebp),%eax +c0101968: 01 d0 add %edx,%eax +c010196a: 0f b6 00 movzbl (%eax),%eax +c010196d: 3c 20 cmp $0x20,%al +c010196f: 74 d9 je c010194a + + cprintf("ide %d: %10u(sectors), '%s'.\n", ideno, ide_devices[ideno].size, ide_devices[ideno].model); +c0101971: 0f b7 55 f6 movzwl -0xa(%ebp),%edx +c0101975: 89 d0 mov %edx,%eax +c0101977: c1 e0 03 shl $0x3,%eax +c010197a: 29 d0 sub %edx,%eax +c010197c: c1 e0 03 shl $0x3,%eax +c010197f: 05 80 b6 12 c0 add $0xc012b680,%eax +c0101984: 8d 48 0c lea 0xc(%eax),%ecx +c0101987: 0f b7 55 f6 movzwl -0xa(%ebp),%edx +c010198b: 89 d0 mov %edx,%eax +c010198d: c1 e0 03 shl $0x3,%eax +c0101990: 29 d0 sub %edx,%eax +c0101992: c1 e0 03 shl $0x3,%eax +c0101995: 05 88 b6 12 c0 add $0xc012b688,%eax +c010199a: 8b 10 mov (%eax),%edx +c010199c: 0f b7 45 f6 movzwl -0xa(%ebp),%eax +c01019a0: 89 4c 24 0c mov %ecx,0xc(%esp) +c01019a4: 89 54 24 08 mov %edx,0x8(%esp) +c01019a8: 89 44 24 04 mov %eax,0x4(%esp) +c01019ac: c7 04 24 26 a4 10 c0 movl $0xc010a426,(%esp) +c01019b3: e8 c0 e9 ff ff call c0100378 +c01019b8: eb 01 jmp c01019bb + continue ; +c01019ba: 90 nop + for (ideno = 0; ideno < MAX_IDE; ideno ++) { +c01019bb: 0f b7 45 f6 movzwl -0xa(%ebp),%eax +c01019bf: 40 inc %eax +c01019c0: 66 89 45 f6 mov %ax,-0xa(%ebp) +c01019c4: 0f b7 45 f6 movzwl -0xa(%ebp),%eax +c01019c8: 83 f8 03 cmp $0x3,%eax +c01019cb: 0f 86 36 fd ff ff jbe c0101707 + } + + // enable ide interrupt + pic_enable(IRQ_IDE1); +c01019d1: c7 04 24 0e 00 00 00 movl $0xe,(%esp) +c01019d8: e8 83 05 00 00 call c0101f60 + pic_enable(IRQ_IDE2); +c01019dd: c7 04 24 0f 00 00 00 movl $0xf,(%esp) +c01019e4: e8 77 05 00 00 call c0101f60 +} +c01019e9: 90 nop +c01019ea: 81 c4 50 02 00 00 add $0x250,%esp +c01019f0: 5b pop %ebx +c01019f1: 5f pop %edi +c01019f2: 5d pop %ebp +c01019f3: c3 ret + +c01019f4 : + +bool +ide_device_valid(unsigned short ideno) { +c01019f4: 55 push %ebp +c01019f5: 89 e5 mov %esp,%ebp +c01019f7: 83 ec 04 sub $0x4,%esp +c01019fa: 8b 45 08 mov 0x8(%ebp),%eax +c01019fd: 66 89 45 fc mov %ax,-0x4(%ebp) + return VALID_IDE(ideno); +c0101a01: 0f b7 45 fc movzwl -0x4(%ebp),%eax +c0101a05: 83 f8 03 cmp $0x3,%eax +c0101a08: 77 21 ja c0101a2b +c0101a0a: 0f b7 55 fc movzwl -0x4(%ebp),%edx +c0101a0e: 89 d0 mov %edx,%eax +c0101a10: c1 e0 03 shl $0x3,%eax +c0101a13: 29 d0 sub %edx,%eax +c0101a15: c1 e0 03 shl $0x3,%eax +c0101a18: 05 80 b6 12 c0 add $0xc012b680,%eax +c0101a1d: 0f b6 00 movzbl (%eax),%eax +c0101a20: 84 c0 test %al,%al +c0101a22: 74 07 je c0101a2b +c0101a24: b8 01 00 00 00 mov $0x1,%eax +c0101a29: eb 05 jmp c0101a30 +c0101a2b: b8 00 00 00 00 mov $0x0,%eax +} +c0101a30: 89 ec mov %ebp,%esp +c0101a32: 5d pop %ebp +c0101a33: c3 ret + +c0101a34 : + +size_t +ide_device_size(unsigned short ideno) { +c0101a34: 55 push %ebp +c0101a35: 89 e5 mov %esp,%ebp +c0101a37: 83 ec 08 sub $0x8,%esp +c0101a3a: 8b 45 08 mov 0x8(%ebp),%eax +c0101a3d: 66 89 45 fc mov %ax,-0x4(%ebp) + if (ide_device_valid(ideno)) { +c0101a41: 0f b7 45 fc movzwl -0x4(%ebp),%eax +c0101a45: 89 04 24 mov %eax,(%esp) +c0101a48: e8 a7 ff ff ff call c01019f4 +c0101a4d: 85 c0 test %eax,%eax +c0101a4f: 74 17 je c0101a68 + return ide_devices[ideno].size; +c0101a51: 0f b7 55 fc movzwl -0x4(%ebp),%edx +c0101a55: 89 d0 mov %edx,%eax +c0101a57: c1 e0 03 shl $0x3,%eax +c0101a5a: 29 d0 sub %edx,%eax +c0101a5c: c1 e0 03 shl $0x3,%eax +c0101a5f: 05 88 b6 12 c0 add $0xc012b688,%eax +c0101a64: 8b 00 mov (%eax),%eax +c0101a66: eb 05 jmp c0101a6d + } + return 0; +c0101a68: b8 00 00 00 00 mov $0x0,%eax +} +c0101a6d: 89 ec mov %ebp,%esp +c0101a6f: 5d pop %ebp +c0101a70: c3 ret + +c0101a71 : + +int +ide_read_secs(unsigned short ideno, uint32_t secno, void *dst, size_t nsecs) { +c0101a71: 55 push %ebp +c0101a72: 89 e5 mov %esp,%ebp +c0101a74: 57 push %edi +c0101a75: 53 push %ebx +c0101a76: 83 ec 50 sub $0x50,%esp +c0101a79: 8b 45 08 mov 0x8(%ebp),%eax +c0101a7c: 66 89 45 c4 mov %ax,-0x3c(%ebp) + assert(nsecs <= MAX_NSECS && VALID_IDE(ideno)); +c0101a80: 81 7d 14 80 00 00 00 cmpl $0x80,0x14(%ebp) +c0101a87: 77 23 ja c0101aac +c0101a89: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax +c0101a8d: 83 f8 03 cmp $0x3,%eax +c0101a90: 77 1a ja c0101aac +c0101a92: 0f b7 55 c4 movzwl -0x3c(%ebp),%edx +c0101a96: 89 d0 mov %edx,%eax +c0101a98: c1 e0 03 shl $0x3,%eax +c0101a9b: 29 d0 sub %edx,%eax +c0101a9d: c1 e0 03 shl $0x3,%eax +c0101aa0: 05 80 b6 12 c0 add $0xc012b680,%eax +c0101aa5: 0f b6 00 movzbl (%eax),%eax +c0101aa8: 84 c0 test %al,%al +c0101aaa: 75 24 jne c0101ad0 +c0101aac: c7 44 24 0c 44 a4 10 movl $0xc010a444,0xc(%esp) +c0101ab3: c0 +c0101ab4: c7 44 24 08 ff a3 10 movl $0xc010a3ff,0x8(%esp) +c0101abb: c0 +c0101abc: c7 44 24 04 9f 00 00 movl $0x9f,0x4(%esp) +c0101ac3: 00 +c0101ac4: c7 04 24 14 a4 10 c0 movl $0xc010a414,(%esp) +c0101acb: e8 75 f1 ff ff call c0100c45 <__panic> + assert(secno < MAX_DISK_NSECS && secno + nsecs <= MAX_DISK_NSECS); +c0101ad0: 81 7d 0c ff ff ff 0f cmpl $0xfffffff,0xc(%ebp) +c0101ad7: 77 0f ja c0101ae8 +c0101ad9: 8b 55 0c mov 0xc(%ebp),%edx +c0101adc: 8b 45 14 mov 0x14(%ebp),%eax +c0101adf: 01 d0 add %edx,%eax +c0101ae1: 3d 00 00 00 10 cmp $0x10000000,%eax +c0101ae6: 76 24 jbe c0101b0c +c0101ae8: c7 44 24 0c 6c a4 10 movl $0xc010a46c,0xc(%esp) +c0101aef: c0 +c0101af0: c7 44 24 08 ff a3 10 movl $0xc010a3ff,0x8(%esp) +c0101af7: c0 +c0101af8: c7 44 24 04 a0 00 00 movl $0xa0,0x4(%esp) +c0101aff: 00 +c0101b00: c7 04 24 14 a4 10 c0 movl $0xc010a414,(%esp) +c0101b07: e8 39 f1 ff ff call c0100c45 <__panic> + unsigned short iobase = IO_BASE(ideno), ioctrl = IO_CTRL(ideno); +c0101b0c: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax +c0101b10: d1 e8 shr %eax +c0101b12: 0f b7 c0 movzwl %ax,%eax +c0101b15: 8b 04 85 b4 a3 10 c0 mov -0x3fef5c4c(,%eax,4),%eax +c0101b1c: 66 89 45 f2 mov %ax,-0xe(%ebp) +c0101b20: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax +c0101b24: d1 e8 shr %eax +c0101b26: 0f b7 c0 movzwl %ax,%eax +c0101b29: 0f b7 04 85 b6 a3 10 movzwl -0x3fef5c4a(,%eax,4),%eax +c0101b30: c0 +c0101b31: 66 89 45 f0 mov %ax,-0x10(%ebp) + + ide_wait_ready(iobase, 0); +c0101b35: 0f b7 45 f2 movzwl -0xe(%ebp),%eax +c0101b39: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0101b40: 00 +c0101b41: 89 04 24 mov %eax,(%esp) +c0101b44: e8 4d fb ff ff call c0101696 + + // generate interrupt + outb(ioctrl + ISA_CTRL, 0); +c0101b49: 8b 45 f0 mov -0x10(%ebp),%eax +c0101b4c: 83 c0 02 add $0x2,%eax +c0101b4f: 0f b7 c0 movzwl %ax,%eax +c0101b52: 66 89 45 d6 mov %ax,-0x2a(%ebp) +c0101b56: c6 45 d5 00 movb $0x0,-0x2b(%ebp) asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); -c010211e: 0f b6 45 fd movzbl -0x3(%ebp),%eax -c0102122: 0f b7 55 fe movzwl -0x2(%ebp),%edx -c0102126: ee out %al,(%dx) +c0101b5a: 0f b6 45 d5 movzbl -0x2b(%ebp),%eax +c0101b5e: 0f b7 55 d6 movzwl -0x2a(%ebp),%edx +c0101b62: ee out %al,(%dx) } -c0102127: 90 nop - outb(IO_PIC1, 0x0a); // read IRR by default +c0101b63: 90 nop + outb(iobase + ISA_SECCNT, nsecs); +c0101b64: 8b 45 14 mov 0x14(%ebp),%eax +c0101b67: 0f b6 c0 movzbl %al,%eax +c0101b6a: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c0101b6e: 83 c2 02 add $0x2,%edx +c0101b71: 0f b7 d2 movzwl %dx,%edx +c0101b74: 66 89 55 da mov %dx,-0x26(%ebp) +c0101b78: 88 45 d9 mov %al,-0x27(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101b7b: 0f b6 45 d9 movzbl -0x27(%ebp),%eax +c0101b7f: 0f b7 55 da movzwl -0x26(%ebp),%edx +c0101b83: ee out %al,(%dx) +} +c0101b84: 90 nop + outb(iobase + ISA_SECTOR, secno & 0xFF); +c0101b85: 8b 45 0c mov 0xc(%ebp),%eax +c0101b88: 0f b6 c0 movzbl %al,%eax +c0101b8b: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c0101b8f: 83 c2 03 add $0x3,%edx +c0101b92: 0f b7 d2 movzwl %dx,%edx +c0101b95: 66 89 55 de mov %dx,-0x22(%ebp) +c0101b99: 88 45 dd mov %al,-0x23(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101b9c: 0f b6 45 dd movzbl -0x23(%ebp),%eax +c0101ba0: 0f b7 55 de movzwl -0x22(%ebp),%edx +c0101ba4: ee out %al,(%dx) +} +c0101ba5: 90 nop + outb(iobase + ISA_CYL_LO, (secno >> 8) & 0xFF); +c0101ba6: 8b 45 0c mov 0xc(%ebp),%eax +c0101ba9: c1 e8 08 shr $0x8,%eax +c0101bac: 0f b6 c0 movzbl %al,%eax +c0101baf: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c0101bb3: 83 c2 04 add $0x4,%edx +c0101bb6: 0f b7 d2 movzwl %dx,%edx +c0101bb9: 66 89 55 e2 mov %dx,-0x1e(%ebp) +c0101bbd: 88 45 e1 mov %al,-0x1f(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101bc0: 0f b6 45 e1 movzbl -0x1f(%ebp),%eax +c0101bc4: 0f b7 55 e2 movzwl -0x1e(%ebp),%edx +c0101bc8: ee out %al,(%dx) +} +c0101bc9: 90 nop + outb(iobase + ISA_CYL_HI, (secno >> 16) & 0xFF); +c0101bca: 8b 45 0c mov 0xc(%ebp),%eax +c0101bcd: c1 e8 10 shr $0x10,%eax +c0101bd0: 0f b6 c0 movzbl %al,%eax +c0101bd3: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c0101bd7: 83 c2 05 add $0x5,%edx +c0101bda: 0f b7 d2 movzwl %dx,%edx +c0101bdd: 66 89 55 e6 mov %dx,-0x1a(%ebp) +c0101be1: 88 45 e5 mov %al,-0x1b(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101be4: 0f b6 45 e5 movzbl -0x1b(%ebp),%eax +c0101be8: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx +c0101bec: ee out %al,(%dx) +} +c0101bed: 90 nop + outb(iobase + ISA_SDH, 0xE0 | ((ideno & 1) << 4) | ((secno >> 24) & 0xF)); +c0101bee: 8b 45 c4 mov -0x3c(%ebp),%eax +c0101bf1: c0 e0 04 shl $0x4,%al +c0101bf4: 24 10 and $0x10,%al +c0101bf6: 88 c2 mov %al,%dl +c0101bf8: 8b 45 0c mov 0xc(%ebp),%eax +c0101bfb: c1 e8 18 shr $0x18,%eax +c0101bfe: 24 0f and $0xf,%al +c0101c00: 08 d0 or %dl,%al +c0101c02: 0c e0 or $0xe0,%al +c0101c04: 0f b6 c0 movzbl %al,%eax +c0101c07: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c0101c0b: 83 c2 06 add $0x6,%edx +c0101c0e: 0f b7 d2 movzwl %dx,%edx +c0101c11: 66 89 55 ea mov %dx,-0x16(%ebp) +c0101c15: 88 45 e9 mov %al,-0x17(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101c18: 0f b6 45 e9 movzbl -0x17(%ebp),%eax +c0101c1c: 0f b7 55 ea movzwl -0x16(%ebp),%edx +c0101c20: ee out %al,(%dx) +} +c0101c21: 90 nop + outb(iobase + ISA_COMMAND, IDE_CMD_READ); +c0101c22: 0f b7 45 f2 movzwl -0xe(%ebp),%eax +c0101c26: 83 c0 07 add $0x7,%eax +c0101c29: 0f b7 c0 movzwl %ax,%eax +c0101c2c: 66 89 45 ee mov %ax,-0x12(%ebp) +c0101c30: c6 45 ed 20 movb $0x20,-0x13(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101c34: 0f b6 45 ed movzbl -0x13(%ebp),%eax +c0101c38: 0f b7 55 ee movzwl -0x12(%ebp),%edx +c0101c3c: ee out %al,(%dx) +} +c0101c3d: 90 nop - outb(IO_PIC2, 0x68); // OCW3 - outb(IO_PIC2, 0x0a); // OCW3 + int ret = 0; +c0101c3e: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) + for (; nsecs > 0; nsecs --, dst += SECTSIZE) { +c0101c45: eb 58 jmp c0101c9f + if ((ret = ide_wait_ready(iobase, 1)) != 0) { +c0101c47: 0f b7 45 f2 movzwl -0xe(%ebp),%eax +c0101c4b: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0101c52: 00 +c0101c53: 89 04 24 mov %eax,(%esp) +c0101c56: e8 3b fa ff ff call c0101696 +c0101c5b: 89 45 f4 mov %eax,-0xc(%ebp) +c0101c5e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0101c62: 75 43 jne c0101ca7 + goto out; + } + insl(iobase, dst, SECTSIZE / sizeof(uint32_t)); +c0101c64: 0f b7 45 f2 movzwl -0xe(%ebp),%eax +c0101c68: 89 45 d0 mov %eax,-0x30(%ebp) +c0101c6b: 8b 45 10 mov 0x10(%ebp),%eax +c0101c6e: 89 45 cc mov %eax,-0x34(%ebp) +c0101c71: c7 45 c8 80 00 00 00 movl $0x80,-0x38(%ebp) + asm volatile ( +c0101c78: 8b 55 d0 mov -0x30(%ebp),%edx +c0101c7b: 8b 4d cc mov -0x34(%ebp),%ecx +c0101c7e: 8b 45 c8 mov -0x38(%ebp),%eax +c0101c81: 89 cb mov %ecx,%ebx +c0101c83: 89 df mov %ebx,%edi +c0101c85: 89 c1 mov %eax,%ecx +c0101c87: fc cld +c0101c88: f2 6d repnz insl (%dx),%es:(%edi) +c0101c8a: 89 c8 mov %ecx,%eax +c0101c8c: 89 fb mov %edi,%ebx +c0101c8e: 89 5d cc mov %ebx,-0x34(%ebp) +c0101c91: 89 45 c8 mov %eax,-0x38(%ebp) +} +c0101c94: 90 nop + for (; nsecs > 0; nsecs --, dst += SECTSIZE) { +c0101c95: ff 4d 14 decl 0x14(%ebp) +c0101c98: 81 45 10 00 02 00 00 addl $0x200,0x10(%ebp) +c0101c9f: 83 7d 14 00 cmpl $0x0,0x14(%ebp) +c0101ca3: 75 a2 jne c0101c47 + } - if (irq_mask != 0xFFFF) { -c0102128: 0f b7 05 50 85 12 c0 movzwl 0xc0128550,%eax -c010212f: 3d ff ff 00 00 cmp $0xffff,%eax -c0102134: 74 0f je c0102145 - pic_setmask(irq_mask); -c0102136: 0f b7 05 50 85 12 c0 movzwl 0xc0128550,%eax -c010213d: 89 04 24 mov %eax,(%esp) -c0102140: e8 21 fe ff ff call c0101f66 +out: +c0101ca5: eb 01 jmp c0101ca8 + goto out; +c0101ca7: 90 nop + return ret; +c0101ca8: 8b 45 f4 mov -0xc(%ebp),%eax +} +c0101cab: 83 c4 50 add $0x50,%esp +c0101cae: 5b pop %ebx +c0101caf: 5f pop %edi +c0101cb0: 5d pop %ebp +c0101cb1: c3 ret + +c0101cb2 : + +int +ide_write_secs(unsigned short ideno, uint32_t secno, const void *src, size_t nsecs) { +c0101cb2: 55 push %ebp +c0101cb3: 89 e5 mov %esp,%ebp +c0101cb5: 56 push %esi +c0101cb6: 53 push %ebx +c0101cb7: 83 ec 50 sub $0x50,%esp +c0101cba: 8b 45 08 mov 0x8(%ebp),%eax +c0101cbd: 66 89 45 c4 mov %ax,-0x3c(%ebp) + assert(nsecs <= MAX_NSECS && VALID_IDE(ideno)); +c0101cc1: 81 7d 14 80 00 00 00 cmpl $0x80,0x14(%ebp) +c0101cc8: 77 23 ja c0101ced +c0101cca: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax +c0101cce: 83 f8 03 cmp $0x3,%eax +c0101cd1: 77 1a ja c0101ced +c0101cd3: 0f b7 55 c4 movzwl -0x3c(%ebp),%edx +c0101cd7: 89 d0 mov %edx,%eax +c0101cd9: c1 e0 03 shl $0x3,%eax +c0101cdc: 29 d0 sub %edx,%eax +c0101cde: c1 e0 03 shl $0x3,%eax +c0101ce1: 05 80 b6 12 c0 add $0xc012b680,%eax +c0101ce6: 0f b6 00 movzbl (%eax),%eax +c0101ce9: 84 c0 test %al,%al +c0101ceb: 75 24 jne c0101d11 +c0101ced: c7 44 24 0c 44 a4 10 movl $0xc010a444,0xc(%esp) +c0101cf4: c0 +c0101cf5: c7 44 24 08 ff a3 10 movl $0xc010a3ff,0x8(%esp) +c0101cfc: c0 +c0101cfd: c7 44 24 04 bc 00 00 movl $0xbc,0x4(%esp) +c0101d04: 00 +c0101d05: c7 04 24 14 a4 10 c0 movl $0xc010a414,(%esp) +c0101d0c: e8 34 ef ff ff call c0100c45 <__panic> + assert(secno < MAX_DISK_NSECS && secno + nsecs <= MAX_DISK_NSECS); +c0101d11: 81 7d 0c ff ff ff 0f cmpl $0xfffffff,0xc(%ebp) +c0101d18: 77 0f ja c0101d29 +c0101d1a: 8b 55 0c mov 0xc(%ebp),%edx +c0101d1d: 8b 45 14 mov 0x14(%ebp),%eax +c0101d20: 01 d0 add %edx,%eax +c0101d22: 3d 00 00 00 10 cmp $0x10000000,%eax +c0101d27: 76 24 jbe c0101d4d +c0101d29: c7 44 24 0c 6c a4 10 movl $0xc010a46c,0xc(%esp) +c0101d30: c0 +c0101d31: c7 44 24 08 ff a3 10 movl $0xc010a3ff,0x8(%esp) +c0101d38: c0 +c0101d39: c7 44 24 04 bd 00 00 movl $0xbd,0x4(%esp) +c0101d40: 00 +c0101d41: c7 04 24 14 a4 10 c0 movl $0xc010a414,(%esp) +c0101d48: e8 f8 ee ff ff call c0100c45 <__panic> + unsigned short iobase = IO_BASE(ideno), ioctrl = IO_CTRL(ideno); +c0101d4d: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax +c0101d51: d1 e8 shr %eax +c0101d53: 0f b7 c0 movzwl %ax,%eax +c0101d56: 8b 04 85 b4 a3 10 c0 mov -0x3fef5c4c(,%eax,4),%eax +c0101d5d: 66 89 45 f2 mov %ax,-0xe(%ebp) +c0101d61: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax +c0101d65: d1 e8 shr %eax +c0101d67: 0f b7 c0 movzwl %ax,%eax +c0101d6a: 0f b7 04 85 b6 a3 10 movzwl -0x3fef5c4a(,%eax,4),%eax +c0101d71: c0 +c0101d72: 66 89 45 f0 mov %ax,-0x10(%ebp) + + ide_wait_ready(iobase, 0); +c0101d76: 0f b7 45 f2 movzwl -0xe(%ebp),%eax +c0101d7a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0101d81: 00 +c0101d82: 89 04 24 mov %eax,(%esp) +c0101d85: e8 0c f9 ff ff call c0101696 + + // generate interrupt + outb(ioctrl + ISA_CTRL, 0); +c0101d8a: 8b 45 f0 mov -0x10(%ebp),%eax +c0101d8d: 83 c0 02 add $0x2,%eax +c0101d90: 0f b7 c0 movzwl %ax,%eax +c0101d93: 66 89 45 d6 mov %ax,-0x2a(%ebp) +c0101d97: c6 45 d5 00 movb $0x0,-0x2b(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101d9b: 0f b6 45 d5 movzbl -0x2b(%ebp),%eax +c0101d9f: 0f b7 55 d6 movzwl -0x2a(%ebp),%edx +c0101da3: ee out %al,(%dx) +} +c0101da4: 90 nop + outb(iobase + ISA_SECCNT, nsecs); +c0101da5: 8b 45 14 mov 0x14(%ebp),%eax +c0101da8: 0f b6 c0 movzbl %al,%eax +c0101dab: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c0101daf: 83 c2 02 add $0x2,%edx +c0101db2: 0f b7 d2 movzwl %dx,%edx +c0101db5: 66 89 55 da mov %dx,-0x26(%ebp) +c0101db9: 88 45 d9 mov %al,-0x27(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101dbc: 0f b6 45 d9 movzbl -0x27(%ebp),%eax +c0101dc0: 0f b7 55 da movzwl -0x26(%ebp),%edx +c0101dc4: ee out %al,(%dx) +} +c0101dc5: 90 nop + outb(iobase + ISA_SECTOR, secno & 0xFF); +c0101dc6: 8b 45 0c mov 0xc(%ebp),%eax +c0101dc9: 0f b6 c0 movzbl %al,%eax +c0101dcc: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c0101dd0: 83 c2 03 add $0x3,%edx +c0101dd3: 0f b7 d2 movzwl %dx,%edx +c0101dd6: 66 89 55 de mov %dx,-0x22(%ebp) +c0101dda: 88 45 dd mov %al,-0x23(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101ddd: 0f b6 45 dd movzbl -0x23(%ebp),%eax +c0101de1: 0f b7 55 de movzwl -0x22(%ebp),%edx +c0101de5: ee out %al,(%dx) +} +c0101de6: 90 nop + outb(iobase + ISA_CYL_LO, (secno >> 8) & 0xFF); +c0101de7: 8b 45 0c mov 0xc(%ebp),%eax +c0101dea: c1 e8 08 shr $0x8,%eax +c0101ded: 0f b6 c0 movzbl %al,%eax +c0101df0: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c0101df4: 83 c2 04 add $0x4,%edx +c0101df7: 0f b7 d2 movzwl %dx,%edx +c0101dfa: 66 89 55 e2 mov %dx,-0x1e(%ebp) +c0101dfe: 88 45 e1 mov %al,-0x1f(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101e01: 0f b6 45 e1 movzbl -0x1f(%ebp),%eax +c0101e05: 0f b7 55 e2 movzwl -0x1e(%ebp),%edx +c0101e09: ee out %al,(%dx) +} +c0101e0a: 90 nop + outb(iobase + ISA_CYL_HI, (secno >> 16) & 0xFF); +c0101e0b: 8b 45 0c mov 0xc(%ebp),%eax +c0101e0e: c1 e8 10 shr $0x10,%eax +c0101e11: 0f b6 c0 movzbl %al,%eax +c0101e14: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c0101e18: 83 c2 05 add $0x5,%edx +c0101e1b: 0f b7 d2 movzwl %dx,%edx +c0101e1e: 66 89 55 e6 mov %dx,-0x1a(%ebp) +c0101e22: 88 45 e5 mov %al,-0x1b(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101e25: 0f b6 45 e5 movzbl -0x1b(%ebp),%eax +c0101e29: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx +c0101e2d: ee out %al,(%dx) +} +c0101e2e: 90 nop + outb(iobase + ISA_SDH, 0xE0 | ((ideno & 1) << 4) | ((secno >> 24) & 0xF)); +c0101e2f: 8b 45 c4 mov -0x3c(%ebp),%eax +c0101e32: c0 e0 04 shl $0x4,%al +c0101e35: 24 10 and $0x10,%al +c0101e37: 88 c2 mov %al,%dl +c0101e39: 8b 45 0c mov 0xc(%ebp),%eax +c0101e3c: c1 e8 18 shr $0x18,%eax +c0101e3f: 24 0f and $0xf,%al +c0101e41: 08 d0 or %dl,%al +c0101e43: 0c e0 or $0xe0,%al +c0101e45: 0f b6 c0 movzbl %al,%eax +c0101e48: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c0101e4c: 83 c2 06 add $0x6,%edx +c0101e4f: 0f b7 d2 movzwl %dx,%edx +c0101e52: 66 89 55 ea mov %dx,-0x16(%ebp) +c0101e56: 88 45 e9 mov %al,-0x17(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101e59: 0f b6 45 e9 movzbl -0x17(%ebp),%eax +c0101e5d: 0f b7 55 ea movzwl -0x16(%ebp),%edx +c0101e61: ee out %al,(%dx) +} +c0101e62: 90 nop + outb(iobase + ISA_COMMAND, IDE_CMD_WRITE); +c0101e63: 0f b7 45 f2 movzwl -0xe(%ebp),%eax +c0101e67: 83 c0 07 add $0x7,%eax +c0101e6a: 0f b7 c0 movzwl %ax,%eax +c0101e6d: 66 89 45 ee mov %ax,-0x12(%ebp) +c0101e71: c6 45 ed 30 movb $0x30,-0x13(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101e75: 0f b6 45 ed movzbl -0x13(%ebp),%eax +c0101e79: 0f b7 55 ee movzwl -0x12(%ebp),%edx +c0101e7d: ee out %al,(%dx) +} +c0101e7e: 90 nop + + int ret = 0; +c0101e7f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) + for (; nsecs > 0; nsecs --, src += SECTSIZE) { +c0101e86: eb 58 jmp c0101ee0 + if ((ret = ide_wait_ready(iobase, 1)) != 0) { +c0101e88: 0f b7 45 f2 movzwl -0xe(%ebp),%eax +c0101e8c: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0101e93: 00 +c0101e94: 89 04 24 mov %eax,(%esp) +c0101e97: e8 fa f7 ff ff call c0101696 +c0101e9c: 89 45 f4 mov %eax,-0xc(%ebp) +c0101e9f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0101ea3: 75 43 jne c0101ee8 + goto out; + } + outsl(iobase, src, SECTSIZE / sizeof(uint32_t)); +c0101ea5: 0f b7 45 f2 movzwl -0xe(%ebp),%eax +c0101ea9: 89 45 d0 mov %eax,-0x30(%ebp) +c0101eac: 8b 45 10 mov 0x10(%ebp),%eax +c0101eaf: 89 45 cc mov %eax,-0x34(%ebp) +c0101eb2: c7 45 c8 80 00 00 00 movl $0x80,-0x38(%ebp) + asm volatile ( +c0101eb9: 8b 55 d0 mov -0x30(%ebp),%edx +c0101ebc: 8b 4d cc mov -0x34(%ebp),%ecx +c0101ebf: 8b 45 c8 mov -0x38(%ebp),%eax +c0101ec2: 89 cb mov %ecx,%ebx +c0101ec4: 89 de mov %ebx,%esi +c0101ec6: 89 c1 mov %eax,%ecx +c0101ec8: fc cld +c0101ec9: f2 6f repnz outsl %ds:(%esi),(%dx) +c0101ecb: 89 c8 mov %ecx,%eax +c0101ecd: 89 f3 mov %esi,%ebx +c0101ecf: 89 5d cc mov %ebx,-0x34(%ebp) +c0101ed2: 89 45 c8 mov %eax,-0x38(%ebp) +} +c0101ed5: 90 nop + for (; nsecs > 0; nsecs --, src += SECTSIZE) { +c0101ed6: ff 4d 14 decl 0x14(%ebp) +c0101ed9: 81 45 10 00 02 00 00 addl $0x200,0x10(%ebp) +c0101ee0: 83 7d 14 00 cmpl $0x0,0x14(%ebp) +c0101ee4: 75 a2 jne c0101e88 } + +out: +c0101ee6: eb 01 jmp c0101ee9 + goto out; +c0101ee8: 90 nop + return ret; +c0101ee9: 8b 45 f4 mov -0xc(%ebp),%eax } -c0102145: 90 nop -c0102146: c9 leave -c0102147: c3 ret +c0101eec: 83 c4 50 add $0x50,%esp +c0101eef: 5b pop %ebx +c0101ef0: 5e pop %esi +c0101ef1: 5d pop %ebp +c0101ef2: c3 ret -c0102148 : +c0101ef3 : #include #include /* intr_enable - enable irq interrupt */ void intr_enable(void) { -c0102148: f3 0f 1e fb endbr32 -c010214c: 55 push %ebp -c010214d: 89 e5 mov %esp,%ebp +c0101ef3: 55 push %ebp +c0101ef4: 89 e5 mov %esp,%ebp asm volatile ("sti"); -c010214f: fb sti +c0101ef6: fb sti } -c0102150: 90 nop +c0101ef7: 90 nop sti(); } -c0102151: 90 nop -c0102152: 5d pop %ebp -c0102153: c3 ret +c0101ef8: 90 nop +c0101ef9: 5d pop %ebp +c0101efa: c3 ret -c0102154 : +c0101efb : /* intr_disable - disable irq interrupt */ void intr_disable(void) { -c0102154: f3 0f 1e fb endbr32 -c0102158: 55 push %ebp -c0102159: 89 e5 mov %esp,%ebp +c0101efb: 55 push %ebp +c0101efc: 89 e5 mov %esp,%ebp asm volatile ("cli" ::: "memory"); -c010215b: fa cli +c0101efe: fa cli } -c010215c: 90 nop +c0101eff: 90 nop cli(); } -c010215d: 90 nop -c010215e: 5d pop %ebp -c010215f: c3 ret +c0101f00: 90 nop +c0101f01: 5d pop %ebp +c0101f02: c3 ret + +c0101f03 : +// Initial IRQ mask has interrupt 2 enabled (for slave 8259A). +static uint16_t irq_mask = 0xFFFF & ~(1 << IRQ_SLAVE); +static bool did_init = 0; + +static void +pic_setmask(uint16_t mask) { +c0101f03: 55 push %ebp +c0101f04: 89 e5 mov %esp,%ebp +c0101f06: 83 ec 14 sub $0x14,%esp +c0101f09: 8b 45 08 mov 0x8(%ebp),%eax +c0101f0c: 66 89 45 ec mov %ax,-0x14(%ebp) + irq_mask = mask; +c0101f10: 8b 45 ec mov -0x14(%ebp),%eax +c0101f13: 66 a3 50 85 12 c0 mov %ax,0xc0128550 + if (did_init) { +c0101f19: a1 60 b7 12 c0 mov 0xc012b760,%eax +c0101f1e: 85 c0 test %eax,%eax +c0101f20: 74 39 je c0101f5b + outb(IO_PIC1 + 1, mask); +c0101f22: 8b 45 ec mov -0x14(%ebp),%eax +c0101f25: 0f b6 c0 movzbl %al,%eax +c0101f28: 66 c7 45 fa 21 00 movw $0x21,-0x6(%ebp) +c0101f2e: 88 45 f9 mov %al,-0x7(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101f31: 0f b6 45 f9 movzbl -0x7(%ebp),%eax +c0101f35: 0f b7 55 fa movzwl -0x6(%ebp),%edx +c0101f39: ee out %al,(%dx) +} +c0101f3a: 90 nop + outb(IO_PIC2 + 1, mask >> 8); +c0101f3b: 0f b7 45 ec movzwl -0x14(%ebp),%eax +c0101f3f: c1 e8 08 shr $0x8,%eax +c0101f42: 0f b7 c0 movzwl %ax,%eax +c0101f45: 0f b6 c0 movzbl %al,%eax +c0101f48: 66 c7 45 fe a1 00 movw $0xa1,-0x2(%ebp) +c0101f4e: 88 45 fd mov %al,-0x3(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101f51: 0f b6 45 fd movzbl -0x3(%ebp),%eax +c0101f55: 0f b7 55 fe movzwl -0x2(%ebp),%edx +c0101f59: ee out %al,(%dx) +} +c0101f5a: 90 nop + } +} +c0101f5b: 90 nop +c0101f5c: 89 ec mov %ebp,%esp +c0101f5e: 5d pop %ebp +c0101f5f: c3 ret + +c0101f60 : + +void +pic_enable(unsigned int irq) { +c0101f60: 55 push %ebp +c0101f61: 89 e5 mov %esp,%ebp +c0101f63: 83 ec 04 sub $0x4,%esp + pic_setmask(irq_mask & ~(1 << irq)); +c0101f66: 8b 45 08 mov 0x8(%ebp),%eax +c0101f69: ba 01 00 00 00 mov $0x1,%edx +c0101f6e: 88 c1 mov %al,%cl +c0101f70: d3 e2 shl %cl,%edx +c0101f72: 89 d0 mov %edx,%eax +c0101f74: 98 cwtl +c0101f75: f7 d0 not %eax +c0101f77: 0f bf d0 movswl %ax,%edx +c0101f7a: 0f b7 05 50 85 12 c0 movzwl 0xc0128550,%eax +c0101f81: 98 cwtl +c0101f82: 21 d0 and %edx,%eax +c0101f84: 98 cwtl +c0101f85: 0f b7 c0 movzwl %ax,%eax +c0101f88: 89 04 24 mov %eax,(%esp) +c0101f8b: e8 73 ff ff ff call c0101f03 +} +c0101f90: 90 nop +c0101f91: 89 ec mov %ebp,%esp +c0101f93: 5d pop %ebp +c0101f94: c3 ret + +c0101f95 : + +/* pic_init - initialize the 8259A interrupt controllers */ +void +pic_init(void) { +c0101f95: 55 push %ebp +c0101f96: 89 e5 mov %esp,%ebp +c0101f98: 83 ec 44 sub $0x44,%esp + did_init = 1; +c0101f9b: c7 05 60 b7 12 c0 01 movl $0x1,0xc012b760 +c0101fa2: 00 00 00 +c0101fa5: 66 c7 45 ca 21 00 movw $0x21,-0x36(%ebp) +c0101fab: c6 45 c9 ff movb $0xff,-0x37(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101faf: 0f b6 45 c9 movzbl -0x37(%ebp),%eax +c0101fb3: 0f b7 55 ca movzwl -0x36(%ebp),%edx +c0101fb7: ee out %al,(%dx) +} +c0101fb8: 90 nop +c0101fb9: 66 c7 45 ce a1 00 movw $0xa1,-0x32(%ebp) +c0101fbf: c6 45 cd ff movb $0xff,-0x33(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101fc3: 0f b6 45 cd movzbl -0x33(%ebp),%eax +c0101fc7: 0f b7 55 ce movzwl -0x32(%ebp),%edx +c0101fcb: ee out %al,(%dx) +} +c0101fcc: 90 nop +c0101fcd: 66 c7 45 d2 20 00 movw $0x20,-0x2e(%ebp) +c0101fd3: c6 45 d1 11 movb $0x11,-0x2f(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101fd7: 0f b6 45 d1 movzbl -0x2f(%ebp),%eax +c0101fdb: 0f b7 55 d2 movzwl -0x2e(%ebp),%edx +c0101fdf: ee out %al,(%dx) +} +c0101fe0: 90 nop +c0101fe1: 66 c7 45 d6 21 00 movw $0x21,-0x2a(%ebp) +c0101fe7: c6 45 d5 20 movb $0x20,-0x2b(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101feb: 0f b6 45 d5 movzbl -0x2b(%ebp),%eax +c0101fef: 0f b7 55 d6 movzwl -0x2a(%ebp),%edx +c0101ff3: ee out %al,(%dx) +} +c0101ff4: 90 nop +c0101ff5: 66 c7 45 da 21 00 movw $0x21,-0x26(%ebp) +c0101ffb: c6 45 d9 04 movb $0x4,-0x27(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0101fff: 0f b6 45 d9 movzbl -0x27(%ebp),%eax +c0102003: 0f b7 55 da movzwl -0x26(%ebp),%edx +c0102007: ee out %al,(%dx) +} +c0102008: 90 nop +c0102009: 66 c7 45 de 21 00 movw $0x21,-0x22(%ebp) +c010200f: c6 45 dd 03 movb $0x3,-0x23(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0102013: 0f b6 45 dd movzbl -0x23(%ebp),%eax +c0102017: 0f b7 55 de movzwl -0x22(%ebp),%edx +c010201b: ee out %al,(%dx) +} +c010201c: 90 nop +c010201d: 66 c7 45 e2 a0 00 movw $0xa0,-0x1e(%ebp) +c0102023: c6 45 e1 11 movb $0x11,-0x1f(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0102027: 0f b6 45 e1 movzbl -0x1f(%ebp),%eax +c010202b: 0f b7 55 e2 movzwl -0x1e(%ebp),%edx +c010202f: ee out %al,(%dx) +} +c0102030: 90 nop +c0102031: 66 c7 45 e6 a1 00 movw $0xa1,-0x1a(%ebp) +c0102037: c6 45 e5 28 movb $0x28,-0x1b(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c010203b: 0f b6 45 e5 movzbl -0x1b(%ebp),%eax +c010203f: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx +c0102043: ee out %al,(%dx) +} +c0102044: 90 nop +c0102045: 66 c7 45 ea a1 00 movw $0xa1,-0x16(%ebp) +c010204b: c6 45 e9 02 movb $0x2,-0x17(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c010204f: 0f b6 45 e9 movzbl -0x17(%ebp),%eax +c0102053: 0f b7 55 ea movzwl -0x16(%ebp),%edx +c0102057: ee out %al,(%dx) +} +c0102058: 90 nop +c0102059: 66 c7 45 ee a1 00 movw $0xa1,-0x12(%ebp) +c010205f: c6 45 ed 03 movb $0x3,-0x13(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0102063: 0f b6 45 ed movzbl -0x13(%ebp),%eax +c0102067: 0f b7 55 ee movzwl -0x12(%ebp),%edx +c010206b: ee out %al,(%dx) +} +c010206c: 90 nop +c010206d: 66 c7 45 f2 20 00 movw $0x20,-0xe(%ebp) +c0102073: c6 45 f1 68 movb $0x68,-0xf(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c0102077: 0f b6 45 f1 movzbl -0xf(%ebp),%eax +c010207b: 0f b7 55 f2 movzwl -0xe(%ebp),%edx +c010207f: ee out %al,(%dx) +} +c0102080: 90 nop +c0102081: 66 c7 45 f6 20 00 movw $0x20,-0xa(%ebp) +c0102087: c6 45 f5 0a movb $0xa,-0xb(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c010208b: 0f b6 45 f5 movzbl -0xb(%ebp),%eax +c010208f: 0f b7 55 f6 movzwl -0xa(%ebp),%edx +c0102093: ee out %al,(%dx) +} +c0102094: 90 nop +c0102095: 66 c7 45 fa a0 00 movw $0xa0,-0x6(%ebp) +c010209b: c6 45 f9 68 movb $0x68,-0x7(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c010209f: 0f b6 45 f9 movzbl -0x7(%ebp),%eax +c01020a3: 0f b7 55 fa movzwl -0x6(%ebp),%edx +c01020a7: ee out %al,(%dx) +} +c01020a8: 90 nop +c01020a9: 66 c7 45 fe a0 00 movw $0xa0,-0x2(%ebp) +c01020af: c6 45 fd 0a movb $0xa,-0x3(%ebp) + asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory"); +c01020b3: 0f b6 45 fd movzbl -0x3(%ebp),%eax +c01020b7: 0f b7 55 fe movzwl -0x2(%ebp),%edx +c01020bb: ee out %al,(%dx) +} +c01020bc: 90 nop + outb(IO_PIC1, 0x0a); // read IRR by default + + outb(IO_PIC2, 0x68); // OCW3 + outb(IO_PIC2, 0x0a); // OCW3 + + if (irq_mask != 0xFFFF) { +c01020bd: 0f b7 05 50 85 12 c0 movzwl 0xc0128550,%eax +c01020c4: 3d ff ff 00 00 cmp $0xffff,%eax +c01020c9: 74 0f je c01020da + pic_setmask(irq_mask); +c01020cb: 0f b7 05 50 85 12 c0 movzwl 0xc0128550,%eax +c01020d2: 89 04 24 mov %eax,(%esp) +c01020d5: e8 29 fe ff ff call c0101f03 + } +} +c01020da: 90 nop +c01020db: 89 ec mov %ebp,%esp +c01020dd: 5d pop %ebp +c01020de: c3 ret -c0102160 : +c01020df : #include #include #define TICK_NUM 100 static void print_ticks() { -c0102160: f3 0f 1e fb endbr32 -c0102164: 55 push %ebp -c0102165: 89 e5 mov %esp,%ebp -c0102167: 83 ec 18 sub $0x18,%esp +c01020df: 55 push %ebp +c01020e0: 89 e5 mov %esp,%ebp +c01020e2: 83 ec 18 sub $0x18,%esp cprintf("%d ticks\n",TICK_NUM); -c010216a: c7 44 24 04 64 00 00 movl $0x64,0x4(%esp) -c0102171: 00 -c0102172: c7 04 24 e0 a6 10 c0 movl $0xc010a6e0,(%esp) -c0102179: e8 59 e1 ff ff call c01002d7 +c01020e5: c7 44 24 04 64 00 00 movl $0x64,0x4(%esp) +c01020ec: 00 +c01020ed: c7 04 24 c0 a4 10 c0 movl $0xc010a4c0,(%esp) +c01020f4: e8 7f e2 ff ff call c0100378 #ifdef DEBUG_GRADE cprintf("End of Test.\n"); panic("EOT: kernel seems ok.");//panic 是一个用于处理内核崩溃的函数,它会打印出错误信息并导致系统停止运行。 #endif } -c010217e: 90 nop -c010217f: c9 leave -c0102180: c3 ret +c01020f9: 90 nop +c01020fa: 89 ec mov %ebp,%esp +c01020fc: 5d pop %ebp +c01020fd: c3 ret -c0102181 : +c01020fe : sizeof(idt) - 1, (uintptr_t)idt }; /* idt_init - initialize IDT to each of the entry points in kern/trap/vectors.S */ void idt_init(void) { -c0102181: f3 0f 1e fb endbr32 -c0102185: 55 push %ebp -c0102186: 89 e5 mov %esp,%ebp -c0102188: 83 ec 10 sub $0x10,%esp +c01020fe: 55 push %ebp +c01020ff: 89 e5 mov %esp,%ebp +c0102101: 83 ec 10 sub $0x10,%esp * Notice: the argument of lidt is idt_pd. try to find it! */ extern uintptr_t __vectors[];//声明了一个外部数组 __vectors,该数组存储中断服务例程(ISR)的地址。 int i; for (i = 0; i < sizeof(idt) / sizeof(struct gatedesc); i ++) { -c010218b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) -c0102192: e9 c4 00 00 00 jmp c010225b +c0102104: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) +c010210b: e9 c4 00 00 00 jmp c01021d4 SETGATE(idt[i], 0, GD_KTEXT, __vectors[i], DPL_KERNEL); -c0102197: 8b 45 fc mov -0x4(%ebp),%eax -c010219a: 8b 04 85 e0 85 12 c0 mov -0x3fed7a20(,%eax,4),%eax -c01021a1: 0f b7 d0 movzwl %ax,%edx -c01021a4: 8b 45 fc mov -0x4(%ebp),%eax -c01021a7: 66 89 14 c5 60 b7 12 mov %dx,-0x3fed48a0(,%eax,8) -c01021ae: c0 -c01021af: 8b 45 fc mov -0x4(%ebp),%eax -c01021b2: 66 c7 04 c5 62 b7 12 movw $0x8,-0x3fed489e(,%eax,8) -c01021b9: c0 08 00 -c01021bc: 8b 45 fc mov -0x4(%ebp),%eax -c01021bf: 0f b6 14 c5 64 b7 12 movzbl -0x3fed489c(,%eax,8),%edx -c01021c6: c0 -c01021c7: 80 e2 e0 and $0xe0,%dl -c01021ca: 88 14 c5 64 b7 12 c0 mov %dl,-0x3fed489c(,%eax,8) -c01021d1: 8b 45 fc mov -0x4(%ebp),%eax -c01021d4: 0f b6 14 c5 64 b7 12 movzbl -0x3fed489c(,%eax,8),%edx -c01021db: c0 -c01021dc: 80 e2 1f and $0x1f,%dl -c01021df: 88 14 c5 64 b7 12 c0 mov %dl,-0x3fed489c(,%eax,8) -c01021e6: 8b 45 fc mov -0x4(%ebp),%eax -c01021e9: 0f b6 14 c5 65 b7 12 movzbl -0x3fed489b(,%eax,8),%edx -c01021f0: c0 -c01021f1: 80 e2 f0 and $0xf0,%dl -c01021f4: 80 ca 0e or $0xe,%dl -c01021f7: 88 14 c5 65 b7 12 c0 mov %dl,-0x3fed489b(,%eax,8) -c01021fe: 8b 45 fc mov -0x4(%ebp),%eax -c0102201: 0f b6 14 c5 65 b7 12 movzbl -0x3fed489b(,%eax,8),%edx -c0102208: c0 -c0102209: 80 e2 ef and $0xef,%dl -c010220c: 88 14 c5 65 b7 12 c0 mov %dl,-0x3fed489b(,%eax,8) -c0102213: 8b 45 fc mov -0x4(%ebp),%eax -c0102216: 0f b6 14 c5 65 b7 12 movzbl -0x3fed489b(,%eax,8),%edx -c010221d: c0 -c010221e: 80 e2 9f and $0x9f,%dl -c0102221: 88 14 c5 65 b7 12 c0 mov %dl,-0x3fed489b(,%eax,8) -c0102228: 8b 45 fc mov -0x4(%ebp),%eax -c010222b: 0f b6 14 c5 65 b7 12 movzbl -0x3fed489b(,%eax,8),%edx -c0102232: c0 -c0102233: 80 ca 80 or $0x80,%dl -c0102236: 88 14 c5 65 b7 12 c0 mov %dl,-0x3fed489b(,%eax,8) -c010223d: 8b 45 fc mov -0x4(%ebp),%eax -c0102240: 8b 04 85 e0 85 12 c0 mov -0x3fed7a20(,%eax,4),%eax -c0102247: c1 e8 10 shr $0x10,%eax -c010224a: 0f b7 d0 movzwl %ax,%edx -c010224d: 8b 45 fc mov -0x4(%ebp),%eax -c0102250: 66 89 14 c5 66 b7 12 mov %dx,-0x3fed489a(,%eax,8) -c0102257: c0 +c0102110: 8b 45 fc mov -0x4(%ebp),%eax +c0102113: 8b 04 85 e0 85 12 c0 mov -0x3fed7a20(,%eax,4),%eax +c010211a: 0f b7 d0 movzwl %ax,%edx +c010211d: 8b 45 fc mov -0x4(%ebp),%eax +c0102120: 66 89 14 c5 e0 b7 12 mov %dx,-0x3fed4820(,%eax,8) +c0102127: c0 +c0102128: 8b 45 fc mov -0x4(%ebp),%eax +c010212b: 66 c7 04 c5 e2 b7 12 movw $0x8,-0x3fed481e(,%eax,8) +c0102132: c0 08 00 +c0102135: 8b 45 fc mov -0x4(%ebp),%eax +c0102138: 0f b6 14 c5 e4 b7 12 movzbl -0x3fed481c(,%eax,8),%edx +c010213f: c0 +c0102140: 80 e2 e0 and $0xe0,%dl +c0102143: 88 14 c5 e4 b7 12 c0 mov %dl,-0x3fed481c(,%eax,8) +c010214a: 8b 45 fc mov -0x4(%ebp),%eax +c010214d: 0f b6 14 c5 e4 b7 12 movzbl -0x3fed481c(,%eax,8),%edx +c0102154: c0 +c0102155: 80 e2 1f and $0x1f,%dl +c0102158: 88 14 c5 e4 b7 12 c0 mov %dl,-0x3fed481c(,%eax,8) +c010215f: 8b 45 fc mov -0x4(%ebp),%eax +c0102162: 0f b6 14 c5 e5 b7 12 movzbl -0x3fed481b(,%eax,8),%edx +c0102169: c0 +c010216a: 80 e2 f0 and $0xf0,%dl +c010216d: 80 ca 0e or $0xe,%dl +c0102170: 88 14 c5 e5 b7 12 c0 mov %dl,-0x3fed481b(,%eax,8) +c0102177: 8b 45 fc mov -0x4(%ebp),%eax +c010217a: 0f b6 14 c5 e5 b7 12 movzbl -0x3fed481b(,%eax,8),%edx +c0102181: c0 +c0102182: 80 e2 ef and $0xef,%dl +c0102185: 88 14 c5 e5 b7 12 c0 mov %dl,-0x3fed481b(,%eax,8) +c010218c: 8b 45 fc mov -0x4(%ebp),%eax +c010218f: 0f b6 14 c5 e5 b7 12 movzbl -0x3fed481b(,%eax,8),%edx +c0102196: c0 +c0102197: 80 e2 9f and $0x9f,%dl +c010219a: 88 14 c5 e5 b7 12 c0 mov %dl,-0x3fed481b(,%eax,8) +c01021a1: 8b 45 fc mov -0x4(%ebp),%eax +c01021a4: 0f b6 14 c5 e5 b7 12 movzbl -0x3fed481b(,%eax,8),%edx +c01021ab: c0 +c01021ac: 80 ca 80 or $0x80,%dl +c01021af: 88 14 c5 e5 b7 12 c0 mov %dl,-0x3fed481b(,%eax,8) +c01021b6: 8b 45 fc mov -0x4(%ebp),%eax +c01021b9: 8b 04 85 e0 85 12 c0 mov -0x3fed7a20(,%eax,4),%eax +c01021c0: c1 e8 10 shr $0x10,%eax +c01021c3: 0f b7 d0 movzwl %ax,%edx +c01021c6: 8b 45 fc mov -0x4(%ebp),%eax +c01021c9: 66 89 14 c5 e6 b7 12 mov %dx,-0x3fed481a(,%eax,8) +c01021d0: c0 for (i = 0; i < sizeof(idt) / sizeof(struct gatedesc); i ++) { -c0102258: ff 45 fc incl -0x4(%ebp) -c010225b: 8b 45 fc mov -0x4(%ebp),%eax -c010225e: 3d ff 00 00 00 cmp $0xff,%eax -c0102263: 0f 86 2e ff ff ff jbe c0102197 +c01021d1: ff 45 fc incl -0x4(%ebp) +c01021d4: 8b 45 fc mov -0x4(%ebp),%eax +c01021d7: 3d ff 00 00 00 cmp $0xff,%eax +c01021dc: 0f 86 2e ff ff ff jbe c0102110 //宏用于配置每个 IDT 条目.0 表示最高特权级(内核级)GD_KTEXT: 指向内核代码段的选择子,确保 ISR 在内核代码段中执行。 //__vectors[i]: 对应中断的 ISR 地址,DPL_KERNEL: 描述符特权级,表示该中断只能由内核级代码触发。 // set for switch from user to kernel //SETGATE 这行代码特别设置了 T_SWITCH_TOK(一个特定的中断向量,用于用户态到内核态的切换)的 IDT 条目。 //DPL_USER 表示该中断可以由用户态代码触发 SETGATE(idt[T_SWITCH_TOK], 0, GD_KTEXT, __vectors[T_SWITCH_TOK], DPL_USER); -c0102269: a1 c4 87 12 c0 mov 0xc01287c4,%eax -c010226e: 0f b7 c0 movzwl %ax,%eax -c0102271: 66 a3 28 bb 12 c0 mov %ax,0xc012bb28 -c0102277: 66 c7 05 2a bb 12 c0 movw $0x8,0xc012bb2a -c010227e: 08 00 -c0102280: 0f b6 05 2c bb 12 c0 movzbl 0xc012bb2c,%eax -c0102287: 24 e0 and $0xe0,%al -c0102289: a2 2c bb 12 c0 mov %al,0xc012bb2c -c010228e: 0f b6 05 2c bb 12 c0 movzbl 0xc012bb2c,%eax -c0102295: 24 1f and $0x1f,%al -c0102297: a2 2c bb 12 c0 mov %al,0xc012bb2c -c010229c: 0f b6 05 2d bb 12 c0 movzbl 0xc012bb2d,%eax -c01022a3: 24 f0 and $0xf0,%al -c01022a5: 0c 0e or $0xe,%al -c01022a7: a2 2d bb 12 c0 mov %al,0xc012bb2d -c01022ac: 0f b6 05 2d bb 12 c0 movzbl 0xc012bb2d,%eax -c01022b3: 24 ef and $0xef,%al -c01022b5: a2 2d bb 12 c0 mov %al,0xc012bb2d -c01022ba: 0f b6 05 2d bb 12 c0 movzbl 0xc012bb2d,%eax -c01022c1: 0c 60 or $0x60,%al -c01022c3: a2 2d bb 12 c0 mov %al,0xc012bb2d -c01022c8: 0f b6 05 2d bb 12 c0 movzbl 0xc012bb2d,%eax -c01022cf: 0c 80 or $0x80,%al -c01022d1: a2 2d bb 12 c0 mov %al,0xc012bb2d -c01022d6: a1 c4 87 12 c0 mov 0xc01287c4,%eax -c01022db: c1 e8 10 shr $0x10,%eax -c01022de: 0f b7 c0 movzwl %ax,%eax -c01022e1: 66 a3 2e bb 12 c0 mov %ax,0xc012bb2e -c01022e7: c7 45 f8 60 85 12 c0 movl $0xc0128560,-0x8(%ebp) +c01021e2: a1 c4 87 12 c0 mov 0xc01287c4,%eax +c01021e7: 0f b7 c0 movzwl %ax,%eax +c01021ea: 66 a3 a8 bb 12 c0 mov %ax,0xc012bba8 +c01021f0: 66 c7 05 aa bb 12 c0 movw $0x8,0xc012bbaa +c01021f7: 08 00 +c01021f9: 0f b6 05 ac bb 12 c0 movzbl 0xc012bbac,%eax +c0102200: 24 e0 and $0xe0,%al +c0102202: a2 ac bb 12 c0 mov %al,0xc012bbac +c0102207: 0f b6 05 ac bb 12 c0 movzbl 0xc012bbac,%eax +c010220e: 24 1f and $0x1f,%al +c0102210: a2 ac bb 12 c0 mov %al,0xc012bbac +c0102215: 0f b6 05 ad bb 12 c0 movzbl 0xc012bbad,%eax +c010221c: 24 f0 and $0xf0,%al +c010221e: 0c 0e or $0xe,%al +c0102220: a2 ad bb 12 c0 mov %al,0xc012bbad +c0102225: 0f b6 05 ad bb 12 c0 movzbl 0xc012bbad,%eax +c010222c: 24 ef and $0xef,%al +c010222e: a2 ad bb 12 c0 mov %al,0xc012bbad +c0102233: 0f b6 05 ad bb 12 c0 movzbl 0xc012bbad,%eax +c010223a: 0c 60 or $0x60,%al +c010223c: a2 ad bb 12 c0 mov %al,0xc012bbad +c0102241: 0f b6 05 ad bb 12 c0 movzbl 0xc012bbad,%eax +c0102248: 0c 80 or $0x80,%al +c010224a: a2 ad bb 12 c0 mov %al,0xc012bbad +c010224f: a1 c4 87 12 c0 mov 0xc01287c4,%eax +c0102254: c1 e8 10 shr $0x10,%eax +c0102257: 0f b7 c0 movzwl %ax,%eax +c010225a: 66 a3 ae bb 12 c0 mov %ax,0xc012bbae +c0102260: c7 45 f8 60 85 12 c0 movl $0xc0128560,-0x8(%ebp) asm volatile ("lidt (%0)" :: "r" (pd) : "memory"); -c01022ee: 8b 45 f8 mov -0x8(%ebp),%eax -c01022f1: 0f 01 18 lidtl (%eax) +c0102267: 8b 45 f8 mov -0x8(%ebp),%eax +c010226a: 0f 01 18 lidtl (%eax) } -c01022f4: 90 nop +c010226d: 90 nop // load the IDT //使用 lidt 指令将 IDT 描述符加载到 CPU 中 lidt(&idt_pd); } -c01022f5: 90 nop -c01022f6: c9 leave -c01022f7: c3 ret +c010226e: 90 nop +c010226f: 89 ec mov %ebp,%esp +c0102271: 5d pop %ebp +c0102272: c3 ret -c01022f8 : +c0102273 : static const char * trapname(int trapno) { -c01022f8: f3 0f 1e fb endbr32 -c01022fc: 55 push %ebp -c01022fd: 89 e5 mov %esp,%ebp +c0102273: 55 push %ebp +c0102274: 89 e5 mov %esp,%ebp "Alignment Check", "Machine-Check", "SIMD Floating-Point Exception" }; //如果 trapno 小于数组长度,则返回对应的异常名称。 if (trapno < sizeof(excnames)/sizeof(const char * const)) { -c01022ff: 8b 45 08 mov 0x8(%ebp),%eax -c0102302: 83 f8 13 cmp $0x13,%eax -c0102305: 77 0c ja c0102313 +c0102276: 8b 45 08 mov 0x8(%ebp),%eax +c0102279: 83 f8 13 cmp $0x13,%eax +c010227c: 77 0c ja c010228a return excnames[trapno]; -c0102307: 8b 45 08 mov 0x8(%ebp),%eax -c010230a: 8b 04 85 40 ab 10 c0 mov -0x3fef54c0(,%eax,4),%eax -c0102311: eb 18 jmp c010232b +c010227e: 8b 45 08 mov 0x8(%ebp),%eax +c0102281: 8b 04 85 20 a9 10 c0 mov -0x3fef56e0(,%eax,4),%eax +c0102288: eb 18 jmp c01022a2 } //如果 trapno 在 IRQ_OFFSET 和 IRQ_OFFSET + 16 之间,表示它是一个硬件中断 if (trapno >= IRQ_OFFSET && trapno < IRQ_OFFSET + 16) { -c0102313: 83 7d 08 1f cmpl $0x1f,0x8(%ebp) -c0102317: 7e 0d jle c0102326 -c0102319: 83 7d 08 2f cmpl $0x2f,0x8(%ebp) -c010231d: 7f 07 jg c0102326 +c010228a: 83 7d 08 1f cmpl $0x1f,0x8(%ebp) +c010228e: 7e 0d jle c010229d +c0102290: 83 7d 08 2f cmpl $0x2f,0x8(%ebp) +c0102294: 7f 07 jg c010229d return "Hardware Interrupt"; -c010231f: b8 ea a6 10 c0 mov $0xc010a6ea,%eax -c0102324: eb 05 jmp c010232b +c0102296: b8 ca a4 10 c0 mov $0xc010a4ca,%eax +c010229b: eb 05 jmp c01022a2 } return "(unknown trap)"; -c0102326: b8 fd a6 10 c0 mov $0xc010a6fd,%eax +c010229d: b8 dd a4 10 c0 mov $0xc010a4dd,%eax } -c010232b: 5d pop %ebp -c010232c: c3 ret +c01022a2: 5d pop %ebp +c01022a3: c3 ret -c010232d : +c01022a4 : /* trap_in_kernel - test if trap happened in kernel */ bool trap_in_kernel(struct trapframe *tf) { -c010232d: f3 0f 1e fb endbr32 -c0102331: 55 push %ebp -c0102332: 89 e5 mov %esp,%ebp +c01022a4: 55 push %ebp +c01022a5: 89 e5 mov %esp,%ebp return (tf->tf_cs == (uint16_t)KERNEL_CS); -c0102334: 8b 45 08 mov 0x8(%ebp),%eax -c0102337: 0f b7 40 3c movzwl 0x3c(%eax),%eax -c010233b: 83 f8 08 cmp $0x8,%eax -c010233e: 0f 94 c0 sete %al -c0102341: 0f b6 c0 movzbl %al,%eax +c01022a7: 8b 45 08 mov 0x8(%ebp),%eax +c01022aa: 0f b7 40 3c movzwl 0x3c(%eax),%eax +c01022ae: 83 f8 08 cmp $0x8,%eax +c01022b1: 0f 94 c0 sete %al +c01022b4: 0f b6 c0 movzbl %al,%eax //函数通过检查 tf 中的 tf_cs 字段来判断当前处于哪个特权级,tf_cs 存储了当前代码段选择子的值 //当 tf->tf_cs 等于 KERNEL_CS 时,表示陷阱发生在内核模式下 } -c0102344: 5d pop %ebp -c0102345: c3 ret +c01022b7: 5d pop %ebp +c01022b8: c3 ret -c0102346 : +c01022b9 : "TF", "IF", "DF", "OF", NULL, NULL, "NT", NULL, "RF", "VM", "AC", "VIF", "VIP", "ID", NULL, NULL, }; //struct trapframe *tf,一个指向 trapframe 结构的指针,包含有关陷阱发生时的 CPU 状态的信息。 void print_trapframe(struct trapframe *tf) { -c0102346: f3 0f 1e fb endbr32 -c010234a: 55 push %ebp -c010234b: 89 e5 mov %esp,%ebp -c010234d: 83 ec 28 sub $0x28,%esp +c01022b9: 55 push %ebp +c01022ba: 89 e5 mov %esp,%ebp +c01022bc: 83 ec 28 sub $0x28,%esp cprintf("trapframe at %p\n", tf); //打印陷阱框架地址 -c0102350: 8b 45 08 mov 0x8(%ebp),%eax -c0102353: 89 44 24 04 mov %eax,0x4(%esp) -c0102357: c7 04 24 3e a7 10 c0 movl $0xc010a73e,(%esp) -c010235e: e8 74 df ff ff call c01002d7 +c01022bf: 8b 45 08 mov 0x8(%ebp),%eax +c01022c2: 89 44 24 04 mov %eax,0x4(%esp) +c01022c6: c7 04 24 1e a5 10 c0 movl $0xc010a51e,(%esp) +c01022cd: e8 a6 e0 ff ff call c0100378 print_regs(&tf->tf_regs); //打印寄存器状态 -c0102363: 8b 45 08 mov 0x8(%ebp),%eax -c0102366: 89 04 24 mov %eax,(%esp) -c0102369: e8 8d 01 00 00 call c01024fb +c01022d2: 8b 45 08 mov 0x8(%ebp),%eax +c01022d5: 89 04 24 mov %eax,(%esp) +c01022d8: e8 8f 01 00 00 call c010246c //打印数据段(DS)、扩展段(ES)、文件段(FS)、通用段(GS)的值。 cprintf(" ds 0x----%04x\n", tf->tf_ds); -c010236e: 8b 45 08 mov 0x8(%ebp),%eax -c0102371: 0f b7 40 2c movzwl 0x2c(%eax),%eax -c0102375: 89 44 24 04 mov %eax,0x4(%esp) -c0102379: c7 04 24 4f a7 10 c0 movl $0xc010a74f,(%esp) -c0102380: e8 52 df ff ff call c01002d7 +c01022dd: 8b 45 08 mov 0x8(%ebp),%eax +c01022e0: 0f b7 40 2c movzwl 0x2c(%eax),%eax +c01022e4: 89 44 24 04 mov %eax,0x4(%esp) +c01022e8: c7 04 24 2f a5 10 c0 movl $0xc010a52f,(%esp) +c01022ef: e8 84 e0 ff ff call c0100378 cprintf(" es 0x----%04x\n", tf->tf_es); -c0102385: 8b 45 08 mov 0x8(%ebp),%eax -c0102388: 0f b7 40 28 movzwl 0x28(%eax),%eax -c010238c: 89 44 24 04 mov %eax,0x4(%esp) -c0102390: c7 04 24 62 a7 10 c0 movl $0xc010a762,(%esp) -c0102397: e8 3b df ff ff call c01002d7 +c01022f4: 8b 45 08 mov 0x8(%ebp),%eax +c01022f7: 0f b7 40 28 movzwl 0x28(%eax),%eax +c01022fb: 89 44 24 04 mov %eax,0x4(%esp) +c01022ff: c7 04 24 42 a5 10 c0 movl $0xc010a542,(%esp) +c0102306: e8 6d e0 ff ff call c0100378 cprintf(" fs 0x----%04x\n", tf->tf_fs); -c010239c: 8b 45 08 mov 0x8(%ebp),%eax -c010239f: 0f b7 40 24 movzwl 0x24(%eax),%eax -c01023a3: 89 44 24 04 mov %eax,0x4(%esp) -c01023a7: c7 04 24 75 a7 10 c0 movl $0xc010a775,(%esp) -c01023ae: e8 24 df ff ff call c01002d7 +c010230b: 8b 45 08 mov 0x8(%ebp),%eax +c010230e: 0f b7 40 24 movzwl 0x24(%eax),%eax +c0102312: 89 44 24 04 mov %eax,0x4(%esp) +c0102316: c7 04 24 55 a5 10 c0 movl $0xc010a555,(%esp) +c010231d: e8 56 e0 ff ff call c0100378 cprintf(" gs 0x----%04x\n", tf->tf_gs); -c01023b3: 8b 45 08 mov 0x8(%ebp),%eax -c01023b6: 0f b7 40 20 movzwl 0x20(%eax),%eax -c01023ba: 89 44 24 04 mov %eax,0x4(%esp) -c01023be: c7 04 24 88 a7 10 c0 movl $0xc010a788,(%esp) -c01023c5: e8 0d df ff ff call c01002d7 +c0102322: 8b 45 08 mov 0x8(%ebp),%eax +c0102325: 0f b7 40 20 movzwl 0x20(%eax),%eax +c0102329: 89 44 24 04 mov %eax,0x4(%esp) +c010232d: c7 04 24 68 a5 10 c0 movl $0xc010a568,(%esp) +c0102334: e8 3f e0 ff ff call c0100378 // 打印陷阱号(trap number)及其对应的名称,通过调用 trapname 函数获取。 cprintf(" trap 0x%08x %s\n", tf->tf_trapno, trapname(tf->tf_trapno)); -c01023ca: 8b 45 08 mov 0x8(%ebp),%eax -c01023cd: 8b 40 30 mov 0x30(%eax),%eax -c01023d0: 89 04 24 mov %eax,(%esp) -c01023d3: e8 20 ff ff ff call c01022f8 -c01023d8: 8b 55 08 mov 0x8(%ebp),%edx -c01023db: 8b 52 30 mov 0x30(%edx),%edx -c01023de: 89 44 24 08 mov %eax,0x8(%esp) -c01023e2: 89 54 24 04 mov %edx,0x4(%esp) -c01023e6: c7 04 24 9b a7 10 c0 movl $0xc010a79b,(%esp) -c01023ed: e8 e5 de ff ff call c01002d7 +c0102339: 8b 45 08 mov 0x8(%ebp),%eax +c010233c: 8b 40 30 mov 0x30(%eax),%eax +c010233f: 89 04 24 mov %eax,(%esp) +c0102342: e8 2c ff ff ff call c0102273 +c0102347: 8b 55 08 mov 0x8(%ebp),%edx +c010234a: 8b 52 30 mov 0x30(%edx),%edx +c010234d: 89 44 24 08 mov %eax,0x8(%esp) +c0102351: 89 54 24 04 mov %edx,0x4(%esp) +c0102355: c7 04 24 7b a5 10 c0 movl $0xc010a57b,(%esp) +c010235c: e8 17 e0 ff ff call c0100378 cprintf(" err 0x%08x\n", tf->tf_err);// 如果有错误代码,打印该字段的值。 -c01023f2: 8b 45 08 mov 0x8(%ebp),%eax -c01023f5: 8b 40 34 mov 0x34(%eax),%eax -c01023f8: 89 44 24 04 mov %eax,0x4(%esp) -c01023fc: c7 04 24 ad a7 10 c0 movl $0xc010a7ad,(%esp) -c0102403: e8 cf de ff ff call c01002d7 +c0102361: 8b 45 08 mov 0x8(%ebp),%eax +c0102364: 8b 40 34 mov 0x34(%eax),%eax +c0102367: 89 44 24 04 mov %eax,0x4(%esp) +c010236b: c7 04 24 8d a5 10 c0 movl $0xc010a58d,(%esp) +c0102372: e8 01 e0 ff ff call c0100378 cprintf(" eip 0x%08x\n", tf->tf_eip);//打印当前执行的指令指针(EIP),指向出错或中断的指令。 -c0102408: 8b 45 08 mov 0x8(%ebp),%eax -c010240b: 8b 40 38 mov 0x38(%eax),%eax -c010240e: 89 44 24 04 mov %eax,0x4(%esp) -c0102412: c7 04 24 bc a7 10 c0 movl $0xc010a7bc,(%esp) -c0102419: e8 b9 de ff ff call c01002d7 +c0102377: 8b 45 08 mov 0x8(%ebp),%eax +c010237a: 8b 40 38 mov 0x38(%eax),%eax +c010237d: 89 44 24 04 mov %eax,0x4(%esp) +c0102381: c7 04 24 9c a5 10 c0 movl $0xc010a59c,(%esp) +c0102388: e8 eb df ff ff call c0100378 cprintf(" cs 0x----%04x\n", tf->tf_cs);//打印代码段寄存器(CS)的值。 -c010241e: 8b 45 08 mov 0x8(%ebp),%eax -c0102421: 0f b7 40 3c movzwl 0x3c(%eax),%eax -c0102425: 89 44 24 04 mov %eax,0x4(%esp) -c0102429: c7 04 24 cb a7 10 c0 movl $0xc010a7cb,(%esp) -c0102430: e8 a2 de ff ff call c01002d7 +c010238d: 8b 45 08 mov 0x8(%ebp),%eax +c0102390: 0f b7 40 3c movzwl 0x3c(%eax),%eax +c0102394: 89 44 24 04 mov %eax,0x4(%esp) +c0102398: c7 04 24 ab a5 10 c0 movl $0xc010a5ab,(%esp) +c010239f: e8 d4 df ff ff call c0100378 cprintf(" flag 0x%08x ", tf->tf_eflags);// 打印标志寄存器(EFLAGS)的值 -c0102435: 8b 45 08 mov 0x8(%ebp),%eax -c0102438: 8b 40 40 mov 0x40(%eax),%eax -c010243b: 89 44 24 04 mov %eax,0x4(%esp) -c010243f: c7 04 24 de a7 10 c0 movl $0xc010a7de,(%esp) -c0102446: e8 8c de ff ff call c01002d7 +c01023a4: 8b 45 08 mov 0x8(%ebp),%eax +c01023a7: 8b 40 40 mov 0x40(%eax),%eax +c01023aa: 89 44 24 04 mov %eax,0x4(%esp) +c01023ae: c7 04 24 be a5 10 c0 movl $0xc010a5be,(%esp) +c01023b5: e8 be df ff ff call c0100378 //使用循环遍历 IA32flags 数组,j 表示当前标志位的位掩码。 int i, j; for (i = 0, j = 1; i < sizeof(IA32flags) / sizeof(IA32flags[0]); i ++, j <<= 1) { -c010244b: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -c0102452: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) -c0102459: eb 3d jmp c0102498 +c01023ba: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c01023c1: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) +c01023c8: eb 3d jmp c0102407 if ((tf->tf_eflags & j) && IA32flags[i] != NULL) { -c010245b: 8b 45 08 mov 0x8(%ebp),%eax -c010245e: 8b 50 40 mov 0x40(%eax),%edx -c0102461: 8b 45 f0 mov -0x10(%ebp),%eax -c0102464: 21 d0 and %edx,%eax -c0102466: 85 c0 test %eax,%eax -c0102468: 74 28 je c0102492 -c010246a: 8b 45 f4 mov -0xc(%ebp),%eax -c010246d: 8b 04 85 80 85 12 c0 mov -0x3fed7a80(,%eax,4),%eax -c0102474: 85 c0 test %eax,%eax -c0102476: 74 1a je c0102492 +c01023ca: 8b 45 08 mov 0x8(%ebp),%eax +c01023cd: 8b 50 40 mov 0x40(%eax),%edx +c01023d0: 8b 45 f0 mov -0x10(%ebp),%eax +c01023d3: 21 d0 and %edx,%eax +c01023d5: 85 c0 test %eax,%eax +c01023d7: 74 28 je c0102401 +c01023d9: 8b 45 f4 mov -0xc(%ebp),%eax +c01023dc: 8b 04 85 80 85 12 c0 mov -0x3fed7a80(,%eax,4),%eax +c01023e3: 85 c0 test %eax,%eax +c01023e5: 74 1a je c0102401 cprintf("%s,", IA32flags[i]); -c0102478: 8b 45 f4 mov -0xc(%ebp),%eax -c010247b: 8b 04 85 80 85 12 c0 mov -0x3fed7a80(,%eax,4),%eax -c0102482: 89 44 24 04 mov %eax,0x4(%esp) -c0102486: c7 04 24 ed a7 10 c0 movl $0xc010a7ed,(%esp) -c010248d: e8 45 de ff ff call c01002d7 +c01023e7: 8b 45 f4 mov -0xc(%ebp),%eax +c01023ea: 8b 04 85 80 85 12 c0 mov -0x3fed7a80(,%eax,4),%eax +c01023f1: 89 44 24 04 mov %eax,0x4(%esp) +c01023f5: c7 04 24 cd a5 10 c0 movl $0xc010a5cd,(%esp) +c01023fc: e8 77 df ff ff call c0100378 for (i = 0, j = 1; i < sizeof(IA32flags) / sizeof(IA32flags[0]); i ++, j <<= 1) { -c0102492: ff 45 f4 incl -0xc(%ebp) -c0102495: d1 65 f0 shll -0x10(%ebp) -c0102498: 8b 45 f4 mov -0xc(%ebp),%eax -c010249b: 83 f8 17 cmp $0x17,%eax -c010249e: 76 bb jbe c010245b +c0102401: ff 45 f4 incl -0xc(%ebp) +c0102404: d1 65 f0 shll -0x10(%ebp) +c0102407: 8b 45 f4 mov -0xc(%ebp),%eax +c010240a: 83 f8 17 cmp $0x17,%eax +c010240d: 76 bb jbe c01023ca } } //通过位掩码 FL_IOPL_MASK 获取和打印当前的 I/O 特权级别。 cprintf("IOPL=%d\n", (tf->tf_eflags & FL_IOPL_MASK) >> 12); -c01024a0: 8b 45 08 mov 0x8(%ebp),%eax -c01024a3: 8b 40 40 mov 0x40(%eax),%eax -c01024a6: c1 e8 0c shr $0xc,%eax -c01024a9: 83 e0 03 and $0x3,%eax -c01024ac: 89 44 24 04 mov %eax,0x4(%esp) -c01024b0: c7 04 24 f1 a7 10 c0 movl $0xc010a7f1,(%esp) -c01024b7: e8 1b de ff ff call c01002d7 +c010240f: 8b 45 08 mov 0x8(%ebp),%eax +c0102412: 8b 40 40 mov 0x40(%eax),%eax +c0102415: c1 e8 0c shr $0xc,%eax +c0102418: 83 e0 03 and $0x3,%eax +c010241b: 89 44 24 04 mov %eax,0x4(%esp) +c010241f: c7 04 24 d1 a5 10 c0 movl $0xc010a5d1,(%esp) +c0102426: e8 4d df ff ff call c0100378 //如果陷阱不是在内核中发生的(通过 trap_in_kernel 判断), //则打印栈指针(ESP)和栈段(SS)寄存器的值。 if (!trap_in_kernel(tf)) { -c01024bc: 8b 45 08 mov 0x8(%ebp),%eax -c01024bf: 89 04 24 mov %eax,(%esp) -c01024c2: e8 66 fe ff ff call c010232d -c01024c7: 85 c0 test %eax,%eax -c01024c9: 75 2d jne c01024f8 +c010242b: 8b 45 08 mov 0x8(%ebp),%eax +c010242e: 89 04 24 mov %eax,(%esp) +c0102431: e8 6e fe ff ff call c01022a4 +c0102436: 85 c0 test %eax,%eax +c0102438: 75 2d jne c0102467 cprintf(" esp 0x%08x\n", tf->tf_esp); -c01024cb: 8b 45 08 mov 0x8(%ebp),%eax -c01024ce: 8b 40 44 mov 0x44(%eax),%eax -c01024d1: 89 44 24 04 mov %eax,0x4(%esp) -c01024d5: c7 04 24 fa a7 10 c0 movl $0xc010a7fa,(%esp) -c01024dc: e8 f6 dd ff ff call c01002d7 +c010243a: 8b 45 08 mov 0x8(%ebp),%eax +c010243d: 8b 40 44 mov 0x44(%eax),%eax +c0102440: 89 44 24 04 mov %eax,0x4(%esp) +c0102444: c7 04 24 da a5 10 c0 movl $0xc010a5da,(%esp) +c010244b: e8 28 df ff ff call c0100378 cprintf(" ss 0x----%04x\n", tf->tf_ss); -c01024e1: 8b 45 08 mov 0x8(%ebp),%eax -c01024e4: 0f b7 40 48 movzwl 0x48(%eax),%eax -c01024e8: 89 44 24 04 mov %eax,0x4(%esp) -c01024ec: c7 04 24 09 a8 10 c0 movl $0xc010a809,(%esp) -c01024f3: e8 df dd ff ff call c01002d7 +c0102450: 8b 45 08 mov 0x8(%ebp),%eax +c0102453: 0f b7 40 48 movzwl 0x48(%eax),%eax +c0102457: 89 44 24 04 mov %eax,0x4(%esp) +c010245b: c7 04 24 e9 a5 10 c0 movl $0xc010a5e9,(%esp) +c0102462: e8 11 df ff ff call c0100378 } } -c01024f8: 90 nop -c01024f9: c9 leave -c01024fa: c3 ret +c0102467: 90 nop +c0102468: 89 ec mov %ebp,%esp +c010246a: 5d pop %ebp +c010246b: c3 ret -c01024fb : +c010246c : //定义了一个名为 print_regs 的函数, //打印出存储在 struct pushregs 结构体中的寄存器值。 void print_regs(struct pushregs *regs) { -c01024fb: f3 0f 1e fb endbr32 -c01024ff: 55 push %ebp -c0102500: 89 e5 mov %esp,%ebp -c0102502: 83 ec 18 sub $0x18,%esp +c010246c: 55 push %ebp +c010246d: 89 e5 mov %esp,%ebp +c010246f: 83 ec 18 sub $0x18,%esp cprintf(" edi 0x%08x\n", regs->reg_edi); -c0102505: 8b 45 08 mov 0x8(%ebp),%eax -c0102508: 8b 00 mov (%eax),%eax -c010250a: 89 44 24 04 mov %eax,0x4(%esp) -c010250e: c7 04 24 1c a8 10 c0 movl $0xc010a81c,(%esp) -c0102515: e8 bd dd ff ff call c01002d7 +c0102472: 8b 45 08 mov 0x8(%ebp),%eax +c0102475: 8b 00 mov (%eax),%eax +c0102477: 89 44 24 04 mov %eax,0x4(%esp) +c010247b: c7 04 24 fc a5 10 c0 movl $0xc010a5fc,(%esp) +c0102482: e8 f1 de ff ff call c0100378 cprintf(" esi 0x%08x\n", regs->reg_esi); -c010251a: 8b 45 08 mov 0x8(%ebp),%eax -c010251d: 8b 40 04 mov 0x4(%eax),%eax -c0102520: 89 44 24 04 mov %eax,0x4(%esp) -c0102524: c7 04 24 2b a8 10 c0 movl $0xc010a82b,(%esp) -c010252b: e8 a7 dd ff ff call c01002d7 +c0102487: 8b 45 08 mov 0x8(%ebp),%eax +c010248a: 8b 40 04 mov 0x4(%eax),%eax +c010248d: 89 44 24 04 mov %eax,0x4(%esp) +c0102491: c7 04 24 0b a6 10 c0 movl $0xc010a60b,(%esp) +c0102498: e8 db de ff ff call c0100378 cprintf(" ebp 0x%08x\n", regs->reg_ebp); -c0102530: 8b 45 08 mov 0x8(%ebp),%eax -c0102533: 8b 40 08 mov 0x8(%eax),%eax -c0102536: 89 44 24 04 mov %eax,0x4(%esp) -c010253a: c7 04 24 3a a8 10 c0 movl $0xc010a83a,(%esp) -c0102541: e8 91 dd ff ff call c01002d7 +c010249d: 8b 45 08 mov 0x8(%ebp),%eax +c01024a0: 8b 40 08 mov 0x8(%eax),%eax +c01024a3: 89 44 24 04 mov %eax,0x4(%esp) +c01024a7: c7 04 24 1a a6 10 c0 movl $0xc010a61a,(%esp) +c01024ae: e8 c5 de ff ff call c0100378 cprintf(" oesp 0x%08x\n", regs->reg_oesp);//打印旧的栈指针(OESP),这个寄存器通常在陷阱或中断发生时用于记录上一个栈指针。 -c0102546: 8b 45 08 mov 0x8(%ebp),%eax -c0102549: 8b 40 0c mov 0xc(%eax),%eax -c010254c: 89 44 24 04 mov %eax,0x4(%esp) -c0102550: c7 04 24 49 a8 10 c0 movl $0xc010a849,(%esp) -c0102557: e8 7b dd ff ff call c01002d7 +c01024b3: 8b 45 08 mov 0x8(%ebp),%eax +c01024b6: 8b 40 0c mov 0xc(%eax),%eax +c01024b9: 89 44 24 04 mov %eax,0x4(%esp) +c01024bd: c7 04 24 29 a6 10 c0 movl $0xc010a629,(%esp) +c01024c4: e8 af de ff ff call c0100378 cprintf(" ebx 0x%08x\n", regs->reg_ebx); -c010255c: 8b 45 08 mov 0x8(%ebp),%eax -c010255f: 8b 40 10 mov 0x10(%eax),%eax -c0102562: 89 44 24 04 mov %eax,0x4(%esp) -c0102566: c7 04 24 58 a8 10 c0 movl $0xc010a858,(%esp) -c010256d: e8 65 dd ff ff call c01002d7 +c01024c9: 8b 45 08 mov 0x8(%ebp),%eax +c01024cc: 8b 40 10 mov 0x10(%eax),%eax +c01024cf: 89 44 24 04 mov %eax,0x4(%esp) +c01024d3: c7 04 24 38 a6 10 c0 movl $0xc010a638,(%esp) +c01024da: e8 99 de ff ff call c0100378 cprintf(" edx 0x%08x\n", regs->reg_edx); -c0102572: 8b 45 08 mov 0x8(%ebp),%eax -c0102575: 8b 40 14 mov 0x14(%eax),%eax -c0102578: 89 44 24 04 mov %eax,0x4(%esp) -c010257c: c7 04 24 67 a8 10 c0 movl $0xc010a867,(%esp) -c0102583: e8 4f dd ff ff call c01002d7 +c01024df: 8b 45 08 mov 0x8(%ebp),%eax +c01024e2: 8b 40 14 mov 0x14(%eax),%eax +c01024e5: 89 44 24 04 mov %eax,0x4(%esp) +c01024e9: c7 04 24 47 a6 10 c0 movl $0xc010a647,(%esp) +c01024f0: e8 83 de ff ff call c0100378 cprintf(" ecx 0x%08x\n", regs->reg_ecx); -c0102588: 8b 45 08 mov 0x8(%ebp),%eax -c010258b: 8b 40 18 mov 0x18(%eax),%eax -c010258e: 89 44 24 04 mov %eax,0x4(%esp) -c0102592: c7 04 24 76 a8 10 c0 movl $0xc010a876,(%esp) -c0102599: e8 39 dd ff ff call c01002d7 +c01024f5: 8b 45 08 mov 0x8(%ebp),%eax +c01024f8: 8b 40 18 mov 0x18(%eax),%eax +c01024fb: 89 44 24 04 mov %eax,0x4(%esp) +c01024ff: c7 04 24 56 a6 10 c0 movl $0xc010a656,(%esp) +c0102506: e8 6d de ff ff call c0100378 cprintf(" eax 0x%08x\n", regs->reg_eax); -c010259e: 8b 45 08 mov 0x8(%ebp),%eax -c01025a1: 8b 40 1c mov 0x1c(%eax),%eax -c01025a4: 89 44 24 04 mov %eax,0x4(%esp) -c01025a8: c7 04 24 85 a8 10 c0 movl $0xc010a885,(%esp) -c01025af: e8 23 dd ff ff call c01002d7 -} -c01025b4: 90 nop -c01025b5: c9 leave -c01025b6: c3 ret - -c01025b7 : +c010250b: 8b 45 08 mov 0x8(%ebp),%eax +c010250e: 8b 40 1c mov 0x1c(%eax),%eax +c0102511: 89 44 24 04 mov %eax,0x4(%esp) +c0102515: c7 04 24 65 a6 10 c0 movl $0xc010a665,(%esp) +c010251c: e8 57 de ff ff call c0100378 +} +c0102521: 90 nop +c0102522: 89 ec mov %ebp,%esp +c0102524: 5d pop %ebp +c0102525: c3 ret + +c0102526 : * 此函数用于输出页面故障的详细信息,包括故障地址、访问类型(读/写)、访问模式(用户/内核)以及故障类型(未找到页面/保护故障)。 * * @param tf 指向 trapframe 结构的指针,包含故障发生时的寄存器状态和错误代码。 */ static inline void print_pgfault(struct trapframe *tf) { -c01025b7: 55 push %ebp -c01025b8: 89 e5 mov %esp,%ebp -c01025ba: 53 push %ebx -c01025bb: 83 ec 34 sub $0x34,%esp +c0102526: 55 push %ebp +c0102527: 89 e5 mov %esp,%ebp +c0102529: 83 ec 38 sub $0x38,%esp +c010252c: 89 5d fc mov %ebx,-0x4(%ebp) * bit 2 == 0 表示内核模式,1 表示用户模式 * */ cprintf("page fault at 0x%08x: %c/%c [%s].\n", rcr2(), (tf->tf_err & 4) ? 'U' : 'K', (tf->tf_err & 2) ? 'W' : 'R', (tf->tf_err & 1) ? "protection fault" : "no page found"); -c01025be: 8b 45 08 mov 0x8(%ebp),%eax -c01025c1: 8b 40 34 mov 0x34(%eax),%eax -c01025c4: 83 e0 01 and $0x1,%eax +c010252f: 8b 45 08 mov 0x8(%ebp),%eax +c0102532: 8b 40 34 mov 0x34(%eax),%eax +c0102535: 83 e0 01 and $0x1,%eax cprintf("page fault at 0x%08x: %c/%c [%s].\n", rcr2(), -c01025c7: 85 c0 test %eax,%eax -c01025c9: 74 07 je c01025d2 -c01025cb: bb 94 a8 10 c0 mov $0xc010a894,%ebx -c01025d0: eb 05 jmp c01025d7 -c01025d2: bb a5 a8 10 c0 mov $0xc010a8a5,%ebx +c0102538: 85 c0 test %eax,%eax +c010253a: 74 07 je c0102543 +c010253c: bb 74 a6 10 c0 mov $0xc010a674,%ebx +c0102541: eb 05 jmp c0102548 +c0102543: bb 85 a6 10 c0 mov $0xc010a685,%ebx (tf->tf_err & 2) ? 'W' : 'R', -c01025d7: 8b 45 08 mov 0x8(%ebp),%eax -c01025da: 8b 40 34 mov 0x34(%eax),%eax -c01025dd: 83 e0 02 and $0x2,%eax +c0102548: 8b 45 08 mov 0x8(%ebp),%eax +c010254b: 8b 40 34 mov 0x34(%eax),%eax +c010254e: 83 e0 02 and $0x2,%eax cprintf("page fault at 0x%08x: %c/%c [%s].\n", rcr2(), -c01025e0: 85 c0 test %eax,%eax -c01025e2: 74 07 je c01025eb -c01025e4: b9 57 00 00 00 mov $0x57,%ecx -c01025e9: eb 05 jmp c01025f0 -c01025eb: b9 52 00 00 00 mov $0x52,%ecx +c0102551: 85 c0 test %eax,%eax +c0102553: 74 07 je c010255c +c0102555: b9 57 00 00 00 mov $0x57,%ecx +c010255a: eb 05 jmp c0102561 +c010255c: b9 52 00 00 00 mov $0x52,%ecx (tf->tf_err & 4) ? 'U' : 'K', -c01025f0: 8b 45 08 mov 0x8(%ebp),%eax -c01025f3: 8b 40 34 mov 0x34(%eax),%eax -c01025f6: 83 e0 04 and $0x4,%eax +c0102561: 8b 45 08 mov 0x8(%ebp),%eax +c0102564: 8b 40 34 mov 0x34(%eax),%eax +c0102567: 83 e0 04 and $0x4,%eax cprintf("page fault at 0x%08x: %c/%c [%s].\n", rcr2(), -c01025f9: 85 c0 test %eax,%eax -c01025fb: 74 07 je c0102604 -c01025fd: ba 55 00 00 00 mov $0x55,%edx -c0102602: eb 05 jmp c0102609 -c0102604: ba 4b 00 00 00 mov $0x4b,%edx +c010256a: 85 c0 test %eax,%eax +c010256c: 74 07 je c0102575 +c010256e: ba 55 00 00 00 mov $0x55,%edx +c0102573: eb 05 jmp c010257a +c0102575: ba 4b 00 00 00 mov $0x4b,%edx } static inline uintptr_t rcr2(void) { uintptr_t cr2; asm volatile ("mov %%cr2, %0" : "=r" (cr2) :: "memory"); -c0102609: 0f 20 d0 mov %cr2,%eax -c010260c: 89 45 f4 mov %eax,-0xc(%ebp) +c010257a: 0f 20 d0 mov %cr2,%eax +c010257d: 89 45 f4 mov %eax,-0xc(%ebp) return cr2; -c010260f: 8b 45 f4 mov -0xc(%ebp),%eax -c0102612: 89 5c 24 10 mov %ebx,0x10(%esp) -c0102616: 89 4c 24 0c mov %ecx,0xc(%esp) -c010261a: 89 54 24 08 mov %edx,0x8(%esp) -c010261e: 89 44 24 04 mov %eax,0x4(%esp) -c0102622: c7 04 24 b4 a8 10 c0 movl $0xc010a8b4,(%esp) -c0102629: e8 a9 dc ff ff call c01002d7 -} -c010262e: 90 nop -c010262f: 83 c4 34 add $0x34,%esp -c0102632: 5b pop %ebx -c0102633: 5d pop %ebp -c0102634: c3 ret - -c0102635 : +c0102580: 8b 45 f4 mov -0xc(%ebp),%eax +c0102583: 89 5c 24 10 mov %ebx,0x10(%esp) +c0102587: 89 4c 24 0c mov %ecx,0xc(%esp) +c010258b: 89 54 24 08 mov %edx,0x8(%esp) +c010258f: 89 44 24 04 mov %eax,0x4(%esp) +c0102593: c7 04 24 94 a6 10 c0 movl $0xc010a694,(%esp) +c010259a: e8 d9 dd ff ff call c0100378 +} +c010259f: 90 nop +c01025a0: 8b 5d fc mov -0x4(%ebp),%ebx +c01025a3: 89 ec mov %ebp,%esp +c01025a5: 5d pop %ebp +c01025a6: c3 ret + +c01025a7 : * * @param tf 指向陷阱帧的指针,包含故障发生时的CPU状态信息 * @return 返回页面故障处理的结果,或者在无法处理时引发系统崩溃 */ static int pgfault_handler(struct trapframe *tf) { -c0102635: f3 0f 1e fb endbr32 -c0102639: 55 push %ebp -c010263a: 89 e5 mov %esp,%ebp -c010263c: 83 ec 28 sub $0x28,%esp +c01025a7: 55 push %ebp +c01025a8: 89 e5 mov %esp,%ebp +c01025aa: 83 ec 28 sub $0x28,%esp // 声明一个外部变量,用于检查内存管理结构 extern struct mm_struct *check_mm_struct; // 打印页面故障信息 print_pgfault(tf); -c010263f: 8b 45 08 mov 0x8(%ebp),%eax -c0102642: 89 04 24 mov %eax,(%esp) -c0102645: e8 6d ff ff ff call c01025b7 +c01025ad: 8b 45 08 mov 0x8(%ebp),%eax +c01025b0: 89 04 24 mov %eax,(%esp) +c01025b3: e8 6e ff ff ff call c0102526 // 检查是否存在有效的内存管理结构 if (check_mm_struct != NULL) { -c010264a: a1 c4 e0 12 c0 mov 0xc012e0c4,%eax -c010264f: 85 c0 test %eax,%eax -c0102651: 74 26 je c0102679 +c01025b8: a1 6c c1 12 c0 mov 0xc012c16c,%eax +c01025bd: 85 c0 test %eax,%eax +c01025bf: 74 26 je c01025e7 asm volatile ("mov %%cr2, %0" : "=r" (cr2) :: "memory"); -c0102653: 0f 20 d0 mov %cr2,%eax -c0102656: 89 45 f4 mov %eax,-0xc(%ebp) +c01025c1: 0f 20 d0 mov %cr2,%eax +c01025c4: 89 45 f4 mov %eax,-0xc(%ebp) return cr2; -c0102659: 8b 4d f4 mov -0xc(%ebp),%ecx +c01025c7: 8b 4d f4 mov -0xc(%ebp),%ecx // 如果存在,调用页面故障处理函数 return do_pgfault(check_mm_struct, tf->tf_err, rcr2()); -c010265c: 8b 45 08 mov 0x8(%ebp),%eax -c010265f: 8b 50 34 mov 0x34(%eax),%edx -c0102662: a1 c4 e0 12 c0 mov 0xc012e0c4,%eax -c0102667: 89 4c 24 08 mov %ecx,0x8(%esp) -c010266b: 89 54 24 04 mov %edx,0x4(%esp) -c010266f: 89 04 24 mov %eax,(%esp) -c0102672: e8 86 39 00 00 call c0105ffd -c0102677: eb 1c jmp c0102695 +c01025ca: 8b 45 08 mov 0x8(%ebp),%eax +c01025cd: 8b 50 34 mov 0x34(%eax),%edx +c01025d0: a1 6c c1 12 c0 mov 0xc012c16c,%eax +c01025d5: 89 4c 24 08 mov %ecx,0x8(%esp) +c01025d9: 89 54 24 04 mov %edx,0x4(%esp) +c01025dd: 89 04 24 mov %eax,(%esp) +c01025e0: e8 23 5e 00 00 call c0108408 +c01025e5: eb 1c jmp c0102603 } // 如果没有有效的内存管理结构,引发系统崩溃 panic("unhandled page fault.\n"); -c0102679: c7 44 24 08 d7 a8 10 movl $0xc010a8d7,0x8(%esp) -c0102680: c0 -c0102681: c7 44 24 04 d3 00 00 movl $0xd3,0x4(%esp) -c0102688: 00 -c0102689: c7 04 24 ee a8 10 c0 movl $0xc010a8ee,(%esp) -c0102690: e8 ae dd ff ff call c0100443 <__panic> +c01025e7: c7 44 24 08 b7 a6 10 movl $0xc010a6b7,0x8(%esp) +c01025ee: c0 +c01025ef: c7 44 24 04 d3 00 00 movl $0xd3,0x4(%esp) +c01025f6: 00 +c01025f7: c7 04 24 ce a6 10 c0 movl $0xc010a6ce,(%esp) +c01025fe: e8 42 e6 ff ff call c0100c45 <__panic> } -c0102695: c9 leave -c0102696: c3 ret +c0102603: 89 ec mov %ebp,%esp +c0102605: 5d pop %ebp +c0102606: c3 ret -c0102697 : +c0102607 : struct trapframe switchk2u, *switchu2k; //定义了一个名为 trap_dispatch 的静态函数,根据发生的陷阱类型进行相应的处理。 // 参数 tf 是指向陷阱帧的指针,包含了关于陷阱发生时的CPU状态信息。 static void trap_dispatch(struct trapframe *tf) { -c0102697: f3 0f 1e fb endbr32 -c010269b: 55 push %ebp -c010269c: 89 e5 mov %esp,%ebp -c010269e: 57 push %edi -c010269f: 56 push %esi -c01026a0: 53 push %ebx -c01026a1: 83 ec 2c sub $0x2c,%esp +c0102607: 55 push %ebp +c0102608: 89 e5 mov %esp,%ebp +c010260a: 83 ec 28 sub $0x28,%esp +c010260d: 89 5d fc mov %ebx,-0x4(%ebp) char c; int ret; //通过 switch 语句根据 tf->tf_trapno 的值来分发不同的陷阱处理逻辑。 switch (tf->tf_trapno) { -c01026a4: 8b 45 08 mov 0x8(%ebp),%eax -c01026a7: 8b 40 30 mov 0x30(%eax),%eax -c01026aa: 83 f8 79 cmp $0x79,%eax -c01026ad: 0f 84 fd 01 00 00 je c01028b0 -c01026b3: 83 f8 79 cmp $0x79,%eax -c01026b6: 0f 87 71 02 00 00 ja c010292d -c01026bc: 83 f8 2f cmp $0x2f,%eax -c01026bf: 77 1f ja c01026e0 -c01026c1: 83 f8 0e cmp $0xe,%eax -c01026c4: 0f 82 63 02 00 00 jb c010292d -c01026ca: 83 e8 0e sub $0xe,%eax -c01026cd: 83 f8 21 cmp $0x21,%eax -c01026d0: 0f 87 57 02 00 00 ja c010292d -c01026d6: 8b 04 85 58 a9 10 c0 mov -0x3fef56a8(,%eax,4),%eax -c01026dd: 3e ff e0 notrack jmp *%eax -c01026e0: 83 f8 78 cmp $0x78,%eax -c01026e3: 0f 84 e3 00 00 00 je c01027cc -c01026e9: e9 3f 02 00 00 jmp c010292d +c0102610: 8b 45 08 mov 0x8(%ebp),%eax +c0102613: 8b 40 30 mov 0x30(%eax),%eax +c0102616: 83 f8 79 cmp $0x79,%eax +c0102619: 0f 84 a2 01 00 00 je c01027c1 +c010261f: 83 f8 79 cmp $0x79,%eax +c0102622: 0f 87 16 02 00 00 ja c010283e +c0102628: 83 f8 2f cmp $0x2f,%eax +c010262b: 77 1e ja c010264b +c010262d: 83 f8 0e cmp $0xe,%eax +c0102630: 0f 82 08 02 00 00 jb c010283e +c0102636: 83 e8 0e sub $0xe,%eax +c0102639: 83 f8 21 cmp $0x21,%eax +c010263c: 0f 87 fc 01 00 00 ja c010283e +c0102642: 8b 04 85 38 a7 10 c0 mov -0x3fef58c8(,%eax,4),%eax +c0102649: ff e0 jmp *%eax +c010264b: 83 f8 78 cmp $0x78,%eax +c010264e: 0f 84 e3 00 00 00 je c0102737 +c0102654: e9 e5 01 00 00 jmp c010283e case T_PGFLT: //page fault // 处理页故障中断 if ((ret = pgfault_handler(tf)) != 0) { -c01026ee: 8b 45 08 mov 0x8(%ebp),%eax -c01026f1: 89 04 24 mov %eax,(%esp) -c01026f4: e8 3c ff ff ff call c0102635 -c01026f9: 89 45 e0 mov %eax,-0x20(%ebp) -c01026fc: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) -c0102700: 0f 84 5f 02 00 00 je c0102965 +c0102659: 8b 45 08 mov 0x8(%ebp),%eax +c010265c: 89 04 24 mov %eax,(%esp) +c010265f: e8 43 ff ff ff call c01025a7 +c0102664: 89 45 f0 mov %eax,-0x10(%ebp) +c0102667: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c010266b: 0f 84 05 02 00 00 je c0102876 print_trapframe(tf); -c0102706: 8b 45 08 mov 0x8(%ebp),%eax -c0102709: 89 04 24 mov %eax,(%esp) -c010270c: e8 35 fc ff ff call c0102346 +c0102671: 8b 45 08 mov 0x8(%ebp),%eax +c0102674: 89 04 24 mov %eax,(%esp) +c0102677: e8 3d fc ff ff call c01022b9 panic("handle pgfault failed. %e\n", ret); -c0102711: 8b 45 e0 mov -0x20(%ebp),%eax -c0102714: 89 44 24 0c mov %eax,0xc(%esp) -c0102718: c7 44 24 08 ff a8 10 movl $0xc010a8ff,0x8(%esp) -c010271f: c0 -c0102720: c7 44 24 04 e7 00 00 movl $0xe7,0x4(%esp) -c0102727: 00 -c0102728: c7 04 24 ee a8 10 c0 movl $0xc010a8ee,(%esp) -c010272f: e8 0f dd ff ff call c0100443 <__panic> +c010267c: 8b 45 f0 mov -0x10(%ebp),%eax +c010267f: 89 44 24 0c mov %eax,0xc(%esp) +c0102683: c7 44 24 08 df a6 10 movl $0xc010a6df,0x8(%esp) +c010268a: c0 +c010268b: c7 44 24 04 e7 00 00 movl $0xe7,0x4(%esp) +c0102692: 00 +c0102693: c7 04 24 ce a6 10 c0 movl $0xc010a6ce,(%esp) +c010269a: e8 a6 e5 ff ff call c0100c45 <__panic> /* handle the timer interrupt */ /* (1) After a timer interrupt, you should record this event using a global variable (increase it), such as ticks in kern/driver/clock.c * (2) Every TICK_NUM cycle, you can print some info using a funciton, such as print_ticks(). * (3) Too Simple? Yes, I think so! */ ticks ++; //记录中断事件 -c0102734: a1 54 e0 12 c0 mov 0xc012e054,%eax -c0102739: 40 inc %eax -c010273a: a3 54 e0 12 c0 mov %eax,0xc012e054 +c010269f: a1 24 b4 12 c0 mov 0xc012b424,%eax +c01026a4: 40 inc %eax +c01026a5: a3 24 b4 12 c0 mov %eax,0xc012b424 if (ticks % TICK_NUM == 0) -c010273f: 8b 0d 54 e0 12 c0 mov 0xc012e054,%ecx -c0102745: ba 1f 85 eb 51 mov $0x51eb851f,%edx -c010274a: 89 c8 mov %ecx,%eax -c010274c: f7 e2 mul %edx -c010274e: c1 ea 05 shr $0x5,%edx -c0102751: 89 d0 mov %edx,%eax -c0102753: c1 e0 02 shl $0x2,%eax -c0102756: 01 d0 add %edx,%eax -c0102758: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx -c010275f: 01 d0 add %edx,%eax -c0102761: c1 e0 02 shl $0x2,%eax -c0102764: 29 c1 sub %eax,%ecx -c0102766: 89 ca mov %ecx,%edx -c0102768: 85 d2 test %edx,%edx -c010276a: 0f 85 f8 01 00 00 jne c0102968 +c01026aa: 8b 0d 24 b4 12 c0 mov 0xc012b424,%ecx +c01026b0: ba 1f 85 eb 51 mov $0x51eb851f,%edx +c01026b5: 89 c8 mov %ecx,%eax +c01026b7: f7 e2 mul %edx +c01026b9: c1 ea 05 shr $0x5,%edx +c01026bc: 89 d0 mov %edx,%eax +c01026be: c1 e0 02 shl $0x2,%eax +c01026c1: 01 d0 add %edx,%eax +c01026c3: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx +c01026ca: 01 d0 add %edx,%eax +c01026cc: c1 e0 02 shl $0x2,%eax +c01026cf: 29 c1 sub %eax,%ecx +c01026d1: 89 ca mov %ecx,%edx +c01026d3: 85 d2 test %edx,%edx +c01026d5: 0f 85 9e 01 00 00 jne c0102879 { print_ticks(); -c0102770: e8 eb f9 ff ff call c0102160 +c01026db: e8 ff f9 ff ff call c01020df }//每经过 TICK_NUM 次周期时,调用 print_ticks() 打印信息。 break; -c0102775: e9 ee 01 00 00 jmp c0102968 +c01026e0: e9 94 01 00 00 jmp c0102879 //处理串口中断,调用 cons_getc() 从串口读取字符并打印。 case IRQ_OFFSET + IRQ_COM1: c = cons_getc(); -c010277a: e8 74 f7 ff ff call c0101ef3 -c010277f: 88 45 e7 mov %al,-0x19(%ebp) +c01026e5: e8 3b ef ff ff call c0101625 +c01026ea: 88 45 f7 mov %al,-0x9(%ebp) cprintf("serial [%03d] %c\n", c, c); -c0102782: 0f be 55 e7 movsbl -0x19(%ebp),%edx -c0102786: 0f be 45 e7 movsbl -0x19(%ebp),%eax -c010278a: 89 54 24 08 mov %edx,0x8(%esp) -c010278e: 89 44 24 04 mov %eax,0x4(%esp) -c0102792: c7 04 24 1a a9 10 c0 movl $0xc010a91a,(%esp) -c0102799: e8 39 db ff ff call c01002d7 +c01026ed: 0f be 55 f7 movsbl -0x9(%ebp),%edx +c01026f1: 0f be 45 f7 movsbl -0x9(%ebp),%eax +c01026f5: 89 54 24 08 mov %edx,0x8(%esp) +c01026f9: 89 44 24 04 mov %eax,0x4(%esp) +c01026fd: c7 04 24 fa a6 10 c0 movl $0xc010a6fa,(%esp) +c0102704: e8 6f dc ff ff call c0100378 break; -c010279e: e9 cc 01 00 00 jmp c010296f +c0102709: e9 72 01 00 00 jmp c0102880 //处理键盘中断,调用 cons_getc() 读取键盘输入并打印。 case IRQ_OFFSET + IRQ_KBD: c = cons_getc(); -c01027a3: e8 4b f7 ff ff call c0101ef3 -c01027a8: 88 45 e7 mov %al,-0x19(%ebp) +c010270e: e8 12 ef ff ff call c0101625 +c0102713: 88 45 f7 mov %al,-0x9(%ebp) cprintf("kbd [%03d] %c\n", c, c); -c01027ab: 0f be 55 e7 movsbl -0x19(%ebp),%edx -c01027af: 0f be 45 e7 movsbl -0x19(%ebp),%eax -c01027b3: 89 54 24 08 mov %edx,0x8(%esp) -c01027b7: 89 44 24 04 mov %eax,0x4(%esp) -c01027bb: c7 04 24 2c a9 10 c0 movl $0xc010a92c,(%esp) -c01027c2: e8 10 db ff ff call c01002d7 +c0102716: 0f be 55 f7 movsbl -0x9(%ebp),%edx +c010271a: 0f be 45 f7 movsbl -0x9(%ebp),%eax +c010271e: 89 54 24 08 mov %edx,0x8(%esp) +c0102722: 89 44 24 04 mov %eax,0x4(%esp) +c0102726: c7 04 24 0c a7 10 c0 movl $0xc010a70c,(%esp) +c010272d: e8 46 dc ff ff call c0100378 break; -c01027c7: e9 a3 01 00 00 jmp c010296f +c0102732: e9 49 01 00 00 jmp c0102880 //LAB1 CHALLENGE 1 : YOUR CODE you should modify below codes. case T_SWITCH_TOU://表示发生了从内核模式切换到用户模式的请求。 if (tf->tf_cs != USER_CS) {//判断当前是否在内核模式下 -c01027cc: 8b 45 08 mov 0x8(%ebp),%eax -c01027cf: 0f b7 40 3c movzwl 0x3c(%eax),%eax -c01027d3: 83 f8 1b cmp $0x1b,%eax -c01027d6: 0f 84 8f 01 00 00 je c010296b +c0102737: 8b 45 08 mov 0x8(%ebp),%eax +c010273a: 0f b7 40 3c movzwl 0x3c(%eax),%eax +c010273e: 83 f8 1b cmp $0x1b,%eax +c0102741: 0f 84 35 01 00 00 je c010287c switchk2u = *tf; //保存当前陷阱框架 -c01027dc: 8b 55 08 mov 0x8(%ebp),%edx -c01027df: b8 60 e0 12 c0 mov $0xc012e060,%eax -c01027e4: bb 4c 00 00 00 mov $0x4c,%ebx -c01027e9: 89 c1 mov %eax,%ecx -c01027eb: 83 e1 01 and $0x1,%ecx -c01027ee: 85 c9 test %ecx,%ecx -c01027f0: 74 0c je c01027fe -c01027f2: 0f b6 0a movzbl (%edx),%ecx -c01027f5: 88 08 mov %cl,(%eax) -c01027f7: 8d 40 01 lea 0x1(%eax),%eax -c01027fa: 8d 52 01 lea 0x1(%edx),%edx -c01027fd: 4b dec %ebx -c01027fe: 89 c1 mov %eax,%ecx -c0102800: 83 e1 02 and $0x2,%ecx -c0102803: 85 c9 test %ecx,%ecx -c0102805: 74 0f je c0102816 -c0102807: 0f b7 0a movzwl (%edx),%ecx -c010280a: 66 89 08 mov %cx,(%eax) -c010280d: 8d 40 02 lea 0x2(%eax),%eax -c0102810: 8d 52 02 lea 0x2(%edx),%edx -c0102813: 83 eb 02 sub $0x2,%ebx -c0102816: 89 df mov %ebx,%edi -c0102818: 83 e7 fc and $0xfffffffc,%edi -c010281b: b9 00 00 00 00 mov $0x0,%ecx -c0102820: 8b 34 0a mov (%edx,%ecx,1),%esi -c0102823: 89 34 08 mov %esi,(%eax,%ecx,1) -c0102826: 83 c1 04 add $0x4,%ecx -c0102829: 39 f9 cmp %edi,%ecx -c010282b: 72 f3 jb c0102820 -c010282d: 01 c8 add %ecx,%eax -c010282f: 01 ca add %ecx,%edx -c0102831: b9 00 00 00 00 mov $0x0,%ecx -c0102836: 89 de mov %ebx,%esi -c0102838: 83 e6 02 and $0x2,%esi -c010283b: 85 f6 test %esi,%esi -c010283d: 74 0b je c010284a -c010283f: 0f b7 34 0a movzwl (%edx,%ecx,1),%esi -c0102843: 66 89 34 08 mov %si,(%eax,%ecx,1) -c0102847: 83 c1 02 add $0x2,%ecx -c010284a: 83 e3 01 and $0x1,%ebx -c010284d: 85 db test %ebx,%ebx -c010284f: 74 07 je c0102858 -c0102851: 0f b6 14 0a movzbl (%edx,%ecx,1),%edx -c0102855: 88 14 08 mov %dl,(%eax,%ecx,1) +c0102747: 8b 4d 08 mov 0x8(%ebp),%ecx +c010274a: b8 4c 00 00 00 mov $0x4c,%eax +c010274f: 83 e0 fc and $0xfffffffc,%eax +c0102752: 89 c3 mov %eax,%ebx +c0102754: b8 00 00 00 00 mov $0x0,%eax +c0102759: 8b 14 01 mov (%ecx,%eax,1),%edx +c010275c: 89 90 80 b7 12 c0 mov %edx,-0x3fed4880(%eax) +c0102762: 83 c0 04 add $0x4,%eax +c0102765: 39 d8 cmp %ebx,%eax +c0102767: 72 f0 jb c0102759 switchk2u.tf_cs = USER_CS;//设置用户模式的段寄存器 -c0102858: 66 c7 05 9c e0 12 c0 movw $0x1b,0xc012e09c -c010285f: 1b 00 +c0102769: 66 c7 05 bc b7 12 c0 movw $0x1b,0xc012b7bc +c0102770: 1b 00 //将数据段和栈段寄存器 都设置为 USER_DS(用户数据段) switchk2u.tf_ds = switchk2u.tf_es = switchk2u.tf_ss = USER_DS; -c0102861: 66 c7 05 a8 e0 12 c0 movw $0x23,0xc012e0a8 -c0102868: 23 00 -c010286a: 0f b7 05 a8 e0 12 c0 movzwl 0xc012e0a8,%eax -c0102871: 66 a3 88 e0 12 c0 mov %ax,0xc012e088 -c0102877: 0f b7 05 88 e0 12 c0 movzwl 0xc012e088,%eax -c010287e: 66 a3 8c e0 12 c0 mov %ax,0xc012e08c +c0102772: 66 c7 05 c8 b7 12 c0 movw $0x23,0xc012b7c8 +c0102779: 23 00 +c010277b: 0f b7 05 c8 b7 12 c0 movzwl 0xc012b7c8,%eax +c0102782: 66 a3 a8 b7 12 c0 mov %ax,0xc012b7a8 +c0102788: 0f b7 05 a8 b7 12 c0 movzwl 0xc012b7a8,%eax +c010278f: 66 a3 ac b7 12 c0 mov %ax,0xc012b7ac switchk2u.tf_esp = (uint32_t)tf + sizeof(struct trapframe) - 8; -c0102884: 8b 45 08 mov 0x8(%ebp),%eax -c0102887: 83 c0 44 add $0x44,%eax -c010288a: a3 a4 e0 12 c0 mov %eax,0xc012e0a4 +c0102795: 8b 45 08 mov 0x8(%ebp),%eax +c0102798: 83 c0 44 add $0x44,%eax +c010279b: a3 c4 b7 12 c0 mov %eax,0xc012b7c4 // set eflags, make sure ucore can use io under user mode. // if CPL > IOPL, then cpu will generate a general protection. switchk2u.tf_eflags |= FL_IOPL_MASK;//允许用户模式下进行 I/O 操作 -c010288f: a1 a0 e0 12 c0 mov 0xc012e0a0,%eax -c0102894: 0d 00 30 00 00 or $0x3000,%eax -c0102899: a3 a0 e0 12 c0 mov %eax,0xc012e0a0 +c01027a0: a1 c0 b7 12 c0 mov 0xc012b7c0,%eax +c01027a5: 0d 00 30 00 00 or $0x3000,%eax +c01027aa: a3 c0 b7 12 c0 mov %eax,0xc012b7c0 // set temporary stack // then iret will jump to the right stack *((uint32_t *)tf - 1) = (uint32_t)&switchk2u; -c010289e: 8b 45 08 mov 0x8(%ebp),%eax -c01028a1: 83 e8 04 sub $0x4,%eax -c01028a4: ba 60 e0 12 c0 mov $0xc012e060,%edx -c01028a9: 89 10 mov %edx,(%eax) +c01027af: 8b 45 08 mov 0x8(%ebp),%eax +c01027b2: 83 e8 04 sub $0x4,%eax +c01027b5: ba 80 b7 12 c0 mov $0xc012b780,%edx +c01027ba: 89 10 mov %edx,(%eax) } break; -c01028ab: e9 bb 00 00 00 jmp c010296b +c01027bc: e9 bb 00 00 00 jmp c010287c case T_SWITCH_TOK://T_SWITCH_TOK 表示发生了从用户模式切换到内核模式的请求。 if (tf->tf_cs != KERNEL_CS) { //判断当前是否在用户模式下 -c01028b0: 8b 45 08 mov 0x8(%ebp),%eax -c01028b3: 0f b7 40 3c movzwl 0x3c(%eax),%eax -c01028b7: 83 f8 08 cmp $0x8,%eax -c01028ba: 0f 84 ae 00 00 00 je c010296e +c01027c1: 8b 45 08 mov 0x8(%ebp),%eax +c01027c4: 0f b7 40 3c movzwl 0x3c(%eax),%eax +c01027c8: 83 f8 08 cmp $0x8,%eax +c01027cb: 0f 84 ae 00 00 00 je c010287f tf->tf_cs = KERNEL_CS; -c01028c0: 8b 45 08 mov 0x8(%ebp),%eax -c01028c3: 66 c7 40 3c 08 00 movw $0x8,0x3c(%eax) +c01027d1: 8b 45 08 mov 0x8(%ebp),%eax +c01027d4: 66 c7 40 3c 08 00 movw $0x8,0x3c(%eax) tf->tf_ds = tf->tf_es = KERNEL_DS; -c01028c9: 8b 45 08 mov 0x8(%ebp),%eax -c01028cc: 66 c7 40 28 10 00 movw $0x10,0x28(%eax) -c01028d2: 8b 45 08 mov 0x8(%ebp),%eax -c01028d5: 0f b7 50 28 movzwl 0x28(%eax),%edx -c01028d9: 8b 45 08 mov 0x8(%ebp),%eax -c01028dc: 66 89 50 2c mov %dx,0x2c(%eax) +c01027da: 8b 45 08 mov 0x8(%ebp),%eax +c01027dd: 66 c7 40 28 10 00 movw $0x10,0x28(%eax) +c01027e3: 8b 45 08 mov 0x8(%ebp),%eax +c01027e6: 0f b7 50 28 movzwl 0x28(%eax),%edx +c01027ea: 8b 45 08 mov 0x8(%ebp),%eax +c01027ed: 66 89 50 2c mov %dx,0x2c(%eax) //设置内核模式的段寄存器 tf->tf_eflags &= ~FL_IOPL_MASK; //清除 I/O 权限标志 -c01028e0: 8b 45 08 mov 0x8(%ebp),%eax -c01028e3: 8b 40 40 mov 0x40(%eax),%eax -c01028e6: 25 ff cf ff ff and $0xffffcfff,%eax -c01028eb: 89 c2 mov %eax,%edx -c01028ed: 8b 45 08 mov 0x8(%ebp),%eax -c01028f0: 89 50 40 mov %edx,0x40(%eax) +c01027f1: 8b 45 08 mov 0x8(%ebp),%eax +c01027f4: 8b 40 40 mov 0x40(%eax),%eax +c01027f7: 25 ff cf ff ff and $0xffffcfff,%eax +c01027fc: 89 c2 mov %eax,%edx +c01027fe: 8b 45 08 mov 0x8(%ebp),%eax +c0102801: 89 50 40 mov %edx,0x40(%eax) switchu2k = (struct trapframe *)(tf->tf_esp - (sizeof(struct trapframe) - 8)); -c01028f3: 8b 45 08 mov 0x8(%ebp),%eax -c01028f6: 8b 40 44 mov 0x44(%eax),%eax -c01028f9: 83 e8 44 sub $0x44,%eax -c01028fc: a3 ac e0 12 c0 mov %eax,0xc012e0ac +c0102804: 8b 45 08 mov 0x8(%ebp),%eax +c0102807: 8b 40 44 mov 0x44(%eax),%eax +c010280a: 83 e8 44 sub $0x44,%eax +c010280d: a3 cc b7 12 c0 mov %eax,0xc012b7cc //使用 memmove 将当前的陷阱框架(除了最后8个字节)复制到新的陷阱框架位置 switchu2k memmove(switchu2k, tf, sizeof(struct trapframe) - 8); -c0102901: a1 ac e0 12 c0 mov 0xc012e0ac,%eax -c0102906: c7 44 24 08 44 00 00 movl $0x44,0x8(%esp) -c010290d: 00 -c010290e: 8b 55 08 mov 0x8(%ebp),%edx -c0102911: 89 54 24 04 mov %edx,0x4(%esp) -c0102915: 89 04 24 mov %eax,(%esp) -c0102918: e8 7a 70 00 00 call c0109997 +c0102812: a1 cc b7 12 c0 mov 0xc012b7cc,%eax +c0102817: c7 44 24 08 44 00 00 movl $0x44,0x8(%esp) +c010281e: 00 +c010281f: 8b 55 08 mov 0x8(%ebp),%edx +c0102822: 89 54 24 04 mov %edx,0x4(%esp) +c0102826: 89 04 24 mov %eax,(%esp) +c0102829: e8 f8 76 00 00 call c0109f26 //将新的陷阱框架地址 switchu2k 存储到当前陷阱框架之前的一个栈位置 *((uint32_t *)tf - 1) = (uint32_t)switchu2k; -c010291d: 8b 15 ac e0 12 c0 mov 0xc012e0ac,%edx -c0102923: 8b 45 08 mov 0x8(%ebp),%eax -c0102926: 83 e8 04 sub $0x4,%eax -c0102929: 89 10 mov %edx,(%eax) +c010282e: 8b 15 cc b7 12 c0 mov 0xc012b7cc,%edx +c0102834: 8b 45 08 mov 0x8(%ebp),%eax +c0102837: 83 e8 04 sub $0x4,%eax +c010283a: 89 10 mov %edx,(%eax) } break; -c010292b: eb 41 jmp c010296e +c010283c: eb 41 jmp c010287f break; default: // in kernel, it must be a mistake //检查当前陷阱框架的代码段寄存器 tf->tf_cs 的特权级 //(tf->tf_cs & 3) == 0 检查是否在内核模式中 if ((tf->tf_cs & 3) == 0) { -c010292d: 8b 45 08 mov 0x8(%ebp),%eax -c0102930: 0f b7 40 3c movzwl 0x3c(%eax),%eax -c0102934: 83 e0 03 and $0x3,%eax -c0102937: 85 c0 test %eax,%eax -c0102939: 75 34 jne c010296f +c010283e: 8b 45 08 mov 0x8(%ebp),%eax +c0102841: 0f b7 40 3c movzwl 0x3c(%eax),%eax +c0102845: 83 e0 03 and $0x3,%eax +c0102848: 85 c0 test %eax,%eax +c010284a: 75 34 jne c0102880 print_trapframe(tf); -c010293b: 8b 45 08 mov 0x8(%ebp),%eax -c010293e: 89 04 24 mov %eax,(%esp) -c0102941: e8 00 fa ff ff call c0102346 +c010284c: 8b 45 08 mov 0x8(%ebp),%eax +c010284f: 89 04 24 mov %eax,(%esp) +c0102852: e8 62 fa ff ff call c01022b9 panic("unexpected trap in kernel.\n"); -c0102946: c7 44 24 08 3b a9 10 movl $0xc010a93b,0x8(%esp) -c010294d: c0 -c010294e: c7 44 24 04 2f 01 00 movl $0x12f,0x4(%esp) -c0102955: 00 -c0102956: c7 04 24 ee a8 10 c0 movl $0xc010a8ee,(%esp) -c010295d: e8 e1 da ff ff call c0100443 <__panic> +c0102857: c7 44 24 08 1b a7 10 movl $0xc010a71b,0x8(%esp) +c010285e: c0 +c010285f: c7 44 24 04 2f 01 00 movl $0x12f,0x4(%esp) +c0102866: 00 +c0102867: c7 04 24 ce a6 10 c0 movl $0xc010a6ce,(%esp) +c010286e: e8 d2 e3 ff ff call c0100c45 <__panic> break; -c0102962: 90 nop -c0102963: eb 0a jmp c010296f +c0102873: 90 nop +c0102874: eb 0a jmp c0102880 break; -c0102965: 90 nop -c0102966: eb 07 jmp c010296f +c0102876: 90 nop +c0102877: eb 07 jmp c0102880 break; -c0102968: 90 nop -c0102969: eb 04 jmp c010296f +c0102879: 90 nop +c010287a: eb 04 jmp c0102880 break; -c010296b: 90 nop -c010296c: eb 01 jmp c010296f +c010287c: 90 nop +c010287d: eb 01 jmp c0102880 break; -c010296e: 90 nop +c010287f: 90 nop } } } -c010296f: 90 nop -c0102970: 83 c4 2c add $0x2c,%esp -c0102973: 5b pop %ebx -c0102974: 5e pop %esi -c0102975: 5f pop %edi -c0102976: 5d pop %ebp -c0102977: c3 ret +c0102880: 90 nop +c0102881: 8b 5d fc mov -0x4(%ebp),%ebx +c0102884: 89 ec mov %ebp,%esp +c0102886: 5d pop %ebp +c0102887: c3 ret -c0102978 : +c0102888 : * trap - handles or dispatches an exception/interrupt. if and when trap() returns, * the code in kern/trap/trapentry.S restores the old CPU state saved in the * trapframe and then uses the iret instruction to return from the exception. * */ void trap(struct trapframe *tf) { -c0102978: f3 0f 1e fb endbr32 -c010297c: 55 push %ebp -c010297d: 89 e5 mov %esp,%ebp -c010297f: 83 ec 18 sub $0x18,%esp +c0102888: 55 push %ebp +c0102889: 89 e5 mov %esp,%ebp +c010288b: 83 ec 18 sub $0x18,%esp // dispatch based on what type of trap occurred //该行代码调用 trap_dispatch 函数,将陷阱帧传递给它。 trap_dispatch(tf); -c0102982: 8b 45 08 mov 0x8(%ebp),%eax -c0102985: 89 04 24 mov %eax,(%esp) -c0102988: e8 0a fd ff ff call c0102697 +c010288e: 8b 45 08 mov 0x8(%ebp),%eax +c0102891: 89 04 24 mov %eax,(%esp) +c0102894: e8 6e fd ff ff call c0102607 } -c010298d: 90 nop -c010298e: c9 leave -c010298f: c3 ret +c0102899: 90 nop +c010289a: 89 ec mov %ebp,%esp +c010289c: 5d pop %ebp +c010289d: c3 ret -c0102990 : -# handler -.text +c010289e <__alltraps>: .globl __alltraps -.globl vector0 -vector0: - pushl $0 -c0102990: 6a 00 push $0x0 - pushl $0 -c0102992: 6a 00 push $0x0 - jmp __alltraps -c0102994: e9 69 0a 00 00 jmp c0103402 <__alltraps> +__alltraps: + # push registers to build a trap frame + # therefore make the stack look like a struct trapframe + # 通过 push 指令,将数据段寄存器和所有通用寄存器(使用 pushal)的值压入栈中,以保存当前状态。 + pushl %ds +c010289e: 1e push %ds + pushl %es +c010289f: 06 push %es + pushl %fs +c01028a0: 0f a0 push %fs + pushl %gs +c01028a2: 0f a8 push %gs + pushal +c01028a4: 60 pusha -c0102999 : -.globl vector1 -vector1: - pushl $0 -c0102999: 6a 00 push $0x0 - pushl $1 -c010299b: 6a 01 push $0x1 - jmp __alltraps -c010299d: e9 60 0a 00 00 jmp c0103402 <__alltraps> + # load GD_KDATA into %ds and %es to set up data segments for kernel + # 将常量 GD_KDATA 加载到 %eax 中,然后将其值复制到 %ds 和 %es 中,设置内核的数据段。 + movl $GD_KDATA, %eax +c01028a5: b8 10 00 00 00 mov $0x10,%eax + movw %ax, %ds +c01028aa: 8e d8 mov %eax,%ds + movw %ax, %es +c01028ac: 8e c0 mov %eax,%es -c01029a2 : + # push %esp to pass a pointer to the trapframe as an argument to trap() + # 将 %esp 压栈,以将指向 trapframe 的指针作为参数传递给 trap() + pushl %esp +c01028ae: 54 push %esp + + # call trap(tf), where tf=%esp + # 调用 trap(tf),其中 tf=%esp + call trap +c01028af: e8 d4 ff ff ff call c0102888 + + # pop the pushed stack pointer弹出之前压入的栈指针 + popl %esp +c01028b4: 5c pop %esp + +c01028b5 <__trapret>: + # 返回后继续执行到 trapret... +.globl __trapret +__trapret: + # restore registers from stack + # 定义了返回的入口点 __trapret。 + popal +c01028b5: 61 popa + + # restore %ds, %es, %fs and %gs + # 这里会恢复之前保存的寄存器 + popl %gs +c01028b6: 0f a9 pop %gs + popl %fs +c01028b8: 0f a1 pop %fs + popl %es +c01028ba: 07 pop %es + popl %ds +c01028bb: 1f pop %ds + + # get rid of the trap number and error code + # 通过 iret 指令返回中断处理 + addl $0x8, %esp +c01028bc: 83 c4 08 add $0x8,%esp + iret +c01028bf: cf iret + +c01028c0 : + +.globl forkrets +forkrets: + # set stack to this new process's trapframe + movl 4(%esp), %esp +c01028c0: 8b 64 24 04 mov 0x4(%esp),%esp + jmp __trapret +c01028c4: eb ef jmp c01028b5 <__trapret> + +c01028c6 : +# handler +.text +.globl __alltraps +.globl vector0 +vector0: + pushl $0 +c01028c6: 6a 00 push $0x0 + pushl $0 +c01028c8: 6a 00 push $0x0 + jmp __alltraps +c01028ca: e9 cf ff ff ff jmp c010289e <__alltraps> + +c01028cf : +.globl vector1 +vector1: + pushl $0 +c01028cf: 6a 00 push $0x0 + pushl $1 +c01028d1: 6a 01 push $0x1 + jmp __alltraps +c01028d3: e9 c6 ff ff ff jmp c010289e <__alltraps> + +c01028d8 : .globl vector2 vector2: pushl $0 -c01029a2: 6a 00 push $0x0 +c01028d8: 6a 00 push $0x0 pushl $2 -c01029a4: 6a 02 push $0x2 +c01028da: 6a 02 push $0x2 jmp __alltraps -c01029a6: e9 57 0a 00 00 jmp c0103402 <__alltraps> +c01028dc: e9 bd ff ff ff jmp c010289e <__alltraps> -c01029ab : +c01028e1 : .globl vector3 vector3: pushl $0 -c01029ab: 6a 00 push $0x0 +c01028e1: 6a 00 push $0x0 pushl $3 -c01029ad: 6a 03 push $0x3 +c01028e3: 6a 03 push $0x3 jmp __alltraps -c01029af: e9 4e 0a 00 00 jmp c0103402 <__alltraps> +c01028e5: e9 b4 ff ff ff jmp c010289e <__alltraps> -c01029b4 : +c01028ea : .globl vector4 vector4: pushl $0 -c01029b4: 6a 00 push $0x0 +c01028ea: 6a 00 push $0x0 pushl $4 -c01029b6: 6a 04 push $0x4 +c01028ec: 6a 04 push $0x4 jmp __alltraps -c01029b8: e9 45 0a 00 00 jmp c0103402 <__alltraps> +c01028ee: e9 ab ff ff ff jmp c010289e <__alltraps> -c01029bd : +c01028f3 : .globl vector5 vector5: pushl $0 -c01029bd: 6a 00 push $0x0 +c01028f3: 6a 00 push $0x0 pushl $5 -c01029bf: 6a 05 push $0x5 +c01028f5: 6a 05 push $0x5 jmp __alltraps -c01029c1: e9 3c 0a 00 00 jmp c0103402 <__alltraps> +c01028f7: e9 a2 ff ff ff jmp c010289e <__alltraps> -c01029c6 : +c01028fc : .globl vector6 vector6: pushl $0 -c01029c6: 6a 00 push $0x0 +c01028fc: 6a 00 push $0x0 pushl $6 -c01029c8: 6a 06 push $0x6 +c01028fe: 6a 06 push $0x6 jmp __alltraps -c01029ca: e9 33 0a 00 00 jmp c0103402 <__alltraps> +c0102900: e9 99 ff ff ff jmp c010289e <__alltraps> -c01029cf : +c0102905 : .globl vector7 vector7: pushl $0 -c01029cf: 6a 00 push $0x0 +c0102905: 6a 00 push $0x0 pushl $7 -c01029d1: 6a 07 push $0x7 +c0102907: 6a 07 push $0x7 jmp __alltraps -c01029d3: e9 2a 0a 00 00 jmp c0103402 <__alltraps> +c0102909: e9 90 ff ff ff jmp c010289e <__alltraps> -c01029d8 : +c010290e : .globl vector8 vector8: pushl $8 -c01029d8: 6a 08 push $0x8 +c010290e: 6a 08 push $0x8 jmp __alltraps -c01029da: e9 23 0a 00 00 jmp c0103402 <__alltraps> +c0102910: e9 89 ff ff ff jmp c010289e <__alltraps> -c01029df : +c0102915 : .globl vector9 vector9: pushl $0 -c01029df: 6a 00 push $0x0 +c0102915: 6a 00 push $0x0 pushl $9 -c01029e1: 6a 09 push $0x9 +c0102917: 6a 09 push $0x9 jmp __alltraps -c01029e3: e9 1a 0a 00 00 jmp c0103402 <__alltraps> +c0102919: e9 80 ff ff ff jmp c010289e <__alltraps> -c01029e8 : +c010291e : .globl vector10 vector10: pushl $10 -c01029e8: 6a 0a push $0xa +c010291e: 6a 0a push $0xa jmp __alltraps -c01029ea: e9 13 0a 00 00 jmp c0103402 <__alltraps> +c0102920: e9 79 ff ff ff jmp c010289e <__alltraps> -c01029ef : +c0102925 : .globl vector11 vector11: pushl $11 -c01029ef: 6a 0b push $0xb +c0102925: 6a 0b push $0xb jmp __alltraps -c01029f1: e9 0c 0a 00 00 jmp c0103402 <__alltraps> +c0102927: e9 72 ff ff ff jmp c010289e <__alltraps> -c01029f6 : +c010292c : .globl vector12 vector12: pushl $12 -c01029f6: 6a 0c push $0xc +c010292c: 6a 0c push $0xc jmp __alltraps -c01029f8: e9 05 0a 00 00 jmp c0103402 <__alltraps> +c010292e: e9 6b ff ff ff jmp c010289e <__alltraps> -c01029fd : +c0102933 : .globl vector13 vector13: pushl $13 -c01029fd: 6a 0d push $0xd +c0102933: 6a 0d push $0xd jmp __alltraps -c01029ff: e9 fe 09 00 00 jmp c0103402 <__alltraps> +c0102935: e9 64 ff ff ff jmp c010289e <__alltraps> -c0102a04 : +c010293a : .globl vector14 vector14: pushl $14 -c0102a04: 6a 0e push $0xe +c010293a: 6a 0e push $0xe jmp __alltraps -c0102a06: e9 f7 09 00 00 jmp c0103402 <__alltraps> +c010293c: e9 5d ff ff ff jmp c010289e <__alltraps> -c0102a0b : +c0102941 : .globl vector15 vector15: pushl $0 -c0102a0b: 6a 00 push $0x0 +c0102941: 6a 00 push $0x0 pushl $15 -c0102a0d: 6a 0f push $0xf +c0102943: 6a 0f push $0xf jmp __alltraps -c0102a0f: e9 ee 09 00 00 jmp c0103402 <__alltraps> +c0102945: e9 54 ff ff ff jmp c010289e <__alltraps> -c0102a14 : +c010294a : .globl vector16 vector16: pushl $0 -c0102a14: 6a 00 push $0x0 +c010294a: 6a 00 push $0x0 pushl $16 -c0102a16: 6a 10 push $0x10 +c010294c: 6a 10 push $0x10 jmp __alltraps -c0102a18: e9 e5 09 00 00 jmp c0103402 <__alltraps> +c010294e: e9 4b ff ff ff jmp c010289e <__alltraps> -c0102a1d : +c0102953 : .globl vector17 vector17: pushl $17 -c0102a1d: 6a 11 push $0x11 +c0102953: 6a 11 push $0x11 jmp __alltraps -c0102a1f: e9 de 09 00 00 jmp c0103402 <__alltraps> +c0102955: e9 44 ff ff ff jmp c010289e <__alltraps> -c0102a24 : +c010295a : .globl vector18 vector18: pushl $0 -c0102a24: 6a 00 push $0x0 +c010295a: 6a 00 push $0x0 pushl $18 -c0102a26: 6a 12 push $0x12 +c010295c: 6a 12 push $0x12 jmp __alltraps -c0102a28: e9 d5 09 00 00 jmp c0103402 <__alltraps> +c010295e: e9 3b ff ff ff jmp c010289e <__alltraps> -c0102a2d : +c0102963 : .globl vector19 vector19: pushl $0 -c0102a2d: 6a 00 push $0x0 +c0102963: 6a 00 push $0x0 pushl $19 -c0102a2f: 6a 13 push $0x13 +c0102965: 6a 13 push $0x13 jmp __alltraps -c0102a31: e9 cc 09 00 00 jmp c0103402 <__alltraps> +c0102967: e9 32 ff ff ff jmp c010289e <__alltraps> -c0102a36 : +c010296c : .globl vector20 vector20: pushl $0 -c0102a36: 6a 00 push $0x0 +c010296c: 6a 00 push $0x0 pushl $20 -c0102a38: 6a 14 push $0x14 +c010296e: 6a 14 push $0x14 jmp __alltraps -c0102a3a: e9 c3 09 00 00 jmp c0103402 <__alltraps> +c0102970: e9 29 ff ff ff jmp c010289e <__alltraps> -c0102a3f : +c0102975 : .globl vector21 vector21: pushl $0 -c0102a3f: 6a 00 push $0x0 +c0102975: 6a 00 push $0x0 pushl $21 -c0102a41: 6a 15 push $0x15 +c0102977: 6a 15 push $0x15 jmp __alltraps -c0102a43: e9 ba 09 00 00 jmp c0103402 <__alltraps> +c0102979: e9 20 ff ff ff jmp c010289e <__alltraps> -c0102a48 : +c010297e : .globl vector22 vector22: pushl $0 -c0102a48: 6a 00 push $0x0 +c010297e: 6a 00 push $0x0 pushl $22 -c0102a4a: 6a 16 push $0x16 +c0102980: 6a 16 push $0x16 jmp __alltraps -c0102a4c: e9 b1 09 00 00 jmp c0103402 <__alltraps> +c0102982: e9 17 ff ff ff jmp c010289e <__alltraps> -c0102a51 : +c0102987 : .globl vector23 vector23: pushl $0 -c0102a51: 6a 00 push $0x0 +c0102987: 6a 00 push $0x0 pushl $23 -c0102a53: 6a 17 push $0x17 +c0102989: 6a 17 push $0x17 jmp __alltraps -c0102a55: e9 a8 09 00 00 jmp c0103402 <__alltraps> +c010298b: e9 0e ff ff ff jmp c010289e <__alltraps> -c0102a5a : +c0102990 : .globl vector24 vector24: pushl $0 -c0102a5a: 6a 00 push $0x0 +c0102990: 6a 00 push $0x0 pushl $24 -c0102a5c: 6a 18 push $0x18 +c0102992: 6a 18 push $0x18 jmp __alltraps -c0102a5e: e9 9f 09 00 00 jmp c0103402 <__alltraps> +c0102994: e9 05 ff ff ff jmp c010289e <__alltraps> -c0102a63 : +c0102999 : .globl vector25 vector25: pushl $0 -c0102a63: 6a 00 push $0x0 +c0102999: 6a 00 push $0x0 pushl $25 -c0102a65: 6a 19 push $0x19 +c010299b: 6a 19 push $0x19 jmp __alltraps -c0102a67: e9 96 09 00 00 jmp c0103402 <__alltraps> +c010299d: e9 fc fe ff ff jmp c010289e <__alltraps> -c0102a6c : +c01029a2 : .globl vector26 vector26: pushl $0 -c0102a6c: 6a 00 push $0x0 +c01029a2: 6a 00 push $0x0 pushl $26 -c0102a6e: 6a 1a push $0x1a +c01029a4: 6a 1a push $0x1a jmp __alltraps -c0102a70: e9 8d 09 00 00 jmp c0103402 <__alltraps> +c01029a6: e9 f3 fe ff ff jmp c010289e <__alltraps> -c0102a75 : +c01029ab : .globl vector27 vector27: pushl $0 -c0102a75: 6a 00 push $0x0 +c01029ab: 6a 00 push $0x0 pushl $27 -c0102a77: 6a 1b push $0x1b +c01029ad: 6a 1b push $0x1b jmp __alltraps -c0102a79: e9 84 09 00 00 jmp c0103402 <__alltraps> +c01029af: e9 ea fe ff ff jmp c010289e <__alltraps> -c0102a7e : +c01029b4 : .globl vector28 vector28: pushl $0 -c0102a7e: 6a 00 push $0x0 +c01029b4: 6a 00 push $0x0 pushl $28 -c0102a80: 6a 1c push $0x1c +c01029b6: 6a 1c push $0x1c jmp __alltraps -c0102a82: e9 7b 09 00 00 jmp c0103402 <__alltraps> +c01029b8: e9 e1 fe ff ff jmp c010289e <__alltraps> -c0102a87 : +c01029bd : .globl vector29 vector29: pushl $0 -c0102a87: 6a 00 push $0x0 +c01029bd: 6a 00 push $0x0 pushl $29 -c0102a89: 6a 1d push $0x1d +c01029bf: 6a 1d push $0x1d jmp __alltraps -c0102a8b: e9 72 09 00 00 jmp c0103402 <__alltraps> +c01029c1: e9 d8 fe ff ff jmp c010289e <__alltraps> -c0102a90 : +c01029c6 : .globl vector30 vector30: pushl $0 -c0102a90: 6a 00 push $0x0 +c01029c6: 6a 00 push $0x0 pushl $30 -c0102a92: 6a 1e push $0x1e +c01029c8: 6a 1e push $0x1e jmp __alltraps -c0102a94: e9 69 09 00 00 jmp c0103402 <__alltraps> +c01029ca: e9 cf fe ff ff jmp c010289e <__alltraps> -c0102a99 : +c01029cf : .globl vector31 vector31: pushl $0 -c0102a99: 6a 00 push $0x0 +c01029cf: 6a 00 push $0x0 pushl $31 -c0102a9b: 6a 1f push $0x1f +c01029d1: 6a 1f push $0x1f jmp __alltraps -c0102a9d: e9 60 09 00 00 jmp c0103402 <__alltraps> +c01029d3: e9 c6 fe ff ff jmp c010289e <__alltraps> -c0102aa2 : +c01029d8 : .globl vector32 vector32: pushl $0 -c0102aa2: 6a 00 push $0x0 +c01029d8: 6a 00 push $0x0 pushl $32 -c0102aa4: 6a 20 push $0x20 +c01029da: 6a 20 push $0x20 jmp __alltraps -c0102aa6: e9 57 09 00 00 jmp c0103402 <__alltraps> +c01029dc: e9 bd fe ff ff jmp c010289e <__alltraps> -c0102aab : +c01029e1 : .globl vector33 vector33: pushl $0 -c0102aab: 6a 00 push $0x0 +c01029e1: 6a 00 push $0x0 pushl $33 -c0102aad: 6a 21 push $0x21 +c01029e3: 6a 21 push $0x21 jmp __alltraps -c0102aaf: e9 4e 09 00 00 jmp c0103402 <__alltraps> +c01029e5: e9 b4 fe ff ff jmp c010289e <__alltraps> -c0102ab4 : +c01029ea : .globl vector34 vector34: pushl $0 -c0102ab4: 6a 00 push $0x0 +c01029ea: 6a 00 push $0x0 pushl $34 -c0102ab6: 6a 22 push $0x22 +c01029ec: 6a 22 push $0x22 jmp __alltraps -c0102ab8: e9 45 09 00 00 jmp c0103402 <__alltraps> +c01029ee: e9 ab fe ff ff jmp c010289e <__alltraps> -c0102abd : +c01029f3 : .globl vector35 vector35: pushl $0 -c0102abd: 6a 00 push $0x0 +c01029f3: 6a 00 push $0x0 pushl $35 -c0102abf: 6a 23 push $0x23 +c01029f5: 6a 23 push $0x23 jmp __alltraps -c0102ac1: e9 3c 09 00 00 jmp c0103402 <__alltraps> +c01029f7: e9 a2 fe ff ff jmp c010289e <__alltraps> -c0102ac6 : +c01029fc : .globl vector36 vector36: pushl $0 -c0102ac6: 6a 00 push $0x0 +c01029fc: 6a 00 push $0x0 pushl $36 -c0102ac8: 6a 24 push $0x24 +c01029fe: 6a 24 push $0x24 jmp __alltraps -c0102aca: e9 33 09 00 00 jmp c0103402 <__alltraps> +c0102a00: e9 99 fe ff ff jmp c010289e <__alltraps> -c0102acf : +c0102a05 : .globl vector37 vector37: pushl $0 -c0102acf: 6a 00 push $0x0 +c0102a05: 6a 00 push $0x0 pushl $37 -c0102ad1: 6a 25 push $0x25 +c0102a07: 6a 25 push $0x25 jmp __alltraps -c0102ad3: e9 2a 09 00 00 jmp c0103402 <__alltraps> +c0102a09: e9 90 fe ff ff jmp c010289e <__alltraps> -c0102ad8 : +c0102a0e : .globl vector38 vector38: pushl $0 -c0102ad8: 6a 00 push $0x0 +c0102a0e: 6a 00 push $0x0 pushl $38 -c0102ada: 6a 26 push $0x26 +c0102a10: 6a 26 push $0x26 jmp __alltraps -c0102adc: e9 21 09 00 00 jmp c0103402 <__alltraps> +c0102a12: e9 87 fe ff ff jmp c010289e <__alltraps> -c0102ae1 : +c0102a17 : .globl vector39 vector39: pushl $0 -c0102ae1: 6a 00 push $0x0 +c0102a17: 6a 00 push $0x0 pushl $39 -c0102ae3: 6a 27 push $0x27 +c0102a19: 6a 27 push $0x27 jmp __alltraps -c0102ae5: e9 18 09 00 00 jmp c0103402 <__alltraps> +c0102a1b: e9 7e fe ff ff jmp c010289e <__alltraps> -c0102aea : +c0102a20 : .globl vector40 vector40: pushl $0 -c0102aea: 6a 00 push $0x0 +c0102a20: 6a 00 push $0x0 pushl $40 -c0102aec: 6a 28 push $0x28 +c0102a22: 6a 28 push $0x28 jmp __alltraps -c0102aee: e9 0f 09 00 00 jmp c0103402 <__alltraps> +c0102a24: e9 75 fe ff ff jmp c010289e <__alltraps> -c0102af3 : +c0102a29 : .globl vector41 vector41: pushl $0 -c0102af3: 6a 00 push $0x0 +c0102a29: 6a 00 push $0x0 pushl $41 -c0102af5: 6a 29 push $0x29 +c0102a2b: 6a 29 push $0x29 jmp __alltraps -c0102af7: e9 06 09 00 00 jmp c0103402 <__alltraps> +c0102a2d: e9 6c fe ff ff jmp c010289e <__alltraps> -c0102afc : +c0102a32 : .globl vector42 vector42: pushl $0 -c0102afc: 6a 00 push $0x0 +c0102a32: 6a 00 push $0x0 pushl $42 -c0102afe: 6a 2a push $0x2a +c0102a34: 6a 2a push $0x2a jmp __alltraps -c0102b00: e9 fd 08 00 00 jmp c0103402 <__alltraps> +c0102a36: e9 63 fe ff ff jmp c010289e <__alltraps> -c0102b05 : +c0102a3b : .globl vector43 vector43: pushl $0 -c0102b05: 6a 00 push $0x0 +c0102a3b: 6a 00 push $0x0 pushl $43 -c0102b07: 6a 2b push $0x2b +c0102a3d: 6a 2b push $0x2b jmp __alltraps -c0102b09: e9 f4 08 00 00 jmp c0103402 <__alltraps> +c0102a3f: e9 5a fe ff ff jmp c010289e <__alltraps> -c0102b0e : +c0102a44 : .globl vector44 vector44: pushl $0 -c0102b0e: 6a 00 push $0x0 +c0102a44: 6a 00 push $0x0 pushl $44 -c0102b10: 6a 2c push $0x2c +c0102a46: 6a 2c push $0x2c jmp __alltraps -c0102b12: e9 eb 08 00 00 jmp c0103402 <__alltraps> +c0102a48: e9 51 fe ff ff jmp c010289e <__alltraps> -c0102b17 : +c0102a4d : .globl vector45 vector45: pushl $0 -c0102b17: 6a 00 push $0x0 +c0102a4d: 6a 00 push $0x0 pushl $45 -c0102b19: 6a 2d push $0x2d +c0102a4f: 6a 2d push $0x2d jmp __alltraps -c0102b1b: e9 e2 08 00 00 jmp c0103402 <__alltraps> +c0102a51: e9 48 fe ff ff jmp c010289e <__alltraps> -c0102b20 : +c0102a56 : .globl vector46 vector46: pushl $0 -c0102b20: 6a 00 push $0x0 +c0102a56: 6a 00 push $0x0 pushl $46 -c0102b22: 6a 2e push $0x2e +c0102a58: 6a 2e push $0x2e jmp __alltraps -c0102b24: e9 d9 08 00 00 jmp c0103402 <__alltraps> +c0102a5a: e9 3f fe ff ff jmp c010289e <__alltraps> -c0102b29 : +c0102a5f : .globl vector47 vector47: pushl $0 -c0102b29: 6a 00 push $0x0 +c0102a5f: 6a 00 push $0x0 pushl $47 -c0102b2b: 6a 2f push $0x2f +c0102a61: 6a 2f push $0x2f jmp __alltraps -c0102b2d: e9 d0 08 00 00 jmp c0103402 <__alltraps> +c0102a63: e9 36 fe ff ff jmp c010289e <__alltraps> -c0102b32 : +c0102a68 : .globl vector48 vector48: pushl $0 -c0102b32: 6a 00 push $0x0 +c0102a68: 6a 00 push $0x0 pushl $48 -c0102b34: 6a 30 push $0x30 +c0102a6a: 6a 30 push $0x30 jmp __alltraps -c0102b36: e9 c7 08 00 00 jmp c0103402 <__alltraps> +c0102a6c: e9 2d fe ff ff jmp c010289e <__alltraps> -c0102b3b : +c0102a71 : .globl vector49 vector49: pushl $0 -c0102b3b: 6a 00 push $0x0 +c0102a71: 6a 00 push $0x0 pushl $49 -c0102b3d: 6a 31 push $0x31 +c0102a73: 6a 31 push $0x31 jmp __alltraps -c0102b3f: e9 be 08 00 00 jmp c0103402 <__alltraps> +c0102a75: e9 24 fe ff ff jmp c010289e <__alltraps> -c0102b44 : +c0102a7a : .globl vector50 vector50: pushl $0 -c0102b44: 6a 00 push $0x0 +c0102a7a: 6a 00 push $0x0 pushl $50 -c0102b46: 6a 32 push $0x32 +c0102a7c: 6a 32 push $0x32 jmp __alltraps -c0102b48: e9 b5 08 00 00 jmp c0103402 <__alltraps> +c0102a7e: e9 1b fe ff ff jmp c010289e <__alltraps> -c0102b4d : +c0102a83 : .globl vector51 vector51: pushl $0 -c0102b4d: 6a 00 push $0x0 +c0102a83: 6a 00 push $0x0 pushl $51 -c0102b4f: 6a 33 push $0x33 +c0102a85: 6a 33 push $0x33 jmp __alltraps -c0102b51: e9 ac 08 00 00 jmp c0103402 <__alltraps> +c0102a87: e9 12 fe ff ff jmp c010289e <__alltraps> -c0102b56 : +c0102a8c : .globl vector52 vector52: pushl $0 -c0102b56: 6a 00 push $0x0 +c0102a8c: 6a 00 push $0x0 pushl $52 -c0102b58: 6a 34 push $0x34 +c0102a8e: 6a 34 push $0x34 jmp __alltraps -c0102b5a: e9 a3 08 00 00 jmp c0103402 <__alltraps> +c0102a90: e9 09 fe ff ff jmp c010289e <__alltraps> -c0102b5f : +c0102a95 : .globl vector53 vector53: pushl $0 -c0102b5f: 6a 00 push $0x0 +c0102a95: 6a 00 push $0x0 pushl $53 -c0102b61: 6a 35 push $0x35 +c0102a97: 6a 35 push $0x35 jmp __alltraps -c0102b63: e9 9a 08 00 00 jmp c0103402 <__alltraps> +c0102a99: e9 00 fe ff ff jmp c010289e <__alltraps> -c0102b68 : +c0102a9e : .globl vector54 vector54: pushl $0 -c0102b68: 6a 00 push $0x0 +c0102a9e: 6a 00 push $0x0 pushl $54 -c0102b6a: 6a 36 push $0x36 +c0102aa0: 6a 36 push $0x36 jmp __alltraps -c0102b6c: e9 91 08 00 00 jmp c0103402 <__alltraps> +c0102aa2: e9 f7 fd ff ff jmp c010289e <__alltraps> -c0102b71 : +c0102aa7 : .globl vector55 vector55: pushl $0 -c0102b71: 6a 00 push $0x0 +c0102aa7: 6a 00 push $0x0 pushl $55 -c0102b73: 6a 37 push $0x37 +c0102aa9: 6a 37 push $0x37 jmp __alltraps -c0102b75: e9 88 08 00 00 jmp c0103402 <__alltraps> +c0102aab: e9 ee fd ff ff jmp c010289e <__alltraps> -c0102b7a : +c0102ab0 : .globl vector56 vector56: pushl $0 -c0102b7a: 6a 00 push $0x0 +c0102ab0: 6a 00 push $0x0 pushl $56 -c0102b7c: 6a 38 push $0x38 +c0102ab2: 6a 38 push $0x38 jmp __alltraps -c0102b7e: e9 7f 08 00 00 jmp c0103402 <__alltraps> +c0102ab4: e9 e5 fd ff ff jmp c010289e <__alltraps> -c0102b83 : +c0102ab9 : .globl vector57 vector57: pushl $0 -c0102b83: 6a 00 push $0x0 +c0102ab9: 6a 00 push $0x0 pushl $57 -c0102b85: 6a 39 push $0x39 +c0102abb: 6a 39 push $0x39 jmp __alltraps -c0102b87: e9 76 08 00 00 jmp c0103402 <__alltraps> +c0102abd: e9 dc fd ff ff jmp c010289e <__alltraps> -c0102b8c : +c0102ac2 : .globl vector58 vector58: pushl $0 -c0102b8c: 6a 00 push $0x0 +c0102ac2: 6a 00 push $0x0 pushl $58 -c0102b8e: 6a 3a push $0x3a +c0102ac4: 6a 3a push $0x3a jmp __alltraps -c0102b90: e9 6d 08 00 00 jmp c0103402 <__alltraps> +c0102ac6: e9 d3 fd ff ff jmp c010289e <__alltraps> -c0102b95 : +c0102acb : .globl vector59 vector59: pushl $0 -c0102b95: 6a 00 push $0x0 +c0102acb: 6a 00 push $0x0 pushl $59 -c0102b97: 6a 3b push $0x3b +c0102acd: 6a 3b push $0x3b jmp __alltraps -c0102b99: e9 64 08 00 00 jmp c0103402 <__alltraps> +c0102acf: e9 ca fd ff ff jmp c010289e <__alltraps> -c0102b9e : +c0102ad4 : .globl vector60 vector60: pushl $0 -c0102b9e: 6a 00 push $0x0 +c0102ad4: 6a 00 push $0x0 pushl $60 -c0102ba0: 6a 3c push $0x3c +c0102ad6: 6a 3c push $0x3c jmp __alltraps -c0102ba2: e9 5b 08 00 00 jmp c0103402 <__alltraps> +c0102ad8: e9 c1 fd ff ff jmp c010289e <__alltraps> -c0102ba7 : +c0102add : .globl vector61 vector61: pushl $0 -c0102ba7: 6a 00 push $0x0 +c0102add: 6a 00 push $0x0 pushl $61 -c0102ba9: 6a 3d push $0x3d +c0102adf: 6a 3d push $0x3d jmp __alltraps -c0102bab: e9 52 08 00 00 jmp c0103402 <__alltraps> +c0102ae1: e9 b8 fd ff ff jmp c010289e <__alltraps> -c0102bb0 : +c0102ae6 : .globl vector62 vector62: pushl $0 -c0102bb0: 6a 00 push $0x0 +c0102ae6: 6a 00 push $0x0 pushl $62 -c0102bb2: 6a 3e push $0x3e +c0102ae8: 6a 3e push $0x3e jmp __alltraps -c0102bb4: e9 49 08 00 00 jmp c0103402 <__alltraps> +c0102aea: e9 af fd ff ff jmp c010289e <__alltraps> -c0102bb9 : +c0102aef : .globl vector63 vector63: pushl $0 -c0102bb9: 6a 00 push $0x0 +c0102aef: 6a 00 push $0x0 pushl $63 -c0102bbb: 6a 3f push $0x3f +c0102af1: 6a 3f push $0x3f jmp __alltraps -c0102bbd: e9 40 08 00 00 jmp c0103402 <__alltraps> +c0102af3: e9 a6 fd ff ff jmp c010289e <__alltraps> -c0102bc2 : +c0102af8 : .globl vector64 vector64: pushl $0 -c0102bc2: 6a 00 push $0x0 +c0102af8: 6a 00 push $0x0 pushl $64 -c0102bc4: 6a 40 push $0x40 +c0102afa: 6a 40 push $0x40 jmp __alltraps -c0102bc6: e9 37 08 00 00 jmp c0103402 <__alltraps> +c0102afc: e9 9d fd ff ff jmp c010289e <__alltraps> -c0102bcb : +c0102b01 : .globl vector65 vector65: pushl $0 -c0102bcb: 6a 00 push $0x0 +c0102b01: 6a 00 push $0x0 pushl $65 -c0102bcd: 6a 41 push $0x41 +c0102b03: 6a 41 push $0x41 jmp __alltraps -c0102bcf: e9 2e 08 00 00 jmp c0103402 <__alltraps> +c0102b05: e9 94 fd ff ff jmp c010289e <__alltraps> -c0102bd4 : +c0102b0a : .globl vector66 vector66: pushl $0 -c0102bd4: 6a 00 push $0x0 +c0102b0a: 6a 00 push $0x0 pushl $66 -c0102bd6: 6a 42 push $0x42 +c0102b0c: 6a 42 push $0x42 jmp __alltraps -c0102bd8: e9 25 08 00 00 jmp c0103402 <__alltraps> +c0102b0e: e9 8b fd ff ff jmp c010289e <__alltraps> -c0102bdd : +c0102b13 : .globl vector67 vector67: pushl $0 -c0102bdd: 6a 00 push $0x0 +c0102b13: 6a 00 push $0x0 pushl $67 -c0102bdf: 6a 43 push $0x43 +c0102b15: 6a 43 push $0x43 jmp __alltraps -c0102be1: e9 1c 08 00 00 jmp c0103402 <__alltraps> +c0102b17: e9 82 fd ff ff jmp c010289e <__alltraps> -c0102be6 : +c0102b1c : .globl vector68 vector68: pushl $0 -c0102be6: 6a 00 push $0x0 +c0102b1c: 6a 00 push $0x0 pushl $68 -c0102be8: 6a 44 push $0x44 +c0102b1e: 6a 44 push $0x44 jmp __alltraps -c0102bea: e9 13 08 00 00 jmp c0103402 <__alltraps> +c0102b20: e9 79 fd ff ff jmp c010289e <__alltraps> -c0102bef : +c0102b25 : .globl vector69 vector69: pushl $0 -c0102bef: 6a 00 push $0x0 +c0102b25: 6a 00 push $0x0 pushl $69 -c0102bf1: 6a 45 push $0x45 +c0102b27: 6a 45 push $0x45 jmp __alltraps -c0102bf3: e9 0a 08 00 00 jmp c0103402 <__alltraps> +c0102b29: e9 70 fd ff ff jmp c010289e <__alltraps> -c0102bf8 : +c0102b2e : .globl vector70 vector70: pushl $0 -c0102bf8: 6a 00 push $0x0 +c0102b2e: 6a 00 push $0x0 pushl $70 -c0102bfa: 6a 46 push $0x46 +c0102b30: 6a 46 push $0x46 jmp __alltraps -c0102bfc: e9 01 08 00 00 jmp c0103402 <__alltraps> +c0102b32: e9 67 fd ff ff jmp c010289e <__alltraps> -c0102c01 : +c0102b37 : .globl vector71 vector71: pushl $0 -c0102c01: 6a 00 push $0x0 +c0102b37: 6a 00 push $0x0 pushl $71 -c0102c03: 6a 47 push $0x47 +c0102b39: 6a 47 push $0x47 jmp __alltraps -c0102c05: e9 f8 07 00 00 jmp c0103402 <__alltraps> +c0102b3b: e9 5e fd ff ff jmp c010289e <__alltraps> -c0102c0a : +c0102b40 : .globl vector72 vector72: pushl $0 -c0102c0a: 6a 00 push $0x0 +c0102b40: 6a 00 push $0x0 pushl $72 -c0102c0c: 6a 48 push $0x48 +c0102b42: 6a 48 push $0x48 jmp __alltraps -c0102c0e: e9 ef 07 00 00 jmp c0103402 <__alltraps> +c0102b44: e9 55 fd ff ff jmp c010289e <__alltraps> -c0102c13 : +c0102b49 : .globl vector73 vector73: pushl $0 -c0102c13: 6a 00 push $0x0 +c0102b49: 6a 00 push $0x0 pushl $73 -c0102c15: 6a 49 push $0x49 +c0102b4b: 6a 49 push $0x49 jmp __alltraps -c0102c17: e9 e6 07 00 00 jmp c0103402 <__alltraps> +c0102b4d: e9 4c fd ff ff jmp c010289e <__alltraps> -c0102c1c : +c0102b52 : .globl vector74 vector74: pushl $0 -c0102c1c: 6a 00 push $0x0 +c0102b52: 6a 00 push $0x0 pushl $74 -c0102c1e: 6a 4a push $0x4a +c0102b54: 6a 4a push $0x4a jmp __alltraps -c0102c20: e9 dd 07 00 00 jmp c0103402 <__alltraps> +c0102b56: e9 43 fd ff ff jmp c010289e <__alltraps> -c0102c25 : +c0102b5b : .globl vector75 vector75: pushl $0 -c0102c25: 6a 00 push $0x0 +c0102b5b: 6a 00 push $0x0 pushl $75 -c0102c27: 6a 4b push $0x4b +c0102b5d: 6a 4b push $0x4b jmp __alltraps -c0102c29: e9 d4 07 00 00 jmp c0103402 <__alltraps> +c0102b5f: e9 3a fd ff ff jmp c010289e <__alltraps> -c0102c2e : +c0102b64 : .globl vector76 vector76: pushl $0 -c0102c2e: 6a 00 push $0x0 +c0102b64: 6a 00 push $0x0 pushl $76 -c0102c30: 6a 4c push $0x4c +c0102b66: 6a 4c push $0x4c jmp __alltraps -c0102c32: e9 cb 07 00 00 jmp c0103402 <__alltraps> +c0102b68: e9 31 fd ff ff jmp c010289e <__alltraps> -c0102c37 : +c0102b6d : .globl vector77 vector77: pushl $0 -c0102c37: 6a 00 push $0x0 +c0102b6d: 6a 00 push $0x0 pushl $77 -c0102c39: 6a 4d push $0x4d +c0102b6f: 6a 4d push $0x4d jmp __alltraps -c0102c3b: e9 c2 07 00 00 jmp c0103402 <__alltraps> +c0102b71: e9 28 fd ff ff jmp c010289e <__alltraps> -c0102c40 : +c0102b76 : .globl vector78 vector78: pushl $0 -c0102c40: 6a 00 push $0x0 +c0102b76: 6a 00 push $0x0 pushl $78 -c0102c42: 6a 4e push $0x4e +c0102b78: 6a 4e push $0x4e jmp __alltraps -c0102c44: e9 b9 07 00 00 jmp c0103402 <__alltraps> +c0102b7a: e9 1f fd ff ff jmp c010289e <__alltraps> -c0102c49 : +c0102b7f : .globl vector79 vector79: pushl $0 -c0102c49: 6a 00 push $0x0 +c0102b7f: 6a 00 push $0x0 pushl $79 -c0102c4b: 6a 4f push $0x4f +c0102b81: 6a 4f push $0x4f jmp __alltraps -c0102c4d: e9 b0 07 00 00 jmp c0103402 <__alltraps> +c0102b83: e9 16 fd ff ff jmp c010289e <__alltraps> -c0102c52 : +c0102b88 : .globl vector80 vector80: pushl $0 -c0102c52: 6a 00 push $0x0 +c0102b88: 6a 00 push $0x0 pushl $80 -c0102c54: 6a 50 push $0x50 +c0102b8a: 6a 50 push $0x50 jmp __alltraps -c0102c56: e9 a7 07 00 00 jmp c0103402 <__alltraps> +c0102b8c: e9 0d fd ff ff jmp c010289e <__alltraps> -c0102c5b : +c0102b91 : .globl vector81 vector81: pushl $0 -c0102c5b: 6a 00 push $0x0 +c0102b91: 6a 00 push $0x0 pushl $81 -c0102c5d: 6a 51 push $0x51 +c0102b93: 6a 51 push $0x51 jmp __alltraps -c0102c5f: e9 9e 07 00 00 jmp c0103402 <__alltraps> +c0102b95: e9 04 fd ff ff jmp c010289e <__alltraps> -c0102c64 : +c0102b9a : .globl vector82 vector82: pushl $0 -c0102c64: 6a 00 push $0x0 +c0102b9a: 6a 00 push $0x0 pushl $82 -c0102c66: 6a 52 push $0x52 +c0102b9c: 6a 52 push $0x52 jmp __alltraps -c0102c68: e9 95 07 00 00 jmp c0103402 <__alltraps> +c0102b9e: e9 fb fc ff ff jmp c010289e <__alltraps> -c0102c6d : +c0102ba3 : .globl vector83 vector83: pushl $0 -c0102c6d: 6a 00 push $0x0 +c0102ba3: 6a 00 push $0x0 pushl $83 -c0102c6f: 6a 53 push $0x53 +c0102ba5: 6a 53 push $0x53 jmp __alltraps -c0102c71: e9 8c 07 00 00 jmp c0103402 <__alltraps> +c0102ba7: e9 f2 fc ff ff jmp c010289e <__alltraps> -c0102c76 : +c0102bac : .globl vector84 vector84: pushl $0 -c0102c76: 6a 00 push $0x0 +c0102bac: 6a 00 push $0x0 pushl $84 -c0102c78: 6a 54 push $0x54 +c0102bae: 6a 54 push $0x54 jmp __alltraps -c0102c7a: e9 83 07 00 00 jmp c0103402 <__alltraps> +c0102bb0: e9 e9 fc ff ff jmp c010289e <__alltraps> -c0102c7f : +c0102bb5 : .globl vector85 vector85: pushl $0 -c0102c7f: 6a 00 push $0x0 +c0102bb5: 6a 00 push $0x0 pushl $85 -c0102c81: 6a 55 push $0x55 +c0102bb7: 6a 55 push $0x55 jmp __alltraps -c0102c83: e9 7a 07 00 00 jmp c0103402 <__alltraps> +c0102bb9: e9 e0 fc ff ff jmp c010289e <__alltraps> -c0102c88 : +c0102bbe : .globl vector86 vector86: pushl $0 -c0102c88: 6a 00 push $0x0 +c0102bbe: 6a 00 push $0x0 pushl $86 -c0102c8a: 6a 56 push $0x56 +c0102bc0: 6a 56 push $0x56 jmp __alltraps -c0102c8c: e9 71 07 00 00 jmp c0103402 <__alltraps> +c0102bc2: e9 d7 fc ff ff jmp c010289e <__alltraps> -c0102c91 : +c0102bc7 : .globl vector87 vector87: pushl $0 -c0102c91: 6a 00 push $0x0 +c0102bc7: 6a 00 push $0x0 pushl $87 -c0102c93: 6a 57 push $0x57 +c0102bc9: 6a 57 push $0x57 jmp __alltraps -c0102c95: e9 68 07 00 00 jmp c0103402 <__alltraps> +c0102bcb: e9 ce fc ff ff jmp c010289e <__alltraps> -c0102c9a : +c0102bd0 : .globl vector88 vector88: pushl $0 -c0102c9a: 6a 00 push $0x0 +c0102bd0: 6a 00 push $0x0 pushl $88 -c0102c9c: 6a 58 push $0x58 +c0102bd2: 6a 58 push $0x58 jmp __alltraps -c0102c9e: e9 5f 07 00 00 jmp c0103402 <__alltraps> +c0102bd4: e9 c5 fc ff ff jmp c010289e <__alltraps> -c0102ca3 : +c0102bd9 : .globl vector89 vector89: pushl $0 -c0102ca3: 6a 00 push $0x0 +c0102bd9: 6a 00 push $0x0 pushl $89 -c0102ca5: 6a 59 push $0x59 +c0102bdb: 6a 59 push $0x59 jmp __alltraps -c0102ca7: e9 56 07 00 00 jmp c0103402 <__alltraps> +c0102bdd: e9 bc fc ff ff jmp c010289e <__alltraps> -c0102cac : +c0102be2 : .globl vector90 vector90: pushl $0 -c0102cac: 6a 00 push $0x0 +c0102be2: 6a 00 push $0x0 pushl $90 -c0102cae: 6a 5a push $0x5a +c0102be4: 6a 5a push $0x5a jmp __alltraps -c0102cb0: e9 4d 07 00 00 jmp c0103402 <__alltraps> +c0102be6: e9 b3 fc ff ff jmp c010289e <__alltraps> -c0102cb5 : +c0102beb : .globl vector91 vector91: pushl $0 -c0102cb5: 6a 00 push $0x0 +c0102beb: 6a 00 push $0x0 pushl $91 -c0102cb7: 6a 5b push $0x5b +c0102bed: 6a 5b push $0x5b jmp __alltraps -c0102cb9: e9 44 07 00 00 jmp c0103402 <__alltraps> +c0102bef: e9 aa fc ff ff jmp c010289e <__alltraps> -c0102cbe : +c0102bf4 : .globl vector92 vector92: pushl $0 -c0102cbe: 6a 00 push $0x0 +c0102bf4: 6a 00 push $0x0 pushl $92 -c0102cc0: 6a 5c push $0x5c +c0102bf6: 6a 5c push $0x5c jmp __alltraps -c0102cc2: e9 3b 07 00 00 jmp c0103402 <__alltraps> +c0102bf8: e9 a1 fc ff ff jmp c010289e <__alltraps> -c0102cc7 : +c0102bfd : .globl vector93 vector93: pushl $0 -c0102cc7: 6a 00 push $0x0 +c0102bfd: 6a 00 push $0x0 pushl $93 -c0102cc9: 6a 5d push $0x5d +c0102bff: 6a 5d push $0x5d jmp __alltraps -c0102ccb: e9 32 07 00 00 jmp c0103402 <__alltraps> +c0102c01: e9 98 fc ff ff jmp c010289e <__alltraps> -c0102cd0 : +c0102c06 : .globl vector94 vector94: pushl $0 -c0102cd0: 6a 00 push $0x0 +c0102c06: 6a 00 push $0x0 pushl $94 -c0102cd2: 6a 5e push $0x5e +c0102c08: 6a 5e push $0x5e jmp __alltraps -c0102cd4: e9 29 07 00 00 jmp c0103402 <__alltraps> +c0102c0a: e9 8f fc ff ff jmp c010289e <__alltraps> -c0102cd9 : +c0102c0f : .globl vector95 vector95: pushl $0 -c0102cd9: 6a 00 push $0x0 +c0102c0f: 6a 00 push $0x0 pushl $95 -c0102cdb: 6a 5f push $0x5f +c0102c11: 6a 5f push $0x5f jmp __alltraps -c0102cdd: e9 20 07 00 00 jmp c0103402 <__alltraps> +c0102c13: e9 86 fc ff ff jmp c010289e <__alltraps> -c0102ce2 : +c0102c18 : .globl vector96 vector96: pushl $0 -c0102ce2: 6a 00 push $0x0 +c0102c18: 6a 00 push $0x0 pushl $96 -c0102ce4: 6a 60 push $0x60 +c0102c1a: 6a 60 push $0x60 jmp __alltraps -c0102ce6: e9 17 07 00 00 jmp c0103402 <__alltraps> +c0102c1c: e9 7d fc ff ff jmp c010289e <__alltraps> -c0102ceb : +c0102c21 : .globl vector97 vector97: pushl $0 -c0102ceb: 6a 00 push $0x0 +c0102c21: 6a 00 push $0x0 pushl $97 -c0102ced: 6a 61 push $0x61 +c0102c23: 6a 61 push $0x61 jmp __alltraps -c0102cef: e9 0e 07 00 00 jmp c0103402 <__alltraps> +c0102c25: e9 74 fc ff ff jmp c010289e <__alltraps> -c0102cf4 : +c0102c2a : .globl vector98 vector98: pushl $0 -c0102cf4: 6a 00 push $0x0 +c0102c2a: 6a 00 push $0x0 pushl $98 -c0102cf6: 6a 62 push $0x62 +c0102c2c: 6a 62 push $0x62 jmp __alltraps -c0102cf8: e9 05 07 00 00 jmp c0103402 <__alltraps> +c0102c2e: e9 6b fc ff ff jmp c010289e <__alltraps> -c0102cfd : +c0102c33 : .globl vector99 vector99: pushl $0 -c0102cfd: 6a 00 push $0x0 +c0102c33: 6a 00 push $0x0 pushl $99 -c0102cff: 6a 63 push $0x63 +c0102c35: 6a 63 push $0x63 jmp __alltraps -c0102d01: e9 fc 06 00 00 jmp c0103402 <__alltraps> +c0102c37: e9 62 fc ff ff jmp c010289e <__alltraps> -c0102d06 : +c0102c3c : .globl vector100 vector100: pushl $0 -c0102d06: 6a 00 push $0x0 +c0102c3c: 6a 00 push $0x0 pushl $100 -c0102d08: 6a 64 push $0x64 +c0102c3e: 6a 64 push $0x64 jmp __alltraps -c0102d0a: e9 f3 06 00 00 jmp c0103402 <__alltraps> +c0102c40: e9 59 fc ff ff jmp c010289e <__alltraps> -c0102d0f : +c0102c45 : .globl vector101 vector101: pushl $0 -c0102d0f: 6a 00 push $0x0 +c0102c45: 6a 00 push $0x0 pushl $101 -c0102d11: 6a 65 push $0x65 +c0102c47: 6a 65 push $0x65 jmp __alltraps -c0102d13: e9 ea 06 00 00 jmp c0103402 <__alltraps> +c0102c49: e9 50 fc ff ff jmp c010289e <__alltraps> -c0102d18 : +c0102c4e : .globl vector102 vector102: pushl $0 -c0102d18: 6a 00 push $0x0 +c0102c4e: 6a 00 push $0x0 pushl $102 -c0102d1a: 6a 66 push $0x66 +c0102c50: 6a 66 push $0x66 jmp __alltraps -c0102d1c: e9 e1 06 00 00 jmp c0103402 <__alltraps> +c0102c52: e9 47 fc ff ff jmp c010289e <__alltraps> -c0102d21 : +c0102c57 : .globl vector103 vector103: pushl $0 -c0102d21: 6a 00 push $0x0 +c0102c57: 6a 00 push $0x0 pushl $103 -c0102d23: 6a 67 push $0x67 +c0102c59: 6a 67 push $0x67 jmp __alltraps -c0102d25: e9 d8 06 00 00 jmp c0103402 <__alltraps> +c0102c5b: e9 3e fc ff ff jmp c010289e <__alltraps> -c0102d2a : +c0102c60 : .globl vector104 vector104: pushl $0 -c0102d2a: 6a 00 push $0x0 +c0102c60: 6a 00 push $0x0 pushl $104 -c0102d2c: 6a 68 push $0x68 +c0102c62: 6a 68 push $0x68 jmp __alltraps -c0102d2e: e9 cf 06 00 00 jmp c0103402 <__alltraps> +c0102c64: e9 35 fc ff ff jmp c010289e <__alltraps> -c0102d33 : +c0102c69 : .globl vector105 vector105: pushl $0 -c0102d33: 6a 00 push $0x0 +c0102c69: 6a 00 push $0x0 pushl $105 -c0102d35: 6a 69 push $0x69 +c0102c6b: 6a 69 push $0x69 jmp __alltraps -c0102d37: e9 c6 06 00 00 jmp c0103402 <__alltraps> +c0102c6d: e9 2c fc ff ff jmp c010289e <__alltraps> -c0102d3c : +c0102c72 : .globl vector106 vector106: pushl $0 -c0102d3c: 6a 00 push $0x0 +c0102c72: 6a 00 push $0x0 pushl $106 -c0102d3e: 6a 6a push $0x6a +c0102c74: 6a 6a push $0x6a jmp __alltraps -c0102d40: e9 bd 06 00 00 jmp c0103402 <__alltraps> +c0102c76: e9 23 fc ff ff jmp c010289e <__alltraps> -c0102d45 : +c0102c7b : .globl vector107 vector107: pushl $0 -c0102d45: 6a 00 push $0x0 +c0102c7b: 6a 00 push $0x0 pushl $107 -c0102d47: 6a 6b push $0x6b +c0102c7d: 6a 6b push $0x6b jmp __alltraps -c0102d49: e9 b4 06 00 00 jmp c0103402 <__alltraps> +c0102c7f: e9 1a fc ff ff jmp c010289e <__alltraps> -c0102d4e : +c0102c84 : .globl vector108 vector108: pushl $0 -c0102d4e: 6a 00 push $0x0 +c0102c84: 6a 00 push $0x0 pushl $108 -c0102d50: 6a 6c push $0x6c +c0102c86: 6a 6c push $0x6c jmp __alltraps -c0102d52: e9 ab 06 00 00 jmp c0103402 <__alltraps> +c0102c88: e9 11 fc ff ff jmp c010289e <__alltraps> -c0102d57 : +c0102c8d : .globl vector109 vector109: pushl $0 -c0102d57: 6a 00 push $0x0 +c0102c8d: 6a 00 push $0x0 pushl $109 -c0102d59: 6a 6d push $0x6d +c0102c8f: 6a 6d push $0x6d jmp __alltraps -c0102d5b: e9 a2 06 00 00 jmp c0103402 <__alltraps> +c0102c91: e9 08 fc ff ff jmp c010289e <__alltraps> -c0102d60 : +c0102c96 : .globl vector110 vector110: pushl $0 -c0102d60: 6a 00 push $0x0 +c0102c96: 6a 00 push $0x0 pushl $110 -c0102d62: 6a 6e push $0x6e +c0102c98: 6a 6e push $0x6e jmp __alltraps -c0102d64: e9 99 06 00 00 jmp c0103402 <__alltraps> +c0102c9a: e9 ff fb ff ff jmp c010289e <__alltraps> -c0102d69 : +c0102c9f : .globl vector111 vector111: pushl $0 -c0102d69: 6a 00 push $0x0 +c0102c9f: 6a 00 push $0x0 pushl $111 -c0102d6b: 6a 6f push $0x6f +c0102ca1: 6a 6f push $0x6f jmp __alltraps -c0102d6d: e9 90 06 00 00 jmp c0103402 <__alltraps> +c0102ca3: e9 f6 fb ff ff jmp c010289e <__alltraps> -c0102d72 : +c0102ca8 : .globl vector112 vector112: pushl $0 -c0102d72: 6a 00 push $0x0 +c0102ca8: 6a 00 push $0x0 pushl $112 -c0102d74: 6a 70 push $0x70 +c0102caa: 6a 70 push $0x70 jmp __alltraps -c0102d76: e9 87 06 00 00 jmp c0103402 <__alltraps> +c0102cac: e9 ed fb ff ff jmp c010289e <__alltraps> -c0102d7b : +c0102cb1 : .globl vector113 vector113: pushl $0 -c0102d7b: 6a 00 push $0x0 +c0102cb1: 6a 00 push $0x0 pushl $113 -c0102d7d: 6a 71 push $0x71 +c0102cb3: 6a 71 push $0x71 jmp __alltraps -c0102d7f: e9 7e 06 00 00 jmp c0103402 <__alltraps> +c0102cb5: e9 e4 fb ff ff jmp c010289e <__alltraps> -c0102d84 : +c0102cba : .globl vector114 vector114: pushl $0 -c0102d84: 6a 00 push $0x0 +c0102cba: 6a 00 push $0x0 pushl $114 -c0102d86: 6a 72 push $0x72 +c0102cbc: 6a 72 push $0x72 jmp __alltraps -c0102d88: e9 75 06 00 00 jmp c0103402 <__alltraps> +c0102cbe: e9 db fb ff ff jmp c010289e <__alltraps> -c0102d8d : +c0102cc3 : .globl vector115 vector115: pushl $0 -c0102d8d: 6a 00 push $0x0 +c0102cc3: 6a 00 push $0x0 pushl $115 -c0102d8f: 6a 73 push $0x73 +c0102cc5: 6a 73 push $0x73 jmp __alltraps -c0102d91: e9 6c 06 00 00 jmp c0103402 <__alltraps> +c0102cc7: e9 d2 fb ff ff jmp c010289e <__alltraps> -c0102d96 : +c0102ccc : .globl vector116 vector116: pushl $0 -c0102d96: 6a 00 push $0x0 +c0102ccc: 6a 00 push $0x0 pushl $116 -c0102d98: 6a 74 push $0x74 +c0102cce: 6a 74 push $0x74 jmp __alltraps -c0102d9a: e9 63 06 00 00 jmp c0103402 <__alltraps> +c0102cd0: e9 c9 fb ff ff jmp c010289e <__alltraps> -c0102d9f : +c0102cd5 : .globl vector117 vector117: pushl $0 -c0102d9f: 6a 00 push $0x0 +c0102cd5: 6a 00 push $0x0 pushl $117 -c0102da1: 6a 75 push $0x75 +c0102cd7: 6a 75 push $0x75 jmp __alltraps -c0102da3: e9 5a 06 00 00 jmp c0103402 <__alltraps> +c0102cd9: e9 c0 fb ff ff jmp c010289e <__alltraps> -c0102da8 : +c0102cde : .globl vector118 vector118: pushl $0 -c0102da8: 6a 00 push $0x0 +c0102cde: 6a 00 push $0x0 pushl $118 -c0102daa: 6a 76 push $0x76 +c0102ce0: 6a 76 push $0x76 jmp __alltraps -c0102dac: e9 51 06 00 00 jmp c0103402 <__alltraps> +c0102ce2: e9 b7 fb ff ff jmp c010289e <__alltraps> -c0102db1 : +c0102ce7 : .globl vector119 vector119: pushl $0 -c0102db1: 6a 00 push $0x0 +c0102ce7: 6a 00 push $0x0 pushl $119 -c0102db3: 6a 77 push $0x77 +c0102ce9: 6a 77 push $0x77 jmp __alltraps -c0102db5: e9 48 06 00 00 jmp c0103402 <__alltraps> +c0102ceb: e9 ae fb ff ff jmp c010289e <__alltraps> -c0102dba : +c0102cf0 : .globl vector120 vector120: pushl $0 -c0102dba: 6a 00 push $0x0 +c0102cf0: 6a 00 push $0x0 pushl $120 -c0102dbc: 6a 78 push $0x78 +c0102cf2: 6a 78 push $0x78 jmp __alltraps -c0102dbe: e9 3f 06 00 00 jmp c0103402 <__alltraps> +c0102cf4: e9 a5 fb ff ff jmp c010289e <__alltraps> -c0102dc3 : +c0102cf9 : .globl vector121 vector121: pushl $0 -c0102dc3: 6a 00 push $0x0 +c0102cf9: 6a 00 push $0x0 pushl $121 -c0102dc5: 6a 79 push $0x79 +c0102cfb: 6a 79 push $0x79 jmp __alltraps -c0102dc7: e9 36 06 00 00 jmp c0103402 <__alltraps> +c0102cfd: e9 9c fb ff ff jmp c010289e <__alltraps> -c0102dcc : +c0102d02 : .globl vector122 vector122: pushl $0 -c0102dcc: 6a 00 push $0x0 +c0102d02: 6a 00 push $0x0 pushl $122 -c0102dce: 6a 7a push $0x7a +c0102d04: 6a 7a push $0x7a jmp __alltraps -c0102dd0: e9 2d 06 00 00 jmp c0103402 <__alltraps> +c0102d06: e9 93 fb ff ff jmp c010289e <__alltraps> -c0102dd5 : +c0102d0b : .globl vector123 vector123: pushl $0 -c0102dd5: 6a 00 push $0x0 +c0102d0b: 6a 00 push $0x0 pushl $123 -c0102dd7: 6a 7b push $0x7b +c0102d0d: 6a 7b push $0x7b jmp __alltraps -c0102dd9: e9 24 06 00 00 jmp c0103402 <__alltraps> +c0102d0f: e9 8a fb ff ff jmp c010289e <__alltraps> -c0102dde : +c0102d14 : .globl vector124 vector124: pushl $0 -c0102dde: 6a 00 push $0x0 +c0102d14: 6a 00 push $0x0 pushl $124 -c0102de0: 6a 7c push $0x7c +c0102d16: 6a 7c push $0x7c jmp __alltraps -c0102de2: e9 1b 06 00 00 jmp c0103402 <__alltraps> +c0102d18: e9 81 fb ff ff jmp c010289e <__alltraps> -c0102de7 : +c0102d1d : .globl vector125 vector125: pushl $0 -c0102de7: 6a 00 push $0x0 +c0102d1d: 6a 00 push $0x0 pushl $125 -c0102de9: 6a 7d push $0x7d +c0102d1f: 6a 7d push $0x7d jmp __alltraps -c0102deb: e9 12 06 00 00 jmp c0103402 <__alltraps> +c0102d21: e9 78 fb ff ff jmp c010289e <__alltraps> -c0102df0 : +c0102d26 : .globl vector126 vector126: pushl $0 -c0102df0: 6a 00 push $0x0 +c0102d26: 6a 00 push $0x0 pushl $126 -c0102df2: 6a 7e push $0x7e +c0102d28: 6a 7e push $0x7e jmp __alltraps -c0102df4: e9 09 06 00 00 jmp c0103402 <__alltraps> +c0102d2a: e9 6f fb ff ff jmp c010289e <__alltraps> -c0102df9 : +c0102d2f : .globl vector127 vector127: pushl $0 -c0102df9: 6a 00 push $0x0 +c0102d2f: 6a 00 push $0x0 pushl $127 -c0102dfb: 6a 7f push $0x7f +c0102d31: 6a 7f push $0x7f jmp __alltraps -c0102dfd: e9 00 06 00 00 jmp c0103402 <__alltraps> +c0102d33: e9 66 fb ff ff jmp c010289e <__alltraps> -c0102e02 : +c0102d38 : .globl vector128 vector128: pushl $0 -c0102e02: 6a 00 push $0x0 +c0102d38: 6a 00 push $0x0 pushl $128 -c0102e04: 68 80 00 00 00 push $0x80 +c0102d3a: 68 80 00 00 00 push $0x80 jmp __alltraps -c0102e09: e9 f4 05 00 00 jmp c0103402 <__alltraps> +c0102d3f: e9 5a fb ff ff jmp c010289e <__alltraps> -c0102e0e : +c0102d44 : .globl vector129 vector129: pushl $0 -c0102e0e: 6a 00 push $0x0 +c0102d44: 6a 00 push $0x0 pushl $129 -c0102e10: 68 81 00 00 00 push $0x81 +c0102d46: 68 81 00 00 00 push $0x81 jmp __alltraps -c0102e15: e9 e8 05 00 00 jmp c0103402 <__alltraps> +c0102d4b: e9 4e fb ff ff jmp c010289e <__alltraps> -c0102e1a : +c0102d50 : .globl vector130 vector130: pushl $0 -c0102e1a: 6a 00 push $0x0 +c0102d50: 6a 00 push $0x0 pushl $130 -c0102e1c: 68 82 00 00 00 push $0x82 +c0102d52: 68 82 00 00 00 push $0x82 jmp __alltraps -c0102e21: e9 dc 05 00 00 jmp c0103402 <__alltraps> +c0102d57: e9 42 fb ff ff jmp c010289e <__alltraps> -c0102e26 : +c0102d5c : .globl vector131 vector131: pushl $0 -c0102e26: 6a 00 push $0x0 +c0102d5c: 6a 00 push $0x0 pushl $131 -c0102e28: 68 83 00 00 00 push $0x83 +c0102d5e: 68 83 00 00 00 push $0x83 jmp __alltraps -c0102e2d: e9 d0 05 00 00 jmp c0103402 <__alltraps> +c0102d63: e9 36 fb ff ff jmp c010289e <__alltraps> -c0102e32 : +c0102d68 : .globl vector132 vector132: pushl $0 -c0102e32: 6a 00 push $0x0 +c0102d68: 6a 00 push $0x0 pushl $132 -c0102e34: 68 84 00 00 00 push $0x84 +c0102d6a: 68 84 00 00 00 push $0x84 jmp __alltraps -c0102e39: e9 c4 05 00 00 jmp c0103402 <__alltraps> +c0102d6f: e9 2a fb ff ff jmp c010289e <__alltraps> -c0102e3e : +c0102d74 : .globl vector133 vector133: pushl $0 -c0102e3e: 6a 00 push $0x0 +c0102d74: 6a 00 push $0x0 pushl $133 -c0102e40: 68 85 00 00 00 push $0x85 +c0102d76: 68 85 00 00 00 push $0x85 jmp __alltraps -c0102e45: e9 b8 05 00 00 jmp c0103402 <__alltraps> +c0102d7b: e9 1e fb ff ff jmp c010289e <__alltraps> -c0102e4a : +c0102d80 : .globl vector134 vector134: pushl $0 -c0102e4a: 6a 00 push $0x0 +c0102d80: 6a 00 push $0x0 pushl $134 -c0102e4c: 68 86 00 00 00 push $0x86 +c0102d82: 68 86 00 00 00 push $0x86 jmp __alltraps -c0102e51: e9 ac 05 00 00 jmp c0103402 <__alltraps> +c0102d87: e9 12 fb ff ff jmp c010289e <__alltraps> -c0102e56 : +c0102d8c : .globl vector135 vector135: pushl $0 -c0102e56: 6a 00 push $0x0 +c0102d8c: 6a 00 push $0x0 pushl $135 -c0102e58: 68 87 00 00 00 push $0x87 +c0102d8e: 68 87 00 00 00 push $0x87 jmp __alltraps -c0102e5d: e9 a0 05 00 00 jmp c0103402 <__alltraps> +c0102d93: e9 06 fb ff ff jmp c010289e <__alltraps> -c0102e62 : +c0102d98 : .globl vector136 vector136: pushl $0 -c0102e62: 6a 00 push $0x0 +c0102d98: 6a 00 push $0x0 pushl $136 -c0102e64: 68 88 00 00 00 push $0x88 +c0102d9a: 68 88 00 00 00 push $0x88 jmp __alltraps -c0102e69: e9 94 05 00 00 jmp c0103402 <__alltraps> +c0102d9f: e9 fa fa ff ff jmp c010289e <__alltraps> -c0102e6e : +c0102da4 : .globl vector137 vector137: pushl $0 -c0102e6e: 6a 00 push $0x0 +c0102da4: 6a 00 push $0x0 pushl $137 -c0102e70: 68 89 00 00 00 push $0x89 +c0102da6: 68 89 00 00 00 push $0x89 jmp __alltraps -c0102e75: e9 88 05 00 00 jmp c0103402 <__alltraps> +c0102dab: e9 ee fa ff ff jmp c010289e <__alltraps> -c0102e7a : +c0102db0 : .globl vector138 vector138: pushl $0 -c0102e7a: 6a 00 push $0x0 +c0102db0: 6a 00 push $0x0 pushl $138 -c0102e7c: 68 8a 00 00 00 push $0x8a +c0102db2: 68 8a 00 00 00 push $0x8a jmp __alltraps -c0102e81: e9 7c 05 00 00 jmp c0103402 <__alltraps> +c0102db7: e9 e2 fa ff ff jmp c010289e <__alltraps> -c0102e86 : +c0102dbc : .globl vector139 vector139: pushl $0 -c0102e86: 6a 00 push $0x0 +c0102dbc: 6a 00 push $0x0 pushl $139 -c0102e88: 68 8b 00 00 00 push $0x8b +c0102dbe: 68 8b 00 00 00 push $0x8b jmp __alltraps -c0102e8d: e9 70 05 00 00 jmp c0103402 <__alltraps> +c0102dc3: e9 d6 fa ff ff jmp c010289e <__alltraps> -c0102e92 : +c0102dc8 : .globl vector140 vector140: pushl $0 -c0102e92: 6a 00 push $0x0 +c0102dc8: 6a 00 push $0x0 pushl $140 -c0102e94: 68 8c 00 00 00 push $0x8c +c0102dca: 68 8c 00 00 00 push $0x8c jmp __alltraps -c0102e99: e9 64 05 00 00 jmp c0103402 <__alltraps> +c0102dcf: e9 ca fa ff ff jmp c010289e <__alltraps> -c0102e9e : +c0102dd4 : .globl vector141 vector141: pushl $0 -c0102e9e: 6a 00 push $0x0 +c0102dd4: 6a 00 push $0x0 pushl $141 -c0102ea0: 68 8d 00 00 00 push $0x8d +c0102dd6: 68 8d 00 00 00 push $0x8d jmp __alltraps -c0102ea5: e9 58 05 00 00 jmp c0103402 <__alltraps> +c0102ddb: e9 be fa ff ff jmp c010289e <__alltraps> -c0102eaa : +c0102de0 : .globl vector142 vector142: pushl $0 -c0102eaa: 6a 00 push $0x0 +c0102de0: 6a 00 push $0x0 pushl $142 -c0102eac: 68 8e 00 00 00 push $0x8e +c0102de2: 68 8e 00 00 00 push $0x8e jmp __alltraps -c0102eb1: e9 4c 05 00 00 jmp c0103402 <__alltraps> +c0102de7: e9 b2 fa ff ff jmp c010289e <__alltraps> -c0102eb6 : +c0102dec : .globl vector143 vector143: pushl $0 -c0102eb6: 6a 00 push $0x0 +c0102dec: 6a 00 push $0x0 pushl $143 -c0102eb8: 68 8f 00 00 00 push $0x8f +c0102dee: 68 8f 00 00 00 push $0x8f jmp __alltraps -c0102ebd: e9 40 05 00 00 jmp c0103402 <__alltraps> +c0102df3: e9 a6 fa ff ff jmp c010289e <__alltraps> -c0102ec2 : +c0102df8 : .globl vector144 vector144: pushl $0 -c0102ec2: 6a 00 push $0x0 +c0102df8: 6a 00 push $0x0 pushl $144 -c0102ec4: 68 90 00 00 00 push $0x90 +c0102dfa: 68 90 00 00 00 push $0x90 jmp __alltraps -c0102ec9: e9 34 05 00 00 jmp c0103402 <__alltraps> +c0102dff: e9 9a fa ff ff jmp c010289e <__alltraps> -c0102ece : +c0102e04 : .globl vector145 vector145: pushl $0 -c0102ece: 6a 00 push $0x0 +c0102e04: 6a 00 push $0x0 pushl $145 -c0102ed0: 68 91 00 00 00 push $0x91 +c0102e06: 68 91 00 00 00 push $0x91 jmp __alltraps -c0102ed5: e9 28 05 00 00 jmp c0103402 <__alltraps> +c0102e0b: e9 8e fa ff ff jmp c010289e <__alltraps> -c0102eda : +c0102e10 : .globl vector146 vector146: pushl $0 -c0102eda: 6a 00 push $0x0 +c0102e10: 6a 00 push $0x0 pushl $146 -c0102edc: 68 92 00 00 00 push $0x92 +c0102e12: 68 92 00 00 00 push $0x92 jmp __alltraps -c0102ee1: e9 1c 05 00 00 jmp c0103402 <__alltraps> +c0102e17: e9 82 fa ff ff jmp c010289e <__alltraps> -c0102ee6 : +c0102e1c : .globl vector147 vector147: pushl $0 -c0102ee6: 6a 00 push $0x0 +c0102e1c: 6a 00 push $0x0 pushl $147 -c0102ee8: 68 93 00 00 00 push $0x93 +c0102e1e: 68 93 00 00 00 push $0x93 jmp __alltraps -c0102eed: e9 10 05 00 00 jmp c0103402 <__alltraps> +c0102e23: e9 76 fa ff ff jmp c010289e <__alltraps> -c0102ef2 : +c0102e28 : .globl vector148 vector148: pushl $0 -c0102ef2: 6a 00 push $0x0 +c0102e28: 6a 00 push $0x0 pushl $148 -c0102ef4: 68 94 00 00 00 push $0x94 +c0102e2a: 68 94 00 00 00 push $0x94 jmp __alltraps -c0102ef9: e9 04 05 00 00 jmp c0103402 <__alltraps> +c0102e2f: e9 6a fa ff ff jmp c010289e <__alltraps> -c0102efe : +c0102e34 : .globl vector149 vector149: pushl $0 -c0102efe: 6a 00 push $0x0 +c0102e34: 6a 00 push $0x0 pushl $149 -c0102f00: 68 95 00 00 00 push $0x95 +c0102e36: 68 95 00 00 00 push $0x95 jmp __alltraps -c0102f05: e9 f8 04 00 00 jmp c0103402 <__alltraps> +c0102e3b: e9 5e fa ff ff jmp c010289e <__alltraps> -c0102f0a : +c0102e40 : .globl vector150 vector150: pushl $0 -c0102f0a: 6a 00 push $0x0 +c0102e40: 6a 00 push $0x0 pushl $150 -c0102f0c: 68 96 00 00 00 push $0x96 +c0102e42: 68 96 00 00 00 push $0x96 jmp __alltraps -c0102f11: e9 ec 04 00 00 jmp c0103402 <__alltraps> +c0102e47: e9 52 fa ff ff jmp c010289e <__alltraps> -c0102f16 : +c0102e4c : .globl vector151 vector151: pushl $0 -c0102f16: 6a 00 push $0x0 +c0102e4c: 6a 00 push $0x0 pushl $151 -c0102f18: 68 97 00 00 00 push $0x97 +c0102e4e: 68 97 00 00 00 push $0x97 jmp __alltraps -c0102f1d: e9 e0 04 00 00 jmp c0103402 <__alltraps> +c0102e53: e9 46 fa ff ff jmp c010289e <__alltraps> -c0102f22 : +c0102e58 : .globl vector152 vector152: pushl $0 -c0102f22: 6a 00 push $0x0 +c0102e58: 6a 00 push $0x0 pushl $152 -c0102f24: 68 98 00 00 00 push $0x98 +c0102e5a: 68 98 00 00 00 push $0x98 jmp __alltraps -c0102f29: e9 d4 04 00 00 jmp c0103402 <__alltraps> +c0102e5f: e9 3a fa ff ff jmp c010289e <__alltraps> -c0102f2e : +c0102e64 : .globl vector153 vector153: pushl $0 -c0102f2e: 6a 00 push $0x0 +c0102e64: 6a 00 push $0x0 pushl $153 -c0102f30: 68 99 00 00 00 push $0x99 +c0102e66: 68 99 00 00 00 push $0x99 jmp __alltraps -c0102f35: e9 c8 04 00 00 jmp c0103402 <__alltraps> +c0102e6b: e9 2e fa ff ff jmp c010289e <__alltraps> -c0102f3a : +c0102e70 : .globl vector154 vector154: pushl $0 -c0102f3a: 6a 00 push $0x0 +c0102e70: 6a 00 push $0x0 pushl $154 -c0102f3c: 68 9a 00 00 00 push $0x9a +c0102e72: 68 9a 00 00 00 push $0x9a jmp __alltraps -c0102f41: e9 bc 04 00 00 jmp c0103402 <__alltraps> +c0102e77: e9 22 fa ff ff jmp c010289e <__alltraps> -c0102f46 : +c0102e7c : .globl vector155 vector155: pushl $0 -c0102f46: 6a 00 push $0x0 +c0102e7c: 6a 00 push $0x0 pushl $155 -c0102f48: 68 9b 00 00 00 push $0x9b +c0102e7e: 68 9b 00 00 00 push $0x9b jmp __alltraps -c0102f4d: e9 b0 04 00 00 jmp c0103402 <__alltraps> +c0102e83: e9 16 fa ff ff jmp c010289e <__alltraps> -c0102f52 : +c0102e88 : .globl vector156 vector156: pushl $0 -c0102f52: 6a 00 push $0x0 +c0102e88: 6a 00 push $0x0 pushl $156 -c0102f54: 68 9c 00 00 00 push $0x9c +c0102e8a: 68 9c 00 00 00 push $0x9c jmp __alltraps -c0102f59: e9 a4 04 00 00 jmp c0103402 <__alltraps> +c0102e8f: e9 0a fa ff ff jmp c010289e <__alltraps> -c0102f5e : +c0102e94 : .globl vector157 vector157: pushl $0 -c0102f5e: 6a 00 push $0x0 +c0102e94: 6a 00 push $0x0 pushl $157 -c0102f60: 68 9d 00 00 00 push $0x9d +c0102e96: 68 9d 00 00 00 push $0x9d jmp __alltraps -c0102f65: e9 98 04 00 00 jmp c0103402 <__alltraps> +c0102e9b: e9 fe f9 ff ff jmp c010289e <__alltraps> -c0102f6a : +c0102ea0 : .globl vector158 vector158: pushl $0 -c0102f6a: 6a 00 push $0x0 +c0102ea0: 6a 00 push $0x0 pushl $158 -c0102f6c: 68 9e 00 00 00 push $0x9e +c0102ea2: 68 9e 00 00 00 push $0x9e jmp __alltraps -c0102f71: e9 8c 04 00 00 jmp c0103402 <__alltraps> +c0102ea7: e9 f2 f9 ff ff jmp c010289e <__alltraps> -c0102f76 : +c0102eac : .globl vector159 vector159: pushl $0 -c0102f76: 6a 00 push $0x0 +c0102eac: 6a 00 push $0x0 pushl $159 -c0102f78: 68 9f 00 00 00 push $0x9f +c0102eae: 68 9f 00 00 00 push $0x9f jmp __alltraps -c0102f7d: e9 80 04 00 00 jmp c0103402 <__alltraps> +c0102eb3: e9 e6 f9 ff ff jmp c010289e <__alltraps> -c0102f82 : +c0102eb8 : .globl vector160 vector160: pushl $0 -c0102f82: 6a 00 push $0x0 +c0102eb8: 6a 00 push $0x0 pushl $160 -c0102f84: 68 a0 00 00 00 push $0xa0 +c0102eba: 68 a0 00 00 00 push $0xa0 jmp __alltraps -c0102f89: e9 74 04 00 00 jmp c0103402 <__alltraps> +c0102ebf: e9 da f9 ff ff jmp c010289e <__alltraps> -c0102f8e : +c0102ec4 : .globl vector161 vector161: pushl $0 -c0102f8e: 6a 00 push $0x0 +c0102ec4: 6a 00 push $0x0 pushl $161 -c0102f90: 68 a1 00 00 00 push $0xa1 +c0102ec6: 68 a1 00 00 00 push $0xa1 jmp __alltraps -c0102f95: e9 68 04 00 00 jmp c0103402 <__alltraps> +c0102ecb: e9 ce f9 ff ff jmp c010289e <__alltraps> -c0102f9a : +c0102ed0 : .globl vector162 vector162: pushl $0 -c0102f9a: 6a 00 push $0x0 +c0102ed0: 6a 00 push $0x0 pushl $162 -c0102f9c: 68 a2 00 00 00 push $0xa2 +c0102ed2: 68 a2 00 00 00 push $0xa2 jmp __alltraps -c0102fa1: e9 5c 04 00 00 jmp c0103402 <__alltraps> +c0102ed7: e9 c2 f9 ff ff jmp c010289e <__alltraps> -c0102fa6 : +c0102edc : .globl vector163 vector163: pushl $0 -c0102fa6: 6a 00 push $0x0 +c0102edc: 6a 00 push $0x0 pushl $163 -c0102fa8: 68 a3 00 00 00 push $0xa3 +c0102ede: 68 a3 00 00 00 push $0xa3 jmp __alltraps -c0102fad: e9 50 04 00 00 jmp c0103402 <__alltraps> +c0102ee3: e9 b6 f9 ff ff jmp c010289e <__alltraps> -c0102fb2 : +c0102ee8 : .globl vector164 vector164: pushl $0 -c0102fb2: 6a 00 push $0x0 +c0102ee8: 6a 00 push $0x0 pushl $164 -c0102fb4: 68 a4 00 00 00 push $0xa4 +c0102eea: 68 a4 00 00 00 push $0xa4 jmp __alltraps -c0102fb9: e9 44 04 00 00 jmp c0103402 <__alltraps> +c0102eef: e9 aa f9 ff ff jmp c010289e <__alltraps> -c0102fbe : +c0102ef4 : .globl vector165 vector165: pushl $0 -c0102fbe: 6a 00 push $0x0 +c0102ef4: 6a 00 push $0x0 pushl $165 -c0102fc0: 68 a5 00 00 00 push $0xa5 +c0102ef6: 68 a5 00 00 00 push $0xa5 jmp __alltraps -c0102fc5: e9 38 04 00 00 jmp c0103402 <__alltraps> +c0102efb: e9 9e f9 ff ff jmp c010289e <__alltraps> -c0102fca : +c0102f00 : .globl vector166 vector166: pushl $0 -c0102fca: 6a 00 push $0x0 +c0102f00: 6a 00 push $0x0 pushl $166 -c0102fcc: 68 a6 00 00 00 push $0xa6 +c0102f02: 68 a6 00 00 00 push $0xa6 jmp __alltraps -c0102fd1: e9 2c 04 00 00 jmp c0103402 <__alltraps> +c0102f07: e9 92 f9 ff ff jmp c010289e <__alltraps> -c0102fd6 : +c0102f0c : .globl vector167 vector167: pushl $0 -c0102fd6: 6a 00 push $0x0 +c0102f0c: 6a 00 push $0x0 pushl $167 -c0102fd8: 68 a7 00 00 00 push $0xa7 +c0102f0e: 68 a7 00 00 00 push $0xa7 jmp __alltraps -c0102fdd: e9 20 04 00 00 jmp c0103402 <__alltraps> +c0102f13: e9 86 f9 ff ff jmp c010289e <__alltraps> -c0102fe2 : +c0102f18 : .globl vector168 vector168: pushl $0 -c0102fe2: 6a 00 push $0x0 +c0102f18: 6a 00 push $0x0 pushl $168 -c0102fe4: 68 a8 00 00 00 push $0xa8 +c0102f1a: 68 a8 00 00 00 push $0xa8 jmp __alltraps -c0102fe9: e9 14 04 00 00 jmp c0103402 <__alltraps> +c0102f1f: e9 7a f9 ff ff jmp c010289e <__alltraps> -c0102fee : +c0102f24 : .globl vector169 vector169: pushl $0 -c0102fee: 6a 00 push $0x0 +c0102f24: 6a 00 push $0x0 pushl $169 -c0102ff0: 68 a9 00 00 00 push $0xa9 +c0102f26: 68 a9 00 00 00 push $0xa9 jmp __alltraps -c0102ff5: e9 08 04 00 00 jmp c0103402 <__alltraps> +c0102f2b: e9 6e f9 ff ff jmp c010289e <__alltraps> -c0102ffa : +c0102f30 : .globl vector170 vector170: pushl $0 -c0102ffa: 6a 00 push $0x0 +c0102f30: 6a 00 push $0x0 pushl $170 -c0102ffc: 68 aa 00 00 00 push $0xaa +c0102f32: 68 aa 00 00 00 push $0xaa jmp __alltraps -c0103001: e9 fc 03 00 00 jmp c0103402 <__alltraps> +c0102f37: e9 62 f9 ff ff jmp c010289e <__alltraps> -c0103006 : +c0102f3c : .globl vector171 vector171: pushl $0 -c0103006: 6a 00 push $0x0 +c0102f3c: 6a 00 push $0x0 pushl $171 -c0103008: 68 ab 00 00 00 push $0xab +c0102f3e: 68 ab 00 00 00 push $0xab jmp __alltraps -c010300d: e9 f0 03 00 00 jmp c0103402 <__alltraps> +c0102f43: e9 56 f9 ff ff jmp c010289e <__alltraps> -c0103012 : +c0102f48 : .globl vector172 vector172: pushl $0 -c0103012: 6a 00 push $0x0 +c0102f48: 6a 00 push $0x0 pushl $172 -c0103014: 68 ac 00 00 00 push $0xac +c0102f4a: 68 ac 00 00 00 push $0xac jmp __alltraps -c0103019: e9 e4 03 00 00 jmp c0103402 <__alltraps> +c0102f4f: e9 4a f9 ff ff jmp c010289e <__alltraps> -c010301e : +c0102f54 : .globl vector173 vector173: pushl $0 -c010301e: 6a 00 push $0x0 +c0102f54: 6a 00 push $0x0 pushl $173 -c0103020: 68 ad 00 00 00 push $0xad +c0102f56: 68 ad 00 00 00 push $0xad jmp __alltraps -c0103025: e9 d8 03 00 00 jmp c0103402 <__alltraps> +c0102f5b: e9 3e f9 ff ff jmp c010289e <__alltraps> -c010302a : +c0102f60 : .globl vector174 vector174: pushl $0 -c010302a: 6a 00 push $0x0 +c0102f60: 6a 00 push $0x0 pushl $174 -c010302c: 68 ae 00 00 00 push $0xae +c0102f62: 68 ae 00 00 00 push $0xae jmp __alltraps -c0103031: e9 cc 03 00 00 jmp c0103402 <__alltraps> +c0102f67: e9 32 f9 ff ff jmp c010289e <__alltraps> -c0103036 : +c0102f6c : .globl vector175 vector175: pushl $0 -c0103036: 6a 00 push $0x0 +c0102f6c: 6a 00 push $0x0 pushl $175 -c0103038: 68 af 00 00 00 push $0xaf +c0102f6e: 68 af 00 00 00 push $0xaf jmp __alltraps -c010303d: e9 c0 03 00 00 jmp c0103402 <__alltraps> +c0102f73: e9 26 f9 ff ff jmp c010289e <__alltraps> -c0103042 : +c0102f78 : .globl vector176 vector176: pushl $0 -c0103042: 6a 00 push $0x0 +c0102f78: 6a 00 push $0x0 pushl $176 -c0103044: 68 b0 00 00 00 push $0xb0 +c0102f7a: 68 b0 00 00 00 push $0xb0 jmp __alltraps -c0103049: e9 b4 03 00 00 jmp c0103402 <__alltraps> +c0102f7f: e9 1a f9 ff ff jmp c010289e <__alltraps> -c010304e : +c0102f84 : .globl vector177 vector177: pushl $0 -c010304e: 6a 00 push $0x0 +c0102f84: 6a 00 push $0x0 pushl $177 -c0103050: 68 b1 00 00 00 push $0xb1 +c0102f86: 68 b1 00 00 00 push $0xb1 jmp __alltraps -c0103055: e9 a8 03 00 00 jmp c0103402 <__alltraps> +c0102f8b: e9 0e f9 ff ff jmp c010289e <__alltraps> -c010305a : +c0102f90 : .globl vector178 vector178: pushl $0 -c010305a: 6a 00 push $0x0 +c0102f90: 6a 00 push $0x0 pushl $178 -c010305c: 68 b2 00 00 00 push $0xb2 +c0102f92: 68 b2 00 00 00 push $0xb2 jmp __alltraps -c0103061: e9 9c 03 00 00 jmp c0103402 <__alltraps> +c0102f97: e9 02 f9 ff ff jmp c010289e <__alltraps> -c0103066 : +c0102f9c : .globl vector179 vector179: pushl $0 -c0103066: 6a 00 push $0x0 +c0102f9c: 6a 00 push $0x0 pushl $179 -c0103068: 68 b3 00 00 00 push $0xb3 +c0102f9e: 68 b3 00 00 00 push $0xb3 jmp __alltraps -c010306d: e9 90 03 00 00 jmp c0103402 <__alltraps> +c0102fa3: e9 f6 f8 ff ff jmp c010289e <__alltraps> -c0103072 : +c0102fa8 : .globl vector180 vector180: pushl $0 -c0103072: 6a 00 push $0x0 +c0102fa8: 6a 00 push $0x0 pushl $180 -c0103074: 68 b4 00 00 00 push $0xb4 +c0102faa: 68 b4 00 00 00 push $0xb4 jmp __alltraps -c0103079: e9 84 03 00 00 jmp c0103402 <__alltraps> +c0102faf: e9 ea f8 ff ff jmp c010289e <__alltraps> -c010307e : +c0102fb4 : .globl vector181 vector181: pushl $0 -c010307e: 6a 00 push $0x0 +c0102fb4: 6a 00 push $0x0 pushl $181 -c0103080: 68 b5 00 00 00 push $0xb5 +c0102fb6: 68 b5 00 00 00 push $0xb5 jmp __alltraps -c0103085: e9 78 03 00 00 jmp c0103402 <__alltraps> +c0102fbb: e9 de f8 ff ff jmp c010289e <__alltraps> -c010308a : +c0102fc0 : .globl vector182 vector182: pushl $0 -c010308a: 6a 00 push $0x0 +c0102fc0: 6a 00 push $0x0 pushl $182 -c010308c: 68 b6 00 00 00 push $0xb6 +c0102fc2: 68 b6 00 00 00 push $0xb6 jmp __alltraps -c0103091: e9 6c 03 00 00 jmp c0103402 <__alltraps> +c0102fc7: e9 d2 f8 ff ff jmp c010289e <__alltraps> -c0103096 : +c0102fcc : .globl vector183 vector183: pushl $0 -c0103096: 6a 00 push $0x0 +c0102fcc: 6a 00 push $0x0 pushl $183 -c0103098: 68 b7 00 00 00 push $0xb7 +c0102fce: 68 b7 00 00 00 push $0xb7 jmp __alltraps -c010309d: e9 60 03 00 00 jmp c0103402 <__alltraps> +c0102fd3: e9 c6 f8 ff ff jmp c010289e <__alltraps> -c01030a2 : +c0102fd8 : .globl vector184 vector184: pushl $0 -c01030a2: 6a 00 push $0x0 +c0102fd8: 6a 00 push $0x0 pushl $184 -c01030a4: 68 b8 00 00 00 push $0xb8 +c0102fda: 68 b8 00 00 00 push $0xb8 jmp __alltraps -c01030a9: e9 54 03 00 00 jmp c0103402 <__alltraps> +c0102fdf: e9 ba f8 ff ff jmp c010289e <__alltraps> -c01030ae : +c0102fe4 : .globl vector185 vector185: pushl $0 -c01030ae: 6a 00 push $0x0 +c0102fe4: 6a 00 push $0x0 pushl $185 -c01030b0: 68 b9 00 00 00 push $0xb9 +c0102fe6: 68 b9 00 00 00 push $0xb9 jmp __alltraps -c01030b5: e9 48 03 00 00 jmp c0103402 <__alltraps> +c0102feb: e9 ae f8 ff ff jmp c010289e <__alltraps> -c01030ba : +c0102ff0 : .globl vector186 vector186: pushl $0 -c01030ba: 6a 00 push $0x0 +c0102ff0: 6a 00 push $0x0 pushl $186 -c01030bc: 68 ba 00 00 00 push $0xba +c0102ff2: 68 ba 00 00 00 push $0xba jmp __alltraps -c01030c1: e9 3c 03 00 00 jmp c0103402 <__alltraps> +c0102ff7: e9 a2 f8 ff ff jmp c010289e <__alltraps> -c01030c6 : +c0102ffc : .globl vector187 vector187: pushl $0 -c01030c6: 6a 00 push $0x0 +c0102ffc: 6a 00 push $0x0 pushl $187 -c01030c8: 68 bb 00 00 00 push $0xbb +c0102ffe: 68 bb 00 00 00 push $0xbb jmp __alltraps -c01030cd: e9 30 03 00 00 jmp c0103402 <__alltraps> +c0103003: e9 96 f8 ff ff jmp c010289e <__alltraps> -c01030d2 : +c0103008 : .globl vector188 vector188: pushl $0 -c01030d2: 6a 00 push $0x0 +c0103008: 6a 00 push $0x0 pushl $188 -c01030d4: 68 bc 00 00 00 push $0xbc +c010300a: 68 bc 00 00 00 push $0xbc jmp __alltraps -c01030d9: e9 24 03 00 00 jmp c0103402 <__alltraps> +c010300f: e9 8a f8 ff ff jmp c010289e <__alltraps> -c01030de : +c0103014 : .globl vector189 vector189: pushl $0 -c01030de: 6a 00 push $0x0 +c0103014: 6a 00 push $0x0 pushl $189 -c01030e0: 68 bd 00 00 00 push $0xbd +c0103016: 68 bd 00 00 00 push $0xbd jmp __alltraps -c01030e5: e9 18 03 00 00 jmp c0103402 <__alltraps> +c010301b: e9 7e f8 ff ff jmp c010289e <__alltraps> -c01030ea : +c0103020 : .globl vector190 vector190: pushl $0 -c01030ea: 6a 00 push $0x0 +c0103020: 6a 00 push $0x0 pushl $190 -c01030ec: 68 be 00 00 00 push $0xbe +c0103022: 68 be 00 00 00 push $0xbe jmp __alltraps -c01030f1: e9 0c 03 00 00 jmp c0103402 <__alltraps> +c0103027: e9 72 f8 ff ff jmp c010289e <__alltraps> -c01030f6 : +c010302c : .globl vector191 vector191: pushl $0 -c01030f6: 6a 00 push $0x0 +c010302c: 6a 00 push $0x0 pushl $191 -c01030f8: 68 bf 00 00 00 push $0xbf +c010302e: 68 bf 00 00 00 push $0xbf jmp __alltraps -c01030fd: e9 00 03 00 00 jmp c0103402 <__alltraps> +c0103033: e9 66 f8 ff ff jmp c010289e <__alltraps> -c0103102 : +c0103038 : .globl vector192 vector192: pushl $0 -c0103102: 6a 00 push $0x0 +c0103038: 6a 00 push $0x0 pushl $192 -c0103104: 68 c0 00 00 00 push $0xc0 +c010303a: 68 c0 00 00 00 push $0xc0 jmp __alltraps -c0103109: e9 f4 02 00 00 jmp c0103402 <__alltraps> +c010303f: e9 5a f8 ff ff jmp c010289e <__alltraps> -c010310e : +c0103044 : .globl vector193 vector193: pushl $0 -c010310e: 6a 00 push $0x0 +c0103044: 6a 00 push $0x0 pushl $193 -c0103110: 68 c1 00 00 00 push $0xc1 +c0103046: 68 c1 00 00 00 push $0xc1 jmp __alltraps -c0103115: e9 e8 02 00 00 jmp c0103402 <__alltraps> +c010304b: e9 4e f8 ff ff jmp c010289e <__alltraps> -c010311a : +c0103050 : .globl vector194 vector194: pushl $0 -c010311a: 6a 00 push $0x0 +c0103050: 6a 00 push $0x0 pushl $194 -c010311c: 68 c2 00 00 00 push $0xc2 +c0103052: 68 c2 00 00 00 push $0xc2 jmp __alltraps -c0103121: e9 dc 02 00 00 jmp c0103402 <__alltraps> +c0103057: e9 42 f8 ff ff jmp c010289e <__alltraps> -c0103126 : +c010305c : .globl vector195 vector195: pushl $0 -c0103126: 6a 00 push $0x0 +c010305c: 6a 00 push $0x0 pushl $195 -c0103128: 68 c3 00 00 00 push $0xc3 +c010305e: 68 c3 00 00 00 push $0xc3 jmp __alltraps -c010312d: e9 d0 02 00 00 jmp c0103402 <__alltraps> +c0103063: e9 36 f8 ff ff jmp c010289e <__alltraps> -c0103132 : +c0103068 : .globl vector196 vector196: pushl $0 -c0103132: 6a 00 push $0x0 +c0103068: 6a 00 push $0x0 pushl $196 -c0103134: 68 c4 00 00 00 push $0xc4 +c010306a: 68 c4 00 00 00 push $0xc4 jmp __alltraps -c0103139: e9 c4 02 00 00 jmp c0103402 <__alltraps> +c010306f: e9 2a f8 ff ff jmp c010289e <__alltraps> -c010313e : +c0103074 : .globl vector197 vector197: pushl $0 -c010313e: 6a 00 push $0x0 +c0103074: 6a 00 push $0x0 pushl $197 -c0103140: 68 c5 00 00 00 push $0xc5 +c0103076: 68 c5 00 00 00 push $0xc5 jmp __alltraps -c0103145: e9 b8 02 00 00 jmp c0103402 <__alltraps> +c010307b: e9 1e f8 ff ff jmp c010289e <__alltraps> -c010314a : +c0103080 : .globl vector198 vector198: pushl $0 -c010314a: 6a 00 push $0x0 +c0103080: 6a 00 push $0x0 pushl $198 -c010314c: 68 c6 00 00 00 push $0xc6 +c0103082: 68 c6 00 00 00 push $0xc6 jmp __alltraps -c0103151: e9 ac 02 00 00 jmp c0103402 <__alltraps> +c0103087: e9 12 f8 ff ff jmp c010289e <__alltraps> -c0103156 : +c010308c : .globl vector199 vector199: pushl $0 -c0103156: 6a 00 push $0x0 +c010308c: 6a 00 push $0x0 pushl $199 -c0103158: 68 c7 00 00 00 push $0xc7 +c010308e: 68 c7 00 00 00 push $0xc7 jmp __alltraps -c010315d: e9 a0 02 00 00 jmp c0103402 <__alltraps> +c0103093: e9 06 f8 ff ff jmp c010289e <__alltraps> -c0103162 : +c0103098 : .globl vector200 vector200: pushl $0 -c0103162: 6a 00 push $0x0 +c0103098: 6a 00 push $0x0 pushl $200 -c0103164: 68 c8 00 00 00 push $0xc8 +c010309a: 68 c8 00 00 00 push $0xc8 jmp __alltraps -c0103169: e9 94 02 00 00 jmp c0103402 <__alltraps> +c010309f: e9 fa f7 ff ff jmp c010289e <__alltraps> -c010316e : +c01030a4 : .globl vector201 vector201: pushl $0 -c010316e: 6a 00 push $0x0 +c01030a4: 6a 00 push $0x0 pushl $201 -c0103170: 68 c9 00 00 00 push $0xc9 +c01030a6: 68 c9 00 00 00 push $0xc9 jmp __alltraps -c0103175: e9 88 02 00 00 jmp c0103402 <__alltraps> +c01030ab: e9 ee f7 ff ff jmp c010289e <__alltraps> -c010317a : +c01030b0 : .globl vector202 vector202: pushl $0 -c010317a: 6a 00 push $0x0 +c01030b0: 6a 00 push $0x0 pushl $202 -c010317c: 68 ca 00 00 00 push $0xca +c01030b2: 68 ca 00 00 00 push $0xca jmp __alltraps -c0103181: e9 7c 02 00 00 jmp c0103402 <__alltraps> +c01030b7: e9 e2 f7 ff ff jmp c010289e <__alltraps> -c0103186 : +c01030bc : .globl vector203 vector203: pushl $0 -c0103186: 6a 00 push $0x0 +c01030bc: 6a 00 push $0x0 pushl $203 -c0103188: 68 cb 00 00 00 push $0xcb +c01030be: 68 cb 00 00 00 push $0xcb jmp __alltraps -c010318d: e9 70 02 00 00 jmp c0103402 <__alltraps> +c01030c3: e9 d6 f7 ff ff jmp c010289e <__alltraps> -c0103192 : +c01030c8 : .globl vector204 vector204: pushl $0 -c0103192: 6a 00 push $0x0 +c01030c8: 6a 00 push $0x0 pushl $204 -c0103194: 68 cc 00 00 00 push $0xcc +c01030ca: 68 cc 00 00 00 push $0xcc jmp __alltraps -c0103199: e9 64 02 00 00 jmp c0103402 <__alltraps> +c01030cf: e9 ca f7 ff ff jmp c010289e <__alltraps> -c010319e : +c01030d4 : .globl vector205 vector205: pushl $0 -c010319e: 6a 00 push $0x0 +c01030d4: 6a 00 push $0x0 pushl $205 -c01031a0: 68 cd 00 00 00 push $0xcd +c01030d6: 68 cd 00 00 00 push $0xcd jmp __alltraps -c01031a5: e9 58 02 00 00 jmp c0103402 <__alltraps> +c01030db: e9 be f7 ff ff jmp c010289e <__alltraps> -c01031aa : +c01030e0 : .globl vector206 vector206: pushl $0 -c01031aa: 6a 00 push $0x0 +c01030e0: 6a 00 push $0x0 pushl $206 -c01031ac: 68 ce 00 00 00 push $0xce +c01030e2: 68 ce 00 00 00 push $0xce jmp __alltraps -c01031b1: e9 4c 02 00 00 jmp c0103402 <__alltraps> +c01030e7: e9 b2 f7 ff ff jmp c010289e <__alltraps> -c01031b6 : +c01030ec : .globl vector207 vector207: pushl $0 -c01031b6: 6a 00 push $0x0 +c01030ec: 6a 00 push $0x0 pushl $207 -c01031b8: 68 cf 00 00 00 push $0xcf +c01030ee: 68 cf 00 00 00 push $0xcf jmp __alltraps -c01031bd: e9 40 02 00 00 jmp c0103402 <__alltraps> +c01030f3: e9 a6 f7 ff ff jmp c010289e <__alltraps> -c01031c2 : +c01030f8 : .globl vector208 vector208: pushl $0 -c01031c2: 6a 00 push $0x0 +c01030f8: 6a 00 push $0x0 pushl $208 -c01031c4: 68 d0 00 00 00 push $0xd0 +c01030fa: 68 d0 00 00 00 push $0xd0 jmp __alltraps -c01031c9: e9 34 02 00 00 jmp c0103402 <__alltraps> +c01030ff: e9 9a f7 ff ff jmp c010289e <__alltraps> -c01031ce : +c0103104 : .globl vector209 vector209: pushl $0 -c01031ce: 6a 00 push $0x0 +c0103104: 6a 00 push $0x0 pushl $209 -c01031d0: 68 d1 00 00 00 push $0xd1 +c0103106: 68 d1 00 00 00 push $0xd1 jmp __alltraps -c01031d5: e9 28 02 00 00 jmp c0103402 <__alltraps> +c010310b: e9 8e f7 ff ff jmp c010289e <__alltraps> -c01031da : +c0103110 : .globl vector210 vector210: pushl $0 -c01031da: 6a 00 push $0x0 +c0103110: 6a 00 push $0x0 pushl $210 -c01031dc: 68 d2 00 00 00 push $0xd2 +c0103112: 68 d2 00 00 00 push $0xd2 jmp __alltraps -c01031e1: e9 1c 02 00 00 jmp c0103402 <__alltraps> +c0103117: e9 82 f7 ff ff jmp c010289e <__alltraps> -c01031e6 : +c010311c : .globl vector211 vector211: pushl $0 -c01031e6: 6a 00 push $0x0 +c010311c: 6a 00 push $0x0 pushl $211 -c01031e8: 68 d3 00 00 00 push $0xd3 +c010311e: 68 d3 00 00 00 push $0xd3 jmp __alltraps -c01031ed: e9 10 02 00 00 jmp c0103402 <__alltraps> +c0103123: e9 76 f7 ff ff jmp c010289e <__alltraps> -c01031f2 : +c0103128 : .globl vector212 vector212: pushl $0 -c01031f2: 6a 00 push $0x0 +c0103128: 6a 00 push $0x0 pushl $212 -c01031f4: 68 d4 00 00 00 push $0xd4 +c010312a: 68 d4 00 00 00 push $0xd4 jmp __alltraps -c01031f9: e9 04 02 00 00 jmp c0103402 <__alltraps> +c010312f: e9 6a f7 ff ff jmp c010289e <__alltraps> -c01031fe : +c0103134 : .globl vector213 vector213: pushl $0 -c01031fe: 6a 00 push $0x0 +c0103134: 6a 00 push $0x0 pushl $213 -c0103200: 68 d5 00 00 00 push $0xd5 +c0103136: 68 d5 00 00 00 push $0xd5 jmp __alltraps -c0103205: e9 f8 01 00 00 jmp c0103402 <__alltraps> +c010313b: e9 5e f7 ff ff jmp c010289e <__alltraps> -c010320a : +c0103140 : .globl vector214 vector214: pushl $0 -c010320a: 6a 00 push $0x0 +c0103140: 6a 00 push $0x0 pushl $214 -c010320c: 68 d6 00 00 00 push $0xd6 +c0103142: 68 d6 00 00 00 push $0xd6 jmp __alltraps -c0103211: e9 ec 01 00 00 jmp c0103402 <__alltraps> +c0103147: e9 52 f7 ff ff jmp c010289e <__alltraps> -c0103216 : +c010314c : .globl vector215 vector215: pushl $0 -c0103216: 6a 00 push $0x0 +c010314c: 6a 00 push $0x0 pushl $215 -c0103218: 68 d7 00 00 00 push $0xd7 +c010314e: 68 d7 00 00 00 push $0xd7 jmp __alltraps -c010321d: e9 e0 01 00 00 jmp c0103402 <__alltraps> +c0103153: e9 46 f7 ff ff jmp c010289e <__alltraps> -c0103222 : +c0103158 : .globl vector216 vector216: pushl $0 -c0103222: 6a 00 push $0x0 +c0103158: 6a 00 push $0x0 pushl $216 -c0103224: 68 d8 00 00 00 push $0xd8 +c010315a: 68 d8 00 00 00 push $0xd8 jmp __alltraps -c0103229: e9 d4 01 00 00 jmp c0103402 <__alltraps> +c010315f: e9 3a f7 ff ff jmp c010289e <__alltraps> -c010322e : +c0103164 : .globl vector217 vector217: pushl $0 -c010322e: 6a 00 push $0x0 +c0103164: 6a 00 push $0x0 pushl $217 -c0103230: 68 d9 00 00 00 push $0xd9 +c0103166: 68 d9 00 00 00 push $0xd9 jmp __alltraps -c0103235: e9 c8 01 00 00 jmp c0103402 <__alltraps> +c010316b: e9 2e f7 ff ff jmp c010289e <__alltraps> -c010323a : +c0103170 : .globl vector218 vector218: pushl $0 -c010323a: 6a 00 push $0x0 +c0103170: 6a 00 push $0x0 pushl $218 -c010323c: 68 da 00 00 00 push $0xda +c0103172: 68 da 00 00 00 push $0xda jmp __alltraps -c0103241: e9 bc 01 00 00 jmp c0103402 <__alltraps> +c0103177: e9 22 f7 ff ff jmp c010289e <__alltraps> -c0103246 : +c010317c : .globl vector219 vector219: pushl $0 -c0103246: 6a 00 push $0x0 +c010317c: 6a 00 push $0x0 pushl $219 -c0103248: 68 db 00 00 00 push $0xdb +c010317e: 68 db 00 00 00 push $0xdb jmp __alltraps -c010324d: e9 b0 01 00 00 jmp c0103402 <__alltraps> +c0103183: e9 16 f7 ff ff jmp c010289e <__alltraps> -c0103252 : +c0103188 : .globl vector220 vector220: pushl $0 -c0103252: 6a 00 push $0x0 +c0103188: 6a 00 push $0x0 pushl $220 -c0103254: 68 dc 00 00 00 push $0xdc +c010318a: 68 dc 00 00 00 push $0xdc jmp __alltraps -c0103259: e9 a4 01 00 00 jmp c0103402 <__alltraps> +c010318f: e9 0a f7 ff ff jmp c010289e <__alltraps> -c010325e : +c0103194 : .globl vector221 vector221: pushl $0 -c010325e: 6a 00 push $0x0 +c0103194: 6a 00 push $0x0 pushl $221 -c0103260: 68 dd 00 00 00 push $0xdd +c0103196: 68 dd 00 00 00 push $0xdd jmp __alltraps -c0103265: e9 98 01 00 00 jmp c0103402 <__alltraps> +c010319b: e9 fe f6 ff ff jmp c010289e <__alltraps> -c010326a : +c01031a0 : .globl vector222 vector222: pushl $0 -c010326a: 6a 00 push $0x0 +c01031a0: 6a 00 push $0x0 pushl $222 -c010326c: 68 de 00 00 00 push $0xde +c01031a2: 68 de 00 00 00 push $0xde jmp __alltraps -c0103271: e9 8c 01 00 00 jmp c0103402 <__alltraps> +c01031a7: e9 f2 f6 ff ff jmp c010289e <__alltraps> -c0103276 : +c01031ac : .globl vector223 vector223: pushl $0 -c0103276: 6a 00 push $0x0 +c01031ac: 6a 00 push $0x0 pushl $223 -c0103278: 68 df 00 00 00 push $0xdf +c01031ae: 68 df 00 00 00 push $0xdf jmp __alltraps -c010327d: e9 80 01 00 00 jmp c0103402 <__alltraps> +c01031b3: e9 e6 f6 ff ff jmp c010289e <__alltraps> -c0103282 : +c01031b8 : .globl vector224 vector224: pushl $0 -c0103282: 6a 00 push $0x0 +c01031b8: 6a 00 push $0x0 pushl $224 -c0103284: 68 e0 00 00 00 push $0xe0 +c01031ba: 68 e0 00 00 00 push $0xe0 jmp __alltraps -c0103289: e9 74 01 00 00 jmp c0103402 <__alltraps> +c01031bf: e9 da f6 ff ff jmp c010289e <__alltraps> -c010328e : +c01031c4 : .globl vector225 vector225: pushl $0 -c010328e: 6a 00 push $0x0 +c01031c4: 6a 00 push $0x0 pushl $225 -c0103290: 68 e1 00 00 00 push $0xe1 +c01031c6: 68 e1 00 00 00 push $0xe1 jmp __alltraps -c0103295: e9 68 01 00 00 jmp c0103402 <__alltraps> +c01031cb: e9 ce f6 ff ff jmp c010289e <__alltraps> -c010329a : +c01031d0 : .globl vector226 vector226: pushl $0 -c010329a: 6a 00 push $0x0 +c01031d0: 6a 00 push $0x0 pushl $226 -c010329c: 68 e2 00 00 00 push $0xe2 +c01031d2: 68 e2 00 00 00 push $0xe2 jmp __alltraps -c01032a1: e9 5c 01 00 00 jmp c0103402 <__alltraps> +c01031d7: e9 c2 f6 ff ff jmp c010289e <__alltraps> -c01032a6 : +c01031dc : .globl vector227 vector227: pushl $0 -c01032a6: 6a 00 push $0x0 +c01031dc: 6a 00 push $0x0 pushl $227 -c01032a8: 68 e3 00 00 00 push $0xe3 +c01031de: 68 e3 00 00 00 push $0xe3 jmp __alltraps -c01032ad: e9 50 01 00 00 jmp c0103402 <__alltraps> +c01031e3: e9 b6 f6 ff ff jmp c010289e <__alltraps> -c01032b2 : +c01031e8 : .globl vector228 vector228: pushl $0 -c01032b2: 6a 00 push $0x0 +c01031e8: 6a 00 push $0x0 pushl $228 -c01032b4: 68 e4 00 00 00 push $0xe4 +c01031ea: 68 e4 00 00 00 push $0xe4 jmp __alltraps -c01032b9: e9 44 01 00 00 jmp c0103402 <__alltraps> +c01031ef: e9 aa f6 ff ff jmp c010289e <__alltraps> -c01032be : +c01031f4 : .globl vector229 vector229: pushl $0 -c01032be: 6a 00 push $0x0 +c01031f4: 6a 00 push $0x0 pushl $229 -c01032c0: 68 e5 00 00 00 push $0xe5 +c01031f6: 68 e5 00 00 00 push $0xe5 jmp __alltraps -c01032c5: e9 38 01 00 00 jmp c0103402 <__alltraps> +c01031fb: e9 9e f6 ff ff jmp c010289e <__alltraps> -c01032ca : +c0103200 : .globl vector230 vector230: pushl $0 -c01032ca: 6a 00 push $0x0 +c0103200: 6a 00 push $0x0 pushl $230 -c01032cc: 68 e6 00 00 00 push $0xe6 +c0103202: 68 e6 00 00 00 push $0xe6 jmp __alltraps -c01032d1: e9 2c 01 00 00 jmp c0103402 <__alltraps> +c0103207: e9 92 f6 ff ff jmp c010289e <__alltraps> -c01032d6 : +c010320c : .globl vector231 vector231: pushl $0 -c01032d6: 6a 00 push $0x0 +c010320c: 6a 00 push $0x0 pushl $231 -c01032d8: 68 e7 00 00 00 push $0xe7 +c010320e: 68 e7 00 00 00 push $0xe7 jmp __alltraps -c01032dd: e9 20 01 00 00 jmp c0103402 <__alltraps> +c0103213: e9 86 f6 ff ff jmp c010289e <__alltraps> -c01032e2 : +c0103218 : .globl vector232 vector232: pushl $0 -c01032e2: 6a 00 push $0x0 +c0103218: 6a 00 push $0x0 pushl $232 -c01032e4: 68 e8 00 00 00 push $0xe8 +c010321a: 68 e8 00 00 00 push $0xe8 jmp __alltraps -c01032e9: e9 14 01 00 00 jmp c0103402 <__alltraps> +c010321f: e9 7a f6 ff ff jmp c010289e <__alltraps> -c01032ee : +c0103224 : .globl vector233 vector233: pushl $0 -c01032ee: 6a 00 push $0x0 +c0103224: 6a 00 push $0x0 pushl $233 -c01032f0: 68 e9 00 00 00 push $0xe9 +c0103226: 68 e9 00 00 00 push $0xe9 jmp __alltraps -c01032f5: e9 08 01 00 00 jmp c0103402 <__alltraps> +c010322b: e9 6e f6 ff ff jmp c010289e <__alltraps> -c01032fa : +c0103230 : .globl vector234 vector234: pushl $0 -c01032fa: 6a 00 push $0x0 +c0103230: 6a 00 push $0x0 pushl $234 -c01032fc: 68 ea 00 00 00 push $0xea +c0103232: 68 ea 00 00 00 push $0xea jmp __alltraps -c0103301: e9 fc 00 00 00 jmp c0103402 <__alltraps> +c0103237: e9 62 f6 ff ff jmp c010289e <__alltraps> -c0103306 : +c010323c : .globl vector235 vector235: pushl $0 -c0103306: 6a 00 push $0x0 +c010323c: 6a 00 push $0x0 pushl $235 -c0103308: 68 eb 00 00 00 push $0xeb +c010323e: 68 eb 00 00 00 push $0xeb jmp __alltraps -c010330d: e9 f0 00 00 00 jmp c0103402 <__alltraps> +c0103243: e9 56 f6 ff ff jmp c010289e <__alltraps> -c0103312 : +c0103248 : .globl vector236 vector236: pushl $0 -c0103312: 6a 00 push $0x0 +c0103248: 6a 00 push $0x0 pushl $236 -c0103314: 68 ec 00 00 00 push $0xec +c010324a: 68 ec 00 00 00 push $0xec jmp __alltraps -c0103319: e9 e4 00 00 00 jmp c0103402 <__alltraps> +c010324f: e9 4a f6 ff ff jmp c010289e <__alltraps> -c010331e : +c0103254 : .globl vector237 vector237: pushl $0 -c010331e: 6a 00 push $0x0 +c0103254: 6a 00 push $0x0 pushl $237 -c0103320: 68 ed 00 00 00 push $0xed +c0103256: 68 ed 00 00 00 push $0xed jmp __alltraps -c0103325: e9 d8 00 00 00 jmp c0103402 <__alltraps> +c010325b: e9 3e f6 ff ff jmp c010289e <__alltraps> -c010332a : +c0103260 : .globl vector238 vector238: pushl $0 -c010332a: 6a 00 push $0x0 +c0103260: 6a 00 push $0x0 pushl $238 -c010332c: 68 ee 00 00 00 push $0xee +c0103262: 68 ee 00 00 00 push $0xee jmp __alltraps -c0103331: e9 cc 00 00 00 jmp c0103402 <__alltraps> +c0103267: e9 32 f6 ff ff jmp c010289e <__alltraps> -c0103336 : +c010326c : .globl vector239 vector239: pushl $0 -c0103336: 6a 00 push $0x0 +c010326c: 6a 00 push $0x0 pushl $239 -c0103338: 68 ef 00 00 00 push $0xef +c010326e: 68 ef 00 00 00 push $0xef jmp __alltraps -c010333d: e9 c0 00 00 00 jmp c0103402 <__alltraps> +c0103273: e9 26 f6 ff ff jmp c010289e <__alltraps> -c0103342 : +c0103278 : .globl vector240 vector240: pushl $0 -c0103342: 6a 00 push $0x0 +c0103278: 6a 00 push $0x0 pushl $240 -c0103344: 68 f0 00 00 00 push $0xf0 +c010327a: 68 f0 00 00 00 push $0xf0 jmp __alltraps -c0103349: e9 b4 00 00 00 jmp c0103402 <__alltraps> +c010327f: e9 1a f6 ff ff jmp c010289e <__alltraps> -c010334e : +c0103284 : .globl vector241 vector241: pushl $0 -c010334e: 6a 00 push $0x0 +c0103284: 6a 00 push $0x0 pushl $241 -c0103350: 68 f1 00 00 00 push $0xf1 +c0103286: 68 f1 00 00 00 push $0xf1 jmp __alltraps -c0103355: e9 a8 00 00 00 jmp c0103402 <__alltraps> +c010328b: e9 0e f6 ff ff jmp c010289e <__alltraps> -c010335a : +c0103290 : .globl vector242 vector242: pushl $0 -c010335a: 6a 00 push $0x0 +c0103290: 6a 00 push $0x0 pushl $242 -c010335c: 68 f2 00 00 00 push $0xf2 +c0103292: 68 f2 00 00 00 push $0xf2 jmp __alltraps -c0103361: e9 9c 00 00 00 jmp c0103402 <__alltraps> +c0103297: e9 02 f6 ff ff jmp c010289e <__alltraps> -c0103366 : +c010329c : .globl vector243 vector243: pushl $0 -c0103366: 6a 00 push $0x0 +c010329c: 6a 00 push $0x0 pushl $243 -c0103368: 68 f3 00 00 00 push $0xf3 +c010329e: 68 f3 00 00 00 push $0xf3 jmp __alltraps -c010336d: e9 90 00 00 00 jmp c0103402 <__alltraps> +c01032a3: e9 f6 f5 ff ff jmp c010289e <__alltraps> -c0103372 : +c01032a8 : .globl vector244 vector244: pushl $0 -c0103372: 6a 00 push $0x0 +c01032a8: 6a 00 push $0x0 pushl $244 -c0103374: 68 f4 00 00 00 push $0xf4 +c01032aa: 68 f4 00 00 00 push $0xf4 jmp __alltraps -c0103379: e9 84 00 00 00 jmp c0103402 <__alltraps> +c01032af: e9 ea f5 ff ff jmp c010289e <__alltraps> -c010337e : +c01032b4 : .globl vector245 vector245: pushl $0 -c010337e: 6a 00 push $0x0 +c01032b4: 6a 00 push $0x0 pushl $245 -c0103380: 68 f5 00 00 00 push $0xf5 +c01032b6: 68 f5 00 00 00 push $0xf5 jmp __alltraps -c0103385: e9 78 00 00 00 jmp c0103402 <__alltraps> +c01032bb: e9 de f5 ff ff jmp c010289e <__alltraps> -c010338a : +c01032c0 : .globl vector246 vector246: pushl $0 -c010338a: 6a 00 push $0x0 +c01032c0: 6a 00 push $0x0 pushl $246 -c010338c: 68 f6 00 00 00 push $0xf6 +c01032c2: 68 f6 00 00 00 push $0xf6 jmp __alltraps -c0103391: e9 6c 00 00 00 jmp c0103402 <__alltraps> +c01032c7: e9 d2 f5 ff ff jmp c010289e <__alltraps> -c0103396 : +c01032cc : .globl vector247 vector247: pushl $0 -c0103396: 6a 00 push $0x0 +c01032cc: 6a 00 push $0x0 pushl $247 -c0103398: 68 f7 00 00 00 push $0xf7 +c01032ce: 68 f7 00 00 00 push $0xf7 jmp __alltraps -c010339d: e9 60 00 00 00 jmp c0103402 <__alltraps> +c01032d3: e9 c6 f5 ff ff jmp c010289e <__alltraps> -c01033a2 : +c01032d8 : .globl vector248 vector248: pushl $0 -c01033a2: 6a 00 push $0x0 +c01032d8: 6a 00 push $0x0 pushl $248 -c01033a4: 68 f8 00 00 00 push $0xf8 +c01032da: 68 f8 00 00 00 push $0xf8 jmp __alltraps -c01033a9: e9 54 00 00 00 jmp c0103402 <__alltraps> +c01032df: e9 ba f5 ff ff jmp c010289e <__alltraps> -c01033ae : +c01032e4 : .globl vector249 vector249: pushl $0 -c01033ae: 6a 00 push $0x0 +c01032e4: 6a 00 push $0x0 pushl $249 -c01033b0: 68 f9 00 00 00 push $0xf9 +c01032e6: 68 f9 00 00 00 push $0xf9 jmp __alltraps -c01033b5: e9 48 00 00 00 jmp c0103402 <__alltraps> +c01032eb: e9 ae f5 ff ff jmp c010289e <__alltraps> -c01033ba : +c01032f0 : .globl vector250 vector250: pushl $0 -c01033ba: 6a 00 push $0x0 +c01032f0: 6a 00 push $0x0 pushl $250 -c01033bc: 68 fa 00 00 00 push $0xfa +c01032f2: 68 fa 00 00 00 push $0xfa jmp __alltraps -c01033c1: e9 3c 00 00 00 jmp c0103402 <__alltraps> +c01032f7: e9 a2 f5 ff ff jmp c010289e <__alltraps> -c01033c6 : +c01032fc : .globl vector251 vector251: pushl $0 -c01033c6: 6a 00 push $0x0 +c01032fc: 6a 00 push $0x0 pushl $251 -c01033c8: 68 fb 00 00 00 push $0xfb +c01032fe: 68 fb 00 00 00 push $0xfb jmp __alltraps -c01033cd: e9 30 00 00 00 jmp c0103402 <__alltraps> +c0103303: e9 96 f5 ff ff jmp c010289e <__alltraps> -c01033d2 : +c0103308 : .globl vector252 vector252: pushl $0 -c01033d2: 6a 00 push $0x0 +c0103308: 6a 00 push $0x0 pushl $252 -c01033d4: 68 fc 00 00 00 push $0xfc +c010330a: 68 fc 00 00 00 push $0xfc jmp __alltraps -c01033d9: e9 24 00 00 00 jmp c0103402 <__alltraps> +c010330f: e9 8a f5 ff ff jmp c010289e <__alltraps> -c01033de : +c0103314 : .globl vector253 vector253: pushl $0 -c01033de: 6a 00 push $0x0 +c0103314: 6a 00 push $0x0 pushl $253 -c01033e0: 68 fd 00 00 00 push $0xfd +c0103316: 68 fd 00 00 00 push $0xfd jmp __alltraps -c01033e5: e9 18 00 00 00 jmp c0103402 <__alltraps> +c010331b: e9 7e f5 ff ff jmp c010289e <__alltraps> -c01033ea : +c0103320 : .globl vector254 vector254: pushl $0 -c01033ea: 6a 00 push $0x0 +c0103320: 6a 00 push $0x0 pushl $254 -c01033ec: 68 fe 00 00 00 push $0xfe +c0103322: 68 fe 00 00 00 push $0xfe jmp __alltraps -c01033f1: e9 0c 00 00 00 jmp c0103402 <__alltraps> +c0103327: e9 72 f5 ff ff jmp c010289e <__alltraps> -c01033f6 : +c010332c : .globl vector255 vector255: pushl $0 -c01033f6: 6a 00 push $0x0 +c010332c: 6a 00 push $0x0 pushl $255 -c01033f8: 68 ff 00 00 00 push $0xff +c010332e: 68 ff 00 00 00 push $0xff jmp __alltraps -c01033fd: e9 00 00 00 00 jmp c0103402 <__alltraps> - -c0103402 <__alltraps>: -.globl __alltraps -__alltraps: - # push registers to build a trap frame - # therefore make the stack look like a struct trapframe - # 通过 push 指令,将数据段寄存器和所有通用寄存器(使用 pushal)的值压入栈中,以保存当前状态。 - pushl %ds -c0103402: 1e push %ds - pushl %es -c0103403: 06 push %es - pushl %fs -c0103404: 0f a0 push %fs - pushl %gs -c0103406: 0f a8 push %gs - pushal -c0103408: 60 pusha - - # load GD_KDATA into %ds and %es to set up data segments for kernel - # 将常量 GD_KDATA 加载到 %eax 中,然后将其值复制到 %ds 和 %es 中,设置内核的数据段。 - movl $GD_KDATA, %eax -c0103409: b8 10 00 00 00 mov $0x10,%eax - movw %ax, %ds -c010340e: 8e d8 mov %eax,%ds - movw %ax, %es -c0103410: 8e c0 mov %eax,%es - - # push %esp to pass a pointer to the trapframe as an argument to trap() - # 将 %esp 压栈,以将指向 trapframe 的指针作为参数传递给 trap() - pushl %esp -c0103412: 54 push %esp - - # call trap(tf), where tf=%esp - # 调用 trap(tf),其中 tf=%esp - call trap -c0103413: e8 60 f5 ff ff call c0102978 - - # pop the pushed stack pointer弹出之前压入的栈指针 - popl %esp -c0103418: 5c pop %esp - -c0103419 <__trapret>: - # 返回后继续执行到 trapret... -.globl __trapret -__trapret: - # restore registers from stack - # 定义了返回的入口点 __trapret。 - popal -c0103419: 61 popa - - # restore %ds, %es, %fs and %gs - # 这里会恢复之前保存的寄存器 - popl %gs -c010341a: 0f a9 pop %gs - popl %fs -c010341c: 0f a1 pop %fs - popl %es -c010341e: 07 pop %es - popl %ds -c010341f: 1f pop %ds - - # get rid of the trap number and error code - # 通过 iret 指令返回中断处理 - addl $0x8, %esp -c0103420: 83 c4 08 add $0x8,%esp - iret -c0103423: cf iret - -c0103424 : - -.globl forkrets -forkrets: - # set stack to this new process's trapframe - movl 4(%esp), %esp -c0103424: 8b 64 24 04 mov 0x4(%esp),%esp - jmp __trapret -c0103428: eb ef jmp c0103419 <__trapret> +c0103333: e9 66 f5 ff ff jmp c010289e <__alltraps> -c010342a : +c0103338 : extern struct Page *pages; extern size_t npage; static inline ppn_t page2ppn(struct Page *page) { -c010342a: 55 push %ebp -c010342b: 89 e5 mov %esp,%ebp +c0103338: 55 push %ebp +c0103339: 89 e5 mov %esp,%ebp return page - pages; -c010342d: a1 b8 e0 12 c0 mov 0xc012e0b8,%eax -c0103432: 8b 55 08 mov 0x8(%ebp),%edx -c0103435: 29 c2 sub %eax,%edx -c0103437: 89 d0 mov %edx,%eax -c0103439: c1 f8 05 sar $0x5,%eax +c010333b: 8b 15 00 c0 12 c0 mov 0xc012c000,%edx +c0103341: 8b 45 08 mov 0x8(%ebp),%eax +c0103344: 29 d0 sub %edx,%eax +c0103346: c1 f8 05 sar $0x5,%eax } -c010343c: 5d pop %ebp -c010343d: c3 ret +c0103349: 5d pop %ebp +c010334a: c3 ret -c010343e : +c010334b : static inline uintptr_t page2pa(struct Page *page) { -c010343e: 55 push %ebp -c010343f: 89 e5 mov %esp,%ebp -c0103441: 83 ec 04 sub $0x4,%esp +c010334b: 55 push %ebp +c010334c: 89 e5 mov %esp,%ebp +c010334e: 83 ec 04 sub $0x4,%esp return page2ppn(page) << PGSHIFT; -c0103444: 8b 45 08 mov 0x8(%ebp),%eax -c0103447: 89 04 24 mov %eax,(%esp) -c010344a: e8 db ff ff ff call c010342a -c010344f: c1 e0 0c shl $0xc,%eax -} -c0103452: c9 leave -c0103453: c3 ret - -c0103454 : - -static inline struct Page * -pa2page(uintptr_t pa) { -c0103454: 55 push %ebp -c0103455: 89 e5 mov %esp,%ebp -c0103457: 83 ec 18 sub $0x18,%esp - if (PPN(pa) >= npage) { -c010345a: 8b 45 08 mov 0x8(%ebp),%eax -c010345d: c1 e8 0c shr $0xc,%eax -c0103460: 89 c2 mov %eax,%edx -c0103462: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0103467: 39 c2 cmp %eax,%edx -c0103469: 72 1c jb c0103487 - panic("pa2page called with invalid pa"); -c010346b: c7 44 24 08 90 ab 10 movl $0xc010ab90,0x8(%esp) -c0103472: c0 -c0103473: c7 44 24 04 5f 00 00 movl $0x5f,0x4(%esp) -c010347a: 00 -c010347b: c7 04 24 af ab 10 c0 movl $0xc010abaf,(%esp) -c0103482: e8 bc cf ff ff call c0100443 <__panic> - } - return &pages[PPN(pa)]; -c0103487: a1 b8 e0 12 c0 mov 0xc012e0b8,%eax -c010348c: 8b 55 08 mov 0x8(%ebp),%edx -c010348f: c1 ea 0c shr $0xc,%edx -c0103492: c1 e2 05 shl $0x5,%edx -c0103495: 01 d0 add %edx,%eax +c0103351: 8b 45 08 mov 0x8(%ebp),%eax +c0103354: 89 04 24 mov %eax,(%esp) +c0103357: e8 dc ff ff ff call c0103338 +c010335c: c1 e0 0c shl $0xc,%eax } -c0103497: c9 leave -c0103498: c3 ret +c010335f: 89 ec mov %ebp,%esp +c0103361: 5d pop %ebp +c0103362: c3 ret -c0103499 : - -static inline void * -page2kva(struct Page *page) { -c0103499: 55 push %ebp -c010349a: 89 e5 mov %esp,%ebp -c010349c: 83 ec 28 sub $0x28,%esp - return KADDR(page2pa(page)); -c010349f: 8b 45 08 mov 0x8(%ebp),%eax -c01034a2: 89 04 24 mov %eax,(%esp) -c01034a5: e8 94 ff ff ff call c010343e -c01034aa: 89 45 f4 mov %eax,-0xc(%ebp) -c01034ad: 8b 45 f4 mov -0xc(%ebp),%eax -c01034b0: c1 e8 0c shr $0xc,%eax -c01034b3: 89 45 f0 mov %eax,-0x10(%ebp) -c01034b6: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c01034bb: 39 45 f0 cmp %eax,-0x10(%ebp) -c01034be: 72 23 jb c01034e3 -c01034c0: 8b 45 f4 mov -0xc(%ebp),%eax -c01034c3: 89 44 24 0c mov %eax,0xc(%esp) -c01034c7: c7 44 24 08 c0 ab 10 movl $0xc010abc0,0x8(%esp) -c01034ce: c0 -c01034cf: c7 44 24 04 66 00 00 movl $0x66,0x4(%esp) -c01034d6: 00 -c01034d7: c7 04 24 af ab 10 c0 movl $0xc010abaf,(%esp) -c01034de: e8 60 cf ff ff call c0100443 <__panic> -c01034e3: 8b 45 f4 mov -0xc(%ebp),%eax -c01034e6: 2d 00 00 00 40 sub $0x40000000,%eax -} -c01034eb: c9 leave -c01034ec: c3 ret - -c01034ed : -kva2page(void *kva) { - return pa2page(PADDR(kva)); -} - -static inline struct Page * -pte2page(pte_t pte) { -c01034ed: 55 push %ebp -c01034ee: 89 e5 mov %esp,%ebp -c01034f0: 83 ec 18 sub $0x18,%esp - if (!(pte & PTE_P)) { -c01034f3: 8b 45 08 mov 0x8(%ebp),%eax -c01034f6: 83 e0 01 and $0x1,%eax -c01034f9: 85 c0 test %eax,%eax -c01034fb: 75 1c jne c0103519 - panic("pte2page called with invalid pte"); -c01034fd: c7 44 24 08 e4 ab 10 movl $0xc010abe4,0x8(%esp) -c0103504: c0 -c0103505: c7 44 24 04 71 00 00 movl $0x71,0x4(%esp) -c010350c: 00 -c010350d: c7 04 24 af ab 10 c0 movl $0xc010abaf,(%esp) -c0103514: e8 2a cf ff ff call c0100443 <__panic> - } - return pa2page(PTE_ADDR(pte)); -c0103519: 8b 45 08 mov 0x8(%ebp),%eax -c010351c: 25 00 f0 ff ff and $0xfffff000,%eax -c0103521: 89 04 24 mov %eax,(%esp) -c0103524: e8 2b ff ff ff call c0103454 -} -c0103529: c9 leave -c010352a: c3 ret - -c010352b : - -static inline struct Page * +c0103363 : pde2page(pde_t pde) { -c010352b: 55 push %ebp -c010352c: 89 e5 mov %esp,%ebp -c010352e: 83 ec 18 sub $0x18,%esp return pa2page(PDE_ADDR(pde)); -c0103531: 8b 45 08 mov 0x8(%ebp),%eax -c0103534: 25 00 f0 ff ff and $0xfffff000,%eax -c0103539: 89 04 24 mov %eax,(%esp) -c010353c: e8 13 ff ff ff call c0103454 } -c0103541: c9 leave -c0103542: c3 ret - -c0103543 : static inline int page_ref(struct Page *page) { -c0103543: 55 push %ebp -c0103544: 89 e5 mov %esp,%ebp +c0103363: 55 push %ebp +c0103364: 89 e5 mov %esp,%ebp return page->ref; -c0103546: 8b 45 08 mov 0x8(%ebp),%eax -c0103549: 8b 00 mov (%eax),%eax +c0103366: 8b 45 08 mov 0x8(%ebp),%eax +c0103369: 8b 00 mov (%eax),%eax } -c010354b: 5d pop %ebp -c010354c: c3 ret +c010336b: 5d pop %ebp +c010336c: c3 ret -c010354d : +c010336d : static inline void set_page_ref(struct Page *page, int val) { -c010354d: 55 push %ebp -c010354e: 89 e5 mov %esp,%ebp +c010336d: 55 push %ebp +c010336e: 89 e5 mov %esp,%ebp page->ref = val; -c0103550: 8b 45 08 mov 0x8(%ebp),%eax -c0103553: 8b 55 0c mov 0xc(%ebp),%edx -c0103556: 89 10 mov %edx,(%eax) -} -c0103558: 90 nop -c0103559: 5d pop %ebp -c010355a: c3 ret - -c010355b : - -static inline int -page_ref_inc(struct Page *page) { -c010355b: 55 push %ebp -c010355c: 89 e5 mov %esp,%ebp - page->ref += 1; -c010355e: 8b 45 08 mov 0x8(%ebp),%eax -c0103561: 8b 00 mov (%eax),%eax -c0103563: 8d 50 01 lea 0x1(%eax),%edx -c0103566: 8b 45 08 mov 0x8(%ebp),%eax -c0103569: 89 10 mov %edx,(%eax) - return page->ref; -c010356b: 8b 45 08 mov 0x8(%ebp),%eax -c010356e: 8b 00 mov (%eax),%eax +c0103370: 8b 45 08 mov 0x8(%ebp),%eax +c0103373: 8b 55 0c mov 0xc(%ebp),%edx +c0103376: 89 10 mov %edx,(%eax) } -c0103570: 5d pop %ebp -c0103571: c3 ret +c0103378: 90 nop +c0103379: 5d pop %ebp +c010337a: c3 ret -c0103572 : +c010337b : +#define nr_free (free_area.nr_free) -static inline int -page_ref_dec(struct Page *page) { -c0103572: 55 push %ebp -c0103573: 89 e5 mov %esp,%ebp - page->ref -= 1; -c0103575: 8b 45 08 mov 0x8(%ebp),%eax -c0103578: 8b 00 mov (%eax),%eax -c010357a: 8d 50 ff lea -0x1(%eax),%edx -c010357d: 8b 45 08 mov 0x8(%ebp),%eax -c0103580: 89 10 mov %edx,(%eax) - return page->ref; -c0103582: 8b 45 08 mov 0x8(%ebp),%eax -c0103585: 8b 00 mov (%eax),%eax +//free_list` 用于记录空闲内存块,nr_free` 是空闲内存块的总数。 +//用default_init函数来初始化 `free_list`,并将 `nr_free` 设置为 0。 +static void +default_init(void) { +c010337b: 55 push %ebp +c010337c: 89 e5 mov %esp,%ebp +c010337e: 83 ec 10 sub $0x10,%esp +c0103381: c7 45 fc e4 bf 12 c0 movl $0xc012bfe4,-0x4(%ebp) + * list_init - initialize a new entry + * @elm: new entry to be initialized + * */ +static inline void +list_init(list_entry_t *elm) { + elm->prev = elm->next = elm; +c0103388: 8b 45 fc mov -0x4(%ebp),%eax +c010338b: 8b 55 fc mov -0x4(%ebp),%edx +c010338e: 89 50 04 mov %edx,0x4(%eax) +c0103391: 8b 45 fc mov -0x4(%ebp),%eax +c0103394: 8b 50 04 mov 0x4(%eax),%edx +c0103397: 8b 45 fc mov -0x4(%ebp),%eax +c010339a: 89 10 mov %edx,(%eax) +} +c010339c: 90 nop + list_init(&free_list); + nr_free = 0; +c010339d: c7 05 ec bf 12 c0 00 movl $0x0,0xc012bfec +c01033a4: 00 00 00 } -c0103587: 5d pop %ebp -c0103588: c3 ret +c01033a7: 90 nop +c01033a8: 89 ec mov %ebp,%esp +c01033aa: 5d pop %ebp +c01033ab: c3 ret -c0103589 <__intr_save>: -__intr_save(void) { -c0103589: 55 push %ebp -c010358a: 89 e5 mov %esp,%ebp -c010358c: 83 ec 18 sub $0x18,%esp - asm volatile ("pushfl; popl %0" : "=r" (eflags)); -c010358f: 9c pushf -c0103590: 58 pop %eax -c0103591: 89 45 f4 mov %eax,-0xc(%ebp) - return eflags; -c0103594: 8b 45 f4 mov -0xc(%ebp),%eax - if (read_eflags() & FL_IF) { -c0103597: 25 00 02 00 00 and $0x200,%eax -c010359c: 85 c0 test %eax,%eax -c010359e: 74 0c je c01035ac <__intr_save+0x23> - intr_disable(); -c01035a0: e8 af eb ff ff call c0102154 - return 1; -c01035a5: b8 01 00 00 00 mov $0x1,%eax -c01035aa: eb 05 jmp c01035b1 <__intr_save+0x28> - return 0; -c01035ac: b8 00 00 00 00 mov $0x0,%eax -} -c01035b1: c9 leave -c01035b2: c3 ret +c01033ac : -c01035b3 <__intr_restore>: -__intr_restore(bool flag) { -c01035b3: 55 push %ebp -c01035b4: 89 e5 mov %esp,%ebp -c01035b6: 83 ec 08 sub $0x8,%esp - if (flag) { -c01035b9: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c01035bd: 74 05 je c01035c4 <__intr_restore+0x11> - intr_enable(); -c01035bf: e8 84 eb ff ff call c0102148 +//用于初始化一段连续的物理页,并将它们加入到空闲内存管理系统中. +//struct Page *base:指向要初始化的页块的起始地址。size_t n:要初始化的页的数量。 +static void +default_init_memmap(struct Page *base, size_t n) { +c01033ac: 55 push %ebp +c01033ad: 89 e5 mov %esp,%ebp +c01033af: 83 ec 48 sub $0x48,%esp + assert(n > 0);// 确保请求的页数大于零 +c01033b2: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) +c01033b6: 75 24 jne c01033dc +c01033b8: c7 44 24 0c 70 a9 10 movl $0xc010a970,0xc(%esp) +c01033bf: c0 +c01033c0: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c01033c7: c0 +c01033c8: c7 44 24 04 9a 00 00 movl $0x9a,0x4(%esp) +c01033cf: 00 +c01033d0: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c01033d7: e8 69 d8 ff ff call c0100c45 <__panic> + struct Page *p = base;// 指向当前初始化的页 +c01033dc: 8b 45 08 mov 0x8(%ebp),%eax +c01033df: 89 45 f4 mov %eax,-0xc(%ebp) + // 遍历每一页,设置其状态 + for (; p != base + n; p ++) { +c01033e2: eb 7d jmp c0103461 + assert(PageReserved(p));//检查每个页是否被标记为“保留”。若没有被保留,函数将抛出错误。 +c01033e4: 8b 45 f4 mov -0xc(%ebp),%eax +c01033e7: 83 c0 04 add $0x4,%eax +c01033ea: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) +c01033f1: 89 45 ec mov %eax,-0x14(%ebp) + * @addr: the address to count from + * */ +static inline bool +test_bit(int nr, volatile void *addr) { + int oldbit; + asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); +c01033f4: 8b 45 ec mov -0x14(%ebp),%eax +c01033f7: 8b 55 f0 mov -0x10(%ebp),%edx +c01033fa: 0f a3 10 bt %edx,(%eax) +c01033fd: 19 c0 sbb %eax,%eax +c01033ff: 89 45 e8 mov %eax,-0x18(%ebp) + return oldbit != 0; +c0103402: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) +c0103406: 0f 95 c0 setne %al +c0103409: 0f b6 c0 movzbl %al,%eax +c010340c: 85 c0 test %eax,%eax +c010340e: 75 24 jne c0103434 +c0103410: c7 44 24 0c a1 a9 10 movl $0xc010a9a1,0xc(%esp) +c0103417: c0 +c0103418: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c010341f: c0 +c0103420: c7 44 24 04 9e 00 00 movl $0x9e,0x4(%esp) +c0103427: 00 +c0103428: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c010342f: e8 11 d8 ff ff call c0100c45 <__panic> + p->flags = p->property = 0;//将页的 flags 和 property 字段设置为 0,表示该页未分配、未使用。 +c0103434: 8b 45 f4 mov -0xc(%ebp),%eax +c0103437: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) +c010343e: 8b 45 f4 mov -0xc(%ebp),%eax +c0103441: 8b 50 08 mov 0x8(%eax),%edx +c0103444: 8b 45 f4 mov -0xc(%ebp),%eax +c0103447: 89 50 04 mov %edx,0x4(%eax) + set_page_ref(p, 0);//将页的引用计数设置为 0,表明没有任何引用指向此页。 +c010344a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0103451: 00 +c0103452: 8b 45 f4 mov -0xc(%ebp),%eax +c0103455: 89 04 24 mov %eax,(%esp) +c0103458: e8 10 ff ff ff call c010336d + for (; p != base + n; p ++) { +c010345d: 83 45 f4 20 addl $0x20,-0xc(%ebp) +c0103461: 8b 45 0c mov 0xc(%ebp),%eax +c0103464: c1 e0 05 shl $0x5,%eax +c0103467: 89 c2 mov %eax,%edx +c0103469: 8b 45 08 mov 0x8(%ebp),%eax +c010346c: 01 d0 add %edx,%eax +c010346e: 39 45 f4 cmp %eax,-0xc(%ebp) +c0103471: 0f 85 6d ff ff ff jne c01033e4 + } + // 设置第一个页的 property 为块的总数 + base->property = n; +c0103477: 8b 45 08 mov 0x8(%ebp),%eax +c010347a: 8b 55 0c mov 0xc(%ebp),%edx +c010347d: 89 50 08 mov %edx,0x8(%eax) + SetPageProperty(base);// 设置当前页的有效标志 +c0103480: 8b 45 08 mov 0x8(%ebp),%eax +c0103483: 83 c0 04 add $0x4,%eax +c0103486: c7 45 d0 01 00 00 00 movl $0x1,-0x30(%ebp) +c010348d: 89 45 cc mov %eax,-0x34(%ebp) + asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); +c0103490: 8b 45 cc mov -0x34(%ebp),%eax +c0103493: 8b 55 d0 mov -0x30(%ebp),%edx +c0103496: 0f ab 10 bts %edx,(%eax) } -c01035c4: 90 nop -c01035c5: c9 leave -c01035c6: c3 ret - -c01035c7 : - * data/code segement registers for kernel. - * lgdt - 加载全局描述符表寄存器并重置内核的数据/代码段寄存器。 +c0103499: 90 nop + nr_free += n;// 更新空闲页计数 +c010349a: 8b 15 ec bf 12 c0 mov 0xc012bfec,%edx +c01034a0: 8b 45 0c mov 0xc(%ebp),%eax +c01034a3: 01 d0 add %edx,%eax +c01034a5: a3 ec bf 12 c0 mov %eax,0xc012bfec + list_add_before(&free_list, &(base->page_link));// 将该块添加到空闲列表中 +c01034aa: 8b 45 08 mov 0x8(%ebp),%eax +c01034ad: 83 c0 0c add $0xc,%eax +c01034b0: c7 45 e4 e4 bf 12 c0 movl $0xc012bfe4,-0x1c(%ebp) +c01034b7: 89 45 e0 mov %eax,-0x20(%ebp) + * Insert the new element @elm *before* the element @listelm which + * is already in the list. * */ -//定义了一个静态内联函数 lgdt,接收一个指向伪描述符(struct pseudodesc)的指针 pd static inline void -lgdt(struct pseudodesc *pd) { -c01035c7: 55 push %ebp -c01035c8: 89 e5 mov %esp,%ebp - //这行汇编代码使用 lgdt 指令加载 GDT。%0 被替换为指向 pd 的指针,告诉处理器 GDT 的地址。 - asm volatile ("lgdt (%0)" :: "r" (pd)); -c01035ca: 8b 45 08 mov 0x8(%ebp),%eax -c01035cd: 0f 01 10 lgdtl (%eax) - asm volatile ("movw %%ax, %%gs" :: "a" (USER_DS));//将 USER_DS(用户数据段)的值移动到 gs 段寄存器。 -c01035d0: b8 23 00 00 00 mov $0x23,%eax -c01035d5: 8e e8 mov %eax,%gs - asm volatile ("movw %%ax, %%fs" :: "a" (USER_DS));//将 USER_DS 的值移动到 fs 段寄存器。 -c01035d7: b8 23 00 00 00 mov $0x23,%eax -c01035dc: 8e e0 mov %eax,%fs - asm volatile ("movw %%ax, %%es" :: "a" (KERNEL_DS));//将 KERNEL_DS(内核数据段)的值移动到 es 段寄存器。 -c01035de: b8 10 00 00 00 mov $0x10,%eax -c01035e3: 8e c0 mov %eax,%es - asm volatile ("movw %%ax, %%ds" :: "a" (KERNEL_DS));//将 KERNEL_DS 的值移动到 ds 段寄存器 -c01035e5: b8 10 00 00 00 mov $0x10,%eax -c01035ea: 8e d8 mov %eax,%ds - asm volatile ("movw %%ax, %%ss" :: "a" (KERNEL_DS));//将 KERNEL_DS 的值移动到 ss 段寄存器 -c01035ec: b8 10 00 00 00 mov $0x10,%eax -c01035f1: 8e d0 mov %eax,%ss - // reload cs - //通过 ljmp 指令重新加载代码段寄存器 cs,并跳转到标签 1。 - asm volatile ("ljmp %0, $1f\n 1:\n" :: "i" (KERNEL_CS)); -c01035f3: ea fa 35 10 c0 08 00 ljmp $0x8,$0xc01035fa -} -c01035fa: 90 nop -c01035fb: 5d pop %ebp -c01035fc: c3 ret - -c01035fd : - * load_esp0 - 修改默认任务状态段中的 ESP0,以便在从用户态陷入内核态时能够使用不同的内核栈。 +list_add_before(list_entry_t *listelm, list_entry_t *elm) { + __list_add(elm, listelm->prev, listelm); +c01034ba: 8b 45 e4 mov -0x1c(%ebp),%eax +c01034bd: 8b 00 mov (%eax),%eax +c01034bf: 8b 55 e0 mov -0x20(%ebp),%edx +c01034c2: 89 55 dc mov %edx,-0x24(%ebp) +c01034c5: 89 45 d8 mov %eax,-0x28(%ebp) +c01034c8: 8b 45 e4 mov -0x1c(%ebp),%eax +c01034cb: 89 45 d4 mov %eax,-0x2c(%ebp) + * This is only for internal list manipulation where we know + * the prev/next entries already! * */ -//uintptr_t esp0:这是新的堆栈指针,通常指向内核栈的顶部。 -//修改当前任务状态段(TSS)中的 ESP0 值。ESP0 是在从用户态切换到内核态时,CPU 使用的内核栈指针。 -void -load_esp0(uintptr_t esp0) { -c01035fd: f3 0f 1e fb endbr32 -c0103601: 55 push %ebp -c0103602: 89 e5 mov %esp,%ebp - ts.ts_esp0 = esp0; -c0103604: 8b 45 08 mov 0x8(%ebp),%eax -c0103607: a3 a4 bf 12 c0 mov %eax,0xc012bfa4 +static inline void +__list_add(list_entry_t *elm, list_entry_t *prev, list_entry_t *next) { + prev->next = next->prev = elm; +c01034ce: 8b 45 d4 mov -0x2c(%ebp),%eax +c01034d1: 8b 55 dc mov -0x24(%ebp),%edx +c01034d4: 89 10 mov %edx,(%eax) +c01034d6: 8b 45 d4 mov -0x2c(%ebp),%eax +c01034d9: 8b 10 mov (%eax),%edx +c01034db: 8b 45 d8 mov -0x28(%ebp),%eax +c01034de: 89 50 04 mov %edx,0x4(%eax) + elm->next = next; +c01034e1: 8b 45 dc mov -0x24(%ebp),%eax +c01034e4: 8b 55 d4 mov -0x2c(%ebp),%edx +c01034e7: 89 50 04 mov %edx,0x4(%eax) + elm->prev = prev; +c01034ea: 8b 45 dc mov -0x24(%ebp),%eax +c01034ed: 8b 55 d8 mov -0x28(%ebp),%edx +c01034f0: 89 10 mov %edx,(%eax) +} +c01034f2: 90 nop +} +c01034f3: 90 nop } -c010360c: 90 nop -c010360d: 5d pop %ebp -c010360e: c3 ret +c01034f4: 90 nop +c01034f5: 89 ec mov %ebp,%esp +c01034f7: 5d pop %ebp +c01034f8: c3 ret -c010360f : +c01034f9 : -/* gdt_init - initialize the default GDT and TSS */ -/* gdt_init - 初始化默认的 GDT 和 TSS */ -static void -gdt_init(void) { -c010360f: f3 0f 1e fb endbr32 -c0103613: 55 push %ebp -c0103614: 89 e5 mov %esp,%ebp -c0103616: 83 ec 14 sub $0x14,%esp - // 设置启动内核栈和默认的 SS0 - // set boot kernel stack and default SS0 - load_esp0((uintptr_t)bootstacktop); -c0103619: b8 00 80 12 c0 mov $0xc0128000,%eax -c010361e: 89 04 24 mov %eax,(%esp) -c0103621: e8 d7 ff ff ff call c01035fd - ts.ts_ss0 = KERNEL_DS; -c0103626: 66 c7 05 a8 bf 12 c0 movw $0x10,0xc012bfa8 -c010362d: 10 00 - // 初始化 GDT 中的 TSS 字段 - // initialize the TSS filed of the gdt - gdt[SEG_TSS] = SEGTSS(STS_T32A, (uintptr_t)&ts, sizeof(ts), DPL_KERNEL); -c010362f: 66 c7 05 28 8a 12 c0 movw $0x68,0xc0128a28 -c0103636: 68 00 -c0103638: b8 a0 bf 12 c0 mov $0xc012bfa0,%eax -c010363d: 0f b7 c0 movzwl %ax,%eax -c0103640: 66 a3 2a 8a 12 c0 mov %ax,0xc0128a2a -c0103646: b8 a0 bf 12 c0 mov $0xc012bfa0,%eax -c010364b: c1 e8 10 shr $0x10,%eax -c010364e: a2 2c 8a 12 c0 mov %al,0xc0128a2c -c0103653: 0f b6 05 2d 8a 12 c0 movzbl 0xc0128a2d,%eax -c010365a: 24 f0 and $0xf0,%al -c010365c: 0c 09 or $0x9,%al -c010365e: a2 2d 8a 12 c0 mov %al,0xc0128a2d -c0103663: 0f b6 05 2d 8a 12 c0 movzbl 0xc0128a2d,%eax -c010366a: 24 ef and $0xef,%al -c010366c: a2 2d 8a 12 c0 mov %al,0xc0128a2d -c0103671: 0f b6 05 2d 8a 12 c0 movzbl 0xc0128a2d,%eax -c0103678: 24 9f and $0x9f,%al -c010367a: a2 2d 8a 12 c0 mov %al,0xc0128a2d -c010367f: 0f b6 05 2d 8a 12 c0 movzbl 0xc0128a2d,%eax -c0103686: 0c 80 or $0x80,%al -c0103688: a2 2d 8a 12 c0 mov %al,0xc0128a2d -c010368d: 0f b6 05 2e 8a 12 c0 movzbl 0xc0128a2e,%eax -c0103694: 24 f0 and $0xf0,%al -c0103696: a2 2e 8a 12 c0 mov %al,0xc0128a2e -c010369b: 0f b6 05 2e 8a 12 c0 movzbl 0xc0128a2e,%eax -c01036a2: 24 ef and $0xef,%al -c01036a4: a2 2e 8a 12 c0 mov %al,0xc0128a2e -c01036a9: 0f b6 05 2e 8a 12 c0 movzbl 0xc0128a2e,%eax -c01036b0: 24 df and $0xdf,%al -c01036b2: a2 2e 8a 12 c0 mov %al,0xc0128a2e -c01036b7: 0f b6 05 2e 8a 12 c0 movzbl 0xc0128a2e,%eax -c01036be: 0c 40 or $0x40,%al -c01036c0: a2 2e 8a 12 c0 mov %al,0xc0128a2e -c01036c5: 0f b6 05 2e 8a 12 c0 movzbl 0xc0128a2e,%eax -c01036cc: 24 7f and $0x7f,%al -c01036ce: a2 2e 8a 12 c0 mov %al,0xc0128a2e -c01036d3: b8 a0 bf 12 c0 mov $0xc012bfa0,%eax -c01036d8: c1 e8 18 shr $0x18,%eax -c01036db: a2 2f 8a 12 c0 mov %al,0xc0128a2f - // 使用lgdt加载全局描述符表,更新所有段寄存器 - // reload all segment registers - lgdt(&gdt_pd); -c01036e0: c7 04 24 30 8a 12 c0 movl $0xc0128a30,(%esp) -c01036e7: e8 db fe ff ff call c01035c7 -c01036ec: 66 c7 45 fe 28 00 movw $0x28,-0x2(%ebp) - asm volatile ("ltr %0" :: "r" (sel) : "memory"); -c01036f2: 0f b7 45 fe movzwl -0x2(%ebp),%eax -c01036f6: 0f 00 d8 ltr %ax -} -c01036f9: 90 nop - // 加载 TSS,使 CPU 在进行特权级切换时能够正确使用 TSS。 - // load the TSS - ltr(GD_TSS); +//用于分配指定数量的连续物理页。该函数实现了首次适应内存分配算法。 +static struct Page * +default_alloc_pages(size_t n) { +c01034f9: 55 push %ebp +c01034fa: 89 e5 mov %esp,%ebp +c01034fc: 83 ec 68 sub $0x68,%esp + assert(n > 0);// 确保请求的页数大于零 +c01034ff: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0103503: 75 24 jne c0103529 +c0103505: c7 44 24 0c 70 a9 10 movl $0xc010a970,0xc(%esp) +c010350c: c0 +c010350d: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103514: c0 +c0103515: c7 44 24 04 ac 00 00 movl $0xac,0x4(%esp) +c010351c: 00 +c010351d: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103524: e8 1c d7 ff ff call c0100c45 <__panic> + if (n > nr_free) {// 检查请求的页数是否超过空闲页数 +c0103529: a1 ec bf 12 c0 mov 0xc012bfec,%eax +c010352e: 39 45 08 cmp %eax,0x8(%ebp) +c0103531: 76 0a jbe c010353d + return NULL; +c0103533: b8 00 00 00 00 mov $0x0,%eax +c0103538: e9 3c 01 00 00 jmp c0103679 + } + struct Page *page = NULL;// 初始化分配的页指针 +c010353d: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) + list_entry_t *le = &free_list;// 初始化链表迭代器 +c0103544: c7 45 f0 e4 bf 12 c0 movl $0xc012bfe4,-0x10(%ebp) + // 遍历空闲列表,寻找第一个满足条件的块 + while ((le = list_next(le)) != &free_list) { +c010354b: eb 1c jmp c0103569 + struct Page *p = le2page(le, page_link);// 将链表节点转换为 Page 结构体 +c010354d: 8b 45 f0 mov -0x10(%ebp),%eax +c0103550: 83 e8 0c sub $0xc,%eax +c0103553: 89 45 ec mov %eax,-0x14(%ebp) + if (p->property >= n) {// 检查当前块的页数是否满足请求 +c0103556: 8b 45 ec mov -0x14(%ebp),%eax +c0103559: 8b 40 08 mov 0x8(%eax),%eax +c010355c: 39 45 08 cmp %eax,0x8(%ebp) +c010355f: 77 08 ja c0103569 + page = p;// 找到合适的块 +c0103561: 8b 45 ec mov -0x14(%ebp),%eax +c0103564: 89 45 f4 mov %eax,-0xc(%ebp) + break;// 退出循环 +c0103567: eb 18 jmp c0103581 +c0103569: 8b 45 f0 mov -0x10(%ebp),%eax +c010356c: 89 45 e4 mov %eax,-0x1c(%ebp) + return listelm->next; +c010356f: 8b 45 e4 mov -0x1c(%ebp),%eax +c0103572: 8b 40 04 mov 0x4(%eax),%eax + while ((le = list_next(le)) != &free_list) { +c0103575: 89 45 f0 mov %eax,-0x10(%ebp) +c0103578: 81 7d f0 e4 bf 12 c0 cmpl $0xc012bfe4,-0x10(%ebp) +c010357f: 75 cc jne c010354d + } + } + if (page != NULL) {// 如果找到合适的块 +c0103581: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0103585: 0f 84 eb 00 00 00 je c0103676 + //list_del(&(page->page_link));// 从空闲列表中删除该块 + if (page->property > n) { +c010358b: 8b 45 f4 mov -0xc(%ebp),%eax +c010358e: 8b 40 08 mov 0x8(%eax),%eax +c0103591: 39 45 08 cmp %eax,0x8(%ebp) +c0103594: 0f 83 88 00 00 00 jae c0103622 + struct Page *p = page + n;// 指向剩余的页 +c010359a: 8b 45 08 mov 0x8(%ebp),%eax +c010359d: c1 e0 05 shl $0x5,%eax +c01035a0: 89 c2 mov %eax,%edx +c01035a2: 8b 45 f4 mov -0xc(%ebp),%eax +c01035a5: 01 d0 add %edx,%eax +c01035a7: 89 45 e8 mov %eax,-0x18(%ebp) + p->property = page->property - n;// 更新剩余块的页数 +c01035aa: 8b 45 f4 mov -0xc(%ebp),%eax +c01035ad: 8b 40 08 mov 0x8(%eax),%eax +c01035b0: 2b 45 08 sub 0x8(%ebp),%eax +c01035b3: 89 c2 mov %eax,%edx +c01035b5: 8b 45 e8 mov -0x18(%ebp),%eax +c01035b8: 89 50 08 mov %edx,0x8(%eax) + SetPageProperty(p); +c01035bb: 8b 45 e8 mov -0x18(%ebp),%eax +c01035be: 83 c0 04 add $0x4,%eax +c01035c1: c7 45 cc 01 00 00 00 movl $0x1,-0x34(%ebp) +c01035c8: 89 45 c8 mov %eax,-0x38(%ebp) + asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); +c01035cb: 8b 45 c8 mov -0x38(%ebp),%eax +c01035ce: 8b 55 cc mov -0x34(%ebp),%edx +c01035d1: 0f ab 10 bts %edx,(%eax) } -c01036fa: 90 nop -c01036fb: c9 leave -c01036fc: c3 ret - -c01036fd : - -//init_pmm_manager - initialize a pmm_manager instance -//初始化一个 pmm_manager 实例 -static void -init_pmm_manager(void) { -c01036fd: f3 0f 1e fb endbr32 -c0103701: 55 push %ebp -c0103702: 89 e5 mov %esp,%ebp -c0103704: 83 ec 18 sub $0x18,%esp - //将 pmm_manager 指向默认的 PMM 管理器实例。 - pmm_manager = &default_pmm_manager; -c0103707: c7 05 b0 e0 12 c0 2c movl $0xc010c12c,0xc012e0b0 -c010370e: c1 10 c0 - //使用 cprintf 打印当前内存管理器的名称。 - cprintf("memory management: %s\n", pmm_manager->name); -c0103711: a1 b0 e0 12 c0 mov 0xc012e0b0,%eax -c0103716: 8b 00 mov (%eax),%eax -c0103718: 89 44 24 04 mov %eax,0x4(%esp) -c010371c: c7 04 24 10 ac 10 c0 movl $0xc010ac10,(%esp) -c0103723: e8 af cb ff ff call c01002d7 - //调用 PMM 管理器的初始化函数,以设置和准备内存管理的相关数据结构。 - pmm_manager->init(); -c0103728: a1 b0 e0 12 c0 mov 0xc012e0b0,%eax -c010372d: 8b 40 04 mov 0x4(%eax),%eax -c0103730: ff d0 call *%eax +c01035d4: 90 nop + list_add_after(&(page->page_link), &(p->page_link));// 将剩余块添加回空闲列表 +c01035d5: 8b 45 e8 mov -0x18(%ebp),%eax +c01035d8: 83 c0 0c add $0xc,%eax +c01035db: 8b 55 f4 mov -0xc(%ebp),%edx +c01035de: 83 c2 0c add $0xc,%edx +c01035e1: 89 55 e0 mov %edx,-0x20(%ebp) +c01035e4: 89 45 dc mov %eax,-0x24(%ebp) + __list_add(elm, listelm, listelm->next); +c01035e7: 8b 45 e0 mov -0x20(%ebp),%eax +c01035ea: 8b 40 04 mov 0x4(%eax),%eax +c01035ed: 8b 55 dc mov -0x24(%ebp),%edx +c01035f0: 89 55 d8 mov %edx,-0x28(%ebp) +c01035f3: 8b 55 e0 mov -0x20(%ebp),%edx +c01035f6: 89 55 d4 mov %edx,-0x2c(%ebp) +c01035f9: 89 45 d0 mov %eax,-0x30(%ebp) + prev->next = next->prev = elm; +c01035fc: 8b 45 d0 mov -0x30(%ebp),%eax +c01035ff: 8b 55 d8 mov -0x28(%ebp),%edx +c0103602: 89 10 mov %edx,(%eax) +c0103604: 8b 45 d0 mov -0x30(%ebp),%eax +c0103607: 8b 10 mov (%eax),%edx +c0103609: 8b 45 d4 mov -0x2c(%ebp),%eax +c010360c: 89 50 04 mov %edx,0x4(%eax) + elm->next = next; +c010360f: 8b 45 d8 mov -0x28(%ebp),%eax +c0103612: 8b 55 d0 mov -0x30(%ebp),%edx +c0103615: 89 50 04 mov %edx,0x4(%eax) + elm->prev = prev; +c0103618: 8b 45 d8 mov -0x28(%ebp),%eax +c010361b: 8b 55 d4 mov -0x2c(%ebp),%edx +c010361e: 89 10 mov %edx,(%eax) } -c0103732: 90 nop -c0103733: c9 leave -c0103734: c3 ret - -c0103735 : - -//init_memmap - call pmm->init_memmap to build Page struct for free memory -// init_memmap - 调用 pmm->init_memmap 构建空闲内存的 Page 结构 -//struct Page *base:指向内存页的基础地址。 size_t n:要初始化的页数。 -static void -init_memmap(struct Page *base, size_t n) { -c0103735: f3 0f 1e fb endbr32 -c0103739: 55 push %ebp -c010373a: 89 e5 mov %esp,%ebp -c010373c: 83 ec 18 sub $0x18,%esp - pmm_manager->init_memmap(base, n); -c010373f: a1 b0 e0 12 c0 mov 0xc012e0b0,%eax -c0103744: 8b 40 08 mov 0x8(%eax),%eax -c0103747: 8b 55 0c mov 0xc(%ebp),%edx -c010374a: 89 54 24 04 mov %edx,0x4(%esp) -c010374e: 8b 55 08 mov 0x8(%ebp),%edx -c0103751: 89 14 24 mov %edx,(%esp) -c0103754: ff d0 call *%eax +c0103620: 90 nop } -c0103756: 90 nop -c0103757: c9 leave -c0103758: c3 ret - -c0103759 : - -//alloc_pages - call pmm->alloc_pages to allocate a continuous n*PAGESIZE memory -// alloc_pages - 调用 pmm->alloc_pages 分配连续的 n*PAGESIZE 内存 -struct Page * -alloc_pages(size_t n) { -c0103759: f3 0f 1e fb endbr32 -c010375d: 55 push %ebp -c010375e: 89 e5 mov %esp,%ebp -c0103760: 83 ec 28 sub $0x28,%esp - struct Page *page=NULL; -c0103763: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) - bool intr_flag; - //使用 local_intr_save 保存当前的中断状态,以避免在分配内存时发生中断。 - while (1) - { - local_intr_save(intr_flag); -c010376a: e8 1a fe ff ff call c0103589 <__intr_save> -c010376f: 89 45 f0 mov %eax,-0x10(%ebp) - { - page = pmm_manager->alloc_pages(n);//尝试分配 n 个页面。 -c0103772: a1 b0 e0 12 c0 mov 0xc012e0b0,%eax -c0103777: 8b 40 0c mov 0xc(%eax),%eax -c010377a: 8b 55 08 mov 0x8(%ebp),%edx -c010377d: 89 14 24 mov %edx,(%esp) -c0103780: ff d0 call *%eax -c0103782: 89 45 f4 mov %eax,-0xc(%ebp) - } - local_intr_restore(intr_flag); -c0103785: 8b 45 f0 mov -0x10(%ebp),%eax -c0103788: 89 04 24 mov %eax,(%esp) -c010378b: e8 23 fe ff ff call c01035b3 <__intr_restore> - - if (page != NULL || n > 1 || swap_init_ok == 0) break; -c0103790: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0103794: 75 2d jne c01037c3 -c0103796: 83 7d 08 01 cmpl $0x1,0x8(%ebp) -c010379a: 77 27 ja c01037c3 -c010379c: a1 14 c0 12 c0 mov 0xc012c014,%eax -c01037a1: 85 c0 test %eax,%eax -c01037a3: 74 1e je c01037c3 - - extern struct mm_struct *check_mm_struct; - //cprintf("page %x, call swap_out in alloc_pages %d\n",page, n); - swap_out(check_mm_struct, n, 0); -c01037a5: 8b 55 08 mov 0x8(%ebp),%edx -c01037a8: a1 c4 e0 12 c0 mov 0xc012e0c4,%eax -c01037ad: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c01037b4: 00 -c01037b5: 89 54 24 04 mov %edx,0x4(%esp) -c01037b9: 89 04 24 mov %eax,(%esp) -c01037bc: e8 7c 33 00 00 call c0106b3d - { -c01037c1: eb a7 jmp c010376a +c0103621: 90 nop } - //cprintf("n %d,get page %x, No %d in alloc_pages\n",n,page,(page-pages)); - return page; -c01037c3: 8b 45 f4 mov -0xc(%ebp),%eax + list_del(&(page->page_link)); +c0103622: 8b 45 f4 mov -0xc(%ebp),%eax +c0103625: 83 c0 0c add $0xc,%eax +c0103628: 89 45 bc mov %eax,-0x44(%ebp) + __list_del(listelm->prev, listelm->next); +c010362b: 8b 45 bc mov -0x44(%ebp),%eax +c010362e: 8b 40 04 mov 0x4(%eax),%eax +c0103631: 8b 55 bc mov -0x44(%ebp),%edx +c0103634: 8b 12 mov (%edx),%edx +c0103636: 89 55 b8 mov %edx,-0x48(%ebp) +c0103639: 89 45 b4 mov %eax,-0x4c(%ebp) + * This is only for internal list manipulation where we know + * the prev/next entries already! + * */ +static inline void +__list_del(list_entry_t *prev, list_entry_t *next) { + prev->next = next; +c010363c: 8b 45 b8 mov -0x48(%ebp),%eax +c010363f: 8b 55 b4 mov -0x4c(%ebp),%edx +c0103642: 89 50 04 mov %edx,0x4(%eax) + next->prev = prev; +c0103645: 8b 45 b4 mov -0x4c(%ebp),%eax +c0103648: 8b 55 b8 mov -0x48(%ebp),%edx +c010364b: 89 10 mov %edx,(%eax) } -c01037c6: c9 leave -c01037c7: c3 ret - -c01037c8 : - -//free_pages - call pmm->free_pages to free a continuous n*PAGESIZE memory -// free_pages - 调用 pmm->free_pages 释放连续的 n*PAGESIZE 内存 -//struct Page *base:指向要释放的内存页的基础地址。size_t n:要释放的页数。 -void -free_pages(struct Page *base, size_t n) { -c01037c8: f3 0f 1e fb endbr32 -c01037cc: 55 push %ebp -c01037cd: 89 e5 mov %esp,%ebp -c01037cf: 83 ec 28 sub $0x28,%esp - bool intr_flag; - //使用 local_intr_save 保存当前的中断状态,以避免在释放内存时发生中断。 - local_intr_save(intr_flag); -c01037d2: e8 b2 fd ff ff call c0103589 <__intr_save> -c01037d7: 89 45 f4 mov %eax,-0xc(%ebp) - { - //调用物理内存管理器的 free_pages 函数释放 n 页的内存。 - pmm_manager->free_pages(base, n); -c01037da: a1 b0 e0 12 c0 mov 0xc012e0b0,%eax -c01037df: 8b 40 10 mov 0x10(%eax),%eax -c01037e2: 8b 55 0c mov 0xc(%ebp),%edx -c01037e5: 89 54 24 04 mov %edx,0x4(%esp) -c01037e9: 8b 55 08 mov 0x8(%ebp),%edx -c01037ec: 89 14 24 mov %edx,(%esp) -c01037ef: ff d0 call *%eax - } - local_intr_restore(intr_flag); -c01037f1: 8b 45 f4 mov -0xc(%ebp),%eax -c01037f4: 89 04 24 mov %eax,(%esp) -c01037f7: e8 b7 fd ff ff call c01035b3 <__intr_restore> +c010364d: 90 nop } -c01037fc: 90 nop -c01037fd: c9 leave -c01037fe: c3 ret - -c01037ff : - -//nr_free_pages - call pmm->nr_free_pages to get the size (nr*PAGESIZE) -//of current free memory -// nr_free_pages - 调用 pmm->nr_free_pages 获取当前空闲内存的大小 (nr * PAGESIZE) -size_t -nr_free_pages(void) { -c01037ff: f3 0f 1e fb endbr32 -c0103803: 55 push %ebp -c0103804: 89 e5 mov %esp,%ebp -c0103806: 83 ec 28 sub $0x28,%esp - size_t ret;// 定义变量 ret 用于存储返回的空闲内存大小 - bool intr_flag;// 定义变量 intr_flag 用于保存中断状态 - local_intr_save(intr_flag);// 保存当前中断状态,并禁用中断 -c0103809: e8 7b fd ff ff call c0103589 <__intr_save> -c010380e: 89 45 f4 mov %eax,-0xc(%ebp) - { - ret = pmm_manager->nr_free_pages();// 调用物理内存管理器的函数获取空闲内存页数 -c0103811: a1 b0 e0 12 c0 mov 0xc012e0b0,%eax -c0103816: 8b 40 14 mov 0x14(%eax),%eax -c0103819: ff d0 call *%eax -c010381b: 89 45 f0 mov %eax,-0x10(%ebp) +c010364e: 90 nop + nr_free -= n;// 减少空闲页的计数 +c010364f: a1 ec bf 12 c0 mov 0xc012bfec,%eax +c0103654: 2b 45 08 sub 0x8(%ebp),%eax +c0103657: a3 ec bf 12 c0 mov %eax,0xc012bfec + ClearPageProperty(page);// 清除已分配页的属性 +c010365c: 8b 45 f4 mov -0xc(%ebp),%eax +c010365f: 83 c0 04 add $0x4,%eax +c0103662: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) +c0103669: 89 45 c0 mov %eax,-0x40(%ebp) + asm volatile ("btrl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); +c010366c: 8b 45 c0 mov -0x40(%ebp),%eax +c010366f: 8b 55 c4 mov -0x3c(%ebp),%edx +c0103672: 0f b3 10 btr %edx,(%eax) +} +c0103675: 90 nop } - local_intr_restore(intr_flag);// 恢复之前保存的中断状态 -c010381e: 8b 45 f4 mov -0xc(%ebp),%eax -c0103821: 89 04 24 mov %eax,(%esp) -c0103824: e8 8a fd ff ff call c01035b3 <__intr_restore> - return ret;// 返回空闲内存的大小 -c0103829: 8b 45 f0 mov -0x10(%ebp),%eax + return page;// 返回分配的页块 +c0103676: 8b 45 f4 mov -0xc(%ebp),%eax } -c010382c: c9 leave -c010382d: c3 ret +c0103679: 89 ec mov %ebp,%esp +c010367b: 5d pop %ebp +c010367c: c3 ret -c010382e : +c010367d : -/* pmm_init - initialize the physical memory management */ -/* pmm_init - 初始化物理内存管理 */ static void -page_init(void) { -c010382e: f3 0f 1e fb endbr32 -c0103832: 55 push %ebp -c0103833: 89 e5 mov %esp,%ebp -c0103835: 57 push %edi -c0103836: 56 push %esi -c0103837: 53 push %ebx -c0103838: 81 ec 9c 00 00 00 sub $0x9c,%esp - // 获取物理内存映射信息,存于特定地址 - struct e820map *memmap = (struct e820map *)(0x8000 + KERNBASE); -c010383e: c7 45 c4 00 80 00 c0 movl $0xc0008000,-0x3c(%ebp) - uint64_t maxpa = 0;// 初始化最大物理地址为0 -c0103845: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) -c010384c: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) - - cprintf("e820map:\n");// 打印“e820map”标题 -c0103853: c7 04 24 27 ac 10 c0 movl $0xc010ac27,(%esp) -c010385a: e8 78 ca ff ff call c01002d7 - int i; - for (i = 0; i < memmap->nr_map; i ++) {// 遍历内存映射数组 -c010385f: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) -c0103866: e9 1a 01 00 00 jmp c0103985 - uint64_t begin = memmap->map[i].addr, end = begin + memmap->map[i].size;// 获取每个区域的起始和结束地址 -c010386b: 8b 4d c4 mov -0x3c(%ebp),%ecx -c010386e: 8b 55 dc mov -0x24(%ebp),%edx -c0103871: 89 d0 mov %edx,%eax -c0103873: c1 e0 02 shl $0x2,%eax -c0103876: 01 d0 add %edx,%eax -c0103878: c1 e0 02 shl $0x2,%eax -c010387b: 01 c8 add %ecx,%eax -c010387d: 8b 50 08 mov 0x8(%eax),%edx -c0103880: 8b 40 04 mov 0x4(%eax),%eax -c0103883: 89 45 a0 mov %eax,-0x60(%ebp) -c0103886: 89 55 a4 mov %edx,-0x5c(%ebp) -c0103889: 8b 4d c4 mov -0x3c(%ebp),%ecx -c010388c: 8b 55 dc mov -0x24(%ebp),%edx -c010388f: 89 d0 mov %edx,%eax -c0103891: c1 e0 02 shl $0x2,%eax -c0103894: 01 d0 add %edx,%eax -c0103896: c1 e0 02 shl $0x2,%eax -c0103899: 01 c8 add %ecx,%eax -c010389b: 8b 48 0c mov 0xc(%eax),%ecx -c010389e: 8b 58 10 mov 0x10(%eax),%ebx -c01038a1: 8b 45 a0 mov -0x60(%ebp),%eax -c01038a4: 8b 55 a4 mov -0x5c(%ebp),%edx -c01038a7: 01 c8 add %ecx,%eax -c01038a9: 11 da adc %ebx,%edx -c01038ab: 89 45 98 mov %eax,-0x68(%ebp) -c01038ae: 89 55 9c mov %edx,-0x64(%ebp) - cprintf(" memory: %08llx, [%08llx, %08llx], type = %d.\n",// 打印内存区域的信息 -c01038b1: 8b 4d c4 mov -0x3c(%ebp),%ecx -c01038b4: 8b 55 dc mov -0x24(%ebp),%edx -c01038b7: 89 d0 mov %edx,%eax -c01038b9: c1 e0 02 shl $0x2,%eax -c01038bc: 01 d0 add %edx,%eax -c01038be: c1 e0 02 shl $0x2,%eax -c01038c1: 01 c8 add %ecx,%eax -c01038c3: 83 c0 14 add $0x14,%eax -c01038c6: 8b 00 mov (%eax),%eax -c01038c8: 89 45 84 mov %eax,-0x7c(%ebp) -c01038cb: 8b 45 98 mov -0x68(%ebp),%eax -c01038ce: 8b 55 9c mov -0x64(%ebp),%edx -c01038d1: 83 c0 ff add $0xffffffff,%eax -c01038d4: 83 d2 ff adc $0xffffffff,%edx -c01038d7: 89 85 78 ff ff ff mov %eax,-0x88(%ebp) -c01038dd: 89 95 7c ff ff ff mov %edx,-0x84(%ebp) -c01038e3: 8b 4d c4 mov -0x3c(%ebp),%ecx -c01038e6: 8b 55 dc mov -0x24(%ebp),%edx -c01038e9: 89 d0 mov %edx,%eax -c01038eb: c1 e0 02 shl $0x2,%eax -c01038ee: 01 d0 add %edx,%eax -c01038f0: c1 e0 02 shl $0x2,%eax -c01038f3: 01 c8 add %ecx,%eax -c01038f5: 8b 48 0c mov 0xc(%eax),%ecx -c01038f8: 8b 58 10 mov 0x10(%eax),%ebx -c01038fb: 8b 55 84 mov -0x7c(%ebp),%edx -c01038fe: 89 54 24 1c mov %edx,0x1c(%esp) -c0103902: 8b 85 78 ff ff ff mov -0x88(%ebp),%eax -c0103908: 8b 95 7c ff ff ff mov -0x84(%ebp),%edx -c010390e: 89 44 24 14 mov %eax,0x14(%esp) -c0103912: 89 54 24 18 mov %edx,0x18(%esp) -c0103916: 8b 45 a0 mov -0x60(%ebp),%eax -c0103919: 8b 55 a4 mov -0x5c(%ebp),%edx -c010391c: 89 44 24 0c mov %eax,0xc(%esp) -c0103920: 89 54 24 10 mov %edx,0x10(%esp) -c0103924: 89 4c 24 04 mov %ecx,0x4(%esp) -c0103928: 89 5c 24 08 mov %ebx,0x8(%esp) -c010392c: c7 04 24 34 ac 10 c0 movl $0xc010ac34,(%esp) -c0103933: e8 9f c9 ff ff call c01002d7 - memmap->map[i].size, begin, end - 1, memmap->map[i].type); - if (memmap->map[i].type == E820_ARM) {// 检查内存类型是否为可用内存 -c0103938: 8b 4d c4 mov -0x3c(%ebp),%ecx -c010393b: 8b 55 dc mov -0x24(%ebp),%edx -c010393e: 89 d0 mov %edx,%eax -c0103940: c1 e0 02 shl $0x2,%eax -c0103943: 01 d0 add %edx,%eax -c0103945: c1 e0 02 shl $0x2,%eax -c0103948: 01 c8 add %ecx,%eax -c010394a: 83 c0 14 add $0x14,%eax -c010394d: 8b 00 mov (%eax),%eax -c010394f: 83 f8 01 cmp $0x1,%eax -c0103952: 75 2e jne c0103982 - if (maxpa < end && begin < KMEMSIZE) {// 检查当前区域是否在有效范围内 -c0103954: 8b 45 e0 mov -0x20(%ebp),%eax -c0103957: 8b 55 e4 mov -0x1c(%ebp),%edx -c010395a: 3b 45 98 cmp -0x68(%ebp),%eax -c010395d: 89 d0 mov %edx,%eax -c010395f: 1b 45 9c sbb -0x64(%ebp),%eax -c0103962: 73 1e jae c0103982 -c0103964: ba ff ff ff 37 mov $0x37ffffff,%edx -c0103969: b8 00 00 00 00 mov $0x0,%eax -c010396e: 3b 55 a0 cmp -0x60(%ebp),%edx -c0103971: 1b 45 a4 sbb -0x5c(%ebp),%eax -c0103974: 72 0c jb c0103982 - maxpa = end;// 更新最大物理地址 -c0103976: 8b 45 98 mov -0x68(%ebp),%eax -c0103979: 8b 55 9c mov -0x64(%ebp),%edx -c010397c: 89 45 e0 mov %eax,-0x20(%ebp) -c010397f: 89 55 e4 mov %edx,-0x1c(%ebp) - for (i = 0; i < memmap->nr_map; i ++) {// 遍历内存映射数组 -c0103982: ff 45 dc incl -0x24(%ebp) -c0103985: 8b 45 c4 mov -0x3c(%ebp),%eax -c0103988: 8b 00 mov (%eax),%eax -c010398a: 39 45 dc cmp %eax,-0x24(%ebp) -c010398d: 0f 8c d8 fe ff ff jl c010386b - } - } - } - if (maxpa > KMEMSIZE) {// 如果最大物理地址超过了预定义的内存上限 -c0103993: ba 00 00 00 38 mov $0x38000000,%edx -c0103998: b8 00 00 00 00 mov $0x0,%eax -c010399d: 3b 55 e0 cmp -0x20(%ebp),%edx -c01039a0: 1b 45 e4 sbb -0x1c(%ebp),%eax -c01039a3: 73 0e jae c01039b3 - maxpa = KMEMSIZE;// 将其限制为内存上限 -c01039a5: c7 45 e0 00 00 00 38 movl $0x38000000,-0x20(%ebp) -c01039ac: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) +default_free_pages(struct Page *base, size_t n) { +c010367d: 55 push %ebp +c010367e: 89 e5 mov %esp,%ebp +c0103680: 81 ec 98 00 00 00 sub $0x98,%esp + assert(n > 0);// 确保请求释放的页数大于零 +c0103686: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) +c010368a: 75 24 jne c01036b0 +c010368c: c7 44 24 0c 70 a9 10 movl $0xc010a970,0xc(%esp) +c0103693: c0 +c0103694: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c010369b: c0 +c010369c: c7 44 24 04 cb 00 00 movl $0xcb,0x4(%esp) +c01036a3: 00 +c01036a4: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c01036ab: e8 95 d5 ff ff call c0100c45 <__panic> + struct Page *p = base; +c01036b0: 8b 45 08 mov 0x8(%ebp),%eax +c01036b3: 89 45 f4 mov %eax,-0xc(%ebp) + // 遍历释放的页,检查状态并重置 + for (; p != base + n; p ++) { +c01036b6: e9 9d 00 00 00 jmp c0103758 + assert(!PageReserved(p) && !PageProperty(p));// 确保页没有被保留并且没有属性 +c01036bb: 8b 45 f4 mov -0xc(%ebp),%eax +c01036be: 83 c0 04 add $0x4,%eax +c01036c1: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) +c01036c8: 89 45 e8 mov %eax,-0x18(%ebp) + asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); +c01036cb: 8b 45 e8 mov -0x18(%ebp),%eax +c01036ce: 8b 55 ec mov -0x14(%ebp),%edx +c01036d1: 0f a3 10 bt %edx,(%eax) +c01036d4: 19 c0 sbb %eax,%eax +c01036d6: 89 45 e4 mov %eax,-0x1c(%ebp) + return oldbit != 0; +c01036d9: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) +c01036dd: 0f 95 c0 setne %al +c01036e0: 0f b6 c0 movzbl %al,%eax +c01036e3: 85 c0 test %eax,%eax +c01036e5: 75 2c jne c0103713 +c01036e7: 8b 45 f4 mov -0xc(%ebp),%eax +c01036ea: 83 c0 04 add $0x4,%eax +c01036ed: c7 45 e0 01 00 00 00 movl $0x1,-0x20(%ebp) +c01036f4: 89 45 dc mov %eax,-0x24(%ebp) + asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); +c01036f7: 8b 45 dc mov -0x24(%ebp),%eax +c01036fa: 8b 55 e0 mov -0x20(%ebp),%edx +c01036fd: 0f a3 10 bt %edx,(%eax) +c0103700: 19 c0 sbb %eax,%eax +c0103702: 89 45 d8 mov %eax,-0x28(%ebp) + return oldbit != 0; +c0103705: 83 7d d8 00 cmpl $0x0,-0x28(%ebp) +c0103709: 0f 95 c0 setne %al +c010370c: 0f b6 c0 movzbl %al,%eax +c010370f: 85 c0 test %eax,%eax +c0103711: 74 24 je c0103737 +c0103713: c7 44 24 0c b4 a9 10 movl $0xc010a9b4,0xc(%esp) +c010371a: c0 +c010371b: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103722: c0 +c0103723: c7 44 24 04 cf 00 00 movl $0xcf,0x4(%esp) +c010372a: 00 +c010372b: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103732: e8 0e d5 ff ff call c0100c45 <__panic> + p->flags = 0;// 清除 flags 字段 +c0103737: 8b 45 f4 mov -0xc(%ebp),%eax +c010373a: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) + set_page_ref(p, 0);// 清除引用计数 +c0103741: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0103748: 00 +c0103749: 8b 45 f4 mov -0xc(%ebp),%eax +c010374c: 89 04 24 mov %eax,(%esp) +c010374f: e8 19 fc ff ff call c010336d + for (; p != base + n; p ++) { +c0103754: 83 45 f4 20 addl $0x20,-0xc(%ebp) +c0103758: 8b 45 0c mov 0xc(%ebp),%eax +c010375b: c1 e0 05 shl $0x5,%eax +c010375e: 89 c2 mov %eax,%edx +c0103760: 8b 45 08 mov 0x8(%ebp),%eax +c0103763: 01 d0 add %edx,%eax +c0103765: 39 45 f4 cmp %eax,-0xc(%ebp) +c0103768: 0f 85 4d ff ff ff jne c01036bb } - - extern char end[];// 引入全局变量 end,指向内存的结束位置 - - npage = maxpa / PGSIZE;// 计算可用页数 -c01039b3: 8b 45 e0 mov -0x20(%ebp),%eax -c01039b6: 8b 55 e4 mov -0x1c(%ebp),%edx -c01039b9: 0f ac d0 0c shrd $0xc,%edx,%eax -c01039bd: c1 ea 0c shr $0xc,%edx -c01039c0: a3 80 bf 12 c0 mov %eax,0xc012bf80 - pages = (struct Page *)ROUNDUP((void *)end, PGSIZE);// 将 end 对齐到页边界,指向页结构数组的开头 -c01039c5: c7 45 c0 00 10 00 00 movl $0x1000,-0x40(%ebp) -c01039cc: b8 b8 e1 12 c0 mov $0xc012e1b8,%eax -c01039d1: 8d 50 ff lea -0x1(%eax),%edx -c01039d4: 8b 45 c0 mov -0x40(%ebp),%eax -c01039d7: 01 d0 add %edx,%eax -c01039d9: 89 45 bc mov %eax,-0x44(%ebp) -c01039dc: 8b 45 bc mov -0x44(%ebp),%eax -c01039df: ba 00 00 00 00 mov $0x0,%edx -c01039e4: f7 75 c0 divl -0x40(%ebp) -c01039e7: 8b 45 bc mov -0x44(%ebp),%eax -c01039ea: 29 d0 sub %edx,%eax -c01039ec: a3 b8 e0 12 c0 mov %eax,0xc012e0b8 - - for (i = 0; i < npage; i ++) {// 遍历每一页 -c01039f1: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) -c01039f8: eb 27 jmp c0103a21 - SetPageReserved(pages + i);// 将每一页标记为保留状态 -c01039fa: a1 b8 e0 12 c0 mov 0xc012e0b8,%eax -c01039ff: 8b 55 dc mov -0x24(%ebp),%edx -c0103a02: c1 e2 05 shl $0x5,%edx -c0103a05: 01 d0 add %edx,%eax -c0103a07: 83 c0 04 add $0x4,%eax -c0103a0a: c7 45 94 00 00 00 00 movl $0x0,-0x6c(%ebp) -c0103a11: 89 45 90 mov %eax,-0x70(%ebp) - * Note that @nr may be almost arbitrarily large; this function is not - * restricted to acting on a single-word quantity. - * */ -static inline void -set_bit(int nr, volatile void *addr) { + // 设置基页的属性为释放的页数 + base->property = n; +c010376e: 8b 45 08 mov 0x8(%ebp),%eax +c0103771: 8b 55 0c mov 0xc(%ebp),%edx +c0103774: 89 50 08 mov %edx,0x8(%eax) + SetPageProperty(base);// 设置页的有效标志 +c0103777: 8b 45 08 mov 0x8(%ebp),%eax +c010377a: 83 c0 04 add $0x4,%eax +c010377d: c7 45 d0 01 00 00 00 movl $0x1,-0x30(%ebp) +c0103784: 89 45 cc mov %eax,-0x34(%ebp) asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); -c0103a14: 8b 45 90 mov -0x70(%ebp),%eax -c0103a17: 8b 55 94 mov -0x6c(%ebp),%edx -c0103a1a: 0f ab 10 bts %edx,(%eax) +c0103787: 8b 45 cc mov -0x34(%ebp),%eax +c010378a: 8b 55 d0 mov -0x30(%ebp),%edx +c010378d: 0f ab 10 bts %edx,(%eax) } -c0103a1d: 90 nop - for (i = 0; i < npage; i ++) {// 遍历每一页 -c0103a1e: ff 45 dc incl -0x24(%ebp) -c0103a21: 8b 55 dc mov -0x24(%ebp),%edx -c0103a24: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0103a29: 39 c2 cmp %eax,%edx -c0103a2b: 72 cd jb c01039fa +c0103790: 90 nop +c0103791: c7 45 d4 e4 bf 12 c0 movl $0xc012bfe4,-0x2c(%ebp) + return listelm->next; +c0103798: 8b 45 d4 mov -0x2c(%ebp),%eax +c010379b: 8b 40 04 mov 0x4(%eax),%eax + // 遍历空闲列表,检查是否需要合并 + list_entry_t *le = list_next(&free_list); +c010379e: 89 45 f0 mov %eax,-0x10(%ebp) + while (le != &free_list) { +c01037a1: e9 00 01 00 00 jmp c01038a6 + p = le2page(le, page_link); +c01037a6: 8b 45 f0 mov -0x10(%ebp),%eax +c01037a9: 83 e8 0c sub $0xc,%eax +c01037ac: 89 45 f4 mov %eax,-0xc(%ebp) +c01037af: 8b 45 f0 mov -0x10(%ebp),%eax +c01037b2: 89 45 c8 mov %eax,-0x38(%ebp) +c01037b5: 8b 45 c8 mov -0x38(%ebp),%eax +c01037b8: 8b 40 04 mov 0x4(%eax),%eax + le = list_next(le); +c01037bb: 89 45 f0 mov %eax,-0x10(%ebp) + // 如果当前页块与释放的页块相邻,合并 + if (base + base->property == p) { +c01037be: 8b 45 08 mov 0x8(%ebp),%eax +c01037c1: 8b 40 08 mov 0x8(%eax),%eax +c01037c4: c1 e0 05 shl $0x5,%eax +c01037c7: 89 c2 mov %eax,%edx +c01037c9: 8b 45 08 mov 0x8(%ebp),%eax +c01037cc: 01 d0 add %edx,%eax +c01037ce: 39 45 f4 cmp %eax,-0xc(%ebp) +c01037d1: 75 5d jne c0103830 + base->property += p->property;// 合并当前页块 +c01037d3: 8b 45 08 mov 0x8(%ebp),%eax +c01037d6: 8b 50 08 mov 0x8(%eax),%edx +c01037d9: 8b 45 f4 mov -0xc(%ebp),%eax +c01037dc: 8b 40 08 mov 0x8(%eax),%eax +c01037df: 01 c2 add %eax,%edx +c01037e1: 8b 45 08 mov 0x8(%ebp),%eax +c01037e4: 89 50 08 mov %edx,0x8(%eax) + ClearPageProperty(p);// 清除合并页的属性 +c01037e7: 8b 45 f4 mov -0xc(%ebp),%eax +c01037ea: 83 c0 04 add $0x4,%eax +c01037ed: c7 45 b8 01 00 00 00 movl $0x1,-0x48(%ebp) +c01037f4: 89 45 b4 mov %eax,-0x4c(%ebp) + asm volatile ("btrl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); +c01037f7: 8b 45 b4 mov -0x4c(%ebp),%eax +c01037fa: 8b 55 b8 mov -0x48(%ebp),%edx +c01037fd: 0f b3 10 btr %edx,(%eax) +} +c0103800: 90 nop + list_del(&(p->page_link));// 从空闲列表中删除合并页 +c0103801: 8b 45 f4 mov -0xc(%ebp),%eax +c0103804: 83 c0 0c add $0xc,%eax +c0103807: 89 45 c4 mov %eax,-0x3c(%ebp) + __list_del(listelm->prev, listelm->next); +c010380a: 8b 45 c4 mov -0x3c(%ebp),%eax +c010380d: 8b 40 04 mov 0x4(%eax),%eax +c0103810: 8b 55 c4 mov -0x3c(%ebp),%edx +c0103813: 8b 12 mov (%edx),%edx +c0103815: 89 55 c0 mov %edx,-0x40(%ebp) +c0103818: 89 45 bc mov %eax,-0x44(%ebp) + prev->next = next; +c010381b: 8b 45 c0 mov -0x40(%ebp),%eax +c010381e: 8b 55 bc mov -0x44(%ebp),%edx +c0103821: 89 50 04 mov %edx,0x4(%eax) + next->prev = prev; +c0103824: 8b 45 bc mov -0x44(%ebp),%eax +c0103827: 8b 55 c0 mov -0x40(%ebp),%edx +c010382a: 89 10 mov %edx,(%eax) +} +c010382c: 90 nop +} +c010382d: 90 nop +c010382e: eb 76 jmp c01038a6 + } + else if (p + p->property == base) { +c0103830: 8b 45 f4 mov -0xc(%ebp),%eax +c0103833: 8b 40 08 mov 0x8(%eax),%eax +c0103836: c1 e0 05 shl $0x5,%eax +c0103839: 89 c2 mov %eax,%edx +c010383b: 8b 45 f4 mov -0xc(%ebp),%eax +c010383e: 01 d0 add %edx,%eax +c0103840: 39 45 08 cmp %eax,0x8(%ebp) +c0103843: 75 61 jne c01038a6 + p->property += base->property;// 合并前一个页块 +c0103845: 8b 45 f4 mov -0xc(%ebp),%eax +c0103848: 8b 50 08 mov 0x8(%eax),%edx +c010384b: 8b 45 08 mov 0x8(%ebp),%eax +c010384e: 8b 40 08 mov 0x8(%eax),%eax +c0103851: 01 c2 add %eax,%edx +c0103853: 8b 45 f4 mov -0xc(%ebp),%eax +c0103856: 89 50 08 mov %edx,0x8(%eax) + ClearPageProperty(base);// 清除当前页的属性 +c0103859: 8b 45 08 mov 0x8(%ebp),%eax +c010385c: 83 c0 04 add $0x4,%eax +c010385f: c7 45 a4 01 00 00 00 movl $0x1,-0x5c(%ebp) +c0103866: 89 45 a0 mov %eax,-0x60(%ebp) + asm volatile ("btrl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); +c0103869: 8b 45 a0 mov -0x60(%ebp),%eax +c010386c: 8b 55 a4 mov -0x5c(%ebp),%edx +c010386f: 0f b3 10 btr %edx,(%eax) +} +c0103872: 90 nop + base = p;// 更新 base 指针 +c0103873: 8b 45 f4 mov -0xc(%ebp),%eax +c0103876: 89 45 08 mov %eax,0x8(%ebp) + list_del(&(p->page_link));// 从空闲列表中删除当前页 +c0103879: 8b 45 f4 mov -0xc(%ebp),%eax +c010387c: 83 c0 0c add $0xc,%eax +c010387f: 89 45 b0 mov %eax,-0x50(%ebp) + __list_del(listelm->prev, listelm->next); +c0103882: 8b 45 b0 mov -0x50(%ebp),%eax +c0103885: 8b 40 04 mov 0x4(%eax),%eax +c0103888: 8b 55 b0 mov -0x50(%ebp),%edx +c010388b: 8b 12 mov (%edx),%edx +c010388d: 89 55 ac mov %edx,-0x54(%ebp) +c0103890: 89 45 a8 mov %eax,-0x58(%ebp) + prev->next = next; +c0103893: 8b 45 ac mov -0x54(%ebp),%eax +c0103896: 8b 55 a8 mov -0x58(%ebp),%edx +c0103899: 89 50 04 mov %edx,0x4(%eax) + next->prev = prev; +c010389c: 8b 45 a8 mov -0x58(%ebp),%eax +c010389f: 8b 55 ac mov -0x54(%ebp),%edx +c01038a2: 89 10 mov %edx,(%eax) +} +c01038a4: 90 nop +} +c01038a5: 90 nop + while (le != &free_list) { +c01038a6: 81 7d f0 e4 bf 12 c0 cmpl $0xc012bfe4,-0x10(%ebp) +c01038ad: 0f 85 f3 fe ff ff jne c01037a6 + } } - - uintptr_t freemem = PADDR((uintptr_t)pages + sizeof(struct Page) * npage);// 计算可用内存的起始地址 -c0103a2d: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0103a32: c1 e0 05 shl $0x5,%eax -c0103a35: 89 c2 mov %eax,%edx -c0103a37: a1 b8 e0 12 c0 mov 0xc012e0b8,%eax -c0103a3c: 01 d0 add %edx,%eax -c0103a3e: 89 45 b8 mov %eax,-0x48(%ebp) -c0103a41: 81 7d b8 ff ff ff bf cmpl $0xbfffffff,-0x48(%ebp) -c0103a48: 77 23 ja c0103a6d -c0103a4a: 8b 45 b8 mov -0x48(%ebp),%eax -c0103a4d: 89 44 24 0c mov %eax,0xc(%esp) -c0103a51: c7 44 24 08 64 ac 10 movl $0xc010ac64,0x8(%esp) -c0103a58: c0 -c0103a59: c7 44 24 04 1a 01 00 movl $0x11a,0x4(%esp) -c0103a60: 00 -c0103a61: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0103a68: e8 d6 c9 ff ff call c0100443 <__panic> -c0103a6d: 8b 45 b8 mov -0x48(%ebp),%eax -c0103a70: 05 00 00 00 40 add $0x40000000,%eax -c0103a75: 89 45 b4 mov %eax,-0x4c(%ebp) - - for (i = 0; i < memmap->nr_map; i ++) {// 再次遍历内存映射 -c0103a78: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) -c0103a7f: e9 4b 01 00 00 jmp c0103bcf - uint64_t begin = memmap->map[i].addr, end = begin + memmap->map[i].size;// 获取每个区域的起始和结束地址 -c0103a84: 8b 4d c4 mov -0x3c(%ebp),%ecx -c0103a87: 8b 55 dc mov -0x24(%ebp),%edx -c0103a8a: 89 d0 mov %edx,%eax -c0103a8c: c1 e0 02 shl $0x2,%eax -c0103a8f: 01 d0 add %edx,%eax -c0103a91: c1 e0 02 shl $0x2,%eax -c0103a94: 01 c8 add %ecx,%eax -c0103a96: 8b 50 08 mov 0x8(%eax),%edx -c0103a99: 8b 40 04 mov 0x4(%eax),%eax -c0103a9c: 89 45 d0 mov %eax,-0x30(%ebp) -c0103a9f: 89 55 d4 mov %edx,-0x2c(%ebp) -c0103aa2: 8b 4d c4 mov -0x3c(%ebp),%ecx -c0103aa5: 8b 55 dc mov -0x24(%ebp),%edx -c0103aa8: 89 d0 mov %edx,%eax -c0103aaa: c1 e0 02 shl $0x2,%eax -c0103aad: 01 d0 add %edx,%eax -c0103aaf: c1 e0 02 shl $0x2,%eax -c0103ab2: 01 c8 add %ecx,%eax -c0103ab4: 8b 48 0c mov 0xc(%eax),%ecx -c0103ab7: 8b 58 10 mov 0x10(%eax),%ebx -c0103aba: 8b 45 d0 mov -0x30(%ebp),%eax -c0103abd: 8b 55 d4 mov -0x2c(%ebp),%edx -c0103ac0: 01 c8 add %ecx,%eax -c0103ac2: 11 da adc %ebx,%edx -c0103ac4: 89 45 c8 mov %eax,-0x38(%ebp) -c0103ac7: 89 55 cc mov %edx,-0x34(%ebp) - if (memmap->map[i].type == E820_ARM) {// 如果区域类型为可用内存 -c0103aca: 8b 4d c4 mov -0x3c(%ebp),%ecx -c0103acd: 8b 55 dc mov -0x24(%ebp),%edx -c0103ad0: 89 d0 mov %edx,%eax -c0103ad2: c1 e0 02 shl $0x2,%eax -c0103ad5: 01 d0 add %edx,%eax -c0103ad7: c1 e0 02 shl $0x2,%eax -c0103ada: 01 c8 add %ecx,%eax -c0103adc: 83 c0 14 add $0x14,%eax -c0103adf: 8b 00 mov (%eax),%eax -c0103ae1: 83 f8 01 cmp $0x1,%eax -c0103ae4: 0f 85 e2 00 00 00 jne c0103bcc - if (begin < freemem) {// 如果起始地址小于可用内存地址 -c0103aea: 8b 45 b4 mov -0x4c(%ebp),%eax -c0103aed: ba 00 00 00 00 mov $0x0,%edx -c0103af2: 8b 4d d4 mov -0x2c(%ebp),%ecx -c0103af5: 39 45 d0 cmp %eax,-0x30(%ebp) -c0103af8: 19 d1 sbb %edx,%ecx -c0103afa: 73 0d jae c0103b09 - begin = freemem;//将起始地址设置为可用内存地址 -c0103afc: 8b 45 b4 mov -0x4c(%ebp),%eax -c0103aff: 89 45 d0 mov %eax,-0x30(%ebp) -c0103b02: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) - } - if (end > KMEMSIZE) {// 如果结束地址超过内存上限 -c0103b09: ba 00 00 00 38 mov $0x38000000,%edx -c0103b0e: b8 00 00 00 00 mov $0x0,%eax -c0103b13: 3b 55 c8 cmp -0x38(%ebp),%edx -c0103b16: 1b 45 cc sbb -0x34(%ebp),%eax -c0103b19: 73 0e jae c0103b29 - end = KMEMSIZE;// 将其限制为内存上限 -c0103b1b: c7 45 c8 00 00 00 38 movl $0x38000000,-0x38(%ebp) -c0103b22: c7 45 cc 00 00 00 00 movl $0x0,-0x34(%ebp) - } - if (begin < end) {// 如果起始地址小于结束地址 -c0103b29: 8b 45 d0 mov -0x30(%ebp),%eax -c0103b2c: 8b 55 d4 mov -0x2c(%ebp),%edx -c0103b2f: 3b 45 c8 cmp -0x38(%ebp),%eax -c0103b32: 89 d0 mov %edx,%eax -c0103b34: 1b 45 cc sbb -0x34(%ebp),%eax -c0103b37: 0f 83 8f 00 00 00 jae c0103bcc - begin = ROUNDUP(begin, PGSIZE);// 将起始地址对齐到页边界 -c0103b3d: c7 45 b0 00 10 00 00 movl $0x1000,-0x50(%ebp) -c0103b44: 8b 55 d0 mov -0x30(%ebp),%edx -c0103b47: 8b 45 b0 mov -0x50(%ebp),%eax -c0103b4a: 01 d0 add %edx,%eax -c0103b4c: 48 dec %eax -c0103b4d: 89 45 ac mov %eax,-0x54(%ebp) -c0103b50: 8b 45 ac mov -0x54(%ebp),%eax -c0103b53: ba 00 00 00 00 mov $0x0,%edx -c0103b58: f7 75 b0 divl -0x50(%ebp) -c0103b5b: 8b 45 ac mov -0x54(%ebp),%eax -c0103b5e: 29 d0 sub %edx,%eax -c0103b60: ba 00 00 00 00 mov $0x0,%edx -c0103b65: 89 45 d0 mov %eax,-0x30(%ebp) -c0103b68: 89 55 d4 mov %edx,-0x2c(%ebp) - end = ROUNDDOWN(end, PGSIZE);// 将结束地址对齐到页边界 -c0103b6b: 8b 45 c8 mov -0x38(%ebp),%eax -c0103b6e: 89 45 a8 mov %eax,-0x58(%ebp) -c0103b71: 8b 45 a8 mov -0x58(%ebp),%eax -c0103b74: ba 00 00 00 00 mov $0x0,%edx -c0103b79: 89 c3 mov %eax,%ebx -c0103b7b: 81 e3 00 f0 ff ff and $0xfffff000,%ebx -c0103b81: 89 de mov %ebx,%esi -c0103b83: 89 d0 mov %edx,%eax -c0103b85: 83 e0 00 and $0x0,%eax -c0103b88: 89 c7 mov %eax,%edi -c0103b8a: 89 75 c8 mov %esi,-0x38(%ebp) -c0103b8d: 89 7d cc mov %edi,-0x34(%ebp) - if (begin < end) {// 如果调整后的起始地址仍小于结束地址 -c0103b90: 8b 45 d0 mov -0x30(%ebp),%eax -c0103b93: 8b 55 d4 mov -0x2c(%ebp),%edx -c0103b96: 3b 45 c8 cmp -0x38(%ebp),%eax -c0103b99: 89 d0 mov %edx,%eax -c0103b9b: 1b 45 cc sbb -0x34(%ebp),%eax -c0103b9e: 73 2c jae c0103bcc - init_memmap(pa2page(begin), (end - begin) / PGSIZE);// 初始化内存页映射 -c0103ba0: 8b 45 c8 mov -0x38(%ebp),%eax -c0103ba3: 8b 55 cc mov -0x34(%ebp),%edx -c0103ba6: 2b 45 d0 sub -0x30(%ebp),%eax -c0103ba9: 1b 55 d4 sbb -0x2c(%ebp),%edx -c0103bac: 0f ac d0 0c shrd $0xc,%edx,%eax -c0103bb0: c1 ea 0c shr $0xc,%edx -c0103bb3: 89 c3 mov %eax,%ebx -c0103bb5: 8b 45 d0 mov -0x30(%ebp),%eax -c0103bb8: 89 04 24 mov %eax,(%esp) -c0103bbb: e8 94 f8 ff ff call c0103454 -c0103bc0: 89 5c 24 04 mov %ebx,0x4(%esp) -c0103bc4: 89 04 24 mov %eax,(%esp) -c0103bc7: e8 69 fb ff ff call c0103735 - for (i = 0; i < memmap->nr_map; i ++) {// 再次遍历内存映射 -c0103bcc: ff 45 dc incl -0x24(%ebp) -c0103bcf: 8b 45 c4 mov -0x3c(%ebp),%eax -c0103bd2: 8b 00 mov (%eax),%eax -c0103bd4: 39 45 dc cmp %eax,-0x24(%ebp) -c0103bd7: 0f 8c a7 fe ff ff jl c0103a84 - } - } + nr_free += n;// 更新空闲页的计数 +c01038b3: 8b 15 ec bf 12 c0 mov 0xc012bfec,%edx +c01038b9: 8b 45 0c mov 0xc(%ebp),%eax +c01038bc: 01 d0 add %edx,%eax +c01038be: a3 ec bf 12 c0 mov %eax,0xc012bfec +c01038c3: c7 45 9c e4 bf 12 c0 movl $0xc012bfe4,-0x64(%ebp) + return listelm->next; +c01038ca: 8b 45 9c mov -0x64(%ebp),%eax +c01038cd: 8b 40 04 mov 0x4(%eax),%eax + le = list_next(&free_list); +c01038d0: 89 45 f0 mov %eax,-0x10(%ebp) + while (le != &free_list) +c01038d3: eb 66 jmp c010393b + { + p = le2page(le, page_link); +c01038d5: 8b 45 f0 mov -0x10(%ebp),%eax +c01038d8: 83 e8 0c sub $0xc,%eax +c01038db: 89 45 f4 mov %eax,-0xc(%ebp) + if (base + base->property <= p) +c01038de: 8b 45 08 mov 0x8(%ebp),%eax +c01038e1: 8b 40 08 mov 0x8(%eax),%eax +c01038e4: c1 e0 05 shl $0x5,%eax +c01038e7: 89 c2 mov %eax,%edx +c01038e9: 8b 45 08 mov 0x8(%ebp),%eax +c01038ec: 01 d0 add %edx,%eax +c01038ee: 39 45 f4 cmp %eax,-0xc(%ebp) +c01038f1: 72 39 jb c010392c + { + assert(base + base->property != p); +c01038f3: 8b 45 08 mov 0x8(%ebp),%eax +c01038f6: 8b 40 08 mov 0x8(%eax),%eax +c01038f9: c1 e0 05 shl $0x5,%eax +c01038fc: 89 c2 mov %eax,%edx +c01038fe: 8b 45 08 mov 0x8(%ebp),%eax +c0103901: 01 d0 add %edx,%eax +c0103903: 39 45 f4 cmp %eax,-0xc(%ebp) +c0103906: 75 3e jne c0103946 +c0103908: c7 44 24 0c d9 a9 10 movl $0xc010a9d9,0xc(%esp) +c010390f: c0 +c0103910: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103917: c0 +c0103918: c7 44 24 04 ef 00 00 movl $0xef,0x4(%esp) +c010391f: 00 +c0103920: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103927: e8 19 d3 ff ff call c0100c45 <__panic> +c010392c: 8b 45 f0 mov -0x10(%ebp),%eax +c010392f: 89 45 98 mov %eax,-0x68(%ebp) +c0103932: 8b 45 98 mov -0x68(%ebp),%eax +c0103935: 8b 40 04 mov 0x4(%eax),%eax + break; } + le = list_next(le); +c0103938: 89 45 f0 mov %eax,-0x10(%ebp) + while (le != &free_list) +c010393b: 81 7d f0 e4 bf 12 c0 cmpl $0xc012bfe4,-0x10(%ebp) +c0103942: 75 91 jne c01038d5 +c0103944: eb 01 jmp c0103947 + break; +c0103946: 90 nop } + + list_add_before(le, &(base->page_link));// 将释放的页块添加到空闲列表中 +c0103947: 8b 45 08 mov 0x8(%ebp),%eax +c010394a: 8d 50 0c lea 0xc(%eax),%edx +c010394d: 8b 45 f0 mov -0x10(%ebp),%eax +c0103950: 89 45 94 mov %eax,-0x6c(%ebp) +c0103953: 89 55 90 mov %edx,-0x70(%ebp) + __list_add(elm, listelm->prev, listelm); +c0103956: 8b 45 94 mov -0x6c(%ebp),%eax +c0103959: 8b 00 mov (%eax),%eax +c010395b: 8b 55 90 mov -0x70(%ebp),%edx +c010395e: 89 55 8c mov %edx,-0x74(%ebp) +c0103961: 89 45 88 mov %eax,-0x78(%ebp) +c0103964: 8b 45 94 mov -0x6c(%ebp),%eax +c0103967: 89 45 84 mov %eax,-0x7c(%ebp) + prev->next = next->prev = elm; +c010396a: 8b 45 84 mov -0x7c(%ebp),%eax +c010396d: 8b 55 8c mov -0x74(%ebp),%edx +c0103970: 89 10 mov %edx,(%eax) +c0103972: 8b 45 84 mov -0x7c(%ebp),%eax +c0103975: 8b 10 mov (%eax),%edx +c0103977: 8b 45 88 mov -0x78(%ebp),%eax +c010397a: 89 50 04 mov %edx,0x4(%eax) + elm->next = next; +c010397d: 8b 45 8c mov -0x74(%ebp),%eax +c0103980: 8b 55 84 mov -0x7c(%ebp),%edx +c0103983: 89 50 04 mov %edx,0x4(%eax) + elm->prev = prev; +c0103986: 8b 45 8c mov -0x74(%ebp),%eax +c0103989: 8b 55 88 mov -0x78(%ebp),%edx +c010398c: 89 10 mov %edx,(%eax) +} +c010398e: 90 nop } -c0103bdd: 90 nop -c0103bde: 90 nop -c0103bdf: 81 c4 9c 00 00 00 add $0x9c,%esp -c0103be5: 5b pop %ebx -c0103be6: 5e pop %esi -c0103be7: 5f pop %edi -c0103be8: 5d pop %ebp -c0103be9: c3 ret +c010398f: 90 nop +} +c0103990: 90 nop +c0103991: 89 ec mov %ebp,%esp +c0103993: 5d pop %ebp +c0103994: c3 ret -c0103bea : -//la: 需要映射的线性地址(经过 x86 段映射后的地址) -// size: memory size size: 内存大小 -// pa: physical address of this memory pa:该内存的物理地址 -// perm: permission of this memory perm: 该内存的权限 -static void -boot_map_segment(pde_t *pgdir, uintptr_t la, size_t size, uintptr_t pa, uint32_t perm) { -c0103bea: f3 0f 1e fb endbr32 -c0103bee: 55 push %ebp -c0103bef: 89 e5 mov %esp,%ebp -c0103bf1: 83 ec 38 sub $0x38,%esp - // 确保线性地址和物理地址的页偏移相同 - assert(PGOFF(la) == PGOFF(pa)); -c0103bf4: 8b 45 0c mov 0xc(%ebp),%eax -c0103bf7: 33 45 14 xor 0x14(%ebp),%eax -c0103bfa: 25 ff 0f 00 00 and $0xfff,%eax -c0103bff: 85 c0 test %eax,%eax -c0103c01: 74 24 je c0103c27 -c0103c03: c7 44 24 0c 96 ac 10 movl $0xc010ac96,0xc(%esp) -c0103c0a: c0 -c0103c0b: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0103c12: c0 -c0103c13: c7 44 24 04 3b 01 00 movl $0x13b,0x4(%esp) -c0103c1a: 00 -c0103c1b: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0103c22: e8 1c c8 ff ff call c0100443 <__panic> - // 计算需要映射的页数,ROUNDUP 将总大小对齐到下一个页大小的边界 - size_t n = ROUNDUP(size + PGOFF(la), PGSIZE) / PGSIZE; -c0103c27: c7 45 f0 00 10 00 00 movl $0x1000,-0x10(%ebp) -c0103c2e: 8b 45 0c mov 0xc(%ebp),%eax -c0103c31: 25 ff 0f 00 00 and $0xfff,%eax -c0103c36: 89 c2 mov %eax,%edx -c0103c38: 8b 45 10 mov 0x10(%ebp),%eax -c0103c3b: 01 c2 add %eax,%edx -c0103c3d: 8b 45 f0 mov -0x10(%ebp),%eax -c0103c40: 01 d0 add %edx,%eax -c0103c42: 48 dec %eax -c0103c43: 89 45 ec mov %eax,-0x14(%ebp) -c0103c46: 8b 45 ec mov -0x14(%ebp),%eax -c0103c49: ba 00 00 00 00 mov $0x0,%edx -c0103c4e: f7 75 f0 divl -0x10(%ebp) -c0103c51: 8b 45 ec mov -0x14(%ebp),%eax -c0103c54: 29 d0 sub %edx,%eax -c0103c56: c1 e8 0c shr $0xc,%eax -c0103c59: 89 45 f4 mov %eax,-0xc(%ebp) - // 将线性地址向下对齐到页边界 - la = ROUNDDOWN(la, PGSIZE); -c0103c5c: 8b 45 0c mov 0xc(%ebp),%eax -c0103c5f: 89 45 e8 mov %eax,-0x18(%ebp) -c0103c62: 8b 45 e8 mov -0x18(%ebp),%eax -c0103c65: 25 00 f0 ff ff and $0xfffff000,%eax -c0103c6a: 89 45 0c mov %eax,0xc(%ebp) - // 将物理地址向下对齐到页边界 - pa = ROUNDDOWN(pa, PGSIZE); -c0103c6d: 8b 45 14 mov 0x14(%ebp),%eax -c0103c70: 89 45 e4 mov %eax,-0x1c(%ebp) -c0103c73: 8b 45 e4 mov -0x1c(%ebp),%eax -c0103c76: 25 00 f0 ff ff and $0xfffff000,%eax -c0103c7b: 89 45 14 mov %eax,0x14(%ebp) - // 循环遍历每一页,直到映射的页数为零 - for (; n > 0; n --, la += PGSIZE, pa += PGSIZE) { -c0103c7e: eb 68 jmp c0103ce8 - // 获取当前页的页表项指针,如果不存在则创建新的页表项 - pte_t *ptep = get_pte(pgdir, la, 1); -c0103c80: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) -c0103c87: 00 -c0103c88: 8b 45 0c mov 0xc(%ebp),%eax -c0103c8b: 89 44 24 04 mov %eax,0x4(%esp) -c0103c8f: 8b 45 08 mov 0x8(%ebp),%eax -c0103c92: 89 04 24 mov %eax,(%esp) -c0103c95: e8 8f 01 00 00 call c0103e29 -c0103c9a: 89 45 e0 mov %eax,-0x20(%ebp) - // 确保页表项指针不为空 - assert(ptep != NULL); -c0103c9d: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) -c0103ca1: 75 24 jne c0103cc7 -c0103ca3: c7 44 24 0c c2 ac 10 movl $0xc010acc2,0xc(%esp) -c0103caa: c0 -c0103cab: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0103cb2: c0 -c0103cb3: c7 44 24 04 47 01 00 movl $0x147,0x4(%esp) -c0103cba: 00 -c0103cbb: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0103cc2: e8 7c c7 ff ff call c0100443 <__panic> - // 设置页表项,包含物理地址、存在位和权限 - *ptep = pa | PTE_P | perm; -c0103cc7: 8b 45 14 mov 0x14(%ebp),%eax -c0103cca: 0b 45 18 or 0x18(%ebp),%eax -c0103ccd: 83 c8 01 or $0x1,%eax -c0103cd0: 89 c2 mov %eax,%edx -c0103cd2: 8b 45 e0 mov -0x20(%ebp),%eax -c0103cd5: 89 10 mov %edx,(%eax) - for (; n > 0; n --, la += PGSIZE, pa += PGSIZE) { -c0103cd7: ff 4d f4 decl -0xc(%ebp) -c0103cda: 81 45 0c 00 10 00 00 addl $0x1000,0xc(%ebp) -c0103ce1: 81 45 14 00 10 00 00 addl $0x1000,0x14(%ebp) -c0103ce8: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0103cec: 75 92 jne c0103c80 - } -} -c0103cee: 90 nop -c0103cef: 90 nop -c0103cf0: c9 leave -c0103cf1: c3 ret - -c0103cf2 : -// return value: the kernel virtual address of this allocated page -//note: this function is used to get the memory for PDT(Page Directory Table)&PT(Page Table) -//boot_alloc_page - 使用 pmm->alloc_pages(1) 分配一页内存.返回值: 分配的页面的内核虚拟地址 -//注意: 此函数用于获取页目录表(PDT)和页表(PT)的内存 -static void * -boot_alloc_page(void) { -c0103cf2: f3 0f 1e fb endbr32 -c0103cf6: 55 push %ebp -c0103cf7: 89 e5 mov %esp,%ebp -c0103cf9: 83 ec 28 sub $0x28,%esp - struct Page *p = alloc_page();// 调用分配页面的函数 -c0103cfc: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0103d03: e8 51 fa ff ff call c0103759 -c0103d08: 89 45 f4 mov %eax,-0xc(%ebp) - if (p == NULL) {// 检查分配是否成功 -c0103d0b: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0103d0f: 75 1c jne c0103d2d - panic("boot_alloc_page failed.\n");// 如果分配失败,则触发异常 -c0103d11: c7 44 24 08 cf ac 10 movl $0xc010accf,0x8(%esp) -c0103d18: c0 -c0103d19: c7 44 24 04 56 01 00 movl $0x156,0x4(%esp) -c0103d20: 00 -c0103d21: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0103d28: e8 16 c7 ff ff call c0100443 <__panic> - } - return page2kva(p);// 返回分配页面的内核虚拟地址 -c0103d2d: 8b 45 f4 mov -0xc(%ebp),%eax -c0103d30: 89 04 24 mov %eax,(%esp) -c0103d33: e8 61 f7 ff ff call c0103499 -} -c0103d38: c9 leave -c0103d39: c3 ret - -c0103d3a : -//pmm_init - setup a pmm to manage physical memory, build PDT&PT to setup paging mechanism -// - check the correctness of pmm & paging mechanism, print PDT&PT -//pmm_init - 设置物理内存管理器,构建页目录表(PDT)和页表(PT),以设置分页机制 -// - 检查物理内存管理器和分页机制的正确性,打印页目录表和页表 -void -pmm_init(void) { -c0103d3a: f3 0f 1e fb endbr32 -c0103d3e: 55 push %ebp -c0103d3f: 89 e5 mov %esp,%ebp -c0103d41: 83 ec 38 sub $0x38,%esp - // We've already enabled paging - // 我们已经启用了分页 - boot_cr3 = PADDR(boot_pgdir); -c0103d44: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0103d49: 89 45 f4 mov %eax,-0xc(%ebp) -c0103d4c: 81 7d f4 ff ff ff bf cmpl $0xbfffffff,-0xc(%ebp) -c0103d53: 77 23 ja c0103d78 -c0103d55: 8b 45 f4 mov -0xc(%ebp),%eax -c0103d58: 89 44 24 0c mov %eax,0xc(%esp) -c0103d5c: c7 44 24 08 64 ac 10 movl $0xc010ac64,0x8(%esp) -c0103d63: c0 -c0103d64: c7 44 24 04 63 01 00 movl $0x163,0x4(%esp) -c0103d6b: 00 -c0103d6c: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0103d73: e8 cb c6 ff ff call c0100443 <__panic> -c0103d78: 8b 45 f4 mov -0xc(%ebp),%eax -c0103d7b: 05 00 00 00 40 add $0x40000000,%eax -c0103d80: a3 b4 e0 12 c0 mov %eax,0xc012e0b4 - // 我们需要分配/释放物理内存(粒度为 4KB 或其他大小)。 - // 因此在 pmm.h 中定义了物理内存管理器的框架(struct pmm_manager)。 - // 首先,我们应该基于该框架初始化一个物理内存管理器(pmm)。 - // 然后 pmm 可以分配/释放物理内存。 - // 现在,first_fit/best_fit/worst_fit/buddy_system 的 pmm 都可用。 - init_pmm_manager();// 初始化物理内存管理器 -c0103d85: e8 73 f9 ff ff call c01036fd - - // detect physical memory space, reserve already used memory, - // then use pmm->init_memmap to create free page list - // 检测物理内存空间,保留已经使用的内存, - // 然后使用 pmm->init_memmap 创建空闲页面列表 - page_init();// 初始化页面管理 -c0103d8a: e8 9f fa ff ff call c010382e - - //use pmm->check to verify the correctness of the alloc/free function in a pmm - // 使用 pmm->check 验证 pmm 中分配/释放函数的正确性 - check_alloc_page();// 检查页面分配功能 -c0103d8f: e8 c7 04 00 00 call c010425b - - check_pgdir();// 检查页目录的状态 -c0103d94: e8 e5 04 00 00 call c010427e - - // recursively insert boot_pgdir in itself - // to form a virtual page table at virtual address VPT - // 递归地将 boot_pgdir 插入到自身中 - // 在虚拟地址 VPT 处形成虚拟页表 - boot_pgdir[PDX(VPT)] = PADDR(boot_pgdir) | PTE_P | PTE_W;// 设置页目录项,映射自身 -c0103d99: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0103d9e: 89 45 f0 mov %eax,-0x10(%ebp) -c0103da1: 81 7d f0 ff ff ff bf cmpl $0xbfffffff,-0x10(%ebp) -c0103da8: 77 23 ja c0103dcd -c0103daa: 8b 45 f0 mov -0x10(%ebp),%eax -c0103dad: 89 44 24 0c mov %eax,0xc(%esp) -c0103db1: c7 44 24 08 64 ac 10 movl $0xc010ac64,0x8(%esp) -c0103db8: c0 -c0103db9: c7 44 24 04 83 01 00 movl $0x183,0x4(%esp) -c0103dc0: 00 -c0103dc1: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0103dc8: e8 76 c6 ff ff call c0100443 <__panic> -c0103dcd: 8b 45 f0 mov -0x10(%ebp),%eax -c0103dd0: 8d 90 00 00 00 40 lea 0x40000000(%eax),%edx -c0103dd6: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0103ddb: 05 ac 0f 00 00 add $0xfac,%eax -c0103de0: 83 ca 03 or $0x3,%edx -c0103de3: 89 10 mov %edx,(%eax) - - // map all physical memory to linear memory with base linear addr KERNBASE - // linear_addr KERNBASE ~ KERNBASE + KMEMSIZE = phy_addr 0 ~ KMEMSIZE - // 将所有物理内存映射到线性内存,基地址为 KERNBASE - // 线性地址 KERNBASE ~ KERNBASE + KMEMSIZE = 物理地址 0 ~ KMEMSIZE - boot_map_segment(boot_pgdir, KERNBASE, KMEMSIZE, 0, PTE_W);// 映射物理内存 -c0103de5: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0103dea: c7 44 24 10 02 00 00 movl $0x2,0x10(%esp) -c0103df1: 00 -c0103df2: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) -c0103df9: 00 -c0103dfa: c7 44 24 08 00 00 00 movl $0x38000000,0x8(%esp) -c0103e01: 38 -c0103e02: c7 44 24 04 00 00 00 movl $0xc0000000,0x4(%esp) -c0103e09: c0 -c0103e0a: 89 04 24 mov %eax,(%esp) -c0103e0d: e8 d8 fd ff ff call c0103bea - // then set kernel stack (ss:esp) in TSS, setup TSS in gdt, load TSS - // 由于我们正在使用引导加载程序的 GDT, - // 我们应该重新加载 GDT(第二次,也是最后一次),以获取用户段和 TSS - // 映射虚拟地址 0 ~ 4G = 线性地址 0 ~ 4G - // 然后在 TSS 中设置内核栈 (ss:esp),在 gdt 中设置 TSS,加载 TSS - gdt_init();// 初始化全局描述符表 -c0103e12: e8 f8 f7 ff ff call c010360f - - //now the basic virtual memory map(see memalyout.h) is established. - //check the correctness of the basic virtual memory map. - // 现在基本的虚拟内存映射(见 memlayout.h)已建立。 - // 检查基础虚拟内存映射的正确性。 - check_boot_pgdir(); // 检查页目录的正确性 -c0103e17: e8 02 0b 00 00 call c010491e - - print_pgdir(); // 打印页目录表 -c0103e1c: e8 87 0f 00 00 call c0104da8 - kmalloc_init(); -c0103e21: e8 b9 28 00 00 call c01066df - -} -c0103e26: 90 nop -c0103e27: c9 leave -c0103e28: c3 ret - -c0103e29 : -// pgdir: 页目录的内核虚拟基地址 -// la: 需要映射的线性地址 -// create: 一个逻辑值,决定是否为页表分配一页 -// 返回值:该 PTE 的内核虚拟地址 -pte_t * -get_pte(pde_t *pgdir, uintptr_t la, bool create) { -c0103e29: f3 0f 1e fb endbr32 -c0103e2d: 55 push %ebp -c0103e2e: 89 e5 mov %esp,%ebp -c0103e30: 83 ec 38 sub $0x38,%esp - // (7) set page directory entry's permission - } - return NULL; // (8) return page table entry -#endif - // (1) 找到页目录项 - pde_t *pdep = &pgdir[PDX(la)];// 使用 PDX 宏获取页目录索引 -c0103e33: 8b 45 0c mov 0xc(%ebp),%eax -c0103e36: c1 e8 16 shr $0x16,%eax -c0103e39: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx -c0103e40: 8b 45 08 mov 0x8(%ebp),%eax -c0103e43: 01 d0 add %edx,%eax -c0103e45: 89 45 f4 mov %eax,-0xc(%ebp) - // (2) 检查页目录项是否存在 - if (!(*pdep & PTE_P)) {// 如果页目录项的存在位 PTE_P 没有被设置 -c0103e48: 8b 45 f4 mov -0xc(%ebp),%eax -c0103e4b: 8b 00 mov (%eax),%eax -c0103e4d: 83 e0 01 and $0x1,%eax -c0103e50: 85 c0 test %eax,%eax -c0103e52: 0f 85 af 00 00 00 jne c0103f07 - struct Page *page;// 声明一个指针,用于指向新分配的页面 - // 检查是否允许创建新页表,或者分配页表失败 - if (!create || (page = alloc_page()) == NULL) {// 如果不允许创建或分配失败 -c0103e58: 83 7d 10 00 cmpl $0x0,0x10(%ebp) -c0103e5c: 74 15 je c0103e73 -c0103e5e: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0103e65: e8 ef f8 ff ff call c0103759 -c0103e6a: 89 45 f0 mov %eax,-0x10(%ebp) -c0103e6d: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c0103e71: 75 0a jne c0103e7d - return NULL;// 返回 NULL,表示无法获取页表 -c0103e73: b8 00 00 00 00 mov $0x0,%eax -c0103e78: e9 e7 00 00 00 jmp c0103f64 - } - // 设置新分配页面的引用计数为 1 - set_page_ref(page, 1); -c0103e7d: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0103e84: 00 -c0103e85: 8b 45 f0 mov -0x10(%ebp),%eax -c0103e88: 89 04 24 mov %eax,(%esp) -c0103e8b: e8 bd f6 ff ff call c010354d - uintptr_t pa = page2pa(page);// 获取新分配页面的物理地址 -c0103e90: 8b 45 f0 mov -0x10(%ebp),%eax -c0103e93: 89 04 24 mov %eax,(%esp) -c0103e96: e8 a3 f5 ff ff call c010343e -c0103e9b: 89 45 ec mov %eax,-0x14(%ebp) - memset(KADDR(pa), 0, PGSIZE);// 清空新分配的页表内容,初始化为零 -c0103e9e: 8b 45 ec mov -0x14(%ebp),%eax -c0103ea1: 89 45 e8 mov %eax,-0x18(%ebp) -c0103ea4: 8b 45 e8 mov -0x18(%ebp),%eax -c0103ea7: c1 e8 0c shr $0xc,%eax -c0103eaa: 89 45 e4 mov %eax,-0x1c(%ebp) -c0103ead: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0103eb2: 39 45 e4 cmp %eax,-0x1c(%ebp) -c0103eb5: 72 23 jb c0103eda -c0103eb7: 8b 45 e8 mov -0x18(%ebp),%eax -c0103eba: 89 44 24 0c mov %eax,0xc(%esp) -c0103ebe: c7 44 24 08 c0 ab 10 movl $0xc010abc0,0x8(%esp) -c0103ec5: c0 -c0103ec6: c7 44 24 04 dd 01 00 movl $0x1dd,0x4(%esp) -c0103ecd: 00 -c0103ece: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0103ed5: e8 69 c5 ff ff call c0100443 <__panic> -c0103eda: 8b 45 e8 mov -0x18(%ebp),%eax -c0103edd: 2d 00 00 00 40 sub $0x40000000,%eax -c0103ee2: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) -c0103ee9: 00 -c0103eea: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0103ef1: 00 -c0103ef2: 89 04 24 mov %eax,(%esp) -c0103ef5: e8 5a 5a 00 00 call c0109954 - // 更新页目录项,设置物理地址和权限位 - *pdep = pa | PTE_U | PTE_W | PTE_P;// 将物理地址和权限位(用户可访问、可写、有效)合并设置 -c0103efa: 8b 45 ec mov -0x14(%ebp),%eax -c0103efd: 83 c8 07 or $0x7,%eax -c0103f00: 89 c2 mov %eax,%edx -c0103f02: 8b 45 f4 mov -0xc(%ebp),%eax -c0103f05: 89 10 mov %edx,(%eax) - } - // 返回指定线性地址 la 对应的页表项的内核虚拟地址 - return &((pte_t *)KADDR(PDE_ADDR(*pdep)))[PTX(la)];// 计算并返回页表项的指针 -c0103f07: 8b 45 f4 mov -0xc(%ebp),%eax -c0103f0a: 8b 00 mov (%eax),%eax -c0103f0c: 25 00 f0 ff ff and $0xfffff000,%eax -c0103f11: 89 45 e0 mov %eax,-0x20(%ebp) -c0103f14: 8b 45 e0 mov -0x20(%ebp),%eax -c0103f17: c1 e8 0c shr $0xc,%eax -c0103f1a: 89 45 dc mov %eax,-0x24(%ebp) -c0103f1d: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0103f22: 39 45 dc cmp %eax,-0x24(%ebp) -c0103f25: 72 23 jb c0103f4a -c0103f27: 8b 45 e0 mov -0x20(%ebp),%eax -c0103f2a: 89 44 24 0c mov %eax,0xc(%esp) -c0103f2e: c7 44 24 08 c0 ab 10 movl $0xc010abc0,0x8(%esp) -c0103f35: c0 -c0103f36: c7 44 24 04 e2 01 00 movl $0x1e2,0x4(%esp) -c0103f3d: 00 -c0103f3e: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0103f45: e8 f9 c4 ff ff call c0100443 <__panic> -c0103f4a: 8b 45 e0 mov -0x20(%ebp),%eax -c0103f4d: 2d 00 00 00 40 sub $0x40000000,%eax -c0103f52: 89 c2 mov %eax,%edx -c0103f54: 8b 45 0c mov 0xc(%ebp),%eax -c0103f57: c1 e8 0c shr $0xc,%eax -c0103f5a: 25 ff 03 00 00 and $0x3ff,%eax -c0103f5f: c1 e0 02 shl $0x2,%eax -c0103f62: 01 d0 add %edx,%eax -} -c0103f64: c9 leave -c0103f65: c3 ret - -c0103f66 : - -//get_page - get related Page struct for linear address la using PDT pgdir -// get_page - 获取与线性地址 la 相关的 Page 结构体,使用页目录 pgdir -struct Page * -get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { -c0103f66: f3 0f 1e fb endbr32 -c0103f6a: 55 push %ebp -c0103f6b: 89 e5 mov %esp,%ebp -c0103f6d: 83 ec 28 sub $0x28,%esp - // 调用 get_pte 函数获取对应线性地址 la 的页表项指针 - pte_t *ptep = get_pte(pgdir, la, 0); -c0103f70: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c0103f77: 00 -c0103f78: 8b 45 0c mov 0xc(%ebp),%eax -c0103f7b: 89 44 24 04 mov %eax,0x4(%esp) -c0103f7f: 8b 45 08 mov 0x8(%ebp),%eax -c0103f82: 89 04 24 mov %eax,(%esp) -c0103f85: e8 9f fe ff ff call c0103e29 -c0103f8a: 89 45 f4 mov %eax,-0xc(%ebp) - // 如果 ptep_store 指针不为 NULL,将 ptep 存储到 ptep_store 指向的位置 - if (ptep_store != NULL) { -c0103f8d: 83 7d 10 00 cmpl $0x0,0x10(%ebp) -c0103f91: 74 08 je c0103f9b - *ptep_store = ptep; // 存储当前页表项的指针 -c0103f93: 8b 45 10 mov 0x10(%ebp),%eax -c0103f96: 8b 55 f4 mov -0xc(%ebp),%edx -c0103f99: 89 10 mov %edx,(%eax) - } - // 检查 ptep 是否有效以及页表项的存在位 PTE_P 是否被设置 - if (ptep != NULL && *ptep & PTE_P) { -c0103f9b: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0103f9f: 74 1b je c0103fbc -c0103fa1: 8b 45 f4 mov -0xc(%ebp),%eax -c0103fa4: 8b 00 mov (%eax),%eax -c0103fa6: 83 e0 01 and $0x1,%eax -c0103fa9: 85 c0 test %eax,%eax -c0103fab: 74 0f je c0103fbc - // 返回与页表项对应的 Page 结构体 - return pte2page(*ptep);// 将页表项转换为对应的 Page 结构 -c0103fad: 8b 45 f4 mov -0xc(%ebp),%eax -c0103fb0: 8b 00 mov (%eax),%eax -c0103fb2: 89 04 24 mov %eax,(%esp) -c0103fb5: e8 33 f5 ff ff call c01034ed -c0103fba: eb 05 jmp c0103fc1 - } - // 如果未找到有效的页,返回 NULL - return NULL; -c0103fbc: b8 00 00 00 00 mov $0x0,%eax -} -c0103fc1: c9 leave -c0103fc2: c3 ret - -c0103fc3 : - -//page_remove_pte - free an Page sturct which is related linear address la -// - and clean(invalidate) pte which is related linear address la -//note: PT is changed, so the TLB need to be invalidate -static inline void -page_remove_pte(pde_t *pgdir, uintptr_t la, pte_t *ptep) { -c0103fc3: 55 push %ebp -c0103fc4: 89 e5 mov %esp,%ebp -c0103fc6: 83 ec 28 sub $0x28,%esp - //(4) and free this page when page reference reachs 0 - //(5) clear second page table entry - //(6) flush tlb - } -#endif - if (*ptep & PTE_P) { -c0103fc9: 8b 45 10 mov 0x10(%ebp),%eax -c0103fcc: 8b 00 mov (%eax),%eax -c0103fce: 83 e0 01 and $0x1,%eax -c0103fd1: 85 c0 test %eax,%eax -c0103fd3: 74 4d je c0104022 - struct Page *page = pte2page(*ptep);// 找到对应的物理页 -c0103fd5: 8b 45 10 mov 0x10(%ebp),%eax -c0103fd8: 8b 00 mov (%eax),%eax -c0103fda: 89 04 24 mov %eax,(%esp) -c0103fdd: e8 0b f5 ff ff call c01034ed -c0103fe2: 89 45 f4 mov %eax,-0xc(%ebp) - // 减少物理页的引用计数,如果引用计数为零,释放该物理页 - if (page_ref_dec(page) == 0) { -c0103fe5: 8b 45 f4 mov -0xc(%ebp),%eax -c0103fe8: 89 04 24 mov %eax,(%esp) -c0103feb: e8 82 f5 ff ff call c0103572 -c0103ff0: 85 c0 test %eax,%eax -c0103ff2: 75 13 jne c0104007 - free_page(page); -c0103ff4: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0103ffb: 00 -c0103ffc: 8b 45 f4 mov -0xc(%ebp),%eax -c0103fff: 89 04 24 mov %eax,(%esp) -c0104002: e8 c1 f7 ff ff call c01037c8 - } - *ptep = 0;// 清除页表项 -c0104007: 8b 45 10 mov 0x10(%ebp),%eax -c010400a: c7 00 00 00 00 00 movl $0x0,(%eax) - tlb_invalidate(pgdir, la);// 刷新 TLB -c0104010: 8b 45 0c mov 0xc(%ebp),%eax -c0104013: 89 44 24 04 mov %eax,0x4(%esp) -c0104017: 8b 45 08 mov 0x8(%ebp),%eax -c010401a: 89 04 24 mov %eax,(%esp) -c010401d: e8 09 01 00 00 call c010412b - } -} -c0104022: 90 nop -c0104023: c9 leave -c0104024: c3 ret - -c0104025 : - -//page_remove - free an Page which is related linear address la and has an validated pte -//移除一个虚拟地址对应的页面 -void -page_remove(pde_t *pgdir, uintptr_t la) { -c0104025: f3 0f 1e fb endbr32 -c0104029: 55 push %ebp -c010402a: 89 e5 mov %esp,%ebp -c010402c: 83 ec 28 sub $0x28,%esp - //调用 get_pte 函数获取给定虚拟地址 la 对应的页表项指针 ptep。 - pte_t *ptep = get_pte(pgdir, la, 0); -c010402f: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c0104036: 00 -c0104037: 8b 45 0c mov 0xc(%ebp),%eax -c010403a: 89 44 24 04 mov %eax,0x4(%esp) -c010403e: 8b 45 08 mov 0x8(%ebp),%eax -c0104041: 89 04 24 mov %eax,(%esp) -c0104044: e8 e0 fd ff ff call c0103e29 -c0104049: 89 45 f4 mov %eax,-0xc(%ebp) - //如果 ptep 不为 NULL,则调用 page_remove_pte 函数移除该页表项。 - if (ptep != NULL) { -c010404c: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0104050: 74 19 je c010406b - page_remove_pte(pgdir, la, ptep); -c0104052: 8b 45 f4 mov -0xc(%ebp),%eax -c0104055: 89 44 24 08 mov %eax,0x8(%esp) -c0104059: 8b 45 0c mov 0xc(%ebp),%eax -c010405c: 89 44 24 04 mov %eax,0x4(%esp) -c0104060: 8b 45 08 mov 0x8(%ebp),%eax -c0104063: 89 04 24 mov %eax,(%esp) -c0104066: e8 58 ff ff ff call c0103fc3 - } -} -c010406b: 90 nop -c010406c: c9 leave -c010406d: c3 ret - -c010406e : -// perm: the permission of this Page which is setted in related pte -// return value: always 0 -//note: PT is changed, so the TLB need to be invalidate -//将一个页面插入到页表中。 -int -page_insert(pde_t *pgdir, struct Page *page, uintptr_t la, uint32_t perm) { -c010406e: f3 0f 1e fb endbr32 -c0104072: 55 push %ebp -c0104073: 89 e5 mov %esp,%ebp -c0104075: 83 ec 28 sub $0x28,%esp - //通过 get_pte 函数获取指定虚拟地址 la 对应的页表项指针 ptep。 - pte_t *ptep = get_pte(pgdir, la, 1); -c0104078: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) -c010407f: 00 -c0104080: 8b 45 10 mov 0x10(%ebp),%eax -c0104083: 89 44 24 04 mov %eax,0x4(%esp) -c0104087: 8b 45 08 mov 0x8(%ebp),%eax -c010408a: 89 04 24 mov %eax,(%esp) -c010408d: e8 97 fd ff ff call c0103e29 -c0104092: 89 45 f4 mov %eax,-0xc(%ebp) - //如果 ptep 为 NULL,表示内存分配失败,返回 -E_NO_MEM。 - if (ptep == NULL) { -c0104095: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0104099: 75 0a jne c01040a5 - return -E_NO_MEM; -c010409b: b8 fc ff ff ff mov $0xfffffffc,%eax -c01040a0: e9 84 00 00 00 jmp c0104129 - } - //调用 page_ref_inc 增加页面的引用计数。 - page_ref_inc(page); -c01040a5: 8b 45 0c mov 0xc(%ebp),%eax -c01040a8: 89 04 24 mov %eax,(%esp) -c01040ab: e8 ab f4 ff ff call c010355b - //如果页表项已存在且指向当前页面,则减少页面引用计数。 - if (*ptep & PTE_P) { -c01040b0: 8b 45 f4 mov -0xc(%ebp),%eax -c01040b3: 8b 00 mov (%eax),%eax -c01040b5: 83 e0 01 and $0x1,%eax -c01040b8: 85 c0 test %eax,%eax -c01040ba: 74 3e je c01040fa - struct Page *p = pte2page(*ptep); -c01040bc: 8b 45 f4 mov -0xc(%ebp),%eax -c01040bf: 8b 00 mov (%eax),%eax -c01040c1: 89 04 24 mov %eax,(%esp) -c01040c4: e8 24 f4 ff ff call c01034ed -c01040c9: 89 45 f0 mov %eax,-0x10(%ebp) - if (p == page) { -c01040cc: 8b 45 f0 mov -0x10(%ebp),%eax -c01040cf: 3b 45 0c cmp 0xc(%ebp),%eax -c01040d2: 75 0d jne c01040e1 - page_ref_dec(page); -c01040d4: 8b 45 0c mov 0xc(%ebp),%eax -c01040d7: 89 04 24 mov %eax,(%esp) -c01040da: e8 93 f4 ff ff call c0103572 -c01040df: eb 19 jmp c01040fa - } - //如果页表项已存在但指向其他页面,则调用 page_remove_pte 移除旧的页表项。 - else { - page_remove_pte(pgdir, la, ptep); -c01040e1: 8b 45 f4 mov -0xc(%ebp),%eax -c01040e4: 89 44 24 08 mov %eax,0x8(%esp) -c01040e8: 8b 45 10 mov 0x10(%ebp),%eax -c01040eb: 89 44 24 04 mov %eax,0x4(%esp) -c01040ef: 8b 45 08 mov 0x8(%ebp),%eax -c01040f2: 89 04 24 mov %eax,(%esp) -c01040f5: e8 c9 fe ff ff call c0103fc3 - } - } - *ptep = page2pa(page) | PTE_P | perm; -c01040fa: 8b 45 0c mov 0xc(%ebp),%eax -c01040fd: 89 04 24 mov %eax,(%esp) -c0104100: e8 39 f3 ff ff call c010343e -c0104105: 0b 45 14 or 0x14(%ebp),%eax -c0104108: 83 c8 01 or $0x1,%eax -c010410b: 89 c2 mov %eax,%edx -c010410d: 8b 45 f4 mov -0xc(%ebp),%eax -c0104110: 89 10 mov %edx,(%eax) - tlb_invalidate(pgdir, la);//刷新 TLB -c0104112: 8b 45 10 mov 0x10(%ebp),%eax -c0104115: 89 44 24 04 mov %eax,0x4(%esp) -c0104119: 8b 45 08 mov 0x8(%ebp),%eax -c010411c: 89 04 24 mov %eax,(%esp) -c010411f: e8 07 00 00 00 call c010412b - return 0; -c0104124: b8 00 00 00 00 mov $0x0,%eax -} -c0104129: c9 leave -c010412a: c3 ret - -c010412b : - -// invalidate a TLB entry, but only if the page tables being -// edited are the ones currently in use by the processor. -//无效化指定地址的TLB条目 -void -tlb_invalidate(pde_t *pgdir, uintptr_t la) { -c010412b: f3 0f 1e fb endbr32 -c010412f: 55 push %ebp -c0104130: 89 e5 mov %esp,%ebp -c0104132: 83 ec 28 sub $0x28,%esp -} - -static inline uintptr_t -rcr3(void) { - uintptr_t cr3; - asm volatile ("mov %%cr3, %0" : "=r" (cr3) :: "memory"); -c0104135: 0f 20 d8 mov %cr3,%eax -c0104138: 89 45 f0 mov %eax,-0x10(%ebp) - return cr3; -c010413b: 8b 55 f0 mov -0x10(%ebp),%edx - //检查当前页目录地址是否与传入的页目录地址相同。 - if (rcr3() == PADDR(pgdir)) { -c010413e: 8b 45 08 mov 0x8(%ebp),%eax -c0104141: 89 45 f4 mov %eax,-0xc(%ebp) -c0104144: 81 7d f4 ff ff ff bf cmpl $0xbfffffff,-0xc(%ebp) -c010414b: 77 23 ja c0104170 -c010414d: 8b 45 f4 mov -0xc(%ebp),%eax -c0104150: 89 44 24 0c mov %eax,0xc(%esp) -c0104154: c7 44 24 08 64 ac 10 movl $0xc010ac64,0x8(%esp) -c010415b: c0 -c010415c: c7 44 24 04 56 02 00 movl $0x256,0x4(%esp) -c0104163: 00 -c0104164: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c010416b: e8 d3 c2 ff ff call c0100443 <__panic> -c0104170: 8b 45 f4 mov -0xc(%ebp),%eax -c0104173: 05 00 00 00 40 add $0x40000000,%eax -c0104178: 39 d0 cmp %edx,%eax -c010417a: 75 0d jne c0104189 - //如果相同,则调用 invlpg 函数无效化指定线性地址的TLB条目。 - invlpg((void *)la); -c010417c: 8b 45 0c mov 0xc(%ebp),%eax -c010417f: 89 45 ec mov %eax,-0x14(%ebp) -} - -static inline void -invlpg(void *addr) { - asm volatile ("invlpg (%0)" :: "r" (addr) : "memory"); -c0104182: 8b 45 ec mov -0x14(%ebp),%eax -c0104185: 0f 01 38 invlpg (%eax) -} -c0104188: 90 nop - } -} -c0104189: 90 nop -c010418a: c9 leave -c010418b: c3 ret - -c010418c : -// pgdir_alloc_page - call alloc_page & page_insert functions to -// - allocate a page size memory & setup an addr map -// - pa<->la with linear address la and the PDT pgdir -//参数包括页目录指针 pgdir、线性地址 la 和权限 perm。 -struct Page * -pgdir_alloc_page(pde_t *pgdir, uintptr_t la, uint32_t perm) { -c010418c: f3 0f 1e fb endbr32 -c0104190: 55 push %ebp -c0104191: 89 e5 mov %esp,%ebp -c0104193: 83 ec 28 sub $0x28,%esp - struct Page *page = alloc_page();//分配一个新的页面存储在 page 指针中 -c0104196: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c010419d: e8 b7 f5 ff ff call c0103759 -c01041a2: 89 45 f4 mov %eax,-0xc(%ebp) - if (page != NULL) {//检查 page 是否不为 NULL,即分配是否成功。 -c01041a5: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c01041a9: 0f 84 a7 00 00 00 je c0104256 - if (page_insert(pgdir, page, la, perm) != 0) {//将页面插入到指定的线性地址 la 处。 -c01041af: 8b 45 10 mov 0x10(%ebp),%eax -c01041b2: 89 44 24 0c mov %eax,0xc(%esp) -c01041b6: 8b 45 0c mov 0xc(%ebp),%eax -c01041b9: 89 44 24 08 mov %eax,0x8(%esp) -c01041bd: 8b 45 f4 mov -0xc(%ebp),%eax -c01041c0: 89 44 24 04 mov %eax,0x4(%esp) -c01041c4: 8b 45 08 mov 0x8(%ebp),%eax -c01041c7: 89 04 24 mov %eax,(%esp) -c01041ca: e8 9f fe ff ff call c010406e -c01041cf: 85 c0 test %eax,%eax -c01041d1: 74 1a je c01041ed - free_page(page);//释放分配的页面。 -c01041d3: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c01041da: 00 -c01041db: 8b 45 f4 mov -0xc(%ebp),%eax -c01041de: 89 04 24 mov %eax,(%esp) -c01041e1: e8 e2 f5 ff ff call c01037c8 - return NULL;//返回 NULL,表示页面插入失败。 -c01041e6: b8 00 00 00 00 mov $0x0,%eax -c01041eb: eb 6c jmp c0104259 - } - if (swap_init_ok){//检查交换区是否已初始化成功 -c01041ed: a1 14 c0 12 c0 mov 0xc012c014,%eax -c01041f2: 85 c0 test %eax,%eax -c01041f4: 74 60 je c0104256 - //将页面映射到交换区。 - swap_map_swappable(check_mm_struct, la, page, 0); -c01041f6: a1 c4 e0 12 c0 mov 0xc012e0c4,%eax -c01041fb: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) -c0104202: 00 -c0104203: 8b 55 f4 mov -0xc(%ebp),%edx -c0104206: 89 54 24 08 mov %edx,0x8(%esp) -c010420a: 8b 55 0c mov 0xc(%ebp),%edx -c010420d: 89 54 24 04 mov %edx,0x4(%esp) -c0104211: 89 04 24 mov %eax,(%esp) -c0104214: e8 d0 28 00 00 call c0106ae9 - //设置页面的虚拟地址 pra_vaddr 为 la - page->pra_vaddr=la; -c0104219: 8b 45 f4 mov -0xc(%ebp),%eax -c010421c: 8b 55 0c mov 0xc(%ebp),%edx -c010421f: 89 50 1c mov %edx,0x1c(%eax) - //断言页面的引用计数为1,确保页面没有被其他地方引用。 - assert(page_ref(page) == 1); -c0104222: 8b 45 f4 mov -0xc(%ebp),%eax -c0104225: 89 04 24 mov %eax,(%esp) -c0104228: e8 16 f3 ff ff call c0103543 -c010422d: 83 f8 01 cmp $0x1,%eax -c0104230: 74 24 je c0104256 -c0104232: c7 44 24 0c e8 ac 10 movl $0xc010ace8,0xc(%esp) -c0104239: c0 -c010423a: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104241: c0 -c0104242: c7 44 24 04 6e 02 00 movl $0x26e,0x4(%esp) -c0104249: 00 -c010424a: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104251: e8 ed c1 ff ff call c0100443 <__panic> - //cprintf("get No. %d page: pra_vaddr %x, pra_link.prev %x, pra_link_next %x in pgdir_alloc_page\n", (page-pages), page->pra_vaddr,page->pra_page_link.prev, page->pra_page_link.next); - } - - } - - return page; -c0104256: 8b 45 f4 mov -0xc(%ebp),%eax -} -c0104259: c9 leave -c010425a: c3 ret - -c010425b : - -static void -check_alloc_page(void) { -c010425b: f3 0f 1e fb endbr32 -c010425f: 55 push %ebp -c0104260: 89 e5 mov %esp,%ebp -c0104262: 83 ec 18 sub $0x18,%esp - //调用内存管理器的 check 方法,用于检查内存分配是否正常。 - pmm_manager->check(); -c0104265: a1 b0 e0 12 c0 mov 0xc012e0b0,%eax -c010426a: 8b 40 18 mov 0x18(%eax),%eax -c010426d: ff d0 call *%eax - cprintf("check_alloc_page() succeeded!\n"); -c010426f: c7 04 24 fc ac 10 c0 movl $0xc010acfc,(%esp) -c0104276: e8 5c c0 ff ff call c01002d7 -} -c010427b: 90 nop -c010427c: c9 leave -c010427d: c3 ret - -c010427e : - -//用于验证页目录和页表的正确性。 -static void -check_pgdir(void) { -c010427e: f3 0f 1e fb endbr32 -c0104282: 55 push %ebp -c0104283: 89 e5 mov %esp,%ebp -c0104285: 83 ec 38 sub $0x38,%esp - //确保内存页面数量在合理范围内 - assert(npage <= KMEMSIZE / PGSIZE); -c0104288: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c010428d: 3d 00 80 03 00 cmp $0x38000,%eax -c0104292: 76 24 jbe c01042b8 -c0104294: c7 44 24 0c 1b ad 10 movl $0xc010ad1b,0xc(%esp) -c010429b: c0 -c010429c: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01042a3: c0 -c01042a4: c7 44 24 04 82 02 00 movl $0x282,0x4(%esp) -c01042ab: 00 -c01042ac: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01042b3: e8 8b c1 ff ff call c0100443 <__panic> - //确保页目录不为空且对齐, - assert(boot_pgdir != NULL && (uint32_t)PGOFF(boot_pgdir) == 0); -c01042b8: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c01042bd: 85 c0 test %eax,%eax -c01042bf: 74 0e je c01042cf -c01042c1: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c01042c6: 25 ff 0f 00 00 and $0xfff,%eax -c01042cb: 85 c0 test %eax,%eax -c01042cd: 74 24 je c01042f3 -c01042cf: c7 44 24 0c 38 ad 10 movl $0xc010ad38,0xc(%esp) -c01042d6: c0 -c01042d7: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01042de: c0 -c01042df: c7 44 24 04 84 02 00 movl $0x284,0x4(%esp) -c01042e6: 00 -c01042e7: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01042ee: e8 50 c1 ff ff call c0100443 <__panic> - //确保虚拟地址 0x0 没有映射任何页面 - assert(get_page(boot_pgdir, 0x0, NULL) == NULL); -c01042f3: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c01042f8: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c01042ff: 00 -c0104300: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0104307: 00 -c0104308: 89 04 24 mov %eax,(%esp) -c010430b: e8 56 fc ff ff call c0103f66 -c0104310: 85 c0 test %eax,%eax -c0104312: 74 24 je c0104338 -c0104314: c7 44 24 0c 70 ad 10 movl $0xc010ad70,0xc(%esp) -c010431b: c0 -c010431c: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104323: c0 -c0104324: c7 44 24 04 86 02 00 movl $0x286,0x4(%esp) -c010432b: 00 -c010432c: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104333: e8 0b c1 ff ff call c0100443 <__panic> - - //定义两个页面指针 p1 和 p2 - struct Page *p1, *p2; - //分配一个页面 p1 - p1 = alloc_page(); -c0104338: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c010433f: e8 15 f4 ff ff call c0103759 -c0104344: 89 45 f4 mov %eax,-0xc(%ebp) - //将 p1 插入到虚拟地址 0x0 - assert(page_insert(boot_pgdir, p1, 0x0, 0) == 0); -c0104347: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c010434c: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) -c0104353: 00 -c0104354: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c010435b: 00 -c010435c: 8b 55 f4 mov -0xc(%ebp),%edx -c010435f: 89 54 24 04 mov %edx,0x4(%esp) -c0104363: 89 04 24 mov %eax,(%esp) -c0104366: e8 03 fd ff ff call c010406e -c010436b: 85 c0 test %eax,%eax -c010436d: 74 24 je c0104393 -c010436f: c7 44 24 0c 98 ad 10 movl $0xc010ad98,0xc(%esp) -c0104376: c0 -c0104377: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c010437e: c0 -c010437f: c7 44 24 04 8d 02 00 movl $0x28d,0x4(%esp) -c0104386: 00 -c0104387: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c010438e: e8 b0 c0 ff ff call c0100443 <__panic> - - // 获取虚拟地址 0x0 对应的页表项指针 - pte_t *ptep; - assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); -c0104393: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0104398: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c010439f: 00 -c01043a0: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c01043a7: 00 -c01043a8: 89 04 24 mov %eax,(%esp) -c01043ab: e8 79 fa ff ff call c0103e29 -c01043b0: 89 45 f0 mov %eax,-0x10(%ebp) -c01043b3: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c01043b7: 75 24 jne c01043dd -c01043b9: c7 44 24 0c c4 ad 10 movl $0xc010adc4,0xc(%esp) -c01043c0: c0 -c01043c1: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01043c8: c0 -c01043c9: c7 44 24 04 91 02 00 movl $0x291,0x4(%esp) -c01043d0: 00 -c01043d1: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01043d8: e8 66 c0 ff ff call c0100443 <__panic> - // 验证页表项对应的页面是 p1 - assert(pte2page(*ptep) == p1); -c01043dd: 8b 45 f0 mov -0x10(%ebp),%eax -c01043e0: 8b 00 mov (%eax),%eax -c01043e2: 89 04 24 mov %eax,(%esp) -c01043e5: e8 03 f1 ff ff call c01034ed -c01043ea: 39 45 f4 cmp %eax,-0xc(%ebp) -c01043ed: 74 24 je c0104413 -c01043ef: c7 44 24 0c f1 ad 10 movl $0xc010adf1,0xc(%esp) -c01043f6: c0 -c01043f7: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01043fe: c0 -c01043ff: c7 44 24 04 93 02 00 movl $0x293,0x4(%esp) -c0104406: 00 -c0104407: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c010440e: e8 30 c0 ff ff call c0100443 <__panic> - // 验证 p1 的引用计数为 1 - assert(page_ref(p1) == 1); -c0104413: 8b 45 f4 mov -0xc(%ebp),%eax -c0104416: 89 04 24 mov %eax,(%esp) -c0104419: e8 25 f1 ff ff call c0103543 -c010441e: 83 f8 01 cmp $0x1,%eax -c0104421: 74 24 je c0104447 -c0104423: c7 44 24 0c 07 ae 10 movl $0xc010ae07,0xc(%esp) -c010442a: c0 -c010442b: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104432: c0 -c0104433: c7 44 24 04 95 02 00 movl $0x295,0x4(%esp) -c010443a: 00 -c010443b: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104442: e8 fc bf ff ff call c0100443 <__panic> - // 获取虚拟地址 PGSIZE 对应的页表项指针 - ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; -c0104447: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c010444c: 8b 00 mov (%eax),%eax -c010444e: 25 00 f0 ff ff and $0xfffff000,%eax -c0104453: 89 45 ec mov %eax,-0x14(%ebp) -c0104456: 8b 45 ec mov -0x14(%ebp),%eax -c0104459: c1 e8 0c shr $0xc,%eax -c010445c: 89 45 e8 mov %eax,-0x18(%ebp) -c010445f: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0104464: 39 45 e8 cmp %eax,-0x18(%ebp) -c0104467: 72 23 jb c010448c -c0104469: 8b 45 ec mov -0x14(%ebp),%eax -c010446c: 89 44 24 0c mov %eax,0xc(%esp) -c0104470: c7 44 24 08 c0 ab 10 movl $0xc010abc0,0x8(%esp) -c0104477: c0 -c0104478: c7 44 24 04 97 02 00 movl $0x297,0x4(%esp) -c010447f: 00 -c0104480: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104487: e8 b7 bf ff ff call c0100443 <__panic> -c010448c: 8b 45 ec mov -0x14(%ebp),%eax -c010448f: 2d 00 00 00 40 sub $0x40000000,%eax -c0104494: 83 c0 04 add $0x4,%eax -c0104497: 89 45 f0 mov %eax,-0x10(%ebp) - assert(get_pte(boot_pgdir, PGSIZE, 0) == ptep); -c010449a: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c010449f: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c01044a6: 00 -c01044a7: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) -c01044ae: 00 -c01044af: 89 04 24 mov %eax,(%esp) -c01044b2: e8 72 f9 ff ff call c0103e29 -c01044b7: 39 45 f0 cmp %eax,-0x10(%ebp) -c01044ba: 74 24 je c01044e0 -c01044bc: c7 44 24 0c 1c ae 10 movl $0xc010ae1c,0xc(%esp) -c01044c3: c0 -c01044c4: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01044cb: c0 -c01044cc: c7 44 24 04 98 02 00 movl $0x298,0x4(%esp) -c01044d3: 00 -c01044d4: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01044db: e8 63 bf ff ff call c0100443 <__panic> - // 分配一个页面 p2 - p2 = alloc_page(); -c01044e0: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c01044e7: e8 6d f2 ff ff call c0103759 -c01044ec: 89 45 e4 mov %eax,-0x1c(%ebp) - // 将 p2 插入到虚拟地址 PGSIZE,并设置用户和写权限 - assert(page_insert(boot_pgdir, p2, PGSIZE, PTE_U | PTE_W) == 0); -c01044ef: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c01044f4: c7 44 24 0c 06 00 00 movl $0x6,0xc(%esp) -c01044fb: 00 -c01044fc: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) -c0104503: 00 -c0104504: 8b 55 e4 mov -0x1c(%ebp),%edx -c0104507: 89 54 24 04 mov %edx,0x4(%esp) -c010450b: 89 04 24 mov %eax,(%esp) -c010450e: e8 5b fb ff ff call c010406e -c0104513: 85 c0 test %eax,%eax -c0104515: 74 24 je c010453b -c0104517: c7 44 24 0c 44 ae 10 movl $0xc010ae44,0xc(%esp) -c010451e: c0 -c010451f: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104526: c0 -c0104527: c7 44 24 04 9c 02 00 movl $0x29c,0x4(%esp) -c010452e: 00 -c010452f: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104536: e8 08 bf ff ff call c0100443 <__panic> - // 获取虚拟地址 PGSIZE 对应的页表项指针 - assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); -c010453b: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0104540: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c0104547: 00 -c0104548: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) -c010454f: 00 -c0104550: 89 04 24 mov %eax,(%esp) -c0104553: e8 d1 f8 ff ff call c0103e29 -c0104558: 89 45 f0 mov %eax,-0x10(%ebp) -c010455b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c010455f: 75 24 jne c0104585 -c0104561: c7 44 24 0c 7c ae 10 movl $0xc010ae7c,0xc(%esp) -c0104568: c0 -c0104569: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104570: c0 -c0104571: c7 44 24 04 9e 02 00 movl $0x29e,0x4(%esp) -c0104578: 00 -c0104579: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104580: e8 be be ff ff call c0100443 <__panic> - // 验证页表项设置了用户权限 - assert(*ptep & PTE_U); -c0104585: 8b 45 f0 mov -0x10(%ebp),%eax -c0104588: 8b 00 mov (%eax),%eax -c010458a: 83 e0 04 and $0x4,%eax -c010458d: 85 c0 test %eax,%eax -c010458f: 75 24 jne c01045b5 -c0104591: c7 44 24 0c ac ae 10 movl $0xc010aeac,0xc(%esp) -c0104598: c0 -c0104599: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01045a0: c0 -c01045a1: c7 44 24 04 a0 02 00 movl $0x2a0,0x4(%esp) -c01045a8: 00 -c01045a9: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01045b0: e8 8e be ff ff call c0100443 <__panic> - // 验证页表项设置了写权限 - assert(*ptep & PTE_W); -c01045b5: 8b 45 f0 mov -0x10(%ebp),%eax -c01045b8: 8b 00 mov (%eax),%eax -c01045ba: 83 e0 02 and $0x2,%eax -c01045bd: 85 c0 test %eax,%eax -c01045bf: 75 24 jne c01045e5 -c01045c1: c7 44 24 0c ba ae 10 movl $0xc010aeba,0xc(%esp) -c01045c8: c0 -c01045c9: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01045d0: c0 -c01045d1: c7 44 24 04 a2 02 00 movl $0x2a2,0x4(%esp) -c01045d8: 00 -c01045d9: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01045e0: e8 5e be ff ff call c0100443 <__panic> - // 验证页目录项设置了用户权限 - assert(boot_pgdir[0] & PTE_U); -c01045e5: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c01045ea: 8b 00 mov (%eax),%eax -c01045ec: 83 e0 04 and $0x4,%eax -c01045ef: 85 c0 test %eax,%eax -c01045f1: 75 24 jne c0104617 -c01045f3: c7 44 24 0c c8 ae 10 movl $0xc010aec8,0xc(%esp) -c01045fa: c0 -c01045fb: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104602: c0 -c0104603: c7 44 24 04 a4 02 00 movl $0x2a4,0x4(%esp) -c010460a: 00 -c010460b: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104612: e8 2c be ff ff call c0100443 <__panic> - // 验证 p2 的引用计数为 1 - assert(page_ref(p2) == 1); -c0104617: 8b 45 e4 mov -0x1c(%ebp),%eax -c010461a: 89 04 24 mov %eax,(%esp) -c010461d: e8 21 ef ff ff call c0103543 -c0104622: 83 f8 01 cmp $0x1,%eax -c0104625: 74 24 je c010464b -c0104627: c7 44 24 0c de ae 10 movl $0xc010aede,0xc(%esp) -c010462e: c0 -c010462f: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104636: c0 -c0104637: c7 44 24 04 a6 02 00 movl $0x2a6,0x4(%esp) -c010463e: 00 -c010463f: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104646: e8 f8 bd ff ff call c0100443 <__panic> - - // 将 p1 插入到虚拟地址 PGSIZE,替换掉 p2 - assert(page_insert(boot_pgdir, p1, PGSIZE, 0) == 0); -c010464b: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0104650: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) -c0104657: 00 -c0104658: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) -c010465f: 00 -c0104660: 8b 55 f4 mov -0xc(%ebp),%edx -c0104663: 89 54 24 04 mov %edx,0x4(%esp) -c0104667: 89 04 24 mov %eax,(%esp) -c010466a: e8 ff f9 ff ff call c010406e -c010466f: 85 c0 test %eax,%eax -c0104671: 74 24 je c0104697 -c0104673: c7 44 24 0c f0 ae 10 movl $0xc010aef0,0xc(%esp) -c010467a: c0 -c010467b: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104682: c0 -c0104683: c7 44 24 04 a9 02 00 movl $0x2a9,0x4(%esp) -c010468a: 00 -c010468b: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104692: e8 ac bd ff ff call c0100443 <__panic> - // 验证 p1 的引用计数增加到 2 - assert(page_ref(p1) == 2); -c0104697: 8b 45 f4 mov -0xc(%ebp),%eax -c010469a: 89 04 24 mov %eax,(%esp) -c010469d: e8 a1 ee ff ff call c0103543 -c01046a2: 83 f8 02 cmp $0x2,%eax -c01046a5: 74 24 je c01046cb -c01046a7: c7 44 24 0c 1c af 10 movl $0xc010af1c,0xc(%esp) -c01046ae: c0 -c01046af: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01046b6: c0 -c01046b7: c7 44 24 04 ab 02 00 movl $0x2ab,0x4(%esp) -c01046be: 00 -c01046bf: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01046c6: e8 78 bd ff ff call c0100443 <__panic> - // 验证 p2 的引用计数减少到 0 - assert(page_ref(p2) == 0); -c01046cb: 8b 45 e4 mov -0x1c(%ebp),%eax -c01046ce: 89 04 24 mov %eax,(%esp) -c01046d1: e8 6d ee ff ff call c0103543 -c01046d6: 85 c0 test %eax,%eax -c01046d8: 74 24 je c01046fe -c01046da: c7 44 24 0c 2e af 10 movl $0xc010af2e,0xc(%esp) -c01046e1: c0 -c01046e2: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01046e9: c0 -c01046ea: c7 44 24 04 ad 02 00 movl $0x2ad,0x4(%esp) -c01046f1: 00 -c01046f2: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01046f9: e8 45 bd ff ff call c0100443 <__panic> - // 获取虚拟地址 PGSIZE 对应的页表项指针 - assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); -c01046fe: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0104703: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c010470a: 00 -c010470b: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) -c0104712: 00 -c0104713: 89 04 24 mov %eax,(%esp) -c0104716: e8 0e f7 ff ff call c0103e29 -c010471b: 89 45 f0 mov %eax,-0x10(%ebp) -c010471e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c0104722: 75 24 jne c0104748 -c0104724: c7 44 24 0c 7c ae 10 movl $0xc010ae7c,0xc(%esp) -c010472b: c0 -c010472c: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104733: c0 -c0104734: c7 44 24 04 af 02 00 movl $0x2af,0x4(%esp) -c010473b: 00 -c010473c: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104743: e8 fb bc ff ff call c0100443 <__panic> - // 验证页表项对应的页面是 p1 - assert(pte2page(*ptep) == p1); -c0104748: 8b 45 f0 mov -0x10(%ebp),%eax -c010474b: 8b 00 mov (%eax),%eax -c010474d: 89 04 24 mov %eax,(%esp) -c0104750: e8 98 ed ff ff call c01034ed -c0104755: 39 45 f4 cmp %eax,-0xc(%ebp) -c0104758: 74 24 je c010477e -c010475a: c7 44 24 0c f1 ad 10 movl $0xc010adf1,0xc(%esp) -c0104761: c0 -c0104762: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104769: c0 -c010476a: c7 44 24 04 b1 02 00 movl $0x2b1,0x4(%esp) -c0104771: 00 -c0104772: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104779: e8 c5 bc ff ff call c0100443 <__panic> - // 验证页表项没有设置用户权限 - assert((*ptep & PTE_U) == 0); -c010477e: 8b 45 f0 mov -0x10(%ebp),%eax -c0104781: 8b 00 mov (%eax),%eax -c0104783: 83 e0 04 and $0x4,%eax -c0104786: 85 c0 test %eax,%eax -c0104788: 74 24 je c01047ae -c010478a: c7 44 24 0c 40 af 10 movl $0xc010af40,0xc(%esp) -c0104791: c0 -c0104792: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104799: c0 -c010479a: c7 44 24 04 b3 02 00 movl $0x2b3,0x4(%esp) -c01047a1: 00 -c01047a2: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01047a9: e8 95 bc ff ff call c0100443 <__panic> - - //移除虚拟地址 0x0 的映射, - page_remove(boot_pgdir, 0x0); -c01047ae: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c01047b3: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c01047ba: 00 -c01047bb: 89 04 24 mov %eax,(%esp) -c01047be: e8 62 f8 ff ff call c0104025 - //验证 p1 的引用计数减少到 1。 - assert(page_ref(p1) == 1); -c01047c3: 8b 45 f4 mov -0xc(%ebp),%eax -c01047c6: 89 04 24 mov %eax,(%esp) -c01047c9: e8 75 ed ff ff call c0103543 -c01047ce: 83 f8 01 cmp $0x1,%eax -c01047d1: 74 24 je c01047f7 -c01047d3: c7 44 24 0c 07 ae 10 movl $0xc010ae07,0xc(%esp) -c01047da: c0 -c01047db: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01047e2: c0 -c01047e3: c7 44 24 04 b8 02 00 movl $0x2b8,0x4(%esp) -c01047ea: 00 -c01047eb: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01047f2: e8 4c bc ff ff call c0100443 <__panic> - //验证 p2 的引用计数减少到 0 - assert(page_ref(p2) == 0); -c01047f7: 8b 45 e4 mov -0x1c(%ebp),%eax -c01047fa: 89 04 24 mov %eax,(%esp) -c01047fd: e8 41 ed ff ff call c0103543 -c0104802: 85 c0 test %eax,%eax -c0104804: 74 24 je c010482a -c0104806: c7 44 24 0c 2e af 10 movl $0xc010af2e,0xc(%esp) -c010480d: c0 -c010480e: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104815: c0 -c0104816: c7 44 24 04 ba 02 00 movl $0x2ba,0x4(%esp) -c010481d: 00 -c010481e: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104825: e8 19 bc ff ff call c0100443 <__panic> - - //移除虚拟地址 PGSIZE 的映射, - page_remove(boot_pgdir, PGSIZE); -c010482a: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c010482f: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) -c0104836: 00 -c0104837: 89 04 24 mov %eax,(%esp) -c010483a: e8 e6 f7 ff ff call c0104025 - //验证 p1 的引用计数减少到 0 - assert(page_ref(p1) == 0); -c010483f: 8b 45 f4 mov -0xc(%ebp),%eax -c0104842: 89 04 24 mov %eax,(%esp) -c0104845: e8 f9 ec ff ff call c0103543 -c010484a: 85 c0 test %eax,%eax -c010484c: 74 24 je c0104872 -c010484e: c7 44 24 0c 55 af 10 movl $0xc010af55,0xc(%esp) -c0104855: c0 -c0104856: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c010485d: c0 -c010485e: c7 44 24 04 bf 02 00 movl $0x2bf,0x4(%esp) -c0104865: 00 -c0104866: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c010486d: e8 d1 bb ff ff call c0100443 <__panic> - //验证 p2 的引用计数减少到 0 - assert(page_ref(p2) == 0); -c0104872: 8b 45 e4 mov -0x1c(%ebp),%eax -c0104875: 89 04 24 mov %eax,(%esp) -c0104878: e8 c6 ec ff ff call c0103543 -c010487d: 85 c0 test %eax,%eax -c010487f: 74 24 je c01048a5 -c0104881: c7 44 24 0c 2e af 10 movl $0xc010af2e,0xc(%esp) -c0104888: c0 -c0104889: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104890: c0 -c0104891: c7 44 24 04 c1 02 00 movl $0x2c1,0x4(%esp) -c0104898: 00 -c0104899: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01048a0: e8 9e bb ff ff call c0100443 <__panic> - - //验证页目录的第一页表的引用计数为 1。 - assert(page_ref(pde2page(boot_pgdir[0])) == 1); -c01048a5: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c01048aa: 8b 00 mov (%eax),%eax -c01048ac: 89 04 24 mov %eax,(%esp) -c01048af: e8 77 ec ff ff call c010352b -c01048b4: 89 04 24 mov %eax,(%esp) -c01048b7: e8 87 ec ff ff call c0103543 -c01048bc: 83 f8 01 cmp $0x1,%eax -c01048bf: 74 24 je c01048e5 -c01048c1: c7 44 24 0c 68 af 10 movl $0xc010af68,0xc(%esp) -c01048c8: c0 -c01048c9: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01048d0: c0 -c01048d1: c7 44 24 04 c4 02 00 movl $0x2c4,0x4(%esp) -c01048d8: 00 -c01048d9: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01048e0: e8 5e bb ff ff call c0100443 <__panic> - //释放页目录的第一页表 - free_page(pde2page(boot_pgdir[0])); -c01048e5: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c01048ea: 8b 00 mov (%eax),%eax -c01048ec: 89 04 24 mov %eax,(%esp) -c01048ef: e8 37 ec ff ff call c010352b -c01048f4: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c01048fb: 00 -c01048fc: 89 04 24 mov %eax,(%esp) -c01048ff: e8 c4 ee ff ff call c01037c8 - //清空页目录的第一页表 - boot_pgdir[0] = 0; -c0104904: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0104909: c7 00 00 00 00 00 movl $0x0,(%eax) +c0103995 : - cprintf("check_pgdir() succeeded!\n"); -c010490f: c7 04 24 8f af 10 c0 movl $0xc010af8f,(%esp) -c0104916: e8 bc b9 ff ff call c01002d7 +//用于返回当前系统中可用的空闲页的数量。 +static size_t +default_nr_free_pages(void) { +c0103995: 55 push %ebp +c0103996: 89 e5 mov %esp,%ebp + return nr_free;// 返回当前空闲页的数量 +c0103998: a1 ec bf 12 c0 mov 0xc012bfec,%eax } -c010491b: 90 nop -c010491c: c9 leave -c010491d: c3 ret +c010399d: 5d pop %ebp +c010399e: c3 ret -c010491e : +c010399f : -//检查内核页表 boot_pgdir 的正确性 +//basic_check 函数用于测试内存分配和释放的基本功能, +//确保在不同情况下内存管理系统的正确性,包括分配、释放、合并和引用计数等操作。 static void -check_boot_pgdir(void) { -c010491e: f3 0f 1e fb endbr32 -c0104922: 55 push %ebp -c0104923: 89 e5 mov %esp,%ebp -c0104925: 83 ec 38 sub $0x38,%esp - pte_t *ptep;// 定义一个指向页表项的指针 - int i; - for (i = 0; i < npage; i += PGSIZE) {// 遍历所有页面 -c0104928: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -c010492f: e9 ca 00 00 00 jmp c01049fe - // 获取第 i 个页面的页表项,并确保其不为空 - assert((ptep = get_pte(boot_pgdir, (uintptr_t)KADDR(i), 0)) != NULL); -c0104934: 8b 45 f4 mov -0xc(%ebp),%eax -c0104937: 89 45 e4 mov %eax,-0x1c(%ebp) -c010493a: 8b 45 e4 mov -0x1c(%ebp),%eax -c010493d: c1 e8 0c shr $0xc,%eax -c0104940: 89 45 e0 mov %eax,-0x20(%ebp) -c0104943: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0104948: 39 45 e0 cmp %eax,-0x20(%ebp) -c010494b: 72 23 jb c0104970 -c010494d: 8b 45 e4 mov -0x1c(%ebp),%eax -c0104950: 89 44 24 0c mov %eax,0xc(%esp) -c0104954: c7 44 24 08 c0 ab 10 movl $0xc010abc0,0x8(%esp) -c010495b: c0 -c010495c: c7 44 24 04 d4 02 00 movl $0x2d4,0x4(%esp) -c0104963: 00 -c0104964: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c010496b: e8 d3 ba ff ff call c0100443 <__panic> -c0104970: 8b 45 e4 mov -0x1c(%ebp),%eax -c0104973: 2d 00 00 00 40 sub $0x40000000,%eax -c0104978: 89 c2 mov %eax,%edx -c010497a: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c010497f: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c0104986: 00 -c0104987: 89 54 24 04 mov %edx,0x4(%esp) -c010498b: 89 04 24 mov %eax,(%esp) -c010498e: e8 96 f4 ff ff call c0103e29 -c0104993: 89 45 dc mov %eax,-0x24(%ebp) -c0104996: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) -c010499a: 75 24 jne c01049c0 -c010499c: c7 44 24 0c ac af 10 movl $0xc010afac,0xc(%esp) -c01049a3: c0 -c01049a4: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01049ab: c0 -c01049ac: c7 44 24 04 d4 02 00 movl $0x2d4,0x4(%esp) -c01049b3: 00 -c01049b4: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01049bb: e8 83 ba ff ff call c0100443 <__panic> - // 验证页表项的物理地址是否正确 - assert(PTE_ADDR(*ptep) == i); -c01049c0: 8b 45 dc mov -0x24(%ebp),%eax -c01049c3: 8b 00 mov (%eax),%eax -c01049c5: 25 00 f0 ff ff and $0xfffff000,%eax -c01049ca: 89 c2 mov %eax,%edx -c01049cc: 8b 45 f4 mov -0xc(%ebp),%eax -c01049cf: 39 c2 cmp %eax,%edx -c01049d1: 74 24 je c01049f7 -c01049d3: c7 44 24 0c e9 af 10 movl $0xc010afe9,0xc(%esp) -c01049da: c0 -c01049db: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c01049e2: c0 -c01049e3: c7 44 24 04 d6 02 00 movl $0x2d6,0x4(%esp) -c01049ea: 00 -c01049eb: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c01049f2: e8 4c ba ff ff call c0100443 <__panic> - for (i = 0; i < npage; i += PGSIZE) {// 遍历所有页面 -c01049f7: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp) -c01049fe: 8b 55 f4 mov -0xc(%ebp),%edx -c0104a01: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0104a06: 39 c2 cmp %eax,%edx -c0104a08: 0f 82 26 ff ff ff jb c0104934 - } - // 验证页目录项的物理地址是否正确 - assert(PDE_ADDR(boot_pgdir[PDX(VPT)]) == PADDR(boot_pgdir)); -c0104a0e: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0104a13: 05 ac 0f 00 00 add $0xfac,%eax -c0104a18: 8b 00 mov (%eax),%eax -c0104a1a: 25 00 f0 ff ff and $0xfffff000,%eax -c0104a1f: 89 c2 mov %eax,%edx -c0104a21: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0104a26: 89 45 f0 mov %eax,-0x10(%ebp) -c0104a29: 81 7d f0 ff ff ff bf cmpl $0xbfffffff,-0x10(%ebp) -c0104a30: 77 23 ja c0104a55 -c0104a32: 8b 45 f0 mov -0x10(%ebp),%eax -c0104a35: 89 44 24 0c mov %eax,0xc(%esp) -c0104a39: c7 44 24 08 64 ac 10 movl $0xc010ac64,0x8(%esp) -c0104a40: c0 -c0104a41: c7 44 24 04 d9 02 00 movl $0x2d9,0x4(%esp) -c0104a48: 00 -c0104a49: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104a50: e8 ee b9 ff ff call c0100443 <__panic> -c0104a55: 8b 45 f0 mov -0x10(%ebp),%eax -c0104a58: 05 00 00 00 40 add $0x40000000,%eax -c0104a5d: 39 d0 cmp %edx,%eax -c0104a5f: 74 24 je c0104a85 -c0104a61: c7 44 24 0c 00 b0 10 movl $0xc010b000,0xc(%esp) -c0104a68: c0 -c0104a69: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104a70: c0 -c0104a71: c7 44 24 04 d9 02 00 movl $0x2d9,0x4(%esp) -c0104a78: 00 -c0104a79: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104a80: e8 be b9 ff ff call c0100443 <__panic> - - assert(boot_pgdir[0] == 0);// 确保页目录的第一个项为0 -c0104a85: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0104a8a: 8b 00 mov (%eax),%eax -c0104a8c: 85 c0 test %eax,%eax -c0104a8e: 74 24 je c0104ab4 -c0104a90: c7 44 24 0c 34 b0 10 movl $0xc010b034,0xc(%esp) -c0104a97: c0 -c0104a98: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104a9f: c0 -c0104aa0: c7 44 24 04 db 02 00 movl $0x2db,0x4(%esp) -c0104aa7: 00 -c0104aa8: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104aaf: e8 8f b9 ff ff call c0100443 <__panic> - - struct Page *p;// 定义一个指向页面的指针 - p = alloc_page();// 分配一个页面 -c0104ab4: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0104abb: e8 99 ec ff ff call c0103759 -c0104ac0: 89 45 ec mov %eax,-0x14(%ebp) - // 将页面插入到虚拟地址 0x100,并确保操作成功 - assert(page_insert(boot_pgdir, p, 0x100, PTE_W) == 0); -c0104ac3: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0104ac8: c7 44 24 0c 02 00 00 movl $0x2,0xc(%esp) -c0104acf: 00 -c0104ad0: c7 44 24 08 00 01 00 movl $0x100,0x8(%esp) -c0104ad7: 00 -c0104ad8: 8b 55 ec mov -0x14(%ebp),%edx -c0104adb: 89 54 24 04 mov %edx,0x4(%esp) -c0104adf: 89 04 24 mov %eax,(%esp) -c0104ae2: e8 87 f5 ff ff call c010406e -c0104ae7: 85 c0 test %eax,%eax -c0104ae9: 74 24 je c0104b0f -c0104aeb: c7 44 24 0c 48 b0 10 movl $0xc010b048,0xc(%esp) -c0104af2: c0 -c0104af3: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104afa: c0 -c0104afb: c7 44 24 04 e0 02 00 movl $0x2e0,0x4(%esp) -c0104b02: 00 -c0104b03: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104b0a: e8 34 b9 ff ff call c0100443 <__panic> - assert(page_ref(p) == 1);// 验证页面的引用计数为1 -c0104b0f: 8b 45 ec mov -0x14(%ebp),%eax -c0104b12: 89 04 24 mov %eax,(%esp) -c0104b15: e8 29 ea ff ff call c0103543 -c0104b1a: 83 f8 01 cmp $0x1,%eax -c0104b1d: 74 24 je c0104b43 -c0104b1f: c7 44 24 0c 76 b0 10 movl $0xc010b076,0xc(%esp) -c0104b26: c0 -c0104b27: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104b2e: c0 -c0104b2f: c7 44 24 04 e1 02 00 movl $0x2e1,0x4(%esp) -c0104b36: 00 -c0104b37: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104b3e: e8 00 b9 ff ff call c0100443 <__panic> - // 将页面插入到虚拟地址 0x100 + PGSIZE,并确保操作成功 - assert(page_insert(boot_pgdir, p, 0x100 + PGSIZE, PTE_W) == 0); -c0104b43: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0104b48: c7 44 24 0c 02 00 00 movl $0x2,0xc(%esp) -c0104b4f: 00 -c0104b50: c7 44 24 08 00 11 00 movl $0x1100,0x8(%esp) -c0104b57: 00 -c0104b58: 8b 55 ec mov -0x14(%ebp),%edx -c0104b5b: 89 54 24 04 mov %edx,0x4(%esp) -c0104b5f: 89 04 24 mov %eax,(%esp) -c0104b62: e8 07 f5 ff ff call c010406e -c0104b67: 85 c0 test %eax,%eax -c0104b69: 74 24 je c0104b8f -c0104b6b: c7 44 24 0c 88 b0 10 movl $0xc010b088,0xc(%esp) -c0104b72: c0 -c0104b73: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104b7a: c0 -c0104b7b: c7 44 24 04 e3 02 00 movl $0x2e3,0x4(%esp) -c0104b82: 00 -c0104b83: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104b8a: e8 b4 b8 ff ff call c0100443 <__panic> - assert(page_ref(p) == 2);// 验证页面的引用计数为2 -c0104b8f: 8b 45 ec mov -0x14(%ebp),%eax -c0104b92: 89 04 24 mov %eax,(%esp) -c0104b95: e8 a9 e9 ff ff call c0103543 -c0104b9a: 83 f8 02 cmp $0x2,%eax -c0104b9d: 74 24 je c0104bc3 -c0104b9f: c7 44 24 0c bf b0 10 movl $0xc010b0bf,0xc(%esp) -c0104ba6: c0 -c0104ba7: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104bae: c0 -c0104baf: c7 44 24 04 e4 02 00 movl $0x2e4,0x4(%esp) -c0104bb6: 00 -c0104bb7: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104bbe: e8 80 b8 ff ff call c0100443 <__panic> +basic_check(void) { +c010399f: 55 push %ebp +c01039a0: 89 e5 mov %esp,%ebp +c01039a2: 83 ec 48 sub $0x48,%esp + struct Page *p0, *p1, *p2; + p0 = p1 = p2 = NULL; +c01039a5: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c01039ac: 8b 45 f4 mov -0xc(%ebp),%eax +c01039af: 89 45 f0 mov %eax,-0x10(%ebp) +c01039b2: 8b 45 f0 mov -0x10(%ebp),%eax +c01039b5: 89 45 ec mov %eax,-0x14(%ebp) + // 分配三个页面 + assert((p0 = alloc_page()) != NULL); +c01039b8: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c01039bf: e8 17 16 00 00 call c0104fdb +c01039c4: 89 45 ec mov %eax,-0x14(%ebp) +c01039c7: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) +c01039cb: 75 24 jne c01039f1 +c01039cd: c7 44 24 0c f4 a9 10 movl $0xc010a9f4,0xc(%esp) +c01039d4: c0 +c01039d5: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c01039dc: c0 +c01039dd: c7 44 24 04 05 01 00 movl $0x105,0x4(%esp) +c01039e4: 00 +c01039e5: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c01039ec: e8 54 d2 ff ff call c0100c45 <__panic> + assert((p1 = alloc_page()) != NULL); +c01039f1: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c01039f8: e8 de 15 00 00 call c0104fdb +c01039fd: 89 45 f0 mov %eax,-0x10(%ebp) +c0103a00: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c0103a04: 75 24 jne c0103a2a +c0103a06: c7 44 24 0c 10 aa 10 movl $0xc010aa10,0xc(%esp) +c0103a0d: c0 +c0103a0e: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103a15: c0 +c0103a16: c7 44 24 04 06 01 00 movl $0x106,0x4(%esp) +c0103a1d: 00 +c0103a1e: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103a25: e8 1b d2 ff ff call c0100c45 <__panic> + assert((p2 = alloc_page()) != NULL); +c0103a2a: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0103a31: e8 a5 15 00 00 call c0104fdb +c0103a36: 89 45 f4 mov %eax,-0xc(%ebp) +c0103a39: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0103a3d: 75 24 jne c0103a63 +c0103a3f: c7 44 24 0c 2c aa 10 movl $0xc010aa2c,0xc(%esp) +c0103a46: c0 +c0103a47: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103a4e: c0 +c0103a4f: c7 44 24 04 07 01 00 movl $0x107,0x4(%esp) +c0103a56: 00 +c0103a57: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103a5e: e8 e2 d1 ff ff call c0100c45 <__panic> + // 确保所有分配的页面是不同的 + assert(p0 != p1 && p0 != p2 && p1 != p2); +c0103a63: 8b 45 ec mov -0x14(%ebp),%eax +c0103a66: 3b 45 f0 cmp -0x10(%ebp),%eax +c0103a69: 74 10 je c0103a7b +c0103a6b: 8b 45 ec mov -0x14(%ebp),%eax +c0103a6e: 3b 45 f4 cmp -0xc(%ebp),%eax +c0103a71: 74 08 je c0103a7b +c0103a73: 8b 45 f0 mov -0x10(%ebp),%eax +c0103a76: 3b 45 f4 cmp -0xc(%ebp),%eax +c0103a79: 75 24 jne c0103a9f +c0103a7b: c7 44 24 0c 48 aa 10 movl $0xc010aa48,0xc(%esp) +c0103a82: c0 +c0103a83: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103a8a: c0 +c0103a8b: c7 44 24 04 09 01 00 movl $0x109,0x4(%esp) +c0103a92: 00 +c0103a93: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103a9a: e8 a6 d1 ff ff call c0100c45 <__panic> + // 确保页面的引用计数为 0 + assert(page_ref(p0) == 0 && page_ref(p1) == 0 && page_ref(p2) == 0); +c0103a9f: 8b 45 ec mov -0x14(%ebp),%eax +c0103aa2: 89 04 24 mov %eax,(%esp) +c0103aa5: e8 b9 f8 ff ff call c0103363 +c0103aaa: 85 c0 test %eax,%eax +c0103aac: 75 1e jne c0103acc +c0103aae: 8b 45 f0 mov -0x10(%ebp),%eax +c0103ab1: 89 04 24 mov %eax,(%esp) +c0103ab4: e8 aa f8 ff ff call c0103363 +c0103ab9: 85 c0 test %eax,%eax +c0103abb: 75 0f jne c0103acc +c0103abd: 8b 45 f4 mov -0xc(%ebp),%eax +c0103ac0: 89 04 24 mov %eax,(%esp) +c0103ac3: e8 9b f8 ff ff call c0103363 +c0103ac8: 85 c0 test %eax,%eax +c0103aca: 74 24 je c0103af0 +c0103acc: c7 44 24 0c 6c aa 10 movl $0xc010aa6c,0xc(%esp) +c0103ad3: c0 +c0103ad4: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103adb: c0 +c0103adc: c7 44 24 04 0b 01 00 movl $0x10b,0x4(%esp) +c0103ae3: 00 +c0103ae4: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103aeb: e8 55 d1 ff ff call c0100c45 <__panic> + // 确保页面地址在合法范围内 + assert(page2pa(p0) < npage * PGSIZE); +c0103af0: 8b 45 ec mov -0x14(%ebp),%eax +c0103af3: 89 04 24 mov %eax,(%esp) +c0103af6: e8 50 f8 ff ff call c010334b +c0103afb: 8b 15 04 c0 12 c0 mov 0xc012c004,%edx +c0103b01: c1 e2 0c shl $0xc,%edx +c0103b04: 39 d0 cmp %edx,%eax +c0103b06: 72 24 jb c0103b2c +c0103b08: c7 44 24 0c a8 aa 10 movl $0xc010aaa8,0xc(%esp) +c0103b0f: c0 +c0103b10: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103b17: c0 +c0103b18: c7 44 24 04 0d 01 00 movl $0x10d,0x4(%esp) +c0103b1f: 00 +c0103b20: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103b27: e8 19 d1 ff ff call c0100c45 <__panic> + assert(page2pa(p1) < npage * PGSIZE); +c0103b2c: 8b 45 f0 mov -0x10(%ebp),%eax +c0103b2f: 89 04 24 mov %eax,(%esp) +c0103b32: e8 14 f8 ff ff call c010334b +c0103b37: 8b 15 04 c0 12 c0 mov 0xc012c004,%edx +c0103b3d: c1 e2 0c shl $0xc,%edx +c0103b40: 39 d0 cmp %edx,%eax +c0103b42: 72 24 jb c0103b68 +c0103b44: c7 44 24 0c c5 aa 10 movl $0xc010aac5,0xc(%esp) +c0103b4b: c0 +c0103b4c: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103b53: c0 +c0103b54: c7 44 24 04 0e 01 00 movl $0x10e,0x4(%esp) +c0103b5b: 00 +c0103b5c: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103b63: e8 dd d0 ff ff call c0100c45 <__panic> + assert(page2pa(p2) < npage * PGSIZE); +c0103b68: 8b 45 f4 mov -0xc(%ebp),%eax +c0103b6b: 89 04 24 mov %eax,(%esp) +c0103b6e: e8 d8 f7 ff ff call c010334b +c0103b73: 8b 15 04 c0 12 c0 mov 0xc012c004,%edx +c0103b79: c1 e2 0c shl $0xc,%edx +c0103b7c: 39 d0 cmp %edx,%eax +c0103b7e: 72 24 jb c0103ba4 +c0103b80: c7 44 24 0c e2 aa 10 movl $0xc010aae2,0xc(%esp) +c0103b87: c0 +c0103b88: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103b8f: c0 +c0103b90: c7 44 24 04 0f 01 00 movl $0x10f,0x4(%esp) +c0103b97: 00 +c0103b98: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103b9f: e8 a1 d0 ff ff call c0100c45 <__panic> + // 保存当前的空闲页面链表和数量 + list_entry_t free_list_store = free_list; +c0103ba4: a1 e4 bf 12 c0 mov 0xc012bfe4,%eax +c0103ba9: 8b 15 e8 bf 12 c0 mov 0xc012bfe8,%edx +c0103baf: 89 45 d0 mov %eax,-0x30(%ebp) +c0103bb2: 89 55 d4 mov %edx,-0x2c(%ebp) +c0103bb5: c7 45 dc e4 bf 12 c0 movl $0xc012bfe4,-0x24(%ebp) + elm->prev = elm->next = elm; +c0103bbc: 8b 45 dc mov -0x24(%ebp),%eax +c0103bbf: 8b 55 dc mov -0x24(%ebp),%edx +c0103bc2: 89 50 04 mov %edx,0x4(%eax) +c0103bc5: 8b 45 dc mov -0x24(%ebp),%eax +c0103bc8: 8b 50 04 mov 0x4(%eax),%edx +c0103bcb: 8b 45 dc mov -0x24(%ebp),%eax +c0103bce: 89 10 mov %edx,(%eax) +} +c0103bd0: 90 nop +c0103bd1: c7 45 e0 e4 bf 12 c0 movl $0xc012bfe4,-0x20(%ebp) + return list->next == list; +c0103bd8: 8b 45 e0 mov -0x20(%ebp),%eax +c0103bdb: 8b 40 04 mov 0x4(%eax),%eax +c0103bde: 39 45 e0 cmp %eax,-0x20(%ebp) +c0103be1: 0f 94 c0 sete %al +c0103be4: 0f b6 c0 movzbl %al,%eax + list_init(&free_list);// 初始化空闲列表 + assert(list_empty(&free_list));// 确保空闲列表为空 +c0103be7: 85 c0 test %eax,%eax +c0103be9: 75 24 jne c0103c0f +c0103beb: c7 44 24 0c ff aa 10 movl $0xc010aaff,0xc(%esp) +c0103bf2: c0 +c0103bf3: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103bfa: c0 +c0103bfb: c7 44 24 04 13 01 00 movl $0x113,0x4(%esp) +c0103c02: 00 +c0103c03: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103c0a: e8 36 d0 ff ff call c0100c45 <__panic> - const char *str = "ucore: Hello world!!";// 定义一个字符串 -c0104bc3: c7 45 e8 d0 b0 10 c0 movl $0xc010b0d0,-0x18(%ebp) - strcpy((void *)0x100, str);// 将字符串复制到虚拟地址 0x100 -c0104bca: 8b 45 e8 mov -0x18(%ebp),%eax -c0104bcd: 89 44 24 04 mov %eax,0x4(%esp) -c0104bd1: c7 04 24 00 01 00 00 movl $0x100,(%esp) -c0104bd8: e8 93 4a 00 00 call c0109670 - // 验证两个映射地址的数据是否一致 - assert(strcmp((void *)0x100, (void *)(0x100 + PGSIZE)) == 0); -c0104bdd: c7 44 24 04 00 11 00 movl $0x1100,0x4(%esp) -c0104be4: 00 -c0104be5: c7 04 24 00 01 00 00 movl $0x100,(%esp) -c0104bec: e8 fd 4a 00 00 call c01096ee -c0104bf1: 85 c0 test %eax,%eax -c0104bf3: 74 24 je c0104c19 -c0104bf5: c7 44 24 0c e8 b0 10 movl $0xc010b0e8,0xc(%esp) -c0104bfc: c0 -c0104bfd: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104c04: c0 -c0104c05: c7 44 24 04 e9 02 00 movl $0x2e9,0x4(%esp) -c0104c0c: 00 -c0104c0d: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104c14: e8 2a b8 ff ff call c0100443 <__panic> - // 在页面的 0x100 偏移处设置字符串结束符 - *(char *)(page2kva(p) + 0x100) = '\0'; -c0104c19: 8b 45 ec mov -0x14(%ebp),%eax -c0104c1c: 89 04 24 mov %eax,(%esp) -c0104c1f: e8 75 e8 ff ff call c0103499 -c0104c24: 05 00 01 00 00 add $0x100,%eax -c0104c29: c6 00 00 movb $0x0,(%eax) - assert(strlen((const char *)0x100) == 0);// 验证字符串长度为0 -c0104c2c: c7 04 24 00 01 00 00 movl $0x100,(%esp) -c0104c33: e8 da 49 00 00 call c0109612 -c0104c38: 85 c0 test %eax,%eax -c0104c3a: 74 24 je c0104c60 -c0104c3c: c7 44 24 0c 20 b1 10 movl $0xc010b120,0xc(%esp) -c0104c43: c0 -c0104c44: c7 44 24 08 ad ac 10 movl $0xc010acad,0x8(%esp) -c0104c4b: c0 -c0104c4c: c7 44 24 04 ec 02 00 movl $0x2ec,0x4(%esp) -c0104c53: 00 -c0104c54: c7 04 24 88 ac 10 c0 movl $0xc010ac88,(%esp) -c0104c5b: e8 e3 b7 ff ff call c0100443 <__panic> + unsigned int nr_free_store = nr_free;// 保存当前空闲页数量 +c0103c0f: a1 ec bf 12 c0 mov 0xc012bfec,%eax +c0103c14: 89 45 e8 mov %eax,-0x18(%ebp) + nr_free = 0;// 将空闲页数量设为 0 +c0103c17: c7 05 ec bf 12 c0 00 movl $0x0,0xc012bfec +c0103c1e: 00 00 00 + // 请求分配页面,但当前没有空闲页面 + assert(alloc_page() == NULL); +c0103c21: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0103c28: e8 ae 13 00 00 call c0104fdb +c0103c2d: 85 c0 test %eax,%eax +c0103c2f: 74 24 je c0103c55 +c0103c31: c7 44 24 0c 16 ab 10 movl $0xc010ab16,0xc(%esp) +c0103c38: c0 +c0103c39: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103c40: c0 +c0103c41: c7 44 24 04 18 01 00 movl $0x118,0x4(%esp) +c0103c48: 00 +c0103c49: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103c50: e8 f0 cf ff ff call c0100c45 <__panic> + // 释放之前分配的页面 + free_page(p0); +c0103c55: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0103c5c: 00 +c0103c5d: 8b 45 ec mov -0x14(%ebp),%eax +c0103c60: 89 04 24 mov %eax,(%esp) +c0103c63: e8 e0 13 00 00 call c0105048 + free_page(p1); +c0103c68: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0103c6f: 00 +c0103c70: 8b 45 f0 mov -0x10(%ebp),%eax +c0103c73: 89 04 24 mov %eax,(%esp) +c0103c76: e8 cd 13 00 00 call c0105048 + free_page(p2); +c0103c7b: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0103c82: 00 +c0103c83: 8b 45 f4 mov -0xc(%ebp),%eax +c0103c86: 89 04 24 mov %eax,(%esp) +c0103c89: e8 ba 13 00 00 call c0105048 + assert(nr_free == 3);// 确保释放后空闲页数量为 3 +c0103c8e: a1 ec bf 12 c0 mov 0xc012bfec,%eax +c0103c93: 83 f8 03 cmp $0x3,%eax +c0103c96: 74 24 je c0103cbc +c0103c98: c7 44 24 0c 2b ab 10 movl $0xc010ab2b,0xc(%esp) +c0103c9f: c0 +c0103ca0: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103ca7: c0 +c0103ca8: c7 44 24 04 1d 01 00 movl $0x11d,0x4(%esp) +c0103caf: 00 +c0103cb0: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103cb7: e8 89 cf ff ff call c0100c45 <__panic> + // 再次分配三个页面 + assert((p0 = alloc_page()) != NULL); +c0103cbc: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0103cc3: e8 13 13 00 00 call c0104fdb +c0103cc8: 89 45 ec mov %eax,-0x14(%ebp) +c0103ccb: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) +c0103ccf: 75 24 jne c0103cf5 +c0103cd1: c7 44 24 0c f4 a9 10 movl $0xc010a9f4,0xc(%esp) +c0103cd8: c0 +c0103cd9: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103ce0: c0 +c0103ce1: c7 44 24 04 1f 01 00 movl $0x11f,0x4(%esp) +c0103ce8: 00 +c0103ce9: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103cf0: e8 50 cf ff ff call c0100c45 <__panic> + assert((p1 = alloc_page()) != NULL); +c0103cf5: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0103cfc: e8 da 12 00 00 call c0104fdb +c0103d01: 89 45 f0 mov %eax,-0x10(%ebp) +c0103d04: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c0103d08: 75 24 jne c0103d2e +c0103d0a: c7 44 24 0c 10 aa 10 movl $0xc010aa10,0xc(%esp) +c0103d11: c0 +c0103d12: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103d19: c0 +c0103d1a: c7 44 24 04 20 01 00 movl $0x120,0x4(%esp) +c0103d21: 00 +c0103d22: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103d29: e8 17 cf ff ff call c0100c45 <__panic> + assert((p2 = alloc_page()) != NULL); +c0103d2e: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0103d35: e8 a1 12 00 00 call c0104fdb +c0103d3a: 89 45 f4 mov %eax,-0xc(%ebp) +c0103d3d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0103d41: 75 24 jne c0103d67 +c0103d43: c7 44 24 0c 2c aa 10 movl $0xc010aa2c,0xc(%esp) +c0103d4a: c0 +c0103d4b: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103d52: c0 +c0103d53: c7 44 24 04 21 01 00 movl $0x121,0x4(%esp) +c0103d5a: 00 +c0103d5b: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103d62: e8 de ce ff ff call c0100c45 <__panic> + // 测试空闲页面是否不足 + assert(alloc_page() == NULL); +c0103d67: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0103d6e: e8 68 12 00 00 call c0104fdb +c0103d73: 85 c0 test %eax,%eax +c0103d75: 74 24 je c0103d9b +c0103d77: c7 44 24 0c 16 ab 10 movl $0xc010ab16,0xc(%esp) +c0103d7e: c0 +c0103d7f: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103d86: c0 +c0103d87: c7 44 24 04 23 01 00 movl $0x123,0x4(%esp) +c0103d8e: 00 +c0103d8f: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103d96: e8 aa ce ff ff call c0100c45 <__panic> + // 释放 p0,并检查空闲列表 + free_page(p0); +c0103d9b: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0103da2: 00 +c0103da3: 8b 45 ec mov -0x14(%ebp),%eax +c0103da6: 89 04 24 mov %eax,(%esp) +c0103da9: e8 9a 12 00 00 call c0105048 +c0103dae: c7 45 d8 e4 bf 12 c0 movl $0xc012bfe4,-0x28(%ebp) +c0103db5: 8b 45 d8 mov -0x28(%ebp),%eax +c0103db8: 8b 40 04 mov 0x4(%eax),%eax +c0103dbb: 39 45 d8 cmp %eax,-0x28(%ebp) +c0103dbe: 0f 94 c0 sete %al +c0103dc1: 0f b6 c0 movzbl %al,%eax + assert(!list_empty(&free_list));// 确保空闲列表不为空 +c0103dc4: 85 c0 test %eax,%eax +c0103dc6: 74 24 je c0103dec +c0103dc8: c7 44 24 0c 38 ab 10 movl $0xc010ab38,0xc(%esp) +c0103dcf: c0 +c0103dd0: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103dd7: c0 +c0103dd8: c7 44 24 04 26 01 00 movl $0x126,0x4(%esp) +c0103ddf: 00 +c0103de0: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103de7: e8 59 ce ff ff call c0100c45 <__panic> - free_page(p);// 释放页面 p -c0104c60: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0104c67: 00 -c0104c68: 8b 45 ec mov -0x14(%ebp),%eax -c0104c6b: 89 04 24 mov %eax,(%esp) -c0104c6e: e8 55 eb ff ff call c01037c8 - free_page(pde2page(boot_pgdir[0]));// 释放页目录项对应的页面 -c0104c73: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0104c78: 8b 00 mov (%eax),%eax -c0104c7a: 89 04 24 mov %eax,(%esp) -c0104c7d: e8 a9 e8 ff ff call c010352b -c0104c82: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0104c89: 00 -c0104c8a: 89 04 24 mov %eax,(%esp) -c0104c8d: e8 36 eb ff ff call c01037c8 - boot_pgdir[0] = 0;// 将页目录的第一个项设为0 -c0104c92: a1 e0 89 12 c0 mov 0xc01289e0,%eax -c0104c97: c7 00 00 00 00 00 movl $0x0,(%eax) + struct Page *p; + // 重新分配 p0,确保取回的是相同的页面 + assert((p = alloc_page()) == p0); +c0103dec: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0103df3: e8 e3 11 00 00 call c0104fdb +c0103df8: 89 45 e4 mov %eax,-0x1c(%ebp) +c0103dfb: 8b 45 e4 mov -0x1c(%ebp),%eax +c0103dfe: 3b 45 ec cmp -0x14(%ebp),%eax +c0103e01: 74 24 je c0103e27 +c0103e03: c7 44 24 0c 50 ab 10 movl $0xc010ab50,0xc(%esp) +c0103e0a: c0 +c0103e0b: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103e12: c0 +c0103e13: c7 44 24 04 2a 01 00 movl $0x12a,0x4(%esp) +c0103e1a: 00 +c0103e1b: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103e22: e8 1e ce ff ff call c0100c45 <__panic> + assert(alloc_page() == NULL);// 确保没有更多的页面可分配 +c0103e27: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0103e2e: e8 a8 11 00 00 call c0104fdb +c0103e33: 85 c0 test %eax,%eax +c0103e35: 74 24 je c0103e5b +c0103e37: c7 44 24 0c 16 ab 10 movl $0xc010ab16,0xc(%esp) +c0103e3e: c0 +c0103e3f: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103e46: c0 +c0103e47: c7 44 24 04 2b 01 00 movl $0x12b,0x4(%esp) +c0103e4e: 00 +c0103e4f: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103e56: e8 ea cd ff ff call c0100c45 <__panic> - cprintf("check_boot_pgdir() succeeded!\n");// 输出成功信息 -c0104c9d: c7 04 24 44 b1 10 c0 movl $0xc010b144,(%esp) -c0104ca4: e8 2e b6 ff ff call c01002d7 + assert(nr_free == 0);// 确保当前空闲页面数量为 0 +c0103e5b: a1 ec bf 12 c0 mov 0xc012bfec,%eax +c0103e60: 85 c0 test %eax,%eax +c0103e62: 74 24 je c0103e88 +c0103e64: c7 44 24 0c 69 ab 10 movl $0xc010ab69,0xc(%esp) +c0103e6b: c0 +c0103e6c: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103e73: c0 +c0103e74: c7 44 24 04 2d 01 00 movl $0x12d,0x4(%esp) +c0103e7b: 00 +c0103e7c: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103e83: e8 bd cd ff ff call c0100c45 <__panic> + // 恢复之前的空闲页面链表和数量 + free_list = free_list_store; +c0103e88: 8b 45 d0 mov -0x30(%ebp),%eax +c0103e8b: 8b 55 d4 mov -0x2c(%ebp),%edx +c0103e8e: a3 e4 bf 12 c0 mov %eax,0xc012bfe4 +c0103e93: 89 15 e8 bf 12 c0 mov %edx,0xc012bfe8 + nr_free = nr_free_store; +c0103e99: 8b 45 e8 mov -0x18(%ebp),%eax +c0103e9c: a3 ec bf 12 c0 mov %eax,0xc012bfec + // 释放最后的页面 + free_page(p); +c0103ea1: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0103ea8: 00 +c0103ea9: 8b 45 e4 mov -0x1c(%ebp),%eax +c0103eac: 89 04 24 mov %eax,(%esp) +c0103eaf: e8 94 11 00 00 call c0105048 + free_page(p1); +c0103eb4: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0103ebb: 00 +c0103ebc: 8b 45 f0 mov -0x10(%ebp),%eax +c0103ebf: 89 04 24 mov %eax,(%esp) +c0103ec2: e8 81 11 00 00 call c0105048 + free_page(p2); +c0103ec7: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0103ece: 00 +c0103ecf: 8b 45 f4 mov -0xc(%ebp),%eax +c0103ed2: 89 04 24 mov %eax,(%esp) +c0103ed5: e8 6e 11 00 00 call c0105048 } -c0104ca9: 90 nop -c0104caa: c9 leave -c0104cab: c3 ret +c0103eda: 90 nop +c0103edb: 89 ec mov %ebp,%esp +c0103edd: 5d pop %ebp +c0103ede: c3 ret -c0104cac : - -//perm2str - use string 'u,r,w,-' to present the permission -static const char * -perm2str(int perm) { -c0104cac: f3 0f 1e fb endbr32 -c0104cb0: 55 push %ebp -c0104cb1: 89 e5 mov %esp,%ebp - //定义一个静态字符数组 str,长度为4 - static char str[4]; - //如果 perm 与 PTE_U 按位与的结果不为0,则 str[0] 设置为 'u',否则设置为 '-' - str[0] = (perm & PTE_U) ? 'u' : '-'; -c0104cb3: 8b 45 08 mov 0x8(%ebp),%eax -c0104cb6: 83 e0 04 and $0x4,%eax -c0104cb9: 85 c0 test %eax,%eax -c0104cbb: 74 04 je c0104cc1 -c0104cbd: b0 75 mov $0x75,%al -c0104cbf: eb 02 jmp c0104cc3 -c0104cc1: b0 2d mov $0x2d,%al -c0104cc3: a2 08 c0 12 c0 mov %al,0xc012c008 - //str[1] 始终设置为 'r' - str[1] = 'r'; -c0104cc8: c6 05 09 c0 12 c0 72 movb $0x72,0xc012c009 - //如果 perm 与 PTE_W 按位与的结果不为0,则 str[2] 设置为 'w',否则设置为 '-' - str[2] = (perm & PTE_W) ? 'w' : '-'; -c0104ccf: 8b 45 08 mov 0x8(%ebp),%eax -c0104cd2: 83 e0 02 and $0x2,%eax -c0104cd5: 85 c0 test %eax,%eax -c0104cd7: 74 04 je c0104cdd -c0104cd9: b0 77 mov $0x77,%al -c0104cdb: eb 02 jmp c0104cdf -c0104cdd: b0 2d mov $0x2d,%al -c0104cdf: a2 0a c0 12 c0 mov %al,0xc012c00a - //str[3] 设置为字符串结束符 \0 - str[3] = '\0'; -c0104ce4: c6 05 0b c0 12 c0 00 movb $0x0,0xc012c00b - return str; -c0104ceb: b8 08 c0 12 c0 mov $0xc012c008,%eax -} -c0104cf0: 5d pop %ebp -c0104cf1: c3 ret +c0103edf : -c0104cf2 : -// left_store: the pointer of the high side of table's next range -// right_store: the pointer of the low side of table's next range -// return value: 0 - not a invalid item range, perm - a valid item range with perm permission -//从页表中获取指定范围内的有效项,并根据权限进行处理。 -static int -get_pgtable_items(size_t left, size_t right, size_t start, uintptr_t *table, size_t *left_store, size_t *right_store) { -c0104cf2: f3 0f 1e fb endbr32 -c0104cf6: 55 push %ebp -c0104cf7: 89 e5 mov %esp,%ebp -c0104cf9: 83 ec 10 sub $0x10,%esp - if (start >= right) {// 检查起始索引是否超出右边界 -c0104cfc: 8b 45 10 mov 0x10(%ebp),%eax -c0104cff: 3b 45 0c cmp 0xc(%ebp),%eax -c0104d02: 72 0d jb c0104d11 - return 0;// 如果超出右边界,返回0 -c0104d04: b8 00 00 00 00 mov $0x0,%eax -c0104d09: e9 98 00 00 00 jmp c0104da6 - } - while (start < right && !(table[start] & PTE_P)) {// 查找第一个有效项(PTE_P位为1的项) - start ++;// 索引递增 -c0104d0e: ff 45 10 incl 0x10(%ebp) - while (start < right && !(table[start] & PTE_P)) {// 查找第一个有效项(PTE_P位为1的项) -c0104d11: 8b 45 10 mov 0x10(%ebp),%eax -c0104d14: 3b 45 0c cmp 0xc(%ebp),%eax -c0104d17: 73 18 jae c0104d31 -c0104d19: 8b 45 10 mov 0x10(%ebp),%eax -c0104d1c: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx -c0104d23: 8b 45 14 mov 0x14(%ebp),%eax -c0104d26: 01 d0 add %edx,%eax -c0104d28: 8b 00 mov (%eax),%eax -c0104d2a: 83 e0 01 and $0x1,%eax -c0104d2d: 85 c0 test %eax,%eax -c0104d2f: 74 dd je c0104d0e - } - if (start < right) {// 检查是否找到有效项 -c0104d31: 8b 45 10 mov 0x10(%ebp),%eax -c0104d34: 3b 45 0c cmp 0xc(%ebp),%eax -c0104d37: 73 68 jae c0104da1 - if (left_store != NULL) {// 如果left_store不为NULL -c0104d39: 83 7d 18 00 cmpl $0x0,0x18(%ebp) -c0104d3d: 74 08 je c0104d47 - *left_store = start;// 记录左边界索引 -c0104d3f: 8b 45 18 mov 0x18(%ebp),%eax -c0104d42: 8b 55 10 mov 0x10(%ebp),%edx -c0104d45: 89 10 mov %edx,(%eax) - } - int perm = (table[start ++] & PTE_USER);// 获取当前项的用户权限位并递增索引 -c0104d47: 8b 45 10 mov 0x10(%ebp),%eax -c0104d4a: 8d 50 01 lea 0x1(%eax),%edx -c0104d4d: 89 55 10 mov %edx,0x10(%ebp) -c0104d50: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx -c0104d57: 8b 45 14 mov 0x14(%ebp),%eax -c0104d5a: 01 d0 add %edx,%eax -c0104d5c: 8b 00 mov (%eax),%eax -c0104d5e: 83 e0 07 and $0x7,%eax -c0104d61: 89 45 fc mov %eax,-0x4(%ebp) - while (start < right && (table[start] & PTE_USER) == perm) {// 查找具有相同用户权限的连续项 -c0104d64: eb 03 jmp c0104d69 - start ++;// 索引递增 -c0104d66: ff 45 10 incl 0x10(%ebp) - while (start < right && (table[start] & PTE_USER) == perm) {// 查找具有相同用户权限的连续项 -c0104d69: 8b 45 10 mov 0x10(%ebp),%eax -c0104d6c: 3b 45 0c cmp 0xc(%ebp),%eax -c0104d6f: 73 1d jae c0104d8e -c0104d71: 8b 45 10 mov 0x10(%ebp),%eax -c0104d74: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx -c0104d7b: 8b 45 14 mov 0x14(%ebp),%eax -c0104d7e: 01 d0 add %edx,%eax -c0104d80: 8b 00 mov (%eax),%eax -c0104d82: 83 e0 07 and $0x7,%eax -c0104d85: 89 c2 mov %eax,%edx -c0104d87: 8b 45 fc mov -0x4(%ebp),%eax -c0104d8a: 39 c2 cmp %eax,%edx -c0104d8c: 74 d8 je c0104d66 - } - if (right_store != NULL) {// 如果right_store不为NULL -c0104d8e: 83 7d 1c 00 cmpl $0x0,0x1c(%ebp) -c0104d92: 74 08 je c0104d9c - *right_store = start;// 记录右边界索引 -c0104d94: 8b 45 1c mov 0x1c(%ebp),%eax -c0104d97: 8b 55 10 mov 0x10(%ebp),%edx -c0104d9a: 89 10 mov %edx,(%eax) - } - return perm;// 返回用户权限位 -c0104d9c: 8b 45 fc mov -0x4(%ebp),%eax -c0104d9f: eb 05 jmp c0104da6 +// LAB2: below code is used to check the first fit allocation algorithm (your EXERCISE 1) +// NOTICE: You SHOULD NOT CHANGE basic_check, default_check functions! +static void +default_check(void) { +c0103edf: 55 push %ebp +c0103ee0: 89 e5 mov %esp,%ebp +c0103ee2: 81 ec 98 00 00 00 sub $0x98,%esp + int count = 0, total = 0; +c0103ee8: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c0103eef: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) + list_entry_t *le = &free_list; +c0103ef6: c7 45 ec e4 bf 12 c0 movl $0xc012bfe4,-0x14(%ebp) + // 遍历空闲列表,计算空闲页面的数量和总属性值 + while ((le = list_next(le)) != &free_list) { +c0103efd: eb 6a jmp c0103f69 + struct Page *p = le2page(le, page_link); +c0103eff: 8b 45 ec mov -0x14(%ebp),%eax +c0103f02: 83 e8 0c sub $0xc,%eax +c0103f05: 89 45 d4 mov %eax,-0x2c(%ebp) + assert(PageProperty(p));// 确保每个页面的属性是有效的 +c0103f08: 8b 45 d4 mov -0x2c(%ebp),%eax +c0103f0b: 83 c0 04 add $0x4,%eax +c0103f0e: c7 45 d0 01 00 00 00 movl $0x1,-0x30(%ebp) +c0103f15: 89 45 cc mov %eax,-0x34(%ebp) + asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); +c0103f18: 8b 45 cc mov -0x34(%ebp),%eax +c0103f1b: 8b 55 d0 mov -0x30(%ebp),%edx +c0103f1e: 0f a3 10 bt %edx,(%eax) +c0103f21: 19 c0 sbb %eax,%eax +c0103f23: 89 45 c8 mov %eax,-0x38(%ebp) + return oldbit != 0; +c0103f26: 83 7d c8 00 cmpl $0x0,-0x38(%ebp) +c0103f2a: 0f 95 c0 setne %al +c0103f2d: 0f b6 c0 movzbl %al,%eax +c0103f30: 85 c0 test %eax,%eax +c0103f32: 75 24 jne c0103f58 +c0103f34: c7 44 24 0c 76 ab 10 movl $0xc010ab76,0xc(%esp) +c0103f3b: c0 +c0103f3c: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103f43: c0 +c0103f44: c7 44 24 04 40 01 00 movl $0x140,0x4(%esp) +c0103f4b: 00 +c0103f4c: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103f53: e8 ed cc ff ff call c0100c45 <__panic> + count ++, total += p->property;// 累加页面属性 +c0103f58: ff 45 f4 incl -0xc(%ebp) +c0103f5b: 8b 45 d4 mov -0x2c(%ebp),%eax +c0103f5e: 8b 50 08 mov 0x8(%eax),%edx +c0103f61: 8b 45 f0 mov -0x10(%ebp),%eax +c0103f64: 01 d0 add %edx,%eax +c0103f66: 89 45 f0 mov %eax,-0x10(%ebp) +c0103f69: 8b 45 ec mov -0x14(%ebp),%eax +c0103f6c: 89 45 c4 mov %eax,-0x3c(%ebp) + return listelm->next; +c0103f6f: 8b 45 c4 mov -0x3c(%ebp),%eax +c0103f72: 8b 40 04 mov 0x4(%eax),%eax + while ((le = list_next(le)) != &free_list) { +c0103f75: 89 45 ec mov %eax,-0x14(%ebp) +c0103f78: 81 7d ec e4 bf 12 c0 cmpl $0xc012bfe4,-0x14(%ebp) +c0103f7f: 0f 85 7a ff ff ff jne c0103eff } - return 0;// 如果未找到有效项,返回0 -c0104da1: b8 00 00 00 00 mov $0x0,%eax -} -c0104da6: c9 leave -c0104da7: c3 ret + // 确保总属性值与空闲页面数量匹配 + assert(total == nr_free_pages()); +c0103f85: e8 f3 10 00 00 call c010507d +c0103f8a: 8b 55 f0 mov -0x10(%ebp),%edx +c0103f8d: 39 d0 cmp %edx,%eax +c0103f8f: 74 24 je c0103fb5 +c0103f91: c7 44 24 0c 86 ab 10 movl $0xc010ab86,0xc(%esp) +c0103f98: c0 +c0103f99: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103fa0: c0 +c0103fa1: c7 44 24 04 44 01 00 movl $0x144,0x4(%esp) +c0103fa8: 00 +c0103fa9: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103fb0: e8 90 cc ff ff call c0100c45 <__panic> + // 调用 basic_check 以验证基本的内存管理功能 + basic_check(); +c0103fb5: e8 e5 f9 ff ff call c010399f + // 分配 5 个页面 + struct Page *p0 = alloc_pages(5), *p1, *p2; +c0103fba: c7 04 24 05 00 00 00 movl $0x5,(%esp) +c0103fc1: e8 15 10 00 00 call c0104fdb +c0103fc6: 89 45 e8 mov %eax,-0x18(%ebp) + assert(p0 != NULL);// 确保成功分配 +c0103fc9: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) +c0103fcd: 75 24 jne c0103ff3 +c0103fcf: c7 44 24 0c 9f ab 10 movl $0xc010ab9f,0xc(%esp) +c0103fd6: c0 +c0103fd7: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0103fde: c0 +c0103fdf: c7 44 24 04 49 01 00 movl $0x149,0x4(%esp) +c0103fe6: 00 +c0103fe7: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0103fee: e8 52 cc ff ff call c0100c45 <__panic> + assert(!PageProperty(p0));// 确保分配的页面不带属性 +c0103ff3: 8b 45 e8 mov -0x18(%ebp),%eax +c0103ff6: 83 c0 04 add $0x4,%eax +c0103ff9: c7 45 c0 01 00 00 00 movl $0x1,-0x40(%ebp) +c0104000: 89 45 bc mov %eax,-0x44(%ebp) + asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); +c0104003: 8b 45 bc mov -0x44(%ebp),%eax +c0104006: 8b 55 c0 mov -0x40(%ebp),%edx +c0104009: 0f a3 10 bt %edx,(%eax) +c010400c: 19 c0 sbb %eax,%eax +c010400e: 89 45 b8 mov %eax,-0x48(%ebp) + return oldbit != 0; +c0104011: 83 7d b8 00 cmpl $0x0,-0x48(%ebp) +c0104015: 0f 95 c0 setne %al +c0104018: 0f b6 c0 movzbl %al,%eax +c010401b: 85 c0 test %eax,%eax +c010401d: 74 24 je c0104043 +c010401f: c7 44 24 0c aa ab 10 movl $0xc010abaa,0xc(%esp) +c0104026: c0 +c0104027: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c010402e: c0 +c010402f: c7 44 24 04 4a 01 00 movl $0x14a,0x4(%esp) +c0104036: 00 +c0104037: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c010403e: e8 02 cc ff ff call c0100c45 <__panic> + // 初始化并检查空闲列表 + list_entry_t free_list_store = free_list; +c0104043: a1 e4 bf 12 c0 mov 0xc012bfe4,%eax +c0104048: 8b 15 e8 bf 12 c0 mov 0xc012bfe8,%edx +c010404e: 89 45 80 mov %eax,-0x80(%ebp) +c0104051: 89 55 84 mov %edx,-0x7c(%ebp) +c0104054: c7 45 b0 e4 bf 12 c0 movl $0xc012bfe4,-0x50(%ebp) + elm->prev = elm->next = elm; +c010405b: 8b 45 b0 mov -0x50(%ebp),%eax +c010405e: 8b 55 b0 mov -0x50(%ebp),%edx +c0104061: 89 50 04 mov %edx,0x4(%eax) +c0104064: 8b 45 b0 mov -0x50(%ebp),%eax +c0104067: 8b 50 04 mov 0x4(%eax),%edx +c010406a: 8b 45 b0 mov -0x50(%ebp),%eax +c010406d: 89 10 mov %edx,(%eax) +} +c010406f: 90 nop +c0104070: c7 45 b4 e4 bf 12 c0 movl $0xc012bfe4,-0x4c(%ebp) + return list->next == list; +c0104077: 8b 45 b4 mov -0x4c(%ebp),%eax +c010407a: 8b 40 04 mov 0x4(%eax),%eax +c010407d: 39 45 b4 cmp %eax,-0x4c(%ebp) +c0104080: 0f 94 c0 sete %al +c0104083: 0f b6 c0 movzbl %al,%eax + list_init(&free_list); + assert(list_empty(&free_list));// 确保空闲列表为空 +c0104086: 85 c0 test %eax,%eax +c0104088: 75 24 jne c01040ae +c010408a: c7 44 24 0c ff aa 10 movl $0xc010aaff,0xc(%esp) +c0104091: c0 +c0104092: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0104099: c0 +c010409a: c7 44 24 04 4e 01 00 movl $0x14e,0x4(%esp) +c01040a1: 00 +c01040a2: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c01040a9: e8 97 cb ff ff call c0100c45 <__panic> + assert(alloc_page() == NULL);// 确保没有页面可分配 +c01040ae: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c01040b5: e8 21 0f 00 00 call c0104fdb +c01040ba: 85 c0 test %eax,%eax +c01040bc: 74 24 je c01040e2 +c01040be: c7 44 24 0c 16 ab 10 movl $0xc010ab16,0xc(%esp) +c01040c5: c0 +c01040c6: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c01040cd: c0 +c01040ce: c7 44 24 04 4f 01 00 movl $0x14f,0x4(%esp) +c01040d5: 00 +c01040d6: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c01040dd: e8 63 cb ff ff call c0100c45 <__panic> -c0104da8 : + unsigned int nr_free_store = nr_free;// 保存当前空闲页数 +c01040e2: a1 ec bf 12 c0 mov 0xc012bfec,%eax +c01040e7: 89 45 e4 mov %eax,-0x1c(%ebp) + nr_free = 0;// 将空闲页数设为 0 +c01040ea: c7 05 ec bf 12 c0 00 movl $0x0,0xc012bfec +c01040f1: 00 00 00 + // 释放 3 个页面并确保分配页面时没有足够的空闲页 + free_pages(p0 + 2, 3); +c01040f4: 8b 45 e8 mov -0x18(%ebp),%eax +c01040f7: 83 c0 40 add $0x40,%eax +c01040fa: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp) +c0104101: 00 +c0104102: 89 04 24 mov %eax,(%esp) +c0104105: e8 3e 0f 00 00 call c0105048 + assert(alloc_pages(4) == NULL);// 确保无法分配 4 个页面 +c010410a: c7 04 24 04 00 00 00 movl $0x4,(%esp) +c0104111: e8 c5 0e 00 00 call c0104fdb +c0104116: 85 c0 test %eax,%eax +c0104118: 74 24 je c010413e +c010411a: c7 44 24 0c bc ab 10 movl $0xc010abbc,0xc(%esp) +c0104121: c0 +c0104122: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0104129: c0 +c010412a: c7 44 24 04 55 01 00 movl $0x155,0x4(%esp) +c0104131: 00 +c0104132: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0104139: e8 07 cb ff ff call c0100c45 <__panic> + assert(PageProperty(p0 + 2) && p0[2].property == 3);// 检查页面属性 +c010413e: 8b 45 e8 mov -0x18(%ebp),%eax +c0104141: 83 c0 40 add $0x40,%eax +c0104144: 83 c0 04 add $0x4,%eax +c0104147: c7 45 ac 01 00 00 00 movl $0x1,-0x54(%ebp) +c010414e: 89 45 a8 mov %eax,-0x58(%ebp) + asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); +c0104151: 8b 45 a8 mov -0x58(%ebp),%eax +c0104154: 8b 55 ac mov -0x54(%ebp),%edx +c0104157: 0f a3 10 bt %edx,(%eax) +c010415a: 19 c0 sbb %eax,%eax +c010415c: 89 45 a4 mov %eax,-0x5c(%ebp) + return oldbit != 0; +c010415f: 83 7d a4 00 cmpl $0x0,-0x5c(%ebp) +c0104163: 0f 95 c0 setne %al +c0104166: 0f b6 c0 movzbl %al,%eax +c0104169: 85 c0 test %eax,%eax +c010416b: 74 0e je c010417b +c010416d: 8b 45 e8 mov -0x18(%ebp),%eax +c0104170: 83 c0 40 add $0x40,%eax +c0104173: 8b 40 08 mov 0x8(%eax),%eax +c0104176: 83 f8 03 cmp $0x3,%eax +c0104179: 74 24 je c010419f +c010417b: c7 44 24 0c d4 ab 10 movl $0xc010abd4,0xc(%esp) +c0104182: c0 +c0104183: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c010418a: c0 +c010418b: c7 44 24 04 56 01 00 movl $0x156,0x4(%esp) +c0104192: 00 +c0104193: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c010419a: e8 a6 ca ff ff call c0100c45 <__panic> + assert((p1 = alloc_pages(3)) != NULL);// 再次分配 3 个页面 +c010419f: c7 04 24 03 00 00 00 movl $0x3,(%esp) +c01041a6: e8 30 0e 00 00 call c0104fdb +c01041ab: 89 45 e0 mov %eax,-0x20(%ebp) +c01041ae: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) +c01041b2: 75 24 jne c01041d8 +c01041b4: c7 44 24 0c 00 ac 10 movl $0xc010ac00,0xc(%esp) +c01041bb: c0 +c01041bc: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c01041c3: c0 +c01041c4: c7 44 24 04 57 01 00 movl $0x157,0x4(%esp) +c01041cb: 00 +c01041cc: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c01041d3: e8 6d ca ff ff call c0100c45 <__panic> + assert(alloc_page() == NULL);// 确保没有页面可分配 +c01041d8: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c01041df: e8 f7 0d 00 00 call c0104fdb +c01041e4: 85 c0 test %eax,%eax +c01041e6: 74 24 je c010420c +c01041e8: c7 44 24 0c 16 ab 10 movl $0xc010ab16,0xc(%esp) +c01041ef: c0 +c01041f0: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c01041f7: c0 +c01041f8: c7 44 24 04 58 01 00 movl $0x158,0x4(%esp) +c01041ff: 00 +c0104200: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0104207: e8 39 ca ff ff call c0100c45 <__panic> + assert(p0 + 2 == p1);// 确保分配的页面是释放的页面 +c010420c: 8b 45 e8 mov -0x18(%ebp),%eax +c010420f: 83 c0 40 add $0x40,%eax +c0104212: 39 45 e0 cmp %eax,-0x20(%ebp) +c0104215: 74 24 je c010423b +c0104217: c7 44 24 0c 1e ac 10 movl $0xc010ac1e,0xc(%esp) +c010421e: c0 +c010421f: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0104226: c0 +c0104227: c7 44 24 04 59 01 00 movl $0x159,0x4(%esp) +c010422e: 00 +c010422f: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0104236: e8 0a ca ff ff call c0100c45 <__panic> -//print_pgdir - print the PDT&PT -void -print_pgdir(void) { -c0104da8: f3 0f 1e fb endbr32 -c0104dac: 55 push %ebp -c0104dad: 89 e5 mov %esp,%ebp -c0104daf: 57 push %edi -c0104db0: 56 push %esi -c0104db1: 53 push %ebx -c0104db2: 83 ec 4c sub $0x4c,%esp - cprintf("-------------------- BEGIN --------------------\n"); -c0104db5: c7 04 24 64 b1 10 c0 movl $0xc010b164,(%esp) -c0104dbc: e8 16 b5 ff ff call c01002d7 - // 定义变量 left, right 和 perm - size_t left, right = 0, perm; -c0104dc1: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) - // 遍历页目录项 - while ((perm = get_pgtable_items(0, NPDEENTRY, right, vpd, &left, &right)) != 0) { -c0104dc8: e9 fa 00 00 00 jmp c0104ec7 - // 打印页目录项的信息 - cprintf("PDE(%03x) %08x-%08x %08x %s\n", right - left, -c0104dcd: 8b 45 e4 mov -0x1c(%ebp),%eax -c0104dd0: 89 04 24 mov %eax,(%esp) -c0104dd3: e8 d4 fe ff ff call c0104cac - left * PTSIZE, right * PTSIZE, (right - left) * PTSIZE, perm2str(perm)); -c0104dd8: 8b 4d dc mov -0x24(%ebp),%ecx -c0104ddb: 8b 55 e0 mov -0x20(%ebp),%edx -c0104dde: 29 d1 sub %edx,%ecx -c0104de0: 89 ca mov %ecx,%edx - cprintf("PDE(%03x) %08x-%08x %08x %s\n", right - left, -c0104de2: 89 d6 mov %edx,%esi -c0104de4: c1 e6 16 shl $0x16,%esi -c0104de7: 8b 55 dc mov -0x24(%ebp),%edx -c0104dea: 89 d3 mov %edx,%ebx -c0104dec: c1 e3 16 shl $0x16,%ebx -c0104def: 8b 55 e0 mov -0x20(%ebp),%edx -c0104df2: 89 d1 mov %edx,%ecx -c0104df4: c1 e1 16 shl $0x16,%ecx -c0104df7: 8b 7d dc mov -0x24(%ebp),%edi -c0104dfa: 8b 55 e0 mov -0x20(%ebp),%edx -c0104dfd: 29 d7 sub %edx,%edi -c0104dff: 89 fa mov %edi,%edx -c0104e01: 89 44 24 14 mov %eax,0x14(%esp) -c0104e05: 89 74 24 10 mov %esi,0x10(%esp) -c0104e09: 89 5c 24 0c mov %ebx,0xc(%esp) -c0104e0d: 89 4c 24 08 mov %ecx,0x8(%esp) -c0104e11: 89 54 24 04 mov %edx,0x4(%esp) -c0104e15: c7 04 24 95 b1 10 c0 movl $0xc010b195,(%esp) -c0104e1c: e8 b6 b4 ff ff call c01002d7 - // 计算页表项的起始和结束索引 - size_t l, r = left * NPTEENTRY; -c0104e21: 8b 45 e0 mov -0x20(%ebp),%eax -c0104e24: c1 e0 0a shl $0xa,%eax -c0104e27: 89 45 d4 mov %eax,-0x2c(%ebp) - // 遍历页表项 - while ((perm = get_pgtable_items(left * NPTEENTRY, right * NPTEENTRY, r, vpt, &l, &r)) != 0) { -c0104e2a: eb 54 jmp c0104e80 - // 打印页表项的信息 - cprintf(" |-- PTE(%05x) %08x-%08x %08x %s\n", r - l, -c0104e2c: 8b 45 e4 mov -0x1c(%ebp),%eax -c0104e2f: 89 04 24 mov %eax,(%esp) -c0104e32: e8 75 fe ff ff call c0104cac - l * PGSIZE, r * PGSIZE, (r - l) * PGSIZE, perm2str(perm)); -c0104e37: 8b 4d d4 mov -0x2c(%ebp),%ecx -c0104e3a: 8b 55 d8 mov -0x28(%ebp),%edx -c0104e3d: 29 d1 sub %edx,%ecx -c0104e3f: 89 ca mov %ecx,%edx - cprintf(" |-- PTE(%05x) %08x-%08x %08x %s\n", r - l, -c0104e41: 89 d6 mov %edx,%esi -c0104e43: c1 e6 0c shl $0xc,%esi -c0104e46: 8b 55 d4 mov -0x2c(%ebp),%edx -c0104e49: 89 d3 mov %edx,%ebx -c0104e4b: c1 e3 0c shl $0xc,%ebx -c0104e4e: 8b 55 d8 mov -0x28(%ebp),%edx -c0104e51: 89 d1 mov %edx,%ecx -c0104e53: c1 e1 0c shl $0xc,%ecx -c0104e56: 8b 7d d4 mov -0x2c(%ebp),%edi -c0104e59: 8b 55 d8 mov -0x28(%ebp),%edx -c0104e5c: 29 d7 sub %edx,%edi -c0104e5e: 89 fa mov %edi,%edx -c0104e60: 89 44 24 14 mov %eax,0x14(%esp) -c0104e64: 89 74 24 10 mov %esi,0x10(%esp) -c0104e68: 89 5c 24 0c mov %ebx,0xc(%esp) -c0104e6c: 89 4c 24 08 mov %ecx,0x8(%esp) -c0104e70: 89 54 24 04 mov %edx,0x4(%esp) -c0104e74: c7 04 24 b4 b1 10 c0 movl $0xc010b1b4,(%esp) -c0104e7b: e8 57 b4 ff ff call c01002d7 - while ((perm = get_pgtable_items(left * NPTEENTRY, right * NPTEENTRY, r, vpt, &l, &r)) != 0) { -c0104e80: be 00 00 c0 fa mov $0xfac00000,%esi -c0104e85: 8b 45 d4 mov -0x2c(%ebp),%eax -c0104e88: 8b 55 dc mov -0x24(%ebp),%edx -c0104e8b: 89 d3 mov %edx,%ebx -c0104e8d: c1 e3 0a shl $0xa,%ebx -c0104e90: 8b 55 e0 mov -0x20(%ebp),%edx -c0104e93: 89 d1 mov %edx,%ecx -c0104e95: c1 e1 0a shl $0xa,%ecx -c0104e98: 8d 55 d4 lea -0x2c(%ebp),%edx -c0104e9b: 89 54 24 14 mov %edx,0x14(%esp) -c0104e9f: 8d 55 d8 lea -0x28(%ebp),%edx -c0104ea2: 89 54 24 10 mov %edx,0x10(%esp) -c0104ea6: 89 74 24 0c mov %esi,0xc(%esp) -c0104eaa: 89 44 24 08 mov %eax,0x8(%esp) -c0104eae: 89 5c 24 04 mov %ebx,0x4(%esp) -c0104eb2: 89 0c 24 mov %ecx,(%esp) -c0104eb5: e8 38 fe ff ff call c0104cf2 -c0104eba: 89 45 e4 mov %eax,-0x1c(%ebp) -c0104ebd: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) -c0104ec1: 0f 85 65 ff ff ff jne c0104e2c - while ((perm = get_pgtable_items(0, NPDEENTRY, right, vpd, &left, &right)) != 0) { -c0104ec7: b9 00 b0 fe fa mov $0xfafeb000,%ecx -c0104ecc: 8b 45 dc mov -0x24(%ebp),%eax -c0104ecf: 8d 55 dc lea -0x24(%ebp),%edx -c0104ed2: 89 54 24 14 mov %edx,0x14(%esp) -c0104ed6: 8d 55 e0 lea -0x20(%ebp),%edx -c0104ed9: 89 54 24 10 mov %edx,0x10(%esp) -c0104edd: 89 4c 24 0c mov %ecx,0xc(%esp) -c0104ee1: 89 44 24 08 mov %eax,0x8(%esp) -c0104ee5: c7 44 24 04 00 04 00 movl $0x400,0x4(%esp) -c0104eec: 00 -c0104eed: c7 04 24 00 00 00 00 movl $0x0,(%esp) -c0104ef4: e8 f9 fd ff ff call c0104cf2 -c0104ef9: 89 45 e4 mov %eax,-0x1c(%ebp) -c0104efc: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) -c0104f00: 0f 85 c7 fe ff ff jne c0104dcd - } - } - cprintf("--------------------- END ---------------------\n"); -c0104f06: c7 04 24 d8 b1 10 c0 movl $0xc010b1d8,(%esp) -c0104f0d: e8 c5 b3 ff ff call c01002d7 -} -c0104f12: 90 nop -c0104f13: 83 c4 4c add $0x4c,%esp -c0104f16: 5b pop %ebx -c0104f17: 5e pop %esi -c0104f18: 5f pop %edi -c0104f19: 5d pop %ebp -c0104f1a: c3 ret - -c0104f1b <_fifo_init_mm>: - * (2) _fifo_init_mm: init pra_list_head and let mm->sm_priv point to the addr of pra_list_head. - * Now, From the memory control struct mm_struct, we can access FIFO PRA - */ -static int -_fifo_init_mm(struct mm_struct *mm) -{ -c0104f1b: f3 0f 1e fb endbr32 -c0104f1f: 55 push %ebp -c0104f20: 89 e5 mov %esp,%ebp -c0104f22: 83 ec 10 sub $0x10,%esp -c0104f25: c7 45 fc bc e0 12 c0 movl $0xc012e0bc,-0x4(%ebp) - * list_init - initialize a new entry - * @elm: new entry to be initialized - * */ -static inline void -list_init(list_entry_t *elm) { - elm->prev = elm->next = elm; -c0104f2c: 8b 45 fc mov -0x4(%ebp),%eax -c0104f2f: 8b 55 fc mov -0x4(%ebp),%edx -c0104f32: 89 50 04 mov %edx,0x4(%eax) -c0104f35: 8b 45 fc mov -0x4(%ebp),%eax -c0104f38: 8b 50 04 mov 0x4(%eax),%edx -c0104f3b: 8b 45 fc mov -0x4(%ebp),%eax -c0104f3e: 89 10 mov %edx,(%eax) -} -c0104f40: 90 nop - //初始化一个链表头 pra_list_head - list_init(&pra_list_head); - //将 mm 结构中的 sm_priv 字段指向这个链表头 - mm->sm_priv = &pra_list_head; -c0104f41: 8b 45 08 mov 0x8(%ebp),%eax -c0104f44: c7 40 14 bc e0 12 c0 movl $0xc012e0bc,0x14(%eax) - //cprintf(" mm->sm_priv %x in fifo_init_mm\n",mm->sm_priv); - //返回 0 表示成功 - return 0; -c0104f4b: b8 00 00 00 00 mov $0x0,%eax + p2 = p0 + 1;// 设置 p2 为 p0 的下一个页面 +c010423b: 8b 45 e8 mov -0x18(%ebp),%eax +c010423e: 83 c0 20 add $0x20,%eax +c0104241: 89 45 dc mov %eax,-0x24(%ebp) + free_page(p0);// 释放 p0 页面 +c0104244: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c010424b: 00 +c010424c: 8b 45 e8 mov -0x18(%ebp),%eax +c010424f: 89 04 24 mov %eax,(%esp) +c0104252: e8 f1 0d 00 00 call c0105048 + free_pages(p1, 3);// 释放 p1 指向的页面 +c0104257: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp) +c010425e: 00 +c010425f: 8b 45 e0 mov -0x20(%ebp),%eax +c0104262: 89 04 24 mov %eax,(%esp) +c0104265: e8 de 0d 00 00 call c0105048 + assert(PageProperty(p0) && p0->property == 1);// 检查 p0 属性 +c010426a: 8b 45 e8 mov -0x18(%ebp),%eax +c010426d: 83 c0 04 add $0x4,%eax +c0104270: c7 45 a0 01 00 00 00 movl $0x1,-0x60(%ebp) +c0104277: 89 45 9c mov %eax,-0x64(%ebp) + asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); +c010427a: 8b 45 9c mov -0x64(%ebp),%eax +c010427d: 8b 55 a0 mov -0x60(%ebp),%edx +c0104280: 0f a3 10 bt %edx,(%eax) +c0104283: 19 c0 sbb %eax,%eax +c0104285: 89 45 98 mov %eax,-0x68(%ebp) + return oldbit != 0; +c0104288: 83 7d 98 00 cmpl $0x0,-0x68(%ebp) +c010428c: 0f 95 c0 setne %al +c010428f: 0f b6 c0 movzbl %al,%eax +c0104292: 85 c0 test %eax,%eax +c0104294: 74 0b je c01042a1 +c0104296: 8b 45 e8 mov -0x18(%ebp),%eax +c0104299: 8b 40 08 mov 0x8(%eax),%eax +c010429c: 83 f8 01 cmp $0x1,%eax +c010429f: 74 24 je c01042c5 +c01042a1: c7 44 24 0c 2c ac 10 movl $0xc010ac2c,0xc(%esp) +c01042a8: c0 +c01042a9: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c01042b0: c0 +c01042b1: c7 44 24 04 5e 01 00 movl $0x15e,0x4(%esp) +c01042b8: 00 +c01042b9: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c01042c0: e8 80 c9 ff ff call c0100c45 <__panic> + assert(PageProperty(p1) && p1->property == 3);// 检查 p1 属性 +c01042c5: 8b 45 e0 mov -0x20(%ebp),%eax +c01042c8: 83 c0 04 add $0x4,%eax +c01042cb: c7 45 94 01 00 00 00 movl $0x1,-0x6c(%ebp) +c01042d2: 89 45 90 mov %eax,-0x70(%ebp) + asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); +c01042d5: 8b 45 90 mov -0x70(%ebp),%eax +c01042d8: 8b 55 94 mov -0x6c(%ebp),%edx +c01042db: 0f a3 10 bt %edx,(%eax) +c01042de: 19 c0 sbb %eax,%eax +c01042e0: 89 45 8c mov %eax,-0x74(%ebp) + return oldbit != 0; +c01042e3: 83 7d 8c 00 cmpl $0x0,-0x74(%ebp) +c01042e7: 0f 95 c0 setne %al +c01042ea: 0f b6 c0 movzbl %al,%eax +c01042ed: 85 c0 test %eax,%eax +c01042ef: 74 0b je c01042fc +c01042f1: 8b 45 e0 mov -0x20(%ebp),%eax +c01042f4: 8b 40 08 mov 0x8(%eax),%eax +c01042f7: 83 f8 03 cmp $0x3,%eax +c01042fa: 74 24 je c0104320 +c01042fc: c7 44 24 0c 54 ac 10 movl $0xc010ac54,0xc(%esp) +c0104303: c0 +c0104304: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c010430b: c0 +c010430c: c7 44 24 04 5f 01 00 movl $0x15f,0x4(%esp) +c0104313: 00 +c0104314: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c010431b: e8 25 c9 ff ff call c0100c45 <__panic> + // 确保重分配的页面是之前释放的页面 + assert((p0 = alloc_page()) == p2 - 1); +c0104320: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0104327: e8 af 0c 00 00 call c0104fdb +c010432c: 89 45 e8 mov %eax,-0x18(%ebp) +c010432f: 8b 45 dc mov -0x24(%ebp),%eax +c0104332: 83 e8 20 sub $0x20,%eax +c0104335: 39 45 e8 cmp %eax,-0x18(%ebp) +c0104338: 74 24 je c010435e +c010433a: c7 44 24 0c 7a ac 10 movl $0xc010ac7a,0xc(%esp) +c0104341: c0 +c0104342: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0104349: c0 +c010434a: c7 44 24 04 61 01 00 movl $0x161,0x4(%esp) +c0104351: 00 +c0104352: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0104359: e8 e7 c8 ff ff call c0100c45 <__panic> + free_page(p0);// 释放分配的页面 +c010435e: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0104365: 00 +c0104366: 8b 45 e8 mov -0x18(%ebp),%eax +c0104369: 89 04 24 mov %eax,(%esp) +c010436c: e8 d7 0c 00 00 call c0105048 + assert((p0 = alloc_pages(2)) == p2 + 1);// 分配 2 个页面并检查 +c0104371: c7 04 24 02 00 00 00 movl $0x2,(%esp) +c0104378: e8 5e 0c 00 00 call c0104fdb +c010437d: 89 45 e8 mov %eax,-0x18(%ebp) +c0104380: 8b 45 dc mov -0x24(%ebp),%eax +c0104383: 83 c0 20 add $0x20,%eax +c0104386: 39 45 e8 cmp %eax,-0x18(%ebp) +c0104389: 74 24 je c01043af +c010438b: c7 44 24 0c 98 ac 10 movl $0xc010ac98,0xc(%esp) +c0104392: c0 +c0104393: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c010439a: c0 +c010439b: c7 44 24 04 63 01 00 movl $0x163,0x4(%esp) +c01043a2: 00 +c01043a3: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c01043aa: e8 96 c8 ff ff call c0100c45 <__panic> + // 释放页面并检查空闲状态 + free_pages(p0, 2); +c01043af: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) +c01043b6: 00 +c01043b7: 8b 45 e8 mov -0x18(%ebp),%eax +c01043ba: 89 04 24 mov %eax,(%esp) +c01043bd: e8 86 0c 00 00 call c0105048 + free_page(p2); +c01043c2: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c01043c9: 00 +c01043ca: 8b 45 dc mov -0x24(%ebp),%eax +c01043cd: 89 04 24 mov %eax,(%esp) +c01043d0: e8 73 0c 00 00 call c0105048 + // 再次分配 5 个页面 + assert((p0 = alloc_pages(5)) != NULL); +c01043d5: c7 04 24 05 00 00 00 movl $0x5,(%esp) +c01043dc: e8 fa 0b 00 00 call c0104fdb +c01043e1: 89 45 e8 mov %eax,-0x18(%ebp) +c01043e4: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) +c01043e8: 75 24 jne c010440e +c01043ea: c7 44 24 0c b8 ac 10 movl $0xc010acb8,0xc(%esp) +c01043f1: c0 +c01043f2: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c01043f9: c0 +c01043fa: c7 44 24 04 68 01 00 movl $0x168,0x4(%esp) +c0104401: 00 +c0104402: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0104409: e8 37 c8 ff ff call c0100c45 <__panic> + assert(alloc_page() == NULL);// 确保没有额外页面可分配 +c010440e: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0104415: e8 c1 0b 00 00 call c0104fdb +c010441a: 85 c0 test %eax,%eax +c010441c: 74 24 je c0104442 +c010441e: c7 44 24 0c 16 ab 10 movl $0xc010ab16,0xc(%esp) +c0104425: c0 +c0104426: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c010442d: c0 +c010442e: c7 44 24 04 69 01 00 movl $0x169,0x4(%esp) +c0104435: 00 +c0104436: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c010443d: e8 03 c8 ff ff call c0100c45 <__panic> + + assert(nr_free == 0);// 确保空闲页数为 0 +c0104442: a1 ec bf 12 c0 mov 0xc012bfec,%eax +c0104447: 85 c0 test %eax,%eax +c0104449: 74 24 je c010446f +c010444b: c7 44 24 0c 69 ab 10 movl $0xc010ab69,0xc(%esp) +c0104452: c0 +c0104453: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c010445a: c0 +c010445b: c7 44 24 04 6b 01 00 movl $0x16b,0x4(%esp) +c0104462: 00 +c0104463: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c010446a: e8 d6 c7 ff ff call c0100c45 <__panic> + nr_free = nr_free_store;// 恢复空闲页数 +c010446f: 8b 45 e4 mov -0x1c(%ebp),%eax +c0104472: a3 ec bf 12 c0 mov %eax,0xc012bfec + // 恢复空闲列表状态 + free_list = free_list_store; +c0104477: 8b 45 80 mov -0x80(%ebp),%eax +c010447a: 8b 55 84 mov -0x7c(%ebp),%edx +c010447d: a3 e4 bf 12 c0 mov %eax,0xc012bfe4 +c0104482: 89 15 e8 bf 12 c0 mov %edx,0xc012bfe8 + free_pages(p0, 5);// 释放所有分配的页面 +c0104488: c7 44 24 04 05 00 00 movl $0x5,0x4(%esp) +c010448f: 00 +c0104490: 8b 45 e8 mov -0x18(%ebp),%eax +c0104493: 89 04 24 mov %eax,(%esp) +c0104496: e8 ad 0b 00 00 call c0105048 + // 验证空闲列表的一致性 + le = &free_list; +c010449b: c7 45 ec e4 bf 12 c0 movl $0xc012bfe4,-0x14(%ebp) + while ((le = list_next(le)) != &free_list) { +c01044a2: eb 1c jmp c01044c0 + struct Page *p = le2page(le, page_link); +c01044a4: 8b 45 ec mov -0x14(%ebp),%eax +c01044a7: 83 e8 0c sub $0xc,%eax +c01044aa: 89 45 d8 mov %eax,-0x28(%ebp) + count --, total -= p->property; +c01044ad: ff 4d f4 decl -0xc(%ebp) +c01044b0: 8b 55 f0 mov -0x10(%ebp),%edx +c01044b3: 8b 45 d8 mov -0x28(%ebp),%eax +c01044b6: 8b 48 08 mov 0x8(%eax),%ecx +c01044b9: 89 d0 mov %edx,%eax +c01044bb: 29 c8 sub %ecx,%eax +c01044bd: 89 45 f0 mov %eax,-0x10(%ebp) +c01044c0: 8b 45 ec mov -0x14(%ebp),%eax +c01044c3: 89 45 88 mov %eax,-0x78(%ebp) + return listelm->next; +c01044c6: 8b 45 88 mov -0x78(%ebp),%eax +c01044c9: 8b 40 04 mov 0x4(%eax),%eax + while ((le = list_next(le)) != &free_list) { +c01044cc: 89 45 ec mov %eax,-0x14(%ebp) +c01044cf: 81 7d ec e4 bf 12 c0 cmpl $0xc012bfe4,-0x14(%ebp) +c01044d6: 75 cc jne c01044a4 + } + assert(count == 0);// 确保所有页面都已处理 +c01044d8: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c01044dc: 74 24 je c0104502 +c01044de: c7 44 24 0c d6 ac 10 movl $0xc010acd6,0xc(%esp) +c01044e5: c0 +c01044e6: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c01044ed: c0 +c01044ee: c7 44 24 04 76 01 00 movl $0x176,0x4(%esp) +c01044f5: 00 +c01044f6: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c01044fd: e8 43 c7 ff ff call c0100c45 <__panic> + assert(total == 0);// 确保总属性值为 0 +c0104502: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c0104506: 74 24 je c010452c +c0104508: c7 44 24 0c e1 ac 10 movl $0xc010ace1,0xc(%esp) +c010450f: c0 +c0104510: c7 44 24 08 76 a9 10 movl $0xc010a976,0x8(%esp) +c0104517: c0 +c0104518: c7 44 24 04 77 01 00 movl $0x177,0x4(%esp) +c010451f: 00 +c0104520: c7 04 24 8b a9 10 c0 movl $0xc010a98b,(%esp) +c0104527: e8 19 c7 ff ff call c0100c45 <__panic> +} +c010452c: 90 nop +c010452d: 89 ec mov %ebp,%esp +c010452f: 5d pop %ebp +c0104530: c3 ret + +c0104531 <__intr_save>: +__intr_save(void) { +c0104531: 55 push %ebp +c0104532: 89 e5 mov %esp,%ebp +c0104534: 83 ec 18 sub $0x18,%esp + asm volatile ("pushfl; popl %0" : "=r" (eflags)); +c0104537: 9c pushf +c0104538: 58 pop %eax +c0104539: 89 45 f4 mov %eax,-0xc(%ebp) + return eflags; +c010453c: 8b 45 f4 mov -0xc(%ebp),%eax + if (read_eflags() & FL_IF) { +c010453f: 25 00 02 00 00 and $0x200,%eax +c0104544: 85 c0 test %eax,%eax +c0104546: 74 0c je c0104554 <__intr_save+0x23> + intr_disable(); +c0104548: e8 ae d9 ff ff call c0101efb + return 1; +c010454d: b8 01 00 00 00 mov $0x1,%eax +c0104552: eb 05 jmp c0104559 <__intr_save+0x28> + return 0; +c0104554: b8 00 00 00 00 mov $0x0,%eax } -c0104f50: c9 leave -c0104f51: c3 ret +c0104559: 89 ec mov %ebp,%esp +c010455b: 5d pop %ebp +c010455c: c3 ret -c0104f52 <_fifo_map_swappable>: -/* - * (3)_fifo_map_swappable: According FIFO PRA, we should link the most recent arrival page at the back of pra_list_head qeueue - */ -static int -_fifo_map_swappable(struct mm_struct *mm, uintptr_t addr, struct Page *page, int swap_in) -{ -c0104f52: f3 0f 1e fb endbr32 -c0104f56: 55 push %ebp -c0104f57: 89 e5 mov %esp,%ebp -c0104f59: 83 ec 48 sub $0x48,%esp - //获取 mm_struct 结构中的 sm_priv 指针, - //并将其转换为 list_entry_t 类型的链表头指针 head - list_entry_t *head=(list_entry_t*) mm->sm_priv; -c0104f5c: 8b 45 08 mov 0x8(%ebp),%eax -c0104f5f: 8b 40 14 mov 0x14(%eax),%eax -c0104f62: 89 45 f4 mov %eax,-0xc(%ebp) - list_entry_t *entry=&(page->pra_page_link); -c0104f65: 8b 45 10 mov 0x10(%ebp),%eax -c0104f68: 83 c0 14 add $0x14,%eax -c0104f6b: 89 45 f0 mov %eax,-0x10(%ebp) - - assert(entry != NULL && head != NULL); -c0104f6e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c0104f72: 74 06 je c0104f7a <_fifo_map_swappable+0x28> -c0104f74: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0104f78: 75 24 jne c0104f9e <_fifo_map_swappable+0x4c> -c0104f7a: c7 44 24 0c 0c b2 10 movl $0xc010b20c,0xc(%esp) -c0104f81: c0 -c0104f82: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c0104f89: c0 -c0104f8a: c7 44 24 04 37 00 00 movl $0x37,0x4(%esp) -c0104f91: 00 -c0104f92: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c0104f99: e8 a5 b4 ff ff call c0100443 <__panic> -c0104f9e: 8b 45 f4 mov -0xc(%ebp),%eax -c0104fa1: 89 45 ec mov %eax,-0x14(%ebp) -c0104fa4: 8b 45 f0 mov -0x10(%ebp),%eax -c0104fa7: 89 45 e8 mov %eax,-0x18(%ebp) -c0104faa: 8b 45 ec mov -0x14(%ebp),%eax -c0104fad: 89 45 e4 mov %eax,-0x1c(%ebp) -c0104fb0: 8b 45 e8 mov -0x18(%ebp),%eax -c0104fb3: 89 45 e0 mov %eax,-0x20(%ebp) - * Insert the new element @elm *after* the element @listelm which - * is already in the list. - * */ -static inline void -list_add_after(list_entry_t *listelm, list_entry_t *elm) { - __list_add(elm, listelm, listelm->next); -c0104fb6: 8b 45 e4 mov -0x1c(%ebp),%eax -c0104fb9: 8b 40 04 mov 0x4(%eax),%eax -c0104fbc: 8b 55 e0 mov -0x20(%ebp),%edx -c0104fbf: 89 55 dc mov %edx,-0x24(%ebp) -c0104fc2: 8b 55 e4 mov -0x1c(%ebp),%edx -c0104fc5: 89 55 d8 mov %edx,-0x28(%ebp) -c0104fc8: 89 45 d4 mov %eax,-0x2c(%ebp) - * This is only for internal list manipulation where we know - * the prev/next entries already! - * */ -static inline void -__list_add(list_entry_t *elm, list_entry_t *prev, list_entry_t *next) { - prev->next = next->prev = elm; -c0104fcb: 8b 45 d4 mov -0x2c(%ebp),%eax -c0104fce: 8b 55 dc mov -0x24(%ebp),%edx -c0104fd1: 89 10 mov %edx,(%eax) -c0104fd3: 8b 45 d4 mov -0x2c(%ebp),%eax -c0104fd6: 8b 10 mov (%eax),%edx -c0104fd8: 8b 45 d8 mov -0x28(%ebp),%eax -c0104fdb: 89 50 04 mov %edx,0x4(%eax) - elm->next = next; -c0104fde: 8b 45 dc mov -0x24(%ebp),%eax -c0104fe1: 8b 55 d4 mov -0x2c(%ebp),%edx -c0104fe4: 89 50 04 mov %edx,0x4(%eax) - elm->prev = prev; -c0104fe7: 8b 45 dc mov -0x24(%ebp),%eax -c0104fea: 8b 55 d8 mov -0x28(%ebp),%edx -c0104fed: 89 10 mov %edx,(%eax) +c010455d <__intr_restore>: +__intr_restore(bool flag) { +c010455d: 55 push %ebp +c010455e: 89 e5 mov %esp,%ebp +c0104560: 83 ec 08 sub $0x8,%esp + if (flag) { +c0104563: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0104567: 74 05 je c010456e <__intr_restore+0x11> + intr_enable(); +c0104569: e8 85 d9 ff ff call c0101ef3 } -c0104fef: 90 nop +c010456e: 90 nop +c010456f: 89 ec mov %ebp,%esp +c0104571: 5d pop %ebp +c0104572: c3 ret + +c0104573 : +page2ppn(struct Page *page) { +c0104573: 55 push %ebp +c0104574: 89 e5 mov %esp,%ebp + return page - pages; +c0104576: 8b 15 00 c0 12 c0 mov 0xc012c000,%edx +c010457c: 8b 45 08 mov 0x8(%ebp),%eax +c010457f: 29 d0 sub %edx,%eax +c0104581: c1 f8 05 sar $0x5,%eax } -c0104ff0: 90 nop +c0104584: 5d pop %ebp +c0104585: c3 ret + +c0104586 : +page2pa(struct Page *page) { +c0104586: 55 push %ebp +c0104587: 89 e5 mov %esp,%ebp +c0104589: 83 ec 04 sub $0x4,%esp + return page2ppn(page) << PGSHIFT; +c010458c: 8b 45 08 mov 0x8(%ebp),%eax +c010458f: 89 04 24 mov %eax,(%esp) +c0104592: e8 dc ff ff ff call c0104573 +c0104597: c1 e0 0c shl $0xc,%eax } -c0104ff1: 90 nop - //record the page access situlation - /*LAB3 EXERCISE 2: YOUR CODE*/ - //(1)link the most recent arrival page at the back of the pra_list_head qeueue. - //将最近到达的页面链接到 pra_list_head 队列的末尾 - list_add(head, entry); - return 0; -c0104ff2: b8 00 00 00 00 mov $0x0,%eax +c010459a: 89 ec mov %ebp,%esp +c010459c: 5d pop %ebp +c010459d: c3 ret + +c010459e : +pa2page(uintptr_t pa) { +c010459e: 55 push %ebp +c010459f: 89 e5 mov %esp,%ebp +c01045a1: 83 ec 18 sub $0x18,%esp + if (PPN(pa) >= npage) { +c01045a4: 8b 45 08 mov 0x8(%ebp),%eax +c01045a7: c1 e8 0c shr $0xc,%eax +c01045aa: 89 c2 mov %eax,%edx +c01045ac: a1 04 c0 12 c0 mov 0xc012c004,%eax +c01045b1: 39 c2 cmp %eax,%edx +c01045b3: 72 1c jb c01045d1 + panic("pa2page called with invalid pa"); +c01045b5: c7 44 24 08 1c ad 10 movl $0xc010ad1c,0x8(%esp) +c01045bc: c0 +c01045bd: c7 44 24 04 5f 00 00 movl $0x5f,0x4(%esp) +c01045c4: 00 +c01045c5: c7 04 24 3b ad 10 c0 movl $0xc010ad3b,(%esp) +c01045cc: e8 74 c6 ff ff call c0100c45 <__panic> + return &pages[PPN(pa)]; +c01045d1: 8b 15 00 c0 12 c0 mov 0xc012c000,%edx +c01045d7: 8b 45 08 mov 0x8(%ebp),%eax +c01045da: c1 e8 0c shr $0xc,%eax +c01045dd: c1 e0 05 shl $0x5,%eax +c01045e0: 01 d0 add %edx,%eax } -c0104ff7: c9 leave -c0104ff8: c3 ret +c01045e2: 89 ec mov %ebp,%esp +c01045e4: 5d pop %ebp +c01045e5: c3 ret -c0104ff9 <_fifo_swap_out_victim>: - * - * @return 返回0表示成功,其他值表示失败。 - */ -static int -_fifo_swap_out_victim(struct mm_struct *mm, struct Page ** ptr_page, int in_tick) +c01045e6 : +page2kva(struct Page *page) { +c01045e6: 55 push %ebp +c01045e7: 89 e5 mov %esp,%ebp +c01045e9: 83 ec 28 sub $0x28,%esp + return KADDR(page2pa(page)); +c01045ec: 8b 45 08 mov 0x8(%ebp),%eax +c01045ef: 89 04 24 mov %eax,(%esp) +c01045f2: e8 8f ff ff ff call c0104586 +c01045f7: 89 45 f4 mov %eax,-0xc(%ebp) +c01045fa: 8b 45 f4 mov -0xc(%ebp),%eax +c01045fd: c1 e8 0c shr $0xc,%eax +c0104600: 89 45 f0 mov %eax,-0x10(%ebp) +c0104603: a1 04 c0 12 c0 mov 0xc012c004,%eax +c0104608: 39 45 f0 cmp %eax,-0x10(%ebp) +c010460b: 72 23 jb c0104630 +c010460d: 8b 45 f4 mov -0xc(%ebp),%eax +c0104610: 89 44 24 0c mov %eax,0xc(%esp) +c0104614: c7 44 24 08 4c ad 10 movl $0xc010ad4c,0x8(%esp) +c010461b: c0 +c010461c: c7 44 24 04 66 00 00 movl $0x66,0x4(%esp) +c0104623: 00 +c0104624: c7 04 24 3b ad 10 c0 movl $0xc010ad3b,(%esp) +c010462b: e8 15 c6 ff ff call c0100c45 <__panic> +c0104630: 8b 45 f4 mov -0xc(%ebp),%eax +c0104633: 2d 00 00 00 40 sub $0x40000000,%eax +} +c0104638: 89 ec mov %ebp,%esp +c010463a: 5d pop %ebp +c010463b: c3 ret + +c010463c : +kva2page(void *kva) { +c010463c: 55 push %ebp +c010463d: 89 e5 mov %esp,%ebp +c010463f: 83 ec 28 sub $0x28,%esp + return pa2page(PADDR(kva)); +c0104642: 8b 45 08 mov 0x8(%ebp),%eax +c0104645: 89 45 f4 mov %eax,-0xc(%ebp) +c0104648: 81 7d f4 ff ff ff bf cmpl $0xbfffffff,-0xc(%ebp) +c010464f: 77 23 ja c0104674 +c0104651: 8b 45 f4 mov -0xc(%ebp),%eax +c0104654: 89 44 24 0c mov %eax,0xc(%esp) +c0104658: c7 44 24 08 70 ad 10 movl $0xc010ad70,0x8(%esp) +c010465f: c0 +c0104660: c7 44 24 04 6b 00 00 movl $0x6b,0x4(%esp) +c0104667: 00 +c0104668: c7 04 24 3b ad 10 c0 movl $0xc010ad3b,(%esp) +c010466f: e8 d1 c5 ff ff call c0100c45 <__panic> +c0104674: 8b 45 f4 mov -0xc(%ebp),%eax +c0104677: 05 00 00 00 40 add $0x40000000,%eax +c010467c: 89 04 24 mov %eax,(%esp) +c010467f: e8 1a ff ff ff call c010459e +} +c0104684: 89 ec mov %ebp,%esp +c0104686: 5d pop %ebp +c0104687: c3 ret + +c0104688 <__slob_get_free_pages>: +static slob_t *slobfree = &arena; +static bigblock_t *bigblocks; + + +static void* __slob_get_free_pages(gfp_t gfp, int order) { -c0104ff9: f3 0f 1e fb endbr32 -c0104ffd: 55 push %ebp -c0104ffe: 89 e5 mov %esp,%ebp -c0105000: 83 ec 38 sub $0x38,%esp - list_entry_t *head=(list_entry_t*) mm->sm_priv; -c0105003: 8b 45 08 mov 0x8(%ebp),%eax -c0105006: 8b 40 14 mov 0x14(%eax),%eax -c0105009: 89 45 f4 mov %eax,-0xc(%ebp) - assert(head != NULL); -c010500c: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0105010: 75 24 jne c0105036 <_fifo_swap_out_victim+0x3d> -c0105012: c7 44 24 0c 53 b2 10 movl $0xc010b253,0xc(%esp) -c0105019: c0 -c010501a: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c0105021: c0 -c0105022: c7 44 24 04 50 00 00 movl $0x50,0x4(%esp) -c0105029: 00 -c010502a: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c0105031: e8 0d b4 ff ff call c0100443 <__panic> - assert(in_tick==0); -c0105036: 83 7d 10 00 cmpl $0x0,0x10(%ebp) -c010503a: 74 24 je c0105060 <_fifo_swap_out_victim+0x67> -c010503c: c7 44 24 0c 60 b2 10 movl $0xc010b260,0xc(%esp) -c0105043: c0 -c0105044: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c010504b: c0 -c010504c: c7 44 24 04 51 00 00 movl $0x51,0x4(%esp) -c0105053: 00 -c0105054: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c010505b: e8 e3 b3 ff ff call c0100443 <__panic> - /* Select the victim */ - /*LAB3 EXERCISE 2: YOUR CODE*/ - //(1) unlink the earliest arrival page in front of pra_list_head qeueue - //(2) assign the value of *ptr_page to the addr of this page - //head->prev 获取链表中最先到达的页面 - list_entry_t *le = head->prev; -c0105060: 8b 45 f4 mov -0xc(%ebp),%eax -c0105063: 8b 00 mov (%eax),%eax -c0105065: 89 45 f0 mov %eax,-0x10(%ebp) - assert(head!=le); -c0105068: 8b 45 f4 mov -0xc(%ebp),%eax -c010506b: 3b 45 f0 cmp -0x10(%ebp),%eax -c010506e: 75 24 jne c0105094 <_fifo_swap_out_victim+0x9b> -c0105070: c7 44 24 0c 6b b2 10 movl $0xc010b26b,0xc(%esp) -c0105077: c0 -c0105078: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c010507f: c0 -c0105080: c7 44 24 04 58 00 00 movl $0x58,0x4(%esp) -c0105087: 00 -c0105088: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c010508f: e8 af b3 ff ff call c0100443 <__panic> - struct Page *p = le2page(le, pra_page_link); -c0105094: 8b 45 f0 mov -0x10(%ebp),%eax -c0105097: 83 e8 14 sub $0x14,%eax -c010509a: 89 45 ec mov %eax,-0x14(%ebp) -c010509d: 8b 45 f0 mov -0x10(%ebp),%eax -c01050a0: 89 45 e8 mov %eax,-0x18(%ebp) - __list_del(listelm->prev, listelm->next); -c01050a3: 8b 45 e8 mov -0x18(%ebp),%eax -c01050a6: 8b 40 04 mov 0x4(%eax),%eax -c01050a9: 8b 55 e8 mov -0x18(%ebp),%edx -c01050ac: 8b 12 mov (%edx),%edx -c01050ae: 89 55 e4 mov %edx,-0x1c(%ebp) -c01050b1: 89 45 e0 mov %eax,-0x20(%ebp) - * This is only for internal list manipulation where we know - * the prev/next entries already! - * */ -static inline void -__list_del(list_entry_t *prev, list_entry_t *next) { - prev->next = next; -c01050b4: 8b 45 e4 mov -0x1c(%ebp),%eax -c01050b7: 8b 55 e0 mov -0x20(%ebp),%edx -c01050ba: 89 50 04 mov %edx,0x4(%eax) - next->prev = prev; -c01050bd: 8b 45 e0 mov -0x20(%ebp),%eax -c01050c0: 8b 55 e4 mov -0x1c(%ebp),%edx -c01050c3: 89 10 mov %edx,(%eax) -} -c01050c5: 90 nop -} -c01050c6: 90 nop - //使用 list_del 函数将该页面从链表中移除。 - list_del(le); - assert(p != NULL); -c01050c7: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) -c01050cb: 75 24 jne c01050f1 <_fifo_swap_out_victim+0xf8> -c01050cd: c7 44 24 0c 74 b2 10 movl $0xc010b274,0xc(%esp) -c01050d4: c0 -c01050d5: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c01050dc: c0 -c01050dd: c7 44 24 04 5c 00 00 movl $0x5c,0x4(%esp) -c01050e4: 00 -c01050e5: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c01050ec: e8 52 b3 ff ff call c0100443 <__panic> - //将移除的页面指针赋值给 *ptr_page - *ptr_page = p; -c01050f1: 8b 45 0c mov 0xc(%ebp),%eax -c01050f4: 8b 55 ec mov -0x14(%ebp),%edx -c01050f7: 89 10 mov %edx,(%eax) - - return 0; -c01050f9: b8 00 00 00 00 mov $0x0,%eax +c0104688: 55 push %ebp +c0104689: 89 e5 mov %esp,%ebp +c010468b: 83 ec 28 sub $0x28,%esp + struct Page * page = alloc_pages(1 << order); +c010468e: 8b 45 0c mov 0xc(%ebp),%eax +c0104691: ba 01 00 00 00 mov $0x1,%edx +c0104696: 88 c1 mov %al,%cl +c0104698: d3 e2 shl %cl,%edx +c010469a: 89 d0 mov %edx,%eax +c010469c: 89 04 24 mov %eax,(%esp) +c010469f: e8 37 09 00 00 call c0104fdb +c01046a4: 89 45 f4 mov %eax,-0xc(%ebp) + if(!page) +c01046a7: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c01046ab: 75 07 jne c01046b4 <__slob_get_free_pages+0x2c> + return NULL; +c01046ad: b8 00 00 00 00 mov $0x0,%eax +c01046b2: eb 0b jmp c01046bf <__slob_get_free_pages+0x37> + return page2kva(page); +c01046b4: 8b 45 f4 mov -0xc(%ebp),%eax +c01046b7: 89 04 24 mov %eax,(%esp) +c01046ba: e8 27 ff ff ff call c01045e6 } -c01050fe: c9 leave -c01050ff: c3 ret +c01046bf: 89 ec mov %ebp,%esp +c01046c1: 5d pop %ebp +c01046c2: c3 ret -c0105100 <_fifo_check_swap>: - * - * 返回值: - * - 0: 表示所有检查均通过。 - */ -static int -_fifo_check_swap(void) { -c0105100: f3 0f 1e fb endbr32 -c0105104: 55 push %ebp -c0105105: 89 e5 mov %esp,%ebp -c0105107: 83 ec 18 sub $0x18,%esp - // 写入虚拟页 c 并检查页面故障数 - cprintf("write Virt Page c in fifo_check_swap\n"); -c010510a: c7 04 24 80 b2 10 c0 movl $0xc010b280,(%esp) -c0105111: e8 c1 b1 ff ff call c01002d7 - *(unsigned char *)0x3000 = 0x0c; -c0105116: b8 00 30 00 00 mov $0x3000,%eax -c010511b: c6 00 0c movb $0xc,(%eax) - assert(pgfault_num==4); -c010511e: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0105123: 83 f8 04 cmp $0x4,%eax -c0105126: 74 24 je c010514c <_fifo_check_swap+0x4c> -c0105128: c7 44 24 0c a6 b2 10 movl $0xc010b2a6,0xc(%esp) -c010512f: c0 -c0105130: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c0105137: c0 -c0105138: c7 44 24 04 70 00 00 movl $0x70,0x4(%esp) -c010513f: 00 -c0105140: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c0105147: e8 f7 b2 ff ff call c0100443 <__panic> +c01046c3 <__slob_free_pages>: - // 写入虚拟页 a 并检查页面故障数 - cprintf("write Virt Page a in fifo_check_swap\n"); -c010514c: c7 04 24 b8 b2 10 c0 movl $0xc010b2b8,(%esp) -c0105153: e8 7f b1 ff ff call c01002d7 - *(unsigned char *)0x1000 = 0x0a; -c0105158: b8 00 10 00 00 mov $0x1000,%eax -c010515d: c6 00 0a movb $0xa,(%eax) - assert(pgfault_num==4); -c0105160: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0105165: 83 f8 04 cmp $0x4,%eax -c0105168: 74 24 je c010518e <_fifo_check_swap+0x8e> -c010516a: c7 44 24 0c a6 b2 10 movl $0xc010b2a6,0xc(%esp) -c0105171: c0 -c0105172: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c0105179: c0 -c010517a: c7 44 24 04 75 00 00 movl $0x75,0x4(%esp) -c0105181: 00 -c0105182: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c0105189: e8 b5 b2 ff ff call c0100443 <__panic> +#define __slob_get_free_page(gfp) __slob_get_free_pages(gfp, 0) - // 写入虚拟页 d 并检查页面故障数 - cprintf("write Virt Page d in fifo_check_swap\n"); -c010518e: c7 04 24 e0 b2 10 c0 movl $0xc010b2e0,(%esp) -c0105195: e8 3d b1 ff ff call c01002d7 - *(unsigned char *)0x4000 = 0x0d; -c010519a: b8 00 40 00 00 mov $0x4000,%eax -c010519f: c6 00 0d movb $0xd,(%eax) - assert(pgfault_num==4); -c01051a2: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c01051a7: 83 f8 04 cmp $0x4,%eax -c01051aa: 74 24 je c01051d0 <_fifo_check_swap+0xd0> -c01051ac: c7 44 24 0c a6 b2 10 movl $0xc010b2a6,0xc(%esp) -c01051b3: c0 -c01051b4: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c01051bb: c0 -c01051bc: c7 44 24 04 7a 00 00 movl $0x7a,0x4(%esp) -c01051c3: 00 -c01051c4: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c01051cb: e8 73 b2 ff ff call c0100443 <__panic> +static inline void __slob_free_pages(unsigned long kva, int order) +{ +c01046c3: 55 push %ebp +c01046c4: 89 e5 mov %esp,%ebp +c01046c6: 83 ec 18 sub $0x18,%esp +c01046c9: 89 5d fc mov %ebx,-0x4(%ebp) + free_pages(kva2page(kva), 1 << order); +c01046cc: 8b 45 0c mov 0xc(%ebp),%eax +c01046cf: ba 01 00 00 00 mov $0x1,%edx +c01046d4: 88 c1 mov %al,%cl +c01046d6: d3 e2 shl %cl,%edx +c01046d8: 89 d0 mov %edx,%eax +c01046da: 89 c3 mov %eax,%ebx +c01046dc: 8b 45 08 mov 0x8(%ebp),%eax +c01046df: 89 04 24 mov %eax,(%esp) +c01046e2: e8 55 ff ff ff call c010463c +c01046e7: 89 5c 24 04 mov %ebx,0x4(%esp) +c01046eb: 89 04 24 mov %eax,(%esp) +c01046ee: e8 55 09 00 00 call c0105048 +} +c01046f3: 90 nop +c01046f4: 8b 5d fc mov -0x4(%ebp),%ebx +c01046f7: 89 ec mov %ebp,%esp +c01046f9: 5d pop %ebp +c01046fa: c3 ret + +c01046fb : - // 写入虚拟页 b 并检查页面故障数 - cprintf("write Virt Page b in fifo_check_swap\n"); -c01051d0: c7 04 24 08 b3 10 c0 movl $0xc010b308,(%esp) -c01051d7: e8 fb b0 ff ff call c01002d7 - *(unsigned char *)0x2000 = 0x0b; -c01051dc: b8 00 20 00 00 mov $0x2000,%eax -c01051e1: c6 00 0b movb $0xb,(%eax) - assert(pgfault_num==4); -c01051e4: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c01051e9: 83 f8 04 cmp $0x4,%eax -c01051ec: 74 24 je c0105212 <_fifo_check_swap+0x112> -c01051ee: c7 44 24 0c a6 b2 10 movl $0xc010b2a6,0xc(%esp) -c01051f5: c0 -c01051f6: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c01051fd: c0 -c01051fe: c7 44 24 04 7f 00 00 movl $0x7f,0x4(%esp) -c0105205: 00 -c0105206: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c010520d: e8 31 b2 ff ff call c0100443 <__panic> +static void slob_free(void *b, int size); - // 写入虚拟页 e 并检查页面故障数 - cprintf("write Virt Page e in fifo_check_swap\n"); -c0105212: c7 04 24 30 b3 10 c0 movl $0xc010b330,(%esp) -c0105219: e8 b9 b0 ff ff call c01002d7 - *(unsigned char *)0x5000 = 0x0e; -c010521e: b8 00 50 00 00 mov $0x5000,%eax -c0105223: c6 00 0e movb $0xe,(%eax) - assert(pgfault_num==5); -c0105226: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c010522b: 83 f8 05 cmp $0x5,%eax -c010522e: 74 24 je c0105254 <_fifo_check_swap+0x154> -c0105230: c7 44 24 0c 56 b3 10 movl $0xc010b356,0xc(%esp) -c0105237: c0 -c0105238: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c010523f: c0 -c0105240: c7 44 24 04 84 00 00 movl $0x84,0x4(%esp) -c0105247: 00 -c0105248: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c010524f: e8 ef b1 ff ff call c0100443 <__panic> +static void *slob_alloc(size_t size, gfp_t gfp, int align) +{ +c01046fb: 55 push %ebp +c01046fc: 89 e5 mov %esp,%ebp +c01046fe: 83 ec 38 sub $0x38,%esp + assert( (size + SLOB_UNIT) < PAGE_SIZE ); +c0104701: 8b 45 08 mov 0x8(%ebp),%eax +c0104704: 83 c0 08 add $0x8,%eax +c0104707: 3d ff 0f 00 00 cmp $0xfff,%eax +c010470c: 76 24 jbe c0104732 +c010470e: c7 44 24 0c 94 ad 10 movl $0xc010ad94,0xc(%esp) +c0104715: c0 +c0104716: c7 44 24 08 b3 ad 10 movl $0xc010adb3,0x8(%esp) +c010471d: c0 +c010471e: c7 44 24 04 64 00 00 movl $0x64,0x4(%esp) +c0104725: 00 +c0104726: c7 04 24 c8 ad 10 c0 movl $0xc010adc8,(%esp) +c010472d: e8 13 c5 ff ff call c0100c45 <__panic> - // 再次写入虚拟页 b 并检查页面故障数 - cprintf("write Virt Page b in fifo_check_swap\n"); -c0105254: c7 04 24 08 b3 10 c0 movl $0xc010b308,(%esp) -c010525b: e8 77 b0 ff ff call c01002d7 - *(unsigned char *)0x2000 = 0x0b; -c0105260: b8 00 20 00 00 mov $0x2000,%eax -c0105265: c6 00 0b movb $0xb,(%eax) - assert(pgfault_num==5); -c0105268: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c010526d: 83 f8 05 cmp $0x5,%eax -c0105270: 74 24 je c0105296 <_fifo_check_swap+0x196> -c0105272: c7 44 24 0c 56 b3 10 movl $0xc010b356,0xc(%esp) -c0105279: c0 -c010527a: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c0105281: c0 -c0105282: c7 44 24 04 89 00 00 movl $0x89,0x4(%esp) -c0105289: 00 -c010528a: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c0105291: e8 ad b1 ff ff call c0100443 <__panic> + slob_t *prev, *cur, *aligned = 0; +c0104732: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) + int delta = 0, units = SLOB_UNITS(size); +c0104739: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp) +c0104740: 8b 45 08 mov 0x8(%ebp),%eax +c0104743: 83 c0 07 add $0x7,%eax +c0104746: c1 e8 03 shr $0x3,%eax +c0104749: 89 45 e0 mov %eax,-0x20(%ebp) + unsigned long flags; - // 再次写入虚拟页 a 并检查页面故障数 - cprintf("write Virt Page a in fifo_check_swap\n"); -c0105296: c7 04 24 b8 b2 10 c0 movl $0xc010b2b8,(%esp) -c010529d: e8 35 b0 ff ff call c01002d7 - *(unsigned char *)0x1000 = 0x0a; -c01052a2: b8 00 10 00 00 mov $0x1000,%eax -c01052a7: c6 00 0a movb $0xa,(%eax) - assert(pgfault_num==6); -c01052aa: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c01052af: 83 f8 06 cmp $0x6,%eax -c01052b2: 74 24 je c01052d8 <_fifo_check_swap+0x1d8> -c01052b4: c7 44 24 0c 65 b3 10 movl $0xc010b365,0xc(%esp) -c01052bb: c0 -c01052bc: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c01052c3: c0 -c01052c4: c7 44 24 04 8e 00 00 movl $0x8e,0x4(%esp) -c01052cb: 00 -c01052cc: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c01052d3: e8 6b b1 ff ff call c0100443 <__panic> + spin_lock_irqsave(&slob_lock, flags); +c010474c: e8 e0 fd ff ff call c0104531 <__intr_save> +c0104751: 89 45 e4 mov %eax,-0x1c(%ebp) + prev = slobfree; +c0104754: a1 e8 89 12 c0 mov 0xc01289e8,%eax +c0104759: 89 45 f4 mov %eax,-0xc(%ebp) + for (cur = prev->next; ; prev = cur, cur = cur->next) { +c010475c: 8b 45 f4 mov -0xc(%ebp),%eax +c010475f: 8b 40 04 mov 0x4(%eax),%eax +c0104762: 89 45 f0 mov %eax,-0x10(%ebp) + if (align) { +c0104765: 83 7d 10 00 cmpl $0x0,0x10(%ebp) +c0104769: 74 21 je c010478c + aligned = (slob_t *)ALIGN((unsigned long)cur, align); +c010476b: 8b 55 f0 mov -0x10(%ebp),%edx +c010476e: 8b 45 10 mov 0x10(%ebp),%eax +c0104771: 01 d0 add %edx,%eax +c0104773: 8d 50 ff lea -0x1(%eax),%edx +c0104776: 8b 45 10 mov 0x10(%ebp),%eax +c0104779: f7 d8 neg %eax +c010477b: 21 d0 and %edx,%eax +c010477d: 89 45 ec mov %eax,-0x14(%ebp) + delta = aligned - cur; +c0104780: 8b 45 ec mov -0x14(%ebp),%eax +c0104783: 2b 45 f0 sub -0x10(%ebp),%eax +c0104786: c1 f8 03 sar $0x3,%eax +c0104789: 89 45 e8 mov %eax,-0x18(%ebp) + } + if (cur->units >= units + delta) { /* room enough? */ +c010478c: 8b 45 f0 mov -0x10(%ebp),%eax +c010478f: 8b 00 mov (%eax),%eax +c0104791: 8b 4d e0 mov -0x20(%ebp),%ecx +c0104794: 8b 55 e8 mov -0x18(%ebp),%edx +c0104797: 01 ca add %ecx,%edx +c0104799: 39 d0 cmp %edx,%eax +c010479b: 0f 8c aa 00 00 00 jl c010484b + if (delta) { /* need to fragment head to align? */ +c01047a1: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) +c01047a5: 74 38 je c01047df + aligned->units = cur->units - delta; +c01047a7: 8b 45 f0 mov -0x10(%ebp),%eax +c01047aa: 8b 00 mov (%eax),%eax +c01047ac: 2b 45 e8 sub -0x18(%ebp),%eax +c01047af: 89 c2 mov %eax,%edx +c01047b1: 8b 45 ec mov -0x14(%ebp),%eax +c01047b4: 89 10 mov %edx,(%eax) + aligned->next = cur->next; +c01047b6: 8b 45 f0 mov -0x10(%ebp),%eax +c01047b9: 8b 50 04 mov 0x4(%eax),%edx +c01047bc: 8b 45 ec mov -0x14(%ebp),%eax +c01047bf: 89 50 04 mov %edx,0x4(%eax) + cur->next = aligned; +c01047c2: 8b 45 f0 mov -0x10(%ebp),%eax +c01047c5: 8b 55 ec mov -0x14(%ebp),%edx +c01047c8: 89 50 04 mov %edx,0x4(%eax) + cur->units = delta; +c01047cb: 8b 45 f0 mov -0x10(%ebp),%eax +c01047ce: 8b 55 e8 mov -0x18(%ebp),%edx +c01047d1: 89 10 mov %edx,(%eax) + prev = cur; +c01047d3: 8b 45 f0 mov -0x10(%ebp),%eax +c01047d6: 89 45 f4 mov %eax,-0xc(%ebp) + cur = aligned; +c01047d9: 8b 45 ec mov -0x14(%ebp),%eax +c01047dc: 89 45 f0 mov %eax,-0x10(%ebp) + } - // 再次写入虚拟页 b 并检查页面故障数 - cprintf("write Virt Page b in fifo_check_swap\n"); -c01052d8: c7 04 24 08 b3 10 c0 movl $0xc010b308,(%esp) -c01052df: e8 f3 af ff ff call c01002d7 - *(unsigned char *)0x2000 = 0x0b; -c01052e4: b8 00 20 00 00 mov $0x2000,%eax -c01052e9: c6 00 0b movb $0xb,(%eax) - assert(pgfault_num==7); -c01052ec: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c01052f1: 83 f8 07 cmp $0x7,%eax -c01052f4: 74 24 je c010531a <_fifo_check_swap+0x21a> -c01052f6: c7 44 24 0c 74 b3 10 movl $0xc010b374,0xc(%esp) -c01052fd: c0 -c01052fe: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c0105305: c0 -c0105306: c7 44 24 04 93 00 00 movl $0x93,0x4(%esp) -c010530d: 00 -c010530e: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c0105315: e8 29 b1 ff ff call c0100443 <__panic> + if (cur->units == units) /* exact fit? */ +c01047df: 8b 45 f0 mov -0x10(%ebp),%eax +c01047e2: 8b 00 mov (%eax),%eax +c01047e4: 39 45 e0 cmp %eax,-0x20(%ebp) +c01047e7: 75 0e jne c01047f7 + prev->next = cur->next; /* unlink */ +c01047e9: 8b 45 f0 mov -0x10(%ebp),%eax +c01047ec: 8b 50 04 mov 0x4(%eax),%edx +c01047ef: 8b 45 f4 mov -0xc(%ebp),%eax +c01047f2: 89 50 04 mov %edx,0x4(%eax) +c01047f5: eb 3c jmp c0104833 + else { /* fragment */ + prev->next = cur + units; +c01047f7: 8b 45 e0 mov -0x20(%ebp),%eax +c01047fa: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx +c0104801: 8b 45 f0 mov -0x10(%ebp),%eax +c0104804: 01 c2 add %eax,%edx +c0104806: 8b 45 f4 mov -0xc(%ebp),%eax +c0104809: 89 50 04 mov %edx,0x4(%eax) + prev->next->units = cur->units - units; +c010480c: 8b 45 f0 mov -0x10(%ebp),%eax +c010480f: 8b 10 mov (%eax),%edx +c0104811: 8b 45 f4 mov -0xc(%ebp),%eax +c0104814: 8b 40 04 mov 0x4(%eax),%eax +c0104817: 2b 55 e0 sub -0x20(%ebp),%edx +c010481a: 89 10 mov %edx,(%eax) + prev->next->next = cur->next; +c010481c: 8b 45 f4 mov -0xc(%ebp),%eax +c010481f: 8b 40 04 mov 0x4(%eax),%eax +c0104822: 8b 55 f0 mov -0x10(%ebp),%edx +c0104825: 8b 52 04 mov 0x4(%edx),%edx +c0104828: 89 50 04 mov %edx,0x4(%eax) + cur->units = units; +c010482b: 8b 45 f0 mov -0x10(%ebp),%eax +c010482e: 8b 55 e0 mov -0x20(%ebp),%edx +c0104831: 89 10 mov %edx,(%eax) + } - // 再次写入虚拟页 c 并检查页面故障数 - cprintf("write Virt Page c in fifo_check_swap\n"); -c010531a: c7 04 24 80 b2 10 c0 movl $0xc010b280,(%esp) -c0105321: e8 b1 af ff ff call c01002d7 - *(unsigned char *)0x3000 = 0x0c; -c0105326: b8 00 30 00 00 mov $0x3000,%eax -c010532b: c6 00 0c movb $0xc,(%eax) - assert(pgfault_num==8); -c010532e: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0105333: 83 f8 08 cmp $0x8,%eax -c0105336: 74 24 je c010535c <_fifo_check_swap+0x25c> -c0105338: c7 44 24 0c 83 b3 10 movl $0xc010b383,0xc(%esp) -c010533f: c0 -c0105340: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c0105347: c0 -c0105348: c7 44 24 04 98 00 00 movl $0x98,0x4(%esp) -c010534f: 00 -c0105350: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c0105357: e8 e7 b0 ff ff call c0100443 <__panic> + slobfree = prev; +c0104833: 8b 45 f4 mov -0xc(%ebp),%eax +c0104836: a3 e8 89 12 c0 mov %eax,0xc01289e8 + spin_unlock_irqrestore(&slob_lock, flags); +c010483b: 8b 45 e4 mov -0x1c(%ebp),%eax +c010483e: 89 04 24 mov %eax,(%esp) +c0104841: e8 17 fd ff ff call c010455d <__intr_restore> + return cur; +c0104846: 8b 45 f0 mov -0x10(%ebp),%eax +c0104849: eb 7f jmp c01048ca + } + if (cur == slobfree) { +c010484b: a1 e8 89 12 c0 mov 0xc01289e8,%eax +c0104850: 39 45 f0 cmp %eax,-0x10(%ebp) +c0104853: 75 61 jne c01048b6 + spin_unlock_irqrestore(&slob_lock, flags); +c0104855: 8b 45 e4 mov -0x1c(%ebp),%eax +c0104858: 89 04 24 mov %eax,(%esp) +c010485b: e8 fd fc ff ff call c010455d <__intr_restore> - // 再次写入虚拟页 d 并检查页面故障数 - cprintf("write Virt Page d in fifo_check_swap\n"); -c010535c: c7 04 24 e0 b2 10 c0 movl $0xc010b2e0,(%esp) -c0105363: e8 6f af ff ff call c01002d7 - *(unsigned char *)0x4000 = 0x0d; -c0105368: b8 00 40 00 00 mov $0x4000,%eax -c010536d: c6 00 0d movb $0xd,(%eax) - assert(pgfault_num==9); -c0105370: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0105375: 83 f8 09 cmp $0x9,%eax -c0105378: 74 24 je c010539e <_fifo_check_swap+0x29e> -c010537a: c7 44 24 0c 92 b3 10 movl $0xc010b392,0xc(%esp) -c0105381: c0 -c0105382: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c0105389: c0 -c010538a: c7 44 24 04 9d 00 00 movl $0x9d,0x4(%esp) -c0105391: 00 -c0105392: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c0105399: e8 a5 b0 ff ff call c0100443 <__panic> + if (size == PAGE_SIZE) /* trying to shrink arena? */ +c0104860: 81 7d 08 00 10 00 00 cmpl $0x1000,0x8(%ebp) +c0104867: 75 07 jne c0104870 + return 0; +c0104869: b8 00 00 00 00 mov $0x0,%eax +c010486e: eb 5a jmp c01048ca - // 再次写入虚拟页 e 并检查页面故障数 - cprintf("write Virt Page e in fifo_check_swap\n"); -c010539e: c7 04 24 30 b3 10 c0 movl $0xc010b330,(%esp) -c01053a5: e8 2d af ff ff call c01002d7 - *(unsigned char *)0x5000 = 0x0e; -c01053aa: b8 00 50 00 00 mov $0x5000,%eax -c01053af: c6 00 0e movb $0xe,(%eax) - assert(pgfault_num==10); -c01053b2: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c01053b7: 83 f8 0a cmp $0xa,%eax -c01053ba: 74 24 je c01053e0 <_fifo_check_swap+0x2e0> -c01053bc: c7 44 24 0c a1 b3 10 movl $0xc010b3a1,0xc(%esp) -c01053c3: c0 -c01053c4: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c01053cb: c0 -c01053cc: c7 44 24 04 a2 00 00 movl $0xa2,0x4(%esp) -c01053d3: 00 -c01053d4: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c01053db: e8 63 b0 ff ff call c0100443 <__panic> + cur = (slob_t *)__slob_get_free_page(gfp); +c0104870: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0104877: 00 +c0104878: 8b 45 0c mov 0xc(%ebp),%eax +c010487b: 89 04 24 mov %eax,(%esp) +c010487e: e8 05 fe ff ff call c0104688 <__slob_get_free_pages> +c0104883: 89 45 f0 mov %eax,-0x10(%ebp) + if (!cur) +c0104886: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c010488a: 75 07 jne c0104893 + return 0; +c010488c: b8 00 00 00 00 mov $0x0,%eax +c0104891: eb 37 jmp c01048ca - // 再次写入虚拟页 a 并检查页面故障数 - cprintf("write Virt Page a in fifo_check_swap\n"); -c01053e0: c7 04 24 b8 b2 10 c0 movl $0xc010b2b8,(%esp) -c01053e7: e8 eb ae ff ff call c01002d7 - assert(*(unsigned char *)0x1000 == 0x0a); -c01053ec: b8 00 10 00 00 mov $0x1000,%eax -c01053f1: 0f b6 00 movzbl (%eax),%eax -c01053f4: 3c 0a cmp $0xa,%al -c01053f6: 74 24 je c010541c <_fifo_check_swap+0x31c> -c01053f8: c7 44 24 0c b4 b3 10 movl $0xc010b3b4,0xc(%esp) -c01053ff: c0 -c0105400: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c0105407: c0 -c0105408: c7 44 24 04 a6 00 00 movl $0xa6,0x4(%esp) -c010540f: 00 -c0105410: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c0105417: e8 27 b0 ff ff call c0100443 <__panic> - *(unsigned char *)0x1000 = 0x0a; -c010541c: b8 00 10 00 00 mov $0x1000,%eax -c0105421: c6 00 0a movb $0xa,(%eax) - assert(pgfault_num==11); -c0105424: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0105429: 83 f8 0b cmp $0xb,%eax -c010542c: 74 24 je c0105452 <_fifo_check_swap+0x352> -c010542e: c7 44 24 0c d5 b3 10 movl $0xc010b3d5,0xc(%esp) -c0105435: c0 -c0105436: c7 44 24 08 2a b2 10 movl $0xc010b22a,0x8(%esp) -c010543d: c0 -c010543e: c7 44 24 04 a8 00 00 movl $0xa8,0x4(%esp) -c0105445: 00 -c0105446: c7 04 24 3f b2 10 c0 movl $0xc010b23f,(%esp) -c010544d: e8 f1 af ff ff call c0100443 <__panic> - return 0; -c0105452: b8 00 00 00 00 mov $0x0,%eax + slob_free(cur, PAGE_SIZE); +c0104893: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) +c010489a: 00 +c010489b: 8b 45 f0 mov -0x10(%ebp),%eax +c010489e: 89 04 24 mov %eax,(%esp) +c01048a1: e8 28 00 00 00 call c01048ce + spin_lock_irqsave(&slob_lock, flags); +c01048a6: e8 86 fc ff ff call c0104531 <__intr_save> +c01048ab: 89 45 e4 mov %eax,-0x1c(%ebp) + cur = slobfree; +c01048ae: a1 e8 89 12 c0 mov 0xc01289e8,%eax +c01048b3: 89 45 f0 mov %eax,-0x10(%ebp) + for (cur = prev->next; ; prev = cur, cur = cur->next) { +c01048b6: 8b 45 f0 mov -0x10(%ebp),%eax +c01048b9: 89 45 f4 mov %eax,-0xc(%ebp) +c01048bc: 8b 45 f0 mov -0x10(%ebp),%eax +c01048bf: 8b 40 04 mov 0x4(%eax),%eax +c01048c2: 89 45 f0 mov %eax,-0x10(%ebp) + if (align) { +c01048c5: e9 9b fe ff ff jmp c0104765 + } + } +} +c01048ca: 89 ec mov %ebp,%esp +c01048cc: 5d pop %ebp +c01048cd: c3 ret + +c01048ce : + +static void slob_free(void *block, int size) +{ +c01048ce: 55 push %ebp +c01048cf: 89 e5 mov %esp,%ebp +c01048d1: 83 ec 28 sub $0x28,%esp + slob_t *cur, *b = (slob_t *)block; +c01048d4: 8b 45 08 mov 0x8(%ebp),%eax +c01048d7: 89 45 f0 mov %eax,-0x10(%ebp) + unsigned long flags; + + if (!block) +c01048da: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c01048de: 0f 84 01 01 00 00 je c01049e5 + return; + + if (size) +c01048e4: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) +c01048e8: 74 10 je c01048fa + b->units = SLOB_UNITS(size); +c01048ea: 8b 45 0c mov 0xc(%ebp),%eax +c01048ed: 83 c0 07 add $0x7,%eax +c01048f0: c1 e8 03 shr $0x3,%eax +c01048f3: 89 c2 mov %eax,%edx +c01048f5: 8b 45 f0 mov -0x10(%ebp),%eax +c01048f8: 89 10 mov %edx,(%eax) + + /* Find reinsertion point */ + spin_lock_irqsave(&slob_lock, flags); +c01048fa: e8 32 fc ff ff call c0104531 <__intr_save> +c01048ff: 89 45 ec mov %eax,-0x14(%ebp) + for (cur = slobfree; !(b > cur && b < cur->next); cur = cur->next) +c0104902: a1 e8 89 12 c0 mov 0xc01289e8,%eax +c0104907: 89 45 f4 mov %eax,-0xc(%ebp) +c010490a: eb 27 jmp c0104933 + if (cur >= cur->next && (b > cur || b < cur->next)) +c010490c: 8b 45 f4 mov -0xc(%ebp),%eax +c010490f: 8b 40 04 mov 0x4(%eax),%eax +c0104912: 39 45 f4 cmp %eax,-0xc(%ebp) +c0104915: 72 13 jb c010492a +c0104917: 8b 45 f0 mov -0x10(%ebp),%eax +c010491a: 3b 45 f4 cmp -0xc(%ebp),%eax +c010491d: 77 27 ja c0104946 +c010491f: 8b 45 f4 mov -0xc(%ebp),%eax +c0104922: 8b 40 04 mov 0x4(%eax),%eax +c0104925: 39 45 f0 cmp %eax,-0x10(%ebp) +c0104928: 72 1c jb c0104946 + for (cur = slobfree; !(b > cur && b < cur->next); cur = cur->next) +c010492a: 8b 45 f4 mov -0xc(%ebp),%eax +c010492d: 8b 40 04 mov 0x4(%eax),%eax +c0104930: 89 45 f4 mov %eax,-0xc(%ebp) +c0104933: 8b 45 f0 mov -0x10(%ebp),%eax +c0104936: 3b 45 f4 cmp -0xc(%ebp),%eax +c0104939: 76 d1 jbe c010490c +c010493b: 8b 45 f4 mov -0xc(%ebp),%eax +c010493e: 8b 40 04 mov 0x4(%eax),%eax +c0104941: 39 45 f0 cmp %eax,-0x10(%ebp) +c0104944: 73 c6 jae c010490c + break; + + if (b + b->units == cur->next) { +c0104946: 8b 45 f0 mov -0x10(%ebp),%eax +c0104949: 8b 00 mov (%eax),%eax +c010494b: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx +c0104952: 8b 45 f0 mov -0x10(%ebp),%eax +c0104955: 01 c2 add %eax,%edx +c0104957: 8b 45 f4 mov -0xc(%ebp),%eax +c010495a: 8b 40 04 mov 0x4(%eax),%eax +c010495d: 39 c2 cmp %eax,%edx +c010495f: 75 25 jne c0104986 + b->units += cur->next->units; +c0104961: 8b 45 f0 mov -0x10(%ebp),%eax +c0104964: 8b 10 mov (%eax),%edx +c0104966: 8b 45 f4 mov -0xc(%ebp),%eax +c0104969: 8b 40 04 mov 0x4(%eax),%eax +c010496c: 8b 00 mov (%eax),%eax +c010496e: 01 c2 add %eax,%edx +c0104970: 8b 45 f0 mov -0x10(%ebp),%eax +c0104973: 89 10 mov %edx,(%eax) + b->next = cur->next->next; +c0104975: 8b 45 f4 mov -0xc(%ebp),%eax +c0104978: 8b 40 04 mov 0x4(%eax),%eax +c010497b: 8b 50 04 mov 0x4(%eax),%edx +c010497e: 8b 45 f0 mov -0x10(%ebp),%eax +c0104981: 89 50 04 mov %edx,0x4(%eax) +c0104984: eb 0c jmp c0104992 + } else + b->next = cur->next; +c0104986: 8b 45 f4 mov -0xc(%ebp),%eax +c0104989: 8b 50 04 mov 0x4(%eax),%edx +c010498c: 8b 45 f0 mov -0x10(%ebp),%eax +c010498f: 89 50 04 mov %edx,0x4(%eax) + + if (cur + cur->units == b) { +c0104992: 8b 45 f4 mov -0xc(%ebp),%eax +c0104995: 8b 00 mov (%eax),%eax +c0104997: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx +c010499e: 8b 45 f4 mov -0xc(%ebp),%eax +c01049a1: 01 d0 add %edx,%eax +c01049a3: 39 45 f0 cmp %eax,-0x10(%ebp) +c01049a6: 75 1f jne c01049c7 + cur->units += b->units; +c01049a8: 8b 45 f4 mov -0xc(%ebp),%eax +c01049ab: 8b 10 mov (%eax),%edx +c01049ad: 8b 45 f0 mov -0x10(%ebp),%eax +c01049b0: 8b 00 mov (%eax),%eax +c01049b2: 01 c2 add %eax,%edx +c01049b4: 8b 45 f4 mov -0xc(%ebp),%eax +c01049b7: 89 10 mov %edx,(%eax) + cur->next = b->next; +c01049b9: 8b 45 f0 mov -0x10(%ebp),%eax +c01049bc: 8b 50 04 mov 0x4(%eax),%edx +c01049bf: 8b 45 f4 mov -0xc(%ebp),%eax +c01049c2: 89 50 04 mov %edx,0x4(%eax) +c01049c5: eb 09 jmp c01049d0 + } else + cur->next = b; +c01049c7: 8b 45 f4 mov -0xc(%ebp),%eax +c01049ca: 8b 55 f0 mov -0x10(%ebp),%edx +c01049cd: 89 50 04 mov %edx,0x4(%eax) + + slobfree = cur; +c01049d0: 8b 45 f4 mov -0xc(%ebp),%eax +c01049d3: a3 e8 89 12 c0 mov %eax,0xc01289e8 + + spin_unlock_irqrestore(&slob_lock, flags); +c01049d8: 8b 45 ec mov -0x14(%ebp),%eax +c01049db: 89 04 24 mov %eax,(%esp) +c01049de: e8 7a fb ff ff call c010455d <__intr_restore> +c01049e3: eb 01 jmp c01049e6 + return; +c01049e5: 90 nop } -c0105457: c9 leave -c0105458: c3 ret +c01049e6: 89 ec mov %ebp,%esp +c01049e8: 5d pop %ebp +c01049e9: c3 ret -c0105459 <_fifo_init>: +c01049ea : -static int -_fifo_init(void) -{ -c0105459: f3 0f 1e fb endbr32 -c010545d: 55 push %ebp -c010545e: 89 e5 mov %esp,%ebp - return 0; -c0105460: b8 00 00 00 00 mov $0x0,%eax + +void +slob_init(void) { +c01049ea: 55 push %ebp +c01049eb: 89 e5 mov %esp,%ebp +c01049ed: 83 ec 18 sub $0x18,%esp + cprintf("use SLOB allocator\n"); +c01049f0: c7 04 24 da ad 10 c0 movl $0xc010adda,(%esp) +c01049f7: e8 7c b9 ff ff call c0100378 } -c0105465: 5d pop %ebp -c0105466: c3 ret +c01049fc: 90 nop +c01049fd: 89 ec mov %ebp,%esp +c01049ff: 5d pop %ebp +c0104a00: c3 ret -c0105467 <_fifo_set_unswappable>: +c0104a01 : -static int -_fifo_set_unswappable(struct mm_struct *mm, uintptr_t addr) -{ -c0105467: f3 0f 1e fb endbr32 -c010546b: 55 push %ebp -c010546c: 89 e5 mov %esp,%ebp - return 0; -c010546e: b8 00 00 00 00 mov $0x0,%eax +inline void +kmalloc_init(void) { +c0104a01: 55 push %ebp +c0104a02: 89 e5 mov %esp,%ebp +c0104a04: 83 ec 18 sub $0x18,%esp + slob_init(); +c0104a07: e8 de ff ff ff call c01049ea + cprintf("kmalloc_init() succeeded!\n"); +c0104a0c: c7 04 24 ee ad 10 c0 movl $0xc010adee,(%esp) +c0104a13: e8 60 b9 ff ff call c0100378 } -c0105473: 5d pop %ebp -c0105474: c3 ret +c0104a18: 90 nop +c0104a19: 89 ec mov %ebp,%esp +c0104a1b: 5d pop %ebp +c0104a1c: c3 ret -c0105475 <_fifo_tick_event>: +c0104a1d : -static int -_fifo_tick_event(struct mm_struct *mm) -{ return 0; } -c0105475: f3 0f 1e fb endbr32 -c0105479: 55 push %ebp -c010547a: 89 e5 mov %esp,%ebp -c010547c: b8 00 00 00 00 mov $0x0,%eax -c0105481: 5d pop %ebp -c0105482: c3 ret - -c0105483 : -pa2page(uintptr_t pa) { -c0105483: 55 push %ebp -c0105484: 89 e5 mov %esp,%ebp -c0105486: 83 ec 18 sub $0x18,%esp - if (PPN(pa) >= npage) { -c0105489: 8b 45 08 mov 0x8(%ebp),%eax -c010548c: c1 e8 0c shr $0xc,%eax -c010548f: 89 c2 mov %eax,%edx -c0105491: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0105496: 39 c2 cmp %eax,%edx -c0105498: 72 1c jb c01054b6 - panic("pa2page called with invalid pa"); -c010549a: c7 44 24 08 f8 b3 10 movl $0xc010b3f8,0x8(%esp) -c01054a1: c0 -c01054a2: c7 44 24 04 5f 00 00 movl $0x5f,0x4(%esp) -c01054a9: 00 -c01054aa: c7 04 24 17 b4 10 c0 movl $0xc010b417,(%esp) -c01054b1: e8 8d af ff ff call c0100443 <__panic> - return &pages[PPN(pa)]; -c01054b6: a1 b8 e0 12 c0 mov 0xc012e0b8,%eax -c01054bb: 8b 55 08 mov 0x8(%ebp),%edx -c01054be: c1 ea 0c shr $0xc,%edx -c01054c1: c1 e2 05 shl $0x5,%edx -c01054c4: 01 d0 add %edx,%eax +size_t +slob_allocated(void) { +c0104a1d: 55 push %ebp +c0104a1e: 89 e5 mov %esp,%ebp + return 0; +c0104a20: b8 00 00 00 00 mov $0x0,%eax } -c01054c6: c9 leave -c01054c7: c3 ret +c0104a25: 5d pop %ebp +c0104a26: c3 ret -c01054c8 : -pde2page(pde_t pde) { -c01054c8: 55 push %ebp -c01054c9: 89 e5 mov %esp,%ebp -c01054cb: 83 ec 18 sub $0x18,%esp - return pa2page(PDE_ADDR(pde)); -c01054ce: 8b 45 08 mov 0x8(%ebp),%eax -c01054d1: 25 00 f0 ff ff and $0xfffff000,%eax -c01054d6: 89 04 24 mov %eax,(%esp) -c01054d9: e8 a5 ff ff ff call c0105483 -} -c01054de: c9 leave -c01054df: c3 ret +c0104a27 : -c01054e0 : - * 它包括内存映射列表、页目录、映射缓存等重要信息 - * - * @return 分配并初始化后的`mm_struct`结构体指针,如果分配失败则返回NULL - */ -struct mm_struct * -mm_create(void) { -c01054e0: f3 0f 1e fb endbr32 -c01054e4: 55 push %ebp -c01054e5: 89 e5 mov %esp,%ebp -c01054e7: 83 ec 28 sub $0x28,%esp - // 分配一个mm_struct结构体的空间 - struct mm_struct *mm = kmalloc(sizeof(struct mm_struct)); -c01054ea: c7 04 24 18 00 00 00 movl $0x18,(%esp) -c01054f1: e8 40 13 00 00 call c0106836 -c01054f6: 89 45 f4 mov %eax,-0xc(%ebp) - // 检查是否成功分配了内存 - if (mm != NULL) { -c01054f9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c01054fd: 74 59 je c0105558 - // 初始化内存映射列表 - list_init(&(mm->mmap_list)); -c01054ff: 8b 45 f4 mov -0xc(%ebp),%eax -c0105502: 89 45 f0 mov %eax,-0x10(%ebp) - elm->prev = elm->next = elm; -c0105505: 8b 45 f0 mov -0x10(%ebp),%eax -c0105508: 8b 55 f0 mov -0x10(%ebp),%edx -c010550b: 89 50 04 mov %edx,0x4(%eax) -c010550e: 8b 45 f0 mov -0x10(%ebp),%eax -c0105511: 8b 50 04 mov 0x4(%eax),%edx -c0105514: 8b 45 f0 mov -0x10(%ebp),%eax -c0105517: 89 10 mov %edx,(%eax) -} -c0105519: 90 nop - // 设置映射缓存为NULL,表示尚未缓存任何映射 - mm->mmap_cache = NULL; -c010551a: 8b 45 f4 mov -0xc(%ebp),%eax -c010551d: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) - // 设置页目录为NULL,表示尚未分配页目录 - mm->pgdir = NULL; -c0105524: 8b 45 f4 mov -0xc(%ebp),%eax -c0105527: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) - // 初始化映射计数为0,表示尚未创建任何内存映射 - mm->map_count = 0; -c010552e: 8b 45 f4 mov -0xc(%ebp),%eax -c0105531: c7 40 10 00 00 00 00 movl $0x0,0x10(%eax) - // 如果交换空间初始化成功,则为当前内存管理结构体进行交换空间初始化 - if (swap_init_ok) swap_init_mm(mm); -c0105538: a1 14 c0 12 c0 mov 0xc012c014,%eax -c010553d: 85 c0 test %eax,%eax -c010553f: 74 0d je c010554e -c0105541: 8b 45 f4 mov -0xc(%ebp),%eax -c0105544: 89 04 24 mov %eax,(%esp) -c0105547: e8 65 15 00 00 call c0106ab1 -c010554c: eb 0a jmp c0105558 - else mm->sm_priv = NULL; -c010554e: 8b 45 f4 mov -0xc(%ebp),%eax -c0105551: c7 40 14 00 00 00 00 movl $0x0,0x14(%eax) - } - // 返回分配并初始化后的内存管理结构体指针 - return mm; -c0105558: 8b 45 f4 mov -0xc(%ebp),%eax +size_t +kallocated(void) { +c0104a27: 55 push %ebp +c0104a28: 89 e5 mov %esp,%ebp + return slob_allocated(); +c0104a2a: e8 ee ff ff ff call c0104a1d } -c010555b: c9 leave -c010555c: c3 ret +c0104a2f: 5d pop %ebp +c0104a30: c3 ret -c010555d : - * @param vm_flags 虚拟内存区域的标志,表示内存区域的权限和特性。 - * - * @return 返回指向新创建的vma_struct结构体的指针,如果内存分配失败,则返回NULL。 - */ -struct vma_struct * -vma_create(uintptr_t vm_start, uintptr_t vm_end, uint32_t vm_flags) { -c010555d: f3 0f 1e fb endbr32 -c0105561: 55 push %ebp -c0105562: 89 e5 mov %esp,%ebp -c0105564: 83 ec 28 sub $0x28,%esp - // 分配vma_struct结构体所需的内存空间 - struct vma_struct *vma = kmalloc(sizeof(struct vma_struct)); -c0105567: c7 04 24 18 00 00 00 movl $0x18,(%esp) -c010556e: e8 c3 12 00 00 call c0106836 -c0105573: 89 45 f4 mov %eax,-0xc(%ebp) - // 检查内存是否成功分配 - if (vma != NULL) { -c0105576: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c010557a: 74 1b je c0105597 - // 初始化vma_struct的成员变量 - vma->vm_start = vm_start; -c010557c: 8b 45 f4 mov -0xc(%ebp),%eax -c010557f: 8b 55 08 mov 0x8(%ebp),%edx -c0105582: 89 50 04 mov %edx,0x4(%eax) - vma->vm_end = vm_end; -c0105585: 8b 45 f4 mov -0xc(%ebp),%eax -c0105588: 8b 55 0c mov 0xc(%ebp),%edx -c010558b: 89 50 08 mov %edx,0x8(%eax) - vma->vm_flags = vm_flags; -c010558e: 8b 45 f4 mov -0xc(%ebp),%eax -c0105591: 8b 55 10 mov 0x10(%ebp),%edx -c0105594: 89 50 0c mov %edx,0xc(%eax) - } - // 返回指向新创建的vma_struct结构体的指针,或在内存分配失败时返回NULL - return vma; -c0105597: 8b 45 f4 mov -0xc(%ebp),%eax -} -c010559a: c9 leave -c010559b: c3 ret +c0104a31 : -c010559c : - * 此函数首先检查mmap_cache是否包含所需的VMA,以加速查找过程 - * 如果mmap_cache未命中,则遍历VMA列表,直到找到包含给定地址的VMA或确定不存在这样的VMA - * 如果找到了合适的VMA,它将更新mmap_cache以供后续查找使用 - */ -struct vma_struct * -find_vma(struct mm_struct *mm, uintptr_t addr) { -c010559c: f3 0f 1e fb endbr32 -c01055a0: 55 push %ebp -c01055a1: 89 e5 mov %esp,%ebp -c01055a3: 83 ec 20 sub $0x20,%esp - struct vma_struct *vma = NULL;// 初始化VMA指针为NULL -c01055a6: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) - if (mm != NULL) {// 检查传入的内存描述符是否有效 -c01055ad: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c01055b1: 0f 84 95 00 00 00 je c010564c - // 检查mmap_cache是否包含所需的VMA - vma = mm->mmap_cache; -c01055b7: 8b 45 08 mov 0x8(%ebp),%eax -c01055ba: 8b 40 08 mov 0x8(%eax),%eax -c01055bd: 89 45 fc mov %eax,-0x4(%ebp) - if (!(vma != NULL && vma->vm_start <= addr && vma->vm_end > addr)) { -c01055c0: 83 7d fc 00 cmpl $0x0,-0x4(%ebp) -c01055c4: 74 16 je c01055dc -c01055c6: 8b 45 fc mov -0x4(%ebp),%eax -c01055c9: 8b 40 04 mov 0x4(%eax),%eax -c01055cc: 39 45 0c cmp %eax,0xc(%ebp) -c01055cf: 72 0b jb c01055dc -c01055d1: 8b 45 fc mov -0x4(%ebp),%eax -c01055d4: 8b 40 08 mov 0x8(%eax),%eax -c01055d7: 39 45 0c cmp %eax,0xc(%ebp) -c01055da: 72 61 jb c010563d - // 如果mmap_cache未命中,则开始遍历VMA列表 - bool found = 0;// 初始化找到标志为0 -c01055dc: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%ebp) - // 获取VMA列表的头指针 - list_entry_t *list = &(mm->mmap_list), *le = list; -c01055e3: 8b 45 08 mov 0x8(%ebp),%eax -c01055e6: 89 45 f0 mov %eax,-0x10(%ebp) -c01055e9: 8b 45 f0 mov -0x10(%ebp),%eax -c01055ec: 89 45 f4 mov %eax,-0xc(%ebp) - while ((le = list_next(le)) != list) { // 遍历VMA列表 -c01055ef: eb 28 jmp c0105619 - vma = le2vma(le, list_link);// 将链表项转换为VMA结构 -c01055f1: 8b 45 f4 mov -0xc(%ebp),%eax -c01055f4: 83 e8 10 sub $0x10,%eax -c01055f7: 89 45 fc mov %eax,-0x4(%ebp) - // 检查当前VMA是否包含给定地址 - if (vma->vm_start<=addr && addr < vma->vm_end) { -c01055fa: 8b 45 fc mov -0x4(%ebp),%eax -c01055fd: 8b 40 04 mov 0x4(%eax),%eax -c0105600: 39 45 0c cmp %eax,0xc(%ebp) -c0105603: 72 14 jb c0105619 -c0105605: 8b 45 fc mov -0x4(%ebp),%eax -c0105608: 8b 40 08 mov 0x8(%eax),%eax -c010560b: 39 45 0c cmp %eax,0xc(%ebp) -c010560e: 73 09 jae c0105619 - found = 1;// 找到合适的VMA -c0105610: c7 45 f8 01 00 00 00 movl $0x1,-0x8(%ebp) - break;// 结束循环 -c0105617: eb 17 jmp c0105630 -c0105619: 8b 45 f4 mov -0xc(%ebp),%eax -c010561c: 89 45 ec mov %eax,-0x14(%ebp) - return listelm->next; -c010561f: 8b 45 ec mov -0x14(%ebp),%eax -c0105622: 8b 40 04 mov 0x4(%eax),%eax - while ((le = list_next(le)) != list) { // 遍历VMA列表 -c0105625: 89 45 f4 mov %eax,-0xc(%ebp) -c0105628: 8b 45 f4 mov -0xc(%ebp),%eax -c010562b: 3b 45 f0 cmp -0x10(%ebp),%eax -c010562e: 75 c1 jne c01055f1 - } - } - if (!found) {// 如果未找到合适的VMA -c0105630: 83 7d f8 00 cmpl $0x0,-0x8(%ebp) -c0105634: 75 07 jne c010563d - vma = NULL;// 将VMA指针设置为NULL -c0105636: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) - } - } - // 如果找到了合适的VMA,更新mmap_cache - if (vma != NULL) { -c010563d: 83 7d fc 00 cmpl $0x0,-0x4(%ebp) -c0105641: 74 09 je c010564c - mm->mmap_cache = vma;// 更新mmap_cache以加速后续查找 -c0105643: 8b 45 08 mov 0x8(%ebp),%eax -c0105646: 8b 55 fc mov -0x4(%ebp),%edx -c0105649: 89 50 08 mov %edx,0x8(%eax) - } - } - return vma; -c010564c: 8b 45 fc mov -0x4(%ebp),%eax +static int find_order(int size) +{ +c0104a31: 55 push %ebp +c0104a32: 89 e5 mov %esp,%ebp +c0104a34: 83 ec 10 sub $0x10,%esp + int order = 0; +c0104a37: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) + for ( ; size > 4096 ; size >>=1) +c0104a3e: eb 06 jmp c0104a46 + order++; +c0104a40: ff 45 fc incl -0x4(%ebp) + for ( ; size > 4096 ; size >>=1) +c0104a43: d1 7d 08 sarl 0x8(%ebp) +c0104a46: 81 7d 08 00 10 00 00 cmpl $0x1000,0x8(%ebp) +c0104a4d: 7f f1 jg c0104a40 + return order; +c0104a4f: 8b 45 fc mov -0x4(%ebp),%eax } -c010564f: c9 leave -c0105650: c3 ret +c0104a52: 89 ec mov %ebp,%esp +c0104a54: 5d pop %ebp +c0104a55: c3 ret -c0105651 : - * - * @param prev 指向前一个虚拟内存区域(VMA)的结构体指针 - * @param next 指向后一个虚拟内存区域(VMA)的结构体指针 - */ -static inline void -check_vma_overlap(struct vma_struct *prev, struct vma_struct *next) { -c0105651: 55 push %ebp -c0105652: 89 e5 mov %esp,%ebp -c0105654: 83 ec 18 sub $0x18,%esp - assert(prev->vm_start < prev->vm_end);// 确保前一个VMA的地址范围是有效的 -c0105657: 8b 45 08 mov 0x8(%ebp),%eax -c010565a: 8b 50 04 mov 0x4(%eax),%edx -c010565d: 8b 45 08 mov 0x8(%ebp),%eax -c0105660: 8b 40 08 mov 0x8(%eax),%eax -c0105663: 39 c2 cmp %eax,%edx -c0105665: 72 24 jb c010568b -c0105667: c7 44 24 0c 25 b4 10 movl $0xc010b425,0xc(%esp) -c010566e: c0 -c010566f: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105676: c0 -c0105677: c7 44 24 04 a0 00 00 movl $0xa0,0x4(%esp) -c010567e: 00 -c010567f: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105686: e8 b8 ad ff ff call c0100443 <__panic> - assert(prev->vm_end <= next->vm_start);// 确保两个VMA之间没有重叠 -c010568b: 8b 45 08 mov 0x8(%ebp),%eax -c010568e: 8b 50 08 mov 0x8(%eax),%edx -c0105691: 8b 45 0c mov 0xc(%ebp),%eax -c0105694: 8b 40 04 mov 0x4(%eax),%eax -c0105697: 39 c2 cmp %eax,%edx -c0105699: 76 24 jbe c01056bf -c010569b: c7 44 24 0c 68 b4 10 movl $0xc010b468,0xc(%esp) -c01056a2: c0 -c01056a3: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c01056aa: c0 -c01056ab: c7 44 24 04 a1 00 00 movl $0xa1,0x4(%esp) -c01056b2: 00 -c01056b3: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c01056ba: e8 84 ad ff ff call c0100443 <__panic> - assert(next->vm_start < next->vm_end);// 确保后一个VMA的地址范围是有效的 -c01056bf: 8b 45 0c mov 0xc(%ebp),%eax -c01056c2: 8b 50 04 mov 0x4(%eax),%edx -c01056c5: 8b 45 0c mov 0xc(%ebp),%eax -c01056c8: 8b 40 08 mov 0x8(%eax),%eax -c01056cb: 39 c2 cmp %eax,%edx -c01056cd: 72 24 jb c01056f3 -c01056cf: c7 44 24 0c 87 b4 10 movl $0xc010b487,0xc(%esp) -c01056d6: c0 -c01056d7: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c01056de: c0 -c01056df: c7 44 24 04 a2 00 00 movl $0xa2,0x4(%esp) -c01056e6: 00 -c01056e7: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c01056ee: e8 50 ad ff ff call c0100443 <__panic> -} -c01056f3: 90 nop -c01056f4: c9 leave -c01056f5: c3 ret - -c01056f6 : - * - * @param mm 指向内存描述符结构 `struct mm_struct` 的指针,表示一个进程的内存空间。 - * @param vma 指向要插入的VMA结构 `struct vma_struct` 的指针,描述一个内存区域。 - */ -void -insert_vma_struct(struct mm_struct *mm, struct vma_struct *vma) { -c01056f6: f3 0f 1e fb endbr32 -c01056fa: 55 push %ebp -c01056fb: 89 e5 mov %esp,%ebp -c01056fd: 83 ec 48 sub $0x48,%esp - // 断言VMA结构的起始地址小于结束地址,确保VMA结构的有效性。 - assert(vma->vm_start < vma->vm_end); -c0105700: 8b 45 0c mov 0xc(%ebp),%eax -c0105703: 8b 50 04 mov 0x4(%eax),%edx -c0105706: 8b 45 0c mov 0xc(%ebp),%eax -c0105709: 8b 40 08 mov 0x8(%eax),%eax -c010570c: 39 c2 cmp %eax,%edx -c010570e: 72 24 jb c0105734 -c0105710: c7 44 24 0c a5 b4 10 movl $0xc010b4a5,0xc(%esp) -c0105717: c0 -c0105718: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c010571f: c0 -c0105720: c7 44 24 04 b3 00 00 movl $0xb3,0x4(%esp) -c0105727: 00 -c0105728: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c010572f: e8 0f ad ff ff call c0100443 <__panic> - // 指向内存描述符中的VMA链表。 - list_entry_t *list = &(mm->mmap_list); -c0105734: 8b 45 08 mov 0x8(%ebp),%eax -c0105737: 89 45 ec mov %eax,-0x14(%ebp) - // 遍历链表以找到新VMA结构的正确插入位置。 - list_entry_t *le_prev = list, *le_next; -c010573a: 8b 45 ec mov -0x14(%ebp),%eax -c010573d: 89 45 f4 mov %eax,-0xc(%ebp) +c0104a56 <__kmalloc>: - list_entry_t *le = list; -c0105740: 8b 45 ec mov -0x14(%ebp),%eax -c0105743: 89 45 f0 mov %eax,-0x10(%ebp) - // 遍历链表以找到新VMA结构的正确插入位置 - while ((le = list_next(le)) != list) { -c0105746: eb 1f jmp c0105767 - struct vma_struct *mmap_prev = le2vma(le, list_link); -c0105748: 8b 45 f0 mov -0x10(%ebp),%eax -c010574b: 83 e8 10 sub $0x10,%eax -c010574e: 89 45 e8 mov %eax,-0x18(%ebp) - // 如果当前VMA的起始地址大于新VMA的起始地址,则跳出循环 - if (mmap_prev->vm_start > vma->vm_start) { -c0105751: 8b 45 e8 mov -0x18(%ebp),%eax -c0105754: 8b 50 04 mov 0x4(%eax),%edx -c0105757: 8b 45 0c mov 0xc(%ebp),%eax -c010575a: 8b 40 04 mov 0x4(%eax),%eax -c010575d: 39 c2 cmp %eax,%edx -c010575f: 77 1f ja c0105780 - break; - } - le_prev = le; -c0105761: 8b 45 f0 mov -0x10(%ebp),%eax -c0105764: 89 45 f4 mov %eax,-0xc(%ebp) -c0105767: 8b 45 f0 mov -0x10(%ebp),%eax -c010576a: 89 45 e0 mov %eax,-0x20(%ebp) -c010576d: 8b 45 e0 mov -0x20(%ebp),%eax -c0105770: 8b 40 04 mov 0x4(%eax),%eax - while ((le = list_next(le)) != list) { -c0105773: 89 45 f0 mov %eax,-0x10(%ebp) -c0105776: 8b 45 f0 mov -0x10(%ebp),%eax -c0105779: 3b 45 ec cmp -0x14(%ebp),%eax -c010577c: 75 ca jne c0105748 -c010577e: eb 01 jmp c0105781 - break; -c0105780: 90 nop -c0105781: 8b 45 f4 mov -0xc(%ebp),%eax -c0105784: 89 45 dc mov %eax,-0x24(%ebp) -c0105787: 8b 45 dc mov -0x24(%ebp),%eax -c010578a: 8b 40 04 mov 0x4(%eax),%eax - } - // 获取下一个链表项 - le_next = list_next(le_prev); -c010578d: 89 45 e4 mov %eax,-0x1c(%ebp) +static void *__kmalloc(size_t size, gfp_t gfp) +{ +c0104a56: 55 push %ebp +c0104a57: 89 e5 mov %esp,%ebp +c0104a59: 83 ec 28 sub $0x28,%esp + slob_t *m; + bigblock_t *bb; + unsigned long flags; - /* check overlap */ - // 检查前一个VMA结构是否与新VMA结构重叠 - if (le_prev != list) { -c0105790: 8b 45 f4 mov -0xc(%ebp),%eax -c0105793: 3b 45 ec cmp -0x14(%ebp),%eax -c0105796: 74 15 je c01057ad - check_vma_overlap(le2vma(le_prev, list_link), vma); -c0105798: 8b 45 f4 mov -0xc(%ebp),%eax -c010579b: 8d 50 f0 lea -0x10(%eax),%edx -c010579e: 8b 45 0c mov 0xc(%ebp),%eax -c01057a1: 89 44 24 04 mov %eax,0x4(%esp) -c01057a5: 89 14 24 mov %edx,(%esp) -c01057a8: e8 a4 fe ff ff call c0105651 - } - // 检查下一个VMA结构是否与新VMA结构重叠 - if (le_next != list) { -c01057ad: 8b 45 e4 mov -0x1c(%ebp),%eax -c01057b0: 3b 45 ec cmp -0x14(%ebp),%eax -c01057b3: 74 15 je c01057ca - check_vma_overlap(vma, le2vma(le_next, list_link)); -c01057b5: 8b 45 e4 mov -0x1c(%ebp),%eax -c01057b8: 83 e8 10 sub $0x10,%eax -c01057bb: 89 44 24 04 mov %eax,0x4(%esp) -c01057bf: 8b 45 0c mov 0xc(%ebp),%eax -c01057c2: 89 04 24 mov %eax,(%esp) -c01057c5: e8 87 fe ff ff call c0105651 - } - // 设置VMA结构所属的内存描述符 - vma->vm_mm = mm; -c01057ca: 8b 45 0c mov 0xc(%ebp),%eax -c01057cd: 8b 55 08 mov 0x8(%ebp),%edx -c01057d0: 89 10 mov %edx,(%eax) - // 将新VMA结构插入链表 - list_add_after(le_prev, &(vma->list_link)); -c01057d2: 8b 45 0c mov 0xc(%ebp),%eax -c01057d5: 8d 50 10 lea 0x10(%eax),%edx -c01057d8: 8b 45 f4 mov -0xc(%ebp),%eax -c01057db: 89 45 d8 mov %eax,-0x28(%ebp) -c01057de: 89 55 d4 mov %edx,-0x2c(%ebp) - __list_add(elm, listelm, listelm->next); -c01057e1: 8b 45 d8 mov -0x28(%ebp),%eax -c01057e4: 8b 40 04 mov 0x4(%eax),%eax -c01057e7: 8b 55 d4 mov -0x2c(%ebp),%edx -c01057ea: 89 55 d0 mov %edx,-0x30(%ebp) -c01057ed: 8b 55 d8 mov -0x28(%ebp),%edx -c01057f0: 89 55 cc mov %edx,-0x34(%ebp) -c01057f3: 89 45 c8 mov %eax,-0x38(%ebp) - prev->next = next->prev = elm; -c01057f6: 8b 45 c8 mov -0x38(%ebp),%eax -c01057f9: 8b 55 d0 mov -0x30(%ebp),%edx -c01057fc: 89 10 mov %edx,(%eax) -c01057fe: 8b 45 c8 mov -0x38(%ebp),%eax -c0105801: 8b 10 mov (%eax),%edx -c0105803: 8b 45 cc mov -0x34(%ebp),%eax -c0105806: 89 50 04 mov %edx,0x4(%eax) - elm->next = next; -c0105809: 8b 45 d0 mov -0x30(%ebp),%eax -c010580c: 8b 55 c8 mov -0x38(%ebp),%edx -c010580f: 89 50 04 mov %edx,0x4(%eax) - elm->prev = prev; -c0105812: 8b 45 d0 mov -0x30(%ebp),%eax -c0105815: 8b 55 cc mov -0x34(%ebp),%edx -c0105818: 89 10 mov %edx,(%eax) -} -c010581a: 90 nop -} -c010581b: 90 nop - // 增加内存描述符中的映射计数 - mm->map_count ++; -c010581c: 8b 45 08 mov 0x8(%ebp),%eax -c010581f: 8b 40 10 mov 0x10(%eax),%eax -c0105822: 8d 50 01 lea 0x1(%eax),%edx -c0105825: 8b 45 08 mov 0x8(%ebp),%eax -c0105828: 89 50 10 mov %edx,0x10(%eax) -} -c010582b: 90 nop -c010582c: c9 leave -c010582d: c3 ret + if (size < PAGE_SIZE - SLOB_UNIT) { +c0104a5c: 81 7d 08 f7 0f 00 00 cmpl $0xff7,0x8(%ebp) +c0104a63: 77 3b ja c0104aa0 <__kmalloc+0x4a> + m = slob_alloc(size + SLOB_UNIT, gfp, 0); +c0104a65: 8b 45 08 mov 0x8(%ebp),%eax +c0104a68: 8d 50 08 lea 0x8(%eax),%edx +c0104a6b: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c0104a72: 00 +c0104a73: 8b 45 0c mov 0xc(%ebp),%eax +c0104a76: 89 44 24 04 mov %eax,0x4(%esp) +c0104a7a: 89 14 24 mov %edx,(%esp) +c0104a7d: e8 79 fc ff ff call c01046fb +c0104a82: 89 45 ec mov %eax,-0x14(%ebp) + return m ? (void *)(m + 1) : 0; +c0104a85: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) +c0104a89: 74 0b je c0104a96 <__kmalloc+0x40> +c0104a8b: 8b 45 ec mov -0x14(%ebp),%eax +c0104a8e: 83 c0 08 add $0x8,%eax +c0104a91: e9 b0 00 00 00 jmp c0104b46 <__kmalloc+0xf0> +c0104a96: b8 00 00 00 00 mov $0x0,%eax +c0104a9b: e9 a6 00 00 00 jmp c0104b46 <__kmalloc+0xf0> + } -c010582e : - * 此函数遍历并销毁与内存管理结构(mm_struct)关联的所有虚拟内存区域(VMA), - * 然后释放内存管理结构本身所占用的内存。这样做是为了确保在销毁内存管理结构之前, - * 所有相关的资源都被正确地释放。 - */ -void -mm_destroy(struct mm_struct *mm) { -c010582e: f3 0f 1e fb endbr32 -c0105832: 55 push %ebp -c0105833: 89 e5 mov %esp,%ebp -c0105835: 83 ec 38 sub $0x38,%esp - // 获取内存映射列表的头指针 - list_entry_t *list = &(mm->mmap_list), *le; -c0105838: 8b 45 08 mov 0x8(%ebp),%eax -c010583b: 89 45 f4 mov %eax,-0xc(%ebp) - // 遍历内存映射列表,直到回到起点 - while ((le = list_next(list)) != list) { -c010583e: eb 40 jmp c0105880 -c0105840: 8b 45 f0 mov -0x10(%ebp),%eax -c0105843: 89 45 ec mov %eax,-0x14(%ebp) - __list_del(listelm->prev, listelm->next); -c0105846: 8b 45 ec mov -0x14(%ebp),%eax -c0105849: 8b 40 04 mov 0x4(%eax),%eax -c010584c: 8b 55 ec mov -0x14(%ebp),%edx -c010584f: 8b 12 mov (%edx),%edx -c0105851: 89 55 e8 mov %edx,-0x18(%ebp) -c0105854: 89 45 e4 mov %eax,-0x1c(%ebp) - prev->next = next; -c0105857: 8b 45 e8 mov -0x18(%ebp),%eax -c010585a: 8b 55 e4 mov -0x1c(%ebp),%edx -c010585d: 89 50 04 mov %edx,0x4(%eax) - next->prev = prev; -c0105860: 8b 45 e4 mov -0x1c(%ebp),%eax -c0105863: 8b 55 e8 mov -0x18(%ebp),%edx -c0105866: 89 10 mov %edx,(%eax) -} -c0105868: 90 nop -} -c0105869: 90 nop - // 从列表中删除当前虚拟内存区域的项 - list_del(le); - // 释放虚拟内存区域结构的内存 - kfree(le2vma(le, list_link),sizeof(struct vma_struct)); //kfree vma -c010586a: 8b 45 f0 mov -0x10(%ebp),%eax -c010586d: 83 e8 10 sub $0x10,%eax -c0105870: c7 44 24 04 18 00 00 movl $0x18,0x4(%esp) -c0105877: 00 -c0105878: 89 04 24 mov %eax,(%esp) -c010587b: e8 d5 0f 00 00 call c0106855 -c0105880: 8b 45 f4 mov -0xc(%ebp),%eax -c0105883: 89 45 e0 mov %eax,-0x20(%ebp) - return listelm->next; -c0105886: 8b 45 e0 mov -0x20(%ebp),%eax -c0105889: 8b 40 04 mov 0x4(%eax),%eax - while ((le = list_next(list)) != list) { -c010588c: 89 45 f0 mov %eax,-0x10(%ebp) -c010588f: 8b 45 f0 mov -0x10(%ebp),%eax -c0105892: 3b 45 f4 cmp -0xc(%ebp),%eax -c0105895: 75 a9 jne c0105840 - } - // 释放内存管理结构本身的内存 - kfree(mm, sizeof(struct mm_struct)); //kfree mm -c0105897: c7 44 24 04 18 00 00 movl $0x18,0x4(%esp) -c010589e: 00 -c010589f: 8b 45 08 mov 0x8(%ebp),%eax -c01058a2: 89 04 24 mov %eax,(%esp) -c01058a5: e8 ab 0f 00 00 call c0106855 - // 将指针设置为NULL,表示该结构已被销毁 - mm=NULL; -c01058aa: c7 45 08 00 00 00 00 movl $0x0,0x8(%ebp) -} -c01058b1: 90 nop -c01058b2: c9 leave -c01058b3: c3 ret + bb = slob_alloc(sizeof(bigblock_t), gfp, 0); +c0104aa0: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c0104aa7: 00 +c0104aa8: 8b 45 0c mov 0xc(%ebp),%eax +c0104aab: 89 44 24 04 mov %eax,0x4(%esp) +c0104aaf: c7 04 24 0c 00 00 00 movl $0xc,(%esp) +c0104ab6: e8 40 fc ff ff call c01046fb +c0104abb: 89 45 f4 mov %eax,-0xc(%ebp) + if (!bb) +c0104abe: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0104ac2: 75 07 jne c0104acb <__kmalloc+0x75> + return 0; +c0104ac4: b8 00 00 00 00 mov $0x0,%eax +c0104ac9: eb 7b jmp c0104b46 <__kmalloc+0xf0> -c01058b4 : -/** - * 初始化虚拟内存管理(VMM)系统。 - * 此函数通过执行一系列检查来确保VMM系统可以正确初始化和运行。 - */ -void -vmm_init(void) { -c01058b4: f3 0f 1e fb endbr32 -c01058b8: 55 push %ebp -c01058b9: 89 e5 mov %esp,%ebp -c01058bb: 83 ec 08 sub $0x8,%esp - // 检查VMM系统的状态和环境,以确保其能够正常工作。 - check_vmm(); -c01058be: e8 03 00 00 00 call c01058c6 -} -c01058c3: 90 nop -c01058c4: c9 leave -c01058c5: c3 ret + bb->order = find_order(size); +c0104acb: 8b 45 08 mov 0x8(%ebp),%eax +c0104ace: 89 04 24 mov %eax,(%esp) +c0104ad1: e8 5b ff ff ff call c0104a31 +c0104ad6: 8b 55 f4 mov -0xc(%ebp),%edx +c0104ad9: 89 02 mov %eax,(%edx) + bb->pages = (void *)__slob_get_free_pages(gfp, bb->order); +c0104adb: 8b 45 f4 mov -0xc(%ebp),%eax +c0104ade: 8b 00 mov (%eax),%eax +c0104ae0: 89 44 24 04 mov %eax,0x4(%esp) +c0104ae4: 8b 45 0c mov 0xc(%ebp),%eax +c0104ae7: 89 04 24 mov %eax,(%esp) +c0104aea: e8 99 fb ff ff call c0104688 <__slob_get_free_pages> +c0104aef: 8b 55 f4 mov -0xc(%ebp),%edx +c0104af2: 89 42 04 mov %eax,0x4(%edx) -c01058c6 : - * 此函数的目的是确保虚拟内存管理系统的正确性通过检查内存区域结构(VMA)、页面故障处理以及免费页面计数的 consistency 来实现 - * 它首先保存当前的免费页面数量,然后执行与 VMA 和页面故障相关的检查,最后确认免费页面数量未发生变化 - * 这是为了确保在检查过程中,内存状态没有因为错误或意外的修改而改变,从而验证内存管理的正确性 - */ -static void -check_vmm(void) { -c01058c6: f3 0f 1e fb endbr32 -c01058ca: 55 push %ebp -c01058cb: 89 e5 mov %esp,%ebp -c01058cd: 83 ec 28 sub $0x28,%esp - // 保存当前的免费页面数量,用于后续的 consistency 检查 - size_t nr_free_pages_store = nr_free_pages(); -c01058d0: e8 2a df ff ff call c01037ff -c01058d5: 89 45 f4 mov %eax,-0xc(%ebp) - // 检查虚拟内存区域(VMA)结构的正确性 - check_vma_struct(); -c01058d8: e8 42 00 00 00 call c010591f - // 检查页面故障处理的正确性 - check_pgfault(); -c01058dd: e8 d3 04 00 00 call c0105db5 - // 确保在检查过程中免费页面数量未发生变化,表明内存管理操作是正确的 - assert(nr_free_pages_store == nr_free_pages()); -c01058e2: e8 18 df ff ff call c01037ff -c01058e7: 39 45 f4 cmp %eax,-0xc(%ebp) -c01058ea: 74 24 je c0105910 -c01058ec: c7 44 24 0c c4 b4 10 movl $0xc010b4c4,0xc(%esp) -c01058f3: c0 -c01058f4: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c01058fb: c0 -c01058fc: c7 44 24 04 0e 01 00 movl $0x10e,0x4(%esp) -c0105903: 00 -c0105904: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c010590b: e8 33 ab ff ff call c0100443 <__panic> - // 如果所有检查都通过,输出成功信息 - cprintf("check_vmm() succeeded.\n"); -c0105910: c7 04 24 eb b4 10 c0 movl $0xc010b4eb,(%esp) -c0105917: e8 bb a9 ff ff call c01002d7 + if (bb->pages) { +c0104af5: 8b 45 f4 mov -0xc(%ebp),%eax +c0104af8: 8b 40 04 mov 0x4(%eax),%eax +c0104afb: 85 c0 test %eax,%eax +c0104afd: 74 2f je c0104b2e <__kmalloc+0xd8> + spin_lock_irqsave(&block_lock, flags); +c0104aff: e8 2d fa ff ff call c0104531 <__intr_save> +c0104b04: 89 45 f0 mov %eax,-0x10(%ebp) + bb->next = bigblocks; +c0104b07: 8b 15 f0 bf 12 c0 mov 0xc012bff0,%edx +c0104b0d: 8b 45 f4 mov -0xc(%ebp),%eax +c0104b10: 89 50 08 mov %edx,0x8(%eax) + bigblocks = bb; +c0104b13: 8b 45 f4 mov -0xc(%ebp),%eax +c0104b16: a3 f0 bf 12 c0 mov %eax,0xc012bff0 + spin_unlock_irqrestore(&block_lock, flags); +c0104b1b: 8b 45 f0 mov -0x10(%ebp),%eax +c0104b1e: 89 04 24 mov %eax,(%esp) +c0104b21: e8 37 fa ff ff call c010455d <__intr_restore> + return bb->pages; +c0104b26: 8b 45 f4 mov -0xc(%ebp),%eax +c0104b29: 8b 40 04 mov 0x4(%eax),%eax +c0104b2c: eb 18 jmp c0104b46 <__kmalloc+0xf0> + } + + slob_free(bb, sizeof(bigblock_t)); +c0104b2e: c7 44 24 04 0c 00 00 movl $0xc,0x4(%esp) +c0104b35: 00 +c0104b36: 8b 45 f4 mov -0xc(%ebp),%eax +c0104b39: 89 04 24 mov %eax,(%esp) +c0104b3c: e8 8d fd ff ff call c01048ce + return 0; +c0104b41: b8 00 00 00 00 mov $0x0,%eax } -c010591c: 90 nop -c010591d: c9 leave -c010591e: c3 ret +c0104b46: 89 ec mov %ebp,%esp +c0104b48: 5d pop %ebp +c0104b49: c3 ret -c010591f : +c0104b4a : -//测试虚拟内存区域(VMA)结构的创建、插入和查找功能。 -static void -check_vma_struct(void) { -c010591f: f3 0f 1e fb endbr32 -c0105923: 55 push %ebp -c0105924: 89 e5 mov %esp,%ebp -c0105926: 83 ec 68 sub $0x68,%esp - // 记录当前空闲页面数量 - size_t nr_free_pages_store = nr_free_pages(); -c0105929: e8 d1 de ff ff call c01037ff -c010592e: 89 45 ec mov %eax,-0x14(%ebp) +void * +kmalloc(size_t size) +{ +c0104b4a: 55 push %ebp +c0104b4b: 89 e5 mov %esp,%ebp +c0104b4d: 83 ec 18 sub $0x18,%esp + return __kmalloc(size, 0); +c0104b50: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0104b57: 00 +c0104b58: 8b 45 08 mov 0x8(%ebp),%eax +c0104b5b: 89 04 24 mov %eax,(%esp) +c0104b5e: e8 f3 fe ff ff call c0104a56 <__kmalloc> +} +c0104b63: 89 ec mov %ebp,%esp +c0104b65: 5d pop %ebp +c0104b66: c3 ret - struct mm_struct *mm = mm_create();// 创建内存管理结构 mm -c0105931: e8 aa fb ff ff call c01054e0 -c0105936: 89 45 e8 mov %eax,-0x18(%ebp) - assert(mm != NULL);// 确保 mm 不为 NULL -c0105939: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) -c010593d: 75 24 jne c0105963 -c010593f: c7 44 24 0c 03 b5 10 movl $0xc010b503,0xc(%esp) -c0105946: c0 -c0105947: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c010594e: c0 -c010594f: c7 44 24 04 1a 01 00 movl $0x11a,0x4(%esp) -c0105956: 00 -c0105957: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c010595e: e8 e0 aa ff ff call c0100443 <__panic> +c0104b67 : - int step1 = 10, step2 = step1 * 10;// 定义两个步骤的步数 -c0105963: c7 45 e4 0a 00 00 00 movl $0xa,-0x1c(%ebp) -c010596a: 8b 55 e4 mov -0x1c(%ebp),%edx -c010596d: 89 d0 mov %edx,%eax -c010596f: c1 e0 02 shl $0x2,%eax -c0105972: 01 d0 add %edx,%eax -c0105974: 01 c0 add %eax,%eax -c0105976: 89 45 e0 mov %eax,-0x20(%ebp) - int i; - for (i = step1; i >= 1; i --) {// 第一步:创建并插入10个VMA -c0105979: 8b 45 e4 mov -0x1c(%ebp),%eax -c010597c: 89 45 f4 mov %eax,-0xc(%ebp) -c010597f: eb 6f jmp c01059f0 - // 创建 VMA 结构 - struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0); -c0105981: 8b 55 f4 mov -0xc(%ebp),%edx -c0105984: 89 d0 mov %edx,%eax -c0105986: c1 e0 02 shl $0x2,%eax -c0105989: 01 d0 add %edx,%eax -c010598b: 83 c0 02 add $0x2,%eax -c010598e: 89 c1 mov %eax,%ecx -c0105990: 8b 55 f4 mov -0xc(%ebp),%edx -c0105993: 89 d0 mov %edx,%eax -c0105995: c1 e0 02 shl $0x2,%eax -c0105998: 01 d0 add %edx,%eax -c010599a: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c01059a1: 00 -c01059a2: 89 4c 24 04 mov %ecx,0x4(%esp) -c01059a6: 89 04 24 mov %eax,(%esp) -c01059a9: e8 af fb ff ff call c010555d -c01059ae: 89 45 bc mov %eax,-0x44(%ebp) - assert(vma != NULL);// 确保 VMA 不为 NULL -c01059b1: 83 7d bc 00 cmpl $0x0,-0x44(%ebp) -c01059b5: 75 24 jne c01059db -c01059b7: c7 44 24 0c 0e b5 10 movl $0xc010b50e,0xc(%esp) -c01059be: c0 -c01059bf: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c01059c6: c0 -c01059c7: c7 44 24 04 22 01 00 movl $0x122,0x4(%esp) -c01059ce: 00 -c01059cf: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c01059d6: e8 68 aa ff ff call c0100443 <__panic> - insert_vma_struct(mm, vma); //将 VMA 插入到 mm 中 -c01059db: 8b 45 bc mov -0x44(%ebp),%eax -c01059de: 89 44 24 04 mov %eax,0x4(%esp) -c01059e2: 8b 45 e8 mov -0x18(%ebp),%eax -c01059e5: 89 04 24 mov %eax,(%esp) -c01059e8: e8 09 fd ff ff call c01056f6 - for (i = step1; i >= 1; i --) {// 第一步:创建并插入10个VMA -c01059ed: ff 4d f4 decl -0xc(%ebp) -c01059f0: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c01059f4: 7f 8b jg c0105981 - } +void kfree(void *block) +{ +c0104b67: 55 push %ebp +c0104b68: 89 e5 mov %esp,%ebp +c0104b6a: 83 ec 28 sub $0x28,%esp + bigblock_t *bb, **last = &bigblocks; +c0104b6d: c7 45 f0 f0 bf 12 c0 movl $0xc012bff0,-0x10(%ebp) + unsigned long flags; - for (i = step1 + 1; i <= step2; i ++) {// 第二步:创建并插入90个VMA -c01059f6: 8b 45 e4 mov -0x1c(%ebp),%eax -c01059f9: 40 inc %eax -c01059fa: 89 45 f4 mov %eax,-0xc(%ebp) -c01059fd: eb 6f jmp c0105a6e - // 创建 VMA 结构 - struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0); -c01059ff: 8b 55 f4 mov -0xc(%ebp),%edx -c0105a02: 89 d0 mov %edx,%eax -c0105a04: c1 e0 02 shl $0x2,%eax -c0105a07: 01 d0 add %edx,%eax -c0105a09: 83 c0 02 add $0x2,%eax -c0105a0c: 89 c1 mov %eax,%ecx -c0105a0e: 8b 55 f4 mov -0xc(%ebp),%edx -c0105a11: 89 d0 mov %edx,%eax -c0105a13: c1 e0 02 shl $0x2,%eax -c0105a16: 01 d0 add %edx,%eax -c0105a18: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c0105a1f: 00 -c0105a20: 89 4c 24 04 mov %ecx,0x4(%esp) -c0105a24: 89 04 24 mov %eax,(%esp) -c0105a27: e8 31 fb ff ff call c010555d -c0105a2c: 89 45 c0 mov %eax,-0x40(%ebp) - assert(vma != NULL);// 确保 VMA 不为 NULL -c0105a2f: 83 7d c0 00 cmpl $0x0,-0x40(%ebp) -c0105a33: 75 24 jne c0105a59 -c0105a35: c7 44 24 0c 0e b5 10 movl $0xc010b50e,0xc(%esp) -c0105a3c: c0 -c0105a3d: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105a44: c0 -c0105a45: c7 44 24 04 29 01 00 movl $0x129,0x4(%esp) -c0105a4c: 00 -c0105a4d: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105a54: e8 ea a9 ff ff call c0100443 <__panic> - insert_vma_struct(mm, vma);// 将 VMA 插入到 mm 中 -c0105a59: 8b 45 c0 mov -0x40(%ebp),%eax -c0105a5c: 89 44 24 04 mov %eax,0x4(%esp) -c0105a60: 8b 45 e8 mov -0x18(%ebp),%eax -c0105a63: 89 04 24 mov %eax,(%esp) -c0105a66: e8 8b fc ff ff call c01056f6 - for (i = step1 + 1; i <= step2; i ++) {// 第二步:创建并插入90个VMA -c0105a6b: ff 45 f4 incl -0xc(%ebp) -c0105a6e: 8b 45 f4 mov -0xc(%ebp),%eax -c0105a71: 3b 45 e0 cmp -0x20(%ebp),%eax -c0105a74: 7e 89 jle c01059ff - } - // 获取 VMA 链表的第一个节点 - list_entry_t *le = list_next(&(mm->mmap_list)); -c0105a76: 8b 45 e8 mov -0x18(%ebp),%eax -c0105a79: 89 45 b8 mov %eax,-0x48(%ebp) -c0105a7c: 8b 45 b8 mov -0x48(%ebp),%eax -c0105a7f: 8b 40 04 mov 0x4(%eax),%eax -c0105a82: 89 45 f0 mov %eax,-0x10(%ebp) + if (!block) +c0104b74: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0104b78: 0f 84 a3 00 00 00 je c0104c21 + return; - for (i = 1; i <= step2; i ++) {// 验证插入顺序 -c0105a85: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp) -c0105a8c: e9 96 00 00 00 jmp c0105b27 - assert(le != &(mm->mmap_list));// 确保节点不为空 -c0105a91: 8b 45 e8 mov -0x18(%ebp),%eax -c0105a94: 39 45 f0 cmp %eax,-0x10(%ebp) -c0105a97: 75 24 jne c0105abd -c0105a99: c7 44 24 0c 1a b5 10 movl $0xc010b51a,0xc(%esp) -c0105aa0: c0 -c0105aa1: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105aa8: c0 -c0105aa9: c7 44 24 04 30 01 00 movl $0x130,0x4(%esp) -c0105ab0: 00 -c0105ab1: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105ab8: e8 86 a9 ff ff call c0100443 <__panic> - struct vma_struct *mmap = le2vma(le, list_link);// 将链表节点转换为 VMA 结构 -c0105abd: 8b 45 f0 mov -0x10(%ebp),%eax -c0105ac0: 83 e8 10 sub $0x10,%eax -c0105ac3: 89 45 c4 mov %eax,-0x3c(%ebp) - // 确认 VMA 的起始和结束地址 - assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2); -c0105ac6: 8b 45 c4 mov -0x3c(%ebp),%eax -c0105ac9: 8b 48 04 mov 0x4(%eax),%ecx -c0105acc: 8b 55 f4 mov -0xc(%ebp),%edx -c0105acf: 89 d0 mov %edx,%eax -c0105ad1: c1 e0 02 shl $0x2,%eax -c0105ad4: 01 d0 add %edx,%eax -c0105ad6: 39 c1 cmp %eax,%ecx -c0105ad8: 75 17 jne c0105af1 -c0105ada: 8b 45 c4 mov -0x3c(%ebp),%eax -c0105add: 8b 48 08 mov 0x8(%eax),%ecx -c0105ae0: 8b 55 f4 mov -0xc(%ebp),%edx -c0105ae3: 89 d0 mov %edx,%eax -c0105ae5: c1 e0 02 shl $0x2,%eax -c0105ae8: 01 d0 add %edx,%eax -c0105aea: 83 c0 02 add $0x2,%eax -c0105aed: 39 c1 cmp %eax,%ecx -c0105aef: 74 24 je c0105b15 -c0105af1: c7 44 24 0c 34 b5 10 movl $0xc010b534,0xc(%esp) -c0105af8: c0 -c0105af9: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105b00: c0 -c0105b01: c7 44 24 04 33 01 00 movl $0x133,0x4(%esp) -c0105b08: 00 -c0105b09: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105b10: e8 2e a9 ff ff call c0100443 <__panic> -c0105b15: 8b 45 f0 mov -0x10(%ebp),%eax -c0105b18: 89 45 b4 mov %eax,-0x4c(%ebp) -c0105b1b: 8b 45 b4 mov -0x4c(%ebp),%eax -c0105b1e: 8b 40 04 mov 0x4(%eax),%eax - le = list_next(le);// 移动到下一个节点 -c0105b21: 89 45 f0 mov %eax,-0x10(%ebp) - for (i = 1; i <= step2; i ++) {// 验证插入顺序 -c0105b24: ff 45 f4 incl -0xc(%ebp) -c0105b27: 8b 45 f4 mov -0xc(%ebp),%eax -c0105b2a: 3b 45 e0 cmp -0x20(%ebp),%eax -c0105b2d: 0f 8e 5e ff ff ff jle c0105a91 - } + if (!((unsigned long)block & (PAGE_SIZE-1))) { +c0104b7e: 8b 45 08 mov 0x8(%ebp),%eax +c0104b81: 25 ff 0f 00 00 and $0xfff,%eax +c0104b86: 85 c0 test %eax,%eax +c0104b88: 75 7f jne c0104c09 + /* might be on the big block list */ + spin_lock_irqsave(&block_lock, flags); +c0104b8a: e8 a2 f9 ff ff call c0104531 <__intr_save> +c0104b8f: 89 45 ec mov %eax,-0x14(%ebp) + for (bb = bigblocks; bb; last = &bb->next, bb = bb->next) { +c0104b92: a1 f0 bf 12 c0 mov 0xc012bff0,%eax +c0104b97: 89 45 f4 mov %eax,-0xc(%ebp) +c0104b9a: eb 5c jmp c0104bf8 + if (bb->pages == block) { +c0104b9c: 8b 45 f4 mov -0xc(%ebp),%eax +c0104b9f: 8b 40 04 mov 0x4(%eax),%eax +c0104ba2: 39 45 08 cmp %eax,0x8(%ebp) +c0104ba5: 75 3f jne c0104be6 + *last = bb->next; +c0104ba7: 8b 45 f4 mov -0xc(%ebp),%eax +c0104baa: 8b 50 08 mov 0x8(%eax),%edx +c0104bad: 8b 45 f0 mov -0x10(%ebp),%eax +c0104bb0: 89 10 mov %edx,(%eax) + spin_unlock_irqrestore(&block_lock, flags); +c0104bb2: 8b 45 ec mov -0x14(%ebp),%eax +c0104bb5: 89 04 24 mov %eax,(%esp) +c0104bb8: e8 a0 f9 ff ff call c010455d <__intr_restore> + __slob_free_pages((unsigned long)block, bb->order); +c0104bbd: 8b 45 f4 mov -0xc(%ebp),%eax +c0104bc0: 8b 10 mov (%eax),%edx +c0104bc2: 8b 45 08 mov 0x8(%ebp),%eax +c0104bc5: 89 54 24 04 mov %edx,0x4(%esp) +c0104bc9: 89 04 24 mov %eax,(%esp) +c0104bcc: e8 f2 fa ff ff call c01046c3 <__slob_free_pages> + slob_free(bb, sizeof(bigblock_t)); +c0104bd1: c7 44 24 04 0c 00 00 movl $0xc,0x4(%esp) +c0104bd8: 00 +c0104bd9: 8b 45 f4 mov -0xc(%ebp),%eax +c0104bdc: 89 04 24 mov %eax,(%esp) +c0104bdf: e8 ea fc ff ff call c01048ce + return; +c0104be4: eb 3c jmp c0104c22 + for (bb = bigblocks; bb; last = &bb->next, bb = bb->next) { +c0104be6: 8b 45 f4 mov -0xc(%ebp),%eax +c0104be9: 83 c0 08 add $0x8,%eax +c0104bec: 89 45 f0 mov %eax,-0x10(%ebp) +c0104bef: 8b 45 f4 mov -0xc(%ebp),%eax +c0104bf2: 8b 40 08 mov 0x8(%eax),%eax +c0104bf5: 89 45 f4 mov %eax,-0xc(%ebp) +c0104bf8: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0104bfc: 75 9e jne c0104b9c + } + } + spin_unlock_irqrestore(&block_lock, flags); +c0104bfe: 8b 45 ec mov -0x14(%ebp),%eax +c0104c01: 89 04 24 mov %eax,(%esp) +c0104c04: e8 54 f9 ff ff call c010455d <__intr_restore> + } - for (i = 5; i <= 5 * step2; i +=5) {// 查找特定地址范围内的 VMA -c0105b33: c7 45 f4 05 00 00 00 movl $0x5,-0xc(%ebp) -c0105b3a: e9 cb 01 00 00 jmp c0105d0a - struct vma_struct *vma1 = find_vma(mm, i);// 查找地址 i 处的 VMA -c0105b3f: 8b 45 f4 mov -0xc(%ebp),%eax -c0105b42: 89 44 24 04 mov %eax,0x4(%esp) -c0105b46: 8b 45 e8 mov -0x18(%ebp),%eax -c0105b49: 89 04 24 mov %eax,(%esp) -c0105b4c: e8 4b fa ff ff call c010559c -c0105b51: 89 45 d8 mov %eax,-0x28(%ebp) - assert(vma1 != NULL);// 确保找到 VMA -c0105b54: 83 7d d8 00 cmpl $0x0,-0x28(%ebp) -c0105b58: 75 24 jne c0105b7e -c0105b5a: c7 44 24 0c 69 b5 10 movl $0xc010b569,0xc(%esp) -c0105b61: c0 -c0105b62: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105b69: c0 -c0105b6a: c7 44 24 04 39 01 00 movl $0x139,0x4(%esp) -c0105b71: 00 -c0105b72: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105b79: e8 c5 a8 ff ff call c0100443 <__panic> - // 查找地址 i + 1 处的 VMA - struct vma_struct *vma2 = find_vma(mm, i+1); -c0105b7e: 8b 45 f4 mov -0xc(%ebp),%eax -c0105b81: 40 inc %eax -c0105b82: 89 44 24 04 mov %eax,0x4(%esp) -c0105b86: 8b 45 e8 mov -0x18(%ebp),%eax -c0105b89: 89 04 24 mov %eax,(%esp) -c0105b8c: e8 0b fa ff ff call c010559c -c0105b91: 89 45 d4 mov %eax,-0x2c(%ebp) - assert(vma2 != NULL);// 确保找到 VMA -c0105b94: 83 7d d4 00 cmpl $0x0,-0x2c(%ebp) -c0105b98: 75 24 jne c0105bbe -c0105b9a: c7 44 24 0c 76 b5 10 movl $0xc010b576,0xc(%esp) -c0105ba1: c0 -c0105ba2: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105ba9: c0 -c0105baa: c7 44 24 04 3c 01 00 movl $0x13c,0x4(%esp) -c0105bb1: 00 -c0105bb2: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105bb9: e8 85 a8 ff ff call c0100443 <__panic> - // 查找地址 i + 2 处的 VMA - struct vma_struct *vma3 = find_vma(mm, i+2); -c0105bbe: 8b 45 f4 mov -0xc(%ebp),%eax -c0105bc1: 83 c0 02 add $0x2,%eax -c0105bc4: 89 44 24 04 mov %eax,0x4(%esp) -c0105bc8: 8b 45 e8 mov -0x18(%ebp),%eax -c0105bcb: 89 04 24 mov %eax,(%esp) -c0105bce: e8 c9 f9 ff ff call c010559c -c0105bd3: 89 45 d0 mov %eax,-0x30(%ebp) - assert(vma3 == NULL);// 确保未找到 VMA -c0105bd6: 83 7d d0 00 cmpl $0x0,-0x30(%ebp) -c0105bda: 74 24 je c0105c00 -c0105bdc: c7 44 24 0c 83 b5 10 movl $0xc010b583,0xc(%esp) -c0105be3: c0 -c0105be4: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105beb: c0 -c0105bec: c7 44 24 04 3f 01 00 movl $0x13f,0x4(%esp) -c0105bf3: 00 -c0105bf4: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105bfb: e8 43 a8 ff ff call c0100443 <__panic> - // 查找地址 i + 3 处的 VMA - struct vma_struct *vma4 = find_vma(mm, i+3); -c0105c00: 8b 45 f4 mov -0xc(%ebp),%eax -c0105c03: 83 c0 03 add $0x3,%eax -c0105c06: 89 44 24 04 mov %eax,0x4(%esp) -c0105c0a: 8b 45 e8 mov -0x18(%ebp),%eax -c0105c0d: 89 04 24 mov %eax,(%esp) -c0105c10: e8 87 f9 ff ff call c010559c -c0105c15: 89 45 cc mov %eax,-0x34(%ebp) - assert(vma4 == NULL);// 确保未找到 VMA -c0105c18: 83 7d cc 00 cmpl $0x0,-0x34(%ebp) -c0105c1c: 74 24 je c0105c42 -c0105c1e: c7 44 24 0c 90 b5 10 movl $0xc010b590,0xc(%esp) -c0105c25: c0 -c0105c26: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105c2d: c0 -c0105c2e: c7 44 24 04 42 01 00 movl $0x142,0x4(%esp) -c0105c35: 00 -c0105c36: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105c3d: e8 01 a8 ff ff call c0100443 <__panic> - // 查找地址 i + 4 处的 VMA - struct vma_struct *vma5 = find_vma(mm, i+4); -c0105c42: 8b 45 f4 mov -0xc(%ebp),%eax -c0105c45: 83 c0 04 add $0x4,%eax -c0105c48: 89 44 24 04 mov %eax,0x4(%esp) -c0105c4c: 8b 45 e8 mov -0x18(%ebp),%eax -c0105c4f: 89 04 24 mov %eax,(%esp) -c0105c52: e8 45 f9 ff ff call c010559c -c0105c57: 89 45 c8 mov %eax,-0x38(%ebp) - assert(vma5 == NULL);// 确保未找到 VMA -c0105c5a: 83 7d c8 00 cmpl $0x0,-0x38(%ebp) -c0105c5e: 74 24 je c0105c84 -c0105c60: c7 44 24 0c 9d b5 10 movl $0xc010b59d,0xc(%esp) -c0105c67: c0 -c0105c68: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105c6f: c0 -c0105c70: c7 44 24 04 45 01 00 movl $0x145,0x4(%esp) -c0105c77: 00 -c0105c78: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105c7f: e8 bf a7 ff ff call c0100443 <__panic> - // 确认 VMA1 的起始和结束地址 - assert(vma1->vm_start == i && vma1->vm_end == i + 2); -c0105c84: 8b 45 d8 mov -0x28(%ebp),%eax -c0105c87: 8b 50 04 mov 0x4(%eax),%edx -c0105c8a: 8b 45 f4 mov -0xc(%ebp),%eax -c0105c8d: 39 c2 cmp %eax,%edx -c0105c8f: 75 10 jne c0105ca1 -c0105c91: 8b 45 d8 mov -0x28(%ebp),%eax -c0105c94: 8b 40 08 mov 0x8(%eax),%eax -c0105c97: 8b 55 f4 mov -0xc(%ebp),%edx -c0105c9a: 83 c2 02 add $0x2,%edx -c0105c9d: 39 d0 cmp %edx,%eax -c0105c9f: 74 24 je c0105cc5 -c0105ca1: c7 44 24 0c ac b5 10 movl $0xc010b5ac,0xc(%esp) -c0105ca8: c0 -c0105ca9: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105cb0: c0 -c0105cb1: c7 44 24 04 47 01 00 movl $0x147,0x4(%esp) -c0105cb8: 00 -c0105cb9: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105cc0: e8 7e a7 ff ff call c0100443 <__panic> - // 确认 VMA2 的起始和结束地址 - assert(vma2->vm_start == i && vma2->vm_end == i + 2); -c0105cc5: 8b 45 d4 mov -0x2c(%ebp),%eax -c0105cc8: 8b 50 04 mov 0x4(%eax),%edx -c0105ccb: 8b 45 f4 mov -0xc(%ebp),%eax -c0105cce: 39 c2 cmp %eax,%edx -c0105cd0: 75 10 jne c0105ce2 -c0105cd2: 8b 45 d4 mov -0x2c(%ebp),%eax -c0105cd5: 8b 40 08 mov 0x8(%eax),%eax -c0105cd8: 8b 55 f4 mov -0xc(%ebp),%edx -c0105cdb: 83 c2 02 add $0x2,%edx -c0105cde: 39 d0 cmp %edx,%eax -c0105ce0: 74 24 je c0105d06 -c0105ce2: c7 44 24 0c dc b5 10 movl $0xc010b5dc,0xc(%esp) -c0105ce9: c0 -c0105cea: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105cf1: c0 -c0105cf2: c7 44 24 04 49 01 00 movl $0x149,0x4(%esp) -c0105cf9: 00 -c0105cfa: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105d01: e8 3d a7 ff ff call c0100443 <__panic> - for (i = 5; i <= 5 * step2; i +=5) {// 查找特定地址范围内的 VMA -c0105d06: 83 45 f4 05 addl $0x5,-0xc(%ebp) -c0105d0a: 8b 55 e0 mov -0x20(%ebp),%edx -c0105d0d: 89 d0 mov %edx,%eax -c0105d0f: c1 e0 02 shl $0x2,%eax -c0105d12: 01 d0 add %edx,%eax -c0105d14: 39 45 f4 cmp %eax,-0xc(%ebp) -c0105d17: 0f 8e 22 fe ff ff jle c0105b3f - } - // 检查小于5的地址范围内是否存在 VMA - for (i =4; i>=0; i--) { -c0105d1d: c7 45 f4 04 00 00 00 movl $0x4,-0xc(%ebp) -c0105d24: eb 6f jmp c0105d95 - // 查找地址 i 处的 VMA - struct vma_struct *vma_below_5= find_vma(mm,i); -c0105d26: 8b 45 f4 mov -0xc(%ebp),%eax -c0105d29: 89 44 24 04 mov %eax,0x4(%esp) -c0105d2d: 8b 45 e8 mov -0x18(%ebp),%eax -c0105d30: 89 04 24 mov %eax,(%esp) -c0105d33: e8 64 f8 ff ff call c010559c -c0105d38: 89 45 dc mov %eax,-0x24(%ebp) - if (vma_below_5 != NULL ) {// 如果找到 VMA -c0105d3b: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) -c0105d3f: 74 27 je c0105d68 - cprintf("vma_below_5: i %x, start %x, end %x\n",i, vma_below_5->vm_start, vma_below_5->vm_end); -c0105d41: 8b 45 dc mov -0x24(%ebp),%eax -c0105d44: 8b 50 08 mov 0x8(%eax),%edx -c0105d47: 8b 45 dc mov -0x24(%ebp),%eax -c0105d4a: 8b 40 04 mov 0x4(%eax),%eax -c0105d4d: 89 54 24 0c mov %edx,0xc(%esp) -c0105d51: 89 44 24 08 mov %eax,0x8(%esp) -c0105d55: 8b 45 f4 mov -0xc(%ebp),%eax -c0105d58: 89 44 24 04 mov %eax,0x4(%esp) -c0105d5c: c7 04 24 0c b6 10 c0 movl $0xc010b60c,(%esp) -c0105d63: e8 6f a5 ff ff call c01002d7 - } - assert(vma_below_5 == NULL);// 确保未找到 VMA -c0105d68: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) -c0105d6c: 74 24 je c0105d92 -c0105d6e: c7 44 24 0c 31 b6 10 movl $0xc010b631,0xc(%esp) -c0105d75: c0 -c0105d76: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105d7d: c0 -c0105d7e: c7 44 24 04 52 01 00 movl $0x152,0x4(%esp) -c0105d85: 00 -c0105d86: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105d8d: e8 b1 a6 ff ff call c0100443 <__panic> - for (i =4; i>=0; i--) { -c0105d92: ff 4d f4 decl -0xc(%ebp) -c0105d95: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0105d99: 79 8b jns c0105d26 - } + slob_free((slob_t *)block - 1, 0); +c0104c09: 8b 45 08 mov 0x8(%ebp),%eax +c0104c0c: 83 e8 08 sub $0x8,%eax +c0104c0f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0104c16: 00 +c0104c17: 89 04 24 mov %eax,(%esp) +c0104c1a: e8 af fc ff ff call c01048ce + return; +c0104c1f: eb 01 jmp c0104c22 + return; +c0104c21: 90 nop +} +c0104c22: 89 ec mov %ebp,%esp +c0104c24: 5d pop %ebp +c0104c25: c3 ret - mm_destroy(mm);// 销毁 mm 结构 -c0105d9b: 8b 45 e8 mov -0x18(%ebp),%eax -c0105d9e: 89 04 24 mov %eax,(%esp) -c0105da1: e8 88 fa ff ff call c010582e +c0104c26 : - // 确保释放的页面数量与初始记录一致 - //assert(nr_free_pages_store == nr_free_pages()); - // 输出成功信息 - cprintf("check_vma_struct() succeeded!\n"); -c0105da6: c7 04 24 48 b6 10 c0 movl $0xc010b648,(%esp) -c0105dad: e8 25 a5 ff ff call c01002d7 + +unsigned int ksize(const void *block) +{ +c0104c26: 55 push %ebp +c0104c27: 89 e5 mov %esp,%ebp +c0104c29: 83 ec 28 sub $0x28,%esp + bigblock_t *bb; + unsigned long flags; + + if (!block) +c0104c2c: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0104c30: 75 07 jne c0104c39 + return 0; +c0104c32: b8 00 00 00 00 mov $0x0,%eax +c0104c37: eb 6b jmp c0104ca4 + + if (!((unsigned long)block & (PAGE_SIZE-1))) { +c0104c39: 8b 45 08 mov 0x8(%ebp),%eax +c0104c3c: 25 ff 0f 00 00 and $0xfff,%eax +c0104c41: 85 c0 test %eax,%eax +c0104c43: 75 54 jne c0104c99 + spin_lock_irqsave(&block_lock, flags); +c0104c45: e8 e7 f8 ff ff call c0104531 <__intr_save> +c0104c4a: 89 45 f0 mov %eax,-0x10(%ebp) + for (bb = bigblocks; bb; bb = bb->next) +c0104c4d: a1 f0 bf 12 c0 mov 0xc012bff0,%eax +c0104c52: 89 45 f4 mov %eax,-0xc(%ebp) +c0104c55: eb 31 jmp c0104c88 + if (bb->pages == block) { +c0104c57: 8b 45 f4 mov -0xc(%ebp),%eax +c0104c5a: 8b 40 04 mov 0x4(%eax),%eax +c0104c5d: 39 45 08 cmp %eax,0x8(%ebp) +c0104c60: 75 1d jne c0104c7f + spin_unlock_irqrestore(&slob_lock, flags); +c0104c62: 8b 45 f0 mov -0x10(%ebp),%eax +c0104c65: 89 04 24 mov %eax,(%esp) +c0104c68: e8 f0 f8 ff ff call c010455d <__intr_restore> + return PAGE_SIZE << bb->order; +c0104c6d: 8b 45 f4 mov -0xc(%ebp),%eax +c0104c70: 8b 00 mov (%eax),%eax +c0104c72: ba 00 10 00 00 mov $0x1000,%edx +c0104c77: 88 c1 mov %al,%cl +c0104c79: d3 e2 shl %cl,%edx +c0104c7b: 89 d0 mov %edx,%eax +c0104c7d: eb 25 jmp c0104ca4 + for (bb = bigblocks; bb; bb = bb->next) +c0104c7f: 8b 45 f4 mov -0xc(%ebp),%eax +c0104c82: 8b 40 08 mov 0x8(%eax),%eax +c0104c85: 89 45 f4 mov %eax,-0xc(%ebp) +c0104c88: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0104c8c: 75 c9 jne c0104c57 + } + spin_unlock_irqrestore(&block_lock, flags); +c0104c8e: 8b 45 f0 mov -0x10(%ebp),%eax +c0104c91: 89 04 24 mov %eax,(%esp) +c0104c94: e8 c4 f8 ff ff call c010455d <__intr_restore> + } + + return ((slob_t *)block - 1)->units * SLOB_UNIT; +c0104c99: 8b 45 08 mov 0x8(%ebp),%eax +c0104c9c: 83 e8 08 sub $0x8,%eax +c0104c9f: 8b 00 mov (%eax),%eax +c0104ca1: c1 e0 03 shl $0x3,%eax } -c0105db2: 90 nop -c0105db3: c9 leave -c0105db4: c3 ret +c0104ca4: 89 ec mov %ebp,%esp +c0104ca6: 5d pop %ebp +c0104ca7: c3 ret -c0105db5 : -struct mm_struct *check_mm_struct; +c0104ca8 : +page2ppn(struct Page *page) { +c0104ca8: 55 push %ebp +c0104ca9: 89 e5 mov %esp,%ebp + return page - pages; +c0104cab: 8b 15 00 c0 12 c0 mov 0xc012c000,%edx +c0104cb1: 8b 45 08 mov 0x8(%ebp),%eax +c0104cb4: 29 d0 sub %edx,%eax +c0104cb6: c1 f8 05 sar $0x5,%eax +} +c0104cb9: 5d pop %ebp +c0104cba: c3 ret -// check_pgfault - check correctness of pgfault handler -// 检查页故障处理的正确性 -static void -check_pgfault(void) { -c0105db5: f3 0f 1e fb endbr32 -c0105db9: 55 push %ebp -c0105dba: 89 e5 mov %esp,%ebp -c0105dbc: 83 ec 38 sub $0x38,%esp - // 保存当前空闲页面的数量,用于后续检查 - size_t nr_free_pages_store = nr_free_pages(); -c0105dbf: e8 3b da ff ff call c01037ff -c0105dc4: 89 45 ec mov %eax,-0x14(%ebp) - // 创建内存管理结构体 - check_mm_struct = mm_create(); -c0105dc7: e8 14 f7 ff ff call c01054e0 -c0105dcc: a3 c4 e0 12 c0 mov %eax,0xc012e0c4 - // 确保内存管理结构体创建成功 - assert(check_mm_struct != NULL); -c0105dd1: a1 c4 e0 12 c0 mov 0xc012e0c4,%eax -c0105dd6: 85 c0 test %eax,%eax -c0105dd8: 75 24 jne c0105dfe -c0105dda: c7 44 24 0c 67 b6 10 movl $0xc010b667,0xc(%esp) -c0105de1: c0 -c0105de2: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105de9: c0 -c0105dea: c7 44 24 04 68 01 00 movl $0x168,0x4(%esp) -c0105df1: 00 -c0105df2: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105df9: e8 45 a6 ff ff call c0100443 <__panic> - // 将新创建的内存管理结构体赋值给局部变量mm - struct mm_struct *mm = check_mm_struct; -c0105dfe: a1 c4 e0 12 c0 mov 0xc012e0c4,%eax -c0105e03: 89 45 e8 mov %eax,-0x18(%ebp) - // 将引导程序的页目录复制到新创建的内存管理结构体中 - pde_t *pgdir = mm->pgdir = boot_pgdir; -c0105e06: 8b 15 e0 89 12 c0 mov 0xc01289e0,%edx -c0105e0c: 8b 45 e8 mov -0x18(%ebp),%eax -c0105e0f: 89 50 0c mov %edx,0xc(%eax) -c0105e12: 8b 45 e8 mov -0x18(%ebp),%eax -c0105e15: 8b 40 0c mov 0xc(%eax),%eax -c0105e18: 89 45 e4 mov %eax,-0x1c(%ebp) - // 确保页目录的第0项是空的 - assert(pgdir[0] == 0); -c0105e1b: 8b 45 e4 mov -0x1c(%ebp),%eax -c0105e1e: 8b 00 mov (%eax),%eax -c0105e20: 85 c0 test %eax,%eax -c0105e22: 74 24 je c0105e48 -c0105e24: c7 44 24 0c 7f b6 10 movl $0xc010b67f,0xc(%esp) -c0105e2b: c0 -c0105e2c: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105e33: c0 -c0105e34: c7 44 24 04 6e 01 00 movl $0x16e,0x4(%esp) -c0105e3b: 00 -c0105e3c: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105e43: e8 fb a5 ff ff call c0100443 <__panic> - // 创建一个虚拟内存区域结构体,具有写权限 - struct vma_struct *vma = vma_create(0, PTSIZE, VM_WRITE); -c0105e48: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp) -c0105e4f: 00 -c0105e50: c7 44 24 04 00 00 40 movl $0x400000,0x4(%esp) -c0105e57: 00 -c0105e58: c7 04 24 00 00 00 00 movl $0x0,(%esp) -c0105e5f: e8 f9 f6 ff ff call c010555d -c0105e64: 89 45 e0 mov %eax,-0x20(%ebp) - // 确保虚拟内存区域结构体创建成功 - assert(vma != NULL); -c0105e67: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) -c0105e6b: 75 24 jne c0105e91 -c0105e6d: c7 44 24 0c 0e b5 10 movl $0xc010b50e,0xc(%esp) -c0105e74: c0 -c0105e75: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105e7c: c0 -c0105e7d: c7 44 24 04 72 01 00 movl $0x172,0x4(%esp) -c0105e84: 00 -c0105e85: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105e8c: e8 b2 a5 ff ff call c0100443 <__panic> - // 将虚拟内存区域结构体插入到内存管理结构体中 - insert_vma_struct(mm, vma); -c0105e91: 8b 45 e0 mov -0x20(%ebp),%eax -c0105e94: 89 44 24 04 mov %eax,0x4(%esp) -c0105e98: 8b 45 e8 mov -0x18(%ebp),%eax -c0105e9b: 89 04 24 mov %eax,(%esp) -c0105e9e: e8 53 f8 ff ff call c01056f6 - // 定义一个地址,用于访问虚拟内存 - uintptr_t addr = 0x100; -c0105ea3: c7 45 dc 00 01 00 00 movl $0x100,-0x24(%ebp) - // 确保通过该地址可以找到之前插入的虚拟内存区域 - assert(find_vma(mm, addr) == vma); -c0105eaa: 8b 45 dc mov -0x24(%ebp),%eax -c0105ead: 89 44 24 04 mov %eax,0x4(%esp) -c0105eb1: 8b 45 e8 mov -0x18(%ebp),%eax -c0105eb4: 89 04 24 mov %eax,(%esp) -c0105eb7: e8 e0 f6 ff ff call c010559c -c0105ebc: 39 45 e0 cmp %eax,-0x20(%ebp) -c0105ebf: 74 24 je c0105ee5 -c0105ec1: c7 44 24 0c 8d b6 10 movl $0xc010b68d,0xc(%esp) -c0105ec8: c0 -c0105ec9: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105ed0: c0 -c0105ed1: c7 44 24 04 78 01 00 movl $0x178,0x4(%esp) -c0105ed8: 00 -c0105ed9: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105ee0: e8 5e a5 ff ff call c0100443 <__panic> - // 初始化一个累加器,用于校验写入的数据 - int i, sum = 0; -c0105ee5: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) - // 写入数据到虚拟内存,并累加 - for (i = 0; i < 100; i ++) { -c0105eec: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -c0105ef3: eb 16 jmp c0105f0b - *(char *)(addr + i) = i; -c0105ef5: 8b 55 f4 mov -0xc(%ebp),%edx -c0105ef8: 8b 45 dc mov -0x24(%ebp),%eax -c0105efb: 01 d0 add %edx,%eax -c0105efd: 8b 55 f4 mov -0xc(%ebp),%edx -c0105f00: 88 10 mov %dl,(%eax) - sum += i; -c0105f02: 8b 45 f4 mov -0xc(%ebp),%eax -c0105f05: 01 45 f0 add %eax,-0x10(%ebp) - for (i = 0; i < 100; i ++) { -c0105f08: ff 45 f4 incl -0xc(%ebp) -c0105f0b: 83 7d f4 63 cmpl $0x63,-0xc(%ebp) -c0105f0f: 7e e4 jle c0105ef5 - } - // 读取虚拟内存中的数据,并减去,最终结果应为0 - for (i = 0; i < 100; i ++) { -c0105f11: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -c0105f18: eb 14 jmp c0105f2e - sum -= *(char *)(addr + i); -c0105f1a: 8b 55 f4 mov -0xc(%ebp),%edx -c0105f1d: 8b 45 dc mov -0x24(%ebp),%eax -c0105f20: 01 d0 add %edx,%eax -c0105f22: 0f b6 00 movzbl (%eax),%eax -c0105f25: 0f be c0 movsbl %al,%eax -c0105f28: 29 45 f0 sub %eax,-0x10(%ebp) - for (i = 0; i < 100; i ++) { -c0105f2b: ff 45 f4 incl -0xc(%ebp) -c0105f2e: 83 7d f4 63 cmpl $0x63,-0xc(%ebp) -c0105f32: 7e e6 jle c0105f1a - } - // 确保累加器的值为0,证明数据读写正确 - assert(sum == 0); -c0105f34: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c0105f38: 74 24 je c0105f5e -c0105f3a: c7 44 24 0c a7 b6 10 movl $0xc010b6a7,0xc(%esp) -c0105f41: c0 -c0105f42: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105f49: c0 -c0105f4a: c7 44 24 04 85 01 00 movl $0x185,0x4(%esp) -c0105f51: 00 -c0105f52: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105f59: e8 e5 a4 ff ff call c0100443 <__panic> - // 移除页目录中的相应页面 - page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); -c0105f5e: 8b 45 dc mov -0x24(%ebp),%eax -c0105f61: 89 45 d8 mov %eax,-0x28(%ebp) -c0105f64: 8b 45 d8 mov -0x28(%ebp),%eax -c0105f67: 25 00 f0 ff ff and $0xfffff000,%eax -c0105f6c: 89 44 24 04 mov %eax,0x4(%esp) -c0105f70: 8b 45 e4 mov -0x1c(%ebp),%eax -c0105f73: 89 04 24 mov %eax,(%esp) -c0105f76: e8 aa e0 ff ff call c0104025 - // 释放第0项页目录对应的页面 - free_page(pde2page(pgdir[0])); -c0105f7b: 8b 45 e4 mov -0x1c(%ebp),%eax -c0105f7e: 8b 00 mov (%eax),%eax -c0105f80: 89 04 24 mov %eax,(%esp) -c0105f83: e8 40 f5 ff ff call c01054c8 -c0105f88: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0105f8f: 00 -c0105f90: 89 04 24 mov %eax,(%esp) -c0105f93: e8 30 d8 ff ff call c01037c8 - // 将页目录的第0项设置为空 - pgdir[0] = 0; -c0105f98: 8b 45 e4 mov -0x1c(%ebp),%eax -c0105f9b: c7 00 00 00 00 00 movl $0x0,(%eax) - // 将内存管理结构体中的页目录设置为空 - mm->pgdir = NULL; -c0105fa1: 8b 45 e8 mov -0x18(%ebp),%eax -c0105fa4: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) - // 销毁内存管理结构体 - mm_destroy(mm); -c0105fab: 8b 45 e8 mov -0x18(%ebp),%eax -c0105fae: 89 04 24 mov %eax,(%esp) -c0105fb1: e8 78 f8 ff ff call c010582e - // 将检查用的内存管理结构体设置为空 - check_mm_struct = NULL; -c0105fb6: c7 05 c4 e0 12 c0 00 movl $0x0,0xc012e0c4 -c0105fbd: 00 00 00 - // 确保空闲页面的数量没有变化,证明内存管理正确 - assert(nr_free_pages_store == nr_free_pages()); -c0105fc0: e8 3a d8 ff ff call c01037ff -c0105fc5: 39 45 ec cmp %eax,-0x14(%ebp) -c0105fc8: 74 24 je c0105fee -c0105fca: c7 44 24 0c c4 b4 10 movl $0xc010b4c4,0xc(%esp) -c0105fd1: c0 -c0105fd2: c7 44 24 08 43 b4 10 movl $0xc010b443,0x8(%esp) -c0105fd9: c0 -c0105fda: c7 44 24 04 93 01 00 movl $0x193,0x4(%esp) -c0105fe1: 00 -c0105fe2: c7 04 24 58 b4 10 c0 movl $0xc010b458,(%esp) -c0105fe9: e8 55 a4 ff ff call c0100443 <__panic> - // 打印成功信息 - cprintf("check_pgfault() succeeded!\n"); -c0105fee: c7 04 24 b0 b6 10 c0 movl $0xc010b6b0,(%esp) -c0105ff5: e8 dd a2 ff ff call c01002d7 +c0104cbb : +page2pa(struct Page *page) { +c0104cbb: 55 push %ebp +c0104cbc: 89 e5 mov %esp,%ebp +c0104cbe: 83 ec 04 sub $0x4,%esp + return page2ppn(page) << PGSHIFT; +c0104cc1: 8b 45 08 mov 0x8(%ebp),%eax +c0104cc4: 89 04 24 mov %eax,(%esp) +c0104cc7: e8 dc ff ff ff call c0104ca8 +c0104ccc: c1 e0 0c shl $0xc,%eax } -c0105ffa: 90 nop -c0105ffb: c9 leave -c0105ffc: c3 ret +c0104ccf: 89 ec mov %ebp,%esp +c0104cd1: 5d pop %ebp +c0104cd2: c3 ret -c0105ffd : - * @param addr 引发页面错误的线性地址。 - * - * @return 成功返回0,失败返回负错误码。 - */ -int -do_pgfault(struct mm_struct *mm, uint32_t error_code, uintptr_t addr) { -c0105ffd: f3 0f 1e fb endbr32 -c0106001: 55 push %ebp -c0106002: 89 e5 mov %esp,%ebp -c0106004: 83 ec 38 sub $0x38,%esp - int ret = -E_INVAL;// 初始化返回值为无效错误 -c0106007: c7 45 f4 fd ff ff ff movl $0xfffffffd,-0xc(%ebp) - //try to find a vma which include addr - // 尝试找到包含 addr 的 vma - struct vma_struct *vma = find_vma(mm, addr); -c010600e: 8b 45 10 mov 0x10(%ebp),%eax -c0106011: 89 44 24 04 mov %eax,0x4(%esp) -c0106015: 8b 45 08 mov 0x8(%ebp),%eax -c0106018: 89 04 24 mov %eax,(%esp) -c010601b: e8 7c f5 ff ff call c010559c -c0106020: 89 45 ec mov %eax,-0x14(%ebp) +c0104cd3 : +pa2page(uintptr_t pa) { +c0104cd3: 55 push %ebp +c0104cd4: 89 e5 mov %esp,%ebp +c0104cd6: 83 ec 18 sub $0x18,%esp + if (PPN(pa) >= npage) { +c0104cd9: 8b 45 08 mov 0x8(%ebp),%eax +c0104cdc: c1 e8 0c shr $0xc,%eax +c0104cdf: 89 c2 mov %eax,%edx +c0104ce1: a1 04 c0 12 c0 mov 0xc012c004,%eax +c0104ce6: 39 c2 cmp %eax,%edx +c0104ce8: 72 1c jb c0104d06 + panic("pa2page called with invalid pa"); +c0104cea: c7 44 24 08 0c ae 10 movl $0xc010ae0c,0x8(%esp) +c0104cf1: c0 +c0104cf2: c7 44 24 04 5f 00 00 movl $0x5f,0x4(%esp) +c0104cf9: 00 +c0104cfa: c7 04 24 2b ae 10 c0 movl $0xc010ae2b,(%esp) +c0104d01: e8 3f bf ff ff call c0100c45 <__panic> + return &pages[PPN(pa)]; +c0104d06: 8b 15 00 c0 12 c0 mov 0xc012c000,%edx +c0104d0c: 8b 45 08 mov 0x8(%ebp),%eax +c0104d0f: c1 e8 0c shr $0xc,%eax +c0104d12: c1 e0 05 shl $0x5,%eax +c0104d15: 01 d0 add %edx,%eax +} +c0104d17: 89 ec mov %ebp,%esp +c0104d19: 5d pop %ebp +c0104d1a: c3 ret - pgfault_num++;// 增加页面错误计数 -c0106023: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0106028: 40 inc %eax -c0106029: a3 0c c0 12 c0 mov %eax,0xc012c00c - // 检查 addr 是否在 mm 的 vma 范围内 - //If the addr is in the range of a mm's vma? - if (vma == NULL || vma->vm_start > addr) { -c010602e: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) -c0106032: 74 0b je c010603f -c0106034: 8b 45 ec mov -0x14(%ebp),%eax -c0106037: 8b 40 04 mov 0x4(%eax),%eax -c010603a: 39 45 10 cmp %eax,0x10(%ebp) -c010603d: 73 18 jae c0106057 - cprintf("not valid addr %x, and can not find it in vma\n", addr); -c010603f: 8b 45 10 mov 0x10(%ebp),%eax -c0106042: 89 44 24 04 mov %eax,0x4(%esp) -c0106046: c7 04 24 cc b6 10 c0 movl $0xc010b6cc,(%esp) -c010604d: e8 85 a2 ff ff call c01002d7 - goto failed;// 跳转到错误处理部分 -c0106052: e9 ba 01 00 00 jmp c0106211 - } - //check the error_code - // 检查错误代码 - switch (error_code & 3) { -c0106057: 8b 45 0c mov 0xc(%ebp),%eax -c010605a: 83 e0 03 and $0x3,%eax -c010605d: 85 c0 test %eax,%eax -c010605f: 74 34 je c0106095 -c0106061: 83 f8 01 cmp $0x1,%eax -c0106064: 74 1e je c0106084 - default: - /* 默认错误代码标志:3 (W/R=1, P=1): 写操作,存在 */ - /* error code flag : default is 3 ( W/R=1, P=1): write, present */ - case 2: /* error code flag : (W/R=1, P=0): write, not present */ - /* 错误代码标志:(W/R=1, P=0): 写操作,不存在 */ - if (!(vma->vm_flags & VM_WRITE)) { -c0106066: 8b 45 ec mov -0x14(%ebp),%eax -c0106069: 8b 40 0c mov 0xc(%eax),%eax -c010606c: 83 e0 02 and $0x2,%eax -c010606f: 85 c0 test %eax,%eax -c0106071: 75 40 jne c01060b3 - cprintf("do_pgfault failed: error code flag = write AND not present, but the addr's vma cannot write\n"); -c0106073: c7 04 24 fc b6 10 c0 movl $0xc010b6fc,(%esp) -c010607a: e8 58 a2 ff ff call c01002d7 - goto failed;// 跳转到错误处理部分 -c010607f: e9 8d 01 00 00 jmp c0106211 - } - break; - case 1: /* error code flag : (W/R=0, P=1): read, present */ - /* 错误代码标志:(W/R=0, P=1): 读操作,存在 */ - cprintf("do_pgfault failed: error code flag = read AND present\n"); -c0106084: c7 04 24 5c b7 10 c0 movl $0xc010b75c,(%esp) -c010608b: e8 47 a2 ff ff call c01002d7 - goto failed;// 跳转到错误处理部分 -c0106090: e9 7c 01 00 00 jmp c0106211 - case 0: /* error code flag : (W/R=0, P=0): read, not present */ - /* 错误代码标志:(W/R=0, P=0): 读操作,不存在 */ - if (!(vma->vm_flags & (VM_READ | VM_EXEC))) { -c0106095: 8b 45 ec mov -0x14(%ebp),%eax -c0106098: 8b 40 0c mov 0xc(%eax),%eax -c010609b: 83 e0 05 and $0x5,%eax -c010609e: 85 c0 test %eax,%eax -c01060a0: 75 12 jne c01060b4 - cprintf("do_pgfault failed: error code flag = read AND not present, but the addr's vma cannot read or exec\n"); -c01060a2: c7 04 24 94 b7 10 c0 movl $0xc010b794,(%esp) -c01060a9: e8 29 a2 ff ff call c01002d7 - goto failed;// 跳转到错误处理部分 -c01060ae: e9 5e 01 00 00 jmp c0106211 - break; -c01060b3: 90 nop - /* 如果 (写入已存在的地址) 或 - * (写入不存在的地址且地址可写) 或 - * (读取不存在的地址且地址可读) - * 则继续处理 - */ - uint32_t perm = PTE_U;// 初始化权限标志为用户可访问 -c01060b4: c7 45 f0 04 00 00 00 movl $0x4,-0x10(%ebp) - if (vma->vm_flags & VM_WRITE) { -c01060bb: 8b 45 ec mov -0x14(%ebp),%eax -c01060be: 8b 40 0c mov 0xc(%eax),%eax -c01060c1: 83 e0 02 and $0x2,%eax -c01060c4: 85 c0 test %eax,%eax -c01060c6: 74 04 je c01060cc - perm |= PTE_W;// 如果 vma 可写,则设置写权限 -c01060c8: 83 4d f0 02 orl $0x2,-0x10(%ebp) - } - addr = ROUNDDOWN(addr, PGSIZE);// 将地址对齐到页边界 -c01060cc: 8b 45 10 mov 0x10(%ebp),%eax -c01060cf: 89 45 e8 mov %eax,-0x18(%ebp) -c01060d2: 8b 45 e8 mov -0x18(%ebp),%eax -c01060d5: 25 00 f0 ff ff and $0xfffff000,%eax -c01060da: 89 45 10 mov %eax,0x10(%ebp) +c0104d1b : +page2kva(struct Page *page) { +c0104d1b: 55 push %ebp +c0104d1c: 89 e5 mov %esp,%ebp +c0104d1e: 83 ec 28 sub $0x28,%esp + return KADDR(page2pa(page)); +c0104d21: 8b 45 08 mov 0x8(%ebp),%eax +c0104d24: 89 04 24 mov %eax,(%esp) +c0104d27: e8 8f ff ff ff call c0104cbb +c0104d2c: 89 45 f4 mov %eax,-0xc(%ebp) +c0104d2f: 8b 45 f4 mov -0xc(%ebp),%eax +c0104d32: c1 e8 0c shr $0xc,%eax +c0104d35: 89 45 f0 mov %eax,-0x10(%ebp) +c0104d38: a1 04 c0 12 c0 mov 0xc012c004,%eax +c0104d3d: 39 45 f0 cmp %eax,-0x10(%ebp) +c0104d40: 72 23 jb c0104d65 +c0104d42: 8b 45 f4 mov -0xc(%ebp),%eax +c0104d45: 89 44 24 0c mov %eax,0xc(%esp) +c0104d49: c7 44 24 08 3c ae 10 movl $0xc010ae3c,0x8(%esp) +c0104d50: c0 +c0104d51: c7 44 24 04 66 00 00 movl $0x66,0x4(%esp) +c0104d58: 00 +c0104d59: c7 04 24 2b ae 10 c0 movl $0xc010ae2b,(%esp) +c0104d60: e8 e0 be ff ff call c0100c45 <__panic> +c0104d65: 8b 45 f4 mov -0xc(%ebp),%eax +c0104d68: 2d 00 00 00 40 sub $0x40000000,%eax +} +c0104d6d: 89 ec mov %ebp,%esp +c0104d6f: 5d pop %ebp +c0104d70: c3 ret + +c0104d71 : +pte2page(pte_t pte) { +c0104d71: 55 push %ebp +c0104d72: 89 e5 mov %esp,%ebp +c0104d74: 83 ec 18 sub $0x18,%esp + if (!(pte & PTE_P)) { +c0104d77: 8b 45 08 mov 0x8(%ebp),%eax +c0104d7a: 83 e0 01 and $0x1,%eax +c0104d7d: 85 c0 test %eax,%eax +c0104d7f: 75 1c jne c0104d9d + panic("pte2page called with invalid pte"); +c0104d81: c7 44 24 08 60 ae 10 movl $0xc010ae60,0x8(%esp) +c0104d88: c0 +c0104d89: c7 44 24 04 71 00 00 movl $0x71,0x4(%esp) +c0104d90: 00 +c0104d91: c7 04 24 2b ae 10 c0 movl $0xc010ae2b,(%esp) +c0104d98: e8 a8 be ff ff call c0100c45 <__panic> + return pa2page(PTE_ADDR(pte)); +c0104d9d: 8b 45 08 mov 0x8(%ebp),%eax +c0104da0: 25 00 f0 ff ff and $0xfffff000,%eax +c0104da5: 89 04 24 mov %eax,(%esp) +c0104da8: e8 26 ff ff ff call c0104cd3 +} +c0104dad: 89 ec mov %ebp,%esp +c0104daf: 5d pop %ebp +c0104db0: c3 ret + +c0104db1 : +pde2page(pde_t pde) { +c0104db1: 55 push %ebp +c0104db2: 89 e5 mov %esp,%ebp +c0104db4: 83 ec 18 sub $0x18,%esp + return pa2page(PDE_ADDR(pde)); +c0104db7: 8b 45 08 mov 0x8(%ebp),%eax +c0104dba: 25 00 f0 ff ff and $0xfffff000,%eax +c0104dbf: 89 04 24 mov %eax,(%esp) +c0104dc2: e8 0c ff ff ff call c0104cd3 +} +c0104dc7: 89 ec mov %ebp,%esp +c0104dc9: 5d pop %ebp +c0104dca: c3 ret - ret = -E_NO_MEM;// 初始化返回值为内存不足错误 -c01060dd: c7 45 f4 fc ff ff ff movl $0xfffffffc,-0xc(%ebp) +c0104dcb : +page_ref(struct Page *page) { +c0104dcb: 55 push %ebp +c0104dcc: 89 e5 mov %esp,%ebp + return page->ref; +c0104dce: 8b 45 08 mov 0x8(%ebp),%eax +c0104dd1: 8b 00 mov (%eax),%eax +} +c0104dd3: 5d pop %ebp +c0104dd4: c3 ret - pte_t *ptep=NULL; -c01060e4: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) -#endif - // try to find a pte, if pte's PT(Page Table) isn't existed, then create a PT. - // (notice the 3th parameter '1') - // 尝试找到一个页表项 pte,如果包含该 pte 的页表不存在,则创建一个页表。 - // 注意第三个参数 '1' 表示如果需要,可以创建新的页表。 - if ((ptep = get_pte(mm->pgdir, addr, 1)) == NULL) { -c01060eb: 8b 45 08 mov 0x8(%ebp),%eax -c01060ee: 8b 40 0c mov 0xc(%eax),%eax -c01060f1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) -c01060f8: 00 -c01060f9: 8b 55 10 mov 0x10(%ebp),%edx -c01060fc: 89 54 24 04 mov %edx,0x4(%esp) -c0106100: 89 04 24 mov %eax,(%esp) -c0106103: e8 21 dd ff ff call c0103e29 -c0106108: 89 45 e4 mov %eax,-0x1c(%ebp) -c010610b: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) -c010610f: 75 11 jne c0106122 - cprintf("get_pte in do_pgfault failed\n");// 输出错误信息 -c0106111: c7 04 24 f7 b7 10 c0 movl $0xc010b7f7,(%esp) -c0106118: e8 ba a1 ff ff call c01002d7 - goto failed;// 跳转到错误处理部分 -c010611d: e9 ef 00 00 00 jmp c0106211 - } - // 如果页表项 pte 的物理地址不存在,则分配一页内存并映射物理地址与逻辑地址 - if (*ptep == 0) { // if the phy addr isn't exist, then alloc a page & map the phy addr with logical addr -c0106122: 8b 45 e4 mov -0x1c(%ebp),%eax -c0106125: 8b 00 mov (%eax),%eax -c0106127: 85 c0 test %eax,%eax -c0106129: 75 35 jne c0106160 - if (pgdir_alloc_page(mm->pgdir, addr, perm) == NULL) { -c010612b: 8b 45 08 mov 0x8(%ebp),%eax -c010612e: 8b 40 0c mov 0xc(%eax),%eax -c0106131: 8b 55 f0 mov -0x10(%ebp),%edx -c0106134: 89 54 24 08 mov %edx,0x8(%esp) -c0106138: 8b 55 10 mov 0x10(%ebp),%edx -c010613b: 89 54 24 04 mov %edx,0x4(%esp) -c010613f: 89 04 24 mov %eax,(%esp) -c0106142: e8 45 e0 ff ff call c010418c -c0106147: 85 c0 test %eax,%eax -c0106149: 0f 85 bb 00 00 00 jne c010620a - cprintf("pgdir_alloc_page in do_pgfault failed\n");// 输出错误信息 -c010614f: c7 04 24 18 b8 10 c0 movl $0xc010b818,(%esp) -c0106156: e8 7c a1 ff ff call c01002d7 - goto failed;// 跳转到错误处理部分 -c010615b: e9 b1 00 00 00 jmp c0106211 - } - else { // if this pte is a swap entry, then load data from disk to a page with phy addr - // and call page_insert to map the phy addr with logical addr - // 如果页表项 pte 是一个交换项,则从磁盘加载数据到 - //一个具有物理地址的页面,并映射物理地址与逻辑地址 - if(swap_init_ok) {// 检查交换初始化是否成功 -c0106160: a1 14 c0 12 c0 mov 0xc012c014,%eax -c0106165: 85 c0 test %eax,%eax -c0106167: 0f 84 86 00 00 00 je c01061f3 - struct Page *page=NULL;// 声明一个页面指针 -c010616d: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) - if ((ret = swap_in(mm, addr, &page)) != 0) { -c0106174: 8d 45 e0 lea -0x20(%ebp),%eax -c0106177: 89 44 24 08 mov %eax,0x8(%esp) -c010617b: 8b 45 10 mov 0x10(%ebp),%eax -c010617e: 89 44 24 04 mov %eax,0x4(%esp) -c0106182: 8b 45 08 mov 0x8(%ebp),%eax -c0106185: 89 04 24 mov %eax,(%esp) -c0106188: e8 2a 0b 00 00 call c0106cb7 -c010618d: 89 45 f4 mov %eax,-0xc(%ebp) -c0106190: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0106194: 74 0e je c01061a4 - cprintf("swap_in in do_pgfault failed\n"); -c0106196: c7 04 24 3f b8 10 c0 movl $0xc010b83f,(%esp) -c010619d: e8 35 a1 ff ff call c01002d7 -c01061a2: eb 6d jmp c0106211 - goto failed; - } - page_insert(mm->pgdir, page, addr, perm);// 设置物理地址与逻辑地址的映射 -c01061a4: 8b 55 e0 mov -0x20(%ebp),%edx -c01061a7: 8b 45 08 mov 0x8(%ebp),%eax -c01061aa: 8b 40 0c mov 0xc(%eax),%eax -c01061ad: 8b 4d f0 mov -0x10(%ebp),%ecx -c01061b0: 89 4c 24 0c mov %ecx,0xc(%esp) -c01061b4: 8b 4d 10 mov 0x10(%ebp),%ecx -c01061b7: 89 4c 24 08 mov %ecx,0x8(%esp) -c01061bb: 89 54 24 04 mov %edx,0x4(%esp) -c01061bf: 89 04 24 mov %eax,(%esp) -c01061c2: e8 a7 de ff ff call c010406e - swap_map_swappable(mm, addr, page, 1);// 设置页面可交换 -c01061c7: 8b 45 e0 mov -0x20(%ebp),%eax -c01061ca: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) -c01061d1: 00 -c01061d2: 89 44 24 08 mov %eax,0x8(%esp) -c01061d6: 8b 45 10 mov 0x10(%ebp),%eax -c01061d9: 89 44 24 04 mov %eax,0x4(%esp) -c01061dd: 8b 45 08 mov 0x8(%ebp),%eax -c01061e0: 89 04 24 mov %eax,(%esp) -c01061e3: e8 01 09 00 00 call c0106ae9 - page->pra_vaddr = addr;// 记录页面的虚拟地址 -c01061e8: 8b 45 e0 mov -0x20(%ebp),%eax -c01061eb: 8b 55 10 mov 0x10(%ebp),%edx -c01061ee: 89 50 1c mov %edx,0x1c(%eax) -c01061f1: eb 17 jmp c010620a - } - else { - cprintf("no swap_init_ok but ptep is %x, failed\n",*ptep); -c01061f3: 8b 45 e4 mov -0x1c(%ebp),%eax -c01061f6: 8b 00 mov (%eax),%eax -c01061f8: 89 44 24 04 mov %eax,0x4(%esp) -c01061fc: c7 04 24 60 b8 10 c0 movl $0xc010b860,(%esp) -c0106203: e8 cf a0 ff ff call c01002d7 - goto failed;// 跳转到错误处理部分 -c0106208: eb 07 jmp c0106211 - } - } - ret = 0;// 设置返回值为成功 -c010620a: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -failed: - return ret;// 返回结果 -c0106211: 8b 45 f4 mov -0xc(%ebp),%eax +c0104dd5 : +set_page_ref(struct Page *page, int val) { +c0104dd5: 55 push %ebp +c0104dd6: 89 e5 mov %esp,%ebp + page->ref = val; +c0104dd8: 8b 45 08 mov 0x8(%ebp),%eax +c0104ddb: 8b 55 0c mov 0xc(%ebp),%edx +c0104dde: 89 10 mov %edx,(%eax) +} +c0104de0: 90 nop +c0104de1: 5d pop %ebp +c0104de2: c3 ret + +c0104de3 : + +static inline int +page_ref_inc(struct Page *page) { +c0104de3: 55 push %ebp +c0104de4: 89 e5 mov %esp,%ebp + page->ref += 1; +c0104de6: 8b 45 08 mov 0x8(%ebp),%eax +c0104de9: 8b 00 mov (%eax),%eax +c0104deb: 8d 50 01 lea 0x1(%eax),%edx +c0104dee: 8b 45 08 mov 0x8(%ebp),%eax +c0104df1: 89 10 mov %edx,(%eax) + return page->ref; +c0104df3: 8b 45 08 mov 0x8(%ebp),%eax +c0104df6: 8b 00 mov (%eax),%eax +} +c0104df8: 5d pop %ebp +c0104df9: c3 ret + +c0104dfa : + +static inline int +page_ref_dec(struct Page *page) { +c0104dfa: 55 push %ebp +c0104dfb: 89 e5 mov %esp,%ebp + page->ref -= 1; +c0104dfd: 8b 45 08 mov 0x8(%ebp),%eax +c0104e00: 8b 00 mov (%eax),%eax +c0104e02: 8d 50 ff lea -0x1(%eax),%edx +c0104e05: 8b 45 08 mov 0x8(%ebp),%eax +c0104e08: 89 10 mov %edx,(%eax) + return page->ref; +c0104e0a: 8b 45 08 mov 0x8(%ebp),%eax +c0104e0d: 8b 00 mov (%eax),%eax } -c0106214: c9 leave -c0106215: c3 ret +c0104e0f: 5d pop %ebp +c0104e10: c3 ret -c0106216 <__intr_save>: +c0104e11 <__intr_save>: __intr_save(void) { -c0106216: 55 push %ebp -c0106217: 89 e5 mov %esp,%ebp -c0106219: 83 ec 18 sub $0x18,%esp +c0104e11: 55 push %ebp +c0104e12: 89 e5 mov %esp,%ebp +c0104e14: 83 ec 18 sub $0x18,%esp asm volatile ("pushfl; popl %0" : "=r" (eflags)); -c010621c: 9c pushf -c010621d: 58 pop %eax -c010621e: 89 45 f4 mov %eax,-0xc(%ebp) +c0104e17: 9c pushf +c0104e18: 58 pop %eax +c0104e19: 89 45 f4 mov %eax,-0xc(%ebp) return eflags; -c0106221: 8b 45 f4 mov -0xc(%ebp),%eax +c0104e1c: 8b 45 f4 mov -0xc(%ebp),%eax if (read_eflags() & FL_IF) { -c0106224: 25 00 02 00 00 and $0x200,%eax -c0106229: 85 c0 test %eax,%eax -c010622b: 74 0c je c0106239 <__intr_save+0x23> +c0104e1f: 25 00 02 00 00 and $0x200,%eax +c0104e24: 85 c0 test %eax,%eax +c0104e26: 74 0c je c0104e34 <__intr_save+0x23> intr_disable(); -c010622d: e8 22 bf ff ff call c0102154 +c0104e28: e8 ce d0 ff ff call c0101efb return 1; -c0106232: b8 01 00 00 00 mov $0x1,%eax -c0106237: eb 05 jmp c010623e <__intr_save+0x28> +c0104e2d: b8 01 00 00 00 mov $0x1,%eax +c0104e32: eb 05 jmp c0104e39 <__intr_save+0x28> return 0; -c0106239: b8 00 00 00 00 mov $0x0,%eax +c0104e34: b8 00 00 00 00 mov $0x0,%eax } -c010623e: c9 leave -c010623f: c3 ret +c0104e39: 89 ec mov %ebp,%esp +c0104e3b: 5d pop %ebp +c0104e3c: c3 ret -c0106240 <__intr_restore>: +c0104e3d <__intr_restore>: __intr_restore(bool flag) { -c0106240: 55 push %ebp -c0106241: 89 e5 mov %esp,%ebp -c0106243: 83 ec 08 sub $0x8,%esp +c0104e3d: 55 push %ebp +c0104e3e: 89 e5 mov %esp,%ebp +c0104e40: 83 ec 08 sub $0x8,%esp if (flag) { -c0106246: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c010624a: 74 05 je c0106251 <__intr_restore+0x11> +c0104e43: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0104e47: 74 05 je c0104e4e <__intr_restore+0x11> intr_enable(); -c010624c: e8 f7 be ff ff call c0102148 +c0104e49: e8 a5 d0 ff ff call c0101ef3 } -c0106251: 90 nop -c0106252: c9 leave -c0106253: c3 ret +c0104e4e: 90 nop +c0104e4f: 89 ec mov %ebp,%esp +c0104e51: 5d pop %ebp +c0104e52: c3 ret -c0106254 : -page2ppn(struct Page *page) { -c0106254: 55 push %ebp -c0106255: 89 e5 mov %esp,%ebp - return page - pages; -c0106257: a1 b8 e0 12 c0 mov 0xc012e0b8,%eax -c010625c: 8b 55 08 mov 0x8(%ebp),%edx -c010625f: 29 c2 sub %eax,%edx -c0106261: 89 d0 mov %edx,%eax -c0106263: c1 f8 05 sar $0x5,%eax +c0104e53 : + * data/code segement registers for kernel. + * lgdt - 加载全局描述符表寄存器并重置内核的数据/代码段寄存器。 + * */ +//定义了一个静态内联函数 lgdt,接收一个指向伪描述符(struct pseudodesc)的指针 pd +static inline void +lgdt(struct pseudodesc *pd) { +c0104e53: 55 push %ebp +c0104e54: 89 e5 mov %esp,%ebp + //这行汇编代码使用 lgdt 指令加载 GDT。%0 被替换为指向 pd 的指针,告诉处理器 GDT 的地址。 + asm volatile ("lgdt (%0)" :: "r" (pd)); +c0104e56: 8b 45 08 mov 0x8(%ebp),%eax +c0104e59: 0f 01 10 lgdtl (%eax) + asm volatile ("movw %%ax, %%gs" :: "a" (USER_DS));//将 USER_DS(用户数据段)的值移动到 gs 段寄存器。 +c0104e5c: b8 23 00 00 00 mov $0x23,%eax +c0104e61: 8e e8 mov %eax,%gs + asm volatile ("movw %%ax, %%fs" :: "a" (USER_DS));//将 USER_DS 的值移动到 fs 段寄存器。 +c0104e63: b8 23 00 00 00 mov $0x23,%eax +c0104e68: 8e e0 mov %eax,%fs + asm volatile ("movw %%ax, %%es" :: "a" (KERNEL_DS));//将 KERNEL_DS(内核数据段)的值移动到 es 段寄存器。 +c0104e6a: b8 10 00 00 00 mov $0x10,%eax +c0104e6f: 8e c0 mov %eax,%es + asm volatile ("movw %%ax, %%ds" :: "a" (KERNEL_DS));//将 KERNEL_DS 的值移动到 ds 段寄存器 +c0104e71: b8 10 00 00 00 mov $0x10,%eax +c0104e76: 8e d8 mov %eax,%ds + asm volatile ("movw %%ax, %%ss" :: "a" (KERNEL_DS));//将 KERNEL_DS 的值移动到 ss 段寄存器 +c0104e78: b8 10 00 00 00 mov $0x10,%eax +c0104e7d: 8e d0 mov %eax,%ss + // reload cs + //通过 ljmp 指令重新加载代码段寄存器 cs,并跳转到标签 1。 + asm volatile ("ljmp %0, $1f\n 1:\n" :: "i" (KERNEL_CS)); +c0104e7f: ea 86 4e 10 c0 08 00 ljmp $0x8,$0xc0104e86 } -c0106266: 5d pop %ebp -c0106267: c3 ret +c0104e86: 90 nop +c0104e87: 5d pop %ebp +c0104e88: c3 ret -c0106268 : -page2pa(struct Page *page) { -c0106268: 55 push %ebp -c0106269: 89 e5 mov %esp,%ebp -c010626b: 83 ec 04 sub $0x4,%esp - return page2ppn(page) << PGSHIFT; -c010626e: 8b 45 08 mov 0x8(%ebp),%eax -c0106271: 89 04 24 mov %eax,(%esp) -c0106274: e8 db ff ff ff call c0106254 -c0106279: c1 e0 0c shl $0xc,%eax +c0104e89 : + * load_esp0 - 修改默认任务状态段中的 ESP0,以便在从用户态陷入内核态时能够使用不同的内核栈。 + * */ +//uintptr_t esp0:这是新的堆栈指针,通常指向内核栈的顶部。 +//修改当前任务状态段(TSS)中的 ESP0 值。ESP0 是在从用户态切换到内核态时,CPU 使用的内核栈指针。 +void +load_esp0(uintptr_t esp0) { +c0104e89: 55 push %ebp +c0104e8a: 89 e5 mov %esp,%ebp + ts.ts_esp0 = esp0; +c0104e8c: 8b 45 08 mov 0x8(%ebp),%eax +c0104e8f: a3 24 c0 12 c0 mov %eax,0xc012c024 } -c010627c: c9 leave -c010627d: c3 ret +c0104e94: 90 nop +c0104e95: 5d pop %ebp +c0104e96: c3 ret -c010627e : -pa2page(uintptr_t pa) { -c010627e: 55 push %ebp -c010627f: 89 e5 mov %esp,%ebp -c0106281: 83 ec 18 sub $0x18,%esp - if (PPN(pa) >= npage) { -c0106284: 8b 45 08 mov 0x8(%ebp),%eax -c0106287: c1 e8 0c shr $0xc,%eax -c010628a: 89 c2 mov %eax,%edx -c010628c: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0106291: 39 c2 cmp %eax,%edx -c0106293: 72 1c jb c01062b1 - panic("pa2page called with invalid pa"); -c0106295: c7 44 24 08 88 b8 10 movl $0xc010b888,0x8(%esp) -c010629c: c0 -c010629d: c7 44 24 04 5f 00 00 movl $0x5f,0x4(%esp) -c01062a4: 00 -c01062a5: c7 04 24 a7 b8 10 c0 movl $0xc010b8a7,(%esp) -c01062ac: e8 92 a1 ff ff call c0100443 <__panic> - return &pages[PPN(pa)]; -c01062b1: a1 b8 e0 12 c0 mov 0xc012e0b8,%eax -c01062b6: 8b 55 08 mov 0x8(%ebp),%edx -c01062b9: c1 ea 0c shr $0xc,%edx -c01062bc: c1 e2 05 shl $0x5,%edx -c01062bf: 01 d0 add %edx,%eax +c0104e97 : + +/* gdt_init - initialize the default GDT and TSS */ +/* gdt_init - 初始化默认的 GDT 和 TSS */ +static void +gdt_init(void) { +c0104e97: 55 push %ebp +c0104e98: 89 e5 mov %esp,%ebp +c0104e9a: 83 ec 14 sub $0x14,%esp + // 设置启动内核栈和默认的 SS0 + // set boot kernel stack and default SS0 + load_esp0((uintptr_t)bootstacktop); +c0104e9d: b8 00 80 12 c0 mov $0xc0128000,%eax +c0104ea2: 89 04 24 mov %eax,(%esp) +c0104ea5: e8 df ff ff ff call c0104e89 + ts.ts_ss0 = KERNEL_DS; +c0104eaa: 66 c7 05 28 c0 12 c0 movw $0x10,0xc012c028 +c0104eb1: 10 00 + // 初始化 GDT 中的 TSS 字段 + // initialize the TSS filed of the gdt + gdt[SEG_TSS] = SEGTSS(STS_T32A, (uintptr_t)&ts, sizeof(ts), DPL_KERNEL); +c0104eb3: 66 c7 05 48 8a 12 c0 movw $0x68,0xc0128a48 +c0104eba: 68 00 +c0104ebc: b8 20 c0 12 c0 mov $0xc012c020,%eax +c0104ec1: 0f b7 c0 movzwl %ax,%eax +c0104ec4: 66 a3 4a 8a 12 c0 mov %ax,0xc0128a4a +c0104eca: b8 20 c0 12 c0 mov $0xc012c020,%eax +c0104ecf: c1 e8 10 shr $0x10,%eax +c0104ed2: a2 4c 8a 12 c0 mov %al,0xc0128a4c +c0104ed7: 0f b6 05 4d 8a 12 c0 movzbl 0xc0128a4d,%eax +c0104ede: 24 f0 and $0xf0,%al +c0104ee0: 0c 09 or $0x9,%al +c0104ee2: a2 4d 8a 12 c0 mov %al,0xc0128a4d +c0104ee7: 0f b6 05 4d 8a 12 c0 movzbl 0xc0128a4d,%eax +c0104eee: 24 ef and $0xef,%al +c0104ef0: a2 4d 8a 12 c0 mov %al,0xc0128a4d +c0104ef5: 0f b6 05 4d 8a 12 c0 movzbl 0xc0128a4d,%eax +c0104efc: 24 9f and $0x9f,%al +c0104efe: a2 4d 8a 12 c0 mov %al,0xc0128a4d +c0104f03: 0f b6 05 4d 8a 12 c0 movzbl 0xc0128a4d,%eax +c0104f0a: 0c 80 or $0x80,%al +c0104f0c: a2 4d 8a 12 c0 mov %al,0xc0128a4d +c0104f11: 0f b6 05 4e 8a 12 c0 movzbl 0xc0128a4e,%eax +c0104f18: 24 f0 and $0xf0,%al +c0104f1a: a2 4e 8a 12 c0 mov %al,0xc0128a4e +c0104f1f: 0f b6 05 4e 8a 12 c0 movzbl 0xc0128a4e,%eax +c0104f26: 24 ef and $0xef,%al +c0104f28: a2 4e 8a 12 c0 mov %al,0xc0128a4e +c0104f2d: 0f b6 05 4e 8a 12 c0 movzbl 0xc0128a4e,%eax +c0104f34: 24 df and $0xdf,%al +c0104f36: a2 4e 8a 12 c0 mov %al,0xc0128a4e +c0104f3b: 0f b6 05 4e 8a 12 c0 movzbl 0xc0128a4e,%eax +c0104f42: 0c 40 or $0x40,%al +c0104f44: a2 4e 8a 12 c0 mov %al,0xc0128a4e +c0104f49: 0f b6 05 4e 8a 12 c0 movzbl 0xc0128a4e,%eax +c0104f50: 24 7f and $0x7f,%al +c0104f52: a2 4e 8a 12 c0 mov %al,0xc0128a4e +c0104f57: b8 20 c0 12 c0 mov $0xc012c020,%eax +c0104f5c: c1 e8 18 shr $0x18,%eax +c0104f5f: a2 4f 8a 12 c0 mov %al,0xc0128a4f + // 使用lgdt加载全局描述符表,更新所有段寄存器 + // reload all segment registers + lgdt(&gdt_pd); +c0104f64: c7 04 24 50 8a 12 c0 movl $0xc0128a50,(%esp) +c0104f6b: e8 e3 fe ff ff call c0104e53 +c0104f70: 66 c7 45 fe 28 00 movw $0x28,-0x2(%ebp) + asm volatile ("ltr %0" :: "r" (sel) : "memory"); +c0104f76: 0f b7 45 fe movzwl -0x2(%ebp),%eax +c0104f7a: 0f 00 d8 ltr %ax +} +c0104f7d: 90 nop + // 加载 TSS,使 CPU 在进行特权级切换时能够正确使用 TSS。 + // load the TSS + ltr(GD_TSS); } -c01062c1: c9 leave -c01062c2: c3 ret +c0104f7e: 90 nop +c0104f7f: 89 ec mov %ebp,%esp +c0104f81: 5d pop %ebp +c0104f82: c3 ret -c01062c3 : -page2kva(struct Page *page) { -c01062c3: 55 push %ebp -c01062c4: 89 e5 mov %esp,%ebp -c01062c6: 83 ec 28 sub $0x28,%esp - return KADDR(page2pa(page)); -c01062c9: 8b 45 08 mov 0x8(%ebp),%eax -c01062cc: 89 04 24 mov %eax,(%esp) -c01062cf: e8 94 ff ff ff call c0106268 -c01062d4: 89 45 f4 mov %eax,-0xc(%ebp) -c01062d7: 8b 45 f4 mov -0xc(%ebp),%eax -c01062da: c1 e8 0c shr $0xc,%eax -c01062dd: 89 45 f0 mov %eax,-0x10(%ebp) -c01062e0: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c01062e5: 39 45 f0 cmp %eax,-0x10(%ebp) -c01062e8: 72 23 jb c010630d -c01062ea: 8b 45 f4 mov -0xc(%ebp),%eax -c01062ed: 89 44 24 0c mov %eax,0xc(%esp) -c01062f1: c7 44 24 08 b8 b8 10 movl $0xc010b8b8,0x8(%esp) -c01062f8: c0 -c01062f9: c7 44 24 04 66 00 00 movl $0x66,0x4(%esp) -c0106300: 00 -c0106301: c7 04 24 a7 b8 10 c0 movl $0xc010b8a7,(%esp) -c0106308: e8 36 a1 ff ff call c0100443 <__panic> -c010630d: 8b 45 f4 mov -0xc(%ebp),%eax -c0106310: 2d 00 00 00 40 sub $0x40000000,%eax -} -c0106315: c9 leave -c0106316: c3 ret - -c0106317 : -kva2page(void *kva) { -c0106317: 55 push %ebp -c0106318: 89 e5 mov %esp,%ebp -c010631a: 83 ec 28 sub $0x28,%esp - return pa2page(PADDR(kva)); -c010631d: 8b 45 08 mov 0x8(%ebp),%eax -c0106320: 89 45 f4 mov %eax,-0xc(%ebp) -c0106323: 81 7d f4 ff ff ff bf cmpl $0xbfffffff,-0xc(%ebp) -c010632a: 77 23 ja c010634f -c010632c: 8b 45 f4 mov -0xc(%ebp),%eax -c010632f: 89 44 24 0c mov %eax,0xc(%esp) -c0106333: c7 44 24 08 dc b8 10 movl $0xc010b8dc,0x8(%esp) -c010633a: c0 -c010633b: c7 44 24 04 6b 00 00 movl $0x6b,0x4(%esp) -c0106342: 00 -c0106343: c7 04 24 a7 b8 10 c0 movl $0xc010b8a7,(%esp) -c010634a: e8 f4 a0 ff ff call c0100443 <__panic> -c010634f: 8b 45 f4 mov -0xc(%ebp),%eax -c0106352: 05 00 00 00 40 add $0x40000000,%eax -c0106357: 89 04 24 mov %eax,(%esp) -c010635a: e8 1f ff ff ff call c010627e -} -c010635f: c9 leave -c0106360: c3 ret - -c0106361 <__slob_get_free_pages>: -static slob_t *slobfree = &arena; -static bigblock_t *bigblocks; +c0104f83 : +//init_pmm_manager - initialize a pmm_manager instance +//初始化一个 pmm_manager 实例 +static void +init_pmm_manager(void) { +c0104f83: 55 push %ebp +c0104f84: 89 e5 mov %esp,%ebp +c0104f86: 83 ec 18 sub $0x18,%esp + //将 pmm_manager 指向默认的 PMM 管理器实例。 + pmm_manager = &default_pmm_manager; +c0104f89: c7 05 0c c0 12 c0 00 movl $0xc010ad00,0xc012c00c +c0104f90: ad 10 c0 + //使用 cprintf 打印当前内存管理器的名称。 + cprintf("memory management: %s\n", pmm_manager->name); +c0104f93: a1 0c c0 12 c0 mov 0xc012c00c,%eax +c0104f98: 8b 00 mov (%eax),%eax +c0104f9a: 89 44 24 04 mov %eax,0x4(%esp) +c0104f9e: c7 04 24 8c ae 10 c0 movl $0xc010ae8c,(%esp) +c0104fa5: e8 ce b3 ff ff call c0100378 + //调用 PMM 管理器的初始化函数,以设置和准备内存管理的相关数据结构。 + pmm_manager->init(); +c0104faa: a1 0c c0 12 c0 mov 0xc012c00c,%eax +c0104faf: 8b 40 04 mov 0x4(%eax),%eax +c0104fb2: ff d0 call *%eax +} +c0104fb4: 90 nop +c0104fb5: 89 ec mov %ebp,%esp +c0104fb7: 5d pop %ebp +c0104fb8: c3 ret -static void* __slob_get_free_pages(gfp_t gfp, int order) -{ -c0106361: f3 0f 1e fb endbr32 -c0106365: 55 push %ebp -c0106366: 89 e5 mov %esp,%ebp -c0106368: 83 ec 28 sub $0x28,%esp - struct Page * page = alloc_pages(1 << order); -c010636b: 8b 45 0c mov 0xc(%ebp),%eax -c010636e: ba 01 00 00 00 mov $0x1,%edx -c0106373: 88 c1 mov %al,%cl -c0106375: d3 e2 shl %cl,%edx -c0106377: 89 d0 mov %edx,%eax -c0106379: 89 04 24 mov %eax,(%esp) -c010637c: e8 d8 d3 ff ff call c0103759 -c0106381: 89 45 f4 mov %eax,-0xc(%ebp) - if(!page) -c0106384: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0106388: 75 07 jne c0106391 <__slob_get_free_pages+0x30> - return NULL; -c010638a: b8 00 00 00 00 mov $0x0,%eax -c010638f: eb 0b jmp c010639c <__slob_get_free_pages+0x3b> - return page2kva(page); -c0106391: 8b 45 f4 mov -0xc(%ebp),%eax -c0106394: 89 04 24 mov %eax,(%esp) -c0106397: e8 27 ff ff ff call c01062c3 +c0104fb9 : + +//init_memmap - call pmm->init_memmap to build Page struct for free memory +// init_memmap - 调用 pmm->init_memmap 构建空闲内存的 Page 结构 +//struct Page *base:指向内存页的基础地址。 size_t n:要初始化的页数。 +static void +init_memmap(struct Page *base, size_t n) { +c0104fb9: 55 push %ebp +c0104fba: 89 e5 mov %esp,%ebp +c0104fbc: 83 ec 18 sub $0x18,%esp + pmm_manager->init_memmap(base, n); +c0104fbf: a1 0c c0 12 c0 mov 0xc012c00c,%eax +c0104fc4: 8b 40 08 mov 0x8(%eax),%eax +c0104fc7: 8b 55 0c mov 0xc(%ebp),%edx +c0104fca: 89 54 24 04 mov %edx,0x4(%esp) +c0104fce: 8b 55 08 mov 0x8(%ebp),%edx +c0104fd1: 89 14 24 mov %edx,(%esp) +c0104fd4: ff d0 call *%eax +} +c0104fd6: 90 nop +c0104fd7: 89 ec mov %ebp,%esp +c0104fd9: 5d pop %ebp +c0104fda: c3 ret + +c0104fdb : + +//alloc_pages - call pmm->alloc_pages to allocate a continuous n*PAGESIZE memory +// alloc_pages - 调用 pmm->alloc_pages 分配连续的 n*PAGESIZE 内存 +struct Page * +alloc_pages(size_t n) { +c0104fdb: 55 push %ebp +c0104fdc: 89 e5 mov %esp,%ebp +c0104fde: 83 ec 28 sub $0x28,%esp + struct Page *page=NULL; +c0104fe1: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) + bool intr_flag; + //使用 local_intr_save 保存当前的中断状态,以避免在分配内存时发生中断。 + while (1) + { + local_intr_save(intr_flag); +c0104fe8: e8 24 fe ff ff call c0104e11 <__intr_save> +c0104fed: 89 45 f0 mov %eax,-0x10(%ebp) + { + page = pmm_manager->alloc_pages(n);//尝试分配 n 个页面。 +c0104ff0: a1 0c c0 12 c0 mov 0xc012c00c,%eax +c0104ff5: 8b 40 0c mov 0xc(%eax),%eax +c0104ff8: 8b 55 08 mov 0x8(%ebp),%edx +c0104ffb: 89 14 24 mov %edx,(%esp) +c0104ffe: ff d0 call *%eax +c0105000: 89 45 f4 mov %eax,-0xc(%ebp) + } + local_intr_restore(intr_flag); +c0105003: 8b 45 f0 mov -0x10(%ebp),%eax +c0105006: 89 04 24 mov %eax,(%esp) +c0105009: e8 2f fe ff ff call c0104e3d <__intr_restore> + + if (page != NULL || n > 1 || swap_init_ok == 0) break; +c010500e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0105012: 75 2d jne c0105041 +c0105014: 83 7d 08 01 cmpl $0x1,0x8(%ebp) +c0105018: 77 27 ja c0105041 +c010501a: a1 a4 c0 12 c0 mov 0xc012c0a4,%eax +c010501f: 85 c0 test %eax,%eax +c0105021: 74 1e je c0105041 + + extern struct mm_struct *check_mm_struct; + //cprintf("page %x, call swap_out in alloc_pages %d\n",page, n); + swap_out(check_mm_struct, n, 0); +c0105023: 8b 55 08 mov 0x8(%ebp),%edx +c0105026: a1 6c c1 12 c0 mov 0xc012c16c,%eax +c010502b: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c0105032: 00 +c0105033: 89 54 24 04 mov %edx,0x4(%esp) +c0105037: 89 04 24 mov %eax,(%esp) +c010503a: e8 c5 18 00 00 call c0106904 + { +c010503f: eb a7 jmp c0104fe8 + } + //cprintf("n %d,get page %x, No %d in alloc_pages\n",n,page,(page-pages)); + return page; +c0105041: 8b 45 f4 mov -0xc(%ebp),%eax +} +c0105044: 89 ec mov %ebp,%esp +c0105046: 5d pop %ebp +c0105047: c3 ret + +c0105048 : + +//free_pages - call pmm->free_pages to free a continuous n*PAGESIZE memory +// free_pages - 调用 pmm->free_pages 释放连续的 n*PAGESIZE 内存 +//struct Page *base:指向要释放的内存页的基础地址。size_t n:要释放的页数。 +void +free_pages(struct Page *base, size_t n) { +c0105048: 55 push %ebp +c0105049: 89 e5 mov %esp,%ebp +c010504b: 83 ec 28 sub $0x28,%esp + bool intr_flag; + //使用 local_intr_save 保存当前的中断状态,以避免在释放内存时发生中断。 + local_intr_save(intr_flag); +c010504e: e8 be fd ff ff call c0104e11 <__intr_save> +c0105053: 89 45 f4 mov %eax,-0xc(%ebp) + { + //调用物理内存管理器的 free_pages 函数释放 n 页的内存。 + pmm_manager->free_pages(base, n); +c0105056: a1 0c c0 12 c0 mov 0xc012c00c,%eax +c010505b: 8b 40 10 mov 0x10(%eax),%eax +c010505e: 8b 55 0c mov 0xc(%ebp),%edx +c0105061: 89 54 24 04 mov %edx,0x4(%esp) +c0105065: 8b 55 08 mov 0x8(%ebp),%edx +c0105068: 89 14 24 mov %edx,(%esp) +c010506b: ff d0 call *%eax + } + local_intr_restore(intr_flag); +c010506d: 8b 45 f4 mov -0xc(%ebp),%eax +c0105070: 89 04 24 mov %eax,(%esp) +c0105073: e8 c5 fd ff ff call c0104e3d <__intr_restore> +} +c0105078: 90 nop +c0105079: 89 ec mov %ebp,%esp +c010507b: 5d pop %ebp +c010507c: c3 ret + +c010507d : + +//nr_free_pages - call pmm->nr_free_pages to get the size (nr*PAGESIZE) +//of current free memory +// nr_free_pages - 调用 pmm->nr_free_pages 获取当前空闲内存的大小 (nr * PAGESIZE) +size_t +nr_free_pages(void) { +c010507d: 55 push %ebp +c010507e: 89 e5 mov %esp,%ebp +c0105080: 83 ec 28 sub $0x28,%esp + size_t ret;// 定义变量 ret 用于存储返回的空闲内存大小 + bool intr_flag;// 定义变量 intr_flag 用于保存中断状态 + local_intr_save(intr_flag);// 保存当前中断状态,并禁用中断 +c0105083: e8 89 fd ff ff call c0104e11 <__intr_save> +c0105088: 89 45 f4 mov %eax,-0xc(%ebp) + { + ret = pmm_manager->nr_free_pages();// 调用物理内存管理器的函数获取空闲内存页数 +c010508b: a1 0c c0 12 c0 mov 0xc012c00c,%eax +c0105090: 8b 40 14 mov 0x14(%eax),%eax +c0105093: ff d0 call *%eax +c0105095: 89 45 f0 mov %eax,-0x10(%ebp) + } + local_intr_restore(intr_flag);// 恢复之前保存的中断状态 +c0105098: 8b 45 f4 mov -0xc(%ebp),%eax +c010509b: 89 04 24 mov %eax,(%esp) +c010509e: e8 9a fd ff ff call c0104e3d <__intr_restore> + return ret;// 返回空闲内存的大小 +c01050a3: 8b 45 f0 mov -0x10(%ebp),%eax +} +c01050a6: 89 ec mov %ebp,%esp +c01050a8: 5d pop %ebp +c01050a9: c3 ret + +c01050aa : + +/* pmm_init - initialize the physical memory management */ +/* pmm_init - 初始化物理内存管理 */ +static void +page_init(void) { +c01050aa: 55 push %ebp +c01050ab: 89 e5 mov %esp,%ebp +c01050ad: 57 push %edi +c01050ae: 56 push %esi +c01050af: 53 push %ebx +c01050b0: 81 ec 9c 00 00 00 sub $0x9c,%esp + // 获取物理内存映射信息,存于特定地址 + struct e820map *memmap = (struct e820map *)(0x8000 + KERNBASE); +c01050b6: c7 45 c4 00 80 00 c0 movl $0xc0008000,-0x3c(%ebp) + uint64_t maxpa = 0;// 初始化最大物理地址为0 +c01050bd: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) +c01050c4: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) + + cprintf("e820map:\n");// 打印“e820map”标题 +c01050cb: c7 04 24 a3 ae 10 c0 movl $0xc010aea3,(%esp) +c01050d2: e8 a1 b2 ff ff call c0100378 + int i; + for (i = 0; i < memmap->nr_map; i ++) {// 遍历内存映射数组 +c01050d7: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) +c01050de: e9 0c 01 00 00 jmp c01051ef + uint64_t begin = memmap->map[i].addr, end = begin + memmap->map[i].size;// 获取每个区域的起始和结束地址 +c01050e3: 8b 4d c4 mov -0x3c(%ebp),%ecx +c01050e6: 8b 55 dc mov -0x24(%ebp),%edx +c01050e9: 89 d0 mov %edx,%eax +c01050eb: c1 e0 02 shl $0x2,%eax +c01050ee: 01 d0 add %edx,%eax +c01050f0: c1 e0 02 shl $0x2,%eax +c01050f3: 01 c8 add %ecx,%eax +c01050f5: 8b 50 08 mov 0x8(%eax),%edx +c01050f8: 8b 40 04 mov 0x4(%eax),%eax +c01050fb: 89 45 a0 mov %eax,-0x60(%ebp) +c01050fe: 89 55 a4 mov %edx,-0x5c(%ebp) +c0105101: 8b 4d c4 mov -0x3c(%ebp),%ecx +c0105104: 8b 55 dc mov -0x24(%ebp),%edx +c0105107: 89 d0 mov %edx,%eax +c0105109: c1 e0 02 shl $0x2,%eax +c010510c: 01 d0 add %edx,%eax +c010510e: c1 e0 02 shl $0x2,%eax +c0105111: 01 c8 add %ecx,%eax +c0105113: 8b 48 0c mov 0xc(%eax),%ecx +c0105116: 8b 58 10 mov 0x10(%eax),%ebx +c0105119: 8b 45 a0 mov -0x60(%ebp),%eax +c010511c: 8b 55 a4 mov -0x5c(%ebp),%edx +c010511f: 01 c8 add %ecx,%eax +c0105121: 11 da adc %ebx,%edx +c0105123: 89 45 98 mov %eax,-0x68(%ebp) +c0105126: 89 55 9c mov %edx,-0x64(%ebp) + cprintf(" memory: %08llx, [%08llx, %08llx], type = %d.\n",// 打印内存区域的信息 +c0105129: 8b 4d c4 mov -0x3c(%ebp),%ecx +c010512c: 8b 55 dc mov -0x24(%ebp),%edx +c010512f: 89 d0 mov %edx,%eax +c0105131: c1 e0 02 shl $0x2,%eax +c0105134: 01 d0 add %edx,%eax +c0105136: c1 e0 02 shl $0x2,%eax +c0105139: 01 c8 add %ecx,%eax +c010513b: 83 c0 14 add $0x14,%eax +c010513e: 8b 00 mov (%eax),%eax +c0105140: 89 85 7c ff ff ff mov %eax,-0x84(%ebp) +c0105146: 8b 45 98 mov -0x68(%ebp),%eax +c0105149: 8b 55 9c mov -0x64(%ebp),%edx +c010514c: 83 c0 ff add $0xffffffff,%eax +c010514f: 83 d2 ff adc $0xffffffff,%edx +c0105152: 89 c6 mov %eax,%esi +c0105154: 89 d7 mov %edx,%edi +c0105156: 8b 4d c4 mov -0x3c(%ebp),%ecx +c0105159: 8b 55 dc mov -0x24(%ebp),%edx +c010515c: 89 d0 mov %edx,%eax +c010515e: c1 e0 02 shl $0x2,%eax +c0105161: 01 d0 add %edx,%eax +c0105163: c1 e0 02 shl $0x2,%eax +c0105166: 01 c8 add %ecx,%eax +c0105168: 8b 48 0c mov 0xc(%eax),%ecx +c010516b: 8b 58 10 mov 0x10(%eax),%ebx +c010516e: 8b 85 7c ff ff ff mov -0x84(%ebp),%eax +c0105174: 89 44 24 1c mov %eax,0x1c(%esp) +c0105178: 89 74 24 14 mov %esi,0x14(%esp) +c010517c: 89 7c 24 18 mov %edi,0x18(%esp) +c0105180: 8b 45 a0 mov -0x60(%ebp),%eax +c0105183: 8b 55 a4 mov -0x5c(%ebp),%edx +c0105186: 89 44 24 0c mov %eax,0xc(%esp) +c010518a: 89 54 24 10 mov %edx,0x10(%esp) +c010518e: 89 4c 24 04 mov %ecx,0x4(%esp) +c0105192: 89 5c 24 08 mov %ebx,0x8(%esp) +c0105196: c7 04 24 b0 ae 10 c0 movl $0xc010aeb0,(%esp) +c010519d: e8 d6 b1 ff ff call c0100378 + memmap->map[i].size, begin, end - 1, memmap->map[i].type); + if (memmap->map[i].type == E820_ARM) {// 检查内存类型是否为可用内存 +c01051a2: 8b 4d c4 mov -0x3c(%ebp),%ecx +c01051a5: 8b 55 dc mov -0x24(%ebp),%edx +c01051a8: 89 d0 mov %edx,%eax +c01051aa: c1 e0 02 shl $0x2,%eax +c01051ad: 01 d0 add %edx,%eax +c01051af: c1 e0 02 shl $0x2,%eax +c01051b2: 01 c8 add %ecx,%eax +c01051b4: 83 c0 14 add $0x14,%eax +c01051b7: 8b 00 mov (%eax),%eax +c01051b9: 83 f8 01 cmp $0x1,%eax +c01051bc: 75 2e jne c01051ec + if (maxpa < end && begin < KMEMSIZE) {// 检查当前区域是否在有效范围内 +c01051be: 8b 45 e0 mov -0x20(%ebp),%eax +c01051c1: 8b 55 e4 mov -0x1c(%ebp),%edx +c01051c4: 3b 45 98 cmp -0x68(%ebp),%eax +c01051c7: 89 d0 mov %edx,%eax +c01051c9: 1b 45 9c sbb -0x64(%ebp),%eax +c01051cc: 73 1e jae c01051ec +c01051ce: ba ff ff ff 37 mov $0x37ffffff,%edx +c01051d3: b8 00 00 00 00 mov $0x0,%eax +c01051d8: 3b 55 a0 cmp -0x60(%ebp),%edx +c01051db: 1b 45 a4 sbb -0x5c(%ebp),%eax +c01051de: 72 0c jb c01051ec + maxpa = end;// 更新最大物理地址 +c01051e0: 8b 45 98 mov -0x68(%ebp),%eax +c01051e3: 8b 55 9c mov -0x64(%ebp),%edx +c01051e6: 89 45 e0 mov %eax,-0x20(%ebp) +c01051e9: 89 55 e4 mov %edx,-0x1c(%ebp) + for (i = 0; i < memmap->nr_map; i ++) {// 遍历内存映射数组 +c01051ec: ff 45 dc incl -0x24(%ebp) +c01051ef: 8b 45 c4 mov -0x3c(%ebp),%eax +c01051f2: 8b 00 mov (%eax),%eax +c01051f4: 39 45 dc cmp %eax,-0x24(%ebp) +c01051f7: 0f 8c e6 fe ff ff jl c01050e3 + } + } + } + if (maxpa > KMEMSIZE) {// 如果最大物理地址超过了预定义的内存上限 +c01051fd: ba 00 00 00 38 mov $0x38000000,%edx +c0105202: b8 00 00 00 00 mov $0x0,%eax +c0105207: 3b 55 e0 cmp -0x20(%ebp),%edx +c010520a: 1b 45 e4 sbb -0x1c(%ebp),%eax +c010520d: 73 0e jae c010521d + maxpa = KMEMSIZE;// 将其限制为内存上限 +c010520f: c7 45 e0 00 00 00 38 movl $0x38000000,-0x20(%ebp) +c0105216: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) + } + + extern char end[];// 引入全局变量 end,指向内存的结束位置 + + npage = maxpa / PGSIZE;// 计算可用页数 +c010521d: 8b 45 e0 mov -0x20(%ebp),%eax +c0105220: 8b 55 e4 mov -0x1c(%ebp),%edx +c0105223: 0f ac d0 0c shrd $0xc,%edx,%eax +c0105227: c1 ea 0c shr $0xc,%edx +c010522a: a3 04 c0 12 c0 mov %eax,0xc012c004 + pages = (struct Page *)ROUNDUP((void *)end, PGSIZE);// 将 end 对齐到页边界,指向页结构数组的开头 +c010522f: c7 45 c0 00 10 00 00 movl $0x1000,-0x40(%ebp) +c0105236: b8 b4 e1 12 c0 mov $0xc012e1b4,%eax +c010523b: 8d 50 ff lea -0x1(%eax),%edx +c010523e: 8b 45 c0 mov -0x40(%ebp),%eax +c0105241: 01 d0 add %edx,%eax +c0105243: 89 45 bc mov %eax,-0x44(%ebp) +c0105246: 8b 45 bc mov -0x44(%ebp),%eax +c0105249: ba 00 00 00 00 mov $0x0,%edx +c010524e: f7 75 c0 divl -0x40(%ebp) +c0105251: 8b 45 bc mov -0x44(%ebp),%eax +c0105254: 29 d0 sub %edx,%eax +c0105256: a3 00 c0 12 c0 mov %eax,0xc012c000 + + for (i = 0; i < npage; i ++) {// 遍历每一页 +c010525b: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) +c0105262: eb 28 jmp c010528c + SetPageReserved(pages + i);// 将每一页标记为保留状态 +c0105264: 8b 15 00 c0 12 c0 mov 0xc012c000,%edx +c010526a: 8b 45 dc mov -0x24(%ebp),%eax +c010526d: c1 e0 05 shl $0x5,%eax +c0105270: 01 d0 add %edx,%eax +c0105272: 83 c0 04 add $0x4,%eax +c0105275: c7 45 94 00 00 00 00 movl $0x0,-0x6c(%ebp) +c010527c: 89 45 90 mov %eax,-0x70(%ebp) + asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); +c010527f: 8b 45 90 mov -0x70(%ebp),%eax +c0105282: 8b 55 94 mov -0x6c(%ebp),%edx +c0105285: 0f ab 10 bts %edx,(%eax) +} +c0105288: 90 nop + for (i = 0; i < npage; i ++) {// 遍历每一页 +c0105289: ff 45 dc incl -0x24(%ebp) +c010528c: 8b 55 dc mov -0x24(%ebp),%edx +c010528f: a1 04 c0 12 c0 mov 0xc012c004,%eax +c0105294: 39 c2 cmp %eax,%edx +c0105296: 72 cc jb c0105264 + } + + uintptr_t freemem = PADDR((uintptr_t)pages + sizeof(struct Page) * npage);// 计算可用内存的起始地址 +c0105298: a1 04 c0 12 c0 mov 0xc012c004,%eax +c010529d: c1 e0 05 shl $0x5,%eax +c01052a0: 89 c2 mov %eax,%edx +c01052a2: a1 00 c0 12 c0 mov 0xc012c000,%eax +c01052a7: 01 d0 add %edx,%eax +c01052a9: 89 45 b8 mov %eax,-0x48(%ebp) +c01052ac: 81 7d b8 ff ff ff bf cmpl $0xbfffffff,-0x48(%ebp) +c01052b3: 77 23 ja c01052d8 +c01052b5: 8b 45 b8 mov -0x48(%ebp),%eax +c01052b8: 89 44 24 0c mov %eax,0xc(%esp) +c01052bc: c7 44 24 08 e0 ae 10 movl $0xc010aee0,0x8(%esp) +c01052c3: c0 +c01052c4: c7 44 24 04 1a 01 00 movl $0x11a,0x4(%esp) +c01052cb: 00 +c01052cc: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c01052d3: e8 6d b9 ff ff call c0100c45 <__panic> +c01052d8: 8b 45 b8 mov -0x48(%ebp),%eax +c01052db: 05 00 00 00 40 add $0x40000000,%eax +c01052e0: 89 45 b4 mov %eax,-0x4c(%ebp) + + for (i = 0; i < memmap->nr_map; i ++) {// 再次遍历内存映射 +c01052e3: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) +c01052ea: e9 53 01 00 00 jmp c0105442 + uint64_t begin = memmap->map[i].addr, end = begin + memmap->map[i].size;// 获取每个区域的起始和结束地址 +c01052ef: 8b 4d c4 mov -0x3c(%ebp),%ecx +c01052f2: 8b 55 dc mov -0x24(%ebp),%edx +c01052f5: 89 d0 mov %edx,%eax +c01052f7: c1 e0 02 shl $0x2,%eax +c01052fa: 01 d0 add %edx,%eax +c01052fc: c1 e0 02 shl $0x2,%eax +c01052ff: 01 c8 add %ecx,%eax +c0105301: 8b 50 08 mov 0x8(%eax),%edx +c0105304: 8b 40 04 mov 0x4(%eax),%eax +c0105307: 89 45 d0 mov %eax,-0x30(%ebp) +c010530a: 89 55 d4 mov %edx,-0x2c(%ebp) +c010530d: 8b 4d c4 mov -0x3c(%ebp),%ecx +c0105310: 8b 55 dc mov -0x24(%ebp),%edx +c0105313: 89 d0 mov %edx,%eax +c0105315: c1 e0 02 shl $0x2,%eax +c0105318: 01 d0 add %edx,%eax +c010531a: c1 e0 02 shl $0x2,%eax +c010531d: 01 c8 add %ecx,%eax +c010531f: 8b 48 0c mov 0xc(%eax),%ecx +c0105322: 8b 58 10 mov 0x10(%eax),%ebx +c0105325: 8b 45 d0 mov -0x30(%ebp),%eax +c0105328: 8b 55 d4 mov -0x2c(%ebp),%edx +c010532b: 01 c8 add %ecx,%eax +c010532d: 11 da adc %ebx,%edx +c010532f: 89 45 c8 mov %eax,-0x38(%ebp) +c0105332: 89 55 cc mov %edx,-0x34(%ebp) + if (memmap->map[i].type == E820_ARM) {// 如果区域类型为可用内存 +c0105335: 8b 4d c4 mov -0x3c(%ebp),%ecx +c0105338: 8b 55 dc mov -0x24(%ebp),%edx +c010533b: 89 d0 mov %edx,%eax +c010533d: c1 e0 02 shl $0x2,%eax +c0105340: 01 d0 add %edx,%eax +c0105342: c1 e0 02 shl $0x2,%eax +c0105345: 01 c8 add %ecx,%eax +c0105347: 83 c0 14 add $0x14,%eax +c010534a: 8b 00 mov (%eax),%eax +c010534c: 83 f8 01 cmp $0x1,%eax +c010534f: 0f 85 ea 00 00 00 jne c010543f + if (begin < freemem) {// 如果起始地址小于可用内存地址 +c0105355: 8b 45 b4 mov -0x4c(%ebp),%eax +c0105358: ba 00 00 00 00 mov $0x0,%edx +c010535d: 8b 4d d4 mov -0x2c(%ebp),%ecx +c0105360: 39 45 d0 cmp %eax,-0x30(%ebp) +c0105363: 19 d1 sbb %edx,%ecx +c0105365: 73 0d jae c0105374 + begin = freemem;//将起始地址设置为可用内存地址 +c0105367: 8b 45 b4 mov -0x4c(%ebp),%eax +c010536a: 89 45 d0 mov %eax,-0x30(%ebp) +c010536d: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) + } + if (end > KMEMSIZE) {// 如果结束地址超过内存上限 +c0105374: ba 00 00 00 38 mov $0x38000000,%edx +c0105379: b8 00 00 00 00 mov $0x0,%eax +c010537e: 3b 55 c8 cmp -0x38(%ebp),%edx +c0105381: 1b 45 cc sbb -0x34(%ebp),%eax +c0105384: 73 0e jae c0105394 + end = KMEMSIZE;// 将其限制为内存上限 +c0105386: c7 45 c8 00 00 00 38 movl $0x38000000,-0x38(%ebp) +c010538d: c7 45 cc 00 00 00 00 movl $0x0,-0x34(%ebp) + } + if (begin < end) {// 如果起始地址小于结束地址 +c0105394: 8b 45 d0 mov -0x30(%ebp),%eax +c0105397: 8b 55 d4 mov -0x2c(%ebp),%edx +c010539a: 3b 45 c8 cmp -0x38(%ebp),%eax +c010539d: 89 d0 mov %edx,%eax +c010539f: 1b 45 cc sbb -0x34(%ebp),%eax +c01053a2: 0f 83 97 00 00 00 jae c010543f + begin = ROUNDUP(begin, PGSIZE);// 将起始地址对齐到页边界 +c01053a8: c7 45 b0 00 10 00 00 movl $0x1000,-0x50(%ebp) +c01053af: 8b 55 d0 mov -0x30(%ebp),%edx +c01053b2: 8b 45 b0 mov -0x50(%ebp),%eax +c01053b5: 01 d0 add %edx,%eax +c01053b7: 48 dec %eax +c01053b8: 89 45 ac mov %eax,-0x54(%ebp) +c01053bb: 8b 45 ac mov -0x54(%ebp),%eax +c01053be: ba 00 00 00 00 mov $0x0,%edx +c01053c3: f7 75 b0 divl -0x50(%ebp) +c01053c6: 8b 45 ac mov -0x54(%ebp),%eax +c01053c9: 29 d0 sub %edx,%eax +c01053cb: ba 00 00 00 00 mov $0x0,%edx +c01053d0: 89 45 d0 mov %eax,-0x30(%ebp) +c01053d3: 89 55 d4 mov %edx,-0x2c(%ebp) + end = ROUNDDOWN(end, PGSIZE);// 将结束地址对齐到页边界 +c01053d6: 8b 45 c8 mov -0x38(%ebp),%eax +c01053d9: 89 45 a8 mov %eax,-0x58(%ebp) +c01053dc: 8b 45 a8 mov -0x58(%ebp),%eax +c01053df: ba 00 00 00 00 mov $0x0,%edx +c01053e4: 89 c7 mov %eax,%edi +c01053e6: 81 e7 00 f0 ff ff and $0xfffff000,%edi +c01053ec: 89 7d 80 mov %edi,-0x80(%ebp) +c01053ef: 89 d0 mov %edx,%eax +c01053f1: 83 e0 00 and $0x0,%eax +c01053f4: 89 45 84 mov %eax,-0x7c(%ebp) +c01053f7: 8b 45 80 mov -0x80(%ebp),%eax +c01053fa: 8b 55 84 mov -0x7c(%ebp),%edx +c01053fd: 89 45 c8 mov %eax,-0x38(%ebp) +c0105400: 89 55 cc mov %edx,-0x34(%ebp) + if (begin < end) {// 如果调整后的起始地址仍小于结束地址 +c0105403: 8b 45 d0 mov -0x30(%ebp),%eax +c0105406: 8b 55 d4 mov -0x2c(%ebp),%edx +c0105409: 3b 45 c8 cmp -0x38(%ebp),%eax +c010540c: 89 d0 mov %edx,%eax +c010540e: 1b 45 cc sbb -0x34(%ebp),%eax +c0105411: 73 2c jae c010543f + init_memmap(pa2page(begin), (end - begin) / PGSIZE);// 初始化内存页映射 +c0105413: 8b 45 c8 mov -0x38(%ebp),%eax +c0105416: 8b 55 cc mov -0x34(%ebp),%edx +c0105419: 2b 45 d0 sub -0x30(%ebp),%eax +c010541c: 1b 55 d4 sbb -0x2c(%ebp),%edx +c010541f: 0f ac d0 0c shrd $0xc,%edx,%eax +c0105423: c1 ea 0c shr $0xc,%edx +c0105426: 89 c3 mov %eax,%ebx +c0105428: 8b 45 d0 mov -0x30(%ebp),%eax +c010542b: 89 04 24 mov %eax,(%esp) +c010542e: e8 a0 f8 ff ff call c0104cd3 +c0105433: 89 5c 24 04 mov %ebx,0x4(%esp) +c0105437: 89 04 24 mov %eax,(%esp) +c010543a: e8 7a fb ff ff call c0104fb9 + for (i = 0; i < memmap->nr_map; i ++) {// 再次遍历内存映射 +c010543f: ff 45 dc incl -0x24(%ebp) +c0105442: 8b 45 c4 mov -0x3c(%ebp),%eax +c0105445: 8b 00 mov (%eax),%eax +c0105447: 39 45 dc cmp %eax,-0x24(%ebp) +c010544a: 0f 8c 9f fe ff ff jl c01052ef + } + } + } + } } -c010639c: c9 leave -c010639d: c3 ret - -c010639e <__slob_free_pages>: +c0105450: 90 nop +c0105451: 90 nop +c0105452: 81 c4 9c 00 00 00 add $0x9c,%esp +c0105458: 5b pop %ebx +c0105459: 5e pop %esi +c010545a: 5f pop %edi +c010545b: 5d pop %ebp +c010545c: c3 ret -#define __slob_get_free_page(gfp) __slob_get_free_pages(gfp, 0) +c010545d : +//la: 需要映射的线性地址(经过 x86 段映射后的地址) +// size: memory size size: 内存大小 +// pa: physical address of this memory pa:该内存的物理地址 +// perm: permission of this memory perm: 该内存的权限 +static void +boot_map_segment(pde_t *pgdir, uintptr_t la, size_t size, uintptr_t pa, uint32_t perm) { +c010545d: 55 push %ebp +c010545e: 89 e5 mov %esp,%ebp +c0105460: 83 ec 38 sub $0x38,%esp + // 确保线性地址和物理地址的页偏移相同 + assert(PGOFF(la) == PGOFF(pa)); +c0105463: 8b 45 0c mov 0xc(%ebp),%eax +c0105466: 33 45 14 xor 0x14(%ebp),%eax +c0105469: 25 ff 0f 00 00 and $0xfff,%eax +c010546e: 85 c0 test %eax,%eax +c0105470: 74 24 je c0105496 +c0105472: c7 44 24 0c 12 af 10 movl $0xc010af12,0xc(%esp) +c0105479: c0 +c010547a: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105481: c0 +c0105482: c7 44 24 04 3b 01 00 movl $0x13b,0x4(%esp) +c0105489: 00 +c010548a: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105491: e8 af b7 ff ff call c0100c45 <__panic> + // 计算需要映射的页数,ROUNDUP 将总大小对齐到下一个页大小的边界 + size_t n = ROUNDUP(size + PGOFF(la), PGSIZE) / PGSIZE; +c0105496: c7 45 f0 00 10 00 00 movl $0x1000,-0x10(%ebp) +c010549d: 8b 45 0c mov 0xc(%ebp),%eax +c01054a0: 25 ff 0f 00 00 and $0xfff,%eax +c01054a5: 89 c2 mov %eax,%edx +c01054a7: 8b 45 10 mov 0x10(%ebp),%eax +c01054aa: 01 c2 add %eax,%edx +c01054ac: 8b 45 f0 mov -0x10(%ebp),%eax +c01054af: 01 d0 add %edx,%eax +c01054b1: 48 dec %eax +c01054b2: 89 45 ec mov %eax,-0x14(%ebp) +c01054b5: 8b 45 ec mov -0x14(%ebp),%eax +c01054b8: ba 00 00 00 00 mov $0x0,%edx +c01054bd: f7 75 f0 divl -0x10(%ebp) +c01054c0: 8b 45 ec mov -0x14(%ebp),%eax +c01054c3: 29 d0 sub %edx,%eax +c01054c5: c1 e8 0c shr $0xc,%eax +c01054c8: 89 45 f4 mov %eax,-0xc(%ebp) + // 将线性地址向下对齐到页边界 + la = ROUNDDOWN(la, PGSIZE); +c01054cb: 8b 45 0c mov 0xc(%ebp),%eax +c01054ce: 89 45 e8 mov %eax,-0x18(%ebp) +c01054d1: 8b 45 e8 mov -0x18(%ebp),%eax +c01054d4: 25 00 f0 ff ff and $0xfffff000,%eax +c01054d9: 89 45 0c mov %eax,0xc(%ebp) + // 将物理地址向下对齐到页边界 + pa = ROUNDDOWN(pa, PGSIZE); +c01054dc: 8b 45 14 mov 0x14(%ebp),%eax +c01054df: 89 45 e4 mov %eax,-0x1c(%ebp) +c01054e2: 8b 45 e4 mov -0x1c(%ebp),%eax +c01054e5: 25 00 f0 ff ff and $0xfffff000,%eax +c01054ea: 89 45 14 mov %eax,0x14(%ebp) + // 循环遍历每一页,直到映射的页数为零 + for (; n > 0; n --, la += PGSIZE, pa += PGSIZE) { +c01054ed: eb 68 jmp c0105557 + // 获取当前页的页表项指针,如果不存在则创建新的页表项 + pte_t *ptep = get_pte(pgdir, la, 1); +c01054ef: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) +c01054f6: 00 +c01054f7: 8b 45 0c mov 0xc(%ebp),%eax +c01054fa: 89 44 24 04 mov %eax,0x4(%esp) +c01054fe: 8b 45 08 mov 0x8(%ebp),%eax +c0105501: 89 04 24 mov %eax,(%esp) +c0105504: e8 8d 01 00 00 call c0105696 +c0105509: 89 45 e0 mov %eax,-0x20(%ebp) + // 确保页表项指针不为空 + assert(ptep != NULL); +c010550c: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) +c0105510: 75 24 jne c0105536 +c0105512: c7 44 24 0c 3e af 10 movl $0xc010af3e,0xc(%esp) +c0105519: c0 +c010551a: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105521: c0 +c0105522: c7 44 24 04 47 01 00 movl $0x147,0x4(%esp) +c0105529: 00 +c010552a: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105531: e8 0f b7 ff ff call c0100c45 <__panic> + // 设置页表项,包含物理地址、存在位和权限 + *ptep = pa | PTE_P | perm; +c0105536: 8b 45 14 mov 0x14(%ebp),%eax +c0105539: 0b 45 18 or 0x18(%ebp),%eax +c010553c: 83 c8 01 or $0x1,%eax +c010553f: 89 c2 mov %eax,%edx +c0105541: 8b 45 e0 mov -0x20(%ebp),%eax +c0105544: 89 10 mov %edx,(%eax) + for (; n > 0; n --, la += PGSIZE, pa += PGSIZE) { +c0105546: ff 4d f4 decl -0xc(%ebp) +c0105549: 81 45 0c 00 10 00 00 addl $0x1000,0xc(%ebp) +c0105550: 81 45 14 00 10 00 00 addl $0x1000,0x14(%ebp) +c0105557: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c010555b: 75 92 jne c01054ef + } +} +c010555d: 90 nop +c010555e: 90 nop +c010555f: 89 ec mov %ebp,%esp +c0105561: 5d pop %ebp +c0105562: c3 ret -static inline void __slob_free_pages(unsigned long kva, int order) -{ -c010639e: 55 push %ebp -c010639f: 89 e5 mov %esp,%ebp -c01063a1: 53 push %ebx -c01063a2: 83 ec 14 sub $0x14,%esp - free_pages(kva2page(kva), 1 << order); -c01063a5: 8b 45 0c mov 0xc(%ebp),%eax -c01063a8: ba 01 00 00 00 mov $0x1,%edx -c01063ad: 88 c1 mov %al,%cl -c01063af: d3 e2 shl %cl,%edx -c01063b1: 89 d0 mov %edx,%eax -c01063b3: 89 c3 mov %eax,%ebx -c01063b5: 8b 45 08 mov 0x8(%ebp),%eax -c01063b8: 89 04 24 mov %eax,(%esp) -c01063bb: e8 57 ff ff ff call c0106317 -c01063c0: 89 5c 24 04 mov %ebx,0x4(%esp) -c01063c4: 89 04 24 mov %eax,(%esp) -c01063c7: e8 fc d3 ff ff call c01037c8 -} -c01063cc: 90 nop -c01063cd: 83 c4 14 add $0x14,%esp -c01063d0: 5b pop %ebx -c01063d1: 5d pop %ebp -c01063d2: c3 ret - -c01063d3 : +c0105563 : +// return value: the kernel virtual address of this allocated page +//note: this function is used to get the memory for PDT(Page Directory Table)&PT(Page Table) +//boot_alloc_page - 使用 pmm->alloc_pages(1) 分配一页内存.返回值: 分配的页面的内核虚拟地址 +//注意: 此函数用于获取页目录表(PDT)和页表(PT)的内存 +static void * +boot_alloc_page(void) { +c0105563: 55 push %ebp +c0105564: 89 e5 mov %esp,%ebp +c0105566: 83 ec 28 sub $0x28,%esp + struct Page *p = alloc_page();// 调用分配页面的函数 +c0105569: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0105570: e8 66 fa ff ff call c0104fdb +c0105575: 89 45 f4 mov %eax,-0xc(%ebp) + if (p == NULL) {// 检查分配是否成功 +c0105578: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c010557c: 75 1c jne c010559a + panic("boot_alloc_page failed.\n");// 如果分配失败,则触发异常 +c010557e: c7 44 24 08 4b af 10 movl $0xc010af4b,0x8(%esp) +c0105585: c0 +c0105586: c7 44 24 04 56 01 00 movl $0x156,0x4(%esp) +c010558d: 00 +c010558e: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105595: e8 ab b6 ff ff call c0100c45 <__panic> + } + return page2kva(p);// 返回分配页面的内核虚拟地址 +c010559a: 8b 45 f4 mov -0xc(%ebp),%eax +c010559d: 89 04 24 mov %eax,(%esp) +c01055a0: e8 76 f7 ff ff call c0104d1b +} +c01055a5: 89 ec mov %ebp,%esp +c01055a7: 5d pop %ebp +c01055a8: c3 ret -static void slob_free(void *b, int size); +c01055a9 : +//pmm_init - setup a pmm to manage physical memory, build PDT&PT to setup paging mechanism +// - check the correctness of pmm & paging mechanism, print PDT&PT +//pmm_init - 设置物理内存管理器,构建页目录表(PDT)和页表(PT),以设置分页机制 +// - 检查物理内存管理器和分页机制的正确性,打印页目录表和页表 +void +pmm_init(void) { +c01055a9: 55 push %ebp +c01055aa: 89 e5 mov %esp,%ebp +c01055ac: 83 ec 38 sub $0x38,%esp + // We've already enabled paging + // 我们已经启用了分页 + boot_cr3 = PADDR(boot_pgdir); +c01055af: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c01055b4: 89 45 f4 mov %eax,-0xc(%ebp) +c01055b7: 81 7d f4 ff ff ff bf cmpl $0xbfffffff,-0xc(%ebp) +c01055be: 77 23 ja c01055e3 +c01055c0: 8b 45 f4 mov -0xc(%ebp),%eax +c01055c3: 89 44 24 0c mov %eax,0xc(%esp) +c01055c7: c7 44 24 08 e0 ae 10 movl $0xc010aee0,0x8(%esp) +c01055ce: c0 +c01055cf: c7 44 24 04 63 01 00 movl $0x163,0x4(%esp) +c01055d6: 00 +c01055d7: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c01055de: e8 62 b6 ff ff call c0100c45 <__panic> +c01055e3: 8b 45 f4 mov -0xc(%ebp),%eax +c01055e6: 05 00 00 00 40 add $0x40000000,%eax +c01055eb: a3 08 c0 12 c0 mov %eax,0xc012c008 + // 我们需要分配/释放物理内存(粒度为 4KB 或其他大小)。 + // 因此在 pmm.h 中定义了物理内存管理器的框架(struct pmm_manager)。 + // 首先,我们应该基于该框架初始化一个物理内存管理器(pmm)。 + // 然后 pmm 可以分配/释放物理内存。 + // 现在,first_fit/best_fit/worst_fit/buddy_system 的 pmm 都可用。 + init_pmm_manager();// 初始化物理内存管理器 +c01055f0: e8 8e f9 ff ff call c0104f83 -static void *slob_alloc(size_t size, gfp_t gfp, int align) -{ -c01063d3: f3 0f 1e fb endbr32 -c01063d7: 55 push %ebp -c01063d8: 89 e5 mov %esp,%ebp -c01063da: 83 ec 38 sub $0x38,%esp - assert( (size + SLOB_UNIT) < PAGE_SIZE ); -c01063dd: 8b 45 08 mov 0x8(%ebp),%eax -c01063e0: 83 c0 08 add $0x8,%eax -c01063e3: 3d ff 0f 00 00 cmp $0xfff,%eax -c01063e8: 76 24 jbe c010640e -c01063ea: c7 44 24 0c 00 b9 10 movl $0xc010b900,0xc(%esp) -c01063f1: c0 -c01063f2: c7 44 24 08 1f b9 10 movl $0xc010b91f,0x8(%esp) -c01063f9: c0 -c01063fa: c7 44 24 04 64 00 00 movl $0x64,0x4(%esp) -c0106401: 00 -c0106402: c7 04 24 34 b9 10 c0 movl $0xc010b934,(%esp) -c0106409: e8 35 a0 ff ff call c0100443 <__panic> + // detect physical memory space, reserve already used memory, + // then use pmm->init_memmap to create free page list + // 检测物理内存空间,保留已经使用的内存, + // 然后使用 pmm->init_memmap 创建空闲页面列表 + page_init();// 初始化页面管理 +c01055f5: e8 b0 fa ff ff call c01050aa - slob_t *prev, *cur, *aligned = 0; -c010640e: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) - int delta = 0, units = SLOB_UNITS(size); -c0106415: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp) -c010641c: 8b 45 08 mov 0x8(%ebp),%eax -c010641f: 83 c0 07 add $0x7,%eax -c0106422: c1 e8 03 shr $0x3,%eax -c0106425: 89 45 e0 mov %eax,-0x20(%ebp) - unsigned long flags; + //use pmm->check to verify the correctness of the alloc/free function in a pmm + // 使用 pmm->check 验证 pmm 中分配/释放函数的正确性 + check_alloc_page();// 检查页面分配功能 +c01055fa: e8 bf 04 00 00 call c0105abe - spin_lock_irqsave(&slob_lock, flags); -c0106428: e8 e9 fd ff ff call c0106216 <__intr_save> -c010642d: 89 45 e4 mov %eax,-0x1c(%ebp) - prev = slobfree; -c0106430: a1 68 8a 12 c0 mov 0xc0128a68,%eax -c0106435: 89 45 f4 mov %eax,-0xc(%ebp) - for (cur = prev->next; ; prev = cur, cur = cur->next) { -c0106438: 8b 45 f4 mov -0xc(%ebp),%eax -c010643b: 8b 40 04 mov 0x4(%eax),%eax -c010643e: 89 45 f0 mov %eax,-0x10(%ebp) - if (align) { -c0106441: 83 7d 10 00 cmpl $0x0,0x10(%ebp) -c0106445: 74 21 je c0106468 - aligned = (slob_t *)ALIGN((unsigned long)cur, align); -c0106447: 8b 55 f0 mov -0x10(%ebp),%edx -c010644a: 8b 45 10 mov 0x10(%ebp),%eax -c010644d: 01 d0 add %edx,%eax -c010644f: 8d 50 ff lea -0x1(%eax),%edx -c0106452: 8b 45 10 mov 0x10(%ebp),%eax -c0106455: f7 d8 neg %eax -c0106457: 21 d0 and %edx,%eax -c0106459: 89 45 ec mov %eax,-0x14(%ebp) - delta = aligned - cur; -c010645c: 8b 45 ec mov -0x14(%ebp),%eax -c010645f: 2b 45 f0 sub -0x10(%ebp),%eax -c0106462: c1 f8 03 sar $0x3,%eax -c0106465: 89 45 e8 mov %eax,-0x18(%ebp) - } - if (cur->units >= units + delta) { /* room enough? */ -c0106468: 8b 45 f0 mov -0x10(%ebp),%eax -c010646b: 8b 00 mov (%eax),%eax -c010646d: 8b 4d e0 mov -0x20(%ebp),%ecx -c0106470: 8b 55 e8 mov -0x18(%ebp),%edx -c0106473: 01 ca add %ecx,%edx -c0106475: 39 d0 cmp %edx,%eax -c0106477: 0f 8c aa 00 00 00 jl c0106527 - if (delta) { /* need to fragment head to align? */ -c010647d: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) -c0106481: 74 38 je c01064bb - aligned->units = cur->units - delta; -c0106483: 8b 45 f0 mov -0x10(%ebp),%eax -c0106486: 8b 00 mov (%eax),%eax -c0106488: 2b 45 e8 sub -0x18(%ebp),%eax -c010648b: 89 c2 mov %eax,%edx -c010648d: 8b 45 ec mov -0x14(%ebp),%eax -c0106490: 89 10 mov %edx,(%eax) - aligned->next = cur->next; -c0106492: 8b 45 f0 mov -0x10(%ebp),%eax -c0106495: 8b 50 04 mov 0x4(%eax),%edx -c0106498: 8b 45 ec mov -0x14(%ebp),%eax -c010649b: 89 50 04 mov %edx,0x4(%eax) - cur->next = aligned; -c010649e: 8b 45 f0 mov -0x10(%ebp),%eax -c01064a1: 8b 55 ec mov -0x14(%ebp),%edx -c01064a4: 89 50 04 mov %edx,0x4(%eax) - cur->units = delta; -c01064a7: 8b 45 f0 mov -0x10(%ebp),%eax -c01064aa: 8b 55 e8 mov -0x18(%ebp),%edx -c01064ad: 89 10 mov %edx,(%eax) - prev = cur; -c01064af: 8b 45 f0 mov -0x10(%ebp),%eax -c01064b2: 89 45 f4 mov %eax,-0xc(%ebp) - cur = aligned; -c01064b5: 8b 45 ec mov -0x14(%ebp),%eax -c01064b8: 89 45 f0 mov %eax,-0x10(%ebp) - } + check_pgdir();// 检查页目录的状态 +c01055ff: e8 db 04 00 00 call c0105adf - if (cur->units == units) /* exact fit? */ -c01064bb: 8b 45 f0 mov -0x10(%ebp),%eax -c01064be: 8b 00 mov (%eax),%eax -c01064c0: 39 45 e0 cmp %eax,-0x20(%ebp) -c01064c3: 75 0e jne c01064d3 - prev->next = cur->next; /* unlink */ -c01064c5: 8b 45 f0 mov -0x10(%ebp),%eax -c01064c8: 8b 50 04 mov 0x4(%eax),%edx -c01064cb: 8b 45 f4 mov -0xc(%ebp),%eax -c01064ce: 89 50 04 mov %edx,0x4(%eax) -c01064d1: eb 3c jmp c010650f - else { /* fragment */ - prev->next = cur + units; -c01064d3: 8b 45 e0 mov -0x20(%ebp),%eax -c01064d6: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx -c01064dd: 8b 45 f0 mov -0x10(%ebp),%eax -c01064e0: 01 c2 add %eax,%edx -c01064e2: 8b 45 f4 mov -0xc(%ebp),%eax -c01064e5: 89 50 04 mov %edx,0x4(%eax) - prev->next->units = cur->units - units; -c01064e8: 8b 45 f0 mov -0x10(%ebp),%eax -c01064eb: 8b 10 mov (%eax),%edx -c01064ed: 8b 45 f4 mov -0xc(%ebp),%eax -c01064f0: 8b 40 04 mov 0x4(%eax),%eax -c01064f3: 2b 55 e0 sub -0x20(%ebp),%edx -c01064f6: 89 10 mov %edx,(%eax) - prev->next->next = cur->next; -c01064f8: 8b 45 f4 mov -0xc(%ebp),%eax -c01064fb: 8b 40 04 mov 0x4(%eax),%eax -c01064fe: 8b 55 f0 mov -0x10(%ebp),%edx -c0106501: 8b 52 04 mov 0x4(%edx),%edx -c0106504: 89 50 04 mov %edx,0x4(%eax) - cur->units = units; -c0106507: 8b 45 f0 mov -0x10(%ebp),%eax -c010650a: 8b 55 e0 mov -0x20(%ebp),%edx -c010650d: 89 10 mov %edx,(%eax) - } + // recursively insert boot_pgdir in itself + // to form a virtual page table at virtual address VPT + // 递归地将 boot_pgdir 插入到自身中 + // 在虚拟地址 VPT 处形成虚拟页表 + boot_pgdir[PDX(VPT)] = PADDR(boot_pgdir) | PTE_P | PTE_W;// 设置页目录项,映射自身 +c0105604: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105609: 89 45 f0 mov %eax,-0x10(%ebp) +c010560c: 81 7d f0 ff ff ff bf cmpl $0xbfffffff,-0x10(%ebp) +c0105613: 77 23 ja c0105638 +c0105615: 8b 45 f0 mov -0x10(%ebp),%eax +c0105618: 89 44 24 0c mov %eax,0xc(%esp) +c010561c: c7 44 24 08 e0 ae 10 movl $0xc010aee0,0x8(%esp) +c0105623: c0 +c0105624: c7 44 24 04 83 01 00 movl $0x183,0x4(%esp) +c010562b: 00 +c010562c: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105633: e8 0d b6 ff ff call c0100c45 <__panic> +c0105638: 8b 45 f0 mov -0x10(%ebp),%eax +c010563b: 8d 90 00 00 00 40 lea 0x40000000(%eax),%edx +c0105641: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105646: 05 ac 0f 00 00 add $0xfac,%eax +c010564b: 83 ca 03 or $0x3,%edx +c010564e: 89 10 mov %edx,(%eax) - slobfree = prev; -c010650f: 8b 45 f4 mov -0xc(%ebp),%eax -c0106512: a3 68 8a 12 c0 mov %eax,0xc0128a68 - spin_unlock_irqrestore(&slob_lock, flags); -c0106517: 8b 45 e4 mov -0x1c(%ebp),%eax -c010651a: 89 04 24 mov %eax,(%esp) -c010651d: e8 1e fd ff ff call c0106240 <__intr_restore> - return cur; -c0106522: 8b 45 f0 mov -0x10(%ebp),%eax -c0106525: eb 7f jmp c01065a6 - } - if (cur == slobfree) { -c0106527: a1 68 8a 12 c0 mov 0xc0128a68,%eax -c010652c: 39 45 f0 cmp %eax,-0x10(%ebp) -c010652f: 75 61 jne c0106592 - spin_unlock_irqrestore(&slob_lock, flags); -c0106531: 8b 45 e4 mov -0x1c(%ebp),%eax -c0106534: 89 04 24 mov %eax,(%esp) -c0106537: e8 04 fd ff ff call c0106240 <__intr_restore> + // map all physical memory to linear memory with base linear addr KERNBASE + // linear_addr KERNBASE ~ KERNBASE + KMEMSIZE = phy_addr 0 ~ KMEMSIZE + // 将所有物理内存映射到线性内存,基地址为 KERNBASE + // 线性地址 KERNBASE ~ KERNBASE + KMEMSIZE = 物理地址 0 ~ KMEMSIZE + boot_map_segment(boot_pgdir, KERNBASE, KMEMSIZE, 0, PTE_W);// 映射物理内存 +c0105650: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105655: c7 44 24 10 02 00 00 movl $0x2,0x10(%esp) +c010565c: 00 +c010565d: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) +c0105664: 00 +c0105665: c7 44 24 08 00 00 00 movl $0x38000000,0x8(%esp) +c010566c: 38 +c010566d: c7 44 24 04 00 00 00 movl $0xc0000000,0x4(%esp) +c0105674: c0 +c0105675: 89 04 24 mov %eax,(%esp) +c0105678: e8 e0 fd ff ff call c010545d + // then set kernel stack (ss:esp) in TSS, setup TSS in gdt, load TSS + // 由于我们正在使用引导加载程序的 GDT, + // 我们应该重新加载 GDT(第二次,也是最后一次),以获取用户段和 TSS + // 映射虚拟地址 0 ~ 4G = 线性地址 0 ~ 4G + // 然后在 TSS 中设置内核栈 (ss:esp),在 gdt 中设置 TSS,加载 TSS + gdt_init();// 初始化全局描述符表 +c010567d: e8 15 f8 ff ff call c0104e97 - if (size == PAGE_SIZE) /* trying to shrink arena? */ -c010653c: 81 7d 08 00 10 00 00 cmpl $0x1000,0x8(%ebp) -c0106543: 75 07 jne c010654c - return 0; -c0106545: b8 00 00 00 00 mov $0x0,%eax -c010654a: eb 5a jmp c01065a6 + //now the basic virtual memory map(see memalyout.h) is established. + //check the correctness of the basic virtual memory map. + // 现在基本的虚拟内存映射(见 memlayout.h)已建立。 + // 检查基础虚拟内存映射的正确性。 + check_boot_pgdir(); // 检查页目录的正确性 +c0105682: e8 f6 0a 00 00 call c010617d - cur = (slob_t *)__slob_get_free_page(gfp); -c010654c: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0106553: 00 -c0106554: 8b 45 0c mov 0xc(%ebp),%eax -c0106557: 89 04 24 mov %eax,(%esp) -c010655a: e8 02 fe ff ff call c0106361 <__slob_get_free_pages> -c010655f: 89 45 f0 mov %eax,-0x10(%ebp) - if (!cur) -c0106562: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c0106566: 75 07 jne c010656f - return 0; -c0106568: b8 00 00 00 00 mov $0x0,%eax -c010656d: eb 37 jmp c01065a6 + print_pgdir(); // 打印页目录表 +c0105687: e8 73 0f 00 00 call c01065ff + kmalloc_init(); +c010568c: e8 70 f3 ff ff call c0104a01 - slob_free(cur, PAGE_SIZE); -c010656f: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) -c0106576: 00 -c0106577: 8b 45 f0 mov -0x10(%ebp),%eax -c010657a: 89 04 24 mov %eax,(%esp) -c010657d: e8 26 00 00 00 call c01065a8 - spin_lock_irqsave(&slob_lock, flags); -c0106582: e8 8f fc ff ff call c0106216 <__intr_save> -c0106587: 89 45 e4 mov %eax,-0x1c(%ebp) - cur = slobfree; -c010658a: a1 68 8a 12 c0 mov 0xc0128a68,%eax -c010658f: 89 45 f0 mov %eax,-0x10(%ebp) - for (cur = prev->next; ; prev = cur, cur = cur->next) { -c0106592: 8b 45 f0 mov -0x10(%ebp),%eax -c0106595: 89 45 f4 mov %eax,-0xc(%ebp) -c0106598: 8b 45 f0 mov -0x10(%ebp),%eax -c010659b: 8b 40 04 mov 0x4(%eax),%eax -c010659e: 89 45 f0 mov %eax,-0x10(%ebp) - if (align) { -c01065a1: e9 9b fe ff ff jmp c0106441 - } - } } -c01065a6: c9 leave -c01065a7: c3 ret - -c01065a8 : - -static void slob_free(void *block, int size) -{ -c01065a8: f3 0f 1e fb endbr32 -c01065ac: 55 push %ebp -c01065ad: 89 e5 mov %esp,%ebp -c01065af: 83 ec 28 sub $0x28,%esp - slob_t *cur, *b = (slob_t *)block; -c01065b2: 8b 45 08 mov 0x8(%ebp),%eax -c01065b5: 89 45 f0 mov %eax,-0x10(%ebp) - unsigned long flags; +c0105691: 90 nop +c0105692: 89 ec mov %ebp,%esp +c0105694: 5d pop %ebp +c0105695: c3 ret - if (!block) -c01065b8: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c01065bc: 0f 84 01 01 00 00 je c01066c3 - return; +c0105696 : +// pgdir: 页目录的内核虚拟基地址 +// la: 需要映射的线性地址 +// create: 一个逻辑值,决定是否为页表分配一页 +// 返回值:该 PTE 的内核虚拟地址 +pte_t * +get_pte(pde_t *pgdir, uintptr_t la, bool create) { +c0105696: 55 push %ebp +c0105697: 89 e5 mov %esp,%ebp +c0105699: 83 ec 38 sub $0x38,%esp + // (7) set page directory entry's permission + } + return NULL; // (8) return page table entry +#endif + // (1) 找到页目录项 + pde_t *pdep = &pgdir[PDX(la)];// 使用 PDX 宏获取页目录索引 +c010569c: 8b 45 0c mov 0xc(%ebp),%eax +c010569f: c1 e8 16 shr $0x16,%eax +c01056a2: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx +c01056a9: 8b 45 08 mov 0x8(%ebp),%eax +c01056ac: 01 d0 add %edx,%eax +c01056ae: 89 45 f4 mov %eax,-0xc(%ebp) + // (2) 检查页目录项是否存在 + if (!(*pdep & PTE_P)) {// 如果页目录项的存在位 PTE_P 没有被设置 +c01056b1: 8b 45 f4 mov -0xc(%ebp),%eax +c01056b4: 8b 00 mov (%eax),%eax +c01056b6: 83 e0 01 and $0x1,%eax +c01056b9: 85 c0 test %eax,%eax +c01056bb: 0f 85 af 00 00 00 jne c0105770 + struct Page *page;// 声明一个指针,用于指向新分配的页面 + // 检查是否允许创建新页表,或者分配页表失败 + if (!create || (page = alloc_page()) == NULL) {// 如果不允许创建或分配失败 +c01056c1: 83 7d 10 00 cmpl $0x0,0x10(%ebp) +c01056c5: 74 15 je c01056dc +c01056c7: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c01056ce: e8 08 f9 ff ff call c0104fdb +c01056d3: 89 45 f0 mov %eax,-0x10(%ebp) +c01056d6: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c01056da: 75 0a jne c01056e6 + return NULL;// 返回 NULL,表示无法获取页表 +c01056dc: b8 00 00 00 00 mov $0x0,%eax +c01056e1: e9 e7 00 00 00 jmp c01057cd + } + // 设置新分配页面的引用计数为 1 + set_page_ref(page, 1); +c01056e6: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c01056ed: 00 +c01056ee: 8b 45 f0 mov -0x10(%ebp),%eax +c01056f1: 89 04 24 mov %eax,(%esp) +c01056f4: e8 dc f6 ff ff call c0104dd5 + uintptr_t pa = page2pa(page);// 获取新分配页面的物理地址 +c01056f9: 8b 45 f0 mov -0x10(%ebp),%eax +c01056fc: 89 04 24 mov %eax,(%esp) +c01056ff: e8 b7 f5 ff ff call c0104cbb +c0105704: 89 45 ec mov %eax,-0x14(%ebp) + memset(KADDR(pa), 0, PGSIZE);// 清空新分配的页表内容,初始化为零 +c0105707: 8b 45 ec mov -0x14(%ebp),%eax +c010570a: 89 45 e8 mov %eax,-0x18(%ebp) +c010570d: 8b 45 e8 mov -0x18(%ebp),%eax +c0105710: c1 e8 0c shr $0xc,%eax +c0105713: 89 45 e4 mov %eax,-0x1c(%ebp) +c0105716: a1 04 c0 12 c0 mov 0xc012c004,%eax +c010571b: 39 45 e4 cmp %eax,-0x1c(%ebp) +c010571e: 72 23 jb c0105743 +c0105720: 8b 45 e8 mov -0x18(%ebp),%eax +c0105723: 89 44 24 0c mov %eax,0xc(%esp) +c0105727: c7 44 24 08 3c ae 10 movl $0xc010ae3c,0x8(%esp) +c010572e: c0 +c010572f: c7 44 24 04 dd 01 00 movl $0x1dd,0x4(%esp) +c0105736: 00 +c0105737: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c010573e: e8 02 b5 ff ff call c0100c45 <__panic> +c0105743: 8b 45 e8 mov -0x18(%ebp),%eax +c0105746: 2d 00 00 00 40 sub $0x40000000,%eax +c010574b: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) +c0105752: 00 +c0105753: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c010575a: 00 +c010575b: 89 04 24 mov %eax,(%esp) +c010575e: e8 81 47 00 00 call c0109ee4 + // 更新页目录项,设置物理地址和权限位 + *pdep = pa | PTE_U | PTE_W | PTE_P;// 将物理地址和权限位(用户可访问、可写、有效)合并设置 +c0105763: 8b 45 ec mov -0x14(%ebp),%eax +c0105766: 83 c8 07 or $0x7,%eax +c0105769: 89 c2 mov %eax,%edx +c010576b: 8b 45 f4 mov -0xc(%ebp),%eax +c010576e: 89 10 mov %edx,(%eax) + } + // 返回指定线性地址 la 对应的页表项的内核虚拟地址 + return &((pte_t *)KADDR(PDE_ADDR(*pdep)))[PTX(la)];// 计算并返回页表项的指针 +c0105770: 8b 45 f4 mov -0xc(%ebp),%eax +c0105773: 8b 00 mov (%eax),%eax +c0105775: 25 00 f0 ff ff and $0xfffff000,%eax +c010577a: 89 45 e0 mov %eax,-0x20(%ebp) +c010577d: 8b 45 e0 mov -0x20(%ebp),%eax +c0105780: c1 e8 0c shr $0xc,%eax +c0105783: 89 45 dc mov %eax,-0x24(%ebp) +c0105786: a1 04 c0 12 c0 mov 0xc012c004,%eax +c010578b: 39 45 dc cmp %eax,-0x24(%ebp) +c010578e: 72 23 jb c01057b3 +c0105790: 8b 45 e0 mov -0x20(%ebp),%eax +c0105793: 89 44 24 0c mov %eax,0xc(%esp) +c0105797: c7 44 24 08 3c ae 10 movl $0xc010ae3c,0x8(%esp) +c010579e: c0 +c010579f: c7 44 24 04 e2 01 00 movl $0x1e2,0x4(%esp) +c01057a6: 00 +c01057a7: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c01057ae: e8 92 b4 ff ff call c0100c45 <__panic> +c01057b3: 8b 45 e0 mov -0x20(%ebp),%eax +c01057b6: 2d 00 00 00 40 sub $0x40000000,%eax +c01057bb: 89 c2 mov %eax,%edx +c01057bd: 8b 45 0c mov 0xc(%ebp),%eax +c01057c0: c1 e8 0c shr $0xc,%eax +c01057c3: 25 ff 03 00 00 and $0x3ff,%eax +c01057c8: c1 e0 02 shl $0x2,%eax +c01057cb: 01 d0 add %edx,%eax +} +c01057cd: 89 ec mov %ebp,%esp +c01057cf: 5d pop %ebp +c01057d0: c3 ret + +c01057d1 : - if (size) -c01065c2: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) -c01065c6: 74 10 je c01065d8 - b->units = SLOB_UNITS(size); -c01065c8: 8b 45 0c mov 0xc(%ebp),%eax -c01065cb: 83 c0 07 add $0x7,%eax -c01065ce: c1 e8 03 shr $0x3,%eax -c01065d1: 89 c2 mov %eax,%edx -c01065d3: 8b 45 f0 mov -0x10(%ebp),%eax -c01065d6: 89 10 mov %edx,(%eax) +//get_page - get related Page struct for linear address la using PDT pgdir +// get_page - 获取与线性地址 la 相关的 Page 结构体,使用页目录 pgdir +struct Page * +get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { +c01057d1: 55 push %ebp +c01057d2: 89 e5 mov %esp,%ebp +c01057d4: 83 ec 28 sub $0x28,%esp + // 调用 get_pte 函数获取对应线性地址 la 的页表项指针 + pte_t *ptep = get_pte(pgdir, la, 0); +c01057d7: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c01057de: 00 +c01057df: 8b 45 0c mov 0xc(%ebp),%eax +c01057e2: 89 44 24 04 mov %eax,0x4(%esp) +c01057e6: 8b 45 08 mov 0x8(%ebp),%eax +c01057e9: 89 04 24 mov %eax,(%esp) +c01057ec: e8 a5 fe ff ff call c0105696 +c01057f1: 89 45 f4 mov %eax,-0xc(%ebp) + // 如果 ptep_store 指针不为 NULL,将 ptep 存储到 ptep_store 指向的位置 + if (ptep_store != NULL) { +c01057f4: 83 7d 10 00 cmpl $0x0,0x10(%ebp) +c01057f8: 74 08 je c0105802 + *ptep_store = ptep; // 存储当前页表项的指针 +c01057fa: 8b 45 10 mov 0x10(%ebp),%eax +c01057fd: 8b 55 f4 mov -0xc(%ebp),%edx +c0105800: 89 10 mov %edx,(%eax) + } + // 检查 ptep 是否有效以及页表项的存在位 PTE_P 是否被设置 + if (ptep != NULL && *ptep & PTE_P) { +c0105802: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0105806: 74 1b je c0105823 +c0105808: 8b 45 f4 mov -0xc(%ebp),%eax +c010580b: 8b 00 mov (%eax),%eax +c010580d: 83 e0 01 and $0x1,%eax +c0105810: 85 c0 test %eax,%eax +c0105812: 74 0f je c0105823 + // 返回与页表项对应的 Page 结构体 + return pte2page(*ptep);// 将页表项转换为对应的 Page 结构 +c0105814: 8b 45 f4 mov -0xc(%ebp),%eax +c0105817: 8b 00 mov (%eax),%eax +c0105819: 89 04 24 mov %eax,(%esp) +c010581c: e8 50 f5 ff ff call c0104d71 +c0105821: eb 05 jmp c0105828 + } + // 如果未找到有效的页,返回 NULL + return NULL; +c0105823: b8 00 00 00 00 mov $0x0,%eax +} +c0105828: 89 ec mov %ebp,%esp +c010582a: 5d pop %ebp +c010582b: c3 ret - /* Find reinsertion point */ - spin_lock_irqsave(&slob_lock, flags); -c01065d8: e8 39 fc ff ff call c0106216 <__intr_save> -c01065dd: 89 45 ec mov %eax,-0x14(%ebp) - for (cur = slobfree; !(b > cur && b < cur->next); cur = cur->next) -c01065e0: a1 68 8a 12 c0 mov 0xc0128a68,%eax -c01065e5: 89 45 f4 mov %eax,-0xc(%ebp) -c01065e8: eb 27 jmp c0106611 - if (cur >= cur->next && (b > cur || b < cur->next)) -c01065ea: 8b 45 f4 mov -0xc(%ebp),%eax -c01065ed: 8b 40 04 mov 0x4(%eax),%eax -c01065f0: 39 45 f4 cmp %eax,-0xc(%ebp) -c01065f3: 72 13 jb c0106608 -c01065f5: 8b 45 f0 mov -0x10(%ebp),%eax -c01065f8: 3b 45 f4 cmp -0xc(%ebp),%eax -c01065fb: 77 27 ja c0106624 -c01065fd: 8b 45 f4 mov -0xc(%ebp),%eax -c0106600: 8b 40 04 mov 0x4(%eax),%eax -c0106603: 39 45 f0 cmp %eax,-0x10(%ebp) -c0106606: 72 1c jb c0106624 - for (cur = slobfree; !(b > cur && b < cur->next); cur = cur->next) -c0106608: 8b 45 f4 mov -0xc(%ebp),%eax -c010660b: 8b 40 04 mov 0x4(%eax),%eax -c010660e: 89 45 f4 mov %eax,-0xc(%ebp) -c0106611: 8b 45 f0 mov -0x10(%ebp),%eax -c0106614: 3b 45 f4 cmp -0xc(%ebp),%eax -c0106617: 76 d1 jbe c01065ea -c0106619: 8b 45 f4 mov -0xc(%ebp),%eax -c010661c: 8b 40 04 mov 0x4(%eax),%eax -c010661f: 39 45 f0 cmp %eax,-0x10(%ebp) -c0106622: 73 c6 jae c01065ea - break; +c010582c : - if (b + b->units == cur->next) { -c0106624: 8b 45 f0 mov -0x10(%ebp),%eax -c0106627: 8b 00 mov (%eax),%eax -c0106629: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx -c0106630: 8b 45 f0 mov -0x10(%ebp),%eax -c0106633: 01 c2 add %eax,%edx -c0106635: 8b 45 f4 mov -0xc(%ebp),%eax -c0106638: 8b 40 04 mov 0x4(%eax),%eax -c010663b: 39 c2 cmp %eax,%edx -c010663d: 75 25 jne c0106664 - b->units += cur->next->units; -c010663f: 8b 45 f0 mov -0x10(%ebp),%eax -c0106642: 8b 10 mov (%eax),%edx -c0106644: 8b 45 f4 mov -0xc(%ebp),%eax -c0106647: 8b 40 04 mov 0x4(%eax),%eax -c010664a: 8b 00 mov (%eax),%eax -c010664c: 01 c2 add %eax,%edx -c010664e: 8b 45 f0 mov -0x10(%ebp),%eax -c0106651: 89 10 mov %edx,(%eax) - b->next = cur->next->next; -c0106653: 8b 45 f4 mov -0xc(%ebp),%eax -c0106656: 8b 40 04 mov 0x4(%eax),%eax -c0106659: 8b 50 04 mov 0x4(%eax),%edx -c010665c: 8b 45 f0 mov -0x10(%ebp),%eax -c010665f: 89 50 04 mov %edx,0x4(%eax) -c0106662: eb 0c jmp c0106670 - } else - b->next = cur->next; -c0106664: 8b 45 f4 mov -0xc(%ebp),%eax -c0106667: 8b 50 04 mov 0x4(%eax),%edx -c010666a: 8b 45 f0 mov -0x10(%ebp),%eax -c010666d: 89 50 04 mov %edx,0x4(%eax) +//page_remove_pte - free an Page sturct which is related linear address la +// - and clean(invalidate) pte which is related linear address la +//note: PT is changed, so the TLB need to be invalidate +static inline void +page_remove_pte(pde_t *pgdir, uintptr_t la, pte_t *ptep) { +c010582c: 55 push %ebp +c010582d: 89 e5 mov %esp,%ebp +c010582f: 83 ec 28 sub $0x28,%esp + //(4) and free this page when page reference reachs 0 + //(5) clear second page table entry + //(6) flush tlb + } +#endif + if (*ptep & PTE_P) { +c0105832: 8b 45 10 mov 0x10(%ebp),%eax +c0105835: 8b 00 mov (%eax),%eax +c0105837: 83 e0 01 and $0x1,%eax +c010583a: 85 c0 test %eax,%eax +c010583c: 74 4d je c010588b + struct Page *page = pte2page(*ptep);// 找到对应的物理页 +c010583e: 8b 45 10 mov 0x10(%ebp),%eax +c0105841: 8b 00 mov (%eax),%eax +c0105843: 89 04 24 mov %eax,(%esp) +c0105846: e8 26 f5 ff ff call c0104d71 +c010584b: 89 45 f4 mov %eax,-0xc(%ebp) + // 减少物理页的引用计数,如果引用计数为零,释放该物理页 + if (page_ref_dec(page) == 0) { +c010584e: 8b 45 f4 mov -0xc(%ebp),%eax +c0105851: 89 04 24 mov %eax,(%esp) +c0105854: e8 a1 f5 ff ff call c0104dfa +c0105859: 85 c0 test %eax,%eax +c010585b: 75 13 jne c0105870 + free_page(page); +c010585d: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0105864: 00 +c0105865: 8b 45 f4 mov -0xc(%ebp),%eax +c0105868: 89 04 24 mov %eax,(%esp) +c010586b: e8 d8 f7 ff ff call c0105048 + } + *ptep = 0;// 清除页表项 +c0105870: 8b 45 10 mov 0x10(%ebp),%eax +c0105873: c7 00 00 00 00 00 movl $0x0,(%eax) + tlb_invalidate(pgdir, la);// 刷新 TLB +c0105879: 8b 45 0c mov 0xc(%ebp),%eax +c010587c: 89 44 24 04 mov %eax,0x4(%esp) +c0105880: 8b 45 08 mov 0x8(%ebp),%eax +c0105883: 89 04 24 mov %eax,(%esp) +c0105886: e8 07 01 00 00 call c0105992 + } +} +c010588b: 90 nop +c010588c: 89 ec mov %ebp,%esp +c010588e: 5d pop %ebp +c010588f: c3 ret - if (cur + cur->units == b) { -c0106670: 8b 45 f4 mov -0xc(%ebp),%eax -c0106673: 8b 00 mov (%eax),%eax -c0106675: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx -c010667c: 8b 45 f4 mov -0xc(%ebp),%eax -c010667f: 01 d0 add %edx,%eax -c0106681: 39 45 f0 cmp %eax,-0x10(%ebp) -c0106684: 75 1f jne c01066a5 - cur->units += b->units; -c0106686: 8b 45 f4 mov -0xc(%ebp),%eax -c0106689: 8b 10 mov (%eax),%edx -c010668b: 8b 45 f0 mov -0x10(%ebp),%eax -c010668e: 8b 00 mov (%eax),%eax -c0106690: 01 c2 add %eax,%edx -c0106692: 8b 45 f4 mov -0xc(%ebp),%eax -c0106695: 89 10 mov %edx,(%eax) - cur->next = b->next; -c0106697: 8b 45 f0 mov -0x10(%ebp),%eax -c010669a: 8b 50 04 mov 0x4(%eax),%edx -c010669d: 8b 45 f4 mov -0xc(%ebp),%eax -c01066a0: 89 50 04 mov %edx,0x4(%eax) -c01066a3: eb 09 jmp c01066ae - } else - cur->next = b; -c01066a5: 8b 45 f4 mov -0xc(%ebp),%eax -c01066a8: 8b 55 f0 mov -0x10(%ebp),%edx -c01066ab: 89 50 04 mov %edx,0x4(%eax) +c0105890 : - slobfree = cur; -c01066ae: 8b 45 f4 mov -0xc(%ebp),%eax -c01066b1: a3 68 8a 12 c0 mov %eax,0xc0128a68 +//page_remove - free an Page which is related linear address la and has an validated pte +//移除一个虚拟地址对应的页面 +void +page_remove(pde_t *pgdir, uintptr_t la) { +c0105890: 55 push %ebp +c0105891: 89 e5 mov %esp,%ebp +c0105893: 83 ec 28 sub $0x28,%esp + //调用 get_pte 函数获取给定虚拟地址 la 对应的页表项指针 ptep。 + pte_t *ptep = get_pte(pgdir, la, 0); +c0105896: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c010589d: 00 +c010589e: 8b 45 0c mov 0xc(%ebp),%eax +c01058a1: 89 44 24 04 mov %eax,0x4(%esp) +c01058a5: 8b 45 08 mov 0x8(%ebp),%eax +c01058a8: 89 04 24 mov %eax,(%esp) +c01058ab: e8 e6 fd ff ff call c0105696 +c01058b0: 89 45 f4 mov %eax,-0xc(%ebp) + //如果 ptep 不为 NULL,则调用 page_remove_pte 函数移除该页表项。 + if (ptep != NULL) { +c01058b3: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c01058b7: 74 19 je c01058d2 + page_remove_pte(pgdir, la, ptep); +c01058b9: 8b 45 f4 mov -0xc(%ebp),%eax +c01058bc: 89 44 24 08 mov %eax,0x8(%esp) +c01058c0: 8b 45 0c mov 0xc(%ebp),%eax +c01058c3: 89 44 24 04 mov %eax,0x4(%esp) +c01058c7: 8b 45 08 mov 0x8(%ebp),%eax +c01058ca: 89 04 24 mov %eax,(%esp) +c01058cd: e8 5a ff ff ff call c010582c + } +} +c01058d2: 90 nop +c01058d3: 89 ec mov %ebp,%esp +c01058d5: 5d pop %ebp +c01058d6: c3 ret - spin_unlock_irqrestore(&slob_lock, flags); -c01066b6: 8b 45 ec mov -0x14(%ebp),%eax -c01066b9: 89 04 24 mov %eax,(%esp) -c01066bc: e8 7f fb ff ff call c0106240 <__intr_restore> -c01066c1: eb 01 jmp c01066c4 - return; -c01066c3: 90 nop +c01058d7 : +// perm: the permission of this Page which is setted in related pte +// return value: always 0 +//note: PT is changed, so the TLB need to be invalidate +//将一个页面插入到页表中。 +int +page_insert(pde_t *pgdir, struct Page *page, uintptr_t la, uint32_t perm) { +c01058d7: 55 push %ebp +c01058d8: 89 e5 mov %esp,%ebp +c01058da: 83 ec 28 sub $0x28,%esp + //通过 get_pte 函数获取指定虚拟地址 la 对应的页表项指针 ptep。 + pte_t *ptep = get_pte(pgdir, la, 1); +c01058dd: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) +c01058e4: 00 +c01058e5: 8b 45 10 mov 0x10(%ebp),%eax +c01058e8: 89 44 24 04 mov %eax,0x4(%esp) +c01058ec: 8b 45 08 mov 0x8(%ebp),%eax +c01058ef: 89 04 24 mov %eax,(%esp) +c01058f2: e8 9f fd ff ff call c0105696 +c01058f7: 89 45 f4 mov %eax,-0xc(%ebp) + //如果 ptep 为 NULL,表示内存分配失败,返回 -E_NO_MEM。 + if (ptep == NULL) { +c01058fa: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c01058fe: 75 0a jne c010590a + return -E_NO_MEM; +c0105900: b8 fc ff ff ff mov $0xfffffffc,%eax +c0105905: e9 84 00 00 00 jmp c010598e + } + //调用 page_ref_inc 增加页面的引用计数。 + page_ref_inc(page); +c010590a: 8b 45 0c mov 0xc(%ebp),%eax +c010590d: 89 04 24 mov %eax,(%esp) +c0105910: e8 ce f4 ff ff call c0104de3 + //如果页表项已存在且指向当前页面,则减少页面引用计数。 + if (*ptep & PTE_P) { +c0105915: 8b 45 f4 mov -0xc(%ebp),%eax +c0105918: 8b 00 mov (%eax),%eax +c010591a: 83 e0 01 and $0x1,%eax +c010591d: 85 c0 test %eax,%eax +c010591f: 74 3e je c010595f + struct Page *p = pte2page(*ptep); +c0105921: 8b 45 f4 mov -0xc(%ebp),%eax +c0105924: 8b 00 mov (%eax),%eax +c0105926: 89 04 24 mov %eax,(%esp) +c0105929: e8 43 f4 ff ff call c0104d71 +c010592e: 89 45 f0 mov %eax,-0x10(%ebp) + if (p == page) { +c0105931: 8b 45 f0 mov -0x10(%ebp),%eax +c0105934: 3b 45 0c cmp 0xc(%ebp),%eax +c0105937: 75 0d jne c0105946 + page_ref_dec(page); +c0105939: 8b 45 0c mov 0xc(%ebp),%eax +c010593c: 89 04 24 mov %eax,(%esp) +c010593f: e8 b6 f4 ff ff call c0104dfa +c0105944: eb 19 jmp c010595f + } + //如果页表项已存在但指向其他页面,则调用 page_remove_pte 移除旧的页表项。 + else { + page_remove_pte(pgdir, la, ptep); +c0105946: 8b 45 f4 mov -0xc(%ebp),%eax +c0105949: 89 44 24 08 mov %eax,0x8(%esp) +c010594d: 8b 45 10 mov 0x10(%ebp),%eax +c0105950: 89 44 24 04 mov %eax,0x4(%esp) +c0105954: 8b 45 08 mov 0x8(%ebp),%eax +c0105957: 89 04 24 mov %eax,(%esp) +c010595a: e8 cd fe ff ff call c010582c + } + } + *ptep = page2pa(page) | PTE_P | perm; +c010595f: 8b 45 0c mov 0xc(%ebp),%eax +c0105962: 89 04 24 mov %eax,(%esp) +c0105965: e8 51 f3 ff ff call c0104cbb +c010596a: 0b 45 14 or 0x14(%ebp),%eax +c010596d: 83 c8 01 or $0x1,%eax +c0105970: 89 c2 mov %eax,%edx +c0105972: 8b 45 f4 mov -0xc(%ebp),%eax +c0105975: 89 10 mov %edx,(%eax) + tlb_invalidate(pgdir, la);//刷新 TLB +c0105977: 8b 45 10 mov 0x10(%ebp),%eax +c010597a: 89 44 24 04 mov %eax,0x4(%esp) +c010597e: 8b 45 08 mov 0x8(%ebp),%eax +c0105981: 89 04 24 mov %eax,(%esp) +c0105984: e8 09 00 00 00 call c0105992 + return 0; +c0105989: b8 00 00 00 00 mov $0x0,%eax } -c01066c4: c9 leave -c01066c5: c3 ret - -c01066c6 : - +c010598e: 89 ec mov %ebp,%esp +c0105990: 5d pop %ebp +c0105991: c3 ret +c0105992 : +// invalidate a TLB entry, but only if the page tables being +// edited are the ones currently in use by the processor. +//无效化指定地址的TLB条目 void -slob_init(void) { -c01066c6: f3 0f 1e fb endbr32 -c01066ca: 55 push %ebp -c01066cb: 89 e5 mov %esp,%ebp -c01066cd: 83 ec 18 sub $0x18,%esp - cprintf("use SLOB allocator\n"); -c01066d0: c7 04 24 46 b9 10 c0 movl $0xc010b946,(%esp) -c01066d7: e8 fb 9b ff ff call c01002d7 +tlb_invalidate(pde_t *pgdir, uintptr_t la) { +c0105992: 55 push %ebp +c0105993: 89 e5 mov %esp,%ebp +c0105995: 83 ec 28 sub $0x28,%esp } -c01066dc: 90 nop -c01066dd: c9 leave -c01066de: c3 ret - -c01066df : -inline void -kmalloc_init(void) { -c01066df: f3 0f 1e fb endbr32 -c01066e3: 55 push %ebp -c01066e4: 89 e5 mov %esp,%ebp -c01066e6: 83 ec 18 sub $0x18,%esp - slob_init(); -c01066e9: e8 d8 ff ff ff call c01066c6 - cprintf("kmalloc_init() succeeded!\n"); -c01066ee: c7 04 24 5a b9 10 c0 movl $0xc010b95a,(%esp) -c01066f5: e8 dd 9b ff ff call c01002d7 +static inline uintptr_t +rcr3(void) { + uintptr_t cr3; + asm volatile ("mov %%cr3, %0" : "=r" (cr3) :: "memory"); +c0105998: 0f 20 d8 mov %cr3,%eax +c010599b: 89 45 f0 mov %eax,-0x10(%ebp) + return cr3; +c010599e: 8b 55 f0 mov -0x10(%ebp),%edx + //检查当前页目录地址是否与传入的页目录地址相同。 + if (rcr3() == PADDR(pgdir)) { +c01059a1: 8b 45 08 mov 0x8(%ebp),%eax +c01059a4: 89 45 f4 mov %eax,-0xc(%ebp) +c01059a7: 81 7d f4 ff ff ff bf cmpl $0xbfffffff,-0xc(%ebp) +c01059ae: 77 23 ja c01059d3 +c01059b0: 8b 45 f4 mov -0xc(%ebp),%eax +c01059b3: 89 44 24 0c mov %eax,0xc(%esp) +c01059b7: c7 44 24 08 e0 ae 10 movl $0xc010aee0,0x8(%esp) +c01059be: c0 +c01059bf: c7 44 24 04 56 02 00 movl $0x256,0x4(%esp) +c01059c6: 00 +c01059c7: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c01059ce: e8 72 b2 ff ff call c0100c45 <__panic> +c01059d3: 8b 45 f4 mov -0xc(%ebp),%eax +c01059d6: 05 00 00 00 40 add $0x40000000,%eax +c01059db: 39 d0 cmp %edx,%eax +c01059dd: 75 0d jne c01059ec + //如果相同,则调用 invlpg 函数无效化指定线性地址的TLB条目。 + invlpg((void *)la); +c01059df: 8b 45 0c mov 0xc(%ebp),%eax +c01059e2: 89 45 ec mov %eax,-0x14(%ebp) } -c01066fa: 90 nop -c01066fb: c9 leave -c01066fc: c3 ret -c01066fd : - -size_t -slob_allocated(void) { -c01066fd: f3 0f 1e fb endbr32 -c0106701: 55 push %ebp -c0106702: 89 e5 mov %esp,%ebp - return 0; -c0106704: b8 00 00 00 00 mov $0x0,%eax +static inline void +invlpg(void *addr) { + asm volatile ("invlpg (%0)" :: "r" (addr) : "memory"); +c01059e5: 8b 45 ec mov -0x14(%ebp),%eax +c01059e8: 0f 01 38 invlpg (%eax) } -c0106709: 5d pop %ebp -c010670a: c3 ret - -c010670b : - -size_t -kallocated(void) { -c010670b: f3 0f 1e fb endbr32 -c010670f: 55 push %ebp -c0106710: 89 e5 mov %esp,%ebp - return slob_allocated(); -c0106712: e8 e6 ff ff ff call c01066fd +c01059eb: 90 nop + } } -c0106717: 5d pop %ebp -c0106718: c3 ret +c01059ec: 90 nop +c01059ed: 89 ec mov %ebp,%esp +c01059ef: 5d pop %ebp +c01059f0: c3 ret + +c01059f1 : +// pgdir_alloc_page - call alloc_page & page_insert functions to +// - allocate a page size memory & setup an addr map +// - pa<->la with linear address la and the PDT pgdir +//参数包括页目录指针 pgdir、线性地址 la 和权限 perm。 +struct Page * +pgdir_alloc_page(pde_t *pgdir, uintptr_t la, uint32_t perm) { +c01059f1: 55 push %ebp +c01059f2: 89 e5 mov %esp,%ebp +c01059f4: 83 ec 28 sub $0x28,%esp + struct Page *page = alloc_page();//分配一个新的页面存储在 page 指针中 +c01059f7: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c01059fe: e8 d8 f5 ff ff call c0104fdb +c0105a03: 89 45 f4 mov %eax,-0xc(%ebp) + if (page != NULL) {//检查 page 是否不为 NULL,即分配是否成功。 +c0105a06: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0105a0a: 0f 84 a7 00 00 00 je c0105ab7 + if (page_insert(pgdir, page, la, perm) != 0) {//将页面插入到指定的线性地址 la 处。 +c0105a10: 8b 45 10 mov 0x10(%ebp),%eax +c0105a13: 89 44 24 0c mov %eax,0xc(%esp) +c0105a17: 8b 45 0c mov 0xc(%ebp),%eax +c0105a1a: 89 44 24 08 mov %eax,0x8(%esp) +c0105a1e: 8b 45 f4 mov -0xc(%ebp),%eax +c0105a21: 89 44 24 04 mov %eax,0x4(%esp) +c0105a25: 8b 45 08 mov 0x8(%ebp),%eax +c0105a28: 89 04 24 mov %eax,(%esp) +c0105a2b: e8 a7 fe ff ff call c01058d7 +c0105a30: 85 c0 test %eax,%eax +c0105a32: 74 1a je c0105a4e + free_page(page);//释放分配的页面。 +c0105a34: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0105a3b: 00 +c0105a3c: 8b 45 f4 mov -0xc(%ebp),%eax +c0105a3f: 89 04 24 mov %eax,(%esp) +c0105a42: e8 01 f6 ff ff call c0105048 + return NULL;//返回 NULL,表示页面插入失败。 +c0105a47: b8 00 00 00 00 mov $0x0,%eax +c0105a4c: eb 6c jmp c0105aba + } + if (swap_init_ok){//检查交换区是否已初始化成功 +c0105a4e: a1 a4 c0 12 c0 mov 0xc012c0a4,%eax +c0105a53: 85 c0 test %eax,%eax +c0105a55: 74 60 je c0105ab7 + //将页面映射到交换区。 + swap_map_swappable(check_mm_struct, la, page, 0); +c0105a57: a1 6c c1 12 c0 mov 0xc012c16c,%eax +c0105a5c: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) +c0105a63: 00 +c0105a64: 8b 55 f4 mov -0xc(%ebp),%edx +c0105a67: 89 54 24 08 mov %edx,0x8(%esp) +c0105a6b: 8b 55 0c mov 0xc(%ebp),%edx +c0105a6e: 89 54 24 04 mov %edx,0x4(%esp) +c0105a72: 89 04 24 mov %eax,(%esp) +c0105a75: e8 3a 0e 00 00 call c01068b4 + //设置页面的虚拟地址 pra_vaddr 为 la + page->pra_vaddr=la; +c0105a7a: 8b 45 f4 mov -0xc(%ebp),%eax +c0105a7d: 8b 55 0c mov 0xc(%ebp),%edx +c0105a80: 89 50 1c mov %edx,0x1c(%eax) + //断言页面的引用计数为1,确保页面没有被其他地方引用。 + assert(page_ref(page) == 1); +c0105a83: 8b 45 f4 mov -0xc(%ebp),%eax +c0105a86: 89 04 24 mov %eax,(%esp) +c0105a89: e8 3d f3 ff ff call c0104dcb +c0105a8e: 83 f8 01 cmp $0x1,%eax +c0105a91: 74 24 je c0105ab7 +c0105a93: c7 44 24 0c 64 af 10 movl $0xc010af64,0xc(%esp) +c0105a9a: c0 +c0105a9b: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105aa2: c0 +c0105aa3: c7 44 24 04 6e 02 00 movl $0x26e,0x4(%esp) +c0105aaa: 00 +c0105aab: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105ab2: e8 8e b1 ff ff call c0100c45 <__panic> + //cprintf("get No. %d page: pra_vaddr %x, pra_link.prev %x, pra_link_next %x in pgdir_alloc_page\n", (page-pages), page->pra_vaddr,page->pra_page_link.prev, page->pra_page_link.next); + } -c0106719 : + } -static int find_order(int size) -{ -c0106719: f3 0f 1e fb endbr32 -c010671d: 55 push %ebp -c010671e: 89 e5 mov %esp,%ebp -c0106720: 83 ec 10 sub $0x10,%esp - int order = 0; -c0106723: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) - for ( ; size > 4096 ; size >>=1) -c010672a: eb 06 jmp c0106732 - order++; -c010672c: ff 45 fc incl -0x4(%ebp) - for ( ; size > 4096 ; size >>=1) -c010672f: d1 7d 08 sarl 0x8(%ebp) -c0106732: 81 7d 08 00 10 00 00 cmpl $0x1000,0x8(%ebp) -c0106739: 7f f1 jg c010672c - return order; -c010673b: 8b 45 fc mov -0x4(%ebp),%eax + return page; +c0105ab7: 8b 45 f4 mov -0xc(%ebp),%eax } -c010673e: c9 leave -c010673f: c3 ret +c0105aba: 89 ec mov %ebp,%esp +c0105abc: 5d pop %ebp +c0105abd: c3 ret -c0106740 <__kmalloc>: - -static void *__kmalloc(size_t size, gfp_t gfp) -{ -c0106740: f3 0f 1e fb endbr32 -c0106744: 55 push %ebp -c0106745: 89 e5 mov %esp,%ebp -c0106747: 83 ec 28 sub $0x28,%esp - slob_t *m; - bigblock_t *bb; - unsigned long flags; +c0105abe : - if (size < PAGE_SIZE - SLOB_UNIT) { -c010674a: 81 7d 08 f7 0f 00 00 cmpl $0xff7,0x8(%ebp) -c0106751: 77 3b ja c010678e <__kmalloc+0x4e> - m = slob_alloc(size + SLOB_UNIT, gfp, 0); -c0106753: 8b 45 08 mov 0x8(%ebp),%eax -c0106756: 8d 50 08 lea 0x8(%eax),%edx -c0106759: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c0106760: 00 -c0106761: 8b 45 0c mov 0xc(%ebp),%eax -c0106764: 89 44 24 04 mov %eax,0x4(%esp) -c0106768: 89 14 24 mov %edx,(%esp) -c010676b: e8 63 fc ff ff call c01063d3 -c0106770: 89 45 ec mov %eax,-0x14(%ebp) - return m ? (void *)(m + 1) : 0; -c0106773: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) -c0106777: 74 0b je c0106784 <__kmalloc+0x44> -c0106779: 8b 45 ec mov -0x14(%ebp),%eax -c010677c: 83 c0 08 add $0x8,%eax -c010677f: e9 b0 00 00 00 jmp c0106834 <__kmalloc+0xf4> -c0106784: b8 00 00 00 00 mov $0x0,%eax -c0106789: e9 a6 00 00 00 jmp c0106834 <__kmalloc+0xf4> - } +static void +check_alloc_page(void) { +c0105abe: 55 push %ebp +c0105abf: 89 e5 mov %esp,%ebp +c0105ac1: 83 ec 18 sub $0x18,%esp + //调用内存管理器的 check 方法,用于检查内存分配是否正常。 + pmm_manager->check(); +c0105ac4: a1 0c c0 12 c0 mov 0xc012c00c,%eax +c0105ac9: 8b 40 18 mov 0x18(%eax),%eax +c0105acc: ff d0 call *%eax + cprintf("check_alloc_page() succeeded!\n"); +c0105ace: c7 04 24 78 af 10 c0 movl $0xc010af78,(%esp) +c0105ad5: e8 9e a8 ff ff call c0100378 +} +c0105ada: 90 nop +c0105adb: 89 ec mov %ebp,%esp +c0105add: 5d pop %ebp +c0105ade: c3 ret - bb = slob_alloc(sizeof(bigblock_t), gfp, 0); -c010678e: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c0106795: 00 -c0106796: 8b 45 0c mov 0xc(%ebp),%eax -c0106799: 89 44 24 04 mov %eax,0x4(%esp) -c010679d: c7 04 24 0c 00 00 00 movl $0xc,(%esp) -c01067a4: e8 2a fc ff ff call c01063d3 -c01067a9: 89 45 f4 mov %eax,-0xc(%ebp) - if (!bb) -c01067ac: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c01067b0: 75 07 jne c01067b9 <__kmalloc+0x79> - return 0; -c01067b2: b8 00 00 00 00 mov $0x0,%eax -c01067b7: eb 7b jmp c0106834 <__kmalloc+0xf4> +c0105adf : - bb->order = find_order(size); -c01067b9: 8b 45 08 mov 0x8(%ebp),%eax -c01067bc: 89 04 24 mov %eax,(%esp) -c01067bf: e8 55 ff ff ff call c0106719 -c01067c4: 8b 55 f4 mov -0xc(%ebp),%edx -c01067c7: 89 02 mov %eax,(%edx) - bb->pages = (void *)__slob_get_free_pages(gfp, bb->order); -c01067c9: 8b 45 f4 mov -0xc(%ebp),%eax -c01067cc: 8b 00 mov (%eax),%eax -c01067ce: 89 44 24 04 mov %eax,0x4(%esp) -c01067d2: 8b 45 0c mov 0xc(%ebp),%eax -c01067d5: 89 04 24 mov %eax,(%esp) -c01067d8: e8 84 fb ff ff call c0106361 <__slob_get_free_pages> -c01067dd: 8b 55 f4 mov -0xc(%ebp),%edx -c01067e0: 89 42 04 mov %eax,0x4(%edx) +//用于验证页目录和页表的正确性。 +static void +check_pgdir(void) { +c0105adf: 55 push %ebp +c0105ae0: 89 e5 mov %esp,%ebp +c0105ae2: 83 ec 38 sub $0x38,%esp + //确保内存页面数量在合理范围内 + assert(npage <= KMEMSIZE / PGSIZE); +c0105ae5: a1 04 c0 12 c0 mov 0xc012c004,%eax +c0105aea: 3d 00 80 03 00 cmp $0x38000,%eax +c0105aef: 76 24 jbe c0105b15 +c0105af1: c7 44 24 0c 97 af 10 movl $0xc010af97,0xc(%esp) +c0105af8: c0 +c0105af9: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105b00: c0 +c0105b01: c7 44 24 04 82 02 00 movl $0x282,0x4(%esp) +c0105b08: 00 +c0105b09: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105b10: e8 30 b1 ff ff call c0100c45 <__panic> + //确保页目录不为空且对齐, + assert(boot_pgdir != NULL && (uint32_t)PGOFF(boot_pgdir) == 0); +c0105b15: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105b1a: 85 c0 test %eax,%eax +c0105b1c: 74 0e je c0105b2c +c0105b1e: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105b23: 25 ff 0f 00 00 and $0xfff,%eax +c0105b28: 85 c0 test %eax,%eax +c0105b2a: 74 24 je c0105b50 +c0105b2c: c7 44 24 0c b4 af 10 movl $0xc010afb4,0xc(%esp) +c0105b33: c0 +c0105b34: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105b3b: c0 +c0105b3c: c7 44 24 04 84 02 00 movl $0x284,0x4(%esp) +c0105b43: 00 +c0105b44: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105b4b: e8 f5 b0 ff ff call c0100c45 <__panic> + //确保虚拟地址 0x0 没有映射任何页面 + assert(get_page(boot_pgdir, 0x0, NULL) == NULL); +c0105b50: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105b55: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c0105b5c: 00 +c0105b5d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0105b64: 00 +c0105b65: 89 04 24 mov %eax,(%esp) +c0105b68: e8 64 fc ff ff call c01057d1 +c0105b6d: 85 c0 test %eax,%eax +c0105b6f: 74 24 je c0105b95 +c0105b71: c7 44 24 0c ec af 10 movl $0xc010afec,0xc(%esp) +c0105b78: c0 +c0105b79: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105b80: c0 +c0105b81: c7 44 24 04 86 02 00 movl $0x286,0x4(%esp) +c0105b88: 00 +c0105b89: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105b90: e8 b0 b0 ff ff call c0100c45 <__panic> + + //定义两个页面指针 p1 和 p2 + struct Page *p1, *p2; + //分配一个页面 p1 + p1 = alloc_page(); +c0105b95: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0105b9c: e8 3a f4 ff ff call c0104fdb +c0105ba1: 89 45 f4 mov %eax,-0xc(%ebp) + //将 p1 插入到虚拟地址 0x0 + assert(page_insert(boot_pgdir, p1, 0x0, 0) == 0); +c0105ba4: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105ba9: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) +c0105bb0: 00 +c0105bb1: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c0105bb8: 00 +c0105bb9: 8b 55 f4 mov -0xc(%ebp),%edx +c0105bbc: 89 54 24 04 mov %edx,0x4(%esp) +c0105bc0: 89 04 24 mov %eax,(%esp) +c0105bc3: e8 0f fd ff ff call c01058d7 +c0105bc8: 85 c0 test %eax,%eax +c0105bca: 74 24 je c0105bf0 +c0105bcc: c7 44 24 0c 14 b0 10 movl $0xc010b014,0xc(%esp) +c0105bd3: c0 +c0105bd4: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105bdb: c0 +c0105bdc: c7 44 24 04 8d 02 00 movl $0x28d,0x4(%esp) +c0105be3: 00 +c0105be4: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105beb: e8 55 b0 ff ff call c0100c45 <__panic> - if (bb->pages) { -c01067e3: 8b 45 f4 mov -0xc(%ebp),%eax -c01067e6: 8b 40 04 mov 0x4(%eax),%eax -c01067e9: 85 c0 test %eax,%eax -c01067eb: 74 2f je c010681c <__kmalloc+0xdc> - spin_lock_irqsave(&block_lock, flags); -c01067ed: e8 24 fa ff ff call c0106216 <__intr_save> -c01067f2: 89 45 f0 mov %eax,-0x10(%ebp) - bb->next = bigblocks; -c01067f5: 8b 15 10 c0 12 c0 mov 0xc012c010,%edx -c01067fb: 8b 45 f4 mov -0xc(%ebp),%eax -c01067fe: 89 50 08 mov %edx,0x8(%eax) - bigblocks = bb; -c0106801: 8b 45 f4 mov -0xc(%ebp),%eax -c0106804: a3 10 c0 12 c0 mov %eax,0xc012c010 - spin_unlock_irqrestore(&block_lock, flags); -c0106809: 8b 45 f0 mov -0x10(%ebp),%eax -c010680c: 89 04 24 mov %eax,(%esp) -c010680f: e8 2c fa ff ff call c0106240 <__intr_restore> - return bb->pages; -c0106814: 8b 45 f4 mov -0xc(%ebp),%eax -c0106817: 8b 40 04 mov 0x4(%eax),%eax -c010681a: eb 18 jmp c0106834 <__kmalloc+0xf4> - } + // 获取虚拟地址 0x0 对应的页表项指针 + pte_t *ptep; + assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); +c0105bf0: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105bf5: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c0105bfc: 00 +c0105bfd: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0105c04: 00 +c0105c05: 89 04 24 mov %eax,(%esp) +c0105c08: e8 89 fa ff ff call c0105696 +c0105c0d: 89 45 f0 mov %eax,-0x10(%ebp) +c0105c10: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c0105c14: 75 24 jne c0105c3a +c0105c16: c7 44 24 0c 40 b0 10 movl $0xc010b040,0xc(%esp) +c0105c1d: c0 +c0105c1e: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105c25: c0 +c0105c26: c7 44 24 04 91 02 00 movl $0x291,0x4(%esp) +c0105c2d: 00 +c0105c2e: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105c35: e8 0b b0 ff ff call c0100c45 <__panic> + // 验证页表项对应的页面是 p1 + assert(pte2page(*ptep) == p1); +c0105c3a: 8b 45 f0 mov -0x10(%ebp),%eax +c0105c3d: 8b 00 mov (%eax),%eax +c0105c3f: 89 04 24 mov %eax,(%esp) +c0105c42: e8 2a f1 ff ff call c0104d71 +c0105c47: 39 45 f4 cmp %eax,-0xc(%ebp) +c0105c4a: 74 24 je c0105c70 +c0105c4c: c7 44 24 0c 6d b0 10 movl $0xc010b06d,0xc(%esp) +c0105c53: c0 +c0105c54: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105c5b: c0 +c0105c5c: c7 44 24 04 93 02 00 movl $0x293,0x4(%esp) +c0105c63: 00 +c0105c64: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105c6b: e8 d5 af ff ff call c0100c45 <__panic> + // 验证 p1 的引用计数为 1 + assert(page_ref(p1) == 1); +c0105c70: 8b 45 f4 mov -0xc(%ebp),%eax +c0105c73: 89 04 24 mov %eax,(%esp) +c0105c76: e8 50 f1 ff ff call c0104dcb +c0105c7b: 83 f8 01 cmp $0x1,%eax +c0105c7e: 74 24 je c0105ca4 +c0105c80: c7 44 24 0c 83 b0 10 movl $0xc010b083,0xc(%esp) +c0105c87: c0 +c0105c88: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105c8f: c0 +c0105c90: c7 44 24 04 95 02 00 movl $0x295,0x4(%esp) +c0105c97: 00 +c0105c98: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105c9f: e8 a1 af ff ff call c0100c45 <__panic> + // 获取虚拟地址 PGSIZE 对应的页表项指针 + ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; +c0105ca4: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105ca9: 8b 00 mov (%eax),%eax +c0105cab: 25 00 f0 ff ff and $0xfffff000,%eax +c0105cb0: 89 45 ec mov %eax,-0x14(%ebp) +c0105cb3: 8b 45 ec mov -0x14(%ebp),%eax +c0105cb6: c1 e8 0c shr $0xc,%eax +c0105cb9: 89 45 e8 mov %eax,-0x18(%ebp) +c0105cbc: a1 04 c0 12 c0 mov 0xc012c004,%eax +c0105cc1: 39 45 e8 cmp %eax,-0x18(%ebp) +c0105cc4: 72 23 jb c0105ce9 +c0105cc6: 8b 45 ec mov -0x14(%ebp),%eax +c0105cc9: 89 44 24 0c mov %eax,0xc(%esp) +c0105ccd: c7 44 24 08 3c ae 10 movl $0xc010ae3c,0x8(%esp) +c0105cd4: c0 +c0105cd5: c7 44 24 04 97 02 00 movl $0x297,0x4(%esp) +c0105cdc: 00 +c0105cdd: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105ce4: e8 5c af ff ff call c0100c45 <__panic> +c0105ce9: 8b 45 ec mov -0x14(%ebp),%eax +c0105cec: 2d 00 00 00 40 sub $0x40000000,%eax +c0105cf1: 83 c0 04 add $0x4,%eax +c0105cf4: 89 45 f0 mov %eax,-0x10(%ebp) + assert(get_pte(boot_pgdir, PGSIZE, 0) == ptep); +c0105cf7: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105cfc: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c0105d03: 00 +c0105d04: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) +c0105d0b: 00 +c0105d0c: 89 04 24 mov %eax,(%esp) +c0105d0f: e8 82 f9 ff ff call c0105696 +c0105d14: 39 45 f0 cmp %eax,-0x10(%ebp) +c0105d17: 74 24 je c0105d3d +c0105d19: c7 44 24 0c 98 b0 10 movl $0xc010b098,0xc(%esp) +c0105d20: c0 +c0105d21: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105d28: c0 +c0105d29: c7 44 24 04 98 02 00 movl $0x298,0x4(%esp) +c0105d30: 00 +c0105d31: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105d38: e8 08 af ff ff call c0100c45 <__panic> + // 分配一个页面 p2 + p2 = alloc_page(); +c0105d3d: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0105d44: e8 92 f2 ff ff call c0104fdb +c0105d49: 89 45 e4 mov %eax,-0x1c(%ebp) + // 将 p2 插入到虚拟地址 PGSIZE,并设置用户和写权限 + assert(page_insert(boot_pgdir, p2, PGSIZE, PTE_U | PTE_W) == 0); +c0105d4c: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105d51: c7 44 24 0c 06 00 00 movl $0x6,0xc(%esp) +c0105d58: 00 +c0105d59: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) +c0105d60: 00 +c0105d61: 8b 55 e4 mov -0x1c(%ebp),%edx +c0105d64: 89 54 24 04 mov %edx,0x4(%esp) +c0105d68: 89 04 24 mov %eax,(%esp) +c0105d6b: e8 67 fb ff ff call c01058d7 +c0105d70: 85 c0 test %eax,%eax +c0105d72: 74 24 je c0105d98 +c0105d74: c7 44 24 0c c0 b0 10 movl $0xc010b0c0,0xc(%esp) +c0105d7b: c0 +c0105d7c: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105d83: c0 +c0105d84: c7 44 24 04 9c 02 00 movl $0x29c,0x4(%esp) +c0105d8b: 00 +c0105d8c: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105d93: e8 ad ae ff ff call c0100c45 <__panic> + // 获取虚拟地址 PGSIZE 对应的页表项指针 + assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); +c0105d98: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105d9d: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c0105da4: 00 +c0105da5: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) +c0105dac: 00 +c0105dad: 89 04 24 mov %eax,(%esp) +c0105db0: e8 e1 f8 ff ff call c0105696 +c0105db5: 89 45 f0 mov %eax,-0x10(%ebp) +c0105db8: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c0105dbc: 75 24 jne c0105de2 +c0105dbe: c7 44 24 0c f8 b0 10 movl $0xc010b0f8,0xc(%esp) +c0105dc5: c0 +c0105dc6: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105dcd: c0 +c0105dce: c7 44 24 04 9e 02 00 movl $0x29e,0x4(%esp) +c0105dd5: 00 +c0105dd6: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105ddd: e8 63 ae ff ff call c0100c45 <__panic> + // 验证页表项设置了用户权限 + assert(*ptep & PTE_U); +c0105de2: 8b 45 f0 mov -0x10(%ebp),%eax +c0105de5: 8b 00 mov (%eax),%eax +c0105de7: 83 e0 04 and $0x4,%eax +c0105dea: 85 c0 test %eax,%eax +c0105dec: 75 24 jne c0105e12 +c0105dee: c7 44 24 0c 28 b1 10 movl $0xc010b128,0xc(%esp) +c0105df5: c0 +c0105df6: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105dfd: c0 +c0105dfe: c7 44 24 04 a0 02 00 movl $0x2a0,0x4(%esp) +c0105e05: 00 +c0105e06: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105e0d: e8 33 ae ff ff call c0100c45 <__panic> + // 验证页表项设置了写权限 + assert(*ptep & PTE_W); +c0105e12: 8b 45 f0 mov -0x10(%ebp),%eax +c0105e15: 8b 00 mov (%eax),%eax +c0105e17: 83 e0 02 and $0x2,%eax +c0105e1a: 85 c0 test %eax,%eax +c0105e1c: 75 24 jne c0105e42 +c0105e1e: c7 44 24 0c 36 b1 10 movl $0xc010b136,0xc(%esp) +c0105e25: c0 +c0105e26: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105e2d: c0 +c0105e2e: c7 44 24 04 a2 02 00 movl $0x2a2,0x4(%esp) +c0105e35: 00 +c0105e36: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105e3d: e8 03 ae ff ff call c0100c45 <__panic> + // 验证页目录项设置了用户权限 + assert(boot_pgdir[0] & PTE_U); +c0105e42: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105e47: 8b 00 mov (%eax),%eax +c0105e49: 83 e0 04 and $0x4,%eax +c0105e4c: 85 c0 test %eax,%eax +c0105e4e: 75 24 jne c0105e74 +c0105e50: c7 44 24 0c 44 b1 10 movl $0xc010b144,0xc(%esp) +c0105e57: c0 +c0105e58: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105e5f: c0 +c0105e60: c7 44 24 04 a4 02 00 movl $0x2a4,0x4(%esp) +c0105e67: 00 +c0105e68: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105e6f: e8 d1 ad ff ff call c0100c45 <__panic> + // 验证 p2 的引用计数为 1 + assert(page_ref(p2) == 1); +c0105e74: 8b 45 e4 mov -0x1c(%ebp),%eax +c0105e77: 89 04 24 mov %eax,(%esp) +c0105e7a: e8 4c ef ff ff call c0104dcb +c0105e7f: 83 f8 01 cmp $0x1,%eax +c0105e82: 74 24 je c0105ea8 +c0105e84: c7 44 24 0c 5a b1 10 movl $0xc010b15a,0xc(%esp) +c0105e8b: c0 +c0105e8c: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105e93: c0 +c0105e94: c7 44 24 04 a6 02 00 movl $0x2a6,0x4(%esp) +c0105e9b: 00 +c0105e9c: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105ea3: e8 9d ad ff ff call c0100c45 <__panic> - slob_free(bb, sizeof(bigblock_t)); -c010681c: c7 44 24 04 0c 00 00 movl $0xc,0x4(%esp) -c0106823: 00 -c0106824: 8b 45 f4 mov -0xc(%ebp),%eax -c0106827: 89 04 24 mov %eax,(%esp) -c010682a: e8 79 fd ff ff call c01065a8 - return 0; -c010682f: b8 00 00 00 00 mov $0x0,%eax -} -c0106834: c9 leave -c0106835: c3 ret + // 将 p1 插入到虚拟地址 PGSIZE,替换掉 p2 + assert(page_insert(boot_pgdir, p1, PGSIZE, 0) == 0); +c0105ea8: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105ead: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) +c0105eb4: 00 +c0105eb5: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) +c0105ebc: 00 +c0105ebd: 8b 55 f4 mov -0xc(%ebp),%edx +c0105ec0: 89 54 24 04 mov %edx,0x4(%esp) +c0105ec4: 89 04 24 mov %eax,(%esp) +c0105ec7: e8 0b fa ff ff call c01058d7 +c0105ecc: 85 c0 test %eax,%eax +c0105ece: 74 24 je c0105ef4 +c0105ed0: c7 44 24 0c 6c b1 10 movl $0xc010b16c,0xc(%esp) +c0105ed7: c0 +c0105ed8: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105edf: c0 +c0105ee0: c7 44 24 04 a9 02 00 movl $0x2a9,0x4(%esp) +c0105ee7: 00 +c0105ee8: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105eef: e8 51 ad ff ff call c0100c45 <__panic> + // 验证 p1 的引用计数增加到 2 + assert(page_ref(p1) == 2); +c0105ef4: 8b 45 f4 mov -0xc(%ebp),%eax +c0105ef7: 89 04 24 mov %eax,(%esp) +c0105efa: e8 cc ee ff ff call c0104dcb +c0105eff: 83 f8 02 cmp $0x2,%eax +c0105f02: 74 24 je c0105f28 +c0105f04: c7 44 24 0c 98 b1 10 movl $0xc010b198,0xc(%esp) +c0105f0b: c0 +c0105f0c: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105f13: c0 +c0105f14: c7 44 24 04 ab 02 00 movl $0x2ab,0x4(%esp) +c0105f1b: 00 +c0105f1c: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105f23: e8 1d ad ff ff call c0100c45 <__panic> + // 验证 p2 的引用计数减少到 0 + assert(page_ref(p2) == 0); +c0105f28: 8b 45 e4 mov -0x1c(%ebp),%eax +c0105f2b: 89 04 24 mov %eax,(%esp) +c0105f2e: e8 98 ee ff ff call c0104dcb +c0105f33: 85 c0 test %eax,%eax +c0105f35: 74 24 je c0105f5b +c0105f37: c7 44 24 0c aa b1 10 movl $0xc010b1aa,0xc(%esp) +c0105f3e: c0 +c0105f3f: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105f46: c0 +c0105f47: c7 44 24 04 ad 02 00 movl $0x2ad,0x4(%esp) +c0105f4e: 00 +c0105f4f: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105f56: e8 ea ac ff ff call c0100c45 <__panic> + // 获取虚拟地址 PGSIZE 对应的页表项指针 + assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); +c0105f5b: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0105f60: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c0105f67: 00 +c0105f68: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) +c0105f6f: 00 +c0105f70: 89 04 24 mov %eax,(%esp) +c0105f73: e8 1e f7 ff ff call c0105696 +c0105f78: 89 45 f0 mov %eax,-0x10(%ebp) +c0105f7b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c0105f7f: 75 24 jne c0105fa5 +c0105f81: c7 44 24 0c f8 b0 10 movl $0xc010b0f8,0xc(%esp) +c0105f88: c0 +c0105f89: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105f90: c0 +c0105f91: c7 44 24 04 af 02 00 movl $0x2af,0x4(%esp) +c0105f98: 00 +c0105f99: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105fa0: e8 a0 ac ff ff call c0100c45 <__panic> + // 验证页表项对应的页面是 p1 + assert(pte2page(*ptep) == p1); +c0105fa5: 8b 45 f0 mov -0x10(%ebp),%eax +c0105fa8: 8b 00 mov (%eax),%eax +c0105faa: 89 04 24 mov %eax,(%esp) +c0105fad: e8 bf ed ff ff call c0104d71 +c0105fb2: 39 45 f4 cmp %eax,-0xc(%ebp) +c0105fb5: 74 24 je c0105fdb +c0105fb7: c7 44 24 0c 6d b0 10 movl $0xc010b06d,0xc(%esp) +c0105fbe: c0 +c0105fbf: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105fc6: c0 +c0105fc7: c7 44 24 04 b1 02 00 movl $0x2b1,0x4(%esp) +c0105fce: 00 +c0105fcf: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0105fd6: e8 6a ac ff ff call c0100c45 <__panic> + // 验证页表项没有设置用户权限 + assert((*ptep & PTE_U) == 0); +c0105fdb: 8b 45 f0 mov -0x10(%ebp),%eax +c0105fde: 8b 00 mov (%eax),%eax +c0105fe0: 83 e0 04 and $0x4,%eax +c0105fe3: 85 c0 test %eax,%eax +c0105fe5: 74 24 je c010600b +c0105fe7: c7 44 24 0c bc b1 10 movl $0xc010b1bc,0xc(%esp) +c0105fee: c0 +c0105fef: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0105ff6: c0 +c0105ff7: c7 44 24 04 b3 02 00 movl $0x2b3,0x4(%esp) +c0105ffe: 00 +c0105fff: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0106006: e8 3a ac ff ff call c0100c45 <__panic> + + //移除虚拟地址 0x0 的映射, + page_remove(boot_pgdir, 0x0); +c010600b: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0106010: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0106017: 00 +c0106018: 89 04 24 mov %eax,(%esp) +c010601b: e8 70 f8 ff ff call c0105890 + //验证 p1 的引用计数减少到 1。 + assert(page_ref(p1) == 1); +c0106020: 8b 45 f4 mov -0xc(%ebp),%eax +c0106023: 89 04 24 mov %eax,(%esp) +c0106026: e8 a0 ed ff ff call c0104dcb +c010602b: 83 f8 01 cmp $0x1,%eax +c010602e: 74 24 je c0106054 +c0106030: c7 44 24 0c 83 b0 10 movl $0xc010b083,0xc(%esp) +c0106037: c0 +c0106038: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c010603f: c0 +c0106040: c7 44 24 04 b8 02 00 movl $0x2b8,0x4(%esp) +c0106047: 00 +c0106048: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c010604f: e8 f1 ab ff ff call c0100c45 <__panic> + //验证 p2 的引用计数减少到 0 + assert(page_ref(p2) == 0); +c0106054: 8b 45 e4 mov -0x1c(%ebp),%eax +c0106057: 89 04 24 mov %eax,(%esp) +c010605a: e8 6c ed ff ff call c0104dcb +c010605f: 85 c0 test %eax,%eax +c0106061: 74 24 je c0106087 +c0106063: c7 44 24 0c aa b1 10 movl $0xc010b1aa,0xc(%esp) +c010606a: c0 +c010606b: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0106072: c0 +c0106073: c7 44 24 04 ba 02 00 movl $0x2ba,0x4(%esp) +c010607a: 00 +c010607b: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0106082: e8 be ab ff ff call c0100c45 <__panic> -c0106836 : + //移除虚拟地址 PGSIZE 的映射, + page_remove(boot_pgdir, PGSIZE); +c0106087: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c010608c: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) +c0106093: 00 +c0106094: 89 04 24 mov %eax,(%esp) +c0106097: e8 f4 f7 ff ff call c0105890 + //验证 p1 的引用计数减少到 0 + assert(page_ref(p1) == 0); +c010609c: 8b 45 f4 mov -0xc(%ebp),%eax +c010609f: 89 04 24 mov %eax,(%esp) +c01060a2: e8 24 ed ff ff call c0104dcb +c01060a7: 85 c0 test %eax,%eax +c01060a9: 74 24 je c01060cf +c01060ab: c7 44 24 0c d1 b1 10 movl $0xc010b1d1,0xc(%esp) +c01060b2: c0 +c01060b3: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c01060ba: c0 +c01060bb: c7 44 24 04 bf 02 00 movl $0x2bf,0x4(%esp) +c01060c2: 00 +c01060c3: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c01060ca: e8 76 ab ff ff call c0100c45 <__panic> + //验证 p2 的引用计数减少到 0 + assert(page_ref(p2) == 0); +c01060cf: 8b 45 e4 mov -0x1c(%ebp),%eax +c01060d2: 89 04 24 mov %eax,(%esp) +c01060d5: e8 f1 ec ff ff call c0104dcb +c01060da: 85 c0 test %eax,%eax +c01060dc: 74 24 je c0106102 +c01060de: c7 44 24 0c aa b1 10 movl $0xc010b1aa,0xc(%esp) +c01060e5: c0 +c01060e6: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c01060ed: c0 +c01060ee: c7 44 24 04 c1 02 00 movl $0x2c1,0x4(%esp) +c01060f5: 00 +c01060f6: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c01060fd: e8 43 ab ff ff call c0100c45 <__panic> + + //验证页目录的第一页表的引用计数为 1。 + assert(page_ref(pde2page(boot_pgdir[0])) == 1); +c0106102: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0106107: 8b 00 mov (%eax),%eax +c0106109: 89 04 24 mov %eax,(%esp) +c010610c: e8 a0 ec ff ff call c0104db1 +c0106111: 89 04 24 mov %eax,(%esp) +c0106114: e8 b2 ec ff ff call c0104dcb +c0106119: 83 f8 01 cmp $0x1,%eax +c010611c: 74 24 je c0106142 +c010611e: c7 44 24 0c e4 b1 10 movl $0xc010b1e4,0xc(%esp) +c0106125: c0 +c0106126: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c010612d: c0 +c010612e: c7 44 24 04 c4 02 00 movl $0x2c4,0x4(%esp) +c0106135: 00 +c0106136: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c010613d: e8 03 ab ff ff call c0100c45 <__panic> + //释放页目录的第一页表 + free_page(pde2page(boot_pgdir[0])); +c0106142: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0106147: 8b 00 mov (%eax),%eax +c0106149: 89 04 24 mov %eax,(%esp) +c010614c: e8 60 ec ff ff call c0104db1 +c0106151: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0106158: 00 +c0106159: 89 04 24 mov %eax,(%esp) +c010615c: e8 e7 ee ff ff call c0105048 + //清空页目录的第一页表 + boot_pgdir[0] = 0; +c0106161: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0106166: c7 00 00 00 00 00 movl $0x0,(%eax) -void * -kmalloc(size_t size) -{ -c0106836: f3 0f 1e fb endbr32 -c010683a: 55 push %ebp -c010683b: 89 e5 mov %esp,%ebp -c010683d: 83 ec 18 sub $0x18,%esp - return __kmalloc(size, 0); -c0106840: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0106847: 00 -c0106848: 8b 45 08 mov 0x8(%ebp),%eax -c010684b: 89 04 24 mov %eax,(%esp) -c010684e: e8 ed fe ff ff call c0106740 <__kmalloc> + cprintf("check_pgdir() succeeded!\n"); +c010616c: c7 04 24 0b b2 10 c0 movl $0xc010b20b,(%esp) +c0106173: e8 00 a2 ff ff call c0100378 } -c0106853: c9 leave -c0106854: c3 ret - -c0106855 : +c0106178: 90 nop +c0106179: 89 ec mov %ebp,%esp +c010617b: 5d pop %ebp +c010617c: c3 ret +c010617d : -void kfree(void *block) -{ -c0106855: f3 0f 1e fb endbr32 -c0106859: 55 push %ebp -c010685a: 89 e5 mov %esp,%ebp -c010685c: 83 ec 28 sub $0x28,%esp - bigblock_t *bb, **last = &bigblocks; -c010685f: c7 45 f0 10 c0 12 c0 movl $0xc012c010,-0x10(%ebp) - unsigned long flags; - - if (!block) -c0106866: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c010686a: 0f 84 a3 00 00 00 je c0106913 - return; +//检查内核页表 boot_pgdir 的正确性 +static void +check_boot_pgdir(void) { +c010617d: 55 push %ebp +c010617e: 89 e5 mov %esp,%ebp +c0106180: 83 ec 38 sub $0x38,%esp + pte_t *ptep;// 定义一个指向页表项的指针 + int i; + for (i = 0; i < npage; i += PGSIZE) {// 遍历所有页面 +c0106183: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c010618a: e9 ca 00 00 00 jmp c0106259 + // 获取第 i 个页面的页表项,并确保其不为空 + assert((ptep = get_pte(boot_pgdir, (uintptr_t)KADDR(i), 0)) != NULL); +c010618f: 8b 45 f4 mov -0xc(%ebp),%eax +c0106192: 89 45 e4 mov %eax,-0x1c(%ebp) +c0106195: 8b 45 e4 mov -0x1c(%ebp),%eax +c0106198: c1 e8 0c shr $0xc,%eax +c010619b: 89 45 e0 mov %eax,-0x20(%ebp) +c010619e: a1 04 c0 12 c0 mov 0xc012c004,%eax +c01061a3: 39 45 e0 cmp %eax,-0x20(%ebp) +c01061a6: 72 23 jb c01061cb +c01061a8: 8b 45 e4 mov -0x1c(%ebp),%eax +c01061ab: 89 44 24 0c mov %eax,0xc(%esp) +c01061af: c7 44 24 08 3c ae 10 movl $0xc010ae3c,0x8(%esp) +c01061b6: c0 +c01061b7: c7 44 24 04 d4 02 00 movl $0x2d4,0x4(%esp) +c01061be: 00 +c01061bf: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c01061c6: e8 7a aa ff ff call c0100c45 <__panic> +c01061cb: 8b 45 e4 mov -0x1c(%ebp),%eax +c01061ce: 2d 00 00 00 40 sub $0x40000000,%eax +c01061d3: 89 c2 mov %eax,%edx +c01061d5: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c01061da: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c01061e1: 00 +c01061e2: 89 54 24 04 mov %edx,0x4(%esp) +c01061e6: 89 04 24 mov %eax,(%esp) +c01061e9: e8 a8 f4 ff ff call c0105696 +c01061ee: 89 45 dc mov %eax,-0x24(%ebp) +c01061f1: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) +c01061f5: 75 24 jne c010621b +c01061f7: c7 44 24 0c 28 b2 10 movl $0xc010b228,0xc(%esp) +c01061fe: c0 +c01061ff: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0106206: c0 +c0106207: c7 44 24 04 d4 02 00 movl $0x2d4,0x4(%esp) +c010620e: 00 +c010620f: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0106216: e8 2a aa ff ff call c0100c45 <__panic> + // 验证页表项的物理地址是否正确 + assert(PTE_ADDR(*ptep) == i); +c010621b: 8b 45 dc mov -0x24(%ebp),%eax +c010621e: 8b 00 mov (%eax),%eax +c0106220: 25 00 f0 ff ff and $0xfffff000,%eax +c0106225: 89 c2 mov %eax,%edx +c0106227: 8b 45 f4 mov -0xc(%ebp),%eax +c010622a: 39 c2 cmp %eax,%edx +c010622c: 74 24 je c0106252 +c010622e: c7 44 24 0c 65 b2 10 movl $0xc010b265,0xc(%esp) +c0106235: c0 +c0106236: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c010623d: c0 +c010623e: c7 44 24 04 d6 02 00 movl $0x2d6,0x4(%esp) +c0106245: 00 +c0106246: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c010624d: e8 f3 a9 ff ff call c0100c45 <__panic> + for (i = 0; i < npage; i += PGSIZE) {// 遍历所有页面 +c0106252: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp) +c0106259: 8b 55 f4 mov -0xc(%ebp),%edx +c010625c: a1 04 c0 12 c0 mov 0xc012c004,%eax +c0106261: 39 c2 cmp %eax,%edx +c0106263: 0f 82 26 ff ff ff jb c010618f + } + // 验证页目录项的物理地址是否正确 + assert(PDE_ADDR(boot_pgdir[PDX(VPT)]) == PADDR(boot_pgdir)); +c0106269: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c010626e: 05 ac 0f 00 00 add $0xfac,%eax +c0106273: 8b 00 mov (%eax),%eax +c0106275: 25 00 f0 ff ff and $0xfffff000,%eax +c010627a: 89 c2 mov %eax,%edx +c010627c: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0106281: 89 45 f0 mov %eax,-0x10(%ebp) +c0106284: 81 7d f0 ff ff ff bf cmpl $0xbfffffff,-0x10(%ebp) +c010628b: 77 23 ja c01062b0 +c010628d: 8b 45 f0 mov -0x10(%ebp),%eax +c0106290: 89 44 24 0c mov %eax,0xc(%esp) +c0106294: c7 44 24 08 e0 ae 10 movl $0xc010aee0,0x8(%esp) +c010629b: c0 +c010629c: c7 44 24 04 d9 02 00 movl $0x2d9,0x4(%esp) +c01062a3: 00 +c01062a4: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c01062ab: e8 95 a9 ff ff call c0100c45 <__panic> +c01062b0: 8b 45 f0 mov -0x10(%ebp),%eax +c01062b3: 05 00 00 00 40 add $0x40000000,%eax +c01062b8: 39 d0 cmp %edx,%eax +c01062ba: 74 24 je c01062e0 +c01062bc: c7 44 24 0c 7c b2 10 movl $0xc010b27c,0xc(%esp) +c01062c3: c0 +c01062c4: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c01062cb: c0 +c01062cc: c7 44 24 04 d9 02 00 movl $0x2d9,0x4(%esp) +c01062d3: 00 +c01062d4: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c01062db: e8 65 a9 ff ff call c0100c45 <__panic> - if (!((unsigned long)block & (PAGE_SIZE-1))) { -c0106870: 8b 45 08 mov 0x8(%ebp),%eax -c0106873: 25 ff 0f 00 00 and $0xfff,%eax -c0106878: 85 c0 test %eax,%eax -c010687a: 75 7f jne c01068fb - /* might be on the big block list */ - spin_lock_irqsave(&block_lock, flags); -c010687c: e8 95 f9 ff ff call c0106216 <__intr_save> -c0106881: 89 45 ec mov %eax,-0x14(%ebp) - for (bb = bigblocks; bb; last = &bb->next, bb = bb->next) { -c0106884: a1 10 c0 12 c0 mov 0xc012c010,%eax -c0106889: 89 45 f4 mov %eax,-0xc(%ebp) -c010688c: eb 5c jmp c01068ea - if (bb->pages == block) { -c010688e: 8b 45 f4 mov -0xc(%ebp),%eax -c0106891: 8b 40 04 mov 0x4(%eax),%eax -c0106894: 39 45 08 cmp %eax,0x8(%ebp) -c0106897: 75 3f jne c01068d8 - *last = bb->next; -c0106899: 8b 45 f4 mov -0xc(%ebp),%eax -c010689c: 8b 50 08 mov 0x8(%eax),%edx -c010689f: 8b 45 f0 mov -0x10(%ebp),%eax -c01068a2: 89 10 mov %edx,(%eax) - spin_unlock_irqrestore(&block_lock, flags); -c01068a4: 8b 45 ec mov -0x14(%ebp),%eax -c01068a7: 89 04 24 mov %eax,(%esp) -c01068aa: e8 91 f9 ff ff call c0106240 <__intr_restore> - __slob_free_pages((unsigned long)block, bb->order); -c01068af: 8b 45 f4 mov -0xc(%ebp),%eax -c01068b2: 8b 10 mov (%eax),%edx -c01068b4: 8b 45 08 mov 0x8(%ebp),%eax -c01068b7: 89 54 24 04 mov %edx,0x4(%esp) -c01068bb: 89 04 24 mov %eax,(%esp) -c01068be: e8 db fa ff ff call c010639e <__slob_free_pages> - slob_free(bb, sizeof(bigblock_t)); -c01068c3: c7 44 24 04 0c 00 00 movl $0xc,0x4(%esp) -c01068ca: 00 -c01068cb: 8b 45 f4 mov -0xc(%ebp),%eax -c01068ce: 89 04 24 mov %eax,(%esp) -c01068d1: e8 d2 fc ff ff call c01065a8 - return; -c01068d6: eb 3c jmp c0106914 - for (bb = bigblocks; bb; last = &bb->next, bb = bb->next) { -c01068d8: 8b 45 f4 mov -0xc(%ebp),%eax -c01068db: 83 c0 08 add $0x8,%eax -c01068de: 89 45 f0 mov %eax,-0x10(%ebp) -c01068e1: 8b 45 f4 mov -0xc(%ebp),%eax -c01068e4: 8b 40 08 mov 0x8(%eax),%eax -c01068e7: 89 45 f4 mov %eax,-0xc(%ebp) -c01068ea: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c01068ee: 75 9e jne c010688e - } - } - spin_unlock_irqrestore(&block_lock, flags); -c01068f0: 8b 45 ec mov -0x14(%ebp),%eax -c01068f3: 89 04 24 mov %eax,(%esp) -c01068f6: e8 45 f9 ff ff call c0106240 <__intr_restore> - } + assert(boot_pgdir[0] == 0);// 确保页目录的第一个项为0 +c01062e0: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c01062e5: 8b 00 mov (%eax),%eax +c01062e7: 85 c0 test %eax,%eax +c01062e9: 74 24 je c010630f +c01062eb: c7 44 24 0c b0 b2 10 movl $0xc010b2b0,0xc(%esp) +c01062f2: c0 +c01062f3: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c01062fa: c0 +c01062fb: c7 44 24 04 db 02 00 movl $0x2db,0x4(%esp) +c0106302: 00 +c0106303: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c010630a: e8 36 a9 ff ff call c0100c45 <__panic> - slob_free((slob_t *)block - 1, 0); -c01068fb: 8b 45 08 mov 0x8(%ebp),%eax -c01068fe: 83 e8 08 sub $0x8,%eax -c0106901: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0106908: 00 -c0106909: 89 04 24 mov %eax,(%esp) -c010690c: e8 97 fc ff ff call c01065a8 - return; -c0106911: eb 01 jmp c0106914 - return; -c0106913: 90 nop -} -c0106914: c9 leave -c0106915: c3 ret + struct Page *p;// 定义一个指向页面的指针 + p = alloc_page();// 分配一个页面 +c010630f: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0106316: e8 c0 ec ff ff call c0104fdb +c010631b: 89 45 ec mov %eax,-0x14(%ebp) + // 将页面插入到虚拟地址 0x100,并确保操作成功 + assert(page_insert(boot_pgdir, p, 0x100, PTE_W) == 0); +c010631e: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c0106323: c7 44 24 0c 02 00 00 movl $0x2,0xc(%esp) +c010632a: 00 +c010632b: c7 44 24 08 00 01 00 movl $0x100,0x8(%esp) +c0106332: 00 +c0106333: 8b 55 ec mov -0x14(%ebp),%edx +c0106336: 89 54 24 04 mov %edx,0x4(%esp) +c010633a: 89 04 24 mov %eax,(%esp) +c010633d: e8 95 f5 ff ff call c01058d7 +c0106342: 85 c0 test %eax,%eax +c0106344: 74 24 je c010636a +c0106346: c7 44 24 0c c4 b2 10 movl $0xc010b2c4,0xc(%esp) +c010634d: c0 +c010634e: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0106355: c0 +c0106356: c7 44 24 04 e0 02 00 movl $0x2e0,0x4(%esp) +c010635d: 00 +c010635e: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0106365: e8 db a8 ff ff call c0100c45 <__panic> + assert(page_ref(p) == 1);// 验证页面的引用计数为1 +c010636a: 8b 45 ec mov -0x14(%ebp),%eax +c010636d: 89 04 24 mov %eax,(%esp) +c0106370: e8 56 ea ff ff call c0104dcb +c0106375: 83 f8 01 cmp $0x1,%eax +c0106378: 74 24 je c010639e +c010637a: c7 44 24 0c f2 b2 10 movl $0xc010b2f2,0xc(%esp) +c0106381: c0 +c0106382: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0106389: c0 +c010638a: c7 44 24 04 e1 02 00 movl $0x2e1,0x4(%esp) +c0106391: 00 +c0106392: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0106399: e8 a7 a8 ff ff call c0100c45 <__panic> + // 将页面插入到虚拟地址 0x100 + PGSIZE,并确保操作成功 + assert(page_insert(boot_pgdir, p, 0x100 + PGSIZE, PTE_W) == 0); +c010639e: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c01063a3: c7 44 24 0c 02 00 00 movl $0x2,0xc(%esp) +c01063aa: 00 +c01063ab: c7 44 24 08 00 11 00 movl $0x1100,0x8(%esp) +c01063b2: 00 +c01063b3: 8b 55 ec mov -0x14(%ebp),%edx +c01063b6: 89 54 24 04 mov %edx,0x4(%esp) +c01063ba: 89 04 24 mov %eax,(%esp) +c01063bd: e8 15 f5 ff ff call c01058d7 +c01063c2: 85 c0 test %eax,%eax +c01063c4: 74 24 je c01063ea +c01063c6: c7 44 24 0c 04 b3 10 movl $0xc010b304,0xc(%esp) +c01063cd: c0 +c01063ce: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c01063d5: c0 +c01063d6: c7 44 24 04 e3 02 00 movl $0x2e3,0x4(%esp) +c01063dd: 00 +c01063de: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c01063e5: e8 5b a8 ff ff call c0100c45 <__panic> + assert(page_ref(p) == 2);// 验证页面的引用计数为2 +c01063ea: 8b 45 ec mov -0x14(%ebp),%eax +c01063ed: 89 04 24 mov %eax,(%esp) +c01063f0: e8 d6 e9 ff ff call c0104dcb +c01063f5: 83 f8 02 cmp $0x2,%eax +c01063f8: 74 24 je c010641e +c01063fa: c7 44 24 0c 3b b3 10 movl $0xc010b33b,0xc(%esp) +c0106401: c0 +c0106402: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c0106409: c0 +c010640a: c7 44 24 04 e4 02 00 movl $0x2e4,0x4(%esp) +c0106411: 00 +c0106412: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c0106419: e8 27 a8 ff ff call c0100c45 <__panic> -c0106916 : + const char *str = "ucore: Hello world!!";// 定义一个字符串 +c010641e: c7 45 e8 4c b3 10 c0 movl $0xc010b34c,-0x18(%ebp) + strcpy((void *)0x100, str);// 将字符串复制到虚拟地址 0x100 +c0106425: 8b 45 e8 mov -0x18(%ebp),%eax +c0106428: 89 44 24 04 mov %eax,0x4(%esp) +c010642c: c7 04 24 00 01 00 00 movl $0x100,(%esp) +c0106433: e8 dc 37 00 00 call c0109c14 + // 验证两个映射地址的数据是否一致 + assert(strcmp((void *)0x100, (void *)(0x100 + PGSIZE)) == 0); +c0106438: c7 44 24 04 00 11 00 movl $0x1100,0x4(%esp) +c010643f: 00 +c0106440: c7 04 24 00 01 00 00 movl $0x100,(%esp) +c0106447: e8 40 38 00 00 call c0109c8c +c010644c: 85 c0 test %eax,%eax +c010644e: 74 24 je c0106474 +c0106450: c7 44 24 0c 64 b3 10 movl $0xc010b364,0xc(%esp) +c0106457: c0 +c0106458: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c010645f: c0 +c0106460: c7 44 24 04 e9 02 00 movl $0x2e9,0x4(%esp) +c0106467: 00 +c0106468: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c010646f: e8 d1 a7 ff ff call c0100c45 <__panic> + // 在页面的 0x100 偏移处设置字符串结束符 + *(char *)(page2kva(p) + 0x100) = '\0'; +c0106474: 8b 45 ec mov -0x14(%ebp),%eax +c0106477: 89 04 24 mov %eax,(%esp) +c010647a: e8 9c e8 ff ff call c0104d1b +c010647f: 05 00 01 00 00 add $0x100,%eax +c0106484: c6 00 00 movb $0x0,(%eax) + assert(strlen((const char *)0x100) == 0);// 验证字符串长度为0 +c0106487: c7 04 24 00 01 00 00 movl $0x100,(%esp) +c010648e: e8 27 37 00 00 call c0109bba +c0106493: 85 c0 test %eax,%eax +c0106495: 74 24 je c01064bb +c0106497: c7 44 24 0c 9c b3 10 movl $0xc010b39c,0xc(%esp) +c010649e: c0 +c010649f: c7 44 24 08 29 af 10 movl $0xc010af29,0x8(%esp) +c01064a6: c0 +c01064a7: c7 44 24 04 ec 02 00 movl $0x2ec,0x4(%esp) +c01064ae: 00 +c01064af: c7 04 24 04 af 10 c0 movl $0xc010af04,(%esp) +c01064b6: e8 8a a7 ff ff call c0100c45 <__panic> + free_page(p);// 释放页面 p +c01064bb: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c01064c2: 00 +c01064c3: 8b 45 ec mov -0x14(%ebp),%eax +c01064c6: 89 04 24 mov %eax,(%esp) +c01064c9: e8 7a eb ff ff call c0105048 + free_page(pde2page(boot_pgdir[0]));// 释放页目录项对应的页面 +c01064ce: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c01064d3: 8b 00 mov (%eax),%eax +c01064d5: 89 04 24 mov %eax,(%esp) +c01064d8: e8 d4 e8 ff ff call c0104db1 +c01064dd: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c01064e4: 00 +c01064e5: 89 04 24 mov %eax,(%esp) +c01064e8: e8 5b eb ff ff call c0105048 + boot_pgdir[0] = 0;// 将页目录的第一个项设为0 +c01064ed: a1 00 8a 12 c0 mov 0xc0128a00,%eax +c01064f2: c7 00 00 00 00 00 movl $0x0,(%eax) -unsigned int ksize(const void *block) -{ -c0106916: f3 0f 1e fb endbr32 -c010691a: 55 push %ebp -c010691b: 89 e5 mov %esp,%ebp -c010691d: 83 ec 28 sub $0x28,%esp - bigblock_t *bb; - unsigned long flags; + cprintf("check_boot_pgdir() succeeded!\n");// 输出成功信息 +c01064f8: c7 04 24 c0 b3 10 c0 movl $0xc010b3c0,(%esp) +c01064ff: e8 74 9e ff ff call c0100378 +} +c0106504: 90 nop +c0106505: 89 ec mov %ebp,%esp +c0106507: 5d pop %ebp +c0106508: c3 ret - if (!block) -c0106920: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c0106924: 75 07 jne c010692d - return 0; -c0106926: b8 00 00 00 00 mov $0x0,%eax -c010692b: eb 6b jmp c0106998 +c0106509 : - if (!((unsigned long)block & (PAGE_SIZE-1))) { -c010692d: 8b 45 08 mov 0x8(%ebp),%eax -c0106930: 25 ff 0f 00 00 and $0xfff,%eax -c0106935: 85 c0 test %eax,%eax -c0106937: 75 54 jne c010698d - spin_lock_irqsave(&block_lock, flags); -c0106939: e8 d8 f8 ff ff call c0106216 <__intr_save> -c010693e: 89 45 f0 mov %eax,-0x10(%ebp) - for (bb = bigblocks; bb; bb = bb->next) -c0106941: a1 10 c0 12 c0 mov 0xc012c010,%eax -c0106946: 89 45 f4 mov %eax,-0xc(%ebp) -c0106949: eb 31 jmp c010697c - if (bb->pages == block) { -c010694b: 8b 45 f4 mov -0xc(%ebp),%eax -c010694e: 8b 40 04 mov 0x4(%eax),%eax -c0106951: 39 45 08 cmp %eax,0x8(%ebp) -c0106954: 75 1d jne c0106973 - spin_unlock_irqrestore(&slob_lock, flags); -c0106956: 8b 45 f0 mov -0x10(%ebp),%eax -c0106959: 89 04 24 mov %eax,(%esp) -c010695c: e8 df f8 ff ff call c0106240 <__intr_restore> - return PAGE_SIZE << bb->order; -c0106961: 8b 45 f4 mov -0xc(%ebp),%eax -c0106964: 8b 00 mov (%eax),%eax -c0106966: ba 00 10 00 00 mov $0x1000,%edx -c010696b: 88 c1 mov %al,%cl -c010696d: d3 e2 shl %cl,%edx -c010696f: 89 d0 mov %edx,%eax -c0106971: eb 25 jmp c0106998 - for (bb = bigblocks; bb; bb = bb->next) -c0106973: 8b 45 f4 mov -0xc(%ebp),%eax -c0106976: 8b 40 08 mov 0x8(%eax),%eax -c0106979: 89 45 f4 mov %eax,-0xc(%ebp) -c010697c: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0106980: 75 c9 jne c010694b - } - spin_unlock_irqrestore(&block_lock, flags); -c0106982: 8b 45 f0 mov -0x10(%ebp),%eax -c0106985: 89 04 24 mov %eax,(%esp) -c0106988: e8 b3 f8 ff ff call c0106240 <__intr_restore> - } +//perm2str - use string 'u,r,w,-' to present the permission +static const char * +perm2str(int perm) { +c0106509: 55 push %ebp +c010650a: 89 e5 mov %esp,%ebp + //定义一个静态字符数组 str,长度为4 + static char str[4]; + //如果 perm 与 PTE_U 按位与的结果不为0,则 str[0] 设置为 'u',否则设置为 '-' + str[0] = (perm & PTE_U) ? 'u' : '-'; +c010650c: 8b 45 08 mov 0x8(%ebp),%eax +c010650f: 83 e0 04 and $0x4,%eax +c0106512: 85 c0 test %eax,%eax +c0106514: 74 04 je c010651a +c0106516: b0 75 mov $0x75,%al +c0106518: eb 02 jmp c010651c +c010651a: b0 2d mov $0x2d,%al +c010651c: a2 88 c0 12 c0 mov %al,0xc012c088 + //str[1] 始终设置为 'r' + str[1] = 'r'; +c0106521: c6 05 89 c0 12 c0 72 movb $0x72,0xc012c089 + //如果 perm 与 PTE_W 按位与的结果不为0,则 str[2] 设置为 'w',否则设置为 '-' + str[2] = (perm & PTE_W) ? 'w' : '-'; +c0106528: 8b 45 08 mov 0x8(%ebp),%eax +c010652b: 83 e0 02 and $0x2,%eax +c010652e: 85 c0 test %eax,%eax +c0106530: 74 04 je c0106536 +c0106532: b0 77 mov $0x77,%al +c0106534: eb 02 jmp c0106538 +c0106536: b0 2d mov $0x2d,%al +c0106538: a2 8a c0 12 c0 mov %al,0xc012c08a + //str[3] 设置为字符串结束符 \0 + str[3] = '\0'; +c010653d: c6 05 8b c0 12 c0 00 movb $0x0,0xc012c08b + return str; +c0106544: b8 88 c0 12 c0 mov $0xc012c088,%eax +} +c0106549: 5d pop %ebp +c010654a: c3 ret - return ((slob_t *)block - 1)->units * SLOB_UNIT; -c010698d: 8b 45 08 mov 0x8(%ebp),%eax -c0106990: 83 e8 08 sub $0x8,%eax -c0106993: 8b 00 mov (%eax),%eax -c0106995: c1 e0 03 shl $0x3,%eax +c010654b : +// left_store: the pointer of the high side of table's next range +// right_store: the pointer of the low side of table's next range +// return value: 0 - not a invalid item range, perm - a valid item range with perm permission +//从页表中获取指定范围内的有效项,并根据权限进行处理。 +static int +get_pgtable_items(size_t left, size_t right, size_t start, uintptr_t *table, size_t *left_store, size_t *right_store) { +c010654b: 55 push %ebp +c010654c: 89 e5 mov %esp,%ebp +c010654e: 83 ec 10 sub $0x10,%esp + if (start >= right) {// 检查起始索引是否超出右边界 +c0106551: 8b 45 10 mov 0x10(%ebp),%eax +c0106554: 3b 45 0c cmp 0xc(%ebp),%eax +c0106557: 72 0d jb c0106566 + return 0;// 如果超出右边界,返回0 +c0106559: b8 00 00 00 00 mov $0x0,%eax +c010655e: e9 98 00 00 00 jmp c01065fb + } + while (start < right && !(table[start] & PTE_P)) {// 查找第一个有效项(PTE_P位为1的项) + start ++;// 索引递增 +c0106563: ff 45 10 incl 0x10(%ebp) + while (start < right && !(table[start] & PTE_P)) {// 查找第一个有效项(PTE_P位为1的项) +c0106566: 8b 45 10 mov 0x10(%ebp),%eax +c0106569: 3b 45 0c cmp 0xc(%ebp),%eax +c010656c: 73 18 jae c0106586 +c010656e: 8b 45 10 mov 0x10(%ebp),%eax +c0106571: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx +c0106578: 8b 45 14 mov 0x14(%ebp),%eax +c010657b: 01 d0 add %edx,%eax +c010657d: 8b 00 mov (%eax),%eax +c010657f: 83 e0 01 and $0x1,%eax +c0106582: 85 c0 test %eax,%eax +c0106584: 74 dd je c0106563 + } + if (start < right) {// 检查是否找到有效项 +c0106586: 8b 45 10 mov 0x10(%ebp),%eax +c0106589: 3b 45 0c cmp 0xc(%ebp),%eax +c010658c: 73 68 jae c01065f6 + if (left_store != NULL) {// 如果left_store不为NULL +c010658e: 83 7d 18 00 cmpl $0x0,0x18(%ebp) +c0106592: 74 08 je c010659c + *left_store = start;// 记录左边界索引 +c0106594: 8b 45 18 mov 0x18(%ebp),%eax +c0106597: 8b 55 10 mov 0x10(%ebp),%edx +c010659a: 89 10 mov %edx,(%eax) + } + int perm = (table[start ++] & PTE_USER);// 获取当前项的用户权限位并递增索引 +c010659c: 8b 45 10 mov 0x10(%ebp),%eax +c010659f: 8d 50 01 lea 0x1(%eax),%edx +c01065a2: 89 55 10 mov %edx,0x10(%ebp) +c01065a5: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx +c01065ac: 8b 45 14 mov 0x14(%ebp),%eax +c01065af: 01 d0 add %edx,%eax +c01065b1: 8b 00 mov (%eax),%eax +c01065b3: 83 e0 07 and $0x7,%eax +c01065b6: 89 45 fc mov %eax,-0x4(%ebp) + while (start < right && (table[start] & PTE_USER) == perm) {// 查找具有相同用户权限的连续项 +c01065b9: eb 03 jmp c01065be + start ++;// 索引递增 +c01065bb: ff 45 10 incl 0x10(%ebp) + while (start < right && (table[start] & PTE_USER) == perm) {// 查找具有相同用户权限的连续项 +c01065be: 8b 45 10 mov 0x10(%ebp),%eax +c01065c1: 3b 45 0c cmp 0xc(%ebp),%eax +c01065c4: 73 1d jae c01065e3 +c01065c6: 8b 45 10 mov 0x10(%ebp),%eax +c01065c9: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx +c01065d0: 8b 45 14 mov 0x14(%ebp),%eax +c01065d3: 01 d0 add %edx,%eax +c01065d5: 8b 00 mov (%eax),%eax +c01065d7: 83 e0 07 and $0x7,%eax +c01065da: 89 c2 mov %eax,%edx +c01065dc: 8b 45 fc mov -0x4(%ebp),%eax +c01065df: 39 c2 cmp %eax,%edx +c01065e1: 74 d8 je c01065bb + } + if (right_store != NULL) {// 如果right_store不为NULL +c01065e3: 83 7d 1c 00 cmpl $0x0,0x1c(%ebp) +c01065e7: 74 08 je c01065f1 + *right_store = start;// 记录右边界索引 +c01065e9: 8b 45 1c mov 0x1c(%ebp),%eax +c01065ec: 8b 55 10 mov 0x10(%ebp),%edx +c01065ef: 89 10 mov %edx,(%eax) + } + return perm;// 返回用户权限位 +c01065f1: 8b 45 fc mov -0x4(%ebp),%eax +c01065f4: eb 05 jmp c01065fb + } + return 0;// 如果未找到有效项,返回0 +c01065f6: b8 00 00 00 00 mov $0x0,%eax } -c0106998: c9 leave -c0106999: c3 ret +c01065fb: 89 ec mov %ebp,%esp +c01065fd: 5d pop %ebp +c01065fe: c3 ret + +c01065ff : -c010699a : +//print_pgdir - print the PDT&PT +void +print_pgdir(void) { +c01065ff: 55 push %ebp +c0106600: 89 e5 mov %esp,%ebp +c0106602: 57 push %edi +c0106603: 56 push %esi +c0106604: 53 push %ebx +c0106605: 83 ec 4c sub $0x4c,%esp + cprintf("-------------------- BEGIN --------------------\n"); +c0106608: c7 04 24 e0 b3 10 c0 movl $0xc010b3e0,(%esp) +c010660f: e8 64 9d ff ff call c0100378 + // 定义变量 left, right 和 perm + size_t left, right = 0, perm; +c0106614: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) + // 遍历页目录项 + while ((perm = get_pgtable_items(0, NPDEENTRY, right, vpd, &left, &right)) != 0) { +c010661b: e9 f2 00 00 00 jmp c0106712 + // 打印页目录项的信息 + cprintf("PDE(%03x) %08x-%08x %08x %s\n", right - left, +c0106620: 8b 45 e4 mov -0x1c(%ebp),%eax +c0106623: 89 04 24 mov %eax,(%esp) +c0106626: e8 de fe ff ff call c0106509 + left * PTSIZE, right * PTSIZE, (right - left) * PTSIZE, perm2str(perm)); +c010662b: 8b 55 dc mov -0x24(%ebp),%edx +c010662e: 8b 4d e0 mov -0x20(%ebp),%ecx +c0106631: 29 ca sub %ecx,%edx + cprintf("PDE(%03x) %08x-%08x %08x %s\n", right - left, +c0106633: 89 d6 mov %edx,%esi +c0106635: c1 e6 16 shl $0x16,%esi +c0106638: 8b 55 dc mov -0x24(%ebp),%edx +c010663b: 89 d3 mov %edx,%ebx +c010663d: c1 e3 16 shl $0x16,%ebx +c0106640: 8b 55 e0 mov -0x20(%ebp),%edx +c0106643: 89 d1 mov %edx,%ecx +c0106645: c1 e1 16 shl $0x16,%ecx +c0106648: 8b 55 dc mov -0x24(%ebp),%edx +c010664b: 8b 7d e0 mov -0x20(%ebp),%edi +c010664e: 29 fa sub %edi,%edx +c0106650: 89 44 24 14 mov %eax,0x14(%esp) +c0106654: 89 74 24 10 mov %esi,0x10(%esp) +c0106658: 89 5c 24 0c mov %ebx,0xc(%esp) +c010665c: 89 4c 24 08 mov %ecx,0x8(%esp) +c0106660: 89 54 24 04 mov %edx,0x4(%esp) +c0106664: c7 04 24 11 b4 10 c0 movl $0xc010b411,(%esp) +c010666b: e8 08 9d ff ff call c0100378 + // 计算页表项的起始和结束索引 + size_t l, r = left * NPTEENTRY; +c0106670: 8b 45 e0 mov -0x20(%ebp),%eax +c0106673: c1 e0 0a shl $0xa,%eax +c0106676: 89 45 d4 mov %eax,-0x2c(%ebp) + // 遍历页表项 + while ((perm = get_pgtable_items(left * NPTEENTRY, right * NPTEENTRY, r, vpt, &l, &r)) != 0) { +c0106679: eb 50 jmp c01066cb + // 打印页表项的信息 + cprintf(" |-- PTE(%05x) %08x-%08x %08x %s\n", r - l, +c010667b: 8b 45 e4 mov -0x1c(%ebp),%eax +c010667e: 89 04 24 mov %eax,(%esp) +c0106681: e8 83 fe ff ff call c0106509 + l * PGSIZE, r * PGSIZE, (r - l) * PGSIZE, perm2str(perm)); +c0106686: 8b 55 d4 mov -0x2c(%ebp),%edx +c0106689: 8b 4d d8 mov -0x28(%ebp),%ecx +c010668c: 29 ca sub %ecx,%edx + cprintf(" |-- PTE(%05x) %08x-%08x %08x %s\n", r - l, +c010668e: 89 d6 mov %edx,%esi +c0106690: c1 e6 0c shl $0xc,%esi +c0106693: 8b 55 d4 mov -0x2c(%ebp),%edx +c0106696: 89 d3 mov %edx,%ebx +c0106698: c1 e3 0c shl $0xc,%ebx +c010669b: 8b 55 d8 mov -0x28(%ebp),%edx +c010669e: 89 d1 mov %edx,%ecx +c01066a0: c1 e1 0c shl $0xc,%ecx +c01066a3: 8b 55 d4 mov -0x2c(%ebp),%edx +c01066a6: 8b 7d d8 mov -0x28(%ebp),%edi +c01066a9: 29 fa sub %edi,%edx +c01066ab: 89 44 24 14 mov %eax,0x14(%esp) +c01066af: 89 74 24 10 mov %esi,0x10(%esp) +c01066b3: 89 5c 24 0c mov %ebx,0xc(%esp) +c01066b7: 89 4c 24 08 mov %ecx,0x8(%esp) +c01066bb: 89 54 24 04 mov %edx,0x4(%esp) +c01066bf: c7 04 24 30 b4 10 c0 movl $0xc010b430,(%esp) +c01066c6: e8 ad 9c ff ff call c0100378 + while ((perm = get_pgtable_items(left * NPTEENTRY, right * NPTEENTRY, r, vpt, &l, &r)) != 0) { +c01066cb: be 00 00 c0 fa mov $0xfac00000,%esi +c01066d0: 8b 45 d4 mov -0x2c(%ebp),%eax +c01066d3: 8b 55 dc mov -0x24(%ebp),%edx +c01066d6: 89 d3 mov %edx,%ebx +c01066d8: c1 e3 0a shl $0xa,%ebx +c01066db: 8b 55 e0 mov -0x20(%ebp),%edx +c01066de: 89 d1 mov %edx,%ecx +c01066e0: c1 e1 0a shl $0xa,%ecx +c01066e3: 8d 55 d4 lea -0x2c(%ebp),%edx +c01066e6: 89 54 24 14 mov %edx,0x14(%esp) +c01066ea: 8d 55 d8 lea -0x28(%ebp),%edx +c01066ed: 89 54 24 10 mov %edx,0x10(%esp) +c01066f1: 89 74 24 0c mov %esi,0xc(%esp) +c01066f5: 89 44 24 08 mov %eax,0x8(%esp) +c01066f9: 89 5c 24 04 mov %ebx,0x4(%esp) +c01066fd: 89 0c 24 mov %ecx,(%esp) +c0106700: e8 46 fe ff ff call c010654b +c0106705: 89 45 e4 mov %eax,-0x1c(%ebp) +c0106708: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) +c010670c: 0f 85 69 ff ff ff jne c010667b + while ((perm = get_pgtable_items(0, NPDEENTRY, right, vpd, &left, &right)) != 0) { +c0106712: b9 00 b0 fe fa mov $0xfafeb000,%ecx +c0106717: 8b 45 dc mov -0x24(%ebp),%eax +c010671a: 8d 55 dc lea -0x24(%ebp),%edx +c010671d: 89 54 24 14 mov %edx,0x14(%esp) +c0106721: 8d 55 e0 lea -0x20(%ebp),%edx +c0106724: 89 54 24 10 mov %edx,0x10(%esp) +c0106728: 89 4c 24 0c mov %ecx,0xc(%esp) +c010672c: 89 44 24 08 mov %eax,0x8(%esp) +c0106730: c7 44 24 04 00 04 00 movl $0x400,0x4(%esp) +c0106737: 00 +c0106738: c7 04 24 00 00 00 00 movl $0x0,(%esp) +c010673f: e8 07 fe ff ff call c010654b +c0106744: 89 45 e4 mov %eax,-0x1c(%ebp) +c0106747: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) +c010674b: 0f 85 cf fe ff ff jne c0106620 + } + } + cprintf("--------------------- END ---------------------\n"); +c0106751: c7 04 24 54 b4 10 c0 movl $0xc010b454,(%esp) +c0106758: e8 1b 9c ff ff call c0100378 +} +c010675d: 90 nop +c010675e: 83 c4 4c add $0x4c,%esp +c0106761: 5b pop %ebx +c0106762: 5e pop %esi +c0106763: 5f pop %edi +c0106764: 5d pop %ebp +c0106765: c3 ret + +c0106766 : pa2page(uintptr_t pa) { -c010699a: 55 push %ebp -c010699b: 89 e5 mov %esp,%ebp -c010699d: 83 ec 18 sub $0x18,%esp +c0106766: 55 push %ebp +c0106767: 89 e5 mov %esp,%ebp +c0106769: 83 ec 18 sub $0x18,%esp if (PPN(pa) >= npage) { -c01069a0: 8b 45 08 mov 0x8(%ebp),%eax -c01069a3: c1 e8 0c shr $0xc,%eax -c01069a6: 89 c2 mov %eax,%edx -c01069a8: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c01069ad: 39 c2 cmp %eax,%edx -c01069af: 72 1c jb c01069cd +c010676c: 8b 45 08 mov 0x8(%ebp),%eax +c010676f: c1 e8 0c shr $0xc,%eax +c0106772: 89 c2 mov %eax,%edx +c0106774: a1 04 c0 12 c0 mov 0xc012c004,%eax +c0106779: 39 c2 cmp %eax,%edx +c010677b: 72 1c jb c0106799 panic("pa2page called with invalid pa"); -c01069b1: c7 44 24 08 78 b9 10 movl $0xc010b978,0x8(%esp) -c01069b8: c0 -c01069b9: c7 44 24 04 5f 00 00 movl $0x5f,0x4(%esp) -c01069c0: 00 -c01069c1: c7 04 24 97 b9 10 c0 movl $0xc010b997,(%esp) -c01069c8: e8 76 9a ff ff call c0100443 <__panic> +c010677d: c7 44 24 08 88 b4 10 movl $0xc010b488,0x8(%esp) +c0106784: c0 +c0106785: c7 44 24 04 5f 00 00 movl $0x5f,0x4(%esp) +c010678c: 00 +c010678d: c7 04 24 a7 b4 10 c0 movl $0xc010b4a7,(%esp) +c0106794: e8 ac a4 ff ff call c0100c45 <__panic> return &pages[PPN(pa)]; -c01069cd: a1 b8 e0 12 c0 mov 0xc012e0b8,%eax -c01069d2: 8b 55 08 mov 0x8(%ebp),%edx -c01069d5: c1 ea 0c shr $0xc,%edx -c01069d8: c1 e2 05 shl $0x5,%edx -c01069db: 01 d0 add %edx,%eax +c0106799: 8b 15 00 c0 12 c0 mov 0xc012c000,%edx +c010679f: 8b 45 08 mov 0x8(%ebp),%eax +c01067a2: c1 e8 0c shr $0xc,%eax +c01067a5: c1 e0 05 shl $0x5,%eax +c01067a8: 01 d0 add %edx,%eax } -c01069dd: c9 leave -c01069de: c3 ret +c01067aa: 89 ec mov %ebp,%esp +c01067ac: 5d pop %ebp +c01067ad: c3 ret -c01069df : +c01067ae : pte2page(pte_t pte) { -c01069df: 55 push %ebp -c01069e0: 89 e5 mov %esp,%ebp -c01069e2: 83 ec 18 sub $0x18,%esp +c01067ae: 55 push %ebp +c01067af: 89 e5 mov %esp,%ebp +c01067b1: 83 ec 18 sub $0x18,%esp if (!(pte & PTE_P)) { -c01069e5: 8b 45 08 mov 0x8(%ebp),%eax -c01069e8: 83 e0 01 and $0x1,%eax -c01069eb: 85 c0 test %eax,%eax -c01069ed: 75 1c jne c0106a0b +c01067b4: 8b 45 08 mov 0x8(%ebp),%eax +c01067b7: 83 e0 01 and $0x1,%eax +c01067ba: 85 c0 test %eax,%eax +c01067bc: 75 1c jne c01067da panic("pte2page called with invalid pte"); -c01069ef: c7 44 24 08 a8 b9 10 movl $0xc010b9a8,0x8(%esp) -c01069f6: c0 -c01069f7: c7 44 24 04 71 00 00 movl $0x71,0x4(%esp) -c01069fe: 00 -c01069ff: c7 04 24 97 b9 10 c0 movl $0xc010b997,(%esp) -c0106a06: e8 38 9a ff ff call c0100443 <__panic> +c01067be: c7 44 24 08 b8 b4 10 movl $0xc010b4b8,0x8(%esp) +c01067c5: c0 +c01067c6: c7 44 24 04 71 00 00 movl $0x71,0x4(%esp) +c01067cd: 00 +c01067ce: c7 04 24 a7 b4 10 c0 movl $0xc010b4a7,(%esp) +c01067d5: e8 6b a4 ff ff call c0100c45 <__panic> return pa2page(PTE_ADDR(pte)); -c0106a0b: 8b 45 08 mov 0x8(%ebp),%eax -c0106a0e: 25 00 f0 ff ff and $0xfffff000,%eax -c0106a13: 89 04 24 mov %eax,(%esp) -c0106a16: e8 7f ff ff ff call c010699a +c01067da: 8b 45 08 mov 0x8(%ebp),%eax +c01067dd: 25 00 f0 ff ff and $0xfffff000,%eax +c01067e2: 89 04 24 mov %eax,(%esp) +c01067e5: e8 7c ff ff ff call c0106766 } -c0106a1b: c9 leave -c0106a1c: c3 ret +c01067ea: 89 ec mov %ebp,%esp +c01067ec: 5d pop %ebp +c01067ed: c3 ret -c0106a1d : +c01067ee : static void check_swap(void); int swap_init(void) { -c0106a1d: f3 0f 1e fb endbr32 -c0106a21: 55 push %ebp -c0106a22: 89 e5 mov %esp,%ebp -c0106a24: 83 ec 28 sub $0x28,%esp +c01067ee: 55 push %ebp +c01067ef: 89 e5 mov %esp,%ebp +c01067f1: 83 ec 28 sub $0x28,%esp // 初始化交换文件系统 swapfs_init(); -c0106a27: e8 18 1e 00 00 call c0108844 +c01067f4: e8 a7 1e 00 00 call c01086a0 // 检查最大交换偏移量是否在合法范围内 if (!(1024 <= max_swap_offset && max_swap_offset < MAX_SWAP_OFFSET_LIMIT)) -c0106a2c: a1 7c e1 12 c0 mov 0xc012e17c,%eax -c0106a31: 3d ff 03 00 00 cmp $0x3ff,%eax -c0106a36: 76 0c jbe c0106a44 -c0106a38: a1 7c e1 12 c0 mov 0xc012e17c,%eax -c0106a3d: 3d ff ff ff 00 cmp $0xffffff,%eax -c0106a42: 76 25 jbe c0106a69 +c01067f9: a1 a0 c0 12 c0 mov 0xc012c0a0,%eax +c01067fe: 3d ff 03 00 00 cmp $0x3ff,%eax +c0106803: 76 0c jbe c0106811 +c0106805: a1 a0 c0 12 c0 mov 0xc012c0a0,%eax +c010680a: 3d ff ff ff 00 cmp $0xffffff,%eax +c010680f: 76 25 jbe c0106836 { // 如果最大交换偏移量不合法,输出错误信息并panic panic("bad max_swap_offset %08x.\n", max_swap_offset); -c0106a44: a1 7c e1 12 c0 mov 0xc012e17c,%eax -c0106a49: 89 44 24 0c mov %eax,0xc(%esp) -c0106a4d: c7 44 24 08 c9 b9 10 movl $0xc010b9c9,0x8(%esp) -c0106a54: c0 -c0106a55: c7 44 24 04 28 00 00 movl $0x28,0x4(%esp) -c0106a5c: 00 -c0106a5d: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106a64: e8 da 99 ff ff call c0100443 <__panic> +c0106811: a1 a0 c0 12 c0 mov 0xc012c0a0,%eax +c0106816: 89 44 24 0c mov %eax,0xc(%esp) +c010681a: c7 44 24 08 d9 b4 10 movl $0xc010b4d9,0x8(%esp) +c0106821: c0 +c0106822: c7 44 24 04 28 00 00 movl $0x28,0x4(%esp) +c0106829: 00 +c010682a: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106831: e8 0f a4 ff ff call c0100c45 <__panic> } // 选择并设置交换管理器为FIFO(先进先出)策略 sm = &swap_manager_fifo; -c0106a69: c7 05 1c c0 12 c0 40 movl $0xc0128a40,0xc012c01c -c0106a70: 8a 12 c0 +c0106836: c7 05 60 c1 12 c0 60 movl $0xc0128a60,0xc012c160 +c010683d: 8a 12 c0 // 调用选定交换管理器的初始化函数 int r = sm->init(); -c0106a73: a1 1c c0 12 c0 mov 0xc012c01c,%eax -c0106a78: 8b 40 04 mov 0x4(%eax),%eax -c0106a7b: ff d0 call *%eax -c0106a7d: 89 45 f4 mov %eax,-0xc(%ebp) +c0106840: a1 60 c1 12 c0 mov 0xc012c160,%eax +c0106845: 8b 40 04 mov 0x4(%eax),%eax +c0106848: ff d0 call *%eax +c010684a: 89 45 f4 mov %eax,-0xc(%ebp) // 如果交换管理器初始化成功 if (r == 0) -c0106a80: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0106a84: 75 26 jne c0106aac +c010684d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0106851: 75 26 jne c0106879 { // 标记交换空间初始化为成功 swap_init_ok = 1; -c0106a86: c7 05 14 c0 12 c0 01 movl $0x1,0xc012c014 -c0106a8d: 00 00 00 +c0106853: c7 05 a4 c0 12 c0 01 movl $0x1,0xc012c0a4 +c010685a: 00 00 00 cprintf("SWAP: manager = %s\n", sm->name); -c0106a90: a1 1c c0 12 c0 mov 0xc012c01c,%eax -c0106a95: 8b 00 mov (%eax),%eax -c0106a97: 89 44 24 04 mov %eax,0x4(%esp) -c0106a9b: c7 04 24 f3 b9 10 c0 movl $0xc010b9f3,(%esp) -c0106aa2: e8 30 98 ff ff call c01002d7 +c010685d: a1 60 c1 12 c0 mov 0xc012c160,%eax +c0106862: 8b 00 mov (%eax),%eax +c0106864: 89 44 24 04 mov %eax,0x4(%esp) +c0106868: c7 04 24 03 b5 10 c0 movl $0xc010b503,(%esp) +c010686f: e8 04 9b ff ff call c0100378 // 检查交换空间状态 check_swap(); -c0106aa7: e8 b6 04 00 00 call c0106f62 +c0106874: e8 b0 04 00 00 call c0106d29 } // 返回初始化结果 return r; -c0106aac: 8b 45 f4 mov -0xc(%ebp),%eax +c0106879: 8b 45 f4 mov -0xc(%ebp),%eax } -c0106aaf: c9 leave -c0106ab0: c3 ret +c010687c: 89 ec mov %ebp,%esp +c010687e: 5d pop %ebp +c010687f: c3 ret -c0106ab1 : +c0106880 : int swap_init_mm(struct mm_struct *mm) { -c0106ab1: f3 0f 1e fb endbr32 -c0106ab5: 55 push %ebp -c0106ab6: 89 e5 mov %esp,%ebp -c0106ab8: 83 ec 18 sub $0x18,%esp +c0106880: 55 push %ebp +c0106881: 89 e5 mov %esp,%ebp +c0106883: 83 ec 18 sub $0x18,%esp //调用 sm 结构体中的 init_mm 函数,并将 mm 作为参数传递 return sm->init_mm(mm); -c0106abb: a1 1c c0 12 c0 mov 0xc012c01c,%eax -c0106ac0: 8b 40 08 mov 0x8(%eax),%eax -c0106ac3: 8b 55 08 mov 0x8(%ebp),%edx -c0106ac6: 89 14 24 mov %edx,(%esp) -c0106ac9: ff d0 call *%eax +c0106886: a1 60 c1 12 c0 mov 0xc012c160,%eax +c010688b: 8b 40 08 mov 0x8(%eax),%eax +c010688e: 8b 55 08 mov 0x8(%ebp),%edx +c0106891: 89 14 24 mov %edx,(%esp) +c0106894: ff d0 call *%eax } -c0106acb: c9 leave -c0106acc: c3 ret +c0106896: 89 ec mov %ebp,%esp +c0106898: 5d pop %ebp +c0106899: c3 ret -c0106acd : +c010689a : * * 返回值: sm->tick_event(mm)的返回值 */ int swap_tick_event(struct mm_struct *mm) { -c0106acd: f3 0f 1e fb endbr32 -c0106ad1: 55 push %ebp -c0106ad2: 89 e5 mov %esp,%ebp -c0106ad4: 83 ec 18 sub $0x18,%esp +c010689a: 55 push %ebp +c010689b: 89 e5 mov %esp,%ebp +c010689d: 83 ec 18 sub $0x18,%esp return sm->tick_event(mm); -c0106ad7: a1 1c c0 12 c0 mov 0xc012c01c,%eax -c0106adc: 8b 40 0c mov 0xc(%eax),%eax -c0106adf: 8b 55 08 mov 0x8(%ebp),%edx -c0106ae2: 89 14 24 mov %edx,(%esp) -c0106ae5: ff d0 call *%eax +c01068a0: a1 60 c1 12 c0 mov 0xc012c160,%eax +c01068a5: 8b 40 0c mov 0xc(%eax),%eax +c01068a8: 8b 55 08 mov 0x8(%ebp),%edx +c01068ab: 89 14 24 mov %edx,(%esp) +c01068ae: ff d0 call *%eax } -c0106ae7: c9 leave -c0106ae8: c3 ret +c01068b0: 89 ec mov %ebp,%esp +c01068b2: 5d pop %ebp +c01068b3: c3 ret -c0106ae9 : +c01068b4 : * 此函数的作用是作为交换操作的接口,根据swap_in参数决定是将页面交换入还是交换出 * 它实际上调用了结构体sm中定义的map_swappable函数,因此具体的操作逻辑依赖于该函数的实现 */ int swap_map_swappable(struct mm_struct *mm, uintptr_t addr, struct Page *page, int swap_in) { -c0106ae9: f3 0f 1e fb endbr32 -c0106aed: 55 push %ebp -c0106aee: 89 e5 mov %esp,%ebp -c0106af0: 83 ec 18 sub $0x18,%esp +c01068b4: 55 push %ebp +c01068b5: 89 e5 mov %esp,%ebp +c01068b7: 83 ec 18 sub $0x18,%esp return sm->map_swappable(mm, addr, page, swap_in); -c0106af3: a1 1c c0 12 c0 mov 0xc012c01c,%eax -c0106af8: 8b 40 10 mov 0x10(%eax),%eax -c0106afb: 8b 55 14 mov 0x14(%ebp),%edx -c0106afe: 89 54 24 0c mov %edx,0xc(%esp) -c0106b02: 8b 55 10 mov 0x10(%ebp),%edx -c0106b05: 89 54 24 08 mov %edx,0x8(%esp) -c0106b09: 8b 55 0c mov 0xc(%ebp),%edx -c0106b0c: 89 54 24 04 mov %edx,0x4(%esp) -c0106b10: 8b 55 08 mov 0x8(%ebp),%edx -c0106b13: 89 14 24 mov %edx,(%esp) -c0106b16: ff d0 call *%eax -} -c0106b18: c9 leave -c0106b19: c3 ret - -c0106b1a : +c01068ba: a1 60 c1 12 c0 mov 0xc012c160,%eax +c01068bf: 8b 40 10 mov 0x10(%eax),%eax +c01068c2: 8b 55 14 mov 0x14(%ebp),%edx +c01068c5: 89 54 24 0c mov %edx,0xc(%esp) +c01068c9: 8b 55 10 mov 0x10(%ebp),%edx +c01068cc: 89 54 24 08 mov %edx,0x8(%esp) +c01068d0: 8b 55 0c mov 0xc(%ebp),%edx +c01068d3: 89 54 24 04 mov %edx,0x4(%esp) +c01068d7: 8b 55 08 mov 0x8(%ebp),%edx +c01068da: 89 14 24 mov %edx,(%esp) +c01068dd: ff d0 call *%eax +} +c01068df: 89 ec mov %ebp,%esp +c01068e1: 5d pop %ebp +c01068e2: c3 ret + +c01068e3 : * 此函数通过调用sm->set_unswappable方法来实现,其主要目的是防止指定的内存区域被交换到磁盘, * 通常用于那些需要常驻内存不能被交换出的特殊页面。成功时返回0,失败时返回非零值。 */ int swap_set_unswappable(struct mm_struct *mm, uintptr_t addr) { -c0106b1a: f3 0f 1e fb endbr32 -c0106b1e: 55 push %ebp -c0106b1f: 89 e5 mov %esp,%ebp -c0106b21: 83 ec 18 sub $0x18,%esp +c01068e3: 55 push %ebp +c01068e4: 89 e5 mov %esp,%ebp +c01068e6: 83 ec 18 sub $0x18,%esp return sm->set_unswappable(mm, addr); -c0106b24: a1 1c c0 12 c0 mov 0xc012c01c,%eax -c0106b29: 8b 40 14 mov 0x14(%eax),%eax -c0106b2c: 8b 55 0c mov 0xc(%ebp),%edx -c0106b2f: 89 54 24 04 mov %edx,0x4(%esp) -c0106b33: 8b 55 08 mov 0x8(%ebp),%edx -c0106b36: 89 14 24 mov %edx,(%esp) -c0106b39: ff d0 call *%eax -} -c0106b3b: c9 leave -c0106b3c: c3 ret - -c0106b3d : +c01068e9: a1 60 c1 12 c0 mov 0xc012c160,%eax +c01068ee: 8b 40 14 mov 0x14(%eax),%eax +c01068f1: 8b 55 0c mov 0xc(%ebp),%edx +c01068f4: 89 54 24 04 mov %edx,0x4(%esp) +c01068f8: 8b 55 08 mov 0x8(%ebp),%edx +c01068fb: 89 14 24 mov %edx,(%esp) +c01068fe: ff d0 call *%eax +} +c0106900: 89 ec mov %ebp,%esp +c0106902: 5d pop %ebp +c0106903: c3 ret + +c0106904 : * 此函数通过选择 victim 页面并将其内容写入到交换空间中,来实现内存中页面的交换出操作。 * 它主要用于内存压力较大时,释放内存空间,确保系统稳定运行。 */ int swap_out(struct mm_struct *mm, int n, int in_tick) { -c0106b3d: f3 0f 1e fb endbr32 -c0106b41: 55 push %ebp -c0106b42: 89 e5 mov %esp,%ebp -c0106b44: 83 ec 38 sub $0x38,%esp +c0106904: 55 push %ebp +c0106905: 89 e5 mov %esp,%ebp +c0106907: 83 ec 38 sub $0x38,%esp int i; for (i = 0; i != n; ++ i)// 循环 n 次,每次处理一个页面 -c0106b47: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -c0106b4e: e9 53 01 00 00 jmp c0106ca6 +c010690a: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c0106911: e9 53 01 00 00 jmp c0106a69 uintptr_t v; // 用于存储页面的虚拟地址 //struct Page **ptr_page=NULL; struct Page *page; // 用于存储选中的页面 // cprintf("i %d, SWAP: call swap_out_victim\n",i); // 调用 swap_out_victim 函数选择一个 victim 页面 int r = sm->swap_out_victim(mm, &page, in_tick); -c0106b53: a1 1c c0 12 c0 mov 0xc012c01c,%eax -c0106b58: 8b 40 18 mov 0x18(%eax),%eax -c0106b5b: 8b 55 10 mov 0x10(%ebp),%edx -c0106b5e: 89 54 24 08 mov %edx,0x8(%esp) -c0106b62: 8d 55 e4 lea -0x1c(%ebp),%edx -c0106b65: 89 54 24 04 mov %edx,0x4(%esp) -c0106b69: 8b 55 08 mov 0x8(%ebp),%edx -c0106b6c: 89 14 24 mov %edx,(%esp) -c0106b6f: ff d0 call *%eax -c0106b71: 89 45 f0 mov %eax,-0x10(%ebp) +c0106916: a1 60 c1 12 c0 mov 0xc012c160,%eax +c010691b: 8b 40 18 mov 0x18(%eax),%eax +c010691e: 8b 55 10 mov 0x10(%ebp),%edx +c0106921: 89 54 24 08 mov %edx,0x8(%esp) +c0106925: 8d 55 e4 lea -0x1c(%ebp),%edx +c0106928: 89 54 24 04 mov %edx,0x4(%esp) +c010692c: 8b 55 08 mov 0x8(%ebp),%edx +c010692f: 89 14 24 mov %edx,(%esp) +c0106932: ff d0 call *%eax +c0106934: 89 45 f0 mov %eax,-0x10(%ebp) if (r != 0) {// 如果选择失败 -c0106b74: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c0106b78: 74 18 je c0106b92 +c0106937: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c010693b: 74 18 je c0106955 cprintf("i %d, swap_out: call swap_out_victim failed\n",i);// 输出错误信息 -c0106b7a: 8b 45 f4 mov -0xc(%ebp),%eax -c0106b7d: 89 44 24 04 mov %eax,0x4(%esp) -c0106b81: c7 04 24 08 ba 10 c0 movl $0xc010ba08,(%esp) -c0106b88: e8 4a 97 ff ff call c01002d7 -c0106b8d: e9 20 01 00 00 jmp c0106cb2 +c010693d: 8b 45 f4 mov -0xc(%ebp),%eax +c0106940: 89 44 24 04 mov %eax,0x4(%esp) +c0106944: c7 04 24 18 b5 10 c0 movl $0xc010b518,(%esp) +c010694b: e8 28 9a ff ff call c0100378 +c0106950: e9 20 01 00 00 jmp c0106a75 } //assert(!PageReserved(page)); //cprintf("SWAP: choose victim page 0x%08x\n", page); v=page->pra_vaddr; // 获取页面的虚拟地址 -c0106b92: 8b 45 e4 mov -0x1c(%ebp),%eax -c0106b95: 8b 40 1c mov 0x1c(%eax),%eax -c0106b98: 89 45 ec mov %eax,-0x14(%ebp) +c0106955: 8b 45 e4 mov -0x1c(%ebp),%eax +c0106958: 8b 40 1c mov 0x1c(%eax),%eax +c010695b: 89 45 ec mov %eax,-0x14(%ebp) pte_t *ptep = get_pte(mm->pgdir, v, 0); // 获取页面表项指针 -c0106b9b: 8b 45 08 mov 0x8(%ebp),%eax -c0106b9e: 8b 40 0c mov 0xc(%eax),%eax -c0106ba1: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c0106ba8: 00 -c0106ba9: 8b 55 ec mov -0x14(%ebp),%edx -c0106bac: 89 54 24 04 mov %edx,0x4(%esp) -c0106bb0: 89 04 24 mov %eax,(%esp) -c0106bb3: e8 71 d2 ff ff call c0103e29 -c0106bb8: 89 45 e8 mov %eax,-0x18(%ebp) +c010695e: 8b 45 08 mov 0x8(%ebp),%eax +c0106961: 8b 40 0c mov 0xc(%eax),%eax +c0106964: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c010696b: 00 +c010696c: 8b 55 ec mov -0x14(%ebp),%edx +c010696f: 89 54 24 04 mov %edx,0x4(%esp) +c0106973: 89 04 24 mov %eax,(%esp) +c0106976: e8 1b ed ff ff call c0105696 +c010697b: 89 45 e8 mov %eax,-0x18(%ebp) assert((*ptep & PTE_P) != 0); // 断言页面在物理内存中存在 -c0106bbb: 8b 45 e8 mov -0x18(%ebp),%eax -c0106bbe: 8b 00 mov (%eax),%eax -c0106bc0: 83 e0 01 and $0x1,%eax -c0106bc3: 85 c0 test %eax,%eax -c0106bc5: 75 24 jne c0106beb -c0106bc7: c7 44 24 0c 35 ba 10 movl $0xc010ba35,0xc(%esp) -c0106bce: c0 -c0106bcf: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0106bd6: c0 -c0106bd7: c7 44 24 04 9b 00 00 movl $0x9b,0x4(%esp) -c0106bde: 00 -c0106bdf: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106be6: e8 58 98 ff ff call c0100443 <__panic> +c010697e: 8b 45 e8 mov -0x18(%ebp),%eax +c0106981: 8b 00 mov (%eax),%eax +c0106983: 83 e0 01 and $0x1,%eax +c0106986: 85 c0 test %eax,%eax +c0106988: 75 24 jne c01069ae +c010698a: c7 44 24 0c 45 b5 10 movl $0xc010b545,0xc(%esp) +c0106991: c0 +c0106992: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106999: c0 +c010699a: c7 44 24 04 9b 00 00 movl $0x9b,0x4(%esp) +c01069a1: 00 +c01069a2: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c01069a9: e8 97 a2 ff ff call c0100c45 <__panic> if (swapfs_write( (page->pra_vaddr/PGSIZE+1)<<8, page) != 0) {// 将页面内容写入交换文件 -c0106beb: 8b 45 e4 mov -0x1c(%ebp),%eax -c0106bee: 8b 55 e4 mov -0x1c(%ebp),%edx -c0106bf1: 8b 52 1c mov 0x1c(%edx),%edx -c0106bf4: c1 ea 0c shr $0xc,%edx -c0106bf7: 42 inc %edx -c0106bf8: c1 e2 08 shl $0x8,%edx -c0106bfb: 89 44 24 04 mov %eax,0x4(%esp) -c0106bff: 89 14 24 mov %edx,(%esp) -c0106c02: e8 00 1d 00 00 call c0108907 -c0106c07: 85 c0 test %eax,%eax -c0106c09: 74 34 je c0106c3f +c01069ae: 8b 45 e4 mov -0x1c(%ebp),%eax +c01069b1: 8b 55 e4 mov -0x1c(%ebp),%edx +c01069b4: 8b 52 1c mov 0x1c(%edx),%edx +c01069b7: c1 ea 0c shr $0xc,%edx +c01069ba: 42 inc %edx +c01069bb: c1 e2 08 shl $0x8,%edx +c01069be: 89 44 24 04 mov %eax,0x4(%esp) +c01069c2: 89 14 24 mov %edx,(%esp) +c01069c5: e8 95 1d 00 00 call c010875f +c01069ca: 85 c0 test %eax,%eax +c01069cc: 74 34 je c0106a02 cprintf("SWAP: failed to save\n");// 如果写入失败,输出错误信息 -c0106c0b: c7 04 24 5f ba 10 c0 movl $0xc010ba5f,(%esp) -c0106c12: e8 c0 96 ff ff call c01002d7 +c01069ce: c7 04 24 6f b5 10 c0 movl $0xc010b56f,(%esp) +c01069d5: e8 9e 99 ff ff call c0100378 sm->map_swappable(mm, v, page, 0);// 标记页面为不可交换 -c0106c17: a1 1c c0 12 c0 mov 0xc012c01c,%eax -c0106c1c: 8b 40 10 mov 0x10(%eax),%eax -c0106c1f: 8b 55 e4 mov -0x1c(%ebp),%edx -c0106c22: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) -c0106c29: 00 -c0106c2a: 89 54 24 08 mov %edx,0x8(%esp) -c0106c2e: 8b 55 ec mov -0x14(%ebp),%edx -c0106c31: 89 54 24 04 mov %edx,0x4(%esp) -c0106c35: 8b 55 08 mov 0x8(%ebp),%edx -c0106c38: 89 14 24 mov %edx,(%esp) -c0106c3b: ff d0 call *%eax -c0106c3d: eb 64 jmp c0106ca3 +c01069da: a1 60 c1 12 c0 mov 0xc012c160,%eax +c01069df: 8b 40 10 mov 0x10(%eax),%eax +c01069e2: 8b 55 e4 mov -0x1c(%ebp),%edx +c01069e5: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) +c01069ec: 00 +c01069ed: 89 54 24 08 mov %edx,0x8(%esp) +c01069f1: 8b 55 ec mov -0x14(%ebp),%edx +c01069f4: 89 54 24 04 mov %edx,0x4(%esp) +c01069f8: 8b 55 08 mov 0x8(%ebp),%edx +c01069fb: 89 14 24 mov %edx,(%esp) +c01069fe: ff d0 call *%eax +c0106a00: eb 64 jmp c0106a66 continue; } else { cprintf("swap_out: i %d, store page in vaddr 0x%x to disk swap entry %d\n", i, v, page->pra_vaddr/PGSIZE+1); -c0106c3f: 8b 45 e4 mov -0x1c(%ebp),%eax -c0106c42: 8b 40 1c mov 0x1c(%eax),%eax -c0106c45: c1 e8 0c shr $0xc,%eax -c0106c48: 40 inc %eax -c0106c49: 89 44 24 0c mov %eax,0xc(%esp) -c0106c4d: 8b 45 ec mov -0x14(%ebp),%eax -c0106c50: 89 44 24 08 mov %eax,0x8(%esp) -c0106c54: 8b 45 f4 mov -0xc(%ebp),%eax -c0106c57: 89 44 24 04 mov %eax,0x4(%esp) -c0106c5b: c7 04 24 78 ba 10 c0 movl $0xc010ba78,(%esp) -c0106c62: e8 70 96 ff ff call c01002d7 +c0106a02: 8b 45 e4 mov -0x1c(%ebp),%eax +c0106a05: 8b 40 1c mov 0x1c(%eax),%eax +c0106a08: c1 e8 0c shr $0xc,%eax +c0106a0b: 40 inc %eax +c0106a0c: 89 44 24 0c mov %eax,0xc(%esp) +c0106a10: 8b 45 ec mov -0x14(%ebp),%eax +c0106a13: 89 44 24 08 mov %eax,0x8(%esp) +c0106a17: 8b 45 f4 mov -0xc(%ebp),%eax +c0106a1a: 89 44 24 04 mov %eax,0x4(%esp) +c0106a1e: c7 04 24 88 b5 10 c0 movl $0xc010b588,(%esp) +c0106a25: e8 4e 99 ff ff call c0100378 *ptep = (page->pra_vaddr/PGSIZE+1)<<8; // 更新页面表项,标记页面已交换到磁盘 -c0106c67: 8b 45 e4 mov -0x1c(%ebp),%eax -c0106c6a: 8b 40 1c mov 0x1c(%eax),%eax -c0106c6d: c1 e8 0c shr $0xc,%eax -c0106c70: 40 inc %eax -c0106c71: c1 e0 08 shl $0x8,%eax -c0106c74: 89 c2 mov %eax,%edx -c0106c76: 8b 45 e8 mov -0x18(%ebp),%eax -c0106c79: 89 10 mov %edx,(%eax) +c0106a2a: 8b 45 e4 mov -0x1c(%ebp),%eax +c0106a2d: 8b 40 1c mov 0x1c(%eax),%eax +c0106a30: c1 e8 0c shr $0xc,%eax +c0106a33: 40 inc %eax +c0106a34: c1 e0 08 shl $0x8,%eax +c0106a37: 89 c2 mov %eax,%edx +c0106a39: 8b 45 e8 mov -0x18(%ebp),%eax +c0106a3c: 89 10 mov %edx,(%eax) free_page(page); // 释放页面 -c0106c7b: 8b 45 e4 mov -0x1c(%ebp),%eax -c0106c7e: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0106c85: 00 -c0106c86: 89 04 24 mov %eax,(%esp) -c0106c89: e8 3a cb ff ff call c01037c8 +c0106a3e: 8b 45 e4 mov -0x1c(%ebp),%eax +c0106a41: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c0106a48: 00 +c0106a49: 89 04 24 mov %eax,(%esp) +c0106a4c: e8 f7 e5 ff ff call c0105048 } tlb_invalidate(mm->pgdir, v); // 使 TLB 中对应的条目失效 -c0106c8e: 8b 45 08 mov 0x8(%ebp),%eax -c0106c91: 8b 40 0c mov 0xc(%eax),%eax -c0106c94: 8b 55 ec mov -0x14(%ebp),%edx -c0106c97: 89 54 24 04 mov %edx,0x4(%esp) -c0106c9b: 89 04 24 mov %eax,(%esp) -c0106c9e: e8 88 d4 ff ff call c010412b +c0106a51: 8b 45 08 mov 0x8(%ebp),%eax +c0106a54: 8b 40 0c mov 0xc(%eax),%eax +c0106a57: 8b 55 ec mov -0x14(%ebp),%edx +c0106a5a: 89 54 24 04 mov %edx,0x4(%esp) +c0106a5e: 89 04 24 mov %eax,(%esp) +c0106a61: e8 2c ef ff ff call c0105992 for (i = 0; i != n; ++ i)// 循环 n 次,每次处理一个页面 -c0106ca3: ff 45 f4 incl -0xc(%ebp) -c0106ca6: 8b 45 f4 mov -0xc(%ebp),%eax -c0106ca9: 3b 45 0c cmp 0xc(%ebp),%eax -c0106cac: 0f 85 a1 fe ff ff jne c0106b53 +c0106a66: ff 45 f4 incl -0xc(%ebp) +c0106a69: 8b 45 f4 mov -0xc(%ebp),%eax +c0106a6c: 3b 45 0c cmp 0xc(%ebp),%eax +c0106a6f: 0f 85 a1 fe ff ff jne c0106916 } return i; // 返回实际交换出的页面数量 -c0106cb2: 8b 45 f4 mov -0xc(%ebp),%eax +c0106a75: 8b 45 f4 mov -0xc(%ebp),%eax } -c0106cb5: c9 leave -c0106cb6: c3 ret +c0106a78: 89 ec mov %ebp,%esp +c0106a7a: 5d pop %ebp +c0106a7b: c3 ret -c0106cb7 : +c0106a7c : //实现一个页交换功能。 int swap_in(struct mm_struct *mm, uintptr_t addr, struct Page **ptr_result) { -c0106cb7: f3 0f 1e fb endbr32 -c0106cbb: 55 push %ebp -c0106cbc: 89 e5 mov %esp,%ebp -c0106cbe: 83 ec 28 sub $0x28,%esp +c0106a7c: 55 push %ebp +c0106a7d: 89 e5 mov %esp,%ebp +c0106a7f: 83 ec 28 sub $0x28,%esp //分配一个新的页面result struct Page *result = alloc_page(); -c0106cc1: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0106cc8: e8 8c ca ff ff call c0103759 -c0106ccd: 89 45 f4 mov %eax,-0xc(%ebp) +c0106a82: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0106a89: e8 4d e5 ff ff call c0104fdb +c0106a8e: 89 45 f4 mov %eax,-0xc(%ebp) assert(result!=NULL); -c0106cd0: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0106cd4: 75 24 jne c0106cfa -c0106cd6: c7 44 24 0c b8 ba 10 movl $0xc010bab8,0xc(%esp) -c0106cdd: c0 -c0106cde: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0106ce5: c0 -c0106ce6: c7 44 24 04 b3 00 00 movl $0xb3,0x4(%esp) -c0106ced: 00 -c0106cee: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106cf5: e8 49 97 ff ff call c0100443 <__panic> +c0106a91: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0106a95: 75 24 jne c0106abb +c0106a97: c7 44 24 0c c8 b5 10 movl $0xc010b5c8,0xc(%esp) +c0106a9e: c0 +c0106a9f: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106aa6: c0 +c0106aa7: c7 44 24 04 b3 00 00 movl $0xb3,0x4(%esp) +c0106aae: 00 +c0106aaf: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106ab6: e8 8a a1 ff ff call c0100c45 <__panic> //获取虚拟地址 addr 对应的页表项指针 ptep pte_t *ptep = get_pte(mm->pgdir, addr, 0); -c0106cfa: 8b 45 08 mov 0x8(%ebp),%eax -c0106cfd: 8b 40 0c mov 0xc(%eax),%eax -c0106d00: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c0106d07: 00 -c0106d08: 8b 55 0c mov 0xc(%ebp),%edx -c0106d0b: 89 54 24 04 mov %edx,0x4(%esp) -c0106d0f: 89 04 24 mov %eax,(%esp) -c0106d12: e8 12 d1 ff ff call c0103e29 -c0106d17: 89 45 f0 mov %eax,-0x10(%ebp) +c0106abb: 8b 45 08 mov 0x8(%ebp),%eax +c0106abe: 8b 40 0c mov 0xc(%eax),%eax +c0106ac1: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c0106ac8: 00 +c0106ac9: 8b 55 0c mov 0xc(%ebp),%edx +c0106acc: 89 54 24 04 mov %edx,0x4(%esp) +c0106ad0: 89 04 24 mov %eax,(%esp) +c0106ad3: e8 be eb ff ff call c0105696 +c0106ad8: 89 45 f0 mov %eax,-0x10(%ebp) // cprintf("SWAP: load ptep %x swap entry %d to vaddr 0x%08x, page %x, No %d\n", ptep, (*ptep)>>8, addr, result, (result-pages)); int r; //从交换文件中读取数据到新分配的页面 result 中 if ((r = swapfs_read((*ptep), result)) != 0) -c0106d1a: 8b 45 f0 mov -0x10(%ebp),%eax -c0106d1d: 8b 00 mov (%eax),%eax -c0106d1f: 8b 55 f4 mov -0xc(%ebp),%edx -c0106d22: 89 54 24 04 mov %edx,0x4(%esp) -c0106d26: 89 04 24 mov %eax,(%esp) -c0106d29: e8 63 1b 00 00 call c0108891 -c0106d2e: 89 45 ec mov %eax,-0x14(%ebp) -c0106d31: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) -c0106d35: 74 2a je c0106d61 +c0106adb: 8b 45 f0 mov -0x10(%ebp),%eax +c0106ade: 8b 00 mov (%eax),%eax +c0106ae0: 8b 55 f4 mov -0xc(%ebp),%edx +c0106ae3: 89 54 24 04 mov %edx,0x4(%esp) +c0106ae7: 89 04 24 mov %eax,(%esp) +c0106aea: e8 fc 1b 00 00 call c01086eb +c0106aef: 89 45 ec mov %eax,-0x14(%ebp) +c0106af2: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) +c0106af6: 74 2a je c0106b22 { assert(r!=0); -c0106d37: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) -c0106d3b: 75 24 jne c0106d61 -c0106d3d: c7 44 24 0c c5 ba 10 movl $0xc010bac5,0xc(%esp) -c0106d44: c0 -c0106d45: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0106d4c: c0 -c0106d4d: c7 44 24 04 bc 00 00 movl $0xbc,0x4(%esp) -c0106d54: 00 -c0106d55: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106d5c: e8 e2 96 ff ff call c0100443 <__panic> +c0106af8: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) +c0106afc: 75 24 jne c0106b22 +c0106afe: c7 44 24 0c d5 b5 10 movl $0xc010b5d5,0xc(%esp) +c0106b05: c0 +c0106b06: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106b0d: c0 +c0106b0e: c7 44 24 04 bc 00 00 movl $0xbc,0x4(%esp) +c0106b15: 00 +c0106b16: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106b1d: e8 23 a1 ff ff call c0100c45 <__panic> } cprintf("swap_in: load disk swap entry %d with swap_page in vadr 0x%x\n", (*ptep)>>8, addr); -c0106d61: 8b 45 f0 mov -0x10(%ebp),%eax -c0106d64: 8b 00 mov (%eax),%eax -c0106d66: c1 e8 08 shr $0x8,%eax -c0106d69: 89 c2 mov %eax,%edx -c0106d6b: 8b 45 0c mov 0xc(%ebp),%eax -c0106d6e: 89 44 24 08 mov %eax,0x8(%esp) -c0106d72: 89 54 24 04 mov %edx,0x4(%esp) -c0106d76: c7 04 24 cc ba 10 c0 movl $0xc010bacc,(%esp) -c0106d7d: e8 55 95 ff ff call c01002d7 +c0106b22: 8b 45 f0 mov -0x10(%ebp),%eax +c0106b25: 8b 00 mov (%eax),%eax +c0106b27: c1 e8 08 shr $0x8,%eax +c0106b2a: 89 c2 mov %eax,%edx +c0106b2c: 8b 45 0c mov 0xc(%ebp),%eax +c0106b2f: 89 44 24 08 mov %eax,0x8(%esp) +c0106b33: 89 54 24 04 mov %edx,0x4(%esp) +c0106b37: c7 04 24 dc b5 10 c0 movl $0xc010b5dc,(%esp) +c0106b3e: e8 35 98 ff ff call c0100378 *ptr_result=result; -c0106d82: 8b 45 10 mov 0x10(%ebp),%eax -c0106d85: 8b 55 f4 mov -0xc(%ebp),%edx -c0106d88: 89 10 mov %edx,(%eax) +c0106b43: 8b 45 10 mov 0x10(%ebp),%eax +c0106b46: 8b 55 f4 mov -0xc(%ebp),%edx +c0106b49: 89 10 mov %edx,(%eax) return 0; -c0106d8a: b8 00 00 00 00 mov $0x0,%eax +c0106b4b: b8 00 00 00 00 mov $0x0,%eax } -c0106d8f: c9 leave -c0106d90: c3 ret +c0106b50: 89 ec mov %ebp,%esp +c0106b52: 5d pop %ebp +c0106b53: c3 ret -c0106d91 : +c0106b54 : * 通过向特定内存地址写入数据,并检查页面故障次数是否符合预期,来验证页面管理机制的正确性。 * 此函数没有输入参数和返回值。 */ static inline void check_content_set(void) { -c0106d91: 55 push %ebp -c0106d92: 89 e5 mov %esp,%ebp -c0106d94: 83 ec 18 sub $0x18,%esp +c0106b54: 55 push %ebp +c0106b55: 89 e5 mov %esp,%ebp +c0106b57: 83 ec 18 sub $0x18,%esp *(unsigned char *)0x1000 = 0x0a; -c0106d97: b8 00 10 00 00 mov $0x1000,%eax -c0106d9c: c6 00 0a movb $0xa,(%eax) +c0106b5a: b8 00 10 00 00 mov $0x1000,%eax +c0106b5f: c6 00 0a movb $0xa,(%eax) assert(pgfault_num==1); -c0106d9f: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0106da4: 83 f8 01 cmp $0x1,%eax -c0106da7: 74 24 je c0106dcd -c0106da9: c7 44 24 0c 0a bb 10 movl $0xc010bb0a,0xc(%esp) -c0106db0: c0 -c0106db1: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0106db8: c0 -c0106db9: c7 44 24 04 cd 00 00 movl $0xcd,0x4(%esp) -c0106dc0: 00 -c0106dc1: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106dc8: e8 76 96 ff ff call c0100443 <__panic> +c0106b62: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0106b67: 83 f8 01 cmp $0x1,%eax +c0106b6a: 74 24 je c0106b90 +c0106b6c: c7 44 24 0c 1a b6 10 movl $0xc010b61a,0xc(%esp) +c0106b73: c0 +c0106b74: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106b7b: c0 +c0106b7c: c7 44 24 04 cd 00 00 movl $0xcd,0x4(%esp) +c0106b83: 00 +c0106b84: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106b8b: e8 b5 a0 ff ff call c0100c45 <__panic> *(unsigned char *)0x1010 = 0x0a; -c0106dcd: b8 10 10 00 00 mov $0x1010,%eax -c0106dd2: c6 00 0a movb $0xa,(%eax) +c0106b90: b8 10 10 00 00 mov $0x1010,%eax +c0106b95: c6 00 0a movb $0xa,(%eax) assert(pgfault_num==1); -c0106dd5: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0106dda: 83 f8 01 cmp $0x1,%eax -c0106ddd: 74 24 je c0106e03 -c0106ddf: c7 44 24 0c 0a bb 10 movl $0xc010bb0a,0xc(%esp) -c0106de6: c0 -c0106de7: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0106dee: c0 -c0106def: c7 44 24 04 cf 00 00 movl $0xcf,0x4(%esp) -c0106df6: 00 -c0106df7: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106dfe: e8 40 96 ff ff call c0100443 <__panic> +c0106b98: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0106b9d: 83 f8 01 cmp $0x1,%eax +c0106ba0: 74 24 je c0106bc6 +c0106ba2: c7 44 24 0c 1a b6 10 movl $0xc010b61a,0xc(%esp) +c0106ba9: c0 +c0106baa: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106bb1: c0 +c0106bb2: c7 44 24 04 cf 00 00 movl $0xcf,0x4(%esp) +c0106bb9: 00 +c0106bba: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106bc1: e8 7f a0 ff ff call c0100c45 <__panic> *(unsigned char *)0x2000 = 0x0b; -c0106e03: b8 00 20 00 00 mov $0x2000,%eax -c0106e08: c6 00 0b movb $0xb,(%eax) +c0106bc6: b8 00 20 00 00 mov $0x2000,%eax +c0106bcb: c6 00 0b movb $0xb,(%eax) assert(pgfault_num==2); -c0106e0b: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0106e10: 83 f8 02 cmp $0x2,%eax -c0106e13: 74 24 je c0106e39 -c0106e15: c7 44 24 0c 19 bb 10 movl $0xc010bb19,0xc(%esp) -c0106e1c: c0 -c0106e1d: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0106e24: c0 -c0106e25: c7 44 24 04 d1 00 00 movl $0xd1,0x4(%esp) -c0106e2c: 00 -c0106e2d: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106e34: e8 0a 96 ff ff call c0100443 <__panic> +c0106bce: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0106bd3: 83 f8 02 cmp $0x2,%eax +c0106bd6: 74 24 je c0106bfc +c0106bd8: c7 44 24 0c 29 b6 10 movl $0xc010b629,0xc(%esp) +c0106bdf: c0 +c0106be0: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106be7: c0 +c0106be8: c7 44 24 04 d1 00 00 movl $0xd1,0x4(%esp) +c0106bef: 00 +c0106bf0: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106bf7: e8 49 a0 ff ff call c0100c45 <__panic> *(unsigned char *)0x2010 = 0x0b; -c0106e39: b8 10 20 00 00 mov $0x2010,%eax -c0106e3e: c6 00 0b movb $0xb,(%eax) +c0106bfc: b8 10 20 00 00 mov $0x2010,%eax +c0106c01: c6 00 0b movb $0xb,(%eax) assert(pgfault_num==2); -c0106e41: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0106e46: 83 f8 02 cmp $0x2,%eax -c0106e49: 74 24 je c0106e6f -c0106e4b: c7 44 24 0c 19 bb 10 movl $0xc010bb19,0xc(%esp) -c0106e52: c0 -c0106e53: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0106e5a: c0 -c0106e5b: c7 44 24 04 d3 00 00 movl $0xd3,0x4(%esp) -c0106e62: 00 -c0106e63: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106e6a: e8 d4 95 ff ff call c0100443 <__panic> +c0106c04: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0106c09: 83 f8 02 cmp $0x2,%eax +c0106c0c: 74 24 je c0106c32 +c0106c0e: c7 44 24 0c 29 b6 10 movl $0xc010b629,0xc(%esp) +c0106c15: c0 +c0106c16: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106c1d: c0 +c0106c1e: c7 44 24 04 d3 00 00 movl $0xd3,0x4(%esp) +c0106c25: 00 +c0106c26: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106c2d: e8 13 a0 ff ff call c0100c45 <__panic> *(unsigned char *)0x3000 = 0x0c; -c0106e6f: b8 00 30 00 00 mov $0x3000,%eax -c0106e74: c6 00 0c movb $0xc,(%eax) +c0106c32: b8 00 30 00 00 mov $0x3000,%eax +c0106c37: c6 00 0c movb $0xc,(%eax) assert(pgfault_num==3); -c0106e77: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0106e7c: 83 f8 03 cmp $0x3,%eax -c0106e7f: 74 24 je c0106ea5 -c0106e81: c7 44 24 0c 28 bb 10 movl $0xc010bb28,0xc(%esp) -c0106e88: c0 -c0106e89: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0106e90: c0 -c0106e91: c7 44 24 04 d5 00 00 movl $0xd5,0x4(%esp) -c0106e98: 00 -c0106e99: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106ea0: e8 9e 95 ff ff call c0100443 <__panic> +c0106c3a: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0106c3f: 83 f8 03 cmp $0x3,%eax +c0106c42: 74 24 je c0106c68 +c0106c44: c7 44 24 0c 38 b6 10 movl $0xc010b638,0xc(%esp) +c0106c4b: c0 +c0106c4c: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106c53: c0 +c0106c54: c7 44 24 04 d5 00 00 movl $0xd5,0x4(%esp) +c0106c5b: 00 +c0106c5c: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106c63: e8 dd 9f ff ff call c0100c45 <__panic> *(unsigned char *)0x3010 = 0x0c; -c0106ea5: b8 10 30 00 00 mov $0x3010,%eax -c0106eaa: c6 00 0c movb $0xc,(%eax) +c0106c68: b8 10 30 00 00 mov $0x3010,%eax +c0106c6d: c6 00 0c movb $0xc,(%eax) assert(pgfault_num==3); -c0106ead: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0106eb2: 83 f8 03 cmp $0x3,%eax -c0106eb5: 74 24 je c0106edb -c0106eb7: c7 44 24 0c 28 bb 10 movl $0xc010bb28,0xc(%esp) -c0106ebe: c0 -c0106ebf: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0106ec6: c0 -c0106ec7: c7 44 24 04 d7 00 00 movl $0xd7,0x4(%esp) -c0106ece: 00 -c0106ecf: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106ed6: e8 68 95 ff ff call c0100443 <__panic> +c0106c70: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0106c75: 83 f8 03 cmp $0x3,%eax +c0106c78: 74 24 je c0106c9e +c0106c7a: c7 44 24 0c 38 b6 10 movl $0xc010b638,0xc(%esp) +c0106c81: c0 +c0106c82: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106c89: c0 +c0106c8a: c7 44 24 04 d7 00 00 movl $0xd7,0x4(%esp) +c0106c91: 00 +c0106c92: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106c99: e8 a7 9f ff ff call c0100c45 <__panic> *(unsigned char *)0x4000 = 0x0d; -c0106edb: b8 00 40 00 00 mov $0x4000,%eax -c0106ee0: c6 00 0d movb $0xd,(%eax) +c0106c9e: b8 00 40 00 00 mov $0x4000,%eax +c0106ca3: c6 00 0d movb $0xd,(%eax) assert(pgfault_num==4); -c0106ee3: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0106ee8: 83 f8 04 cmp $0x4,%eax -c0106eeb: 74 24 je c0106f11 -c0106eed: c7 44 24 0c 37 bb 10 movl $0xc010bb37,0xc(%esp) -c0106ef4: c0 -c0106ef5: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0106efc: c0 -c0106efd: c7 44 24 04 d9 00 00 movl $0xd9,0x4(%esp) -c0106f04: 00 -c0106f05: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106f0c: e8 32 95 ff ff call c0100443 <__panic> +c0106ca6: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0106cab: 83 f8 04 cmp $0x4,%eax +c0106cae: 74 24 je c0106cd4 +c0106cb0: c7 44 24 0c 47 b6 10 movl $0xc010b647,0xc(%esp) +c0106cb7: c0 +c0106cb8: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106cbf: c0 +c0106cc0: c7 44 24 04 d9 00 00 movl $0xd9,0x4(%esp) +c0106cc7: 00 +c0106cc8: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106ccf: e8 71 9f ff ff call c0100c45 <__panic> *(unsigned char *)0x4010 = 0x0d; -c0106f11: b8 10 40 00 00 mov $0x4010,%eax -c0106f16: c6 00 0d movb $0xd,(%eax) +c0106cd4: b8 10 40 00 00 mov $0x4010,%eax +c0106cd9: c6 00 0d movb $0xd,(%eax) assert(pgfault_num==4); -c0106f19: a1 0c c0 12 c0 mov 0xc012c00c,%eax -c0106f1e: 83 f8 04 cmp $0x4,%eax -c0106f21: 74 24 je c0106f47 -c0106f23: c7 44 24 0c 37 bb 10 movl $0xc010bb37,0xc(%esp) -c0106f2a: c0 -c0106f2b: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0106f32: c0 -c0106f33: c7 44 24 04 db 00 00 movl $0xdb,0x4(%esp) -c0106f3a: 00 -c0106f3b: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106f42: e8 fc 94 ff ff call c0100443 <__panic> -} -c0106f47: 90 nop -c0106f48: c9 leave -c0106f49: c3 ret - -c0106f4a : +c0106cdc: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0106ce1: 83 f8 04 cmp $0x4,%eax +c0106ce4: 74 24 je c0106d0a +c0106ce6: c7 44 24 0c 47 b6 10 movl $0xc010b647,0xc(%esp) +c0106ced: c0 +c0106cee: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106cf5: c0 +c0106cf6: c7 44 24 04 db 00 00 movl $0xdb,0x4(%esp) +c0106cfd: 00 +c0106cfe: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106d05: e8 3b 9f ff ff call c0100c45 <__panic> +} +c0106d0a: 90 nop +c0106d0b: 89 ec mov %ebp,%esp +c0106d0d: 5d pop %ebp +c0106d0e: c3 ret + +c0106d0f : * * @return int 返回权限检查的结果,非零表示成功,零表示失败 */ static inline int check_content_access(void) { -c0106f4a: 55 push %ebp -c0106f4b: 89 e5 mov %esp,%ebp -c0106f4d: 83 ec 18 sub $0x18,%esp +c0106d0f: 55 push %ebp +c0106d10: 89 e5 mov %esp,%ebp +c0106d12: 83 ec 18 sub $0x18,%esp // 调用swap管理器的检查方法,并将结果返回 int ret = sm->check_swap(); -c0106f50: a1 1c c0 12 c0 mov 0xc012c01c,%eax -c0106f55: 8b 40 1c mov 0x1c(%eax),%eax -c0106f58: ff d0 call *%eax -c0106f5a: 89 45 f4 mov %eax,-0xc(%ebp) +c0106d15: a1 60 c1 12 c0 mov 0xc012c160,%eax +c0106d1a: 8b 40 1c mov 0x1c(%eax),%eax +c0106d1d: ff d0 call *%eax +c0106d1f: 89 45 f4 mov %eax,-0xc(%ebp) return ret; -c0106f5d: 8b 45 f4 mov -0xc(%ebp),%eax +c0106d22: 8b 45 f4 mov -0xc(%ebp),%eax } -c0106f60: c9 leave -c0106f61: c3 ret +c0106d25: 89 ec mov %ebp,%esp +c0106d27: 5d pop %ebp +c0106d28: c3 ret -c0106f62 : +c0106d29 : #define nr_free (free_area.nr_free) // 检查交换机制的正确性,通过模拟页面替换算法 static void check_swap(void) { -c0106f62: f3 0f 1e fb endbr32 -c0106f66: 55 push %ebp -c0106f67: 89 e5 mov %esp,%ebp -c0106f69: 83 ec 78 sub $0x78,%esp +c0106d29: 55 push %ebp +c0106d2a: 89 e5 mov %esp,%ebp +c0106d2c: 83 ec 78 sub $0x78,%esp //backup mem env// 备份内存环境,确保检查后没有页面丢失 int ret, count = 0, total = 0, i; -c0106f6c: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -c0106f73: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) +c0106d2f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c0106d36: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) list_entry_t *le = &free_list; -c0106f7a: c7 45 e8 a4 e1 12 c0 movl $0xc012e1a4,-0x18(%ebp) +c0106d3d: c7 45 e8 e4 bf 12 c0 movl $0xc012bfe4,-0x18(%ebp) while ((le = list_next(le)) != &free_list) { -c0106f81: eb 6a jmp c0106fed +c0106d44: eb 6a jmp c0106db0 struct Page *p = le2page(le, page_link);// 将链表条目转换为页面结构 -c0106f83: 8b 45 e8 mov -0x18(%ebp),%eax -c0106f86: 83 e8 0c sub $0xc,%eax -c0106f89: 89 45 c8 mov %eax,-0x38(%ebp) +c0106d46: 8b 45 e8 mov -0x18(%ebp),%eax +c0106d49: 83 e8 0c sub $0xc,%eax +c0106d4c: 89 45 c8 mov %eax,-0x38(%ebp) assert(PageProperty(p));// 断言页面属性有效 -c0106f8c: 8b 45 c8 mov -0x38(%ebp),%eax -c0106f8f: 83 c0 04 add $0x4,%eax -c0106f92: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) -c0106f99: 89 45 c0 mov %eax,-0x40(%ebp) - * @addr: the address to count from - * */ -static inline bool -test_bit(int nr, volatile void *addr) { - int oldbit; +c0106d4f: 8b 45 c8 mov -0x38(%ebp),%eax +c0106d52: 83 c0 04 add $0x4,%eax +c0106d55: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) +c0106d5c: 89 45 c0 mov %eax,-0x40(%ebp) asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); -c0106f9c: 8b 45 c0 mov -0x40(%ebp),%eax -c0106f9f: 8b 55 c4 mov -0x3c(%ebp),%edx -c0106fa2: 0f a3 10 bt %edx,(%eax) -c0106fa5: 19 c0 sbb %eax,%eax -c0106fa7: 89 45 bc mov %eax,-0x44(%ebp) +c0106d5f: 8b 45 c0 mov -0x40(%ebp),%eax +c0106d62: 8b 55 c4 mov -0x3c(%ebp),%edx +c0106d65: 0f a3 10 bt %edx,(%eax) +c0106d68: 19 c0 sbb %eax,%eax +c0106d6a: 89 45 bc mov %eax,-0x44(%ebp) return oldbit != 0; -c0106faa: 83 7d bc 00 cmpl $0x0,-0x44(%ebp) -c0106fae: 0f 95 c0 setne %al -c0106fb1: 0f b6 c0 movzbl %al,%eax -c0106fb4: 85 c0 test %eax,%eax -c0106fb6: 75 24 jne c0106fdc -c0106fb8: c7 44 24 0c 46 bb 10 movl $0xc010bb46,0xc(%esp) -c0106fbf: c0 -c0106fc0: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0106fc7: c0 -c0106fc8: c7 44 24 04 00 01 00 movl $0x100,0x4(%esp) -c0106fcf: 00 -c0106fd0: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0106fd7: e8 67 94 ff ff call c0100443 <__panic> +c0106d6d: 83 7d bc 00 cmpl $0x0,-0x44(%ebp) +c0106d71: 0f 95 c0 setne %al +c0106d74: 0f b6 c0 movzbl %al,%eax +c0106d77: 85 c0 test %eax,%eax +c0106d79: 75 24 jne c0106d9f +c0106d7b: c7 44 24 0c 56 b6 10 movl $0xc010b656,0xc(%esp) +c0106d82: c0 +c0106d83: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106d8a: c0 +c0106d8b: c7 44 24 04 00 01 00 movl $0x100,0x4(%esp) +c0106d92: 00 +c0106d93: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106d9a: e8 a6 9e ff ff call c0100c45 <__panic> count ++, total += p->property;// 统计页面数量和属性总和 -c0106fdc: ff 45 f4 incl -0xc(%ebp) -c0106fdf: 8b 45 c8 mov -0x38(%ebp),%eax -c0106fe2: 8b 50 08 mov 0x8(%eax),%edx -c0106fe5: 8b 45 f0 mov -0x10(%ebp),%eax -c0106fe8: 01 d0 add %edx,%eax -c0106fea: 89 45 f0 mov %eax,-0x10(%ebp) -c0106fed: 8b 45 e8 mov -0x18(%ebp),%eax -c0106ff0: 89 45 b8 mov %eax,-0x48(%ebp) -c0106ff3: 8b 45 b8 mov -0x48(%ebp),%eax -c0106ff6: 8b 40 04 mov 0x4(%eax),%eax +c0106d9f: ff 45 f4 incl -0xc(%ebp) +c0106da2: 8b 45 c8 mov -0x38(%ebp),%eax +c0106da5: 8b 50 08 mov 0x8(%eax),%edx +c0106da8: 8b 45 f0 mov -0x10(%ebp),%eax +c0106dab: 01 d0 add %edx,%eax +c0106dad: 89 45 f0 mov %eax,-0x10(%ebp) +c0106db0: 8b 45 e8 mov -0x18(%ebp),%eax +c0106db3: 89 45 b8 mov %eax,-0x48(%ebp) +c0106db6: 8b 45 b8 mov -0x48(%ebp),%eax +c0106db9: 8b 40 04 mov 0x4(%eax),%eax while ((le = list_next(le)) != &free_list) { -c0106ff9: 89 45 e8 mov %eax,-0x18(%ebp) -c0106ffc: 81 7d e8 a4 e1 12 c0 cmpl $0xc012e1a4,-0x18(%ebp) -c0107003: 0f 85 7a ff ff ff jne c0106f83 +c0106dbc: 89 45 e8 mov %eax,-0x18(%ebp) +c0106dbf: 81 7d e8 e4 bf 12 c0 cmpl $0xc012bfe4,-0x18(%ebp) +c0106dc6: 0f 85 7a ff ff ff jne c0106d46 } assert(total == nr_free_pages());// 断言统计的属性总和与空闲页面数一致 -c0107009: e8 f1 c7 ff ff call c01037ff -c010700e: 8b 55 f0 mov -0x10(%ebp),%edx -c0107011: 39 d0 cmp %edx,%eax -c0107013: 74 24 je c0107039 -c0107015: c7 44 24 0c 56 bb 10 movl $0xc010bb56,0xc(%esp) -c010701c: c0 -c010701d: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0107024: c0 -c0107025: c7 44 24 04 03 01 00 movl $0x103,0x4(%esp) -c010702c: 00 -c010702d: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0107034: e8 0a 94 ff ff call c0100443 <__panic> +c0106dcc: e8 ac e2 ff ff call c010507d +c0106dd1: 8b 55 f0 mov -0x10(%ebp),%edx +c0106dd4: 39 d0 cmp %edx,%eax +c0106dd6: 74 24 je c0106dfc +c0106dd8: c7 44 24 0c 66 b6 10 movl $0xc010b666,0xc(%esp) +c0106ddf: c0 +c0106de0: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106de7: c0 +c0106de8: c7 44 24 04 03 01 00 movl $0x103,0x4(%esp) +c0106def: 00 +c0106df0: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106df7: e8 49 9e ff ff call c0100c45 <__panic> cprintf("BEGIN check_swap: count %d, total %d\n",count,total);// 打印初始状态 -c0107039: 8b 45 f0 mov -0x10(%ebp),%eax -c010703c: 89 44 24 08 mov %eax,0x8(%esp) -c0107040: 8b 45 f4 mov -0xc(%ebp),%eax -c0107043: 89 44 24 04 mov %eax,0x4(%esp) -c0107047: c7 04 24 70 bb 10 c0 movl $0xc010bb70,(%esp) -c010704e: e8 84 92 ff ff call c01002d7 +c0106dfc: 8b 45 f0 mov -0x10(%ebp),%eax +c0106dff: 89 44 24 08 mov %eax,0x8(%esp) +c0106e03: 8b 45 f4 mov -0xc(%ebp),%eax +c0106e06: 89 44 24 04 mov %eax,0x4(%esp) +c0106e0a: c7 04 24 80 b6 10 c0 movl $0xc010b680,(%esp) +c0106e11: e8 62 95 ff ff call c0100378 //now we set the phy pages env // 设置物理页面环境 struct mm_struct *mm = mm_create();// 创建内存管理结构 -c0107053: e8 88 e4 ff ff call c01054e0 -c0107058: 89 45 e4 mov %eax,-0x1c(%ebp) +c0106e16: e8 1e 0b 00 00 call c0107939 +c0106e1b: 89 45 e4 mov %eax,-0x1c(%ebp) assert(mm != NULL); // 断言内存管理结构创建成功 -c010705b: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) -c010705f: 75 24 jne c0107085 -c0107061: c7 44 24 0c 96 bb 10 movl $0xc010bb96,0xc(%esp) -c0107068: c0 -c0107069: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0107070: c0 -c0107071: c7 44 24 04 08 01 00 movl $0x108,0x4(%esp) -c0107078: 00 -c0107079: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0107080: e8 be 93 ff ff call c0100443 <__panic> +c0106e1e: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) +c0106e22: 75 24 jne c0106e48 +c0106e24: c7 44 24 0c a6 b6 10 movl $0xc010b6a6,0xc(%esp) +c0106e2b: c0 +c0106e2c: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106e33: c0 +c0106e34: c7 44 24 04 08 01 00 movl $0x108,0x4(%esp) +c0106e3b: 00 +c0106e3c: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106e43: e8 fd 9d ff ff call c0100c45 <__panic> extern struct mm_struct *check_mm_struct;// 声明外部变量 assert(check_mm_struct == NULL);// 断言外部变量为空 -c0107085: a1 c4 e0 12 c0 mov 0xc012e0c4,%eax -c010708a: 85 c0 test %eax,%eax -c010708c: 74 24 je c01070b2 -c010708e: c7 44 24 0c a1 bb 10 movl $0xc010bba1,0xc(%esp) -c0107095: c0 -c0107096: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c010709d: c0 -c010709e: c7 44 24 04 0b 01 00 movl $0x10b,0x4(%esp) -c01070a5: 00 -c01070a6: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c01070ad: e8 91 93 ff ff call c0100443 <__panic> +c0106e48: a1 6c c1 12 c0 mov 0xc012c16c,%eax +c0106e4d: 85 c0 test %eax,%eax +c0106e4f: 74 24 je c0106e75 +c0106e51: c7 44 24 0c b1 b6 10 movl $0xc010b6b1,0xc(%esp) +c0106e58: c0 +c0106e59: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106e60: c0 +c0106e61: c7 44 24 04 0b 01 00 movl $0x10b,0x4(%esp) +c0106e68: 00 +c0106e69: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106e70: e8 d0 9d ff ff call c0100c45 <__panic> // 将新创建的内存管理结构赋值给外部变量 check_mm_struct = mm; -c01070b2: 8b 45 e4 mov -0x1c(%ebp),%eax -c01070b5: a3 c4 e0 12 c0 mov %eax,0xc012e0c4 +c0106e75: 8b 45 e4 mov -0x1c(%ebp),%eax +c0106e78: a3 6c c1 12 c0 mov %eax,0xc012c16c pde_t *pgdir = mm->pgdir = boot_pgdir;// 设置页目录 -c01070ba: 8b 15 e0 89 12 c0 mov 0xc01289e0,%edx -c01070c0: 8b 45 e4 mov -0x1c(%ebp),%eax -c01070c3: 89 50 0c mov %edx,0xc(%eax) -c01070c6: 8b 45 e4 mov -0x1c(%ebp),%eax -c01070c9: 8b 40 0c mov 0xc(%eax),%eax -c01070cc: 89 45 e0 mov %eax,-0x20(%ebp) +c0106e7d: 8b 15 00 8a 12 c0 mov 0xc0128a00,%edx +c0106e83: 8b 45 e4 mov -0x1c(%ebp),%eax +c0106e86: 89 50 0c mov %edx,0xc(%eax) +c0106e89: 8b 45 e4 mov -0x1c(%ebp),%eax +c0106e8c: 8b 40 0c mov 0xc(%eax),%eax +c0106e8f: 89 45 e0 mov %eax,-0x20(%ebp) assert(pgdir[0] == 0);// 断言页目录的第一个条目为空 -c01070cf: 8b 45 e0 mov -0x20(%ebp),%eax -c01070d2: 8b 00 mov (%eax),%eax -c01070d4: 85 c0 test %eax,%eax -c01070d6: 74 24 je c01070fc -c01070d8: c7 44 24 0c b9 bb 10 movl $0xc010bbb9,0xc(%esp) -c01070df: c0 -c01070e0: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c01070e7: c0 -c01070e8: c7 44 24 04 11 01 00 movl $0x111,0x4(%esp) -c01070ef: 00 -c01070f0: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c01070f7: e8 47 93 ff ff call c0100443 <__panic> +c0106e92: 8b 45 e0 mov -0x20(%ebp),%eax +c0106e95: 8b 00 mov (%eax),%eax +c0106e97: 85 c0 test %eax,%eax +c0106e99: 74 24 je c0106ebf +c0106e9b: c7 44 24 0c c9 b6 10 movl $0xc010b6c9,0xc(%esp) +c0106ea2: c0 +c0106ea3: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106eaa: c0 +c0106eab: c7 44 24 04 11 01 00 movl $0x111,0x4(%esp) +c0106eb2: 00 +c0106eb3: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106eba: e8 86 9d ff ff call c0100c45 <__panic> // 创建虚拟内存区域 struct vma_struct *vma = vma_create(BEING_CHECK_VALID_VADDR, CHECK_VALID_VADDR, VM_WRITE | VM_READ); -c01070fc: c7 44 24 08 03 00 00 movl $0x3,0x8(%esp) -c0107103: 00 -c0107104: c7 44 24 04 00 60 00 movl $0x6000,0x4(%esp) -c010710b: 00 -c010710c: c7 04 24 00 10 00 00 movl $0x1000,(%esp) -c0107113: e8 45 e4 ff ff call c010555d -c0107118: 89 45 dc mov %eax,-0x24(%ebp) +c0106ebf: c7 44 24 08 03 00 00 movl $0x3,0x8(%esp) +c0106ec6: 00 +c0106ec7: c7 44 24 04 00 60 00 movl $0x6000,0x4(%esp) +c0106ece: 00 +c0106ecf: c7 04 24 00 10 00 00 movl $0x1000,(%esp) +c0106ed6: e8 d9 0a 00 00 call c01079b4 +c0106edb: 89 45 dc mov %eax,-0x24(%ebp) assert(vma != NULL);// 断言虚拟内存区域创建成功 -c010711b: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) -c010711f: 75 24 jne c0107145 -c0107121: c7 44 24 0c c7 bb 10 movl $0xc010bbc7,0xc(%esp) -c0107128: c0 -c0107129: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0107130: c0 -c0107131: c7 44 24 04 15 01 00 movl $0x115,0x4(%esp) -c0107138: 00 -c0107139: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0107140: e8 fe 92 ff ff call c0100443 <__panic> +c0106ede: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) +c0106ee2: 75 24 jne c0106f08 +c0106ee4: c7 44 24 0c d7 b6 10 movl $0xc010b6d7,0xc(%esp) +c0106eeb: c0 +c0106eec: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106ef3: c0 +c0106ef4: c7 44 24 04 15 01 00 movl $0x115,0x4(%esp) +c0106efb: 00 +c0106efc: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106f03: e8 3d 9d ff ff call c0100c45 <__panic> // 插入虚拟内存区域到内存管理结构 insert_vma_struct(mm, vma); -c0107145: 8b 45 dc mov -0x24(%ebp),%eax -c0107148: 89 44 24 04 mov %eax,0x4(%esp) -c010714c: 8b 45 e4 mov -0x1c(%ebp),%eax -c010714f: 89 04 24 mov %eax,(%esp) -c0107152: e8 9f e5 ff ff call c01056f6 +c0106f08: 8b 45 dc mov -0x24(%ebp),%eax +c0106f0b: 89 44 24 04 mov %eax,0x4(%esp) +c0106f0f: 8b 45 e4 mov -0x1c(%ebp),%eax +c0106f12: 89 04 24 mov %eax,(%esp) +c0106f15: e8 31 0c 00 00 call c0107b4b //setup the temp Page Table vaddr 0~4MB/ 设置临时页表,用于虚拟地址 0~4MB cprintf("setup Page Table for vaddr 0X1000, so alloc a page\n");// 打印设置页表的信息 -c0107157: c7 04 24 d4 bb 10 c0 movl $0xc010bbd4,(%esp) -c010715e: e8 74 91 ff ff call c01002d7 +c0106f1a: c7 04 24 e4 b6 10 c0 movl $0xc010b6e4,(%esp) +c0106f21: e8 52 94 ff ff call c0100378 pte_t *temp_ptep=NULL; -c0107163: c7 45 d8 00 00 00 00 movl $0x0,-0x28(%ebp) +c0106f26: c7 45 d8 00 00 00 00 movl $0x0,-0x28(%ebp) temp_ptep = get_pte(mm->pgdir, BEING_CHECK_VALID_VADDR, 1);// 获取页表项 -c010716a: 8b 45 e4 mov -0x1c(%ebp),%eax -c010716d: 8b 40 0c mov 0xc(%eax),%eax -c0107170: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) -c0107177: 00 -c0107178: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) -c010717f: 00 -c0107180: 89 04 24 mov %eax,(%esp) -c0107183: e8 a1 cc ff ff call c0103e29 -c0107188: 89 45 d8 mov %eax,-0x28(%ebp) +c0106f2d: 8b 45 e4 mov -0x1c(%ebp),%eax +c0106f30: 8b 40 0c mov 0xc(%eax),%eax +c0106f33: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) +c0106f3a: 00 +c0106f3b: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) +c0106f42: 00 +c0106f43: 89 04 24 mov %eax,(%esp) +c0106f46: e8 4b e7 ff ff call c0105696 +c0106f4b: 89 45 d8 mov %eax,-0x28(%ebp) assert(temp_ptep!= NULL);// 断言获取页表项成功 -c010718b: 83 7d d8 00 cmpl $0x0,-0x28(%ebp) -c010718f: 75 24 jne c01071b5 -c0107191: c7 44 24 0c 08 bc 10 movl $0xc010bc08,0xc(%esp) -c0107198: c0 -c0107199: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c01071a0: c0 -c01071a1: c7 44 24 04 1e 01 00 movl $0x11e,0x4(%esp) -c01071a8: 00 -c01071a9: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c01071b0: e8 8e 92 ff ff call c0100443 <__panic> +c0106f4e: 83 7d d8 00 cmpl $0x0,-0x28(%ebp) +c0106f52: 75 24 jne c0106f78 +c0106f54: c7 44 24 0c 18 b7 10 movl $0xc010b718,0xc(%esp) +c0106f5b: c0 +c0106f5c: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106f63: c0 +c0106f64: c7 44 24 04 1e 01 00 movl $0x11e,0x4(%esp) +c0106f6b: 00 +c0106f6c: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106f73: e8 cd 9c ff ff call c0100c45 <__panic> cprintf("setup Page Table vaddr 0~4MB OVER!\n");// 打印设置页表完成的信息 -c01071b5: c7 04 24 1c bc 10 c0 movl $0xc010bc1c,(%esp) -c01071bc: e8 16 91 ff ff call c01002d7 +c0106f78: c7 04 24 2c b7 10 c0 movl $0xc010b72c,(%esp) +c0106f7f: e8 f4 93 ff ff call c0100378 for (i=0;i +c0106f84: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) +c0106f8b: e9 a2 00 00 00 jmp c0107032 check_rp[i] = alloc_page();// 分配页面 -c01071cd: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c01071d4: e8 80 c5 ff ff call c0103759 -c01071d9: 8b 55 ec mov -0x14(%ebp),%edx -c01071dc: 89 04 95 e0 e0 12 c0 mov %eax,-0x3fed1f20(,%edx,4) +c0106f90: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0106f97: e8 3f e0 ff ff call c0104fdb +c0106f9c: 8b 55 ec mov -0x14(%ebp),%edx +c0106f9f: 89 04 95 2c c1 12 c0 mov %eax,-0x3fed3ed4(,%edx,4) assert(check_rp[i] != NULL );// 断言分配页面成功 -c01071e3: 8b 45 ec mov -0x14(%ebp),%eax -c01071e6: 8b 04 85 e0 e0 12 c0 mov -0x3fed1f20(,%eax,4),%eax -c01071ed: 85 c0 test %eax,%eax -c01071ef: 75 24 jne c0107215 -c01071f1: c7 44 24 0c 40 bc 10 movl $0xc010bc40,0xc(%esp) -c01071f8: c0 -c01071f9: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0107200: c0 -c0107201: c7 44 24 04 23 01 00 movl $0x123,0x4(%esp) -c0107208: 00 -c0107209: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0107210: e8 2e 92 ff ff call c0100443 <__panic> +c0106fa6: 8b 45 ec mov -0x14(%ebp),%eax +c0106fa9: 8b 04 85 2c c1 12 c0 mov -0x3fed3ed4(,%eax,4),%eax +c0106fb0: 85 c0 test %eax,%eax +c0106fb2: 75 24 jne c0106fd8 +c0106fb4: c7 44 24 0c 50 b7 10 movl $0xc010b750,0xc(%esp) +c0106fbb: c0 +c0106fbc: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0106fc3: c0 +c0106fc4: c7 44 24 04 23 01 00 movl $0x123,0x4(%esp) +c0106fcb: 00 +c0106fcc: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0106fd3: e8 6d 9c ff ff call c0100c45 <__panic> assert(!PageProperty(check_rp[i]));// 断言页面属性无效 -c0107215: 8b 45 ec mov -0x14(%ebp),%eax -c0107218: 8b 04 85 e0 e0 12 c0 mov -0x3fed1f20(,%eax,4),%eax -c010721f: 83 c0 04 add $0x4,%eax -c0107222: c7 45 b4 01 00 00 00 movl $0x1,-0x4c(%ebp) -c0107229: 89 45 b0 mov %eax,-0x50(%ebp) +c0106fd8: 8b 45 ec mov -0x14(%ebp),%eax +c0106fdb: 8b 04 85 2c c1 12 c0 mov -0x3fed3ed4(,%eax,4),%eax +c0106fe2: 83 c0 04 add $0x4,%eax +c0106fe5: c7 45 b4 01 00 00 00 movl $0x1,-0x4c(%ebp) +c0106fec: 89 45 b0 mov %eax,-0x50(%ebp) asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); -c010722c: 8b 45 b0 mov -0x50(%ebp),%eax -c010722f: 8b 55 b4 mov -0x4c(%ebp),%edx -c0107232: 0f a3 10 bt %edx,(%eax) -c0107235: 19 c0 sbb %eax,%eax -c0107237: 89 45 ac mov %eax,-0x54(%ebp) +c0106fef: 8b 45 b0 mov -0x50(%ebp),%eax +c0106ff2: 8b 55 b4 mov -0x4c(%ebp),%edx +c0106ff5: 0f a3 10 bt %edx,(%eax) +c0106ff8: 19 c0 sbb %eax,%eax +c0106ffa: 89 45 ac mov %eax,-0x54(%ebp) return oldbit != 0; -c010723a: 83 7d ac 00 cmpl $0x0,-0x54(%ebp) -c010723e: 0f 95 c0 setne %al -c0107241: 0f b6 c0 movzbl %al,%eax -c0107244: 85 c0 test %eax,%eax -c0107246: 74 24 je c010726c -c0107248: c7 44 24 0c 54 bc 10 movl $0xc010bc54,0xc(%esp) -c010724f: c0 -c0107250: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0107257: c0 -c0107258: c7 44 24 04 24 01 00 movl $0x124,0x4(%esp) -c010725f: 00 -c0107260: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0107267: e8 d7 91 ff ff call c0100443 <__panic> +c0106ffd: 83 7d ac 00 cmpl $0x0,-0x54(%ebp) +c0107001: 0f 95 c0 setne %al +c0107004: 0f b6 c0 movzbl %al,%eax +c0107007: 85 c0 test %eax,%eax +c0107009: 74 24 je c010702f +c010700b: c7 44 24 0c 64 b7 10 movl $0xc010b764,0xc(%esp) +c0107012: c0 +c0107013: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c010701a: c0 +c010701b: c7 44 24 04 24 01 00 movl $0x124,0x4(%esp) +c0107022: 00 +c0107023: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c010702a: e8 16 9c ff ff call c0100c45 <__panic> for (i=0;i +c010702f: ff 45 ec incl -0x14(%ebp) +c0107032: 83 7d ec 03 cmpl $0x3,-0x14(%ebp) +c0107036: 0f 8e 54 ff ff ff jle c0106f90 } list_entry_t free_list_store = free_list;// 保存当前空闲列表 -c0107279: a1 a4 e1 12 c0 mov 0xc012e1a4,%eax -c010727e: 8b 15 a8 e1 12 c0 mov 0xc012e1a8,%edx -c0107284: 89 45 98 mov %eax,-0x68(%ebp) -c0107287: 89 55 9c mov %edx,-0x64(%ebp) -c010728a: c7 45 a4 a4 e1 12 c0 movl $0xc012e1a4,-0x5c(%ebp) +c010703c: a1 e4 bf 12 c0 mov 0xc012bfe4,%eax +c0107041: 8b 15 e8 bf 12 c0 mov 0xc012bfe8,%edx +c0107047: 89 45 98 mov %eax,-0x68(%ebp) +c010704a: 89 55 9c mov %edx,-0x64(%ebp) +c010704d: c7 45 a4 e4 bf 12 c0 movl $0xc012bfe4,-0x5c(%ebp) elm->prev = elm->next = elm; -c0107291: 8b 45 a4 mov -0x5c(%ebp),%eax -c0107294: 8b 55 a4 mov -0x5c(%ebp),%edx -c0107297: 89 50 04 mov %edx,0x4(%eax) -c010729a: 8b 45 a4 mov -0x5c(%ebp),%eax -c010729d: 8b 50 04 mov 0x4(%eax),%edx -c01072a0: 8b 45 a4 mov -0x5c(%ebp),%eax -c01072a3: 89 10 mov %edx,(%eax) -} -c01072a5: 90 nop -c01072a6: c7 45 a8 a4 e1 12 c0 movl $0xc012e1a4,-0x58(%ebp) +c0107054: 8b 45 a4 mov -0x5c(%ebp),%eax +c0107057: 8b 55 a4 mov -0x5c(%ebp),%edx +c010705a: 89 50 04 mov %edx,0x4(%eax) +c010705d: 8b 45 a4 mov -0x5c(%ebp),%eax +c0107060: 8b 50 04 mov 0x4(%eax),%edx +c0107063: 8b 45 a4 mov -0x5c(%ebp),%eax +c0107066: 89 10 mov %edx,(%eax) +} +c0107068: 90 nop +c0107069: c7 45 a8 e4 bf 12 c0 movl $0xc012bfe4,-0x58(%ebp) return list->next == list; -c01072ad: 8b 45 a8 mov -0x58(%ebp),%eax -c01072b0: 8b 40 04 mov 0x4(%eax),%eax -c01072b3: 39 45 a8 cmp %eax,-0x58(%ebp) -c01072b6: 0f 94 c0 sete %al -c01072b9: 0f b6 c0 movzbl %al,%eax +c0107070: 8b 45 a8 mov -0x58(%ebp),%eax +c0107073: 8b 40 04 mov 0x4(%eax),%eax +c0107076: 39 45 a8 cmp %eax,-0x58(%ebp) +c0107079: 0f 94 c0 sete %al +c010707c: 0f b6 c0 movzbl %al,%eax list_init(&free_list);// 初始化空闲列表 assert(list_empty(&free_list));// 断言空闲列表为空 -c01072bc: 85 c0 test %eax,%eax -c01072be: 75 24 jne c01072e4 -c01072c0: c7 44 24 0c 6f bc 10 movl $0xc010bc6f,0xc(%esp) -c01072c7: c0 -c01072c8: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c01072cf: c0 -c01072d0: c7 44 24 04 28 01 00 movl $0x128,0x4(%esp) -c01072d7: 00 -c01072d8: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c01072df: e8 5f 91 ff ff call c0100443 <__panic> +c010707f: 85 c0 test %eax,%eax +c0107081: 75 24 jne c01070a7 +c0107083: c7 44 24 0c 7f b7 10 movl $0xc010b77f,0xc(%esp) +c010708a: c0 +c010708b: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0107092: c0 +c0107093: c7 44 24 04 28 01 00 movl $0x128,0x4(%esp) +c010709a: 00 +c010709b: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c01070a2: e8 9e 9b ff ff call c0100c45 <__panic> //assert(alloc_page() == NULL); unsigned int nr_free_store = nr_free;// 保存当前空闲页面数 -c01072e4: a1 ac e1 12 c0 mov 0xc012e1ac,%eax -c01072e9: 89 45 d4 mov %eax,-0x2c(%ebp) +c01070a7: a1 ec bf 12 c0 mov 0xc012bfec,%eax +c01070ac: 89 45 d4 mov %eax,-0x2c(%ebp) nr_free = 0;// 将空闲页面数设为 0 -c01072ec: c7 05 ac e1 12 c0 00 movl $0x0,0xc012e1ac -c01072f3: 00 00 00 +c01070af: c7 05 ec bf 12 c0 00 movl $0x0,0xc012bfec +c01070b6: 00 00 00 for (i=0;i +c01070b9: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) +c01070c0: eb 1d jmp c01070df free_pages(check_rp[i],1);// 释放页面 -c01072ff: 8b 45 ec mov -0x14(%ebp),%eax -c0107302: 8b 04 85 e0 e0 12 c0 mov -0x3fed1f20(,%eax,4),%eax -c0107309: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0107310: 00 -c0107311: 89 04 24 mov %eax,(%esp) -c0107314: e8 af c4 ff ff call c01037c8 +c01070c2: 8b 45 ec mov -0x14(%ebp),%eax +c01070c5: 8b 04 85 2c c1 12 c0 mov -0x3fed3ed4(,%eax,4),%eax +c01070cc: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c01070d3: 00 +c01070d4: 89 04 24 mov %eax,(%esp) +c01070d7: e8 6c df ff ff call c0105048 for (i=0;i +c01070dc: ff 45 ec incl -0x14(%ebp) +c01070df: 83 7d ec 03 cmpl $0x3,-0x14(%ebp) +c01070e3: 7e dd jle c01070c2 } assert(nr_free==CHECK_VALID_PHY_PAGE_NUM);// 断言释放的页面数正确 -c0107322: a1 ac e1 12 c0 mov 0xc012e1ac,%eax -c0107327: 83 f8 04 cmp $0x4,%eax -c010732a: 74 24 je c0107350 -c010732c: c7 44 24 0c 88 bc 10 movl $0xc010bc88,0xc(%esp) -c0107333: c0 -c0107334: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c010733b: c0 -c010733c: c7 44 24 04 31 01 00 movl $0x131,0x4(%esp) -c0107343: 00 -c0107344: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c010734b: e8 f3 90 ff ff call c0100443 <__panic> +c01070e5: a1 ec bf 12 c0 mov 0xc012bfec,%eax +c01070ea: 83 f8 04 cmp $0x4,%eax +c01070ed: 74 24 je c0107113 +c01070ef: c7 44 24 0c 98 b7 10 movl $0xc010b798,0xc(%esp) +c01070f6: c0 +c01070f7: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c01070fe: c0 +c01070ff: c7 44 24 04 31 01 00 movl $0x131,0x4(%esp) +c0107106: 00 +c0107107: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c010710e: e8 32 9b ff ff call c0100c45 <__panic> cprintf("set up init env for check_swap begin!\n");// 打印设置初始环境开始的信息 -c0107350: c7 04 24 ac bc 10 c0 movl $0xc010bcac,(%esp) -c0107357: e8 7b 8f ff ff call c01002d7 +c0107113: c7 04 24 bc b7 10 c0 movl $0xc010b7bc,(%esp) +c010711a: e8 59 92 ff ff call c0100378 //setup initial vir_page<->phy_page environment for page relpacement algorithm // 设置初始虚拟到物理页面环境,用于页面替换算法 pgfault_num=0;// 初始化页面故障数 -c010735c: c7 05 0c c0 12 c0 00 movl $0x0,0xc012c00c -c0107363: 00 00 00 +c010711f: c7 05 70 c1 12 c0 00 movl $0x0,0xc012c170 +c0107126: 00 00 00 check_content_set();// 设置检查内容 -c0107366: e8 26 fa ff ff call c0106d91 +c0107129: e8 26 fa ff ff call c0106b54 assert( nr_free == 0); // 断言空闲页面数为 0 -c010736b: a1 ac e1 12 c0 mov 0xc012e1ac,%eax -c0107370: 85 c0 test %eax,%eax -c0107372: 74 24 je c0107398 -c0107374: c7 44 24 0c d3 bc 10 movl $0xc010bcd3,0xc(%esp) -c010737b: c0 -c010737c: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0107383: c0 -c0107384: c7 44 24 04 3a 01 00 movl $0x13a,0x4(%esp) -c010738b: 00 -c010738c: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0107393: e8 ab 90 ff ff call c0100443 <__panic> +c010712e: a1 ec bf 12 c0 mov 0xc012bfec,%eax +c0107133: 85 c0 test %eax,%eax +c0107135: 74 24 je c010715b +c0107137: c7 44 24 0c e3 b7 10 movl $0xc010b7e3,0xc(%esp) +c010713e: c0 +c010713f: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0107146: c0 +c0107147: c7 44 24 04 3a 01 00 movl $0x13a,0x4(%esp) +c010714e: 00 +c010714f: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0107156: e8 ea 9a ff ff call c0100c45 <__panic> for(i = 0; i +c010715b: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) +c0107162: eb 25 jmp c0107189 swap_out_seq_no[i]=swap_in_seq_no[i]=-1;// 初始化页面替换序列号 -c01073a1: 8b 45 ec mov -0x14(%ebp),%eax -c01073a4: c7 04 85 00 e1 12 c0 movl $0xffffffff,-0x3fed1f00(,%eax,4) -c01073ab: ff ff ff ff -c01073af: 8b 45 ec mov -0x14(%ebp),%eax -c01073b2: 8b 14 85 00 e1 12 c0 mov -0x3fed1f00(,%eax,4),%edx -c01073b9: 8b 45 ec mov -0x14(%ebp),%eax -c01073bc: 89 14 85 40 e1 12 c0 mov %edx,-0x3fed1ec0(,%eax,4) +c0107164: 8b 45 ec mov -0x14(%ebp),%eax +c0107167: c7 04 85 c0 c0 12 c0 movl $0xffffffff,-0x3fed3f40(,%eax,4) +c010716e: ff ff ff ff +c0107172: 8b 45 ec mov -0x14(%ebp),%eax +c0107175: 8b 14 85 c0 c0 12 c0 mov -0x3fed3f40(,%eax,4),%edx +c010717c: 8b 45 ec mov -0x14(%ebp),%eax +c010717f: 89 14 85 00 c1 12 c0 mov %edx,-0x3fed3f00(,%eax,4) for(i = 0; i +c0107186: ff 45 ec incl -0x14(%ebp) +c0107189: 83 7d ec 09 cmpl $0x9,-0x14(%ebp) +c010718d: 7e d5 jle c0107164 for (i= 0;i +c010718f: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) +c0107196: e9 e8 00 00 00 jmp c0107283 check_ptep[i]=0; -c01073d8: 8b 45 ec mov -0x14(%ebp),%eax -c01073db: c7 04 85 94 e1 12 c0 movl $0x0,-0x3fed1e6c(,%eax,4) -c01073e2: 00 00 00 00 +c010719b: 8b 45 ec mov -0x14(%ebp),%eax +c010719e: c7 04 85 3c c1 12 c0 movl $0x0,-0x3fed3ec4(,%eax,4) +c01071a5: 00 00 00 00 check_ptep[i] = get_pte(pgdir, (i+1)*0x1000, 0);// 获取页表项 -c01073e6: 8b 45 ec mov -0x14(%ebp),%eax -c01073e9: 40 inc %eax -c01073ea: c1 e0 0c shl $0xc,%eax -c01073ed: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c01073f4: 00 -c01073f5: 89 44 24 04 mov %eax,0x4(%esp) -c01073f9: 8b 45 e0 mov -0x20(%ebp),%eax -c01073fc: 89 04 24 mov %eax,(%esp) -c01073ff: e8 25 ca ff ff call c0103e29 -c0107404: 8b 55 ec mov -0x14(%ebp),%edx -c0107407: 89 04 95 94 e1 12 c0 mov %eax,-0x3fed1e6c(,%edx,4) +c01071a9: 8b 45 ec mov -0x14(%ebp),%eax +c01071ac: 40 inc %eax +c01071ad: c1 e0 0c shl $0xc,%eax +c01071b0: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c01071b7: 00 +c01071b8: 89 44 24 04 mov %eax,0x4(%esp) +c01071bc: 8b 45 e0 mov -0x20(%ebp),%eax +c01071bf: 89 04 24 mov %eax,(%esp) +c01071c2: e8 cf e4 ff ff call c0105696 +c01071c7: 8b 55 ec mov -0x14(%ebp),%edx +c01071ca: 89 04 95 3c c1 12 c0 mov %eax,-0x3fed3ec4(,%edx,4) //cprintf("i %d, check_ptep addr %x, value %x\n", i, check_ptep[i], *check_ptep[i]); assert(check_ptep[i] != NULL);// 断言获取页表项成功 -c010740e: 8b 45 ec mov -0x14(%ebp),%eax -c0107411: 8b 04 85 94 e1 12 c0 mov -0x3fed1e6c(,%eax,4),%eax -c0107418: 85 c0 test %eax,%eax -c010741a: 75 24 jne c0107440 -c010741c: c7 44 24 0c e0 bc 10 movl $0xc010bce0,0xc(%esp) -c0107423: c0 -c0107424: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c010742b: c0 -c010742c: c7 44 24 04 42 01 00 movl $0x142,0x4(%esp) -c0107433: 00 -c0107434: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c010743b: e8 03 90 ff ff call c0100443 <__panic> +c01071d1: 8b 45 ec mov -0x14(%ebp),%eax +c01071d4: 8b 04 85 3c c1 12 c0 mov -0x3fed3ec4(,%eax,4),%eax +c01071db: 85 c0 test %eax,%eax +c01071dd: 75 24 jne c0107203 +c01071df: c7 44 24 0c f0 b7 10 movl $0xc010b7f0,0xc(%esp) +c01071e6: c0 +c01071e7: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c01071ee: c0 +c01071ef: c7 44 24 04 42 01 00 movl $0x142,0x4(%esp) +c01071f6: 00 +c01071f7: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c01071fe: e8 42 9a ff ff call c0100c45 <__panic> assert(pte2page(*check_ptep[i]) == check_rp[i]); // 断言页表项对应的页面正确 -c0107440: 8b 45 ec mov -0x14(%ebp),%eax -c0107443: 8b 04 85 94 e1 12 c0 mov -0x3fed1e6c(,%eax,4),%eax -c010744a: 8b 00 mov (%eax),%eax -c010744c: 89 04 24 mov %eax,(%esp) -c010744f: e8 8b f5 ff ff call c01069df -c0107454: 8b 55 ec mov -0x14(%ebp),%edx -c0107457: 8b 14 95 e0 e0 12 c0 mov -0x3fed1f20(,%edx,4),%edx -c010745e: 39 d0 cmp %edx,%eax -c0107460: 74 24 je c0107486 -c0107462: c7 44 24 0c f8 bc 10 movl $0xc010bcf8,0xc(%esp) -c0107469: c0 -c010746a: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c0107471: c0 -c0107472: c7 44 24 04 43 01 00 movl $0x143,0x4(%esp) -c0107479: 00 -c010747a: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0107481: e8 bd 8f ff ff call c0100443 <__panic> +c0107203: 8b 45 ec mov -0x14(%ebp),%eax +c0107206: 8b 04 85 3c c1 12 c0 mov -0x3fed3ec4(,%eax,4),%eax +c010720d: 8b 00 mov (%eax),%eax +c010720f: 89 04 24 mov %eax,(%esp) +c0107212: e8 97 f5 ff ff call c01067ae +c0107217: 8b 55 ec mov -0x14(%ebp),%edx +c010721a: 8b 14 95 2c c1 12 c0 mov -0x3fed3ed4(,%edx,4),%edx +c0107221: 39 d0 cmp %edx,%eax +c0107223: 74 24 je c0107249 +c0107225: c7 44 24 0c 08 b8 10 movl $0xc010b808,0xc(%esp) +c010722c: c0 +c010722d: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c0107234: c0 +c0107235: c7 44 24 04 43 01 00 movl $0x143,0x4(%esp) +c010723c: 00 +c010723d: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c0107244: e8 fc 99 ff ff call c0100c45 <__panic> assert((*check_ptep[i] & PTE_P)); // 断言页表项有效 -c0107486: 8b 45 ec mov -0x14(%ebp),%eax -c0107489: 8b 04 85 94 e1 12 c0 mov -0x3fed1e6c(,%eax,4),%eax -c0107490: 8b 00 mov (%eax),%eax -c0107492: 83 e0 01 and $0x1,%eax -c0107495: 85 c0 test %eax,%eax -c0107497: 75 24 jne c01074bd -c0107499: c7 44 24 0c 20 bd 10 movl $0xc010bd20,0xc(%esp) -c01074a0: c0 -c01074a1: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c01074a8: c0 -c01074a9: c7 44 24 04 44 01 00 movl $0x144,0x4(%esp) -c01074b0: 00 -c01074b1: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c01074b8: e8 86 8f ff ff call c0100443 <__panic> +c0107249: 8b 45 ec mov -0x14(%ebp),%eax +c010724c: 8b 04 85 3c c1 12 c0 mov -0x3fed3ec4(,%eax,4),%eax +c0107253: 8b 00 mov (%eax),%eax +c0107255: 83 e0 01 and $0x1,%eax +c0107258: 85 c0 test %eax,%eax +c010725a: 75 24 jne c0107280 +c010725c: c7 44 24 0c 30 b8 10 movl $0xc010b830,0xc(%esp) +c0107263: c0 +c0107264: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c010726b: c0 +c010726c: c7 44 24 04 44 01 00 movl $0x144,0x4(%esp) +c0107273: 00 +c0107274: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c010727b: e8 c5 99 ff ff call c0100c45 <__panic> for (i= 0;i +c0107280: ff 45 ec incl -0x14(%ebp) +c0107283: 83 7d ec 03 cmpl $0x3,-0x14(%ebp) +c0107287: 0f 8e 0e ff ff ff jle c010719b } cprintf("set up init env for check_swap over!\n");// 打印设置初始环境完成的信息 -c01074ca: c7 04 24 3c bd 10 c0 movl $0xc010bd3c,(%esp) -c01074d1: e8 01 8e ff ff call c01002d7 +c010728d: c7 04 24 4c b8 10 c0 movl $0xc010b84c,(%esp) +c0107294: e8 df 90 ff ff call c0100378 // now access the virt pages to test page relpacement algorithm ret=check_content_access(); -c01074d6: e8 6f fa ff ff call c0106f4a -c01074db: 89 45 d0 mov %eax,-0x30(%ebp) +c0107299: e8 71 fa ff ff call c0106d0f +c010729e: 89 45 d0 mov %eax,-0x30(%ebp) assert(ret==0); // 断言访问检查成功 -c01074de: 83 7d d0 00 cmpl $0x0,-0x30(%ebp) -c01074e2: 74 24 je c0107508 -c01074e4: c7 44 24 0c 62 bd 10 movl $0xc010bd62,0xc(%esp) -c01074eb: c0 -c01074ec: c7 44 24 08 4a ba 10 movl $0xc010ba4a,0x8(%esp) -c01074f3: c0 -c01074f4: c7 44 24 04 49 01 00 movl $0x149,0x4(%esp) -c01074fb: 00 -c01074fc: c7 04 24 e4 b9 10 c0 movl $0xc010b9e4,(%esp) -c0107503: e8 3b 8f ff ff call c0100443 <__panic> +c01072a1: 83 7d d0 00 cmpl $0x0,-0x30(%ebp) +c01072a5: 74 24 je c01072cb +c01072a7: c7 44 24 0c 72 b8 10 movl $0xc010b872,0xc(%esp) +c01072ae: c0 +c01072af: c7 44 24 08 5a b5 10 movl $0xc010b55a,0x8(%esp) +c01072b6: c0 +c01072b7: c7 44 24 04 49 01 00 movl $0x149,0x4(%esp) +c01072be: 00 +c01072bf: c7 04 24 f4 b4 10 c0 movl $0xc010b4f4,(%esp) +c01072c6: e8 7a 99 ff ff call c0100c45 <__panic> //restore kernel mem env for (i=0;i +c01072cb: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) +c01072d2: eb 1d jmp c01072f1 free_pages(check_rp[i],1); -c0107511: 8b 45 ec mov -0x14(%ebp),%eax -c0107514: 8b 04 85 e0 e0 12 c0 mov -0x3fed1f20(,%eax,4),%eax -c010751b: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0107522: 00 -c0107523: 89 04 24 mov %eax,(%esp) -c0107526: e8 9d c2 ff ff call c01037c8 +c01072d4: 8b 45 ec mov -0x14(%ebp),%eax +c01072d7: 8b 04 85 2c c1 12 c0 mov -0x3fed3ed4(,%eax,4),%eax +c01072de: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) +c01072e5: 00 +c01072e6: 89 04 24 mov %eax,(%esp) +c01072e9: e8 5a dd ff ff call c0105048 for (i=0;i +c01072ee: ff 45 ec incl -0x14(%ebp) +c01072f1: 83 7d ec 03 cmpl $0x3,-0x14(%ebp) +c01072f5: 7e dd jle c01072d4 } - //free_page(pte2page(*temp_ptep)); - - mm_destroy(mm);// 销毁内存管理结构 -c0107534: 8b 45 e4 mov -0x1c(%ebp),%eax -c0107537: 89 04 24 mov %eax,(%esp) -c010753a: e8 ef e2 ff ff call c010582e - - nr_free = nr_free_store;// 恢复空闲页面数 -c010753f: 8b 45 d4 mov -0x2c(%ebp),%eax -c0107542: a3 ac e1 12 c0 mov %eax,0xc012e1ac - free_list = free_list_store;// 恢复空闲列表 -c0107547: 8b 45 98 mov -0x68(%ebp),%eax -c010754a: 8b 55 9c mov -0x64(%ebp),%edx -c010754d: a3 a4 e1 12 c0 mov %eax,0xc012e1a4 -c0107552: 89 15 a8 e1 12 c0 mov %edx,0xc012e1a8 + //free_page(pte2page(*temp_ptep)); + + mm_destroy(mm);// 销毁内存管理结构 +c01072f7: 8b 45 e4 mov -0x1c(%ebp),%eax +c01072fa: 89 04 24 mov %eax,(%esp) +c01072fd: e8 7f 09 00 00 call c0107c81 + + nr_free = nr_free_store;// 恢复空闲页面数 +c0107302: 8b 45 d4 mov -0x2c(%ebp),%eax +c0107305: a3 ec bf 12 c0 mov %eax,0xc012bfec + free_list = free_list_store;// 恢复空闲列表 +c010730a: 8b 45 98 mov -0x68(%ebp),%eax +c010730d: 8b 55 9c mov -0x64(%ebp),%edx +c0107310: a3 e4 bf 12 c0 mov %eax,0xc012bfe4 +c0107315: 89 15 e8 bf 12 c0 mov %edx,0xc012bfe8 + + + le = &free_list; +c010731b: c7 45 e8 e4 bf 12 c0 movl $0xc012bfe4,-0x18(%ebp) + while ((le = list_next(le)) != &free_list) { +c0107322: eb 1c jmp c0107340 + struct Page *p = le2page(le, page_link);// 将链表条目转换为页面结构 +c0107324: 8b 45 e8 mov -0x18(%ebp),%eax +c0107327: 83 e8 0c sub $0xc,%eax +c010732a: 89 45 cc mov %eax,-0x34(%ebp) + count --, total -= p->property;// 更新页面数量和属性总和 +c010732d: ff 4d f4 decl -0xc(%ebp) +c0107330: 8b 55 f0 mov -0x10(%ebp),%edx +c0107333: 8b 45 cc mov -0x34(%ebp),%eax +c0107336: 8b 48 08 mov 0x8(%eax),%ecx +c0107339: 89 d0 mov %edx,%eax +c010733b: 29 c8 sub %ecx,%eax +c010733d: 89 45 f0 mov %eax,-0x10(%ebp) +c0107340: 8b 45 e8 mov -0x18(%ebp),%eax +c0107343: 89 45 a0 mov %eax,-0x60(%ebp) + return listelm->next; +c0107346: 8b 45 a0 mov -0x60(%ebp),%eax +c0107349: 8b 40 04 mov 0x4(%eax),%eax + while ((le = list_next(le)) != &free_list) { +c010734c: 89 45 e8 mov %eax,-0x18(%ebp) +c010734f: 81 7d e8 e4 bf 12 c0 cmpl $0xc012bfe4,-0x18(%ebp) +c0107356: 75 cc jne c0107324 + } + cprintf("count is %d, total is %d\n",count,total);// 打印恢复后的状态 +c0107358: 8b 45 f0 mov -0x10(%ebp),%eax +c010735b: 89 44 24 08 mov %eax,0x8(%esp) +c010735f: 8b 45 f4 mov -0xc(%ebp),%eax +c0107362: 89 44 24 04 mov %eax,0x4(%esp) +c0107366: c7 04 24 79 b8 10 c0 movl $0xc010b879,(%esp) +c010736d: e8 06 90 ff ff call c0100378 + //assert(count == 0); + + cprintf("check_swap() succeeded!\n");// 打印检查成功的信息 +c0107372: c7 04 24 93 b8 10 c0 movl $0xc010b893,(%esp) +c0107379: e8 fa 8f ff ff call c0100378 +} +c010737e: 90 nop +c010737f: 89 ec mov %ebp,%esp +c0107381: 5d pop %ebp +c0107382: c3 ret + +c0107383 <_fifo_init_mm>: + * (2) _fifo_init_mm: init pra_list_head and let mm->sm_priv point to the addr of pra_list_head. + * Now, From the memory control struct mm_struct, we can access FIFO PRA + */ +static int +_fifo_init_mm(struct mm_struct *mm) +{ +c0107383: 55 push %ebp +c0107384: 89 e5 mov %esp,%ebp +c0107386: 83 ec 10 sub $0x10,%esp +c0107389: c7 45 fc 64 c1 12 c0 movl $0xc012c164,-0x4(%ebp) + elm->prev = elm->next = elm; +c0107390: 8b 45 fc mov -0x4(%ebp),%eax +c0107393: 8b 55 fc mov -0x4(%ebp),%edx +c0107396: 89 50 04 mov %edx,0x4(%eax) +c0107399: 8b 45 fc mov -0x4(%ebp),%eax +c010739c: 8b 50 04 mov 0x4(%eax),%edx +c010739f: 8b 45 fc mov -0x4(%ebp),%eax +c01073a2: 89 10 mov %edx,(%eax) +} +c01073a4: 90 nop + //初始化一个链表头 pra_list_head + list_init(&pra_list_head); + //将 mm 结构中的 sm_priv 字段指向这个链表头 + mm->sm_priv = &pra_list_head; +c01073a5: 8b 45 08 mov 0x8(%ebp),%eax +c01073a8: c7 40 14 64 c1 12 c0 movl $0xc012c164,0x14(%eax) + //cprintf(" mm->sm_priv %x in fifo_init_mm\n",mm->sm_priv); + //返回 0 表示成功 + return 0; +c01073af: b8 00 00 00 00 mov $0x0,%eax +} +c01073b4: 89 ec mov %ebp,%esp +c01073b6: 5d pop %ebp +c01073b7: c3 ret + +c01073b8 <_fifo_map_swappable>: +/* + * (3)_fifo_map_swappable: According FIFO PRA, we should link the most recent arrival page at the back of pra_list_head qeueue + */ +static int +_fifo_map_swappable(struct mm_struct *mm, uintptr_t addr, struct Page *page, int swap_in) +{ +c01073b8: 55 push %ebp +c01073b9: 89 e5 mov %esp,%ebp +c01073bb: 83 ec 48 sub $0x48,%esp + //获取 mm_struct 结构中的 sm_priv 指针, + //并将其转换为 list_entry_t 类型的链表头指针 head + list_entry_t *head=(list_entry_t*) mm->sm_priv; +c01073be: 8b 45 08 mov 0x8(%ebp),%eax +c01073c1: 8b 40 14 mov 0x14(%eax),%eax +c01073c4: 89 45 f4 mov %eax,-0xc(%ebp) + list_entry_t *entry=&(page->pra_page_link); +c01073c7: 8b 45 10 mov 0x10(%ebp),%eax +c01073ca: 83 c0 14 add $0x14,%eax +c01073cd: 89 45 f0 mov %eax,-0x10(%ebp) + + assert(entry != NULL && head != NULL); +c01073d0: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c01073d4: 74 06 je c01073dc <_fifo_map_swappable+0x24> +c01073d6: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c01073da: 75 24 jne c0107400 <_fifo_map_swappable+0x48> +c01073dc: c7 44 24 0c ac b8 10 movl $0xc010b8ac,0xc(%esp) +c01073e3: c0 +c01073e4: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c01073eb: c0 +c01073ec: c7 44 24 04 37 00 00 movl $0x37,0x4(%esp) +c01073f3: 00 +c01073f4: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c01073fb: e8 45 98 ff ff call c0100c45 <__panic> +c0107400: 8b 45 f4 mov -0xc(%ebp),%eax +c0107403: 89 45 ec mov %eax,-0x14(%ebp) +c0107406: 8b 45 f0 mov -0x10(%ebp),%eax +c0107409: 89 45 e8 mov %eax,-0x18(%ebp) +c010740c: 8b 45 ec mov -0x14(%ebp),%eax +c010740f: 89 45 e4 mov %eax,-0x1c(%ebp) +c0107412: 8b 45 e8 mov -0x18(%ebp),%eax +c0107415: 89 45 e0 mov %eax,-0x20(%ebp) + __list_add(elm, listelm, listelm->next); +c0107418: 8b 45 e4 mov -0x1c(%ebp),%eax +c010741b: 8b 40 04 mov 0x4(%eax),%eax +c010741e: 8b 55 e0 mov -0x20(%ebp),%edx +c0107421: 89 55 dc mov %edx,-0x24(%ebp) +c0107424: 8b 55 e4 mov -0x1c(%ebp),%edx +c0107427: 89 55 d8 mov %edx,-0x28(%ebp) +c010742a: 89 45 d4 mov %eax,-0x2c(%ebp) + prev->next = next->prev = elm; +c010742d: 8b 45 d4 mov -0x2c(%ebp),%eax +c0107430: 8b 55 dc mov -0x24(%ebp),%edx +c0107433: 89 10 mov %edx,(%eax) +c0107435: 8b 45 d4 mov -0x2c(%ebp),%eax +c0107438: 8b 10 mov (%eax),%edx +c010743a: 8b 45 d8 mov -0x28(%ebp),%eax +c010743d: 89 50 04 mov %edx,0x4(%eax) + elm->next = next; +c0107440: 8b 45 dc mov -0x24(%ebp),%eax +c0107443: 8b 55 d4 mov -0x2c(%ebp),%edx +c0107446: 89 50 04 mov %edx,0x4(%eax) + elm->prev = prev; +c0107449: 8b 45 dc mov -0x24(%ebp),%eax +c010744c: 8b 55 d8 mov -0x28(%ebp),%edx +c010744f: 89 10 mov %edx,(%eax) +} +c0107451: 90 nop +} +c0107452: 90 nop +} +c0107453: 90 nop + //record the page access situlation + /*LAB3 EXERCISE 2: YOUR CODE*/ + //(1)link the most recent arrival page at the back of the pra_list_head qeueue. + //将最近到达的页面链接到 pra_list_head 队列的末尾 + list_add(head, entry); + return 0; +c0107454: b8 00 00 00 00 mov $0x0,%eax +} +c0107459: 89 ec mov %ebp,%esp +c010745b: 5d pop %ebp +c010745c: c3 ret + +c010745d <_fifo_swap_out_victim>: + * + * @return 返回0表示成功,其他值表示失败。 + */ +static int +_fifo_swap_out_victim(struct mm_struct *mm, struct Page ** ptr_page, int in_tick) +{ +c010745d: 55 push %ebp +c010745e: 89 e5 mov %esp,%ebp +c0107460: 83 ec 38 sub $0x38,%esp + list_entry_t *head=(list_entry_t*) mm->sm_priv; +c0107463: 8b 45 08 mov 0x8(%ebp),%eax +c0107466: 8b 40 14 mov 0x14(%eax),%eax +c0107469: 89 45 f4 mov %eax,-0xc(%ebp) + assert(head != NULL); +c010746c: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0107470: 75 24 jne c0107496 <_fifo_swap_out_victim+0x39> +c0107472: c7 44 24 0c f3 b8 10 movl $0xc010b8f3,0xc(%esp) +c0107479: c0 +c010747a: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c0107481: c0 +c0107482: c7 44 24 04 50 00 00 movl $0x50,0x4(%esp) +c0107489: 00 +c010748a: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c0107491: e8 af 97 ff ff call c0100c45 <__panic> + assert(in_tick==0); +c0107496: 83 7d 10 00 cmpl $0x0,0x10(%ebp) +c010749a: 74 24 je c01074c0 <_fifo_swap_out_victim+0x63> +c010749c: c7 44 24 0c 00 b9 10 movl $0xc010b900,0xc(%esp) +c01074a3: c0 +c01074a4: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c01074ab: c0 +c01074ac: c7 44 24 04 51 00 00 movl $0x51,0x4(%esp) +c01074b3: 00 +c01074b4: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c01074bb: e8 85 97 ff ff call c0100c45 <__panic> + /* Select the victim */ + /*LAB3 EXERCISE 2: YOUR CODE*/ + //(1) unlink the earliest arrival page in front of pra_list_head qeueue + //(2) assign the value of *ptr_page to the addr of this page + //head->prev 获取链表中最先到达的页面 + list_entry_t *le = head->prev; +c01074c0: 8b 45 f4 mov -0xc(%ebp),%eax +c01074c3: 8b 00 mov (%eax),%eax +c01074c5: 89 45 f0 mov %eax,-0x10(%ebp) + assert(head!=le); +c01074c8: 8b 45 f4 mov -0xc(%ebp),%eax +c01074cb: 3b 45 f0 cmp -0x10(%ebp),%eax +c01074ce: 75 24 jne c01074f4 <_fifo_swap_out_victim+0x97> +c01074d0: c7 44 24 0c 0b b9 10 movl $0xc010b90b,0xc(%esp) +c01074d7: c0 +c01074d8: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c01074df: c0 +c01074e0: c7 44 24 04 58 00 00 movl $0x58,0x4(%esp) +c01074e7: 00 +c01074e8: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c01074ef: e8 51 97 ff ff call c0100c45 <__panic> + struct Page *p = le2page(le, pra_page_link); +c01074f4: 8b 45 f0 mov -0x10(%ebp),%eax +c01074f7: 83 e8 14 sub $0x14,%eax +c01074fa: 89 45 ec mov %eax,-0x14(%ebp) +c01074fd: 8b 45 f0 mov -0x10(%ebp),%eax +c0107500: 89 45 e8 mov %eax,-0x18(%ebp) + __list_del(listelm->prev, listelm->next); +c0107503: 8b 45 e8 mov -0x18(%ebp),%eax +c0107506: 8b 40 04 mov 0x4(%eax),%eax +c0107509: 8b 55 e8 mov -0x18(%ebp),%edx +c010750c: 8b 12 mov (%edx),%edx +c010750e: 89 55 e4 mov %edx,-0x1c(%ebp) +c0107511: 89 45 e0 mov %eax,-0x20(%ebp) + prev->next = next; +c0107514: 8b 45 e4 mov -0x1c(%ebp),%eax +c0107517: 8b 55 e0 mov -0x20(%ebp),%edx +c010751a: 89 50 04 mov %edx,0x4(%eax) + next->prev = prev; +c010751d: 8b 45 e0 mov -0x20(%ebp),%eax +c0107520: 8b 55 e4 mov -0x1c(%ebp),%edx +c0107523: 89 10 mov %edx,(%eax) +} +c0107525: 90 nop +} +c0107526: 90 nop + //使用 list_del 函数将该页面从链表中移除。 + list_del(le); + assert(p != NULL); +c0107527: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) +c010752b: 75 24 jne c0107551 <_fifo_swap_out_victim+0xf4> +c010752d: c7 44 24 0c 14 b9 10 movl $0xc010b914,0xc(%esp) +c0107534: c0 +c0107535: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c010753c: c0 +c010753d: c7 44 24 04 5c 00 00 movl $0x5c,0x4(%esp) +c0107544: 00 +c0107545: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c010754c: e8 f4 96 ff ff call c0100c45 <__panic> + //将移除的页面指针赋值给 *ptr_page + *ptr_page = p; +c0107551: 8b 45 0c mov 0xc(%ebp),%eax +c0107554: 8b 55 ec mov -0x14(%ebp),%edx +c0107557: 89 10 mov %edx,(%eax) + + return 0; +c0107559: b8 00 00 00 00 mov $0x0,%eax +} +c010755e: 89 ec mov %ebp,%esp +c0107560: 5d pop %ebp +c0107561: c3 ret + +c0107562 <_fifo_check_swap>: + * + * 返回值: + * - 0: 表示所有检查均通过。 + */ +static int +_fifo_check_swap(void) { +c0107562: 55 push %ebp +c0107563: 89 e5 mov %esp,%ebp +c0107565: 83 ec 18 sub $0x18,%esp + // 写入虚拟页 c 并检查页面故障数 + cprintf("write Virt Page c in fifo_check_swap\n"); +c0107568: c7 04 24 20 b9 10 c0 movl $0xc010b920,(%esp) +c010756f: e8 04 8e ff ff call c0100378 + *(unsigned char *)0x3000 = 0x0c; +c0107574: b8 00 30 00 00 mov $0x3000,%eax +c0107579: c6 00 0c movb $0xc,(%eax) + assert(pgfault_num==4); +c010757c: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0107581: 83 f8 04 cmp $0x4,%eax +c0107584: 74 24 je c01075aa <_fifo_check_swap+0x48> +c0107586: c7 44 24 0c 46 b9 10 movl $0xc010b946,0xc(%esp) +c010758d: c0 +c010758e: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c0107595: c0 +c0107596: c7 44 24 04 70 00 00 movl $0x70,0x4(%esp) +c010759d: 00 +c010759e: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c01075a5: e8 9b 96 ff ff call c0100c45 <__panic> + + // 写入虚拟页 a 并检查页面故障数 + cprintf("write Virt Page a in fifo_check_swap\n"); +c01075aa: c7 04 24 58 b9 10 c0 movl $0xc010b958,(%esp) +c01075b1: e8 c2 8d ff ff call c0100378 + *(unsigned char *)0x1000 = 0x0a; +c01075b6: b8 00 10 00 00 mov $0x1000,%eax +c01075bb: c6 00 0a movb $0xa,(%eax) + assert(pgfault_num==4); +c01075be: a1 70 c1 12 c0 mov 0xc012c170,%eax +c01075c3: 83 f8 04 cmp $0x4,%eax +c01075c6: 74 24 je c01075ec <_fifo_check_swap+0x8a> +c01075c8: c7 44 24 0c 46 b9 10 movl $0xc010b946,0xc(%esp) +c01075cf: c0 +c01075d0: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c01075d7: c0 +c01075d8: c7 44 24 04 75 00 00 movl $0x75,0x4(%esp) +c01075df: 00 +c01075e0: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c01075e7: e8 59 96 ff ff call c0100c45 <__panic> + + // 写入虚拟页 d 并检查页面故障数 + cprintf("write Virt Page d in fifo_check_swap\n"); +c01075ec: c7 04 24 80 b9 10 c0 movl $0xc010b980,(%esp) +c01075f3: e8 80 8d ff ff call c0100378 + *(unsigned char *)0x4000 = 0x0d; +c01075f8: b8 00 40 00 00 mov $0x4000,%eax +c01075fd: c6 00 0d movb $0xd,(%eax) + assert(pgfault_num==4); +c0107600: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0107605: 83 f8 04 cmp $0x4,%eax +c0107608: 74 24 je c010762e <_fifo_check_swap+0xcc> +c010760a: c7 44 24 0c 46 b9 10 movl $0xc010b946,0xc(%esp) +c0107611: c0 +c0107612: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c0107619: c0 +c010761a: c7 44 24 04 7a 00 00 movl $0x7a,0x4(%esp) +c0107621: 00 +c0107622: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c0107629: e8 17 96 ff ff call c0100c45 <__panic> + + // 写入虚拟页 b 并检查页面故障数 + cprintf("write Virt Page b in fifo_check_swap\n"); +c010762e: c7 04 24 a8 b9 10 c0 movl $0xc010b9a8,(%esp) +c0107635: e8 3e 8d ff ff call c0100378 + *(unsigned char *)0x2000 = 0x0b; +c010763a: b8 00 20 00 00 mov $0x2000,%eax +c010763f: c6 00 0b movb $0xb,(%eax) + assert(pgfault_num==4); +c0107642: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0107647: 83 f8 04 cmp $0x4,%eax +c010764a: 74 24 je c0107670 <_fifo_check_swap+0x10e> +c010764c: c7 44 24 0c 46 b9 10 movl $0xc010b946,0xc(%esp) +c0107653: c0 +c0107654: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c010765b: c0 +c010765c: c7 44 24 04 7f 00 00 movl $0x7f,0x4(%esp) +c0107663: 00 +c0107664: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c010766b: e8 d5 95 ff ff call c0100c45 <__panic> + + // 写入虚拟页 e 并检查页面故障数 + cprintf("write Virt Page e in fifo_check_swap\n"); +c0107670: c7 04 24 d0 b9 10 c0 movl $0xc010b9d0,(%esp) +c0107677: e8 fc 8c ff ff call c0100378 + *(unsigned char *)0x5000 = 0x0e; +c010767c: b8 00 50 00 00 mov $0x5000,%eax +c0107681: c6 00 0e movb $0xe,(%eax) + assert(pgfault_num==5); +c0107684: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0107689: 83 f8 05 cmp $0x5,%eax +c010768c: 74 24 je c01076b2 <_fifo_check_swap+0x150> +c010768e: c7 44 24 0c f6 b9 10 movl $0xc010b9f6,0xc(%esp) +c0107695: c0 +c0107696: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c010769d: c0 +c010769e: c7 44 24 04 84 00 00 movl $0x84,0x4(%esp) +c01076a5: 00 +c01076a6: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c01076ad: e8 93 95 ff ff call c0100c45 <__panic> + + // 再次写入虚拟页 b 并检查页面故障数 + cprintf("write Virt Page b in fifo_check_swap\n"); +c01076b2: c7 04 24 a8 b9 10 c0 movl $0xc010b9a8,(%esp) +c01076b9: e8 ba 8c ff ff call c0100378 + *(unsigned char *)0x2000 = 0x0b; +c01076be: b8 00 20 00 00 mov $0x2000,%eax +c01076c3: c6 00 0b movb $0xb,(%eax) + assert(pgfault_num==5); +c01076c6: a1 70 c1 12 c0 mov 0xc012c170,%eax +c01076cb: 83 f8 05 cmp $0x5,%eax +c01076ce: 74 24 je c01076f4 <_fifo_check_swap+0x192> +c01076d0: c7 44 24 0c f6 b9 10 movl $0xc010b9f6,0xc(%esp) +c01076d7: c0 +c01076d8: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c01076df: c0 +c01076e0: c7 44 24 04 89 00 00 movl $0x89,0x4(%esp) +c01076e7: 00 +c01076e8: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c01076ef: e8 51 95 ff ff call c0100c45 <__panic> + + // 再次写入虚拟页 a 并检查页面故障数 + cprintf("write Virt Page a in fifo_check_swap\n"); +c01076f4: c7 04 24 58 b9 10 c0 movl $0xc010b958,(%esp) +c01076fb: e8 78 8c ff ff call c0100378 + *(unsigned char *)0x1000 = 0x0a; +c0107700: b8 00 10 00 00 mov $0x1000,%eax +c0107705: c6 00 0a movb $0xa,(%eax) + assert(pgfault_num==6); +c0107708: a1 70 c1 12 c0 mov 0xc012c170,%eax +c010770d: 83 f8 06 cmp $0x6,%eax +c0107710: 74 24 je c0107736 <_fifo_check_swap+0x1d4> +c0107712: c7 44 24 0c 05 ba 10 movl $0xc010ba05,0xc(%esp) +c0107719: c0 +c010771a: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c0107721: c0 +c0107722: c7 44 24 04 8e 00 00 movl $0x8e,0x4(%esp) +c0107729: 00 +c010772a: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c0107731: e8 0f 95 ff ff call c0100c45 <__panic> + + // 再次写入虚拟页 b 并检查页面故障数 + cprintf("write Virt Page b in fifo_check_swap\n"); +c0107736: c7 04 24 a8 b9 10 c0 movl $0xc010b9a8,(%esp) +c010773d: e8 36 8c ff ff call c0100378 + *(unsigned char *)0x2000 = 0x0b; +c0107742: b8 00 20 00 00 mov $0x2000,%eax +c0107747: c6 00 0b movb $0xb,(%eax) + assert(pgfault_num==7); +c010774a: a1 70 c1 12 c0 mov 0xc012c170,%eax +c010774f: 83 f8 07 cmp $0x7,%eax +c0107752: 74 24 je c0107778 <_fifo_check_swap+0x216> +c0107754: c7 44 24 0c 14 ba 10 movl $0xc010ba14,0xc(%esp) +c010775b: c0 +c010775c: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c0107763: c0 +c0107764: c7 44 24 04 93 00 00 movl $0x93,0x4(%esp) +c010776b: 00 +c010776c: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c0107773: e8 cd 94 ff ff call c0100c45 <__panic> + + // 再次写入虚拟页 c 并检查页面故障数 + cprintf("write Virt Page c in fifo_check_swap\n"); +c0107778: c7 04 24 20 b9 10 c0 movl $0xc010b920,(%esp) +c010777f: e8 f4 8b ff ff call c0100378 + *(unsigned char *)0x3000 = 0x0c; +c0107784: b8 00 30 00 00 mov $0x3000,%eax +c0107789: c6 00 0c movb $0xc,(%eax) + assert(pgfault_num==8); +c010778c: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0107791: 83 f8 08 cmp $0x8,%eax +c0107794: 74 24 je c01077ba <_fifo_check_swap+0x258> +c0107796: c7 44 24 0c 23 ba 10 movl $0xc010ba23,0xc(%esp) +c010779d: c0 +c010779e: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c01077a5: c0 +c01077a6: c7 44 24 04 98 00 00 movl $0x98,0x4(%esp) +c01077ad: 00 +c01077ae: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c01077b5: e8 8b 94 ff ff call c0100c45 <__panic> + + // 再次写入虚拟页 d 并检查页面故障数 + cprintf("write Virt Page d in fifo_check_swap\n"); +c01077ba: c7 04 24 80 b9 10 c0 movl $0xc010b980,(%esp) +c01077c1: e8 b2 8b ff ff call c0100378 + *(unsigned char *)0x4000 = 0x0d; +c01077c6: b8 00 40 00 00 mov $0x4000,%eax +c01077cb: c6 00 0d movb $0xd,(%eax) + assert(pgfault_num==9); +c01077ce: a1 70 c1 12 c0 mov 0xc012c170,%eax +c01077d3: 83 f8 09 cmp $0x9,%eax +c01077d6: 74 24 je c01077fc <_fifo_check_swap+0x29a> +c01077d8: c7 44 24 0c 32 ba 10 movl $0xc010ba32,0xc(%esp) +c01077df: c0 +c01077e0: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c01077e7: c0 +c01077e8: c7 44 24 04 9d 00 00 movl $0x9d,0x4(%esp) +c01077ef: 00 +c01077f0: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c01077f7: e8 49 94 ff ff call c0100c45 <__panic> + + // 再次写入虚拟页 e 并检查页面故障数 + cprintf("write Virt Page e in fifo_check_swap\n"); +c01077fc: c7 04 24 d0 b9 10 c0 movl $0xc010b9d0,(%esp) +c0107803: e8 70 8b ff ff call c0100378 + *(unsigned char *)0x5000 = 0x0e; +c0107808: b8 00 50 00 00 mov $0x5000,%eax +c010780d: c6 00 0e movb $0xe,(%eax) + assert(pgfault_num==10); +c0107810: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0107815: 83 f8 0a cmp $0xa,%eax +c0107818: 74 24 je c010783e <_fifo_check_swap+0x2dc> +c010781a: c7 44 24 0c 41 ba 10 movl $0xc010ba41,0xc(%esp) +c0107821: c0 +c0107822: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c0107829: c0 +c010782a: c7 44 24 04 a2 00 00 movl $0xa2,0x4(%esp) +c0107831: 00 +c0107832: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c0107839: e8 07 94 ff ff call c0100c45 <__panic> - - le = &free_list; -c0107558: c7 45 e8 a4 e1 12 c0 movl $0xc012e1a4,-0x18(%ebp) - while ((le = list_next(le)) != &free_list) { -c010755f: eb 1c jmp c010757d - struct Page *p = le2page(le, page_link);// 将链表条目转换为页面结构 -c0107561: 8b 45 e8 mov -0x18(%ebp),%eax -c0107564: 83 e8 0c sub $0xc,%eax -c0107567: 89 45 cc mov %eax,-0x34(%ebp) - count --, total -= p->property;// 更新页面数量和属性总和 -c010756a: ff 4d f4 decl -0xc(%ebp) -c010756d: 8b 55 f0 mov -0x10(%ebp),%edx -c0107570: 8b 45 cc mov -0x34(%ebp),%eax -c0107573: 8b 40 08 mov 0x8(%eax),%eax -c0107576: 29 c2 sub %eax,%edx -c0107578: 89 d0 mov %edx,%eax -c010757a: 89 45 f0 mov %eax,-0x10(%ebp) -c010757d: 8b 45 e8 mov -0x18(%ebp),%eax -c0107580: 89 45 a0 mov %eax,-0x60(%ebp) - return listelm->next; -c0107583: 8b 45 a0 mov -0x60(%ebp),%eax -c0107586: 8b 40 04 mov 0x4(%eax),%eax - while ((le = list_next(le)) != &free_list) { -c0107589: 89 45 e8 mov %eax,-0x18(%ebp) -c010758c: 81 7d e8 a4 e1 12 c0 cmpl $0xc012e1a4,-0x18(%ebp) -c0107593: 75 cc jne c0107561 - } - cprintf("count is %d, total is %d\n",count,total);// 打印恢复后的状态 -c0107595: 8b 45 f0 mov -0x10(%ebp),%eax -c0107598: 89 44 24 08 mov %eax,0x8(%esp) -c010759c: 8b 45 f4 mov -0xc(%ebp),%eax -c010759f: 89 44 24 04 mov %eax,0x4(%esp) -c01075a3: c7 04 24 69 bd 10 c0 movl $0xc010bd69,(%esp) -c01075aa: e8 28 8d ff ff call c01002d7 - //assert(count == 0); - - cprintf("check_swap() succeeded!\n");// 打印检查成功的信息 -c01075af: c7 04 24 83 bd 10 c0 movl $0xc010bd83,(%esp) -c01075b6: e8 1c 8d ff ff call c01002d7 + // 再次写入虚拟页 a 并检查页面故障数 + cprintf("write Virt Page a in fifo_check_swap\n"); +c010783e: c7 04 24 58 b9 10 c0 movl $0xc010b958,(%esp) +c0107845: e8 2e 8b ff ff call c0100378 + assert(*(unsigned char *)0x1000 == 0x0a); +c010784a: b8 00 10 00 00 mov $0x1000,%eax +c010784f: 0f b6 00 movzbl (%eax),%eax +c0107852: 3c 0a cmp $0xa,%al +c0107854: 74 24 je c010787a <_fifo_check_swap+0x318> +c0107856: c7 44 24 0c 54 ba 10 movl $0xc010ba54,0xc(%esp) +c010785d: c0 +c010785e: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c0107865: c0 +c0107866: c7 44 24 04 a6 00 00 movl $0xa6,0x4(%esp) +c010786d: 00 +c010786e: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c0107875: e8 cb 93 ff ff call c0100c45 <__panic> + *(unsigned char *)0x1000 = 0x0a; +c010787a: b8 00 10 00 00 mov $0x1000,%eax +c010787f: c6 00 0a movb $0xa,(%eax) + assert(pgfault_num==11); +c0107882: a1 70 c1 12 c0 mov 0xc012c170,%eax +c0107887: 83 f8 0b cmp $0xb,%eax +c010788a: 74 24 je c01078b0 <_fifo_check_swap+0x34e> +c010788c: c7 44 24 0c 75 ba 10 movl $0xc010ba75,0xc(%esp) +c0107893: c0 +c0107894: c7 44 24 08 ca b8 10 movl $0xc010b8ca,0x8(%esp) +c010789b: c0 +c010789c: c7 44 24 04 a8 00 00 movl $0xa8,0x4(%esp) +c01078a3: 00 +c01078a4: c7 04 24 df b8 10 c0 movl $0xc010b8df,(%esp) +c01078ab: e8 95 93 ff ff call c0100c45 <__panic> + return 0; +c01078b0: b8 00 00 00 00 mov $0x0,%eax } -c01075bb: 90 nop -c01075bc: c9 leave -c01075bd: c3 ret +c01078b5: 89 ec mov %ebp,%esp +c01078b7: 5d pop %ebp +c01078b8: c3 ret -c01075be : -page2ppn(struct Page *page) { -c01075be: 55 push %ebp -c01075bf: 89 e5 mov %esp,%ebp - return page - pages; -c01075c1: a1 b8 e0 12 c0 mov 0xc012e0b8,%eax -c01075c6: 8b 55 08 mov 0x8(%ebp),%edx -c01075c9: 29 c2 sub %eax,%edx -c01075cb: 89 d0 mov %edx,%eax -c01075cd: c1 f8 05 sar $0x5,%eax -} -c01075d0: 5d pop %ebp -c01075d1: c3 ret +c01078b9 <_fifo_init>: -c01075d2 : -page2pa(struct Page *page) { -c01075d2: 55 push %ebp -c01075d3: 89 e5 mov %esp,%ebp -c01075d5: 83 ec 04 sub $0x4,%esp - return page2ppn(page) << PGSHIFT; -c01075d8: 8b 45 08 mov 0x8(%ebp),%eax -c01075db: 89 04 24 mov %eax,(%esp) -c01075de: e8 db ff ff ff call c01075be -c01075e3: c1 e0 0c shl $0xc,%eax -} -c01075e6: c9 leave -c01075e7: c3 ret -c01075e8 : -page_ref(struct Page *page) { -c01075e8: 55 push %ebp -c01075e9: 89 e5 mov %esp,%ebp - return page->ref; -c01075eb: 8b 45 08 mov 0x8(%ebp),%eax -c01075ee: 8b 00 mov (%eax),%eax +static int +_fifo_init(void) +{ +c01078b9: 55 push %ebp +c01078ba: 89 e5 mov %esp,%ebp + return 0; +c01078bc: b8 00 00 00 00 mov $0x0,%eax } -c01075f0: 5d pop %ebp -c01075f1: c3 ret +c01078c1: 5d pop %ebp +c01078c2: c3 ret -c01075f2 : -set_page_ref(struct Page *page, int val) { -c01075f2: 55 push %ebp -c01075f3: 89 e5 mov %esp,%ebp - page->ref = val; -c01075f5: 8b 45 08 mov 0x8(%ebp),%eax -c01075f8: 8b 55 0c mov 0xc(%ebp),%edx -c01075fb: 89 10 mov %edx,(%eax) +c01078c3 <_fifo_set_unswappable>: + +static int +_fifo_set_unswappable(struct mm_struct *mm, uintptr_t addr) +{ +c01078c3: 55 push %ebp +c01078c4: 89 e5 mov %esp,%ebp + return 0; +c01078c6: b8 00 00 00 00 mov $0x0,%eax } -c01075fd: 90 nop -c01075fe: 5d pop %ebp -c01075ff: c3 ret +c01078cb: 5d pop %ebp +c01078cc: c3 ret -c0107600 : -#define nr_free (free_area.nr_free) +c01078cd <_fifo_tick_event>: -//free_list` 用于记录空闲内存块,nr_free` 是空闲内存块的总数。 -//用default_init函数来初始化 `free_list`,并将 `nr_free` 设置为 0。 -static void -default_init(void) { -c0107600: f3 0f 1e fb endbr32 -c0107604: 55 push %ebp -c0107605: 89 e5 mov %esp,%ebp -c0107607: 83 ec 10 sub $0x10,%esp -c010760a: c7 45 fc a4 e1 12 c0 movl $0xc012e1a4,-0x4(%ebp) - elm->prev = elm->next = elm; -c0107611: 8b 45 fc mov -0x4(%ebp),%eax -c0107614: 8b 55 fc mov -0x4(%ebp),%edx -c0107617: 89 50 04 mov %edx,0x4(%eax) -c010761a: 8b 45 fc mov -0x4(%ebp),%eax -c010761d: 8b 50 04 mov 0x4(%eax),%edx -c0107620: 8b 45 fc mov -0x4(%ebp),%eax -c0107623: 89 10 mov %edx,(%eax) -} -c0107625: 90 nop - list_init(&free_list); - nr_free = 0; -c0107626: c7 05 ac e1 12 c0 00 movl $0x0,0xc012e1ac -c010762d: 00 00 00 +static int +_fifo_tick_event(struct mm_struct *mm) +{ return 0; } +c01078cd: 55 push %ebp +c01078ce: 89 e5 mov %esp,%ebp +c01078d0: b8 00 00 00 00 mov $0x0,%eax +c01078d5: 5d pop %ebp +c01078d6: c3 ret + +c01078d7 : +pa2page(uintptr_t pa) { +c01078d7: 55 push %ebp +c01078d8: 89 e5 mov %esp,%ebp +c01078da: 83 ec 18 sub $0x18,%esp + if (PPN(pa) >= npage) { +c01078dd: 8b 45 08 mov 0x8(%ebp),%eax +c01078e0: c1 e8 0c shr $0xc,%eax +c01078e3: 89 c2 mov %eax,%edx +c01078e5: a1 04 c0 12 c0 mov 0xc012c004,%eax +c01078ea: 39 c2 cmp %eax,%edx +c01078ec: 72 1c jb c010790a + panic("pa2page called with invalid pa"); +c01078ee: c7 44 24 08 98 ba 10 movl $0xc010ba98,0x8(%esp) +c01078f5: c0 +c01078f6: c7 44 24 04 5f 00 00 movl $0x5f,0x4(%esp) +c01078fd: 00 +c01078fe: c7 04 24 b7 ba 10 c0 movl $0xc010bab7,(%esp) +c0107905: e8 3b 93 ff ff call c0100c45 <__panic> + return &pages[PPN(pa)]; +c010790a: 8b 15 00 c0 12 c0 mov 0xc012c000,%edx +c0107910: 8b 45 08 mov 0x8(%ebp),%eax +c0107913: c1 e8 0c shr $0xc,%eax +c0107916: c1 e0 05 shl $0x5,%eax +c0107919: 01 d0 add %edx,%eax } -c0107630: 90 nop -c0107631: c9 leave -c0107632: c3 ret +c010791b: 89 ec mov %ebp,%esp +c010791d: 5d pop %ebp +c010791e: c3 ret -c0107633 : +c010791f : +pde2page(pde_t pde) { +c010791f: 55 push %ebp +c0107920: 89 e5 mov %esp,%ebp +c0107922: 83 ec 18 sub $0x18,%esp + return pa2page(PDE_ADDR(pde)); +c0107925: 8b 45 08 mov 0x8(%ebp),%eax +c0107928: 25 00 f0 ff ff and $0xfffff000,%eax +c010792d: 89 04 24 mov %eax,(%esp) +c0107930: e8 a2 ff ff ff call c01078d7 +} +c0107935: 89 ec mov %ebp,%esp +c0107937: 5d pop %ebp +c0107938: c3 ret -//用于初始化一段连续的物理页,并将它们加入到空闲内存管理系统中. -//struct Page *base:指向要初始化的页块的起始地址。size_t n:要初始化的页的数量。 -static void -default_init_memmap(struct Page *base, size_t n) { -c0107633: f3 0f 1e fb endbr32 -c0107637: 55 push %ebp -c0107638: 89 e5 mov %esp,%ebp -c010763a: 83 ec 48 sub $0x48,%esp - assert(n > 0);// 确保请求的页数大于零 -c010763d: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) -c0107641: 75 24 jne c0107667 -c0107643: c7 44 24 0c 9c bd 10 movl $0xc010bd9c,0xc(%esp) -c010764a: c0 -c010764b: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107652: c0 -c0107653: c7 44 24 04 9a 00 00 movl $0x9a,0x4(%esp) -c010765a: 00 -c010765b: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107662: e8 dc 8d ff ff call c0100443 <__panic> - struct Page *p = base;// 指向当前初始化的页 -c0107667: 8b 45 08 mov 0x8(%ebp),%eax -c010766a: 89 45 f4 mov %eax,-0xc(%ebp) - // 遍历每一页,设置其状态 - for (; p != base + n; p ++) { -c010766d: eb 7d jmp c01076ec - assert(PageReserved(p));//检查每个页是否被标记为“保留”。若没有被保留,函数将抛出错误。 -c010766f: 8b 45 f4 mov -0xc(%ebp),%eax -c0107672: 83 c0 04 add $0x4,%eax -c0107675: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) -c010767c: 89 45 ec mov %eax,-0x14(%ebp) - asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); -c010767f: 8b 45 ec mov -0x14(%ebp),%eax -c0107682: 8b 55 f0 mov -0x10(%ebp),%edx -c0107685: 0f a3 10 bt %edx,(%eax) -c0107688: 19 c0 sbb %eax,%eax -c010768a: 89 45 e8 mov %eax,-0x18(%ebp) - return oldbit != 0; -c010768d: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) -c0107691: 0f 95 c0 setne %al -c0107694: 0f b6 c0 movzbl %al,%eax -c0107697: 85 c0 test %eax,%eax -c0107699: 75 24 jne c01076bf -c010769b: c7 44 24 0c cd bd 10 movl $0xc010bdcd,0xc(%esp) -c01076a2: c0 -c01076a3: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01076aa: c0 -c01076ab: c7 44 24 04 9e 00 00 movl $0x9e,0x4(%esp) -c01076b2: 00 -c01076b3: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01076ba: e8 84 8d ff ff call c0100443 <__panic> - p->flags = p->property = 0;//将页的 flags 和 property 字段设置为 0,表示该页未分配、未使用。 -c01076bf: 8b 45 f4 mov -0xc(%ebp),%eax -c01076c2: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) -c01076c9: 8b 45 f4 mov -0xc(%ebp),%eax -c01076cc: 8b 50 08 mov 0x8(%eax),%edx -c01076cf: 8b 45 f4 mov -0xc(%ebp),%eax -c01076d2: 89 50 04 mov %edx,0x4(%eax) - set_page_ref(p, 0);//将页的引用计数设置为 0,表明没有任何引用指向此页。 -c01076d5: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c01076dc: 00 -c01076dd: 8b 45 f4 mov -0xc(%ebp),%eax -c01076e0: 89 04 24 mov %eax,(%esp) -c01076e3: e8 0a ff ff ff call c01075f2 - for (; p != base + n; p ++) { -c01076e8: 83 45 f4 20 addl $0x20,-0xc(%ebp) -c01076ec: 8b 45 0c mov 0xc(%ebp),%eax -c01076ef: c1 e0 05 shl $0x5,%eax -c01076f2: 89 c2 mov %eax,%edx -c01076f4: 8b 45 08 mov 0x8(%ebp),%eax -c01076f7: 01 d0 add %edx,%eax -c01076f9: 39 45 f4 cmp %eax,-0xc(%ebp) -c01076fc: 0f 85 6d ff ff ff jne c010766f +c0107939 : + * 它包括内存映射列表、页目录、映射缓存等重要信息 + * + * @return 分配并初始化后的`mm_struct`结构体指针,如果分配失败则返回NULL + */ +struct mm_struct * +mm_create(void) { +c0107939: 55 push %ebp +c010793a: 89 e5 mov %esp,%ebp +c010793c: 83 ec 28 sub $0x28,%esp + // 分配一个mm_struct结构体的空间 + struct mm_struct *mm = kmalloc(sizeof(struct mm_struct)); +c010793f: c7 04 24 18 00 00 00 movl $0x18,(%esp) +c0107946: e8 ff d1 ff ff call c0104b4a +c010794b: 89 45 f4 mov %eax,-0xc(%ebp) + // 检查是否成功分配了内存 + if (mm != NULL) { +c010794e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0107952: 74 59 je c01079ad + // 初始化内存映射列表 + list_init(&(mm->mmap_list)); +c0107954: 8b 45 f4 mov -0xc(%ebp),%eax +c0107957: 89 45 f0 mov %eax,-0x10(%ebp) + elm->prev = elm->next = elm; +c010795a: 8b 45 f0 mov -0x10(%ebp),%eax +c010795d: 8b 55 f0 mov -0x10(%ebp),%edx +c0107960: 89 50 04 mov %edx,0x4(%eax) +c0107963: 8b 45 f0 mov -0x10(%ebp),%eax +c0107966: 8b 50 04 mov 0x4(%eax),%edx +c0107969: 8b 45 f0 mov -0x10(%ebp),%eax +c010796c: 89 10 mov %edx,(%eax) +} +c010796e: 90 nop + // 设置映射缓存为NULL,表示尚未缓存任何映射 + mm->mmap_cache = NULL; +c010796f: 8b 45 f4 mov -0xc(%ebp),%eax +c0107972: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) + // 设置页目录为NULL,表示尚未分配页目录 + mm->pgdir = NULL; +c0107979: 8b 45 f4 mov -0xc(%ebp),%eax +c010797c: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) + // 初始化映射计数为0,表示尚未创建任何内存映射 + mm->map_count = 0; +c0107983: 8b 45 f4 mov -0xc(%ebp),%eax +c0107986: c7 40 10 00 00 00 00 movl $0x0,0x10(%eax) + // 如果交换空间初始化成功,则为当前内存管理结构体进行交换空间初始化 + if (swap_init_ok) swap_init_mm(mm); +c010798d: a1 a4 c0 12 c0 mov 0xc012c0a4,%eax +c0107992: 85 c0 test %eax,%eax +c0107994: 74 0d je c01079a3 +c0107996: 8b 45 f4 mov -0xc(%ebp),%eax +c0107999: 89 04 24 mov %eax,(%esp) +c010799c: e8 df ee ff ff call c0106880 +c01079a1: eb 0a jmp c01079ad + else mm->sm_priv = NULL; +c01079a3: 8b 45 f4 mov -0xc(%ebp),%eax +c01079a6: c7 40 14 00 00 00 00 movl $0x0,0x14(%eax) } - // 设置第一个页的 property 为块的总数 - base->property = n; -c0107702: 8b 45 08 mov 0x8(%ebp),%eax -c0107705: 8b 55 0c mov 0xc(%ebp),%edx -c0107708: 89 50 08 mov %edx,0x8(%eax) - SetPageProperty(base);// 设置当前页的有效标志 -c010770b: 8b 45 08 mov 0x8(%ebp),%eax -c010770e: 83 c0 04 add $0x4,%eax -c0107711: c7 45 d0 01 00 00 00 movl $0x1,-0x30(%ebp) -c0107718: 89 45 cc mov %eax,-0x34(%ebp) - asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); -c010771b: 8b 45 cc mov -0x34(%ebp),%eax -c010771e: 8b 55 d0 mov -0x30(%ebp),%edx -c0107721: 0f ab 10 bts %edx,(%eax) -} -c0107724: 90 nop - nr_free += n;// 更新空闲页计数 -c0107725: 8b 15 ac e1 12 c0 mov 0xc012e1ac,%edx -c010772b: 8b 45 0c mov 0xc(%ebp),%eax -c010772e: 01 d0 add %edx,%eax -c0107730: a3 ac e1 12 c0 mov %eax,0xc012e1ac - list_add_before(&free_list, &(base->page_link));// 将该块添加到空闲列表中 -c0107735: 8b 45 08 mov 0x8(%ebp),%eax -c0107738: 83 c0 0c add $0xc,%eax -c010773b: c7 45 e4 a4 e1 12 c0 movl $0xc012e1a4,-0x1c(%ebp) -c0107742: 89 45 e0 mov %eax,-0x20(%ebp) - __list_add(elm, listelm->prev, listelm); -c0107745: 8b 45 e4 mov -0x1c(%ebp),%eax -c0107748: 8b 00 mov (%eax),%eax -c010774a: 8b 55 e0 mov -0x20(%ebp),%edx -c010774d: 89 55 dc mov %edx,-0x24(%ebp) -c0107750: 89 45 d8 mov %eax,-0x28(%ebp) -c0107753: 8b 45 e4 mov -0x1c(%ebp),%eax -c0107756: 89 45 d4 mov %eax,-0x2c(%ebp) - prev->next = next->prev = elm; -c0107759: 8b 45 d4 mov -0x2c(%ebp),%eax -c010775c: 8b 55 dc mov -0x24(%ebp),%edx -c010775f: 89 10 mov %edx,(%eax) -c0107761: 8b 45 d4 mov -0x2c(%ebp),%eax -c0107764: 8b 10 mov (%eax),%edx -c0107766: 8b 45 d8 mov -0x28(%ebp),%eax -c0107769: 89 50 04 mov %edx,0x4(%eax) - elm->next = next; -c010776c: 8b 45 dc mov -0x24(%ebp),%eax -c010776f: 8b 55 d4 mov -0x2c(%ebp),%edx -c0107772: 89 50 04 mov %edx,0x4(%eax) - elm->prev = prev; -c0107775: 8b 45 dc mov -0x24(%ebp),%eax -c0107778: 8b 55 d8 mov -0x28(%ebp),%edx -c010777b: 89 10 mov %edx,(%eax) -} -c010777d: 90 nop -} -c010777e: 90 nop + // 返回分配并初始化后的内存管理结构体指针 + return mm; +c01079ad: 8b 45 f4 mov -0xc(%ebp),%eax } -c010777f: 90 nop -c0107780: c9 leave -c0107781: c3 ret +c01079b0: 89 ec mov %ebp,%esp +c01079b2: 5d pop %ebp +c01079b3: c3 ret -c0107782 : - -//用于分配指定数量的连续物理页。该函数实现了首次适应内存分配算法。 -static struct Page * -default_alloc_pages(size_t n) { -c0107782: f3 0f 1e fb endbr32 -c0107786: 55 push %ebp -c0107787: 89 e5 mov %esp,%ebp -c0107789: 83 ec 68 sub $0x68,%esp - assert(n > 0);// 确保请求的页数大于零 -c010778c: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c0107790: 75 24 jne c01077b6 -c0107792: c7 44 24 0c 9c bd 10 movl $0xc010bd9c,0xc(%esp) -c0107799: c0 -c010779a: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01077a1: c0 -c01077a2: c7 44 24 04 ac 00 00 movl $0xac,0x4(%esp) -c01077a9: 00 -c01077aa: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01077b1: e8 8d 8c ff ff call c0100443 <__panic> - if (n > nr_free) {// 检查请求的页数是否超过空闲页数 -c01077b6: a1 ac e1 12 c0 mov 0xc012e1ac,%eax -c01077bb: 39 45 08 cmp %eax,0x8(%ebp) -c01077be: 76 0a jbe c01077ca - return NULL; -c01077c0: b8 00 00 00 00 mov $0x0,%eax -c01077c5: e9 3c 01 00 00 jmp c0107906 +c01079b4 : + * @param vm_flags 虚拟内存区域的标志,表示内存区域的权限和特性。 + * + * @return 返回指向新创建的vma_struct结构体的指针,如果内存分配失败,则返回NULL。 + */ +struct vma_struct * +vma_create(uintptr_t vm_start, uintptr_t vm_end, uint32_t vm_flags) { +c01079b4: 55 push %ebp +c01079b5: 89 e5 mov %esp,%ebp +c01079b7: 83 ec 28 sub $0x28,%esp + // 分配vma_struct结构体所需的内存空间 + struct vma_struct *vma = kmalloc(sizeof(struct vma_struct)); +c01079ba: c7 04 24 18 00 00 00 movl $0x18,(%esp) +c01079c1: e8 84 d1 ff ff call c0104b4a +c01079c6: 89 45 f4 mov %eax,-0xc(%ebp) + // 检查内存是否成功分配 + if (vma != NULL) { +c01079c9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c01079cd: 74 1b je c01079ea + // 初始化vma_struct的成员变量 + vma->vm_start = vm_start; +c01079cf: 8b 45 f4 mov -0xc(%ebp),%eax +c01079d2: 8b 55 08 mov 0x8(%ebp),%edx +c01079d5: 89 50 04 mov %edx,0x4(%eax) + vma->vm_end = vm_end; +c01079d8: 8b 45 f4 mov -0xc(%ebp),%eax +c01079db: 8b 55 0c mov 0xc(%ebp),%edx +c01079de: 89 50 08 mov %edx,0x8(%eax) + vma->vm_flags = vm_flags; +c01079e1: 8b 45 f4 mov -0xc(%ebp),%eax +c01079e4: 8b 55 10 mov 0x10(%ebp),%edx +c01079e7: 89 50 0c mov %edx,0xc(%eax) } - struct Page *page = NULL;// 初始化分配的页指针 -c01077ca: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) - list_entry_t *le = &free_list;// 初始化链表迭代器 -c01077d1: c7 45 f0 a4 e1 12 c0 movl $0xc012e1a4,-0x10(%ebp) - // 遍历空闲列表,寻找第一个满足条件的块 - while ((le = list_next(le)) != &free_list) { -c01077d8: eb 1c jmp c01077f6 - struct Page *p = le2page(le, page_link);// 将链表节点转换为 Page 结构体 -c01077da: 8b 45 f0 mov -0x10(%ebp),%eax -c01077dd: 83 e8 0c sub $0xc,%eax -c01077e0: 89 45 ec mov %eax,-0x14(%ebp) - if (p->property >= n) {// 检查当前块的页数是否满足请求 -c01077e3: 8b 45 ec mov -0x14(%ebp),%eax -c01077e6: 8b 40 08 mov 0x8(%eax),%eax -c01077e9: 39 45 08 cmp %eax,0x8(%ebp) -c01077ec: 77 08 ja c01077f6 - page = p;// 找到合适的块 -c01077ee: 8b 45 ec mov -0x14(%ebp),%eax -c01077f1: 89 45 f4 mov %eax,-0xc(%ebp) - break;// 退出循环 -c01077f4: eb 18 jmp c010780e -c01077f6: 8b 45 f0 mov -0x10(%ebp),%eax -c01077f9: 89 45 e4 mov %eax,-0x1c(%ebp) + // 返回指向新创建的vma_struct结构体的指针,或在内存分配失败时返回NULL + return vma; +c01079ea: 8b 45 f4 mov -0xc(%ebp),%eax +} +c01079ed: 89 ec mov %ebp,%esp +c01079ef: 5d pop %ebp +c01079f0: c3 ret + +c01079f1 : + * 此函数首先检查mmap_cache是否包含所需的VMA,以加速查找过程 + * 如果mmap_cache未命中,则遍历VMA列表,直到找到包含给定地址的VMA或确定不存在这样的VMA + * 如果找到了合适的VMA,它将更新mmap_cache以供后续查找使用 + */ +struct vma_struct * +find_vma(struct mm_struct *mm, uintptr_t addr) { +c01079f1: 55 push %ebp +c01079f2: 89 e5 mov %esp,%ebp +c01079f4: 83 ec 20 sub $0x20,%esp + struct vma_struct *vma = NULL;// 初始化VMA指针为NULL +c01079f7: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) + if (mm != NULL) {// 检查传入的内存描述符是否有效 +c01079fe: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0107a02: 0f 84 95 00 00 00 je c0107a9d + // 检查mmap_cache是否包含所需的VMA + vma = mm->mmap_cache; +c0107a08: 8b 45 08 mov 0x8(%ebp),%eax +c0107a0b: 8b 40 08 mov 0x8(%eax),%eax +c0107a0e: 89 45 fc mov %eax,-0x4(%ebp) + if (!(vma != NULL && vma->vm_start <= addr && vma->vm_end > addr)) { +c0107a11: 83 7d fc 00 cmpl $0x0,-0x4(%ebp) +c0107a15: 74 16 je c0107a2d +c0107a17: 8b 45 fc mov -0x4(%ebp),%eax +c0107a1a: 8b 40 04 mov 0x4(%eax),%eax +c0107a1d: 39 45 0c cmp %eax,0xc(%ebp) +c0107a20: 72 0b jb c0107a2d +c0107a22: 8b 45 fc mov -0x4(%ebp),%eax +c0107a25: 8b 40 08 mov 0x8(%eax),%eax +c0107a28: 39 45 0c cmp %eax,0xc(%ebp) +c0107a2b: 72 61 jb c0107a8e + // 如果mmap_cache未命中,则开始遍历VMA列表 + bool found = 0;// 初始化找到标志为0 +c0107a2d: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%ebp) + // 获取VMA列表的头指针 + list_entry_t *list = &(mm->mmap_list), *le = list; +c0107a34: 8b 45 08 mov 0x8(%ebp),%eax +c0107a37: 89 45 f0 mov %eax,-0x10(%ebp) +c0107a3a: 8b 45 f0 mov -0x10(%ebp),%eax +c0107a3d: 89 45 f4 mov %eax,-0xc(%ebp) + while ((le = list_next(le)) != list) { // 遍历VMA列表 +c0107a40: eb 28 jmp c0107a6a + vma = le2vma(le, list_link);// 将链表项转换为VMA结构 +c0107a42: 8b 45 f4 mov -0xc(%ebp),%eax +c0107a45: 83 e8 10 sub $0x10,%eax +c0107a48: 89 45 fc mov %eax,-0x4(%ebp) + // 检查当前VMA是否包含给定地址 + if (vma->vm_start<=addr && addr < vma->vm_end) { +c0107a4b: 8b 45 fc mov -0x4(%ebp),%eax +c0107a4e: 8b 40 04 mov 0x4(%eax),%eax +c0107a51: 39 45 0c cmp %eax,0xc(%ebp) +c0107a54: 72 14 jb c0107a6a +c0107a56: 8b 45 fc mov -0x4(%ebp),%eax +c0107a59: 8b 40 08 mov 0x8(%eax),%eax +c0107a5c: 39 45 0c cmp %eax,0xc(%ebp) +c0107a5f: 73 09 jae c0107a6a + found = 1;// 找到合适的VMA +c0107a61: c7 45 f8 01 00 00 00 movl $0x1,-0x8(%ebp) + break;// 结束循环 +c0107a68: eb 17 jmp c0107a81 +c0107a6a: 8b 45 f4 mov -0xc(%ebp),%eax +c0107a6d: 89 45 ec mov %eax,-0x14(%ebp) return listelm->next; -c01077fc: 8b 45 e4 mov -0x1c(%ebp),%eax -c01077ff: 8b 40 04 mov 0x4(%eax),%eax - while ((le = list_next(le)) != &free_list) { -c0107802: 89 45 f0 mov %eax,-0x10(%ebp) -c0107805: 81 7d f0 a4 e1 12 c0 cmpl $0xc012e1a4,-0x10(%ebp) -c010780c: 75 cc jne c01077da +c0107a70: 8b 45 ec mov -0x14(%ebp),%eax +c0107a73: 8b 40 04 mov 0x4(%eax),%eax + while ((le = list_next(le)) != list) { // 遍历VMA列表 +c0107a76: 89 45 f4 mov %eax,-0xc(%ebp) +c0107a79: 8b 45 f4 mov -0xc(%ebp),%eax +c0107a7c: 3b 45 f0 cmp -0x10(%ebp),%eax +c0107a7f: 75 c1 jne c0107a42 + } + } + if (!found) {// 如果未找到合适的VMA +c0107a81: 83 7d f8 00 cmpl $0x0,-0x8(%ebp) +c0107a85: 75 07 jne c0107a8e + vma = NULL;// 将VMA指针设置为NULL +c0107a87: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) + } + } + // 如果找到了合适的VMA,更新mmap_cache + if (vma != NULL) { +c0107a8e: 83 7d fc 00 cmpl $0x0,-0x4(%ebp) +c0107a92: 74 09 je c0107a9d + mm->mmap_cache = vma;// 更新mmap_cache以加速后续查找 +c0107a94: 8b 45 08 mov 0x8(%ebp),%eax +c0107a97: 8b 55 fc mov -0x4(%ebp),%edx +c0107a9a: 89 50 08 mov %edx,0x8(%eax) } } - if (page != NULL) {// 如果找到合适的块 -c010780e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0107812: 0f 84 eb 00 00 00 je c0107903 - //list_del(&(page->page_link));// 从空闲列表中删除该块 - if (page->property > n) { -c0107818: 8b 45 f4 mov -0xc(%ebp),%eax -c010781b: 8b 40 08 mov 0x8(%eax),%eax -c010781e: 39 45 08 cmp %eax,0x8(%ebp) -c0107821: 0f 83 88 00 00 00 jae c01078af - struct Page *p = page + n;// 指向剩余的页 -c0107827: 8b 45 08 mov 0x8(%ebp),%eax -c010782a: c1 e0 05 shl $0x5,%eax -c010782d: 89 c2 mov %eax,%edx -c010782f: 8b 45 f4 mov -0xc(%ebp),%eax -c0107832: 01 d0 add %edx,%eax -c0107834: 89 45 e8 mov %eax,-0x18(%ebp) - p->property = page->property - n;// 更新剩余块的页数 -c0107837: 8b 45 f4 mov -0xc(%ebp),%eax -c010783a: 8b 40 08 mov 0x8(%eax),%eax -c010783d: 2b 45 08 sub 0x8(%ebp),%eax -c0107840: 89 c2 mov %eax,%edx -c0107842: 8b 45 e8 mov -0x18(%ebp),%eax -c0107845: 89 50 08 mov %edx,0x8(%eax) - SetPageProperty(p); -c0107848: 8b 45 e8 mov -0x18(%ebp),%eax -c010784b: 83 c0 04 add $0x4,%eax -c010784e: c7 45 cc 01 00 00 00 movl $0x1,-0x34(%ebp) -c0107855: 89 45 c8 mov %eax,-0x38(%ebp) - asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); -c0107858: 8b 45 c8 mov -0x38(%ebp),%eax -c010785b: 8b 55 cc mov -0x34(%ebp),%edx -c010785e: 0f ab 10 bts %edx,(%eax) -} -c0107861: 90 nop - list_add_after(&(page->page_link), &(p->page_link));// 将剩余块添加回空闲列表 -c0107862: 8b 45 e8 mov -0x18(%ebp),%eax -c0107865: 83 c0 0c add $0xc,%eax -c0107868: 8b 55 f4 mov -0xc(%ebp),%edx -c010786b: 83 c2 0c add $0xc,%edx -c010786e: 89 55 e0 mov %edx,-0x20(%ebp) -c0107871: 89 45 dc mov %eax,-0x24(%ebp) - __list_add(elm, listelm, listelm->next); -c0107874: 8b 45 e0 mov -0x20(%ebp),%eax -c0107877: 8b 40 04 mov 0x4(%eax),%eax -c010787a: 8b 55 dc mov -0x24(%ebp),%edx -c010787d: 89 55 d8 mov %edx,-0x28(%ebp) -c0107880: 8b 55 e0 mov -0x20(%ebp),%edx -c0107883: 89 55 d4 mov %edx,-0x2c(%ebp) -c0107886: 89 45 d0 mov %eax,-0x30(%ebp) - prev->next = next->prev = elm; -c0107889: 8b 45 d0 mov -0x30(%ebp),%eax -c010788c: 8b 55 d8 mov -0x28(%ebp),%edx -c010788f: 89 10 mov %edx,(%eax) -c0107891: 8b 45 d0 mov -0x30(%ebp),%eax -c0107894: 8b 10 mov (%eax),%edx -c0107896: 8b 45 d4 mov -0x2c(%ebp),%eax -c0107899: 89 50 04 mov %edx,0x4(%eax) - elm->next = next; -c010789c: 8b 45 d8 mov -0x28(%ebp),%eax -c010789f: 8b 55 d0 mov -0x30(%ebp),%edx -c01078a2: 89 50 04 mov %edx,0x4(%eax) - elm->prev = prev; -c01078a5: 8b 45 d8 mov -0x28(%ebp),%eax -c01078a8: 8b 55 d4 mov -0x2c(%ebp),%edx -c01078ab: 89 10 mov %edx,(%eax) -} -c01078ad: 90 nop -} -c01078ae: 90 nop - } - list_del(&(page->page_link)); -c01078af: 8b 45 f4 mov -0xc(%ebp),%eax -c01078b2: 83 c0 0c add $0xc,%eax -c01078b5: 89 45 bc mov %eax,-0x44(%ebp) - __list_del(listelm->prev, listelm->next); -c01078b8: 8b 45 bc mov -0x44(%ebp),%eax -c01078bb: 8b 40 04 mov 0x4(%eax),%eax -c01078be: 8b 55 bc mov -0x44(%ebp),%edx -c01078c1: 8b 12 mov (%edx),%edx -c01078c3: 89 55 b8 mov %edx,-0x48(%ebp) -c01078c6: 89 45 b4 mov %eax,-0x4c(%ebp) - prev->next = next; -c01078c9: 8b 45 b8 mov -0x48(%ebp),%eax -c01078cc: 8b 55 b4 mov -0x4c(%ebp),%edx -c01078cf: 89 50 04 mov %edx,0x4(%eax) - next->prev = prev; -c01078d2: 8b 45 b4 mov -0x4c(%ebp),%eax -c01078d5: 8b 55 b8 mov -0x48(%ebp),%edx -c01078d8: 89 10 mov %edx,(%eax) -} -c01078da: 90 nop -} -c01078db: 90 nop - nr_free -= n;// 减少空闲页的计数 -c01078dc: a1 ac e1 12 c0 mov 0xc012e1ac,%eax -c01078e1: 2b 45 08 sub 0x8(%ebp),%eax -c01078e4: a3 ac e1 12 c0 mov %eax,0xc012e1ac - ClearPageProperty(page);// 清除已分配页的属性 -c01078e9: 8b 45 f4 mov -0xc(%ebp),%eax -c01078ec: 83 c0 04 add $0x4,%eax -c01078ef: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) -c01078f6: 89 45 c0 mov %eax,-0x40(%ebp) - asm volatile ("btrl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); -c01078f9: 8b 45 c0 mov -0x40(%ebp),%eax -c01078fc: 8b 55 c4 mov -0x3c(%ebp),%edx -c01078ff: 0f b3 10 btr %edx,(%eax) -} -c0107902: 90 nop - } - return page;// 返回分配的页块 -c0107903: 8b 45 f4 mov -0xc(%ebp),%eax + return vma; +c0107a9d: 8b 45 fc mov -0x4(%ebp),%eax } -c0107906: c9 leave -c0107907: c3 ret +c0107aa0: 89 ec mov %ebp,%esp +c0107aa2: 5d pop %ebp +c0107aa3: c3 ret -c0107908 : +c0107aa4 : + * + * @param prev 指向前一个虚拟内存区域(VMA)的结构体指针 + * @param next 指向后一个虚拟内存区域(VMA)的结构体指针 + */ +static inline void +check_vma_overlap(struct vma_struct *prev, struct vma_struct *next) { +c0107aa4: 55 push %ebp +c0107aa5: 89 e5 mov %esp,%ebp +c0107aa7: 83 ec 18 sub $0x18,%esp + assert(prev->vm_start < prev->vm_end);// 确保前一个VMA的地址范围是有效的 +c0107aaa: 8b 45 08 mov 0x8(%ebp),%eax +c0107aad: 8b 50 04 mov 0x4(%eax),%edx +c0107ab0: 8b 45 08 mov 0x8(%ebp),%eax +c0107ab3: 8b 40 08 mov 0x8(%eax),%eax +c0107ab6: 39 c2 cmp %eax,%edx +c0107ab8: 72 24 jb c0107ade +c0107aba: c7 44 24 0c c5 ba 10 movl $0xc010bac5,0xc(%esp) +c0107ac1: c0 +c0107ac2: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0107ac9: c0 +c0107aca: c7 44 24 04 a1 00 00 movl $0xa1,0x4(%esp) +c0107ad1: 00 +c0107ad2: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0107ad9: e8 67 91 ff ff call c0100c45 <__panic> + assert(prev->vm_end <= next->vm_start);// 确保两个VMA之间没有重叠 +c0107ade: 8b 45 08 mov 0x8(%ebp),%eax +c0107ae1: 8b 50 08 mov 0x8(%eax),%edx +c0107ae4: 8b 45 0c mov 0xc(%ebp),%eax +c0107ae7: 8b 40 04 mov 0x4(%eax),%eax +c0107aea: 39 c2 cmp %eax,%edx +c0107aec: 76 24 jbe c0107b12 +c0107aee: c7 44 24 0c 08 bb 10 movl $0xc010bb08,0xc(%esp) +c0107af5: c0 +c0107af6: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0107afd: c0 +c0107afe: c7 44 24 04 a2 00 00 movl $0xa2,0x4(%esp) +c0107b05: 00 +c0107b06: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0107b0d: e8 33 91 ff ff call c0100c45 <__panic> + assert(next->vm_start < next->vm_end);// 确保后一个VMA的地址范围是有效的 +c0107b12: 8b 45 0c mov 0xc(%ebp),%eax +c0107b15: 8b 50 04 mov 0x4(%eax),%edx +c0107b18: 8b 45 0c mov 0xc(%ebp),%eax +c0107b1b: 8b 40 08 mov 0x8(%eax),%eax +c0107b1e: 39 c2 cmp %eax,%edx +c0107b20: 72 24 jb c0107b46 +c0107b22: c7 44 24 0c 27 bb 10 movl $0xc010bb27,0xc(%esp) +c0107b29: c0 +c0107b2a: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0107b31: c0 +c0107b32: c7 44 24 04 a3 00 00 movl $0xa3,0x4(%esp) +c0107b39: 00 +c0107b3a: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0107b41: e8 ff 90 ff ff call c0100c45 <__panic> +} +c0107b46: 90 nop +c0107b47: 89 ec mov %ebp,%esp +c0107b49: 5d pop %ebp +c0107b4a: c3 ret + +c0107b4b : + * + * @param mm 指向内存描述符结构 `struct mm_struct` 的指针,表示一个进程的内存空间。 + * @param vma 指向要插入的VMA结构 `struct vma_struct` 的指针,描述一个内存区域。 + */ +void +insert_vma_struct(struct mm_struct *mm, struct vma_struct *vma) { +c0107b4b: 55 push %ebp +c0107b4c: 89 e5 mov %esp,%ebp +c0107b4e: 83 ec 48 sub $0x48,%esp + // 断言VMA结构的起始地址小于结束地址,确保VMA结构的有效性。 + assert(vma->vm_start < vma->vm_end); +c0107b51: 8b 45 0c mov 0xc(%ebp),%eax +c0107b54: 8b 50 04 mov 0x4(%eax),%edx +c0107b57: 8b 45 0c mov 0xc(%ebp),%eax +c0107b5a: 8b 40 08 mov 0x8(%eax),%eax +c0107b5d: 39 c2 cmp %eax,%edx +c0107b5f: 72 24 jb c0107b85 +c0107b61: c7 44 24 0c 45 bb 10 movl $0xc010bb45,0xc(%esp) +c0107b68: c0 +c0107b69: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0107b70: c0 +c0107b71: c7 44 24 04 b4 00 00 movl $0xb4,0x4(%esp) +c0107b78: 00 +c0107b79: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0107b80: e8 c0 90 ff ff call c0100c45 <__panic> + // 指向内存描述符中的VMA链表。 + list_entry_t *list = &(mm->mmap_list); +c0107b85: 8b 45 08 mov 0x8(%ebp),%eax +c0107b88: 89 45 ec mov %eax,-0x14(%ebp) + // 遍历链表以找到新VMA结构的正确插入位置。 + list_entry_t *le_prev = list, *le_next; +c0107b8b: 8b 45 ec mov -0x14(%ebp),%eax +c0107b8e: 89 45 f4 mov %eax,-0xc(%ebp) -static void -default_free_pages(struct Page *base, size_t n) { -c0107908: f3 0f 1e fb endbr32 -c010790c: 55 push %ebp -c010790d: 89 e5 mov %esp,%ebp -c010790f: 81 ec 98 00 00 00 sub $0x98,%esp - assert(n > 0);// 确保请求释放的页数大于零 -c0107915: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) -c0107919: 75 24 jne c010793f -c010791b: c7 44 24 0c 9c bd 10 movl $0xc010bd9c,0xc(%esp) -c0107922: c0 -c0107923: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c010792a: c0 -c010792b: c7 44 24 04 cb 00 00 movl $0xcb,0x4(%esp) -c0107932: 00 -c0107933: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c010793a: e8 04 8b ff ff call c0100443 <__panic> - struct Page *p = base; -c010793f: 8b 45 08 mov 0x8(%ebp),%eax -c0107942: 89 45 f4 mov %eax,-0xc(%ebp) - // 遍历释放的页,检查状态并重置 - for (; p != base + n; p ++) { -c0107945: e9 9d 00 00 00 jmp c01079e7 - assert(!PageReserved(p) && !PageProperty(p));// 确保页没有被保留并且没有属性 -c010794a: 8b 45 f4 mov -0xc(%ebp),%eax -c010794d: 83 c0 04 add $0x4,%eax -c0107950: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) -c0107957: 89 45 e8 mov %eax,-0x18(%ebp) - asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); -c010795a: 8b 45 e8 mov -0x18(%ebp),%eax -c010795d: 8b 55 ec mov -0x14(%ebp),%edx -c0107960: 0f a3 10 bt %edx,(%eax) -c0107963: 19 c0 sbb %eax,%eax -c0107965: 89 45 e4 mov %eax,-0x1c(%ebp) - return oldbit != 0; -c0107968: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) -c010796c: 0f 95 c0 setne %al -c010796f: 0f b6 c0 movzbl %al,%eax -c0107972: 85 c0 test %eax,%eax -c0107974: 75 2c jne c01079a2 -c0107976: 8b 45 f4 mov -0xc(%ebp),%eax -c0107979: 83 c0 04 add $0x4,%eax -c010797c: c7 45 e0 01 00 00 00 movl $0x1,-0x20(%ebp) -c0107983: 89 45 dc mov %eax,-0x24(%ebp) - asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); -c0107986: 8b 45 dc mov -0x24(%ebp),%eax -c0107989: 8b 55 e0 mov -0x20(%ebp),%edx -c010798c: 0f a3 10 bt %edx,(%eax) -c010798f: 19 c0 sbb %eax,%eax -c0107991: 89 45 d8 mov %eax,-0x28(%ebp) - return oldbit != 0; -c0107994: 83 7d d8 00 cmpl $0x0,-0x28(%ebp) -c0107998: 0f 95 c0 setne %al -c010799b: 0f b6 c0 movzbl %al,%eax -c010799e: 85 c0 test %eax,%eax -c01079a0: 74 24 je c01079c6 -c01079a2: c7 44 24 0c e0 bd 10 movl $0xc010bde0,0xc(%esp) -c01079a9: c0 -c01079aa: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01079b1: c0 -c01079b2: c7 44 24 04 cf 00 00 movl $0xcf,0x4(%esp) -c01079b9: 00 -c01079ba: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01079c1: e8 7d 8a ff ff call c0100443 <__panic> - p->flags = 0;// 清除 flags 字段 -c01079c6: 8b 45 f4 mov -0xc(%ebp),%eax -c01079c9: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) - set_page_ref(p, 0);// 清除引用计数 -c01079d0: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c01079d7: 00 -c01079d8: 8b 45 f4 mov -0xc(%ebp),%eax -c01079db: 89 04 24 mov %eax,(%esp) -c01079de: e8 0f fc ff ff call c01075f2 - for (; p != base + n; p ++) { -c01079e3: 83 45 f4 20 addl $0x20,-0xc(%ebp) -c01079e7: 8b 45 0c mov 0xc(%ebp),%eax -c01079ea: c1 e0 05 shl $0x5,%eax -c01079ed: 89 c2 mov %eax,%edx -c01079ef: 8b 45 08 mov 0x8(%ebp),%eax -c01079f2: 01 d0 add %edx,%eax -c01079f4: 39 45 f4 cmp %eax,-0xc(%ebp) -c01079f7: 0f 85 4d ff ff ff jne c010794a + list_entry_t *le = list; +c0107b91: 8b 45 ec mov -0x14(%ebp),%eax +c0107b94: 89 45 f0 mov %eax,-0x10(%ebp) + // 遍历链表以找到新VMA结构的正确插入位置 + while ((le = list_next(le)) != list) { +c0107b97: eb 1f jmp c0107bb8 + struct vma_struct *mmap_prev = le2vma(le, list_link); +c0107b99: 8b 45 f0 mov -0x10(%ebp),%eax +c0107b9c: 83 e8 10 sub $0x10,%eax +c0107b9f: 89 45 e8 mov %eax,-0x18(%ebp) + // 如果当前VMA的起始地址大于新VMA的起始地址,则跳出循环 + if (mmap_prev->vm_start > vma->vm_start) { +c0107ba2: 8b 45 e8 mov -0x18(%ebp),%eax +c0107ba5: 8b 50 04 mov 0x4(%eax),%edx +c0107ba8: 8b 45 0c mov 0xc(%ebp),%eax +c0107bab: 8b 40 04 mov 0x4(%eax),%eax +c0107bae: 39 c2 cmp %eax,%edx +c0107bb0: 77 1f ja c0107bd1 + break; + } + le_prev = le; +c0107bb2: 8b 45 f0 mov -0x10(%ebp),%eax +c0107bb5: 89 45 f4 mov %eax,-0xc(%ebp) +c0107bb8: 8b 45 f0 mov -0x10(%ebp),%eax +c0107bbb: 89 45 e0 mov %eax,-0x20(%ebp) +c0107bbe: 8b 45 e0 mov -0x20(%ebp),%eax +c0107bc1: 8b 40 04 mov 0x4(%eax),%eax + while ((le = list_next(le)) != list) { +c0107bc4: 89 45 f0 mov %eax,-0x10(%ebp) +c0107bc7: 8b 45 f0 mov -0x10(%ebp),%eax +c0107bca: 3b 45 ec cmp -0x14(%ebp),%eax +c0107bcd: 75 ca jne c0107b99 +c0107bcf: eb 01 jmp c0107bd2 + break; +c0107bd1: 90 nop +c0107bd2: 8b 45 f4 mov -0xc(%ebp),%eax +c0107bd5: 89 45 dc mov %eax,-0x24(%ebp) +c0107bd8: 8b 45 dc mov -0x24(%ebp),%eax +c0107bdb: 8b 40 04 mov 0x4(%eax),%eax + } + // 获取下一个链表项 + le_next = list_next(le_prev); +c0107bde: 89 45 e4 mov %eax,-0x1c(%ebp) + + /* check overlap */ + // 检查前一个VMA结构是否与新VMA结构重叠 + if (le_prev != list) { +c0107be1: 8b 45 f4 mov -0xc(%ebp),%eax +c0107be4: 3b 45 ec cmp -0x14(%ebp),%eax +c0107be7: 74 15 je c0107bfe + check_vma_overlap(le2vma(le_prev, list_link), vma); +c0107be9: 8b 45 f4 mov -0xc(%ebp),%eax +c0107bec: 8d 50 f0 lea -0x10(%eax),%edx +c0107bef: 8b 45 0c mov 0xc(%ebp),%eax +c0107bf2: 89 44 24 04 mov %eax,0x4(%esp) +c0107bf6: 89 14 24 mov %edx,(%esp) +c0107bf9: e8 a6 fe ff ff call c0107aa4 } - // 设置基页的属性为释放的页数 - base->property = n; -c01079fd: 8b 45 08 mov 0x8(%ebp),%eax -c0107a00: 8b 55 0c mov 0xc(%ebp),%edx -c0107a03: 89 50 08 mov %edx,0x8(%eax) - SetPageProperty(base);// 设置页的有效标志 -c0107a06: 8b 45 08 mov 0x8(%ebp),%eax -c0107a09: 83 c0 04 add $0x4,%eax -c0107a0c: c7 45 d0 01 00 00 00 movl $0x1,-0x30(%ebp) -c0107a13: 89 45 cc mov %eax,-0x34(%ebp) - asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); -c0107a16: 8b 45 cc mov -0x34(%ebp),%eax -c0107a19: 8b 55 d0 mov -0x30(%ebp),%edx -c0107a1c: 0f ab 10 bts %edx,(%eax) -} -c0107a1f: 90 nop -c0107a20: c7 45 d4 a4 e1 12 c0 movl $0xc012e1a4,-0x2c(%ebp) - return listelm->next; -c0107a27: 8b 45 d4 mov -0x2c(%ebp),%eax -c0107a2a: 8b 40 04 mov 0x4(%eax),%eax - // 遍历空闲列表,检查是否需要合并 - list_entry_t *le = list_next(&free_list); -c0107a2d: 89 45 f0 mov %eax,-0x10(%ebp) - while (le != &free_list) { -c0107a30: e9 00 01 00 00 jmp c0107b35 - p = le2page(le, page_link); -c0107a35: 8b 45 f0 mov -0x10(%ebp),%eax -c0107a38: 83 e8 0c sub $0xc,%eax -c0107a3b: 89 45 f4 mov %eax,-0xc(%ebp) -c0107a3e: 8b 45 f0 mov -0x10(%ebp),%eax -c0107a41: 89 45 c8 mov %eax,-0x38(%ebp) -c0107a44: 8b 45 c8 mov -0x38(%ebp),%eax -c0107a47: 8b 40 04 mov 0x4(%eax),%eax - le = list_next(le); -c0107a4a: 89 45 f0 mov %eax,-0x10(%ebp) - // 如果当前页块与释放的页块相邻,合并 - if (base + base->property == p) { -c0107a4d: 8b 45 08 mov 0x8(%ebp),%eax -c0107a50: 8b 40 08 mov 0x8(%eax),%eax -c0107a53: c1 e0 05 shl $0x5,%eax -c0107a56: 89 c2 mov %eax,%edx -c0107a58: 8b 45 08 mov 0x8(%ebp),%eax -c0107a5b: 01 d0 add %edx,%eax -c0107a5d: 39 45 f4 cmp %eax,-0xc(%ebp) -c0107a60: 75 5d jne c0107abf - base->property += p->property;// 合并当前页块 -c0107a62: 8b 45 08 mov 0x8(%ebp),%eax -c0107a65: 8b 50 08 mov 0x8(%eax),%edx -c0107a68: 8b 45 f4 mov -0xc(%ebp),%eax -c0107a6b: 8b 40 08 mov 0x8(%eax),%eax -c0107a6e: 01 c2 add %eax,%edx -c0107a70: 8b 45 08 mov 0x8(%ebp),%eax -c0107a73: 89 50 08 mov %edx,0x8(%eax) - ClearPageProperty(p);// 清除合并页的属性 -c0107a76: 8b 45 f4 mov -0xc(%ebp),%eax -c0107a79: 83 c0 04 add $0x4,%eax -c0107a7c: c7 45 b8 01 00 00 00 movl $0x1,-0x48(%ebp) -c0107a83: 89 45 b4 mov %eax,-0x4c(%ebp) - asm volatile ("btrl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); -c0107a86: 8b 45 b4 mov -0x4c(%ebp),%eax -c0107a89: 8b 55 b8 mov -0x48(%ebp),%edx -c0107a8c: 0f b3 10 btr %edx,(%eax) -} -c0107a8f: 90 nop - list_del(&(p->page_link));// 从空闲列表中删除合并页 -c0107a90: 8b 45 f4 mov -0xc(%ebp),%eax -c0107a93: 83 c0 0c add $0xc,%eax -c0107a96: 89 45 c4 mov %eax,-0x3c(%ebp) - __list_del(listelm->prev, listelm->next); -c0107a99: 8b 45 c4 mov -0x3c(%ebp),%eax -c0107a9c: 8b 40 04 mov 0x4(%eax),%eax -c0107a9f: 8b 55 c4 mov -0x3c(%ebp),%edx -c0107aa2: 8b 12 mov (%edx),%edx -c0107aa4: 89 55 c0 mov %edx,-0x40(%ebp) -c0107aa7: 89 45 bc mov %eax,-0x44(%ebp) - prev->next = next; -c0107aaa: 8b 45 c0 mov -0x40(%ebp),%eax -c0107aad: 8b 55 bc mov -0x44(%ebp),%edx -c0107ab0: 89 50 04 mov %edx,0x4(%eax) - next->prev = prev; -c0107ab3: 8b 45 bc mov -0x44(%ebp),%eax -c0107ab6: 8b 55 c0 mov -0x40(%ebp),%edx -c0107ab9: 89 10 mov %edx,(%eax) -} -c0107abb: 90 nop + // 检查下一个VMA结构是否与新VMA结构重叠 + if (le_next != list) { +c0107bfe: 8b 45 e4 mov -0x1c(%ebp),%eax +c0107c01: 3b 45 ec cmp -0x14(%ebp),%eax +c0107c04: 74 15 je c0107c1b + check_vma_overlap(vma, le2vma(le_next, list_link)); +c0107c06: 8b 45 e4 mov -0x1c(%ebp),%eax +c0107c09: 83 e8 10 sub $0x10,%eax +c0107c0c: 89 44 24 04 mov %eax,0x4(%esp) +c0107c10: 8b 45 0c mov 0xc(%ebp),%eax +c0107c13: 89 04 24 mov %eax,(%esp) +c0107c16: e8 89 fe ff ff call c0107aa4 + } + // 设置VMA结构所属的内存描述符 + vma->vm_mm = mm; +c0107c1b: 8b 45 0c mov 0xc(%ebp),%eax +c0107c1e: 8b 55 08 mov 0x8(%ebp),%edx +c0107c21: 89 10 mov %edx,(%eax) + // 将新VMA结构插入链表 + list_add_after(le_prev, &(vma->list_link)); +c0107c23: 8b 45 0c mov 0xc(%ebp),%eax +c0107c26: 8d 50 10 lea 0x10(%eax),%edx +c0107c29: 8b 45 f4 mov -0xc(%ebp),%eax +c0107c2c: 89 45 d8 mov %eax,-0x28(%ebp) +c0107c2f: 89 55 d4 mov %edx,-0x2c(%ebp) + __list_add(elm, listelm, listelm->next); +c0107c32: 8b 45 d8 mov -0x28(%ebp),%eax +c0107c35: 8b 40 04 mov 0x4(%eax),%eax +c0107c38: 8b 55 d4 mov -0x2c(%ebp),%edx +c0107c3b: 89 55 d0 mov %edx,-0x30(%ebp) +c0107c3e: 8b 55 d8 mov -0x28(%ebp),%edx +c0107c41: 89 55 cc mov %edx,-0x34(%ebp) +c0107c44: 89 45 c8 mov %eax,-0x38(%ebp) + prev->next = next->prev = elm; +c0107c47: 8b 45 c8 mov -0x38(%ebp),%eax +c0107c4a: 8b 55 d0 mov -0x30(%ebp),%edx +c0107c4d: 89 10 mov %edx,(%eax) +c0107c4f: 8b 45 c8 mov -0x38(%ebp),%eax +c0107c52: 8b 10 mov (%eax),%edx +c0107c54: 8b 45 cc mov -0x34(%ebp),%eax +c0107c57: 89 50 04 mov %edx,0x4(%eax) + elm->next = next; +c0107c5a: 8b 45 d0 mov -0x30(%ebp),%eax +c0107c5d: 8b 55 c8 mov -0x38(%ebp),%edx +c0107c60: 89 50 04 mov %edx,0x4(%eax) + elm->prev = prev; +c0107c63: 8b 45 d0 mov -0x30(%ebp),%eax +c0107c66: 8b 55 cc mov -0x34(%ebp),%edx +c0107c69: 89 10 mov %edx,(%eax) } -c0107abc: 90 nop -c0107abd: eb 76 jmp c0107b35 - } - else if (p + p->property == base) { -c0107abf: 8b 45 f4 mov -0xc(%ebp),%eax -c0107ac2: 8b 40 08 mov 0x8(%eax),%eax -c0107ac5: c1 e0 05 shl $0x5,%eax -c0107ac8: 89 c2 mov %eax,%edx -c0107aca: 8b 45 f4 mov -0xc(%ebp),%eax -c0107acd: 01 d0 add %edx,%eax -c0107acf: 39 45 08 cmp %eax,0x8(%ebp) -c0107ad2: 75 61 jne c0107b35 - p->property += base->property;// 合并前一个页块 -c0107ad4: 8b 45 f4 mov -0xc(%ebp),%eax -c0107ad7: 8b 50 08 mov 0x8(%eax),%edx -c0107ada: 8b 45 08 mov 0x8(%ebp),%eax -c0107add: 8b 40 08 mov 0x8(%eax),%eax -c0107ae0: 01 c2 add %eax,%edx -c0107ae2: 8b 45 f4 mov -0xc(%ebp),%eax -c0107ae5: 89 50 08 mov %edx,0x8(%eax) - ClearPageProperty(base);// 清除当前页的属性 -c0107ae8: 8b 45 08 mov 0x8(%ebp),%eax -c0107aeb: 83 c0 04 add $0x4,%eax -c0107aee: c7 45 a4 01 00 00 00 movl $0x1,-0x5c(%ebp) -c0107af5: 89 45 a0 mov %eax,-0x60(%ebp) - asm volatile ("btrl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr)); -c0107af8: 8b 45 a0 mov -0x60(%ebp),%eax -c0107afb: 8b 55 a4 mov -0x5c(%ebp),%edx -c0107afe: 0f b3 10 btr %edx,(%eax) +c0107c6b: 90 nop } -c0107b01: 90 nop - base = p;// 更新 base 指针 -c0107b02: 8b 45 f4 mov -0xc(%ebp),%eax -c0107b05: 89 45 08 mov %eax,0x8(%ebp) - list_del(&(p->page_link));// 从空闲列表中删除当前页 -c0107b08: 8b 45 f4 mov -0xc(%ebp),%eax -c0107b0b: 83 c0 0c add $0xc,%eax -c0107b0e: 89 45 b0 mov %eax,-0x50(%ebp) +c0107c6c: 90 nop + // 增加内存描述符中的映射计数 + mm->map_count ++; +c0107c6d: 8b 45 08 mov 0x8(%ebp),%eax +c0107c70: 8b 40 10 mov 0x10(%eax),%eax +c0107c73: 8d 50 01 lea 0x1(%eax),%edx +c0107c76: 8b 45 08 mov 0x8(%ebp),%eax +c0107c79: 89 50 10 mov %edx,0x10(%eax) +} +c0107c7c: 90 nop +c0107c7d: 89 ec mov %ebp,%esp +c0107c7f: 5d pop %ebp +c0107c80: c3 ret + +c0107c81 : + * 此函数遍历并销毁与内存管理结构(mm_struct)关联的所有虚拟内存区域(VMA), + * 然后释放内存管理结构本身所占用的内存。这样做是为了确保在销毁内存管理结构之前, + * 所有相关的资源都被正确地释放。 + */ +void +mm_destroy(struct mm_struct *mm) { +c0107c81: 55 push %ebp +c0107c82: 89 e5 mov %esp,%ebp +c0107c84: 83 ec 38 sub $0x38,%esp + // 获取内存映射列表的头指针 + list_entry_t *list = &(mm->mmap_list), *le; +c0107c87: 8b 45 08 mov 0x8(%ebp),%eax +c0107c8a: 89 45 f4 mov %eax,-0xc(%ebp) + // 遍历内存映射列表,直到回到起点 + while ((le = list_next(list)) != list) { +c0107c8d: eb 38 jmp c0107cc7 +c0107c8f: 8b 45 f0 mov -0x10(%ebp),%eax +c0107c92: 89 45 ec mov %eax,-0x14(%ebp) __list_del(listelm->prev, listelm->next); -c0107b11: 8b 45 b0 mov -0x50(%ebp),%eax -c0107b14: 8b 40 04 mov 0x4(%eax),%eax -c0107b17: 8b 55 b0 mov -0x50(%ebp),%edx -c0107b1a: 8b 12 mov (%edx),%edx -c0107b1c: 89 55 ac mov %edx,-0x54(%ebp) -c0107b1f: 89 45 a8 mov %eax,-0x58(%ebp) +c0107c95: 8b 45 ec mov -0x14(%ebp),%eax +c0107c98: 8b 40 04 mov 0x4(%eax),%eax +c0107c9b: 8b 55 ec mov -0x14(%ebp),%edx +c0107c9e: 8b 12 mov (%edx),%edx +c0107ca0: 89 55 e8 mov %edx,-0x18(%ebp) +c0107ca3: 89 45 e4 mov %eax,-0x1c(%ebp) prev->next = next; -c0107b22: 8b 45 ac mov -0x54(%ebp),%eax -c0107b25: 8b 55 a8 mov -0x58(%ebp),%edx -c0107b28: 89 50 04 mov %edx,0x4(%eax) +c0107ca6: 8b 45 e8 mov -0x18(%ebp),%eax +c0107ca9: 8b 55 e4 mov -0x1c(%ebp),%edx +c0107cac: 89 50 04 mov %edx,0x4(%eax) next->prev = prev; -c0107b2b: 8b 45 a8 mov -0x58(%ebp),%eax -c0107b2e: 8b 55 ac mov -0x54(%ebp),%edx -c0107b31: 89 10 mov %edx,(%eax) +c0107caf: 8b 45 e4 mov -0x1c(%ebp),%eax +c0107cb2: 8b 55 e8 mov -0x18(%ebp),%edx +c0107cb5: 89 10 mov %edx,(%eax) } -c0107b33: 90 nop +c0107cb7: 90 nop } -c0107b34: 90 nop - while (le != &free_list) { -c0107b35: 81 7d f0 a4 e1 12 c0 cmpl $0xc012e1a4,-0x10(%ebp) -c0107b3c: 0f 85 f3 fe ff ff jne c0107a35 - } - } - nr_free += n;// 更新空闲页的计数 -c0107b42: 8b 15 ac e1 12 c0 mov 0xc012e1ac,%edx -c0107b48: 8b 45 0c mov 0xc(%ebp),%eax -c0107b4b: 01 d0 add %edx,%eax -c0107b4d: a3 ac e1 12 c0 mov %eax,0xc012e1ac -c0107b52: c7 45 9c a4 e1 12 c0 movl $0xc012e1a4,-0x64(%ebp) +c0107cb8: 90 nop + // 从列表中删除当前虚拟内存区域的项 + list_del(le); + // 释放虚拟内存区域结构的内存 + kfree(le2vma(le, list_link)); +c0107cb9: 8b 45 f0 mov -0x10(%ebp),%eax +c0107cbc: 83 e8 10 sub $0x10,%eax +c0107cbf: 89 04 24 mov %eax,(%esp) +c0107cc2: e8 a0 ce ff ff call c0104b67 +c0107cc7: 8b 45 f4 mov -0xc(%ebp),%eax +c0107cca: 89 45 e0 mov %eax,-0x20(%ebp) return listelm->next; -c0107b59: 8b 45 9c mov -0x64(%ebp),%eax -c0107b5c: 8b 40 04 mov 0x4(%eax),%eax - le = list_next(&free_list); -c0107b5f: 89 45 f0 mov %eax,-0x10(%ebp) - while (le != &free_list) -c0107b62: eb 66 jmp c0107bca - { - p = le2page(le, page_link); -c0107b64: 8b 45 f0 mov -0x10(%ebp),%eax -c0107b67: 83 e8 0c sub $0xc,%eax -c0107b6a: 89 45 f4 mov %eax,-0xc(%ebp) - if (base + base->property <= p) -c0107b6d: 8b 45 08 mov 0x8(%ebp),%eax -c0107b70: 8b 40 08 mov 0x8(%eax),%eax -c0107b73: c1 e0 05 shl $0x5,%eax -c0107b76: 89 c2 mov %eax,%edx -c0107b78: 8b 45 08 mov 0x8(%ebp),%eax -c0107b7b: 01 d0 add %edx,%eax -c0107b7d: 39 45 f4 cmp %eax,-0xc(%ebp) -c0107b80: 72 39 jb c0107bbb - { - assert(base + base->property != p); -c0107b82: 8b 45 08 mov 0x8(%ebp),%eax -c0107b85: 8b 40 08 mov 0x8(%eax),%eax -c0107b88: c1 e0 05 shl $0x5,%eax -c0107b8b: 89 c2 mov %eax,%edx -c0107b8d: 8b 45 08 mov 0x8(%ebp),%eax -c0107b90: 01 d0 add %edx,%eax -c0107b92: 39 45 f4 cmp %eax,-0xc(%ebp) -c0107b95: 75 3e jne c0107bd5 -c0107b97: c7 44 24 0c 05 be 10 movl $0xc010be05,0xc(%esp) -c0107b9e: c0 -c0107b9f: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107ba6: c0 -c0107ba7: c7 44 24 04 ef 00 00 movl $0xef,0x4(%esp) -c0107bae: 00 -c0107baf: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107bb6: e8 88 88 ff ff call c0100443 <__panic> -c0107bbb: 8b 45 f0 mov -0x10(%ebp),%eax -c0107bbe: 89 45 98 mov %eax,-0x68(%ebp) -c0107bc1: 8b 45 98 mov -0x68(%ebp),%eax -c0107bc4: 8b 40 04 mov 0x4(%eax),%eax - break; - } - le = list_next(le); -c0107bc7: 89 45 f0 mov %eax,-0x10(%ebp) - while (le != &free_list) -c0107bca: 81 7d f0 a4 e1 12 c0 cmpl $0xc012e1a4,-0x10(%ebp) -c0107bd1: 75 91 jne c0107b64 -c0107bd3: eb 01 jmp c0107bd6 - break; -c0107bd5: 90 nop +c0107ccd: 8b 45 e0 mov -0x20(%ebp),%eax +c0107cd0: 8b 40 04 mov 0x4(%eax),%eax + while ((le = list_next(list)) != list) { +c0107cd3: 89 45 f0 mov %eax,-0x10(%ebp) +c0107cd6: 8b 45 f0 mov -0x10(%ebp),%eax +c0107cd9: 3b 45 f4 cmp -0xc(%ebp),%eax +c0107cdc: 75 b1 jne c0107c8f + //kfree(le2vma(le, list_link), sizeof(struct vma_struct)); //kfree vma } - - list_add_before(le, &(base->page_link));// 将释放的页块添加到空闲列表中 -c0107bd6: 8b 45 08 mov 0x8(%ebp),%eax -c0107bd9: 8d 50 0c lea 0xc(%eax),%edx -c0107bdc: 8b 45 f0 mov -0x10(%ebp),%eax -c0107bdf: 89 45 94 mov %eax,-0x6c(%ebp) -c0107be2: 89 55 90 mov %edx,-0x70(%ebp) - __list_add(elm, listelm->prev, listelm); -c0107be5: 8b 45 94 mov -0x6c(%ebp),%eax -c0107be8: 8b 00 mov (%eax),%eax -c0107bea: 8b 55 90 mov -0x70(%ebp),%edx -c0107bed: 89 55 8c mov %edx,-0x74(%ebp) -c0107bf0: 89 45 88 mov %eax,-0x78(%ebp) -c0107bf3: 8b 45 94 mov -0x6c(%ebp),%eax -c0107bf6: 89 45 84 mov %eax,-0x7c(%ebp) - prev->next = next->prev = elm; -c0107bf9: 8b 45 84 mov -0x7c(%ebp),%eax -c0107bfc: 8b 55 8c mov -0x74(%ebp),%edx -c0107bff: 89 10 mov %edx,(%eax) -c0107c01: 8b 45 84 mov -0x7c(%ebp),%eax -c0107c04: 8b 10 mov (%eax),%edx -c0107c06: 8b 45 88 mov -0x78(%ebp),%eax -c0107c09: 89 50 04 mov %edx,0x4(%eax) - elm->next = next; -c0107c0c: 8b 45 8c mov -0x74(%ebp),%eax -c0107c0f: 8b 55 84 mov -0x7c(%ebp),%edx -c0107c12: 89 50 04 mov %edx,0x4(%eax) - elm->prev = prev; -c0107c15: 8b 45 8c mov -0x74(%ebp),%eax -c0107c18: 8b 55 88 mov -0x78(%ebp),%edx -c0107c1b: 89 10 mov %edx,(%eax) -} -c0107c1d: 90 nop -} -c0107c1e: 90 nop + // 释放内存管理结构本身的内存 + kfree(mm); //kfree mm +c0107cde: 8b 45 08 mov 0x8(%ebp),%eax +c0107ce1: 89 04 24 mov %eax,(%esp) +c0107ce4: e8 7e ce ff ff call c0104b67 + //kfree(mm, sizeof(struct mm_struct)); //kfree mm + // 将指针设置为NULL,表示该结构已被销毁 + mm=NULL; +c0107ce9: c7 45 08 00 00 00 00 movl $0x0,0x8(%ebp) } -c0107c1f: 90 nop -c0107c20: c9 leave -c0107c21: c3 ret +c0107cf0: 90 nop +c0107cf1: 89 ec mov %ebp,%esp +c0107cf3: 5d pop %ebp +c0107cf4: c3 ret -c0107c22 : +c0107cf5 : +/** + * 初始化虚拟内存管理(VMM)系统。 + * 此函数通过执行一系列检查来确保VMM系统可以正确初始化和运行。 + */ +void +vmm_init(void) { +c0107cf5: 55 push %ebp +c0107cf6: 89 e5 mov %esp,%ebp +c0107cf8: 83 ec 08 sub $0x8,%esp + // 检查VMM系统的状态和环境,以确保其能够正常工作。 + check_vmm(); +c0107cfb: e8 05 00 00 00 call c0107d05 +} +c0107d00: 90 nop +c0107d01: 89 ec mov %ebp,%esp +c0107d03: 5d pop %ebp +c0107d04: c3 ret -//用于返回当前系统中可用的空闲页的数量。 -static size_t -default_nr_free_pages(void) { -c0107c22: f3 0f 1e fb endbr32 -c0107c26: 55 push %ebp -c0107c27: 89 e5 mov %esp,%ebp - return nr_free;// 返回当前空闲页的数量 -c0107c29: a1 ac e1 12 c0 mov 0xc012e1ac,%eax +c0107d05 : + * 此函数的目的是确保虚拟内存管理系统的正确性通过检查内存区域结构(VMA)、页面故障处理以及免费页面计数的 consistency 来实现 + * 它首先保存当前的免费页面数量,然后执行与 VMA 和页面故障相关的检查,最后确认免费页面数量未发生变化 + * 这是为了确保在检查过程中,内存状态没有因为错误或意外的修改而改变,从而验证内存管理的正确性 + */ +static void +check_vmm(void) { +c0107d05: 55 push %ebp +c0107d06: 89 e5 mov %esp,%ebp +c0107d08: 83 ec 28 sub $0x28,%esp + // 保存当前的免费页面数量,用于后续的 consistency 检查 + size_t nr_free_pages_store = nr_free_pages(); +c0107d0b: e8 6d d3 ff ff call c010507d +c0107d10: 89 45 f4 mov %eax,-0xc(%ebp) + // 检查虚拟内存区域(VMA)结构的正确性 + check_vma_struct(); +c0107d13: e8 16 00 00 00 call c0107d2e + // 检查页面故障处理的正确性 + check_pgfault(); +c0107d18: e8 a5 04 00 00 call c01081c2 + // 确保在检查过程中免费页面数量未发生变化,表明内存管理操作是正确的 + // assert(nr_free_pages_store == nr_free_pages()); + // 如果所有检查都通过,输出成功信息 + cprintf("check_vmm() succeeded.\n"); +c0107d1d: c7 04 24 61 bb 10 c0 movl $0xc010bb61,(%esp) +c0107d24: e8 4f 86 ff ff call c0100378 } -c0107c2e: 5d pop %ebp -c0107c2f: c3 ret +c0107d29: 90 nop +c0107d2a: 89 ec mov %ebp,%esp +c0107d2c: 5d pop %ebp +c0107d2d: c3 ret -c0107c30 : +c0107d2e : -//basic_check 函数用于测试内存分配和释放的基本功能, -//确保在不同情况下内存管理系统的正确性,包括分配、释放、合并和引用计数等操作。 +//测试虚拟内存区域(VMA)结构的创建、插入和查找功能。 static void -basic_check(void) { -c0107c30: f3 0f 1e fb endbr32 -c0107c34: 55 push %ebp -c0107c35: 89 e5 mov %esp,%ebp -c0107c37: 83 ec 48 sub $0x48,%esp - struct Page *p0, *p1, *p2; - p0 = p1 = p2 = NULL; -c0107c3a: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -c0107c41: 8b 45 f4 mov -0xc(%ebp),%eax -c0107c44: 89 45 f0 mov %eax,-0x10(%ebp) -c0107c47: 8b 45 f0 mov -0x10(%ebp),%eax -c0107c4a: 89 45 ec mov %eax,-0x14(%ebp) - // 分配三个页面 - assert((p0 = alloc_page()) != NULL); -c0107c4d: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0107c54: e8 00 bb ff ff call c0103759 -c0107c59: 89 45 ec mov %eax,-0x14(%ebp) -c0107c5c: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) -c0107c60: 75 24 jne c0107c86 -c0107c62: c7 44 24 0c 20 be 10 movl $0xc010be20,0xc(%esp) -c0107c69: c0 -c0107c6a: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107c71: c0 -c0107c72: c7 44 24 04 05 01 00 movl $0x105,0x4(%esp) -c0107c79: 00 -c0107c7a: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107c81: e8 bd 87 ff ff call c0100443 <__panic> - assert((p1 = alloc_page()) != NULL); -c0107c86: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0107c8d: e8 c7 ba ff ff call c0103759 -c0107c92: 89 45 f0 mov %eax,-0x10(%ebp) -c0107c95: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c0107c99: 75 24 jne c0107cbf -c0107c9b: c7 44 24 0c 3c be 10 movl $0xc010be3c,0xc(%esp) -c0107ca2: c0 -c0107ca3: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107caa: c0 -c0107cab: c7 44 24 04 06 01 00 movl $0x106,0x4(%esp) -c0107cb2: 00 -c0107cb3: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107cba: e8 84 87 ff ff call c0100443 <__panic> - assert((p2 = alloc_page()) != NULL); -c0107cbf: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0107cc6: e8 8e ba ff ff call c0103759 -c0107ccb: 89 45 f4 mov %eax,-0xc(%ebp) -c0107cce: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0107cd2: 75 24 jne c0107cf8 -c0107cd4: c7 44 24 0c 58 be 10 movl $0xc010be58,0xc(%esp) -c0107cdb: c0 -c0107cdc: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107ce3: c0 -c0107ce4: c7 44 24 04 07 01 00 movl $0x107,0x4(%esp) -c0107ceb: 00 -c0107cec: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107cf3: e8 4b 87 ff ff call c0100443 <__panic> - // 确保所有分配的页面是不同的 - assert(p0 != p1 && p0 != p2 && p1 != p2); -c0107cf8: 8b 45 ec mov -0x14(%ebp),%eax -c0107cfb: 3b 45 f0 cmp -0x10(%ebp),%eax -c0107cfe: 74 10 je c0107d10 -c0107d00: 8b 45 ec mov -0x14(%ebp),%eax -c0107d03: 3b 45 f4 cmp -0xc(%ebp),%eax -c0107d06: 74 08 je c0107d10 -c0107d08: 8b 45 f0 mov -0x10(%ebp),%eax -c0107d0b: 3b 45 f4 cmp -0xc(%ebp),%eax -c0107d0e: 75 24 jne c0107d34 -c0107d10: c7 44 24 0c 74 be 10 movl $0xc010be74,0xc(%esp) -c0107d17: c0 -c0107d18: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107d1f: c0 -c0107d20: c7 44 24 04 09 01 00 movl $0x109,0x4(%esp) -c0107d27: 00 -c0107d28: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107d2f: e8 0f 87 ff ff call c0100443 <__panic> - // 确保页面的引用计数为 0 - assert(page_ref(p0) == 0 && page_ref(p1) == 0 && page_ref(p2) == 0); -c0107d34: 8b 45 ec mov -0x14(%ebp),%eax -c0107d37: 89 04 24 mov %eax,(%esp) -c0107d3a: e8 a9 f8 ff ff call c01075e8 -c0107d3f: 85 c0 test %eax,%eax -c0107d41: 75 1e jne c0107d61 -c0107d43: 8b 45 f0 mov -0x10(%ebp),%eax -c0107d46: 89 04 24 mov %eax,(%esp) -c0107d49: e8 9a f8 ff ff call c01075e8 -c0107d4e: 85 c0 test %eax,%eax -c0107d50: 75 0f jne c0107d61 -c0107d52: 8b 45 f4 mov -0xc(%ebp),%eax -c0107d55: 89 04 24 mov %eax,(%esp) -c0107d58: e8 8b f8 ff ff call c01075e8 -c0107d5d: 85 c0 test %eax,%eax -c0107d5f: 74 24 je c0107d85 -c0107d61: c7 44 24 0c 98 be 10 movl $0xc010be98,0xc(%esp) -c0107d68: c0 -c0107d69: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107d70: c0 -c0107d71: c7 44 24 04 0b 01 00 movl $0x10b,0x4(%esp) -c0107d78: 00 -c0107d79: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107d80: e8 be 86 ff ff call c0100443 <__panic> - // 确保页面地址在合法范围内 - assert(page2pa(p0) < npage * PGSIZE); -c0107d85: 8b 45 ec mov -0x14(%ebp),%eax -c0107d88: 89 04 24 mov %eax,(%esp) -c0107d8b: e8 42 f8 ff ff call c01075d2 -c0107d90: 8b 15 80 bf 12 c0 mov 0xc012bf80,%edx -c0107d96: c1 e2 0c shl $0xc,%edx -c0107d99: 39 d0 cmp %edx,%eax -c0107d9b: 72 24 jb c0107dc1 -c0107d9d: c7 44 24 0c d4 be 10 movl $0xc010bed4,0xc(%esp) -c0107da4: c0 -c0107da5: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107dac: c0 -c0107dad: c7 44 24 04 0d 01 00 movl $0x10d,0x4(%esp) -c0107db4: 00 -c0107db5: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107dbc: e8 82 86 ff ff call c0100443 <__panic> - assert(page2pa(p1) < npage * PGSIZE); -c0107dc1: 8b 45 f0 mov -0x10(%ebp),%eax -c0107dc4: 89 04 24 mov %eax,(%esp) -c0107dc7: e8 06 f8 ff ff call c01075d2 -c0107dcc: 8b 15 80 bf 12 c0 mov 0xc012bf80,%edx -c0107dd2: c1 e2 0c shl $0xc,%edx -c0107dd5: 39 d0 cmp %edx,%eax -c0107dd7: 72 24 jb c0107dfd -c0107dd9: c7 44 24 0c f1 be 10 movl $0xc010bef1,0xc(%esp) -c0107de0: c0 -c0107de1: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107de8: c0 -c0107de9: c7 44 24 04 0e 01 00 movl $0x10e,0x4(%esp) -c0107df0: 00 -c0107df1: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107df8: e8 46 86 ff ff call c0100443 <__panic> - assert(page2pa(p2) < npage * PGSIZE); -c0107dfd: 8b 45 f4 mov -0xc(%ebp),%eax -c0107e00: 89 04 24 mov %eax,(%esp) -c0107e03: e8 ca f7 ff ff call c01075d2 -c0107e08: 8b 15 80 bf 12 c0 mov 0xc012bf80,%edx -c0107e0e: c1 e2 0c shl $0xc,%edx -c0107e11: 39 d0 cmp %edx,%eax -c0107e13: 72 24 jb c0107e39 -c0107e15: c7 44 24 0c 0e bf 10 movl $0xc010bf0e,0xc(%esp) -c0107e1c: c0 -c0107e1d: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107e24: c0 -c0107e25: c7 44 24 04 0f 01 00 movl $0x10f,0x4(%esp) -c0107e2c: 00 -c0107e2d: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107e34: e8 0a 86 ff ff call c0100443 <__panic> - // 保存当前的空闲页面链表和数量 - list_entry_t free_list_store = free_list; -c0107e39: a1 a4 e1 12 c0 mov 0xc012e1a4,%eax -c0107e3e: 8b 15 a8 e1 12 c0 mov 0xc012e1a8,%edx -c0107e44: 89 45 d0 mov %eax,-0x30(%ebp) -c0107e47: 89 55 d4 mov %edx,-0x2c(%ebp) -c0107e4a: c7 45 dc a4 e1 12 c0 movl $0xc012e1a4,-0x24(%ebp) - elm->prev = elm->next = elm; -c0107e51: 8b 45 dc mov -0x24(%ebp),%eax -c0107e54: 8b 55 dc mov -0x24(%ebp),%edx -c0107e57: 89 50 04 mov %edx,0x4(%eax) -c0107e5a: 8b 45 dc mov -0x24(%ebp),%eax -c0107e5d: 8b 50 04 mov 0x4(%eax),%edx -c0107e60: 8b 45 dc mov -0x24(%ebp),%eax -c0107e63: 89 10 mov %edx,(%eax) -} -c0107e65: 90 nop -c0107e66: c7 45 e0 a4 e1 12 c0 movl $0xc012e1a4,-0x20(%ebp) - return list->next == list; -c0107e6d: 8b 45 e0 mov -0x20(%ebp),%eax -c0107e70: 8b 40 04 mov 0x4(%eax),%eax -c0107e73: 39 45 e0 cmp %eax,-0x20(%ebp) -c0107e76: 0f 94 c0 sete %al -c0107e79: 0f b6 c0 movzbl %al,%eax - list_init(&free_list);// 初始化空闲列表 - assert(list_empty(&free_list));// 确保空闲列表为空 -c0107e7c: 85 c0 test %eax,%eax -c0107e7e: 75 24 jne c0107ea4 -c0107e80: c7 44 24 0c 2b bf 10 movl $0xc010bf2b,0xc(%esp) -c0107e87: c0 -c0107e88: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107e8f: c0 -c0107e90: c7 44 24 04 13 01 00 movl $0x113,0x4(%esp) -c0107e97: 00 -c0107e98: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107e9f: e8 9f 85 ff ff call c0100443 <__panic> +check_vma_struct(void) { +c0107d2e: 55 push %ebp +c0107d2f: 89 e5 mov %esp,%ebp +c0107d31: 83 ec 68 sub $0x68,%esp + // 记录当前空闲页面数量 + size_t nr_free_pages_store = nr_free_pages(); +c0107d34: e8 44 d3 ff ff call c010507d +c0107d39: 89 45 ec mov %eax,-0x14(%ebp) - unsigned int nr_free_store = nr_free;// 保存当前空闲页数量 -c0107ea4: a1 ac e1 12 c0 mov 0xc012e1ac,%eax -c0107ea9: 89 45 e8 mov %eax,-0x18(%ebp) - nr_free = 0;// 将空闲页数量设为 0 -c0107eac: c7 05 ac e1 12 c0 00 movl $0x0,0xc012e1ac -c0107eb3: 00 00 00 - // 请求分配页面,但当前没有空闲页面 - assert(alloc_page() == NULL); -c0107eb6: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0107ebd: e8 97 b8 ff ff call c0103759 -c0107ec2: 85 c0 test %eax,%eax -c0107ec4: 74 24 je c0107eea -c0107ec6: c7 44 24 0c 42 bf 10 movl $0xc010bf42,0xc(%esp) -c0107ecd: c0 -c0107ece: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107ed5: c0 -c0107ed6: c7 44 24 04 18 01 00 movl $0x118,0x4(%esp) -c0107edd: 00 -c0107ede: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107ee5: e8 59 85 ff ff call c0100443 <__panic> - // 释放之前分配的页面 - free_page(p0); -c0107eea: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0107ef1: 00 -c0107ef2: 8b 45 ec mov -0x14(%ebp),%eax -c0107ef5: 89 04 24 mov %eax,(%esp) -c0107ef8: e8 cb b8 ff ff call c01037c8 - free_page(p1); -c0107efd: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0107f04: 00 -c0107f05: 8b 45 f0 mov -0x10(%ebp),%eax -c0107f08: 89 04 24 mov %eax,(%esp) -c0107f0b: e8 b8 b8 ff ff call c01037c8 - free_page(p2); -c0107f10: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0107f17: 00 -c0107f18: 8b 45 f4 mov -0xc(%ebp),%eax -c0107f1b: 89 04 24 mov %eax,(%esp) -c0107f1e: e8 a5 b8 ff ff call c01037c8 - assert(nr_free == 3);// 确保释放后空闲页数量为 3 -c0107f23: a1 ac e1 12 c0 mov 0xc012e1ac,%eax -c0107f28: 83 f8 03 cmp $0x3,%eax -c0107f2b: 74 24 je c0107f51 -c0107f2d: c7 44 24 0c 57 bf 10 movl $0xc010bf57,0xc(%esp) -c0107f34: c0 -c0107f35: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107f3c: c0 -c0107f3d: c7 44 24 04 1d 01 00 movl $0x11d,0x4(%esp) -c0107f44: 00 -c0107f45: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107f4c: e8 f2 84 ff ff call c0100443 <__panic> - // 再次分配三个页面 - assert((p0 = alloc_page()) != NULL); -c0107f51: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0107f58: e8 fc b7 ff ff call c0103759 -c0107f5d: 89 45 ec mov %eax,-0x14(%ebp) -c0107f60: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) -c0107f64: 75 24 jne c0107f8a -c0107f66: c7 44 24 0c 20 be 10 movl $0xc010be20,0xc(%esp) -c0107f6d: c0 -c0107f6e: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107f75: c0 -c0107f76: c7 44 24 04 1f 01 00 movl $0x11f,0x4(%esp) -c0107f7d: 00 -c0107f7e: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107f85: e8 b9 84 ff ff call c0100443 <__panic> - assert((p1 = alloc_page()) != NULL); -c0107f8a: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0107f91: e8 c3 b7 ff ff call c0103759 -c0107f96: 89 45 f0 mov %eax,-0x10(%ebp) -c0107f99: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c0107f9d: 75 24 jne c0107fc3 -c0107f9f: c7 44 24 0c 3c be 10 movl $0xc010be3c,0xc(%esp) -c0107fa6: c0 -c0107fa7: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107fae: c0 -c0107faf: c7 44 24 04 20 01 00 movl $0x120,0x4(%esp) -c0107fb6: 00 -c0107fb7: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107fbe: e8 80 84 ff ff call c0100443 <__panic> - assert((p2 = alloc_page()) != NULL); -c0107fc3: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0107fca: e8 8a b7 ff ff call c0103759 -c0107fcf: 89 45 f4 mov %eax,-0xc(%ebp) -c0107fd2: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0107fd6: 75 24 jne c0107ffc -c0107fd8: c7 44 24 0c 58 be 10 movl $0xc010be58,0xc(%esp) -c0107fdf: c0 -c0107fe0: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0107fe7: c0 -c0107fe8: c7 44 24 04 21 01 00 movl $0x121,0x4(%esp) -c0107fef: 00 -c0107ff0: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0107ff7: e8 47 84 ff ff call c0100443 <__panic> - // 测试空闲页面是否不足 - assert(alloc_page() == NULL); -c0107ffc: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0108003: e8 51 b7 ff ff call c0103759 -c0108008: 85 c0 test %eax,%eax -c010800a: 74 24 je c0108030 -c010800c: c7 44 24 0c 42 bf 10 movl $0xc010bf42,0xc(%esp) -c0108013: c0 -c0108014: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c010801b: c0 -c010801c: c7 44 24 04 23 01 00 movl $0x123,0x4(%esp) -c0108023: 00 -c0108024: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c010802b: e8 13 84 ff ff call c0100443 <__panic> - // 释放 p0,并检查空闲列表 - free_page(p0); -c0108030: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0108037: 00 -c0108038: 8b 45 ec mov -0x14(%ebp),%eax -c010803b: 89 04 24 mov %eax,(%esp) -c010803e: e8 85 b7 ff ff call c01037c8 -c0108043: c7 45 d8 a4 e1 12 c0 movl $0xc012e1a4,-0x28(%ebp) -c010804a: 8b 45 d8 mov -0x28(%ebp),%eax -c010804d: 8b 40 04 mov 0x4(%eax),%eax -c0108050: 39 45 d8 cmp %eax,-0x28(%ebp) -c0108053: 0f 94 c0 sete %al -c0108056: 0f b6 c0 movzbl %al,%eax - assert(!list_empty(&free_list));// 确保空闲列表不为空 -c0108059: 85 c0 test %eax,%eax -c010805b: 74 24 je c0108081 -c010805d: c7 44 24 0c 64 bf 10 movl $0xc010bf64,0xc(%esp) -c0108064: c0 -c0108065: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c010806c: c0 -c010806d: c7 44 24 04 26 01 00 movl $0x126,0x4(%esp) -c0108074: 00 -c0108075: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c010807c: e8 c2 83 ff ff call c0100443 <__panic> + struct mm_struct *mm = mm_create();// 创建内存管理结构 mm +c0107d3c: e8 f8 fb ff ff call c0107939 +c0107d41: 89 45 e8 mov %eax,-0x18(%ebp) + assert(mm != NULL);// 确保 mm 不为 NULL +c0107d44: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) +c0107d48: 75 24 jne c0107d6e +c0107d4a: c7 44 24 0c 79 bb 10 movl $0xc010bb79,0xc(%esp) +c0107d51: c0 +c0107d52: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0107d59: c0 +c0107d5a: c7 44 24 04 1d 01 00 movl $0x11d,0x4(%esp) +c0107d61: 00 +c0107d62: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0107d69: e8 d7 8e ff ff call c0100c45 <__panic> - struct Page *p; - // 重新分配 p0,确保取回的是相同的页面 - assert((p = alloc_page()) == p0); -c0108081: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0108088: e8 cc b6 ff ff call c0103759 -c010808d: 89 45 e4 mov %eax,-0x1c(%ebp) -c0108090: 8b 45 e4 mov -0x1c(%ebp),%eax -c0108093: 3b 45 ec cmp -0x14(%ebp),%eax -c0108096: 74 24 je c01080bc -c0108098: c7 44 24 0c 7c bf 10 movl $0xc010bf7c,0xc(%esp) -c010809f: c0 -c01080a0: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01080a7: c0 -c01080a8: c7 44 24 04 2a 01 00 movl $0x12a,0x4(%esp) -c01080af: 00 -c01080b0: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01080b7: e8 87 83 ff ff call c0100443 <__panic> - assert(alloc_page() == NULL);// 确保没有更多的页面可分配 -c01080bc: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c01080c3: e8 91 b6 ff ff call c0103759 -c01080c8: 85 c0 test %eax,%eax -c01080ca: 74 24 je c01080f0 -c01080cc: c7 44 24 0c 42 bf 10 movl $0xc010bf42,0xc(%esp) -c01080d3: c0 -c01080d4: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01080db: c0 -c01080dc: c7 44 24 04 2b 01 00 movl $0x12b,0x4(%esp) -c01080e3: 00 -c01080e4: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01080eb: e8 53 83 ff ff call c0100443 <__panic> + int step1 = 10, step2 = step1 * 10;// 定义两个步骤的步数 +c0107d6e: c7 45 e4 0a 00 00 00 movl $0xa,-0x1c(%ebp) +c0107d75: 8b 55 e4 mov -0x1c(%ebp),%edx +c0107d78: 89 d0 mov %edx,%eax +c0107d7a: c1 e0 02 shl $0x2,%eax +c0107d7d: 01 d0 add %edx,%eax +c0107d7f: 01 c0 add %eax,%eax +c0107d81: 89 45 e0 mov %eax,-0x20(%ebp) - assert(nr_free == 0);// 确保当前空闲页面数量为 0 -c01080f0: a1 ac e1 12 c0 mov 0xc012e1ac,%eax -c01080f5: 85 c0 test %eax,%eax -c01080f7: 74 24 je c010811d -c01080f9: c7 44 24 0c 95 bf 10 movl $0xc010bf95,0xc(%esp) -c0108100: c0 -c0108101: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0108108: c0 -c0108109: c7 44 24 04 2d 01 00 movl $0x12d,0x4(%esp) -c0108110: 00 -c0108111: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0108118: e8 26 83 ff ff call c0100443 <__panic> - // 恢复之前的空闲页面链表和数量 - free_list = free_list_store; -c010811d: 8b 45 d0 mov -0x30(%ebp),%eax -c0108120: 8b 55 d4 mov -0x2c(%ebp),%edx -c0108123: a3 a4 e1 12 c0 mov %eax,0xc012e1a4 -c0108128: 89 15 a8 e1 12 c0 mov %edx,0xc012e1a8 - nr_free = nr_free_store; -c010812e: 8b 45 e8 mov -0x18(%ebp),%eax -c0108131: a3 ac e1 12 c0 mov %eax,0xc012e1ac - // 释放最后的页面 - free_page(p); -c0108136: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c010813d: 00 -c010813e: 8b 45 e4 mov -0x1c(%ebp),%eax -c0108141: 89 04 24 mov %eax,(%esp) -c0108144: e8 7f b6 ff ff call c01037c8 - free_page(p1); -c0108149: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0108150: 00 -c0108151: 8b 45 f0 mov -0x10(%ebp),%eax -c0108154: 89 04 24 mov %eax,(%esp) -c0108157: e8 6c b6 ff ff call c01037c8 - free_page(p2); -c010815c: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0108163: 00 -c0108164: 8b 45 f4 mov -0xc(%ebp),%eax -c0108167: 89 04 24 mov %eax,(%esp) -c010816a: e8 59 b6 ff ff call c01037c8 -} -c010816f: 90 nop -c0108170: c9 leave -c0108171: c3 ret + int i; + for (i = step1; i >= 1; i --) {// 第一步:创建并插入10个VMA +c0107d84: 8b 45 e4 mov -0x1c(%ebp),%eax +c0107d87: 89 45 f4 mov %eax,-0xc(%ebp) +c0107d8a: eb 6f jmp c0107dfb + // 创建 VMA 结构 + struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0); +c0107d8c: 8b 55 f4 mov -0xc(%ebp),%edx +c0107d8f: 89 d0 mov %edx,%eax +c0107d91: c1 e0 02 shl $0x2,%eax +c0107d94: 01 d0 add %edx,%eax +c0107d96: 83 c0 02 add $0x2,%eax +c0107d99: 89 c1 mov %eax,%ecx +c0107d9b: 8b 55 f4 mov -0xc(%ebp),%edx +c0107d9e: 89 d0 mov %edx,%eax +c0107da0: c1 e0 02 shl $0x2,%eax +c0107da3: 01 d0 add %edx,%eax +c0107da5: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c0107dac: 00 +c0107dad: 89 4c 24 04 mov %ecx,0x4(%esp) +c0107db1: 89 04 24 mov %eax,(%esp) +c0107db4: e8 fb fb ff ff call c01079b4 +c0107db9: 89 45 bc mov %eax,-0x44(%ebp) + assert(vma != NULL);// 确保 VMA 不为 NULL +c0107dbc: 83 7d bc 00 cmpl $0x0,-0x44(%ebp) +c0107dc0: 75 24 jne c0107de6 +c0107dc2: c7 44 24 0c 84 bb 10 movl $0xc010bb84,0xc(%esp) +c0107dc9: c0 +c0107dca: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0107dd1: c0 +c0107dd2: c7 44 24 04 25 01 00 movl $0x125,0x4(%esp) +c0107dd9: 00 +c0107dda: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0107de1: e8 5f 8e ff ff call c0100c45 <__panic> + insert_vma_struct(mm, vma); //将 VMA 插入到 mm 中 +c0107de6: 8b 45 bc mov -0x44(%ebp),%eax +c0107de9: 89 44 24 04 mov %eax,0x4(%esp) +c0107ded: 8b 45 e8 mov -0x18(%ebp),%eax +c0107df0: 89 04 24 mov %eax,(%esp) +c0107df3: e8 53 fd ff ff call c0107b4b + for (i = step1; i >= 1; i --) {// 第一步:创建并插入10个VMA +c0107df8: ff 4d f4 decl -0xc(%ebp) +c0107dfb: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0107dff: 7f 8b jg c0107d8c + } -c0108172 : + for (i = step1 + 1; i <= step2; i ++) {// 第二步:创建并插入90个VMA +c0107e01: 8b 45 e4 mov -0x1c(%ebp),%eax +c0107e04: 40 inc %eax +c0107e05: 89 45 f4 mov %eax,-0xc(%ebp) +c0107e08: eb 6f jmp c0107e79 + // 创建 VMA 结构 + struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0); +c0107e0a: 8b 55 f4 mov -0xc(%ebp),%edx +c0107e0d: 89 d0 mov %edx,%eax +c0107e0f: c1 e0 02 shl $0x2,%eax +c0107e12: 01 d0 add %edx,%eax +c0107e14: 83 c0 02 add $0x2,%eax +c0107e17: 89 c1 mov %eax,%ecx +c0107e19: 8b 55 f4 mov -0xc(%ebp),%edx +c0107e1c: 89 d0 mov %edx,%eax +c0107e1e: c1 e0 02 shl $0x2,%eax +c0107e21: 01 d0 add %edx,%eax +c0107e23: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c0107e2a: 00 +c0107e2b: 89 4c 24 04 mov %ecx,0x4(%esp) +c0107e2f: 89 04 24 mov %eax,(%esp) +c0107e32: e8 7d fb ff ff call c01079b4 +c0107e37: 89 45 c0 mov %eax,-0x40(%ebp) + assert(vma != NULL);// 确保 VMA 不为 NULL +c0107e3a: 83 7d c0 00 cmpl $0x0,-0x40(%ebp) +c0107e3e: 75 24 jne c0107e64 +c0107e40: c7 44 24 0c 84 bb 10 movl $0xc010bb84,0xc(%esp) +c0107e47: c0 +c0107e48: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0107e4f: c0 +c0107e50: c7 44 24 04 2c 01 00 movl $0x12c,0x4(%esp) +c0107e57: 00 +c0107e58: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0107e5f: e8 e1 8d ff ff call c0100c45 <__panic> + insert_vma_struct(mm, vma);// 将 VMA 插入到 mm 中 +c0107e64: 8b 45 c0 mov -0x40(%ebp),%eax +c0107e67: 89 44 24 04 mov %eax,0x4(%esp) +c0107e6b: 8b 45 e8 mov -0x18(%ebp),%eax +c0107e6e: 89 04 24 mov %eax,(%esp) +c0107e71: e8 d5 fc ff ff call c0107b4b + for (i = step1 + 1; i <= step2; i ++) {// 第二步:创建并插入90个VMA +c0107e76: ff 45 f4 incl -0xc(%ebp) +c0107e79: 8b 45 f4 mov -0xc(%ebp),%eax +c0107e7c: 3b 45 e0 cmp -0x20(%ebp),%eax +c0107e7f: 7e 89 jle c0107e0a + } + // 获取 VMA 链表的第一个节点 + list_entry_t *le = list_next(&(mm->mmap_list)); +c0107e81: 8b 45 e8 mov -0x18(%ebp),%eax +c0107e84: 89 45 b8 mov %eax,-0x48(%ebp) +c0107e87: 8b 45 b8 mov -0x48(%ebp),%eax +c0107e8a: 8b 40 04 mov 0x4(%eax),%eax +c0107e8d: 89 45 f0 mov %eax,-0x10(%ebp) -// LAB2: below code is used to check the first fit allocation algorithm (your EXERCISE 1) -// NOTICE: You SHOULD NOT CHANGE basic_check, default_check functions! -static void -default_check(void) { -c0108172: f3 0f 1e fb endbr32 -c0108176: 55 push %ebp -c0108177: 89 e5 mov %esp,%ebp -c0108179: 81 ec 98 00 00 00 sub $0x98,%esp - int count = 0, total = 0; -c010817f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -c0108186: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) - list_entry_t *le = &free_list; -c010818d: c7 45 ec a4 e1 12 c0 movl $0xc012e1a4,-0x14(%ebp) - // 遍历空闲列表,计算空闲页面的数量和总属性值 - while ((le = list_next(le)) != &free_list) { -c0108194: eb 6a jmp c0108200 - struct Page *p = le2page(le, page_link); -c0108196: 8b 45 ec mov -0x14(%ebp),%eax -c0108199: 83 e8 0c sub $0xc,%eax -c010819c: 89 45 d4 mov %eax,-0x2c(%ebp) - assert(PageProperty(p));// 确保每个页面的属性是有效的 -c010819f: 8b 45 d4 mov -0x2c(%ebp),%eax -c01081a2: 83 c0 04 add $0x4,%eax -c01081a5: c7 45 d0 01 00 00 00 movl $0x1,-0x30(%ebp) -c01081ac: 89 45 cc mov %eax,-0x34(%ebp) - asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); -c01081af: 8b 45 cc mov -0x34(%ebp),%eax -c01081b2: 8b 55 d0 mov -0x30(%ebp),%edx -c01081b5: 0f a3 10 bt %edx,(%eax) -c01081b8: 19 c0 sbb %eax,%eax -c01081ba: 89 45 c8 mov %eax,-0x38(%ebp) - return oldbit != 0; -c01081bd: 83 7d c8 00 cmpl $0x0,-0x38(%ebp) -c01081c1: 0f 95 c0 setne %al -c01081c4: 0f b6 c0 movzbl %al,%eax -c01081c7: 85 c0 test %eax,%eax -c01081c9: 75 24 jne c01081ef -c01081cb: c7 44 24 0c a2 bf 10 movl $0xc010bfa2,0xc(%esp) -c01081d2: c0 -c01081d3: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01081da: c0 -c01081db: c7 44 24 04 40 01 00 movl $0x140,0x4(%esp) -c01081e2: 00 -c01081e3: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01081ea: e8 54 82 ff ff call c0100443 <__panic> - count ++, total += p->property;// 累加页面属性 -c01081ef: ff 45 f4 incl -0xc(%ebp) -c01081f2: 8b 45 d4 mov -0x2c(%ebp),%eax -c01081f5: 8b 50 08 mov 0x8(%eax),%edx -c01081f8: 8b 45 f0 mov -0x10(%ebp),%eax -c01081fb: 01 d0 add %edx,%eax -c01081fd: 89 45 f0 mov %eax,-0x10(%ebp) -c0108200: 8b 45 ec mov -0x14(%ebp),%eax -c0108203: 89 45 c4 mov %eax,-0x3c(%ebp) - return listelm->next; -c0108206: 8b 45 c4 mov -0x3c(%ebp),%eax -c0108209: 8b 40 04 mov 0x4(%eax),%eax - while ((le = list_next(le)) != &free_list) { -c010820c: 89 45 ec mov %eax,-0x14(%ebp) -c010820f: 81 7d ec a4 e1 12 c0 cmpl $0xc012e1a4,-0x14(%ebp) -c0108216: 0f 85 7a ff ff ff jne c0108196 + for (i = 1; i <= step2; i ++) {// 验证插入顺序 +c0107e90: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp) +c0107e97: e9 96 00 00 00 jmp c0107f32 + assert(le != &(mm->mmap_list));// 确保节点不为空 +c0107e9c: 8b 45 e8 mov -0x18(%ebp),%eax +c0107e9f: 39 45 f0 cmp %eax,-0x10(%ebp) +c0107ea2: 75 24 jne c0107ec8 +c0107ea4: c7 44 24 0c 90 bb 10 movl $0xc010bb90,0xc(%esp) +c0107eab: c0 +c0107eac: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0107eb3: c0 +c0107eb4: c7 44 24 04 33 01 00 movl $0x133,0x4(%esp) +c0107ebb: 00 +c0107ebc: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0107ec3: e8 7d 8d ff ff call c0100c45 <__panic> + struct vma_struct *mmap = le2vma(le, list_link);// 将链表节点转换为 VMA 结构 +c0107ec8: 8b 45 f0 mov -0x10(%ebp),%eax +c0107ecb: 83 e8 10 sub $0x10,%eax +c0107ece: 89 45 c4 mov %eax,-0x3c(%ebp) + // 确认 VMA 的起始和结束地址 + assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2); +c0107ed1: 8b 45 c4 mov -0x3c(%ebp),%eax +c0107ed4: 8b 48 04 mov 0x4(%eax),%ecx +c0107ed7: 8b 55 f4 mov -0xc(%ebp),%edx +c0107eda: 89 d0 mov %edx,%eax +c0107edc: c1 e0 02 shl $0x2,%eax +c0107edf: 01 d0 add %edx,%eax +c0107ee1: 39 c1 cmp %eax,%ecx +c0107ee3: 75 17 jne c0107efc +c0107ee5: 8b 45 c4 mov -0x3c(%ebp),%eax +c0107ee8: 8b 48 08 mov 0x8(%eax),%ecx +c0107eeb: 8b 55 f4 mov -0xc(%ebp),%edx +c0107eee: 89 d0 mov %edx,%eax +c0107ef0: c1 e0 02 shl $0x2,%eax +c0107ef3: 01 d0 add %edx,%eax +c0107ef5: 83 c0 02 add $0x2,%eax +c0107ef8: 39 c1 cmp %eax,%ecx +c0107efa: 74 24 je c0107f20 +c0107efc: c7 44 24 0c a8 bb 10 movl $0xc010bba8,0xc(%esp) +c0107f03: c0 +c0107f04: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0107f0b: c0 +c0107f0c: c7 44 24 04 36 01 00 movl $0x136,0x4(%esp) +c0107f13: 00 +c0107f14: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0107f1b: e8 25 8d ff ff call c0100c45 <__panic> +c0107f20: 8b 45 f0 mov -0x10(%ebp),%eax +c0107f23: 89 45 b4 mov %eax,-0x4c(%ebp) +c0107f26: 8b 45 b4 mov -0x4c(%ebp),%eax +c0107f29: 8b 40 04 mov 0x4(%eax),%eax + le = list_next(le);// 移动到下一个节点 +c0107f2c: 89 45 f0 mov %eax,-0x10(%ebp) + for (i = 1; i <= step2; i ++) {// 验证插入顺序 +c0107f2f: ff 45 f4 incl -0xc(%ebp) +c0107f32: 8b 45 f4 mov -0xc(%ebp),%eax +c0107f35: 3b 45 e0 cmp -0x20(%ebp),%eax +c0107f38: 0f 8e 5e ff ff ff jle c0107e9c + } + + for (i = 5; i <= 5 * step2; i +=5) {// 查找特定地址范围内的 VMA +c0107f3e: c7 45 f4 05 00 00 00 movl $0x5,-0xc(%ebp) +c0107f45: e9 cb 01 00 00 jmp c0108115 + struct vma_struct *vma1 = find_vma(mm, i);// 查找地址 i 处的 VMA +c0107f4a: 8b 45 f4 mov -0xc(%ebp),%eax +c0107f4d: 89 44 24 04 mov %eax,0x4(%esp) +c0107f51: 8b 45 e8 mov -0x18(%ebp),%eax +c0107f54: 89 04 24 mov %eax,(%esp) +c0107f57: e8 95 fa ff ff call c01079f1 +c0107f5c: 89 45 d8 mov %eax,-0x28(%ebp) + assert(vma1 != NULL);// 确保找到 VMA +c0107f5f: 83 7d d8 00 cmpl $0x0,-0x28(%ebp) +c0107f63: 75 24 jne c0107f89 +c0107f65: c7 44 24 0c dd bb 10 movl $0xc010bbdd,0xc(%esp) +c0107f6c: c0 +c0107f6d: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0107f74: c0 +c0107f75: c7 44 24 04 3c 01 00 movl $0x13c,0x4(%esp) +c0107f7c: 00 +c0107f7d: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0107f84: e8 bc 8c ff ff call c0100c45 <__panic> + // 查找地址 i + 1 处的 VMA + struct vma_struct *vma2 = find_vma(mm, i+1); +c0107f89: 8b 45 f4 mov -0xc(%ebp),%eax +c0107f8c: 40 inc %eax +c0107f8d: 89 44 24 04 mov %eax,0x4(%esp) +c0107f91: 8b 45 e8 mov -0x18(%ebp),%eax +c0107f94: 89 04 24 mov %eax,(%esp) +c0107f97: e8 55 fa ff ff call c01079f1 +c0107f9c: 89 45 d4 mov %eax,-0x2c(%ebp) + assert(vma2 != NULL);// 确保找到 VMA +c0107f9f: 83 7d d4 00 cmpl $0x0,-0x2c(%ebp) +c0107fa3: 75 24 jne c0107fc9 +c0107fa5: c7 44 24 0c ea bb 10 movl $0xc010bbea,0xc(%esp) +c0107fac: c0 +c0107fad: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0107fb4: c0 +c0107fb5: c7 44 24 04 3f 01 00 movl $0x13f,0x4(%esp) +c0107fbc: 00 +c0107fbd: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0107fc4: e8 7c 8c ff ff call c0100c45 <__panic> + // 查找地址 i + 2 处的 VMA + struct vma_struct *vma3 = find_vma(mm, i+2); +c0107fc9: 8b 45 f4 mov -0xc(%ebp),%eax +c0107fcc: 83 c0 02 add $0x2,%eax +c0107fcf: 89 44 24 04 mov %eax,0x4(%esp) +c0107fd3: 8b 45 e8 mov -0x18(%ebp),%eax +c0107fd6: 89 04 24 mov %eax,(%esp) +c0107fd9: e8 13 fa ff ff call c01079f1 +c0107fde: 89 45 d0 mov %eax,-0x30(%ebp) + assert(vma3 == NULL);// 确保未找到 VMA +c0107fe1: 83 7d d0 00 cmpl $0x0,-0x30(%ebp) +c0107fe5: 74 24 je c010800b +c0107fe7: c7 44 24 0c f7 bb 10 movl $0xc010bbf7,0xc(%esp) +c0107fee: c0 +c0107fef: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0107ff6: c0 +c0107ff7: c7 44 24 04 42 01 00 movl $0x142,0x4(%esp) +c0107ffe: 00 +c0107fff: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0108006: e8 3a 8c ff ff call c0100c45 <__panic> + // 查找地址 i + 3 处的 VMA + struct vma_struct *vma4 = find_vma(mm, i+3); +c010800b: 8b 45 f4 mov -0xc(%ebp),%eax +c010800e: 83 c0 03 add $0x3,%eax +c0108011: 89 44 24 04 mov %eax,0x4(%esp) +c0108015: 8b 45 e8 mov -0x18(%ebp),%eax +c0108018: 89 04 24 mov %eax,(%esp) +c010801b: e8 d1 f9 ff ff call c01079f1 +c0108020: 89 45 cc mov %eax,-0x34(%ebp) + assert(vma4 == NULL);// 确保未找到 VMA +c0108023: 83 7d cc 00 cmpl $0x0,-0x34(%ebp) +c0108027: 74 24 je c010804d +c0108029: c7 44 24 0c 04 bc 10 movl $0xc010bc04,0xc(%esp) +c0108030: c0 +c0108031: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0108038: c0 +c0108039: c7 44 24 04 45 01 00 movl $0x145,0x4(%esp) +c0108040: 00 +c0108041: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0108048: e8 f8 8b ff ff call c0100c45 <__panic> + // 查找地址 i + 4 处的 VMA + struct vma_struct *vma5 = find_vma(mm, i+4); +c010804d: 8b 45 f4 mov -0xc(%ebp),%eax +c0108050: 83 c0 04 add $0x4,%eax +c0108053: 89 44 24 04 mov %eax,0x4(%esp) +c0108057: 8b 45 e8 mov -0x18(%ebp),%eax +c010805a: 89 04 24 mov %eax,(%esp) +c010805d: e8 8f f9 ff ff call c01079f1 +c0108062: 89 45 c8 mov %eax,-0x38(%ebp) + assert(vma5 == NULL);// 确保未找到 VMA +c0108065: 83 7d c8 00 cmpl $0x0,-0x38(%ebp) +c0108069: 74 24 je c010808f +c010806b: c7 44 24 0c 11 bc 10 movl $0xc010bc11,0xc(%esp) +c0108072: c0 +c0108073: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c010807a: c0 +c010807b: c7 44 24 04 48 01 00 movl $0x148,0x4(%esp) +c0108082: 00 +c0108083: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c010808a: e8 b6 8b ff ff call c0100c45 <__panic> + // 确认 VMA1 的起始和结束地址 + assert(vma1->vm_start == i && vma1->vm_end == i + 2); +c010808f: 8b 45 d8 mov -0x28(%ebp),%eax +c0108092: 8b 50 04 mov 0x4(%eax),%edx +c0108095: 8b 45 f4 mov -0xc(%ebp),%eax +c0108098: 39 c2 cmp %eax,%edx +c010809a: 75 10 jne c01080ac +c010809c: 8b 45 d8 mov -0x28(%ebp),%eax +c010809f: 8b 40 08 mov 0x8(%eax),%eax +c01080a2: 8b 55 f4 mov -0xc(%ebp),%edx +c01080a5: 83 c2 02 add $0x2,%edx +c01080a8: 39 d0 cmp %edx,%eax +c01080aa: 74 24 je c01080d0 +c01080ac: c7 44 24 0c 20 bc 10 movl $0xc010bc20,0xc(%esp) +c01080b3: c0 +c01080b4: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c01080bb: c0 +c01080bc: c7 44 24 04 4a 01 00 movl $0x14a,0x4(%esp) +c01080c3: 00 +c01080c4: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c01080cb: e8 75 8b ff ff call c0100c45 <__panic> + // 确认 VMA2 的起始和结束地址 + assert(vma2->vm_start == i && vma2->vm_end == i + 2); +c01080d0: 8b 45 d4 mov -0x2c(%ebp),%eax +c01080d3: 8b 50 04 mov 0x4(%eax),%edx +c01080d6: 8b 45 f4 mov -0xc(%ebp),%eax +c01080d9: 39 c2 cmp %eax,%edx +c01080db: 75 10 jne c01080ed +c01080dd: 8b 45 d4 mov -0x2c(%ebp),%eax +c01080e0: 8b 40 08 mov 0x8(%eax),%eax +c01080e3: 8b 55 f4 mov -0xc(%ebp),%edx +c01080e6: 83 c2 02 add $0x2,%edx +c01080e9: 39 d0 cmp %edx,%eax +c01080eb: 74 24 je c0108111 +c01080ed: c7 44 24 0c 50 bc 10 movl $0xc010bc50,0xc(%esp) +c01080f4: c0 +c01080f5: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c01080fc: c0 +c01080fd: c7 44 24 04 4c 01 00 movl $0x14c,0x4(%esp) +c0108104: 00 +c0108105: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c010810c: e8 34 8b ff ff call c0100c45 <__panic> + for (i = 5; i <= 5 * step2; i +=5) {// 查找特定地址范围内的 VMA +c0108111: 83 45 f4 05 addl $0x5,-0xc(%ebp) +c0108115: 8b 55 e0 mov -0x20(%ebp),%edx +c0108118: 89 d0 mov %edx,%eax +c010811a: c1 e0 02 shl $0x2,%eax +c010811d: 01 d0 add %edx,%eax +c010811f: 39 45 f4 cmp %eax,-0xc(%ebp) +c0108122: 0f 8e 22 fe ff ff jle c0107f4a + } + // 检查小于5的地址范围内是否存在 VMA + for (i =4; i>=0; i--) { +c0108128: c7 45 f4 04 00 00 00 movl $0x4,-0xc(%ebp) +c010812f: eb 6f jmp c01081a0 + // 查找地址 i 处的 VMA + struct vma_struct *vma_below_5= find_vma(mm,i); +c0108131: 8b 45 f4 mov -0xc(%ebp),%eax +c0108134: 89 44 24 04 mov %eax,0x4(%esp) +c0108138: 8b 45 e8 mov -0x18(%ebp),%eax +c010813b: 89 04 24 mov %eax,(%esp) +c010813e: e8 ae f8 ff ff call c01079f1 +c0108143: 89 45 dc mov %eax,-0x24(%ebp) + if (vma_below_5 != NULL ) {// 如果找到 VMA +c0108146: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) +c010814a: 74 27 je c0108173 + cprintf("vma_below_5: i %x, start %x, end %x\n",i, vma_below_5->vm_start, vma_below_5->vm_end); +c010814c: 8b 45 dc mov -0x24(%ebp),%eax +c010814f: 8b 50 08 mov 0x8(%eax),%edx +c0108152: 8b 45 dc mov -0x24(%ebp),%eax +c0108155: 8b 40 04 mov 0x4(%eax),%eax +c0108158: 89 54 24 0c mov %edx,0xc(%esp) +c010815c: 89 44 24 08 mov %eax,0x8(%esp) +c0108160: 8b 45 f4 mov -0xc(%ebp),%eax +c0108163: 89 44 24 04 mov %eax,0x4(%esp) +c0108167: c7 04 24 80 bc 10 c0 movl $0xc010bc80,(%esp) +c010816e: e8 05 82 ff ff call c0100378 + } + assert(vma_below_5 == NULL);// 确保未找到 VMA +c0108173: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) +c0108177: 74 24 je c010819d +c0108179: c7 44 24 0c a5 bc 10 movl $0xc010bca5,0xc(%esp) +c0108180: c0 +c0108181: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0108188: c0 +c0108189: c7 44 24 04 55 01 00 movl $0x155,0x4(%esp) +c0108190: 00 +c0108191: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0108198: e8 a8 8a ff ff call c0100c45 <__panic> + for (i =4; i>=0; i--) { +c010819d: ff 4d f4 decl -0xc(%ebp) +c01081a0: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c01081a4: 79 8b jns c0108131 } - // 确保总属性值与空闲页面数量匹配 - assert(total == nr_free_pages()); -c010821c: e8 de b5 ff ff call c01037ff -c0108221: 8b 55 f0 mov -0x10(%ebp),%edx -c0108224: 39 d0 cmp %edx,%eax -c0108226: 74 24 je c010824c -c0108228: c7 44 24 0c b2 bf 10 movl $0xc010bfb2,0xc(%esp) -c010822f: c0 -c0108230: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0108237: c0 -c0108238: c7 44 24 04 44 01 00 movl $0x144,0x4(%esp) -c010823f: 00 -c0108240: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0108247: e8 f7 81 ff ff call c0100443 <__panic> - // 调用 basic_check 以验证基本的内存管理功能 - basic_check(); -c010824c: e8 df f9 ff ff call c0107c30 - // 分配 5 个页面 - struct Page *p0 = alloc_pages(5), *p1, *p2; -c0108251: c7 04 24 05 00 00 00 movl $0x5,(%esp) -c0108258: e8 fc b4 ff ff call c0103759 -c010825d: 89 45 e8 mov %eax,-0x18(%ebp) - assert(p0 != NULL);// 确保成功分配 -c0108260: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) -c0108264: 75 24 jne c010828a -c0108266: c7 44 24 0c cb bf 10 movl $0xc010bfcb,0xc(%esp) -c010826d: c0 -c010826e: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0108275: c0 -c0108276: c7 44 24 04 49 01 00 movl $0x149,0x4(%esp) -c010827d: 00 -c010827e: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0108285: e8 b9 81 ff ff call c0100443 <__panic> - assert(!PageProperty(p0));// 确保分配的页面不带属性 -c010828a: 8b 45 e8 mov -0x18(%ebp),%eax -c010828d: 83 c0 04 add $0x4,%eax -c0108290: c7 45 c0 01 00 00 00 movl $0x1,-0x40(%ebp) -c0108297: 89 45 bc mov %eax,-0x44(%ebp) - asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); -c010829a: 8b 45 bc mov -0x44(%ebp),%eax -c010829d: 8b 55 c0 mov -0x40(%ebp),%edx -c01082a0: 0f a3 10 bt %edx,(%eax) -c01082a3: 19 c0 sbb %eax,%eax -c01082a5: 89 45 b8 mov %eax,-0x48(%ebp) - return oldbit != 0; -c01082a8: 83 7d b8 00 cmpl $0x0,-0x48(%ebp) -c01082ac: 0f 95 c0 setne %al -c01082af: 0f b6 c0 movzbl %al,%eax -c01082b2: 85 c0 test %eax,%eax -c01082b4: 74 24 je c01082da -c01082b6: c7 44 24 0c d6 bf 10 movl $0xc010bfd6,0xc(%esp) -c01082bd: c0 -c01082be: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01082c5: c0 -c01082c6: c7 44 24 04 4a 01 00 movl $0x14a,0x4(%esp) -c01082cd: 00 -c01082ce: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01082d5: e8 69 81 ff ff call c0100443 <__panic> - // 初始化并检查空闲列表 - list_entry_t free_list_store = free_list; -c01082da: a1 a4 e1 12 c0 mov 0xc012e1a4,%eax -c01082df: 8b 15 a8 e1 12 c0 mov 0xc012e1a8,%edx -c01082e5: 89 45 80 mov %eax,-0x80(%ebp) -c01082e8: 89 55 84 mov %edx,-0x7c(%ebp) -c01082eb: c7 45 b0 a4 e1 12 c0 movl $0xc012e1a4,-0x50(%ebp) - elm->prev = elm->next = elm; -c01082f2: 8b 45 b0 mov -0x50(%ebp),%eax -c01082f5: 8b 55 b0 mov -0x50(%ebp),%edx -c01082f8: 89 50 04 mov %edx,0x4(%eax) -c01082fb: 8b 45 b0 mov -0x50(%ebp),%eax -c01082fe: 8b 50 04 mov 0x4(%eax),%edx -c0108301: 8b 45 b0 mov -0x50(%ebp),%eax -c0108304: 89 10 mov %edx,(%eax) -} -c0108306: 90 nop -c0108307: c7 45 b4 a4 e1 12 c0 movl $0xc012e1a4,-0x4c(%ebp) - return list->next == list; -c010830e: 8b 45 b4 mov -0x4c(%ebp),%eax -c0108311: 8b 40 04 mov 0x4(%eax),%eax -c0108314: 39 45 b4 cmp %eax,-0x4c(%ebp) -c0108317: 0f 94 c0 sete %al -c010831a: 0f b6 c0 movzbl %al,%eax - list_init(&free_list); - assert(list_empty(&free_list));// 确保空闲列表为空 -c010831d: 85 c0 test %eax,%eax -c010831f: 75 24 jne c0108345 -c0108321: c7 44 24 0c 2b bf 10 movl $0xc010bf2b,0xc(%esp) -c0108328: c0 -c0108329: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0108330: c0 -c0108331: c7 44 24 04 4e 01 00 movl $0x14e,0x4(%esp) -c0108338: 00 -c0108339: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0108340: e8 fe 80 ff ff call c0100443 <__panic> - assert(alloc_page() == NULL);// 确保没有页面可分配 -c0108345: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c010834c: e8 08 b4 ff ff call c0103759 -c0108351: 85 c0 test %eax,%eax -c0108353: 74 24 je c0108379 -c0108355: c7 44 24 0c 42 bf 10 movl $0xc010bf42,0xc(%esp) -c010835c: c0 -c010835d: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0108364: c0 -c0108365: c7 44 24 04 4f 01 00 movl $0x14f,0x4(%esp) -c010836c: 00 -c010836d: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0108374: e8 ca 80 ff ff call c0100443 <__panic> - unsigned int nr_free_store = nr_free;// 保存当前空闲页数 -c0108379: a1 ac e1 12 c0 mov 0xc012e1ac,%eax -c010837e: 89 45 e4 mov %eax,-0x1c(%ebp) - nr_free = 0;// 将空闲页数设为 0 -c0108381: c7 05 ac e1 12 c0 00 movl $0x0,0xc012e1ac -c0108388: 00 00 00 - // 释放 3 个页面并确保分配页面时没有足够的空闲页 - free_pages(p0 + 2, 3); -c010838b: 8b 45 e8 mov -0x18(%ebp),%eax -c010838e: 83 c0 40 add $0x40,%eax -c0108391: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp) + mm_destroy(mm);// 销毁 mm 结构 +c01081a6: 8b 45 e8 mov -0x18(%ebp),%eax +c01081a9: 89 04 24 mov %eax,(%esp) +c01081ac: e8 d0 fa ff ff call c0107c81 + + // 确保释放的页面数量与初始记录一致 + // assert(nr_free_pages_store == nr_free_pages()); + // 输出成功信息 + cprintf("check_vma_struct() succeeded!\n"); +c01081b1: c7 04 24 bc bc 10 c0 movl $0xc010bcbc,(%esp) +c01081b8: e8 bb 81 ff ff call c0100378 +} +c01081bd: 90 nop +c01081be: 89 ec mov %ebp,%esp +c01081c0: 5d pop %ebp +c01081c1: c3 ret + +c01081c2 : +struct mm_struct *check_mm_struct; + +// check_pgfault - check correctness of pgfault handler +// 检查页故障处理的正确性 +static void +check_pgfault(void) { +c01081c2: 55 push %ebp +c01081c3: 89 e5 mov %esp,%ebp +c01081c5: 83 ec 38 sub $0x38,%esp + // 保存当前空闲页面的数量,用于后续检查 + size_t nr_free_pages_store = nr_free_pages(); +c01081c8: e8 b0 ce ff ff call c010507d +c01081cd: 89 45 ec mov %eax,-0x14(%ebp) + // 创建内存管理结构体 + check_mm_struct = mm_create(); +c01081d0: e8 64 f7 ff ff call c0107939 +c01081d5: a3 6c c1 12 c0 mov %eax,0xc012c16c + // 确保内存管理结构体创建成功 + assert(check_mm_struct != NULL); +c01081da: a1 6c c1 12 c0 mov 0xc012c16c,%eax +c01081df: 85 c0 test %eax,%eax +c01081e1: 75 24 jne c0108207 +c01081e3: c7 44 24 0c db bc 10 movl $0xc010bcdb,0xc(%esp) +c01081ea: c0 +c01081eb: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c01081f2: c0 +c01081f3: c7 44 24 04 6b 01 00 movl $0x16b,0x4(%esp) +c01081fa: 00 +c01081fb: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0108202: e8 3e 8a ff ff call c0100c45 <__panic> + // 将新创建的内存管理结构体赋值给局部变量mm + struct mm_struct *mm = check_mm_struct; +c0108207: a1 6c c1 12 c0 mov 0xc012c16c,%eax +c010820c: 89 45 e8 mov %eax,-0x18(%ebp) + // 将引导程序的页目录复制到新创建的内存管理结构体中 + pde_t *pgdir = mm->pgdir = boot_pgdir; +c010820f: 8b 15 00 8a 12 c0 mov 0xc0128a00,%edx +c0108215: 8b 45 e8 mov -0x18(%ebp),%eax +c0108218: 89 50 0c mov %edx,0xc(%eax) +c010821b: 8b 45 e8 mov -0x18(%ebp),%eax +c010821e: 8b 40 0c mov 0xc(%eax),%eax +c0108221: 89 45 e4 mov %eax,-0x1c(%ebp) + // 确保页目录的第0项是空的 + assert(pgdir[0] == 0); +c0108224: 8b 45 e4 mov -0x1c(%ebp),%eax +c0108227: 8b 00 mov (%eax),%eax +c0108229: 85 c0 test %eax,%eax +c010822b: 74 24 je c0108251 +c010822d: c7 44 24 0c f3 bc 10 movl $0xc010bcf3,0xc(%esp) +c0108234: c0 +c0108235: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c010823c: c0 +c010823d: c7 44 24 04 71 01 00 movl $0x171,0x4(%esp) +c0108244: 00 +c0108245: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c010824c: e8 f4 89 ff ff call c0100c45 <__panic> + // 创建一个虚拟内存区域结构体,具有写权限 + struct vma_struct *vma = vma_create(0, PTSIZE, VM_WRITE); +c0108251: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp) +c0108258: 00 +c0108259: c7 44 24 04 00 00 40 movl $0x400000,0x4(%esp) +c0108260: 00 +c0108261: c7 04 24 00 00 00 00 movl $0x0,(%esp) +c0108268: e8 47 f7 ff ff call c01079b4 +c010826d: 89 45 e0 mov %eax,-0x20(%ebp) + // 确保虚拟内存区域结构体创建成功 + assert(vma != NULL); +c0108270: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) +c0108274: 75 24 jne c010829a +c0108276: c7 44 24 0c 84 bb 10 movl $0xc010bb84,0xc(%esp) +c010827d: c0 +c010827e: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0108285: c0 +c0108286: c7 44 24 04 75 01 00 movl $0x175,0x4(%esp) +c010828d: 00 +c010828e: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0108295: e8 ab 89 ff ff call c0100c45 <__panic> + // 将虚拟内存区域结构体插入到内存管理结构体中 + insert_vma_struct(mm, vma); +c010829a: 8b 45 e0 mov -0x20(%ebp),%eax +c010829d: 89 44 24 04 mov %eax,0x4(%esp) +c01082a1: 8b 45 e8 mov -0x18(%ebp),%eax +c01082a4: 89 04 24 mov %eax,(%esp) +c01082a7: e8 9f f8 ff ff call c0107b4b + // 定义一个地址,用于访问虚拟内存 + uintptr_t addr = 0x100; +c01082ac: c7 45 dc 00 01 00 00 movl $0x100,-0x24(%ebp) + // 确保通过该地址可以找到之前插入的虚拟内存区域 + assert(find_vma(mm, addr) == vma); +c01082b3: 8b 45 dc mov -0x24(%ebp),%eax +c01082b6: 89 44 24 04 mov %eax,0x4(%esp) +c01082ba: 8b 45 e8 mov -0x18(%ebp),%eax +c01082bd: 89 04 24 mov %eax,(%esp) +c01082c0: e8 2c f7 ff ff call c01079f1 +c01082c5: 39 45 e0 cmp %eax,-0x20(%ebp) +c01082c8: 74 24 je c01082ee +c01082ca: c7 44 24 0c 01 bd 10 movl $0xc010bd01,0xc(%esp) +c01082d1: c0 +c01082d2: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c01082d9: c0 +c01082da: c7 44 24 04 7b 01 00 movl $0x17b,0x4(%esp) +c01082e1: 00 +c01082e2: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c01082e9: e8 57 89 ff ff call c0100c45 <__panic> + // 初始化一个累加器,用于校验写入的数据 + int i, sum = 0; +c01082ee: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) + // 写入数据到虚拟内存,并累加 + for (i = 0; i < 100; i ++) { +c01082f5: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c01082fc: eb 16 jmp c0108314 + *(char *)(addr + i) = i; +c01082fe: 8b 55 f4 mov -0xc(%ebp),%edx +c0108301: 8b 45 dc mov -0x24(%ebp),%eax +c0108304: 01 d0 add %edx,%eax +c0108306: 8b 55 f4 mov -0xc(%ebp),%edx +c0108309: 88 10 mov %dl,(%eax) + sum += i; +c010830b: 8b 45 f4 mov -0xc(%ebp),%eax +c010830e: 01 45 f0 add %eax,-0x10(%ebp) + for (i = 0; i < 100; i ++) { +c0108311: ff 45 f4 incl -0xc(%ebp) +c0108314: 83 7d f4 63 cmpl $0x63,-0xc(%ebp) +c0108318: 7e e4 jle c01082fe + } + // 读取虚拟内存中的数据,并减去,最终结果应为0 + for (i = 0; i < 100; i ++) { +c010831a: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c0108321: eb 14 jmp c0108337 + sum -= *(char *)(addr + i); +c0108323: 8b 55 f4 mov -0xc(%ebp),%edx +c0108326: 8b 45 dc mov -0x24(%ebp),%eax +c0108329: 01 d0 add %edx,%eax +c010832b: 0f b6 00 movzbl (%eax),%eax +c010832e: 0f be c0 movsbl %al,%eax +c0108331: 29 45 f0 sub %eax,-0x10(%ebp) + for (i = 0; i < 100; i ++) { +c0108334: ff 45 f4 incl -0xc(%ebp) +c0108337: 83 7d f4 63 cmpl $0x63,-0xc(%ebp) +c010833b: 7e e6 jle c0108323 + } + // 确保累加器的值为0,证明数据读写正确 + assert(sum == 0); +c010833d: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c0108341: 74 24 je c0108367 +c0108343: c7 44 24 0c 1b bd 10 movl $0xc010bd1b,0xc(%esp) +c010834a: c0 +c010834b: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c0108352: c0 +c0108353: c7 44 24 04 88 01 00 movl $0x188,0x4(%esp) +c010835a: 00 +c010835b: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c0108362: e8 de 88 ff ff call c0100c45 <__panic> + // 移除页目录中的相应页面 + page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); +c0108367: 8b 45 dc mov -0x24(%ebp),%eax +c010836a: 89 45 d8 mov %eax,-0x28(%ebp) +c010836d: 8b 45 d8 mov -0x28(%ebp),%eax +c0108370: 25 00 f0 ff ff and $0xfffff000,%eax +c0108375: 89 44 24 04 mov %eax,0x4(%esp) +c0108379: 8b 45 e4 mov -0x1c(%ebp),%eax +c010837c: 89 04 24 mov %eax,(%esp) +c010837f: e8 0c d5 ff ff call c0105890 + // 释放第0项页目录对应的页面 + free_page(pde2page(pgdir[0])); +c0108384: 8b 45 e4 mov -0x1c(%ebp),%eax +c0108387: 8b 00 mov (%eax),%eax +c0108389: 89 04 24 mov %eax,(%esp) +c010838c: e8 8e f5 ff ff call c010791f +c0108391: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) c0108398: 00 c0108399: 89 04 24 mov %eax,(%esp) -c010839c: e8 27 b4 ff ff call c01037c8 - assert(alloc_pages(4) == NULL);// 确保无法分配 4 个页面 -c01083a1: c7 04 24 04 00 00 00 movl $0x4,(%esp) -c01083a8: e8 ac b3 ff ff call c0103759 -c01083ad: 85 c0 test %eax,%eax -c01083af: 74 24 je c01083d5 -c01083b1: c7 44 24 0c e8 bf 10 movl $0xc010bfe8,0xc(%esp) -c01083b8: c0 -c01083b9: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01083c0: c0 -c01083c1: c7 44 24 04 55 01 00 movl $0x155,0x4(%esp) -c01083c8: 00 -c01083c9: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01083d0: e8 6e 80 ff ff call c0100443 <__panic> - assert(PageProperty(p0 + 2) && p0[2].property == 3);// 检查页面属性 -c01083d5: 8b 45 e8 mov -0x18(%ebp),%eax -c01083d8: 83 c0 40 add $0x40,%eax -c01083db: 83 c0 04 add $0x4,%eax -c01083de: c7 45 ac 01 00 00 00 movl $0x1,-0x54(%ebp) -c01083e5: 89 45 a8 mov %eax,-0x58(%ebp) - asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); -c01083e8: 8b 45 a8 mov -0x58(%ebp),%eax -c01083eb: 8b 55 ac mov -0x54(%ebp),%edx -c01083ee: 0f a3 10 bt %edx,(%eax) -c01083f1: 19 c0 sbb %eax,%eax -c01083f3: 89 45 a4 mov %eax,-0x5c(%ebp) - return oldbit != 0; -c01083f6: 83 7d a4 00 cmpl $0x0,-0x5c(%ebp) -c01083fa: 0f 95 c0 setne %al -c01083fd: 0f b6 c0 movzbl %al,%eax -c0108400: 85 c0 test %eax,%eax -c0108402: 74 0e je c0108412 -c0108404: 8b 45 e8 mov -0x18(%ebp),%eax -c0108407: 83 c0 40 add $0x40,%eax -c010840a: 8b 40 08 mov 0x8(%eax),%eax -c010840d: 83 f8 03 cmp $0x3,%eax -c0108410: 74 24 je c0108436 -c0108412: c7 44 24 0c 00 c0 10 movl $0xc010c000,0xc(%esp) -c0108419: c0 -c010841a: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0108421: c0 -c0108422: c7 44 24 04 56 01 00 movl $0x156,0x4(%esp) -c0108429: 00 -c010842a: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0108431: e8 0d 80 ff ff call c0100443 <__panic> - assert((p1 = alloc_pages(3)) != NULL);// 再次分配 3 个页面 -c0108436: c7 04 24 03 00 00 00 movl $0x3,(%esp) -c010843d: e8 17 b3 ff ff call c0103759 -c0108442: 89 45 e0 mov %eax,-0x20(%ebp) -c0108445: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) -c0108449: 75 24 jne c010846f -c010844b: c7 44 24 0c 2c c0 10 movl $0xc010c02c,0xc(%esp) -c0108452: c0 -c0108453: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c010845a: c0 -c010845b: c7 44 24 04 57 01 00 movl $0x157,0x4(%esp) -c0108462: 00 -c0108463: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c010846a: e8 d4 7f ff ff call c0100443 <__panic> - assert(alloc_page() == NULL);// 确保没有页面可分配 -c010846f: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0108476: e8 de b2 ff ff call c0103759 -c010847b: 85 c0 test %eax,%eax -c010847d: 74 24 je c01084a3 -c010847f: c7 44 24 0c 42 bf 10 movl $0xc010bf42,0xc(%esp) -c0108486: c0 -c0108487: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c010848e: c0 -c010848f: c7 44 24 04 58 01 00 movl $0x158,0x4(%esp) -c0108496: 00 -c0108497: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c010849e: e8 a0 7f ff ff call c0100443 <__panic> - assert(p0 + 2 == p1);// 确保分配的页面是释放的页面 -c01084a3: 8b 45 e8 mov -0x18(%ebp),%eax -c01084a6: 83 c0 40 add $0x40,%eax -c01084a9: 39 45 e0 cmp %eax,-0x20(%ebp) -c01084ac: 74 24 je c01084d2 -c01084ae: c7 44 24 0c 4a c0 10 movl $0xc010c04a,0xc(%esp) -c01084b5: c0 -c01084b6: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01084bd: c0 -c01084be: c7 44 24 04 59 01 00 movl $0x159,0x4(%esp) -c01084c5: 00 -c01084c6: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01084cd: e8 71 7f ff ff call c0100443 <__panic> +c010839c: e8 a7 cc ff ff call c0105048 + // 将页目录的第0项设置为空 + pgdir[0] = 0; +c01083a1: 8b 45 e4 mov -0x1c(%ebp),%eax +c01083a4: c7 00 00 00 00 00 movl $0x0,(%eax) + // 将内存管理结构体中的页目录设置为空 + mm->pgdir = NULL; +c01083aa: 8b 45 e8 mov -0x18(%ebp),%eax +c01083ad: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) + // 销毁内存管理结构体 + mm_destroy(mm); +c01083b4: 8b 45 e8 mov -0x18(%ebp),%eax +c01083b7: 89 04 24 mov %eax,(%esp) +c01083ba: e8 c2 f8 ff ff call c0107c81 + // 将检查用的内存管理结构体设置为空 + check_mm_struct = NULL; +c01083bf: c7 05 6c c1 12 c0 00 movl $0x0,0xc012c16c +c01083c6: 00 00 00 + // 确保空闲页面的数量没有变化,证明内存管理正确 + assert(nr_free_pages_store == nr_free_pages()); +c01083c9: e8 af cc ff ff call c010507d +c01083ce: 39 45 ec cmp %eax,-0x14(%ebp) +c01083d1: 74 24 je c01083f7 +c01083d3: c7 44 24 0c 24 bd 10 movl $0xc010bd24,0xc(%esp) +c01083da: c0 +c01083db: c7 44 24 08 e3 ba 10 movl $0xc010bae3,0x8(%esp) +c01083e2: c0 +c01083e3: c7 44 24 04 96 01 00 movl $0x196,0x4(%esp) +c01083ea: 00 +c01083eb: c7 04 24 f8 ba 10 c0 movl $0xc010baf8,(%esp) +c01083f2: e8 4e 88 ff ff call c0100c45 <__panic> + // 打印成功信息 + cprintf("check_pgfault() succeeded!\n"); +c01083f7: c7 04 24 4b bd 10 c0 movl $0xc010bd4b,(%esp) +c01083fe: e8 75 7f ff ff call c0100378 +} +c0108403: 90 nop +c0108404: 89 ec mov %ebp,%esp +c0108406: 5d pop %ebp +c0108407: c3 ret - p2 = p0 + 1;// 设置 p2 为 p0 的下一个页面 -c01084d2: 8b 45 e8 mov -0x18(%ebp),%eax -c01084d5: 83 c0 20 add $0x20,%eax -c01084d8: 89 45 dc mov %eax,-0x24(%ebp) - free_page(p0);// 释放 p0 页面 -c01084db: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c01084e2: 00 -c01084e3: 8b 45 e8 mov -0x18(%ebp),%eax -c01084e6: 89 04 24 mov %eax,(%esp) -c01084e9: e8 da b2 ff ff call c01037c8 - free_pages(p1, 3);// 释放 p1 指向的页面 -c01084ee: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp) -c01084f5: 00 -c01084f6: 8b 45 e0 mov -0x20(%ebp),%eax -c01084f9: 89 04 24 mov %eax,(%esp) -c01084fc: e8 c7 b2 ff ff call c01037c8 - assert(PageProperty(p0) && p0->property == 1);// 检查 p0 属性 -c0108501: 8b 45 e8 mov -0x18(%ebp),%eax -c0108504: 83 c0 04 add $0x4,%eax -c0108507: c7 45 a0 01 00 00 00 movl $0x1,-0x60(%ebp) -c010850e: 89 45 9c mov %eax,-0x64(%ebp) - asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); -c0108511: 8b 45 9c mov -0x64(%ebp),%eax -c0108514: 8b 55 a0 mov -0x60(%ebp),%edx -c0108517: 0f a3 10 bt %edx,(%eax) -c010851a: 19 c0 sbb %eax,%eax -c010851c: 89 45 98 mov %eax,-0x68(%ebp) - return oldbit != 0; -c010851f: 83 7d 98 00 cmpl $0x0,-0x68(%ebp) -c0108523: 0f 95 c0 setne %al -c0108526: 0f b6 c0 movzbl %al,%eax -c0108529: 85 c0 test %eax,%eax -c010852b: 74 0b je c0108538 -c010852d: 8b 45 e8 mov -0x18(%ebp),%eax -c0108530: 8b 40 08 mov 0x8(%eax),%eax -c0108533: 83 f8 01 cmp $0x1,%eax -c0108536: 74 24 je c010855c -c0108538: c7 44 24 0c 58 c0 10 movl $0xc010c058,0xc(%esp) -c010853f: c0 -c0108540: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0108547: c0 -c0108548: c7 44 24 04 5e 01 00 movl $0x15e,0x4(%esp) -c010854f: 00 -c0108550: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0108557: e8 e7 7e ff ff call c0100443 <__panic> - assert(PageProperty(p1) && p1->property == 3);// 检查 p1 属性 -c010855c: 8b 45 e0 mov -0x20(%ebp),%eax -c010855f: 83 c0 04 add $0x4,%eax -c0108562: c7 45 94 01 00 00 00 movl $0x1,-0x6c(%ebp) -c0108569: 89 45 90 mov %eax,-0x70(%ebp) - asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr)); -c010856c: 8b 45 90 mov -0x70(%ebp),%eax -c010856f: 8b 55 94 mov -0x6c(%ebp),%edx -c0108572: 0f a3 10 bt %edx,(%eax) -c0108575: 19 c0 sbb %eax,%eax -c0108577: 89 45 8c mov %eax,-0x74(%ebp) - return oldbit != 0; -c010857a: 83 7d 8c 00 cmpl $0x0,-0x74(%ebp) -c010857e: 0f 95 c0 setne %al -c0108581: 0f b6 c0 movzbl %al,%eax -c0108584: 85 c0 test %eax,%eax -c0108586: 74 0b je c0108593 -c0108588: 8b 45 e0 mov -0x20(%ebp),%eax -c010858b: 8b 40 08 mov 0x8(%eax),%eax -c010858e: 83 f8 03 cmp $0x3,%eax -c0108591: 74 24 je c01085b7 -c0108593: c7 44 24 0c 80 c0 10 movl $0xc010c080,0xc(%esp) -c010859a: c0 -c010859b: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01085a2: c0 -c01085a3: c7 44 24 04 5f 01 00 movl $0x15f,0x4(%esp) -c01085aa: 00 -c01085ab: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01085b2: e8 8c 7e ff ff call c0100443 <__panic> - // 确保重分配的页面是之前释放的页面 - assert((p0 = alloc_page()) == p2 - 1); -c01085b7: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c01085be: e8 96 b1 ff ff call c0103759 -c01085c3: 89 45 e8 mov %eax,-0x18(%ebp) -c01085c6: 8b 45 dc mov -0x24(%ebp),%eax -c01085c9: 83 e8 20 sub $0x20,%eax -c01085cc: 39 45 e8 cmp %eax,-0x18(%ebp) -c01085cf: 74 24 je c01085f5 -c01085d1: c7 44 24 0c a6 c0 10 movl $0xc010c0a6,0xc(%esp) -c01085d8: c0 -c01085d9: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01085e0: c0 -c01085e1: c7 44 24 04 61 01 00 movl $0x161,0x4(%esp) -c01085e8: 00 -c01085e9: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01085f0: e8 4e 7e ff ff call c0100443 <__panic> - free_page(p0);// 释放分配的页面 -c01085f5: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c01085fc: 00 -c01085fd: 8b 45 e8 mov -0x18(%ebp),%eax -c0108600: 89 04 24 mov %eax,(%esp) -c0108603: e8 c0 b1 ff ff call c01037c8 - assert((p0 = alloc_pages(2)) == p2 + 1);// 分配 2 个页面并检查 -c0108608: c7 04 24 02 00 00 00 movl $0x2,(%esp) -c010860f: e8 45 b1 ff ff call c0103759 -c0108614: 89 45 e8 mov %eax,-0x18(%ebp) -c0108617: 8b 45 dc mov -0x24(%ebp),%eax -c010861a: 83 c0 20 add $0x20,%eax -c010861d: 39 45 e8 cmp %eax,-0x18(%ebp) -c0108620: 74 24 je c0108646 -c0108622: c7 44 24 0c c4 c0 10 movl $0xc010c0c4,0xc(%esp) -c0108629: c0 -c010862a: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0108631: c0 -c0108632: c7 44 24 04 63 01 00 movl $0x163,0x4(%esp) -c0108639: 00 -c010863a: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0108641: e8 fd 7d ff ff call c0100443 <__panic> - // 释放页面并检查空闲状态 - free_pages(p0, 2); -c0108646: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) -c010864d: 00 -c010864e: 8b 45 e8 mov -0x18(%ebp),%eax -c0108651: 89 04 24 mov %eax,(%esp) -c0108654: e8 6f b1 ff ff call c01037c8 - free_page(p2); -c0108659: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) -c0108660: 00 -c0108661: 8b 45 dc mov -0x24(%ebp),%eax -c0108664: 89 04 24 mov %eax,(%esp) -c0108667: e8 5c b1 ff ff call c01037c8 - // 再次分配 5 个页面 - assert((p0 = alloc_pages(5)) != NULL); -c010866c: c7 04 24 05 00 00 00 movl $0x5,(%esp) -c0108673: e8 e1 b0 ff ff call c0103759 -c0108678: 89 45 e8 mov %eax,-0x18(%ebp) -c010867b: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) -c010867f: 75 24 jne c01086a5 -c0108681: c7 44 24 0c e4 c0 10 movl $0xc010c0e4,0xc(%esp) -c0108688: c0 -c0108689: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0108690: c0 -c0108691: c7 44 24 04 68 01 00 movl $0x168,0x4(%esp) -c0108698: 00 -c0108699: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01086a0: e8 9e 7d ff ff call c0100443 <__panic> - assert(alloc_page() == NULL);// 确保没有额外页面可分配 -c01086a5: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c01086ac: e8 a8 b0 ff ff call c0103759 -c01086b1: 85 c0 test %eax,%eax -c01086b3: 74 24 je c01086d9 -c01086b5: c7 44 24 0c 42 bf 10 movl $0xc010bf42,0xc(%esp) -c01086bc: c0 -c01086bd: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01086c4: c0 -c01086c5: c7 44 24 04 69 01 00 movl $0x169,0x4(%esp) -c01086cc: 00 -c01086cd: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01086d4: e8 6a 7d ff ff call c0100443 <__panic> +c0108408 : + * @param addr 引发页面错误的线性地址。 + * + * @return 成功返回0,失败返回负错误码。 + */ +int +do_pgfault(struct mm_struct *mm, uint32_t error_code, uintptr_t addr) { +c0108408: 55 push %ebp +c0108409: 89 e5 mov %esp,%ebp +c010840b: 83 ec 38 sub $0x38,%esp + int ret = -E_INVAL;// 初始化返回值为无效错误 +c010840e: c7 45 f4 fd ff ff ff movl $0xfffffffd,-0xc(%ebp) + //try to find a vma which include addr + // 尝试找到包含 addr 的 vma + struct vma_struct *vma = find_vma(mm, addr); +c0108415: 8b 45 10 mov 0x10(%ebp),%eax +c0108418: 89 44 24 04 mov %eax,0x4(%esp) +c010841c: 8b 45 08 mov 0x8(%ebp),%eax +c010841f: 89 04 24 mov %eax,(%esp) +c0108422: e8 ca f5 ff ff call c01079f1 +c0108427: 89 45 ec mov %eax,-0x14(%ebp) - assert(nr_free == 0);// 确保空闲页数为 0 -c01086d9: a1 ac e1 12 c0 mov 0xc012e1ac,%eax -c01086de: 85 c0 test %eax,%eax -c01086e0: 74 24 je c0108706 -c01086e2: c7 44 24 0c 95 bf 10 movl $0xc010bf95,0xc(%esp) -c01086e9: c0 -c01086ea: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01086f1: c0 -c01086f2: c7 44 24 04 6b 01 00 movl $0x16b,0x4(%esp) -c01086f9: 00 -c01086fa: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0108701: e8 3d 7d ff ff call c0100443 <__panic> - nr_free = nr_free_store;// 恢复空闲页数 -c0108706: 8b 45 e4 mov -0x1c(%ebp),%eax -c0108709: a3 ac e1 12 c0 mov %eax,0xc012e1ac - // 恢复空闲列表状态 - free_list = free_list_store; -c010870e: 8b 45 80 mov -0x80(%ebp),%eax -c0108711: 8b 55 84 mov -0x7c(%ebp),%edx -c0108714: a3 a4 e1 12 c0 mov %eax,0xc012e1a4 -c0108719: 89 15 a8 e1 12 c0 mov %edx,0xc012e1a8 - free_pages(p0, 5);// 释放所有分配的页面 -c010871f: c7 44 24 04 05 00 00 movl $0x5,0x4(%esp) -c0108726: 00 -c0108727: 8b 45 e8 mov -0x18(%ebp),%eax -c010872a: 89 04 24 mov %eax,(%esp) -c010872d: e8 96 b0 ff ff call c01037c8 - // 验证空闲列表的一致性 - le = &free_list; -c0108732: c7 45 ec a4 e1 12 c0 movl $0xc012e1a4,-0x14(%ebp) - while ((le = list_next(le)) != &free_list) { -c0108739: eb 1c jmp c0108757 - struct Page *p = le2page(le, page_link); -c010873b: 8b 45 ec mov -0x14(%ebp),%eax -c010873e: 83 e8 0c sub $0xc,%eax -c0108741: 89 45 d8 mov %eax,-0x28(%ebp) - count --, total -= p->property; -c0108744: ff 4d f4 decl -0xc(%ebp) -c0108747: 8b 55 f0 mov -0x10(%ebp),%edx -c010874a: 8b 45 d8 mov -0x28(%ebp),%eax -c010874d: 8b 40 08 mov 0x8(%eax),%eax -c0108750: 29 c2 sub %eax,%edx -c0108752: 89 d0 mov %edx,%eax -c0108754: 89 45 f0 mov %eax,-0x10(%ebp) -c0108757: 8b 45 ec mov -0x14(%ebp),%eax -c010875a: 89 45 88 mov %eax,-0x78(%ebp) - return listelm->next; -c010875d: 8b 45 88 mov -0x78(%ebp),%eax -c0108760: 8b 40 04 mov 0x4(%eax),%eax - while ((le = list_next(le)) != &free_list) { -c0108763: 89 45 ec mov %eax,-0x14(%ebp) -c0108766: 81 7d ec a4 e1 12 c0 cmpl $0xc012e1a4,-0x14(%ebp) -c010876d: 75 cc jne c010873b + pgfault_num++;// 增加页面错误计数 +c010842a: a1 70 c1 12 c0 mov 0xc012c170,%eax +c010842f: 40 inc %eax +c0108430: a3 70 c1 12 c0 mov %eax,0xc012c170 + // 检查 addr 是否在 mm 的 vma 范围内 + //If the addr is in the range of a mm's vma? + if (vma == NULL || vma->vm_start > addr) { +c0108435: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) +c0108439: 74 0b je c0108446 +c010843b: 8b 45 ec mov -0x14(%ebp),%eax +c010843e: 8b 40 04 mov 0x4(%eax),%eax +c0108441: 39 45 10 cmp %eax,0x10(%ebp) +c0108444: 73 18 jae c010845e + cprintf("not valid addr %x, and can not find it in vma\n", addr); +c0108446: 8b 45 10 mov 0x10(%ebp),%eax +c0108449: 89 44 24 04 mov %eax,0x4(%esp) +c010844d: c7 04 24 68 bd 10 c0 movl $0xc010bd68,(%esp) +c0108454: e8 1f 7f ff ff call c0100378 + goto failed;// 跳转到错误处理部分 +c0108459: e9 ba 01 00 00 jmp c0108618 } - assert(count == 0);// 确保所有页面都已处理 -c010876f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0108773: 74 24 je c0108799 -c0108775: c7 44 24 0c 02 c1 10 movl $0xc010c102,0xc(%esp) -c010877c: c0 -c010877d: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c0108784: c0 -c0108785: c7 44 24 04 76 01 00 movl $0x176,0x4(%esp) -c010878c: 00 -c010878d: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c0108794: e8 aa 7c ff ff call c0100443 <__panic> - assert(total == 0);// 确保总属性值为 0 -c0108799: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c010879d: 74 24 je c01087c3 -c010879f: c7 44 24 0c 0d c1 10 movl $0xc010c10d,0xc(%esp) -c01087a6: c0 -c01087a7: c7 44 24 08 a2 bd 10 movl $0xc010bda2,0x8(%esp) -c01087ae: c0 -c01087af: c7 44 24 04 77 01 00 movl $0x177,0x4(%esp) -c01087b6: 00 -c01087b7: c7 04 24 b7 bd 10 c0 movl $0xc010bdb7,(%esp) -c01087be: e8 80 7c ff ff call c0100443 <__panic> -} -c01087c3: 90 nop -c01087c4: c9 leave -c01087c5: c3 ret - -c01087c6 : + //check the error_code + // 检查错误代码 + switch (error_code & 3) { +c010845e: 8b 45 0c mov 0xc(%ebp),%eax +c0108461: 83 e0 03 and $0x3,%eax +c0108464: 85 c0 test %eax,%eax +c0108466: 74 34 je c010849c +c0108468: 83 f8 01 cmp $0x1,%eax +c010846b: 74 1e je c010848b + default: + /* 默认错误代码标志:3 (W/R=1, P=1): 写操作,存在 */ + /* error code flag : default is 3 ( W/R=1, P=1): write, present */ + case 2: /* error code flag : (W/R=1, P=0): write, not present */ + /* 错误代码标志:(W/R=1, P=0): 写操作,不存在 */ + if (!(vma->vm_flags & VM_WRITE)) { +c010846d: 8b 45 ec mov -0x14(%ebp),%eax +c0108470: 8b 40 0c mov 0xc(%eax),%eax +c0108473: 83 e0 02 and $0x2,%eax +c0108476: 85 c0 test %eax,%eax +c0108478: 75 40 jne c01084ba + cprintf("do_pgfault failed: error code flag = write AND not present, but the addr's vma cannot write\n"); +c010847a: c7 04 24 98 bd 10 c0 movl $0xc010bd98,(%esp) +c0108481: e8 f2 7e ff ff call c0100378 + goto failed;// 跳转到错误处理部分 +c0108486: e9 8d 01 00 00 jmp c0108618 + } + break; + case 1: /* error code flag : (W/R=0, P=1): read, present */ + /* 错误代码标志:(W/R=0, P=1): 读操作,存在 */ + cprintf("do_pgfault failed: error code flag = read AND present\n"); +c010848b: c7 04 24 f8 bd 10 c0 movl $0xc010bdf8,(%esp) +c0108492: e8 e1 7e ff ff call c0100378 + goto failed;// 跳转到错误处理部分 +c0108497: e9 7c 01 00 00 jmp c0108618 + case 0: /* error code flag : (W/R=0, P=0): read, not present */ + /* 错误代码标志:(W/R=0, P=0): 读操作,不存在 */ + if (!(vma->vm_flags & (VM_READ | VM_EXEC))) { +c010849c: 8b 45 ec mov -0x14(%ebp),%eax +c010849f: 8b 40 0c mov 0xc(%eax),%eax +c01084a2: 83 e0 05 and $0x5,%eax +c01084a5: 85 c0 test %eax,%eax +c01084a7: 75 12 jne c01084bb + cprintf("do_pgfault failed: error code flag = read AND not present, but the addr's vma cannot read or exec\n"); +c01084a9: c7 04 24 30 be 10 c0 movl $0xc010be30,(%esp) +c01084b0: e8 c3 7e ff ff call c0100378 + goto failed;// 跳转到错误处理部分 +c01084b5: e9 5e 01 00 00 jmp c0108618 + break; +c01084ba: 90 nop + /* 如果 (写入已存在的地址) 或 + * (写入不存在的地址且地址可写) 或 + * (读取不存在的地址且地址可读) + * 则继续处理 + */ + uint32_t perm = PTE_U;// 初始化权限标志为用户可访问 +c01084bb: c7 45 f0 04 00 00 00 movl $0x4,-0x10(%ebp) + if (vma->vm_flags & VM_WRITE) { +c01084c2: 8b 45 ec mov -0x14(%ebp),%eax +c01084c5: 8b 40 0c mov 0xc(%eax),%eax +c01084c8: 83 e0 02 and $0x2,%eax +c01084cb: 85 c0 test %eax,%eax +c01084cd: 74 04 je c01084d3 + perm |= PTE_W;// 如果 vma 可写,则设置写权限 +c01084cf: 83 4d f0 02 orl $0x2,-0x10(%ebp) + } + addr = ROUNDDOWN(addr, PGSIZE);// 将地址对齐到页边界 +c01084d3: 8b 45 10 mov 0x10(%ebp),%eax +c01084d6: 89 45 e8 mov %eax,-0x18(%ebp) +c01084d9: 8b 45 e8 mov -0x18(%ebp),%eax +c01084dc: 25 00 f0 ff ff and $0xfffff000,%eax +c01084e1: 89 45 10 mov %eax,0x10(%ebp) + + ret = -E_NO_MEM;// 初始化返回值为内存不足错误 +c01084e4: c7 45 f4 fc ff ff ff movl $0xfffffffc,-0xc(%ebp) + + pte_t *ptep=NULL; +c01084eb: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) +#endif + // try to find a pte, if pte's PT(Page Table) isn't existed, then create a PT. + // (notice the 3th parameter '1') + // 尝试找到一个页表项 pte,如果包含该 pte 的页表不存在,则创建一个页表。 + // 注意第三个参数 '1' 表示如果需要,可以创建新的页表。 + if ((ptep = get_pte(mm->pgdir, addr, 1)) == NULL) { +c01084f2: 8b 45 08 mov 0x8(%ebp),%eax +c01084f5: 8b 40 0c mov 0xc(%eax),%eax +c01084f8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) +c01084ff: 00 +c0108500: 8b 55 10 mov 0x10(%ebp),%edx +c0108503: 89 54 24 04 mov %edx,0x4(%esp) +c0108507: 89 04 24 mov %eax,(%esp) +c010850a: e8 87 d1 ff ff call c0105696 +c010850f: 89 45 e4 mov %eax,-0x1c(%ebp) +c0108512: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) +c0108516: 75 11 jne c0108529 + cprintf("get_pte in do_pgfault failed\n");// 输出错误信息 +c0108518: c7 04 24 93 be 10 c0 movl $0xc010be93,(%esp) +c010851f: e8 54 7e ff ff call c0100378 + goto failed;// 跳转到错误处理部分 +c0108524: e9 ef 00 00 00 jmp c0108618 + } + // 如果页表项 pte 的物理地址不存在,则分配一页内存并映射物理地址与逻辑地址 + if (*ptep == 0) { // if the phy addr isn't exist, then alloc a page & map the phy addr with logical addr +c0108529: 8b 45 e4 mov -0x1c(%ebp),%eax +c010852c: 8b 00 mov (%eax),%eax +c010852e: 85 c0 test %eax,%eax +c0108530: 75 35 jne c0108567 + if (pgdir_alloc_page(mm->pgdir, addr, perm) == NULL) { +c0108532: 8b 45 08 mov 0x8(%ebp),%eax +c0108535: 8b 40 0c mov 0xc(%eax),%eax +c0108538: 8b 55 f0 mov -0x10(%ebp),%edx +c010853b: 89 54 24 08 mov %edx,0x8(%esp) +c010853f: 8b 55 10 mov 0x10(%ebp),%edx +c0108542: 89 54 24 04 mov %edx,0x4(%esp) +c0108546: 89 04 24 mov %eax,(%esp) +c0108549: e8 a3 d4 ff ff call c01059f1 +c010854e: 85 c0 test %eax,%eax +c0108550: 0f 85 bb 00 00 00 jne c0108611 + cprintf("pgdir_alloc_page in do_pgfault failed\n");// 输出错误信息 +c0108556: c7 04 24 b4 be 10 c0 movl $0xc010beb4,(%esp) +c010855d: e8 16 7e ff ff call c0100378 + goto failed;// 跳转到错误处理部分 +c0108562: e9 b1 00 00 00 jmp c0108618 + } + else { // if this pte is a swap entry, then load data from disk to a page with phy addr + // and call page_insert to map the phy addr with logical addr + // 如果页表项 pte 是一个交换项,则从磁盘加载数据到 + //一个具有物理地址的页面,并映射物理地址与逻辑地址 + if(swap_init_ok) {// 检查交换初始化是否成功 +c0108567: a1 a4 c0 12 c0 mov 0xc012c0a4,%eax +c010856c: 85 c0 test %eax,%eax +c010856e: 0f 84 86 00 00 00 je c01085fa + struct Page *page=NULL;// 声明一个页面指针 +c0108574: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) + if ((ret = swap_in(mm, addr, &page)) != 0) { +c010857b: 8d 45 e0 lea -0x20(%ebp),%eax +c010857e: 89 44 24 08 mov %eax,0x8(%esp) +c0108582: 8b 45 10 mov 0x10(%ebp),%eax +c0108585: 89 44 24 04 mov %eax,0x4(%esp) +c0108589: 8b 45 08 mov 0x8(%ebp),%eax +c010858c: 89 04 24 mov %eax,(%esp) +c010858f: e8 e8 e4 ff ff call c0106a7c +c0108594: 89 45 f4 mov %eax,-0xc(%ebp) +c0108597: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c010859b: 74 0e je c01085ab + cprintf("swap_in in do_pgfault failed\n"); +c010859d: c7 04 24 db be 10 c0 movl $0xc010bedb,(%esp) +c01085a4: e8 cf 7d ff ff call c0100378 +c01085a9: eb 6d jmp c0108618 + goto failed; + } + page_insert(mm->pgdir, page, addr, perm);// 设置物理地址与逻辑地址的映射 +c01085ab: 8b 55 e0 mov -0x20(%ebp),%edx +c01085ae: 8b 45 08 mov 0x8(%ebp),%eax +c01085b1: 8b 40 0c mov 0xc(%eax),%eax +c01085b4: 8b 4d f0 mov -0x10(%ebp),%ecx +c01085b7: 89 4c 24 0c mov %ecx,0xc(%esp) +c01085bb: 8b 4d 10 mov 0x10(%ebp),%ecx +c01085be: 89 4c 24 08 mov %ecx,0x8(%esp) +c01085c2: 89 54 24 04 mov %edx,0x4(%esp) +c01085c6: 89 04 24 mov %eax,(%esp) +c01085c9: e8 09 d3 ff ff call c01058d7 + swap_map_swappable(mm, addr, page, 1);// 设置页面可交换 +c01085ce: 8b 45 e0 mov -0x20(%ebp),%eax +c01085d1: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) +c01085d8: 00 +c01085d9: 89 44 24 08 mov %eax,0x8(%esp) +c01085dd: 8b 45 10 mov 0x10(%ebp),%eax +c01085e0: 89 44 24 04 mov %eax,0x4(%esp) +c01085e4: 8b 45 08 mov 0x8(%ebp),%eax +c01085e7: 89 04 24 mov %eax,(%esp) +c01085ea: e8 c5 e2 ff ff call c01068b4 + page->pra_vaddr = addr;// 记录页面的虚拟地址 +c01085ef: 8b 45 e0 mov -0x20(%ebp),%eax +c01085f2: 8b 55 10 mov 0x10(%ebp),%edx +c01085f5: 89 50 1c mov %edx,0x1c(%eax) +c01085f8: eb 17 jmp c0108611 + } + else { + cprintf("no swap_init_ok but ptep is %x, failed\n",*ptep); +c01085fa: 8b 45 e4 mov -0x1c(%ebp),%eax +c01085fd: 8b 00 mov (%eax),%eax +c01085ff: 89 44 24 04 mov %eax,0x4(%esp) +c0108603: c7 04 24 fc be 10 c0 movl $0xc010befc,(%esp) +c010860a: e8 69 7d ff ff call c0100378 + goto failed;// 跳转到错误处理部分 +c010860f: eb 07 jmp c0108618 + } + } + ret = 0;// 设置返回值为成功 +c0108611: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +failed: + return ret;// 返回结果 +c0108618: 8b 45 f4 mov -0xc(%ebp),%eax +} +c010861b: 89 ec mov %ebp,%esp +c010861d: 5d pop %ebp +c010861e: c3 ret + +c010861f : page2ppn(struct Page *page) { -c01087c6: 55 push %ebp -c01087c7: 89 e5 mov %esp,%ebp +c010861f: 55 push %ebp +c0108620: 89 e5 mov %esp,%ebp return page - pages; -c01087c9: a1 b8 e0 12 c0 mov 0xc012e0b8,%eax -c01087ce: 8b 55 08 mov 0x8(%ebp),%edx -c01087d1: 29 c2 sub %eax,%edx -c01087d3: 89 d0 mov %edx,%eax -c01087d5: c1 f8 05 sar $0x5,%eax +c0108622: 8b 15 00 c0 12 c0 mov 0xc012c000,%edx +c0108628: 8b 45 08 mov 0x8(%ebp),%eax +c010862b: 29 d0 sub %edx,%eax +c010862d: c1 f8 05 sar $0x5,%eax } -c01087d8: 5d pop %ebp -c01087d9: c3 ret +c0108630: 5d pop %ebp +c0108631: c3 ret -c01087da : +c0108632 : page2pa(struct Page *page) { -c01087da: 55 push %ebp -c01087db: 89 e5 mov %esp,%ebp -c01087dd: 83 ec 04 sub $0x4,%esp +c0108632: 55 push %ebp +c0108633: 89 e5 mov %esp,%ebp +c0108635: 83 ec 04 sub $0x4,%esp return page2ppn(page) << PGSHIFT; -c01087e0: 8b 45 08 mov 0x8(%ebp),%eax -c01087e3: 89 04 24 mov %eax,(%esp) -c01087e6: e8 db ff ff ff call c01087c6 -c01087eb: c1 e0 0c shl $0xc,%eax +c0108638: 8b 45 08 mov 0x8(%ebp),%eax +c010863b: 89 04 24 mov %eax,(%esp) +c010863e: e8 dc ff ff ff call c010861f +c0108643: c1 e0 0c shl $0xc,%eax } -c01087ee: c9 leave -c01087ef: c3 ret +c0108646: 89 ec mov %ebp,%esp +c0108648: 5d pop %ebp +c0108649: c3 ret -c01087f0 : +c010864a : page2kva(struct Page *page) { -c01087f0: 55 push %ebp -c01087f1: 89 e5 mov %esp,%ebp -c01087f3: 83 ec 28 sub $0x28,%esp +c010864a: 55 push %ebp +c010864b: 89 e5 mov %esp,%ebp +c010864d: 83 ec 28 sub $0x28,%esp return KADDR(page2pa(page)); -c01087f6: 8b 45 08 mov 0x8(%ebp),%eax -c01087f9: 89 04 24 mov %eax,(%esp) -c01087fc: e8 d9 ff ff ff call c01087da -c0108801: 89 45 f4 mov %eax,-0xc(%ebp) -c0108804: 8b 45 f4 mov -0xc(%ebp),%eax -c0108807: c1 e8 0c shr $0xc,%eax -c010880a: 89 45 f0 mov %eax,-0x10(%ebp) -c010880d: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0108812: 39 45 f0 cmp %eax,-0x10(%ebp) -c0108815: 72 23 jb c010883a -c0108817: 8b 45 f4 mov -0xc(%ebp),%eax -c010881a: 89 44 24 0c mov %eax,0xc(%esp) -c010881e: c7 44 24 08 48 c1 10 movl $0xc010c148,0x8(%esp) -c0108825: c0 -c0108826: c7 44 24 04 66 00 00 movl $0x66,0x4(%esp) -c010882d: 00 -c010882e: c7 04 24 6b c1 10 c0 movl $0xc010c16b,(%esp) -c0108835: e8 09 7c ff ff call c0100443 <__panic> -c010883a: 8b 45 f4 mov -0xc(%ebp),%eax -c010883d: 2d 00 00 00 40 sub $0x40000000,%eax -} -c0108842: c9 leave -c0108843: c3 ret - -c0108844 : +c0108650: 8b 45 08 mov 0x8(%ebp),%eax +c0108653: 89 04 24 mov %eax,(%esp) +c0108656: e8 d7 ff ff ff call c0108632 +c010865b: 89 45 f4 mov %eax,-0xc(%ebp) +c010865e: 8b 45 f4 mov -0xc(%ebp),%eax +c0108661: c1 e8 0c shr $0xc,%eax +c0108664: 89 45 f0 mov %eax,-0x10(%ebp) +c0108667: a1 04 c0 12 c0 mov 0xc012c004,%eax +c010866c: 39 45 f0 cmp %eax,-0x10(%ebp) +c010866f: 72 23 jb c0108694 +c0108671: 8b 45 f4 mov -0xc(%ebp),%eax +c0108674: 89 44 24 0c mov %eax,0xc(%esp) +c0108678: c7 44 24 08 24 bf 10 movl $0xc010bf24,0x8(%esp) +c010867f: c0 +c0108680: c7 44 24 04 66 00 00 movl $0x66,0x4(%esp) +c0108687: 00 +c0108688: c7 04 24 47 bf 10 c0 movl $0xc010bf47,(%esp) +c010868f: e8 b1 85 ff ff call c0100c45 <__panic> +c0108694: 8b 45 f4 mov -0xc(%ebp),%eax +c0108697: 2d 00 00 00 40 sub $0x40000000,%eax +} +c010869c: 89 ec mov %ebp,%esp +c010869e: 5d pop %ebp +c010869f: c3 ret + +c01086a0 : #include #include #include void swapfs_init(void) { -c0108844: f3 0f 1e fb endbr32 -c0108848: 55 push %ebp -c0108849: 89 e5 mov %esp,%ebp -c010884b: 83 ec 18 sub $0x18,%esp +c01086a0: 55 push %ebp +c01086a1: 89 e5 mov %esp,%ebp +c01086a3: 83 ec 18 sub $0x18,%esp static_assert((PGSIZE % SECTSIZE) == 0); if (!ide_device_valid(SWAP_DEV_NO)) { -c010884e: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0108855: e8 63 88 ff ff call c01010bd -c010885a: 85 c0 test %eax,%eax -c010885c: 75 1c jne c010887a +c01086a6: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c01086ad: e8 42 93 ff ff call c01019f4 +c01086b2: 85 c0 test %eax,%eax +c01086b4: 75 1c jne c01086d2 panic("swap fs isn't available.\n"); -c010885e: c7 44 24 08 79 c1 10 movl $0xc010c179,0x8(%esp) -c0108865: c0 -c0108866: c7 44 24 04 0d 00 00 movl $0xd,0x4(%esp) -c010886d: 00 -c010886e: c7 04 24 93 c1 10 c0 movl $0xc010c193,(%esp) -c0108875: e8 c9 7b ff ff call c0100443 <__panic> +c01086b6: c7 44 24 08 55 bf 10 movl $0xc010bf55,0x8(%esp) +c01086bd: c0 +c01086be: c7 44 24 04 0d 00 00 movl $0xd,0x4(%esp) +c01086c5: 00 +c01086c6: c7 04 24 6f bf 10 c0 movl $0xc010bf6f,(%esp) +c01086cd: e8 73 85 ff ff call c0100c45 <__panic> } max_swap_offset = ide_device_size(SWAP_DEV_NO) / (PGSIZE / SECTSIZE); -c010887a: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0108881: e8 79 88 ff ff call c01010ff -c0108886: c1 e8 03 shr $0x3,%eax -c0108889: a3 7c e1 12 c0 mov %eax,0xc012e17c +c01086d2: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c01086d9: e8 56 93 ff ff call c0101a34 +c01086de: c1 e8 03 shr $0x3,%eax +c01086e1: a3 a0 c0 12 c0 mov %eax,0xc012c0a0 } -c010888e: 90 nop -c010888f: c9 leave -c0108890: c3 ret - -c0108891 : +c01086e6: 90 nop +c01086e7: 89 ec mov %ebp,%esp +c01086e9: 5d pop %ebp +c01086ea: c3 ret -int -swapfs_read(swap_entry_t entry, struct Page *page) { -c0108891: f3 0f 1e fb endbr32 -c0108895: 55 push %ebp -c0108896: 89 e5 mov %esp,%ebp -c0108898: 83 ec 28 sub $0x28,%esp - return ide_read_secs(SWAP_DEV_NO, swap_offset(entry) * PAGE_NSECT, page2kva(page), PAGE_NSECT); -c010889b: 8b 45 0c mov 0xc(%ebp),%eax -c010889e: 89 04 24 mov %eax,(%esp) -c01088a1: e8 4a ff ff ff call c01087f0 -c01088a6: 8b 55 08 mov 0x8(%ebp),%edx -c01088a9: c1 ea 08 shr $0x8,%edx -c01088ac: 89 55 f4 mov %edx,-0xc(%ebp) -c01088af: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c01088b3: 74 0b je c01088c0 -c01088b5: 8b 15 7c e1 12 c0 mov 0xc012e17c,%edx -c01088bb: 39 55 f4 cmp %edx,-0xc(%ebp) -c01088be: 72 23 jb c01088e3 -c01088c0: 8b 45 08 mov 0x8(%ebp),%eax -c01088c3: 89 44 24 0c mov %eax,0xc(%esp) -c01088c7: c7 44 24 08 a4 c1 10 movl $0xc010c1a4,0x8(%esp) -c01088ce: c0 -c01088cf: c7 44 24 04 14 00 00 movl $0x14,0x4(%esp) -c01088d6: 00 -c01088d7: c7 04 24 93 c1 10 c0 movl $0xc010c193,(%esp) -c01088de: e8 60 7b ff ff call c0100443 <__panic> -c01088e3: 8b 55 f4 mov -0xc(%ebp),%edx -c01088e6: c1 e2 03 shl $0x3,%edx -c01088e9: c7 44 24 0c 08 00 00 movl $0x8,0xc(%esp) -c01088f0: 00 -c01088f1: 89 44 24 08 mov %eax,0x8(%esp) -c01088f5: 89 54 24 04 mov %edx,0x4(%esp) -c01088f9: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0108900: e8 39 88 ff ff call c010113e -} -c0108905: c9 leave -c0108906: c3 ret - -c0108907 : +c01086eb : int -swapfs_write(swap_entry_t entry, struct Page *page) { -c0108907: f3 0f 1e fb endbr32 -c010890b: 55 push %ebp -c010890c: 89 e5 mov %esp,%ebp -c010890e: 83 ec 28 sub $0x28,%esp - return ide_write_secs(SWAP_DEV_NO, swap_offset(entry) * PAGE_NSECT, page2kva(page), PAGE_NSECT); -c0108911: 8b 45 0c mov 0xc(%ebp),%eax -c0108914: 89 04 24 mov %eax,(%esp) -c0108917: e8 d4 fe ff ff call c01087f0 -c010891c: 8b 55 08 mov 0x8(%ebp),%edx -c010891f: c1 ea 08 shr $0x8,%edx -c0108922: 89 55 f4 mov %edx,-0xc(%ebp) -c0108925: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0108929: 74 0b je c0108936 -c010892b: 8b 15 7c e1 12 c0 mov 0xc012e17c,%edx -c0108931: 39 55 f4 cmp %edx,-0xc(%ebp) -c0108934: 72 23 jb c0108959 -c0108936: 8b 45 08 mov 0x8(%ebp),%eax -c0108939: 89 44 24 0c mov %eax,0xc(%esp) -c010893d: c7 44 24 08 a4 c1 10 movl $0xc010c1a4,0x8(%esp) -c0108944: c0 -c0108945: c7 44 24 04 19 00 00 movl $0x19,0x4(%esp) -c010894c: 00 -c010894d: c7 04 24 93 c1 10 c0 movl $0xc010c193,(%esp) -c0108954: e8 ea 7a ff ff call c0100443 <__panic> -c0108959: 8b 55 f4 mov -0xc(%ebp),%edx -c010895c: c1 e2 03 shl $0x3,%edx -c010895f: c7 44 24 0c 08 00 00 movl $0x8,0xc(%esp) -c0108966: 00 -c0108967: 89 44 24 08 mov %eax,0x8(%esp) -c010896b: 89 54 24 04 mov %edx,0x4(%esp) -c010896f: c7 04 24 01 00 00 00 movl $0x1,(%esp) -c0108976: e8 08 8a ff ff call c0101383 -} -c010897b: c9 leave -c010897c: c3 ret - -c010897d : -.text -.globl switch_to -switch_to: # switch_to(from, to) - - # save from's registers - movl 4(%esp), %eax # eax points to from -c010897d: 8b 44 24 04 mov 0x4(%esp),%eax - popl 0(%eax) # save eip !popl -c0108981: 8f 00 popl (%eax) - movl %esp, 4(%eax) # save esp::context of from -c0108983: 89 60 04 mov %esp,0x4(%eax) - movl %ebx, 8(%eax) # save ebx::context of from -c0108986: 89 58 08 mov %ebx,0x8(%eax) - movl %ecx, 12(%eax) # save ecx::context of from -c0108989: 89 48 0c mov %ecx,0xc(%eax) - movl %edx, 16(%eax) # save edx::context of from -c010898c: 89 50 10 mov %edx,0x10(%eax) - movl %esi, 20(%eax) # save esi::context of from -c010898f: 89 70 14 mov %esi,0x14(%eax) - movl %edi, 24(%eax) # save edi::context of from -c0108992: 89 78 18 mov %edi,0x18(%eax) - movl %ebp, 28(%eax) # save ebp::context of from -c0108995: 89 68 1c mov %ebp,0x1c(%eax) - - # restore to's registers - movl 4(%esp), %eax # not 8(%esp): popped return address already -c0108998: 8b 44 24 04 mov 0x4(%esp),%eax - # eax now points to to - movl 28(%eax), %ebp # restore ebp::context of to -c010899c: 8b 68 1c mov 0x1c(%eax),%ebp - movl 24(%eax), %edi # restore edi::context of to -c010899f: 8b 78 18 mov 0x18(%eax),%edi - movl 20(%eax), %esi # restore esi::context of to -c01089a2: 8b 70 14 mov 0x14(%eax),%esi - movl 16(%eax), %edx # restore edx::context of to -c01089a5: 8b 50 10 mov 0x10(%eax),%edx - movl 12(%eax), %ecx # restore ecx::context of to -c01089a8: 8b 48 0c mov 0xc(%eax),%ecx - movl 8(%eax), %ebx # restore ebx::context of to -c01089ab: 8b 58 08 mov 0x8(%eax),%ebx - movl 4(%eax), %esp # restore esp::context of to -c01089ae: 8b 60 04 mov 0x4(%eax),%esp - - pushl 0(%eax) # push eip -c01089b1: ff 30 pushl (%eax) - - ret -c01089b3: c3 ret +swapfs_read(swap_entry_t entry, struct Page *page) { +c01086eb: 55 push %ebp +c01086ec: 89 e5 mov %esp,%ebp +c01086ee: 83 ec 28 sub $0x28,%esp + return ide_read_secs(SWAP_DEV_NO, swap_offset(entry) * PAGE_NSECT, page2kva(page), PAGE_NSECT); +c01086f1: 8b 45 0c mov 0xc(%ebp),%eax +c01086f4: 89 04 24 mov %eax,(%esp) +c01086f7: e8 4e ff ff ff call c010864a +c01086fc: 8b 55 08 mov 0x8(%ebp),%edx +c01086ff: c1 ea 08 shr $0x8,%edx +c0108702: 89 55 f4 mov %edx,-0xc(%ebp) +c0108705: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0108709: 74 0b je c0108716 +c010870b: 8b 15 a0 c0 12 c0 mov 0xc012c0a0,%edx +c0108711: 39 55 f4 cmp %edx,-0xc(%ebp) +c0108714: 72 23 jb c0108739 +c0108716: 8b 45 08 mov 0x8(%ebp),%eax +c0108719: 89 44 24 0c mov %eax,0xc(%esp) +c010871d: c7 44 24 08 80 bf 10 movl $0xc010bf80,0x8(%esp) +c0108724: c0 +c0108725: c7 44 24 04 14 00 00 movl $0x14,0x4(%esp) +c010872c: 00 +c010872d: c7 04 24 6f bf 10 c0 movl $0xc010bf6f,(%esp) +c0108734: e8 0c 85 ff ff call c0100c45 <__panic> +c0108739: 8b 55 f4 mov -0xc(%ebp),%edx +c010873c: c1 e2 03 shl $0x3,%edx +c010873f: c7 44 24 0c 08 00 00 movl $0x8,0xc(%esp) +c0108746: 00 +c0108747: 89 44 24 08 mov %eax,0x8(%esp) +c010874b: 89 54 24 04 mov %edx,0x4(%esp) +c010874f: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c0108756: e8 16 93 ff ff call c0101a71 +} +c010875b: 89 ec mov %ebp,%esp +c010875d: 5d pop %ebp +c010875e: c3 ret + +c010875f : -c01089b4 : +int +swapfs_write(swap_entry_t entry, struct Page *page) { +c010875f: 55 push %ebp +c0108760: 89 e5 mov %esp,%ebp +c0108762: 83 ec 28 sub $0x28,%esp + return ide_write_secs(SWAP_DEV_NO, swap_offset(entry) * PAGE_NSECT, page2kva(page), PAGE_NSECT); +c0108765: 8b 45 0c mov 0xc(%ebp),%eax +c0108768: 89 04 24 mov %eax,(%esp) +c010876b: e8 da fe ff ff call c010864a +c0108770: 8b 55 08 mov 0x8(%ebp),%edx +c0108773: c1 ea 08 shr $0x8,%edx +c0108776: 89 55 f4 mov %edx,-0xc(%ebp) +c0108779: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c010877d: 74 0b je c010878a +c010877f: 8b 15 a0 c0 12 c0 mov 0xc012c0a0,%edx +c0108785: 39 55 f4 cmp %edx,-0xc(%ebp) +c0108788: 72 23 jb c01087ad +c010878a: 8b 45 08 mov 0x8(%ebp),%eax +c010878d: 89 44 24 0c mov %eax,0xc(%esp) +c0108791: c7 44 24 08 80 bf 10 movl $0xc010bf80,0x8(%esp) +c0108798: c0 +c0108799: c7 44 24 04 19 00 00 movl $0x19,0x4(%esp) +c01087a0: 00 +c01087a1: c7 04 24 6f bf 10 c0 movl $0xc010bf6f,(%esp) +c01087a8: e8 98 84 ff ff call c0100c45 <__panic> +c01087ad: 8b 55 f4 mov -0xc(%ebp),%edx +c01087b0: c1 e2 03 shl $0x3,%edx +c01087b3: c7 44 24 0c 08 00 00 movl $0x8,0xc(%esp) +c01087ba: 00 +c01087bb: 89 44 24 08 mov %eax,0x8(%esp) +c01087bf: 89 54 24 04 mov %edx,0x4(%esp) +c01087c3: c7 04 24 01 00 00 00 movl $0x1,(%esp) +c01087ca: e8 e3 94 ff ff call c0101cb2 +} +c01087cf: 89 ec mov %ebp,%esp +c01087d1: 5d pop %ebp +c01087d2: c3 ret + +c01087d3 : .text .globl kernel_thread_entry kernel_thread_entry: # void kernel_thread(void) pushl %edx # push arg -c01089b4: 52 push %edx +c01087d3: 52 push %edx call *%ebx # call fn -c01089b5: ff d3 call *%ebx +c01087d4: ff d3 call *%ebx pushl %eax # save the return value of fn(arg) -c01089b7: 50 push %eax +c01087d6: 50 push %eax call do_exit # call do_exit to terminate current thread -c01089b8: e8 9d 08 00 00 call c010925a +c01087d7: e8 88 08 00 00 call c0109064 -c01089bd <__intr_save>: +c01087dc <__intr_save>: __intr_save(void) { -c01089bd: 55 push %ebp -c01089be: 89 e5 mov %esp,%ebp -c01089c0: 83 ec 18 sub $0x18,%esp +c01087dc: 55 push %ebp +c01087dd: 89 e5 mov %esp,%ebp +c01087df: 83 ec 18 sub $0x18,%esp asm volatile ("pushfl; popl %0" : "=r" (eflags)); -c01089c3: 9c pushf -c01089c4: 58 pop %eax -c01089c5: 89 45 f4 mov %eax,-0xc(%ebp) +c01087e2: 9c pushf +c01087e3: 58 pop %eax +c01087e4: 89 45 f4 mov %eax,-0xc(%ebp) return eflags; -c01089c8: 8b 45 f4 mov -0xc(%ebp),%eax +c01087e7: 8b 45 f4 mov -0xc(%ebp),%eax if (read_eflags() & FL_IF) { -c01089cb: 25 00 02 00 00 and $0x200,%eax -c01089d0: 85 c0 test %eax,%eax -c01089d2: 74 0c je c01089e0 <__intr_save+0x23> +c01087ea: 25 00 02 00 00 and $0x200,%eax +c01087ef: 85 c0 test %eax,%eax +c01087f1: 74 0c je c01087ff <__intr_save+0x23> intr_disable(); -c01089d4: e8 7b 97 ff ff call c0102154 +c01087f3: e8 03 97 ff ff call c0101efb return 1; -c01089d9: b8 01 00 00 00 mov $0x1,%eax -c01089de: eb 05 jmp c01089e5 <__intr_save+0x28> +c01087f8: b8 01 00 00 00 mov $0x1,%eax +c01087fd: eb 05 jmp c0108804 <__intr_save+0x28> return 0; -c01089e0: b8 00 00 00 00 mov $0x0,%eax +c01087ff: b8 00 00 00 00 mov $0x0,%eax } -c01089e5: c9 leave -c01089e6: c3 ret +c0108804: 89 ec mov %ebp,%esp +c0108806: 5d pop %ebp +c0108807: c3 ret -c01089e7 <__intr_restore>: +c0108808 <__intr_restore>: __intr_restore(bool flag) { -c01089e7: 55 push %ebp -c01089e8: 89 e5 mov %esp,%ebp -c01089ea: 83 ec 08 sub $0x8,%esp +c0108808: 55 push %ebp +c0108809: 89 e5 mov %esp,%ebp +c010880b: 83 ec 08 sub $0x8,%esp if (flag) { -c01089ed: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c01089f1: 74 05 je c01089f8 <__intr_restore+0x11> +c010880e: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0108812: 74 05 je c0108819 <__intr_restore+0x11> intr_enable(); -c01089f3: e8 50 97 ff ff call c0102148 +c0108814: e8 da 96 ff ff call c0101ef3 } -c01089f8: 90 nop -c01089f9: c9 leave -c01089fa: c3 ret +c0108819: 90 nop +c010881a: 89 ec mov %ebp,%esp +c010881c: 5d pop %ebp +c010881d: c3 ret -c01089fb : +c010881e : page2ppn(struct Page *page) { -c01089fb: 55 push %ebp -c01089fc: 89 e5 mov %esp,%ebp +c010881e: 55 push %ebp +c010881f: 89 e5 mov %esp,%ebp return page - pages; -c01089fe: a1 b8 e0 12 c0 mov 0xc012e0b8,%eax -c0108a03: 8b 55 08 mov 0x8(%ebp),%edx -c0108a06: 29 c2 sub %eax,%edx -c0108a08: 89 d0 mov %edx,%eax -c0108a0a: c1 f8 05 sar $0x5,%eax +c0108821: 8b 15 00 c0 12 c0 mov 0xc012c000,%edx +c0108827: 8b 45 08 mov 0x8(%ebp),%eax +c010882a: 29 d0 sub %edx,%eax +c010882c: c1 f8 05 sar $0x5,%eax } -c0108a0d: 5d pop %ebp -c0108a0e: c3 ret +c010882f: 5d pop %ebp +c0108830: c3 ret -c0108a0f : +c0108831 : page2pa(struct Page *page) { -c0108a0f: 55 push %ebp -c0108a10: 89 e5 mov %esp,%ebp -c0108a12: 83 ec 04 sub $0x4,%esp +c0108831: 55 push %ebp +c0108832: 89 e5 mov %esp,%ebp +c0108834: 83 ec 04 sub $0x4,%esp return page2ppn(page) << PGSHIFT; -c0108a15: 8b 45 08 mov 0x8(%ebp),%eax -c0108a18: 89 04 24 mov %eax,(%esp) -c0108a1b: e8 db ff ff ff call c01089fb -c0108a20: c1 e0 0c shl $0xc,%eax +c0108837: 8b 45 08 mov 0x8(%ebp),%eax +c010883a: 89 04 24 mov %eax,(%esp) +c010883d: e8 dc ff ff ff call c010881e +c0108842: c1 e0 0c shl $0xc,%eax } -c0108a23: c9 leave -c0108a24: c3 ret +c0108845: 89 ec mov %ebp,%esp +c0108847: 5d pop %ebp +c0108848: c3 ret -c0108a25 : +c0108849 : pa2page(uintptr_t pa) { -c0108a25: 55 push %ebp -c0108a26: 89 e5 mov %esp,%ebp -c0108a28: 83 ec 18 sub $0x18,%esp +c0108849: 55 push %ebp +c010884a: 89 e5 mov %esp,%ebp +c010884c: 83 ec 18 sub $0x18,%esp if (PPN(pa) >= npage) { -c0108a2b: 8b 45 08 mov 0x8(%ebp),%eax -c0108a2e: c1 e8 0c shr $0xc,%eax -c0108a31: 89 c2 mov %eax,%edx -c0108a33: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0108a38: 39 c2 cmp %eax,%edx -c0108a3a: 72 1c jb c0108a58 +c010884f: 8b 45 08 mov 0x8(%ebp),%eax +c0108852: c1 e8 0c shr $0xc,%eax +c0108855: 89 c2 mov %eax,%edx +c0108857: a1 04 c0 12 c0 mov 0xc012c004,%eax +c010885c: 39 c2 cmp %eax,%edx +c010885e: 72 1c jb c010887c panic("pa2page called with invalid pa"); -c0108a3c: c7 44 24 08 c4 c1 10 movl $0xc010c1c4,0x8(%esp) -c0108a43: c0 -c0108a44: c7 44 24 04 5f 00 00 movl $0x5f,0x4(%esp) -c0108a4b: 00 -c0108a4c: c7 04 24 e3 c1 10 c0 movl $0xc010c1e3,(%esp) -c0108a53: e8 eb 79 ff ff call c0100443 <__panic> +c0108860: c7 44 24 08 a0 bf 10 movl $0xc010bfa0,0x8(%esp) +c0108867: c0 +c0108868: c7 44 24 04 5f 00 00 movl $0x5f,0x4(%esp) +c010886f: 00 +c0108870: c7 04 24 bf bf 10 c0 movl $0xc010bfbf,(%esp) +c0108877: e8 c9 83 ff ff call c0100c45 <__panic> return &pages[PPN(pa)]; -c0108a58: a1 b8 e0 12 c0 mov 0xc012e0b8,%eax -c0108a5d: 8b 55 08 mov 0x8(%ebp),%edx -c0108a60: c1 ea 0c shr $0xc,%edx -c0108a63: c1 e2 05 shl $0x5,%edx -c0108a66: 01 d0 add %edx,%eax -} -c0108a68: c9 leave -c0108a69: c3 ret +c010887c: 8b 15 00 c0 12 c0 mov 0xc012c000,%edx +c0108882: 8b 45 08 mov 0x8(%ebp),%eax +c0108885: c1 e8 0c shr $0xc,%eax +c0108888: c1 e0 05 shl $0x5,%eax +c010888b: 01 d0 add %edx,%eax +} +c010888d: 89 ec mov %ebp,%esp +c010888f: 5d pop %ebp +c0108890: c3 ret -c0108a6a : +c0108891 : page2kva(struct Page *page) { -c0108a6a: 55 push %ebp -c0108a6b: 89 e5 mov %esp,%ebp -c0108a6d: 83 ec 28 sub $0x28,%esp +c0108891: 55 push %ebp +c0108892: 89 e5 mov %esp,%ebp +c0108894: 83 ec 28 sub $0x28,%esp return KADDR(page2pa(page)); -c0108a70: 8b 45 08 mov 0x8(%ebp),%eax -c0108a73: 89 04 24 mov %eax,(%esp) -c0108a76: e8 94 ff ff ff call c0108a0f -c0108a7b: 89 45 f4 mov %eax,-0xc(%ebp) -c0108a7e: 8b 45 f4 mov -0xc(%ebp),%eax -c0108a81: c1 e8 0c shr $0xc,%eax -c0108a84: 89 45 f0 mov %eax,-0x10(%ebp) -c0108a87: a1 80 bf 12 c0 mov 0xc012bf80,%eax -c0108a8c: 39 45 f0 cmp %eax,-0x10(%ebp) -c0108a8f: 72 23 jb c0108ab4 -c0108a91: 8b 45 f4 mov -0xc(%ebp),%eax -c0108a94: 89 44 24 0c mov %eax,0xc(%esp) -c0108a98: c7 44 24 08 f4 c1 10 movl $0xc010c1f4,0x8(%esp) -c0108a9f: c0 -c0108aa0: c7 44 24 04 66 00 00 movl $0x66,0x4(%esp) -c0108aa7: 00 -c0108aa8: c7 04 24 e3 c1 10 c0 movl $0xc010c1e3,(%esp) -c0108aaf: e8 8f 79 ff ff call c0100443 <__panic> -c0108ab4: 8b 45 f4 mov -0xc(%ebp),%eax -c0108ab7: 2d 00 00 00 40 sub $0x40000000,%eax -} -c0108abc: c9 leave -c0108abd: c3 ret - -c0108abe : +c0108897: 8b 45 08 mov 0x8(%ebp),%eax +c010889a: 89 04 24 mov %eax,(%esp) +c010889d: e8 8f ff ff ff call c0108831 +c01088a2: 89 45 f4 mov %eax,-0xc(%ebp) +c01088a5: 8b 45 f4 mov -0xc(%ebp),%eax +c01088a8: c1 e8 0c shr $0xc,%eax +c01088ab: 89 45 f0 mov %eax,-0x10(%ebp) +c01088ae: a1 04 c0 12 c0 mov 0xc012c004,%eax +c01088b3: 39 45 f0 cmp %eax,-0x10(%ebp) +c01088b6: 72 23 jb c01088db +c01088b8: 8b 45 f4 mov -0xc(%ebp),%eax +c01088bb: 89 44 24 0c mov %eax,0xc(%esp) +c01088bf: c7 44 24 08 d0 bf 10 movl $0xc010bfd0,0x8(%esp) +c01088c6: c0 +c01088c7: c7 44 24 04 66 00 00 movl $0x66,0x4(%esp) +c01088ce: 00 +c01088cf: c7 04 24 bf bf 10 c0 movl $0xc010bfbf,(%esp) +c01088d6: e8 6a 83 ff ff call c0100c45 <__panic> +c01088db: 8b 45 f4 mov -0xc(%ebp),%eax +c01088de: 2d 00 00 00 40 sub $0x40000000,%eax +} +c01088e3: 89 ec mov %ebp,%esp +c01088e5: 5d pop %ebp +c01088e6: c3 ret + +c01088e7 : kva2page(void *kva) { -c0108abe: 55 push %ebp -c0108abf: 89 e5 mov %esp,%ebp -c0108ac1: 83 ec 28 sub $0x28,%esp +c01088e7: 55 push %ebp +c01088e8: 89 e5 mov %esp,%ebp +c01088ea: 83 ec 28 sub $0x28,%esp return pa2page(PADDR(kva)); -c0108ac4: 8b 45 08 mov 0x8(%ebp),%eax -c0108ac7: 89 45 f4 mov %eax,-0xc(%ebp) -c0108aca: 81 7d f4 ff ff ff bf cmpl $0xbfffffff,-0xc(%ebp) -c0108ad1: 77 23 ja c0108af6 -c0108ad3: 8b 45 f4 mov -0xc(%ebp),%eax -c0108ad6: 89 44 24 0c mov %eax,0xc(%esp) -c0108ada: c7 44 24 08 18 c2 10 movl $0xc010c218,0x8(%esp) -c0108ae1: c0 -c0108ae2: c7 44 24 04 6b 00 00 movl $0x6b,0x4(%esp) -c0108ae9: 00 -c0108aea: c7 04 24 e3 c1 10 c0 movl $0xc010c1e3,(%esp) -c0108af1: e8 4d 79 ff ff call c0100443 <__panic> -c0108af6: 8b 45 f4 mov -0xc(%ebp),%eax -c0108af9: 05 00 00 00 40 add $0x40000000,%eax -c0108afe: 89 04 24 mov %eax,(%esp) -c0108b01: e8 1f ff ff ff call c0108a25 -} -c0108b06: c9 leave -c0108b07: c3 ret - -c0108b08 : +c01088ed: 8b 45 08 mov 0x8(%ebp),%eax +c01088f0: 89 45 f4 mov %eax,-0xc(%ebp) +c01088f3: 81 7d f4 ff ff ff bf cmpl $0xbfffffff,-0xc(%ebp) +c01088fa: 77 23 ja c010891f +c01088fc: 8b 45 f4 mov -0xc(%ebp),%eax +c01088ff: 89 44 24 0c mov %eax,0xc(%esp) +c0108903: c7 44 24 08 f4 bf 10 movl $0xc010bff4,0x8(%esp) +c010890a: c0 +c010890b: c7 44 24 04 6b 00 00 movl $0x6b,0x4(%esp) +c0108912: 00 +c0108913: c7 04 24 bf bf 10 c0 movl $0xc010bfbf,(%esp) +c010891a: e8 26 83 ff ff call c0100c45 <__panic> +c010891f: 8b 45 f4 mov -0xc(%ebp),%eax +c0108922: 05 00 00 00 40 add $0x40000000,%eax +c0108927: 89 04 24 mov %eax,(%esp) +c010892a: e8 1a ff ff ff call c0108849 +} +c010892f: 89 ec mov %ebp,%esp +c0108931: 5d pop %ebp +c0108932: c3 ret + +c0108933 : void forkrets(struct trapframe *tf); void switch_to(struct context *from, struct context *to); // alloc_proc - alloc a proc_struct and init all fields of proc_struct static struct proc_struct * alloc_proc(void) { -c0108b08: f3 0f 1e fb endbr32 -c0108b0c: 55 push %ebp -c0108b0d: 89 e5 mov %esp,%ebp -c0108b0f: 83 ec 28 sub $0x28,%esp +c0108933: 55 push %ebp +c0108934: 89 e5 mov %esp,%ebp +c0108936: 83 ec 28 sub $0x28,%esp struct proc_struct *proc = kmalloc(sizeof(struct proc_struct)); -c0108b12: c7 04 24 68 00 00 00 movl $0x68,(%esp) -c0108b19: e8 18 dd ff ff call c0106836 -c0108b1e: 89 45 f4 mov %eax,-0xc(%ebp) +c0108939: c7 04 24 68 00 00 00 movl $0x68,(%esp) +c0108940: e8 05 c2 ff ff call c0104b4a +c0108945: 89 45 f4 mov %eax,-0xc(%ebp) if (proc != NULL) { -c0108b21: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0108b25: 0f 84 a1 00 00 00 je c0108bcc +c0108948: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c010894c: 0f 84 a1 00 00 00 je c01089f3 * struct trapframe *tf; // Trap frame for current interrupt * uintptr_t cr3; // CR3 register: the base addr of Page Directroy Table(PDT) * uint32_t flags; // Process flag * char name[PROC_NAME_LEN + 1]; // Process name */ proc->state = PROC_UNINIT; // 初始状态为未初始化 -c0108b2b: 8b 45 f4 mov -0xc(%ebp),%eax -c0108b2e: c7 00 00 00 00 00 movl $0x0,(%eax) +c0108952: 8b 45 f4 mov -0xc(%ebp),%eax +c0108955: c7 00 00 00 00 00 movl $0x0,(%eax) proc->pid = -1; // 初始进程ID为-1 -c0108b34: 8b 45 f4 mov -0xc(%ebp),%eax -c0108b37: c7 40 04 ff ff ff ff movl $0xffffffff,0x4(%eax) +c010895b: 8b 45 f4 mov -0xc(%ebp),%eax +c010895e: c7 40 04 ff ff ff ff movl $0xffffffff,0x4(%eax) proc->runs = 0; // 初始运行次数为0 -c0108b3e: 8b 45 f4 mov -0xc(%ebp),%eax -c0108b41: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) +c0108965: 8b 45 f4 mov -0xc(%ebp),%eax +c0108968: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) proc->kstack = 0; // 初始内核栈指针为0 -c0108b48: 8b 45 f4 mov -0xc(%ebp),%eax -c0108b4b: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) +c010896f: 8b 45 f4 mov -0xc(%ebp),%eax +c0108972: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) proc->need_resched = 0; // 初始不需要重新调度 -c0108b52: 8b 45 f4 mov -0xc(%ebp),%eax -c0108b55: c7 40 10 00 00 00 00 movl $0x0,0x10(%eax) +c0108979: 8b 45 f4 mov -0xc(%ebp),%eax +c010897c: c7 40 10 00 00 00 00 movl $0x0,0x10(%eax) proc->parent = NULL; // 初始父进程指针为NULL -c0108b5c: 8b 45 f4 mov -0xc(%ebp),%eax -c0108b5f: c7 40 14 00 00 00 00 movl $0x0,0x14(%eax) +c0108983: 8b 45 f4 mov -0xc(%ebp),%eax +c0108986: c7 40 14 00 00 00 00 movl $0x0,0x14(%eax) proc->mm = NULL; // 初始内存管理结构指针为NULL -c0108b66: 8b 45 f4 mov -0xc(%ebp),%eax -c0108b69: c7 40 18 00 00 00 00 movl $0x0,0x18(%eax) +c010898d: 8b 45 f4 mov -0xc(%ebp),%eax +c0108990: c7 40 18 00 00 00 00 movl $0x0,0x18(%eax) memset(&proc->context, 0, sizeof(struct context)); // 初始化上下文切换信息 -c0108b70: 8b 45 f4 mov -0xc(%ebp),%eax -c0108b73: 83 c0 1c add $0x1c,%eax -c0108b76: c7 44 24 08 20 00 00 movl $0x20,0x8(%esp) -c0108b7d: 00 -c0108b7e: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0108b85: 00 -c0108b86: 89 04 24 mov %eax,(%esp) -c0108b89: e8 c6 0d 00 00 call c0109954 +c0108997: 8b 45 f4 mov -0xc(%ebp),%eax +c010899a: 83 c0 1c add $0x1c,%eax +c010899d: c7 44 24 08 20 00 00 movl $0x20,0x8(%esp) +c01089a4: 00 +c01089a5: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c01089ac: 00 +c01089ad: 89 04 24 mov %eax,(%esp) +c01089b0: e8 2f 15 00 00 call c0109ee4 proc->tf = NULL; // 初始中断陷阱帧指针为NULL -c0108b8e: 8b 45 f4 mov -0xc(%ebp),%eax -c0108b91: c7 40 3c 00 00 00 00 movl $0x0,0x3c(%eax) +c01089b5: 8b 45 f4 mov -0xc(%ebp),%eax +c01089b8: c7 40 3c 00 00 00 00 movl $0x0,0x3c(%eax) proc->cr3 = boot_cr3; // 初始CR3寄存器值为0 -c0108b98: 8b 15 b4 e0 12 c0 mov 0xc012e0b4,%edx -c0108b9e: 8b 45 f4 mov -0xc(%ebp),%eax -c0108ba1: 89 50 40 mov %edx,0x40(%eax) +c01089bf: 8b 15 08 c0 12 c0 mov 0xc012c008,%edx +c01089c5: 8b 45 f4 mov -0xc(%ebp),%eax +c01089c8: 89 50 40 mov %edx,0x40(%eax) proc->flags = 0; // 初始进程标志为0 -c0108ba4: 8b 45 f4 mov -0xc(%ebp),%eax -c0108ba7: c7 40 44 00 00 00 00 movl $0x0,0x44(%eax) +c01089cb: 8b 45 f4 mov -0xc(%ebp),%eax +c01089ce: c7 40 44 00 00 00 00 movl $0x0,0x44(%eax) memset(proc->name, 0, PROC_NAME_LEN); // 初始进程名称为空字符串 -c0108bae: 8b 45 f4 mov -0xc(%ebp),%eax -c0108bb1: 83 c0 48 add $0x48,%eax -c0108bb4: c7 44 24 08 0f 00 00 movl $0xf,0x8(%esp) -c0108bbb: 00 -c0108bbc: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0108bc3: 00 -c0108bc4: 89 04 24 mov %eax,(%esp) -c0108bc7: e8 88 0d 00 00 call c0109954 +c01089d5: 8b 45 f4 mov -0xc(%ebp),%eax +c01089d8: 83 c0 48 add $0x48,%eax +c01089db: c7 44 24 08 0f 00 00 movl $0xf,0x8(%esp) +c01089e2: 00 +c01089e3: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c01089ea: 00 +c01089eb: 89 04 24 mov %eax,(%esp) +c01089ee: e8 f1 14 00 00 call c0109ee4 } return proc; -c0108bcc: 8b 45 f4 mov -0xc(%ebp),%eax +c01089f3: 8b 45 f4 mov -0xc(%ebp),%eax } -c0108bcf: c9 leave -c0108bd0: c3 ret - -c0108bd1 : +c01089f6: 89 ec mov %ebp,%esp +c01089f8: 5d pop %ebp +c01089f9: c3 ret -// set_proc_name - set the name of proc +c01089fa : + * @return 返回指向进程名称的指针,这是在内存中直接修改后的结果 + * + * 注意:此函数直接操作传入的进程结构体,对名称字段进行先清空后赋值的操作 + */ char * set_proc_name(struct proc_struct *proc, const char *name) { -c0108bd1: f3 0f 1e fb endbr32 -c0108bd5: 55 push %ebp -c0108bd6: 89 e5 mov %esp,%ebp -c0108bd8: 83 ec 18 sub $0x18,%esp +c01089fa: 55 push %ebp +c01089fb: 89 e5 mov %esp,%ebp +c01089fd: 83 ec 18 sub $0x18,%esp + + // 清空进程名称字段中的现有内容,以准备存储新的名称 memset(proc->name, 0, sizeof(proc->name)); -c0108bdb: 8b 45 08 mov 0x8(%ebp),%eax -c0108bde: 83 c0 48 add $0x48,%eax -c0108be1: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) -c0108be8: 00 -c0108be9: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0108bf0: 00 -c0108bf1: 89 04 24 mov %eax,(%esp) -c0108bf4: e8 5b 0d 00 00 call c0109954 +c0108a00: 8b 45 08 mov 0x8(%ebp),%eax +c0108a03: 83 c0 48 add $0x48,%eax +c0108a06: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) +c0108a0d: 00 +c0108a0e: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0108a15: 00 +c0108a16: 89 04 24 mov %eax,(%esp) +c0108a19: e8 c6 14 00 00 call c0109ee4 + // 将新的名称复制到进程名称字段中 return memcpy(proc->name, name, PROC_NAME_LEN); -c0108bf9: 8b 45 08 mov 0x8(%ebp),%eax -c0108bfc: 8d 50 48 lea 0x48(%eax),%edx -c0108bff: c7 44 24 08 0f 00 00 movl $0xf,0x8(%esp) -c0108c06: 00 -c0108c07: 8b 45 0c mov 0xc(%ebp),%eax -c0108c0a: 89 44 24 04 mov %eax,0x4(%esp) -c0108c0e: 89 14 24 mov %edx,(%esp) -c0108c11: e8 28 0e 00 00 call c0109a3e +c0108a1e: 8b 45 08 mov 0x8(%ebp),%eax +c0108a21: 8d 50 48 lea 0x48(%eax),%edx +c0108a24: c7 44 24 08 0f 00 00 movl $0xf,0x8(%esp) +c0108a2b: 00 +c0108a2c: 8b 45 0c mov 0xc(%ebp),%eax +c0108a2f: 89 44 24 04 mov %eax,0x4(%esp) +c0108a33: 89 14 24 mov %edx,(%esp) +c0108a36: e8 8e 15 00 00 call c0109fc9 } -c0108c16: c9 leave -c0108c17: c3 ret +c0108a3b: 89 ec mov %ebp,%esp +c0108a3d: 5d pop %ebp +c0108a3e: c3 ret -c0108c18 : +c0108a3f : // get_proc_name - get the name of proc char * get_proc_name(struct proc_struct *proc) { -c0108c18: f3 0f 1e fb endbr32 -c0108c1c: 55 push %ebp -c0108c1d: 89 e5 mov %esp,%ebp -c0108c1f: 83 ec 18 sub $0x18,%esp +c0108a3f: 55 push %ebp +c0108a40: 89 e5 mov %esp,%ebp +c0108a42: 83 ec 18 sub $0x18,%esp static char name[PROC_NAME_LEN + 1]; memset(name, 0, sizeof(name)); -c0108c22: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) -c0108c29: 00 -c0108c2a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0108c31: 00 -c0108c32: c7 04 24 44 e0 12 c0 movl $0xc012e044,(%esp) -c0108c39: e8 16 0d 00 00 call c0109954 +c0108a45: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) +c0108a4c: 00 +c0108a4d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0108a54: 00 +c0108a55: c7 04 24 a4 e1 12 c0 movl $0xc012e1a4,(%esp) +c0108a5c: e8 83 14 00 00 call c0109ee4 return memcpy(name, proc->name, PROC_NAME_LEN); -c0108c3e: 8b 45 08 mov 0x8(%ebp),%eax -c0108c41: 83 c0 48 add $0x48,%eax -c0108c44: c7 44 24 08 0f 00 00 movl $0xf,0x8(%esp) -c0108c4b: 00 -c0108c4c: 89 44 24 04 mov %eax,0x4(%esp) -c0108c50: c7 04 24 44 e0 12 c0 movl $0xc012e044,(%esp) -c0108c57: e8 e2 0d 00 00 call c0109a3e -} -c0108c5c: c9 leave -c0108c5d: c3 ret - -c0108c5e : +c0108a61: 8b 45 08 mov 0x8(%ebp),%eax +c0108a64: 83 c0 48 add $0x48,%eax +c0108a67: c7 44 24 08 0f 00 00 movl $0xf,0x8(%esp) +c0108a6e: 00 +c0108a6f: 89 44 24 04 mov %eax,0x4(%esp) +c0108a73: c7 04 24 a4 e1 12 c0 movl $0xc012e1a4,(%esp) +c0108a7a: e8 4a 15 00 00 call c0109fc9 +} +c0108a7f: 89 ec mov %ebp,%esp +c0108a81: 5d pop %ebp +c0108a82: c3 ret + +c0108a83 : * 它使用静态变量来跟踪最后一个分配的PID和下一个安全PID,以提高效率并避免PID冲突。 * * @return 返回一个未被使用的进程ID。 */ static int get_pid(void) { -c0108c5e: f3 0f 1e fb endbr32 -c0108c62: 55 push %ebp -c0108c63: 89 e5 mov %esp,%ebp -c0108c65: 83 ec 10 sub $0x10,%esp +c0108a83: 55 push %ebp +c0108a84: 89 e5 mov %esp,%ebp +c0108a86: 83 ec 10 sub $0x10,%esp static_assert(MAX_PID > MAX_PROCESS); // 定义一个指向进程结构的指针,用于遍历进程列表。 struct proc_struct *proc; // 初始化列表指针,从进程列表的头部开始。 list_entry_t *list = &proc_list, *le; -c0108c68: c7 45 f8 b0 e1 12 c0 movl $0xc012e1b0,-0x8(%ebp) +c0108a89: c7 45 f8 80 c1 12 c0 movl $0xc012c180,-0x8(%ebp) // 定义静态变量,next_safe用于记录下一个安全的PID值,last_pid用于记录上一个分配的PID。 static int next_safe = MAX_PID, last_pid = MAX_PID; // 尝试递增last_pid以查找下一个可用的PID,如果超过最大值则重置为1。 if (++ last_pid >= MAX_PID) { -c0108c6f: a1 6c 8a 12 c0 mov 0xc0128a6c,%eax -c0108c74: 40 inc %eax -c0108c75: a3 6c 8a 12 c0 mov %eax,0xc0128a6c -c0108c7a: a1 6c 8a 12 c0 mov 0xc0128a6c,%eax -c0108c7f: 3d ff 1f 00 00 cmp $0x1fff,%eax -c0108c84: 7e 0c jle c0108c92 +c0108a90: a1 80 8a 12 c0 mov 0xc0128a80,%eax +c0108a95: 40 inc %eax +c0108a96: a3 80 8a 12 c0 mov %eax,0xc0128a80 +c0108a9b: a1 80 8a 12 c0 mov 0xc0128a80,%eax +c0108aa0: 3d ff 1f 00 00 cmp $0x1fff,%eax +c0108aa5: 7e 0c jle c0108ab3 last_pid = 1; -c0108c86: c7 05 6c 8a 12 c0 01 movl $0x1,0xc0128a6c -c0108c8d: 00 00 00 +c0108aa7: c7 05 80 8a 12 c0 01 movl $0x1,0xc0128a80 +c0108aae: 00 00 00 goto inside; -c0108c90: eb 14 jmp c0108ca6 +c0108ab1: eb 14 jmp c0108ac7 } // 如果当前的last_pid大于等于next_safe,表示需要重新计算下一个安全的PID。 if (last_pid >= next_safe) { -c0108c92: 8b 15 6c 8a 12 c0 mov 0xc0128a6c,%edx -c0108c98: a1 70 8a 12 c0 mov 0xc0128a70,%eax -c0108c9d: 39 c2 cmp %eax,%edx -c0108c9f: 0f 8c ab 00 00 00 jl c0108d50 +c0108ab3: 8b 15 80 8a 12 c0 mov 0xc0128a80,%edx +c0108ab9: a1 84 8a 12 c0 mov 0xc0128a84,%eax +c0108abe: 39 c2 cmp %eax,%edx +c0108ac0: 0f 8c ab 00 00 00 jl c0108b71 inside: -c0108ca5: 90 nop +c0108ac6: 90 nop next_safe = MAX_PID; -c0108ca6: c7 05 70 8a 12 c0 00 movl $0x2000,0xc0128a70 -c0108cad: 20 00 00 +c0108ac7: c7 05 84 8a 12 c0 00 movl $0x2000,0xc0128a84 +c0108ace: 20 00 00 repeat: // 从进程列表的头部开始遍历。 le = list; -c0108cb0: 8b 45 f8 mov -0x8(%ebp),%eax -c0108cb3: 89 45 fc mov %eax,-0x4(%ebp) +c0108ad1: 8b 45 f8 mov -0x8(%ebp),%eax +c0108ad4: 89 45 fc mov %eax,-0x4(%ebp) while ((le = list_next(le)) != list) { -c0108cb6: eb 7d jmp c0108d35 +c0108ad7: eb 7d jmp c0108b56 // 将列表项转换为进程结构。 proc = le2proc(le, list_link); -c0108cb8: 8b 45 fc mov -0x4(%ebp),%eax -c0108cbb: 83 e8 58 sub $0x58,%eax -c0108cbe: 89 45 f4 mov %eax,-0xc(%ebp) +c0108ad9: 8b 45 fc mov -0x4(%ebp),%eax +c0108adc: 83 e8 58 sub $0x58,%eax +c0108adf: 89 45 f4 mov %eax,-0xc(%ebp) // 如果找到相同PID的进程,表示当前last_pid已被使用,需要继续寻找下一个可用的PID。 if (proc->pid == last_pid) { -c0108cc1: 8b 45 f4 mov -0xc(%ebp),%eax -c0108cc4: 8b 50 04 mov 0x4(%eax),%edx -c0108cc7: a1 6c 8a 12 c0 mov 0xc0128a6c,%eax -c0108ccc: 39 c2 cmp %eax,%edx -c0108cce: 75 3c jne c0108d0c +c0108ae2: 8b 45 f4 mov -0xc(%ebp),%eax +c0108ae5: 8b 50 04 mov 0x4(%eax),%edx +c0108ae8: a1 80 8a 12 c0 mov 0xc0128a80,%eax +c0108aed: 39 c2 cmp %eax,%edx +c0108aef: 75 3c jne c0108b2d if (++ last_pid >= next_safe) { -c0108cd0: a1 6c 8a 12 c0 mov 0xc0128a6c,%eax -c0108cd5: 40 inc %eax -c0108cd6: a3 6c 8a 12 c0 mov %eax,0xc0128a6c -c0108cdb: 8b 15 6c 8a 12 c0 mov 0xc0128a6c,%edx -c0108ce1: a1 70 8a 12 c0 mov 0xc0128a70,%eax -c0108ce6: 39 c2 cmp %eax,%edx -c0108ce8: 7c 4b jl c0108d35 +c0108af1: a1 80 8a 12 c0 mov 0xc0128a80,%eax +c0108af6: 40 inc %eax +c0108af7: a3 80 8a 12 c0 mov %eax,0xc0128a80 +c0108afc: 8b 15 80 8a 12 c0 mov 0xc0128a80,%edx +c0108b02: a1 84 8a 12 c0 mov 0xc0128a84,%eax +c0108b07: 39 c2 cmp %eax,%edx +c0108b09: 7c 4b jl c0108b56 if (last_pid >= MAX_PID) { -c0108cea: a1 6c 8a 12 c0 mov 0xc0128a6c,%eax -c0108cef: 3d ff 1f 00 00 cmp $0x1fff,%eax -c0108cf4: 7e 0a jle c0108d00 +c0108b0b: a1 80 8a 12 c0 mov 0xc0128a80,%eax +c0108b10: 3d ff 1f 00 00 cmp $0x1fff,%eax +c0108b15: 7e 0a jle c0108b21 last_pid = 1; -c0108cf6: c7 05 6c 8a 12 c0 01 movl $0x1,0xc0128a6c -c0108cfd: 00 00 00 +c0108b17: c7 05 80 8a 12 c0 01 movl $0x1,0xc0128a80 +c0108b1e: 00 00 00 } next_safe = MAX_PID; -c0108d00: c7 05 70 8a 12 c0 00 movl $0x2000,0xc0128a70 -c0108d07: 20 00 00 +c0108b21: c7 05 84 8a 12 c0 00 movl $0x2000,0xc0128a84 +c0108b28: 20 00 00 goto repeat; -c0108d0a: eb a4 jmp c0108cb0 +c0108b2b: eb a4 jmp c0108ad1 } } // 如果找到一个更大的PID,更新next_safe为当前进程的PID,以确保找到的PID是安全的。 else if (proc->pid > last_pid && next_safe > proc->pid) { -c0108d0c: 8b 45 f4 mov -0xc(%ebp),%eax -c0108d0f: 8b 50 04 mov 0x4(%eax),%edx -c0108d12: a1 6c 8a 12 c0 mov 0xc0128a6c,%eax -c0108d17: 39 c2 cmp %eax,%edx -c0108d19: 7e 1a jle c0108d35 -c0108d1b: 8b 45 f4 mov -0xc(%ebp),%eax -c0108d1e: 8b 50 04 mov 0x4(%eax),%edx -c0108d21: a1 70 8a 12 c0 mov 0xc0128a70,%eax -c0108d26: 39 c2 cmp %eax,%edx -c0108d28: 7d 0b jge c0108d35 +c0108b2d: 8b 45 f4 mov -0xc(%ebp),%eax +c0108b30: 8b 50 04 mov 0x4(%eax),%edx +c0108b33: a1 80 8a 12 c0 mov 0xc0128a80,%eax +c0108b38: 39 c2 cmp %eax,%edx +c0108b3a: 7e 1a jle c0108b56 +c0108b3c: 8b 45 f4 mov -0xc(%ebp),%eax +c0108b3f: 8b 50 04 mov 0x4(%eax),%edx +c0108b42: a1 84 8a 12 c0 mov 0xc0128a84,%eax +c0108b47: 39 c2 cmp %eax,%edx +c0108b49: 7d 0b jge c0108b56 next_safe = proc->pid; -c0108d2a: 8b 45 f4 mov -0xc(%ebp),%eax -c0108d2d: 8b 40 04 mov 0x4(%eax),%eax -c0108d30: a3 70 8a 12 c0 mov %eax,0xc0128a70 -c0108d35: 8b 45 fc mov -0x4(%ebp),%eax -c0108d38: 89 45 f0 mov %eax,-0x10(%ebp) -c0108d3b: 8b 45 f0 mov -0x10(%ebp),%eax -c0108d3e: 8b 40 04 mov 0x4(%eax),%eax +c0108b4b: 8b 45 f4 mov -0xc(%ebp),%eax +c0108b4e: 8b 40 04 mov 0x4(%eax),%eax +c0108b51: a3 84 8a 12 c0 mov %eax,0xc0128a84 +c0108b56: 8b 45 fc mov -0x4(%ebp),%eax +c0108b59: 89 45 f0 mov %eax,-0x10(%ebp) +c0108b5c: 8b 45 f0 mov -0x10(%ebp),%eax +c0108b5f: 8b 40 04 mov 0x4(%eax),%eax while ((le = list_next(le)) != list) { -c0108d41: 89 45 fc mov %eax,-0x4(%ebp) -c0108d44: 8b 45 fc mov -0x4(%ebp),%eax -c0108d47: 3b 45 f8 cmp -0x8(%ebp),%eax -c0108d4a: 0f 85 68 ff ff ff jne c0108cb8 +c0108b62: 89 45 fc mov %eax,-0x4(%ebp) +c0108b65: 8b 45 fc mov -0x4(%ebp),%eax +c0108b68: 3b 45 f8 cmp -0x8(%ebp),%eax +c0108b6b: 0f 85 68 ff ff ff jne c0108ad9 } } } // 返回找到的可用PID。 return last_pid; -c0108d50: a1 6c 8a 12 c0 mov 0xc0128a6c,%eax +c0108b71: a1 80 8a 12 c0 mov 0xc0128a80,%eax } -c0108d55: c9 leave -c0108d56: c3 ret +c0108b76: 89 ec mov %ebp,%esp +c0108b78: 5d pop %ebp +c0108b79: c3 ret -c0108d57 : +c0108b7a : // proc_run - make process "proc" running on cpu // NOTE: before call switch_to, should load base addr of "proc"'s new PDT void proc_run(struct proc_struct *proc) { -c0108d57: f3 0f 1e fb endbr32 -c0108d5b: 55 push %ebp -c0108d5c: 89 e5 mov %esp,%ebp -c0108d5e: 83 ec 28 sub $0x28,%esp +c0108b7a: 55 push %ebp +c0108b7b: 89 e5 mov %esp,%ebp +c0108b7d: 83 ec 28 sub $0x28,%esp if (proc != current) { -c0108d61: a1 28 c0 12 c0 mov 0xc012c028,%eax -c0108d66: 39 45 08 cmp %eax,0x8(%ebp) -c0108d69: 74 64 je c0108dcf +c0108b80: a1 90 c1 12 c0 mov 0xc012c190,%eax +c0108b85: 39 45 08 cmp %eax,0x8(%ebp) +c0108b88: 74 64 je c0108bee bool intr_flag; struct proc_struct *prev = current, *next = proc; -c0108d6b: a1 28 c0 12 c0 mov 0xc012c028,%eax -c0108d70: 89 45 f4 mov %eax,-0xc(%ebp) -c0108d73: 8b 45 08 mov 0x8(%ebp),%eax -c0108d76: 89 45 f0 mov %eax,-0x10(%ebp) +c0108b8a: a1 90 c1 12 c0 mov 0xc012c190,%eax +c0108b8f: 89 45 f4 mov %eax,-0xc(%ebp) +c0108b92: 8b 45 08 mov 0x8(%ebp),%eax +c0108b95: 89 45 f0 mov %eax,-0x10(%ebp) local_intr_save(intr_flag); -c0108d79: e8 3f fc ff ff call c01089bd <__intr_save> -c0108d7e: 89 45 ec mov %eax,-0x14(%ebp) +c0108b98: e8 3f fc ff ff call c01087dc <__intr_save> +c0108b9d: 89 45 ec mov %eax,-0x14(%ebp) { current = proc; -c0108d81: 8b 45 08 mov 0x8(%ebp),%eax -c0108d84: a3 28 c0 12 c0 mov %eax,0xc012c028 +c0108ba0: 8b 45 08 mov 0x8(%ebp),%eax +c0108ba3: a3 90 c1 12 c0 mov %eax,0xc012c190 load_esp0(next->kstack + KSTACKSIZE); -c0108d89: 8b 45 f0 mov -0x10(%ebp),%eax -c0108d8c: 8b 40 0c mov 0xc(%eax),%eax -c0108d8f: 05 00 20 00 00 add $0x2000,%eax -c0108d94: 89 04 24 mov %eax,(%esp) -c0108d97: e8 61 a8 ff ff call c01035fd +c0108ba8: 8b 45 f0 mov -0x10(%ebp),%eax +c0108bab: 8b 40 0c mov 0xc(%eax),%eax +c0108bae: 05 00 20 00 00 add $0x2000,%eax +c0108bb3: 89 04 24 mov %eax,(%esp) +c0108bb6: e8 ce c2 ff ff call c0104e89 lcr3(next->cr3); -c0108d9c: 8b 45 f0 mov -0x10(%ebp),%eax -c0108d9f: 8b 40 40 mov 0x40(%eax),%eax -c0108da2: 89 45 e8 mov %eax,-0x18(%ebp) +c0108bbb: 8b 45 f0 mov -0x10(%ebp),%eax +c0108bbe: 8b 40 40 mov 0x40(%eax),%eax +c0108bc1: 89 45 e8 mov %eax,-0x18(%ebp) asm volatile ("mov %0, %%cr3" :: "r" (cr3) : "memory"); -c0108da5: 8b 45 e8 mov -0x18(%ebp),%eax -c0108da8: 0f 22 d8 mov %eax,%cr3 +c0108bc4: 8b 45 e8 mov -0x18(%ebp),%eax +c0108bc7: 0f 22 d8 mov %eax,%cr3 } -c0108dab: 90 nop +c0108bca: 90 nop switch_to(&(prev->context), &(next->context)); -c0108dac: 8b 45 f0 mov -0x10(%ebp),%eax -c0108daf: 8d 50 1c lea 0x1c(%eax),%edx -c0108db2: 8b 45 f4 mov -0xc(%ebp),%eax -c0108db5: 83 c0 1c add $0x1c,%eax -c0108db8: 89 54 24 04 mov %edx,0x4(%esp) -c0108dbc: 89 04 24 mov %eax,(%esp) -c0108dbf: e8 b9 fb ff ff call c010897d +c0108bcb: 8b 45 f0 mov -0x10(%ebp),%eax +c0108bce: 8d 50 1c lea 0x1c(%eax),%edx +c0108bd1: 8b 45 f4 mov -0xc(%ebp),%eax +c0108bd4: 83 c0 1c add $0x1c,%eax +c0108bd7: 89 54 24 04 mov %edx,0x4(%esp) +c0108bdb: 89 04 24 mov %eax,(%esp) +c0108bde: e8 d5 06 00 00 call c01092b8 } local_intr_restore(intr_flag); -c0108dc4: 8b 45 ec mov -0x14(%ebp),%eax -c0108dc7: 89 04 24 mov %eax,(%esp) -c0108dca: e8 18 fc ff ff call c01089e7 <__intr_restore> +c0108be3: 8b 45 ec mov -0x14(%ebp),%eax +c0108be6: 89 04 24 mov %eax,(%esp) +c0108be9: e8 1a fc ff ff call c0108808 <__intr_restore> } } -c0108dcf: 90 nop -c0108dd0: c9 leave -c0108dd1: c3 ret +c0108bee: 90 nop +c0108bef: 89 ec mov %ebp,%esp +c0108bf1: 5d pop %ebp +c0108bf2: c3 ret -c0108dd2 : +c0108bf3 : // forkret -- the first kernel entry point of a new thread/process // NOTE: the addr of forkret is setted in copy_thread function // after switch_to, the current proc will execute here. static void forkret(void) { -c0108dd2: f3 0f 1e fb endbr32 -c0108dd6: 55 push %ebp -c0108dd7: 89 e5 mov %esp,%ebp -c0108dd9: 83 ec 18 sub $0x18,%esp +c0108bf3: 55 push %ebp +c0108bf4: 89 e5 mov %esp,%ebp +c0108bf6: 83 ec 18 sub $0x18,%esp forkrets(current->tf); -c0108ddc: a1 28 c0 12 c0 mov 0xc012c028,%eax -c0108de1: 8b 40 3c mov 0x3c(%eax),%eax -c0108de4: 89 04 24 mov %eax,(%esp) -c0108de7: e8 38 a6 ff ff call c0103424 +c0108bf9: a1 90 c1 12 c0 mov 0xc012c190,%eax +c0108bfe: 8b 40 3c mov 0x3c(%eax),%eax +c0108c01: 89 04 24 mov %eax,(%esp) +c0108c04: e8 b7 9c ff ff call c01028c0 } -c0108dec: 90 nop -c0108ded: c9 leave -c0108dee: c3 ret +c0108c09: 90 nop +c0108c0a: 89 ec mov %ebp,%esp +c0108c0c: 5d pop %ebp +c0108c0d: c3 ret -c0108def : +c0108c0e : * 这有助于在需要时快速查找进程 * * @param proc 指向进程结构体的指针,表示要添加到哈希表的进程 */ static void hash_proc(struct proc_struct *proc) { -c0108def: f3 0f 1e fb endbr32 -c0108df3: 55 push %ebp -c0108df4: 89 e5 mov %esp,%ebp -c0108df6: 53 push %ebx -c0108df7: 83 ec 34 sub $0x34,%esp +c0108c0e: 55 push %ebp +c0108c0f: 89 e5 mov %esp,%ebp +c0108c11: 83 ec 38 sub $0x38,%esp +c0108c14: 89 5d fc mov %ebx,-0x4(%ebp) // 根据进程的PID计算哈希值,并将进程添加到相应哈希链表的末尾 list_add(hash_list + pid_hashfn(proc->pid), &(proc->hash_link)); -c0108dfa: 8b 45 08 mov 0x8(%ebp),%eax -c0108dfd: 8d 58 60 lea 0x60(%eax),%ebx -c0108e00: 8b 45 08 mov 0x8(%ebp),%eax -c0108e03: 8b 40 04 mov 0x4(%eax),%eax -c0108e06: c7 44 24 04 0a 00 00 movl $0xa,0x4(%esp) -c0108e0d: 00 -c0108e0e: 89 04 24 mov %eax,(%esp) -c0108e11: e8 62 13 00 00 call c010a178 -c0108e16: c1 e0 03 shl $0x3,%eax -c0108e19: 05 40 c0 12 c0 add $0xc012c040,%eax -c0108e1e: 89 45 f4 mov %eax,-0xc(%ebp) -c0108e21: 89 5d f0 mov %ebx,-0x10(%ebp) -c0108e24: 8b 45 f4 mov -0xc(%ebp),%eax -c0108e27: 89 45 ec mov %eax,-0x14(%ebp) -c0108e2a: 8b 45 f0 mov -0x10(%ebp),%eax -c0108e2d: 89 45 e8 mov %eax,-0x18(%ebp) +c0108c17: 8b 45 08 mov 0x8(%ebp),%eax +c0108c1a: 8d 58 60 lea 0x60(%eax),%ebx +c0108c1d: 8b 45 08 mov 0x8(%ebp),%eax +c0108c20: 8b 40 04 mov 0x4(%eax),%eax +c0108c23: c7 44 24 04 0a 00 00 movl $0xa,0x4(%esp) +c0108c2a: 00 +c0108c2b: 89 04 24 mov %eax,(%esp) +c0108c2e: e8 14 08 00 00 call c0109447 +c0108c33: c1 e0 03 shl $0x3,%eax +c0108c36: 05 a0 c1 12 c0 add $0xc012c1a0,%eax +c0108c3b: 89 45 f4 mov %eax,-0xc(%ebp) +c0108c3e: 89 5d f0 mov %ebx,-0x10(%ebp) +c0108c41: 8b 45 f4 mov -0xc(%ebp),%eax +c0108c44: 89 45 ec mov %eax,-0x14(%ebp) +c0108c47: 8b 45 f0 mov -0x10(%ebp),%eax +c0108c4a: 89 45 e8 mov %eax,-0x18(%ebp) __list_add(elm, listelm, listelm->next); -c0108e30: 8b 45 ec mov -0x14(%ebp),%eax -c0108e33: 8b 40 04 mov 0x4(%eax),%eax -c0108e36: 8b 55 e8 mov -0x18(%ebp),%edx -c0108e39: 89 55 e4 mov %edx,-0x1c(%ebp) -c0108e3c: 8b 55 ec mov -0x14(%ebp),%edx -c0108e3f: 89 55 e0 mov %edx,-0x20(%ebp) -c0108e42: 89 45 dc mov %eax,-0x24(%ebp) +c0108c4d: 8b 45 ec mov -0x14(%ebp),%eax +c0108c50: 8b 40 04 mov 0x4(%eax),%eax +c0108c53: 8b 55 e8 mov -0x18(%ebp),%edx +c0108c56: 89 55 e4 mov %edx,-0x1c(%ebp) +c0108c59: 8b 55 ec mov -0x14(%ebp),%edx +c0108c5c: 89 55 e0 mov %edx,-0x20(%ebp) +c0108c5f: 89 45 dc mov %eax,-0x24(%ebp) prev->next = next->prev = elm; -c0108e45: 8b 45 dc mov -0x24(%ebp),%eax -c0108e48: 8b 55 e4 mov -0x1c(%ebp),%edx -c0108e4b: 89 10 mov %edx,(%eax) -c0108e4d: 8b 45 dc mov -0x24(%ebp),%eax -c0108e50: 8b 10 mov (%eax),%edx -c0108e52: 8b 45 e0 mov -0x20(%ebp),%eax -c0108e55: 89 50 04 mov %edx,0x4(%eax) +c0108c62: 8b 45 dc mov -0x24(%ebp),%eax +c0108c65: 8b 55 e4 mov -0x1c(%ebp),%edx +c0108c68: 89 10 mov %edx,(%eax) +c0108c6a: 8b 45 dc mov -0x24(%ebp),%eax +c0108c6d: 8b 10 mov (%eax),%edx +c0108c6f: 8b 45 e0 mov -0x20(%ebp),%eax +c0108c72: 89 50 04 mov %edx,0x4(%eax) elm->next = next; -c0108e58: 8b 45 e4 mov -0x1c(%ebp),%eax -c0108e5b: 8b 55 dc mov -0x24(%ebp),%edx -c0108e5e: 89 50 04 mov %edx,0x4(%eax) +c0108c75: 8b 45 e4 mov -0x1c(%ebp),%eax +c0108c78: 8b 55 dc mov -0x24(%ebp),%edx +c0108c7b: 89 50 04 mov %edx,0x4(%eax) elm->prev = prev; -c0108e61: 8b 45 e4 mov -0x1c(%ebp),%eax -c0108e64: 8b 55 e0 mov -0x20(%ebp),%edx -c0108e67: 89 10 mov %edx,(%eax) +c0108c7e: 8b 45 e4 mov -0x1c(%ebp),%eax +c0108c81: 8b 55 e0 mov -0x20(%ebp),%edx +c0108c84: 89 10 mov %edx,(%eax) } -c0108e69: 90 nop +c0108c86: 90 nop } -c0108e6a: 90 nop +c0108c87: 90 nop } -c0108e6b: 90 nop +c0108c88: 90 nop } -c0108e6c: 90 nop -c0108e6d: 83 c4 34 add $0x34,%esp -c0108e70: 5b pop %ebx -c0108e71: 5d pop %ebp -c0108e72: c3 ret +c0108c89: 90 nop +c0108c8a: 8b 5d fc mov -0x4(%ebp),%ebx +c0108c8d: 89 ec mov %ebp,%esp +c0108c8f: 5d pop %ebp +c0108c90: c3 ret -c0108e73 : +c0108c91 : // find_proc - find proc frome proc hash_list according to pid struct proc_struct * find_proc(int pid) { -c0108e73: f3 0f 1e fb endbr32 -c0108e77: 55 push %ebp -c0108e78: 89 e5 mov %esp,%ebp -c0108e7a: 83 ec 28 sub $0x28,%esp +c0108c91: 55 push %ebp +c0108c92: 89 e5 mov %esp,%ebp +c0108c94: 83 ec 28 sub $0x28,%esp if (0 < pid && pid < MAX_PID) { -c0108e7d: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c0108e81: 7e 5f jle c0108ee2 -c0108e83: 81 7d 08 ff 1f 00 00 cmpl $0x1fff,0x8(%ebp) -c0108e8a: 7f 56 jg c0108ee2 +c0108c97: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0108c9b: 7e 5f jle c0108cfc +c0108c9d: 81 7d 08 ff 1f 00 00 cmpl $0x1fff,0x8(%ebp) +c0108ca4: 7f 56 jg c0108cfc list_entry_t *list = hash_list + pid_hashfn(pid), *le = list; -c0108e8c: 8b 45 08 mov 0x8(%ebp),%eax -c0108e8f: c7 44 24 04 0a 00 00 movl $0xa,0x4(%esp) -c0108e96: 00 -c0108e97: 89 04 24 mov %eax,(%esp) -c0108e9a: e8 d9 12 00 00 call c010a178 -c0108e9f: c1 e0 03 shl $0x3,%eax -c0108ea2: 05 40 c0 12 c0 add $0xc012c040,%eax -c0108ea7: 89 45 f0 mov %eax,-0x10(%ebp) -c0108eaa: 8b 45 f0 mov -0x10(%ebp),%eax -c0108ead: 89 45 f4 mov %eax,-0xc(%ebp) +c0108ca6: 8b 45 08 mov 0x8(%ebp),%eax +c0108ca9: c7 44 24 04 0a 00 00 movl $0xa,0x4(%esp) +c0108cb0: 00 +c0108cb1: 89 04 24 mov %eax,(%esp) +c0108cb4: e8 8e 07 00 00 call c0109447 +c0108cb9: c1 e0 03 shl $0x3,%eax +c0108cbc: 05 a0 c1 12 c0 add $0xc012c1a0,%eax +c0108cc1: 89 45 f0 mov %eax,-0x10(%ebp) +c0108cc4: 8b 45 f0 mov -0x10(%ebp),%eax +c0108cc7: 89 45 f4 mov %eax,-0xc(%ebp) while ((le = list_next(le)) != list) { -c0108eb0: eb 19 jmp c0108ecb +c0108cca: eb 19 jmp c0108ce5 struct proc_struct *proc = le2proc(le, hash_link); -c0108eb2: 8b 45 f4 mov -0xc(%ebp),%eax -c0108eb5: 83 e8 60 sub $0x60,%eax -c0108eb8: 89 45 ec mov %eax,-0x14(%ebp) +c0108ccc: 8b 45 f4 mov -0xc(%ebp),%eax +c0108ccf: 83 e8 60 sub $0x60,%eax +c0108cd2: 89 45 ec mov %eax,-0x14(%ebp) if (proc->pid == pid) { -c0108ebb: 8b 45 ec mov -0x14(%ebp),%eax -c0108ebe: 8b 40 04 mov 0x4(%eax),%eax -c0108ec1: 39 45 08 cmp %eax,0x8(%ebp) -c0108ec4: 75 05 jne c0108ecb +c0108cd5: 8b 45 ec mov -0x14(%ebp),%eax +c0108cd8: 8b 40 04 mov 0x4(%eax),%eax +c0108cdb: 39 45 08 cmp %eax,0x8(%ebp) +c0108cde: 75 05 jne c0108ce5 return proc; -c0108ec6: 8b 45 ec mov -0x14(%ebp),%eax -c0108ec9: eb 1c jmp c0108ee7 -c0108ecb: 8b 45 f4 mov -0xc(%ebp),%eax -c0108ece: 89 45 e8 mov %eax,-0x18(%ebp) +c0108ce0: 8b 45 ec mov -0x14(%ebp),%eax +c0108ce3: eb 1c jmp c0108d01 +c0108ce5: 8b 45 f4 mov -0xc(%ebp),%eax +c0108ce8: 89 45 e8 mov %eax,-0x18(%ebp) return listelm->next; -c0108ed1: 8b 45 e8 mov -0x18(%ebp),%eax -c0108ed4: 8b 40 04 mov 0x4(%eax),%eax +c0108ceb: 8b 45 e8 mov -0x18(%ebp),%eax +c0108cee: 8b 40 04 mov 0x4(%eax),%eax while ((le = list_next(le)) != list) { -c0108ed7: 89 45 f4 mov %eax,-0xc(%ebp) -c0108eda: 8b 45 f4 mov -0xc(%ebp),%eax -c0108edd: 3b 45 f0 cmp -0x10(%ebp),%eax -c0108ee0: 75 d0 jne c0108eb2 +c0108cf1: 89 45 f4 mov %eax,-0xc(%ebp) +c0108cf4: 8b 45 f4 mov -0xc(%ebp),%eax +c0108cf7: 3b 45 f0 cmp -0x10(%ebp),%eax +c0108cfa: 75 d0 jne c0108ccc } } } return NULL; -c0108ee2: b8 00 00 00 00 mov $0x0,%eax +c0108cfc: b8 00 00 00 00 mov $0x0,%eax } -c0108ee7: c9 leave -c0108ee8: c3 ret - -c0108ee9 : +c0108d01: 89 ec mov %ebp,%esp +c0108d03: 5d pop %ebp +c0108d04: c3 ret -// kernel_thread - create a kernel thread using "fn" function -// NOTE: the contents of temp trapframe tf will be copied to -// proc->tf in do_fork-->copy_thread function +c0108d05 : + * + * 该函数通过设置trapframe来创建一个内核线程,并安排其执行指定的函数fn + * 使用do_fork函数来进行实际的线程创建操作,创建的线程将共享父线程的虚拟内存 + */ int kernel_thread(int (*fn)(void *), void *arg, uint32_t clone_flags) { -c0108ee9: f3 0f 1e fb endbr32 -c0108eed: 55 push %ebp -c0108eee: 89 e5 mov %esp,%ebp -c0108ef0: 83 ec 68 sub $0x68,%esp +c0108d05: 55 push %ebp +c0108d06: 89 e5 mov %esp,%ebp +c0108d08: 83 ec 68 sub $0x68,%esp + // 初始化trapframe结构体,用于描述线程的初始状态 struct trapframe tf; memset(&tf, 0, sizeof(struct trapframe)); -c0108ef3: c7 44 24 08 4c 00 00 movl $0x4c,0x8(%esp) -c0108efa: 00 -c0108efb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0108f02: 00 -c0108f03: 8d 45 ac lea -0x54(%ebp),%eax -c0108f06: 89 04 24 mov %eax,(%esp) -c0108f09: e8 46 0a 00 00 call c0109954 +c0108d0b: c7 44 24 08 4c 00 00 movl $0x4c,0x8(%esp) +c0108d12: 00 +c0108d13: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0108d1a: 00 +c0108d1b: 8d 45 ac lea -0x54(%ebp),%eax +c0108d1e: 89 04 24 mov %eax,(%esp) +c0108d21: e8 be 11 00 00 call c0109ee4 + + // 设置代码段和数据段寄存器的值,使线程运行在内核态 tf.tf_cs = KERNEL_CS; -c0108f0e: 66 c7 45 e8 08 00 movw $0x8,-0x18(%ebp) +c0108d26: 66 c7 45 e8 08 00 movw $0x8,-0x18(%ebp) tf.tf_ds = tf.tf_es = tf.tf_ss = KERNEL_DS; -c0108f14: 66 c7 45 f4 10 00 movw $0x10,-0xc(%ebp) -c0108f1a: 0f b7 45 f4 movzwl -0xc(%ebp),%eax -c0108f1e: 66 89 45 d4 mov %ax,-0x2c(%ebp) -c0108f22: 0f b7 45 d4 movzwl -0x2c(%ebp),%eax -c0108f26: 66 89 45 d8 mov %ax,-0x28(%ebp) +c0108d2c: 66 c7 45 f4 10 00 movw $0x10,-0xc(%ebp) +c0108d32: 0f b7 45 f4 movzwl -0xc(%ebp),%eax +c0108d36: 66 89 45 d4 mov %ax,-0x2c(%ebp) +c0108d3a: 0f b7 45 d4 movzwl -0x2c(%ebp),%eax +c0108d3e: 66 89 45 d8 mov %ax,-0x28(%ebp) + + // 将要执行的函数fn的地址和参数arg的地址分别放入ebx和edx寄存器 tf.tf_regs.reg_ebx = (uint32_t)fn; -c0108f2a: 8b 45 08 mov 0x8(%ebp),%eax -c0108f2d: 89 45 bc mov %eax,-0x44(%ebp) +c0108d42: 8b 45 08 mov 0x8(%ebp),%eax +c0108d45: 89 45 bc mov %eax,-0x44(%ebp) tf.tf_regs.reg_edx = (uint32_t)arg; -c0108f30: 8b 45 0c mov 0xc(%ebp),%eax -c0108f33: 89 45 c0 mov %eax,-0x40(%ebp) +c0108d48: 8b 45 0c mov 0xc(%ebp),%eax +c0108d4b: 89 45 c0 mov %eax,-0x40(%ebp) + + // 设置指令指针寄存器eip,使其指向内核线程入口函数kernel_thread_entry tf.tf_eip = (uint32_t)kernel_thread_entry; -c0108f36: b8 b4 89 10 c0 mov $0xc01089b4,%eax -c0108f3b: 89 45 e4 mov %eax,-0x1c(%ebp) +c0108d4e: b8 d3 87 10 c0 mov $0xc01087d3,%eax +c0108d53: 89 45 e4 mov %eax,-0x1c(%ebp) + + // 调用do_fork函数创建新线程,新线程将共享父线程的虚拟内存 + // 并将新线程的初始状态设置为之前准备的trapframe return do_fork(clone_flags | CLONE_VM, 0, &tf); -c0108f3e: 8b 45 10 mov 0x10(%ebp),%eax -c0108f41: 0d 00 01 00 00 or $0x100,%eax -c0108f46: 89 c2 mov %eax,%edx -c0108f48: 8d 45 ac lea -0x54(%ebp),%eax -c0108f4b: 89 44 24 08 mov %eax,0x8(%esp) -c0108f4f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) -c0108f56: 00 -c0108f57: 89 14 24 mov %edx,(%esp) -c0108f5a: e8 98 01 00 00 call c01090f7 -} -c0108f5f: c9 leave -c0108f60: c3 ret - -c0108f61 : +c0108d56: 8b 45 10 mov 0x10(%ebp),%eax +c0108d59: 0d 00 01 00 00 or $0x100,%eax +c0108d5e: 89 c2 mov %eax,%edx +c0108d60: 8d 45 ac lea -0x54(%ebp),%eax +c0108d63: 89 44 24 08 mov %eax,0x8(%esp) +c0108d67: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) +c0108d6e: 00 +c0108d6f: 89 14 24 mov %edx,(%esp) +c0108d72: e8 90 01 00 00 call c0108f07 +} +c0108d77: 89 ec mov %ebp,%esp +c0108d79: 5d pop %ebp +c0108d7a: c3 ret + +c0108d7b : * * 此函数通过分配一页内存用作进程的内核栈,并将该内存页的虚拟地址设置为进程的内核栈地址 * 如果内存分配成功,则返回0;如果内存分配失败,则返回-E_NO_MEM */ static int setup_kstack(struct proc_struct *proc) { -c0108f61: f3 0f 1e fb endbr32 -c0108f65: 55 push %ebp -c0108f66: 89 e5 mov %esp,%ebp -c0108f68: 83 ec 28 sub $0x28,%esp +c0108d7b: 55 push %ebp +c0108d7c: 89 e5 mov %esp,%ebp +c0108d7e: 83 ec 28 sub $0x28,%esp // 分配KSTACKPAGE页内存用作内核栈 struct Page *page = alloc_pages(KSTACKPAGE); -c0108f6b: c7 04 24 02 00 00 00 movl $0x2,(%esp) -c0108f72: e8 e2 a7 ff ff call c0103759 -c0108f77: 89 45 f4 mov %eax,-0xc(%ebp) +c0108d81: c7 04 24 02 00 00 00 movl $0x2,(%esp) +c0108d88: e8 4e c2 ff ff call c0104fdb +c0108d8d: 89 45 f4 mov %eax,-0xc(%ebp) if (page != NULL) { -c0108f7a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c0108f7e: 74 1a je c0108f9a +c0108d90: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0108d94: 74 1a je c0108db0 // 如果内存分配成功,将内存页的虚拟地址设置为进程的内核栈地址 proc->kstack = (uintptr_t)page2kva(page); -c0108f80: 8b 45 f4 mov -0xc(%ebp),%eax -c0108f83: 89 04 24 mov %eax,(%esp) -c0108f86: e8 df fa ff ff call c0108a6a -c0108f8b: 89 c2 mov %eax,%edx -c0108f8d: 8b 45 08 mov 0x8(%ebp),%eax -c0108f90: 89 50 0c mov %edx,0xc(%eax) +c0108d96: 8b 45 f4 mov -0xc(%ebp),%eax +c0108d99: 89 04 24 mov %eax,(%esp) +c0108d9c: e8 f0 fa ff ff call c0108891 +c0108da1: 89 c2 mov %eax,%edx +c0108da3: 8b 45 08 mov 0x8(%ebp),%eax +c0108da6: 89 50 0c mov %edx,0xc(%eax) return 0; -c0108f93: b8 00 00 00 00 mov $0x0,%eax -c0108f98: eb 05 jmp c0108f9f +c0108da9: b8 00 00 00 00 mov $0x0,%eax +c0108dae: eb 05 jmp c0108db5 } // 如果内存分配失败,返回错误码 return -E_NO_MEM; -c0108f9a: b8 fc ff ff ff mov $0xfffffffc,%eax +c0108db0: b8 fc ff ff ff mov $0xfffffffc,%eax } -c0108f9f: c9 leave -c0108fa0: c3 ret +c0108db5: 89 ec mov %ebp,%esp +c0108db7: 5d pop %ebp +c0108db8: c3 ret -c0108fa1 : +c0108db9 : // put_kstack - free the memory space of process kernel stack static void put_kstack(struct proc_struct *proc) { -c0108fa1: f3 0f 1e fb endbr32 -c0108fa5: 55 push %ebp -c0108fa6: 89 e5 mov %esp,%ebp -c0108fa8: 83 ec 18 sub $0x18,%esp +c0108db9: 55 push %ebp +c0108dba: 89 e5 mov %esp,%ebp +c0108dbc: 83 ec 18 sub $0x18,%esp free_pages(kva2page((void *)(proc->kstack)), KSTACKPAGE); -c0108fab: 8b 45 08 mov 0x8(%ebp),%eax -c0108fae: 8b 40 0c mov 0xc(%eax),%eax -c0108fb1: 89 04 24 mov %eax,(%esp) -c0108fb4: e8 05 fb ff ff call c0108abe -c0108fb9: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) -c0108fc0: 00 -c0108fc1: 89 04 24 mov %eax,(%esp) -c0108fc4: e8 ff a7 ff ff call c01037c8 -} -c0108fc9: 90 nop -c0108fca: c9 leave -c0108fcb: c3 ret - -c0108fcc : +c0108dbf: 8b 45 08 mov 0x8(%ebp),%eax +c0108dc2: 8b 40 0c mov 0xc(%eax),%eax +c0108dc5: 89 04 24 mov %eax,(%esp) +c0108dc8: e8 1a fb ff ff call c01088e7 +c0108dcd: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) +c0108dd4: 00 +c0108dd5: 89 04 24 mov %eax,(%esp) +c0108dd8: e8 6b c2 ff ff call c0105048 +} +c0108ddd: 90 nop +c0108dde: 89 ec mov %ebp,%esp +c0108de0: 5d pop %ebp +c0108de1: c3 ret + +c0108de2 : * @param proc 指向新进程的进程结构体指针,用于存储复制的内存管理信息。 * * 断言当前进程没有内存管理信息。 */ static int copy_mm(uint32_t clone_flags, struct proc_struct *proc) { -c0108fcc: f3 0f 1e fb endbr32 -c0108fd0: 55 push %ebp -c0108fd1: 89 e5 mov %esp,%ebp -c0108fd3: 83 ec 18 sub $0x18,%esp +c0108de2: 55 push %ebp +c0108de3: 89 e5 mov %esp,%ebp +c0108de5: 83 ec 18 sub $0x18,%esp assert(current->mm == NULL); -c0108fd6: a1 28 c0 12 c0 mov 0xc012c028,%eax -c0108fdb: 8b 40 18 mov 0x18(%eax),%eax -c0108fde: 85 c0 test %eax,%eax -c0108fe0: 74 24 je c0109006 -c0108fe2: c7 44 24 0c 3c c2 10 movl $0xc010c23c,0xc(%esp) -c0108fe9: c0 -c0108fea: c7 44 24 08 50 c2 10 movl $0xc010c250,0x8(%esp) -c0108ff1: c0 -c0108ff2: c7 44 24 04 37 01 00 movl $0x137,0x4(%esp) -c0108ff9: 00 -c0108ffa: c7 04 24 65 c2 10 c0 movl $0xc010c265,(%esp) -c0109001: e8 3d 74 ff ff call c0100443 <__panic> +c0108de8: a1 90 c1 12 c0 mov 0xc012c190,%eax +c0108ded: 8b 40 18 mov 0x18(%eax),%eax +c0108df0: 85 c0 test %eax,%eax +c0108df2: 74 24 je c0108e18 +c0108df4: c7 44 24 0c 18 c0 10 movl $0xc010c018,0xc(%esp) +c0108dfb: c0 +c0108dfc: c7 44 24 08 2c c0 10 movl $0xc010c02c,0x8(%esp) +c0108e03: c0 +c0108e04: c7 44 24 04 5d 01 00 movl $0x15d,0x4(%esp) +c0108e0b: 00 +c0108e0c: c7 04 24 41 c0 10 c0 movl $0xc010c041,(%esp) +c0108e13: e8 2d 7e ff ff call c0100c45 <__panic> /* do nothing in this project */ return 0; -c0109006: b8 00 00 00 00 mov $0x0,%eax +c0108e18: b8 00 00 00 00 mov $0x0,%eax } -c010900b: c9 leave -c010900c: c3 ret +c0108e1d: 89 ec mov %ebp,%esp +c0108e1f: 5d pop %ebp +c0108e20: c3 ret -c010900d : +c0108e21 : * @param proc 指向新进程的进程结构体,用于存储初始化后的陷阱帧和上下文信息。 * @param esp 新进程的栈指针,表示新进程栈的初始位置。 * @param tf 指向当前线程的陷阱帧结构体,用于将当前线程的执行状态复制到新进程中。 */ static void copy_thread(struct proc_struct *proc, uintptr_t esp, struct trapframe *tf) { -c010900d: f3 0f 1e fb endbr32 -c0109011: 55 push %ebp -c0109012: 89 e5 mov %esp,%ebp -c0109014: 57 push %edi -c0109015: 56 push %esi -c0109016: 53 push %ebx +c0108e21: 55 push %ebp +c0108e22: 89 e5 mov %esp,%ebp +c0108e24: 57 push %edi +c0108e25: 56 push %esi +c0108e26: 53 push %ebx // 初始化新进程的陷阱帧,位于其内核栈的顶部 proc->tf = (struct trapframe *)(proc->kstack + KSTACKSIZE) - 1; -c0109017: 8b 45 08 mov 0x8(%ebp),%eax -c010901a: 8b 40 0c mov 0xc(%eax),%eax -c010901d: 05 b4 1f 00 00 add $0x1fb4,%eax -c0109022: 89 c2 mov %eax,%edx -c0109024: 8b 45 08 mov 0x8(%ebp),%eax -c0109027: 89 50 3c mov %edx,0x3c(%eax) +c0108e27: 8b 45 08 mov 0x8(%ebp),%eax +c0108e2a: 8b 40 0c mov 0xc(%eax),%eax +c0108e2d: 05 b4 1f 00 00 add $0x1fb4,%eax +c0108e32: 89 c2 mov %eax,%edx +c0108e34: 8b 45 08 mov 0x8(%ebp),%eax +c0108e37: 89 50 3c mov %edx,0x3c(%eax) // 将当前线程的陷阱帧内容复制到新进程的陷阱帧 *(proc->tf) = *tf; -c010902a: 8b 45 08 mov 0x8(%ebp),%eax -c010902d: 8b 40 3c mov 0x3c(%eax),%eax -c0109030: 8b 55 10 mov 0x10(%ebp),%edx -c0109033: bb 4c 00 00 00 mov $0x4c,%ebx -c0109038: 89 c1 mov %eax,%ecx -c010903a: 83 e1 01 and $0x1,%ecx -c010903d: 85 c9 test %ecx,%ecx -c010903f: 74 0c je c010904d -c0109041: 0f b6 0a movzbl (%edx),%ecx -c0109044: 88 08 mov %cl,(%eax) -c0109046: 8d 40 01 lea 0x1(%eax),%eax -c0109049: 8d 52 01 lea 0x1(%edx),%edx -c010904c: 4b dec %ebx -c010904d: 89 c1 mov %eax,%ecx -c010904f: 83 e1 02 and $0x2,%ecx -c0109052: 85 c9 test %ecx,%ecx -c0109054: 74 0f je c0109065 -c0109056: 0f b7 0a movzwl (%edx),%ecx -c0109059: 66 89 08 mov %cx,(%eax) -c010905c: 8d 40 02 lea 0x2(%eax),%eax -c010905f: 8d 52 02 lea 0x2(%edx),%edx -c0109062: 83 eb 02 sub $0x2,%ebx -c0109065: 89 df mov %ebx,%edi -c0109067: 83 e7 fc and $0xfffffffc,%edi -c010906a: b9 00 00 00 00 mov $0x0,%ecx -c010906f: 8b 34 0a mov (%edx,%ecx,1),%esi -c0109072: 89 34 08 mov %esi,(%eax,%ecx,1) -c0109075: 83 c1 04 add $0x4,%ecx -c0109078: 39 f9 cmp %edi,%ecx -c010907a: 72 f3 jb c010906f -c010907c: 01 c8 add %ecx,%eax -c010907e: 01 ca add %ecx,%edx -c0109080: b9 00 00 00 00 mov $0x0,%ecx -c0109085: 89 de mov %ebx,%esi -c0109087: 83 e6 02 and $0x2,%esi -c010908a: 85 f6 test %esi,%esi -c010908c: 74 0b je c0109099 -c010908e: 0f b7 34 0a movzwl (%edx,%ecx,1),%esi -c0109092: 66 89 34 08 mov %si,(%eax,%ecx,1) -c0109096: 83 c1 02 add $0x2,%ecx -c0109099: 83 e3 01 and $0x1,%ebx -c010909c: 85 db test %ebx,%ebx -c010909e: 74 07 je c01090a7 -c01090a0: 0f b6 14 0a movzbl (%edx,%ecx,1),%edx -c01090a4: 88 14 08 mov %dl,(%eax,%ecx,1) +c0108e3a: 8b 45 08 mov 0x8(%ebp),%eax +c0108e3d: 8b 40 3c mov 0x3c(%eax),%eax +c0108e40: 8b 55 10 mov 0x10(%ebp),%edx +c0108e43: b9 4c 00 00 00 mov $0x4c,%ecx +c0108e48: 89 c3 mov %eax,%ebx +c0108e4a: 83 e3 01 and $0x1,%ebx +c0108e4d: 85 db test %ebx,%ebx +c0108e4f: 74 0c je c0108e5d +c0108e51: 0f b6 1a movzbl (%edx),%ebx +c0108e54: 88 18 mov %bl,(%eax) +c0108e56: 8d 40 01 lea 0x1(%eax),%eax +c0108e59: 8d 52 01 lea 0x1(%edx),%edx +c0108e5c: 49 dec %ecx +c0108e5d: 89 c3 mov %eax,%ebx +c0108e5f: 83 e3 02 and $0x2,%ebx +c0108e62: 85 db test %ebx,%ebx +c0108e64: 74 0f je c0108e75 +c0108e66: 0f b7 1a movzwl (%edx),%ebx +c0108e69: 66 89 18 mov %bx,(%eax) +c0108e6c: 8d 40 02 lea 0x2(%eax),%eax +c0108e6f: 8d 52 02 lea 0x2(%edx),%edx +c0108e72: 83 e9 02 sub $0x2,%ecx +c0108e75: 89 cf mov %ecx,%edi +c0108e77: 83 e7 fc and $0xfffffffc,%edi +c0108e7a: bb 00 00 00 00 mov $0x0,%ebx +c0108e7f: 8b 34 1a mov (%edx,%ebx,1),%esi +c0108e82: 89 34 18 mov %esi,(%eax,%ebx,1) +c0108e85: 83 c3 04 add $0x4,%ebx +c0108e88: 39 fb cmp %edi,%ebx +c0108e8a: 72 f3 jb c0108e7f +c0108e8c: 01 d8 add %ebx,%eax +c0108e8e: 01 da add %ebx,%edx +c0108e90: bb 00 00 00 00 mov $0x0,%ebx +c0108e95: 89 ce mov %ecx,%esi +c0108e97: 83 e6 02 and $0x2,%esi +c0108e9a: 85 f6 test %esi,%esi +c0108e9c: 74 0b je c0108ea9 +c0108e9e: 0f b7 34 1a movzwl (%edx,%ebx,1),%esi +c0108ea2: 66 89 34 18 mov %si,(%eax,%ebx,1) +c0108ea6: 83 c3 02 add $0x2,%ebx +c0108ea9: 83 e1 01 and $0x1,%ecx +c0108eac: 85 c9 test %ecx,%ecx +c0108eae: 74 07 je c0108eb7 +c0108eb0: 0f b6 14 1a movzbl (%edx,%ebx,1),%edx +c0108eb4: 88 14 18 mov %dl,(%eax,%ebx,1) // 设置子进程的返回值为0,表示fork成功 proc->tf->tf_regs.reg_eax = 0; -c01090a7: 8b 45 08 mov 0x8(%ebp),%eax -c01090aa: 8b 40 3c mov 0x3c(%eax),%eax -c01090ad: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax) +c0108eb7: 8b 45 08 mov 0x8(%ebp),%eax +c0108eba: 8b 40 3c mov 0x3c(%eax),%eax +c0108ebd: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax) // 设置子进程的栈指针为指定的esp位置 proc->tf->tf_esp = esp; -c01090b4: 8b 45 08 mov 0x8(%ebp),%eax -c01090b7: 8b 40 3c mov 0x3c(%eax),%eax -c01090ba: 8b 55 0c mov 0xc(%ebp),%edx -c01090bd: 89 50 44 mov %edx,0x44(%eax) +c0108ec4: 8b 45 08 mov 0x8(%ebp),%eax +c0108ec7: 8b 40 3c mov 0x3c(%eax),%eax +c0108eca: 8b 55 0c mov 0xc(%ebp),%edx +c0108ecd: 89 50 44 mov %edx,0x44(%eax) // 启用子进程的中断标志 proc->tf->tf_eflags |= FL_IF; -c01090c0: 8b 45 08 mov 0x8(%ebp),%eax -c01090c3: 8b 40 3c mov 0x3c(%eax),%eax -c01090c6: 8b 50 40 mov 0x40(%eax),%edx -c01090c9: 8b 45 08 mov 0x8(%ebp),%eax -c01090cc: 8b 40 3c mov 0x3c(%eax),%eax -c01090cf: 81 ca 00 02 00 00 or $0x200,%edx -c01090d5: 89 50 40 mov %edx,0x40(%eax) +c0108ed0: 8b 45 08 mov 0x8(%ebp),%eax +c0108ed3: 8b 40 3c mov 0x3c(%eax),%eax +c0108ed6: 8b 50 40 mov 0x40(%eax),%edx +c0108ed9: 8b 45 08 mov 0x8(%ebp),%eax +c0108edc: 8b 40 3c mov 0x3c(%eax),%eax +c0108edf: 81 ca 00 02 00 00 or $0x200,%edx +c0108ee5: 89 50 40 mov %edx,0x40(%eax) // 设置子进程的初始指令指针为forkret函数的地址 proc->context.eip = (uintptr_t)forkret; -c01090d8: ba d2 8d 10 c0 mov $0xc0108dd2,%edx -c01090dd: 8b 45 08 mov 0x8(%ebp),%eax -c01090e0: 89 50 1c mov %edx,0x1c(%eax) +c0108ee8: ba f3 8b 10 c0 mov $0xc0108bf3,%edx +c0108eed: 8b 45 08 mov 0x8(%ebp),%eax +c0108ef0: 89 50 1c mov %edx,0x1c(%eax) // 设置子进程的栈指针为其陷阱帧的地址 proc->context.esp = (uintptr_t)(proc->tf); -c01090e3: 8b 45 08 mov 0x8(%ebp),%eax -c01090e6: 8b 40 3c mov 0x3c(%eax),%eax -c01090e9: 89 c2 mov %eax,%edx -c01090eb: 8b 45 08 mov 0x8(%ebp),%eax -c01090ee: 89 50 20 mov %edx,0x20(%eax) -} -c01090f1: 90 nop -c01090f2: 5b pop %ebx -c01090f3: 5e pop %esi -c01090f4: 5f pop %edi -c01090f5: 5d pop %ebp -c01090f6: c3 ret - -c01090f7 : - * @clone_flags: used to guide how to clone the child process +c0108ef3: 8b 45 08 mov 0x8(%ebp),%eax +c0108ef6: 8b 40 3c mov 0x3c(%eax),%eax +c0108ef9: 89 c2 mov %eax,%edx +c0108efb: 8b 45 08 mov 0x8(%ebp),%eax +c0108efe: 89 50 20 mov %edx,0x20(%eax) +} +c0108f01: 90 nop +c0108f02: 5b pop %ebx +c0108f03: 5e pop %esi +c0108f04: 5f pop %edi +c0108f05: 5d pop %ebp +c0108f06: c3 ret + +c0108f07 : * @stack: the parent's user stack pointer. if stack==0, It means to fork a kernel thread. * @tf: the trapframe info, which will be copied to child process's proc->tf */ + int do_fork(uint32_t clone_flags, uintptr_t stack, struct trapframe *tf) { -c01090f7: f3 0f 1e fb endbr32 -c01090fb: 55 push %ebp -c01090fc: 89 e5 mov %esp,%ebp -c01090fe: 83 ec 48 sub $0x48,%esp +c0108f07: 55 push %ebp +c0108f08: 89 e5 mov %esp,%ebp +c0108f0a: 83 ec 48 sub $0x48,%esp int ret = -E_NO_FREE_PROC; -c0109101: c7 45 f4 fb ff ff ff movl $0xfffffffb,-0xc(%ebp) +c0108f0d: c7 45 f4 fb ff ff ff movl $0xfffffffb,-0xc(%ebp) struct proc_struct *proc; if (nr_process >= MAX_PROCESS) { -c0109108: a1 40 e0 12 c0 mov 0xc012e040,%eax -c010910d: 3d ff 0f 00 00 cmp $0xfff,%eax -c0109112: 0f 8f 17 01 00 00 jg c010922f +c0108f14: a1 a0 e1 12 c0 mov 0xc012e1a0,%eax +c0108f19: 3d ff 0f 00 00 cmp $0xfff,%eax +c0108f1e: 0f 8f 17 01 00 00 jg c010903b goto fork_out; } ret = -E_NO_MEM; -c0109118: c7 45 f4 fc ff ff ff movl $0xfffffffc,-0xc(%ebp) +c0108f24: c7 45 f4 fc ff ff ff movl $0xfffffffc,-0xc(%ebp) // 4. call copy_thread to setup tf & context in proc_struct // 5. insert proc_struct into hash_list && proc_list // 6. call wakeup_proc to make the new child process RUNNABLE // 7. set ret vaule using child proc's pid //调用alloc_proc,首先获得一块用户信息块 if((proc = alloc_proc()) == NULL){ -c010911f: e8 e4 f9 ff ff call c0108b08 -c0109124: 89 45 f0 mov %eax,-0x10(%ebp) -c0109127: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c010912b: 0f 84 01 01 00 00 je c0109232 +c0108f2b: e8 03 fa ff ff call c0108933 +c0108f30: 89 45 f0 mov %eax,-0x10(%ebp) +c0108f33: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c0108f37: 0f 84 01 01 00 00 je c010903e goto fork_out; } proc->parent = current; -c0109131: 8b 15 28 c0 12 c0 mov 0xc012c028,%edx -c0109137: 8b 45 f0 mov -0x10(%ebp),%eax -c010913a: 89 50 14 mov %edx,0x14(%eax) +c0108f3d: 8b 15 90 c1 12 c0 mov 0xc012c190,%edx +c0108f43: 8b 45 f0 mov -0x10(%ebp),%eax +c0108f46: 89 50 14 mov %edx,0x14(%eax) //为进程分配一个内核栈 ret = setup_kstack(proc); -c010913d: 8b 45 f0 mov -0x10(%ebp),%eax -c0109140: 89 04 24 mov %eax,(%esp) -c0109143: e8 19 fe ff ff call c0108f61 -c0109148: 89 45 f4 mov %eax,-0xc(%ebp) +c0108f49: 8b 45 f0 mov -0x10(%ebp),%eax +c0108f4c: 89 04 24 mov %eax,(%esp) +c0108f4f: e8 27 fe ff ff call c0108d7b +c0108f54: 89 45 f4 mov %eax,-0xc(%ebp) if (ret != 0) { -c010914b: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c010914f: 0f 85 f5 00 00 00 jne c010924a +c0108f57: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0108f5b: 0f 85 f1 00 00 00 jne c0109052 goto bad_fork_cleanup_proc; } //复制原进程的内存管理信息到新进程 ret = copy_mm(clone_flags, proc); -c0109155: 8b 45 f0 mov -0x10(%ebp),%eax -c0109158: 89 44 24 04 mov %eax,0x4(%esp) -c010915c: 8b 45 08 mov 0x8(%ebp),%eax -c010915f: 89 04 24 mov %eax,(%esp) -c0109162: e8 65 fe ff ff call c0108fcc -c0109167: 89 45 f4 mov %eax,-0xc(%ebp) +c0108f61: 8b 45 f0 mov -0x10(%ebp),%eax +c0108f64: 89 44 24 04 mov %eax,0x4(%esp) +c0108f68: 8b 45 08 mov 0x8(%ebp),%eax +c0108f6b: 89 04 24 mov %eax,(%esp) +c0108f6e: e8 6f fe ff ff call c0108de2 +c0108f73: 89 45 f4 mov %eax,-0xc(%ebp) if (ret != 0) { -c010916a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) -c010916e: 0f 85 c4 00 00 00 jne c0109238 +c0108f76: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) +c0108f7a: 0f 85 c4 00 00 00 jne c0109044 goto bad_fork_cleanup_kstack; } //复制原进程上下文到新进程 copy_thread(proc, stack, tf); -c0109174: 8b 45 10 mov 0x10(%ebp),%eax -c0109177: 89 44 24 08 mov %eax,0x8(%esp) -c010917b: 8b 45 0c mov 0xc(%ebp),%eax -c010917e: 89 44 24 04 mov %eax,0x4(%esp) -c0109182: 8b 45 f0 mov -0x10(%ebp),%eax -c0109185: 89 04 24 mov %eax,(%esp) -c0109188: e8 80 fe ff ff call c010900d +c0108f80: 8b 45 10 mov 0x10(%ebp),%eax +c0108f83: 89 44 24 08 mov %eax,0x8(%esp) +c0108f87: 8b 45 0c mov 0xc(%ebp),%eax +c0108f8a: 89 44 24 04 mov %eax,0x4(%esp) +c0108f8e: 8b 45 f0 mov -0x10(%ebp),%eax +c0108f91: 89 04 24 mov %eax,(%esp) +c0108f94: e8 88 fe ff ff call c0108e21 bool intr_flag; local_intr_save(intr_flag); -c010918d: e8 2b f8 ff ff call c01089bd <__intr_save> -c0109192: 89 45 ec mov %eax,-0x14(%ebp) +c0108f99: e8 3e f8 ff ff call c01087dc <__intr_save> +c0108f9e: 89 45 ec mov %eax,-0x14(%ebp) { //为新进程分配一个pid proc->pid = get_pid(); -c0109195: e8 c4 fa ff ff call c0108c5e -c010919a: 8b 55 f0 mov -0x10(%ebp),%edx -c010919d: 89 42 04 mov %eax,0x4(%edx) +c0108fa1: e8 dd fa ff ff call c0108a83 +c0108fa6: 8b 55 f0 mov -0x10(%ebp),%edx +c0108fa9: 89 42 04 mov %eax,0x4(%edx) //将新进程插入到进程列表 hash_proc(proc); -c01091a0: 8b 45 f0 mov -0x10(%ebp),%eax -c01091a3: 89 04 24 mov %eax,(%esp) -c01091a6: e8 44 fc ff ff call c0108def - list_add(&proc_init, &(proc->list_link)); -c01091ab: 8b 45 f0 mov -0x10(%ebp),%eax -c01091ae: 83 c0 58 add $0x58,%eax -c01091b1: c7 45 e8 da 92 10 c0 movl $0xc01092da,-0x18(%ebp) -c01091b8: 89 45 e4 mov %eax,-0x1c(%ebp) -c01091bb: 8b 45 e8 mov -0x18(%ebp),%eax -c01091be: 89 45 e0 mov %eax,-0x20(%ebp) -c01091c1: 8b 45 e4 mov -0x1c(%ebp),%eax -c01091c4: 89 45 dc mov %eax,-0x24(%ebp) +c0108fac: 8b 45 f0 mov -0x10(%ebp),%eax +c0108faf: 89 04 24 mov %eax,(%esp) +c0108fb2: e8 57 fc ff ff call c0108c0e + list_add(&proc_list, &(proc->list_link)); +c0108fb7: 8b 45 f0 mov -0x10(%ebp),%eax +c0108fba: 83 c0 58 add $0x58,%eax +c0108fbd: c7 45 e8 80 c1 12 c0 movl $0xc012c180,-0x18(%ebp) +c0108fc4: 89 45 e4 mov %eax,-0x1c(%ebp) +c0108fc7: 8b 45 e8 mov -0x18(%ebp),%eax +c0108fca: 89 45 e0 mov %eax,-0x20(%ebp) +c0108fcd: 8b 45 e4 mov -0x1c(%ebp),%eax +c0108fd0: 89 45 dc mov %eax,-0x24(%ebp) __list_add(elm, listelm, listelm->next); -c01091c7: 8b 45 e0 mov -0x20(%ebp),%eax -c01091ca: 8b 40 04 mov 0x4(%eax),%eax -c01091cd: 8b 55 dc mov -0x24(%ebp),%edx -c01091d0: 89 55 d8 mov %edx,-0x28(%ebp) -c01091d3: 8b 55 e0 mov -0x20(%ebp),%edx -c01091d6: 89 55 d4 mov %edx,-0x2c(%ebp) -c01091d9: 89 45 d0 mov %eax,-0x30(%ebp) +c0108fd3: 8b 45 e0 mov -0x20(%ebp),%eax +c0108fd6: 8b 40 04 mov 0x4(%eax),%eax +c0108fd9: 8b 55 dc mov -0x24(%ebp),%edx +c0108fdc: 89 55 d8 mov %edx,-0x28(%ebp) +c0108fdf: 8b 55 e0 mov -0x20(%ebp),%edx +c0108fe2: 89 55 d4 mov %edx,-0x2c(%ebp) +c0108fe5: 89 45 d0 mov %eax,-0x30(%ebp) prev->next = next->prev = elm; -c01091dc: 8b 45 d0 mov -0x30(%ebp),%eax -c01091df: 8b 55 d8 mov -0x28(%ebp),%edx -c01091e2: 89 10 mov %edx,(%eax) -c01091e4: 8b 45 d0 mov -0x30(%ebp),%eax -c01091e7: 8b 10 mov (%eax),%edx -c01091e9: 8b 45 d4 mov -0x2c(%ebp),%eax -c01091ec: 89 50 04 mov %edx,0x4(%eax) +c0108fe8: 8b 45 d0 mov -0x30(%ebp),%eax +c0108feb: 8b 55 d8 mov -0x28(%ebp),%edx +c0108fee: 89 10 mov %edx,(%eax) +c0108ff0: 8b 45 d0 mov -0x30(%ebp),%eax +c0108ff3: 8b 10 mov (%eax),%edx +c0108ff5: 8b 45 d4 mov -0x2c(%ebp),%eax +c0108ff8: 89 50 04 mov %edx,0x4(%eax) elm->next = next; -c01091ef: 8b 45 d8 mov -0x28(%ebp),%eax -c01091f2: 8b 55 d0 mov -0x30(%ebp),%edx -c01091f5: 89 50 04 mov %edx,0x4(%eax) +c0108ffb: 8b 45 d8 mov -0x28(%ebp),%eax +c0108ffe: 8b 55 d0 mov -0x30(%ebp),%edx +c0109001: 89 50 04 mov %edx,0x4(%eax) elm->prev = prev; -c01091f8: 8b 45 d8 mov -0x28(%ebp),%eax -c01091fb: 8b 55 d4 mov -0x2c(%ebp),%edx -c01091fe: 89 10 mov %edx,(%eax) +c0109004: 8b 45 d8 mov -0x28(%ebp),%eax +c0109007: 8b 55 d4 mov -0x2c(%ebp),%edx +c010900a: 89 10 mov %edx,(%eax) } -c0109200: 90 nop +c010900c: 90 nop } -c0109201: 90 nop +c010900d: 90 nop } -c0109202: 90 nop +c010900e: 90 nop nr_process ++; -c0109203: a1 40 e0 12 c0 mov 0xc012e040,%eax -c0109208: 40 inc %eax -c0109209: a3 40 e0 12 c0 mov %eax,0xc012e040 +c010900f: a1 a0 e1 12 c0 mov 0xc012e1a0,%eax +c0109014: 40 inc %eax +c0109015: a3 a0 e1 12 c0 mov %eax,0xc012e1a0 } local_intr_restore(intr_flag); -c010920e: 8b 45 ec mov -0x14(%ebp),%eax -c0109211: 89 04 24 mov %eax,(%esp) -c0109214: e8 ce f7 ff ff call c01089e7 <__intr_restore> +c010901a: 8b 45 ec mov -0x14(%ebp),%eax +c010901d: 89 04 24 mov %eax,(%esp) +c0109020: e8 e3 f7 ff ff call c0108808 <__intr_restore> wakeup_proc(proc); -c0109219: 8b 45 f0 mov -0x10(%ebp),%eax -c010921c: 89 04 24 mov %eax,(%esp) -c010921f: e8 d4 02 00 00 call c01094f8 +c0109025: 8b 45 f0 mov -0x10(%ebp),%eax +c0109028: 89 04 24 mov %eax,(%esp) +c010902b: e8 01 03 00 00 call c0109331 ret = proc->pid; -c0109224: 8b 45 f0 mov -0x10(%ebp),%eax -c0109227: 8b 40 04 mov 0x4(%eax),%eax -c010922a: 89 45 f4 mov %eax,-0xc(%ebp) -c010922d: eb 04 jmp c0109233 +c0109030: 8b 45 f0 mov -0x10(%ebp),%eax +c0109033: 8b 40 04 mov 0x4(%eax),%eax +c0109036: 89 45 f4 mov %eax,-0xc(%ebp) +c0109039: eb 04 jmp c010903f goto fork_out; -c010922f: 90 nop -c0109230: eb 01 jmp c0109233 +c010903b: 90 nop +c010903c: eb 01 jmp c010903f goto fork_out; -c0109232: 90 nop +c010903e: 90 nop fork_out: return ret; -c0109233: 8b 45 f4 mov -0xc(%ebp),%eax -c0109236: eb 20 jmp c0109258 +c010903f: 8b 45 f4 mov -0xc(%ebp),%eax +c0109042: eb 1c jmp c0109060 goto bad_fork_cleanup_kstack; -c0109238: 90 nop -c0109239: f3 0f 1e fb endbr32 +c0109044: 90 nop bad_fork_cleanup_kstack: - put_kstack(proc); -c010923d: 8b 45 f0 mov -0x10(%ebp),%eax -c0109240: 89 04 24 mov %eax,(%esp) -c0109243: e8 59 fd ff ff call c0108fa1 -c0109248: eb 01 jmp c010924b - goto bad_fork_cleanup_proc; -c010924a: 90 nop -bad_fork_cleanup_proc: - kfree(proc); -c010924b: 8b 45 f0 mov -0x10(%ebp),%eax -c010924e: 89 04 24 mov %eax,(%esp) -c0109251: e8 ff d5 ff ff call c0106855 - goto fork_out; -c0109256: eb db jmp c0109233 -} -c0109258: c9 leave -c0109259: c3 ret - -c010925a : -// do_exit - called by sys_exit -// 1. call exit_mmap & put_pgdir & mm_destroy to free the almost all memory space of process -// 2. set process' state as PROC_ZOMBIE, then call wakeup_proc(parent) to ask parent reclaim itself. -// 3. call scheduler to switch to other process -int -do_exit(int error_code) { -c010925a: f3 0f 1e fb endbr32 -c010925e: 55 push %ebp -c010925f: 89 e5 mov %esp,%ebp -c0109261: 83 ec 18 sub $0x18,%esp - panic("process exit!!.\n"); -c0109264: c7 44 24 08 79 c2 10 movl $0xc010c279,0x8(%esp) -c010926b: c0 -c010926c: c7 44 24 04 b6 01 00 movl $0x1b6,0x4(%esp) -c0109273: 00 -c0109274: c7 04 24 65 c2 10 c0 movl $0xc010c265,(%esp) -c010927b: e8 c3 71 ff ff call c0100443 <__panic> - -c0109280 : -} - -// init_main - the second kernel thread used to create user_main kernel threads -static int -init_main(void *arg) { -c0109280: f3 0f 1e fb endbr32 -c0109284: 55 push %ebp -c0109285: 89 e5 mov %esp,%ebp -c0109287: 83 ec 18 sub $0x18,%esp - cprintf("this initproc, pid = %d, name = \"%s\"\n", current->pid, get_proc_name(current)); -c010928a: a1 28 c0 12 c0 mov 0xc012c028,%eax -c010928f: 89 04 24 mov %eax,(%esp) -c0109292: e8 81 f9 ff ff call c0108c18 -c0109297: 8b 15 28 c0 12 c0 mov 0xc012c028,%edx -c010929d: 8b 52 04 mov 0x4(%edx),%edx -c01092a0: 89 44 24 08 mov %eax,0x8(%esp) -c01092a4: 89 54 24 04 mov %edx,0x4(%esp) -c01092a8: c7 04 24 8c c2 10 c0 movl $0xc010c28c,(%esp) -c01092af: e8 23 70 ff ff call c01002d7 - cprintf("To U: \"%s\".\n", (const char *)arg); -c01092b4: 8b 45 08 mov 0x8(%ebp),%eax -c01092b7: 89 44 24 04 mov %eax,0x4(%esp) -c01092bb: c7 04 24 b2 c2 10 c0 movl $0xc010c2b2,(%esp) -c01092c2: e8 10 70 ff ff call c01002d7 - cprintf("To U: \"en.., Bye, Bye. :)\"\n"); -c01092c7: c7 04 24 bf c2 10 c0 movl $0xc010c2bf,(%esp) -c01092ce: e8 04 70 ff ff call c01002d7 - return 0; -c01092d3: b8 00 00 00 00 mov $0x0,%eax -} -c01092d8: c9 leave -c01092d9: c3 ret - -c01092da : - -// proc_init - set up the first kernel thread idleproc "idle" by itself and -// - create the second kernel thread init_main -void -proc_init(void) { -c01092da: f3 0f 1e fb endbr32 -c01092de: 55 push %ebp -c01092df: 89 e5 mov %esp,%ebp -c01092e1: 83 ec 28 sub $0x28,%esp -c01092e4: c7 45 ec b0 e1 12 c0 movl $0xc012e1b0,-0x14(%ebp) - elm->prev = elm->next = elm; -c01092eb: 8b 45 ec mov -0x14(%ebp),%eax -c01092ee: 8b 55 ec mov -0x14(%ebp),%edx -c01092f1: 89 50 04 mov %edx,0x4(%eax) -c01092f4: 8b 45 ec mov -0x14(%ebp),%eax -c01092f7: 8b 50 04 mov 0x4(%eax),%edx -c01092fa: 8b 45 ec mov -0x14(%ebp),%eax -c01092fd: 89 10 mov %edx,(%eax) -} -c01092ff: 90 nop - int i; - - list_init(&proc_list); - for (i = 0; i < HASH_LIST_SIZE; i ++) { -c0109300: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) -c0109307: eb 26 jmp c010932f - list_init(hash_list + i); -c0109309: 8b 45 f4 mov -0xc(%ebp),%eax -c010930c: c1 e0 03 shl $0x3,%eax -c010930f: 05 40 c0 12 c0 add $0xc012c040,%eax -c0109314: 89 45 e8 mov %eax,-0x18(%ebp) - elm->prev = elm->next = elm; -c0109317: 8b 45 e8 mov -0x18(%ebp),%eax -c010931a: 8b 55 e8 mov -0x18(%ebp),%edx -c010931d: 89 50 04 mov %edx,0x4(%eax) -c0109320: 8b 45 e8 mov -0x18(%ebp),%eax -c0109323: 8b 50 04 mov 0x4(%eax),%edx -c0109326: 8b 45 e8 mov -0x18(%ebp),%eax -c0109329: 89 10 mov %edx,(%eax) -} -c010932b: 90 nop - for (i = 0; i < HASH_LIST_SIZE; i ++) { -c010932c: ff 45 f4 incl -0xc(%ebp) -c010932f: 81 7d f4 ff 03 00 00 cmpl $0x3ff,-0xc(%ebp) -c0109336: 7e d1 jle c0109309 - } - - if ((idleproc = alloc_proc()) == NULL) { -c0109338: e8 cb f7 ff ff call c0108b08 -c010933d: a3 20 c0 12 c0 mov %eax,0xc012c020 -c0109342: a1 20 c0 12 c0 mov 0xc012c020,%eax -c0109347: 85 c0 test %eax,%eax -c0109349: 75 1c jne c0109367 - panic("cannot alloc idleproc.\n"); -c010934b: c7 44 24 08 db c2 10 movl $0xc010c2db,0x8(%esp) -c0109352: c0 -c0109353: c7 44 24 04 ce 01 00 movl $0x1ce,0x4(%esp) -c010935a: 00 -c010935b: c7 04 24 65 c2 10 c0 movl $0xc010c265,(%esp) -c0109362: e8 dc 70 ff ff call c0100443 <__panic> - } - - idleproc->pid = 0; -c0109367: a1 20 c0 12 c0 mov 0xc012c020,%eax -c010936c: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) - idleproc->state = PROC_RUNNABLE; -c0109373: a1 20 c0 12 c0 mov 0xc012c020,%eax -c0109378: c7 00 02 00 00 00 movl $0x2,(%eax) - idleproc->kstack = (uintptr_t)bootstack; -c010937e: a1 20 c0 12 c0 mov 0xc012c020,%eax -c0109383: ba 00 60 12 c0 mov $0xc0126000,%edx -c0109388: 89 50 0c mov %edx,0xc(%eax) - idleproc->need_resched = 1; -c010938b: a1 20 c0 12 c0 mov 0xc012c020,%eax -c0109390: c7 40 10 01 00 00 00 movl $0x1,0x10(%eax) - set_proc_name(idleproc, "idle"); -c0109397: a1 20 c0 12 c0 mov 0xc012c020,%eax -c010939c: c7 44 24 04 f3 c2 10 movl $0xc010c2f3,0x4(%esp) -c01093a3: c0 -c01093a4: 89 04 24 mov %eax,(%esp) -c01093a7: e8 25 f8 ff ff call c0108bd1 - nr_process ++; -c01093ac: a1 40 e0 12 c0 mov 0xc012e040,%eax -c01093b1: 40 inc %eax -c01093b2: a3 40 e0 12 c0 mov %eax,0xc012e040 - - current = idleproc; -c01093b7: a1 20 c0 12 c0 mov 0xc012c020,%eax -c01093bc: a3 28 c0 12 c0 mov %eax,0xc012c028 - - int pid = kernel_thread(init_main, "Hello world!!", 0); -c01093c1: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) -c01093c8: 00 -c01093c9: c7 44 24 04 f8 c2 10 movl $0xc010c2f8,0x4(%esp) -c01093d0: c0 -c01093d1: c7 04 24 80 92 10 c0 movl $0xc0109280,(%esp) -c01093d8: e8 0c fb ff ff call c0108ee9 -c01093dd: 89 45 f0 mov %eax,-0x10(%ebp) - if (pid <= 0) { -c01093e0: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c01093e4: 7f 1c jg c0109402 - panic("create init_main failed.\n"); -c01093e6: c7 44 24 08 06 c3 10 movl $0xc010c306,0x8(%esp) -c01093ed: c0 -c01093ee: c7 44 24 04 dc 01 00 movl $0x1dc,0x4(%esp) -c01093f5: 00 -c01093f6: c7 04 24 65 c2 10 c0 movl $0xc010c265,(%esp) -c01093fd: e8 41 70 ff ff call c0100443 <__panic> - } - - initproc = find_proc(pid); -c0109402: 8b 45 f0 mov -0x10(%ebp),%eax -c0109405: 89 04 24 mov %eax,(%esp) -c0109408: e8 66 fa ff ff call c0108e73 -c010940d: a3 24 c0 12 c0 mov %eax,0xc012c024 - set_proc_name(initproc, "init"); -c0109412: a1 24 c0 12 c0 mov 0xc012c024,%eax -c0109417: c7 44 24 04 20 c3 10 movl $0xc010c320,0x4(%esp) -c010941e: c0 -c010941f: 89 04 24 mov %eax,(%esp) -c0109422: e8 aa f7 ff ff call c0108bd1 - - assert(idleproc != NULL && idleproc->pid == 0); -c0109427: a1 20 c0 12 c0 mov 0xc012c020,%eax -c010942c: 85 c0 test %eax,%eax -c010942e: 74 0c je c010943c -c0109430: a1 20 c0 12 c0 mov 0xc012c020,%eax -c0109435: 8b 40 04 mov 0x4(%eax),%eax -c0109438: 85 c0 test %eax,%eax -c010943a: 74 24 je c0109460 -c010943c: c7 44 24 0c 28 c3 10 movl $0xc010c328,0xc(%esp) -c0109443: c0 -c0109444: c7 44 24 08 50 c2 10 movl $0xc010c250,0x8(%esp) -c010944b: c0 -c010944c: c7 44 24 04 e2 01 00 movl $0x1e2,0x4(%esp) -c0109453: 00 -c0109454: c7 04 24 65 c2 10 c0 movl $0xc010c265,(%esp) -c010945b: e8 e3 6f ff ff call c0100443 <__panic> - assert(initproc != NULL && initproc->pid == 1); -c0109460: a1 24 c0 12 c0 mov 0xc012c024,%eax -c0109465: 85 c0 test %eax,%eax -c0109467: 74 0d je c0109476 -c0109469: a1 24 c0 12 c0 mov 0xc012c024,%eax -c010946e: 8b 40 04 mov 0x4(%eax),%eax -c0109471: 83 f8 01 cmp $0x1,%eax -c0109474: 74 24 je c010949a -c0109476: c7 44 24 0c 50 c3 10 movl $0xc010c350,0xc(%esp) -c010947d: c0 -c010947e: c7 44 24 08 50 c2 10 movl $0xc010c250,0x8(%esp) -c0109485: c0 -c0109486: c7 44 24 04 e3 01 00 movl $0x1e3,0x4(%esp) -c010948d: 00 -c010948e: c7 04 24 65 c2 10 c0 movl $0xc010c265,(%esp) -c0109495: e8 a9 6f ff ff call c0100443 <__panic> -} -c010949a: 90 nop -c010949b: c9 leave -c010949c: c3 ret - -c010949d : - -// cpu_idle - at the end of kern_init, the first kernel thread idleproc will do below works -void -cpu_idle(void) { -c010949d: f3 0f 1e fb endbr32 -c01094a1: 55 push %ebp -c01094a2: 89 e5 mov %esp,%ebp -c01094a4: 83 ec 08 sub $0x8,%esp - while (1) { - if (current->need_resched) { -c01094a7: a1 28 c0 12 c0 mov 0xc012c028,%eax -c01094ac: 8b 40 10 mov 0x10(%eax),%eax -c01094af: 85 c0 test %eax,%eax -c01094b1: 74 f4 je c01094a7 - schedule(); -c01094b3: e8 8e 00 00 00 call c0109546 - if (current->need_resched) { -c01094b8: eb ed jmp c01094a7 - -c01094ba <__intr_save>: -__intr_save(void) { -c01094ba: 55 push %ebp -c01094bb: 89 e5 mov %esp,%ebp -c01094bd: 83 ec 18 sub $0x18,%esp - asm volatile ("pushfl; popl %0" : "=r" (eflags)); -c01094c0: 9c pushf -c01094c1: 58 pop %eax -c01094c2: 89 45 f4 mov %eax,-0xc(%ebp) - return eflags; -c01094c5: 8b 45 f4 mov -0xc(%ebp),%eax - if (read_eflags() & FL_IF) { -c01094c8: 25 00 02 00 00 and $0x200,%eax -c01094cd: 85 c0 test %eax,%eax -c01094cf: 74 0c je c01094dd <__intr_save+0x23> - intr_disable(); -c01094d1: e8 7e 8c ff ff call c0102154 - return 1; -c01094d6: b8 01 00 00 00 mov $0x1,%eax -c01094db: eb 05 jmp c01094e2 <__intr_save+0x28> - return 0; -c01094dd: b8 00 00 00 00 mov $0x0,%eax -} -c01094e2: c9 leave -c01094e3: c3 ret - -c01094e4 <__intr_restore>: -__intr_restore(bool flag) { -c01094e4: 55 push %ebp -c01094e5: 89 e5 mov %esp,%ebp -c01094e7: 83 ec 08 sub $0x8,%esp - if (flag) { -c01094ea: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c01094ee: 74 05 je c01094f5 <__intr_restore+0x11> - intr_enable(); -c01094f0: e8 53 8c ff ff call c0102148 -} -c01094f5: 90 nop -c01094f6: c9 leave -c01094f7: c3 ret - -c01094f8 : -#include -#include -#include - -void -wakeup_proc(struct proc_struct *proc) { -c01094f8: f3 0f 1e fb endbr32 -c01094fc: 55 push %ebp -c01094fd: 89 e5 mov %esp,%ebp -c01094ff: 83 ec 18 sub $0x18,%esp - assert(proc->state != PROC_ZOMBIE && proc->state != PROC_RUNNABLE); -c0109502: 8b 45 08 mov 0x8(%ebp),%eax -c0109505: 8b 00 mov (%eax),%eax -c0109507: 83 f8 03 cmp $0x3,%eax -c010950a: 74 0a je c0109516 -c010950c: 8b 45 08 mov 0x8(%ebp),%eax -c010950f: 8b 00 mov (%eax),%eax -c0109511: 83 f8 02 cmp $0x2,%eax -c0109514: 75 24 jne c010953a -c0109516: c7 44 24 0c 78 c3 10 movl $0xc010c378,0xc(%esp) -c010951d: c0 -c010951e: c7 44 24 08 b3 c3 10 movl $0xc010c3b3,0x8(%esp) -c0109525: c0 -c0109526: c7 44 24 04 09 00 00 movl $0x9,0x4(%esp) -c010952d: 00 -c010952e: c7 04 24 c8 c3 10 c0 movl $0xc010c3c8,(%esp) -c0109535: e8 09 6f ff ff call c0100443 <__panic> - proc->state = PROC_RUNNABLE; -c010953a: 8b 45 08 mov 0x8(%ebp),%eax -c010953d: c7 00 02 00 00 00 movl $0x2,(%eax) -} -c0109543: 90 nop -c0109544: c9 leave -c0109545: c3 ret - -c0109546 : - -void -schedule(void) { -c0109546: f3 0f 1e fb endbr32 -c010954a: 55 push %ebp -c010954b: 89 e5 mov %esp,%ebp -c010954d: 83 ec 38 sub $0x38,%esp - bool intr_flag; - list_entry_t *le, *last; - struct proc_struct *next = NULL; -c0109550: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) - local_intr_save(intr_flag); -c0109557: e8 5e ff ff ff call c01094ba <__intr_save> -c010955c: 89 45 ec mov %eax,-0x14(%ebp) - { - current->need_resched = 0; -c010955f: a1 28 c0 12 c0 mov 0xc012c028,%eax -c0109564: c7 40 10 00 00 00 00 movl $0x0,0x10(%eax) - last = (current == idleproc) ? &proc_list : &(current->list_link); -c010956b: 8b 15 28 c0 12 c0 mov 0xc012c028,%edx -c0109571: a1 20 c0 12 c0 mov 0xc012c020,%eax -c0109576: 39 c2 cmp %eax,%edx -c0109578: 74 0a je c0109584 -c010957a: a1 28 c0 12 c0 mov 0xc012c028,%eax -c010957f: 83 c0 58 add $0x58,%eax -c0109582: eb 05 jmp c0109589 -c0109584: b8 b0 e1 12 c0 mov $0xc012e1b0,%eax -c0109589: 89 45 e8 mov %eax,-0x18(%ebp) - le = last; -c010958c: 8b 45 e8 mov -0x18(%ebp),%eax -c010958f: 89 45 f4 mov %eax,-0xc(%ebp) -c0109592: 8b 45 f4 mov -0xc(%ebp),%eax -c0109595: 89 45 e4 mov %eax,-0x1c(%ebp) - return listelm->next; -c0109598: 8b 45 e4 mov -0x1c(%ebp),%eax -c010959b: 8b 40 04 mov 0x4(%eax),%eax - do { - if ((le = list_next(le)) != &proc_list) { -c010959e: 89 45 f4 mov %eax,-0xc(%ebp) -c01095a1: 81 7d f4 b0 e1 12 c0 cmpl $0xc012e1b0,-0xc(%ebp) -c01095a8: 74 13 je c01095bd - next = le2proc(le, list_link); -c01095aa: 8b 45 f4 mov -0xc(%ebp),%eax -c01095ad: 83 e8 58 sub $0x58,%eax -c01095b0: 89 45 f0 mov %eax,-0x10(%ebp) - if (next->state == PROC_RUNNABLE) { -c01095b3: 8b 45 f0 mov -0x10(%ebp),%eax -c01095b6: 8b 00 mov (%eax),%eax -c01095b8: 83 f8 02 cmp $0x2,%eax -c01095bb: 74 0a je c01095c7 - break; - } - } - } while (le != last); -c01095bd: 8b 45 f4 mov -0xc(%ebp),%eax -c01095c0: 3b 45 e8 cmp -0x18(%ebp),%eax -c01095c3: 75 cd jne c0109592 -c01095c5: eb 01 jmp c01095c8 - break; -c01095c7: 90 nop - if (next == NULL || next->state != PROC_RUNNABLE) { -c01095c8: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c01095cc: 74 0a je c01095d8 -c01095ce: 8b 45 f0 mov -0x10(%ebp),%eax -c01095d1: 8b 00 mov (%eax),%eax -c01095d3: 83 f8 02 cmp $0x2,%eax -c01095d6: 74 08 je c01095e0 - next = idleproc; -c01095d8: a1 20 c0 12 c0 mov 0xc012c020,%eax -c01095dd: 89 45 f0 mov %eax,-0x10(%ebp) - } - next->runs ++; -c01095e0: 8b 45 f0 mov -0x10(%ebp),%eax -c01095e3: 8b 40 08 mov 0x8(%eax),%eax -c01095e6: 8d 50 01 lea 0x1(%eax),%edx -c01095e9: 8b 45 f0 mov -0x10(%ebp),%eax -c01095ec: 89 50 08 mov %edx,0x8(%eax) - if (next != current) { -c01095ef: a1 28 c0 12 c0 mov 0xc012c028,%eax -c01095f4: 39 45 f0 cmp %eax,-0x10(%ebp) -c01095f7: 74 0b je c0109604 - proc_run(next); -c01095f9: 8b 45 f0 mov -0x10(%ebp),%eax -c01095fc: 89 04 24 mov %eax,(%esp) -c01095ff: e8 53 f7 ff ff call c0108d57 - } - } - local_intr_restore(intr_flag); -c0109604: 8b 45 ec mov -0x14(%ebp),%eax -c0109607: 89 04 24 mov %eax,(%esp) -c010960a: e8 d5 fe ff ff call c01094e4 <__intr_restore> -} -c010960f: 90 nop -c0109610: c9 leave -c0109611: c3 ret - -c0109612 : - * @s: the input string - * - * The strlen() function returns the length of string @s. - * */ -size_t -strlen(const char *s) { -c0109612: f3 0f 1e fb endbr32 -c0109616: 55 push %ebp -c0109617: 89 e5 mov %esp,%ebp -c0109619: 83 ec 10 sub $0x10,%esp - size_t cnt = 0; -c010961c: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) - while (*s ++ != '\0') { -c0109623: eb 03 jmp c0109628 - cnt ++; -c0109625: ff 45 fc incl -0x4(%ebp) - while (*s ++ != '\0') { -c0109628: 8b 45 08 mov 0x8(%ebp),%eax -c010962b: 8d 50 01 lea 0x1(%eax),%edx -c010962e: 89 55 08 mov %edx,0x8(%ebp) -c0109631: 0f b6 00 movzbl (%eax),%eax -c0109634: 84 c0 test %al,%al -c0109636: 75 ed jne c0109625 - } - return cnt; -c0109638: 8b 45 fc mov -0x4(%ebp),%eax -} -c010963b: c9 leave -c010963c: c3 ret - -c010963d : - * The return value is strlen(s), if that is less than @len, or - * @len if there is no '\0' character among the first @len characters - * pointed by @s. - * */ -size_t -strnlen(const char *s, size_t len) { -c010963d: f3 0f 1e fb endbr32 -c0109641: 55 push %ebp -c0109642: 89 e5 mov %esp,%ebp -c0109644: 83 ec 10 sub $0x10,%esp - size_t cnt = 0; -c0109647: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) - while (cnt < len && *s ++ != '\0') { -c010964e: eb 03 jmp c0109653 - cnt ++; -c0109650: ff 45 fc incl -0x4(%ebp) - while (cnt < len && *s ++ != '\0') { -c0109653: 8b 45 fc mov -0x4(%ebp),%eax -c0109656: 3b 45 0c cmp 0xc(%ebp),%eax -c0109659: 73 10 jae c010966b -c010965b: 8b 45 08 mov 0x8(%ebp),%eax -c010965e: 8d 50 01 lea 0x1(%eax),%edx -c0109661: 89 55 08 mov %edx,0x8(%ebp) -c0109664: 0f b6 00 movzbl (%eax),%eax -c0109667: 84 c0 test %al,%al -c0109669: 75 e5 jne c0109650 - } - return cnt; -c010966b: 8b 45 fc mov -0x4(%ebp),%eax -} -c010966e: c9 leave -c010966f: c3 ret - -c0109670 : - * To avoid overflows, the size of array pointed by @dst should be long enough to - * contain the same string as @src (including the terminating null character), and - * should not overlap in memory with @src. - * */ -char * -strcpy(char *dst, const char *src) { -c0109670: f3 0f 1e fb endbr32 -c0109674: 55 push %ebp -c0109675: 89 e5 mov %esp,%ebp -c0109677: 57 push %edi -c0109678: 56 push %esi -c0109679: 83 ec 20 sub $0x20,%esp -c010967c: 8b 45 08 mov 0x8(%ebp),%eax -c010967f: 89 45 f4 mov %eax,-0xc(%ebp) -c0109682: 8b 45 0c mov 0xc(%ebp),%eax -c0109685: 89 45 f0 mov %eax,-0x10(%ebp) -#ifndef __HAVE_ARCH_STRCPY -#define __HAVE_ARCH_STRCPY -static inline char * -__strcpy(char *dst, const char *src) { - int d0, d1, d2; - asm volatile ( -c0109688: 8b 55 f0 mov -0x10(%ebp),%edx -c010968b: 8b 45 f4 mov -0xc(%ebp),%eax -c010968e: 89 d1 mov %edx,%ecx -c0109690: 89 c2 mov %eax,%edx -c0109692: 89 ce mov %ecx,%esi -c0109694: 89 d7 mov %edx,%edi -c0109696: ac lods %ds:(%esi),%al -c0109697: aa stos %al,%es:(%edi) -c0109698: 84 c0 test %al,%al -c010969a: 75 fa jne c0109696 -c010969c: 89 fa mov %edi,%edx -c010969e: 89 f1 mov %esi,%ecx -c01096a0: 89 4d ec mov %ecx,-0x14(%ebp) -c01096a3: 89 55 e8 mov %edx,-0x18(%ebp) -c01096a6: 89 45 e4 mov %eax,-0x1c(%ebp) - "stosb;" - "testb %%al, %%al;" - "jne 1b;" - : "=&S" (d0), "=&D" (d1), "=&a" (d2) - : "0" (src), "1" (dst) : "memory"); - return dst; -c01096a9: 8b 45 f4 mov -0xc(%ebp),%eax - char *p = dst; - while ((*p ++ = *src ++) != '\0') - /* nothing */; - return dst; -#endif /* __HAVE_ARCH_STRCPY */ -} -c01096ac: 83 c4 20 add $0x20,%esp -c01096af: 5e pop %esi -c01096b0: 5f pop %edi -c01096b1: 5d pop %ebp -c01096b2: c3 ret - -c01096b3 : - * @len: maximum number of characters to be copied from @src - * - * The return value is @dst - * */ -char * -strncpy(char *dst, const char *src, size_t len) { -c01096b3: f3 0f 1e fb endbr32 -c01096b7: 55 push %ebp -c01096b8: 89 e5 mov %esp,%ebp -c01096ba: 83 ec 10 sub $0x10,%esp - char *p = dst; -c01096bd: 8b 45 08 mov 0x8(%ebp),%eax -c01096c0: 89 45 fc mov %eax,-0x4(%ebp) - while (len > 0) { -c01096c3: eb 1e jmp c01096e3 - if ((*p = *src) != '\0') { -c01096c5: 8b 45 0c mov 0xc(%ebp),%eax -c01096c8: 0f b6 10 movzbl (%eax),%edx -c01096cb: 8b 45 fc mov -0x4(%ebp),%eax -c01096ce: 88 10 mov %dl,(%eax) -c01096d0: 8b 45 fc mov -0x4(%ebp),%eax -c01096d3: 0f b6 00 movzbl (%eax),%eax -c01096d6: 84 c0 test %al,%al -c01096d8: 74 03 je c01096dd - src ++; -c01096da: ff 45 0c incl 0xc(%ebp) - } - p ++, len --; -c01096dd: ff 45 fc incl -0x4(%ebp) -c01096e0: ff 4d 10 decl 0x10(%ebp) - while (len > 0) { -c01096e3: 83 7d 10 00 cmpl $0x0,0x10(%ebp) -c01096e7: 75 dc jne c01096c5 - } - return dst; -c01096e9: 8b 45 08 mov 0x8(%ebp),%eax -} -c01096ec: c9 leave -c01096ed: c3 ret - -c01096ee : - * - A value greater than zero indicates that the first character that does - * not match has a greater value in @s1 than in @s2; - * - And a value less than zero indicates the opposite. - * */ -int -strcmp(const char *s1, const char *s2) { -c01096ee: f3 0f 1e fb endbr32 -c01096f2: 55 push %ebp -c01096f3: 89 e5 mov %esp,%ebp -c01096f5: 57 push %edi -c01096f6: 56 push %esi -c01096f7: 83 ec 20 sub $0x20,%esp -c01096fa: 8b 45 08 mov 0x8(%ebp),%eax -c01096fd: 89 45 f4 mov %eax,-0xc(%ebp) -c0109700: 8b 45 0c mov 0xc(%ebp),%eax -c0109703: 89 45 f0 mov %eax,-0x10(%ebp) - asm volatile ( -c0109706: 8b 55 f4 mov -0xc(%ebp),%edx -c0109709: 8b 45 f0 mov -0x10(%ebp),%eax -c010970c: 89 d1 mov %edx,%ecx -c010970e: 89 c2 mov %eax,%edx -c0109710: 89 ce mov %ecx,%esi -c0109712: 89 d7 mov %edx,%edi -c0109714: ac lods %ds:(%esi),%al -c0109715: ae scas %es:(%edi),%al -c0109716: 75 08 jne c0109720 -c0109718: 84 c0 test %al,%al -c010971a: 75 f8 jne c0109714 -c010971c: 31 c0 xor %eax,%eax -c010971e: eb 04 jmp c0109724 -c0109720: 19 c0 sbb %eax,%eax -c0109722: 0c 01 or $0x1,%al -c0109724: 89 fa mov %edi,%edx -c0109726: 89 f1 mov %esi,%ecx -c0109728: 89 45 ec mov %eax,-0x14(%ebp) -c010972b: 89 4d e8 mov %ecx,-0x18(%ebp) -c010972e: 89 55 e4 mov %edx,-0x1c(%ebp) - return ret; -c0109731: 8b 45 ec mov -0x14(%ebp),%eax - while (*s1 != '\0' && *s1 == *s2) { - s1 ++, s2 ++; - } - return (int)((unsigned char)*s1 - (unsigned char)*s2); -#endif /* __HAVE_ARCH_STRCMP */ -} -c0109734: 83 c4 20 add $0x20,%esp -c0109737: 5e pop %esi -c0109738: 5f pop %edi -c0109739: 5d pop %ebp -c010973a: c3 ret - -c010973b : - * they are equal to each other, it continues with the following pairs until - * the characters differ, until a terminating null-character is reached, or - * until @n characters match in both strings, whichever happens first. - * */ -int -strncmp(const char *s1, const char *s2, size_t n) { -c010973b: f3 0f 1e fb endbr32 -c010973f: 55 push %ebp -c0109740: 89 e5 mov %esp,%ebp - while (n > 0 && *s1 != '\0' && *s1 == *s2) { -c0109742: eb 09 jmp c010974d - n --, s1 ++, s2 ++; -c0109744: ff 4d 10 decl 0x10(%ebp) -c0109747: ff 45 08 incl 0x8(%ebp) -c010974a: ff 45 0c incl 0xc(%ebp) - while (n > 0 && *s1 != '\0' && *s1 == *s2) { -c010974d: 83 7d 10 00 cmpl $0x0,0x10(%ebp) -c0109751: 74 1a je c010976d -c0109753: 8b 45 08 mov 0x8(%ebp),%eax -c0109756: 0f b6 00 movzbl (%eax),%eax -c0109759: 84 c0 test %al,%al -c010975b: 74 10 je c010976d -c010975d: 8b 45 08 mov 0x8(%ebp),%eax -c0109760: 0f b6 10 movzbl (%eax),%edx -c0109763: 8b 45 0c mov 0xc(%ebp),%eax -c0109766: 0f b6 00 movzbl (%eax),%eax -c0109769: 38 c2 cmp %al,%dl -c010976b: 74 d7 je c0109744 - } - return (n == 0) ? 0 : (int)((unsigned char)*s1 - (unsigned char)*s2); -c010976d: 83 7d 10 00 cmpl $0x0,0x10(%ebp) -c0109771: 74 18 je c010978b -c0109773: 8b 45 08 mov 0x8(%ebp),%eax -c0109776: 0f b6 00 movzbl (%eax),%eax -c0109779: 0f b6 d0 movzbl %al,%edx -c010977c: 8b 45 0c mov 0xc(%ebp),%eax -c010977f: 0f b6 00 movzbl (%eax),%eax -c0109782: 0f b6 c0 movzbl %al,%eax -c0109785: 29 c2 sub %eax,%edx -c0109787: 89 d0 mov %edx,%eax -c0109789: eb 05 jmp c0109790 -c010978b: b8 00 00 00 00 mov $0x0,%eax -} -c0109790: 5d pop %ebp -c0109791: c3 ret - -c0109792 : - * - * The strchr() function returns a pointer to the first occurrence of - * character in @s. If the value is not found, the function returns 'NULL'. - * */ -char * -strchr(const char *s, char c) { -c0109792: f3 0f 1e fb endbr32 -c0109796: 55 push %ebp -c0109797: 89 e5 mov %esp,%ebp -c0109799: 83 ec 04 sub $0x4,%esp -c010979c: 8b 45 0c mov 0xc(%ebp),%eax -c010979f: 88 45 fc mov %al,-0x4(%ebp) - while (*s != '\0') { -c01097a2: eb 13 jmp c01097b7 - if (*s == c) { -c01097a4: 8b 45 08 mov 0x8(%ebp),%eax -c01097a7: 0f b6 00 movzbl (%eax),%eax -c01097aa: 38 45 fc cmp %al,-0x4(%ebp) -c01097ad: 75 05 jne c01097b4 - return (char *)s; -c01097af: 8b 45 08 mov 0x8(%ebp),%eax -c01097b2: eb 12 jmp c01097c6 - } - s ++; -c01097b4: ff 45 08 incl 0x8(%ebp) - while (*s != '\0') { -c01097b7: 8b 45 08 mov 0x8(%ebp),%eax -c01097ba: 0f b6 00 movzbl (%eax),%eax -c01097bd: 84 c0 test %al,%al -c01097bf: 75 e3 jne c01097a4 - } - return NULL; -c01097c1: b8 00 00 00 00 mov $0x0,%eax + put_kstack(proc); +c0109045: 8b 45 f0 mov -0x10(%ebp),%eax +c0109048: 89 04 24 mov %eax,(%esp) +c010904b: e8 69 fd ff ff call c0108db9 +c0109050: eb 01 jmp c0109053 + goto bad_fork_cleanup_proc; +c0109052: 90 nop +bad_fork_cleanup_proc: + kfree(proc); +c0109053: 8b 45 f0 mov -0x10(%ebp),%eax +c0109056: 89 04 24 mov %eax,(%esp) +c0109059: e8 09 bb ff ff call c0104b67 + goto fork_out; +c010905e: eb df jmp c010903f } -c01097c6: c9 leave -c01097c7: c3 ret +c0109060: 89 ec mov %ebp,%esp +c0109062: 5d pop %ebp +c0109063: c3 ret -c01097c8 : - * The strfind() function is like strchr() except that if @c is - * not found in @s, then it returns a pointer to the null byte at the - * end of @s, rather than 'NULL'. - * */ -char * -strfind(const char *s, char c) { -c01097c8: f3 0f 1e fb endbr32 -c01097cc: 55 push %ebp -c01097cd: 89 e5 mov %esp,%ebp -c01097cf: 83 ec 04 sub $0x4,%esp -c01097d2: 8b 45 0c mov 0xc(%ebp),%eax -c01097d5: 88 45 fc mov %al,-0x4(%ebp) - while (*s != '\0') { -c01097d8: eb 0e jmp c01097e8 - if (*s == c) { -c01097da: 8b 45 08 mov 0x8(%ebp),%eax -c01097dd: 0f b6 00 movzbl (%eax),%eax -c01097e0: 38 45 fc cmp %al,-0x4(%ebp) -c01097e3: 74 0f je c01097f4 - break; - } - s ++; -c01097e5: ff 45 08 incl 0x8(%ebp) - while (*s != '\0') { -c01097e8: 8b 45 08 mov 0x8(%ebp),%eax -c01097eb: 0f b6 00 movzbl (%eax),%eax -c01097ee: 84 c0 test %al,%al -c01097f0: 75 e8 jne c01097da -c01097f2: eb 01 jmp c01097f5 - break; -c01097f4: 90 nop - } - return (char *)s; -c01097f5: 8b 45 08 mov 0x8(%ebp),%eax +c0109064 : +// do_exit - called by sys_exit +// 1. call exit_mmap & put_pgdir & mm_destroy to free the almost all memory space of process +// 2. set process' state as PROC_ZOMBIE, then call wakeup_proc(parent) to ask parent reclaim itself. +// 3. call scheduler to switch to other process +int +do_exit(int error_code) { +c0109064: 55 push %ebp +c0109065: 89 e5 mov %esp,%ebp +c0109067: 83 ec 18 sub $0x18,%esp + panic("process exit!!.\n"); +c010906a: c7 44 24 08 55 c0 10 movl $0xc010c055,0x8(%esp) +c0109071: c0 +c0109072: c7 44 24 04 dd 01 00 movl $0x1dd,0x4(%esp) +c0109079: 00 +c010907a: c7 04 24 41 c0 10 c0 movl $0xc010c041,(%esp) +c0109081: e8 bf 7b ff ff call c0100c45 <__panic> + +c0109086 : + * 和初始化参数的内容它不进行任何错误处理或复杂逻辑,主要是为了演示和调试目的 + * + * @return 返回0,表示初始化成功没有返回值表示失败,因为这是一个特殊的初始化进程 + */ +static int +init_main(void *arg) { +c0109086: 55 push %ebp +c0109087: 89 e5 mov %esp,%ebp +c0109089: 83 ec 18 sub $0x18,%esp + // 打印当前进程的pid和名称,用于调试和信息展示 + cprintf("this initproc, pid = %d, name = \"%s\"\n", current->pid, get_proc_name(current)); +c010908c: a1 90 c1 12 c0 mov 0xc012c190,%eax +c0109091: 89 04 24 mov %eax,(%esp) +c0109094: e8 a6 f9 ff ff call c0108a3f +c0109099: 8b 15 90 c1 12 c0 mov 0xc012c190,%edx +c010909f: 8b 52 04 mov 0x4(%edx),%edx +c01090a2: 89 44 24 08 mov %eax,0x8(%esp) +c01090a6: 89 54 24 04 mov %edx,0x4(%esp) +c01090aa: c7 04 24 68 c0 10 c0 movl $0xc010c068,(%esp) +c01090b1: e8 c2 72 ff ff call c0100378 + + // 打印传递给初始化进程的参数,这里假设参数是一个字符串 + cprintf("To U: \"%s\".\n", (const char *)arg); +c01090b6: 8b 45 08 mov 0x8(%ebp),%eax +c01090b9: 89 44 24 04 mov %eax,0x4(%esp) +c01090bd: c7 04 24 8e c0 10 c0 movl $0xc010c08e,(%esp) +c01090c4: e8 af 72 ff ff call c0100378 + + // 打印固定的告别信息,表示初始化进程即将结束 + cprintf("To U: \"en.., Bye, Bye. :)\"\n"); +c01090c9: c7 04 24 9b c0 10 c0 movl $0xc010c09b,(%esp) +c01090d0: e8 a3 72 ff ff call c0100378 + return 0; +c01090d5: b8 00 00 00 00 mov $0x0,%eax } -c01097f8: c9 leave -c01097f9: c3 ret +c01090da: 89 ec mov %ebp,%esp +c01090dc: 5d pop %ebp +c01090dd: c3 ret -c01097fa : - * an optional "0x" or "0X" prefix. - * - * The strtol() function returns the converted integral number as a long int value. - * */ -long -strtol(const char *s, char **endptr, int base) { -c01097fa: f3 0f 1e fb endbr32 -c01097fe: 55 push %ebp -c01097ff: 89 e5 mov %esp,%ebp -c0109801: 83 ec 10 sub $0x10,%esp - int neg = 0; -c0109804: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) - long val = 0; -c010980b: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%ebp) +c01090de : +/** + * proc_init函数是进程管理初始化的核心函数。 + * 它负责初始化进程列表、哈希表、空闲进程、以及创建初始化进程。 + */ +void +proc_init(void) { +c01090de: 55 push %ebp +c01090df: 89 e5 mov %esp,%ebp +c01090e1: 83 ec 28 sub $0x28,%esp +c01090e4: c7 45 ec 80 c1 12 c0 movl $0xc012c180,-0x14(%ebp) + elm->prev = elm->next = elm; +c01090eb: 8b 45 ec mov -0x14(%ebp),%eax +c01090ee: 8b 55 ec mov -0x14(%ebp),%edx +c01090f1: 89 50 04 mov %edx,0x4(%eax) +c01090f4: 8b 45 ec mov -0x14(%ebp),%eax +c01090f7: 8b 50 04 mov 0x4(%eax),%edx +c01090fa: 8b 45 ec mov -0x14(%ebp),%eax +c01090fd: 89 10 mov %edx,(%eax) +} +c01090ff: 90 nop - // gobble initial whitespace - while (*s == ' ' || *s == '\t') { -c0109812: eb 03 jmp c0109817 - s ++; -c0109814: ff 45 08 incl 0x8(%ebp) - while (*s == ' ' || *s == '\t') { -c0109817: 8b 45 08 mov 0x8(%ebp),%eax -c010981a: 0f b6 00 movzbl (%eax),%eax -c010981d: 3c 20 cmp $0x20,%al -c010981f: 74 f3 je c0109814 -c0109821: 8b 45 08 mov 0x8(%ebp),%eax -c0109824: 0f b6 00 movzbl (%eax),%eax -c0109827: 3c 09 cmp $0x9,%al -c0109829: 74 e9 je c0109814 - } + // 初始化全局进程列表 + list_init(&proc_list); - // plus/minus sign - if (*s == '+') { -c010982b: 8b 45 08 mov 0x8(%ebp),%eax -c010982e: 0f b6 00 movzbl (%eax),%eax -c0109831: 3c 2b cmp $0x2b,%al -c0109833: 75 05 jne c010983a - s ++; -c0109835: ff 45 08 incl 0x8(%ebp) -c0109838: eb 14 jmp c010984e - } - else if (*s == '-') { -c010983a: 8b 45 08 mov 0x8(%ebp),%eax -c010983d: 0f b6 00 movzbl (%eax),%eax -c0109840: 3c 2d cmp $0x2d,%al -c0109842: 75 0a jne c010984e - s ++, neg = 1; -c0109844: ff 45 08 incl 0x8(%ebp) -c0109847: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%ebp) + // 初始化哈希列表,用于快速查找进程 + for (i = 0; i < HASH_LIST_SIZE; i ++) { +c0109100: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) +c0109107: eb 26 jmp c010912f + list_init(hash_list + i); +c0109109: 8b 45 f4 mov -0xc(%ebp),%eax +c010910c: c1 e0 03 shl $0x3,%eax +c010910f: 05 a0 c1 12 c0 add $0xc012c1a0,%eax +c0109114: 89 45 e8 mov %eax,-0x18(%ebp) + elm->prev = elm->next = elm; +c0109117: 8b 45 e8 mov -0x18(%ebp),%eax +c010911a: 8b 55 e8 mov -0x18(%ebp),%edx +c010911d: 89 50 04 mov %edx,0x4(%eax) +c0109120: 8b 45 e8 mov -0x18(%ebp),%eax +c0109123: 8b 50 04 mov 0x4(%eax),%edx +c0109126: 8b 45 e8 mov -0x18(%ebp),%eax +c0109129: 89 10 mov %edx,(%eax) +} +c010912b: 90 nop + for (i = 0; i < HASH_LIST_SIZE; i ++) { +c010912c: ff 45 f4 incl -0xc(%ebp) +c010912f: 81 7d f4 ff 03 00 00 cmpl $0x3ff,-0xc(%ebp) +c0109136: 7e d1 jle c0109109 } - // hex or octal base prefix - if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x')) { -c010984e: 83 7d 10 00 cmpl $0x0,0x10(%ebp) -c0109852: 74 06 je c010985a -c0109854: 83 7d 10 10 cmpl $0x10,0x10(%ebp) -c0109858: 75 22 jne c010987c -c010985a: 8b 45 08 mov 0x8(%ebp),%eax -c010985d: 0f b6 00 movzbl (%eax),%eax -c0109860: 3c 30 cmp $0x30,%al -c0109862: 75 18 jne c010987c -c0109864: 8b 45 08 mov 0x8(%ebp),%eax -c0109867: 40 inc %eax -c0109868: 0f b6 00 movzbl (%eax),%eax -c010986b: 3c 78 cmp $0x78,%al -c010986d: 75 0d jne c010987c - s += 2, base = 16; -c010986f: 83 45 08 02 addl $0x2,0x8(%ebp) -c0109873: c7 45 10 10 00 00 00 movl $0x10,0x10(%ebp) -c010987a: eb 29 jmp c01098a5 + // 分配空闲进程idleproc,这是系统中的第一个进程 + if ((idleproc = alloc_proc()) == NULL) { +c0109138: e8 f6 f7 ff ff call c0108933 +c010913d: a3 88 c1 12 c0 mov %eax,0xc012c188 +c0109142: a1 88 c1 12 c0 mov 0xc012c188,%eax +c0109147: 85 c0 test %eax,%eax +c0109149: 75 1c jne c0109167 + panic("cannot alloc idleproc.\n"); +c010914b: c7 44 24 08 b7 c0 10 movl $0xc010c0b7,0x8(%esp) +c0109152: c0 +c0109153: c7 44 24 04 0c 02 00 movl $0x20c,0x4(%esp) +c010915a: 00 +c010915b: c7 04 24 41 c0 10 c0 movl $0xc010c041,(%esp) +c0109162: e8 de 7a ff ff call c0100c45 <__panic> } - else if (base == 0 && s[0] == '0') { -c010987c: 83 7d 10 00 cmpl $0x0,0x10(%ebp) -c0109880: 75 16 jne c0109898 -c0109882: 8b 45 08 mov 0x8(%ebp),%eax -c0109885: 0f b6 00 movzbl (%eax),%eax -c0109888: 3c 30 cmp $0x30,%al -c010988a: 75 0c jne c0109898 - s ++, base = 8; -c010988c: ff 45 08 incl 0x8(%ebp) -c010988f: c7 45 10 08 00 00 00 movl $0x8,0x10(%ebp) -c0109896: eb 0d jmp c01098a5 + + // 设置idleproc的基本信息 + idleproc->pid = 0; +c0109167: a1 88 c1 12 c0 mov 0xc012c188,%eax +c010916c: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) + idleproc->state = PROC_RUNNABLE; +c0109173: a1 88 c1 12 c0 mov 0xc012c188,%eax +c0109178: c7 00 02 00 00 00 movl $0x2,(%eax) + idleproc->kstack = (uintptr_t)bootstack; +c010917e: a1 88 c1 12 c0 mov 0xc012c188,%eax +c0109183: ba 00 60 12 c0 mov $0xc0126000,%edx +c0109188: 89 50 0c mov %edx,0xc(%eax) + idleproc->need_resched = 1; +c010918b: a1 88 c1 12 c0 mov 0xc012c188,%eax +c0109190: c7 40 10 01 00 00 00 movl $0x1,0x10(%eax) + set_proc_name(idleproc, "idle"); +c0109197: a1 88 c1 12 c0 mov 0xc012c188,%eax +c010919c: c7 44 24 04 cf c0 10 movl $0xc010c0cf,0x4(%esp) +c01091a3: c0 +c01091a4: 89 04 24 mov %eax,(%esp) +c01091a7: e8 4e f8 ff ff call c01089fa + nr_process ++; +c01091ac: a1 a0 e1 12 c0 mov 0xc012e1a0,%eax +c01091b1: 40 inc %eax +c01091b2: a3 a0 e1 12 c0 mov %eax,0xc012e1a0 + + // 将当前进程设置为idleproc + current = idleproc; +c01091b7: a1 88 c1 12 c0 mov 0xc012c188,%eax +c01091bc: a3 90 c1 12 c0 mov %eax,0xc012c190 + + // 创建初始化进程init_main,这是系统中的第二个进程 + int pid = kernel_thread(init_main, "Hello world!!", 0); +c01091c1: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) +c01091c8: 00 +c01091c9: c7 44 24 04 d4 c0 10 movl $0xc010c0d4,0x4(%esp) +c01091d0: c0 +c01091d1: c7 04 24 86 90 10 c0 movl $0xc0109086,(%esp) +c01091d8: e8 28 fb ff ff call c0108d05 +c01091dd: 89 45 f0 mov %eax,-0x10(%ebp) + if (pid <= 0) { +c01091e0: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c01091e4: 7f 1c jg c0109202 + panic("create init_main failed.\n"); +c01091e6: c7 44 24 08 e2 c0 10 movl $0xc010c0e2,0x8(%esp) +c01091ed: c0 +c01091ee: c7 44 24 04 1d 02 00 movl $0x21d,0x4(%esp) +c01091f5: 00 +c01091f6: c7 04 24 41 c0 10 c0 movl $0xc010c041,(%esp) +c01091fd: e8 43 7a ff ff call c0100c45 <__panic> } - else if (base == 0) { -c0109898: 83 7d 10 00 cmpl $0x0,0x10(%ebp) -c010989c: 75 07 jne c01098a5 - base = 10; -c010989e: c7 45 10 0a 00 00 00 movl $0xa,0x10(%ebp) - // digits - while (1) { - int dig; + // 查找并设置初始化进程initproc + initproc = find_proc(pid); +c0109202: 8b 45 f0 mov -0x10(%ebp),%eax +c0109205: 89 04 24 mov %eax,(%esp) +c0109208: e8 84 fa ff ff call c0108c91 +c010920d: a3 8c c1 12 c0 mov %eax,0xc012c18c + set_proc_name(initproc, "init"); +c0109212: a1 8c c1 12 c0 mov 0xc012c18c,%eax +c0109217: c7 44 24 04 fc c0 10 movl $0xc010c0fc,0x4(%esp) +c010921e: c0 +c010921f: 89 04 24 mov %eax,(%esp) +c0109222: e8 d3 f7 ff ff call c01089fa - if (*s >= '0' && *s <= '9') { -c01098a5: 8b 45 08 mov 0x8(%ebp),%eax -c01098a8: 0f b6 00 movzbl (%eax),%eax -c01098ab: 3c 2f cmp $0x2f,%al -c01098ad: 7e 1b jle c01098ca -c01098af: 8b 45 08 mov 0x8(%ebp),%eax -c01098b2: 0f b6 00 movzbl (%eax),%eax -c01098b5: 3c 39 cmp $0x39,%al -c01098b7: 7f 11 jg c01098ca - dig = *s - '0'; -c01098b9: 8b 45 08 mov 0x8(%ebp),%eax -c01098bc: 0f b6 00 movzbl (%eax),%eax -c01098bf: 0f be c0 movsbl %al,%eax -c01098c2: 83 e8 30 sub $0x30,%eax -c01098c5: 89 45 f4 mov %eax,-0xc(%ebp) -c01098c8: eb 48 jmp c0109912 - } - else if (*s >= 'a' && *s <= 'z') { -c01098ca: 8b 45 08 mov 0x8(%ebp),%eax -c01098cd: 0f b6 00 movzbl (%eax),%eax -c01098d0: 3c 60 cmp $0x60,%al -c01098d2: 7e 1b jle c01098ef -c01098d4: 8b 45 08 mov 0x8(%ebp),%eax -c01098d7: 0f b6 00 movzbl (%eax),%eax -c01098da: 3c 7a cmp $0x7a,%al -c01098dc: 7f 11 jg c01098ef - dig = *s - 'a' + 10; -c01098de: 8b 45 08 mov 0x8(%ebp),%eax -c01098e1: 0f b6 00 movzbl (%eax),%eax -c01098e4: 0f be c0 movsbl %al,%eax -c01098e7: 83 e8 57 sub $0x57,%eax -c01098ea: 89 45 f4 mov %eax,-0xc(%ebp) -c01098ed: eb 23 jmp c0109912 - } - else if (*s >= 'A' && *s <= 'Z') { -c01098ef: 8b 45 08 mov 0x8(%ebp),%eax -c01098f2: 0f b6 00 movzbl (%eax),%eax -c01098f5: 3c 40 cmp $0x40,%al -c01098f7: 7e 3b jle c0109934 -c01098f9: 8b 45 08 mov 0x8(%ebp),%eax -c01098fc: 0f b6 00 movzbl (%eax),%eax -c01098ff: 3c 5a cmp $0x5a,%al -c0109901: 7f 31 jg c0109934 - dig = *s - 'A' + 10; -c0109903: 8b 45 08 mov 0x8(%ebp),%eax -c0109906: 0f b6 00 movzbl (%eax),%eax -c0109909: 0f be c0 movsbl %al,%eax -c010990c: 83 e8 37 sub $0x37,%eax -c010990f: 89 45 f4 mov %eax,-0xc(%ebp) - } - else { - break; - } - if (dig >= base) { -c0109912: 8b 45 f4 mov -0xc(%ebp),%eax -c0109915: 3b 45 10 cmp 0x10(%ebp),%eax -c0109918: 7d 19 jge c0109933 - break; - } - s ++, val = (val * base) + dig; -c010991a: ff 45 08 incl 0x8(%ebp) -c010991d: 8b 45 f8 mov -0x8(%ebp),%eax -c0109920: 0f af 45 10 imul 0x10(%ebp),%eax -c0109924: 89 c2 mov %eax,%edx -c0109926: 8b 45 f4 mov -0xc(%ebp),%eax -c0109929: 01 d0 add %edx,%eax -c010992b: 89 45 f8 mov %eax,-0x8(%ebp) + // 断言确保idleproc和initproc正确初始化 + assert(idleproc != NULL && idleproc->pid == 0); +c0109227: a1 88 c1 12 c0 mov 0xc012c188,%eax +c010922c: 85 c0 test %eax,%eax +c010922e: 74 0c je c010923c +c0109230: a1 88 c1 12 c0 mov 0xc012c188,%eax +c0109235: 8b 40 04 mov 0x4(%eax),%eax +c0109238: 85 c0 test %eax,%eax +c010923a: 74 24 je c0109260 +c010923c: c7 44 24 0c 04 c1 10 movl $0xc010c104,0xc(%esp) +c0109243: c0 +c0109244: c7 44 24 08 2c c0 10 movl $0xc010c02c,0x8(%esp) +c010924b: c0 +c010924c: c7 44 24 04 25 02 00 movl $0x225,0x4(%esp) +c0109253: 00 +c0109254: c7 04 24 41 c0 10 c0 movl $0xc010c041,(%esp) +c010925b: e8 e5 79 ff ff call c0100c45 <__panic> + assert(initproc != NULL && initproc->pid == 1); +c0109260: a1 8c c1 12 c0 mov 0xc012c18c,%eax +c0109265: 85 c0 test %eax,%eax +c0109267: 74 0d je c0109276 +c0109269: a1 8c c1 12 c0 mov 0xc012c18c,%eax +c010926e: 8b 40 04 mov 0x4(%eax),%eax +c0109271: 83 f8 01 cmp $0x1,%eax +c0109274: 74 24 je c010929a +c0109276: c7 44 24 0c 2c c1 10 movl $0xc010c12c,0xc(%esp) +c010927d: c0 +c010927e: c7 44 24 08 2c c0 10 movl $0xc010c02c,0x8(%esp) +c0109285: c0 +c0109286: c7 44 24 04 26 02 00 movl $0x226,0x4(%esp) +c010928d: 00 +c010928e: c7 04 24 41 c0 10 c0 movl $0xc010c041,(%esp) +c0109295: e8 ab 79 ff ff call c0100c45 <__panic> +} +c010929a: 90 nop +c010929b: 89 ec mov %ebp,%esp +c010929d: 5d pop %ebp +c010929e: c3 ret + +c010929f : + +// cpu_idle - at the end of kern_init, the first kernel thread idleproc will do below works +void +cpu_idle(void) { +c010929f: 55 push %ebp +c01092a0: 89 e5 mov %esp,%ebp +c01092a2: 83 ec 08 sub $0x8,%esp while (1) { -c010992e: e9 72 ff ff ff jmp c01098a5 - break; -c0109933: 90 nop - // we don't properly detect overflow! - } + //检查当前进程是否需要重新调度 + if (current->need_resched) { +c01092a5: a1 90 c1 12 c0 mov 0xc012c190,%eax +c01092aa: 8b 40 10 mov 0x10(%eax),%eax +c01092ad: 85 c0 test %eax,%eax +c01092af: 74 f4 je c01092a5 + schedule(); +c01092b1: e8 c7 00 00 00 call c010937d + if (current->need_resched) { +c01092b6: eb ed jmp c01092a5 - if (endptr) { -c0109934: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) -c0109938: 74 08 je c0109942 - *endptr = (char *) s; -c010993a: 8b 45 0c mov 0xc(%ebp),%eax -c010993d: 8b 55 08 mov 0x8(%ebp),%edx -c0109940: 89 10 mov %edx,(%eax) - } - return (neg ? -val : val); -c0109942: 83 7d fc 00 cmpl $0x0,-0x4(%ebp) -c0109946: 74 07 je c010994f -c0109948: 8b 45 f8 mov -0x8(%ebp),%eax -c010994b: f7 d8 neg %eax -c010994d: eb 03 jmp c0109952 -c010994f: 8b 45 f8 mov -0x8(%ebp),%eax -} -c0109952: c9 leave -c0109953: c3 ret +c01092b8 : +.text +.globl switch_to +switch_to: # switch_to(from, to) -c0109954 : - * @n: number of bytes to be set to the value - * - * The memset() function returns @s. - * */ -void * -memset(void *s, char c, size_t n) { -c0109954: f3 0f 1e fb endbr32 -c0109958: 55 push %ebp -c0109959: 89 e5 mov %esp,%ebp -c010995b: 57 push %edi -c010995c: 83 ec 24 sub $0x24,%esp -c010995f: 8b 45 0c mov 0xc(%ebp),%eax -c0109962: 88 45 d8 mov %al,-0x28(%ebp) -#ifdef __HAVE_ARCH_MEMSET - return __memset(s, c, n); -c0109965: 0f be 55 d8 movsbl -0x28(%ebp),%edx -c0109969: 8b 45 08 mov 0x8(%ebp),%eax -c010996c: 89 45 f8 mov %eax,-0x8(%ebp) -c010996f: 88 55 f7 mov %dl,-0x9(%ebp) -c0109972: 8b 45 10 mov 0x10(%ebp),%eax -c0109975: 89 45 f0 mov %eax,-0x10(%ebp) -#ifndef __HAVE_ARCH_MEMSET -#define __HAVE_ARCH_MEMSET -static inline void * -__memset(void *s, char c, size_t n) { - int d0, d1; - asm volatile ( -c0109978: 8b 4d f0 mov -0x10(%ebp),%ecx -c010997b: 0f b6 45 f7 movzbl -0x9(%ebp),%eax -c010997f: 8b 55 f8 mov -0x8(%ebp),%edx -c0109982: 89 d7 mov %edx,%edi -c0109984: f3 aa rep stos %al,%es:(%edi) -c0109986: 89 fa mov %edi,%edx -c0109988: 89 4d ec mov %ecx,-0x14(%ebp) -c010998b: 89 55 e8 mov %edx,-0x18(%ebp) - "rep; stosb;" - : "=&c" (d0), "=&D" (d1) - : "0" (n), "a" (c), "1" (s) - : "memory"); - return s; -c010998e: 8b 45 f8 mov -0x8(%ebp),%eax - while (n -- > 0) { - *p ++ = c; - } - return s; -#endif /* __HAVE_ARCH_MEMSET */ -} -c0109991: 83 c4 24 add $0x24,%esp -c0109994: 5f pop %edi -c0109995: 5d pop %ebp -c0109996: c3 ret + # save from's registers + movl 4(%esp), %eax # eax points to from +c01092b8: 8b 44 24 04 mov 0x4(%esp),%eax + popl 0(%eax) # save eip !popl +c01092bc: 8f 00 pop (%eax) + movl %esp, 4(%eax) # save esp::context of from +c01092be: 89 60 04 mov %esp,0x4(%eax) + movl %ebx, 8(%eax) # save ebx::context of from +c01092c1: 89 58 08 mov %ebx,0x8(%eax) + movl %ecx, 12(%eax) # save ecx::context of from +c01092c4: 89 48 0c mov %ecx,0xc(%eax) + movl %edx, 16(%eax) # save edx::context of from +c01092c7: 89 50 10 mov %edx,0x10(%eax) + movl %esi, 20(%eax) # save esi::context of from +c01092ca: 89 70 14 mov %esi,0x14(%eax) + movl %edi, 24(%eax) # save edi::context of from +c01092cd: 89 78 18 mov %edi,0x18(%eax) + movl %ebp, 28(%eax) # save ebp::context of from +c01092d0: 89 68 1c mov %ebp,0x1c(%eax) -c0109997 : - * @n: number of bytes to copy - * - * The memmove() function returns @dst. - * */ -void * -memmove(void *dst, const void *src, size_t n) { -c0109997: f3 0f 1e fb endbr32 -c010999b: 55 push %ebp -c010999c: 89 e5 mov %esp,%ebp -c010999e: 57 push %edi -c010999f: 56 push %esi -c01099a0: 53 push %ebx -c01099a1: 83 ec 30 sub $0x30,%esp -c01099a4: 8b 45 08 mov 0x8(%ebp),%eax -c01099a7: 89 45 f0 mov %eax,-0x10(%ebp) -c01099aa: 8b 45 0c mov 0xc(%ebp),%eax -c01099ad: 89 45 ec mov %eax,-0x14(%ebp) -c01099b0: 8b 45 10 mov 0x10(%ebp),%eax -c01099b3: 89 45 e8 mov %eax,-0x18(%ebp) + # restore to's registers + movl 4(%esp), %eax # not 8(%esp): popped return address already +c01092d3: 8b 44 24 04 mov 0x4(%esp),%eax + # eax now points to to + movl 28(%eax), %ebp # restore ebp::context of to +c01092d7: 8b 68 1c mov 0x1c(%eax),%ebp + movl 24(%eax), %edi # restore edi::context of to +c01092da: 8b 78 18 mov 0x18(%eax),%edi + movl 20(%eax), %esi # restore esi::context of to +c01092dd: 8b 70 14 mov 0x14(%eax),%esi + movl 16(%eax), %edx # restore edx::context of to +c01092e0: 8b 50 10 mov 0x10(%eax),%edx + movl 12(%eax), %ecx # restore ecx::context of to +c01092e3: 8b 48 0c mov 0xc(%eax),%ecx + movl 8(%eax), %ebx # restore ebx::context of to +c01092e6: 8b 58 08 mov 0x8(%eax),%ebx + movl 4(%eax), %esp # restore esp::context of to +c01092e9: 8b 60 04 mov 0x4(%eax),%esp -#ifndef __HAVE_ARCH_MEMMOVE -#define __HAVE_ARCH_MEMMOVE -static inline void * -__memmove(void *dst, const void *src, size_t n) { - if (dst < src) { -c01099b6: 8b 45 f0 mov -0x10(%ebp),%eax -c01099b9: 3b 45 ec cmp -0x14(%ebp),%eax -c01099bc: 73 42 jae c0109a00 -c01099be: 8b 45 f0 mov -0x10(%ebp),%eax -c01099c1: 89 45 e4 mov %eax,-0x1c(%ebp) -c01099c4: 8b 45 ec mov -0x14(%ebp),%eax -c01099c7: 89 45 e0 mov %eax,-0x20(%ebp) -c01099ca: 8b 45 e8 mov -0x18(%ebp),%eax -c01099cd: 89 45 dc mov %eax,-0x24(%ebp) - "andl $3, %%ecx;" - "jz 1f;" - "rep; movsb;" - "1:" - : "=&c" (d0), "=&D" (d1), "=&S" (d2) - : "0" (n / 4), "g" (n), "1" (dst), "2" (src) -c01099d0: 8b 45 dc mov -0x24(%ebp),%eax -c01099d3: c1 e8 02 shr $0x2,%eax -c01099d6: 89 c1 mov %eax,%ecx - asm volatile ( -c01099d8: 8b 55 e4 mov -0x1c(%ebp),%edx -c01099db: 8b 45 e0 mov -0x20(%ebp),%eax -c01099de: 89 d7 mov %edx,%edi -c01099e0: 89 c6 mov %eax,%esi -c01099e2: f3 a5 rep movsl %ds:(%esi),%es:(%edi) -c01099e4: 8b 4d dc mov -0x24(%ebp),%ecx -c01099e7: 83 e1 03 and $0x3,%ecx -c01099ea: 74 02 je c01099ee -c01099ec: f3 a4 rep movsb %ds:(%esi),%es:(%edi) -c01099ee: 89 f0 mov %esi,%eax -c01099f0: 89 fa mov %edi,%edx -c01099f2: 89 4d d8 mov %ecx,-0x28(%ebp) -c01099f5: 89 55 d4 mov %edx,-0x2c(%ebp) -c01099f8: 89 45 d0 mov %eax,-0x30(%ebp) - : "memory"); - return dst; -c01099fb: 8b 45 e4 mov -0x1c(%ebp),%eax - return __memcpy(dst, src, n); -c01099fe: eb 36 jmp c0109a36 - : "0" (n), "1" (n - 1 + src), "2" (n - 1 + dst) -c0109a00: 8b 45 e8 mov -0x18(%ebp),%eax -c0109a03: 8d 50 ff lea -0x1(%eax),%edx -c0109a06: 8b 45 ec mov -0x14(%ebp),%eax -c0109a09: 01 c2 add %eax,%edx -c0109a0b: 8b 45 e8 mov -0x18(%ebp),%eax -c0109a0e: 8d 48 ff lea -0x1(%eax),%ecx -c0109a11: 8b 45 f0 mov -0x10(%ebp),%eax -c0109a14: 8d 1c 01 lea (%ecx,%eax,1),%ebx - asm volatile ( -c0109a17: 8b 45 e8 mov -0x18(%ebp),%eax -c0109a1a: 89 c1 mov %eax,%ecx -c0109a1c: 89 d8 mov %ebx,%eax -c0109a1e: 89 d6 mov %edx,%esi -c0109a20: 89 c7 mov %eax,%edi -c0109a22: fd std -c0109a23: f3 a4 rep movsb %ds:(%esi),%es:(%edi) -c0109a25: fc cld -c0109a26: 89 f8 mov %edi,%eax -c0109a28: 89 f2 mov %esi,%edx -c0109a2a: 89 4d cc mov %ecx,-0x34(%ebp) -c0109a2d: 89 55 c8 mov %edx,-0x38(%ebp) -c0109a30: 89 45 c4 mov %eax,-0x3c(%ebp) - return dst; -c0109a33: 8b 45 f0 mov -0x10(%ebp),%eax - *d ++ = *s ++; - } - } - return dst; -#endif /* __HAVE_ARCH_MEMMOVE */ + pushl 0(%eax) # push eip +c01092ec: ff 30 push (%eax) + + ret +c01092ee: c3 ret + +c01092ef <__intr_save>: +__intr_save(void) { +c01092ef: 55 push %ebp +c01092f0: 89 e5 mov %esp,%ebp +c01092f2: 83 ec 18 sub $0x18,%esp + asm volatile ("pushfl; popl %0" : "=r" (eflags)); +c01092f5: 9c pushf +c01092f6: 58 pop %eax +c01092f7: 89 45 f4 mov %eax,-0xc(%ebp) + return eflags; +c01092fa: 8b 45 f4 mov -0xc(%ebp),%eax + if (read_eflags() & FL_IF) { +c01092fd: 25 00 02 00 00 and $0x200,%eax +c0109302: 85 c0 test %eax,%eax +c0109304: 74 0c je c0109312 <__intr_save+0x23> + intr_disable(); +c0109306: e8 f0 8b ff ff call c0101efb + return 1; +c010930b: b8 01 00 00 00 mov $0x1,%eax +c0109310: eb 05 jmp c0109317 <__intr_save+0x28> + return 0; +c0109312: b8 00 00 00 00 mov $0x0,%eax } -c0109a36: 83 c4 30 add $0x30,%esp -c0109a39: 5b pop %ebx -c0109a3a: 5e pop %esi -c0109a3b: 5f pop %edi -c0109a3c: 5d pop %ebp -c0109a3d: c3 ret +c0109317: 89 ec mov %ebp,%esp +c0109319: 5d pop %ebp +c010931a: c3 ret -c0109a3e : - * it always copies exactly @n bytes. To avoid overflows, the size of arrays pointed - * by both @src and @dst, should be at least @n bytes, and should not overlap - * (for overlapping memory area, memmove is a safer approach). - * */ -void * -memcpy(void *dst, const void *src, size_t n) { -c0109a3e: f3 0f 1e fb endbr32 -c0109a42: 55 push %ebp -c0109a43: 89 e5 mov %esp,%ebp -c0109a45: 57 push %edi -c0109a46: 56 push %esi -c0109a47: 83 ec 20 sub $0x20,%esp -c0109a4a: 8b 45 08 mov 0x8(%ebp),%eax -c0109a4d: 89 45 f4 mov %eax,-0xc(%ebp) -c0109a50: 8b 45 0c mov 0xc(%ebp),%eax -c0109a53: 89 45 f0 mov %eax,-0x10(%ebp) -c0109a56: 8b 45 10 mov 0x10(%ebp),%eax -c0109a59: 89 45 ec mov %eax,-0x14(%ebp) - : "0" (n / 4), "g" (n), "1" (dst), "2" (src) -c0109a5c: 8b 45 ec mov -0x14(%ebp),%eax -c0109a5f: c1 e8 02 shr $0x2,%eax -c0109a62: 89 c1 mov %eax,%ecx - asm volatile ( -c0109a64: 8b 55 f4 mov -0xc(%ebp),%edx -c0109a67: 8b 45 f0 mov -0x10(%ebp),%eax -c0109a6a: 89 d7 mov %edx,%edi -c0109a6c: 89 c6 mov %eax,%esi -c0109a6e: f3 a5 rep movsl %ds:(%esi),%es:(%edi) -c0109a70: 8b 4d ec mov -0x14(%ebp),%ecx -c0109a73: 83 e1 03 and $0x3,%ecx -c0109a76: 74 02 je c0109a7a -c0109a78: f3 a4 rep movsb %ds:(%esi),%es:(%edi) -c0109a7a: 89 f0 mov %esi,%eax -c0109a7c: 89 fa mov %edi,%edx -c0109a7e: 89 4d e8 mov %ecx,-0x18(%ebp) -c0109a81: 89 55 e4 mov %edx,-0x1c(%ebp) -c0109a84: 89 45 e0 mov %eax,-0x20(%ebp) - return dst; -c0109a87: 8b 45 f4 mov -0xc(%ebp),%eax - while (n -- > 0) { - *d ++ = *s ++; - } - return dst; -#endif /* __HAVE_ARCH_MEMCPY */ +c010931b <__intr_restore>: +__intr_restore(bool flag) { +c010931b: 55 push %ebp +c010931c: 89 e5 mov %esp,%ebp +c010931e: 83 ec 08 sub $0x8,%esp + if (flag) { +c0109321: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0109325: 74 05 je c010932c <__intr_restore+0x11> + intr_enable(); +c0109327: e8 c7 8b ff ff call c0101ef3 } -c0109a8a: 83 c4 20 add $0x20,%esp -c0109a8d: 5e pop %esi -c0109a8e: 5f pop %edi -c0109a8f: 5d pop %ebp -c0109a90: c3 ret +c010932c: 90 nop +c010932d: 89 ec mov %ebp,%esp +c010932f: 5d pop %ebp +c0109330: c3 ret -c0109a91 : - * match in both memory blocks has a greater value in @v1 than in @v2 - * as if evaluated as unsigned char values; - * - And a value less than zero indicates the opposite. - * */ -int -memcmp(const void *v1, const void *v2, size_t n) { -c0109a91: f3 0f 1e fb endbr32 -c0109a95: 55 push %ebp -c0109a96: 89 e5 mov %esp,%ebp -c0109a98: 83 ec 10 sub $0x10,%esp - const char *s1 = (const char *)v1; -c0109a9b: 8b 45 08 mov 0x8(%ebp),%eax -c0109a9e: 89 45 fc mov %eax,-0x4(%ebp) - const char *s2 = (const char *)v2; -c0109aa1: 8b 45 0c mov 0xc(%ebp),%eax -c0109aa4: 89 45 f8 mov %eax,-0x8(%ebp) - while (n -- > 0) { -c0109aa7: eb 2e jmp c0109ad7 - if (*s1 != *s2) { -c0109aa9: 8b 45 fc mov -0x4(%ebp),%eax -c0109aac: 0f b6 10 movzbl (%eax),%edx -c0109aaf: 8b 45 f8 mov -0x8(%ebp),%eax -c0109ab2: 0f b6 00 movzbl (%eax),%eax -c0109ab5: 38 c2 cmp %al,%dl -c0109ab7: 74 18 je c0109ad1 - return (int)((unsigned char)*s1 - (unsigned char)*s2); -c0109ab9: 8b 45 fc mov -0x4(%ebp),%eax -c0109abc: 0f b6 00 movzbl (%eax),%eax -c0109abf: 0f b6 d0 movzbl %al,%edx -c0109ac2: 8b 45 f8 mov -0x8(%ebp),%eax -c0109ac5: 0f b6 00 movzbl (%eax),%eax -c0109ac8: 0f b6 c0 movzbl %al,%eax -c0109acb: 29 c2 sub %eax,%edx -c0109acd: 89 d0 mov %edx,%eax -c0109acf: eb 18 jmp c0109ae9 +c0109331 : +#include +#include +#include + +void +wakeup_proc(struct proc_struct *proc) { +c0109331: 55 push %ebp +c0109332: 89 e5 mov %esp,%ebp +c0109334: 83 ec 18 sub $0x18,%esp + assert(proc->state != PROC_ZOMBIE && proc->state != PROC_RUNNABLE); +c0109337: 8b 45 08 mov 0x8(%ebp),%eax +c010933a: 8b 00 mov (%eax),%eax +c010933c: 83 f8 03 cmp $0x3,%eax +c010933f: 74 0a je c010934b +c0109341: 8b 45 08 mov 0x8(%ebp),%eax +c0109344: 8b 00 mov (%eax),%eax +c0109346: 83 f8 02 cmp $0x2,%eax +c0109349: 75 24 jne c010936f +c010934b: c7 44 24 0c 54 c1 10 movl $0xc010c154,0xc(%esp) +c0109352: c0 +c0109353: c7 44 24 08 8f c1 10 movl $0xc010c18f,0x8(%esp) +c010935a: c0 +c010935b: c7 44 24 04 09 00 00 movl $0x9,0x4(%esp) +c0109362: 00 +c0109363: c7 04 24 a4 c1 10 c0 movl $0xc010c1a4,(%esp) +c010936a: e8 d6 78 ff ff call c0100c45 <__panic> + proc->state = PROC_RUNNABLE; +c010936f: 8b 45 08 mov 0x8(%ebp),%eax +c0109372: c7 00 02 00 00 00 movl $0x2,(%eax) +} +c0109378: 90 nop +c0109379: 89 ec mov %ebp,%esp +c010937b: 5d pop %ebp +c010937c: c3 ret + +c010937d : + * 如果找到可运行的进程,则选择该进程作为下一个要执行的进程,并进行上下文切换。 + * 如果没有找到可运行的进程,则选择空闲进程作为下一个要执行的进程。 + * 最后,恢复中断状态并退出调度函数。 + */ +void +schedule(void) { +c010937d: 55 push %ebp +c010937e: 89 e5 mov %esp,%ebp +c0109380: 83 ec 38 sub $0x38,%esp + // 保存中断状态标志 + bool intr_flag; + // 定义指向进程列表项的指针 + list_entry_t *le, *last; + // 定义下一个要执行的进程指针,并初始化为NULL + struct proc_struct *next = NULL; +c0109383: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) + // 保存当前中断状态,并禁止中断 + local_intr_save(intr_flag); +c010938a: e8 60 ff ff ff call c01092ef <__intr_save> +c010938f: 89 45 ec mov %eax,-0x14(%ebp) + { + // 标记当前进程不需要重新调度 + current->need_resched = 0; +c0109392: a1 90 c1 12 c0 mov 0xc012c190,%eax +c0109397: c7 40 10 00 00 00 00 movl $0x0,0x10(%eax) + // 确定进程列表的最后一个元素 + last = (current == idleproc) ? &proc_list : &(current->list_link); +c010939e: 8b 15 90 c1 12 c0 mov 0xc012c190,%edx +c01093a4: a1 88 c1 12 c0 mov 0xc012c188,%eax +c01093a9: 39 c2 cmp %eax,%edx +c01093ab: 74 0a je c01093b7 +c01093ad: a1 90 c1 12 c0 mov 0xc012c190,%eax +c01093b2: 83 c0 58 add $0x58,%eax +c01093b5: eb 05 jmp c01093bc +c01093b7: b8 80 c1 12 c0 mov $0xc012c180,%eax +c01093bc: 89 45 e8 mov %eax,-0x18(%ebp) + // 从最后一个元素开始遍历进程列表 + le = last; +c01093bf: 8b 45 e8 mov -0x18(%ebp),%eax +c01093c2: 89 45 f4 mov %eax,-0xc(%ebp) +c01093c5: 8b 45 f4 mov -0xc(%ebp),%eax +c01093c8: 89 45 e4 mov %eax,-0x1c(%ebp) + return listelm->next; +c01093cb: 8b 45 e4 mov -0x1c(%ebp),%eax +c01093ce: 8b 40 04 mov 0x4(%eax),%eax + do { + // 如果不是进程列表的末尾,则继续查找下一个可运行的进程 + if ((le = list_next(le)) != &proc_list) { +c01093d1: 89 45 f4 mov %eax,-0xc(%ebp) +c01093d4: 81 7d f4 80 c1 12 c0 cmpl $0xc012c180,-0xc(%ebp) +c01093db: 74 13 je c01093f0 + // 获取当前列表项对应的进程结构体 + next = le2proc(le, list_link); +c01093dd: 8b 45 f4 mov -0xc(%ebp),%eax +c01093e0: 83 e8 58 sub $0x58,%eax +c01093e3: 89 45 f0 mov %eax,-0x10(%ebp) + // 如果进程处于可运行状态,则停止查找 + if (next->state == PROC_RUNNABLE) { +c01093e6: 8b 45 f0 mov -0x10(%ebp),%eax +c01093e9: 8b 00 mov (%eax),%eax +c01093eb: 83 f8 02 cmp $0x2,%eax +c01093ee: 74 0a je c01093fa + break; + } + } + } while (le != last); +c01093f0: 8b 45 f4 mov -0xc(%ebp),%eax +c01093f3: 3b 45 e8 cmp -0x18(%ebp),%eax +c01093f6: 75 cd jne c01093c5 +c01093f8: eb 01 jmp c01093fb + break; +c01093fa: 90 nop + // 如果没有找到可运行的进程,则选择空闲进程作为下一个要执行的进程 + if (next == NULL || next->state != PROC_RUNNABLE) { +c01093fb: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c01093ff: 74 0a je c010940b +c0109401: 8b 45 f0 mov -0x10(%ebp),%eax +c0109404: 8b 00 mov (%eax),%eax +c0109406: 83 f8 02 cmp $0x2,%eax +c0109409: 74 08 je c0109413 + next = idleproc; +c010940b: a1 88 c1 12 c0 mov 0xc012c188,%eax +c0109410: 89 45 f0 mov %eax,-0x10(%ebp) + } + // 增加下一个要执行的进程的运行次数 + next->runs ++; +c0109413: 8b 45 f0 mov -0x10(%ebp),%eax +c0109416: 8b 40 08 mov 0x8(%eax),%eax +c0109419: 8d 50 01 lea 0x1(%eax),%edx +c010941c: 8b 45 f0 mov -0x10(%ebp),%eax +c010941f: 89 50 08 mov %edx,0x8(%eax) + // 如果下一个要执行的进程不是当前进程,则进行上下文切换 + if (next != current) { +c0109422: a1 90 c1 12 c0 mov 0xc012c190,%eax +c0109427: 39 45 f0 cmp %eax,-0x10(%ebp) +c010942a: 74 0b je c0109437 + proc_run(next); +c010942c: 8b 45 f0 mov -0x10(%ebp),%eax +c010942f: 89 04 24 mov %eax,(%esp) +c0109432: e8 43 f7 ff ff call c0108b7a } - s1 ++, s2 ++; -c0109ad1: ff 45 fc incl -0x4(%ebp) -c0109ad4: ff 45 f8 incl -0x8(%ebp) - while (n -- > 0) { -c0109ad7: 8b 45 10 mov 0x10(%ebp),%eax -c0109ada: 8d 50 ff lea -0x1(%eax),%edx -c0109add: 89 55 10 mov %edx,0x10(%ebp) -c0109ae0: 85 c0 test %eax,%eax -c0109ae2: 75 c5 jne c0109aa9 } - return 0; -c0109ae4: b8 00 00 00 00 mov $0x0,%eax + // 恢复中断状态 + local_intr_restore(intr_flag); +c0109437: 8b 45 ec mov -0x14(%ebp),%eax +c010943a: 89 04 24 mov %eax,(%esp) +c010943d: e8 d9 fe ff ff call c010931b <__intr_restore> } -c0109ae9: c9 leave -c0109aea: c3 ret +c0109442: 90 nop +c0109443: 89 ec mov %ebp,%esp +c0109445: 5d pop %ebp +c0109446: c3 ret -c0109aeb : +c0109447 : + * @bits: the number of bits in a return value + * + * High bits are more random, so we use them. + * */ +uint32_t +hash32(uint32_t val, unsigned int bits) { +c0109447: 55 push %ebp +c0109448: 89 e5 mov %esp,%ebp +c010944a: 83 ec 10 sub $0x10,%esp + uint32_t hash = val * GOLDEN_RATIO_PRIME_32; +c010944d: 8b 45 08 mov 0x8(%ebp),%eax +c0109450: 69 c0 01 00 37 9e imul $0x9e370001,%eax,%eax +c0109456: 89 45 fc mov %eax,-0x4(%ebp) + return (hash >> (32 - bits)); +c0109459: b8 20 00 00 00 mov $0x20,%eax +c010945e: 2b 45 0c sub 0xc(%ebp),%eax +c0109461: 8b 55 fc mov -0x4(%ebp),%edx +c0109464: 88 c1 mov %al,%cl +c0109466: d3 ea shr %cl,%edx +c0109468: 89 d0 mov %edx,%eax +} +c010946a: 89 ec mov %ebp,%esp +c010946c: 5d pop %ebp +c010946d: c3 ret + +c010946e : * @width: maximum number of digits, if the actual width is less than @width, use @padc instead * @padc: character that padded on the left if the actual width is less than @width * */ static void printnum(void (*putch)(int, void*), void *putdat, unsigned long long num, unsigned base, int width, int padc) { -c0109aeb: f3 0f 1e fb endbr32 -c0109aef: 55 push %ebp -c0109af0: 89 e5 mov %esp,%ebp -c0109af2: 83 ec 58 sub $0x58,%esp -c0109af5: 8b 45 10 mov 0x10(%ebp),%eax -c0109af8: 89 45 d0 mov %eax,-0x30(%ebp) -c0109afb: 8b 45 14 mov 0x14(%ebp),%eax -c0109afe: 89 45 d4 mov %eax,-0x2c(%ebp) +c010946e: 55 push %ebp +c010946f: 89 e5 mov %esp,%ebp +c0109471: 83 ec 58 sub $0x58,%esp +c0109474: 8b 45 10 mov 0x10(%ebp),%eax +c0109477: 89 45 d0 mov %eax,-0x30(%ebp) +c010947a: 8b 45 14 mov 0x14(%ebp),%eax +c010947d: 89 45 d4 mov %eax,-0x2c(%ebp) unsigned long long result = num; -c0109b01: 8b 45 d0 mov -0x30(%ebp),%eax -c0109b04: 8b 55 d4 mov -0x2c(%ebp),%edx -c0109b07: 89 45 e8 mov %eax,-0x18(%ebp) -c0109b0a: 89 55 ec mov %edx,-0x14(%ebp) +c0109480: 8b 45 d0 mov -0x30(%ebp),%eax +c0109483: 8b 55 d4 mov -0x2c(%ebp),%edx +c0109486: 89 45 e8 mov %eax,-0x18(%ebp) +c0109489: 89 55 ec mov %edx,-0x14(%ebp) unsigned mod = do_div(result, base); -c0109b0d: 8b 45 18 mov 0x18(%ebp),%eax -c0109b10: 89 45 e4 mov %eax,-0x1c(%ebp) -c0109b13: 8b 45 e8 mov -0x18(%ebp),%eax -c0109b16: 8b 55 ec mov -0x14(%ebp),%edx -c0109b19: 89 45 e0 mov %eax,-0x20(%ebp) -c0109b1c: 89 55 f0 mov %edx,-0x10(%ebp) -c0109b1f: 8b 45 f0 mov -0x10(%ebp),%eax -c0109b22: 89 45 f4 mov %eax,-0xc(%ebp) -c0109b25: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) -c0109b29: 74 1c je c0109b47 -c0109b2b: 8b 45 f0 mov -0x10(%ebp),%eax -c0109b2e: ba 00 00 00 00 mov $0x0,%edx -c0109b33: f7 75 e4 divl -0x1c(%ebp) -c0109b36: 89 55 f4 mov %edx,-0xc(%ebp) -c0109b39: 8b 45 f0 mov -0x10(%ebp),%eax -c0109b3c: ba 00 00 00 00 mov $0x0,%edx -c0109b41: f7 75 e4 divl -0x1c(%ebp) -c0109b44: 89 45 f0 mov %eax,-0x10(%ebp) -c0109b47: 8b 45 e0 mov -0x20(%ebp),%eax -c0109b4a: 8b 55 f4 mov -0xc(%ebp),%edx -c0109b4d: f7 75 e4 divl -0x1c(%ebp) -c0109b50: 89 45 e0 mov %eax,-0x20(%ebp) -c0109b53: 89 55 dc mov %edx,-0x24(%ebp) -c0109b56: 8b 45 e0 mov -0x20(%ebp),%eax -c0109b59: 8b 55 f0 mov -0x10(%ebp),%edx -c0109b5c: 89 45 e8 mov %eax,-0x18(%ebp) -c0109b5f: 89 55 ec mov %edx,-0x14(%ebp) -c0109b62: 8b 45 dc mov -0x24(%ebp),%eax -c0109b65: 89 45 d8 mov %eax,-0x28(%ebp) +c010948c: 8b 45 18 mov 0x18(%ebp),%eax +c010948f: 89 45 e4 mov %eax,-0x1c(%ebp) +c0109492: 8b 45 e8 mov -0x18(%ebp),%eax +c0109495: 8b 55 ec mov -0x14(%ebp),%edx +c0109498: 89 45 e0 mov %eax,-0x20(%ebp) +c010949b: 89 55 f0 mov %edx,-0x10(%ebp) +c010949e: 8b 45 f0 mov -0x10(%ebp),%eax +c01094a1: 89 45 f4 mov %eax,-0xc(%ebp) +c01094a4: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) +c01094a8: 74 1c je c01094c6 +c01094aa: 8b 45 f0 mov -0x10(%ebp),%eax +c01094ad: ba 00 00 00 00 mov $0x0,%edx +c01094b2: f7 75 e4 divl -0x1c(%ebp) +c01094b5: 89 55 f4 mov %edx,-0xc(%ebp) +c01094b8: 8b 45 f0 mov -0x10(%ebp),%eax +c01094bb: ba 00 00 00 00 mov $0x0,%edx +c01094c0: f7 75 e4 divl -0x1c(%ebp) +c01094c3: 89 45 f0 mov %eax,-0x10(%ebp) +c01094c6: 8b 45 e0 mov -0x20(%ebp),%eax +c01094c9: 8b 55 f4 mov -0xc(%ebp),%edx +c01094cc: f7 75 e4 divl -0x1c(%ebp) +c01094cf: 89 45 e0 mov %eax,-0x20(%ebp) +c01094d2: 89 55 dc mov %edx,-0x24(%ebp) +c01094d5: 8b 45 e0 mov -0x20(%ebp),%eax +c01094d8: 8b 55 f0 mov -0x10(%ebp),%edx +c01094db: 89 45 e8 mov %eax,-0x18(%ebp) +c01094de: 89 55 ec mov %edx,-0x14(%ebp) +c01094e1: 8b 45 dc mov -0x24(%ebp),%eax +c01094e4: 89 45 d8 mov %eax,-0x28(%ebp) // first recursively print all preceding (more significant) digits if (num >= base) { -c0109b68: 8b 45 18 mov 0x18(%ebp),%eax -c0109b6b: ba 00 00 00 00 mov $0x0,%edx -c0109b70: 8b 4d d4 mov -0x2c(%ebp),%ecx -c0109b73: 39 45 d0 cmp %eax,-0x30(%ebp) -c0109b76: 19 d1 sbb %edx,%ecx -c0109b78: 72 4c jb c0109bc6 +c01094e7: 8b 45 18 mov 0x18(%ebp),%eax +c01094ea: ba 00 00 00 00 mov $0x0,%edx +c01094ef: 8b 4d d4 mov -0x2c(%ebp),%ecx +c01094f2: 39 45 d0 cmp %eax,-0x30(%ebp) +c01094f5: 19 d1 sbb %edx,%ecx +c01094f7: 72 4c jb c0109545 printnum(putch, putdat, result, base, width - 1, padc); -c0109b7a: 8b 45 1c mov 0x1c(%ebp),%eax -c0109b7d: 8d 50 ff lea -0x1(%eax),%edx -c0109b80: 8b 45 20 mov 0x20(%ebp),%eax -c0109b83: 89 44 24 18 mov %eax,0x18(%esp) -c0109b87: 89 54 24 14 mov %edx,0x14(%esp) -c0109b8b: 8b 45 18 mov 0x18(%ebp),%eax -c0109b8e: 89 44 24 10 mov %eax,0x10(%esp) -c0109b92: 8b 45 e8 mov -0x18(%ebp),%eax -c0109b95: 8b 55 ec mov -0x14(%ebp),%edx -c0109b98: 89 44 24 08 mov %eax,0x8(%esp) -c0109b9c: 89 54 24 0c mov %edx,0xc(%esp) -c0109ba0: 8b 45 0c mov 0xc(%ebp),%eax -c0109ba3: 89 44 24 04 mov %eax,0x4(%esp) -c0109ba7: 8b 45 08 mov 0x8(%ebp),%eax -c0109baa: 89 04 24 mov %eax,(%esp) -c0109bad: e8 39 ff ff ff call c0109aeb -c0109bb2: eb 1b jmp c0109bcf +c01094f9: 8b 45 1c mov 0x1c(%ebp),%eax +c01094fc: 8d 50 ff lea -0x1(%eax),%edx +c01094ff: 8b 45 20 mov 0x20(%ebp),%eax +c0109502: 89 44 24 18 mov %eax,0x18(%esp) +c0109506: 89 54 24 14 mov %edx,0x14(%esp) +c010950a: 8b 45 18 mov 0x18(%ebp),%eax +c010950d: 89 44 24 10 mov %eax,0x10(%esp) +c0109511: 8b 45 e8 mov -0x18(%ebp),%eax +c0109514: 8b 55 ec mov -0x14(%ebp),%edx +c0109517: 89 44 24 08 mov %eax,0x8(%esp) +c010951b: 89 54 24 0c mov %edx,0xc(%esp) +c010951f: 8b 45 0c mov 0xc(%ebp),%eax +c0109522: 89 44 24 04 mov %eax,0x4(%esp) +c0109526: 8b 45 08 mov 0x8(%ebp),%eax +c0109529: 89 04 24 mov %eax,(%esp) +c010952c: e8 3d ff ff ff call c010946e +c0109531: eb 1b jmp c010954e } else { // print any needed pad characters before first digit while (-- width > 0) putch(padc, putdat); -c0109bb4: 8b 45 0c mov 0xc(%ebp),%eax -c0109bb7: 89 44 24 04 mov %eax,0x4(%esp) -c0109bbb: 8b 45 20 mov 0x20(%ebp),%eax -c0109bbe: 89 04 24 mov %eax,(%esp) -c0109bc1: 8b 45 08 mov 0x8(%ebp),%eax -c0109bc4: ff d0 call *%eax +c0109533: 8b 45 0c mov 0xc(%ebp),%eax +c0109536: 89 44 24 04 mov %eax,0x4(%esp) +c010953a: 8b 45 20 mov 0x20(%ebp),%eax +c010953d: 89 04 24 mov %eax,(%esp) +c0109540: 8b 45 08 mov 0x8(%ebp),%eax +c0109543: ff d0 call *%eax while (-- width > 0) -c0109bc6: ff 4d 1c decl 0x1c(%ebp) -c0109bc9: 83 7d 1c 00 cmpl $0x0,0x1c(%ebp) -c0109bcd: 7f e5 jg c0109bb4 +c0109545: ff 4d 1c decl 0x1c(%ebp) +c0109548: 83 7d 1c 00 cmpl $0x0,0x1c(%ebp) +c010954c: 7f e5 jg c0109533 } // then print this (the least significant) digit putch("0123456789abcdef"[mod], putdat); -c0109bcf: 8b 45 d8 mov -0x28(%ebp),%eax -c0109bd2: 05 60 c4 10 c0 add $0xc010c460,%eax -c0109bd7: 0f b6 00 movzbl (%eax),%eax -c0109bda: 0f be c0 movsbl %al,%eax -c0109bdd: 8b 55 0c mov 0xc(%ebp),%edx -c0109be0: 89 54 24 04 mov %edx,0x4(%esp) -c0109be4: 89 04 24 mov %eax,(%esp) -c0109be7: 8b 45 08 mov 0x8(%ebp),%eax -c0109bea: ff d0 call *%eax -} -c0109bec: 90 nop -c0109bed: c9 leave -c0109bee: c3 ret - -c0109bef : +c010954e: 8b 45 d8 mov -0x28(%ebp),%eax +c0109551: 05 3c c2 10 c0 add $0xc010c23c,%eax +c0109556: 0f b6 00 movzbl (%eax),%eax +c0109559: 0f be c0 movsbl %al,%eax +c010955c: 8b 55 0c mov 0xc(%ebp),%edx +c010955f: 89 54 24 04 mov %edx,0x4(%esp) +c0109563: 89 04 24 mov %eax,(%esp) +c0109566: 8b 45 08 mov 0x8(%ebp),%eax +c0109569: ff d0 call *%eax +} +c010956b: 90 nop +c010956c: 89 ec mov %ebp,%esp +c010956e: 5d pop %ebp +c010956f: c3 ret + +c0109570 : * getuint - get an unsigned int of various possible sizes from a varargs list * @ap: a varargs list pointer * @lflag: determines the size of the vararg that @ap points to * */ static unsigned long long getuint(va_list *ap, int lflag) { -c0109bef: f3 0f 1e fb endbr32 -c0109bf3: 55 push %ebp -c0109bf4: 89 e5 mov %esp,%ebp +c0109570: 55 push %ebp +c0109571: 89 e5 mov %esp,%ebp if (lflag >= 2) { -c0109bf6: 83 7d 0c 01 cmpl $0x1,0xc(%ebp) -c0109bfa: 7e 14 jle c0109c10 +c0109573: 83 7d 0c 01 cmpl $0x1,0xc(%ebp) +c0109577: 7e 14 jle c010958d return va_arg(*ap, unsigned long long); -c0109bfc: 8b 45 08 mov 0x8(%ebp),%eax -c0109bff: 8b 00 mov (%eax),%eax -c0109c01: 8d 48 08 lea 0x8(%eax),%ecx -c0109c04: 8b 55 08 mov 0x8(%ebp),%edx -c0109c07: 89 0a mov %ecx,(%edx) -c0109c09: 8b 50 04 mov 0x4(%eax),%edx -c0109c0c: 8b 00 mov (%eax),%eax -c0109c0e: eb 30 jmp c0109c40 +c0109579: 8b 45 08 mov 0x8(%ebp),%eax +c010957c: 8b 00 mov (%eax),%eax +c010957e: 8d 48 08 lea 0x8(%eax),%ecx +c0109581: 8b 55 08 mov 0x8(%ebp),%edx +c0109584: 89 0a mov %ecx,(%edx) +c0109586: 8b 50 04 mov 0x4(%eax),%edx +c0109589: 8b 00 mov (%eax),%eax +c010958b: eb 30 jmp c01095bd } else if (lflag) { -c0109c10: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) -c0109c14: 74 16 je c0109c2c +c010958d: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) +c0109591: 74 16 je c01095a9 return va_arg(*ap, unsigned long); -c0109c16: 8b 45 08 mov 0x8(%ebp),%eax -c0109c19: 8b 00 mov (%eax),%eax -c0109c1b: 8d 48 04 lea 0x4(%eax),%ecx -c0109c1e: 8b 55 08 mov 0x8(%ebp),%edx -c0109c21: 89 0a mov %ecx,(%edx) -c0109c23: 8b 00 mov (%eax),%eax -c0109c25: ba 00 00 00 00 mov $0x0,%edx -c0109c2a: eb 14 jmp c0109c40 +c0109593: 8b 45 08 mov 0x8(%ebp),%eax +c0109596: 8b 00 mov (%eax),%eax +c0109598: 8d 48 04 lea 0x4(%eax),%ecx +c010959b: 8b 55 08 mov 0x8(%ebp),%edx +c010959e: 89 0a mov %ecx,(%edx) +c01095a0: 8b 00 mov (%eax),%eax +c01095a2: ba 00 00 00 00 mov $0x0,%edx +c01095a7: eb 14 jmp c01095bd } else { return va_arg(*ap, unsigned int); -c0109c2c: 8b 45 08 mov 0x8(%ebp),%eax -c0109c2f: 8b 00 mov (%eax),%eax -c0109c31: 8d 48 04 lea 0x4(%eax),%ecx -c0109c34: 8b 55 08 mov 0x8(%ebp),%edx -c0109c37: 89 0a mov %ecx,(%edx) -c0109c39: 8b 00 mov (%eax),%eax -c0109c3b: ba 00 00 00 00 mov $0x0,%edx +c01095a9: 8b 45 08 mov 0x8(%ebp),%eax +c01095ac: 8b 00 mov (%eax),%eax +c01095ae: 8d 48 04 lea 0x4(%eax),%ecx +c01095b1: 8b 55 08 mov 0x8(%ebp),%edx +c01095b4: 89 0a mov %ecx,(%edx) +c01095b6: 8b 00 mov (%eax),%eax +c01095b8: ba 00 00 00 00 mov $0x0,%edx } } -c0109c40: 5d pop %ebp -c0109c41: c3 ret +c01095bd: 5d pop %ebp +c01095be: c3 ret -c0109c42 : +c01095bf : * getint - same as getuint but signed, we can't use getuint because of sign extension * @ap: a varargs list pointer * @lflag: determines the size of the vararg that @ap points to * */ static long long getint(va_list *ap, int lflag) { -c0109c42: f3 0f 1e fb endbr32 -c0109c46: 55 push %ebp -c0109c47: 89 e5 mov %esp,%ebp +c01095bf: 55 push %ebp +c01095c0: 89 e5 mov %esp,%ebp if (lflag >= 2) { -c0109c49: 83 7d 0c 01 cmpl $0x1,0xc(%ebp) -c0109c4d: 7e 14 jle c0109c63 +c01095c2: 83 7d 0c 01 cmpl $0x1,0xc(%ebp) +c01095c6: 7e 14 jle c01095dc return va_arg(*ap, long long); -c0109c4f: 8b 45 08 mov 0x8(%ebp),%eax -c0109c52: 8b 00 mov (%eax),%eax -c0109c54: 8d 48 08 lea 0x8(%eax),%ecx -c0109c57: 8b 55 08 mov 0x8(%ebp),%edx -c0109c5a: 89 0a mov %ecx,(%edx) -c0109c5c: 8b 50 04 mov 0x4(%eax),%edx -c0109c5f: 8b 00 mov (%eax),%eax -c0109c61: eb 28 jmp c0109c8b +c01095c8: 8b 45 08 mov 0x8(%ebp),%eax +c01095cb: 8b 00 mov (%eax),%eax +c01095cd: 8d 48 08 lea 0x8(%eax),%ecx +c01095d0: 8b 55 08 mov 0x8(%ebp),%edx +c01095d3: 89 0a mov %ecx,(%edx) +c01095d5: 8b 50 04 mov 0x4(%eax),%edx +c01095d8: 8b 00 mov (%eax),%eax +c01095da: eb 28 jmp c0109604 } else if (lflag) { -c0109c63: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) -c0109c67: 74 12 je c0109c7b +c01095dc: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) +c01095e0: 74 12 je c01095f4 return va_arg(*ap, long); -c0109c69: 8b 45 08 mov 0x8(%ebp),%eax -c0109c6c: 8b 00 mov (%eax),%eax -c0109c6e: 8d 48 04 lea 0x4(%eax),%ecx -c0109c71: 8b 55 08 mov 0x8(%ebp),%edx -c0109c74: 89 0a mov %ecx,(%edx) -c0109c76: 8b 00 mov (%eax),%eax -c0109c78: 99 cltd -c0109c79: eb 10 jmp c0109c8b +c01095e2: 8b 45 08 mov 0x8(%ebp),%eax +c01095e5: 8b 00 mov (%eax),%eax +c01095e7: 8d 48 04 lea 0x4(%eax),%ecx +c01095ea: 8b 55 08 mov 0x8(%ebp),%edx +c01095ed: 89 0a mov %ecx,(%edx) +c01095ef: 8b 00 mov (%eax),%eax +c01095f1: 99 cltd +c01095f2: eb 10 jmp c0109604 } else { return va_arg(*ap, int); -c0109c7b: 8b 45 08 mov 0x8(%ebp),%eax -c0109c7e: 8b 00 mov (%eax),%eax -c0109c80: 8d 48 04 lea 0x4(%eax),%ecx -c0109c83: 8b 55 08 mov 0x8(%ebp),%edx -c0109c86: 89 0a mov %ecx,(%edx) -c0109c88: 8b 00 mov (%eax),%eax -c0109c8a: 99 cltd +c01095f4: 8b 45 08 mov 0x8(%ebp),%eax +c01095f7: 8b 00 mov (%eax),%eax +c01095f9: 8d 48 04 lea 0x4(%eax),%ecx +c01095fc: 8b 55 08 mov 0x8(%ebp),%edx +c01095ff: 89 0a mov %ecx,(%edx) +c0109601: 8b 00 mov (%eax),%eax +c0109603: 99 cltd } } -c0109c8b: 5d pop %ebp -c0109c8c: c3 ret +c0109604: 5d pop %ebp +c0109605: c3 ret -c0109c8d : +c0109606 : * @putch: specified putch function, print a single character * @putdat: used by @putch function * @fmt: the format string to use * */ void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) { -c0109c8d: f3 0f 1e fb endbr32 -c0109c91: 55 push %ebp -c0109c92: 89 e5 mov %esp,%ebp -c0109c94: 83 ec 28 sub $0x28,%esp +c0109606: 55 push %ebp +c0109607: 89 e5 mov %esp,%ebp +c0109609: 83 ec 28 sub $0x28,%esp va_list ap; va_start(ap, fmt); -c0109c97: 8d 45 14 lea 0x14(%ebp),%eax -c0109c9a: 89 45 f4 mov %eax,-0xc(%ebp) +c010960c: 8d 45 14 lea 0x14(%ebp),%eax +c010960f: 89 45 f4 mov %eax,-0xc(%ebp) vprintfmt(putch, putdat, fmt, ap); -c0109c9d: 8b 45 f4 mov -0xc(%ebp),%eax -c0109ca0: 89 44 24 0c mov %eax,0xc(%esp) -c0109ca4: 8b 45 10 mov 0x10(%ebp),%eax -c0109ca7: 89 44 24 08 mov %eax,0x8(%esp) -c0109cab: 8b 45 0c mov 0xc(%ebp),%eax -c0109cae: 89 44 24 04 mov %eax,0x4(%esp) -c0109cb2: 8b 45 08 mov 0x8(%ebp),%eax -c0109cb5: 89 04 24 mov %eax,(%esp) -c0109cb8: e8 03 00 00 00 call c0109cc0 +c0109612: 8b 45 f4 mov -0xc(%ebp),%eax +c0109615: 89 44 24 0c mov %eax,0xc(%esp) +c0109619: 8b 45 10 mov 0x10(%ebp),%eax +c010961c: 89 44 24 08 mov %eax,0x8(%esp) +c0109620: 8b 45 0c mov 0xc(%ebp),%eax +c0109623: 89 44 24 04 mov %eax,0x4(%esp) +c0109627: 8b 45 08 mov 0x8(%ebp),%eax +c010962a: 89 04 24 mov %eax,(%esp) +c010962d: e8 05 00 00 00 call c0109637 va_end(ap); } -c0109cbd: 90 nop -c0109cbe: c9 leave -c0109cbf: c3 ret +c0109632: 90 nop +c0109633: 89 ec mov %ebp,%esp +c0109635: 5d pop %ebp +c0109636: c3 ret -c0109cc0 : +c0109637 : * * Call this function if you are already dealing with a va_list. * Or you probably want printfmt() instead. * */ void vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap) { -c0109cc0: f3 0f 1e fb endbr32 -c0109cc4: 55 push %ebp -c0109cc5: 89 e5 mov %esp,%ebp -c0109cc7: 56 push %esi -c0109cc8: 53 push %ebx -c0109cc9: 83 ec 40 sub $0x40,%esp +c0109637: 55 push %ebp +c0109638: 89 e5 mov %esp,%ebp +c010963a: 56 push %esi +c010963b: 53 push %ebx +c010963c: 83 ec 40 sub $0x40,%esp register int ch, err; unsigned long long num; int base, width, precision, lflag, altflag; while (1) { while ((ch = *(unsigned char *)fmt ++) != '%') { -c0109ccc: eb 17 jmp c0109ce5 +c010963f: eb 17 jmp c0109658 if (ch == '\0') { -c0109cce: 85 db test %ebx,%ebx -c0109cd0: 0f 84 c0 03 00 00 je c010a096 +c0109641: 85 db test %ebx,%ebx +c0109643: 0f 84 bf 03 00 00 je c0109a08 return; } putch(ch, putdat); -c0109cd6: 8b 45 0c mov 0xc(%ebp),%eax -c0109cd9: 89 44 24 04 mov %eax,0x4(%esp) -c0109cdd: 89 1c 24 mov %ebx,(%esp) -c0109ce0: 8b 45 08 mov 0x8(%ebp),%eax -c0109ce3: ff d0 call *%eax +c0109649: 8b 45 0c mov 0xc(%ebp),%eax +c010964c: 89 44 24 04 mov %eax,0x4(%esp) +c0109650: 89 1c 24 mov %ebx,(%esp) +c0109653: 8b 45 08 mov 0x8(%ebp),%eax +c0109656: ff d0 call *%eax while ((ch = *(unsigned char *)fmt ++) != '%') { -c0109ce5: 8b 45 10 mov 0x10(%ebp),%eax -c0109ce8: 8d 50 01 lea 0x1(%eax),%edx -c0109ceb: 89 55 10 mov %edx,0x10(%ebp) -c0109cee: 0f b6 00 movzbl (%eax),%eax -c0109cf1: 0f b6 d8 movzbl %al,%ebx -c0109cf4: 83 fb 25 cmp $0x25,%ebx -c0109cf7: 75 d5 jne c0109cce +c0109658: 8b 45 10 mov 0x10(%ebp),%eax +c010965b: 8d 50 01 lea 0x1(%eax),%edx +c010965e: 89 55 10 mov %edx,0x10(%ebp) +c0109661: 0f b6 00 movzbl (%eax),%eax +c0109664: 0f b6 d8 movzbl %al,%ebx +c0109667: 83 fb 25 cmp $0x25,%ebx +c010966a: 75 d5 jne c0109641 } // Process a %-escape sequence char padc = ' '; -c0109cf9: c6 45 db 20 movb $0x20,-0x25(%ebp) +c010966c: c6 45 db 20 movb $0x20,-0x25(%ebp) width = precision = -1; -c0109cfd: c7 45 e4 ff ff ff ff movl $0xffffffff,-0x1c(%ebp) -c0109d04: 8b 45 e4 mov -0x1c(%ebp),%eax -c0109d07: 89 45 e8 mov %eax,-0x18(%ebp) +c0109670: c7 45 e4 ff ff ff ff movl $0xffffffff,-0x1c(%ebp) +c0109677: 8b 45 e4 mov -0x1c(%ebp),%eax +c010967a: 89 45 e8 mov %eax,-0x18(%ebp) lflag = altflag = 0; -c0109d0a: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) -c0109d11: 8b 45 dc mov -0x24(%ebp),%eax -c0109d14: 89 45 e0 mov %eax,-0x20(%ebp) +c010967d: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) +c0109684: 8b 45 dc mov -0x24(%ebp),%eax +c0109687: 89 45 e0 mov %eax,-0x20(%ebp) reswitch: switch (ch = *(unsigned char *)fmt ++) { -c0109d17: 8b 45 10 mov 0x10(%ebp),%eax -c0109d1a: 8d 50 01 lea 0x1(%eax),%edx -c0109d1d: 89 55 10 mov %edx,0x10(%ebp) -c0109d20: 0f b6 00 movzbl (%eax),%eax -c0109d23: 0f b6 d8 movzbl %al,%ebx -c0109d26: 8d 43 dd lea -0x23(%ebx),%eax -c0109d29: 83 f8 55 cmp $0x55,%eax -c0109d2c: 0f 87 38 03 00 00 ja c010a06a -c0109d32: 8b 04 85 84 c4 10 c0 mov -0x3fef3b7c(,%eax,4),%eax -c0109d39: 3e ff e0 notrack jmp *%eax +c010968a: 8b 45 10 mov 0x10(%ebp),%eax +c010968d: 8d 50 01 lea 0x1(%eax),%edx +c0109690: 89 55 10 mov %edx,0x10(%ebp) +c0109693: 0f b6 00 movzbl (%eax),%eax +c0109696: 0f b6 d8 movzbl %al,%ebx +c0109699: 8d 43 dd lea -0x23(%ebx),%eax +c010969c: 83 f8 55 cmp $0x55,%eax +c010969f: 0f 87 37 03 00 00 ja c01099dc +c01096a5: 8b 04 85 60 c2 10 c0 mov -0x3fef3da0(,%eax,4),%eax +c01096ac: ff e0 jmp *%eax // flag to pad on the right case '-': padc = '-'; -c0109d3c: c6 45 db 2d movb $0x2d,-0x25(%ebp) +c01096ae: c6 45 db 2d movb $0x2d,-0x25(%ebp) goto reswitch; -c0109d40: eb d5 jmp c0109d17 +c01096b2: eb d6 jmp c010968a // flag to pad with 0's instead of spaces case '0': padc = '0'; -c0109d42: c6 45 db 30 movb $0x30,-0x25(%ebp) +c01096b4: c6 45 db 30 movb $0x30,-0x25(%ebp) goto reswitch; -c0109d46: eb cf jmp c0109d17 +c01096b8: eb d0 jmp c010968a // width field case '1' ... '9': for (precision = 0; ; ++ fmt) { -c0109d48: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) +c01096ba: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) precision = precision * 10 + ch - '0'; -c0109d4f: 8b 55 e4 mov -0x1c(%ebp),%edx -c0109d52: 89 d0 mov %edx,%eax -c0109d54: c1 e0 02 shl $0x2,%eax -c0109d57: 01 d0 add %edx,%eax -c0109d59: 01 c0 add %eax,%eax -c0109d5b: 01 d8 add %ebx,%eax -c0109d5d: 83 e8 30 sub $0x30,%eax -c0109d60: 89 45 e4 mov %eax,-0x1c(%ebp) +c01096c1: 8b 55 e4 mov -0x1c(%ebp),%edx +c01096c4: 89 d0 mov %edx,%eax +c01096c6: c1 e0 02 shl $0x2,%eax +c01096c9: 01 d0 add %edx,%eax +c01096cb: 01 c0 add %eax,%eax +c01096cd: 01 d8 add %ebx,%eax +c01096cf: 83 e8 30 sub $0x30,%eax +c01096d2: 89 45 e4 mov %eax,-0x1c(%ebp) ch = *fmt; -c0109d63: 8b 45 10 mov 0x10(%ebp),%eax -c0109d66: 0f b6 00 movzbl (%eax),%eax -c0109d69: 0f be d8 movsbl %al,%ebx +c01096d5: 8b 45 10 mov 0x10(%ebp),%eax +c01096d8: 0f b6 00 movzbl (%eax),%eax +c01096db: 0f be d8 movsbl %al,%ebx if (ch < '0' || ch > '9') { -c0109d6c: 83 fb 2f cmp $0x2f,%ebx -c0109d6f: 7e 38 jle c0109da9 -c0109d71: 83 fb 39 cmp $0x39,%ebx -c0109d74: 7f 33 jg c0109da9 +c01096de: 83 fb 2f cmp $0x2f,%ebx +c01096e1: 7e 38 jle c010971b +c01096e3: 83 fb 39 cmp $0x39,%ebx +c01096e6: 7f 33 jg c010971b for (precision = 0; ; ++ fmt) { -c0109d76: ff 45 10 incl 0x10(%ebp) +c01096e8: ff 45 10 incl 0x10(%ebp) precision = precision * 10 + ch - '0'; -c0109d79: eb d4 jmp c0109d4f +c01096eb: eb d4 jmp c01096c1 } } goto process_precision; case '*': precision = va_arg(ap, int); -c0109d7b: 8b 45 14 mov 0x14(%ebp),%eax -c0109d7e: 8d 50 04 lea 0x4(%eax),%edx -c0109d81: 89 55 14 mov %edx,0x14(%ebp) -c0109d84: 8b 00 mov (%eax),%eax -c0109d86: 89 45 e4 mov %eax,-0x1c(%ebp) +c01096ed: 8b 45 14 mov 0x14(%ebp),%eax +c01096f0: 8d 50 04 lea 0x4(%eax),%edx +c01096f3: 89 55 14 mov %edx,0x14(%ebp) +c01096f6: 8b 00 mov (%eax),%eax +c01096f8: 89 45 e4 mov %eax,-0x1c(%ebp) goto process_precision; -c0109d89: eb 1f jmp c0109daa +c01096fb: eb 1f jmp c010971c case '.': if (width < 0) -c0109d8b: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) -c0109d8f: 79 86 jns c0109d17 +c01096fd: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) +c0109701: 79 87 jns c010968a width = 0; -c0109d91: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp) +c0109703: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp) goto reswitch; -c0109d98: e9 7a ff ff ff jmp c0109d17 +c010970a: e9 7b ff ff ff jmp c010968a case '#': altflag = 1; -c0109d9d: c7 45 dc 01 00 00 00 movl $0x1,-0x24(%ebp) +c010970f: c7 45 dc 01 00 00 00 movl $0x1,-0x24(%ebp) goto reswitch; -c0109da4: e9 6e ff ff ff jmp c0109d17 +c0109716: e9 6f ff ff ff jmp c010968a goto process_precision; -c0109da9: 90 nop +c010971b: 90 nop process_precision: if (width < 0) -c0109daa: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) -c0109dae: 0f 89 63 ff ff ff jns c0109d17 +c010971c: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) +c0109720: 0f 89 64 ff ff ff jns c010968a width = precision, precision = -1; -c0109db4: 8b 45 e4 mov -0x1c(%ebp),%eax -c0109db7: 89 45 e8 mov %eax,-0x18(%ebp) -c0109dba: c7 45 e4 ff ff ff ff movl $0xffffffff,-0x1c(%ebp) +c0109726: 8b 45 e4 mov -0x1c(%ebp),%eax +c0109729: 89 45 e8 mov %eax,-0x18(%ebp) +c010972c: c7 45 e4 ff ff ff ff movl $0xffffffff,-0x1c(%ebp) goto reswitch; -c0109dc1: e9 51 ff ff ff jmp c0109d17 +c0109733: e9 52 ff ff ff jmp c010968a // long flag (doubled for long long) case 'l': lflag ++; -c0109dc6: ff 45 e0 incl -0x20(%ebp) +c0109738: ff 45 e0 incl -0x20(%ebp) goto reswitch; -c0109dc9: e9 49 ff ff ff jmp c0109d17 +c010973b: e9 4a ff ff ff jmp c010968a // character case 'c': putch(va_arg(ap, int), putdat); -c0109dce: 8b 45 14 mov 0x14(%ebp),%eax -c0109dd1: 8d 50 04 lea 0x4(%eax),%edx -c0109dd4: 89 55 14 mov %edx,0x14(%ebp) -c0109dd7: 8b 00 mov (%eax),%eax -c0109dd9: 8b 55 0c mov 0xc(%ebp),%edx -c0109ddc: 89 54 24 04 mov %edx,0x4(%esp) -c0109de0: 89 04 24 mov %eax,(%esp) -c0109de3: 8b 45 08 mov 0x8(%ebp),%eax -c0109de6: ff d0 call *%eax +c0109740: 8b 45 14 mov 0x14(%ebp),%eax +c0109743: 8d 50 04 lea 0x4(%eax),%edx +c0109746: 89 55 14 mov %edx,0x14(%ebp) +c0109749: 8b 00 mov (%eax),%eax +c010974b: 8b 55 0c mov 0xc(%ebp),%edx +c010974e: 89 54 24 04 mov %edx,0x4(%esp) +c0109752: 89 04 24 mov %eax,(%esp) +c0109755: 8b 45 08 mov 0x8(%ebp),%eax +c0109758: ff d0 call *%eax break; -c0109de8: e9 a4 02 00 00 jmp c010a091 +c010975a: e9 a4 02 00 00 jmp c0109a03 // error message case 'e': err = va_arg(ap, int); -c0109ded: 8b 45 14 mov 0x14(%ebp),%eax -c0109df0: 8d 50 04 lea 0x4(%eax),%edx -c0109df3: 89 55 14 mov %edx,0x14(%ebp) -c0109df6: 8b 18 mov (%eax),%ebx +c010975f: 8b 45 14 mov 0x14(%ebp),%eax +c0109762: 8d 50 04 lea 0x4(%eax),%edx +c0109765: 89 55 14 mov %edx,0x14(%ebp) +c0109768: 8b 18 mov (%eax),%ebx if (err < 0) { -c0109df8: 85 db test %ebx,%ebx -c0109dfa: 79 02 jns c0109dfe +c010976a: 85 db test %ebx,%ebx +c010976c: 79 02 jns c0109770 err = -err; -c0109dfc: f7 db neg %ebx +c010976e: f7 db neg %ebx } if (err > MAXERROR || (p = error_string[err]) == NULL) { -c0109dfe: 83 fb 06 cmp $0x6,%ebx -c0109e01: 7f 0b jg c0109e0e -c0109e03: 8b 34 9d 44 c4 10 c0 mov -0x3fef3bbc(,%ebx,4),%esi -c0109e0a: 85 f6 test %esi,%esi -c0109e0c: 75 23 jne c0109e31 +c0109770: 83 fb 06 cmp $0x6,%ebx +c0109773: 7f 0b jg c0109780 +c0109775: 8b 34 9d 20 c2 10 c0 mov -0x3fef3de0(,%ebx,4),%esi +c010977c: 85 f6 test %esi,%esi +c010977e: 75 23 jne c01097a3 printfmt(putch, putdat, "error %d", err); -c0109e0e: 89 5c 24 0c mov %ebx,0xc(%esp) -c0109e12: c7 44 24 08 71 c4 10 movl $0xc010c471,0x8(%esp) -c0109e19: c0 -c0109e1a: 8b 45 0c mov 0xc(%ebp),%eax -c0109e1d: 89 44 24 04 mov %eax,0x4(%esp) -c0109e21: 8b 45 08 mov 0x8(%ebp),%eax -c0109e24: 89 04 24 mov %eax,(%esp) -c0109e27: e8 61 fe ff ff call c0109c8d +c0109780: 89 5c 24 0c mov %ebx,0xc(%esp) +c0109784: c7 44 24 08 4d c2 10 movl $0xc010c24d,0x8(%esp) +c010978b: c0 +c010978c: 8b 45 0c mov 0xc(%ebp),%eax +c010978f: 89 44 24 04 mov %eax,0x4(%esp) +c0109793: 8b 45 08 mov 0x8(%ebp),%eax +c0109796: 89 04 24 mov %eax,(%esp) +c0109799: e8 68 fe ff ff call c0109606 } else { printfmt(putch, putdat, "%s", p); } break; -c0109e2c: e9 60 02 00 00 jmp c010a091 +c010979e: e9 60 02 00 00 jmp c0109a03 printfmt(putch, putdat, "%s", p); -c0109e31: 89 74 24 0c mov %esi,0xc(%esp) -c0109e35: c7 44 24 08 7a c4 10 movl $0xc010c47a,0x8(%esp) -c0109e3c: c0 -c0109e3d: 8b 45 0c mov 0xc(%ebp),%eax -c0109e40: 89 44 24 04 mov %eax,0x4(%esp) -c0109e44: 8b 45 08 mov 0x8(%ebp),%eax -c0109e47: 89 04 24 mov %eax,(%esp) -c0109e4a: e8 3e fe ff ff call c0109c8d +c01097a3: 89 74 24 0c mov %esi,0xc(%esp) +c01097a7: c7 44 24 08 56 c2 10 movl $0xc010c256,0x8(%esp) +c01097ae: c0 +c01097af: 8b 45 0c mov 0xc(%ebp),%eax +c01097b2: 89 44 24 04 mov %eax,0x4(%esp) +c01097b6: 8b 45 08 mov 0x8(%ebp),%eax +c01097b9: 89 04 24 mov %eax,(%esp) +c01097bc: e8 45 fe ff ff call c0109606 break; -c0109e4f: e9 3d 02 00 00 jmp c010a091 +c01097c1: e9 3d 02 00 00 jmp c0109a03 // string case 's': if ((p = va_arg(ap, char *)) == NULL) { -c0109e54: 8b 45 14 mov 0x14(%ebp),%eax -c0109e57: 8d 50 04 lea 0x4(%eax),%edx -c0109e5a: 89 55 14 mov %edx,0x14(%ebp) -c0109e5d: 8b 30 mov (%eax),%esi -c0109e5f: 85 f6 test %esi,%esi -c0109e61: 75 05 jne c0109e68 +c01097c6: 8b 45 14 mov 0x14(%ebp),%eax +c01097c9: 8d 50 04 lea 0x4(%eax),%edx +c01097cc: 89 55 14 mov %edx,0x14(%ebp) +c01097cf: 8b 30 mov (%eax),%esi +c01097d1: 85 f6 test %esi,%esi +c01097d3: 75 05 jne c01097da p = "(null)"; -c0109e63: be 7d c4 10 c0 mov $0xc010c47d,%esi +c01097d5: be 59 c2 10 c0 mov $0xc010c259,%esi } if (width > 0 && padc != '-') { -c0109e68: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) -c0109e6c: 7e 76 jle c0109ee4 -c0109e6e: 80 7d db 2d cmpb $0x2d,-0x25(%ebp) -c0109e72: 74 70 je c0109ee4 +c01097da: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) +c01097de: 7e 76 jle c0109856 +c01097e0: 80 7d db 2d cmpb $0x2d,-0x25(%ebp) +c01097e4: 74 70 je c0109856 for (width -= strnlen(p, precision); width > 0; width --) { -c0109e74: 8b 45 e4 mov -0x1c(%ebp),%eax -c0109e77: 89 44 24 04 mov %eax,0x4(%esp) -c0109e7b: 89 34 24 mov %esi,(%esp) -c0109e7e: e8 ba f7 ff ff call c010963d -c0109e83: 8b 55 e8 mov -0x18(%ebp),%edx -c0109e86: 29 c2 sub %eax,%edx -c0109e88: 89 d0 mov %edx,%eax -c0109e8a: 89 45 e8 mov %eax,-0x18(%ebp) -c0109e8d: eb 16 jmp c0109ea5 +c01097e6: 8b 45 e4 mov -0x1c(%ebp),%eax +c01097e9: 89 44 24 04 mov %eax,0x4(%esp) +c01097ed: 89 34 24 mov %esi,(%esp) +c01097f0: e8 ee 03 00 00 call c0109be3 +c01097f5: 89 c2 mov %eax,%edx +c01097f7: 8b 45 e8 mov -0x18(%ebp),%eax +c01097fa: 29 d0 sub %edx,%eax +c01097fc: 89 45 e8 mov %eax,-0x18(%ebp) +c01097ff: eb 16 jmp c0109817 putch(padc, putdat); -c0109e8f: 0f be 45 db movsbl -0x25(%ebp),%eax -c0109e93: 8b 55 0c mov 0xc(%ebp),%edx -c0109e96: 89 54 24 04 mov %edx,0x4(%esp) -c0109e9a: 89 04 24 mov %eax,(%esp) -c0109e9d: 8b 45 08 mov 0x8(%ebp),%eax -c0109ea0: ff d0 call *%eax +c0109801: 0f be 45 db movsbl -0x25(%ebp),%eax +c0109805: 8b 55 0c mov 0xc(%ebp),%edx +c0109808: 89 54 24 04 mov %edx,0x4(%esp) +c010980c: 89 04 24 mov %eax,(%esp) +c010980f: 8b 45 08 mov 0x8(%ebp),%eax +c0109812: ff d0 call *%eax for (width -= strnlen(p, precision); width > 0; width --) { -c0109ea2: ff 4d e8 decl -0x18(%ebp) -c0109ea5: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) -c0109ea9: 7f e4 jg c0109e8f +c0109814: ff 4d e8 decl -0x18(%ebp) +c0109817: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) +c010981b: 7f e4 jg c0109801 } } for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) { -c0109eab: eb 37 jmp c0109ee4 +c010981d: eb 37 jmp c0109856 if (altflag && (ch < ' ' || ch > '~')) { -c0109ead: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) -c0109eb1: 74 1f je c0109ed2 -c0109eb3: 83 fb 1f cmp $0x1f,%ebx -c0109eb6: 7e 05 jle c0109ebd -c0109eb8: 83 fb 7e cmp $0x7e,%ebx -c0109ebb: 7e 15 jle c0109ed2 +c010981f: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) +c0109823: 74 1f je c0109844 +c0109825: 83 fb 1f cmp $0x1f,%ebx +c0109828: 7e 05 jle c010982f +c010982a: 83 fb 7e cmp $0x7e,%ebx +c010982d: 7e 15 jle c0109844 putch('?', putdat); -c0109ebd: 8b 45 0c mov 0xc(%ebp),%eax -c0109ec0: 89 44 24 04 mov %eax,0x4(%esp) -c0109ec4: c7 04 24 3f 00 00 00 movl $0x3f,(%esp) -c0109ecb: 8b 45 08 mov 0x8(%ebp),%eax -c0109ece: ff d0 call *%eax -c0109ed0: eb 0f jmp c0109ee1 +c010982f: 8b 45 0c mov 0xc(%ebp),%eax +c0109832: 89 44 24 04 mov %eax,0x4(%esp) +c0109836: c7 04 24 3f 00 00 00 movl $0x3f,(%esp) +c010983d: 8b 45 08 mov 0x8(%ebp),%eax +c0109840: ff d0 call *%eax +c0109842: eb 0f jmp c0109853 } else { putch(ch, putdat); -c0109ed2: 8b 45 0c mov 0xc(%ebp),%eax -c0109ed5: 89 44 24 04 mov %eax,0x4(%esp) -c0109ed9: 89 1c 24 mov %ebx,(%esp) -c0109edc: 8b 45 08 mov 0x8(%ebp),%eax -c0109edf: ff d0 call *%eax +c0109844: 8b 45 0c mov 0xc(%ebp),%eax +c0109847: 89 44 24 04 mov %eax,0x4(%esp) +c010984b: 89 1c 24 mov %ebx,(%esp) +c010984e: 8b 45 08 mov 0x8(%ebp),%eax +c0109851: ff d0 call *%eax for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) { -c0109ee1: ff 4d e8 decl -0x18(%ebp) -c0109ee4: 89 f0 mov %esi,%eax -c0109ee6: 8d 70 01 lea 0x1(%eax),%esi -c0109ee9: 0f b6 00 movzbl (%eax),%eax -c0109eec: 0f be d8 movsbl %al,%ebx -c0109eef: 85 db test %ebx,%ebx -c0109ef1: 74 27 je c0109f1a -c0109ef3: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) -c0109ef7: 78 b4 js c0109ead -c0109ef9: ff 4d e4 decl -0x1c(%ebp) -c0109efc: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) -c0109f00: 79 ab jns c0109ead +c0109853: ff 4d e8 decl -0x18(%ebp) +c0109856: 89 f0 mov %esi,%eax +c0109858: 8d 70 01 lea 0x1(%eax),%esi +c010985b: 0f b6 00 movzbl (%eax),%eax +c010985e: 0f be d8 movsbl %al,%ebx +c0109861: 85 db test %ebx,%ebx +c0109863: 74 27 je c010988c +c0109865: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) +c0109869: 78 b4 js c010981f +c010986b: ff 4d e4 decl -0x1c(%ebp) +c010986e: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) +c0109872: 79 ab jns c010981f } } for (; width > 0; width --) { -c0109f02: eb 16 jmp c0109f1a +c0109874: eb 16 jmp c010988c putch(' ', putdat); -c0109f04: 8b 45 0c mov 0xc(%ebp),%eax -c0109f07: 89 44 24 04 mov %eax,0x4(%esp) -c0109f0b: c7 04 24 20 00 00 00 movl $0x20,(%esp) -c0109f12: 8b 45 08 mov 0x8(%ebp),%eax -c0109f15: ff d0 call *%eax +c0109876: 8b 45 0c mov 0xc(%ebp),%eax +c0109879: 89 44 24 04 mov %eax,0x4(%esp) +c010987d: c7 04 24 20 00 00 00 movl $0x20,(%esp) +c0109884: 8b 45 08 mov 0x8(%ebp),%eax +c0109887: ff d0 call *%eax for (; width > 0; width --) { -c0109f17: ff 4d e8 decl -0x18(%ebp) -c0109f1a: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) -c0109f1e: 7f e4 jg c0109f04 +c0109889: ff 4d e8 decl -0x18(%ebp) +c010988c: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) +c0109890: 7f e4 jg c0109876 + } + break; +c0109892: e9 6c 01 00 00 jmp c0109a03 + + // (signed) decimal + case 'd': + num = getint(&ap, lflag); +c0109897: 8b 45 e0 mov -0x20(%ebp),%eax +c010989a: 89 44 24 04 mov %eax,0x4(%esp) +c010989e: 8d 45 14 lea 0x14(%ebp),%eax +c01098a1: 89 04 24 mov %eax,(%esp) +c01098a4: e8 16 fd ff ff call c01095bf +c01098a9: 89 45 f0 mov %eax,-0x10(%ebp) +c01098ac: 89 55 f4 mov %edx,-0xc(%ebp) + if ((long long)num < 0) { +c01098af: 8b 45 f0 mov -0x10(%ebp),%eax +c01098b2: 8b 55 f4 mov -0xc(%ebp),%edx +c01098b5: 85 d2 test %edx,%edx +c01098b7: 79 26 jns c01098df + putch('-', putdat); +c01098b9: 8b 45 0c mov 0xc(%ebp),%eax +c01098bc: 89 44 24 04 mov %eax,0x4(%esp) +c01098c0: c7 04 24 2d 00 00 00 movl $0x2d,(%esp) +c01098c7: 8b 45 08 mov 0x8(%ebp),%eax +c01098ca: ff d0 call *%eax + num = -(long long)num; +c01098cc: 8b 45 f0 mov -0x10(%ebp),%eax +c01098cf: 8b 55 f4 mov -0xc(%ebp),%edx +c01098d2: f7 d8 neg %eax +c01098d4: 83 d2 00 adc $0x0,%edx +c01098d7: f7 da neg %edx +c01098d9: 89 45 f0 mov %eax,-0x10(%ebp) +c01098dc: 89 55 f4 mov %edx,-0xc(%ebp) } + base = 10; +c01098df: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp) + goto number; +c01098e6: e9 a8 00 00 00 jmp c0109993 + + // unsigned decimal + case 'u': + num = getuint(&ap, lflag); +c01098eb: 8b 45 e0 mov -0x20(%ebp),%eax +c01098ee: 89 44 24 04 mov %eax,0x4(%esp) +c01098f2: 8d 45 14 lea 0x14(%ebp),%eax +c01098f5: 89 04 24 mov %eax,(%esp) +c01098f8: e8 73 fc ff ff call c0109570 +c01098fd: 89 45 f0 mov %eax,-0x10(%ebp) +c0109900: 89 55 f4 mov %edx,-0xc(%ebp) + base = 10; +c0109903: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp) + goto number; +c010990a: e9 84 00 00 00 jmp c0109993 + + // (unsigned) octal + case 'o': + num = getuint(&ap, lflag); +c010990f: 8b 45 e0 mov -0x20(%ebp),%eax +c0109912: 89 44 24 04 mov %eax,0x4(%esp) +c0109916: 8d 45 14 lea 0x14(%ebp),%eax +c0109919: 89 04 24 mov %eax,(%esp) +c010991c: e8 4f fc ff ff call c0109570 +c0109921: 89 45 f0 mov %eax,-0x10(%ebp) +c0109924: 89 55 f4 mov %edx,-0xc(%ebp) + base = 8; +c0109927: c7 45 ec 08 00 00 00 movl $0x8,-0x14(%ebp) + goto number; +c010992e: eb 63 jmp c0109993 + + // pointer + case 'p': + putch('0', putdat); +c0109930: 8b 45 0c mov 0xc(%ebp),%eax +c0109933: 89 44 24 04 mov %eax,0x4(%esp) +c0109937: c7 04 24 30 00 00 00 movl $0x30,(%esp) +c010993e: 8b 45 08 mov 0x8(%ebp),%eax +c0109941: ff d0 call *%eax + putch('x', putdat); +c0109943: 8b 45 0c mov 0xc(%ebp),%eax +c0109946: 89 44 24 04 mov %eax,0x4(%esp) +c010994a: c7 04 24 78 00 00 00 movl $0x78,(%esp) +c0109951: 8b 45 08 mov 0x8(%ebp),%eax +c0109954: ff d0 call *%eax + num = (unsigned long long)(uintptr_t)va_arg(ap, void *); +c0109956: 8b 45 14 mov 0x14(%ebp),%eax +c0109959: 8d 50 04 lea 0x4(%eax),%edx +c010995c: 89 55 14 mov %edx,0x14(%ebp) +c010995f: 8b 00 mov (%eax),%eax +c0109961: 89 45 f0 mov %eax,-0x10(%ebp) +c0109964: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) + base = 16; +c010996b: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp) + goto number; +c0109972: eb 1f jmp c0109993 + + // (unsigned) hexadecimal + case 'x': + num = getuint(&ap, lflag); +c0109974: 8b 45 e0 mov -0x20(%ebp),%eax +c0109977: 89 44 24 04 mov %eax,0x4(%esp) +c010997b: 8d 45 14 lea 0x14(%ebp),%eax +c010997e: 89 04 24 mov %eax,(%esp) +c0109981: e8 ea fb ff ff call c0109570 +c0109986: 89 45 f0 mov %eax,-0x10(%ebp) +c0109989: 89 55 f4 mov %edx,-0xc(%ebp) + base = 16; +c010998c: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp) + number: + printnum(putch, putdat, num, base, width, padc); +c0109993: 0f be 55 db movsbl -0x25(%ebp),%edx +c0109997: 8b 45 ec mov -0x14(%ebp),%eax +c010999a: 89 54 24 18 mov %edx,0x18(%esp) +c010999e: 8b 55 e8 mov -0x18(%ebp),%edx +c01099a1: 89 54 24 14 mov %edx,0x14(%esp) +c01099a5: 89 44 24 10 mov %eax,0x10(%esp) +c01099a9: 8b 45 f0 mov -0x10(%ebp),%eax +c01099ac: 8b 55 f4 mov -0xc(%ebp),%edx +c01099af: 89 44 24 08 mov %eax,0x8(%esp) +c01099b3: 89 54 24 0c mov %edx,0xc(%esp) +c01099b7: 8b 45 0c mov 0xc(%ebp),%eax +c01099ba: 89 44 24 04 mov %eax,0x4(%esp) +c01099be: 8b 45 08 mov 0x8(%ebp),%eax +c01099c1: 89 04 24 mov %eax,(%esp) +c01099c4: e8 a5 fa ff ff call c010946e + break; +c01099c9: eb 38 jmp c0109a03 + + // escaped '%' character + case '%': + putch(ch, putdat); +c01099cb: 8b 45 0c mov 0xc(%ebp),%eax +c01099ce: 89 44 24 04 mov %eax,0x4(%esp) +c01099d2: 89 1c 24 mov %ebx,(%esp) +c01099d5: 8b 45 08 mov 0x8(%ebp),%eax +c01099d8: ff d0 call *%eax + break; +c01099da: eb 27 jmp c0109a03 + + // unrecognized escape sequence - just print it literally + default: + putch('%', putdat); +c01099dc: 8b 45 0c mov 0xc(%ebp),%eax +c01099df: 89 44 24 04 mov %eax,0x4(%esp) +c01099e3: c7 04 24 25 00 00 00 movl $0x25,(%esp) +c01099ea: 8b 45 08 mov 0x8(%ebp),%eax +c01099ed: ff d0 call *%eax + for (fmt --; fmt[-1] != '%'; fmt --) +c01099ef: ff 4d 10 decl 0x10(%ebp) +c01099f2: eb 03 jmp c01099f7 +c01099f4: ff 4d 10 decl 0x10(%ebp) +c01099f7: 8b 45 10 mov 0x10(%ebp),%eax +c01099fa: 48 dec %eax +c01099fb: 0f b6 00 movzbl (%eax),%eax +c01099fe: 3c 25 cmp $0x25,%al +c0109a00: 75 f2 jne c01099f4 + /* do nothing */; + break; +c0109a02: 90 nop + while (1) { +c0109a03: e9 37 fc ff ff jmp c010963f + return; +c0109a08: 90 nop + } + } +} +c0109a09: 83 c4 40 add $0x40,%esp +c0109a0c: 5b pop %ebx +c0109a0d: 5e pop %esi +c0109a0e: 5d pop %ebp +c0109a0f: c3 ret + +c0109a10 : + * sprintputch - 'print' a single character in a buffer + * @ch: the character will be printed + * @b: the buffer to place the character @ch + * */ +static void +sprintputch(int ch, struct sprintbuf *b) { +c0109a10: 55 push %ebp +c0109a11: 89 e5 mov %esp,%ebp + b->cnt ++; +c0109a13: 8b 45 0c mov 0xc(%ebp),%eax +c0109a16: 8b 40 08 mov 0x8(%eax),%eax +c0109a19: 8d 50 01 lea 0x1(%eax),%edx +c0109a1c: 8b 45 0c mov 0xc(%ebp),%eax +c0109a1f: 89 50 08 mov %edx,0x8(%eax) + if (b->buf < b->ebuf) { +c0109a22: 8b 45 0c mov 0xc(%ebp),%eax +c0109a25: 8b 10 mov (%eax),%edx +c0109a27: 8b 45 0c mov 0xc(%ebp),%eax +c0109a2a: 8b 40 04 mov 0x4(%eax),%eax +c0109a2d: 39 c2 cmp %eax,%edx +c0109a2f: 73 12 jae c0109a43 + *b->buf ++ = ch; +c0109a31: 8b 45 0c mov 0xc(%ebp),%eax +c0109a34: 8b 00 mov (%eax),%eax +c0109a36: 8d 48 01 lea 0x1(%eax),%ecx +c0109a39: 8b 55 0c mov 0xc(%ebp),%edx +c0109a3c: 89 0a mov %ecx,(%edx) +c0109a3e: 8b 55 08 mov 0x8(%ebp),%edx +c0109a41: 88 10 mov %dl,(%eax) + } +} +c0109a43: 90 nop +c0109a44: 5d pop %ebp +c0109a45: c3 ret + +c0109a46 : + * @str: the buffer to place the result into + * @size: the size of buffer, including the trailing null space + * @fmt: the format string to use + * */ +int +snprintf(char *str, size_t size, const char *fmt, ...) { +c0109a46: 55 push %ebp +c0109a47: 89 e5 mov %esp,%ebp +c0109a49: 83 ec 28 sub $0x28,%esp + va_list ap; + int cnt; + va_start(ap, fmt); +c0109a4c: 8d 45 14 lea 0x14(%ebp),%eax +c0109a4f: 89 45 f0 mov %eax,-0x10(%ebp) + cnt = vsnprintf(str, size, fmt, ap); +c0109a52: 8b 45 f0 mov -0x10(%ebp),%eax +c0109a55: 89 44 24 0c mov %eax,0xc(%esp) +c0109a59: 8b 45 10 mov 0x10(%ebp),%eax +c0109a5c: 89 44 24 08 mov %eax,0x8(%esp) +c0109a60: 8b 45 0c mov 0xc(%ebp),%eax +c0109a63: 89 44 24 04 mov %eax,0x4(%esp) +c0109a67: 8b 45 08 mov 0x8(%ebp),%eax +c0109a6a: 89 04 24 mov %eax,(%esp) +c0109a6d: e8 0a 00 00 00 call c0109a7c +c0109a72: 89 45 f4 mov %eax,-0xc(%ebp) + va_end(ap); + return cnt; +c0109a75: 8b 45 f4 mov -0xc(%ebp),%eax +} +c0109a78: 89 ec mov %ebp,%esp +c0109a7a: 5d pop %ebp +c0109a7b: c3 ret + +c0109a7c : + * + * Call this function if you are already dealing with a va_list. + * Or you probably want snprintf() instead. + * */ +int +vsnprintf(char *str, size_t size, const char *fmt, va_list ap) { +c0109a7c: 55 push %ebp +c0109a7d: 89 e5 mov %esp,%ebp +c0109a7f: 83 ec 28 sub $0x28,%esp + struct sprintbuf b = {str, str + size - 1, 0}; +c0109a82: 8b 45 08 mov 0x8(%ebp),%eax +c0109a85: 89 45 ec mov %eax,-0x14(%ebp) +c0109a88: 8b 45 0c mov 0xc(%ebp),%eax +c0109a8b: 8d 50 ff lea -0x1(%eax),%edx +c0109a8e: 8b 45 08 mov 0x8(%ebp),%eax +c0109a91: 01 d0 add %edx,%eax +c0109a93: 89 45 f0 mov %eax,-0x10(%ebp) +c0109a96: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) + if (str == NULL || b.buf > b.ebuf) { +c0109a9d: 83 7d 08 00 cmpl $0x0,0x8(%ebp) +c0109aa1: 74 0a je c0109aad +c0109aa3: 8b 55 ec mov -0x14(%ebp),%edx +c0109aa6: 8b 45 f0 mov -0x10(%ebp),%eax +c0109aa9: 39 c2 cmp %eax,%edx +c0109aab: 76 07 jbe c0109ab4 + return -E_INVAL; +c0109aad: b8 fd ff ff ff mov $0xfffffffd,%eax +c0109ab2: eb 2a jmp c0109ade + } + // print the string to the buffer + vprintfmt((void*)sprintputch, &b, fmt, ap); +c0109ab4: 8b 45 14 mov 0x14(%ebp),%eax +c0109ab7: 89 44 24 0c mov %eax,0xc(%esp) +c0109abb: 8b 45 10 mov 0x10(%ebp),%eax +c0109abe: 89 44 24 08 mov %eax,0x8(%esp) +c0109ac2: 8d 45 ec lea -0x14(%ebp),%eax +c0109ac5: 89 44 24 04 mov %eax,0x4(%esp) +c0109ac9: c7 04 24 10 9a 10 c0 movl $0xc0109a10,(%esp) +c0109ad0: e8 62 fb ff ff call c0109637 + // null terminate the buffer + *b.buf = '\0'; +c0109ad5: 8b 45 ec mov -0x14(%ebp),%eax +c0109ad8: c6 00 00 movb $0x0,(%eax) + return b.cnt; +c0109adb: 8b 45 f4 mov -0xc(%ebp),%eax +} +c0109ade: 89 ec mov %ebp,%esp +c0109ae0: 5d pop %ebp +c0109ae1: c3 ret + +c0109ae2 : + * rand - returns a pseudo-random integer + * + * The rand() function return a value in the range [0, RAND_MAX]. + * */ +int +rand(void) { +c0109ae2: 55 push %ebp +c0109ae3: 89 e5 mov %esp,%ebp +c0109ae5: 57 push %edi +c0109ae6: 56 push %esi +c0109ae7: 53 push %ebx +c0109ae8: 83 ec 24 sub $0x24,%esp + next = (next * 0x5DEECE66DLL + 0xBLL) & ((1LL << 48) - 1); +c0109aeb: a1 88 8a 12 c0 mov 0xc0128a88,%eax +c0109af0: 8b 15 8c 8a 12 c0 mov 0xc0128a8c,%edx +c0109af6: 69 fa 6d e6 ec de imul $0xdeece66d,%edx,%edi +c0109afc: 6b f0 05 imul $0x5,%eax,%esi +c0109aff: 01 fe add %edi,%esi +c0109b01: bf 6d e6 ec de mov $0xdeece66d,%edi +c0109b06: f7 e7 mul %edi +c0109b08: 01 d6 add %edx,%esi +c0109b0a: 89 f2 mov %esi,%edx +c0109b0c: 83 c0 0b add $0xb,%eax +c0109b0f: 83 d2 00 adc $0x0,%edx +c0109b12: 89 c7 mov %eax,%edi +c0109b14: 83 e7 ff and $0xffffffff,%edi +c0109b17: 89 f9 mov %edi,%ecx +c0109b19: 0f b7 da movzwl %dx,%ebx +c0109b1c: 89 0d 88 8a 12 c0 mov %ecx,0xc0128a88 +c0109b22: 89 1d 8c 8a 12 c0 mov %ebx,0xc0128a8c + unsigned long long result = (next >> 12); +c0109b28: a1 88 8a 12 c0 mov 0xc0128a88,%eax +c0109b2d: 8b 15 8c 8a 12 c0 mov 0xc0128a8c,%edx +c0109b33: 0f ac d0 0c shrd $0xc,%edx,%eax +c0109b37: c1 ea 0c shr $0xc,%edx +c0109b3a: 89 45 e0 mov %eax,-0x20(%ebp) +c0109b3d: 89 55 e4 mov %edx,-0x1c(%ebp) + return (int)do_div(result, RAND_MAX + 1); +c0109b40: c7 45 dc 00 00 00 80 movl $0x80000000,-0x24(%ebp) +c0109b47: 8b 45 e0 mov -0x20(%ebp),%eax +c0109b4a: 8b 55 e4 mov -0x1c(%ebp),%edx +c0109b4d: 89 45 d8 mov %eax,-0x28(%ebp) +c0109b50: 89 55 e8 mov %edx,-0x18(%ebp) +c0109b53: 8b 45 e8 mov -0x18(%ebp),%eax +c0109b56: 89 45 ec mov %eax,-0x14(%ebp) +c0109b59: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) +c0109b5d: 74 1c je c0109b7b +c0109b5f: 8b 45 e8 mov -0x18(%ebp),%eax +c0109b62: ba 00 00 00 00 mov $0x0,%edx +c0109b67: f7 75 dc divl -0x24(%ebp) +c0109b6a: 89 55 ec mov %edx,-0x14(%ebp) +c0109b6d: 8b 45 e8 mov -0x18(%ebp),%eax +c0109b70: ba 00 00 00 00 mov $0x0,%edx +c0109b75: f7 75 dc divl -0x24(%ebp) +c0109b78: 89 45 e8 mov %eax,-0x18(%ebp) +c0109b7b: 8b 45 d8 mov -0x28(%ebp),%eax +c0109b7e: 8b 55 ec mov -0x14(%ebp),%edx +c0109b81: f7 75 dc divl -0x24(%ebp) +c0109b84: 89 45 d8 mov %eax,-0x28(%ebp) +c0109b87: 89 55 d4 mov %edx,-0x2c(%ebp) +c0109b8a: 8b 45 d8 mov -0x28(%ebp),%eax +c0109b8d: 8b 55 e8 mov -0x18(%ebp),%edx +c0109b90: 89 45 e0 mov %eax,-0x20(%ebp) +c0109b93: 89 55 e4 mov %edx,-0x1c(%ebp) +c0109b96: 8b 45 d4 mov -0x2c(%ebp),%eax +} +c0109b99: 83 c4 24 add $0x24,%esp +c0109b9c: 5b pop %ebx +c0109b9d: 5e pop %esi +c0109b9e: 5f pop %edi +c0109b9f: 5d pop %ebp +c0109ba0: c3 ret + +c0109ba1 : +/* * + * srand - seed the random number generator with the given number + * @seed: the required seed number + * */ +void +srand(unsigned int seed) { +c0109ba1: 55 push %ebp +c0109ba2: 89 e5 mov %esp,%ebp + next = seed; +c0109ba4: 8b 45 08 mov 0x8(%ebp),%eax +c0109ba7: ba 00 00 00 00 mov $0x0,%edx +c0109bac: a3 88 8a 12 c0 mov %eax,0xc0128a88 +c0109bb1: 89 15 8c 8a 12 c0 mov %edx,0xc0128a8c +} +c0109bb7: 90 nop +c0109bb8: 5d pop %ebp +c0109bb9: c3 ret + +c0109bba : + * @s: the input string + * + * The strlen() function returns the length of string @s. + * */ +size_t +strlen(const char *s) { +c0109bba: 55 push %ebp +c0109bbb: 89 e5 mov %esp,%ebp +c0109bbd: 83 ec 10 sub $0x10,%esp + size_t cnt = 0; +c0109bc0: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) + while (*s ++ != '\0') { +c0109bc7: eb 03 jmp c0109bcc + cnt ++; +c0109bc9: ff 45 fc incl -0x4(%ebp) + while (*s ++ != '\0') { +c0109bcc: 8b 45 08 mov 0x8(%ebp),%eax +c0109bcf: 8d 50 01 lea 0x1(%eax),%edx +c0109bd2: 89 55 08 mov %edx,0x8(%ebp) +c0109bd5: 0f b6 00 movzbl (%eax),%eax +c0109bd8: 84 c0 test %al,%al +c0109bda: 75 ed jne c0109bc9 + } + return cnt; +c0109bdc: 8b 45 fc mov -0x4(%ebp),%eax +} +c0109bdf: 89 ec mov %ebp,%esp +c0109be1: 5d pop %ebp +c0109be2: c3 ret + +c0109be3 : + * The return value is strlen(s), if that is less than @len, or + * @len if there is no '\0' character among the first @len characters + * pointed by @s. + * */ +size_t +strnlen(const char *s, size_t len) { +c0109be3: 55 push %ebp +c0109be4: 89 e5 mov %esp,%ebp +c0109be6: 83 ec 10 sub $0x10,%esp + size_t cnt = 0; +c0109be9: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) + while (cnt < len && *s ++ != '\0') { +c0109bf0: eb 03 jmp c0109bf5 + cnt ++; +c0109bf2: ff 45 fc incl -0x4(%ebp) + while (cnt < len && *s ++ != '\0') { +c0109bf5: 8b 45 fc mov -0x4(%ebp),%eax +c0109bf8: 3b 45 0c cmp 0xc(%ebp),%eax +c0109bfb: 73 10 jae c0109c0d +c0109bfd: 8b 45 08 mov 0x8(%ebp),%eax +c0109c00: 8d 50 01 lea 0x1(%eax),%edx +c0109c03: 89 55 08 mov %edx,0x8(%ebp) +c0109c06: 0f b6 00 movzbl (%eax),%eax +c0109c09: 84 c0 test %al,%al +c0109c0b: 75 e5 jne c0109bf2 + } + return cnt; +c0109c0d: 8b 45 fc mov -0x4(%ebp),%eax +} +c0109c10: 89 ec mov %ebp,%esp +c0109c12: 5d pop %ebp +c0109c13: c3 ret + +c0109c14 : + * To avoid overflows, the size of array pointed by @dst should be long enough to + * contain the same string as @src (including the terminating null character), and + * should not overlap in memory with @src. + * */ +char * +strcpy(char *dst, const char *src) { +c0109c14: 55 push %ebp +c0109c15: 89 e5 mov %esp,%ebp +c0109c17: 57 push %edi +c0109c18: 56 push %esi +c0109c19: 83 ec 20 sub $0x20,%esp +c0109c1c: 8b 45 08 mov 0x8(%ebp),%eax +c0109c1f: 89 45 f4 mov %eax,-0xc(%ebp) +c0109c22: 8b 45 0c mov 0xc(%ebp),%eax +c0109c25: 89 45 f0 mov %eax,-0x10(%ebp) +#ifndef __HAVE_ARCH_STRCPY +#define __HAVE_ARCH_STRCPY +static inline char * +__strcpy(char *dst, const char *src) { + int d0, d1, d2; + asm volatile ( +c0109c28: 8b 55 f0 mov -0x10(%ebp),%edx +c0109c2b: 8b 45 f4 mov -0xc(%ebp),%eax +c0109c2e: 89 d1 mov %edx,%ecx +c0109c30: 89 c2 mov %eax,%edx +c0109c32: 89 ce mov %ecx,%esi +c0109c34: 89 d7 mov %edx,%edi +c0109c36: ac lods %ds:(%esi),%al +c0109c37: aa stos %al,%es:(%edi) +c0109c38: 84 c0 test %al,%al +c0109c3a: 75 fa jne c0109c36 +c0109c3c: 89 fa mov %edi,%edx +c0109c3e: 89 f1 mov %esi,%ecx +c0109c40: 89 4d ec mov %ecx,-0x14(%ebp) +c0109c43: 89 55 e8 mov %edx,-0x18(%ebp) +c0109c46: 89 45 e4 mov %eax,-0x1c(%ebp) + "stosb;" + "testb %%al, %%al;" + "jne 1b;" + : "=&S" (d0), "=&D" (d1), "=&a" (d2) + : "0" (src), "1" (dst) : "memory"); + return dst; +c0109c49: 8b 45 f4 mov -0xc(%ebp),%eax + char *p = dst; + while ((*p ++ = *src ++) != '\0') + /* nothing */; + return dst; +#endif /* __HAVE_ARCH_STRCPY */ +} +c0109c4c: 83 c4 20 add $0x20,%esp +c0109c4f: 5e pop %esi +c0109c50: 5f pop %edi +c0109c51: 5d pop %ebp +c0109c52: c3 ret + +c0109c53 : + * @len: maximum number of characters to be copied from @src + * + * The return value is @dst + * */ +char * +strncpy(char *dst, const char *src, size_t len) { +c0109c53: 55 push %ebp +c0109c54: 89 e5 mov %esp,%ebp +c0109c56: 83 ec 10 sub $0x10,%esp + char *p = dst; +c0109c59: 8b 45 08 mov 0x8(%ebp),%eax +c0109c5c: 89 45 fc mov %eax,-0x4(%ebp) + while (len > 0) { +c0109c5f: eb 1e jmp c0109c7f + if ((*p = *src) != '\0') { +c0109c61: 8b 45 0c mov 0xc(%ebp),%eax +c0109c64: 0f b6 10 movzbl (%eax),%edx +c0109c67: 8b 45 fc mov -0x4(%ebp),%eax +c0109c6a: 88 10 mov %dl,(%eax) +c0109c6c: 8b 45 fc mov -0x4(%ebp),%eax +c0109c6f: 0f b6 00 movzbl (%eax),%eax +c0109c72: 84 c0 test %al,%al +c0109c74: 74 03 je c0109c79 + src ++; +c0109c76: ff 45 0c incl 0xc(%ebp) + } + p ++, len --; +c0109c79: ff 45 fc incl -0x4(%ebp) +c0109c7c: ff 4d 10 decl 0x10(%ebp) + while (len > 0) { +c0109c7f: 83 7d 10 00 cmpl $0x0,0x10(%ebp) +c0109c83: 75 dc jne c0109c61 + } + return dst; +c0109c85: 8b 45 08 mov 0x8(%ebp),%eax +} +c0109c88: 89 ec mov %ebp,%esp +c0109c8a: 5d pop %ebp +c0109c8b: c3 ret + +c0109c8c : + * - A value greater than zero indicates that the first character that does + * not match has a greater value in @s1 than in @s2; + * - And a value less than zero indicates the opposite. + * */ +int +strcmp(const char *s1, const char *s2) { +c0109c8c: 55 push %ebp +c0109c8d: 89 e5 mov %esp,%ebp +c0109c8f: 57 push %edi +c0109c90: 56 push %esi +c0109c91: 83 ec 20 sub $0x20,%esp +c0109c94: 8b 45 08 mov 0x8(%ebp),%eax +c0109c97: 89 45 f4 mov %eax,-0xc(%ebp) +c0109c9a: 8b 45 0c mov 0xc(%ebp),%eax +c0109c9d: 89 45 f0 mov %eax,-0x10(%ebp) + asm volatile ( +c0109ca0: 8b 55 f4 mov -0xc(%ebp),%edx +c0109ca3: 8b 45 f0 mov -0x10(%ebp),%eax +c0109ca6: 89 d1 mov %edx,%ecx +c0109ca8: 89 c2 mov %eax,%edx +c0109caa: 89 ce mov %ecx,%esi +c0109cac: 89 d7 mov %edx,%edi +c0109cae: ac lods %ds:(%esi),%al +c0109caf: ae scas %es:(%edi),%al +c0109cb0: 75 08 jne c0109cba +c0109cb2: 84 c0 test %al,%al +c0109cb4: 75 f8 jne c0109cae +c0109cb6: 31 c0 xor %eax,%eax +c0109cb8: eb 04 jmp c0109cbe +c0109cba: 19 c0 sbb %eax,%eax +c0109cbc: 0c 01 or $0x1,%al +c0109cbe: 89 fa mov %edi,%edx +c0109cc0: 89 f1 mov %esi,%ecx +c0109cc2: 89 45 ec mov %eax,-0x14(%ebp) +c0109cc5: 89 4d e8 mov %ecx,-0x18(%ebp) +c0109cc8: 89 55 e4 mov %edx,-0x1c(%ebp) + return ret; +c0109ccb: 8b 45 ec mov -0x14(%ebp),%eax + while (*s1 != '\0' && *s1 == *s2) { + s1 ++, s2 ++; + } + return (int)((unsigned char)*s1 - (unsigned char)*s2); +#endif /* __HAVE_ARCH_STRCMP */ +} +c0109cce: 83 c4 20 add $0x20,%esp +c0109cd1: 5e pop %esi +c0109cd2: 5f pop %edi +c0109cd3: 5d pop %ebp +c0109cd4: c3 ret + +c0109cd5 : + * they are equal to each other, it continues with the following pairs until + * the characters differ, until a terminating null-character is reached, or + * until @n characters match in both strings, whichever happens first. + * */ +int +strncmp(const char *s1, const char *s2, size_t n) { +c0109cd5: 55 push %ebp +c0109cd6: 89 e5 mov %esp,%ebp + while (n > 0 && *s1 != '\0' && *s1 == *s2) { +c0109cd8: eb 09 jmp c0109ce3 + n --, s1 ++, s2 ++; +c0109cda: ff 4d 10 decl 0x10(%ebp) +c0109cdd: ff 45 08 incl 0x8(%ebp) +c0109ce0: ff 45 0c incl 0xc(%ebp) + while (n > 0 && *s1 != '\0' && *s1 == *s2) { +c0109ce3: 83 7d 10 00 cmpl $0x0,0x10(%ebp) +c0109ce7: 74 1a je c0109d03 +c0109ce9: 8b 45 08 mov 0x8(%ebp),%eax +c0109cec: 0f b6 00 movzbl (%eax),%eax +c0109cef: 84 c0 test %al,%al +c0109cf1: 74 10 je c0109d03 +c0109cf3: 8b 45 08 mov 0x8(%ebp),%eax +c0109cf6: 0f b6 10 movzbl (%eax),%edx +c0109cf9: 8b 45 0c mov 0xc(%ebp),%eax +c0109cfc: 0f b6 00 movzbl (%eax),%eax +c0109cff: 38 c2 cmp %al,%dl +c0109d01: 74 d7 je c0109cda + } + return (n == 0) ? 0 : (int)((unsigned char)*s1 - (unsigned char)*s2); +c0109d03: 83 7d 10 00 cmpl $0x0,0x10(%ebp) +c0109d07: 74 18 je c0109d21 +c0109d09: 8b 45 08 mov 0x8(%ebp),%eax +c0109d0c: 0f b6 00 movzbl (%eax),%eax +c0109d0f: 0f b6 d0 movzbl %al,%edx +c0109d12: 8b 45 0c mov 0xc(%ebp),%eax +c0109d15: 0f b6 00 movzbl (%eax),%eax +c0109d18: 0f b6 c8 movzbl %al,%ecx +c0109d1b: 89 d0 mov %edx,%eax +c0109d1d: 29 c8 sub %ecx,%eax +c0109d1f: eb 05 jmp c0109d26 +c0109d21: b8 00 00 00 00 mov $0x0,%eax +} +c0109d26: 5d pop %ebp +c0109d27: c3 ret + +c0109d28 : + * + * The strchr() function returns a pointer to the first occurrence of + * character in @s. If the value is not found, the function returns 'NULL'. + * */ +char * +strchr(const char *s, char c) { +c0109d28: 55 push %ebp +c0109d29: 89 e5 mov %esp,%ebp +c0109d2b: 83 ec 04 sub $0x4,%esp +c0109d2e: 8b 45 0c mov 0xc(%ebp),%eax +c0109d31: 88 45 fc mov %al,-0x4(%ebp) + while (*s != '\0') { +c0109d34: eb 13 jmp c0109d49 + if (*s == c) { +c0109d36: 8b 45 08 mov 0x8(%ebp),%eax +c0109d39: 0f b6 00 movzbl (%eax),%eax +c0109d3c: 38 45 fc cmp %al,-0x4(%ebp) +c0109d3f: 75 05 jne c0109d46 + return (char *)s; +c0109d41: 8b 45 08 mov 0x8(%ebp),%eax +c0109d44: eb 12 jmp c0109d58 + } + s ++; +c0109d46: ff 45 08 incl 0x8(%ebp) + while (*s != '\0') { +c0109d49: 8b 45 08 mov 0x8(%ebp),%eax +c0109d4c: 0f b6 00 movzbl (%eax),%eax +c0109d4f: 84 c0 test %al,%al +c0109d51: 75 e3 jne c0109d36 + } + return NULL; +c0109d53: b8 00 00 00 00 mov $0x0,%eax +} +c0109d58: 89 ec mov %ebp,%esp +c0109d5a: 5d pop %ebp +c0109d5b: c3 ret + +c0109d5c : + * The strfind() function is like strchr() except that if @c is + * not found in @s, then it returns a pointer to the null byte at the + * end of @s, rather than 'NULL'. + * */ +char * +strfind(const char *s, char c) { +c0109d5c: 55 push %ebp +c0109d5d: 89 e5 mov %esp,%ebp +c0109d5f: 83 ec 04 sub $0x4,%esp +c0109d62: 8b 45 0c mov 0xc(%ebp),%eax +c0109d65: 88 45 fc mov %al,-0x4(%ebp) + while (*s != '\0') { +c0109d68: eb 0e jmp c0109d78 + if (*s == c) { +c0109d6a: 8b 45 08 mov 0x8(%ebp),%eax +c0109d6d: 0f b6 00 movzbl (%eax),%eax +c0109d70: 38 45 fc cmp %al,-0x4(%ebp) +c0109d73: 74 0f je c0109d84 + break; + } + s ++; +c0109d75: ff 45 08 incl 0x8(%ebp) + while (*s != '\0') { +c0109d78: 8b 45 08 mov 0x8(%ebp),%eax +c0109d7b: 0f b6 00 movzbl (%eax),%eax +c0109d7e: 84 c0 test %al,%al +c0109d80: 75 e8 jne c0109d6a +c0109d82: eb 01 jmp c0109d85 break; -c0109f20: e9 6c 01 00 00 jmp c010a091 +c0109d84: 90 nop + } + return (char *)s; +c0109d85: 8b 45 08 mov 0x8(%ebp),%eax +} +c0109d88: 89 ec mov %ebp,%esp +c0109d8a: 5d pop %ebp +c0109d8b: c3 ret - // (signed) decimal - case 'd': - num = getint(&ap, lflag); -c0109f25: 8b 45 e0 mov -0x20(%ebp),%eax -c0109f28: 89 44 24 04 mov %eax,0x4(%esp) -c0109f2c: 8d 45 14 lea 0x14(%ebp),%eax -c0109f2f: 89 04 24 mov %eax,(%esp) -c0109f32: e8 0b fd ff ff call c0109c42 -c0109f37: 89 45 f0 mov %eax,-0x10(%ebp) -c0109f3a: 89 55 f4 mov %edx,-0xc(%ebp) - if ((long long)num < 0) { -c0109f3d: 8b 45 f0 mov -0x10(%ebp),%eax -c0109f40: 8b 55 f4 mov -0xc(%ebp),%edx -c0109f43: 85 d2 test %edx,%edx -c0109f45: 79 26 jns c0109f6d - putch('-', putdat); -c0109f47: 8b 45 0c mov 0xc(%ebp),%eax -c0109f4a: 89 44 24 04 mov %eax,0x4(%esp) -c0109f4e: c7 04 24 2d 00 00 00 movl $0x2d,(%esp) -c0109f55: 8b 45 08 mov 0x8(%ebp),%eax -c0109f58: ff d0 call *%eax - num = -(long long)num; -c0109f5a: 8b 45 f0 mov -0x10(%ebp),%eax -c0109f5d: 8b 55 f4 mov -0xc(%ebp),%edx -c0109f60: f7 d8 neg %eax -c0109f62: 83 d2 00 adc $0x0,%edx -c0109f65: f7 da neg %edx -c0109f67: 89 45 f0 mov %eax,-0x10(%ebp) -c0109f6a: 89 55 f4 mov %edx,-0xc(%ebp) - } - base = 10; -c0109f6d: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp) - goto number; -c0109f74: e9 a8 00 00 00 jmp c010a021 +c0109d8c : + * an optional "0x" or "0X" prefix. + * + * The strtol() function returns the converted integral number as a long int value. + * */ +long +strtol(const char *s, char **endptr, int base) { +c0109d8c: 55 push %ebp +c0109d8d: 89 e5 mov %esp,%ebp +c0109d8f: 83 ec 10 sub $0x10,%esp + int neg = 0; +c0109d92: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) + long val = 0; +c0109d99: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%ebp) - // unsigned decimal - case 'u': - num = getuint(&ap, lflag); -c0109f79: 8b 45 e0 mov -0x20(%ebp),%eax -c0109f7c: 89 44 24 04 mov %eax,0x4(%esp) -c0109f80: 8d 45 14 lea 0x14(%ebp),%eax -c0109f83: 89 04 24 mov %eax,(%esp) -c0109f86: e8 64 fc ff ff call c0109bef -c0109f8b: 89 45 f0 mov %eax,-0x10(%ebp) -c0109f8e: 89 55 f4 mov %edx,-0xc(%ebp) - base = 10; -c0109f91: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp) - goto number; -c0109f98: e9 84 00 00 00 jmp c010a021 + // gobble initial whitespace + while (*s == ' ' || *s == '\t') { +c0109da0: eb 03 jmp c0109da5 + s ++; +c0109da2: ff 45 08 incl 0x8(%ebp) + while (*s == ' ' || *s == '\t') { +c0109da5: 8b 45 08 mov 0x8(%ebp),%eax +c0109da8: 0f b6 00 movzbl (%eax),%eax +c0109dab: 3c 20 cmp $0x20,%al +c0109dad: 74 f3 je c0109da2 +c0109daf: 8b 45 08 mov 0x8(%ebp),%eax +c0109db2: 0f b6 00 movzbl (%eax),%eax +c0109db5: 3c 09 cmp $0x9,%al +c0109db7: 74 e9 je c0109da2 + } - // (unsigned) octal - case 'o': - num = getuint(&ap, lflag); -c0109f9d: 8b 45 e0 mov -0x20(%ebp),%eax -c0109fa0: 89 44 24 04 mov %eax,0x4(%esp) -c0109fa4: 8d 45 14 lea 0x14(%ebp),%eax -c0109fa7: 89 04 24 mov %eax,(%esp) -c0109faa: e8 40 fc ff ff call c0109bef -c0109faf: 89 45 f0 mov %eax,-0x10(%ebp) -c0109fb2: 89 55 f4 mov %edx,-0xc(%ebp) - base = 8; -c0109fb5: c7 45 ec 08 00 00 00 movl $0x8,-0x14(%ebp) - goto number; -c0109fbc: eb 63 jmp c010a021 + // plus/minus sign + if (*s == '+') { +c0109db9: 8b 45 08 mov 0x8(%ebp),%eax +c0109dbc: 0f b6 00 movzbl (%eax),%eax +c0109dbf: 3c 2b cmp $0x2b,%al +c0109dc1: 75 05 jne c0109dc8 + s ++; +c0109dc3: ff 45 08 incl 0x8(%ebp) +c0109dc6: eb 14 jmp c0109ddc + } + else if (*s == '-') { +c0109dc8: 8b 45 08 mov 0x8(%ebp),%eax +c0109dcb: 0f b6 00 movzbl (%eax),%eax +c0109dce: 3c 2d cmp $0x2d,%al +c0109dd0: 75 0a jne c0109ddc + s ++, neg = 1; +c0109dd2: ff 45 08 incl 0x8(%ebp) +c0109dd5: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%ebp) + } - // pointer - case 'p': - putch('0', putdat); -c0109fbe: 8b 45 0c mov 0xc(%ebp),%eax -c0109fc1: 89 44 24 04 mov %eax,0x4(%esp) -c0109fc5: c7 04 24 30 00 00 00 movl $0x30,(%esp) -c0109fcc: 8b 45 08 mov 0x8(%ebp),%eax -c0109fcf: ff d0 call *%eax - putch('x', putdat); -c0109fd1: 8b 45 0c mov 0xc(%ebp),%eax -c0109fd4: 89 44 24 04 mov %eax,0x4(%esp) -c0109fd8: c7 04 24 78 00 00 00 movl $0x78,(%esp) -c0109fdf: 8b 45 08 mov 0x8(%ebp),%eax -c0109fe2: ff d0 call *%eax - num = (unsigned long long)(uintptr_t)va_arg(ap, void *); -c0109fe4: 8b 45 14 mov 0x14(%ebp),%eax -c0109fe7: 8d 50 04 lea 0x4(%eax),%edx -c0109fea: 89 55 14 mov %edx,0x14(%ebp) -c0109fed: 8b 00 mov (%eax),%eax -c0109fef: 89 45 f0 mov %eax,-0x10(%ebp) -c0109ff2: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) - base = 16; -c0109ff9: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp) - goto number; -c010a000: eb 1f jmp c010a021 + // hex or octal base prefix + if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x')) { +c0109ddc: 83 7d 10 00 cmpl $0x0,0x10(%ebp) +c0109de0: 74 06 je c0109de8 +c0109de2: 83 7d 10 10 cmpl $0x10,0x10(%ebp) +c0109de6: 75 22 jne c0109e0a +c0109de8: 8b 45 08 mov 0x8(%ebp),%eax +c0109deb: 0f b6 00 movzbl (%eax),%eax +c0109dee: 3c 30 cmp $0x30,%al +c0109df0: 75 18 jne c0109e0a +c0109df2: 8b 45 08 mov 0x8(%ebp),%eax +c0109df5: 40 inc %eax +c0109df6: 0f b6 00 movzbl (%eax),%eax +c0109df9: 3c 78 cmp $0x78,%al +c0109dfb: 75 0d jne c0109e0a + s += 2, base = 16; +c0109dfd: 83 45 08 02 addl $0x2,0x8(%ebp) +c0109e01: c7 45 10 10 00 00 00 movl $0x10,0x10(%ebp) +c0109e08: eb 29 jmp c0109e33 + } + else if (base == 0 && s[0] == '0') { +c0109e0a: 83 7d 10 00 cmpl $0x0,0x10(%ebp) +c0109e0e: 75 16 jne c0109e26 +c0109e10: 8b 45 08 mov 0x8(%ebp),%eax +c0109e13: 0f b6 00 movzbl (%eax),%eax +c0109e16: 3c 30 cmp $0x30,%al +c0109e18: 75 0c jne c0109e26 + s ++, base = 8; +c0109e1a: ff 45 08 incl 0x8(%ebp) +c0109e1d: c7 45 10 08 00 00 00 movl $0x8,0x10(%ebp) +c0109e24: eb 0d jmp c0109e33 + } + else if (base == 0) { +c0109e26: 83 7d 10 00 cmpl $0x0,0x10(%ebp) +c0109e2a: 75 07 jne c0109e33 + base = 10; +c0109e2c: c7 45 10 0a 00 00 00 movl $0xa,0x10(%ebp) - // (unsigned) hexadecimal - case 'x': - num = getuint(&ap, lflag); -c010a002: 8b 45 e0 mov -0x20(%ebp),%eax -c010a005: 89 44 24 04 mov %eax,0x4(%esp) -c010a009: 8d 45 14 lea 0x14(%ebp),%eax -c010a00c: 89 04 24 mov %eax,(%esp) -c010a00f: e8 db fb ff ff call c0109bef -c010a014: 89 45 f0 mov %eax,-0x10(%ebp) -c010a017: 89 55 f4 mov %edx,-0xc(%ebp) - base = 16; -c010a01a: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp) - number: - printnum(putch, putdat, num, base, width, padc); -c010a021: 0f be 55 db movsbl -0x25(%ebp),%edx -c010a025: 8b 45 ec mov -0x14(%ebp),%eax -c010a028: 89 54 24 18 mov %edx,0x18(%esp) -c010a02c: 8b 55 e8 mov -0x18(%ebp),%edx -c010a02f: 89 54 24 14 mov %edx,0x14(%esp) -c010a033: 89 44 24 10 mov %eax,0x10(%esp) -c010a037: 8b 45 f0 mov -0x10(%ebp),%eax -c010a03a: 8b 55 f4 mov -0xc(%ebp),%edx -c010a03d: 89 44 24 08 mov %eax,0x8(%esp) -c010a041: 89 54 24 0c mov %edx,0xc(%esp) -c010a045: 8b 45 0c mov 0xc(%ebp),%eax -c010a048: 89 44 24 04 mov %eax,0x4(%esp) -c010a04c: 8b 45 08 mov 0x8(%ebp),%eax -c010a04f: 89 04 24 mov %eax,(%esp) -c010a052: e8 94 fa ff ff call c0109aeb - break; -c010a057: eb 38 jmp c010a091 + // digits + while (1) { + int dig; - // escaped '%' character - case '%': - putch(ch, putdat); -c010a059: 8b 45 0c mov 0xc(%ebp),%eax -c010a05c: 89 44 24 04 mov %eax,0x4(%esp) -c010a060: 89 1c 24 mov %ebx,(%esp) -c010a063: 8b 45 08 mov 0x8(%ebp),%eax -c010a066: ff d0 call *%eax + if (*s >= '0' && *s <= '9') { +c0109e33: 8b 45 08 mov 0x8(%ebp),%eax +c0109e36: 0f b6 00 movzbl (%eax),%eax +c0109e39: 3c 2f cmp $0x2f,%al +c0109e3b: 7e 1b jle c0109e58 +c0109e3d: 8b 45 08 mov 0x8(%ebp),%eax +c0109e40: 0f b6 00 movzbl (%eax),%eax +c0109e43: 3c 39 cmp $0x39,%al +c0109e45: 7f 11 jg c0109e58 + dig = *s - '0'; +c0109e47: 8b 45 08 mov 0x8(%ebp),%eax +c0109e4a: 0f b6 00 movzbl (%eax),%eax +c0109e4d: 0f be c0 movsbl %al,%eax +c0109e50: 83 e8 30 sub $0x30,%eax +c0109e53: 89 45 f4 mov %eax,-0xc(%ebp) +c0109e56: eb 48 jmp c0109ea0 + } + else if (*s >= 'a' && *s <= 'z') { +c0109e58: 8b 45 08 mov 0x8(%ebp),%eax +c0109e5b: 0f b6 00 movzbl (%eax),%eax +c0109e5e: 3c 60 cmp $0x60,%al +c0109e60: 7e 1b jle c0109e7d +c0109e62: 8b 45 08 mov 0x8(%ebp),%eax +c0109e65: 0f b6 00 movzbl (%eax),%eax +c0109e68: 3c 7a cmp $0x7a,%al +c0109e6a: 7f 11 jg c0109e7d + dig = *s - 'a' + 10; +c0109e6c: 8b 45 08 mov 0x8(%ebp),%eax +c0109e6f: 0f b6 00 movzbl (%eax),%eax +c0109e72: 0f be c0 movsbl %al,%eax +c0109e75: 83 e8 57 sub $0x57,%eax +c0109e78: 89 45 f4 mov %eax,-0xc(%ebp) +c0109e7b: eb 23 jmp c0109ea0 + } + else if (*s >= 'A' && *s <= 'Z') { +c0109e7d: 8b 45 08 mov 0x8(%ebp),%eax +c0109e80: 0f b6 00 movzbl (%eax),%eax +c0109e83: 3c 40 cmp $0x40,%al +c0109e85: 7e 3b jle c0109ec2 +c0109e87: 8b 45 08 mov 0x8(%ebp),%eax +c0109e8a: 0f b6 00 movzbl (%eax),%eax +c0109e8d: 3c 5a cmp $0x5a,%al +c0109e8f: 7f 31 jg c0109ec2 + dig = *s - 'A' + 10; +c0109e91: 8b 45 08 mov 0x8(%ebp),%eax +c0109e94: 0f b6 00 movzbl (%eax),%eax +c0109e97: 0f be c0 movsbl %al,%eax +c0109e9a: 83 e8 37 sub $0x37,%eax +c0109e9d: 89 45 f4 mov %eax,-0xc(%ebp) + } + else { break; -c010a068: eb 27 jmp c010a091 - - // unrecognized escape sequence - just print it literally - default: - putch('%', putdat); -c010a06a: 8b 45 0c mov 0xc(%ebp),%eax -c010a06d: 89 44 24 04 mov %eax,0x4(%esp) -c010a071: c7 04 24 25 00 00 00 movl $0x25,(%esp) -c010a078: 8b 45 08 mov 0x8(%ebp),%eax -c010a07b: ff d0 call *%eax - for (fmt --; fmt[-1] != '%'; fmt --) -c010a07d: ff 4d 10 decl 0x10(%ebp) -c010a080: eb 03 jmp c010a085 -c010a082: ff 4d 10 decl 0x10(%ebp) -c010a085: 8b 45 10 mov 0x10(%ebp),%eax -c010a088: 48 dec %eax -c010a089: 0f b6 00 movzbl (%eax),%eax -c010a08c: 3c 25 cmp $0x25,%al -c010a08e: 75 f2 jne c010a082 - /* do nothing */; + } + if (dig >= base) { +c0109ea0: 8b 45 f4 mov -0xc(%ebp),%eax +c0109ea3: 3b 45 10 cmp 0x10(%ebp),%eax +c0109ea6: 7d 19 jge c0109ec1 break; -c010a090: 90 nop - while (1) { -c010a091: e9 36 fc ff ff jmp c0109ccc - return; -c010a096: 90 nop } + s ++, val = (val * base) + dig; +c0109ea8: ff 45 08 incl 0x8(%ebp) +c0109eab: 8b 45 f8 mov -0x8(%ebp),%eax +c0109eae: 0f af 45 10 imul 0x10(%ebp),%eax +c0109eb2: 89 c2 mov %eax,%edx +c0109eb4: 8b 45 f4 mov -0xc(%ebp),%eax +c0109eb7: 01 d0 add %edx,%eax +c0109eb9: 89 45 f8 mov %eax,-0x8(%ebp) + while (1) { +c0109ebc: e9 72 ff ff ff jmp c0109e33 + break; +c0109ec1: 90 nop + // we don't properly detect overflow! } -} -c010a097: 83 c4 40 add $0x40,%esp -c010a09a: 5b pop %ebx -c010a09b: 5e pop %esi -c010a09c: 5d pop %ebp -c010a09d: c3 ret -c010a09e : - * sprintputch - 'print' a single character in a buffer - * @ch: the character will be printed - * @b: the buffer to place the character @ch - * */ -static void -sprintputch(int ch, struct sprintbuf *b) { -c010a09e: f3 0f 1e fb endbr32 -c010a0a2: 55 push %ebp -c010a0a3: 89 e5 mov %esp,%ebp - b->cnt ++; -c010a0a5: 8b 45 0c mov 0xc(%ebp),%eax -c010a0a8: 8b 40 08 mov 0x8(%eax),%eax -c010a0ab: 8d 50 01 lea 0x1(%eax),%edx -c010a0ae: 8b 45 0c mov 0xc(%ebp),%eax -c010a0b1: 89 50 08 mov %edx,0x8(%eax) - if (b->buf < b->ebuf) { -c010a0b4: 8b 45 0c mov 0xc(%ebp),%eax -c010a0b7: 8b 10 mov (%eax),%edx -c010a0b9: 8b 45 0c mov 0xc(%ebp),%eax -c010a0bc: 8b 40 04 mov 0x4(%eax),%eax -c010a0bf: 39 c2 cmp %eax,%edx -c010a0c1: 73 12 jae c010a0d5 - *b->buf ++ = ch; -c010a0c3: 8b 45 0c mov 0xc(%ebp),%eax -c010a0c6: 8b 00 mov (%eax),%eax -c010a0c8: 8d 48 01 lea 0x1(%eax),%ecx -c010a0cb: 8b 55 0c mov 0xc(%ebp),%edx -c010a0ce: 89 0a mov %ecx,(%edx) -c010a0d0: 8b 55 08 mov 0x8(%ebp),%edx -c010a0d3: 88 10 mov %dl,(%eax) + if (endptr) { +c0109ec2: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) +c0109ec6: 74 08 je c0109ed0 + *endptr = (char *) s; +c0109ec8: 8b 45 0c mov 0xc(%ebp),%eax +c0109ecb: 8b 55 08 mov 0x8(%ebp),%edx +c0109ece: 89 10 mov %edx,(%eax) } -} -c010a0d5: 90 nop -c010a0d6: 5d pop %ebp -c010a0d7: c3 ret - -c010a0d8 : - * @str: the buffer to place the result into - * @size: the size of buffer, including the trailing null space - * @fmt: the format string to use + return (neg ? -val : val); +c0109ed0: 83 7d fc 00 cmpl $0x0,-0x4(%ebp) +c0109ed4: 74 07 je c0109edd +c0109ed6: 8b 45 f8 mov -0x8(%ebp),%eax +c0109ed9: f7 d8 neg %eax +c0109edb: eb 03 jmp c0109ee0 +c0109edd: 8b 45 f8 mov -0x8(%ebp),%eax +} +c0109ee0: 89 ec mov %ebp,%esp +c0109ee2: 5d pop %ebp +c0109ee3: c3 ret + +c0109ee4 : + * @n: number of bytes to be set to the value + * + * The memset() function returns @s. * */ -int -snprintf(char *str, size_t size, const char *fmt, ...) { -c010a0d8: f3 0f 1e fb endbr32 -c010a0dc: 55 push %ebp -c010a0dd: 89 e5 mov %esp,%ebp -c010a0df: 83 ec 28 sub $0x28,%esp - va_list ap; - int cnt; - va_start(ap, fmt); -c010a0e2: 8d 45 14 lea 0x14(%ebp),%eax -c010a0e5: 89 45 f0 mov %eax,-0x10(%ebp) - cnt = vsnprintf(str, size, fmt, ap); -c010a0e8: 8b 45 f0 mov -0x10(%ebp),%eax -c010a0eb: 89 44 24 0c mov %eax,0xc(%esp) -c010a0ef: 8b 45 10 mov 0x10(%ebp),%eax -c010a0f2: 89 44 24 08 mov %eax,0x8(%esp) -c010a0f6: 8b 45 0c mov 0xc(%ebp),%eax -c010a0f9: 89 44 24 04 mov %eax,0x4(%esp) -c010a0fd: 8b 45 08 mov 0x8(%ebp),%eax -c010a100: 89 04 24 mov %eax,(%esp) -c010a103: e8 08 00 00 00 call c010a110 -c010a108: 89 45 f4 mov %eax,-0xc(%ebp) - va_end(ap); - return cnt; -c010a10b: 8b 45 f4 mov -0xc(%ebp),%eax +void * +memset(void *s, char c, size_t n) { +c0109ee4: 55 push %ebp +c0109ee5: 89 e5 mov %esp,%ebp +c0109ee7: 83 ec 28 sub $0x28,%esp +c0109eea: 89 7d fc mov %edi,-0x4(%ebp) +c0109eed: 8b 45 0c mov 0xc(%ebp),%eax +c0109ef0: 88 45 d8 mov %al,-0x28(%ebp) +#ifdef __HAVE_ARCH_MEMSET + return __memset(s, c, n); +c0109ef3: 0f be 55 d8 movsbl -0x28(%ebp),%edx +c0109ef7: 8b 45 08 mov 0x8(%ebp),%eax +c0109efa: 89 45 f8 mov %eax,-0x8(%ebp) +c0109efd: 88 55 f7 mov %dl,-0x9(%ebp) +c0109f00: 8b 45 10 mov 0x10(%ebp),%eax +c0109f03: 89 45 f0 mov %eax,-0x10(%ebp) +#ifndef __HAVE_ARCH_MEMSET +#define __HAVE_ARCH_MEMSET +static inline void * +__memset(void *s, char c, size_t n) { + int d0, d1; + asm volatile ( +c0109f06: 8b 4d f0 mov -0x10(%ebp),%ecx +c0109f09: 0f b6 45 f7 movzbl -0x9(%ebp),%eax +c0109f0d: 8b 55 f8 mov -0x8(%ebp),%edx +c0109f10: 89 d7 mov %edx,%edi +c0109f12: f3 aa rep stos %al,%es:(%edi) +c0109f14: 89 fa mov %edi,%edx +c0109f16: 89 4d ec mov %ecx,-0x14(%ebp) +c0109f19: 89 55 e8 mov %edx,-0x18(%ebp) + "rep; stosb;" + : "=&c" (d0), "=&D" (d1) + : "0" (n), "a" (c), "1" (s) + : "memory"); + return s; +c0109f1c: 8b 45 f8 mov -0x8(%ebp),%eax + while (n -- > 0) { + *p ++ = c; + } + return s; +#endif /* __HAVE_ARCH_MEMSET */ } -c010a10e: c9 leave -c010a10f: c3 ret +c0109f1f: 8b 7d fc mov -0x4(%ebp),%edi +c0109f22: 89 ec mov %ebp,%esp +c0109f24: 5d pop %ebp +c0109f25: c3 ret -c010a110 : +c0109f26 : + * @n: number of bytes to copy * - * Call this function if you are already dealing with a va_list. - * Or you probably want snprintf() instead. + * The memmove() function returns @dst. * */ -int -vsnprintf(char *str, size_t size, const char *fmt, va_list ap) { -c010a110: f3 0f 1e fb endbr32 -c010a114: 55 push %ebp -c010a115: 89 e5 mov %esp,%ebp -c010a117: 83 ec 28 sub $0x28,%esp - struct sprintbuf b = {str, str + size - 1, 0}; -c010a11a: 8b 45 08 mov 0x8(%ebp),%eax -c010a11d: 89 45 ec mov %eax,-0x14(%ebp) -c010a120: 8b 45 0c mov 0xc(%ebp),%eax -c010a123: 8d 50 ff lea -0x1(%eax),%edx -c010a126: 8b 45 08 mov 0x8(%ebp),%eax -c010a129: 01 d0 add %edx,%eax -c010a12b: 89 45 f0 mov %eax,-0x10(%ebp) -c010a12e: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) - if (str == NULL || b.buf > b.ebuf) { -c010a135: 83 7d 08 00 cmpl $0x0,0x8(%ebp) -c010a139: 74 0a je c010a145 -c010a13b: 8b 55 ec mov -0x14(%ebp),%edx -c010a13e: 8b 45 f0 mov -0x10(%ebp),%eax -c010a141: 39 c2 cmp %eax,%edx -c010a143: 76 07 jbe c010a14c - return -E_INVAL; -c010a145: b8 fd ff ff ff mov $0xfffffffd,%eax -c010a14a: eb 2a jmp c010a176 +void * +memmove(void *dst, const void *src, size_t n) { +c0109f26: 55 push %ebp +c0109f27: 89 e5 mov %esp,%ebp +c0109f29: 57 push %edi +c0109f2a: 56 push %esi +c0109f2b: 53 push %ebx +c0109f2c: 83 ec 30 sub $0x30,%esp +c0109f2f: 8b 45 08 mov 0x8(%ebp),%eax +c0109f32: 89 45 f0 mov %eax,-0x10(%ebp) +c0109f35: 8b 45 0c mov 0xc(%ebp),%eax +c0109f38: 89 45 ec mov %eax,-0x14(%ebp) +c0109f3b: 8b 45 10 mov 0x10(%ebp),%eax +c0109f3e: 89 45 e8 mov %eax,-0x18(%ebp) + +#ifndef __HAVE_ARCH_MEMMOVE +#define __HAVE_ARCH_MEMMOVE +static inline void * +__memmove(void *dst, const void *src, size_t n) { + if (dst < src) { +c0109f41: 8b 45 f0 mov -0x10(%ebp),%eax +c0109f44: 3b 45 ec cmp -0x14(%ebp),%eax +c0109f47: 73 42 jae c0109f8b +c0109f49: 8b 45 f0 mov -0x10(%ebp),%eax +c0109f4c: 89 45 e4 mov %eax,-0x1c(%ebp) +c0109f4f: 8b 45 ec mov -0x14(%ebp),%eax +c0109f52: 89 45 e0 mov %eax,-0x20(%ebp) +c0109f55: 8b 45 e8 mov -0x18(%ebp),%eax +c0109f58: 89 45 dc mov %eax,-0x24(%ebp) + "andl $3, %%ecx;" + "jz 1f;" + "rep; movsb;" + "1:" + : "=&c" (d0), "=&D" (d1), "=&S" (d2) + : "0" (n / 4), "g" (n), "1" (dst), "2" (src) +c0109f5b: 8b 45 dc mov -0x24(%ebp),%eax +c0109f5e: c1 e8 02 shr $0x2,%eax +c0109f61: 89 c1 mov %eax,%ecx + asm volatile ( +c0109f63: 8b 55 e4 mov -0x1c(%ebp),%edx +c0109f66: 8b 45 e0 mov -0x20(%ebp),%eax +c0109f69: 89 d7 mov %edx,%edi +c0109f6b: 89 c6 mov %eax,%esi +c0109f6d: f3 a5 rep movsl %ds:(%esi),%es:(%edi) +c0109f6f: 8b 4d dc mov -0x24(%ebp),%ecx +c0109f72: 83 e1 03 and $0x3,%ecx +c0109f75: 74 02 je c0109f79 +c0109f77: f3 a4 rep movsb %ds:(%esi),%es:(%edi) +c0109f79: 89 f0 mov %esi,%eax +c0109f7b: 89 fa mov %edi,%edx +c0109f7d: 89 4d d8 mov %ecx,-0x28(%ebp) +c0109f80: 89 55 d4 mov %edx,-0x2c(%ebp) +c0109f83: 89 45 d0 mov %eax,-0x30(%ebp) + : "memory"); + return dst; +c0109f86: 8b 45 e4 mov -0x1c(%ebp),%eax + return __memcpy(dst, src, n); +c0109f89: eb 36 jmp c0109fc1 + : "0" (n), "1" (n - 1 + src), "2" (n - 1 + dst) +c0109f8b: 8b 45 e8 mov -0x18(%ebp),%eax +c0109f8e: 8d 50 ff lea -0x1(%eax),%edx +c0109f91: 8b 45 ec mov -0x14(%ebp),%eax +c0109f94: 01 c2 add %eax,%edx +c0109f96: 8b 45 e8 mov -0x18(%ebp),%eax +c0109f99: 8d 48 ff lea -0x1(%eax),%ecx +c0109f9c: 8b 45 f0 mov -0x10(%ebp),%eax +c0109f9f: 8d 1c 01 lea (%ecx,%eax,1),%ebx + asm volatile ( +c0109fa2: 8b 45 e8 mov -0x18(%ebp),%eax +c0109fa5: 89 c1 mov %eax,%ecx +c0109fa7: 89 d8 mov %ebx,%eax +c0109fa9: 89 d6 mov %edx,%esi +c0109fab: 89 c7 mov %eax,%edi +c0109fad: fd std +c0109fae: f3 a4 rep movsb %ds:(%esi),%es:(%edi) +c0109fb0: fc cld +c0109fb1: 89 f8 mov %edi,%eax +c0109fb3: 89 f2 mov %esi,%edx +c0109fb5: 89 4d cc mov %ecx,-0x34(%ebp) +c0109fb8: 89 55 c8 mov %edx,-0x38(%ebp) +c0109fbb: 89 45 c4 mov %eax,-0x3c(%ebp) + return dst; +c0109fbe: 8b 45 f0 mov -0x10(%ebp),%eax + *d ++ = *s ++; + } } - // print the string to the buffer - vprintfmt((void*)sprintputch, &b, fmt, ap); -c010a14c: 8b 45 14 mov 0x14(%ebp),%eax -c010a14f: 89 44 24 0c mov %eax,0xc(%esp) -c010a153: 8b 45 10 mov 0x10(%ebp),%eax -c010a156: 89 44 24 08 mov %eax,0x8(%esp) -c010a15a: 8d 45 ec lea -0x14(%ebp),%eax -c010a15d: 89 44 24 04 mov %eax,0x4(%esp) -c010a161: c7 04 24 9e a0 10 c0 movl $0xc010a09e,(%esp) -c010a168: e8 53 fb ff ff call c0109cc0 - // null terminate the buffer - *b.buf = '\0'; -c010a16d: 8b 45 ec mov -0x14(%ebp),%eax -c010a170: c6 00 00 movb $0x0,(%eax) - return b.cnt; -c010a173: 8b 45 f4 mov -0xc(%ebp),%eax + return dst; +#endif /* __HAVE_ARCH_MEMMOVE */ } -c010a176: c9 leave -c010a177: c3 ret +c0109fc1: 83 c4 30 add $0x30,%esp +c0109fc4: 5b pop %ebx +c0109fc5: 5e pop %esi +c0109fc6: 5f pop %edi +c0109fc7: 5d pop %ebp +c0109fc8: c3 ret -c010a178 : - * @bits: the number of bits in a return value - * - * High bits are more random, so we use them. +c0109fc9 : + * it always copies exactly @n bytes. To avoid overflows, the size of arrays pointed + * by both @src and @dst, should be at least @n bytes, and should not overlap + * (for overlapping memory area, memmove is a safer approach). * */ -uint32_t -hash32(uint32_t val, unsigned int bits) { -c010a178: f3 0f 1e fb endbr32 -c010a17c: 55 push %ebp -c010a17d: 89 e5 mov %esp,%ebp -c010a17f: 83 ec 10 sub $0x10,%esp - uint32_t hash = val * GOLDEN_RATIO_PRIME_32; -c010a182: 8b 45 08 mov 0x8(%ebp),%eax -c010a185: 69 c0 01 00 37 9e imul $0x9e370001,%eax,%eax -c010a18b: 89 45 fc mov %eax,-0x4(%ebp) - return (hash >> (32 - bits)); -c010a18e: b8 20 00 00 00 mov $0x20,%eax -c010a193: 2b 45 0c sub 0xc(%ebp),%eax -c010a196: 8b 55 fc mov -0x4(%ebp),%edx -c010a199: 88 c1 mov %al,%cl -c010a19b: d3 ea shr %cl,%edx -c010a19d: 89 d0 mov %edx,%eax +void * +memcpy(void *dst, const void *src, size_t n) { +c0109fc9: 55 push %ebp +c0109fca: 89 e5 mov %esp,%ebp +c0109fcc: 57 push %edi +c0109fcd: 56 push %esi +c0109fce: 83 ec 20 sub $0x20,%esp +c0109fd1: 8b 45 08 mov 0x8(%ebp),%eax +c0109fd4: 89 45 f4 mov %eax,-0xc(%ebp) +c0109fd7: 8b 45 0c mov 0xc(%ebp),%eax +c0109fda: 89 45 f0 mov %eax,-0x10(%ebp) +c0109fdd: 8b 45 10 mov 0x10(%ebp),%eax +c0109fe0: 89 45 ec mov %eax,-0x14(%ebp) + : "0" (n / 4), "g" (n), "1" (dst), "2" (src) +c0109fe3: 8b 45 ec mov -0x14(%ebp),%eax +c0109fe6: c1 e8 02 shr $0x2,%eax +c0109fe9: 89 c1 mov %eax,%ecx + asm volatile ( +c0109feb: 8b 55 f4 mov -0xc(%ebp),%edx +c0109fee: 8b 45 f0 mov -0x10(%ebp),%eax +c0109ff1: 89 d7 mov %edx,%edi +c0109ff3: 89 c6 mov %eax,%esi +c0109ff5: f3 a5 rep movsl %ds:(%esi),%es:(%edi) +c0109ff7: 8b 4d ec mov -0x14(%ebp),%ecx +c0109ffa: 83 e1 03 and $0x3,%ecx +c0109ffd: 74 02 je c010a001 +c0109fff: f3 a4 rep movsb %ds:(%esi),%es:(%edi) +c010a001: 89 f0 mov %esi,%eax +c010a003: 89 fa mov %edi,%edx +c010a005: 89 4d e8 mov %ecx,-0x18(%ebp) +c010a008: 89 55 e4 mov %edx,-0x1c(%ebp) +c010a00b: 89 45 e0 mov %eax,-0x20(%ebp) + return dst; +c010a00e: 8b 45 f4 mov -0xc(%ebp),%eax + while (n -- > 0) { + *d ++ = *s ++; + } + return dst; +#endif /* __HAVE_ARCH_MEMCPY */ } -c010a19f: c9 leave -c010a1a0: c3 ret +c010a011: 83 c4 20 add $0x20,%esp +c010a014: 5e pop %esi +c010a015: 5f pop %edi +c010a016: 5d pop %ebp +c010a017: c3 ret -c010a1a1 : - * rand - returns a pseudo-random integer - * - * The rand() function return a value in the range [0, RAND_MAX]. +c010a018 : + * match in both memory blocks has a greater value in @v1 than in @v2 + * as if evaluated as unsigned char values; + * - And a value less than zero indicates the opposite. * */ int -rand(void) { -c010a1a1: f3 0f 1e fb endbr32 -c010a1a5: 55 push %ebp -c010a1a6: 89 e5 mov %esp,%ebp -c010a1a8: 57 push %edi -c010a1a9: 56 push %esi -c010a1aa: 53 push %ebx -c010a1ab: 83 ec 24 sub $0x24,%esp - next = (next * 0x5DEECE66DLL + 0xBLL) & ((1LL << 48) - 1); -c010a1ae: a1 78 8a 12 c0 mov 0xc0128a78,%eax -c010a1b3: 8b 15 7c 8a 12 c0 mov 0xc0128a7c,%edx -c010a1b9: 69 fa 6d e6 ec de imul $0xdeece66d,%edx,%edi -c010a1bf: 6b f0 05 imul $0x5,%eax,%esi -c010a1c2: 01 fe add %edi,%esi -c010a1c4: bf 6d e6 ec de mov $0xdeece66d,%edi -c010a1c9: f7 e7 mul %edi -c010a1cb: 01 d6 add %edx,%esi -c010a1cd: 89 f2 mov %esi,%edx -c010a1cf: 83 c0 0b add $0xb,%eax -c010a1d2: 83 d2 00 adc $0x0,%edx -c010a1d5: 89 c7 mov %eax,%edi -c010a1d7: 83 e7 ff and $0xffffffff,%edi -c010a1da: 89 f9 mov %edi,%ecx -c010a1dc: 0f b7 da movzwl %dx,%ebx -c010a1df: 89 0d 78 8a 12 c0 mov %ecx,0xc0128a78 -c010a1e5: 89 1d 7c 8a 12 c0 mov %ebx,0xc0128a7c - unsigned long long result = (next >> 12); -c010a1eb: a1 78 8a 12 c0 mov 0xc0128a78,%eax -c010a1f0: 8b 15 7c 8a 12 c0 mov 0xc0128a7c,%edx -c010a1f6: 0f ac d0 0c shrd $0xc,%edx,%eax -c010a1fa: c1 ea 0c shr $0xc,%edx -c010a1fd: 89 45 e0 mov %eax,-0x20(%ebp) -c010a200: 89 55 e4 mov %edx,-0x1c(%ebp) - return (int)do_div(result, RAND_MAX + 1); -c010a203: c7 45 dc 00 00 00 80 movl $0x80000000,-0x24(%ebp) -c010a20a: 8b 45 e0 mov -0x20(%ebp),%eax -c010a20d: 8b 55 e4 mov -0x1c(%ebp),%edx -c010a210: 89 45 d8 mov %eax,-0x28(%ebp) -c010a213: 89 55 e8 mov %edx,-0x18(%ebp) -c010a216: 8b 45 e8 mov -0x18(%ebp),%eax -c010a219: 89 45 ec mov %eax,-0x14(%ebp) -c010a21c: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) -c010a220: 74 1c je c010a23e -c010a222: 8b 45 e8 mov -0x18(%ebp),%eax -c010a225: ba 00 00 00 00 mov $0x0,%edx -c010a22a: f7 75 dc divl -0x24(%ebp) -c010a22d: 89 55 ec mov %edx,-0x14(%ebp) -c010a230: 8b 45 e8 mov -0x18(%ebp),%eax -c010a233: ba 00 00 00 00 mov $0x0,%edx -c010a238: f7 75 dc divl -0x24(%ebp) -c010a23b: 89 45 e8 mov %eax,-0x18(%ebp) -c010a23e: 8b 45 d8 mov -0x28(%ebp),%eax -c010a241: 8b 55 ec mov -0x14(%ebp),%edx -c010a244: f7 75 dc divl -0x24(%ebp) -c010a247: 89 45 d8 mov %eax,-0x28(%ebp) -c010a24a: 89 55 d4 mov %edx,-0x2c(%ebp) -c010a24d: 8b 45 d8 mov -0x28(%ebp),%eax -c010a250: 8b 55 e8 mov -0x18(%ebp),%edx -c010a253: 89 45 e0 mov %eax,-0x20(%ebp) -c010a256: 89 55 e4 mov %edx,-0x1c(%ebp) -c010a259: 8b 45 d4 mov -0x2c(%ebp),%eax -} -c010a25c: 83 c4 24 add $0x24,%esp -c010a25f: 5b pop %ebx -c010a260: 5e pop %esi -c010a261: 5f pop %edi -c010a262: 5d pop %ebp -c010a263: c3 ret - -c010a264 : -/* * - * srand - seed the random number generator with the given number - * @seed: the required seed number - * */ -void -srand(unsigned int seed) { -c010a264: f3 0f 1e fb endbr32 -c010a268: 55 push %ebp -c010a269: 89 e5 mov %esp,%ebp - next = seed; -c010a26b: 8b 45 08 mov 0x8(%ebp),%eax -c010a26e: ba 00 00 00 00 mov $0x0,%edx -c010a273: a3 78 8a 12 c0 mov %eax,0xc0128a78 -c010a278: 89 15 7c 8a 12 c0 mov %edx,0xc0128a7c -} -c010a27e: 90 nop -c010a27f: 5d pop %ebp -c010a280: c3 ret +memcmp(const void *v1, const void *v2, size_t n) { +c010a018: 55 push %ebp +c010a019: 89 e5 mov %esp,%ebp +c010a01b: 83 ec 10 sub $0x10,%esp + const char *s1 = (const char *)v1; +c010a01e: 8b 45 08 mov 0x8(%ebp),%eax +c010a021: 89 45 fc mov %eax,-0x4(%ebp) + const char *s2 = (const char *)v2; +c010a024: 8b 45 0c mov 0xc(%ebp),%eax +c010a027: 89 45 f8 mov %eax,-0x8(%ebp) + while (n -- > 0) { +c010a02a: eb 2e jmp c010a05a + if (*s1 != *s2) { +c010a02c: 8b 45 fc mov -0x4(%ebp),%eax +c010a02f: 0f b6 10 movzbl (%eax),%edx +c010a032: 8b 45 f8 mov -0x8(%ebp),%eax +c010a035: 0f b6 00 movzbl (%eax),%eax +c010a038: 38 c2 cmp %al,%dl +c010a03a: 74 18 je c010a054 + return (int)((unsigned char)*s1 - (unsigned char)*s2); +c010a03c: 8b 45 fc mov -0x4(%ebp),%eax +c010a03f: 0f b6 00 movzbl (%eax),%eax +c010a042: 0f b6 d0 movzbl %al,%edx +c010a045: 8b 45 f8 mov -0x8(%ebp),%eax +c010a048: 0f b6 00 movzbl (%eax),%eax +c010a04b: 0f b6 c8 movzbl %al,%ecx +c010a04e: 89 d0 mov %edx,%eax +c010a050: 29 c8 sub %ecx,%eax +c010a052: eb 18 jmp c010a06c + } + s1 ++, s2 ++; +c010a054: ff 45 fc incl -0x4(%ebp) +c010a057: ff 45 f8 incl -0x8(%ebp) + while (n -- > 0) { +c010a05a: 8b 45 10 mov 0x10(%ebp),%eax +c010a05d: 8d 50 ff lea -0x1(%eax),%edx +c010a060: 89 55 10 mov %edx,0x10(%ebp) +c010a063: 85 c0 test %eax,%eax +c010a065: 75 c5 jne c010a02c + } + return 0; +c010a067: b8 00 00 00 00 mov $0x0,%eax +} +c010a06c: 89 ec mov %ebp,%esp +c010a06e: 5d pop %ebp +c010a06f: c3 ret diff --git a/labcodes/lab4/obj/kernel.sym b/labcodes/lab4/obj/kernel.sym index d7f21eb5e05dae33233961827ffa024b4fa66a69..379f6ba93e87c6ba89843fa2f315a671b84f70d4 100644 --- a/labcodes/lab4/obj/kernel.sym +++ b/labcodes/lab4/obj/kernel.sym @@ -1,611 +1,603 @@ -c0100000 .text -c010a2a0 .rodata -c010c5dc .stab -c0120f4d .stabstr -c0126000 .data -c0129000 .data.pgdir -c012b000 .bss -00000000 .comment -00000000 obj/kern/init/entry.o +00000000 entry.o c010001e next c0100034 spin c012a000 __boot_pt1 00000400 i 00000000 init.c -c010015c lab1_print_cur_status -c012b000 round.1862 -c010021e lab1_switch_to_user -c010022f lab1_switch_to_kernel -c010023d lab1_switch_test -00000000 stdio.c -c010027b cputch +c0100156 lab1_print_cur_status +c012b000 round.0 +c0100216 lab1_switch_to_user +c0100223 lab1_switch_to_kernel +c010022d lab1_switch_test 00000000 readline.c c012b020 buf -00000000 panic.c -c012b420 is_panic +00000000 stdio.c +c0100320 cputch 00000000 kdebug.c -c010051e stab_binsearch -c0100ad7 read_eip +c0100423 stab_binsearch +c01009d4 read_eip 00000000 kmonitor.c c0128000 commands -c0100af6 parse -c0100bb1 runcmd -00000000 ide.c -c010a58c channels -c012b440 ide_devices -c0100d59 ide_wait_ready +c01009ed parse +c0100aa6 runcmd +00000000 panic.c +c012b420 is_panic 00000000 clock.c 00000000 console.c -c0101633 __intr_save -c010165d __intr_restore -c0101671 delay -c012b520 crt_buf -c012b524 crt_pos -c012b526 addr_6845 -c01016be cga_init -c012b528 serial_exists -c01017a8 serial_init -c0101897 lpt_putc_sub -c0101917 lpt_putc -c010195b cga_putc -c0101b51 serial_putc_sub -c0101baf serial_putc -c012b540 cons -c0101bf3 cons_intr -c0101c44 serial_proc_data +c0100d7f __intr_save +c0100dab __intr_restore +c0100dc1 delay +c012b440 crt_buf +c012b444 crt_pos +c012b446 addr_6845 +c0100e0c cga_init +c012b448 serial_exists +c0100ef4 serial_init +c0100fe1 lpt_putc_sub +c010105f lpt_putc +c01010a1 cga_putc +c0101297 serial_putc_sub +c01012f3 serial_putc +c012b460 cons +c0101335 cons_intr +c0101384 serial_proc_data c0128040 shiftcode c0128140 togglecode c0128240 normalmap c0128340 shiftmap c0128440 ctlmap c0128540 charcode -c0101cc1 kbd_proc_data -c012b748 shift.1590 -c0101e4a kbd_intr -c0101e63 kbd_init +c01013fd kbd_proc_data +c012b668 shift.0 +c0101584 kbd_intr +c010159b kbd_init +00000000 ide.c +c010a3b4 channels +c012b680 ide_devices +c0101696 ide_wait_ready +00000000 intr.c 00000000 picirq.c c0128550 irq_mask -c012b74c did_init -c0101f66 pic_setmask -00000000 intr.c +c012b760 did_init +c0101f03 pic_setmask 00000000 trap.c -c0102160 print_ticks -c012b760 idt +c01020df print_ticks +c012b7e0 idt c0128560 idt_pd -c01022f8 trapname -c010ab40 excnames.1683 +c0102273 trapname +c010a920 excnames.0 c0128580 IA32flags -c01025b7 print_pgfault -c0102635 pgfault_handler -c012bf60 in_swap_tick_event -c0102697 trap_dispatch +c0102526 print_pgfault +c01025a7 pgfault_handler +c012bfe0 in_swap_tick_event +c0102607 trap_dispatch +00000000 default_pmm.c +c0103338 page2ppn +c010334b page2pa +c0103363 page_ref +c010336d set_page_ref +c010337b default_init +c01033ac default_init_memmap +c01034f9 default_alloc_pages +c010367d default_free_pages +c0103995 default_nr_free_pages +c010399f basic_check +c0103edf default_check +00000000 kmalloc.c +c0104531 __intr_save +c010455d __intr_restore +c0104573 page2ppn +c0104586 page2pa +c010459e pa2page +c01045e6 page2kva +c010463c kva2page +c01289e0 arena +c01289e8 slobfree +c012bff0 bigblocks +c0104688 __slob_get_free_pages +c01046c3 __slob_free_pages +c01046fb slob_alloc +c01048ce slob_free +c0104a31 find_order +c0104a56 __kmalloc 00000000 pmm.c -c010342a page2ppn -c010343e page2pa -c0103454 pa2page -c0103499 page2kva -c01034ed pte2page -c010352b pde2page -c0103543 page_ref -c010354d set_page_ref -c010355b page_ref_inc -c0103572 page_ref_dec -c0103589 __intr_save -c01035b3 __intr_restore -c012bfa0 ts -c0128a00 gdt -c0128a30 gdt_pd -c01035c7 lgdt -c010360f gdt_init -c01036fd init_pmm_manager -c0103735 init_memmap -c010382e page_init -c0103bea boot_map_segment -c0103cf2 boot_alloc_page -c010425b check_alloc_page -c010427e check_pgdir -c010491e check_boot_pgdir -c0103fc3 page_remove_pte -c0104cac perm2str -c012c008 str.1871 -c0104cf2 get_pgtable_items +c0104ca8 page2ppn +c0104cbb page2pa +c0104cd3 pa2page +c0104d1b page2kva +c0104d71 pte2page +c0104db1 pde2page +c0104dcb page_ref +c0104dd5 set_page_ref +c0104de3 page_ref_inc +c0104dfa page_ref_dec +c0104e11 __intr_save +c0104e3d __intr_restore +c012c020 ts +c0128a20 gdt +c0128a50 gdt_pd +c0104e53 lgdt +c0104e97 gdt_init +c0104f83 init_pmm_manager +c0104fb9 init_memmap +c01050aa page_init +c010545d boot_map_segment +c0105563 boot_alloc_page +c0105abe check_alloc_page +c0105adf check_pgdir +c010617d check_boot_pgdir +c010582c page_remove_pte +c0106509 perm2str +c012c088 str.0 +c010654b get_pgtable_items +00000000 swap.c +c0106766 pa2page +c01067ae pte2page +c012c160 sm +c0106d29 check_swap +c0106b54 check_content_set +c0106d0f check_content_access 00000000 swap_fifo.c -c0104f1b _fifo_init_mm -c0104f52 _fifo_map_swappable -c0104ff9 _fifo_swap_out_victim -c0105100 _fifo_check_swap -c0105459 _fifo_init -c0105467 _fifo_set_unswappable -c0105475 _fifo_tick_event +c0107383 _fifo_init_mm +c01073b8 _fifo_map_swappable +c010745d _fifo_swap_out_victim +c0107562 _fifo_check_swap +c01078b9 _fifo_init +c01078c3 _fifo_set_unswappable +c01078cd _fifo_tick_event 00000000 vmm.c -c0105483 pa2page -c01054c8 pde2page -c0105651 check_vma_overlap -c01058c6 check_vmm -c010591f check_vma_struct -c0105db5 check_pgfault -00000000 kmalloc.c -c0106216 __intr_save -c0106240 __intr_restore -c0106254 page2ppn -c0106268 page2pa -c010627e pa2page -c01062c3 page2kva -c0106317 kva2page -c0128a60 arena -c0128a68 slobfree -c012c010 bigblocks -c0106361 __slob_get_free_pages -c010639e __slob_free_pages -c01063d3 slob_alloc -c01065a8 slob_free -c0106719 find_order -c0106740 __kmalloc -00000000 swap.c -c010699a pa2page -c01069df pte2page -c012c01c sm -c0106f62 check_swap -c0106d91 check_content_set -c0106f4a check_content_access -00000000 default_pmm.c -c01075be page2ppn -c01075d2 page2pa -c01075e8 page_ref -c01075f2 set_page_ref -c0107600 default_init -c0107633 default_init_memmap -c0107782 default_alloc_pages -c0107908 default_free_pages -c0107c22 default_nr_free_pages -c0107c30 basic_check -c0108172 default_check +c01078d7 pa2page +c010791f pde2page +c0107aa4 check_vma_overlap +c0107d05 check_vmm +c0107d2e check_vma_struct +c01081c2 check_pgfault 00000000 swapfs.c -c01087c6 page2ppn -c01087da page2pa -c01087f0 page2kva +c010861f page2ppn +c0108632 page2pa +c010864a page2kva 00000000 proc.c -c01089bd __intr_save -c01089e7 __intr_restore -c01089fb page2ppn -c0108a0f page2pa -c0108a25 pa2page -c0108a6a page2kva -c0108abe kva2page -c012c040 hash_list -c012e040 nr_process -c0108b08 alloc_proc -c012e044 name.1770 -c0108c5e get_pid -c0128a6c last_pid.1780 -c0128a70 next_safe.1779 -c0108dd2 forkret -c0108def hash_proc -c0108f61 setup_kstack -c0108fa1 put_kstack -c0108fcc copy_mm -c010900d copy_thread -c0109280 init_main +c01087dc __intr_save +c0108808 __intr_restore +c010881e page2ppn +c0108831 page2pa +c0108849 pa2page +c0108891 page2kva +c01088e7 kva2page +c012c1a0 hash_list +c012e1a0 nr_process +c0108933 alloc_proc +c012e1a4 name.2 +c0108a83 get_pid +c0128a80 last_pid.1 +c0128a84 next_safe.0 +c0108bf3 forkret +c0108c0e hash_proc +c0108d7b setup_kstack +c0108db9 put_kstack +c0108de2 copy_mm +c0108e21 copy_thread +c0109086 init_main 00000000 sched.c -c01094ba __intr_save -c01094e4 __intr_restore -00000000 string.c -00000000 printfmt.c -c010c444 error_string -c0109aeb printnum -c0109bef getuint -c0109c42 getint -c010a09e sprintputch +c01092ef __intr_save +c010931b __intr_restore 00000000 hash.c +00000000 printfmt.c +c010c220 error_string +c010946e printnum +c0109570 getuint +c01095bf getint +c0109a10 sprintputch 00000000 rand.c -c0128a78 next -c010335a vector242 -c0102db1 vector119 -c010099a print_kerninfo -c0102c91 vector87 -c0102c88 vector86 -c01033c6 vector251 -c0109670 strcpy -c01010bd ide_device_valid -c0102cb5 vector91 -c0102aab vector33 -c0102f9a vector162 -c01031fe vector213 -c0102d4e vector108 -c0102b05 vector43 -c01066fd slob_allocated +c0128a88 next +00000000 string.c +c0103290 vector242 +c0102ce7 vector119 +c010089b print_kerninfo +c0102bc7 vector87 +c0102bbe vector86 +c01032fc vector251 +c0109c14 strcpy +c01019f4 ide_device_valid +c0102beb vector91 +c01029e1 vector33 +c0102ed0 vector162 +c0103134 vector213 +c0102c84 vector108 +c0102a3b vector43 +c0104a1d slob_allocated c0100000 kern_entry -c0100d43 mon_backtrace -c0102fbe vector165 -c01030ae vector185 -c0102d8d vector115 -c0102dcc vector122 -c010406e page_insert -c0102f52 vector156 -c010337e vector245 -c01030de vector189 -c01029cf vector7 -c0102ba7 vector61 -c0102a5a vector24 -c0102d69 vector111 -c0103162 vector200 -c0102bdd vector67 -c01094f8 wakeup_proc -c010670b kallocated -c010418c pgdir_alloc_page -c0102e7a vector138 -c0102c1c vector74 -c0109997 memmove -c0102b83 vector57 -c01054e0 mm_create -c010a0d8 snprintf -c0102346 print_trapframe -c010320a vector214 -c0109cc0 vprintfmt -c0102cfd vector99 -c0103f66 get_page -c0103402 __alltraps -c0101ef3 cons_getc -c0102e9e vector141 -c0100510 is_kernel_panic -c0103012 vector172 -c0100aec print_stackframe -c010334e vector241 -c012e0bc pra_list_head -c01033de vector253 -c01029ab vector3 -c0103424 forkrets -c01029a2 vector2 -c01090f7 do_fork -c01032a6 vector227 -c0108ee9 kernel_thread -c01031da vector210 -c012c020 idleproc -c0103282 vector224 -c0102af3 vector41 -c0128a40 swap_manager_fifo -c01002d7 cprintf -c012e1b0 proc_list -c0102a3f vector21 -c010304e vector177 -c0102da8 vector118 -c0102bf8 vector70 -c0102bef vector69 -c010331e vector237 -c0102bc2 vector64 -c0102a75 vector27 -c01058b4 vmm_init -c0102e32 vector132 -c01030ba vector186 -c010322e vector217 -c010582e mm_destroy -c01089b4 kernel_thread_entry -c0109a3e memcpy -c0102999 vector1 -c010305a vector178 -c0102ad8 vector38 -c0106855 kfree -c010332a vector238 -c010038a readline -c0102e3e vector133 -c0102c13 vector73 -c0102ec2 vector144 -c010ac0c vpd +c0100c31 mon_backtrace +c0102ef4 vector165 +c0102fe4 vector185 +c0102cc3 vector115 +c0102d02 vector122 +c01058d7 page_insert +c0102e88 vector156 +c01032b4 vector245 +c0103014 vector189 +c0102905 vector7 +c0102add vector61 +c0102990 vector24 +c0102c9f vector111 +c0103098 vector200 +c0102b13 vector67 +c0109331 wakeup_proc +c0104a27 kallocated +c01059f1 pgdir_alloc_page +c0102db0 vector138 +c0102b52 vector74 +c0109f26 memmove +c0102ab9 vector57 +c0107939 mm_create +c0109a46 snprintf +c01022b9 print_trapframe +c0103140 vector214 +c0109637 vprintfmt +c0102c33 vector99 +c01057d1 get_page +c010289e __alltraps +c0101625 cons_getc +c0102dd4 vector141 +c0100d0c is_kernel_panic +c0102f48 vector172 +c01009e7 print_stackframe +c0103284 vector241 +c012c164 pra_list_head +c0103314 vector253 +c01028e1 vector3 +c01028c0 forkrets +c01028d8 vector2 +c0108f07 do_fork +c01031dc vector227 +c0108d05 kernel_thread +c0103110 vector210 +c012c188 idleproc +c01031b8 vector224 +c0102a29 vector41 +c0128a60 swap_manager_fifo +c0100378 cprintf +c012c180 proc_list +c0102975 vector21 +c0102f84 vector177 +c0102cde vector118 +c0102b2e vector70 +c0102b25 vector69 +c0103254 vector237 +c0102af8 vector64 +c01029ab vector27 +c0107cf5 vmm_init +c0102d68 vector132 +c0102ff0 vector186 +c0103164 vector217 +c0107c81 mm_destroy +c01087d3 kernel_thread_entry +c0109fc9 memcpy +c01028cf vector1 +c0102f90 vector178 +c0102a0e vector38 +c0104b67 kfree +c0103260 vector238 +c0100269 readline +c0102d74 vector133 +c0102b49 vector73 +c0102df8 vector144 +c010ae88 vpd c0100036 kern_init -c01033ea vector254 -c0102d0f vector101 -c01031e6 vector211 -c010302a vector174 -c0103366 vector243 -c0102e02 vector128 -c0102c5b vector81 -c01037c8 free_pages -c01029fd vector13 -c010a110 vsnprintf -c0102b4d vector51 -c0102a14 vector16 +c0103320 vector254 +c0102c45 vector101 +c010311c vector211 +c0102f60 vector174 +c010329c vector243 +c0102d38 vector128 +c0102b91 vector81 +c0105048 free_pages +c0102933 vector13 +c0109a7c vsnprintf +c0102a83 vector51 +c010294a vector16 c012b000 edata -c0101e81 cons_init -c0106cb7 swap_in -c0101383 ide_write_secs -c012e0b0 pmm_manager -c0103342 vector240 -c0102b68 vector54 -c0102a2d vector19 -c0120f4c __STAB_END__ -c0102cbe vector92 -c0103372 vector244 -c012c014 swap_init_ok -c01035fd load_esp0 -c0102e92 vector140 -c0102b17 vector45 -c0102c49 vector79 -c01032be vector229 -c0106a1d swap_init -c0102f6a vector158 -c0101fc5 pic_enable -c0108844 swapfs_init -c012e0e0 check_rp -c0102ae1 vector39 -c0102fe2 vector168 -c0102abd vector35 -c0102d7b vector113 -c0120f4d __STABSTR_BEGIN__ -c0102de7 vector125 -c0100443 __panic -c012c024 initproc -c0103222 vector216 -c0102bb9 vector63 -c0102a6c vector26 -c0101c9f serial_intr -c010310e vector193 -c0103132 vector196 -c0100113 grade_backtrace0 -c01031ce vector209 -c01029b4 vector4 -c0102ffa vector170 -c0109546 schedule -c0102e62 vector136 -c01029e8 vector10 -c01031aa vector206 -c01033f6 vector255 -c010307e vector181 -c0102b95 vector59 -c0100132 grade_backtrace -c0102c7f vector85 -c0102c76 vector84 -c010897d switch_to -c0103096 vector183 -c0102f76 vector159 -c01031f2 vector212 -c0102b29 vector47 -c01097fa strtol -c01032b2 vector228 -c0102afc vector42 -c0102d84 vector114 -c010963d strnlen -c0103036 vector175 -c0102eb6 vector143 -c0102e1a vector130 -c010c12c default_pmm_manager -c010338a vector246 -c01029df vector9 -c0102eaa vector142 -c0102d06 vector100 -c010316e vector201 -c0102181 idt_init -c0100a30 print_debuginfo -c010559c find_vma -c012e100 swap_in_seq_no -c0102b9e vector60 -c0102a51 vector23 -c0103312 vector236 -c012bf80 npage -c0105ffd do_pgfault -c01032d6 vector231 -c0108bd1 set_proc_name -c0102bd4 vector66 -c0102a87 vector29 -c0104da8 print_pgdir -c0102e56 vector135 -c0100c6a kmonitor -c0102c37 vector77 -c0103072 vector180 -c01015c8 clock_init -c01031c2 vector208 -c0102cf4 vector98 -c0102ceb vector97 -c01037ff nr_free_pages -c0106916 ksize -c0103042 vector176 -c010311a vector194 -c0102aa2 vector32 -c012e0b4 boot_cr3 -c012e1b8 end -c0103156 vector199 -c010925a do_exit -c0102e26 vector131 -c01033d2 vector252 -c0102990 vector0 -c01097c8 strfind -c0101eb2 cons_putc -c012e140 swap_out_seq_no -c010a281 etext -c0102ece vector145 -c0102d45 vector107 -c01289e0 boot_pgdir -c0102aea vector40 -c0102148 intr_enable -c0102d18 vector102 -c0102b7a vector56 -c0102be6 vector68 -c01029c6 vector6 -c010a1a1 rand -c0102e0e vector129 -c010313e vector197 -c0102f22 vector152 +c01015b7 cons_init +c0106a7c swap_in +c0101cb2 ide_write_secs +c012c00c pmm_manager +c0103278 vector240 +c0102a9e vector54 +c0102963 vector19 +c011f024 __STAB_END__ +c0102bf4 vector92 +c01032a8 vector244 +c012c0a4 swap_init_ok +c0104e89 load_esp0 +c0102dc8 vector140 +c0102a4d vector45 +c0102b7f vector79 +c01031f4 vector229 +c01067ee swap_init +c0102ea0 vector158 +c0101f60 pic_enable +c01086a0 swapfs_init +c012c12c check_rp +c0102a17 vector39 +c0102f18 vector168 +c01029f3 vector35 +c0102cb1 vector113 +c011f025 __STABSTR_BEGIN__ +c0102d1d vector125 +c0100c45 __panic +c012c18c initproc +c0103158 vector216 +c0102aef vector63 +c01029a2 vector26 +c01013dd serial_intr +c0103044 vector193 +c0103068 vector196 +c0100111 grade_backtrace0 +c0103104 vector209 +c01028ea vector4 +c0102f30 vector170 +c010937d schedule +c0102d98 vector136 +c010291e vector10 +c01030e0 vector206 +c010332c vector255 +c0102fb4 vector181 +c0102acb vector59 +c010012e grade_backtrace +c0102bb5 vector85 +c0102bac vector84 +c01092b8 switch_to +c0102fcc vector183 +c0102eac vector159 +c0103128 vector212 +c0102a5f vector47 +c0109d8c strtol +c01031e8 vector228 +c0102a32 vector42 +c0102cba vector114 +c0109be3 strnlen +c0102f6c vector175 +c0102dec vector143 +c0102d50 vector130 +c010ad00 default_pmm_manager +c01032c0 vector246 +c0102915 vector9 +c0102de0 vector142 +c0102c3c vector100 +c01030a4 vector201 +c01020fe idt_init +c010092f print_debuginfo +c01079f1 find_vma +c012c0c0 swap_in_seq_no +c0102ad4 vector60 +c0102987 vector23 +c0103248 vector236 +c012c004 npage +c0108408 do_pgfault +c010320c vector231 +c01089fa set_proc_name +c0102b0a vector66 +c01029bd vector29 +c01065ff print_pgdir +c0102d8c vector135 +c0100b5e kmonitor +c0102b6d vector77 +c0102fa8 vector180 +c0100d16 clock_init +c01030f8 vector208 +c0102c2a vector98 +c0102c21 vector97 +c010507d nr_free_pages +c0104c26 ksize +c0102f78 vector176 +c0103050 vector194 +c01029d8 vector32 +c012c008 boot_cr3 +c012e1b4 end +c010308c vector199 +c0109064 do_exit +c0102d5c vector131 +c0103308 vector252 +c01028c6 vector0 +c0109d5c strfind +c01015e6 cons_putc +c012c100 swap_out_seq_no +c010a070 etext +c0102e04 vector145 +c0102c7b vector107 +c0128a00 boot_pgdir +c0102a20 vector40 +c0101ef3 intr_enable +c0102c4e vector102 +c0102ab0 vector56 +c0102b1c vector68 +c01028fc vector6 +c0109ae2 rand +c0102d44 vector129 +c0103074 vector197 +c0102e58 vector152 c01285e0 __vectors -c01032ca vector230 -c010973b strncmp -c01066c6 slob_init -c0103e29 get_pte -c01010ff ide_device_size -c0102acf vector37 -c012e168 check_swap_addr -c010319e vector205 -c0102f8e vector161 -c012c028 current -c01096b3 strncpy -c0102c01 vector71 -c0102f82 vector160 -c01066df kmalloc_init -c0103216 vector215 -c0102f5e vector157 -c0102154 intr_disable -c01024fb print_regs -c0102d72 vector112 -c01000b8 grade_backtrace2 -c010308a vector182 -c01029f6 vector12 -c0109a91 memcmp -c0102d57 vector109 -c0102a36 vector20 -c0102b5f vector53 -c0102a24 vector18 -c010949d cpu_idle -c0102cd9 vector95 -c010329a vector226 -c0102b3b vector49 -c0102b0e vector44 -c0102c40 vector78 -c010301e vector173 -c0108891 swapfs_read -c0102d9f vector117 -c010232d trap_in_kernel -c0106b1a swap_set_unswappable -c0102c64 vector82 -c010326a vector222 -c01029d8 vector8 -c0102efe vector149 -c0100301 cputchar -c0109954 memset -c01032e2 vector232 -c010113e ide_read_secs -c0102d3c vector106 -c0103252 vector220 -c0102cac vector90 -c0102fa6 vector163 -c010a264 srand -c01032fa vector234 -c0106ae9 swap_map_swappable -c0102bb0 vector62 -c0102a63 vector25 -c010314a vector198 -c0102dba vector120 -c010036c getchar -c0104025 page_remove -c010a178 hash32 -c0102b44 vector50 -c0102a0b vector15 -c012c018 swap_out_num -c0109c8d printfmt -c0102f16 vector151 -c0102c6d vector83 -c0102ca3 vector89 -c0102c9a vector88 -c0102978 trap -c0103066 vector179 -c0102ab4 vector34 -c0125848 __STABSTR_END__ -c0102b20 vector46 -c01096ee strcmp -c0102e4a vector134 -c0103276 vector223 -c010323a vector218 -c0100670 debuginfo_eip -c012e17c max_swap_offset -c01056f6 insert_vma_struct -c0101ffc pic_init -c010328e vector225 -c01030c6 vector187 -c0103d3a pmm_init -c0102a90 vector30 -c0102df9 vector127 -c012e054 ticks -c0103102 vector192 -c0102fca vector166 -c0102c2e vector76 -c0102c25 vector75 -c0103126 vector195 -c0102f0a vector150 -c0102b8c vector58 -c01033a2 vector248 -c0102dd5 vector123 -c0102ce2 vector96 -c0102a99 vector31 -c0103186 vector203 -c0103759 alloc_pages -c0102e86 vector139 -c0102f2e vector153 -c0102fb2 vector164 -c0102dc3 vector121 -c012e060 switchk2u -c01029bd vector5 -c0102fd6 vector167 -c0102f46 vector155 -c01033ae vector249 -c010ac08 vpt -c01033ba vector250 -c0102dde vector124 -c0102d60 vector110 -c0103192 vector204 -c012e180 swap_page -c0103419 __trapret -c01002a0 vcprintf -c0102e6e vector137 -c01004c5 __warn -c0103396 vector247 -c0102a48 vector22 -c010317a vector202 -c0102c0a vector72 -c0102b71 vector55 -c0100319 cputs +c0103200 vector230 +c0109cd5 strncmp +c01049ea slob_init +c0105696 get_pte +c0101a34 ide_device_size +c0102a05 vector37 +c012c14c check_swap_addr +c01030d4 vector205 +c0102ec4 vector161 +c012c190 current +c0109c53 strncpy +c0102b37 vector71 +c0102eb8 vector160 +c0104a01 kmalloc_init +c010314c vector215 +c0102e94 vector157 +c0101efb intr_disable +c010246c print_regs +c0102ca8 vector112 +c01000b9 grade_backtrace2 +c0102fc0 vector182 +c010292c vector12 +c010a018 memcmp +c0102c8d vector109 +c010296c vector20 +c0102a95 vector53 +c010295a vector18 +c010929f cpu_idle +c0102c0f vector95 +c01031d0 vector226 +c0102a71 vector49 +c0102a44 vector44 +c0102b76 vector78 +c0102f54 vector173 +c01086eb swapfs_read +c0102cd5 vector117 +c01022a4 trap_in_kernel +c01068e3 swap_set_unswappable +c0102b9a vector82 +c01031a0 vector222 +c010290e vector8 +c0102e34 vector149 +c01003a0 cputchar +c0109ee4 memset +c0103218 vector232 +c0101a71 ide_read_secs +c0102c72 vector106 +c0103188 vector220 +c0102be2 vector90 +c0102edc vector163 +c0109ba1 srand +c0103230 vector234 +c01068b4 swap_map_swappable +c0102ae6 vector62 +c0102999 vector25 +c0103080 vector198 +c0102cf0 vector120 +c0100407 getchar +c0105890 page_remove +c0109447 hash32 +c0102a7a vector50 +c0102941 vector15 +c012c128 swap_out_num +c0109606 printfmt +c0102e4c vector151 +c0102ba3 vector83 +c0102bd9 vector89 +c0102bd0 vector88 +c0102888 trap +c0102f9c vector179 +c01029ea vector34 +c01254b4 __STABSTR_END__ +c0102a56 vector46 +c0109c8c strcmp +c0102d80 vector134 +c01031ac vector223 +c0103170 vector218 +c0100573 debuginfo_eip +c012c0a0 max_swap_offset +c0107b4b insert_vma_struct +c0101f95 pic_init +c01031c4 vector225 +c0102ffc vector187 +c01055a9 pmm_init +c01029c6 vector30 +c0102d2f vector127 +c012b424 ticks +c0103038 vector192 +c0102f00 vector166 +c0102b64 vector76 +c0102b5b vector75 +c010305c vector195 +c0102e40 vector150 +c0102ac2 vector58 +c01032d8 vector248 +c0102d0b vector123 +c0102c18 vector96 +c01029cf vector31 +c01030bc vector203 +c0104fdb alloc_pages +c0102dbc vector139 +c0102e64 vector153 +c0102ee8 vector164 +c0102cf9 vector121 +c012b780 switchk2u +c01028f3 vector5 +c0102f0c vector167 +c0102e7c vector155 +c01032e4 vector249 +c010ae84 vpt +c01032f0 vector250 +c0102d14 vector124 +c0102c96 vector110 +c01030c8 vector204 +c012c0a8 swap_page +c01028b5 __trapret +c0100343 vcprintf +c0102da4 vector137 +c0100cc3 __warn +c01032cc vector247 +c010297e vector22 +c01030b0 vector202 +c0102b40 vector72 +c0102aa7 vector55 +c01003b6 cputs c0128000 bootstacktop -c0108e73 find_proc -c0102df0 vector126 -c0102bcb vector65 -c0102a7e vector28 -c0102fee vector169 -c0106acd swap_tick_event -c01032ee vector233 -c0106b3d swap_out -c0106836 kmalloc -c010555d vma_create -c0102ee6 vector147 -c0108d57 proc_run +c0108c91 find_proc +c0102d26 vector126 +c0102b01 vector65 +c01029b4 vector28 +c0102f24 vector169 +c010689a swap_tick_event +c0103224 vector233 +c0106904 swap_out +c0104b4a kmalloc +c01079b4 vma_create +c0102e1c vector147 +c0108b7a proc_run c0126000 bootstack c0129000 __boot_pgdir -c0102d2a vector104 -c012e1a4 free_area -c0102d96 vector116 -c0108907 swapfs_write -c010c5dc __STAB_BEGIN__ -c012e194 check_ptep -c0102b56 vector52 -c0102a1d vector17 -c01030a2 vector184 -c0109612 strlen -c0108c18 get_proc_name -c012c00c pgfault_num -c01031b6 vector207 -c01030ea vector190 -c0100db6 ide_init -c0103336 vector239 -c0102cd0 vector94 -c0102cc7 vector93 -c01030d2 vector188 -c0109792 strchr -c0102b32 vector48 -c012e0c4 check_mm_struct -c0106ab1 swap_init_mm -c01000e1 grade_backtrace1 -c0103246 vector219 -c0102ef2 vector148 -c010325e vector221 -c0102c52 vector80 -c0103006 vector171 -c0102f3a vector154 -c0102ac6 vector36 -c012e0ac switchu2k -c0103306 vector235 -c0102d33 vector105 -c0100d2d mon_kerninfo -c012e0b8 pages -c0102eda vector146 -c01030f6 vector191 -c01092da proc_init -c0102d21 vector103 -c0100cce mon_help -c01029ef vector11 -c010412b tlb_invalidate -c0102a04 vector14 +c0102c60 vector104 +c012bfe4 free_area +c0102ccc vector116 +c010875f swapfs_write +c010c3b8 __STAB_BEGIN__ +c012c13c check_ptep +c0102a8c vector52 +c0102953 vector17 +c0102fd8 vector184 +c0109bba strlen +c0108a3f get_proc_name +c012c170 pgfault_num +c01030ec vector207 +c0103020 vector190 +c01016f1 ide_init +c010326c vector239 +c0102c06 vector94 +c0102bfd vector93 +c0103008 vector188 +c0109d28 strchr +c0102a68 vector48 +c012c16c check_mm_struct +c0106880 swap_init_mm +c01000e0 grade_backtrace1 +c010317c vector219 +c0102e28 vector148 +c0103194 vector221 +c0102b88 vector80 +c0102f3c vector171 +c0102e70 vector154 +c01029fc vector36 +c012b7cc switchu2k +c010323c vector235 +c0102c69 vector105 +c0100c1d mon_kerninfo +c012c000 pages +c0102e10 vector146 +c010302c vector191 +c01090de proc_init +c0102c57 vector103 +c0100bc0 mon_help +c0102925 vector11 +c0105992 tlb_invalidate +c010293a vector14 diff --git a/labcodes/lab4/obj/libs/hash.o b/labcodes/lab4/obj/libs/hash.o index 0bd564d36c5cedc0500211db7aac173589b6acf0..c81a1fceeb3ccc82c17b4f30e44038a75e69409a 100644 Binary files a/labcodes/lab4/obj/libs/hash.o and b/labcodes/lab4/obj/libs/hash.o differ diff --git a/labcodes/lab4/obj/libs/printfmt.o b/labcodes/lab4/obj/libs/printfmt.o index 571e71b236af1cb3985c1110715265adbc97b29c..41a9c32cc965f862c9cc3ae6f994003b4da58691 100644 Binary files a/labcodes/lab4/obj/libs/printfmt.o and b/labcodes/lab4/obj/libs/printfmt.o differ diff --git a/labcodes/lab4/obj/libs/rand.o b/labcodes/lab4/obj/libs/rand.o index ba6066b49acb1eef2905d1af41895e6ebf290dd6..86760c36aa0cfc7da8ee2a3b3e538a668e5ef1f5 100644 Binary files a/labcodes/lab4/obj/libs/rand.o and b/labcodes/lab4/obj/libs/rand.o differ diff --git a/labcodes/lab4/obj/libs/string.o b/labcodes/lab4/obj/libs/string.o index 275bdc12d5eb1137fe125262bb99060cecf77003..1e3bf53a07d3ded3268b428698b7a04ae324ab42 100644 Binary files a/labcodes/lab4/obj/libs/string.o and b/labcodes/lab4/obj/libs/string.o differ diff --git a/labcodes/lab4/obj/sign/tools/sign.o b/labcodes/lab4/obj/sign/tools/sign.o index 27d8fe9452db16aed33d14ef2a447b1336351ed0..781cf8734dfd6a26f4a282a35189d784a2cfb617 100644 Binary files a/labcodes/lab4/obj/sign/tools/sign.o and b/labcodes/lab4/obj/sign/tools/sign.o differ diff --git a/labcodes/lab4/tools/gdbinit b/labcodes/lab4/tools/gdbinit index 6a429c1b2692afb6fd94ab0051171026b0b26350..2c9adc9ddfad6c5302169f441b451f4ae403ade3 100644 --- a/labcodes/lab4/tools/gdbinit +++ b/labcodes/lab4/tools/gdbinit @@ -1,5 +1,7 @@ file bin/kernel target remote :1234 b kern_init -break swap_init +b proc_init +b kernel_thread +b do_fork continue