Open cosven opened 5 years ago
Floppy and hard disks for PCs are divided into 512 byte regions called sectors.
If the disk is bootable, the first sector is called the boot sector
When the BIOS finds a bootable floppy or hard disk, it loads the 512-byte boot sector into memory at physical addresses 0x7c00 through 0x7dff, and then uses a jmp instruction to set the CS:IP to 0000:7c00, passing control to the boot loader.
the way a modern BIOS boots from a CD-ROM is a bit more complicated (and more powerful).
For 6.828, we will use the conventional hard drive boot mechanism
The boot loader consists of one assembly language source file, boot/boot.S, and one C source file, boot/main.c Look through these source files carefully and make sure you understand what's going on.
The boot loader must perform two main functions:
First, the boot loader switches the processor from real mode to 32-bit protected mode, because it is only in this mode that software can access all the memory above 1MB in the processor's physical address space. Second, the boot loader reads the kernel from the hard disk by directly accessing the IDE disk device registers via the x86's special I/O instructions.
这篇博客对代码有比较详细的中文注释和解释,它的参考资料也很好 https://blog.csdn.net/scnu20142005027/article/details/51147402
阅读时产生的一些疑问
A20 地址总线干啥用的?网上很多博客都有提到
PS/2 Controller IO Ports 是啥东西? 看这个资料,解释的 非常好 https://wiki.osdev.org/%228042%22_PS/2_Controller#Overview 。
PS / 2控制器(通常称为“键盘控制器”)位于主板上。在早期,控制器是一个单芯片(8042)。截至今天,它是Advanced Integrated Peripheral的一部分。 该名称具有误导性,因为控制器不仅仅控制与PS / 2设备的通信。 此处应该有一张图(可以看出它的 0x60 和 0x64 Port 是和 CPU 通信的)。
扫了几篇博客,有的说把 0xdf 写到 0x60 port 会关闭,但看 boot.S 代码,明显这是开启 A20 Gate,有点疑惑。
A20是为了兼容以前的cpu的。不打开a20,即使是在保护模式,也只能访问到1M的内存,这个东西只有x86有。
A20是为了兼容以前的cpu的。不打开a20,即使是在保护模式,也只能访问到1M的内存,这个东西只有x86有。
又发现了一个「只学了第一节」的课程...
lab1: Booting a PC
https://pdos.csail.mit.edu/6.828/2018/labs/lab1/
Part 1: PC Bootstrap
这个实验主要分为几个部分
练习 1:使用 GDB 来调试启动过程,从实验结果得到的一些结论:
练习 2:继续使用 GDB 单步调试,看看启动时候都干了啥?
没有太懂,资料也很少,但是这个过程和 DMA 应该有关,http://www.voidcn.com/article/p-eajspssw-dp.html 这篇博客有一定参考价值。下面贴一下它的结论
interrupt descriptor table: 能在调试中看到一些
CLI
CLD
相关指令,似乎是与这个中断描述表有关系。看不太懂,先不管。