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 typedef unsigned char kdb_machinst_t;
17 * KDB_MAXBPT describes the total number of breakpoints
18 * supported by this architecure.
23 * KDB_MAXHARDBPT describes the total number of hardware
24 * breakpoint registers that exist.
26 #define KDB_MAXHARDBPT 4
29 * Platform specific environment entries
31 #define KDB_PLATFORM_ENV "IDMODE=x86_64", "BYTESPERWORD=8", "IDCOUNT=16"
34 * Define the direction that the stack grows
36 #define KDB_STACK_DIRECTION (-1) /* Stack grows down */
39 * Support for ia32 debug registers
41 typedef struct _kdbhard_bp {
42 kdb_machreg_t bph_reg; /* Register this breakpoint uses */
44 unsigned int bph_free:1; /* Register available for use */
45 unsigned int bph_data:1; /* Data Access breakpoint */
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) */
52 extern kdbhard_bp_t kdb_hardbreaks[/* KDB_MAXHARDBPT */];
54 #define IA32_BREAKPOINT_INSTRUCTION 0xcc
56 #define DR6_BT 0x00008000
57 #define DR6_BS 0x00004000
58 #define DR6_BD 0x00002000
60 #define DR6_B3 0x00000008
61 #define DR6_B2 0x00000004
62 #define DR6_B1 0x00000002
63 #define DR6_B0 0x00000001
65 #define DR7_RW_VAL(dr, drnum) \
66 (((dr) >> (16 + (4 * (drnum)))) & 0x3)
68 #define DR7_RW_SET(dr, drnum, rw) \
70 (dr) &= ~(0x3 << (16 + (4 * (drnum)))); \
71 (dr) |= (((rw) & 0x3) << (16 + (4 * (drnum)))); \
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)
84 #define DR7_LEN_VAL(dr, drnum) \
85 (((dr) >> (18 + (4 * (drnum)))) & 0x3)
87 #define DR7_LEN_SET(dr, drnum, rw) \
89 (dr) &= ~(0x3 << (18 + (4 * (drnum)))); \
90 (dr) |= (((rw) & 0x3) << (18 + (4 * (drnum)))); \
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)
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)
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)
127 #define DR7_GD 0x00002000 /* General Detect Enable */
128 #define DR7_GE 0x00000200 /* Global exact */
129 #define DR7_LE 0x00000100 /* Local exact */
131 extern kdb_machreg_t kdba_getdr6(void);
132 extern void kdba_putdr6(kdb_machreg_t);
134 extern kdb_machreg_t kdba_getdr7(void);
136 extern kdb_machreg_t kdba_getdr(int);
137 extern void kdba_putdr(int, kdb_machreg_t);
139 extern kdb_machreg_t kdb_getcr(int);
141 #define KDB_HAVE_LONGJMP
142 #ifdef KDB_HAVE_LONGJMP
144 * reg indicies for x86_64 setjmp/longjmp
155 typedef struct __kdb_jmp_buf {
156 unsigned long regs[8]; /* kdba_setjmp assumes fixed offsets here */
159 extern int asmlinkage kdba_setjmp(kdb_jmp_buf *);
160 extern void asmlinkage kdba_longjmp(kdb_jmp_buf *, int);
162 extern kdb_jmp_buf *kdbjmpbuf;
163 #endif /* KDB_HAVE_LONGJMP */
165 /* Arch specific data saved for running processes */
167 struct kdba_running_process {
168 int dummy[0]; /* Everything is in pt_regs for i386 */
172 void kdba_save_running(struct kdba_running_process *k, struct pt_regs *regs)
177 void kdba_unsave_running(struct kdba_running_process *k, struct pt_regs *regs)
181 #define kdba_wait_for_cpus()
183 #endif /* !_ASM_KDBPRIVATE_H */