blob: 33533198756f62eaf585cd8ea8621283fa659887 [file] [log] [blame]
cerion896a1372005-01-25 12:24:25 +00001
2/*---------------------------------------------------------------*/
sewardj752f9062010-05-03 21:38:49 +00003/*--- begin libvex_guest_ppc32.h ---*/
cerion896a1372005-01-25 12:24:25 +00004/*---------------------------------------------------------------*/
5
6/*
sewardj752f9062010-05-03 21:38:49 +00007 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
cerion896a1372005-01-25 12:24:25 +00009
sewardj752f9062010-05-03 21:38:49 +000010 Copyright (C) 2004-2010 OpenWorks LLP
11 info@open-works.net
cerion896a1372005-01-25 12:24:25 +000012
sewardj752f9062010-05-03 21:38:49 +000013 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.
cerion896a1372005-01-25 12:24:25 +000017
sewardj752f9062010-05-03 21:38:49 +000018 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
sewardj7bd6ffe2005-08-03 16:07:36 +000026 02110-1301, USA.
27
sewardj752f9062010-05-03 21:38:49 +000028 The GNU General Public License is contained in the file COPYING.
cerion896a1372005-01-25 12:24:25 +000029
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.
cerion896a1372005-01-25 12:24:25 +000034*/
35
cerion1515db92005-01-25 17:21:23 +000036#ifndef __LIBVEX_PUB_GUEST_PPC32_H
37#define __LIBVEX_PUB_GUEST_PPC32_H
cerion896a1372005-01-25 12:24:25 +000038
39#include "libvex_basictypes.h"
40#include "libvex_emwarn.h"
41
42
43/*---------------------------------------------------------------*/
cerion1515db92005-01-25 17:21:23 +000044/*--- Vex's representation of the PPC32 CPU state ---*/
cerion896a1372005-01-25 12:24:25 +000045/*---------------------------------------------------------------*/
46
sewardjaca070a2006-10-17 00:28:22 +000047#define VEX_GUEST_PPC32_REDIR_STACK_SIZE (16/*entries*/ * 2/*words per entry*/)
48
cerion896a1372005-01-25 12:24:25 +000049typedef
50 struct {
cerion4e9083c2005-03-03 05:29:17 +000051 /* 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;
cerion896a1372005-01-25 12:24:25 +000084
cerion98d105a2005-02-04 16:13:58 +000085 // Floating Point Registers
cerion4e9083c2005-03-03 05:29:17 +000086 /* 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;
cerion98d105a2005-02-04 16:13:58 +0000118
cerion6529aff2005-06-28 17:30:56 +0000119 // Vector Registers
sewardj478646f2008-05-01 20:13:04 +0000120 // 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;
cerion6529aff2005-06-28 17:30:56 +0000155
cerionb66dfa32005-07-01 18:41:01 +0000156 /* 896 */ UInt guest_CIA; // IP (no arch visible register)
157 /* 900 */ UInt guest_LR; // Link Register
158 /* 904 */ UInt guest_CTR; // Count Register
cerion896a1372005-01-25 12:24:25 +0000159
sewardjb51f0f42005-07-18 11:38:02 +0000160 /* 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 */
cerion896a1372005-01-25 12:24:25 +0000165
sewardjb51f0f42005-07-18 11:38:02 +0000166 /* 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 */
cerione77ce012005-01-25 16:56:18 +0000183
cerion094d1392005-06-20 13:45:57 +0000184 /* FP Status & Control Register fields */
sewardjb51f0f42005-07-18 11:38:02 +0000185 /* 928 */ UInt guest_FPROUND; // FP Rounding Mode
cerion6529aff2005-06-28 17:30:56 +0000186
187 /* Vector Save/Restore Register */
cerionb66dfa32005-07-01 18:41:01 +0000188 /* 932 */ UInt guest_VRSAVE;
cerion6529aff2005-06-28 17:30:56 +0000189
190 /* Vector Status and Control Register */
cerionb66dfa32005-07-01 18:41:01 +0000191 /* 936 */ UInt guest_VSCR;
cerion896a1372005-01-25 12:24:25 +0000192
193 /* Emulation warnings */
cerionb66dfa32005-07-01 18:41:01 +0000194 /* 940 */ UInt guest_EMWARN;
cerion896a1372005-01-25 12:24:25 +0000195
sewardjce02aa72006-01-12 12:27:58 +0000196 /* For icbi: record start and length of area to invalidate */
sewardje9d8a262009-07-01 08:06:34 +0000197 /* 944 */ UInt guest_TISTART;
198 /* 948 */ UInt guest_TILEN;
sewardjce02aa72006-01-12 12:27:58 +0000199
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. */
sewardje9d8a262009-07-01 08:06:34 +0000206 /* 952 */ UInt guest_NRADDR;
207 /* 956 */ UInt guest_NRADDR_GPR2; /* needed by aix */
sewardjaca070a2006-10-17 00:28:22 +0000208
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. */
sewardje9d8a262009-07-01 08:06:34 +0000213 /* 960 */ UInt guest_REDIR_SP;
214 /* 964 */ UInt guest_REDIR_STACK[VEX_GUEST_PPC32_REDIR_STACK_SIZE];
sewardjaca070a2006-10-17 00:28:22 +0000215
sewardje86310f2009-03-19 22:21:40 +0000216 /* 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;
sewardjaca070a2006-10-17 00:28:22 +0000220
221 /* SPRG3, which AIUI is readonly in user space. Needed for
222 threading on AIX. */
223 /* ??? */ UInt guest_SPRG3_RO;
sewardj7787af42005-08-04 18:32:19 +0000224
cerion896a1372005-01-25 12:24:25 +0000225 /* Padding to make it have an 8-aligned size */
sewardjaca070a2006-10-17 00:28:22 +0000226 /* UInt padding; */
cerion896a1372005-01-25 12:24:25 +0000227 }
cerion1515db92005-01-25 17:21:23 +0000228 VexGuestPPC32State;
cerion896a1372005-01-25 12:24:25 +0000229
230
231/*---------------------------------------------------------------*/
cerion1515db92005-01-25 17:21:23 +0000232/*--- Utility functions for PPC32 guest stuff. ---*/
cerion896a1372005-01-25 12:24:25 +0000233/*---------------------------------------------------------------*/
234
235/* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */
236
cerion1515db92005-01-25 17:21:23 +0000237/* Initialise all guest PPC32 state. */
cerion896a1372005-01-25 12:24:25 +0000238
239extern
cerion1515db92005-01-25 17:21:23 +0000240void LibVEX_GuestPPC32_initialise ( /*OUT*/VexGuestPPC32State* vex_state );
cerion896a1372005-01-25 12:24:25 +0000241
cerion900f6b52005-07-08 13:34:47 +0000242
sewardjb51f0f42005-07-18 11:38:02 +0000243/* Write the given native %CR value to the supplied VexGuestPPC32State
244 structure. */
cerion900f6b52005-07-08 13:34:47 +0000245extern
sewardjb51f0f42005-07-18 11:38:02 +0000246void LibVEX_GuestPPC32_put_CR ( UInt cr_native,
cerion900f6b52005-07-08 13:34:47 +0000247 /*OUT*/VexGuestPPC32State* vex_state );
248
cerioned623db2005-06-20 12:42:04 +0000249/* Extract from the supplied VexGuestPPC32State structure the
sewardjb51f0f42005-07-18 11:38:02 +0000250 corresponding native %CR value. */
cerion896a1372005-01-25 12:24:25 +0000251extern
sewardjb51f0f42005-07-18 11:38:02 +0000252UInt LibVEX_GuestPPC32_get_CR ( /*IN*/VexGuestPPC32State* vex_state );
cerion896a1372005-01-25 12:24:25 +0000253
sewardjb51f0f42005-07-18 11:38:02 +0000254
255/* Write the given native %XER value to the supplied VexGuestPPC32State
256 structure. */
cerion51900a22005-07-08 13:10:35 +0000257extern
sewardjb51f0f42005-07-18 11:38:02 +0000258void 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. */
263extern
264UInt LibVEX_GuestPPC32_get_XER ( /*IN*/VexGuestPPC32State* vex_state );
cerion896a1372005-01-25 12:24:25 +0000265
cerion1515db92005-01-25 17:21:23 +0000266#endif /* ndef __LIBVEX_PUB_GUEST_PPC32_H */
cerion896a1372005-01-25 12:24:25 +0000267
268
269/*---------------------------------------------------------------*/
cerion1515db92005-01-25 17:21:23 +0000270/*--- libvex_guest_ppc32.h ---*/
cerion896a1372005-01-25 12:24:25 +0000271/*---------------------------------------------------------------*/