Power-On stage
The value of the CPU register when power on is Cs:0xffff, ip:0x0000, at this time the CPU is in real mode so will go to execute address addr = cs * + IP = 0xffff0 here is cured in ROM
A program is the BIOS, then the BIOS will read the MBR (boot sector 512B), the 512B (also BOOTSECT.S content) of the program loaded into the 0x7c00:0 place.
The stage of Bootsect.s
Move yourself from 0x7c00:0 to 0x9000:0, then read the contents of the next 4 sectors to 0x9000:0x200, then read the system img to 0x1000:0 and display the loading system ...
Then jmp went to 0x9000:0x200 to start executing SETUP.S's content.
SETUP.S Stage
Save the hard disk parameters and other information to 0x90000, move the system img at 0x10000 to the absolute address 0x0000, set the GDT (NULL, code snippet, data segment, hold), set IDT (NULL)
Use LGDT to load the GDT table, Lidt load the IDT table, open the A20 address line, place the CR0 register PE bit, enter the protection mode, JMP 0x8:0 Now it's protected mode, so we're going to look for the GDT
The second item, the segment descriptor for the snippet, jumps to the saved address in the segment descriptor (already set to 0) and executes the 0x0000 code, which is Head.s
Head.s Stage
Since the value of the register has changed to reload the GDT and IDT content, push _main to the stack, call set page target and 4 page table subroutine, set CR0 Register PG bit, turn on paging mode, perform RET instruction popup _main to IP, execute main function enter inside The process of nuclear initialization.
Linux 0.11 boot process