Added some comments.
[reactos.git] / freeldr / notes.txt
1 FreeLoader notes
2
3 To build FreeLoader you will need DJGPP because Mingw32 doesn't support 16-bit code
4 ext2 filesystem support needs to be added.
5 The MessageBox() function needs to not allocate memory. Because it gets called when memory allocation fails.
6
7 Memory layout:
8
9 0000:0000 - 0000:0FFF: Interrupt vector table & BIOS data
10 0000:1000 - 0000:6FFF: Real mode stack area
11 0000:7000 - 0000:7FFF: Unused
12 0000:8000 - xxxx:xxxx: FreeLoader program & data area
13 xxxx:xxxx - 7000:7FFF: Random memory allocation heap
14 7000:8000 - 7000:FFFF: Protected mode stack area
15 8000:0000 - 8000:FFFF: File system read buffer
16 9000:0000 - 9000:FFFF: Disk read buffer for BIOS Int 13h
17 A000:0000 - FFFF:FFFF: reserved
18
19
20 FreeLoader Boot Process
21
22 FAT 12/16/32 Boot Sector
23
24 The BIOS loads the boot sector at 0000:7C00. The FAT32 boot sector
25 relocates itself higher in memory at 9000:0000 and loads it's extra sector
26 at 9000:0200 and then looks for freeldr.sys on the file system. Once found
27 it loads freeldr.sys to 0000:7E00 and then jumps to it's entry point at
28 0000:8000. The FAT12/16 boot sector does no relocation, it just searches for
29 the freeldr.sys and loads the first 512 bytes to 0000:7E00. This extra code
30 enables it to fully navigate the file allocation table. Then it loads
31 freeldr.sys to 0000:7E00 and jumps to it's entry point at 0000:8000. Before
32 FreeLoader gets control the boot sector saves the screen contents to a buffer
33 at 9000:8000 and the cursor x & y position to bytes at 9000:8FA0 & 9000:8FA1
34 respectively.
35
36
37 ISO-9660 (CD-ROM) Boot Sector
38
39 The BIOS loads the boot sector (2048 bytes) at 0000:7C00. First, the
40 boot sector relocates itself to 0000:7000 (up to 0000:7800). Then it looks
41 for the I386 directory and makes it the current directory. Next it looks for
42 FREELDR.SYS and loads it at 0000:8000. Finally it restores the boot drive
43 number in the DL register and jumps to FreeLoader's entry point at 0000:8000.
44
45
46 FreeLoader Initialization
47
48 When FreeLoader gets control it saves the boot drive, passed to it in
49 the DL register, and sets up the stack, enables protected mode, and calls
50 BootMain().