Skip to content

Commit

Permalink
xtensa: adapt soc code to use prep_c
Browse files Browse the repository at this point in the history
Many xtensa target jump from soc code directly into cstart and depend on
architecture code being initialized in arch_kernel_init(). Instead of
jumping to cstart, jump to newly introduced prep_c similar to all other
architectures, where common platfotm initialization will happen.

Signed-off-by: Anas Nashif <[email protected]>
  • Loading branch information
nashif committed Jul 9, 2024
1 parent 1f04c64 commit ec66949
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion arch/xtensa/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ zephyr_library_sources(
irq_manage.c
thread.c
vector_handlers.c
prep_c.c
)

zephyr_library_sources_ifdef(CONFIG_XTENSA_USE_CORE_CRT1 crt1.S prep_c.c)
zephyr_library_sources_ifdef(CONFIG_XTENSA_USE_CORE_CRT1 crt1.S)
zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c)
zephyr_library_sources_ifdef(CONFIG_THREAD_LOCAL_STORAGE tls.c)
zephyr_library_sources_ifdef(CONFIG_XTENSA_ENABLE_BACKTRACE xtensa_backtrace.c)
Expand Down
6 changes: 3 additions & 3 deletions soc/espressif/esp32/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern int _ext_ram_bss_start;
extern int _ext_ram_bss_end;
#endif

extern void z_cstart(void);
extern void z_prep_c(void);
extern void esp_reset_reason_init(void);

#ifdef CONFIG_SOC_ENABLE_APPCPU
Expand Down Expand Up @@ -120,7 +120,7 @@ void IRAM_ATTR __esp_platform_start(void)

/* Initialize the architecture CPU pointer. Some of the
* initialization code wants a valid _current before
* arch_kernel_init() is invoked.
* z_prep_c() is invoked.
*/
__asm__ __volatile__("wsr.MISC0 %0; rsync" : : "r"(&_kernel.cpus[0]));

Expand Down Expand Up @@ -188,7 +188,7 @@ void IRAM_ATTR __esp_platform_start(void)
esp_intr_initialize();

/* Start Zephyr */
z_cstart();
z_prep_c();

CODE_UNREACHABLE;
}
Expand Down
6 changes: 3 additions & 3 deletions soc/espressif/esp32/soc_appcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <esp_app_format.h>
#include <zephyr/sys/printk.h>

extern void z_cstart(void);
extern void z_prep_c(void);

/*
* This is written in C rather than assembly since, during the port bring up,
Expand Down Expand Up @@ -69,13 +69,13 @@ void __app_cpu_start(void)

/* Initialize the architecture CPU pointer. Some of the
* initialization code wants a valid _current before
* arch_kernel_init() is invoked.
* z_prep_c() is invoked.
*/
__asm__ __volatile__("wsr.MISC0 %0; rsync" : : "r"(&_kernel.cpus[0]));

esp_intr_initialize();
/* Start Zephyr */
z_cstart();
z_prep_c();

CODE_UNREACHABLE;
}
Expand Down
2 changes: 1 addition & 1 deletion soc/espressif/esp32s2/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void __attribute__((section(".iram1"))) __esp_platform_start(void)

esp_intr_initialize();
/* Start Zephyr */
z_cstart();
z_prep_c();

CODE_UNREACHABLE;
}
Expand Down
4 changes: 2 additions & 2 deletions soc/espressif/esp32s3/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern int _ext_ram_bss_start;
extern int _ext_ram_bss_end;
#endif

extern void z_cstart(void);
extern void z_prep_c(void);
extern void esp_reset_reason_init(void);

#ifdef CONFIG_SOC_ENABLE_APPCPU
Expand Down Expand Up @@ -212,7 +212,7 @@ void IRAM_ATTR __esp_platform_start(void)
esp_intr_initialize();

/* Start Zephyr */
z_cstart();
z_prep_c();

CODE_UNREACHABLE;
}
Expand Down
4 changes: 2 additions & 2 deletions soc/espressif/esp32s3/soc_appcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <esp_app_format.h>
#include <esp_clk_internal.h>

extern void z_cstart(void);
extern void z_prep_c(void);

static void core_intr_matrix_clear(void)
{
Expand Down Expand Up @@ -72,7 +72,7 @@ void IRAM_ATTR __app_cpu_start(void)
esp_intr_initialize();

/* Start Zephyr */
z_cstart();
z_prep_c();

CODE_UNREACHABLE;
}
Expand Down
4 changes: 2 additions & 2 deletions soc/intel/intel_adsp/common/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,6 @@ __imr void boot_core0(void)
xtensa_vecbase_lock();

/* Zephyr! */
extern FUNC_NORETURN void z_cstart(void);
z_cstart();
extern FUNC_NORETURN void z_prep_c(void);
z_prep_c();
}
2 changes: 1 addition & 1 deletion soc/mediatek/mtk_adsp/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,5 @@ void c_boot(void)
val = 0xffffffff;
__asm__ volatile("wsr %0, INTCLEAR" :: "r"(val));

z_cstart();
z_prep_c();
}

0 comments on commit ec66949

Please sign in to comment.