040297578820138fd77dc2755a6ac6eb6f1d9ffd
[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 FreeLoader does not currently work with extended partitions.
5 Linux booting support needs to be added.
6 ext2 filesystem support needs to be added.
7 The MessageBox() function needs to not allocate memory. Because it gets called when memory allocation fails.
8
9 Old memory layout:
10
11 0000:0000 - 0000:0FFF: Interrupt vector table & BIOS data
12 0000:1000 - 0000:6FFF: Real mode stack area
13 0000:7000 - xxxx:xxxx: FreeLoader program & data area
14 xxxx:xxxx - 6000:0000: Protected mode stack area & heap
15 6000:0000 - 6000:C000: Filesystem data buffer
16 6000:C000 - 7000:0000: FREELDR.INI loaded here
17 7000:0000 - 7000:FFFF: scratch area for any function's use (ie sector buffer for biosdisk()) - can be overwritten by any function
18 8000:0000 - 9000:FFFF: fat table entry buffer
19 A000:0000 - FFFF:FFFF: reserved
20
21
22 New memory layout:
23
24 0000:0000 - 0000:0FFF: Interrupt vector table & BIOS data
25 0000:1000 - 0000:6FFF: Real mode stack area
26 0000:7000 - 0000:7FFF: Unused
27 0000:8000 - xxxx:xxxx: FreeLoader program & data area
28 xxxx:xxxx - 7000:7FFF: Random memory allocation heap
29 7000:8000 - 7000:FFFF: Protected mode stack area
30 8000:0000 - 8000:FFFF: File system read buffer
31 9000:0000 - 9000:FFFF: Disk read buffer for BIOS Int 13h
32 A000:0000 - FFFF:FFFF: reserved
33
34
35 FreeLoader Boot Process
36
37 Boot Sector
38
39 The BIOS loads the boot sector at 0000:7C00. The FAT32 boot sector relocates itself higher in memory at 9000:0000 and loads it's extra sector at 9000:0200 and then looks for freeldr.sys on the file system. Once found it loads freeldr.sys to 0000:7E00 and then jumps to it's entry point at 0000:8000. The FAT12/16 boot sector does no relocation, it just searches for the freeldr.sys and loads the first 512 bytes to 0000:7E00. This extra code enables it to fully navigate the file allocation table. Then it loads freeldr.sys to 0000:7E00 and jumps to it's entry point at 0000:8000. Before FreeLoader gets control the boot sector saves the screen contents to a buffer at 9000:8000 and the cursor x & y position to bytes at 9000:8FA0 & 9000:8FA1 respectively.
40
41 FreeLoader Initialization
42
43 When FreeLoader gets control it saves the boot drive, passed to it in the DL register, and sets up the stack, enables protected mode, and calls BootMain().