Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* -*- linux-c -*-
0003  *
0004  *  $Id: sysrq.h,v 1.3 1997/07/17 11:54:33 mj Exp $
0005  *
0006  *  Linux Magic System Request Key Hacks
0007  *
0008  *  (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
0009  *
0010  *  (c) 2000 Crutcher Dunnavant <crutcher+kernel@datastacks.com>
0011  *  overhauled to use key registration
0012  *  based upon discusions in irc://irc.openprojects.net/#kernelnewbies
0013  */
0014 
0015 #ifndef _LINUX_SYSRQ_H
0016 #define _LINUX_SYSRQ_H
0017 
0018 #include <linux/errno.h>
0019 #include <linux/types.h>
0020 
0021 /* Possible values of bitmask for enabling sysrq functions */
0022 /* 0x0001 is reserved for enable everything */
0023 #define SYSRQ_ENABLE_LOG    0x0002
0024 #define SYSRQ_ENABLE_KEYBOARD   0x0004
0025 #define SYSRQ_ENABLE_DUMP   0x0008
0026 #define SYSRQ_ENABLE_SYNC   0x0010
0027 #define SYSRQ_ENABLE_REMOUNT    0x0020
0028 #define SYSRQ_ENABLE_SIGNAL 0x0040
0029 #define SYSRQ_ENABLE_BOOT   0x0080
0030 #define SYSRQ_ENABLE_RTNICE 0x0100
0031 
0032 struct sysrq_key_op {
0033     void (* const handler)(int);
0034     const char * const help_msg;
0035     const char * const action_msg;
0036     const int enable_mask;
0037 };
0038 
0039 #ifdef CONFIG_MAGIC_SYSRQ
0040 
0041 /* Generic SysRq interface -- you may call it from any device driver, supplying
0042  * ASCII code of the key, pointer to registers and kbd/tty structs (if they
0043  * are available -- else NULL's).
0044  */
0045 
0046 void handle_sysrq(int key);
0047 void __handle_sysrq(int key, bool check_mask);
0048 int register_sysrq_key(int key, const struct sysrq_key_op *op);
0049 int unregister_sysrq_key(int key, const struct sysrq_key_op *op);
0050 extern const struct sysrq_key_op *__sysrq_reboot_op;
0051 
0052 int sysrq_toggle_support(int enable_mask);
0053 int sysrq_mask(void);
0054 
0055 #else
0056 
0057 static inline void handle_sysrq(int key)
0058 {
0059 }
0060 
0061 static inline void __handle_sysrq(int key, bool check_mask)
0062 {
0063 }
0064 
0065 static inline int register_sysrq_key(int key, const struct sysrq_key_op *op)
0066 {
0067     return -EINVAL;
0068 }
0069 
0070 static inline int unregister_sysrq_key(int key, const struct sysrq_key_op *op)
0071 {
0072     return -EINVAL;
0073 }
0074 
0075 static inline int sysrq_mask(void)
0076 {
0077     /* Magic SysRq disabled mask */
0078     return 0;
0079 }
0080 
0081 #endif
0082 
0083 #endif /* _LINUX_SYSRQ_H */