blob: 8351f0e91cb7298f9dd01180fe3c3fe3d15bf9ea [file] [log] [blame]
sewardj362cf842012-06-07 08:59:53 +00001
2/*---------------------------------------------------------------*/
3/*--- begin libvex_guest_mips32.h ---*/
4/*---------------------------------------------------------------*/
5
6/*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
9
sewardj785952d2015-08-21 11:29:16 +000010 Copyright (C) 2010-2015 RT-RK
sewardj362cf842012-06-07 08:59:53 +000011 mips-valgrind@rt-rk.com
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., 59 Temple Place, Suite 330, Boston, MA
26 02111-1307, USA.
27
28 The GNU General Public License is contained in the file COPYING.
29*/
30
31#ifndef __LIBVEX_PUB_GUEST_MIPS32_H
32#define __LIBVEX_PUB_GUEST_MIPS32_H
33
34#include "libvex_basictypes.h"
sewardj362cf842012-06-07 08:59:53 +000035
36
37/*---------------------------------------------------------------*/
38/*--- Vex's representation of the MIPS32 CPU state. ---*/
39/*---------------------------------------------------------------*/
40
41typedef
42 struct {
43 /* CPU Registers */
dejanj0e006f22014-02-19 11:56:29 +000044 /* 0 */ UInt guest_r0; /* Hardwired to 0 */
45 /* 4 */ UInt guest_r1; /* Assembler temporary */
46 /* 8 */ UInt guest_r2; /* Values for function returns ...*/
47 /* 12 */ UInt guest_r3; /* ...and expression evaluation */
48 /* 16 */ UInt guest_r4; /* Function arguments */
49 /* 20 */ UInt guest_r5;
50 /* 24 */ UInt guest_r6;
51 /* 28 */ UInt guest_r7;
52 /* 32 */ UInt guest_r8; /* Temporaries */
53 /* 36 */ UInt guest_r9;
54 /* 40 */ UInt guest_r10;
55 /* 44 */ UInt guest_r11;
56 /* 48 */ UInt guest_r12;
57 /* 52 */ UInt guest_r13;
58 /* 56 */ UInt guest_r14;
59 /* 60 */ UInt guest_r15;
60 /* 64 */ UInt guest_r16; /* Saved temporaries */
61 /* 68 */ UInt guest_r17;
62 /* 72 */ UInt guest_r18;
63 /* 76 */ UInt guest_r19;
64 /* 80 */ UInt guest_r20;
65 /* 84 */ UInt guest_r21;
66 /* 88 */ UInt guest_r22;
67 /* 92 */ UInt guest_r23;
68 /* 96 */ UInt guest_r24; /* Temporaries */
69 /* 100 */ UInt guest_r25;
70 /* 104 */ UInt guest_r26; /* Reserved for OS kernel */
71 /* 108 */ UInt guest_r27;
72 /* 112 */ UInt guest_r28; /* Global pointer */
73 /* 116 */ UInt guest_r29; /* Stack pointer */
74 /* 120 */ UInt guest_r30; /* Frame pointer */
75 /* 124 */ UInt guest_r31; /* Return address */
76 /* 128 */ UInt guest_PC; /* Program counter */
77 /* 132 */ UInt guest_HI; /* Multiply and divide register higher result */
78 /* 136 */ UInt guest_LO; /* Multiply and divide register lower result */
sewardj362cf842012-06-07 08:59:53 +000079
80 /* FPU Registers */
dejanj0e006f22014-02-19 11:56:29 +000081 /* 144 */ ULong guest_f0; /* Floating point general purpose registers */
82 /* 152 */ ULong guest_f1;
83 /* 160 */ ULong guest_f2;
84 /* 168 */ ULong guest_f3;
85 /* 176 */ ULong guest_f4;
86 /* 184 */ ULong guest_f5;
87 /* 192 */ ULong guest_f6;
88 /* 200 */ ULong guest_f7;
89 /* 208 */ ULong guest_f8;
90 /* 216 */ ULong guest_f9;
91 /* 224 */ ULong guest_f10;
92 /* 232 */ ULong guest_f11;
93 /* 240 */ ULong guest_f12;
94 /* 248 */ ULong guest_f13;
95 /* 256 */ ULong guest_f14;
96 /* 264 */ ULong guest_f15;
97 /* 272 */ ULong guest_f16;
98 /* 280 */ ULong guest_f17;
99 /* 288 */ ULong guest_f18;
100 /* 296 */ ULong guest_f19;
101 /* 304 */ ULong guest_f20;
102 /* 312 */ ULong guest_f21;
103 /* 320 */ ULong guest_f22;
104 /* 328 */ ULong guest_f23;
105 /* 336 */ ULong guest_f24;
106 /* 344 */ ULong guest_f25;
107 /* 352 */ ULong guest_f26;
108 /* 360 */ ULong guest_f27;
109 /* 368 */ ULong guest_f28;
110 /* 376 */ ULong guest_f29;
111 /* 384 */ ULong guest_f30;
112 /* 392 */ ULong guest_f31;
113
114 /* 400 */ UInt guest_FIR;
115 /* 404 */ UInt guest_FCCR;
116 /* 408 */ UInt guest_FEXR;
117 /* 412 */ UInt guest_FENR;
118 /* 416 */ UInt guest_FCSR;
sewardj362cf842012-06-07 08:59:53 +0000119
120 /* TLS pointer for the thread. It's read-only in user space.
121 On Linux it is set in user space by various thread-related
122 syscalls.
123 User Local Register.
124 This register provides read access to the coprocessor 0
125 UserLocal register, if it is implemented. In some operating
126 environments, the UserLocal register is a pointer to a
127 thread-specific storage block.
128 */
dejanj0e006f22014-02-19 11:56:29 +0000129 /* 420 */ UInt guest_ULR;
sewardj362cf842012-06-07 08:59:53 +0000130
florian6ef84be2012-08-26 03:20:07 +0000131 /* Emulation notes */
dejanj0e006f22014-02-19 11:56:29 +0000132 /* 424 */ UInt guest_EMNOTE;
sewardj362cf842012-06-07 08:59:53 +0000133
134 /* For clflush: record start and length of area to invalidate */
sewardj05f5e012014-05-04 10:52:11 +0000135 /* 428 */ UInt guest_CMSTART;
136 /* 432 */ UInt guest_CMLEN;
dejanj0e006f22014-02-19 11:56:29 +0000137 /* 436 */ UInt guest_NRADDR;
sewardj362cf842012-06-07 08:59:53 +0000138
dejanj0e006f22014-02-19 11:56:29 +0000139 /* 440 */ UInt host_EvC_FAILADDR;
140 /* 444 */ UInt host_EvC_COUNTER;
141 /* 448 */ UInt guest_COND;
dejanjc3fee0d2013-07-25 09:08:03 +0000142
dejanjc3fee0d2013-07-25 09:08:03 +0000143 /* MIPS32 DSP ASE(r2) specific registers. */
dejanj0e006f22014-02-19 11:56:29 +0000144 /* 452 */ UInt guest_DSPControl;
145 /* 456 */ ULong guest_ac0;
146 /* 464 */ ULong guest_ac1;
147 /* 472 */ ULong guest_ac2;
148 /* 480 */ ULong guest_ac3;
149
Elliott Hughesa0664b92017-04-18 17:46:52 -0700150 /* 488 */ UInt guest_CP0_status;
151
152 /* 492 */ UInt padding;
sewardj362cf842012-06-07 08:59:53 +0000153} VexGuestMIPS32State;
154/*---------------------------------------------------------------*/
155/*--- Utility functions for MIPS32 guest stuff. ---*/
156/*---------------------------------------------------------------*/
157
158/* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */
159
160/* Initialise all guest MIPS32 state. */
161
162extern
163void LibVEX_GuestMIPS32_initialise ( /*OUT*/VexGuestMIPS32State* vex_state );
164
Elliott Hughesa0664b92017-04-18 17:46:52 -0700165/* FR bit of CP0_STATUS_FR register */
166#define MIPS_CP0_STATUS_FR (1ul << 26)
sewardj362cf842012-06-07 08:59:53 +0000167
168#endif /* ndef __LIBVEX_PUB_GUEST_MIPS32_H */
169
170
171/*---------------------------------------------------------------*/
172/*--- libvex_guest_mips32.h ---*/
173/*---------------------------------------------------------------*/