linux/include/linux/sysrq.h

/* SPDX-License-Identifier: GPL-2.0 */
/* -*- linux-c -*-
 *
 *	$Id: sysrq.h,v 1.3 1997/07/17 11:54:33 mj Exp $
 *
 *	Linux Magic System Request Key Hacks
 *
 *	(c) 1997 Martin Mares <[email protected]>
 *
 *	(c) 2000 Crutcher Dunnavant <[email protected]>
 *	overhauled to use key registration
 *	based upon discusions in irc://irc.openprojects.net/#kernelnewbies
 */

#ifndef _LINUX_SYSRQ_H
#define _LINUX_SYSRQ_H

#include <linux/errno.h>
#include <linux/types.h>

/* Possible values of bitmask for enabling sysrq functions */
/* 0x0001 is reserved for enable everything */
#define SYSRQ_ENABLE_LOG
#define SYSRQ_ENABLE_KEYBOARD
#define SYSRQ_ENABLE_DUMP
#define SYSRQ_ENABLE_SYNC
#define SYSRQ_ENABLE_REMOUNT
#define SYSRQ_ENABLE_SIGNAL
#define SYSRQ_ENABLE_BOOT
#define SYSRQ_ENABLE_RTNICE

struct sysrq_key_op {};

#ifdef CONFIG_MAGIC_SYSRQ

/* Generic SysRq interface -- you may call it from any device driver, supplying
 * ASCII code of the key, pointer to registers and kbd/tty structs (if they
 * are available -- else NULL's).
 */

void handle_sysrq(u8 key);
void __handle_sysrq(u8 key, bool check_mask);
int register_sysrq_key(u8 key, const struct sysrq_key_op *op);
int unregister_sysrq_key(u8 key, const struct sysrq_key_op *op);
extern const struct sysrq_key_op *__sysrq_reboot_op;

int sysrq_toggle_support(int enable_mask);
int sysrq_mask(void);

#else

static inline void handle_sysrq(u8 key)
{
}

static inline void __handle_sysrq(u8 key, bool check_mask)
{
}

static inline int register_sysrq_key(u8 key, const struct sysrq_key_op *op)
{
	return -EINVAL;
}

static inline int unregister_sysrq_key(u8 key, const struct sysrq_key_op *op)
{
	return -EINVAL;
}

static inline int sysrq_mask(void)
{
	/* Magic SysRq disabled mask */
	return 0;
}

#endif

#endif /* _LINUX_SYSRQ_H */