Skip to content

Commit fff91cb

Browse files
Flavio Ceolincarlescufi
authored andcommitted
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 <[email protected]>
1 parent a1bb2b9 commit fff91cb

File tree

4 files changed

+8
-35
lines changed

4 files changed

+8
-35
lines changed

arch/xtensa/core/crt1.S

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
.global __start
2525
.type z_cstart, @function
2626

27-
#ifdef CONFIG_XTENSA_MMU
28-
.type z_xtensa_mmu_init, @function
29-
#endif
30-
3127

3228
/* Macros to abstract away ABI differences */
3329

@@ -192,10 +188,6 @@ _start:
192188

193189
#endif /* !XCHAL_HAVE_BOOTLOADER */
194190

195-
#ifdef CONFIG_XTENSA_MMU
196-
CALL z_xtensa_mmu_init
197-
#endif
198-
199191
/* Enter C domain, never returns from here */
200192
CALL z_cstart
201193

arch/xtensa/core/xtensa_mmu.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,18 @@ __weak void arch_xtensa_mmu_post_init(bool is_core0)
213213
ARG_UNUSED(is_core0);
214214
}
215215

216-
static void xtensa_mmu_init(bool is_core0)
216+
void z_xtensa_mmu_init(void)
217217
{
218218
volatile uint8_t entry;
219219
uint32_t ps, vecbase;
220220

221-
if (is_core0) {
221+
if (_current_cpu->id == 0) {
222222
/* This is normally done via arch_kernel_init() inside z_cstart().
223223
* However, before that is called, we go through the sys_init of
224224
* INIT_LEVEL_EARLY, which is going to result in TLB misses.
225225
* So setup whatever necessary so the exception handler can work
226226
* properly.
227227
*/
228-
z_xtensa_kernel_init();
229228
xtensa_init_page_tables();
230229
}
231230

@@ -326,17 +325,7 @@ static void xtensa_mmu_init(bool is_core0)
326325
xtensa_dtlb_entry_invalidate_sync(Z_XTENSA_TLB_ENTRY(Z_XTENSA_PTEVADDR + MB(4), 3));
327326
xtensa_itlb_entry_invalidate_sync(Z_XTENSA_TLB_ENTRY(Z_XTENSA_PTEVADDR + MB(4), 3));
328327

329-
arch_xtensa_mmu_post_init(is_core0);
330-
}
331-
332-
void z_xtensa_mmu_init(void)
333-
{
334-
xtensa_mmu_init(true);
335-
}
336-
337-
void z_xtensa_mmu_smp_init(void)
338-
{
339-
xtensa_mmu_init(false);
328+
arch_xtensa_mmu_post_init(_current_cpu->id == 0);
340329
}
341330

342331
#ifdef CONFIG_ARCH_HAS_RESERVED_PAGE_FRAMES

arch/xtensa/include/kernel_arch_func.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern void z_xtensa_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
2525
K_KERNEL_STACK_ARRAY_DECLARE(z_interrupt_stacks, CONFIG_MP_MAX_NUM_CPUS,
2626
CONFIG_ISR_STACK_SIZE);
2727

28-
static ALWAYS_INLINE void z_xtensa_kernel_init(void)
28+
static ALWAYS_INLINE void arch_kernel_init(void)
2929
{
3030
_cpu_t *cpu0 = &_kernel.cpus[0];
3131

@@ -51,21 +51,15 @@ static ALWAYS_INLINE void z_xtensa_kernel_init(void)
5151
* win.
5252
*/
5353
XTENSA_WSR(ZSR_CPU_STR, cpu0);
54-
}
55-
56-
static ALWAYS_INLINE void arch_kernel_init(void)
57-
{
58-
#ifndef CONFIG_XTENSA_MMU
59-
/* This is called in z_xtensa_mmu_init() before z_cstart()
60-
* so we do not need to call it again.
61-
*/
62-
z_xtensa_kernel_init();
63-
#endif
6454

6555
#ifdef CONFIG_INIT_STACKS
6656
memset(Z_KERNEL_STACK_BUFFER(z_interrupt_stacks[0]), 0xAA,
6757
K_KERNEL_STACK_SIZEOF(z_interrupt_stacks[0]));
6858
#endif
59+
60+
#ifdef CONFIG_XTENSA_MMU
61+
z_xtensa_mmu_init();
62+
#endif
6963
}
7064

7165
void xtensa_switch(void *switch_to, void **switched_from);

include/zephyr/arch/xtensa/xtensa_mmu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,4 @@ extern int xtensa_soc_mmu_ranges_num;
2626

2727
void z_xtensa_mmu_init(void);
2828

29-
void z_xtensa_mmu_smp_init(void);
30-
3129
#endif /* ZEPHYR_INCLUDE_ARCH_XTENSA_XTENSA_MMU_H */

0 commit comments

Comments
 (0)