1 /*
2  * Copyright (c) 2015 Wind River Systems, Inc.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @file x86-specific reboot functionalities
9  *
10  * @details Implements the required 'arch' sub-APIs.
11  */
12 
13 #include <zephyr/kernel.h>
14 #include <zephyr/sys/reboot.h>
15 
16 /* reboot through Reset Control Register (I/O port 0xcf9) */
17 
18 #define X86_RST_CNT_REG 0xcf9
19 #define X86_RST_CNT_SYS_RST 0x02
20 #define X86_RST_CNT_CPU_RST 0x4
21 #define X86_RST_CNT_FULL_RST 0x08
22 
cold_reboot(void)23 static inline void cold_reboot(void)
24 {
25 	uint8_t reset_value = X86_RST_CNT_CPU_RST | X86_RST_CNT_SYS_RST |
26 				X86_RST_CNT_FULL_RST;
27 	sys_out8(reset_value, X86_RST_CNT_REG);
28 }
29 
sys_arch_reboot(int type)30 void __weak sys_arch_reboot(int type)
31 {
32 	switch (type) {
33 	case SYS_REBOOT_COLD:
34 		cold_reboot();
35 		break;
36 	default:
37 		/* do nothing */
38 		break;
39 	}
40 }
41