xtensa: mmu: Simplify initialization

Simplify the logic around xtensa_mmu_init.

- Do not have a different path to init part of kernel
- Call xtensa_mmu_init from C

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2023-11-01 22:55:43 -07:00 committed by Carles Cufí
commit fff91cb542
4 changed files with 8 additions and 35 deletions

View file

@ -24,10 +24,6 @@
.global __start
.type z_cstart, @function
#ifdef CONFIG_XTENSA_MMU
.type z_xtensa_mmu_init, @function
#endif
/* Macros to abstract away ABI differences */
@ -192,10 +188,6 @@ _start:
#endif /* !XCHAL_HAVE_BOOTLOADER */
#ifdef CONFIG_XTENSA_MMU
CALL z_xtensa_mmu_init
#endif
/* Enter C domain, never returns from here */
CALL z_cstart

View file

@ -213,19 +213,18 @@ __weak void arch_xtensa_mmu_post_init(bool is_core0)
ARG_UNUSED(is_core0);
}
static void xtensa_mmu_init(bool is_core0)
void z_xtensa_mmu_init(void)
{
volatile uint8_t entry;
uint32_t ps, vecbase;
if (is_core0) {
if (_current_cpu->id == 0) {
/* This is normally done via arch_kernel_init() inside z_cstart().
* However, before that is called, we go through the sys_init of
* INIT_LEVEL_EARLY, which is going to result in TLB misses.
* So setup whatever necessary so the exception handler can work
* properly.
*/
z_xtensa_kernel_init();
xtensa_init_page_tables();
}
@ -326,17 +325,7 @@ static void xtensa_mmu_init(bool is_core0)
xtensa_dtlb_entry_invalidate_sync(Z_XTENSA_TLB_ENTRY(Z_XTENSA_PTEVADDR + MB(4), 3));
xtensa_itlb_entry_invalidate_sync(Z_XTENSA_TLB_ENTRY(Z_XTENSA_PTEVADDR + MB(4), 3));
arch_xtensa_mmu_post_init(is_core0);
}
void z_xtensa_mmu_init(void)
{
xtensa_mmu_init(true);
}
void z_xtensa_mmu_smp_init(void)
{
xtensa_mmu_init(false);
arch_xtensa_mmu_post_init(_current_cpu->id == 0);
}
#ifdef CONFIG_ARCH_HAS_RESERVED_PAGE_FRAMES

View file

@ -25,7 +25,7 @@ extern void z_xtensa_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
K_KERNEL_STACK_ARRAY_DECLARE(z_interrupt_stacks, CONFIG_MP_MAX_NUM_CPUS,
CONFIG_ISR_STACK_SIZE);
static ALWAYS_INLINE void z_xtensa_kernel_init(void)
static ALWAYS_INLINE void arch_kernel_init(void)
{
_cpu_t *cpu0 = &_kernel.cpus[0];
@ -51,21 +51,15 @@ static ALWAYS_INLINE void z_xtensa_kernel_init(void)
* win.
*/
XTENSA_WSR(ZSR_CPU_STR, cpu0);
}
static ALWAYS_INLINE void arch_kernel_init(void)
{
#ifndef CONFIG_XTENSA_MMU
/* This is called in z_xtensa_mmu_init() before z_cstart()
* so we do not need to call it again.
*/
z_xtensa_kernel_init();
#endif
#ifdef CONFIG_INIT_STACKS
memset(Z_KERNEL_STACK_BUFFER(z_interrupt_stacks[0]), 0xAA,
K_KERNEL_STACK_SIZEOF(z_interrupt_stacks[0]));
#endif
#ifdef CONFIG_XTENSA_MMU
z_xtensa_mmu_init();
#endif
}
void xtensa_switch(void *switch_to, void **switched_from);

View file

@ -26,6 +26,4 @@ extern int xtensa_soc_mmu_ranges_num;
void z_xtensa_mmu_init(void);
void z_xtensa_mmu_smp_init(void);
#endif /* ZEPHYR_INCLUDE_ARCH_XTENSA_XTENSA_MMU_H */