MIPS: Lantiq: Fix external interrupt sources
[linux-2.6/linux-mips.git] / include / linux / kdb.h
blob529d9a0c75a5bb26249f2d766800e58a1b1440da
1 #ifndef _KDB_H
2 #define _KDB_H
4 /*
5 * Kernel Debugger Architecture Independent Global Headers
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
11 * Copyright (c) 2000-2007 Silicon Graphics, Inc. All Rights Reserved.
12 * Copyright (C) 2000 Stephane Eranian <eranian@hpl.hp.com>
13 * Copyright (C) 2009 Jason Wessel <jason.wessel@windriver.com>
16 #ifdef CONFIG_KGDB_KDB
17 #include <linux/init.h>
18 #include <linux/sched.h>
19 #include <linux/atomic.h>
21 #define KDB_POLL_FUNC_MAX 5
22 extern int kdb_poll_idx;
25 * kdb_initial_cpu is initialized to -1, and is set to the cpu
26 * number whenever the kernel debugger is entered.
28 extern int kdb_initial_cpu;
29 extern atomic_t kdb_event;
31 /* Types and messages used for dynamically added kdb shell commands */
33 #define KDB_MAXARGS 16 /* Maximum number of arguments to a function */
35 typedef enum {
36 KDB_REPEAT_NONE = 0, /* Do not repeat this command */
37 KDB_REPEAT_NO_ARGS, /* Repeat the command without arguments */
38 KDB_REPEAT_WITH_ARGS, /* Repeat the command including its arguments */
39 } kdb_repeat_t;
41 typedef int (*kdb_func_t)(int, const char **);
43 /* KDB return codes from a command or internal kdb function */
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)
67 * kdb_diemsg
69 * Contains a pointer to the last string supplied to the
70 * kernel 'die' panic function.
72 extern const char *kdb_diemsg;
74 #define KDB_FLAG_EARLYKDB (1 << 0) /* set from boot parameter kdb=early */
75 #define KDB_FLAG_CATASTROPHIC (1 << 1) /* A catastrophic event has occurred */
76 #define KDB_FLAG_CMD_INTERRUPT (1 << 2) /* Previous command was interrupted */
77 #define KDB_FLAG_NOIPI (1 << 3) /* Do not send IPIs */
78 #define KDB_FLAG_ONLY_DO_DUMP (1 << 4) /* Only do a dump, used when
79 * kdb is off */
80 #define KDB_FLAG_NO_CONSOLE (1 << 5) /* No console is available,
81 * kdb is disabled */
82 #define KDB_FLAG_NO_VT_CONSOLE (1 << 6) /* No VT console is available, do
83 * not use keyboard */
84 #define KDB_FLAG_NO_I8042 (1 << 7) /* No i8042 chip is available, do
85 * not use keyboard */
87 extern int kdb_flags; /* Global flags, see kdb_state for per cpu state */
89 extern void kdb_save_flags(void);
90 extern void kdb_restore_flags(void);
92 #define KDB_FLAG(flag) (kdb_flags & KDB_FLAG_##flag)
93 #define KDB_FLAG_SET(flag) ((void)(kdb_flags |= KDB_FLAG_##flag))
94 #define KDB_FLAG_CLEAR(flag) ((void)(kdb_flags &= ~KDB_FLAG_##flag))
97 * External entry point for the kernel debugger. The pt_regs
98 * at the time of entry are supplied along with the reason for
99 * entry to the kernel debugger.
102 typedef enum {
103 KDB_REASON_ENTER = 1, /* KDB_ENTER() trap/fault - regs valid */
104 KDB_REASON_ENTER_SLAVE, /* KDB_ENTER_SLAVE() trap/fault - regs valid */
105 KDB_REASON_BREAK, /* Breakpoint inst. - regs valid */
106 KDB_REASON_DEBUG, /* Debug Fault - regs valid */
107 KDB_REASON_OOPS, /* Kernel Oops - regs valid */
108 KDB_REASON_SWITCH, /* CPU switch - regs valid*/
109 KDB_REASON_KEYBOARD, /* Keyboard entry - regs valid */
110 KDB_REASON_NMI, /* Non-maskable interrupt; regs valid */
111 KDB_REASON_RECURSE, /* Recursive entry to kdb;
112 * regs probably valid */
113 KDB_REASON_SSTEP, /* Single Step trap. - regs valid */
114 } kdb_reason_t;
116 extern int kdb_trap_printk;
117 extern int vkdb_printf(const char *fmt, va_list args)
118 __attribute__ ((format (printf, 1, 0)));
119 extern int kdb_printf(const char *, ...)
120 __attribute__ ((format (printf, 1, 2)));
121 typedef int (*kdb_printf_t)(const char *, ...)
122 __attribute__ ((format (printf, 1, 2)));
124 extern void kdb_init(int level);
126 /* Access to kdb specific polling devices */
127 typedef int (*get_char_func)(void);
128 extern get_char_func kdb_poll_funcs[];
129 extern int kdb_get_kbd_char(void);
131 static inline
132 int kdb_process_cpu(const struct task_struct *p)
134 unsigned int cpu = task_thread_info(p)->cpu;
135 if (cpu > num_possible_cpus())
136 cpu = 0;
137 return cpu;
140 /* kdb access to register set for stack dumping */
141 extern struct pt_regs *kdb_current_regs;
142 #ifdef CONFIG_KALLSYMS
143 extern const char *kdb_walk_kallsyms(loff_t *pos);
144 #else /* ! CONFIG_KALLSYMS */
145 static inline const char *kdb_walk_kallsyms(loff_t *pos)
147 return NULL;
149 #endif /* ! CONFIG_KALLSYMS */
151 /* Dynamic kdb shell command registration */
152 extern int kdb_register(char *, kdb_func_t, char *, char *, short);
153 extern int kdb_register_repeat(char *, kdb_func_t, char *, char *,
154 short, kdb_repeat_t);
155 extern int kdb_unregister(char *);
156 #else /* ! CONFIG_KGDB_KDB */
157 #define kdb_printf(...)
158 #define kdb_init(x)
159 #define kdb_register(...)
160 #define kdb_register_repeat(...)
161 #define kdb_uregister(x)
162 #endif /* CONFIG_KGDB_KDB */
163 enum {
164 KDB_NOT_INITIALIZED,
165 KDB_INIT_EARLY,
166 KDB_INIT_FULL,
169 extern int kdbgetintenv(const char *, int *);
170 extern int kdb_set(int, const char **);
172 #endif /* !_KDB_H */