[FREELDR]: Update the FreeLdr's startup notes.

svn path=/trunk/; revision=73859
This commit is contained in:
Hermès Bélusca-Maïto 2017-02-20 15:45:01 +00:00
parent dba6b1c35c
commit 5da9304c6d

View file

@ -1,6 +1,8 @@
FreeLoader notes FreeLoader notes (for x86 PC architecture only!)
================================================
Memory layout: Memory layout (WARNING: may be out-of-date)
-~-~-~-~-~-~-
0000:0000 - 0000:0FFF: Interrupt vector table & BIOS data 0000:0000 - 0000:0FFF: Interrupt vector table & BIOS data
0000:1000 - 0000:6FFF: Real mode stack area 0000:1000 - 0000:6FFF: Real mode stack area
@ -14,44 +16,45 @@ A000:0000 - FFFF:FFFF: reserved
FreeLoader Boot Process FreeLoader Boot Process
-~-~-~-~-~-~-~-~-~-~-~-
FAT 12/16/32 Boot Sector FAT 12/16/32 Boot Sector
The BIOS loads the boot sector at 0000:7C00. The FAT32 boot sector The BIOS loads the boot sector at 0000:7C00. The FAT12/16 boot sector just
relocates itself higher in memory at 9000:0000 and loads it's extra sector searches for FREELDR.SYS and loads its first 512 bytes to 0000:F800. This extra
at 9000:0200 and then looks for freeldr.sys on the file system. Once found helper code enables it to fully navigate the file allocation table. The boot
it loads freeldr.sys to 0000:7E00 and then jumps to it's entry point at sector then jumps to FREELDR.SYS entry point at 0000:F803 and the helper code
0000:8000. The FAT12/16 boot sector does no relocation, it just searches for takes the relay. It finishes loading the FREELDR.SYS image and finally jumps to
the freeldr.sys and loads the first 512 bytes to 0000:7E00. This extra code its final entry point at 0000:FA00.
enables it to fully navigate the file allocation table. Then it loads The FAT32 boot sector loads its extra sector at 0000:7E00 and looks for
freeldr.sys to 0000:7E00 and jumps to it's entry point at 0000:8000. Before FREELDR.SYS on the file system. Once found it loads FREELDR.SYS to 0000:F800
FreeLoader gets control the boot sector saves the screen contents to a buffer and jumps to its entry point at the same address. This allows it to jump over
at 9000:8000 and the cursor x & y position to bytes at 9000:8FA0 & 9000:8FA1 the FAT12/16 extra helper code situated at this address, and go to the final
respectively. entry point at 0000:FA00.
ISO-9660 (CD-ROM) Boot Sector ISO-9660 (CD-ROM) Boot Sector
The BIOS loads the boot sector (2048 bytes) at 0000:7C00. First, the The BIOS loads the boot sector (2048 bytes) at 0000:7C00. First, the
boot sector relocates itself to 0000:7000 (up to 0000:7800). Then it looks boot sector relocates itself to 0000:7000 (up to 0000:7800). Then it looks
for the LOADER directory and makes it the current directory. Next it looks for for the LOADER directory and makes it the current directory. Next it looks
FREELDR.SYS and loads it at 0000:8000. Finally it restores the boot drive 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:8000. number in the DL register and jumps to FreeLoader's entry point at 0000:F800.
Multiboot Multiboot
Freeldr contains a multiboot signature and can itself be loaded by a Freeldr contains a multiboot signature and can itself be loaded by a
multiboot-compliant loader (like Grub). The multiboot header instructs the multiboot-compliant loader (like GRUB). The multiboot header instructs the
primary loader to load freeldr.sys at 0x200000 (needs to be above 1MB). Control 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 is then transferred to the multiboot entry point. Since FREELDR.SYS expects to
be loaded at a base address 0000:8000 it will start by relocating itself there be loaded at a base address 0000:F800 it will start by relocating itself there
and then jumping to the relocated copy. and then jumping to the relocated copy.
FreeLoader Initialization FreeLoader Initialization
-~-~-~-~-~-~-~-~-~-~-~-~-
When FreeLoader gets control it saves the boot drive, passed to it in When FreeLoader gets control it saves the boot drive and partition, passed
the DL register, and sets up the stack, enables protected mode, and calls to it respectively in the DL and DH registers, and sets up the stack, enables
BootMain(). protected mode, and calls BootMain().