1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-18 08:22:04 +00:00

Exosphere: Copy initial data image to DRAM for coldboot init.

This commit is contained in:
Michael Scire 2018-05-18 06:49:49 -06:00
parent 1a9f095463
commit ea905725c4
2 changed files with 26 additions and 7 deletions

View file

@ -122,7 +122,7 @@ uintptr_t get_coldboot_crt0_stack_address(void) {
void coldboot_init(coldboot_crt0_reloc_list_t *reloc_list, uintptr_t start_cold) {
//MAILBOX_NX_SECMON_BOOT_TIME = TIMERUS_CNTR_1US_0;
//MAKE_REG32(0x7000E400ULL) = 0x10;
MAKE_REG32(0x7000E400ULL) = 0x10;
/* Custom approach */
reloc_list->reloc_base = start_cold;

View file

@ -94,8 +94,9 @@ __start_cold:
cmp x0, x2
blo 1b
adr x20, __start_cold
adr x19, g_coldboot_crt0_relocation_list
adr x19, __start_cold
adr x20, g_coldboot_crt0_relocation_list
sub x20, x20, x19
ldr x16, =_post_cold_crt0_reloc
br x16
@ -106,9 +107,27 @@ _post_cold_crt0_reloc:
mov sp, x0
mov fp, #0
/* X1 is already set to __start_cold (original load location) from above. */
mov x0, x19
/* Relocate Exosphere image to free DRAM, clearing the image in IRAM. */
ldr x0, =0x80010000
add x20, x20, x0
ldr x2, =__loaded_end_lma__
ldr x3, =0x40020000
sub x21, x2, x3
mov x1, x19
mov x2, x21
add x2, x2, x0
2:
ldp x3, x4, [x1]
stp x3, x4, [x0], #0x10
stp xzr, xzr, [x1], #0x10
cmp x0, x2
blo 2b
/* X0 = TZ-in-DRAM, X1 = relocation-list-in-DRAM. */
ldr x0, =0x80010000
mov x1, x20
/* Set size in coldboot relocation list. */
str x21, [x1, #0x8]
bl coldboot_init
ldr x16, =__jump_to_main_cold
@ -240,7 +259,7 @@ __jump_to_lower_el:
.align 3
.global g_coldboot_crt0_relocation_list
g_coldboot_crt0_relocation_list:
.quad 0, __loaded_end_lma__ /* __start_cold, to be set & loaded size */
.quad 0, 0 /* __start_cold, to be set & loaded size */
.quad 1, 5 /* number of sections to relocate/clear before & after mmu init */
/* Relocations */
.quad __warmboot_crt0_start__, __warmboot_crt0_end__, __warmboot_crt0_lma__