The steps in booting an x86 IBM PC
Posted: Thu Jul 24, 2003 10:37 am
I'm trying to get a list of things that must be done in booting an IBM PC x86 style, and loading a kernel. This is "pure mode" - no Grub or anything like that. Here's my list, note that everything's in order, from start to kernel main(). If any of these things are incorrect or there are things missing (even optional things) please reply with the corrections:
1. Start with 512-byte bootsector, which gets loaded at 0000:7C00h. Bootsectors start in 16-bit real mode. A pointer to the PnP check structure is located in ES:DI and the driver we booted from can be identified by examining the DL register. See:
http://www.phoenix.com/resources/specs-bbs101.pdf
XXX: If we booted from floppy, perhaps kill the motor now? See the Linux kernel sources.
2. The bootsector now enables the A20 gate so we can see more than 1MB of system memory.
3. Either slurp up the kernel into memory using int 13h or load a bigger and more capable boot programme and jump to it.
XXX: Relocation issues: what gets moved and where, and of course, why?
Or should step 4, going into 32-bit pmode, come before loading the kernel/boot programme??
4. Once in the boot programme or in the kernel just before main(), we optionally setup paging and switch into protected mode. Usually paging and protected mode are switched on at the same time by MOVing a new value into CR0 with the pmode and paging bits switched on. Disable interrupts now (??) or should we have done this earlier?
5. We are now running in 32-bit protected mode. Here somewhere we install our interrupt vectors by programming the APIC. (??)
6. After installing interrupts, re-enable interrupts and stomp all over BIOS area if using kernel's own device drivers. (?? Read Linux kernel source, it apparently claims some of the BIOS areas for itself, or have I misunderstood something?)
7. Jump to kernel main().
I hope this is a good list to work from. I could sure use with some input so we can create a reference document from which to work from, like a kernel developer's TODO list for i386+ processors. Perhaps also reproduce Ralf Brown's interrupt list in an appendix for easy reference while loading the kernel in 16-bit mode.
1. Start with 512-byte bootsector, which gets loaded at 0000:7C00h. Bootsectors start in 16-bit real mode. A pointer to the PnP check structure is located in ES:DI and the driver we booted from can be identified by examining the DL register. See:
http://www.phoenix.com/resources/specs-bbs101.pdf
XXX: If we booted from floppy, perhaps kill the motor now? See the Linux kernel sources.
2. The bootsector now enables the A20 gate so we can see more than 1MB of system memory.
3. Either slurp up the kernel into memory using int 13h or load a bigger and more capable boot programme and jump to it.
XXX: Relocation issues: what gets moved and where, and of course, why?
Or should step 4, going into 32-bit pmode, come before loading the kernel/boot programme??
4. Once in the boot programme or in the kernel just before main(), we optionally setup paging and switch into protected mode. Usually paging and protected mode are switched on at the same time by MOVing a new value into CR0 with the pmode and paging bits switched on. Disable interrupts now (??) or should we have done this earlier?
5. We are now running in 32-bit protected mode. Here somewhere we install our interrupt vectors by programming the APIC. (??)
6. After installing interrupts, re-enable interrupts and stomp all over BIOS area if using kernel's own device drivers. (?? Read Linux kernel source, it apparently claims some of the BIOS areas for itself, or have I misunderstood something?)
7. Jump to kernel main().
I hope this is a good list to work from. I could sure use with some input so we can create a reference document from which to work from, like a kernel developer's TODO list for i386+ processors. Perhaps also reproduce Ralf Brown's interrupt list in an appendix for easy reference while loading the kernel in 16-bit mode.