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 Aug 5, 2024
1 parent 43898cb commit 8315a6b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
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
3 changes: 2 additions & 1 deletion soc/espressif/esp32s2/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

extern void rtc_clk_cpu_freq_set_xtal(void);
extern void esp_reset_reason_init(void);
extern void z_prep_c(void);

#if CONFIG_ESP_SPIRAM
extern int _ext_ram_bss_start;
Expand Down Expand Up @@ -143,7 +144,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 8315a6b

Please sign in to comment.