cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 1 | |
| 2 | /*---------------------------------------------------------------*/ |
| 3 | /*--- ---*/ |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 4 | /*--- This file (libvex_guest_ppc32.h) is ---*/ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 5 | /*--- Copyright (c) 2005 OpenWorks LLP. All rights reserved. ---*/ |
| 6 | /*--- ---*/ |
| 7 | /*---------------------------------------------------------------*/ |
| 8 | |
| 9 | /* |
| 10 | This file is part of LibVEX, a library for dynamic binary |
| 11 | instrumentation and translation. |
| 12 | |
| 13 | Copyright (C) 2005 OpenWorks, LLP. |
| 14 | |
| 15 | This program is free software; you can redistribute it and/or modify |
| 16 | it under the terms of the GNU General Public License as published by |
| 17 | the Free Software Foundation; Version 2 dated June 1991 of the |
| 18 | license. |
| 19 | |
| 20 | This program is distributed in the hope that it will be useful, |
| 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or liability |
| 23 | for damages. See the GNU General Public License for more details. |
| 24 | |
| 25 | Neither the names of the U.S. Department of Energy nor the |
| 26 | University of California nor the names of its contributors may be |
| 27 | used to endorse or promote products derived from this software |
| 28 | without prior written permission. |
| 29 | |
| 30 | You should have received a copy of the GNU General Public License |
| 31 | along with this program; if not, write to the Free Software |
| 32 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 33 | USA. |
| 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 | |
| 47 | typedef |
| 48 | struct { |
cerion | 4e9083c | 2005-03-03 05:29:17 +0000 | [diff] [blame] | 49 | /* General Purpose Registers */ |
| 50 | /* 0 */ UInt guest_GPR0; |
| 51 | /* 4 */ UInt guest_GPR1; |
| 52 | /* 8 */ UInt guest_GPR2; |
| 53 | /* 12 */ UInt guest_GPR3; |
| 54 | /* 16 */ UInt guest_GPR4; |
| 55 | /* 20 */ UInt guest_GPR5; |
| 56 | /* 24 */ UInt guest_GPR6; |
| 57 | /* 28 */ UInt guest_GPR7; |
| 58 | /* 32 */ UInt guest_GPR8; |
| 59 | /* 36 */ UInt guest_GPR9; |
| 60 | /* 40 */ UInt guest_GPR10; |
| 61 | /* 44 */ UInt guest_GPR11; |
| 62 | /* 48 */ UInt guest_GPR12; |
| 63 | /* 52 */ UInt guest_GPR13; |
| 64 | /* 56 */ UInt guest_GPR14; |
| 65 | /* 60 */ UInt guest_GPR15; |
| 66 | /* 64 */ UInt guest_GPR16; |
| 67 | /* 68 */ UInt guest_GPR17; |
| 68 | /* 72 */ UInt guest_GPR18; |
| 69 | /* 76 */ UInt guest_GPR19; |
| 70 | /* 80 */ UInt guest_GPR20; |
| 71 | /* 84 */ UInt guest_GPR21; |
| 72 | /* 88 */ UInt guest_GPR22; |
| 73 | /* 92 */ UInt guest_GPR23; |
| 74 | /* 96 */ UInt guest_GPR24; |
| 75 | /* 100 */ UInt guest_GPR25; |
| 76 | /* 104 */ UInt guest_GPR26; |
| 77 | /* 108 */ UInt guest_GPR27; |
| 78 | /* 112 */ UInt guest_GPR28; |
| 79 | /* 116 */ UInt guest_GPR29; |
| 80 | /* 120 */ UInt guest_GPR30; |
| 81 | /* 124 */ UInt guest_GPR31; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 82 | |
cerion | 98d105a | 2005-02-04 16:13:58 +0000 | [diff] [blame] | 83 | // Floating Point Registers |
cerion | 4e9083c | 2005-03-03 05:29:17 +0000 | [diff] [blame] | 84 | /* 128 */ ULong guest_FPR0; |
| 85 | /* 136 */ ULong guest_FPR1; |
| 86 | /* 144 */ ULong guest_FPR2; |
| 87 | /* 152 */ ULong guest_FPR3; |
| 88 | /* 160 */ ULong guest_FPR4; |
| 89 | /* 168 */ ULong guest_FPR5; |
| 90 | /* 176 */ ULong guest_FPR6; |
| 91 | /* 184 */ ULong guest_FPR7; |
| 92 | /* 192 */ ULong guest_FPR8; |
| 93 | /* 200 */ ULong guest_FPR9; |
| 94 | /* 208 */ ULong guest_FPR10; |
| 95 | /* 216 */ ULong guest_FPR11; |
| 96 | /* 224 */ ULong guest_FPR12; |
| 97 | /* 232 */ ULong guest_FPR13; |
| 98 | /* 240 */ ULong guest_FPR14; |
| 99 | /* 248 */ ULong guest_FPR15; |
| 100 | /* 256 */ ULong guest_FPR16; |
| 101 | /* 264 */ ULong guest_FPR17; |
| 102 | /* 272 */ ULong guest_FPR18; |
| 103 | /* 280 */ ULong guest_FPR19; |
| 104 | /* 288 */ ULong guest_FPR20; |
| 105 | /* 296 */ ULong guest_FPR21; |
| 106 | /* 304 */ ULong guest_FPR22; |
| 107 | /* 312 */ ULong guest_FPR23; |
| 108 | /* 320 */ ULong guest_FPR24; |
| 109 | /* 328 */ ULong guest_FPR25; |
| 110 | /* 336 */ ULong guest_FPR26; |
| 111 | /* 344 */ ULong guest_FPR27; |
| 112 | /* 352 */ ULong guest_FPR28; |
| 113 | /* 360 */ ULong guest_FPR29; |
| 114 | /* 368 */ ULong guest_FPR30; |
| 115 | /* 376 */ ULong guest_FPR31; |
cerion | 98d105a | 2005-02-04 16:13:58 +0000 | [diff] [blame] | 116 | |
cerion | 6529aff | 2005-06-28 17:30:56 +0000 | [diff] [blame] | 117 | // Vector Registers |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 118 | /* 384 */ U128 guest_VR0; |
| 119 | /* 400 */ U128 guest_VR1; |
| 120 | /* 416 */ U128 guest_VR2; |
| 121 | /* 432 */ U128 guest_VR3; |
| 122 | /* 448 */ U128 guest_VR4; |
| 123 | /* 464 */ U128 guest_VR5; |
| 124 | /* 480 */ U128 guest_VR6; |
| 125 | /* 496 */ U128 guest_VR7; |
| 126 | /* 512 */ U128 guest_VR8; |
| 127 | /* 528 */ U128 guest_VR9; |
| 128 | /* 544 */ U128 guest_VR10; |
| 129 | /* 560 */ U128 guest_VR11; |
| 130 | /* 576 */ U128 guest_VR12; |
| 131 | /* 592 */ U128 guest_VR13; |
| 132 | /* 608 */ U128 guest_VR14; |
| 133 | /* 624 */ U128 guest_VR15; |
| 134 | /* 640 */ U128 guest_VR16; |
| 135 | /* 656 */ U128 guest_VR17; |
| 136 | /* 672 */ U128 guest_VR18; |
| 137 | /* 688 */ U128 guest_VR19; |
| 138 | /* 704 */ U128 guest_VR20; |
| 139 | /* 720 */ U128 guest_VR21; |
| 140 | /* 736 */ U128 guest_VR22; |
| 141 | /* 752 */ U128 guest_VR23; |
| 142 | /* 768 */ U128 guest_VR24; |
| 143 | /* 784 */ U128 guest_VR25; |
| 144 | /* 800 */ U128 guest_VR26; |
| 145 | /* 816 */ U128 guest_VR27; |
| 146 | /* 832 */ U128 guest_VR28; |
| 147 | /* 848 */ U128 guest_VR29; |
| 148 | /* 864 */ U128 guest_VR30; |
| 149 | /* 880 */ U128 guest_VR31; |
cerion | 6529aff | 2005-06-28 17:30:56 +0000 | [diff] [blame] | 150 | |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 151 | /* 896 */ UInt guest_CIA; // IP (no arch visible register) |
| 152 | /* 900 */ UInt guest_LR; // Link Register |
| 153 | /* 904 */ UInt guest_CTR; // Count Register |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 154 | |
cerion | bcc1f04 | 2005-02-08 11:12:02 +0000 | [diff] [blame] | 155 | /* CR[7]: thunk used to calculate these flags. */ |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 156 | /* 908 */ UInt guest_CC_OP; |
| 157 | /* 912 */ UInt guest_CC_DEP1; |
| 158 | /* 916 */ UInt guest_CC_DEP2; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 159 | |
cerion | bcc1f04 | 2005-02-08 11:12:02 +0000 | [diff] [blame] | 160 | // CR[0:6]: Used for 'compare' ops |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 161 | /* 920 */ UInt guest_CR0to6; |
cerion | e77ce01 | 2005-01-25 16:56:18 +0000 | [diff] [blame] | 162 | |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 163 | /* FP Status & Control Register fields */ |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 164 | /* 924 */ UInt guest_FPROUND; // FP Rounding Mode |
cerion | 98d105a | 2005-02-04 16:13:58 +0000 | [diff] [blame] | 165 | |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 166 | /* 928 */ UInt guest_XER; // XER Register |
cerion | 6529aff | 2005-06-28 17:30:56 +0000 | [diff] [blame] | 167 | |
| 168 | /* Vector Save/Restore Register */ |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 169 | /* 932 */ UInt guest_VRSAVE; |
cerion | 6529aff | 2005-06-28 17:30:56 +0000 | [diff] [blame] | 170 | |
| 171 | /* Vector Status and Control Register */ |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 172 | /* 936 */ UInt guest_VSCR; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 173 | |
| 174 | /* Emulation warnings */ |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 175 | /* 940 */ UInt guest_EMWARN; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 176 | |
sewardj | 7ce9d15 | 2005-03-15 16:54:13 +0000 | [diff] [blame] | 177 | /* For icbi: record start and length of area to invalidate */ |
cerion | b66dfa3 | 2005-07-01 18:41:01 +0000 | [diff] [blame] | 178 | /* 944 */ UInt guest_TISTART; |
| 179 | /* 948 */ UInt guest_TILEN; |
sewardj | 7ce9d15 | 2005-03-15 16:54:13 +0000 | [diff] [blame] | 180 | |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 181 | /* Padding to make it have an 8-aligned size */ |
cerion | e9d361a | 2005-03-04 17:35:29 +0000 | [diff] [blame] | 182 | /* UInt padding; */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 183 | } |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 184 | VexGuestPPC32State; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 185 | |
| 186 | |
| 187 | /*---------------------------------------------------------------*/ |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 188 | /*--- Utility functions for PPC32 guest stuff. ---*/ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 189 | /*---------------------------------------------------------------*/ |
| 190 | |
| 191 | /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */ |
| 192 | |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 193 | /* Initialise all guest PPC32 state. */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 194 | |
| 195 | extern |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 196 | void LibVEX_GuestPPC32_initialise ( /*OUT*/VexGuestPPC32State* vex_state ); |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 197 | |
cerion | 900f6b5 | 2005-07-08 13:34:47 +0000 | [diff] [blame^] | 198 | /* Write the given native %cr7 value to the supplied |
| 199 | VexGuestPPC32State structure */ |
| 200 | extern |
| 201 | void LibVEX_GuestPPC32_put_cr7 ( UInt cr7_native, |
| 202 | /*OUT*/VexGuestPPC32State* vex_state ); |
| 203 | |
| 204 | /* Ditto, but for entire %cr */ |
| 205 | extern |
| 206 | void LibVEX_GuestPPC32_put_cr ( UInt cr_native, |
| 207 | /*OUT*/VexGuestPPC32State* vex_state ); |
| 208 | |
cerion | ed623db | 2005-06-20 12:42:04 +0000 | [diff] [blame] | 209 | /* Extract from the supplied VexGuestPPC32State structure the |
| 210 | corresponding native %cr7 value. */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 211 | extern |
cerion | ed623db | 2005-06-20 12:42:04 +0000 | [diff] [blame] | 212 | UInt LibVEX_GuestPPC32_get_cr7 ( /*IN*/VexGuestPPC32State* vex_state ); |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 213 | |
cerion | 51900a2 | 2005-07-08 13:10:35 +0000 | [diff] [blame] | 214 | /* Ditto, but for entire %cr */ |
| 215 | extern |
| 216 | UInt LibVEX_GuestPPC32_get_cr ( /*IN*/VexGuestPPC32State* vex_state ); |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 217 | |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 218 | #endif /* ndef __LIBVEX_PUB_GUEST_PPC32_H */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 219 | |
| 220 | |
| 221 | /*---------------------------------------------------------------*/ |
cerion | 1515db9 | 2005-01-25 17:21:23 +0000 | [diff] [blame] | 222 | /*--- libvex_guest_ppc32.h ---*/ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 223 | /*---------------------------------------------------------------*/ |