blob: e63799a6e89515d0893606530b07e101f39c52fb [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _LINUX_REBOOT_H
3#define _LINUX_REBOOT_H
4
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
6#include <linux/notifier.h>
David Howells607ca462012-10-13 10:46:48 +01007#include <uapi/linux/reboot.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Andrey Smirnov2d8364b2017-11-17 15:30:57 -08009struct device;
10
Amerigo Wangc5f41752011-07-25 17:13:10 -070011#define SYS_DOWN 0x0001 /* Notify of system down */
12#define SYS_RESTART SYS_DOWN
13#define SYS_HALT 0x0002 /* Notify of system halt */
14#define SYS_POWER_OFF 0x0003 /* Notify of system power off */
15
Robin Holtedf2b132013-07-08 16:01:35 -070016enum reboot_mode {
17 REBOOT_COLD = 0,
18 REBOOT_WARM,
Robin Holtc97a7002013-07-08 16:01:36 -070019 REBOOT_HARD,
20 REBOOT_SOFT,
Robin Holt7b6d8642013-07-08 16:01:40 -070021 REBOOT_GPIO,
Robin Holtedf2b132013-07-08 16:01:35 -070022};
Robin Holt1b3a5d02013-07-08 16:01:42 -070023extern enum reboot_mode reboot_mode;
24
25enum reboot_type {
Ingo Molnar5be44a62014-04-04 08:41:26 +020026 BOOT_TRIPLE = 't',
27 BOOT_KBD = 'k',
28 BOOT_BIOS = 'b',
29 BOOT_ACPI = 'a',
30 BOOT_EFI = 'e',
31 BOOT_CF9_FORCE = 'p',
32 BOOT_CF9_SAFE = 'q',
Robin Holt1b3a5d02013-07-08 16:01:42 -070033};
34extern enum reboot_type reboot_type;
35
36extern int reboot_default;
37extern int reboot_cpu;
38extern int reboot_force;
39
Robin Holtedf2b132013-07-08 16:01:35 -070040
Linus Torvalds1da177e2005-04-16 15:20:36 -070041extern int register_reboot_notifier(struct notifier_block *);
42extern int unregister_reboot_notifier(struct notifier_block *);
43
Andrey Smirnov2d8364b2017-11-17 15:30:57 -080044extern int devm_register_reboot_notifier(struct device *, struct notifier_block *);
45
Guenter Roeckb63adb972014-09-26 00:03:16 +000046extern int register_restart_handler(struct notifier_block *);
47extern int unregister_restart_handler(struct notifier_block *);
48extern void do_kernel_restart(char *cmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50/*
51 * Architecture-specific implementations of sys_reboot commands.
52 */
53
Vivek Goyalc97102b2013-12-18 17:08:31 -080054extern void migrate_to_reboot_cpu(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055extern void machine_restart(char *cmd);
56extern void machine_halt(void);
57extern void machine_power_off(void);
58
Eric W. Biedermandc009d92005-06-25 14:57:52 -070059extern void machine_shutdown(void);
Alexander Nyberg6e274d12005-06-25 14:58:26 -070060struct pt_regs;
61extern void machine_crash_shutdown(struct pt_regs *);
Eric W. Biedermandc009d92005-06-25 14:57:52 -070062
Robin Holt972ee832013-07-08 16:01:34 -070063/*
Eric W. Biederman4a00ea12005-07-26 11:24:14 -060064 * Architecture independent implemenations of sys_reboot commands.
65 */
66
Huang Yingca195b72008-08-15 00:40:24 -070067extern void kernel_restart_prepare(char *cmd);
Eric W. Biederman4a00ea12005-07-26 11:24:14 -060068extern void kernel_restart(char *cmd);
69extern void kernel_halt(void);
70extern void kernel_power_off(void);
Adrian Bunk83cc5ed2006-06-25 05:47:41 -070071
Dave Youngeb5572f2010-03-10 15:23:59 -080072extern int C_A_D; /* for sysctl */
Adrian Bunk83cc5ed2006-06-25 05:47:41 -070073void ctrl_alt_del(void);
Eric W. Biederman4a00ea12005-07-26 11:24:14 -060074
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070075#define POWEROFF_CMD_PATH_LEN 256
76extern char poweroff_cmd[POWEROFF_CMD_PATH_LEN];
77
Joel Stanley7a54f462015-04-15 16:16:53 -070078extern void orderly_poweroff(bool force);
79extern void orderly_reboot(void);
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070080
Eric W. Biederman7c903472005-07-26 11:29:55 -060081/*
82 * Emergency restart, callable from an interrupt handler.
83 */
84
85extern void emergency_restart(void);
86#include <asm/emergency-restart.h>
87
Linus Torvalds1da177e2005-04-16 15:20:36 -070088#endif /* _LINUX_REBOOT_H */