• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-2017 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_OV32; /* in lsb */
177       /* 1167 */ UChar guest_XER_CA; /* in lsb */
178       /* 1168 */ UChar guest_XER_CA32; /* in lsb */
179       /* 1169 */ UChar guest_XER_BC; /* all bits */
180 
181       /* CR pieces */
182       /* 1170 */ UChar guest_CR0_321; /* in [3:1] */
183       /* 1171 */ UChar guest_CR0_0;   /* in lsb */
184       /* 1172 */ UChar guest_CR1_321; /* in [3:1] */
185       /* 1173 */ UChar guest_CR1_0;   /* in lsb */
186       /* 1174 */ UChar guest_CR2_321; /* in [3:1] */
187       /* 1175 */ UChar guest_CR2_0;   /* in lsb */
188       /* 1176 */ UChar guest_CR3_321; /* in [3:1] */
189       /* 1177 */ UChar guest_CR3_0;   /* in lsb */
190       /* 1178 */ UChar guest_CR4_321; /* in [3:1] */
191       /* 1179 */ UChar guest_CR4_0;   /* in lsb */
192       /* 1180 */ UChar guest_CR5_321; /* in [3:1] */
193       /* 1181 */ UChar guest_CR5_0;   /* in lsb */
194       /* 1182 */ UChar guest_CR6_321; /* in [3:1] */
195       /* 1183 */ UChar guest_CR6_0;   /* in lsb */
196       /* 1184 */ UChar guest_CR7_321; /* in [3:1] */
197       /* 1185 */ UChar guest_CR7_0;   /* in lsb */
198 
199       /* FP Status and  Control Register fields. Only rounding mode fields
200        * and Floating-point Condition Code (FPCC) fields in the FPSCR are
201        * supported.
202        */
203       /* 1186 */ UChar guest_FPROUND; // Binary Floating Point Rounding Mode
204       /* 1187 */ UChar guest_DFPROUND; // Decimal Floating Point Rounding Mode
205       /* 1188 */ UChar guest_C_FPCC;   // Floating-Point Result Class Descriptor
206                                        // and Floating-point Condition Code
207       /* 1189 */ UChar pad0;
208       /* 1190 */ UChar pad1;
209       /* 1191 */ UChar pad2;
210 
211       /* Vector Save/Restore Register */
212       /* 1192 */ UInt guest_VRSAVE;
213 
214       /* Vector Status and Control Register */
215       /* 1196 */ UInt guest_VSCR;
216 
217       /* Emulation notes */
218       /* 1200 */ UInt guest_EMNOTE;
219 
220       /* For icbi: record start and length of area to invalidate */
221       /* 1204 */ UInt guest_CMSTART;
222       /* 1208 */ UInt guest_CMLEN;
223 
224       /* Used to record the unredirected guest address at the start of
225          a translation whose start has been redirected.  By reading
226          this pseudo-register shortly afterwards, the translation can
227          find out what the corresponding no-redirection address was.
228          Note, this is only set for wrap-style redirects, not for
229          replace-style ones. */
230       /* 1212 */ UInt guest_NRADDR;
231       /* 1216 */ UInt guest_NRADDR_GPR2; /* needed by aix */
232 
233      /* A grows-upwards stack for hidden saves/restores of LR and R2
234         needed for function interception and wrapping on ppc32-aix5.
235         A horrible hack.  REDIR_SP points to the highest live entry,
236         and so starts at -1. */
237       /* 1220 */ UInt guest_REDIR_SP;
238       /* 1224 */ UInt guest_REDIR_STACK[VEX_GUEST_PPC32_REDIR_STACK_SIZE];
239 
240       /* Needed for Darwin (but mandated for all guest architectures):
241          CIA at the last SC insn.  Used when backing up to restart a
242          syscall that has been interrupted by a signal. */
243       /* 134C */ UInt guest_IP_AT_SYSCALL;
244 
245       /* SPRG3, which AIUI is readonly in user space.  Needed for
246          threading on AIX. */
247       /* 1356 */ UInt guest_SPRG3_RO;
248       /* 1360 */ UInt  padding1;
249       /* 1364 */ ULong guest_TFHAR;     // Transaction Failure Handler Address Register
250       /* 1372 */ ULong guest_TEXASR;    // Transaction EXception And Summary Register
251       /* 1380 */ ULong guest_TFIAR;     // Transaction Failure Instruction Address Register
252       /* 1388 */ ULong guest_PPR;       // Program Priority register
253       /* 1396 */ UInt  guest_TEXASRU;   // Transaction EXception And Summary Register Upper
254       /* 1400 */ UInt  guest_PSPB;      // Problem State Priority Boost register
255       /* Padding to make it have an 16-aligned size */
256       /* 1404 */ UInt  padding2;
257       /* 1408 */ UInt  padding3;
258       /* 1412 */ UInt  padding4;
259    }
260    VexGuestPPC32State;
261 
262 
263 /*---------------------------------------------------------------*/
264 /*--- Utility functions for PPC32 guest stuff.                ---*/
265 /*---------------------------------------------------------------*/
266 
267 /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */
268 
269 /* Initialise all guest PPC32 state. */
270 
271 extern
272 void LibVEX_GuestPPC32_initialise ( /*OUT*/VexGuestPPC32State* vex_state );
273 
274 
275 /* Write the given native %CR value to the supplied VexGuestPPC32State
276    structure. */
277 extern
278 void LibVEX_GuestPPC32_put_CR ( UInt cr_native,
279                                 /*OUT*/VexGuestPPC32State* vex_state );
280 
281 /* Extract from the supplied VexGuestPPC32State structure the
282    corresponding native %CR value. */
283 extern
284 UInt LibVEX_GuestPPC32_get_CR ( /*IN*/const VexGuestPPC32State* vex_state );
285 
286 
287 /* Write the given native %XER value to the supplied VexGuestPPC32State
288    structure. */
289 extern
290 void LibVEX_GuestPPC32_put_XER ( UInt xer_native,
291                                  /*OUT*/VexGuestPPC32State* vex_state );
292 
293 /* Extract from the supplied VexGuestPPC32State structure the
294    corresponding native %XER value. */
295 extern
296 UInt LibVEX_GuestPPC32_get_XER ( /*IN*/const VexGuestPPC32State* vex_state );
297 
298 #endif /* ndef __LIBVEX_PUB_GUEST_PPC32_H */
299 
300 
301 /*---------------------------------------------------------------*/
302 /*---                                    libvex_guest_ppc32.h ---*/
303 /*---------------------------------------------------------------*/
304