memory: Add mmu_init_secondary() to init MMU for secondaries

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2021-09-15 22:11:48 +09:00
parent 52f432f0f6
commit d53b40da48
2 changed files with 22 additions and 0 deletions

View file

@ -461,6 +461,27 @@ void mmu_init(void)
printf("MMU: running with MMU and caches enabled!\n");
}
static void mmu_secondary_setup(void)
{
mmu_configure();
mmu_init_sprr();
// Enable EL0 memory access by EL1
msr(PAN, 0);
// RES1 bits
u64 sctlr = SCTLR_LSMAOE | SCTLR_nTLSMD | SCTLR_TSCXT | SCTLR_ITD;
// Configure translation
sctlr |= SCTLR_I | SCTLR_C | SCTLR_M | SCTLR_SPAN;
write_sctlr(sctlr);
}
void mmu_init_secondary(int cpu)
{
smp_call4(cpu, mmu_secondary_setup, 0, 0, 0, 0);
smp_wait(cpu);
}
void mmu_shutdown(void)
{
fb_console_reserve_lines(3);

View file

@ -24,6 +24,7 @@ void dc_civac_range(void *addr, size_t length);
void dcsw_op_all(u64 op_type);
void mmu_init(void);
void mmu_init_secondary(int cpu);
void mmu_shutdown(void);
u64 mmu_disable(void);