blob: 8c71874e84852b5cefb9b9bf0a06a877457eaf86 [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/* -*- 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
Thomas Petazzoni89bbc032006-09-30 23:27:54 -070015#ifndef _LINUX_SYSRQ_H
16#define _LINUX_SYSRQ_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Tobias Doerffel82e33102009-07-05 12:08:23 -070018#include <linux/errno.h>
Dmitry Torokhovf3353972010-08-17 21:15:47 -070019#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
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
32struct sysrq_key_op {
Dmitry Torokhov1495cc92010-08-17 21:15:46 -070033 void (*handler)(int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 char *help_msg;
35 char *action_msg;
36 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
Dmitry Torokhovf3353972010-08-17 21:15:47 -070046void handle_sysrq(int key);
47void __handle_sysrq(int key, bool check_mask);
Ingo Molnar5d6f6472006-12-13 00:34:36 -080048int register_sysrq_key(int key, struct sysrq_key_op *op);
49int unregister_sysrq_key(int key, struct sysrq_key_op *op);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050struct sysrq_key_op *__sysrq_get_key_op(int key);
51
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -070052int sysrq_toggle_support(int enable_mask);
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#else
55
Dmitry Torokhovf3353972010-08-17 21:15:47 -070056static inline void handle_sysrq(int key)
Ingo Molnar5d6f6472006-12-13 00:34:36 -080057{
58}
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Dmitry Torokhovf3353972010-08-17 21:15:47 -070060static inline void __handle_sysrq(int key, bool check_mask)
Dmitry Torokhov1495cc92010-08-17 21:15:46 -070061{
62}
63
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -070064static inline int register_sysrq_key(int key, struct sysrq_key_op *op)
65{
66 return -EINVAL;
67}
68
69static inline int unregister_sysrq_key(int key, struct sysrq_key_op *op)
70{
71 return -EINVAL;
72}
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74#endif
Thomas Petazzoni89bbc032006-09-30 23:27:54 -070075
76#endif /* _LINUX_SYSRQ_H */