Preface:之前已经做了一部分MIT-6.828了,后来要考托福就搁置了,现在重新捡起来。
顺便把所有的博客迁移到我的域名www.shaojintian.cn下

Sources:xv6 book && xv6 source codes
Exercise1:

看懂x86 的32bit汇编,参见xv6 book附录A

Exercise2:

Use GDB’ssi(Step Instruction) command to trace into the ROM BIOS for a few more instructions, and try to guess what it might be doing.

答案:依照提示使用GDB si

Exercise 3.

阅读bootloader的源码,回答问题
1:At what point does the processor start executing 32-bit code? What exactly causes the switch from 16- to 32-bit mode?

答案:
MIT6.828——Lab1 Booting a PC
ljmp to 0x7c32 从i8086->i386(16bit->32bit)

2:What is the last instruction of the boot loader executed, and what is the first instruction of the kernel it just loaded?

答案:
last instruction:
查阅xv6 book, boot loader call bootmain() to call kernel and run kernel
所以去boot.asm 找bootmain的位置
然后去找此汇编中bootmain()最后一条语句为
((void (*)(void)) (ELFHDR->e_entry))();
找到此语句汇编的指向为

call *0x10018

kernel 第一个instruction:

从boot.asm找到最后一条指令的SI为0x7d6b
打上断点

MIT6.828——Lab1 Booting a PC
MIT6.828——Lab1 Booting a PC

movw $0x1234, 0x472

反汇编
objdump -d obj/kern/kernel 验证了这个结果

3:Where is the first instruction of the kernel?

答案:
0x10000c

4:How does the boot loader decide how many sectors it must read in order to fetch the entire kernel from disk? Where does it find this information?

答案:
xv6 book chapter2 说明kernel是ELF文件
kernel的大小包含在ELF的文件program header中
MIT6.828——Lab1 Booting a PC
Exercise 4
Download the code for pointers.c, run it, and make sure you understand where all of the printed values come from.

相关文章: