VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-TestDoModesByOne.c

Last change on this file was 106061, checked in by vboxsync, 3 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.6 KB
Line 
1/* $Id: bs3-mode-TestDoModesByOne.c 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * BS3Kit - Bs3TestDoModesByOne
4 */
5
6/*
7 * Copyright (C) 2007-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
41#if TMPL_MODE == BS3_MODE_RM
42# define BS3_USE_RM_TEXT_SEG 1 /* Real mode version in RMTEXT16 segment to save space. */
43# include "bs3kit-template-header.h"
44# include "bs3-cmn-test.h"
45#else
46# include "bs3kit-template-header.h"
47# include "bs3-cmn-test.h"
48#endif
49#include "bs3-mode-TestDoModes.h"
50
51
52/*********************************************************************************************************************************
53* Assembly Symbols *
54*********************************************************************************************************************************/
55/* Assembly helpers for switching to the work bitcount and calling it. */
56BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo16_f16(uint8_t bMode);
57BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo16_c32(uint8_t bMode);
58BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo16_c64(uint8_t bMode);
59BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo32_f16(uint8_t bMode);
60BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo32_c32(uint8_t bMode);
61BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo32_c64(uint8_t bMode);
62BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo64_f16(uint8_t bMode);
63BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo64_c32(uint8_t bMode);
64BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo64_c64(uint8_t bMode);
65
66
67/** The current worker function, picked up by our assembly helpers. */
68#ifndef DOXYGEN_RUNNING
69# define g_pfnBs3TestDoModesByOneCurrent BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent)
70#endif
71extern PFNBS3TESTDOMODE g_pfnBs3TestDoModesByOneCurrent;
72
73#include <iprt/asm-amd64-x86.h>
74
75
76#undef Bs3TestDoModesByOne
77BS3_MODE_DEF(void, Bs3TestDoModesByOne,(PCBS3TESTMODEBYONEENTRY paEntries, size_t cEntries, uint32_t fFlags))
78{
79 bool const fVerbose = true;
80 bool const fDoV86Modes = true;
81 bool const fDoWeirdV86Modes = true;
82 uint16_t const uCpuDetected = g_uBs3CpuDetected;
83 uint8_t const bCpuType = uCpuDetected & BS3CPU_TYPE_MASK;
84 bool const fHavePae = RT_BOOL(uCpuDetected & BS3CPU_F_PAE);
85 bool const fHaveLongMode = RT_BOOL(uCpuDetected & BS3CPU_F_LONG_MODE);
86 unsigned i;
87
88#if 1 /* debug. */
89 Bs3Printf("Bs3TestDoModesByOne: uCpuDetected=%#x fHavePae=%d fHaveLongMode=%d\n", uCpuDetected, fHavePae, fHaveLongMode);
90#endif
91
92 /*
93 * Inform about modes we won't test (if any).
94 */
95 if (bCpuType < BS3CPU_80286)
96 Bs3Printf("Only executing real-mode tests as no 80286+ CPU was detected.\n");
97 else if (bCpuType < BS3CPU_80386)
98 Bs3Printf("80286 CPU: Only executing 16-bit protected and real mode tests.\n");
99 else if (!fHavePae)
100 Bs3Printf("PAE and long mode tests will be skipped.\n");
101 else if (!fHaveLongMode)
102 Bs3Printf("Long mode tests will be skipped.\n");
103#if ARCH_BITS != 16
104 Bs3Printf("Real-mode tests will be skipped.\n");
105#endif
106
107 /*
108 * The real run.
109 */
110 for (i = 0; i < cEntries; i++)
111 {
112 const char *pszFmtStr = "Error #%u (%#x) in %s!\n";
113 bool fSkipped = true;
114 bool const fOnlyPaging = RT_BOOL((paEntries[i].fFlags | fFlags) & BS3TESTMODEBYONEENTRY_F_ONLY_PAGING);
115 bool const fMinimal = RT_BOOL((paEntries[i].fFlags | fFlags) & BS3TESTMODEBYONEENTRY_F_MINIMAL);
116 bool const fSkipV8086 = RT_BOOL((paEntries[i].fFlags | fFlags) & BS3TESTMODEBYONEENTRY_F_SKIP_V8086);
117 bool const fCurDoV86Modes = fDoV86Modes && !fMinimal && !fSkipV8086;
118 bool const fCurDoWeirdV86Modes = fDoWeirdV86Modes && fCurDoV86Modes;
119 uint8_t bErrNo;
120 Bs3TestSub(paEntries[i].pszSubTest);
121
122#define PRE_DO_CALL(a_szModeName) do { if (fVerbose) Bs3TestPrintf("...%s\n", a_szModeName); } while (0)
123#define CHECK_RESULT(a_szModeName) \
124 do { \
125 if (bErrNo != BS3TESTDOMODE_SKIPPED) \
126 { \
127 /*Bs3Printf("bErrNo=%#x %s\n", bErrNo, a_szModeName);*/ \
128 fSkipped = false; \
129 if (bErrNo != 0) \
130 Bs3TestFailedF(pszFmtStr, bErrNo, bErrNo, a_szModeName); \
131 } \
132 } while (0)
133
134 g_pfnBs3TestDoModesByOneCurrent = paEntries[i].pfnWorker;
135
136#if ARCH_BITS != 64
137
138# if ARCH_BITS == 16
139 if (!fOnlyPaging)
140 {
141 PRE_DO_CALL(g_szBs3ModeName_rm);
142 bErrNo = TMPL_NM(Bs3TestCallDoerInRM)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
143 CHECK_RESULT(g_szBs3ModeName_rm);
144 }
145# else
146 if (!fOnlyPaging && (paEntries[i].fFlags | fFlags) & BS3TESTMODEBYONEENTRY_F_REAL_MODE_READY)
147 {
148 PRE_DO_CALL(g_szBs3ModeName_rm);
149 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_RM);
150 CHECK_RESULT(g_szBs3ModeName_rm);
151 }
152# endif
153
154 if (bCpuType < BS3CPU_80286)
155 {
156 if (fSkipped)
157 Bs3TestSkipped(NULL);
158 continue;
159 }
160
161 /*
162 * Unpaged prot mode.
163 */
164 if (!fOnlyPaging && (!fMinimal || bCpuType < BS3CPU_80386))
165 {
166 PRE_DO_CALL(g_szBs3ModeName_pe16);
167# if ARCH_BITS == 16
168 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
169# else
170 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
171# endif
172 CHECK_RESULT(g_szBs3ModeName_pe16);
173 }
174 if (bCpuType < BS3CPU_80386)
175 {
176 if (fSkipped)
177 Bs3TestSkipped(NULL);
178 continue;
179 }
180
181 if (!fOnlyPaging)
182 {
183 PRE_DO_CALL(g_szBs3ModeName_pe16_32);
184# if ARCH_BITS == 32
185 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PE16_32);
186# else
187 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PE16_32);
188# endif
189 CHECK_RESULT(g_szBs3ModeName_pe16_32);
190 }
191
192 if (fCurDoWeirdV86Modes && !fOnlyPaging)
193 {
194 PRE_DO_CALL(g_szBs3ModeName_pe16_v86);
195# if ARCH_BITS == 16
196 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
197# else
198 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_V86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
199# endif
200 CHECK_RESULT(g_szBs3ModeName_pe16_v86);
201 }
202
203 if (!fOnlyPaging)
204 {
205 PRE_DO_CALL(g_szBs3ModeName_pe32);
206# if ARCH_BITS == 32
207 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PE32);
208# else
209 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PE32);
210# endif
211 CHECK_RESULT(g_szBs3ModeName_pe32);
212 }
213
214 if (!fOnlyPaging && !fMinimal)
215 {
216 PRE_DO_CALL(g_szBs3ModeName_pe32_16);
217# if ARCH_BITS == 16
218 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
219# else
220 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32_16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
221# endif
222 CHECK_RESULT(g_szBs3ModeName_pe32_16);
223 }
224
225 if (fCurDoV86Modes && !fOnlyPaging)
226 {
227 PRE_DO_CALL(g_szBs3ModeName_pev86);
228# if ARCH_BITS == 16
229 bErrNo = TMPL_NM(Bs3TestCallDoerInPEV86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
230# else
231 bErrNo = TMPL_NM(Bs3TestCallDoerInPEV86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
232# endif
233 CHECK_RESULT(g_szBs3ModeName_pev86);
234 }
235
236 /*
237 * Paged protected mode.
238 */
239 if (!fMinimal)
240 {
241 PRE_DO_CALL(g_szBs3ModeName_pp16);
242# if ARCH_BITS == 16
243 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
244# else
245 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
246# endif
247 CHECK_RESULT(g_szBs3ModeName_pp16);
248 }
249
250 if (!fMinimal)
251 {
252 PRE_DO_CALL(g_szBs3ModeName_pp16_32);
253# if ARCH_BITS == 32
254 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PP16_32);
255# else
256 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PP16_32);
257# endif
258 CHECK_RESULT(g_szBs3ModeName_pp16_32);
259 }
260
261 if (fCurDoWeirdV86Modes)
262 {
263 PRE_DO_CALL(g_szBs3ModeName_pp16_v86);
264# if ARCH_BITS == 16
265 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
266# else
267 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_V86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
268# endif
269 CHECK_RESULT(g_szBs3ModeName_pp16_v86);
270 }
271
272 if (true)
273 {
274 PRE_DO_CALL(g_szBs3ModeName_pp32);
275# if ARCH_BITS == 32
276 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PP32);
277# else
278 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PP32);
279# endif
280 CHECK_RESULT(g_szBs3ModeName_pp32);
281 }
282
283 if (!fMinimal)
284 {
285 PRE_DO_CALL(g_szBs3ModeName_pp32_16);
286# if ARCH_BITS == 16
287 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
288# else
289 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32_16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
290# endif
291 CHECK_RESULT(g_szBs3ModeName_pp32_16);
292 }
293
294 if (fCurDoV86Modes)
295 {
296 PRE_DO_CALL(g_szBs3ModeName_ppv86);
297# if ARCH_BITS == 16
298 bErrNo = TMPL_NM(Bs3TestCallDoerInPPV86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
299# else
300 bErrNo = TMPL_NM(Bs3TestCallDoerInPPV86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
301# endif
302 CHECK_RESULT(g_szBs3ModeName_ppv86);
303 }
304
305
306 /*
307 * Protected mode with PAE paging.
308 */
309 if (!fMinimal)
310 {
311 PRE_DO_CALL(g_szBs3ModeName_pae16);
312# if ARCH_BITS == 16
313 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
314# else
315 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
316# endif
317 CHECK_RESULT(g_szBs3ModeName_pae16);
318 }
319
320 if (!fMinimal)
321 {
322 PRE_DO_CALL(g_szBs3ModeName_pae16_32);
323# if ARCH_BITS == 32
324 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PAE16_32);
325# else
326 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PAE16_32);
327# endif
328 CHECK_RESULT(g_szBs3ModeName_pae16_32);
329 }
330
331 if (fCurDoWeirdV86Modes)
332 {
333 PRE_DO_CALL(g_szBs3ModeName_pae16_v86);
334# if ARCH_BITS == 16
335 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
336# else
337 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_V86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
338# endif
339 CHECK_RESULT(g_szBs3ModeName_pae16_v86);
340 }
341
342 if (true)
343 {
344 PRE_DO_CALL(g_szBs3ModeName_pae32);
345# if ARCH_BITS == 32
346 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PAE32);
347# else
348 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PAE32);
349# endif
350 CHECK_RESULT(g_szBs3ModeName_pae32);
351 }
352
353 if (!fMinimal)
354 {
355 PRE_DO_CALL(g_szBs3ModeName_pae32_16);
356# if ARCH_BITS == 16
357 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
358# else
359 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32_16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
360# endif
361 CHECK_RESULT(g_szBs3ModeName_pae32_16);
362 }
363
364 if (fCurDoV86Modes)
365 {
366 PRE_DO_CALL(g_szBs3ModeName_paev86);
367# if ARCH_BITS == 16
368 bErrNo = TMPL_NM(Bs3TestCallDoerInPAEV86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
369# else
370 bErrNo = TMPL_NM(Bs3TestCallDoerInPAEV86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
371# endif
372 CHECK_RESULT(g_szBs3ModeName_paev86);
373 }
374
375#endif /* ARCH_BITS != 64 */
376
377 /*
378 * Long mode.
379 */
380 if (!fHaveLongMode)
381 {
382 if (fSkipped)
383 Bs3TestSkipped(NULL);
384 continue;
385 }
386
387 if (!fMinimal)
388 {
389 PRE_DO_CALL(g_szBs3ModeName_lm16);
390#if ARCH_BITS == 16
391 bErrNo = TMPL_NM(Bs3TestCallDoerInLM16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
392#else
393 bErrNo = TMPL_NM(Bs3TestCallDoerInLM16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
394#endif
395 CHECK_RESULT(g_szBs3ModeName_lm16);
396 }
397
398 if (!fMinimal)
399 {
400 PRE_DO_CALL(g_szBs3ModeName_lm32);
401#if ARCH_BITS == 32
402 bErrNo = TMPL_NM(Bs3TestCallDoerInLM32)(CONV_TO_FLAT(paEntries[i].pfnWorker));
403#else
404 bErrNo = TMPL_NM(Bs3TestCallDoerInLM32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)));
405#endif
406 CHECK_RESULT(g_szBs3ModeName_lm32);
407 }
408
409 if (true)
410 {
411 PRE_DO_CALL(g_szBs3ModeName_lm64);
412#if ARCH_BITS == 64
413 bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_LM64);
414#else
415 bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c64)), BS3_MODE_LM64);
416#endif
417 CHECK_RESULT(g_szBs3ModeName_lm64);
418 }
419
420 if (fSkipped)
421 Bs3TestSkipped("skipped\n");
422 }
423 Bs3TestSubDone();
424}
425
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette