This source file includes following definitions.
- __printf
- kdb_walk_kallsyms
- __printf
- kdb_init
- kdb_register
- kdb_register_flags
- kdb_unregister
1 #ifndef _KDB_H
2 #define _KDB_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #define KDB_ENABLE_NO_ARGS_SHIFT 10
22
23 typedef enum {
24 KDB_ENABLE_ALL = (1 << 0),
25 KDB_ENABLE_MEM_READ = (1 << 1),
26 KDB_ENABLE_MEM_WRITE = (1 << 2),
27 KDB_ENABLE_REG_READ = (1 << 3),
28 KDB_ENABLE_REG_WRITE = (1 << 4),
29 KDB_ENABLE_INSPECT = (1 << 5),
30 KDB_ENABLE_FLOW_CTRL = (1 << 6),
31 KDB_ENABLE_SIGNAL = (1 << 7),
32 KDB_ENABLE_REBOOT = (1 << 8),
33
34
35
36
37 KDB_ENABLE_ALWAYS_SAFE = (1 << 9),
38 KDB_ENABLE_MASK = (1 << KDB_ENABLE_NO_ARGS_SHIFT) - 1,
39
40 KDB_ENABLE_ALL_NO_ARGS = KDB_ENABLE_ALL << KDB_ENABLE_NO_ARGS_SHIFT,
41 KDB_ENABLE_MEM_READ_NO_ARGS = KDB_ENABLE_MEM_READ
42 << KDB_ENABLE_NO_ARGS_SHIFT,
43 KDB_ENABLE_MEM_WRITE_NO_ARGS = KDB_ENABLE_MEM_WRITE
44 << KDB_ENABLE_NO_ARGS_SHIFT,
45 KDB_ENABLE_REG_READ_NO_ARGS = KDB_ENABLE_REG_READ
46 << KDB_ENABLE_NO_ARGS_SHIFT,
47 KDB_ENABLE_REG_WRITE_NO_ARGS = KDB_ENABLE_REG_WRITE
48 << KDB_ENABLE_NO_ARGS_SHIFT,
49 KDB_ENABLE_INSPECT_NO_ARGS = KDB_ENABLE_INSPECT
50 << KDB_ENABLE_NO_ARGS_SHIFT,
51 KDB_ENABLE_FLOW_CTRL_NO_ARGS = KDB_ENABLE_FLOW_CTRL
52 << KDB_ENABLE_NO_ARGS_SHIFT,
53 KDB_ENABLE_SIGNAL_NO_ARGS = KDB_ENABLE_SIGNAL
54 << KDB_ENABLE_NO_ARGS_SHIFT,
55 KDB_ENABLE_REBOOT_NO_ARGS = KDB_ENABLE_REBOOT
56 << KDB_ENABLE_NO_ARGS_SHIFT,
57 KDB_ENABLE_ALWAYS_SAFE_NO_ARGS = KDB_ENABLE_ALWAYS_SAFE
58 << KDB_ENABLE_NO_ARGS_SHIFT,
59 KDB_ENABLE_MASK_NO_ARGS = KDB_ENABLE_MASK << KDB_ENABLE_NO_ARGS_SHIFT,
60
61 KDB_REPEAT_NO_ARGS = 0x40000000,
62 KDB_REPEAT_WITH_ARGS = 0x80000000,
63 } kdb_cmdflags_t;
64
65 typedef int (*kdb_func_t)(int, const char **);
66
67 #ifdef CONFIG_KGDB_KDB
68 #include <linux/init.h>
69 #include <linux/sched.h>
70 #include <linux/atomic.h>
71
72 #define KDB_POLL_FUNC_MAX 5
73 extern int kdb_poll_idx;
74
75
76
77
78
79 extern int kdb_initial_cpu;
80
81
82
83 #define KDB_MAXARGS 16
84
85
86 #define KDB_NOTFOUND (-1)
87 #define KDB_ARGCOUNT (-2)
88 #define KDB_BADWIDTH (-3)
89 #define KDB_BADRADIX (-4)
90 #define KDB_NOTENV (-5)
91 #define KDB_NOENVVALUE (-6)
92 #define KDB_NOTIMP (-7)
93 #define KDB_ENVFULL (-8)
94 #define KDB_ENVBUFFULL (-9)
95 #define KDB_TOOMANYBPT (-10)
96 #define KDB_TOOMANYDBREGS (-11)
97 #define KDB_DUPBPT (-12)
98 #define KDB_BPTNOTFOUND (-13)
99 #define KDB_BADMODE (-14)
100 #define KDB_BADINT (-15)
101 #define KDB_INVADDRFMT (-16)
102 #define KDB_BADREG (-17)
103 #define KDB_BADCPUNUM (-18)
104 #define KDB_BADLENGTH (-19)
105 #define KDB_NOBP (-20)
106 #define KDB_BADADDR (-21)
107 #define KDB_NOPERM (-22)
108
109
110
111
112
113
114
115 extern const char *kdb_diemsg;
116
117 #define KDB_FLAG_EARLYKDB (1 << 0)
118 #define KDB_FLAG_CATASTROPHIC (1 << 1)
119 #define KDB_FLAG_CMD_INTERRUPT (1 << 2)
120 #define KDB_FLAG_NOIPI (1 << 3)
121 #define KDB_FLAG_NO_CONSOLE (1 << 5)
122
123 #define KDB_FLAG_NO_VT_CONSOLE (1 << 6)
124
125 #define KDB_FLAG_NO_I8042 (1 << 7)
126
127
128 extern int kdb_flags;
129
130 extern void kdb_save_flags(void);
131 extern void kdb_restore_flags(void);
132
133 #define KDB_FLAG(flag) (kdb_flags & KDB_FLAG_##flag)
134 #define KDB_FLAG_SET(flag) ((void)(kdb_flags |= KDB_FLAG_##flag))
135 #define KDB_FLAG_CLEAR(flag) ((void)(kdb_flags &= ~KDB_FLAG_##flag))
136
137
138
139
140
141
142
143 typedef enum {
144 KDB_REASON_ENTER = 1,
145 KDB_REASON_ENTER_SLAVE,
146 KDB_REASON_BREAK,
147 KDB_REASON_DEBUG,
148 KDB_REASON_OOPS,
149 KDB_REASON_SWITCH,
150 KDB_REASON_KEYBOARD,
151 KDB_REASON_NMI,
152 KDB_REASON_RECURSE,
153
154 KDB_REASON_SSTEP,
155 KDB_REASON_SYSTEM_NMI,
156 } kdb_reason_t;
157
158 enum kdb_msgsrc {
159 KDB_MSGSRC_INTERNAL,
160 KDB_MSGSRC_PRINTK,
161 };
162
163 extern int kdb_trap_printk;
164 extern int kdb_printf_cpu;
165 extern __printf(2, 0) int vkdb_printf(enum kdb_msgsrc src, const char *fmt,
166 va_list args);
167 extern __printf(1, 2) int kdb_printf(const char *, ...);
168 typedef __printf(1, 2) int (*kdb_printf_t)(const char *, ...);
169
170 extern void kdb_init(int level);
171
172
173 typedef int (*get_char_func)(void);
174 extern get_char_func kdb_poll_funcs[];
175 extern int kdb_get_kbd_char(void);
176
177 static inline
178 int kdb_process_cpu(const struct task_struct *p)
179 {
180 unsigned int cpu = task_cpu(p);
181 if (cpu > num_possible_cpus())
182 cpu = 0;
183 return cpu;
184 }
185
186
187 extern struct pt_regs *kdb_current_regs;
188 #ifdef CONFIG_KALLSYMS
189 extern const char *kdb_walk_kallsyms(loff_t *pos);
190 #else
191 static inline const char *kdb_walk_kallsyms(loff_t *pos)
192 {
193 return NULL;
194 }
195 #endif
196
197
198 extern int kdb_register(char *, kdb_func_t, char *, char *, short);
199 extern int kdb_register_flags(char *, kdb_func_t, char *, char *,
200 short, kdb_cmdflags_t);
201 extern int kdb_unregister(char *);
202 #else
203 static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; }
204 static inline void kdb_init(int level) {}
205 static inline int kdb_register(char *cmd, kdb_func_t func, char *usage,
206 char *help, short minlen) { return 0; }
207 static inline int kdb_register_flags(char *cmd, kdb_func_t func, char *usage,
208 char *help, short minlen,
209 kdb_cmdflags_t flags) { return 0; }
210 static inline int kdb_unregister(char *cmd) { return 0; }
211 #endif
212 enum {
213 KDB_NOT_INITIALIZED,
214 KDB_INIT_EARLY,
215 KDB_INIT_FULL,
216 };
217
218 extern int kdbgetintenv(const char *, int *);
219 extern int kdb_set(int, const char **);
220
221 #endif