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 * Copyright 2018 Joyent, Inc. 26 */ 27 28 #ifndef _MDB_KREG_H 29 #define _MDB_KREG_H 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_GSBASE KDIREG_GSBASE 79 #define KREG_KGSBASE KDIREG_KGSBASE 80 #define KREG_TRAPNO KDIREG_TRAPNO 81 #define KREG_ERR KDIREG_ERR 82 #define KREG_CR2 KDIREG_CR2 83 #define KREG_CR3 KDIREG_CR3 84 #define KREG_RIP KDIREG_RIP 85 #define KREG_CS KDIREG_CS 86 #define KREG_RFLAGS KDIREG_RFLAGS 87 #define KREG_RSP KDIREG_RSP 88 #define KREG_SS KDIREG_SS 89 90 #define KREG_PC KREG_RIP 91 #define KREG_SP KREG_RSP 92 #define KREG_FP KREG_RBP 93 94 #else /* __amd64 */ 95 96 #define KREG_SAVFP KDIREG_SAVFP 97 #define KREG_SAVPC KDIREG_SAVPC 98 #define KREG_SS KDIREG_SS 99 #define KREG_GS KDIREG_GS 100 #define KREG_FS KDIREG_FS 101 #define KREG_ES KDIREG_ES 102 #define KREG_DS KDIREG_DS 103 #define KREG_EDI KDIREG_EDI 104 #define KREG_ESI KDIREG_ESI 105 #define KREG_EBP KDIREG_EBP 106 #define KREG_ESP KDIREG_ESP 107 #define KREG_EBX KDIREG_EBX 108 #define KREG_EDX KDIREG_EDX 109 #define KREG_ECX KDIREG_ECX 110 #define KREG_EAX KDIREG_EAX 111 #define KREG_TRAPNO KDIREG_TRAPNO 112 #define KREG_ERR KDIREG_ERR 113 #define KREG_EIP KDIREG_EIP 114 #define KREG_CS KDIREG_CS 115 #define KREG_EFLAGS KDIREG_EFLAGS 116 #define KREG_UESP KDIREG_UESP 117 118 #define KREG_PC KREG_EIP 119 #define KREG_SP KREG_ESP 120 #define KREG_FP KREG_EBP 121 122 #endif /* __amd64 */ 123 124 #define KREG_EFLAGS_ID_MASK 0x00200000 125 #define KREG_EFLAGS_ID_SHIFT 21 126 127 #define KREG_EFLAGS_VIP_MASK 0x00100000 128 #define KREG_EFLAGS_VIP_SHIFT 20 129 130 #define KREG_EFLAGS_VIF_MASK 0x00080000 131 #define KREG_EFLAGS_VIF_SHIFT 19 132 133 #define KREG_EFLAGS_AC_MASK 0x00040000 134 #define KREG_EFLAGS_AC_SHIFT 18 135 136 #define KREG_EFLAGS_VM_MASK 0x00020000 137 #define KREG_EFLAGS_VM_SHIFT 17 138 139 #define KREG_EFLAGS_RF_MASK 0x00010000 140 #define KREG_EFLAGS_RF_SHIFT 16 141 142 #define KREG_EFLAGS_NT_MASK 0x00004000 143 #define KREG_EFLAGS_NT_SHIFT 14 144 145 #define KREG_EFLAGS_IOPL_MASK 0x00003000 146 #define KREG_EFLAGS_IOPL_SHIFT 12 147 148 #define KREG_EFLAGS_OF_MASK 0x00000800 149 #define KREG_EFLAGS_OF_SHIFT 11 150 151 #define KREG_EFLAGS_DF_MASK 0x00000400 152 #define KREG_EFLAGS_DF_SHIFT 10 153 154 #define KREG_EFLAGS_IF_MASK 0x00000200 155 #define KREG_EFLAGS_IF_SHIFT 9 156 157 #define KREG_EFLAGS_TF_MASK 0x00000100 158 #define KREG_EFLAGS_TF_SHIFT 8 159 160 #define KREG_EFLAGS_SF_MASK 0x00000080 161 #define KREG_EFLAGS_SF_SHIFT 7 162 163 #define KREG_EFLAGS_ZF_MASK 0x00000040 164 #define KREG_EFLAGS_ZF_SHIFT 6 165 166 #define KREG_EFLAGS_AF_MASK 0x00000010 167 #define KREG_EFLAGS_AF_SHIFT 4 168 169 #define KREG_EFLAGS_PF_MASK 0x00000004 170 #define KREG_EFLAGS_PF_SHIFT 2 171 172 #define KREG_EFLAGS_CF_MASK 0x00000001 173 #define KREG_EFLAGS_CF_SHIFT 0 174 175 /* %dr7 */ 176 #define KREG_DRCTL_WP_BASESHIFT 16 177 #define KREG_DRCTL_WP_INCRSHIFT 4 178 #define KREG_DRCTL_WP_LENSHIFT 2 179 #define KREG_DRCTL_WP_LENRWMASK 0xf 180 181 #define KREG_DRCTL_WP_EXEC 0 182 #define KREG_DRCTL_WP_WONLY 1 183 #define KREG_DRCTL_WP_IORW 2 184 #define KREG_DRCTL_WP_RW 3 185 186 #define KREG_DRCTL_WP_SHIFT(n) \ 187 (KREG_DRCTL_WP_BASESHIFT + KREG_DRCTL_WP_INCRSHIFT * (n)) 188 #define KREG_DRCTL_WP_MASK(n) \ 189 (KREG_DRCTL_WP_LENRWMASK << KREG_DRCTL_WP_SHIFT(n)) 190 #define KREG_DRCTL_WP_LENRW(n, len, rw) \ 191 ((((len) << KREG_DRCTL_WP_LENSHIFT) | (rw)) << KREG_DRCTL_WP_SHIFT(n)) 192 193 #define KREG_DRCTL_WPEN_INCRSHIFT 2 194 #define KREG_DRCTL_WPEN_MASK(n) \ 195 (3 << (KREG_DRCTL_WPEN_INCRSHIFT * (n))) 196 #define KREG_DRCTL_WPEN(n) KREG_DRCTL_WPEN_MASK(n) 197 198 /* %dr6 */ 199 #define KREG_DRSTAT_BT_MASK 0x00008000 200 #define KREG_DRSTAT_BS_MASK 0x00004000 201 #define KREG_DRSTAT_BD_MASK 0x00002000 202 203 #define KREG_DRSTAT_WP_MASK(n) (1 << (n)) 204 205 #ifdef __cplusplus 206 } 207 #endif 208 209 #endif /* _MDB_KREG_H */