1 /*
2 * Copyright (c) 2018 Synopsys.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/kernel.h>
8 #include <zephyr/sys/printk.h>
9 #include <zephyr/devicetree.h>
10
11 #if defined(CONFIG_SOC_NSIM_SEM)
12 #define NORMAL_FIRMWARE_ENTRY 0x40000
13 #elif defined(CONFIG_SOC_EMSK)
14 #define NORMAL_FIRMWARE_ENTRY 0x20000
15 #endif
16
17
18 #define STACKSIZE 1024
19 #define PRIORITY 7
20 #define SLEEPTIME 1000
21
22
threadA(void * dummy1,void * dummy2,void * dummy3)23 void threadA(void *dummy1, void *dummy2, void *dummy3)
24 {
25 ARG_UNUSED(dummy1);
26 ARG_UNUSED(dummy2);
27 ARG_UNUSED(dummy3);
28
29
30 printk("Go to normal application\n");
31
32 arc_go_to_normal(*((uint32_t *)(NORMAL_FIRMWARE_ENTRY)));
33
34 printk("should not come here\n");
35
36 }
37
38 K_THREAD_DEFINE(thread_a, STACKSIZE, threadA, NULL, NULL, NULL,
39 PRIORITY, 0, 0);
40
41
main(void)42 int main(void)
43 {
44 /* necessary configuration before go to normal */
45 int32_t i = 0;
46
47 /* allocate timer 0 and timer1 to normal mode */
48 z_arc_v2_irq_uinit_secure_set(DT_IRQN(DT_NODELABEL(timer0)), 0);
49 z_arc_v2_irq_uinit_secure_set(DT_IRQN(DT_NODELABEL(timer1)), 0);
50
51 /* disable the secure interrupts for debug purpose*/
52 /* _arc_v2_irq_unit_int_disable(IRQ_S_TIMER0); */
53
54 while (1) {
55 printk("I am the %s thread in secure world: %d\n",
56 __func__, i++);
57 k_msleep(SLEEPTIME);
58 }
59 return 0;
60 }
61