1FreeLoader notes (for x86 PC architecture only!) 2================================================ 3 4Memory layout (WARNING: may be out-of-date) 5-~-~-~-~-~-~- 6 70000:0000 - 0000:0FFF: Interrupt vector table & BIOS data 80000:1000 - 0000:6FFF: Real mode stack area 90000:7000 - 0000:7FFF: Cmdline (multiboot) 100000:8000 - xxxx:xxxx: FreeLoader program & data area 11xxxx:xxxx - 7000:7FFF: Random memory allocation heap 127000:8000 - 7000:FFFF: Protected mode stack area 138000:0000 - 8000:FFFF: File system read buffer 149000:0000 - 9000:FFFF: Disk read buffer for BIOS Int 13h 15A000:0000 - FFFF:FFFF: reserved 16 17 18FreeLoader Boot Process 19-~-~-~-~-~-~-~-~-~-~-~- 20 21FAT 12/16/32 Boot Sector 22 23 The BIOS loads the boot sector at 0000:7C00. The FAT12/16 boot sector just 24searches for FREELDR.SYS and loads its first 512 bytes to 0000:F800. This extra 25helper code enables it to fully navigate the file allocation table. The boot 26sector then jumps to FREELDR.SYS entry point at 0000:F803 and the helper code 27takes the relay. It finishes loading the FREELDR.SYS image and finally jumps to 28its final entry point at 0000:FA00. 29 The FAT32 boot sector loads its extra sector at 0000:7E00 and looks for 30FREELDR.SYS on the file system. Once found it loads FREELDR.SYS to 0000:F800 31and jumps to its entry point at the same address. This allows it to jump over 32the FAT12/16 extra helper code situated at this address, and go to the final 33entry point at 0000:FA00. 34 35 36ISO-9660 (CD-ROM) Boot Sector 37 38 The BIOS loads the boot sector (2048 bytes) at 0000:7C00. First, the 39boot sector relocates itself to 0000:7000 (up to 0000:7800). Then it looks 40for the LOADER directory and makes it the current directory. Next it looks 41for FREELDR.SYS and loads it at 0000:F800. Finally it restores the boot drive 42number in the DL register and jumps to FreeLoader's entry point at 0000:F800. 43 44 45Multiboot 46 47 Freeldr contains a multiboot signature and can itself be loaded by a 48multiboot-compliant loader (like GRUB). The multiboot header instructs the 49primary loader to load FREELDR.SYS at 0x200000 (needs to be above 1MB). Control 50is then transferred to the multiboot entry point. Since FREELDR.SYS expects to 51be loaded at a base address 0000:F800 it will start by relocating itself there 52and then jumping to the relocated copy. 53 54 55FreeLoader Initialization 56-~-~-~-~-~-~-~-~-~-~-~-~- 57 58 When FreeLoader gets control it saves the boot drive and partition, passed 59to it respectively in the DL and DH registers, and sets up the stack, enables 60protected mode, and calls BootMain(). 61