mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 12:21:18 +00:00
thermosphere: fix bugs:
- missing barriers after setting elr/spsr - .text.start* matching .text.startup (which contains main, thanks @fincs)
This commit is contained in:
parent
1d58ba8d52
commit
4e6108839d
4 changed files with 23 additions and 6 deletions
|
@ -380,7 +380,7 @@ static void package2_fixup_thermosphere_and_entrypoint(package2_header_t *packag
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Swap kernel entrypoint with Thermosphère */
|
/* 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;
|
package2->metadata.entrypoint = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,7 @@ SECTIONS
|
||||||
.text :
|
.text :
|
||||||
{
|
{
|
||||||
. = ALIGN(8);
|
. = ALIGN(8);
|
||||||
__main_start__ = ABSOLUTE(.);
|
KEEP(*(.crt0*));
|
||||||
*(.text.start*)
|
|
||||||
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
|
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
|
||||||
*(.text.exit .text.exit.*)
|
*(.text.exit .text.exit.*)
|
||||||
*(.text.startup .text.startup.*)
|
*(.text.startup .text.startup.*)
|
||||||
|
@ -24,7 +23,7 @@ SECTIONS
|
||||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
*(.text .stub .text.* .gnu.linkonce.t.*)
|
||||||
. = ALIGN(0x800);
|
. = ALIGN(0x800);
|
||||||
__vectors_start__ = ABSOLUTE(.);
|
__vectors_start__ = ABSOLUTE(.);
|
||||||
*(.vectors*);
|
KEEP(*(.vectors*));
|
||||||
. = ALIGN(8);
|
. = ALIGN(8);
|
||||||
} >main
|
} >main
|
||||||
|
|
||||||
|
|
7
thermosphere/src/main.c
Normal file
7
thermosphere/src/main.c
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Setup stuff
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -18,13 +18,14 @@
|
||||||
#define cpuactlr_el1 s3_1_c15_c2_0
|
#define cpuactlr_el1 s3_1_c15_c2_0
|
||||||
#define cpuectlr_el1 s3_1_c15_c2_1
|
#define cpuectlr_el1 s3_1_c15_c2_1
|
||||||
|
|
||||||
.section .text.start, "ax", %progbits
|
.section .crt0, "ax", %progbits
|
||||||
.align 3
|
.align 3
|
||||||
.global _start
|
.global _start
|
||||||
.type _start, %function
|
.type _start, %function
|
||||||
|
|
||||||
_start:
|
_start:
|
||||||
b start
|
b start
|
||||||
|
nop
|
||||||
|
|
||||||
.global g_kernelEntrypoint
|
.global g_kernelEntrypoint
|
||||||
g_kernelEntrypoint:
|
g_kernelEntrypoint:
|
||||||
|
@ -40,7 +41,10 @@ start:
|
||||||
msr elr_el2, x8
|
msr elr_el2, x8
|
||||||
mov x8, #(0b1111 << 6 | 0b0101) // EL1h+DAIF
|
mov x8, #(0b1111 << 6 | 0b0101) // EL1h+DAIF
|
||||||
msr spsr_el2, x8
|
msr spsr_el2, x8
|
||||||
eret
|
|
||||||
|
// Make sure the regs have been set
|
||||||
|
dsb sy
|
||||||
|
isb
|
||||||
|
|
||||||
// Set VBAR
|
// Set VBAR
|
||||||
ldr x8, =__vectors_start__
|
ldr x8, =__vectors_start__
|
||||||
|
@ -50,6 +54,10 @@ start:
|
||||||
ldr x8, =__stacks_top__
|
ldr x8, =__stacks_top__
|
||||||
mov sp, x8
|
mov sp, x8
|
||||||
|
|
||||||
|
// Make sure the regs have been set
|
||||||
|
dsb sy
|
||||||
|
isb
|
||||||
|
|
||||||
// Don't call init array to save space?
|
// Don't call init array to save space?
|
||||||
// Clear BSS
|
// Clear BSS
|
||||||
ldr x0, =__bss_start__
|
ldr x0, =__bss_start__
|
||||||
|
@ -59,9 +67,12 @@ start:
|
||||||
bl memset
|
bl memset
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
bl main
|
||||||
|
|
||||||
// Jump to kernel
|
// Jump to kernel
|
||||||
mov x0, x19
|
mov x0, x19
|
||||||
|
dsb sy
|
||||||
|
isb
|
||||||
eret
|
eret
|
||||||
|
|
||||||
.pool
|
.pool
|
||||||
|
|
Loading…
Reference in a new issue