- Update to 2.6.25-rc3.
[linux-flexiantxendom0-3.2.10.git] / include / asm-x86 / kdbprivate_32.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-2006 Silicon Graphics, Inc.  All Rights Reserved.
12  */
13
14 typedef unsigned char kdb_machinst_t;
15
16 /*
17  * KDB_MAXBPT describes the total number of breakpoints
18  * supported by this architecure.
19  */
20 #define KDB_MAXBPT      16
21
22 /*
23  * KDB_MAXHARDBPT describes the total number of hardware
24  * breakpoint registers that exist.
25  */
26 #define KDB_MAXHARDBPT   4
27
28 /* Maximum number of arguments to a function  */
29 #define KDBA_MAXARGS    16
30
31 /*
32  * Platform specific environment entries
33  */
34 #define KDB_PLATFORM_ENV        "IDMODE=x86", "BYTESPERWORD=4", "IDCOUNT=16"
35
36 /*
37  * Support for ia32 debug registers
38  */
39 typedef struct _kdbhard_bp {
40         kdb_machreg_t   bph_reg;        /* Register this breakpoint uses */
41
42         unsigned int    bph_free:1;     /* Register available for use */
43         unsigned int    bph_data:1;     /* Data Access breakpoint */
44
45         unsigned int    bph_write:1;    /* Write Data breakpoint */
46         unsigned int    bph_mode:2;     /* 0=inst, 1=write, 2=io, 3=read */
47         unsigned int    bph_length:2;   /* 0=1, 1=2, 2=BAD, 3=4 (bytes) */
48 } kdbhard_bp_t;
49
50 #define IA32_BREAKPOINT_INSTRUCTION     0xcc
51
52 #define DR6_BT  0x00008000
53 #define DR6_BS  0x00004000
54 #define DR6_BD  0x00002000
55
56 #define DR6_B3  0x00000008
57 #define DR6_B2  0x00000004
58 #define DR6_B1  0x00000002
59 #define DR6_B0  0x00000001
60 #define DR6_DR_MASK  0x0000000F
61
62 #define DR7_RW_VAL(dr, drnum) \
63        (((dr) >> (16 + (4 * (drnum)))) & 0x3)
64
65 #define DR7_RW_SET(dr, drnum, rw)                              \
66        do {                                                    \
67                (dr) &= ~(0x3 << (16 + (4 * (drnum))));         \
68                (dr) |= (((rw) & 0x3) << (16 + (4 * (drnum)))); \
69        } while (0)
70
71 #define DR7_RW0(dr)             DR7_RW_VAL(dr, 0)
72 #define DR7_RW0SET(dr,rw)       DR7_RW_SET(dr, 0, rw)
73 #define DR7_RW1(dr)             DR7_RW_VAL(dr, 1)
74 #define DR7_RW1SET(dr,rw)       DR7_RW_SET(dr, 1, rw)
75 #define DR7_RW2(dr)             DR7_RW_VAL(dr, 2)
76 #define DR7_RW2SET(dr,rw)       DR7_RW_SET(dr, 2, rw)
77 #define DR7_RW3(dr)             DR7_RW_VAL(dr, 3)
78 #define DR7_RW3SET(dr,rw)       DR7_RW_SET(dr, 3, rw)
79
80
81 #define DR7_LEN_VAL(dr, drnum) \
82        (((dr) >> (18 + (4 * (drnum)))) & 0x3)
83
84 #define DR7_LEN_SET(dr, drnum, rw)                             \
85        do {                                                    \
86                (dr) &= ~(0x3 << (18 + (4 * (drnum))));         \
87                (dr) |= (((rw) & 0x3) << (18 + (4 * (drnum)))); \
88        } while (0)
89
90 #define DR7_LEN0(dr)            DR7_LEN_VAL(dr, 0)
91 #define DR7_LEN0SET(dr,len)     DR7_LEN_SET(dr, 0, len)
92 #define DR7_LEN1(dr)            DR7_LEN_VAL(dr, 1)
93 #define DR7_LEN1SET(dr,len)     DR7_LEN_SET(dr, 1, len)
94 #define DR7_LEN2(dr)            DR7_LEN_VAL(dr, 2)
95 #define DR7_LEN2SET(dr,len)     DR7_LEN_SET(dr, 2, len)
96 #define DR7_LEN3(dr)            DR7_LEN_VAL(dr, 3)
97 #define DR7_LEN3SET(dr,len)     DR7_LEN_SET(dr, 3, len)
98
99 #define DR7_G0(dr)    (((dr)>>1)&0x1)
100 #define DR7_G0SET(dr) ((dr) |= 0x2)
101 #define DR7_G0CLR(dr) ((dr) &= ~0x2)
102 #define DR7_G1(dr)    (((dr)>>3)&0x1)
103 #define DR7_G1SET(dr) ((dr) |= 0x8)
104 #define DR7_G1CLR(dr) ((dr) &= ~0x8)
105 #define DR7_G2(dr)    (((dr)>>5)&0x1)
106 #define DR7_G2SET(dr) ((dr) |= 0x20)
107 #define DR7_G2CLR(dr) ((dr) &= ~0x20)
108 #define DR7_G3(dr)    (((dr)>>7)&0x1)
109 #define DR7_G3SET(dr) ((dr) |= 0x80)
110 #define DR7_G3CLR(dr) ((dr) &= ~0x80)
111
112 #define DR7_L0(dr)    (((dr))&0x1)
113 #define DR7_L0SET(dr) ((dr) |= 0x1)
114 #define DR7_L0CLR(dr) ((dr) &= ~0x1)
115 #define DR7_L1(dr)    (((dr)>>2)&0x1)
116 #define DR7_L1SET(dr) ((dr) |= 0x4)
117 #define DR7_L1CLR(dr) ((dr) &= ~0x4)
118 #define DR7_L2(dr)    (((dr)>>4)&0x1)
119 #define DR7_L2SET(dr) ((dr) |= 0x10)
120 #define DR7_L2CLR(dr) ((dr) &= ~0x10)
121 #define DR7_L3(dr)    (((dr)>>6)&0x1)
122 #define DR7_L3SET(dr) ((dr) |= 0x40)
123 #define DR7_L3CLR(dr) ((dr) &= ~0x40)
124
125 #define DR7_GD          0x00002000              /* General Detect Enable */
126 #define DR7_GE          0x00000200              /* Global exact */
127 #define DR7_LE          0x00000100              /* Local exact */
128
129 #define DR_TYPE_EXECUTE 0x0
130 #define DR_TYPE_WRITE   0x1
131 #define DR_TYPE_IO      0x2
132 #define DR_TYPE_RW      0x3
133
134 extern kdb_machreg_t kdba_getdr6(void);
135 extern void kdba_putdr6(kdb_machreg_t);
136
137 extern kdb_machreg_t kdba_getdr7(void);
138
139 /*
140  * Support for setjmp/longjmp
141  */
142 #define JB_BX   0
143 #define JB_SI   1
144 #define JB_DI   2
145 #define JB_BP   3
146 #define JB_SP   4
147 #define JB_PC   5
148
149 typedef struct __kdb_jmp_buf {
150         unsigned long   regs[6];        /* kdba_setjmp assumes fixed offsets here */
151 } kdb_jmp_buf;
152
153 extern int asmlinkage kdba_setjmp(kdb_jmp_buf *);
154 extern void asmlinkage kdba_longjmp(kdb_jmp_buf *, int);
155 #define kdba_setjmp kdba_setjmp
156
157 extern kdb_jmp_buf  *kdbjmpbuf;
158
159 /* Arch specific data saved for running processes */
160
161 struct kdba_running_process {
162         long esp;       /* CONFIG_4KSTACKS may be on a different stack */
163         long eip;       /* eip when esp was set */
164 };
165
166 static inline
167 void kdba_save_running(struct kdba_running_process *k, struct pt_regs *regs)
168 {
169         k->esp = current_stack_pointer;
170         __asm__ __volatile__ ( " lea 1f,%%eax; movl %%eax,%0 ; 1: " : "=r"(k->eip) : : "eax" );
171 }
172
173 static inline
174 void kdba_unsave_running(struct kdba_running_process *k, struct pt_regs *regs)
175 {
176 }
177
178 struct kdb_activation_record;
179 extern void kdba_get_stack_info_alternate(kdb_machreg_t addr, int cpu,
180                                           struct kdb_activation_record *ar);
181
182 extern void kdba_wait_for_cpus(void);
183
184 extern void kdb_interrupt(void);
185
186 #define KDB_INT_REGISTERS       8
187
188
189 #endif  /* !_ASM_KDBPRIVATE_H */