1 | /* $Id: structs.h 11982 2008-09-02 13:09:44Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Recompiler - structure offset tables.
|
---|
4 | *
|
---|
5 | * Used by op.c and VBoxRecompiler.c to verify they have the
|
---|
6 | * same understanding of the internal structures when using
|
---|
7 | * different compilers (GCC 4.x vs. 3.x/ELF).
|
---|
8 | */
|
---|
9 |
|
---|
10 | /*
|
---|
11 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
12 | *
|
---|
13 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
14 | * available from http://www.virtualbox.org. This file is free software;
|
---|
15 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
16 | * General Public License (GPL) as published by the Free Software
|
---|
17 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
18 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
19 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
20 | *
|
---|
21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
22 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
23 | * additional information or have any questions.
|
---|
24 | */
|
---|
25 |
|
---|
26 |
|
---|
27 | #if REM_STRUCT_OP
|
---|
28 |
|
---|
29 | /*
|
---|
30 | * we're in op.c
|
---|
31 | */
|
---|
32 | # define REM_STRUCT_TABLE(strct) const int g_aiOpStruct_ ## strct []
|
---|
33 |
|
---|
34 | # define REM_THE_END(strct) sizeof(strct) | 0x42000000
|
---|
35 | # define REM_SIZEOF(strct) sizeof(strct)
|
---|
36 | # define REM_OFFSETOF(strct, memb) RT_OFFSETOF(strct, memb)
|
---|
37 | # define REM_SIZEOFMEMB(strct, memb) RT_SIZEOFMEMB(strct, memb)
|
---|
38 |
|
---|
39 | #else /* !REM_STRUCT_OP */
|
---|
40 | /*
|
---|
41 | * We're in VBoxRecompiler.c.
|
---|
42 | */
|
---|
43 | # define REM_STRUCT_TABLE(strct) \
|
---|
44 | extern const int g_aiOpStruct_ ## strct []; \
|
---|
45 | \
|
---|
46 | const REMSTRUCTENTRY g_aMyStruct_ ## strct []
|
---|
47 |
|
---|
48 | # define REM_THE_END(strct) { sizeof(strct) | 0x42000000, #strct " - the end" }
|
---|
49 | # define REM_SIZEOF(strct) { sizeof(strct) , #strct " - size of" }
|
---|
50 | # define REM_OFFSETOF(strct, memb) { RT_OFFSETOF(strct, memb) , #strct "::" #memb " - offsetof" }
|
---|
51 | # define REM_SIZEOFMEMB(strct, memb) { RT_SIZEOFMEMB(strct, memb), #strct "::" #memb " - sizeof" }
|
---|
52 |
|
---|
53 | /** Matches the My and Op tables for a strct. */
|
---|
54 | # define ASSERT_STRUCT_TABLE(strct) \
|
---|
55 | for (i = 0; i < RT_ELEMENTS(g_aMyStruct_ ## strct); i++) \
|
---|
56 | AssertReleaseMsg(g_aMyStruct_ ## strct [i].iValue == g_aiOpStruct_ ## strct [i], \
|
---|
57 | (#strct "[%d] - %d != %d - %s\n", \
|
---|
58 | i, \
|
---|
59 | g_aMyStruct_ ## strct [i].iValue,\
|
---|
60 | g_aiOpStruct_ ## strct [i], \
|
---|
61 | g_aMyStruct_ ## strct [i].pszExpr))
|
---|
62 |
|
---|
63 | /** Struct check entry. */
|
---|
64 | typedef struct REMSTRUCTENTRY
|
---|
65 | {
|
---|
66 | int iValue;
|
---|
67 | const char *pszExpr;
|
---|
68 | } REMSTRUCTENTRY;
|
---|
69 |
|
---|
70 | #endif /* !REM_STRUCT_OP */
|
---|
71 |
|
---|
72 |
|
---|
73 | REM_STRUCT_TABLE(Misc) =
|
---|
74 | {
|
---|
75 | REM_SIZEOF(char),
|
---|
76 | REM_SIZEOF(short),
|
---|
77 | REM_SIZEOF(int),
|
---|
78 | REM_SIZEOF(long),
|
---|
79 | REM_SIZEOF(float),
|
---|
80 | REM_SIZEOF(double),
|
---|
81 | REM_SIZEOF(long double),
|
---|
82 | REM_SIZEOF(void *),
|
---|
83 | REM_SIZEOF(char *),
|
---|
84 | REM_SIZEOF(short *),
|
---|
85 | REM_SIZEOF(long *),
|
---|
86 | REM_SIZEOF(size_t),
|
---|
87 | REM_SIZEOF(uint8_t),
|
---|
88 | REM_SIZEOF(uint16_t),
|
---|
89 | REM_SIZEOF(uint32_t),
|
---|
90 | REM_SIZEOF(uint64_t),
|
---|
91 | REM_SIZEOF(uintptr_t),
|
---|
92 | REM_SIZEOF(RTGCUINTPTR),
|
---|
93 | REM_SIZEOF(RTHCUINTPTR),
|
---|
94 | REM_SIZEOF(RTR3UINTPTR),
|
---|
95 | REM_SIZEOF(RTR0UINTPTR),
|
---|
96 | REM_THE_END(char)
|
---|
97 | };
|
---|
98 |
|
---|
99 | REM_STRUCT_TABLE(TLB) =
|
---|
100 | {
|
---|
101 | REM_SIZEOF(CPUTLBEntry),
|
---|
102 | REM_OFFSETOF(CPUTLBEntry, addr_read),
|
---|
103 | REM_OFFSETOF(CPUTLBEntry, addr_write),
|
---|
104 | REM_OFFSETOF(CPUTLBEntry, addr_code),
|
---|
105 | REM_OFFSETOF(CPUTLBEntry, addend),
|
---|
106 | REM_THE_END(CPUTLBEntry)
|
---|
107 | };
|
---|
108 |
|
---|
109 | REM_STRUCT_TABLE(SegmentCache) =
|
---|
110 | {
|
---|
111 | REM_SIZEOF(SegmentCache),
|
---|
112 | REM_OFFSETOF(SegmentCache, selector),
|
---|
113 | REM_OFFSETOF(SegmentCache, base),
|
---|
114 | REM_OFFSETOF(SegmentCache, limit),
|
---|
115 | REM_OFFSETOF(SegmentCache, flags),
|
---|
116 | REM_OFFSETOF(SegmentCache, newselector),
|
---|
117 | REM_THE_END(SegmentCache)
|
---|
118 | };
|
---|
119 |
|
---|
120 | REM_STRUCT_TABLE(XMMReg) =
|
---|
121 | {
|
---|
122 | REM_SIZEOF(XMMReg),
|
---|
123 | REM_OFFSETOF(XMMReg, _b[1]),
|
---|
124 | REM_OFFSETOF(XMMReg, _w[1]),
|
---|
125 | REM_OFFSETOF(XMMReg, _l[1]),
|
---|
126 | REM_OFFSETOF(XMMReg, _q[1]),
|
---|
127 | REM_OFFSETOF(XMMReg, _s[1]),
|
---|
128 | REM_OFFSETOF(XMMReg, _d[1]),
|
---|
129 | REM_THE_END(XMMReg)
|
---|
130 | };
|
---|
131 |
|
---|
132 | REM_STRUCT_TABLE(MMXReg) =
|
---|
133 | {
|
---|
134 | REM_SIZEOF(MMXReg),
|
---|
135 | REM_OFFSETOF(MMXReg, _b[1]),
|
---|
136 | REM_OFFSETOF(MMXReg, _w[1]),
|
---|
137 | REM_OFFSETOF(MMXReg, _l[1]),
|
---|
138 | REM_OFFSETOF(MMXReg, q),
|
---|
139 | REM_THE_END(MMXReg)
|
---|
140 | };
|
---|
141 |
|
---|
142 | REM_STRUCT_TABLE(float_status) =
|
---|
143 | {
|
---|
144 | REM_SIZEOF(float_status),
|
---|
145 | //REM_OFFSETOF(float_status, float_detect_tininess),
|
---|
146 | REM_OFFSETOF(float_status, float_rounding_mode),
|
---|
147 | //REM_OFFSETOF(float_status, float_exception_flags),
|
---|
148 | REM_OFFSETOF(float_status, floatx80_rounding_precision),
|
---|
149 | REM_THE_END(float_status)
|
---|
150 | };
|
---|
151 |
|
---|
152 | REM_STRUCT_TABLE(float32u) =
|
---|
153 | {
|
---|
154 | REM_SIZEOF(float32u),
|
---|
155 | REM_OFFSETOF(float32u, f),
|
---|
156 | REM_SIZEOFMEMB(float32u, f),
|
---|
157 | REM_OFFSETOF(float32u, i),
|
---|
158 | REM_SIZEOFMEMB(float32u, i),
|
---|
159 | REM_THE_END(float32u)
|
---|
160 | };
|
---|
161 |
|
---|
162 | REM_STRUCT_TABLE(float64u) =
|
---|
163 | {
|
---|
164 | REM_SIZEOF(float64u),
|
---|
165 | REM_OFFSETOF(float64u, f),
|
---|
166 | REM_SIZEOFMEMB(float64u, f),
|
---|
167 | REM_OFFSETOF(float64u, i),
|
---|
168 | REM_SIZEOFMEMB(float64u, i),
|
---|
169 | REM_THE_END(float64u)
|
---|
170 | };
|
---|
171 |
|
---|
172 | REM_STRUCT_TABLE(floatx80u) =
|
---|
173 | {
|
---|
174 | REM_SIZEOF(floatx80u),
|
---|
175 | REM_OFFSETOF(floatx80u, f),
|
---|
176 | REM_SIZEOFMEMB(floatx80u, f),
|
---|
177 | REM_OFFSETOF(floatx80u, i),
|
---|
178 | REM_SIZEOFMEMB(floatx80u, i),
|
---|
179 | REM_OFFSETOF(floatx80u, i.low),
|
---|
180 | REM_SIZEOFMEMB(floatx80u, i.low),
|
---|
181 | REM_OFFSETOF(floatx80u, i.high),
|
---|
182 | REM_SIZEOFMEMB(floatx80u, i.high),
|
---|
183 | REM_THE_END(floatx80u)
|
---|
184 | };
|
---|
185 |
|
---|
186 | REM_STRUCT_TABLE(CPUState) =
|
---|
187 | {
|
---|
188 | REM_SIZEOF(CPUState),
|
---|
189 | REM_OFFSETOF(CPUState, regs),
|
---|
190 | REM_OFFSETOF(CPUState, regs[R_EAX]),
|
---|
191 | REM_OFFSETOF(CPUState, regs[R_EBX]),
|
---|
192 | REM_OFFSETOF(CPUState, regs[R_ECX]),
|
---|
193 | REM_OFFSETOF(CPUState, regs[R_EDX]),
|
---|
194 | REM_OFFSETOF(CPUState, regs[R_ESI]),
|
---|
195 | REM_OFFSETOF(CPUState, regs[R_EDI]),
|
---|
196 | REM_OFFSETOF(CPUState, regs[R_EBP]),
|
---|
197 | REM_OFFSETOF(CPUState, regs[R_ESP]),
|
---|
198 | REM_OFFSETOF(CPUState, eip),
|
---|
199 | REM_OFFSETOF(CPUState, eflags),
|
---|
200 | REM_OFFSETOF(CPUState, cc_src),
|
---|
201 | REM_OFFSETOF(CPUState, cc_dst),
|
---|
202 | REM_OFFSETOF(CPUState, cc_op),
|
---|
203 | REM_OFFSETOF(CPUState, df),
|
---|
204 | REM_OFFSETOF(CPUState, hflags),
|
---|
205 | REM_OFFSETOF(CPUState, segs),
|
---|
206 | REM_OFFSETOF(CPUState, segs[R_SS]),
|
---|
207 | REM_OFFSETOF(CPUState, segs[R_CS]),
|
---|
208 | REM_OFFSETOF(CPUState, segs[R_DS]),
|
---|
209 | REM_OFFSETOF(CPUState, segs[R_ES]),
|
---|
210 | REM_OFFSETOF(CPUState, segs[R_FS]),
|
---|
211 | REM_OFFSETOF(CPUState, segs[R_GS]),
|
---|
212 | REM_OFFSETOF(CPUState, ldt),
|
---|
213 | REM_OFFSETOF(CPUState, tr),
|
---|
214 | REM_OFFSETOF(CPUState, gdt),
|
---|
215 | REM_OFFSETOF(CPUState, idt),
|
---|
216 | REM_OFFSETOF(CPUState, cr),
|
---|
217 | REM_SIZEOFMEMB(CPUState, cr),
|
---|
218 | REM_OFFSETOF(CPUState, cr[1]),
|
---|
219 | REM_OFFSETOF(CPUState, a20_mask),
|
---|
220 | REM_OFFSETOF(CPUState, fpstt),
|
---|
221 | REM_OFFSETOF(CPUState, fpus),
|
---|
222 | REM_OFFSETOF(CPUState, fpuc),
|
---|
223 | REM_OFFSETOF(CPUState, fptags),
|
---|
224 | REM_SIZEOFMEMB(CPUState, fptags),
|
---|
225 | REM_OFFSETOF(CPUState, fptags[1]),
|
---|
226 | REM_OFFSETOF(CPUState, fpregs),
|
---|
227 | REM_SIZEOFMEMB(CPUState, fpregs),
|
---|
228 | REM_OFFSETOF(CPUState, fpregs[1]),
|
---|
229 | REM_OFFSETOF(CPUState, fp_status),
|
---|
230 | REM_OFFSETOF(CPUState, ft0),
|
---|
231 | REM_SIZEOFMEMB(CPUState, ft0),
|
---|
232 | REM_OFFSETOF(CPUState, fp_convert),
|
---|
233 | REM_SIZEOFMEMB(CPUState, fp_convert),
|
---|
234 | REM_OFFSETOF(CPUState, sse_status),
|
---|
235 | REM_OFFSETOF(CPUState, mxcsr),
|
---|
236 | REM_OFFSETOF(CPUState, xmm_regs),
|
---|
237 | REM_SIZEOFMEMB(CPUState, xmm_regs),
|
---|
238 | REM_OFFSETOF(CPUState, xmm_regs[1]),
|
---|
239 | REM_OFFSETOF(CPUState, mmx_t0),
|
---|
240 | REM_OFFSETOF(CPUState, sysenter_cs),
|
---|
241 | REM_OFFSETOF(CPUState, sysenter_esp),
|
---|
242 | REM_OFFSETOF(CPUState, sysenter_eip),
|
---|
243 | REM_OFFSETOF(CPUState, efer),
|
---|
244 | REM_OFFSETOF(CPUState, star),
|
---|
245 | REM_OFFSETOF(CPUState, pat),
|
---|
246 | REM_OFFSETOF(CPUState, jmp_env),
|
---|
247 | REM_SIZEOFMEMB(CPUState, jmp_env),
|
---|
248 | REM_OFFSETOF(CPUState, exception_index),
|
---|
249 | REM_OFFSETOF(CPUState, error_code),
|
---|
250 | REM_OFFSETOF(CPUState, exception_is_int),
|
---|
251 | REM_OFFSETOF(CPUState, exception_next_eip),
|
---|
252 | REM_OFFSETOF(CPUState, dr),
|
---|
253 | REM_SIZEOFMEMB(CPUState, dr),
|
---|
254 | REM_OFFSETOF(CPUState, dr[1]),
|
---|
255 | REM_OFFSETOF(CPUState, smbase),
|
---|
256 | REM_OFFSETOF(CPUState, interrupt_request),
|
---|
257 | REM_OFFSETOF(CPUState, user_mode_only),
|
---|
258 | REM_OFFSETOF(CPUState, state),
|
---|
259 | REM_OFFSETOF(CPUState, pVM),
|
---|
260 | REM_OFFSETOF(CPUState, pvCodeBuffer),
|
---|
261 | REM_OFFSETOF(CPUState, cbCodeBuffer),
|
---|
262 | REM_OFFSETOF(CPUState, cpuid_features),
|
---|
263 | REM_OFFSETOF(CPUState, cpuid_ext_features),
|
---|
264 | REM_OFFSETOF(CPUState, cpuid_ext2_features),
|
---|
265 |
|
---|
266 | /* cpu-defs.h */
|
---|
267 | REM_OFFSETOF(CPUState, current_tb),
|
---|
268 | REM_OFFSETOF(CPUState, mem_write_pc),
|
---|
269 | REM_OFFSETOF(CPUState, mem_write_vaddr),
|
---|
270 | REM_OFFSETOF(CPUState, tlb_table),
|
---|
271 | REM_SIZEOFMEMB(CPUState, tlb_table),
|
---|
272 | REM_OFFSETOF(CPUState, tb_jmp_cache),
|
---|
273 | REM_SIZEOFMEMB(CPUState, tb_jmp_cache),
|
---|
274 | REM_OFFSETOF(CPUState, breakpoints),
|
---|
275 | REM_SIZEOFMEMB(CPUState, breakpoints),
|
---|
276 | REM_OFFSETOF(CPUState, nb_breakpoints),
|
---|
277 | REM_OFFSETOF(CPUState, singlestep_enabled),
|
---|
278 | REM_OFFSETOF(CPUState, next_cpu),
|
---|
279 | REM_OFFSETOF(CPUState, cpu_index),
|
---|
280 | REM_OFFSETOF(CPUState, opaque),
|
---|
281 |
|
---|
282 | REM_THE_END(CPUState)
|
---|
283 | };
|
---|
284 |
|
---|
285 | #undef REM_THE_END
|
---|
286 | #undef REM_OFFSETOF
|
---|
287 | #undef REM_SIZEOF
|
---|
288 | #undef REM_SIZEOFMEMB
|
---|
289 | #undef REM_STRUCT_TABLE
|
---|
290 |
|
---|