1 /* 2 * Copyright (c) 2019 Carlo Caione <ccaione@baylibre.com> 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @file 9 * @brief Full C support initialization 10 * 11 * Initialization of full C support: zero the .bss and call z_cstart(). 12 * 13 * Stack is available in this module, but not the global data/bss until their 14 * initialization is performed. 15 */ 16 17 #include <kernel_internal.h> 18 #include <zephyr/linker/linker-defs.h> 19 #include <zephyr/platform/hooks.h> 20 #include <zephyr/arch/cache.h> 21 22 extern void z_arm64_mm_init(bool is_primary_core); 23 z_arm64_mm_init(bool is_primary_core)24__weak void z_arm64_mm_init(bool is_primary_core) { } 25 26 /** 27 * 28 * @brief Prepare to and run C code 29 * 30 * This routine prepares for the execution of and runs C code. 31 * 32 */ z_prep_c(void)33void z_prep_c(void) 34 { 35 #if defined(CONFIG_SOC_PREP_HOOK) 36 soc_prep_hook(); 37 #endif 38 39 /* Initialize tpidrro_el0 with our struct _cpu instance address */ 40 write_tpidrro_el0((uintptr_t)&_kernel.cpus[0]); 41 42 z_bss_zero(); 43 z_data_copy(); 44 #ifdef CONFIG_ARM64_SAFE_EXCEPTION_STACK 45 /* After bss clean, _kernel.cpus is in bss section */ 46 z_arm64_safe_exception_stack_init(); 47 #endif 48 z_arm64_mm_init(true); 49 z_arm64_interrupt_init(); 50 51 z_cstart(); 52 CODE_UNREACHABLE; 53 } 54 55 56 #if CONFIG_MP_MAX_NUM_CPUS > 1 57 extern FUNC_NORETURN void arch_secondary_cpu_init(void); z_arm64_secondary_prep_c(void)58void z_arm64_secondary_prep_c(void) 59 { 60 arch_secondary_cpu_init(); 61 #if CONFIG_ARCH_CACHE 62 arch_cache_init(); 63 #endif 64 65 CODE_UNREACHABLE; 66 } 67 #endif 68