1 /*
2  * Copyright (c) 2021 Katsuhiro Suzuki
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @file
9  * @brief QEMU RISC-V virt machine hardware depended interface
10  */
11 
12 #include <zephyr/kernel.h>
13 #include <zephyr/arch/cpu.h>
14 #include <zephyr/sys/util.h>
15 
16 #define SIFIVE_SYSCON_TEST 0x00100000
17 
18 /*
19  * Exit QEMU and tell error number.
20  *   Higher 16bits: indicates error number.
21  *   Lower 16bits : set FINISHER_FAIL
22  */
23 #define FINISHER_FAIL		0x3333
24 
25 /* Exit QEMU successfully */
26 #define FINISHER_EXIT		0x5555
27 
28 /* Reboot machine */
29 #define FINISHER_REBOOT		0x7777
30 
sys_arch_reboot(int type)31 void sys_arch_reboot(int type)
32 {
33 	volatile uint32_t *reg = (uint32_t *)SIFIVE_SYSCON_TEST;
34 
35 	*reg = FINISHER_REBOOT;
36 
37 	ARG_UNUSED(type);
38 }
39