thermosphere: fix bugs:

- missing barriers after setting elr/spsr
- .text.start* matching .text.startup (which contains main, thanks @fincs)
This commit is contained in:
TuxSH 2019-07-18 23:43:49 +02:00
parent 1d58ba8d52
commit 4e6108839d
4 changed files with 23 additions and 6 deletions

View file

@ -380,7 +380,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;
}

View file

@ -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

7
thermosphere/src/main.c Normal file
View file

@ -0,0 +1,7 @@
#include "utils.h"
int main(void)
{
// Setup stuff
return 0;
}

View file

@ -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