1 | /* $Id: bs3-mode-TestDoModes.c 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * BS3Kit - Bs3TestDoModes
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2022 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #if TMPL_MODE == BS3_MODE_RM
|
---|
32 | # define BS3_USE_RM_TEXT_SEG 1 /* Real mode version in RMTEXT16 segment to save space. */
|
---|
33 | # include "bs3kit-template-header.h"
|
---|
34 | # include "bs3-cmn-test.h"
|
---|
35 | #else
|
---|
36 | # include "bs3kit-template-header.h"
|
---|
37 | # include "bs3-cmn-test.h"
|
---|
38 | #endif
|
---|
39 | #include "bs3-mode-TestDoModes.h"
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Warns about CPU modes that must be skipped.
|
---|
45 | *
|
---|
46 | * It will try not warn about modes for which there are no tests.
|
---|
47 | *
|
---|
48 | * @param paEntries The mode test entries.
|
---|
49 | * @param cEntries The number of tests.
|
---|
50 | * @param bCpuType The CPU type byte (see #BS3CPU_TYPE_MASK).
|
---|
51 | * @param fHavePae Whether the CPU has PAE.
|
---|
52 | * @param fHaveLongMode Whether the CPU does long mode.
|
---|
53 | */
|
---|
54 | static void bs3TestWarnAboutSkippedModes(PCBS3TESTMODEENTRY paEntries, unsigned cEntries,
|
---|
55 | uint8_t bCpuType, bool fHavePae, bool fHaveLongMode)
|
---|
56 | {
|
---|
57 | bool fComplained286 = false;
|
---|
58 | bool fComplained386 = false;
|
---|
59 | bool fComplainedPAE = false;
|
---|
60 | bool fComplainedAMD64 = false;
|
---|
61 | unsigned i;
|
---|
62 |
|
---|
63 | /*
|
---|
64 | * Complaint run.
|
---|
65 | */
|
---|
66 | for (i = 0; i < cEntries; i++)
|
---|
67 | {
|
---|
68 | if ( !fComplained286
|
---|
69 | && paEntries[i].pfnDoPE16)
|
---|
70 | {
|
---|
71 | if (bCpuType < BS3CPU_80286)
|
---|
72 | {
|
---|
73 | Bs3Printf("Only executing real-mode tests as no 80286+ CPU was detected.\n");
|
---|
74 | break;
|
---|
75 | }
|
---|
76 | fComplained286 = true;
|
---|
77 | }
|
---|
78 |
|
---|
79 | if ( !fComplained386
|
---|
80 | && ( paEntries[i].pfnDoPE16_32
|
---|
81 | || paEntries[i].pfnDoPE16_V86
|
---|
82 | || paEntries[i].pfnDoPE32
|
---|
83 | || paEntries[i].pfnDoPE32_16
|
---|
84 | || paEntries[i].pfnDoPEV86
|
---|
85 | || paEntries[i].pfnDoPP16
|
---|
86 | || paEntries[i].pfnDoPP16_32
|
---|
87 | || paEntries[i].pfnDoPP16_V86
|
---|
88 | || paEntries[i].pfnDoPP32
|
---|
89 | || paEntries[i].pfnDoPP32_16
|
---|
90 | || paEntries[i].pfnDoPPV86) )
|
---|
91 | {
|
---|
92 | if (bCpuType < BS3CPU_80386)
|
---|
93 | {
|
---|
94 | Bs3Printf("80286 CPU: Only executing 16-bit protected and real mode tests.\n");
|
---|
95 | break;
|
---|
96 | }
|
---|
97 | fComplained386 = true;
|
---|
98 | }
|
---|
99 |
|
---|
100 | if ( !fComplainedPAE
|
---|
101 | && ( paEntries[i].pfnDoPAE16
|
---|
102 | || paEntries[i].pfnDoPAE16_32
|
---|
103 | || paEntries[i].pfnDoPAE16_V86
|
---|
104 | || paEntries[i].pfnDoPAE32
|
---|
105 | || paEntries[i].pfnDoPAE32_16
|
---|
106 | || paEntries[i].pfnDoPAEV86) )
|
---|
107 | {
|
---|
108 | if (!fHavePae)
|
---|
109 | {
|
---|
110 | Bs3Printf("PAE and long mode tests will be skipped.\n");
|
---|
111 | break;
|
---|
112 | }
|
---|
113 | fComplainedPAE = true;
|
---|
114 | }
|
---|
115 |
|
---|
116 | if ( !fComplainedAMD64
|
---|
117 | && ( paEntries[i].pfnDoLM16
|
---|
118 | || paEntries[i].pfnDoLM32
|
---|
119 | || paEntries[i].pfnDoLM64) )
|
---|
120 | {
|
---|
121 | if (!fHaveLongMode)
|
---|
122 | {
|
---|
123 | Bs3Printf("Long mode tests will be skipped.\n");
|
---|
124 | break;
|
---|
125 | }
|
---|
126 | fComplainedAMD64 = true;
|
---|
127 | }
|
---|
128 | }
|
---|
129 | }
|
---|
130 |
|
---|
131 | #undef Bs3TestDoModes
|
---|
132 | BS3_MODE_DEF(void, Bs3TestDoModes,(PCBS3TESTMODEENTRY paEntries, size_t cEntries))
|
---|
133 | {
|
---|
134 | bool const fVerbose = true;
|
---|
135 | bool const fDoV86Modes = true;
|
---|
136 | bool const fDoWeirdV86Modes = true;
|
---|
137 | uint16_t const uCpuDetected = g_uBs3CpuDetected;
|
---|
138 | uint8_t const bCpuType = uCpuDetected & BS3CPU_TYPE_MASK;
|
---|
139 | bool const fHavePae = RT_BOOL(uCpuDetected & BS3CPU_F_PAE);
|
---|
140 | bool const fHaveLongMode = RT_BOOL(uCpuDetected & BS3CPU_F_LONG_MODE);
|
---|
141 | unsigned i;
|
---|
142 |
|
---|
143 | #if 1 /* debug. */
|
---|
144 | Bs3Printf("Bs3TestDoModes: uCpuDetected=%#x fHavePae=%d fHaveLongMode=%d\n", uCpuDetected, fHavePae, fHaveLongMode);
|
---|
145 | #endif
|
---|
146 | bs3TestWarnAboutSkippedModes(paEntries, cEntries, bCpuType, fHavePae, fHaveLongMode);
|
---|
147 |
|
---|
148 | /*
|
---|
149 | * The real run.
|
---|
150 | */
|
---|
151 | for (i = 0; i < cEntries; i++)
|
---|
152 | {
|
---|
153 | const char *pszFmtStr = "Error #%u (%#x) in %s!\n";
|
---|
154 | bool fSkipped = true;
|
---|
155 | uint8_t bErrNo;
|
---|
156 |
|
---|
157 | if (paEntries[i].pszSubTest != NULL)
|
---|
158 | Bs3TestSub(paEntries[i].pszSubTest);
|
---|
159 |
|
---|
160 | #define PRE_DO_CALL(a_szModeName) do { if (fVerbose) Bs3TestPrintf("...%s\n", a_szModeName); } while (0)
|
---|
161 | #define CHECK_RESULT(a_szModeName) \
|
---|
162 | do { \
|
---|
163 | if (bErrNo != BS3TESTDOMODE_SKIPPED) \
|
---|
164 | { \
|
---|
165 | /*Bs3Printf("bErrNo=%#x %s\n", bErrNo, a_szModeName);*/ \
|
---|
166 | fSkipped = false; \
|
---|
167 | if (bErrNo != 0) \
|
---|
168 | Bs3TestFailedF(pszFmtStr, bErrNo, bErrNo, a_szModeName); \
|
---|
169 | } \
|
---|
170 | } while (0)
|
---|
171 |
|
---|
172 | if (paEntries[i].pfnDoRM)
|
---|
173 | {
|
---|
174 | PRE_DO_CALL(g_szBs3ModeName_rm);
|
---|
175 | bErrNo = TMPL_NM(Bs3TestCallDoerInRM)(CONV_TO_RM_FAR16(paEntries[i].pfnDoRM));
|
---|
176 | CHECK_RESULT(g_szBs3ModeName_rm);
|
---|
177 | }
|
---|
178 |
|
---|
179 | if (bCpuType < BS3CPU_80286)
|
---|
180 | {
|
---|
181 | if (fSkipped)
|
---|
182 | Bs3TestSkipped(NULL);
|
---|
183 | continue;
|
---|
184 | }
|
---|
185 |
|
---|
186 | /*
|
---|
187 | * Unpaged prot mode.
|
---|
188 | */
|
---|
189 | if (paEntries[i].pfnDoPE16)
|
---|
190 | {
|
---|
191 | PRE_DO_CALL(g_szBs3ModeName_pe16);
|
---|
192 | bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPE16));
|
---|
193 | CHECK_RESULT(g_szBs3ModeName_pe16);
|
---|
194 | }
|
---|
195 | if (bCpuType < BS3CPU_80386)
|
---|
196 | {
|
---|
197 | if (fSkipped)
|
---|
198 | Bs3TestSkipped(NULL);
|
---|
199 | continue;
|
---|
200 | }
|
---|
201 |
|
---|
202 | if (paEntries[i].pfnDoPE16_32)
|
---|
203 | {
|
---|
204 | PRE_DO_CALL(g_szBs3ModeName_pe16_32);
|
---|
205 | bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPE16_32), BS3_MODE_PE16_32);
|
---|
206 | CHECK_RESULT(g_szBs3ModeName_pe16_32);
|
---|
207 | }
|
---|
208 |
|
---|
209 | if (paEntries[i].pfnDoPE16_V86 && fDoWeirdV86Modes)
|
---|
210 | {
|
---|
211 | PRE_DO_CALL(g_szBs3ModeName_pe16_v86);
|
---|
212 | bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPE16_V86));
|
---|
213 | CHECK_RESULT(g_szBs3ModeName_pe16_v86);
|
---|
214 | }
|
---|
215 |
|
---|
216 | if (paEntries[i].pfnDoPE32)
|
---|
217 | {
|
---|
218 | PRE_DO_CALL(g_szBs3ModeName_pe32);
|
---|
219 | bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(paEntries[i].pfnDoPE32), BS3_MODE_PE32);
|
---|
220 | CHECK_RESULT(g_szBs3ModeName_pe32);
|
---|
221 | }
|
---|
222 |
|
---|
223 | if (paEntries[i].pfnDoPE32_16)
|
---|
224 | {
|
---|
225 | PRE_DO_CALL(g_szBs3ModeName_pe32_16);
|
---|
226 | bErrNo = TMPL_NM(Bs3TestCallDoerInPE32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPE32_16));
|
---|
227 | CHECK_RESULT(g_szBs3ModeName_pe32_16);
|
---|
228 | }
|
---|
229 |
|
---|
230 | if (paEntries[i].pfnDoPEV86 && fDoV86Modes)
|
---|
231 | {
|
---|
232 | PRE_DO_CALL(g_szBs3ModeName_pev86);
|
---|
233 | bErrNo = TMPL_NM(Bs3TestCallDoerInPEV86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPEV86));
|
---|
234 | CHECK_RESULT(g_szBs3ModeName_pev86);
|
---|
235 | }
|
---|
236 |
|
---|
237 | /*
|
---|
238 | * Paged protected mode.
|
---|
239 | */
|
---|
240 | if (paEntries[i].pfnDoPP16)
|
---|
241 | {
|
---|
242 | PRE_DO_CALL(g_szBs3ModeName_pp16);
|
---|
243 | bErrNo = TMPL_NM(Bs3TestCallDoerInPP16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPP16));
|
---|
244 | CHECK_RESULT(g_szBs3ModeName_pp16);
|
---|
245 | }
|
---|
246 |
|
---|
247 | if (paEntries[i].pfnDoPP16_32)
|
---|
248 | {
|
---|
249 | PRE_DO_CALL(g_szBs3ModeName_pp16_32);
|
---|
250 | bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPP16_32), BS3_MODE_PP16_32);
|
---|
251 | CHECK_RESULT(g_szBs3ModeName_pp16_32);
|
---|
252 | }
|
---|
253 |
|
---|
254 | if (paEntries[i].pfnDoPP16_V86 && fDoWeirdV86Modes)
|
---|
255 | {
|
---|
256 | PRE_DO_CALL(g_szBs3ModeName_pp16_v86);
|
---|
257 | bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPP16_V86));
|
---|
258 | CHECK_RESULT(g_szBs3ModeName_pp16_v86);
|
---|
259 | }
|
---|
260 |
|
---|
261 | if (paEntries[i].pfnDoPP32)
|
---|
262 | {
|
---|
263 | PRE_DO_CALL(g_szBs3ModeName_pp32);
|
---|
264 | bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(paEntries[i].pfnDoPP32), BS3_MODE_PP32);
|
---|
265 | CHECK_RESULT(g_szBs3ModeName_pp32);
|
---|
266 | }
|
---|
267 |
|
---|
268 | if (paEntries[i].pfnDoPP32_16)
|
---|
269 | {
|
---|
270 | PRE_DO_CALL(g_szBs3ModeName_pp32_16);
|
---|
271 | bErrNo = TMPL_NM(Bs3TestCallDoerInPP32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPP32_16));
|
---|
272 | CHECK_RESULT(g_szBs3ModeName_pp32_16);
|
---|
273 | }
|
---|
274 |
|
---|
275 | if (paEntries[i].pfnDoPPV86 && fDoV86Modes)
|
---|
276 | {
|
---|
277 | PRE_DO_CALL(g_szBs3ModeName_ppv86);
|
---|
278 | bErrNo = TMPL_NM(Bs3TestCallDoerInPPV86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPPV86));
|
---|
279 | CHECK_RESULT(g_szBs3ModeName_ppv86);
|
---|
280 | }
|
---|
281 |
|
---|
282 | /*
|
---|
283 | * Protected mode with PAE paging.
|
---|
284 | */
|
---|
285 | if (!fHavePae)
|
---|
286 | {
|
---|
287 | if (fSkipped)
|
---|
288 | Bs3TestSkipped(NULL);
|
---|
289 | continue;
|
---|
290 | }
|
---|
291 |
|
---|
292 | if (paEntries[i].pfnDoPAE16)
|
---|
293 | {
|
---|
294 | PRE_DO_CALL(g_szBs3ModeName_pae16);
|
---|
295 | bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPAE16));
|
---|
296 | CHECK_RESULT(g_szBs3ModeName_pae16);
|
---|
297 | }
|
---|
298 |
|
---|
299 | if (paEntries[i].pfnDoPAE16_32)
|
---|
300 | {
|
---|
301 | PRE_DO_CALL(g_szBs3ModeName_pae16_32);
|
---|
302 | bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE16_32), BS3_MODE_PAE16_32);
|
---|
303 | CHECK_RESULT(g_szBs3ModeName_pae16_32);
|
---|
304 | }
|
---|
305 |
|
---|
306 | if (paEntries[i].pfnDoPAE16_V86 && fDoWeirdV86Modes)
|
---|
307 | {
|
---|
308 | PRE_DO_CALL(g_szBs3ModeName_pae16_v86);
|
---|
309 | bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPAE16_V86));
|
---|
310 | CHECK_RESULT(g_szBs3ModeName_pae16_v86);
|
---|
311 | }
|
---|
312 |
|
---|
313 | if (paEntries[i].pfnDoPAE32)
|
---|
314 | {
|
---|
315 | PRE_DO_CALL(g_szBs3ModeName_pae32);
|
---|
316 | bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE32), BS3_MODE_PAE32);
|
---|
317 | CHECK_RESULT(g_szBs3ModeName_pae32);
|
---|
318 | }
|
---|
319 |
|
---|
320 | if (paEntries[i].pfnDoPAE32_16)
|
---|
321 | {
|
---|
322 | PRE_DO_CALL(g_szBs3ModeName_pae32_16);
|
---|
323 | bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPAE32_16));
|
---|
324 | CHECK_RESULT(g_szBs3ModeName_pae32_16);
|
---|
325 | }
|
---|
326 |
|
---|
327 | if (paEntries[i].pfnDoPAEV86 && fDoV86Modes)
|
---|
328 | {
|
---|
329 | PRE_DO_CALL(g_szBs3ModeName_paev86);
|
---|
330 | bErrNo = TMPL_NM(Bs3TestCallDoerInPAEV86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPAEV86));
|
---|
331 | CHECK_RESULT(g_szBs3ModeName_paev86);
|
---|
332 | }
|
---|
333 |
|
---|
334 | /*
|
---|
335 | * Long mode.
|
---|
336 | */
|
---|
337 | if (!fHaveLongMode)
|
---|
338 | {
|
---|
339 | if (fSkipped)
|
---|
340 | Bs3TestSkipped(NULL);
|
---|
341 | continue;
|
---|
342 | }
|
---|
343 |
|
---|
344 | if (paEntries[i].pfnDoLM16)
|
---|
345 | {
|
---|
346 | PRE_DO_CALL(g_szBs3ModeName_lm16);
|
---|
347 | bErrNo = TMPL_NM(Bs3TestCallDoerInLM16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoLM16));
|
---|
348 | CHECK_RESULT(g_szBs3ModeName_lm16);
|
---|
349 | }
|
---|
350 |
|
---|
351 | if (paEntries[i].pfnDoLM32)
|
---|
352 | {
|
---|
353 | PRE_DO_CALL(g_szBs3ModeName_lm32);
|
---|
354 | bErrNo = TMPL_NM(Bs3TestCallDoerInLM32)(CONV_TO_FLAT(paEntries[i].pfnDoLM32));
|
---|
355 | CHECK_RESULT(g_szBs3ModeName_lm32);
|
---|
356 | }
|
---|
357 |
|
---|
358 | if (paEntries[i].pfnDoLM64)
|
---|
359 | {
|
---|
360 | PRE_DO_CALL(g_szBs3ModeName_lm64);
|
---|
361 | bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(paEntries[i].pfnDoLM64), BS3_MODE_LM64);
|
---|
362 | CHECK_RESULT(g_szBs3ModeName_lm64);
|
---|
363 | }
|
---|
364 |
|
---|
365 | if (fSkipped)
|
---|
366 | Bs3TestSkipped("skipped\n");
|
---|
367 | }
|
---|
368 | Bs3TestSubDone();
|
---|
369 | }
|
---|
370 |
|
---|