1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_REBOOT_H
3 #define _LINUX_REBOOT_H
6 #include <linux/notifier.h>
7 #include <uapi/linux/reboot.h>
10 struct sys_off_handler;
12 #define SYS_DOWN 0x0001 /* Notify of system down */
13 #define SYS_RESTART SYS_DOWN
14 #define SYS_HALT 0x0002 /* Notify of system halt */
15 #define SYS_POWER_OFF 0x0003 /* Notify of system power off */
18 REBOOT_UNDEFINED = -1,
25 extern enum reboot_mode reboot_mode;
26 extern enum reboot_mode panic_reboot_mode;
37 extern enum reboot_type reboot_type;
39 extern int reboot_default;
40 extern int reboot_cpu;
41 extern int reboot_force;
44 extern int register_reboot_notifier(struct notifier_block *);
45 extern int unregister_reboot_notifier(struct notifier_block *);
47 extern int devm_register_reboot_notifier(struct device *, struct notifier_block *);
49 extern int register_restart_handler(struct notifier_block *);
50 extern int unregister_restart_handler(struct notifier_block *);
51 extern void do_kernel_restart(char *cmd);
54 * Architecture-specific implementations of sys_reboot commands.
57 extern void migrate_to_reboot_cpu(void);
58 extern void machine_restart(char *cmd);
59 extern void machine_halt(void);
60 extern void machine_power_off(void);
62 extern void machine_shutdown(void);
64 extern void machine_crash_shutdown(struct pt_regs *);
66 void do_kernel_power_off(void);
69 * sys-off handler API.
73 * Standard sys-off priority levels. Users are expected to set priorities
74 * relative to the standard levels.
76 * SYS_OFF_PRIO_PLATFORM: Use this for platform-level handlers.
78 * SYS_OFF_PRIO_LOW: Use this for handler of last resort.
80 * SYS_OFF_PRIO_DEFAULT: Use this for normal handlers.
82 * SYS_OFF_PRIO_HIGH: Use this for higher priority handlers.
84 * SYS_OFF_PRIO_FIRMWARE: Use this if handler uses firmware call.
86 #define SYS_OFF_PRIO_PLATFORM -256
87 #define SYS_OFF_PRIO_LOW -128
88 #define SYS_OFF_PRIO_DEFAULT 0
89 #define SYS_OFF_PRIO_HIGH 192
90 #define SYS_OFF_PRIO_FIRMWARE 224
94 * @SYS_OFF_MODE_POWER_OFF_PREPARE:
96 * Handlers prepare system to be powered off. Handlers are
99 SYS_OFF_MODE_POWER_OFF_PREPARE,
102 * @SYS_OFF_MODE_POWER_OFF:
104 * Handlers power-off system. Handlers are disallowed to sleep.
106 SYS_OFF_MODE_POWER_OFF,
109 * @SYS_OFF_MODE_RESTART_PREPARE:
111 * Handlers prepare system to be restarted. Handlers are
114 SYS_OFF_MODE_RESTART_PREPARE,
117 * @SYS_OFF_MODE_RESTART:
119 * Handlers restart system. Handlers are disallowed to sleep.
121 SYS_OFF_MODE_RESTART,
125 * struct sys_off_data - sys-off callback argument
127 * @mode: Mode ID. Currently used only by the sys-off restart mode,
128 * see enum reboot_mode for the available modes.
129 * @cb_data: User's callback data.
130 * @cmd: Command string. Currently used only by the sys-off restart mode,
133 struct sys_off_data {
139 struct sys_off_handler *
140 register_sys_off_handler(enum sys_off_mode mode,
142 int (*callback)(struct sys_off_data *data),
144 void unregister_sys_off_handler(struct sys_off_handler *handler);
146 int devm_register_sys_off_handler(struct device *dev,
147 enum sys_off_mode mode,
149 int (*callback)(struct sys_off_data *data),
152 int devm_register_power_off_handler(struct device *dev,
153 int (*callback)(struct sys_off_data *data),
156 int devm_register_restart_handler(struct device *dev,
157 int (*callback)(struct sys_off_data *data),
160 int register_platform_power_off(void (*power_off)(void));
161 void unregister_platform_power_off(void (*power_off)(void));
164 * Architecture independent implemenations of sys_reboot commands.
167 extern void kernel_restart_prepare(char *cmd);
168 extern void kernel_restart(char *cmd);
169 extern void kernel_halt(void);
170 extern void kernel_power_off(void);
171 extern bool kernel_can_power_off(void);
173 void ctrl_alt_del(void);
175 extern void orderly_poweroff(bool force);
176 extern void orderly_reboot(void);
177 void hw_protection_shutdown(const char *reason, int ms_until_forced);
180 * Emergency restart, callable from an interrupt handler.
183 extern void emergency_restart(void);
184 #include <asm/emergency-restart.h>
186 #endif /* _LINUX_REBOOT_H */