From e50cbe8eb763cf63fb44b047d5164f6fbf07eb39 Mon Sep 17 00:00:00 2001 From: Alejandro Sior Date: Fri, 13 May 2022 20:50:39 +0200 Subject: 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). --- rt/hare.sc | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 rt/hare.sc (limited to 'rt/hare.sc') diff --git a/rt/hare.sc b/rt/hare.sc new file mode 100644 index 0000000..0cb9c02 --- /dev/null +++ b/rt/hare.sc @@ -0,0 +1,74 @@ +OUTPUT_FORMAT(elf64-x86-64) +ENTRY(_stage0) + +PHDRS { + headers PT_PHDR PHDRS; + text PT_LOAD FILEHDR PHDRS; + data PT_LOAD; +} + +SECTIONS { + . = 0x0; + + . = 0x500; + . = ALIGN(4096); + _p4 = .; + . += 4096; + _p3 = .; + . += 4096; + _p2 = .; + . += 4096; + _p1 = .; + . += 4096; + + . = 0x7c00; + stack_top = .; + + boot_start = .; + + boot : { + boot_stage0_start = .; + *(boot.stage0) + boot_stage0_end = .; + + boot_stage1_start = .; + *(boot.stage1) + boot_stage1_end = .; + + . = ALIGN(512); + } + + .text : { + KEEP (*(.text)) + *(.text.*) + } :text + .data : { + KEEP (*(.data)) + *(.data.*) + . = ALIGN(16); + KEEP (*(.exception_array)) + } :data + .init_array : { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } :data + .fini_array : { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + } :data + .test_array : { + PROVIDE_HIDDEN (__test_array_start = .); + KEEP (*(.test_array)) + PROVIDE_HIDDEN (__test_array_end = .); + } :data + + .bss : { + KEEP (*(.bss)) + *(.bss.*) + } :data + + + boot_end = .; +} -- cgit v1.2.3