1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* -*- linux-c -*-
3  *
4  *	$Id: sysrq.h,v 1.3 1997/07/17 11:54:33 mj Exp $
5  *
6  *	Linux Magic System Request Key Hacks
7  *
8  *	(c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
9  *
10  *	(c) 2000 Crutcher Dunnavant <crutcher+kernel@datastacks.com>
11  *	overhauled to use key registration
12  *	based upon discusions in irc://irc.openprojects.net/#kernelnewbies
13  */
14 
15 #ifndef _LINUX_SYSRQ_H
16 #define _LINUX_SYSRQ_H
17 
18 #include <linux/errno.h>
19 #include <linux/types.h>
20 
21 /* Possible values of bitmask for enabling sysrq functions */
22 /* 0x0001 is reserved for enable everything */
23 #define SYSRQ_ENABLE_LOG	0x0002
24 #define SYSRQ_ENABLE_KEYBOARD	0x0004
25 #define SYSRQ_ENABLE_DUMP	0x0008
26 #define SYSRQ_ENABLE_SYNC	0x0010
27 #define SYSRQ_ENABLE_REMOUNT	0x0020
28 #define SYSRQ_ENABLE_SIGNAL	0x0040
29 #define SYSRQ_ENABLE_BOOT	0x0080
30 #define SYSRQ_ENABLE_RTNICE	0x0100
31 
32 struct sysrq_key_op {
33 	void (* const handler)(int);
34 	const char * const help_msg;
35 	const char * const action_msg;
36 	const int enable_mask;
37 };
38 
39 #ifdef CONFIG_MAGIC_SYSRQ
40 
41 /* Generic SysRq interface -- you may call it from any device driver, supplying
42  * ASCII code of the key, pointer to registers and kbd/tty structs (if they
43  * are available -- else NULL's).
44  */
45 
46 void handle_sysrq(int key);
47 void __handle_sysrq(int key, bool check_mask);
48 int register_sysrq_key(int key, const struct sysrq_key_op *op);
49 int unregister_sysrq_key(int key, const struct sysrq_key_op *op);
50 extern const struct sysrq_key_op *__sysrq_reboot_op;
51 
52 int sysrq_toggle_support(int enable_mask);
53 int sysrq_mask(void);
54 
55 #else
56 
handle_sysrq(int key)57 static inline void handle_sysrq(int key)
58 {
59 }
60 
__handle_sysrq(int key,bool check_mask)61 static inline void __handle_sysrq(int key, bool check_mask)
62 {
63 }
64 
register_sysrq_key(int key,const struct sysrq_key_op * op)65 static inline int register_sysrq_key(int key, const struct sysrq_key_op *op)
66 {
67 	return -EINVAL;
68 }
69 
unregister_sysrq_key(int key,const struct sysrq_key_op * op)70 static inline int unregister_sysrq_key(int key, const struct sysrq_key_op *op)
71 {
72 	return -EINVAL;
73 }
74 
sysrq_mask(void)75 static inline int sysrq_mask(void)
76 {
77 	/* Magic SysRq disabled mask */
78 	return 0;
79 }
80 
81 #endif
82 
83 #endif /* _LINUX_SYSRQ_H */
84