blob: bbd4ea02040b2aeba6556370e58b9b0f76e18222 [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 {
49 // General Purpose Registers
50 UInt guest_GPR0;
51 UInt guest_GPR1;
52 UInt guest_GPR2;
53 UInt guest_GPR3;
54 UInt guest_GPR4;
55 UInt guest_GPR5;
56 UInt guest_GPR6;
57 UInt guest_GPR7;
58 UInt guest_GPR8;
59 UInt guest_GPR9;
60 UInt guest_GPR10;
61 UInt guest_GPR11;
62 UInt guest_GPR12;
63 UInt guest_GPR13;
64 UInt guest_GPR14;
65 UInt guest_GPR15;
66 UInt guest_GPR16;
67 UInt guest_GPR17;
68 UInt guest_GPR18;
69 UInt guest_GPR19;
70 UInt guest_GPR20;
71 UInt guest_GPR21;
72 UInt guest_GPR22;
73 UInt guest_GPR23;
74 UInt guest_GPR24;
75 UInt guest_GPR25;
76 UInt guest_GPR26;
77 UInt guest_GPR27;
78 UInt guest_GPR28;
79 UInt guest_GPR29;
80 UInt guest_GPR30;
81 UInt guest_GPR31;
82
cerione77ce012005-01-25 16:56:18 +000083 UInt guest_CIA; // Current Instruction Address (no architecturally visible register)
cerion896a1372005-01-25 12:24:25 +000084 UInt guest_LR; // Link Register
85 UInt guest_CTR; // Count Register
86
cerione77ce012005-01-25 16:56:18 +000087 /* CR0: Use last result for delayed calc of CR0[0,1,2] (neg,pos,zero)
88 (bit3 is just a redundant copy of XER_SO) */
cerion896a1372005-01-25 12:24:25 +000089 UInt guest_Result; // Result of last op
90
cerione77ce012005-01-25 16:56:18 +000091 // CR1: Used for FP - don't need yet.
92 // CR2:7: Used for 'compare' instructions
93 UChar guest_CR2;
94 UChar guest_CR3;
95 UChar guest_CR4;
96 UChar guest_CR5;
97 UChar guest_CR6;
98 UChar guest_CR7;
99
100 /* XER */
101 UChar guest_XER_SO; // Summary Overflow
102 UChar guest_XER_OV; // Overflow
103 UChar guest_XER_CA; // Carry
104// UChar guest_XER_ByteCount;
cerion896a1372005-01-25 12:24:25 +0000105
106 /* Emulation warnings */
107 UInt guest_EMWARN;
108
109 /* Padding to make it have an 8-aligned size */
cerion1515db92005-01-25 17:21:23 +0000110 UChar padding_1b1;
111 UChar padding_1b2;
112 UChar padding_1b3;
cerion896a1372005-01-25 12:24:25 +0000113 UInt padding_4b;
114 }
cerion1515db92005-01-25 17:21:23 +0000115 VexGuestPPC32State;
cerion896a1372005-01-25 12:24:25 +0000116
117
118/*---------------------------------------------------------------*/
cerion1515db92005-01-25 17:21:23 +0000119/*--- Utility functions for PPC32 guest stuff. ---*/
cerion896a1372005-01-25 12:24:25 +0000120/*---------------------------------------------------------------*/
121
122/* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */
123
cerion1515db92005-01-25 17:21:23 +0000124/* Initialise all guest PPC32 state. */
cerion896a1372005-01-25 12:24:25 +0000125
126extern
cerion1515db92005-01-25 17:21:23 +0000127void LibVEX_GuestPPC32_initialise ( /*OUT*/VexGuestPPC32State* vex_state );
cerion896a1372005-01-25 12:24:25 +0000128
cerion1515db92005-01-25 17:21:23 +0000129/* Calculate the PPC32 flag state from the saved data. */
cerion896a1372005-01-25 12:24:25 +0000130
131extern
cerion1515db92005-01-25 17:21:23 +0000132UInt LibVEX_GuestPPC32_get_flags ( /*IN*/VexGuestPPC32State* vex_state );
cerion896a1372005-01-25 12:24:25 +0000133
134
cerion1515db92005-01-25 17:21:23 +0000135#endif /* ndef __LIBVEX_PUB_GUEST_PPC32_H */
cerion896a1372005-01-25 12:24:25 +0000136
137
138/*---------------------------------------------------------------*/
cerion1515db92005-01-25 17:21:23 +0000139/*--- libvex_guest_ppc32.h ---*/
cerion896a1372005-01-25 12:24:25 +0000140/*---------------------------------------------------------------*/