Drop obsoleted patch.
[linux-flexiantxendom0-3.2.10.git] / include / asm-ia64 / kdbprivate.h
1 #ifndef _ASM_KDBPRIVATE_H
2 #define _ASM_KDBPRIVATE_H
3
4 /*
5  * Kernel Debugger Architecture Dependent Private Headers
6  *
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.
10  *
11  * Copyright (c) 1999-2004 Silicon Graphics, Inc.  All Rights Reserved.
12  */
13
14 /* Definition of an machine instruction.
15  * Takes care of VLIW processors like Itanium
16  */
17
18 typedef struct {
19         unsigned long inst[2];
20 } kdb_machinst_t;
21
22 /*
23  * KDB_MAXBPT describes the total number of breakpoints
24  * supported by this architecure.
25  */
26 #define KDB_MAXBPT      16
27
28 /*
29  * KDB_MAXHARDBPT describes the total number of hardware
30  * breakpoint registers that exist.
31  */
32 #define KDB_MAXHARDBPT   4
33
34 /*
35  * Platform specific environment entries
36  */
37 #define KDB_PLATFORM_ENV        "IDMODE=ia64", "BYTESPERWORD=4", "IDCOUNT=8"
38
39 /*
40  * Define the direction that the stack grows
41  */
42 #define KDB_STACK_DIRECTION     (-1)    /* Stack grows down */
43
44 /*
45  * Support for IA64 debug registers
46  */
47 typedef struct _kdbhard_bp {
48         kdb_machreg_t   bph_reg;        /* Register this breakpoint uses */
49
50         unsigned int    bph_free:1;     /* Register available for use */
51         unsigned int    bph_data:1;     /* Data Access breakpoint */
52
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) */
56 } kdbhard_bp_t;
57
58 #define getprsregs(regs)        ((struct switch_stack *)regs -1)
59
60 /* bkpt support using break inst instead of IBP reg */
61
62 /*
63  * Define certain specific instructions
64  */
65 #define BREAK_INSTR             (long)(KDB_BREAK_BREAK << (5+6))
66 #define INST_SLOT0_MASK         (0x1ffffffffffL << 5)
67
68 #define BKPTMODE_DATAR  3
69 #define BKPTMODE_IO     2
70 #define BKPTMODE_DATAW  1
71 #define BKPTMODE_INST   0
72
73 /* Some of the fault registers needed by kdb but not passed with
74  * regs or switch stack.
75  */
76 typedef struct fault_regs {
77         unsigned long   isr ;
78         unsigned long   ifa ;
79         unsigned long   iim ;
80         unsigned long   itir ;
81 } fault_regs_t ;
82
83 #define KDB_HAVE_LONGJMP
84 #ifdef KDB_HAVE_LONGJMP
85 /*
86  * Support for setjmp/longjmp
87  */
88
89 /* __jmp_buf definition copied from libc/sysdeps/unix/sysv/linux/ia64/bits/setjmp.h */
90
91 #define _JBLEN  70
92
93 typedef struct __kdb_jmp_buf {
94         unsigned long   __jmp_buf[_JBLEN];
95 } kdb_jmp_buf __attribute__ ((aligned (16)));
96
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);
101
102 extern kdb_jmp_buf *kdbjmpbuf;
103 #endif  /* KDB_HAVE_LONGJMP */
104
105 /* Arch specific data saved for running processes */
106
107 struct kdba_running_process {
108         struct switch_stack *sw;
109 };
110
111 static inline
112 void kdba_save_running(struct kdba_running_process *k, struct pt_regs *regs)
113 {
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.
117          */
118 }
119
120 static inline
121 void kdba_unsave_running(struct kdba_running_process *k, struct pt_regs *regs)
122 {
123 }
124
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.
127  */
128
129 #include <linux/interrupt.h>    /* for irqreturn_t */
130
131 struct kdba_sw_interrupt_data {
132         irqreturn_t (*handler)(int, void *, struct pt_regs *);
133         int irq;
134         void *arg;
135         struct pt_regs *regs;
136         irqreturn_t ret;
137 };
138
139 extern void kdba_sw_interrupt(struct unw_frame_info *, void *);
140
141 /* Generate a wrapper function to create a switch_stack before
142  * entering an interrupt handler.
143  */
144
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)      \
148 {                                                               \
149         struct kdba_sw_interrupt_data id = {                    \
150                 .handler = &real_##name,                        \
151                 .irq = irq,                                     \
152                 .arg = arg,                                     \
153                 .regs = regs,                                   \
154                 .ret = 0,                                       \
155         };                                                      \
156         before;                                                 \
157         unw_init_running(kdba_sw_interrupt, &id);               \
158         after;                                                  \
159         return id.ret;                                          \
160 }
161
162 #define KDBA_SW_INTERRUPT_WRAPPER(name)                         \
163         KDBA_SW_INTERRUPT_WRAPPER3(name,,)
164
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.
169  *
170  * data_type must be a structure that contains 'struct pt_regs *regs;'.
171  */
172
173 #define KDBA_UNWIND_HANDLER(name, data_type, debug_value, invoke...)    \
174 void name(struct unw_frame_info *info, void *vdata)                     \
175 {                                                                       \
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);   \
186         krp->arch.sw = sw;                                              \
187         prev_regs = krp->regs;                                          \
188         kdb_save_running(data->regs);                                   \
189         invoke;                                                         \
190         kdb_unsave_running(data->regs);                                 \
191         krp->regs = prev_regs;                                          \
192         krp->arch.sw = prev_sw;                                         \
193 }
194
195 enum kdba_serial_console {
196         KDBA_SC_NONE = 0,
197         KDBA_SC_STANDARD,
198         KDBA_SC_SGI_L1,
199 };
200
201 extern enum kdba_serial_console kdba_serial_console;
202
203 #endif  /* !_ASM_KDBPRIVATE_H */