File: sysrq.h

package info (click to toggle)
kernel-source-2.4.10 2.4.10-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 137,328 kB
  • ctags: 423,898
  • sloc: ansic: 2,403,930; asm: 140,471; makefile: 8,170; sh: 3,099; perl: 2,077; yacc: 1,177; cpp: 755; tcl: 577; lex: 343; awk: 251; lisp: 218; sed: 72
file content (109 lines) | stat: -rw-r--r-- 2,590 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* -*- 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 <mj@atrey.karlin.mff.cuni.cz>
 *
 *	(c) 2000 Crutcher Dunnavant <crutcher+kernel@datastacks.com>
 *	overhauled to use key registration
 *	based upon discusions in irc://irc.openprojects.net/#kernelnewbies
 */

#include <linux/config.h>

struct pt_regs;
struct kbd_struct;
struct tty_struct;

struct sysrq_key_op {
	void (*handler)(int, struct pt_regs *,
			struct kbd_struct *, struct tty_struct *);
	char *help_msg;
	char *action_msg;
};

/* 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(int, struct pt_regs *,
		struct kbd_struct *, struct tty_struct *);


/* 
 * Nonlocking version of handle sysrq, used by sysrq handlers that need to
 * call sysrq handlers
 */

void __handle_sysrq_nolock(int, struct pt_regs *,
                struct kbd_struct *, struct tty_struct *);


#ifdef CONFIG_MAGIC_SYSRQ

/*
 * Sysrq registration manipulation functions
 */

void __sysrq_lock_table (void);
void __sysrq_unlock_table (void);
struct sysrq_key_op *__sysrq_get_key_op (int key);
void __sysrq_put_key_op (int key, struct sysrq_key_op *op_p);

extern __inline__ int
__sysrq_swap_key_ops_nolock(int key, struct sysrq_key_op *insert_op_p,
				struct sysrq_key_op *remove_op_p) {
	int retval;
	if (__sysrq_get_key_op(key) == remove_op_p) {
		__sysrq_put_key_op(key, insert_op_p);
		retval = 0;
	} else {
                retval = -1;
	}
	return retval;
}

extern __inline__ int
__sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
				struct sysrq_key_op *remove_op_p) {
	int retval;
	__sysrq_lock_table();
	retval = __sysrq_swap_key_ops_nolock(key, insert_op_p, remove_op_p);
	__sysrq_unlock_table();
	return retval;
}
	
static inline int register_sysrq_key(int key, struct sysrq_key_op *op_p)
{
	return __sysrq_swap_key_ops(key, op_p, NULL);
}

static inline int unregister_sysrq_key(int key, struct sysrq_key_op *op_p)
{
	return __sysrq_swap_key_ops(key, NULL, op_p);
}

#else
#define register_sysrq_key(a,b)		do {} while(0)
#define unregister_sysrq_key(a,b)	do {} while(0)
#endif

/* Deferred actions */

extern int emergency_sync_scheduled;

#define EMERG_SYNC 1
#define EMERG_REMOUNT 2

void do_emergency_sync(void);

#ifdef CONFIG_MAGIC_SYSRQ
#define CHECK_EMERGENCY_SYNC			\
	if (emergency_sync_scheduled)		\
		do_emergency_sync();
#else
#define CHECK_EMERGENCY_SYNC
#endif