Added legacy loader documentation and planning

This commit is contained in:
Eric-Paul Ickhorn 2023-05-26 21:09:43 +02:00
parent cc04e1be5c
commit a6d7a3f8bb
1 changed files with 39 additions and 0 deletions

39
docs/legacy_loader.md Normal file
View File

@ -0,0 +1,39 @@
# Legacy Loader
The legacy loader only is another code path which, in the end, merges together
with the UEFI - code path again. It has no special purpose except of that one.
## Order of Working
The Nightloader's Stage 0 - Loader searchs for its partition which has the
type `0x9d` in the MBR (Master Boot Record).
It initializes a GDT (Global Descriptor Table) for going into 32-bit - mode,
making it possible to use more of the RAM. This is particularily useful for
loading the whole partition of the Stage 2 into RAM without having problems
with the memory limitations of the 16-bit real mode (which has 20-bit addresses).
Following that, it loads the 256MB of the NightLoader-partition into memory
at address 0x8000, or 32768 in decimal. If the partition has another size than
256MB, the Nightloader - Stage 0 will fail to load it.
If the partition isn't formatted correctly, the boot process will fail.
The Stage 0 - loader tries to find the path `/night/starter.bin` in its
partition and starts that executable code, which it loads to address 0x8000,
at its first byte.
Now, the Starter is working. Aforementioned executable code has one purpose:
load the ELF-executable of the actual Stage 2 - loader and start a function
inside of it which is named `main`. If such function does not exist, it should
display a debug-message which basically tells that the user needs a *very*
skilled technician right about *yesterday*.
## Current State
The Nightloader:
- can find its own partition in the Master Boot Record
- writes an error message onto the screen if it couldn't find its own partition
- does not go into 32-bit mode
- only loads 8 sectors (4096 bytes) of the Stage 2 - partition into the RAM