From 42396735bf770136ce70761e407387d98935e8fb Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sat, 6 Jul 2024 13:00:14 -0400 Subject: [PATCH] xtensa: introduce prep_c for xtensa xtensa is the only architecutre doing thing differently and introduces inconsistency in the init process and dependencies as we attemp to cleanup init levels and remove misused of SYS_INIT. Introduce prep_c for this architecture and align with other architectures. Signed-off-by: Anas Nashif --- arch/xtensa/core/CMakeLists.txt | 1 + arch/xtensa/core/crt1.S | 4 ++-- arch/xtensa/core/prep_c.c | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 arch/xtensa/core/prep_c.c diff --git a/arch/xtensa/core/CMakeLists.txt b/arch/xtensa/core/CMakeLists.txt index 56ca1071b01..d03e3641b42 100644 --- a/arch/xtensa/core/CMakeLists.txt +++ b/arch/xtensa/core/CMakeLists.txt @@ -12,6 +12,7 @@ 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) diff --git a/arch/xtensa/core/crt1.S b/arch/xtensa/core/crt1.S index e881a41fc92..5e3bf9e8a2c 100644 --- a/arch/xtensa/core/crt1.S +++ b/arch/xtensa/core/crt1.S @@ -22,7 +22,7 @@ */ .global __start -.type z_cstart, @function +.type z_prep_c, @function /* Macros to abstract away ABI differences */ @@ -189,6 +189,6 @@ _start: #endif /* !XCHAL_HAVE_BOOTLOADER */ /* Enter C domain, never returns from here */ - CALL z_cstart + CALL z_prep_c .size _start, . - _start diff --git a/arch/xtensa/core/prep_c.c b/arch/xtensa/core/prep_c.c new file mode 100644 index 00000000000..963958cd244 --- /dev/null +++ b/arch/xtensa/core/prep_c.c @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 Intel Corporation. + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include + +extern FUNC_NORETURN void z_cstart(void); + +/** + * + * @brief Prepare to and run C code + * + * This routine prepares for the execution of and runs C code. + * + */ +void z_prep_c(void) +{ + z_cstart(); + CODE_UNREACHABLE; +}