Booting A PC

ZealOS only supports traditional BIOS booting, not the newer technique, UEFI.  This document describes BIOS booting.

When you turn-on (power-up) a computer or you do a hardware reset, the computer starts executing the BIOS.  Sometimes, you must 
change the BIOS boot order to boot the device you want.

The BIOS loads a boot sector from CD/DVD, hard disk or whatever.    The boot sector runs in 16-bit real mode and often loads-in 
a second file that's bigger if it can't be done by just one sector.  It's a safe bet that boot sectors are hand-coded assembly 
language.   Most boot sectors use the BIOS to load-in the next stage.

Not only do boot sectors have a size limit, 512 bytes or 2048 bytes for CD/DVD, the files they load have to fit within 640K 
because they run in 16-bit mode.    This means they usually can't just load the whole operating system and start it running.    
Some boot loaders, like Grub, have a capability of switching modes before handing-off control to the operating system.  The 
operating system must load the rest of itself.  With ZealOS, the ::/Kernel.BIN.C file is loaded by the boot sector. We try to 
put a minimum in the Kernel Module, so that it will always fit in 640K.  When Kernel.BIN runs, it switches to 32-bit mode, then, 
to 64-bit mode allowing access to more memory.  Then, it loads in the rest of ZealOS by executing ::/StartOS.CC.

All the boot related code for ZealOS is in the /System/Boot directory.

BootDVD.CC          CD/DVD boot sector.
BootDVDIns.CC       Prep for CD/DVD install by creating /0000Boot/0000Kernel.BIN.C.
If you are curious about CD/DVDs, see DiskISORedSea.CC.  To make a custom bootable CD/DVD, look here Bootable CD.

BootMHD.CC          Stage 1 Master HD boot loader.
BootMHD2.CC         Stage 2 Master HD boot loader.
BootMHDIns.CC       Installs Master HD boot loader.
BootMHD goes on block zero.  /0000Boot/BootMHD2.BIN.C is stored as a file in a partition, risky and unusual, since most master 
boot loaders place stage 2 in a gap that's not in any partition.  BootMHD2 displays a menu and boots a partition.

BootHD.CC           HD partition boot record.
BootHDIns.CC        Installs HD partition boot record.
BootHD is the boot record for a ZealOS partition.  Each partition has its own partition boot record, the first block of the 
partition.

The boot records don't access directories because that would make them too big for one block and would make them depend on a 
file system layout.  Instead, they get patched with the LBA, logical block addresses, to load files.    To update with a new 
ZealOS kernel, you must create a ::/Kernel.BIN.C binary file and patch the boot loader so it knows the LBA blocks to load.  Ther
efore, you usually recompile the kernel and update the boot sector at the same time with    BootHDIns().    BootMHDIns() will 
install a master boot loader.

With ZealOS, ::/Kernel.BIN.C loads ::/Compiler/Compiler.BIN so it can work with source code from then on.  It compiles start-up 
scripts beginning with ::/StartOS.CC into the System Task's memory including the code in the /System and /Home directories.

It is possible to do a fast reboot without doing a hardware reset.  You might do this when working on ::/Kernel.BIN.C or your 
start-up scripts when you want to compile them effect.  See BootRAM().


/* Graphics Not Rendered in HTML */