]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/valgrind/src/valgrind-3.6.0-svn/VEX/pub/libvex_guest_ppc64.h
update
[l4.git] / l4 / pkg / valgrind / src / valgrind-3.6.0-svn / VEX / pub / libvex_guest_ppc64.h
1
2 /*---------------------------------------------------------------*/
3 /*--- begin                              libvex_guest_ppc64.h ---*/
4 /*---------------------------------------------------------------*/
5
6 /*
7    This file is part of Valgrind, a dynamic binary instrumentation
8    framework.
9
10    Copyright (C) 2004-2010 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_PPC64_H
37 #define __LIBVEX_PUB_GUEST_PPC64_H
38
39 #include "libvex_basictypes.h"
40 #include "libvex_emwarn.h"
41
42 /*
43     volatile ==  caller-saved (not preserved across function calls)
44 non-volatile ==  callee-saved (preserved across function calls)
45
46 r0        Volatile register used in function prologs
47 r1        Stack frame pointer
48 r2        TOC pointer
49 r3        Volatile parameter and return value register
50 r4-r10    Volatile registers used for function parameters
51 r11       Volatile register used in calls by pointer and as an
52           environment pointer for languages which require one
53 r12       Volatile register used for exception handling and glink code
54 r13       Reserved for use as system thread ID
55 r14-r31   Nonvolatile registers used for local variables
56
57 f0        Volatile scratch register
58 f1-f4     Volatile floating point parameter and return value registers
59 f5-f13    Volatile floating point parameter registers
60 f14-f31   Nonvolatile registers
61
62 LR        Link register (volatile)
63 CTR       Loop counter register (volatile)
64 XER       Fixed point exception register (volatile)
65 FPSCR     Floating point status and control register (volatile)
66
67 CR0-CR1   Volatile condition code register fields
68 CR2-CR4   Nonvolatile condition code register fields
69 CR5-CR7   Volatile condition code register fields
70
71 On processors with the VMX feature.
72
73 v0-v1     Volatile scratch registers
74 v2-v13    Volatile vector parameters registers
75 v14-v19   Volatile scratch registers
76 v20-v31   Non-volatile registers
77 vrsave    Non-volatile 32-bit register
78 */
79
80
81 /*---------------------------------------------------------------*/
82 /*--- Vex's representation of the PPC64 CPU state             ---*/
83 /*---------------------------------------------------------------*/
84
85 #define VEX_GUEST_PPC64_REDIR_STACK_SIZE (16/*entries*/ * 2/*words per entry*/)
86
87 typedef
88    struct {
89       /* General Purpose Registers */
90       /*   0 */ ULong guest_GPR0;
91       /*   8 */ ULong guest_GPR1;
92       /*  16 */ ULong guest_GPR2;
93       /*  24 */ ULong guest_GPR3;
94       /*  32 */ ULong guest_GPR4;
95       /*  40 */ ULong guest_GPR5;
96       /*  48 */ ULong guest_GPR6;
97       /*  56 */ ULong guest_GPR7;
98       /*  64 */ ULong guest_GPR8;
99       /*  72 */ ULong guest_GPR9;
100       /*  80 */ ULong guest_GPR10;
101       /*  88 */ ULong guest_GPR11;
102       /*  96 */ ULong guest_GPR12;
103       /* 104 */ ULong guest_GPR13;
104       /* 112 */ ULong guest_GPR14;
105       /* 120 */ ULong guest_GPR15;
106       /* 128 */ ULong guest_GPR16;
107       /* 136 */ ULong guest_GPR17;
108       /* 144 */ ULong guest_GPR18;
109       /* 152 */ ULong guest_GPR19;
110       /* 160 */ ULong guest_GPR20;
111       /* 168 */ ULong guest_GPR21;
112       /* 176 */ ULong guest_GPR22;
113       /* 184 */ ULong guest_GPR23;
114       /* 192 */ ULong guest_GPR24;
115       /* 200 */ ULong guest_GPR25;
116       /* 208 */ ULong guest_GPR26;
117       /* 216 */ ULong guest_GPR27;
118       /* 224 */ ULong guest_GPR28;
119       /* 232 */ ULong guest_GPR29;
120       /* 240 */ ULong guest_GPR30;
121       /* 248 */ ULong guest_GPR31;
122
123       // Vector Registers, Floating Point Registers, and VSX Registers
124       // With ISA 2.06, the "Vector-Scalar Floating-point" category
125       // provides facilities to support vector and scalar binary floating-
126       // point operations.  A unified register file is an integral part
127       // of this new facility, combining floating point and vector registers
128       // using a 64x128-bit vector.  These are referred to as VSR[0..63].
129       // The floating point registers are now mapped into double word element 0
130       // of VSR[0..31]. The 32x128-bit vector registers defined by the "Vector
131       // Facility [Category: Vector]" are now mapped to VSR[32..63].
132
133       // IMPORTANT: the user of libvex must place the guest state so as
134       // to ensure that guest_VSR{0..63}, and any shadows thereof, are
135       // 16-aligned.
136
137       /*  256 */ U128 guest_VSR0;
138       /*  272 */ U128 guest_VSR1;
139       /*  288 */ U128 guest_VSR2;
140       /*  304 */ U128 guest_VSR3;
141       /*  320 */ U128 guest_VSR4;
142       /*  336 */ U128 guest_VSR5;
143       /*  352 */ U128 guest_VSR6;
144       /*  368 */ U128 guest_VSR7;
145       /*  384 */ U128 guest_VSR8;
146       /*  400 */ U128 guest_VSR9;
147       /*  416 */ U128 guest_VSR10;
148       /*  432 */ U128 guest_VSR11;
149       /*  448 */ U128 guest_VSR12;
150       /*  464 */ U128 guest_VSR13;
151       /*  480 */ U128 guest_VSR14;
152       /*  496 */ U128 guest_VSR15;
153       /*  512 */ U128 guest_VSR16;
154       /*  528 */ U128 guest_VSR17;
155       /*  544 */ U128 guest_VSR18;
156       /*  560 */ U128 guest_VSR19;
157       /*  576 */ U128 guest_VSR20;
158       /*  592 */ U128 guest_VSR21;
159       /*  608 */ U128 guest_VSR22;
160       /*  624 */ U128 guest_VSR23;
161       /*  640 */ U128 guest_VSR24;
162       /*  656 */ U128 guest_VSR25;
163       /*  672 */ U128 guest_VSR26;
164       /*  688 */ U128 guest_VSR27;
165       /*  704 */ U128 guest_VSR28;
166       /*  720 */ U128 guest_VSR29;
167       /*  736 */ U128 guest_VSR30;
168       /*  752 */ U128 guest_VSR31;
169       /*  768 */ U128 guest_VSR32;
170       /*  784 */ U128 guest_VSR33;
171       /*  800 */ U128 guest_VSR34;
172       /*  816 */ U128 guest_VSR35;
173       /*  832 */ U128 guest_VSR36;
174       /*  848 */ U128 guest_VSR37;
175       /*  864 */ U128 guest_VSR38;
176       /*  880 */ U128 guest_VSR39;
177       /*  896 */ U128 guest_VSR40;
178       /*  912 */ U128 guest_VSR41;
179       /*  928 */ U128 guest_VSR42;
180       /*  944 */ U128 guest_VSR43;
181       /*  960 */ U128 guest_VSR44;
182       /*  976 */ U128 guest_VSR45;
183       /*  992 */ U128 guest_VSR46;
184       /* 1008 */ U128 guest_VSR47;
185       /* 1024 */ U128 guest_VSR48;
186       /* 1040 */ U128 guest_VSR49;
187       /* 1056 */ U128 guest_VSR50;
188       /* 1072 */ U128 guest_VSR51;
189       /* 1088 */ U128 guest_VSR52;
190       /* 1104 */ U128 guest_VSR53;
191       /* 1120 */ U128 guest_VSR54;
192       /* 1136 */ U128 guest_VSR55;
193       /* 1152 */ U128 guest_VSR56;
194       /* 1168 */ U128 guest_VSR57;
195       /* 1184 */ U128 guest_VSR58;
196       /* 1200 */ U128 guest_VSR59;
197       /* 1216 */ U128 guest_VSR60;
198       /* 1232 */ U128 guest_VSR61;
199       /* 1248 */ U128 guest_VSR62;
200       /* 1264 */ U128 guest_VSR63;
201
202       /* 1280 */ ULong guest_CIA;    // IP (no arch visible register)
203       /* 1288 */ ULong guest_LR;     // Link Register
204       /* 1296 */ ULong guest_CTR;    // Count Register
205
206       /* XER pieces */
207       /* 1304 */ UChar guest_XER_SO; /* in lsb */
208       /* 1305 */ UChar guest_XER_OV; /* in lsb */
209       /* 1306 */ UChar guest_XER_CA; /* in lsb */
210       /* 1307 */ UChar guest_XER_BC; /* all bits */
211
212       /* CR pieces */
213       /* 1308 */ UChar guest_CR0_321; /* in [3:1] */
214       /* 1309 */ UChar guest_CR0_0;   /* in lsb */
215       /* 1310 */ UChar guest_CR1_321; /* in [3:1] */
216       /* 1311 */ UChar guest_CR1_0;   /* in lsb */
217       /* 1312 */ UChar guest_CR2_321; /* in [3:1] */
218       /* 1313 */ UChar guest_CR2_0;   /* in lsb */
219       /* 1314 */ UChar guest_CR3_321; /* in [3:1] */
220       /* 1315 */ UChar guest_CR3_0;   /* in lsb */
221       /* 1316 */ UChar guest_CR4_321; /* in [3:1] */
222       /* 1317 */ UChar guest_CR4_0;   /* in lsb */
223       /* 1318 */ UChar guest_CR5_321; /* in [3:1] */
224       /* 1319 */ UChar guest_CR5_0;   /* in lsb */
225       /* 1320 */ UChar guest_CR6_321; /* in [3:1] */
226       /* 1321 */ UChar guest_CR6_0;   /* in lsb */
227       /* 1322 */ UChar guest_CR7_321; /* in [3:1] */
228       /* 1323 */ UChar guest_CR7_0;   /* in lsb */
229
230       /* FP Status & Control Register fields */
231       /* 1324 */ UInt guest_FPROUND; // FP Rounding Mode
232
233       /* Vector Save/Restore Register */
234       /* 1328 */ UInt guest_VRSAVE;
235
236       /* Vector Status and Control Register */
237       /* 1332 */ UInt guest_VSCR;
238
239       /* Emulation warnings */
240       /* 1336 */ UInt guest_EMWARN;
241
242       /* gcc adds 4 bytes padding here: pre-empt it. */
243       /* 1340 */ UInt  padding;
244
245       /* For icbi: record start and length of area to invalidate */
246       /* 1344 */ ULong guest_TISTART;
247       /* 1352 */ ULong guest_TILEN;
248
249       /* Used to record the unredirected guest address at the start of
250          a translation whose start has been redirected.  By reading
251          this pseudo-register shortly afterwards, the translation can
252          find out what the corresponding no-redirection address was.
253          Note, this is only set for wrap-style redirects, not for
254          replace-style ones. */
255       /* 1360 */ ULong guest_NRADDR;
256       /* 1368 */ ULong guest_NRADDR_GPR2;
257
258      /* A grows-upwards stack for hidden saves/restores of LR and R2
259         needed for function interception and wrapping on ppc64-linux.
260         A horrible hack.  REDIR_SP points to the highest live entry,
261         and so starts at -1. */
262       /* 1376 */ ULong guest_REDIR_SP;
263       /* 1384 */ ULong guest_REDIR_STACK[VEX_GUEST_PPC64_REDIR_STACK_SIZE];
264
265       /* Needed for AIX: CIA at the last SC insn.  Used when backing up
266          to restart a syscall that has been interrupted by a signal. */
267       /* 1640 */ ULong guest_IP_AT_SYSCALL;
268
269       /* SPRG3, which AIUI is readonly in user space.  Needed for
270          threading on AIX. */
271       /* 1648 */ ULong guest_SPRG3_RO;
272
273       /* Padding to make it have an 16-aligned size */
274       /* 1656 */ ULong padding2;
275    }
276    VexGuestPPC64State;
277
278
279 /*---------------------------------------------------------------*/
280 /*--- Utility functions for PPC64 guest stuff.                ---*/
281 /*---------------------------------------------------------------*/
282
283 /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */
284
285 /* Initialise all guest PPC64 state. */
286 extern
287 void LibVEX_GuestPPC64_initialise ( /*OUT*/VexGuestPPC64State* vex_state );
288
289
290 /* Write the given native %CR value to the supplied VexGuestPPC64State
291    structure.  Note, %CR is 32-bits even for ppc64. */
292 extern
293 void LibVEX_GuestPPC64_put_CR ( UInt cr_native,
294                                 /*OUT*/VexGuestPPC64State* vex_state );
295
296 /* Extract from the supplied VexGuestPPC64State structure the
297    corresponding native %CR value.  Note, %CR is 32-bits even for
298    ppc64. */
299 extern
300 UInt LibVEX_GuestPPC64_get_CR ( /*IN*/VexGuestPPC64State* vex_state );
301
302
303 /* Write the given native %XER value to the supplied
304    VexGuestPPC64State structure.  Note, %XER is 32-bits even for
305    ppc64. */
306 extern
307 void LibVEX_GuestPPC64_put_XER ( UInt xer_native,
308                                  /*OUT*/VexGuestPPC64State* vex_state );
309
310 /* Extract from the supplied VexGuestPPC64State structure the
311    corresponding native %XER value.  Note, %CR is 32-bits even for
312    ppc64. */
313 extern
314 UInt LibVEX_GuestPPC64_get_XER ( /*IN*/VexGuestPPC64State* vex_state );
315
316 #endif /* ndef __LIBVEX_PUB_GUEST_PPC64_H */
317
318
319 /*---------------------------------------------------------------*/
320 /*---                                    libvex_guest_ppc64.h ---*/
321 /*---------------------------------------------------------------*/