VirtualBox

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

Last change on this file since 102157 was 98103, checked in by vboxsync, 2 years 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.5 KB
Line 
1/* $Id: bs3-mode-TestDoModesByOne.c 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * BS3Kit - Bs3TestDoModesByOne
4 */
5
6/*
7 * Copyright (C) 2007-2023 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 fCurDoV86Modes = fDoV86Modes && !fMinimal;
117 bool const fCurDoWeirdV86Modes = fDoWeirdV86Modes && fCurDoV86Modes;
118 uint8_t bErrNo;
119 Bs3TestSub(paEntries[i].pszSubTest);
120
121#define PRE_DO_CALL(a_szModeName) do { if (fVerbose) Bs3TestPrintf("...%s\n", a_szModeName); } while (0)
122#define CHECK_RESULT(a_szModeName) \
123 do { \
124 if (bErrNo != BS3TESTDOMODE_SKIPPED) \
125 { \
126 /*Bs3Printf("bErrNo=%#x %s\n", bErrNo, a_szModeName);*/ \
127 fSkipped = false; \
128 if (bErrNo != 0) \
129 Bs3TestFailedF(pszFmtStr, bErrNo, bErrNo, a_szModeName); \
130 } \
131 } while (0)
132
133 g_pfnBs3TestDoModesByOneCurrent = paEntries[i].pfnWorker;
134
135#if ARCH_BITS != 64
136
137# if ARCH_BITS == 16
138 if (!fOnlyPaging)
139 {
140 PRE_DO_CALL(g_szBs3ModeName_rm);
141 bErrNo = TMPL_NM(Bs3TestCallDoerInRM)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
142 CHECK_RESULT(g_szBs3ModeName_rm);
143 }
144# else
145 if (!fOnlyPaging && (paEntries[i].fFlags | fFlags) & BS3TESTMODEBYONEENTRY_F_REAL_MODE_READY)
146 {
147 PRE_DO_CALL(g_szBs3ModeName_rm);
148 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_RM);
149 CHECK_RESULT(g_szBs3ModeName_rm);
150 }
151# endif
152
153 if (bCpuType < BS3CPU_80286)
154 {
155 if (fSkipped)
156 Bs3TestSkipped(NULL);
157 continue;
158 }
159
160 /*
161 * Unpaged prot mode.
162 */
163 if (!fOnlyPaging && (!fMinimal || bCpuType < BS3CPU_80386))
164 {
165 PRE_DO_CALL(g_szBs3ModeName_pe16);
166# if ARCH_BITS == 16
167 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
168# else
169 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
170# endif
171 CHECK_RESULT(g_szBs3ModeName_pe16);
172 }
173 if (bCpuType < BS3CPU_80386)
174 {
175 if (fSkipped)
176 Bs3TestSkipped(NULL);
177 continue;
178 }
179
180 if (!fOnlyPaging)
181 {
182 PRE_DO_CALL(g_szBs3ModeName_pe16_32);
183# if ARCH_BITS == 32
184 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PE16_32);
185# else
186 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PE16_32);
187# endif
188 CHECK_RESULT(g_szBs3ModeName_pe16_32);
189 }
190
191 if (fCurDoWeirdV86Modes && !fOnlyPaging)
192 {
193 PRE_DO_CALL(g_szBs3ModeName_pe16_v86);
194# if ARCH_BITS == 16
195 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
196# else
197 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_V86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
198# endif
199 CHECK_RESULT(g_szBs3ModeName_pe16_v86);
200 }
201
202 if (!fOnlyPaging)
203 {
204 PRE_DO_CALL(g_szBs3ModeName_pe32);
205# if ARCH_BITS == 32
206 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PE32);
207# else
208 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PE32);
209# endif
210 CHECK_RESULT(g_szBs3ModeName_pe32);
211 }
212
213 if (!fOnlyPaging && !fMinimal)
214 {
215 PRE_DO_CALL(g_szBs3ModeName_pe32_16);
216# if ARCH_BITS == 16
217 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
218# else
219 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32_16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
220# endif
221 CHECK_RESULT(g_szBs3ModeName_pe32_16);
222 }
223
224 if (fCurDoV86Modes && !fOnlyPaging)
225 {
226 PRE_DO_CALL(g_szBs3ModeName_pev86);
227# if ARCH_BITS == 16
228 bErrNo = TMPL_NM(Bs3TestCallDoerInPEV86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
229# else
230 bErrNo = TMPL_NM(Bs3TestCallDoerInPEV86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
231# endif
232 CHECK_RESULT(g_szBs3ModeName_pev86);
233 }
234
235 /*
236 * Paged protected mode.
237 */
238 if (!fMinimal)
239 {
240 PRE_DO_CALL(g_szBs3ModeName_pp16);
241# if ARCH_BITS == 16
242 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
243# else
244 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
245# endif
246 CHECK_RESULT(g_szBs3ModeName_pp16);
247 }
248
249 if (!fMinimal)
250 {
251 PRE_DO_CALL(g_szBs3ModeName_pp16_32);
252# if ARCH_BITS == 32
253 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PP16_32);
254# else
255 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PP16_32);
256# endif
257 CHECK_RESULT(g_szBs3ModeName_pp16_32);
258 }
259
260 if (fCurDoWeirdV86Modes)
261 {
262 PRE_DO_CALL(g_szBs3ModeName_pp16_v86);
263# if ARCH_BITS == 16
264 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
265# else
266 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_V86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
267# endif
268 CHECK_RESULT(g_szBs3ModeName_pp16_v86);
269 }
270
271 if (true)
272 {
273 PRE_DO_CALL(g_szBs3ModeName_pp32);
274# if ARCH_BITS == 32
275 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PP32);
276# else
277 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PP32);
278# endif
279 CHECK_RESULT(g_szBs3ModeName_pp32);
280 }
281
282 if (!fMinimal)
283 {
284 PRE_DO_CALL(g_szBs3ModeName_pp32_16);
285# if ARCH_BITS == 16
286 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
287# else
288 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32_16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
289# endif
290 CHECK_RESULT(g_szBs3ModeName_pp32_16);
291 }
292
293 if (fCurDoV86Modes)
294 {
295 PRE_DO_CALL(g_szBs3ModeName_ppv86);
296# if ARCH_BITS == 16
297 bErrNo = TMPL_NM(Bs3TestCallDoerInPPV86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
298# else
299 bErrNo = TMPL_NM(Bs3TestCallDoerInPPV86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
300# endif
301 CHECK_RESULT(g_szBs3ModeName_ppv86);
302 }
303
304
305 /*
306 * Protected mode with PAE paging.
307 */
308 if (!fMinimal)
309 {
310 PRE_DO_CALL(g_szBs3ModeName_pae16);
311# if ARCH_BITS == 16
312 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
313# else
314 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
315# endif
316 CHECK_RESULT(g_szBs3ModeName_pae16);
317 }
318
319 if (!fMinimal)
320 {
321 PRE_DO_CALL(g_szBs3ModeName_pae16_32);
322# if ARCH_BITS == 32
323 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PAE16_32);
324# else
325 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PAE16_32);
326# endif
327 CHECK_RESULT(g_szBs3ModeName_pae16_32);
328 }
329
330 if (fCurDoWeirdV86Modes)
331 {
332 PRE_DO_CALL(g_szBs3ModeName_pae16_v86);
333# if ARCH_BITS == 16
334 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
335# else
336 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_V86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
337# endif
338 CHECK_RESULT(g_szBs3ModeName_pae16_v86);
339 }
340
341 if (true)
342 {
343 PRE_DO_CALL(g_szBs3ModeName_pae32);
344# if ARCH_BITS == 32
345 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PAE32);
346# else
347 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PAE32);
348# endif
349 CHECK_RESULT(g_szBs3ModeName_pae32);
350 }
351
352 if (!fMinimal)
353 {
354 PRE_DO_CALL(g_szBs3ModeName_pae32_16);
355# if ARCH_BITS == 16
356 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
357# else
358 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32_16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
359# endif
360 CHECK_RESULT(g_szBs3ModeName_pae32_16);
361 }
362
363 if (fCurDoV86Modes)
364 {
365 PRE_DO_CALL(g_szBs3ModeName_paev86);
366# if ARCH_BITS == 16
367 bErrNo = TMPL_NM(Bs3TestCallDoerInPAEV86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
368# else
369 bErrNo = TMPL_NM(Bs3TestCallDoerInPAEV86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
370# endif
371 CHECK_RESULT(g_szBs3ModeName_paev86);
372 }
373
374#endif /* ARCH_BITS != 64 */
375
376 /*
377 * Long mode.
378 */
379 if (!fHaveLongMode)
380 {
381 if (fSkipped)
382 Bs3TestSkipped(NULL);
383 continue;
384 }
385
386 if (!fMinimal)
387 {
388 PRE_DO_CALL(g_szBs3ModeName_lm16);
389#if ARCH_BITS == 16
390 bErrNo = TMPL_NM(Bs3TestCallDoerInLM16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
391#else
392 bErrNo = TMPL_NM(Bs3TestCallDoerInLM16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
393#endif
394 CHECK_RESULT(g_szBs3ModeName_lm16);
395 }
396
397 if (!fMinimal)
398 {
399 PRE_DO_CALL(g_szBs3ModeName_lm32);
400#if ARCH_BITS == 32
401 bErrNo = TMPL_NM(Bs3TestCallDoerInLM32)(CONV_TO_FLAT(paEntries[i].pfnWorker));
402#else
403 bErrNo = TMPL_NM(Bs3TestCallDoerInLM32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)));
404#endif
405 CHECK_RESULT(g_szBs3ModeName_lm32);
406 }
407
408 if (true)
409 {
410 PRE_DO_CALL(g_szBs3ModeName_lm64);
411#if ARCH_BITS == 64
412 bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_LM64);
413#else
414 bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c64)), BS3_MODE_LM64);
415#endif
416 CHECK_RESULT(g_szBs3ModeName_lm64);
417 }
418
419 if (fSkipped)
420 Bs3TestSkipped("skipped\n");
421 }
422 Bs3TestSubDone();
423}
424
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