[NTOSKRNL/FREELDR/NDK]
[reactos.git] / reactos / boot / freeldr / notes.txt
1 FreeLoader notes
2
3 Memory layout:
4
5 0000:0000 - 0000:0FFF: Interrupt vector table & BIOS data
6 0000:1000 - 0000:6FFF: Real mode stack area
7 0000:7000 - 0000:7FFF: Cmdline (multiboot)
8 0000:8000 - xxxx:xxxx: FreeLoader program & data area
9 xxxx:xxxx - 7000:7FFF: Random memory allocation heap
10 7000:8000 - 7000:FFFF: Protected mode stack area
11 8000:0000 - 8000:FFFF: File system read buffer
12 9000:0000 - 9000:FFFF: Disk read buffer for BIOS Int 13h
13 A000:0000 - FFFF:FFFF: reserved
14
15
16 FreeLoader Boot Process
17
18 FAT 12/16/32 Boot Sector
19
20 The BIOS loads the boot sector at 0000:7C00. The FAT32 boot sector
21 relocates itself higher in memory at 9000:0000 and loads it's extra sector
22 at 9000:0200 and then looks for freeldr.sys on the file system. Once found
23 it loads freeldr.sys to 0000:7E00 and then jumps to it's entry point at
24 0000:8000. The FAT12/16 boot sector does no relocation, it just searches for
25 the freeldr.sys and loads the first 512 bytes to 0000:7E00. This extra code
26 enables it to fully navigate the file allocation table. Then it loads
27 freeldr.sys to 0000:7E00 and jumps to it's entry point at 0000:8000. Before
28 FreeLoader gets control the boot sector saves the screen contents to a buffer
29 at 9000:8000 and the cursor x & y position to bytes at 9000:8FA0 & 9000:8FA1
30 respectively.
31
32
33 ISO-9660 (CD-ROM) Boot Sector
34
35 The BIOS loads the boot sector (2048 bytes) at 0000:7C00. First, the
36 boot sector relocates itself to 0000:7000 (up to 0000:7800). Then it looks
37 for the LOADER directory and makes it the current directory. Next it looks for
38 FREELDR.SYS and loads it at 0000:8000. Finally it restores the boot drive
39 number in the DL register and jumps to FreeLoader's entry point at 0000:8000.
40
41
42 Multiboot
43
44 Freeldr contains a multiboot signature and can itself be loaded by a
45 multiboot-compliant loader (like Grub). The multiboot header instructs the
46 primary loader to load freeldr.sys at 0x200000 (needs to be above 1MB). Control
47 is then transferred to the multiboot entry point. Since freeldr.sys expects to
48 be loaded at a base address 0000:8000 it will start by relocating itself there
49 and then jumping to the relocated copy.
50
51
52
53 FreeLoader Initialization
54
55 When FreeLoader gets control it saves the boot drive, passed to it in
56 the DL register, and sets up the stack, enables protected mode, and calls
57 BootMain().