- Update to 2.6.25-rc3.
[linux-flexiantxendom0-3.2.10.git] / include / asm-x86 / kdbprivate_64.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_64", "BYTESPERWORD=8", "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 #define DR7_LEN0(dr)        DR7_LEN_VAL(dr, 0)
90 #define DR7_LEN0SET(dr,len)  DR7_LEN_SET(dr, 0, len)
91 #define DR7_LEN1(dr)        DR7_LEN_VAL(dr, 1)
92 #define DR7_LEN1SET(dr,len)  DR7_LEN_SET(dr, 1, len)
93 #define DR7_LEN2(dr)        DR7_LEN_VAL(dr, 2)
94 #define DR7_LEN2SET(dr,len)  DR7_LEN_SET(dr, 2, len)
95 #define DR7_LEN3(dr)        DR7_LEN_VAL(dr, 3)
96 #define DR7_LEN3SET(dr,len)  DR7_LEN_SET(dr, 3, len)
97
98 #define DR7_G0(dr)    (((dr)>>1)&0x1)
99 #define DR7_G0SET(dr) ((dr) |= 0x2)
100 #define DR7_G0CLR(dr) ((dr) &= ~0x2)
101 #define DR7_G1(dr)    (((dr)>>3)&0x1)
102 #define DR7_G1SET(dr) ((dr) |= 0x8)
103 #define DR7_G1CLR(dr) ((dr) &= ~0x8)
104 #define DR7_G2(dr)    (((dr)>>5)&0x1)
105 #define DR7_G2SET(dr) ((dr) |= 0x20)
106 #define DR7_G2CLR(dr) ((dr) &= ~0x20)
107 #define DR7_G3(dr)    (((dr)>>7)&0x1)
108 #define DR7_G3SET(dr) ((dr) |= 0x80)
109 #define DR7_G3CLR(dr) ((dr) &= ~0x80)
110
111 #define DR7_L0(dr)    (((dr))&0x1)
112 #define DR7_L0SET(dr) ((dr) |= 0x1)
113 #define DR7_L0CLR(dr) ((dr) &= ~0x1)
114 #define DR7_L1(dr)    (((dr)>>2)&0x1)
115 #define DR7_L1SET(dr) ((dr) |= 0x4)
116 #define DR7_L1CLR(dr) ((dr) &= ~0x4)
117 #define DR7_L2(dr)    (((dr)>>4)&0x1)
118 #define DR7_L2SET(dr) ((dr) |= 0x10)
119 #define DR7_L2CLR(dr) ((dr) &= ~0x10)
120 #define DR7_L3(dr)    (((dr)>>6)&0x1)
121 #define DR7_L3SET(dr) ((dr) |= 0x40)
122 #define DR7_L3CLR(dr) ((dr) &= ~0x40)
123
124 #define DR7_GD          0x00002000              /* General Detect Enable */
125 #define DR7_GE          0x00000200              /* Global exact */
126 #define DR7_LE          0x00000100              /* Local exact */
127
128 extern kdb_machreg_t kdba_getdr6(void);
129 extern void kdba_putdr6(kdb_machreg_t);
130
131 extern kdb_machreg_t kdba_getdr7(void);
132
133 extern kdb_machreg_t kdba_getdr(int);
134 extern void kdba_putdr(int, kdb_machreg_t);
135
136 extern kdb_machreg_t kdb_getcr(int);
137
138 /*
139  * reg indicies for x86_64 setjmp/longjmp
140  */
141 #define JB_RBX   0
142 #define JB_RBP   1
143 #define JB_R12   2
144 #define JB_R13   3
145 #define JB_R14   4
146 #define JB_R15   5
147 #define JB_RSP   6
148 #define JB_PC    7
149
150 typedef struct __kdb_jmp_buf {
151         unsigned long   regs[8];        /* kdba_setjmp assumes fixed offsets here */
152 } kdb_jmp_buf;
153
154 extern int asmlinkage kdba_setjmp(kdb_jmp_buf *);
155 extern void asmlinkage kdba_longjmp(kdb_jmp_buf *, int);
156 #define kdba_setjmp kdba_setjmp
157
158 extern kdb_jmp_buf  *kdbjmpbuf;
159
160 /* Arch specific data saved for running processes */
161
162 struct kdba_running_process {
163         long rsp;       /* KDB may be on a different stack */
164         long rip;       /* rip when rsp was set */
165 };
166
167 register unsigned long current_stack_pointer asm("rsp") __used;
168
169 static inline
170 void kdba_save_running(struct kdba_running_process *k, struct pt_regs *regs)
171 {
172         k->rsp = current_stack_pointer;
173         __asm__ __volatile__ ( " lea 0(%%rip),%%rax; movq %%rax,%0 ; " : "=r"(k->rip) : : "rax" );
174 }
175
176 static inline
177 void kdba_unsave_running(struct kdba_running_process *k, struct pt_regs *regs)
178 {
179 }
180
181 struct kdb_activation_record;
182 extern void kdba_get_stack_info_alternate(kdb_machreg_t addr, int cpu,
183                                           struct kdb_activation_record *ar);
184
185 extern void kdba_wait_for_cpus(void);
186
187 extern asmlinkage void kdb_interrupt(void);
188
189 #define KDB_INT_REGISTERS       16
190
191 #endif  /* !_ASM_KDBPRIVATE_H */