Tuesday, May 2, 2023

Bootsect

Bootsect (bootsect.s) is 1 sector in length and loaded to memory location x07C00 (31,744B) by BIOS interrupt 13.  Bootsect runs in real mode which addresses 1MB (20 bit address. 1MB = 1,048,576B).  BIOS IVT is loaded in x00000 to x003FF by BIOS (256 interrupts with 4 bytes each total 1KB), followed by BIOS data (256B from x00400 to x004FF).  The interrupt service routine is 8KB in length and is loaded to x0E05B, which is 56KB after.  So the memory is not used from about 65KB and up to where BIOS is located at xFE000 for 8KB until the end of the real memory.

Once Bootsect is loaded and starts to run, it will load the next 2 sectors from the boot device into memory.  The 2 sectors contain the set up program (setup.s).

Before reading in setup.s, Bootsect firstly relocates itself from x07C00 (BOOTSEG at address ~32K) to x09000 (INITSEG at address 576K).  Bootsect the establishes the stack at x9FF00 (address ~655K) with ~63KB space from end of INITSEG.  

Bootsect uses interrupt x13h (disk service program) to load setup program to memory at address x90200 (512KB = 1 sector after bootsect.s) for 5 sectors (2.5KB or A00).  

Bootsect then loads the system modules into memory.  Bootsect uses interrupt x13h again and loads 240 sectors (120KB) into x10000 (address at 65K, after the BIOS IVT, BIOS data and IVT service routine).  As this takes some time to load so many sectors from floppy disk, Bootsect will display "Loading System...." message on the console.  System modules span from x10000 to x11E00 (up to address ~73K).

Lastly, bootsect inspects the root device number and record in at 01A964 (root_dev) in system data.  Bootsect than transfers the execution to the set up program at x90200.

No comments: