$FG,5$$TX+CX,"Booting A PC"$$FG$

$WW,1$When you turn-on (better term is "power-up"!) a computer or do a hardware rst, it starts in the $FG,2$BIOS$FG$.  Sometimes, you must change the $FG,2$BIOS$FG$ boot order to boot stuff.

The $FG,2$BIOS$FG$ loads a boot sect from CD-ROM or hard disk or whatever.  The boot sect runs in 16-bit mode and often loads-in a second file that's bigger if it can't be done by just one sect.  It's a safe bet that boot sects are hand-coded assembly language  Most boot sects use the $FG,2$BIOS$FG$ to load-in the rest.

Not only do boot sects have a size limit, 512 bytes or 2048 bytes for CD-ROM, 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.  I guess some boot loaders, like $LK,"Grub","FI:::/SparrowOS/Doc/Grub.TXT.Z"$, have a capability of switching modes before handing-off ctrl to the operating system.  Anyway, the operating system must load the rest of itself.  My $LK,"OSMain","FI:::/SparrowOS/OSMain/OSStart.CPP.Z"$ module is what the boot sect loads and I try to put a minimum in it so that it will always fit in 640K.  It switches to 32-bit mode, then, to 64-bit mode allowing access to more memory.  It loads in the rest of SparrowOS.

All the boot related stuff for SparrowOS is in the $FG,2$/SparrowOS/Adam/Boot$FG$ directory.

$LK,"InsBoot.CPP.Z","FI:::/SparrowOS/Adam/Boot/InsBoot.CPP.Z"$	Installs and patches boot sects
$LK,"BootCD.CPP.Z","FI:::/SparrowOS/Adam/Boot/BootCD.CPP.Z"$	CD-ROM Boot sect
$LK,"BootMHD.CPP.Z","FI:::/SparrowOS/Adam/Boot/BootMHD.CPP.Z"$	Master HD boot record
$LK,"BootMHD2.CPP.Z","FI:::/SparrowOS/Adam/Boot/BootMHD2.CPP.Z"$	Stage 2 master boot loader
$LK,"BootHD.CPP.Z","FI:::/SparrowOS/Adam/Boot/BootHD.CPP.Z"$	HD partition boot record

$FG,2$BootCD$FG$ is the CD-ROM boot sect.  If you are curious on the layout of $FG,2$ISO9660$FG$ CD-ROMs, see $LK,"DiskCDDVD.CPP.Z","FI:::/SparrowOS/Adam/Dsk/DskCDDVD.CPP.Z"$.  To make a custom bootable CD-ROM, look here $LK,"Bootable CD","FF:::/SparrowOS/Doc/FileMgr.TXT.Z,BurnProdu"$.

$FG,2$BootMHD$FG$ is the master boot record for a hard drive.  This goes on block zero.  It loads-in $FG,2$BootMHD2$FG$ which is stored as a file on a partition, kinda risky and unusual -- most other master boot loaders place stage 2 in a gap that's not in any particular partition.   $FG,2$BootMHD2$FG$ displays a menu and will boot a partition.  Each partition has it's own partition boot record, the first block of the partition.  $FG,2$BootHD$FG$ is the boot record for a SparrowOS partition.

My 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 other stuff.  To update with a new SparrowOS kernel ($FG,2$OSMain$FG$), you must create a binary file and patch the boot loader so it knows the LBA blocks to load.  Therefore, you usually recompile the kernel and update the boot sect at the same time.  $LK,"InstallBoot","MN:InstallBoot"$() does this.  $LK,"InstallMasterBoot","MN:InstallMasterBoot"$() will install a master boot loader.

With SparrowOS , the $FG,2$OSMain$FG$ module loads the $FG,2$Compiler$FG$ module so it can process start-up scripts and works with srource code from then on.  $LK,"::/SparrowOS/OSMain/Adam1.CPP.Z","FI:::/SparrowOS/OSMain/Adam1.CPP.Z"$ is the starting start-up script.  It processes (compiles into memory) the stuff in the $FG,2$/SparrowOS/Adam$FG$ directory and ends by $FG,2$#include$FG$ing the $LK,"HOME/Adam3.CPP.Z","FI:HOME/Adam3.CPP.Z"$ file.

It is possible to reboot without doing a hardware rst.  This is faster.  You might do this when working on $FG,2$OSMain$FG$ or your start-up scripts when you want them to take effect.  See $LK,"Boot","MN:Boot"$().

$SP,"",1$
























































                      LoseThos MBR    @   LoseThos MBR part 2       OSMain       /LT/OSMain/Adam1.APZ      /LT/Adam/Adam2.APZ    @  HOME/Adam3.APZ      HOME/DoIt.CPZ `      `            LoseThos CD-ROM BootLoader    x   LoseThos Partition BootBlock !       @   !  L     t   !          !D  L  D    !   L       !`            !      0     !          !         !       <                 Boot() Soft boot   