1 /*
2  * Copyright (c) 2016 Jean-Paul Etienne <fractalclone@gmail.com>
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 and call z_cstart().
13  *
14  * Stack is available in this module, but not the global data/bss until their
15  * initialization is performed.
16  */
17 
18 #include <stddef.h>
19 #include <toolchain.h>
20 #include <kernel_structs.h>
21 #include <kernel_internal.h>
22 #include <core_pmp.h>
23 
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  * @return N/A
31  */
32 
_PrepC(void)33 void _PrepC(void)
34 {
35 	z_bss_zero();
36 #ifdef CONFIG_XIP
37 	z_data_copy();
38 #endif
39 #if defined(CONFIG_RISCV_SOC_INTERRUPT_INIT)
40 	soc_interrupt_init();
41 #endif
42 #ifdef CONFIG_PMP_STACK_GUARD
43 	z_riscv_configure_interrupt_stack_guard();
44 #endif
45 	z_cstart();
46 	CODE_UNREACHABLE;
47 }
48