2013-04-27

2013-04-27 - Bootloader Design

So, my plan is this ...

The 512-byte boot sector loads a small 16-bit loader.  This loader will then load a text file detailing modules to load, the first being the 32-bit kernel.  The 16-bit loader will then load all of these 32-bit modules.  Its last act will be to switch to 32-bit mode and start the 32-bit kernel proper.

The downside to this is that the 16-bit loader will have to understand the various file-systems it may encounter, but this can be mitigated by requiring a small boot partition which contains the modules.

The upside is that the config file can be modified to account for many different boot devices, including, but not limited to, the following situations:

  • Booting from a floppy (which will need a floppy driver)
  • Booting from a hard drive (which will need a S/PATA driver)
  • Booting from a CD-ROM drive (which will need an ATAPI driver)
  • Booting from a network (which requests file by name)
  • Booting from a USB device (which requires PCI, USB, and class drivers)


The bigger upside is that the 16-bit bootloader will be able to request blocks from any (bootable) block device using the BIOS routines and will be able to load any file by name from a PXE network boot using the BIOS routines.  That way, we're not doing the same thing as a certain other OS of booting from a USB drive using the BIOS, jumping into protected mode, then finding that our boot device went away.

One downside is that we only have 640k of space to load the modules into (which should be OK as they can be read-only drivers for the various  drives)

The 16-bit loader will also have to create an identifier from the boot device in order to pass this to the 32-bit kernel so that I can find the same boot device using the 32-bit drivers (when the BIOS is no longer available).
It could even be made "intelligent" to the point of identifying (guessing) what device drivers it will need, but it is dependant on the BIOS if it's even possible to get any information about what the booted device is.

Most BIOSes just pretend that a USB hard drive is a normal hard drive, leaving a surprise for the OS when they jump to 32-bit armed with an ATA driver and find no drive to boot from