1 /*
2  * Copyright 2023 NXP
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/kernel.h>
8 #include <zephyr/device.h>
9 #include <zephyr/init.h>
10 #include <zephyr/cache.h>
11 
12 #include <cmsis_core.h>
13 #include <OsIf.h>
14 
15 #ifdef CONFIG_XIP
16 /* Image Vector Table structure definition for S32K3XX */
17 struct ivt {
18 	uint32_t header;
19 	uint32_t boot_configure;
20 	const uint32_t reserved_1;
21 	const uint32_t *cm7_0_start_address;
22 	const uint32_t reserved_2;
23 	const uint32_t *cm7_1_start_address;
24 	const uint32_t reserved_3;
25 	const uint32_t *cm7_2_start_address;
26 	const uint32_t reserved_4;
27 	const uint32_t *lc_configure;
28 	uint8_t reserved7[216];
29 };
30 
31 #define IVT_MAGIC_MARKER 0x5AA55AA5
32 
33 extern char _vector_start[];
34 
35 /*
36  * IVT for SoC S32K344, the minimal boot configuration is:
37  * - Watchdog (SWT0) is disabled (default value).
38  * - Non-Secure Boot is used (default value).
39  * - Ungate clock for Cortex-M7_0 after boot.
40  * - Application start address of Cortex-M7_0 is application's vector table.
41  */
42 const struct ivt ivt_header __attribute__((section(".ivt_header"))) = {
43 	.header = IVT_MAGIC_MARKER,
44 	.boot_configure = 1,
45 	.cm7_0_start_address = (const void *)_vector_start,
46 	.cm7_1_start_address = NULL,
47 	.cm7_2_start_address = NULL,
48 	.lc_configure = NULL,
49 };
50 #endif /* CONFIG_XIP */
51 
soc_early_init_hook(void)52 void soc_early_init_hook(void)
53 {
54 	sys_cache_instr_enable();
55 	sys_cache_data_enable();
56 
57 	OsIf_Init(NULL);
58 }
59