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