blob: 37f25989707f7f1cf8064e72f997b19cb2e5d050 [file] [log] [blame]
cerion896a1372005-01-25 12:24:25 +00001
2/*---------------------------------------------------------------*/
3/*--- ---*/
cerion1515db92005-01-25 17:21:23 +00004/*--- This file (libvex_guest_ppc32.h) is ---*/
cerion896a1372005-01-25 12:24:25 +00005/*--- 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
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
47typedef
48 struct {
cerion4e9083c2005-03-03 05:29:17 +000049 /* 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;
cerion896a1372005-01-25 12:24:25 +000082
cerion98d105a2005-02-04 16:13:58 +000083 // Floating Point Registers
cerion4e9083c2005-03-03 05:29:17 +000084 /* 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;
cerion98d105a2005-02-04 16:13:58 +0000116
cerion6529aff2005-06-28 17:30:56 +0000117 // Vector Registers
cerionb66dfa32005-07-01 18:41:01 +0000118 /* 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;
cerion6529aff2005-06-28 17:30:56 +0000150
cerionb66dfa32005-07-01 18:41:01 +0000151 /* 896 */ UInt guest_CIA; // IP (no arch visible register)
152 /* 900 */ UInt guest_LR; // Link Register
153 /* 904 */ UInt guest_CTR; // Count Register
cerion896a1372005-01-25 12:24:25 +0000154
cerionbcc1f042005-02-08 11:12:02 +0000155 /* CR[7]: thunk used to calculate these flags. */
cerionb66dfa32005-07-01 18:41:01 +0000156 /* 908 */ UInt guest_CC_OP;
157 /* 912 */ UInt guest_CC_DEP1;
158 /* 916 */ UInt guest_CC_DEP2;
cerion896a1372005-01-25 12:24:25 +0000159
cerionbcc1f042005-02-08 11:12:02 +0000160 // CR[0:6]: Used for 'compare' ops
cerionb66dfa32005-07-01 18:41:01 +0000161 /* 920 */ UInt guest_CR0to6;
cerione77ce012005-01-25 16:56:18 +0000162
cerion094d1392005-06-20 13:45:57 +0000163 /* FP Status & Control Register fields */
cerionb66dfa32005-07-01 18:41:01 +0000164 /* 924 */ UInt guest_FPROUND; // FP Rounding Mode
cerion98d105a2005-02-04 16:13:58 +0000165
cerionb66dfa32005-07-01 18:41:01 +0000166 /* 928 */ UInt guest_XER; // XER Register
cerion6529aff2005-06-28 17:30:56 +0000167
168 /* Vector Save/Restore Register */
cerionb66dfa32005-07-01 18:41:01 +0000169 /* 932 */ UInt guest_VRSAVE;
cerion6529aff2005-06-28 17:30:56 +0000170
171 /* Vector Status and Control Register */
cerionb66dfa32005-07-01 18:41:01 +0000172 /* 936 */ UInt guest_VSCR;
cerion896a1372005-01-25 12:24:25 +0000173
174 /* Emulation warnings */
cerionb66dfa32005-07-01 18:41:01 +0000175 /* 940 */ UInt guest_EMWARN;
cerion896a1372005-01-25 12:24:25 +0000176
sewardj7ce9d152005-03-15 16:54:13 +0000177 /* For icbi: record start and length of area to invalidate */
cerionb66dfa32005-07-01 18:41:01 +0000178 /* 944 */ UInt guest_TISTART;
179 /* 948 */ UInt guest_TILEN;
sewardj7ce9d152005-03-15 16:54:13 +0000180
cerion896a1372005-01-25 12:24:25 +0000181 /* Padding to make it have an 8-aligned size */
cerione9d361a2005-03-04 17:35:29 +0000182 /* UInt padding; */
cerion896a1372005-01-25 12:24:25 +0000183 }
cerion1515db92005-01-25 17:21:23 +0000184 VexGuestPPC32State;
cerion896a1372005-01-25 12:24:25 +0000185
186
187/*---------------------------------------------------------------*/
cerion1515db92005-01-25 17:21:23 +0000188/*--- Utility functions for PPC32 guest stuff. ---*/
cerion896a1372005-01-25 12:24:25 +0000189/*---------------------------------------------------------------*/
190
191/* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */
192
cerion1515db92005-01-25 17:21:23 +0000193/* Initialise all guest PPC32 state. */
cerion896a1372005-01-25 12:24:25 +0000194
195extern
cerion1515db92005-01-25 17:21:23 +0000196void LibVEX_GuestPPC32_initialise ( /*OUT*/VexGuestPPC32State* vex_state );
cerion896a1372005-01-25 12:24:25 +0000197
cerion900f6b52005-07-08 13:34:47 +0000198/* Write the given native %cr7 value to the supplied
199 VexGuestPPC32State structure */
200extern
201void LibVEX_GuestPPC32_put_cr7 ( UInt cr7_native,
202 /*OUT*/VexGuestPPC32State* vex_state );
203
204/* Ditto, but for entire %cr */
205extern
206void LibVEX_GuestPPC32_put_cr ( UInt cr_native,
207 /*OUT*/VexGuestPPC32State* vex_state );
208
cerioned623db2005-06-20 12:42:04 +0000209/* Extract from the supplied VexGuestPPC32State structure the
210 corresponding native %cr7 value. */
cerion896a1372005-01-25 12:24:25 +0000211extern
cerioned623db2005-06-20 12:42:04 +0000212UInt LibVEX_GuestPPC32_get_cr7 ( /*IN*/VexGuestPPC32State* vex_state );
cerion896a1372005-01-25 12:24:25 +0000213
cerion51900a22005-07-08 13:10:35 +0000214/* Ditto, but for entire %cr */
215extern
216UInt LibVEX_GuestPPC32_get_cr ( /*IN*/VexGuestPPC32State* vex_state );
cerion896a1372005-01-25 12:24:25 +0000217
cerion1515db92005-01-25 17:21:23 +0000218#endif /* ndef __LIBVEX_PUB_GUEST_PPC32_H */
cerion896a1372005-01-25 12:24:25 +0000219
220
221/*---------------------------------------------------------------*/
cerion1515db92005-01-25 17:21:23 +0000222/*--- libvex_guest_ppc32.h ---*/
cerion896a1372005-01-25 12:24:25 +0000223/*---------------------------------------------------------------*/