Friday, July 08, 2005

Loading the kernel

After POST [], the BIOS looks at the first sector of the primary boot device. If boot code is written in the first sector, it is loaded into the memory at address 0x7C00 by the BIOS and the system jumps to that code. Now, how does the BIOS identify the boot loader code? Since, this boot code is the first to get loaded into memory, we call it as Primary Bootloader, which can only be a maximum of 512 bytes. The last 2 bytes of a boot loader has, 0xAA55. This is the standard signature for any primary boot loader. Since, the primary loader needs to be less than 512 bytes, it should be written in x86 assembly language.

The primary loader loads either secondary bootloader or kernel into memory. The choice is left to you. The secondary loader does not have the constraint of being less than 512 bytes. It can be of any size and it can be written in a high-level language, such as C, C++, etc. The primary job of a secondary loader needs to set up the environment for kernel, i.e., GDT, IDT, etc, load the kernel and jump to it.


No comments: