1 2 /*---------------------------------------------------------------*/ 3 /*--- begin libvex_guest_ppc32.h ---*/ 4 /*---------------------------------------------------------------*/ 5 6 /* 7 This file is part of Valgrind, a dynamic binary instrumentation 8 framework. 9 10 Copyright (C) 2004-2013 OpenWorks LLP 11 info@open-works.net 12 13 This program is free software; you can redistribute it and/or 14 modify it under the terms of the GNU General Public License as 15 published by the Free Software Foundation; either version 2 of the 16 License, or (at your option) any later version. 17 18 This program is distributed in the hope that it will be useful, but 19 WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 General Public License for more details. 22 23 You should have received a copy of the GNU General Public License 24 along with this program; if not, write to the Free Software 25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 26 02110-1301, USA. 27 28 The GNU General Public License is contained in the file COPYING. 29 30 Neither the names of the U.S. Department of Energy nor the 31 University of California nor the names of its contributors may be 32 used to endorse or promote products derived from this software 33 without prior written permission. 34 */ 35 36 #ifndef __LIBVEX_PUB_GUEST_PPC32_H 37 #define __LIBVEX_PUB_GUEST_PPC32_H 38 39 #include "libvex_basictypes.h" 40 41 42 /*---------------------------------------------------------------*/ 43 /*--- Vex's representation of the PPC32 CPU state ---*/ 44 /*---------------------------------------------------------------*/ 45 46 #define VEX_GUEST_PPC32_REDIR_STACK_SIZE (16/*entries*/ * 2/*words per entry*/) 47 48 typedef 49 struct { 50 /* Event check fail addr and counter. */ 51 /* 0 */ UInt host_EvC_FAILADDR; 52 /* 4 */ UInt host_EvC_COUNTER; 53 /* 8 */ UInt pad3; 54 /* 12 */ UInt pad4; 55 /* Add 16 to all the numbers below. Sigh. */ 56 /* General Purpose Registers */ 57 /* 0 */ UInt guest_GPR0; 58 /* 4 */ UInt guest_GPR1; 59 /* 8 */ UInt guest_GPR2; 60 /* 12 */ UInt guest_GPR3; 61 /* 16 */ UInt guest_GPR4; 62 /* 20 */ UInt guest_GPR5; 63 /* 24 */ UInt guest_GPR6; 64 /* 28 */ UInt guest_GPR7; 65 /* 32 */ UInt guest_GPR8; 66 /* 36 */ UInt guest_GPR9; 67 /* 40 */ UInt guest_GPR10; 68 /* 44 */ UInt guest_GPR11; 69 /* 48 */ UInt guest_GPR12; 70 /* 52 */ UInt guest_GPR13; 71 /* 56 */ UInt guest_GPR14; 72 /* 60 */ UInt guest_GPR15; 73 /* 64 */ UInt guest_GPR16; 74 /* 68 */ UInt guest_GPR17; 75 /* 72 */ UInt guest_GPR18; 76 /* 76 */ UInt guest_GPR19; 77 /* 80 */ UInt guest_GPR20; 78 /* 84 */ UInt guest_GPR21; 79 /* 88 */ UInt guest_GPR22; 80 /* 92 */ UInt guest_GPR23; 81 /* 96 */ UInt guest_GPR24; 82 /* 100 */ UInt guest_GPR25; 83 /* 104 */ UInt guest_GPR26; 84 /* 108 */ UInt guest_GPR27; 85 /* 112 */ UInt guest_GPR28; 86 /* 116 */ UInt guest_GPR29; 87 /* 120 */ UInt guest_GPR30; 88 /* 124 */ UInt guest_GPR31; 89 90 // Vector Registers, Floating Point Registers, and VSX Registers 91 // With ISA 2.06, the "Vector-Scalar Floating-point" category 92 // provides facilities to support vector and scalar binary floating- 93 // point operations. A unified register file is an integral part 94 // of this new facility, combining floating point and vector registers 95 // using a 64x128-bit vector. These are referred to as VSR[0..63]. 96 // The floating point registers are now mapped into double word element 0 97 // of VSR[0..31]. The 32x128-bit vector registers defined by the "Vector 98 // Facility [Category: Vector]" are now mapped to VSR[32..63]. 99 100 // IMPORTANT: the user of libvex must place the guest state so as 101 // to ensure that guest_VSR{0..63}, and any shadows thereof, are 102 // 16-aligned. 103 104 /* 128 */ U128 guest_VSR0; 105 /* 144 */ U128 guest_VSR1; 106 /* 160 */ U128 guest_VSR2; 107 /* 176 */ U128 guest_VSR3; 108 /* 192 */ U128 guest_VSR4; 109 /* 208 */ U128 guest_VSR5; 110 /* 224 */ U128 guest_VSR6; 111 /* 240 */ U128 guest_VSR7; 112 /* 256 */ U128 guest_VSR8; 113 /* 272 */ U128 guest_VSR9; 114 /* 288 */ U128 guest_VSR10; 115 /* 304 */ U128 guest_VSR11; 116 /* 320 */ U128 guest_VSR12; 117 /* 336 */ U128 guest_VSR13; 118 /* 352 */ U128 guest_VSR14; 119 /* 368 */ U128 guest_VSR15; 120 /* 384 */ U128 guest_VSR16; 121 /* 400 */ U128 guest_VSR17; 122 /* 416 */ U128 guest_VSR18; 123 /* 432 */ U128 guest_VSR19; 124 /* 448 */ U128 guest_VSR20; 125 /* 464 */ U128 guest_VSR21; 126 /* 480 */ U128 guest_VSR22; 127 /* 496 */ U128 guest_VSR23; 128 /* 512 */ U128 guest_VSR24; 129 /* 528 */ U128 guest_VSR25; 130 /* 544 */ U128 guest_VSR26; 131 /* 560 */ U128 guest_VSR27; 132 /* 576 */ U128 guest_VSR28; 133 /* 592 */ U128 guest_VSR29; 134 /* 608 */ U128 guest_VSR30; 135 /* 624 */ U128 guest_VSR31; 136 /* 640 */ U128 guest_VSR32; 137 /* 656 */ U128 guest_VSR33; 138 /* 672 */ U128 guest_VSR34; 139 /* 688 */ U128 guest_VSR35; 140 /* 704 */ U128 guest_VSR36; 141 /* 720 */ U128 guest_VSR37; 142 /* 736 */ U128 guest_VSR38; 143 /* 752 */ U128 guest_VSR39; 144 /* 768 */ U128 guest_VSR40; 145 /* 784 */ U128 guest_VSR41; 146 /* 800 */ U128 guest_VSR42; 147 /* 816 */ U128 guest_VSR43; 148 /* 832 */ U128 guest_VSR44; 149 /* 848 */ U128 guest_VSR45; 150 /* 864 */ U128 guest_VSR46; 151 /* 880 */ U128 guest_VSR47; 152 /* 896 */ U128 guest_VSR48; 153 /* 912 */ U128 guest_VSR49; 154 /* 928 */ U128 guest_VSR50; 155 /* 944 */ U128 guest_VSR51; 156 /* 960 */ U128 guest_VSR52; 157 /* 976 */ U128 guest_VSR53; 158 /* 992 */ U128 guest_VSR54; 159 /* 1008 */ U128 guest_VSR55; 160 /* 1024 */ U128 guest_VSR56; 161 /* 1040 */ U128 guest_VSR57; 162 /* 1056 */ U128 guest_VSR58; 163 /* 1072 */ U128 guest_VSR59; 164 /* 1088 */ U128 guest_VSR60; 165 /* 1104 */ U128 guest_VSR61; 166 /* 1120 */ U128 guest_VSR62; 167 /* 1136 */ U128 guest_VSR63; 168 169 /* 1152 */ UInt guest_CIA; // IP (no arch visible register) 170 /* 1156 */ UInt guest_LR; // Link Register 171 /* 1160 */ UInt guest_CTR; // Count Register 172 173 /* XER pieces */ 174 /* 1164 */ UChar guest_XER_SO; /* in lsb */ 175 /* 1165 */ UChar guest_XER_OV; /* in lsb */ 176 /* 1166 */ UChar guest_XER_CA; /* in lsb */ 177 /* 1167 */ UChar guest_XER_BC; /* all bits */ 178 179 /* CR pieces */ 180 /* 1168 */ UChar guest_CR0_321; /* in [3:1] */ 181 /* 1169 */ UChar guest_CR0_0; /* in lsb */ 182 /* 1170 */ UChar guest_CR1_321; /* in [3:1] */ 183 /* 1171 */ UChar guest_CR1_0; /* in lsb */ 184 /* 1172 */ UChar guest_CR2_321; /* in [3:1] */ 185 /* 1173 */ UChar guest_CR2_0; /* in lsb */ 186 /* 1174 */ UChar guest_CR3_321; /* in [3:1] */ 187 /* 1175 */ UChar guest_CR3_0; /* in lsb */ 188 /* 1176 */ UChar guest_CR4_321; /* in [3:1] */ 189 /* 1177 */ UChar guest_CR4_0; /* in lsb */ 190 /* 1178 */ UChar guest_CR5_321; /* in [3:1] */ 191 /* 1179 */ UChar guest_CR5_0; /* in lsb */ 192 /* 1180 */ UChar guest_CR6_321; /* in [3:1] */ 193 /* 1181 */ UChar guest_CR6_0; /* in lsb */ 194 /* 1182 */ UChar guest_CR7_321; /* in [3:1] */ 195 /* 1183 */ UChar guest_CR7_0; /* in lsb */ 196 197 /* FP Status & Control Register fields. Only rounding mode fields are supported. */ 198 /* 1184 */ UChar guest_FPROUND; // Binary Floating Point Rounding Mode 199 /* 1185 */ UChar guest_DFPROUND; // Decimal Floating Point Rounding Mode 200 /* 1186 */ UChar pad1; 201 /* 1187 */ UChar pad2; 202 203 /* Vector Save/Restore Register */ 204 /* 1188 */ UInt guest_VRSAVE; 205 206 /* Vector Status and Control Register */ 207 /* 1192 */ UInt guest_VSCR; 208 209 /* Emulation notes */ 210 /* 1196 */ UInt guest_EMNOTE; 211 212 /* For icbi: record start and length of area to invalidate */ 213 /* 1200 */ UInt guest_CMSTART; 214 /* 1204 */ UInt guest_CMLEN; 215 216 /* Used to record the unredirected guest address at the start of 217 a translation whose start has been redirected. By reading 218 this pseudo-register shortly afterwards, the translation can 219 find out what the corresponding no-redirection address was. 220 Note, this is only set for wrap-style redirects, not for 221 replace-style ones. */ 222 /* 1208 */ UInt guest_NRADDR; 223 /* 1212 */ UInt guest_NRADDR_GPR2; /* needed by aix */ 224 225 /* A grows-upwards stack for hidden saves/restores of LR and R2 226 needed for function interception and wrapping on ppc32-aix5. 227 A horrible hack. REDIR_SP points to the highest live entry, 228 and so starts at -1. */ 229 /* 1216 */ UInt guest_REDIR_SP; 230 /* 1220 */ UInt guest_REDIR_STACK[VEX_GUEST_PPC32_REDIR_STACK_SIZE]; 231 232 /* Needed for AIX (but mandated for all guest architectures): 233 CIA at the last SC insn. Used when backing up to restart a 234 syscall that has been interrupted by a signal. */ 235 /* 1348 */ UInt guest_IP_AT_SYSCALL; 236 237 /* SPRG3, which AIUI is readonly in user space. Needed for 238 threading on AIX. */ 239 /* 1352 */ UInt guest_SPRG3_RO; 240 /* 1356 */ UInt padding1; 241 /* 1360 */ ULong guest_TFHAR; // Transaction Failure Handler Address Register 242 /* 1368 */ ULong guest_TEXASR; // Transaction EXception And Summary Register 243 /* 1376 */ ULong guest_TFIAR; // Transaction Failure Instruction Address Register 244 245 /* Padding to make it have an 16-aligned size */ 246 /* 1384 */ UInt padding2; 247 248 } 249 VexGuestPPC32State; 250 251 252 /*---------------------------------------------------------------*/ 253 /*--- Utility functions for PPC32 guest stuff. ---*/ 254 /*---------------------------------------------------------------*/ 255 256 /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */ 257 258 /* Initialise all guest PPC32 state. */ 259 260 extern 261 void LibVEX_GuestPPC32_initialise ( /*OUT*/VexGuestPPC32State* vex_state ); 262 263 264 /* Write the given native %CR value to the supplied VexGuestPPC32State 265 structure. */ 266 extern 267 void LibVEX_GuestPPC32_put_CR ( UInt cr_native, 268 /*OUT*/VexGuestPPC32State* vex_state ); 269 270 /* Extract from the supplied VexGuestPPC32State structure the 271 corresponding native %CR value. */ 272 extern 273 UInt LibVEX_GuestPPC32_get_CR ( /*IN*/const VexGuestPPC32State* vex_state ); 274 275 276 /* Write the given native %XER value to the supplied VexGuestPPC32State 277 structure. */ 278 extern 279 void LibVEX_GuestPPC32_put_XER ( UInt xer_native, 280 /*OUT*/VexGuestPPC32State* vex_state ); 281 282 /* Extract from the supplied VexGuestPPC32State structure the 283 corresponding native %XER value. */ 284 extern 285 UInt LibVEX_GuestPPC32_get_XER ( /*IN*/const VexGuestPPC32State* vex_state ); 286 287 #endif /* ndef __LIBVEX_PUB_GUEST_PPC32_H */ 288 289 290 /*---------------------------------------------------------------*/ 291 /*--- libvex_guest_ppc32.h ---*/ 292 /*---------------------------------------------------------------*/ 293