1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-18 18:06:40 +00:00
Atmosphere/exosphere/src/coldboot_main.c

29 lines
1,002 B
C
Raw Normal View History

2018-02-25 02:54:28 +00:00
#include <string.h>
#include "utils.h"
#include "mmu.h"
#include "memory_map.h"
2018-02-27 21:29:47 +00:00
#include "arm.h"
2018-03-01 00:40:09 +00:00
#include "cpu_context.h"
2018-02-25 02:54:28 +00:00
extern uint8_t __pk2ldr_start__[], __pk2ldr_end__[];
/* start.s */
2018-03-01 00:40:09 +00:00
void __attribute__((noreturn)) __jump_to_lower_el(uint64_t arg, uintptr_t ep, unsigned int el);
void coldboot_main(void) {
uintptr_t *mmu_l3_table = (uintptr_t *)TZRAM_GET_SEGMENT_ADDRESS(TZRAM_SEGMENT_ID_L3_TRANSLATION_TABLE);
uintptr_t pk2ldr = TZRAM_GET_SEGMENT_ADDRESS(TZRAM_SEGMENT_ID_PK2LDR);
2018-03-01 00:40:09 +00:00
uintptr_t ep;
uint64_t arg;
2018-02-25 02:54:28 +00:00
/* Clear and unmap pk2ldr (which is reused as exception entry stacks) */
memset((void *)pk2ldr, 0, __pk2ldr_end__ - __pk2ldr_start__);
mmu_unmap_range(3, mmu_l3_table, pk2ldr, __pk2ldr_end__ - __pk2ldr_start__);
2018-02-25 02:54:28 +00:00
tlb_invalidate_all_inner_shareable();
2018-03-01 00:40:09 +00:00
use_core_entrypoint_and_argument(get_core_id(), &ep, &arg);
/* Nintendo jumps to EL1, we jump to EL2. Both are supported with all current packages2. */
__jump_to_lower_el(arg, ep, 2);
}