diff --git a/fusee/fusee-secondary/src/package2.c b/fusee/fusee-secondary/src/package2.c index 4c7654766..c37e7b46c 100644 --- a/fusee/fusee-secondary/src/package2.c +++ b/fusee/fusee-secondary/src/package2.c @@ -362,7 +362,7 @@ static void package2_fixup_thermosphere_and_entrypoint(package2_header_t *packag } /* Swap kernel entrypoint with Thermosphère */ - *(uint32_t *)(dst + 4) = DRAM_BASE_PHYSICAL + package2->metadata.entrypoint; + *(uint64_t *)(dst + 8) = DRAM_BASE_PHYSICAL + package2->metadata.entrypoint; package2->metadata.entrypoint = 0; } diff --git a/thermosphere/linker.ld b/thermosphere/linker.ld index c007c3100..63cfe80f9 100644 --- a/thermosphere/linker.ld +++ b/thermosphere/linker.ld @@ -15,8 +15,7 @@ SECTIONS .text : { . = ALIGN(8); - __main_start__ = ABSOLUTE(.); - *(.text.start*) + KEEP(*(.crt0*)); *(.text.unlikely .text.*_unlikely .text.unlikely.*) *(.text.exit .text.exit.*) *(.text.startup .text.startup.*) @@ -24,7 +23,7 @@ SECTIONS *(.text .stub .text.* .gnu.linkonce.t.*) . = ALIGN(0x800); __vectors_start__ = ABSOLUTE(.); - *(.vectors*); + KEEP(*(.vectors*)); . = ALIGN(8); } >main diff --git a/thermosphere/src/main.c b/thermosphere/src/main.c new file mode 100644 index 000000000..0ca0b8b37 --- /dev/null +++ b/thermosphere/src/main.c @@ -0,0 +1,7 @@ +#include "utils.h" + +int main(void) +{ + // Setup stuff + return 0; +} diff --git a/thermosphere/src/start.s b/thermosphere/src/start.s index 42b0b5654..16d492173 100644 --- a/thermosphere/src/start.s +++ b/thermosphere/src/start.s @@ -18,13 +18,14 @@ #define cpuactlr_el1 s3_1_c15_c2_0 #define cpuectlr_el1 s3_1_c15_c2_1 -.section .text.start, "ax", %progbits +.section .crt0, "ax", %progbits .align 3 .global _start .type _start, %function _start: b start + nop .global g_kernelEntrypoint g_kernelEntrypoint: @@ -40,7 +41,10 @@ start: msr elr_el2, x8 mov x8, #(0b1111 << 6 | 0b0101) // EL1h+DAIF msr spsr_el2, x8 - eret + + // Make sure the regs have been set + dsb sy + isb // Set VBAR ldr x8, =__vectors_start__ @@ -50,6 +54,10 @@ start: ldr x8, =__stacks_top__ mov sp, x8 + // Make sure the regs have been set + dsb sy + isb + // Don't call init array to save space? // Clear BSS ldr x0, =__bss_start__ @@ -59,9 +67,12 @@ start: bl memset // TODO + bl main // Jump to kernel mov x0, x19 + dsb sy + isb eret .pool