1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef __LINUX_SYSRQ_H__
14#define __LINUX_SYSRQ_H__
15
16#include <linux/config.h>
17
18struct pt_regs;
19struct kbd_struct;
20struct tty_struct;
21
22struct sysrq_key_op {
23 void (*handler)(int, struct pt_regs *,
24 struct kbd_struct *, struct tty_struct *);
25 char *help_msg;
26 char *action_msg;
27};
28
29#ifdef CONFIG_MAGIC_SYSRQ
30
31
32
33
34
35
36void handle_sysrq(int, struct pt_regs *,
37 struct kbd_struct *, struct tty_struct *);
38
39
40
41
42
43
44
45void __handle_sysrq_nolock(int, struct pt_regs *,
46 struct kbd_struct *, struct tty_struct *);
47
48
49
50
51
52
53
54void __sysrq_lock_table (void);
55void __sysrq_unlock_table (void);
56struct sysrq_key_op *__sysrq_get_key_op (int key);
57void __sysrq_put_key_op (int key, struct sysrq_key_op *op_p);
58
59extern __inline__ int
60__sysrq_swap_key_ops_nolock(int key, struct sysrq_key_op *insert_op_p,
61 struct sysrq_key_op *remove_op_p)
62{
63 int retval;
64 if (__sysrq_get_key_op(key) == remove_op_p) {
65 __sysrq_put_key_op(key, insert_op_p);
66 retval = 0;
67 } else {
68 retval = -1;
69 }
70 return retval;
71}
72
73extern __inline__ int
74__sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
75 struct sysrq_key_op *remove_op_p) {
76 int retval;
77 __sysrq_lock_table();
78 retval = __sysrq_swap_key_ops_nolock(key, insert_op_p, remove_op_p);
79 __sysrq_unlock_table();
80 return retval;
81}
82
83static inline int register_sysrq_key(int key, struct sysrq_key_op *op_p)
84{
85 return __sysrq_swap_key_ops(key, op_p, NULL);
86}
87
88static inline int unregister_sysrq_key(int key, struct sysrq_key_op *op_p)
89{
90 return __sysrq_swap_key_ops(key, NULL, op_p);
91}
92
93#else
94
95static inline int __reterr(void)
96{
97 return -EINVAL;
98}
99
100#define register_sysrq_key(ig,nore) __reterr()
101#define unregister_sysrq_key(ig,nore) __reterr()
102
103#endif
104
105
106
107
108extern volatile int emergency_sync_scheduled;
109
110#define EMERG_SYNC 1
111#define EMERG_REMOUNT 2
112
113void do_emergency_sync(void);
114
115#ifdef CONFIG_MAGIC_SYSRQ
116#define CHECK_EMERGENCY_SYNC \
117 if (emergency_sync_scheduled) \
118 do_emergency_sync();
119#else
120#define CHECK_EMERGENCY_SYNC
121#endif
122
123#endif
124