2 /*---------------------------------------------------------------*/
3 /*--- begin libvex_guest_ppc32.h ---*/
4 /*---------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2004-2017 OpenWorks LLP
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.
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.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
28 Neither the names of the U.S. Department of Energy nor the
29 University of California nor the names of its contributors may be
30 used to endorse or promote products derived from this software
31 without prior written permission.
34 #ifndef __LIBVEX_PUB_GUEST_PPC32_H
35 #define __LIBVEX_PUB_GUEST_PPC32_H
37 #include "libvex_basictypes.h"
40 /*---------------------------------------------------------------*/
41 /*--- Vex's representation of the PPC32 CPU state ---*/
42 /*---------------------------------------------------------------*/
44 #define VEX_GUEST_PPC32_REDIR_STACK_SIZE (16/*entries*/ * 2/*words per entry*/)
48 /* Event check fail addr and counter. */
49 /* 0 */ UInt host_EvC_FAILADDR
;
50 /* 4 */ UInt host_EvC_COUNTER
;
53 /* Add 16 to all the numbers below. Sigh. */
54 /* General Purpose Registers */
55 /* 0 */ UInt guest_GPR0
;
56 /* 4 */ UInt guest_GPR1
;
57 /* 8 */ UInt guest_GPR2
;
58 /* 12 */ UInt guest_GPR3
;
59 /* 16 */ UInt guest_GPR4
;
60 /* 20 */ UInt guest_GPR5
;
61 /* 24 */ UInt guest_GPR6
;
62 /* 28 */ UInt guest_GPR7
;
63 /* 32 */ UInt guest_GPR8
;
64 /* 36 */ UInt guest_GPR9
;
65 /* 40 */ UInt guest_GPR10
;
66 /* 44 */ UInt guest_GPR11
;
67 /* 48 */ UInt guest_GPR12
;
68 /* 52 */ UInt guest_GPR13
;
69 /* 56 */ UInt guest_GPR14
;
70 /* 60 */ UInt guest_GPR15
;
71 /* 64 */ UInt guest_GPR16
;
72 /* 68 */ UInt guest_GPR17
;
73 /* 72 */ UInt guest_GPR18
;
74 /* 76 */ UInt guest_GPR19
;
75 /* 80 */ UInt guest_GPR20
;
76 /* 84 */ UInt guest_GPR21
;
77 /* 88 */ UInt guest_GPR22
;
78 /* 92 */ UInt guest_GPR23
;
79 /* 96 */ UInt guest_GPR24
;
80 /* 100 */ UInt guest_GPR25
;
81 /* 104 */ UInt guest_GPR26
;
82 /* 108 */ UInt guest_GPR27
;
83 /* 112 */ UInt guest_GPR28
;
84 /* 116 */ UInt guest_GPR29
;
85 /* 120 */ UInt guest_GPR30
;
86 /* 124 */ UInt guest_GPR31
;
88 // Vector Registers, Floating Point Registers, and VSX Registers
89 // With ISA 2.06, the "Vector-Scalar Floating-point" category
90 // provides facilities to support vector and scalar binary floating-
91 // point operations. A unified register file is an integral part
92 // of this new facility, combining floating point and vector registers
93 // using a 64x128-bit vector. These are referred to as VSR[0..63].
94 // The floating point registers are now mapped into double word element 0
95 // of VSR[0..31]. The 32x128-bit vector registers defined by the "Vector
96 // Facility [Category: Vector]" are now mapped to VSR[32..63].
98 // IMPORTANT: the user of libvex must place the guest state so as
99 // to ensure that guest_VSR{0..63}, and any shadows thereof, are
102 /* 128 */ U128 guest_VSR0
;
103 /* 144 */ U128 guest_VSR1
;
104 /* 160 */ U128 guest_VSR2
;
105 /* 176 */ U128 guest_VSR3
;
106 /* 192 */ U128 guest_VSR4
;
107 /* 208 */ U128 guest_VSR5
;
108 /* 224 */ U128 guest_VSR6
;
109 /* 240 */ U128 guest_VSR7
;
110 /* 256 */ U128 guest_VSR8
;
111 /* 272 */ U128 guest_VSR9
;
112 /* 288 */ U128 guest_VSR10
;
113 /* 304 */ U128 guest_VSR11
;
114 /* 320 */ U128 guest_VSR12
;
115 /* 336 */ U128 guest_VSR13
;
116 /* 352 */ U128 guest_VSR14
;
117 /* 368 */ U128 guest_VSR15
;
118 /* 384 */ U128 guest_VSR16
;
119 /* 400 */ U128 guest_VSR17
;
120 /* 416 */ U128 guest_VSR18
;
121 /* 432 */ U128 guest_VSR19
;
122 /* 448 */ U128 guest_VSR20
;
123 /* 464 */ U128 guest_VSR21
;
124 /* 480 */ U128 guest_VSR22
;
125 /* 496 */ U128 guest_VSR23
;
126 /* 512 */ U128 guest_VSR24
;
127 /* 528 */ U128 guest_VSR25
;
128 /* 544 */ U128 guest_VSR26
;
129 /* 560 */ U128 guest_VSR27
;
130 /* 576 */ U128 guest_VSR28
;
131 /* 592 */ U128 guest_VSR29
;
132 /* 608 */ U128 guest_VSR30
;
133 /* 624 */ U128 guest_VSR31
;
134 /* 640 */ U128 guest_VSR32
;
135 /* 656 */ U128 guest_VSR33
;
136 /* 672 */ U128 guest_VSR34
;
137 /* 688 */ U128 guest_VSR35
;
138 /* 704 */ U128 guest_VSR36
;
139 /* 720 */ U128 guest_VSR37
;
140 /* 736 */ U128 guest_VSR38
;
141 /* 752 */ U128 guest_VSR39
;
142 /* 768 */ U128 guest_VSR40
;
143 /* 784 */ U128 guest_VSR41
;
144 /* 800 */ U128 guest_VSR42
;
145 /* 816 */ U128 guest_VSR43
;
146 /* 832 */ U128 guest_VSR44
;
147 /* 848 */ U128 guest_VSR45
;
148 /* 864 */ U128 guest_VSR46
;
149 /* 880 */ U128 guest_VSR47
;
150 /* 896 */ U128 guest_VSR48
;
151 /* 912 */ U128 guest_VSR49
;
152 /* 928 */ U128 guest_VSR50
;
153 /* 944 */ U128 guest_VSR51
;
154 /* 960 */ U128 guest_VSR52
;
155 /* 976 */ U128 guest_VSR53
;
156 /* 992 */ U128 guest_VSR54
;
157 /* 1008 */ U128 guest_VSR55
;
158 /* 1024 */ U128 guest_VSR56
;
159 /* 1040 */ U128 guest_VSR57
;
160 /* 1056 */ U128 guest_VSR58
;
161 /* 1072 */ U128 guest_VSR59
;
162 /* 1088 */ U128 guest_VSR60
;
163 /* 1104 */ U128 guest_VSR61
;
164 /* 1120 */ U128 guest_VSR62
;
165 /* 1136 */ U128 guest_VSR63
;
167 /* 1152 */ UInt guest_CIA
; // IP (no arch visible register)
168 /* 1156 */ UInt guest_LR
; // Link Register
169 /* 1160 */ UInt guest_CTR
; // Count Register
172 /* 1164 */ UChar guest_XER_SO
; /* in lsb */
173 /* 1165 */ UChar guest_XER_OV
; /* in lsb */
174 /* 1166 */ UChar guest_XER_OV32
; /* in lsb */
175 /* 1167 */ UChar guest_XER_CA
; /* in lsb */
176 /* 1168 */ UChar guest_XER_CA32
; /* in lsb */
177 /* 1169 */ UChar guest_XER_BC
; /* all bits */
180 /* 1170 */ UChar guest_CR0_321
; /* in [3:1] */
181 /* 1171 */ UChar guest_CR0_0
; /* in lsb */
182 /* 1172 */ UChar guest_CR1_321
; /* in [3:1] */
183 /* 1173 */ UChar guest_CR1_0
; /* in lsb */
184 /* 1174 */ UChar guest_CR2_321
; /* in [3:1] */
185 /* 1175 */ UChar guest_CR2_0
; /* in lsb */
186 /* 1176 */ UChar guest_CR3_321
; /* in [3:1] */
187 /* 1177 */ UChar guest_CR3_0
; /* in lsb */
188 /* 1178 */ UChar guest_CR4_321
; /* in [3:1] */
189 /* 1179 */ UChar guest_CR4_0
; /* in lsb */
190 /* 1180 */ UChar guest_CR5_321
; /* in [3:1] */
191 /* 1181 */ UChar guest_CR5_0
; /* in lsb */
192 /* 1182 */ UChar guest_CR6_321
; /* in [3:1] */
193 /* 1183 */ UChar guest_CR6_0
; /* in lsb */
194 /* 1184 */ UChar guest_CR7_321
; /* in [3:1] */
195 /* 1185 */ UChar guest_CR7_0
; /* in lsb */
197 /* FP Status and Control Register fields. Only rounding mode fields
198 * and Floating-point Condition Code (FPCC) fields in the FPSCR are
201 /* 1186 */ UChar guest_FPROUND
; // Binary Floating Point Rounding Mode
202 /* 1187 */ UChar guest_DFPROUND
; // Decimal Floating Point Rounding Mode
203 /* 1188 */ UChar guest_C_FPCC
; // Floating-Point Result Class Descriptor
204 // and Floating-point Condition Code
205 /* 1189 */ UChar pad0
;
206 /* 1190 */ UChar pad1
;
207 /* 1191 */ UChar pad2
;
209 /* Vector Save/Restore Register */
210 /* 1192 */ UInt guest_VRSAVE
;
212 /* Vector Status and Control Register */
213 /* 1196 */ UInt guest_VSCR
;
215 /* Emulation notes */
216 /* 1200 */ UInt guest_EMNOTE
;
218 /* For icbi: record start and length of area to invalidate */
219 /* 1204 */ UInt guest_CMSTART
;
220 /* 1208 */ UInt guest_CMLEN
;
222 /* Used to record the unredirected guest address at the start of
223 a translation whose start has been redirected. By reading
224 this pseudo-register shortly afterwards, the translation can
225 find out what the corresponding no-redirection address was.
226 Note, this is only set for wrap-style redirects, not for
227 replace-style ones. */
228 /* 1212 */ UInt guest_NRADDR
;
229 /* 1216 */ UInt guest_NRADDR_GPR2
; /* needed by aix */
231 /* A grows-upwards stack for hidden saves/restores of LR and R2
232 needed for function interception and wrapping on ppc32-aix5.
233 A horrible hack. REDIR_SP points to the highest live entry,
234 and so starts at -1. */
235 /* 1220 */ UInt guest_REDIR_SP
;
236 /* 1224 */ UInt guest_REDIR_STACK
[VEX_GUEST_PPC32_REDIR_STACK_SIZE
];
238 /* Needed for Darwin (but mandated for all guest architectures):
239 CIA at the last SC insn. Used when backing up to restart a
240 syscall that has been interrupted by a signal. */
241 /* 134C */ UInt guest_IP_AT_SYSCALL
;
243 /* SPRG3, which AIUI is readonly in user space. Needed for
245 /* 1356 */ UInt guest_SPRG3_RO
;
246 /* 1360 */ UInt padding1
;
247 /* 1364 */ ULong guest_TFHAR
; // Transaction Failure Handler Address Register
248 /* 1372 */ ULong guest_TEXASR
; // Transaction EXception And Summary Register
249 /* 1380 */ ULong guest_TFIAR
; // Transaction Failure Instruction Address Register
250 /* 1388 */ ULong guest_PPR
; // Program Priority register
251 /* 1396 */ UInt guest_TEXASRU
; // Transaction EXception And Summary Register Upper
252 /* 1400 */ UInt guest_PSPB
; // Problem State Priority Boost register
253 /* 1404 */ ULong guest_DSCR
; // Data Stream Control register
255 /* ISA 3.1 Accumulators. There are eight accumulators each contains four
256 128-bit rows. Declare each acculator and row explicitly, then use a
257 helper to map ACC[i][row] to the explicitly declared entry.
258 Technically not supported in 32-bit mode but needs to be defined. */
259 /* 1412 */ U128 guest_ACC_0_r0
;
260 /* 1428 */ U128 guest_ACC_0_r1
;
261 /* 1444 */ U128 guest_ACC_0_r2
;
262 /* 1460 */ U128 guest_ACC_0_r3
;
263 /* 1476 */ U128 guest_ACC_1_r0
;
264 /* 1492 */ U128 guest_ACC_1_r1
;
265 /* 1508 */ U128 guest_ACC_1_r2
;
266 /* 1524 */ U128 guest_ACC_1_r3
;
267 /* 1540 */ U128 guest_ACC_2_r0
;
268 /* 1556 */ U128 guest_ACC_2_r1
;
269 /* 1572 */ U128 guest_ACC_2_r2
;
270 /* 1588 */ U128 guest_ACC_2_r3
;
271 /* 1604 */ U128 guest_ACC_3_r0
;
272 /* 1620 */ U128 guest_ACC_3_r1
;
273 /* 1636 */ U128 guest_ACC_3_r2
;
274 /* 1652 */ U128 guest_ACC_3_r3
;
275 /* 1668 */ U128 guest_ACC_4_r0
;
276 /* 1684 */ U128 guest_ACC_4_r1
;
277 /* 1700 */ U128 guest_ACC_4_r2
;
278 /* 1716 */ U128 guest_ACC_4_r3
;
279 /* 1732 */ U128 guest_ACC_5_r0
;
280 /* 1748 */ U128 guest_ACC_5_r1
;
281 /* 1780 */ U128 guest_ACC_5_r2
;
282 /* 1796 */ U128 guest_ACC_5_r3
;
283 /* 1812 */ U128 guest_ACC_6_r0
;
284 /* 1828 */ U128 guest_ACC_6_r1
;
285 /* 1844 */ U128 guest_ACC_6_r2
;
286 /* 1860 */ U128 guest_ACC_6_r3
;
287 /* 1876 */ U128 guest_ACC_7_r0
;
288 /* 1892 */ U128 guest_ACC_7_r1
;
289 /* 1908 */ U128 guest_ACC_7_r2
;
290 /* 1924 */ U128 guest_ACC_7_r3
;
292 /* Padding to make it have an 16-aligned size */
293 /* 1940 */ UInt guest_syscall_flag
;
294 /* 1944 * UInt padding2; */
299 /*---------------------------------------------------------------*/
300 /*--- Utility functions for PPC32 guest stuff. ---*/
301 /*---------------------------------------------------------------*/
303 /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */
305 /* Initialise all guest PPC32 state. */
308 void LibVEX_GuestPPC32_initialise ( /*OUT*/VexGuestPPC32State
* vex_state
);
311 /* Write the given native %CR value to the supplied VexGuestPPC32State
314 void LibVEX_GuestPPC32_put_CR ( UInt cr_native
,
315 /*OUT*/VexGuestPPC32State
* vex_state
);
317 /* Extract from the supplied VexGuestPPC32State structure the
318 corresponding native %CR value. */
320 UInt
LibVEX_GuestPPC32_get_CR ( /*IN*/const VexGuestPPC32State
* vex_state
);
323 /* Write the given native %XER value to the supplied VexGuestPPC32State
326 void LibVEX_GuestPPC32_put_XER ( UInt xer_native
,
327 /*OUT*/VexGuestPPC32State
* vex_state
);
329 /* Extract from the supplied VexGuestPPC32State structure the
330 corresponding native %XER value. */
332 UInt
LibVEX_GuestPPC32_get_XER ( /*IN*/const VexGuestPPC32State
* vex_state
);
334 #endif /* ndef __LIBVEX_PUB_GUEST_PPC32_H */
337 /*---------------------------------------------------------------*/
338 /*--- libvex_guest_ppc32.h ---*/
339 /*---------------------------------------------------------------*/