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 | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame^] | 10 | Copyright (C) 2004-2010 OpenWorks LLP |
| 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" |
| 40 | #include "libvex_emwarn.h" |
| 41 | |
| 42 | |
| 43 | /*---------------------------------------------------------------*/ |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 44 | /*--- Vex's representation of the PPC32 CPU state ---*/ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 45 | /*---------------------------------------------------------------*/ |
| 46 | |
sewardj | aca070a | 2006-10-17 00:28:22 +0000 | [diff] [blame] | 47 | #define VEX_GUEST_PPC32_REDIR_STACK_SIZE (16/*entries*/ * 2/*words per entry*/) |
| 48 | |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 49 | typedef |
| 50 | struct { |
cerion | 4e9083c | 2005-03-03 05:29:17 +0000 | [diff] [blame] | 51 | /* General Purpose Registers */ |
| 52 | /* 0 */ UInt guest_GPR0; |
| 53 | /* 4 */ UInt guest_GPR1; |
| 54 | /* 8 */ UInt guest_GPR2; |
| 55 | /* 12 */ UInt guest_GPR3; |
| 56 | /* 16 */ UInt guest_GPR4; |
| 57 | /* 20 */ UInt guest_GPR5; |
| 58 | /* 24 */ UInt guest_GPR6; |
| 59 | /* 28 */ UInt guest_GPR7; |
| 60 | /* 32 */ UInt guest_GPR8; |
| 61 | /* 36 */ UInt guest_GPR9; |
| 62 | /* 40 */ UInt guest_GPR10; |
| 63 | /* 44 */ UInt guest_GPR11; |
| 64 | /* 48 */ UInt guest_GPR12; |
| 65 | /* 52 */ UInt guest_GPR13; |
| 66 | /* 56 */ UInt guest_GPR14; |
| 67 | /* 60 */ UInt guest_GPR15; |
| 68 | /* 64 */ UInt guest_GPR16; |
| 69 | /* 68 */ UInt guest_GPR17; |
| 70 | /* 72 */ UInt guest_GPR18; |
| 71 | /* 76 */ UInt guest_GPR19; |
| 72 | /* 80 */ UInt guest_GPR20; |
| 73 | /* 84 */ UInt guest_GPR21; |
| 74 | /* 88 */ UInt guest_GPR22; |
| 75 | /* 92 */ UInt guest_GPR23; |
| 76 | /* 96 */ UInt guest_GPR24; |
| 77 | /* 100 */ UInt guest_GPR25; |
| 78 | /* 104 */ UInt guest_GPR26; |
| 79 | /* 108 */ UInt guest_GPR27; |
| 80 | /* 112 */ UInt guest_GPR28; |
| 81 | /* 116 */ UInt guest_GPR29; |
| 82 | /* 120 */ UInt guest_GPR30; |
| 83 | /* 124 */ UInt guest_GPR31; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 84 | |
cerion | 98d105a | 2005-02-04 16:13:58 +0000 | [diff] [blame] | 85 | // Floating Point Registers |
cerion | 4e9083c | 2005-03-03 05:29:17 +0000 | [diff] [blame] | 86 | /* 128 */ ULong guest_FPR0; |
| 87 | /* 136 */ ULong guest_FPR1; |
| 88 | /* 144 */ ULong guest_FPR2; |
| 89 | /* 152 */ ULong guest_FPR3; |
| 90 | /* 160 */ ULong guest_FPR4; |
| 91 | /* 168 */ ULong guest_FPR5; |
| 92 | /* 176 */ ULong guest_FPR6; |
| 93 | /* 184 */ ULong guest_FPR7; |
| 94 | /* 192 */ ULong guest_FPR8; |
| 95 | /* 200 */ ULong guest_FPR9; |
| 96 | /* 208 */ ULong guest_FPR10; |
| 97 | /* 216 */ ULong guest_FPR11; |
| 98 | /* 224 */ ULong guest_FPR12; |
| 99 | /* 232 */ ULong guest_FPR13; |
| 100 | /* 240 */ ULong guest_FPR14; |
| 101 | /* 248 */ ULong guest_FPR15; |
| 102 | /* 256 */ ULong guest_FPR16; |
| 103 | /* 264 */ ULong guest_FPR17; |
| 104 | /* 272 */ ULong guest_FPR18; |
| 105 | /* 280 */ ULong guest_FPR19; |
| 106 | /* 288 */ ULong guest_FPR20; |
| 107 | /* 296 */ ULong guest_FPR21; |
| 108 | /* 304 */ ULong guest_FPR22; |
| 109 | /* 312 */ ULong guest_FPR23; |
| 110 | /* 320 */ ULong guest_FPR24; |
| 111 | /* 328 */ ULong guest_FPR25; |
| 112 | /* 336 */ ULong guest_FPR26; |
| 113 | /* 344 */ ULong guest_FPR27; |
| 114 | /* 352 */ ULong guest_FPR28; |
| 115 | /* 360 */ ULong guest_FPR29; |
| 116 | /* 368 */ ULong guest_FPR30; |
| 117 | /* 376 */ ULong guest_FPR31; |
cerion | 98d105a | 2005-02-04 16:13:58 +0000 | [diff] [blame] | 118 | |
cerion | 6529aff | 2005-06-28 17:30:56 +0000 | [diff] [blame] | 119 | // Vector Registers |
sewardj | 478646f | 2008-05-01 20:13:04 +0000 | [diff] [blame] | 120 | // IMPORTANT: the user of libvex must place the guest state so as |
| 121 | // to ensure that guest_VR{0..31}, and any shadows thereof, are |
| 122 | // 16-aligned. |
| 123 | /* 384 */ U128 guest_VR0; |
| 124 | /* 400 */ U128 guest_VR1; |
| 125 | /* 416 */ U128 guest_VR2; |
| 126 | /* 432 */ U128 guest_VR3; |
| 127 | /* 448 */ U128 guest_VR4; |
| 128 | /* 464 */ U128 guest_VR5; |
| 129 | /* 480 */ U128 guest_VR6; |
| 130 | /* 496 */ U128 guest_VR7; |
| 131 | /* 512 */ U128 guest_VR8; |
| 132 | /* 528 */ U128 guest_VR9; |
| 133 | /* 544 */ U128 guest_VR10; |
| 134 | /* 560 */ U128 guest_VR11; |
| 135 | /* 576 */ U128 guest_VR12; |
| 136 | /* 592 */ U128 guest_VR13; |
| 137 | /* 608 */ U128 guest_VR14; |
| 138 | /* 624 */ U128 guest_VR15; |
| 139 | /* 640 */ U128 guest_VR16; |
| 140 | /* 656 */ U128 guest_VR17; |
| 141 | /* 672 */ U128 guest_VR18; |
| 142 | /* 688 */ U128 guest_VR19; |
| 143 | /* 704 */ U128 guest_VR20; |
| 144 | /* 720 */ U128 guest_VR21; |
| 145 | /* 736 */ U128 guest_VR22; |
| 146 | /* 752 */ U128 guest_VR23; |
| 147 | /* 768 */ U128 guest_VR24; |
| 148 | /* 784 */ U128 guest_VR25; |
| 149 | /* 800 */ U128 guest_VR26; |
| 150 | /* 816 */ U128 guest_VR27; |
| 151 | /* 832 */ U128 guest_VR28; |
| 152 | /* 848 */ U128 guest_VR29; |
| 153 | /* 864 */ U128 guest_VR30; |
| 154 | /* 880 */ U128 guest_VR31; |
cerion | 6529aff | 2005-06-28 17:30:56 +0000 | [diff] [blame] | 155 | |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 156 | /* 896 */ UInt guest_CIA; // IP (no arch visible register) |
| 157 | /* 900 */ UInt guest_LR; // Link Register |
| 158 | /* 904 */ UInt guest_CTR; // Count Register |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 159 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 160 | /* XER pieces */ |
| 161 | /* 908 */ UChar guest_XER_SO; /* in lsb */ |
| 162 | /* 909 */ UChar guest_XER_OV; /* in lsb */ |
| 163 | /* 910 */ UChar guest_XER_CA; /* in lsb */ |
| 164 | /* 911 */ UChar guest_XER_BC; /* all bits */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 165 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 166 | /* CR pieces */ |
| 167 | /* 912 */ UChar guest_CR0_321; /* in [3:1] */ |
| 168 | /* 913 */ UChar guest_CR0_0; /* in lsb */ |
| 169 | /* 914 */ UChar guest_CR1_321; /* in [3:1] */ |
| 170 | /* 915 */ UChar guest_CR1_0; /* in lsb */ |
| 171 | /* 916 */ UChar guest_CR2_321; /* in [3:1] */ |
| 172 | /* 917 */ UChar guest_CR2_0; /* in lsb */ |
| 173 | /* 918 */ UChar guest_CR3_321; /* in [3:1] */ |
| 174 | /* 919 */ UChar guest_CR3_0; /* in lsb */ |
| 175 | /* 920 */ UChar guest_CR4_321; /* in [3:1] */ |
| 176 | /* 921 */ UChar guest_CR4_0; /* in lsb */ |
| 177 | /* 922 */ UChar guest_CR5_321; /* in [3:1] */ |
| 178 | /* 923 */ UChar guest_CR5_0; /* in lsb */ |
| 179 | /* 924 */ UChar guest_CR6_321; /* in [3:1] */ |
| 180 | /* 925 */ UChar guest_CR6_0; /* in lsb */ |
| 181 | /* 926 */ UChar guest_CR7_321; /* in [3:1] */ |
| 182 | /* 927 */ UChar guest_CR7_0; /* in lsb */ |
cerion | e77ce01 | 2005-01-25 16:56:18 +0000 | [diff] [blame] | 183 | |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 184 | /* FP Status & Control Register fields */ |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 185 | /* 928 */ UInt guest_FPROUND; // FP Rounding Mode |
cerion | 6529aff | 2005-06-28 17:30:56 +0000 | [diff] [blame] | 186 | |
| 187 | /* Vector Save/Restore Register */ |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 188 | /* 932 */ UInt guest_VRSAVE; |
cerion | 6529aff | 2005-06-28 17:30:56 +0000 | [diff] [blame] | 189 | |
| 190 | /* Vector Status and Control Register */ |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 191 | /* 936 */ UInt guest_VSCR; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 192 | |
| 193 | /* Emulation warnings */ |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 194 | /* 940 */ UInt guest_EMWARN; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 195 | |
sewardj | ce02aa7 | 2006-01-12 12:27:58 +0000 | [diff] [blame] | 196 | /* For icbi: record start and length of area to invalidate */ |
sewardj | e9d8a26 | 2009-07-01 08:06:34 +0000 | [diff] [blame] | 197 | /* 944 */ UInt guest_TISTART; |
| 198 | /* 948 */ UInt guest_TILEN; |
sewardj | ce02aa7 | 2006-01-12 12:27:58 +0000 | [diff] [blame] | 199 | |
| 200 | /* Used to record the unredirected guest address at the start of |
| 201 | a translation whose start has been redirected. By reading |
| 202 | this pseudo-register shortly afterwards, the translation can |
| 203 | find out what the corresponding no-redirection address was. |
| 204 | Note, this is only set for wrap-style redirects, not for |
| 205 | replace-style ones. */ |
sewardj | e9d8a26 | 2009-07-01 08:06:34 +0000 | [diff] [blame] | 206 | /* 952 */ UInt guest_NRADDR; |
| 207 | /* 956 */ UInt guest_NRADDR_GPR2; /* needed by aix */ |
sewardj | aca070a | 2006-10-17 00:28:22 +0000 | [diff] [blame] | 208 | |
| 209 | /* A grows-upwards stack for hidden saves/restores of LR and R2 |
| 210 | needed for function interception and wrapping on ppc32-aix5. |
| 211 | A horrible hack. REDIR_SP points to the highest live entry, |
| 212 | and so starts at -1. */ |
sewardj | e9d8a26 | 2009-07-01 08:06:34 +0000 | [diff] [blame] | 213 | /* 960 */ UInt guest_REDIR_SP; |
| 214 | /* 964 */ UInt guest_REDIR_STACK[VEX_GUEST_PPC32_REDIR_STACK_SIZE]; |
sewardj | aca070a | 2006-10-17 00:28:22 +0000 | [diff] [blame] | 215 | |
sewardj | e86310f | 2009-03-19 22:21:40 +0000 | [diff] [blame] | 216 | /* Needed for AIX (but mandated for all guest architectures): |
| 217 | CIA at the last SC insn. Used when backing up to restart a |
| 218 | syscall that has been interrupted by a signal. */ |
| 219 | /* ??? */ UInt guest_IP_AT_SYSCALL; |
sewardj | aca070a | 2006-10-17 00:28:22 +0000 | [diff] [blame] | 220 | |
| 221 | /* SPRG3, which AIUI is readonly in user space. Needed for |
| 222 | threading on AIX. */ |
| 223 | /* ??? */ UInt guest_SPRG3_RO; |
sewardj | 7787af4 | 2005-08-04 18:32:19 +0000 | [diff] [blame] | 224 | |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 225 | /* Padding to make it have an 8-aligned size */ |
sewardj | aca070a | 2006-10-17 00:28:22 +0000 | [diff] [blame] | 226 | /* UInt padding; */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 227 | } |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 228 | VexGuestPPC32State; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 229 | |
| 230 | |
| 231 | /*---------------------------------------------------------------*/ |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 232 | /*--- Utility functions for PPC32 guest stuff. ---*/ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 233 | /*---------------------------------------------------------------*/ |
| 234 | |
| 235 | /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */ |
| 236 | |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 237 | /* Initialise all guest PPC32 state. */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 238 | |
| 239 | extern |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 240 | void LibVEX_GuestPPC32_initialise ( /*OUT*/VexGuestPPC32State* vex_state ); |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 241 | |
cerion | 900f6b5 | 2005-07-08 13:34:47 +0000 | [diff] [blame] | 242 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 243 | /* Write the given native %CR value to the supplied VexGuestPPC32State |
| 244 | structure. */ |
cerion | 900f6b5 | 2005-07-08 13:34:47 +0000 | [diff] [blame] | 245 | extern |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 246 | void LibVEX_GuestPPC32_put_CR ( UInt cr_native, |
cerion | 900f6b5 | 2005-07-08 13:34:47 +0000 | [diff] [blame] | 247 | /*OUT*/VexGuestPPC32State* vex_state ); |
| 248 | |
cerion | ed623db | 2005-06-20 12:42:04 +0000 | [diff] [blame] | 249 | /* Extract from the supplied VexGuestPPC32State structure the |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 250 | corresponding native %CR value. */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 251 | extern |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 252 | UInt LibVEX_GuestPPC32_get_CR ( /*IN*/VexGuestPPC32State* vex_state ); |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 253 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 254 | |
| 255 | /* Write the given native %XER value to the supplied VexGuestPPC32State |
| 256 | structure. */ |
cerion | 51900a2 | 2005-07-08 13:10:35 +0000 | [diff] [blame] | 257 | extern |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 258 | void LibVEX_GuestPPC32_put_XER ( UInt xer_native, |
| 259 | /*OUT*/VexGuestPPC32State* vex_state ); |
| 260 | |
| 261 | /* Extract from the supplied VexGuestPPC32State structure the |
| 262 | corresponding native %XER value. */ |
| 263 | extern |
| 264 | UInt LibVEX_GuestPPC32_get_XER ( /*IN*/VexGuestPPC32State* vex_state ); |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 265 | |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 266 | #endif /* ndef __LIBVEX_PUB_GUEST_PPC32_H */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 267 | |
| 268 | |
| 269 | /*---------------------------------------------------------------*/ |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 270 | /*--- libvex_guest_ppc32.h ---*/ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 271 | /*---------------------------------------------------------------*/ |