mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-13 23:46:40 +00:00
Clear pk2ldr in coldboot_main
This commit is contained in:
parent
a00e68e94a
commit
b0079e404d
2 changed files with 15 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
#include <string.h>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "mmu.h"
|
#include "mmu.h"
|
||||||
#include "memory_map.h"
|
#include "memory_map.h"
|
||||||
|
@ -6,6 +7,8 @@ extern void (*__fini_array_start[])(void);
|
||||||
extern void (*__fini_array_end[])(void);
|
extern void (*__fini_array_end[])(void);
|
||||||
extern void _fini(void);
|
extern void _fini(void);
|
||||||
|
|
||||||
|
extern uint8_t __pk2ldr_start__[], __pk2ldr_end__[];
|
||||||
|
|
||||||
extern void __jump_to_lower_el(uint64_t arg, uintptr_t ep, unsigned int el);
|
extern void __jump_to_lower_el(uint64_t arg, uintptr_t ep, unsigned int el);
|
||||||
|
|
||||||
void coldboot_main(void);
|
void coldboot_main(void);
|
||||||
|
@ -18,5 +21,13 @@ static void __libc_fini_array(void) __attribute__((used)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void coldboot_main(void) {
|
void coldboot_main(void) {
|
||||||
/* TODO */
|
uintptr_t *mmu_l3_table = (uintptr_t *)tzram_get_segment_address(TZRAM_SEGMENT_ID_L3_TRANSLATION_TABLE);
|
||||||
|
void *pk2ldr = (void *)tzram_get_segment_address(TZRAM_SEGMENT_ID_PK2LDR);
|
||||||
|
|
||||||
|
/* Clear and unmap pk2ldr (which is reused as exception entry stacks) */
|
||||||
|
memset(pk2ldr, 0, __pk2ldr_end__ - __pk2ldr_start__);
|
||||||
|
mmu_unmap_range(mmu_l3_table, pk2ldr, __pk2ldr_end__ - __pk2ldr_start__);
|
||||||
|
tlb_invalidate_all_inner_shareable();
|
||||||
|
|
||||||
|
/* TODO: stuff & jump to lower EL */
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,21 +150,21 @@ static inline void mmu_unmap(unsigned int level, uintptr_t *tbl, uintptr_t base_
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void mmu_map_block_range(unsigned int level, uintptr_t *tbl, uintptr_t base_addr, uintptr_t phys_addr, size_t size, uint64_t attrs) {
|
static inline void mmu_map_block_range(unsigned int level, uintptr_t *tbl, uintptr_t base_addr, uintptr_t phys_addr, size_t size, uint64_t attrs) {
|
||||||
size = (size >> MMU_Lx_SHIFT(level)) << MMU_Lx_SHIFT(level);
|
size = ((size + (BITL(MMU_Lx_SHIFT(level)) - 1)) >> MMU_Lx_SHIFT(level)) << MMU_Lx_SHIFT(level);
|
||||||
for(size_t offset = 0; offset < size; offset += MMU_Lx_SHIFT(level)) {
|
for(size_t offset = 0; offset < size; offset += MMU_Lx_SHIFT(level)) {
|
||||||
mmu_map_block(level, tbl, base_addr + offset, phys_addr + offset, attrs);
|
mmu_map_block(level, tbl, base_addr + offset, phys_addr + offset, attrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void mmu_map_page_range(uintptr_t *tbl, uintptr_t base_addr, uintptr_t phys_addr, size_t size, uint64_t attrs) {
|
static inline void mmu_map_page_range(uintptr_t *tbl, uintptr_t base_addr, uintptr_t phys_addr, size_t size, uint64_t attrs) {
|
||||||
size = (size >> MMU_Lx_SHIFT(3)) << MMU_Lx_SHIFT(3);
|
size = ((size + (BITL(MMU_Lx_SHIFT(3)) - 1)) >> MMU_Lx_SHIFT(3)) << MMU_Lx_SHIFT(3);
|
||||||
for(size_t offset = 0; offset < size; offset += MMU_Lx_SHIFT(3)) {
|
for(size_t offset = 0; offset < size; offset += MMU_Lx_SHIFT(3)) {
|
||||||
mmu_map_page(tbl, base_addr + offset, phys_addr + offset, attrs);
|
mmu_map_page(tbl, base_addr + offset, phys_addr + offset, attrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void mmu_unmap_range(unsigned int level, uintptr_t *tbl, uintptr_t base_addr, size_t size) {
|
static inline void mmu_unmap_range(unsigned int level, uintptr_t *tbl, uintptr_t base_addr, size_t size) {
|
||||||
size = (size >> MMU_Lx_SHIFT(level)) << MMU_Lx_SHIFT(level);
|
size = ((size + (BITL(MMU_Lx_SHIFT(level)) - 1)) >> MMU_Lx_SHIFT(level)) << MMU_Lx_SHIFT(level);
|
||||||
for(size_t offset = 0; offset < size; offset += MMU_Lx_SHIFT(level)) {
|
for(size_t offset = 0; offset < size; offset += MMU_Lx_SHIFT(level)) {
|
||||||
mmu_unmap(level, tbl, base_addr + offset);
|
mmu_unmap(level, tbl, base_addr + offset);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue