- more 2.6.17 port work (still does not build)
[linux-flexiantxendom0-3.2.10.git] / include / asm-x86_64 / 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 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         /*
29          * Platform specific environment entries
30          */
31 #define KDB_PLATFORM_ENV        "IDMODE=x86_64", "BYTESPERWORD=8", "IDCOUNT=16"
32
33         /*
34          * Define the direction that the stack grows
35          */
36 #define KDB_STACK_DIRECTION     (-1)    /* Stack grows down */
37
38         /*
39          * Support for ia32 debug registers 
40          */
41 typedef struct _kdbhard_bp {
42         kdb_machreg_t   bph_reg;        /* Register this breakpoint uses */
43
44         unsigned int    bph_free:1;     /* Register available for use */
45         unsigned int    bph_data:1;     /* Data Access breakpoint */
46
47         unsigned int    bph_write:1;    /* Write Data breakpoint */
48         unsigned int    bph_mode:2;     /* 0=inst, 1=write, 2=io, 3=read */
49         unsigned int    bph_length:2;   /* 0=1, 1=2, 2=BAD, 3=4 (bytes) */
50 } kdbhard_bp_t;
51
52 extern kdbhard_bp_t     kdb_hardbreaks[/* KDB_MAXHARDBPT */];
53
54 #define IA32_BREAKPOINT_INSTRUCTION     0xcc
55
56 #define DR6_BT  0x00008000
57 #define DR6_BS  0x00004000
58 #define DR6_BD  0x00002000
59
60 #define DR6_B3  0x00000008
61 #define DR6_B2  0x00000004
62 #define DR6_B1  0x00000002
63 #define DR6_B0  0x00000001
64
65 #define DR7_RW_VAL(dr, drnum) \
66        (((dr) >> (16 + (4 * (drnum)))) & 0x3)
67
68 #define DR7_RW_SET(dr, drnum, rw)                              \
69        do {                                                    \
70                (dr) &= ~(0x3 << (16 + (4 * (drnum))));         \
71                (dr) |= (((rw) & 0x3) << (16 + (4 * (drnum)))); \
72        } while (0)
73
74 #define DR7_RW0(dr)       DR7_RW_VAL(dr, 0)
75 #define DR7_RW0SET(dr,rw)  DR7_RW_SET(dr, 0, rw)
76 #define DR7_RW1(dr)       DR7_RW_VAL(dr, 1)
77 #define DR7_RW1SET(dr,rw)  DR7_RW_SET(dr, 1, rw)
78 #define DR7_RW2(dr)       DR7_RW_VAL(dr, 2)
79 #define DR7_RW2SET(dr,rw)  DR7_RW_SET(dr, 2, rw)
80 #define DR7_RW3(dr)       DR7_RW_VAL(dr, 3)
81 #define DR7_RW3SET(dr,rw)  DR7_RW_SET(dr, 3, rw)
82
83
84 #define DR7_LEN_VAL(dr, drnum) \
85        (((dr) >> (18 + (4 * (drnum)))) & 0x3)
86
87 #define DR7_LEN_SET(dr, drnum, rw)                             \
88        do {                                                    \
89                (dr) &= ~(0x3 << (18 + (4 * (drnum))));         \
90                (dr) |= (((rw) & 0x3) << (18 + (4 * (drnum)))); \
91        } while (0)
92 #define DR7_LEN0(dr)        DR7_LEN_VAL(dr, 0)
93 #define DR7_LEN0SET(dr,len)  DR7_LEN_SET(dr, 0, len)
94 #define DR7_LEN1(dr)        DR7_LEN_VAL(dr, 1)
95 #define DR7_LEN1SET(dr,len)  DR7_LEN_SET(dr, 1, len)
96 #define DR7_LEN2(dr)        DR7_LEN_VAL(dr, 2)
97 #define DR7_LEN2SET(dr,len)  DR7_LEN_SET(dr, 2, len)
98 #define DR7_LEN3(dr)        DR7_LEN_VAL(dr, 3)
99 #define DR7_LEN3SET(dr,len)  DR7_LEN_SET(dr, 3, len)
100
101 #define DR7_G0(dr)    (((dr)>>1)&0x1)
102 #define DR7_G0SET(dr) ((dr) |= 0x2)
103 #define DR7_G0CLR(dr) ((dr) &= ~0x2)
104 #define DR7_G1(dr)    (((dr)>>3)&0x1)
105 #define DR7_G1SET(dr) ((dr) |= 0x8)
106 #define DR7_G1CLR(dr) ((dr) &= ~0x8)
107 #define DR7_G2(dr)    (((dr)>>5)&0x1)
108 #define DR7_G2SET(dr) ((dr) |= 0x20)
109 #define DR7_G2CLR(dr) ((dr) &= ~0x20)
110 #define DR7_G3(dr)    (((dr)>>7)&0x1)
111 #define DR7_G3SET(dr) ((dr) |= 0x80)
112 #define DR7_G3CLR(dr) ((dr) &= ~0x80)
113
114 #define DR7_L0(dr)    (((dr))&0x1)
115 #define DR7_L0SET(dr) ((dr) |= 0x1)
116 #define DR7_L0CLR(dr) ((dr) &= ~0x1)
117 #define DR7_L1(dr)    (((dr)>>2)&0x1)
118 #define DR7_L1SET(dr) ((dr) |= 0x4)
119 #define DR7_L1CLR(dr) ((dr) &= ~0x4)
120 #define DR7_L2(dr)    (((dr)>>4)&0x1)
121 #define DR7_L2SET(dr) ((dr) |= 0x10)
122 #define DR7_L2CLR(dr) ((dr) &= ~0x10)
123 #define DR7_L3(dr)    (((dr)>>6)&0x1)
124 #define DR7_L3SET(dr) ((dr) |= 0x40)
125 #define DR7_L3CLR(dr) ((dr) &= ~0x40)
126
127 #define DR7_GD          0x00002000              /* General Detect Enable */
128 #define DR7_GE          0x00000200              /* Global exact */
129 #define DR7_LE          0x00000100              /* Local exact */
130
131 extern kdb_machreg_t kdba_getdr6(void);
132 extern void kdba_putdr6(kdb_machreg_t);
133
134 extern kdb_machreg_t kdba_getdr7(void);
135
136 extern kdb_machreg_t kdba_getdr(int);
137 extern void kdba_putdr(int, kdb_machreg_t);
138
139 extern kdb_machreg_t kdb_getcr(int);
140
141 #define KDB_HAVE_LONGJMP
142 #ifdef KDB_HAVE_LONGJMP
143 /*
144  * reg indicies for x86_64 setjmp/longjmp
145  */
146 #define JB_RBX   0
147 #define JB_RBP   1
148 #define JB_R12   2
149 #define JB_R13   3
150 #define JB_R14   4
151 #define JB_R15   5
152 #define JB_RSP   6
153 #define JB_PC    7
154
155 typedef struct __kdb_jmp_buf {
156         unsigned long   regs[8];        /* kdba_setjmp assumes fixed offsets here */
157 } kdb_jmp_buf;
158
159 extern int asmlinkage kdba_setjmp(kdb_jmp_buf *);
160 extern void asmlinkage kdba_longjmp(kdb_jmp_buf *, int);
161
162 extern kdb_jmp_buf  *kdbjmpbuf;
163 #endif  /* KDB_HAVE_LONGJMP */
164
165 /* Arch specific data saved for running processes */
166
167 struct kdba_running_process {
168         int dummy[0];   /* Everything is in pt_regs for i386 */
169 };
170
171 static inline
172 void kdba_save_running(struct kdba_running_process *k, struct pt_regs *regs)
173 {
174 }
175
176 static inline
177 void kdba_unsave_running(struct kdba_running_process *k, struct pt_regs *regs)
178 {
179 }
180
181 #define kdba_wait_for_cpus()
182
183 #endif  /* !_ASM_KDBPRIVATE_H */