cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

reboot.h (4476B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2#ifndef _LINUX_REBOOT_H
      3#define _LINUX_REBOOT_H
      4
      5
      6#include <linux/notifier.h>
      7#include <uapi/linux/reboot.h>
      8
      9struct device;
     10struct sys_off_handler;
     11
     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 */
     16
     17enum reboot_mode {
     18	REBOOT_UNDEFINED = -1,
     19	REBOOT_COLD = 0,
     20	REBOOT_WARM,
     21	REBOOT_HARD,
     22	REBOOT_SOFT,
     23	REBOOT_GPIO,
     24};
     25extern enum reboot_mode reboot_mode;
     26extern enum reboot_mode panic_reboot_mode;
     27
     28enum reboot_type {
     29	BOOT_TRIPLE	= 't',
     30	BOOT_KBD	= 'k',
     31	BOOT_BIOS	= 'b',
     32	BOOT_ACPI	= 'a',
     33	BOOT_EFI	= 'e',
     34	BOOT_CF9_FORCE	= 'p',
     35	BOOT_CF9_SAFE	= 'q',
     36};
     37extern enum reboot_type reboot_type;
     38
     39extern int reboot_default;
     40extern int reboot_cpu;
     41extern int reboot_force;
     42
     43
     44extern int register_reboot_notifier(struct notifier_block *);
     45extern int unregister_reboot_notifier(struct notifier_block *);
     46
     47extern int devm_register_reboot_notifier(struct device *, struct notifier_block *);
     48
     49extern int register_restart_handler(struct notifier_block *);
     50extern int unregister_restart_handler(struct notifier_block *);
     51extern void do_kernel_restart(char *cmd);
     52
     53/*
     54 * Architecture-specific implementations of sys_reboot commands.
     55 */
     56
     57extern void migrate_to_reboot_cpu(void);
     58extern void machine_restart(char *cmd);
     59extern void machine_halt(void);
     60extern void machine_power_off(void);
     61
     62extern void machine_shutdown(void);
     63struct pt_regs;
     64extern void machine_crash_shutdown(struct pt_regs *);
     65
     66void do_kernel_power_off(void);
     67
     68/*
     69 * sys-off handler API.
     70 */
     71
     72/*
     73 * Standard sys-off priority levels. Users are expected to set priorities
     74 * relative to the standard levels.
     75 *
     76 * SYS_OFF_PRIO_PLATFORM:	Use this for platform-level handlers.
     77 *
     78 * SYS_OFF_PRIO_LOW:		Use this for handler of last resort.
     79 *
     80 * SYS_OFF_PRIO_DEFAULT:	Use this for normal handlers.
     81 *
     82 * SYS_OFF_PRIO_HIGH:		Use this for higher priority handlers.
     83 *
     84 * SYS_OFF_PRIO_FIRMWARE:	Use this if handler uses firmware call.
     85 */
     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
     91
     92enum sys_off_mode {
     93	/**
     94	 * @SYS_OFF_MODE_POWER_OFF_PREPARE:
     95	 *
     96	 * Handlers prepare system to be powered off. Handlers are
     97	 * allowed to sleep.
     98	 */
     99	SYS_OFF_MODE_POWER_OFF_PREPARE,
    100
    101	/**
    102	 * @SYS_OFF_MODE_POWER_OFF:
    103	 *
    104	 * Handlers power-off system. Handlers are disallowed to sleep.
    105	 */
    106	SYS_OFF_MODE_POWER_OFF,
    107
    108	/**
    109	 * @SYS_OFF_MODE_RESTART:
    110	 *
    111	 * Handlers restart system. Handlers are disallowed to sleep.
    112	 */
    113	SYS_OFF_MODE_RESTART,
    114};
    115
    116/**
    117 * struct sys_off_data - sys-off callback argument
    118 *
    119 * @mode: Mode ID. Currently used only by the sys-off restart mode,
    120 *        see enum reboot_mode for the available modes.
    121 * @cb_data: User's callback data.
    122 * @cmd: Command string. Currently used only by the sys-off restart mode,
    123 *       NULL otherwise.
    124 */
    125struct sys_off_data {
    126	int mode;
    127	void *cb_data;
    128	const char *cmd;
    129};
    130
    131struct sys_off_handler *
    132register_sys_off_handler(enum sys_off_mode mode,
    133			 int priority,
    134			 int (*callback)(struct sys_off_data *data),
    135			 void *cb_data);
    136void unregister_sys_off_handler(struct sys_off_handler *handler);
    137
    138int devm_register_sys_off_handler(struct device *dev,
    139				  enum sys_off_mode mode,
    140				  int priority,
    141				  int (*callback)(struct sys_off_data *data),
    142				  void *cb_data);
    143
    144int devm_register_power_off_handler(struct device *dev,
    145				    int (*callback)(struct sys_off_data *data),
    146				    void *cb_data);
    147
    148int devm_register_restart_handler(struct device *dev,
    149				  int (*callback)(struct sys_off_data *data),
    150				  void *cb_data);
    151
    152int register_platform_power_off(void (*power_off)(void));
    153void unregister_platform_power_off(void (*power_off)(void));
    154
    155/*
    156 * Architecture independent implemenations of sys_reboot commands.
    157 */
    158
    159extern void kernel_restart_prepare(char *cmd);
    160extern void kernel_restart(char *cmd);
    161extern void kernel_halt(void);
    162extern void kernel_power_off(void);
    163extern bool kernel_can_power_off(void);
    164
    165void ctrl_alt_del(void);
    166
    167extern void orderly_poweroff(bool force);
    168extern void orderly_reboot(void);
    169void hw_protection_shutdown(const char *reason, int ms_until_forced);
    170
    171/*
    172 * Emergency restart, callable from an interrupt handler.
    173 */
    174
    175extern void emergency_restart(void);
    176#include <asm/emergency-restart.h>
    177
    178#endif /* _LINUX_REBOOT_H */