2017-02-20 15:45:01 +00:00
|
|
|
FreeLoader notes (for x86 PC architecture only!)
|
|
|
|
================================================
|
2001-05-15 03:50:25 +00:00
|
|
|
|
2017-02-20 15:45:01 +00:00
|
|
|
Memory layout (WARNING: may be out-of-date)
|
|
|
|
-~-~-~-~-~-~-
|
2001-11-15 07:48:33 +00:00
|
|
|
|
|
|
|
0000:0000 - 0000:0FFF: Interrupt vector table & BIOS data
|
|
|
|
0000:1000 - 0000:6FFF: Real mode stack area
|
2004-11-01 20:49:32 +00:00
|
|
|
0000:7000 - 0000:7FFF: Cmdline (multiboot)
|
2001-11-15 07:48:33 +00:00
|
|
|
0000:8000 - xxxx:xxxx: FreeLoader program & data area
|
2002-02-26 23:17:22 +00:00
|
|
|
xxxx:xxxx - 7000:7FFF: Random memory allocation heap
|
|
|
|
7000:8000 - 7000:FFFF: Protected mode stack area
|
|
|
|
8000:0000 - 8000:FFFF: File system read buffer
|
|
|
|
9000:0000 - 9000:FFFF: Disk read buffer for BIOS Int 13h
|
2001-11-15 07:48:33 +00:00
|
|
|
A000:0000 - FFFF:FFFF: reserved
|
|
|
|
|
|
|
|
|
|
|
|
FreeLoader Boot Process
|
2017-02-20 15:45:01 +00:00
|
|
|
-~-~-~-~-~-~-~-~-~-~-~-
|
2001-11-15 07:48:33 +00:00
|
|
|
|
2002-04-22 12:05:07 +00:00
|
|
|
FAT 12/16/32 Boot Sector
|
|
|
|
|
2017-02-20 15:45:01 +00:00
|
|
|
The BIOS loads the boot sector at 0000:7C00. The FAT12/16 boot sector just
|
|
|
|
searches for FREELDR.SYS and loads its first 512 bytes to 0000:F800. This extra
|
|
|
|
helper code enables it to fully navigate the file allocation table. The boot
|
|
|
|
sector then jumps to FREELDR.SYS entry point at 0000:F803 and the helper code
|
|
|
|
takes the relay. It finishes loading the FREELDR.SYS image and finally jumps to
|
|
|
|
its final entry point at 0000:FA00.
|
|
|
|
The FAT32 boot sector loads its extra sector at 0000:7E00 and looks for
|
|
|
|
FREELDR.SYS on the file system. Once found it loads FREELDR.SYS to 0000:F800
|
|
|
|
and jumps to its entry point at the same address. This allows it to jump over
|
|
|
|
the FAT12/16 extra helper code situated at this address, and go to the final
|
|
|
|
entry point at 0000:FA00.
|
2002-04-22 12:05:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
ISO-9660 (CD-ROM) Boot Sector
|
|
|
|
|
2017-02-20 15:45:01 +00:00
|
|
|
The BIOS loads the boot sector (2048 bytes) at 0000:7C00. First, the
|
2002-04-22 12:05:07 +00:00
|
|
|
boot sector relocates itself to 0000:7000 (up to 0000:7800). Then it looks
|
2017-02-20 15:45:01 +00:00
|
|
|
for the LOADER directory and makes it the current directory. Next it looks
|
|
|
|
for FREELDR.SYS and loads it at 0000:F800. Finally it restores the boot drive
|
|
|
|
number in the DL register and jumps to FreeLoader's entry point at 0000:F800.
|
2001-11-15 07:48:33 +00:00
|
|
|
|
|
|
|
|
2004-11-01 20:49:32 +00:00
|
|
|
Multiboot
|
|
|
|
|
2017-02-20 15:45:01 +00:00
|
|
|
Freeldr contains a multiboot signature and can itself be loaded by a
|
|
|
|
multiboot-compliant loader (like GRUB). The multiboot header instructs the
|
|
|
|
primary loader to load FREELDR.SYS at 0x200000 (needs to be above 1MB). Control
|
|
|
|
is then transferred to the multiboot entry point. Since FREELDR.SYS expects to
|
|
|
|
be loaded at a base address 0000:F800 it will start by relocating itself there
|
2004-11-01 20:49:32 +00:00
|
|
|
and then jumping to the relocated copy.
|
|
|
|
|
|
|
|
|
2001-11-15 07:48:33 +00:00
|
|
|
FreeLoader Initialization
|
2017-02-20 15:45:01 +00:00
|
|
|
-~-~-~-~-~-~-~-~-~-~-~-~-
|
2001-11-15 07:48:33 +00:00
|
|
|
|
2017-02-20 15:45:01 +00:00
|
|
|
When FreeLoader gets control it saves the boot drive and partition, passed
|
|
|
|
to it respectively in the DL and DH registers, and sets up the stack, enables
|
|
|
|
protected mode, and calls BootMain().
|