1 /* 2 * Copyright (c) 2014 Wind River Systems, Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @file 9 * @brief Full C support initialization 10 * 11 * 12 * Initialization of full C support: zero the .bss, copy the .data if XIP, 13 * call z_cstart(). 14 * 15 * Stack is available in this module, but not the global data/bss until their 16 * initialization is performed. 17 */ 18 19 #include <zephyr/types.h> 20 #include <zephyr/toolchain.h> 21 #include <zephyr/linker/linker-defs.h> 22 #include <zephyr/kernel_structs.h> 23 #include <kernel_internal.h> 24 25 /** 26 * @brief Prepare to and run C code 27 * 28 * This routine prepares for the execution of and runs C code. 29 */ 30 z_prep_c(void)31void z_prep_c(void) 32 { 33 z_bss_zero(); 34 z_data_copy(); 35 /* In most XIP scenarios we copy the exception code into RAM, so need 36 * to flush instruction cache. 37 */ 38 #ifdef CONFIG_XIP 39 z_nios2_icache_flush_all(); 40 #if ALT_CPU_ICACHE_SIZE > 0 41 /* Only need to flush the data cache here if there actually is an 42 * instruction cache, so that the cached instruction data written is 43 * actually committed. 44 */ 45 z_nios2_dcache_flush_all(); 46 #endif 47 #endif 48 z_cstart(); 49 CODE_UNREACHABLE; 50 } 51