1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #ifndef _MDB_KREG_H
27 #define _MDB_KREG_H
28
29 #pragma ident "%Z%%M% %I% %E% SMI"
30
31 #include <sys/kdi_regs.h>
32 #ifndef _ASM
33 #include <sys/types.h>
34 #endif
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 #ifndef _ASM
41 #ifdef __amd64
42 typedef uint64_t kreg_t;
43 #else /* __amd64 */
44 typedef uint32_t kreg_t;
45 #endif /* __amd64 */
46 #endif /* !_ASM */
47
48 #define KREG_NGREG KDIREG_NGREG
49
50 /*
51 * The order of these registers corresponds to a slightly altered struct regs,
52 * in the order kmdb entry pushes onto the stack.
53 */
54
55 #ifdef __amd64
56
57 #define KREG_SAVFP KDIREG_SAVFP
58 #define KREG_SAVPC KDIREG_SAVPC
59 #define KREG_RDI KDIREG_RDI
60 #define KREG_RSI KDIREG_RSI
61 #define KREG_RDX KDIREG_RDX
62 #define KREG_RCX KDIREG_RCX
63 #define KREG_R8 KDIREG_R8
64 #define KREG_R9 KDIREG_R9
65 #define KREG_RAX KDIREG_RAX
66 #define KREG_RBX KDIREG_RBX
67 #define KREG_RBP KDIREG_RBP
68 #define KREG_R10 KDIREG_R10
69 #define KREG_R11 KDIREG_R11
70 #define KREG_R12 KDIREG_R12
71 #define KREG_R13 KDIREG_R13
72 #define KREG_R14 KDIREG_R14
73 #define KREG_R15 KDIREG_R15
74 #define KREG_DS KDIREG_DS
75 #define KREG_ES KDIREG_ES
76 #define KREG_FS KDIREG_FS
77 #define KREG_GS KDIREG_GS
78 #define KREG_TRAPNO KDIREG_TRAPNO
79 #define KREG_ERR KDIREG_ERR
80 #define KREG_RIP KDIREG_RIP
81 #define KREG_CS KDIREG_CS
82 #define KREG_RFLAGS KDIREG_RFLAGS
83 #define KREG_RSP KDIREG_RSP
84 #define KREG_SS KDIREG_SS
85
86 #define KREG_PC KREG_RIP
87 #define KREG_SP KREG_RSP
88 #define KREG_FP KREG_RBP
89
90 #else /* __amd64 */
91
92 #define KREG_SAVFP KDIREG_SAVFP
93 #define KREG_SAVPC KDIREG_SAVPC
94 #define KREG_SS KDIREG_SS
95 #define KREG_GS KDIREG_GS
96 #define KREG_FS KDIREG_FS
97 #define KREG_ES KDIREG_ES
98 #define KREG_DS KDIREG_DS
99 #define KREG_EDI KDIREG_EDI
100 #define KREG_ESI KDIREG_ESI
101 #define KREG_EBP KDIREG_EBP
102 #define KREG_ESP KDIREG_ESP
103 #define KREG_EBX KDIREG_EBX
104 #define KREG_EDX KDIREG_EDX
105 #define KREG_ECX KDIREG_ECX
106 #define KREG_EAX KDIREG_EAX
107 #define KREG_TRAPNO KDIREG_TRAPNO
108 #define KREG_ERR KDIREG_ERR
109 #define KREG_EIP KDIREG_EIP
110 #define KREG_CS KDIREG_CS
111 #define KREG_EFLAGS KDIREG_EFLAGS
112 #define KREG_UESP KDIREG_UESP
113
114 #define KREG_PC KREG_EIP
115 #define KREG_SP KREG_ESP
116 #define KREG_FP KREG_EBP
117
118 #endif /* __amd64 */
119
120 #define KREG_EFLAGS_ID_MASK 0x00200000
121 #define KREG_EFLAGS_ID_SHIFT 21
122
123 #define KREG_EFLAGS_VIP_MASK 0x00100000
124 #define KREG_EFLAGS_VIP_SHIFT 20
125
126 #define KREG_EFLAGS_VIF_MASK 0x00080000
127 #define KREG_EFLAGS_VIF_SHIFT 19
128
129 #define KREG_EFLAGS_AC_MASK 0x00040000
130 #define KREG_EFLAGS_AC_SHIFT 18
131
132 #define KREG_EFLAGS_VM_MASK 0x00020000
133 #define KREG_EFLAGS_VM_SHIFT 17
134
135 #define KREG_EFLAGS_RF_MASK 0x00010000
136 #define KREG_EFLAGS_RF_SHIFT 16
137
138 #define KREG_EFLAGS_NT_MASK 0x00004000
139 #define KREG_EFLAGS_NT_SHIFT 14
140
141 #define KREG_EFLAGS_IOPL_MASK 0x00003000
142 #define KREG_EFLAGS_IOPL_SHIFT 12
143
144 #define KREG_EFLAGS_OF_MASK 0x00000800
145 #define KREG_EFLAGS_OF_SHIFT 11
146
147 #define KREG_EFLAGS_DF_MASK 0x00000400
148 #define KREG_EFLAGS_DF_SHIFT 10
149
150 #define KREG_EFLAGS_IF_MASK 0x00000200
151 #define KREG_EFLAGS_IF_SHIFT 9
152
153 #define KREG_EFLAGS_TF_MASK 0x00000100
154 #define KREG_EFLAGS_TF_SHIFT 8
155
156 #define KREG_EFLAGS_SF_MASK 0x00000080
157 #define KREG_EFLAGS_SF_SHIFT 7
158
159 #define KREG_EFLAGS_ZF_MASK 0x00000040
160 #define KREG_EFLAGS_ZF_SHIFT 6
161
162 #define KREG_EFLAGS_AF_MASK 0x00000010
163 #define KREG_EFLAGS_AF_SHIFT 4
164
165 #define KREG_EFLAGS_PF_MASK 0x00000004
166 #define KREG_EFLAGS_PF_SHIFT 2
167
168 #define KREG_EFLAGS_CF_MASK 0x00000001
169 #define KREG_EFLAGS_CF_SHIFT 0
170
171 /* %dr7 */
172 #define KREG_DRCTL_WP_BASESHIFT 16
173 #define KREG_DRCTL_WP_INCRSHIFT 4
174 #define KREG_DRCTL_WP_LENSHIFT 2
175 #define KREG_DRCTL_WP_LENRWMASK 0xf
176
177 #define KREG_DRCTL_WP_EXEC 0
178 #define KREG_DRCTL_WP_WONLY 1
179 #define KREG_DRCTL_WP_IORW 2
180 #define KREG_DRCTL_WP_RW 3
181
182 #define KREG_DRCTL_WP_SHIFT(n) \
183 (KREG_DRCTL_WP_BASESHIFT + KREG_DRCTL_WP_INCRSHIFT * (n))
184 #define KREG_DRCTL_WP_MASK(n) \
185 (KREG_DRCTL_WP_LENRWMASK << KREG_DRCTL_WP_SHIFT(n))
186 #define KREG_DRCTL_WP_LENRW(n, len, rw) \
187 ((((len) << KREG_DRCTL_WP_LENSHIFT) | (rw)) << KREG_DRCTL_WP_SHIFT(n))
188
189 #define KREG_DRCTL_WPEN_INCRSHIFT 2
190 #define KREG_DRCTL_WPEN_MASK(n) \
191 (3 << (KREG_DRCTL_WPEN_INCRSHIFT * (n)))
192 #define KREG_DRCTL_WPEN(n) KREG_DRCTL_WPEN_MASK(n)
193
194 /* %dr6 */
195 #define KREG_DRSTAT_BT_MASK 0x00008000
196 #define KREG_DRSTAT_BS_MASK 0x00004000
197 #define KREG_DRSTAT_BD_MASK 0x00002000
198
199 #define KREG_DRSTAT_WP_MASK(n) (1 << (n))
200
201 #ifdef __cplusplus
202 }
203 #endif
204
205 #endif /* _MDB_KREG_H */