cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 1 | |
| 2 | /*---------------------------------------------------------------*/ |
sewardj | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame] | 3 | /*--- begin libvex_guest_ppc32.h ---*/ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 4 | /*---------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
sewardj | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame] | 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 9 | |
sewardj | 25e5473 | 2012-08-05 15:36:51 +0000 | [diff] [blame] | 10 | Copyright (C) 2004-2012 OpenWorks LLP |
sewardj | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame] | 11 | info@open-works.net |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 12 | |
sewardj | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame] | 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. |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 17 | |
sewardj | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame] | 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 |
sewardj | 7bd6ffe | 2005-08-03 16:07:36 +0000 | [diff] [blame] | 26 | 02110-1301, USA. |
| 27 | |
sewardj | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame] | 28 | The GNU General Public License is contained in the file COPYING. |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 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. |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 34 | */ |
| 35 | |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 36 | #ifndef __LIBVEX_PUB_GUEST_PPC32_H |
| 37 | #define __LIBVEX_PUB_GUEST_PPC32_H |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 38 | |
| 39 | #include "libvex_basictypes.h" |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 40 | |
| 41 | |
| 42 | /*---------------------------------------------------------------*/ |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 43 | /*--- Vex's representation of the PPC32 CPU state ---*/ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 44 | /*---------------------------------------------------------------*/ |
| 45 | |
sewardj | aca070a | 2006-10-17 00:28:22 +0000 | [diff] [blame] | 46 | #define VEX_GUEST_PPC32_REDIR_STACK_SIZE (16/*entries*/ * 2/*words per entry*/) |
| 47 | |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 48 | typedef |
| 49 | struct { |
sewardj | 3dee849 | 2012-04-20 00:13:28 +0000 | [diff] [blame] | 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. */ |
cerion | 4e9083c | 2005-03-03 05:29:17 +0000 | [diff] [blame] | 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; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 89 | |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 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]. |
cerion | 98d105a | 2005-02-04 16:13:58 +0000 | [diff] [blame] | 99 | |
sewardj | 478646f | 2008-05-01 20:13:04 +0000 | [diff] [blame] | 100 | // IMPORTANT: the user of libvex must place the guest state so as |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 101 | // to ensure that guest_VSR{0..63}, and any shadows thereof, are |
sewardj | 478646f | 2008-05-01 20:13:04 +0000 | [diff] [blame] | 102 | // 16-aligned. |
cerion | 6529aff | 2005-06-28 17:30:56 +0000 | [diff] [blame] | 103 | |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 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 |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 172 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 173 | /* XER pieces */ |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 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 */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 178 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 179 | /* CR pieces */ |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 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 */ |
cerion | e77ce01 | 2005-01-25 16:56:18 +0000 | [diff] [blame] | 196 | |
sewardj | c6bbd47 | 2012-04-02 10:20:48 +0000 | [diff] [blame] | 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; |
cerion | 6529aff | 2005-06-28 17:30:56 +0000 | [diff] [blame] | 202 | |
| 203 | /* Vector Save/Restore Register */ |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 204 | /* 1188 */ UInt guest_VRSAVE; |
cerion | 6529aff | 2005-06-28 17:30:56 +0000 | [diff] [blame] | 205 | |
| 206 | /* Vector Status and Control Register */ |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 207 | /* 1192 */ UInt guest_VSCR; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 208 | |
florian | 6ef84be | 2012-08-26 03:20:07 +0000 | [diff] [blame] | 209 | /* Emulation notes */ |
| 210 | /* 1196 */ UInt guest_EMNOTE; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 211 | |
sewardj | ce02aa7 | 2006-01-12 12:27:58 +0000 | [diff] [blame] | 212 | /* For icbi: record start and length of area to invalidate */ |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 213 | /* 1200 */ UInt guest_TISTART; |
| 214 | /* 1204 */ UInt guest_TILEN; |
sewardj | ce02aa7 | 2006-01-12 12:27:58 +0000 | [diff] [blame] | 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. */ |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 222 | /* 1208 */ UInt guest_NRADDR; |
| 223 | /* 1212 */ UInt guest_NRADDR_GPR2; /* needed by aix */ |
sewardj | aca070a | 2006-10-17 00:28:22 +0000 | [diff] [blame] | 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. */ |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 229 | /* 1216 */ UInt guest_REDIR_SP; |
| 230 | /* 1220 */ UInt guest_REDIR_STACK[VEX_GUEST_PPC32_REDIR_STACK_SIZE]; |
sewardj | aca070a | 2006-10-17 00:28:22 +0000 | [diff] [blame] | 231 | |
sewardj | e86310f | 2009-03-19 22:21:40 +0000 | [diff] [blame] | 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. */ |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 235 | /* 1348 */ UInt guest_IP_AT_SYSCALL; |
sewardj | aca070a | 2006-10-17 00:28:22 +0000 | [diff] [blame] | 236 | |
| 237 | /* SPRG3, which AIUI is readonly in user space. Needed for |
| 238 | threading on AIX. */ |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 239 | /* 1352 */ UInt guest_SPRG3_RO; |
sewardj | 7787af4 | 2005-08-04 18:32:19 +0000 | [diff] [blame] | 240 | |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 241 | /* Padding to make it have an 8-aligned size */ |
sewardj | 66d5ef2 | 2011-04-15 11:55:00 +0000 | [diff] [blame] | 242 | /* 1356 */ UInt padding; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 243 | } |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 244 | VexGuestPPC32State; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 245 | |
| 246 | |
| 247 | /*---------------------------------------------------------------*/ |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 248 | /*--- Utility functions for PPC32 guest stuff. ---*/ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 249 | /*---------------------------------------------------------------*/ |
| 250 | |
| 251 | /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */ |
| 252 | |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 253 | /* Initialise all guest PPC32 state. */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 254 | |
| 255 | extern |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 256 | void LibVEX_GuestPPC32_initialise ( /*OUT*/VexGuestPPC32State* vex_state ); |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 257 | |
cerion | 900f6b5 | 2005-07-08 13:34:47 +0000 | [diff] [blame] | 258 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 259 | /* Write the given native %CR value to the supplied VexGuestPPC32State |
| 260 | structure. */ |
cerion | 900f6b5 | 2005-07-08 13:34:47 +0000 | [diff] [blame] | 261 | extern |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 262 | void LibVEX_GuestPPC32_put_CR ( UInt cr_native, |
cerion | 900f6b5 | 2005-07-08 13:34:47 +0000 | [diff] [blame] | 263 | /*OUT*/VexGuestPPC32State* vex_state ); |
| 264 | |
cerion | ed623db | 2005-06-20 12:42:04 +0000 | [diff] [blame] | 265 | /* Extract from the supplied VexGuestPPC32State structure the |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 266 | corresponding native %CR value. */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 267 | extern |
florian | efa834a | 2012-11-24 21:07:14 +0000 | [diff] [blame] | 268 | UInt LibVEX_GuestPPC32_get_CR ( /*IN*/const VexGuestPPC32State* vex_state ); |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 269 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 270 | |
| 271 | /* Write the given native %XER value to the supplied VexGuestPPC32State |
| 272 | structure. */ |
cerion | 51900a2 | 2005-07-08 13:10:35 +0000 | [diff] [blame] | 273 | extern |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 274 | void LibVEX_GuestPPC32_put_XER ( UInt xer_native, |
| 275 | /*OUT*/VexGuestPPC32State* vex_state ); |
| 276 | |
| 277 | /* Extract from the supplied VexGuestPPC32State structure the |
| 278 | corresponding native %XER value. */ |
| 279 | extern |
florian | efa834a | 2012-11-24 21:07:14 +0000 | [diff] [blame] | 280 | UInt LibVEX_GuestPPC32_get_XER ( /*IN*/const VexGuestPPC32State* vex_state ); |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 281 | |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 282 | #endif /* ndef __LIBVEX_PUB_GUEST_PPC32_H */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 283 | |
| 284 | |
| 285 | /*---------------------------------------------------------------*/ |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 286 | /*--- libvex_guest_ppc32.h ---*/ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 287 | /*---------------------------------------------------------------*/ |