Compare commits

..

4 Commits

Author SHA1 Message Date
Eric-Paul Ickhorn a6d7a3f8bb Added legacy loader documentation and planning 2023-05-26 21:09:43 +02:00
Eric-Paul Ickhorn cc04e1be5c Added build-files - directory to .gitignore 2023-05-26 20:59:56 +02:00
Eric-Paul Ickhorn 7025bca2b1 MOved the stage 2 - starter to a more sensible path 2023-05-26 20:46:26 +02:00
Eric-Paul Ickhorn 100be4743d Moved the bootsector to a more sensible path 2023-05-26 20:45:45 +02:00
8 changed files with 43 additions and 0 deletions

4
.gitignore vendored
View File

@ -177,3 +177,7 @@ go.work
*.png *.png
*.webp *.webp
# Build-Directories
*build/

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