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