1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_REBOOT_H
3 #define _LINUX_REBOOT_H
4
5 #include <linux/notifier.h>
6 #include <uapi/linux/reboot.h>
7
8 struct device;
9
10 #define SYS_DOWN 0x0001 /* Notify of system down */
11 #define SYS_RESTART SYS_DOWN
12 #define SYS_HALT 0x0002 /* Notify of system halt */
13 #define SYS_POWER_OFF 0x0003 /* Notify of system power off */
14
15 enum reboot_mode {
16 REBOOT_UNDEFINED = -1,
17 REBOOT_COLD = 0,
18 REBOOT_WARM,
19 REBOOT_HARD,
20 REBOOT_SOFT,
21 REBOOT_GPIO,
22 };
23 extern enum reboot_mode reboot_mode;
24 extern enum reboot_mode panic_reboot_mode;
25
26 enum reboot_type {
27 BOOT_TRIPLE = 't',
28 BOOT_KBD = 'k',
29 BOOT_BIOS = 'b',
30 BOOT_ACPI = 'a',
31 BOOT_EFI = 'e',
32 BOOT_CF9_FORCE = 'p',
33 BOOT_CF9_SAFE = 'q',
34 };
35 extern enum reboot_type reboot_type;
36
37 extern int reboot_default;
38 extern int reboot_cpu;
39 extern int reboot_force;
40
41 extern int register_reboot_notifier(struct notifier_block *);
42 extern int unregister_reboot_notifier(struct notifier_block *);
43
44 extern int devm_register_reboot_notifier(struct device *, struct notifier_block *);
45
46 extern int register_restart_handler(struct notifier_block *);
47 extern int unregister_restart_handler(struct notifier_block *);
48 extern void do_kernel_restart(char *cmd);
49
50 #ifdef CONFIG_NO_GKI
51 extern int register_pre_restart_handler(struct notifier_block *nb);
52 extern int unregister_pre_restart_handler(struct notifier_block *nb);
53 extern void do_kernel_pre_restart(char *cmd);
54 #else
register_pre_restart_handler(struct notifier_block * nb)55 static inline int register_pre_restart_handler(struct notifier_block *nb)
56 {
57 return 0;
58 }
59
unregister_pre_restart_handler(struct notifier_block * nb)60 static inline int unregister_pre_restart_handler(struct notifier_block *nb)
61 {
62 return 0;
63 }
64
do_kernel_pre_restart(char * cmd)65 static inline void do_kernel_pre_restart(char *cmd)
66 {
67 }
68 #endif
69
70 /*
71 * Architecture-specific implementations of sys_reboot commands.
72 */
73
74 extern void migrate_to_reboot_cpu(void);
75 extern void machine_restart(char *cmd);
76 extern void machine_halt(void);
77 extern void machine_power_off(void);
78
79 extern void machine_shutdown(void);
80 struct pt_regs;
81 extern void machine_crash_shutdown(struct pt_regs *);
82
83 /*
84 * Architecture independent implemenations of sys_reboot commands.
85 */
86
87 extern void kernel_restart_prepare(char *cmd);
88 extern void kernel_restart(char *cmd);
89 extern void kernel_halt(void);
90 extern void kernel_power_off(void);
91
92 extern int C_A_D; /* for sysctl */
93 void ctrl_alt_del(void);
94
95 #define POWEROFF_CMD_PATH_LEN 256
96 extern char poweroff_cmd[POWEROFF_CMD_PATH_LEN];
97
98 extern void orderly_poweroff(bool force);
99 extern void orderly_reboot(void);
100
101 /*
102 * Emergency restart, callable from an interrupt handler.
103 */
104
105 extern void emergency_restart(void);
106 #include <asm/emergency-restart.h>
107
108 #endif /* _LINUX_REBOOT_H */
109