1 #ifndef _ASM_KDBPRIVATE_H
2 #define _ASM_KDBPRIVATE_H
5 * Kernel Debugger Architecture Dependent Private 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
11 * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
14 /* Definition of an machine instruction.
15 * Takes care of VLIW processors like Itanium
19 unsigned long inst[2];
23 * KDB_MAXBPT describes the total number of breakpoints
24 * supported by this architecure.
29 * KDB_MAXHARDBPT describes the total number of hardware
30 * breakpoint registers that exist.
32 #define KDB_MAXHARDBPT 4
35 * Platform specific environment entries
37 #define KDB_PLATFORM_ENV "IDMODE=ia64", "BYTESPERWORD=4", "IDCOUNT=8"
40 * Define the direction that the stack grows
42 #define KDB_STACK_DIRECTION (-1) /* Stack grows down */
45 * Support for IA64 debug registers
47 typedef struct _kdbhard_bp {
48 kdb_machreg_t bph_reg; /* Register this breakpoint uses */
50 unsigned int bph_free:1; /* Register available for use */
51 unsigned int bph_data:1; /* Data Access breakpoint */
53 unsigned int bph_write:1; /* Write Data breakpoint */
54 unsigned int bph_mode:2; /* 0=inst, 1=write, 2=io, 3=read */
55 unsigned int bph_length:2; /* 0=1, 1=2, 2=BAD, 3=4 (bytes) */
58 #define getprsregs(regs) ((struct switch_stack *)regs -1)
60 /* bkpt support using break inst instead of IBP reg */
63 * Define certain specific instructions
65 #define BREAK_INSTR (long)(KDB_BREAK_BREAK << (5+6))
66 #define INST_SLOT0_MASK (0x1ffffffffffL << 5)
68 #define BKPTMODE_DATAR 3
70 #define BKPTMODE_DATAW 1
71 #define BKPTMODE_INST 0
73 /* Some of the fault registers needed by kdb but not passed with
74 * regs or switch stack.
76 typedef struct fault_regs {
83 #define KDB_HAVE_LONGJMP
84 #ifdef KDB_HAVE_LONGJMP
86 * Support for setjmp/longjmp
89 /* __jmp_buf definition copied from libc/sysdeps/unix/sysv/linux/ia64/bits/setjmp.h */
93 typedef struct __kdb_jmp_buf {
94 unsigned long __jmp_buf[_JBLEN];
95 } kdb_jmp_buf __attribute__ ((aligned (16)));
97 extern int kdba_setjmp(kdb_jmp_buf *);
98 extern int kdba_setjmp_asm(kdb_jmp_buf *);
99 extern void kdba_longjmp(kdb_jmp_buf *, int);
100 extern void kdba_longjmp_asm(kdb_jmp_buf *, int);
102 extern kdb_jmp_buf *kdbjmpbuf;
103 #endif /* KDB_HAVE_LONGJMP */
105 /* Arch specific data saved for running processes */
107 struct kdba_running_process {
108 struct switch_stack *sw;
112 void kdba_save_running(struct kdba_running_process *k, struct pt_regs *regs)
114 /* ia64 data is saved by unw_init_running() via kdba_main_loop() for
115 * normal kdb entry and kdba_interrupt_switch_stack() for wierd
116 * interrupt handlers.
121 void kdba_unsave_running(struct kdba_running_process *k, struct pt_regs *regs)
125 /* kdba wrappers which want to save switch stack will call unw_init_running().
126 * That routine only takes a void* so pack the interrupt data into a structure.
129 #include <linux/interrupt.h> /* for irqreturn_t */
131 struct kdba_sw_interrupt_data {
132 irqreturn_t (*handler)(int, void *, struct pt_regs *);
135 struct pt_regs *regs;
139 extern void kdba_sw_interrupt(struct unw_frame_info *, void *);
141 /* Generate a wrapper function to create a switch_stack before
142 * entering an interrupt handler.
145 #define KDBA_SW_INTERRUPT_WRAPPER3(name,before,after) \
146 irqreturn_t real_##name(int, void *, struct pt_regs *); \
147 irqreturn_t name(int irq, void *arg, struct pt_regs *regs) \
149 struct kdba_sw_interrupt_data id = { \
150 .handler = &real_##name, \
157 unw_init_running(kdba_sw_interrupt, &id); \
162 #define KDBA_SW_INTERRUPT_WRAPPER(name) \
163 KDBA_SW_INTERRUPT_WRAPPER3(name,,)
165 /* The kdba handlers that sit between wrapper -> unw_init_running -> real
166 * function are almost identical. They differ in the function name, the
167 * type of data passed as void* to unw_init_running, the value to print
168 * in the debug statement and the invocation of the real function.
170 * data_type must be a structure that contains 'struct pt_regs *regs;'.
173 #define KDBA_UNWIND_HANDLER(name, data_type, debug_value, invoke...) \
174 void name(struct unw_frame_info *info, void *vdata) \
176 data_type *data = vdata; \
177 struct switch_stack *sw, *prev_sw; \
178 struct pt_regs *prev_regs; \
179 struct kdb_running_process *krp = \
180 kdb_running_process + smp_processor_id(); \
181 KDB_DEBUG_STATE(__FUNCTION__, debug_value); \
182 prev_sw = krp->arch.sw; \
183 sw = (struct switch_stack *)(info+1); \
184 /* padding from unw_init_running */ \
185 sw = (struct switch_stack *)(((unsigned long)sw + 15) & ~15); \
187 prev_regs = krp->regs; \
188 kdb_save_running(data->regs); \
190 kdb_unsave_running(data->regs); \
191 krp->regs = prev_regs; \
192 krp->arch.sw = prev_sw; \
195 enum kdba_serial_console {
201 extern enum kdba_serial_console kdba_serial_console;
203 #endif /* !_ASM_KDBPRIVATE_H */