1#ifndef _KDB_H
2#define _KDB_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16typedef enum {
17 KDB_REPEAT_NONE = 0,
18 KDB_REPEAT_NO_ARGS,
19 KDB_REPEAT_WITH_ARGS,
20} kdb_repeat_t;
21
22typedef int (*kdb_func_t)(int, const char **);
23
24#ifdef CONFIG_KGDB_KDB
25#include <linux/init.h>
26#include <linux/sched.h>
27#include <linux/atomic.h>
28
29#define KDB_POLL_FUNC_MAX 5
30extern int kdb_poll_idx;
31
32
33
34
35
36extern int kdb_initial_cpu;
37extern atomic_t kdb_event;
38
39
40
41#define KDB_MAXARGS 16
42
43
44#define KDB_NOTFOUND (-1)
45#define KDB_ARGCOUNT (-2)
46#define KDB_BADWIDTH (-3)
47#define KDB_BADRADIX (-4)
48#define KDB_NOTENV (-5)
49#define KDB_NOENVVALUE (-6)
50#define KDB_NOTIMP (-7)
51#define KDB_ENVFULL (-8)
52#define KDB_ENVBUFFULL (-9)
53#define KDB_TOOMANYBPT (-10)
54#define KDB_TOOMANYDBREGS (-11)
55#define KDB_DUPBPT (-12)
56#define KDB_BPTNOTFOUND (-13)
57#define KDB_BADMODE (-14)
58#define KDB_BADINT (-15)
59#define KDB_INVADDRFMT (-16)
60#define KDB_BADREG (-17)
61#define KDB_BADCPUNUM (-18)
62#define KDB_BADLENGTH (-19)
63#define KDB_NOBP (-20)
64#define KDB_BADADDR (-21)
65
66
67
68
69
70
71
72extern const char *kdb_diemsg;
73
74#define KDB_FLAG_EARLYKDB (1 << 0)
75#define KDB_FLAG_CATASTROPHIC (1 << 1)
76#define KDB_FLAG_CMD_INTERRUPT (1 << 2)
77#define KDB_FLAG_NOIPI (1 << 3)
78#define KDB_FLAG_NO_CONSOLE (1 << 5)
79
80#define KDB_FLAG_NO_VT_CONSOLE (1 << 6)
81
82#define KDB_FLAG_NO_I8042 (1 << 7)
83
84
85extern int kdb_flags;
86
87extern void kdb_save_flags(void);
88extern void kdb_restore_flags(void);
89
90#define KDB_FLAG(flag) (kdb_flags & KDB_FLAG_##flag)
91#define KDB_FLAG_SET(flag) ((void)(kdb_flags |= KDB_FLAG_##flag))
92#define KDB_FLAG_CLEAR(flag) ((void)(kdb_flags &= ~KDB_FLAG_##flag))
93
94
95
96
97
98
99
100typedef enum {
101 KDB_REASON_ENTER = 1,
102 KDB_REASON_ENTER_SLAVE,
103 KDB_REASON_BREAK,
104 KDB_REASON_DEBUG,
105 KDB_REASON_OOPS,
106 KDB_REASON_SWITCH,
107 KDB_REASON_KEYBOARD,
108 KDB_REASON_NMI,
109 KDB_REASON_RECURSE,
110
111 KDB_REASON_SSTEP,
112} kdb_reason_t;
113
114extern int kdb_trap_printk;
115extern __printf(1, 0) int vkdb_printf(const char *fmt, va_list args);
116extern __printf(1, 2) int kdb_printf(const char *, ...);
117typedef __printf(1, 2) int (*kdb_printf_t)(const char *, ...);
118
119extern void kdb_init(int level);
120
121
122typedef int (*get_char_func)(void);
123extern get_char_func kdb_poll_funcs[];
124extern int kdb_get_kbd_char(void);
125
126static inline
127int kdb_process_cpu(const struct task_struct *p)
128{
129 unsigned int cpu = task_thread_info(p)->cpu;
130 if (cpu > num_possible_cpus())
131 cpu = 0;
132 return cpu;
133}
134
135
136extern struct pt_regs *kdb_current_regs;
137#ifdef CONFIG_KALLSYMS
138extern const char *kdb_walk_kallsyms(loff_t *pos);
139#else
140static inline const char *kdb_walk_kallsyms(loff_t *pos)
141{
142 return NULL;
143}
144#endif
145
146
147extern int kdb_register(char *, kdb_func_t, char *, char *, short);
148extern int kdb_register_repeat(char *, kdb_func_t, char *, char *,
149 short, kdb_repeat_t);
150extern int kdb_unregister(char *);
151#else
152static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; }
153static inline void kdb_init(int level) {}
154static inline int kdb_register(char *cmd, kdb_func_t func, char *usage,
155 char *help, short minlen) { return 0; }
156static inline int kdb_register_repeat(char *cmd, kdb_func_t func, char *usage,
157 char *help, short minlen,
158 kdb_repeat_t repeat) { return 0; }
159static inline int kdb_unregister(char *cmd) { return 0; }
160#endif
161enum {
162 KDB_NOT_INITIALIZED,
163 KDB_INIT_EARLY,
164 KDB_INIT_FULL,
165};
166
167extern int kdbgetintenv(const char *, int *);
168extern int kdb_set(int, const char **);
169
170#endif
171