diff options
| author | Alejandro Sior <aho@sior.be> | 2022-05-13 20:50:39 +0200 |
|---|---|---|
| committer | Alejandro Sior <aho@sior.be> | 2022-05-13 20:50:39 +0200 |
| commit | e50cbe8eb763cf63fb44b047d5164f6fbf07eb39 (patch) | |
| tree | 8acb610a4f33462c843f54016861780ffadc010d /rt/start.ha | |
boot: longmode to realmode stub
This is the initial commit to the repo. It adds all the code.
The last proper thing that I got working before committing is
calling real mode functions from long mode using a stub.
Next up, I would like to implement a disk reader abstraction over
the BIOS in order to read form partitions (most notably FAT32).
Diffstat (limited to 'rt/start.ha')
| -rw-r--r-- | rt/start.ha | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/rt/start.ha b/rt/start.ha new file mode 100644 index 0000000..edbc5a5 --- /dev/null +++ b/rt/start.ha @@ -0,0 +1,24 @@ +@symbol("main") fn main() void; + +const @symbol("__init_array_start") init_start: [*]*fn() void; +const @symbol("__init_array_end") init_end: [*]*fn() void; +const @symbol("__fini_array_start") fini_start: [*]*fn() void; +const @symbol("__fini_array_end") fini_end: [*]*fn() void; + +export @noreturn @symbol("_hare") fn _hare() void = { + const ninit = (&init_end: uintptr - &init_start: uintptr): size + / size(*fn() void); + for (let i = 0z; i < ninit; i += 1) { + init_start[i](); + }; + + main(); + + const nfini = (&fini_end: uintptr - &fini_start: uintptr): size + / size(*fn() void); + for (let i = 0z; i < nfini; i += 1) { + fini_start[i](); + }; + + halt(); +}; |
