描述1 | 类型 | 大小 | 地址偏移 |
|
jmp LOCAL(after_BPB) |
| 2 |
|
|
nop |
| 1 |
|
|
_start + GRUB_BOOT_MACHINE_BPB_START | 占位 | 1 |
|
|
_start + 4 | 下节开始于4 |
| 0x7c04 |
|
|
|
| 0x7c04 |
|
Mode | Byte | 1 | 0x7c04 | 保存磁盘读模式 |
disk_address_packet: |
| 0 | 0x7c05 |
|
sectors: | Long | 4 | 0x7c05 |
|
Heads | Long | 4 | 0x7c09 |
|
Cylinders: | Word | 2 | 0x7c0d |
|
Sector_start | Byte | 1 | 0x7c10 |
|
Head_start | Byte | 1 | 0x7c11 |
|
Cylinder_start | Word | 2 | 0x7c12 |
|
… |
|
| 0x7c14 |
|
_start + GRUB_BOOT_MACHINE_BPB_END | 占位 | 0 | 0x7c5a |
|
kernel_address | Word | 2 | 0x7c5a | 0x8000 |
_start + GRUB_BOOT_MACHINE_KERNEL_SECTOR | 占位 |
| 0x7c5c |
|
kernel_sector | Long*2 | 8 | 0x7c5c | 5c-63 |
_start + GRUB_BOOT_MACHINE_BOOT_DRIVE | 占位 | 0 | 0x7c64 |
|
boot_drive | Byte | 1 | 0x7c64 |
|
LOCAL(after_BPB): |
| 0 | 0x7c65 | 0x7C00处的跳转到达这里 |
cli |
| 1 | 0x7c65 |
|
_start + GRUB_BOOT_MACHINE_DRIVE_CHECK | 占位 | 0 | 0x7c66 | 检查到引是否偏移66 |
boot_drive_check | 标号 | 0 | 0x7c66 | 检查dl中驱动器号 |
|
|
|
|
|
Struct DAP{
BYTE sizeOfDap; //1
BYTE reserved; //1; =0
WORD nrSectionToRead; //2 需要读的扇区数
LONG offset; //4 segment:offset指向内存缓冲区,读到的东西放到这里
LONGLONG startSectionNr;//8 起始扇区编号
}disk_address_packet
| 硬盘 | 内存 内存地址
| |
| | | |
| | |压缩的内核 |
|continue kernel, if exists | | |
| kernel.img | |startup.s |0x8200
| diskboot.s | |diskboot.img |0x8000
|___MBR,boot.s________ | |_boot.s_______ |0x7c00
startup.s 检验内核 解压内核 初始化内核变量 跳转到内核(内核是grub内核,不是linux内核)