VirtualBox

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

Last change on this file since 95296 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.8 KB
Line 
1/* $Id: bs3-mode-TestDoModesByOne.c 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * BS3Kit - Bs3TestDoModesByOne
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* Assembly Symbols *
44*********************************************************************************************************************************/
45/* Assembly helpers for switching to the work bitcount and calling it. */
46BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo16_f16(uint8_t bMode);
47BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo16_c32(uint8_t bMode);
48BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo16_c64(uint8_t bMode);
49BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo32_f16(uint8_t bMode);
50BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo32_c32(uint8_t bMode);
51BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo32_c64(uint8_t bMode);
52BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo64_f16(uint8_t bMode);
53BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo64_c32(uint8_t bMode);
54BS3_DECL_FAR(uint8_t) Bs3TestCallDoerTo64_c64(uint8_t bMode);
55
56
57/** The current worker function, picked up by our assembly helpers. */
58#ifndef DOXYGEN_RUNNING
59# define g_pfnBs3TestDoModesByOneCurrent BS3_CMN_NM(g_pfnBs3TestDoModesByOneCurrent)
60#endif
61extern PFNBS3TESTDOMODE g_pfnBs3TestDoModesByOneCurrent;
62
63#include <iprt/asm-amd64-x86.h>
64
65
66#undef Bs3TestDoModesByOne
67BS3_MODE_DEF(void, Bs3TestDoModesByOne,(PCBS3TESTMODEBYONEENTRY paEntries, size_t cEntries, uint32_t fFlags))
68{
69 bool const fVerbose = true;
70 bool const fDoV86Modes = true;
71 bool const fDoWeirdV86Modes = true;
72 uint16_t const uCpuDetected = g_uBs3CpuDetected;
73 uint8_t const bCpuType = uCpuDetected & BS3CPU_TYPE_MASK;
74 bool const fHavePae = RT_BOOL(uCpuDetected & BS3CPU_F_PAE);
75 bool const fHaveLongMode = RT_BOOL(uCpuDetected & BS3CPU_F_LONG_MODE);
76 unsigned i;
77
78#if 1 /* debug. */
79 Bs3Printf("Bs3TestDoModesByOne: uCpuDetected=%#x fHavePae=%d fHaveLongMode=%d\n", uCpuDetected, fHavePae, fHaveLongMode);
80#endif
81
82 /*
83 * Inform about modes we won't test (if any).
84 */
85 if (bCpuType < BS3CPU_80286)
86 Bs3Printf("Only executing real-mode tests as no 80286+ CPU was detected.\n");
87 else if (bCpuType < BS3CPU_80386)
88 Bs3Printf("80286 CPU: Only executing 16-bit protected and real mode tests.\n");
89 else if (!fHavePae)
90 Bs3Printf("PAE and long mode tests will be skipped.\n");
91 else if (!fHaveLongMode)
92 Bs3Printf("Long mode tests will be skipped.\n");
93#if ARCH_BITS != 16
94 Bs3Printf("Real-mode tests will be skipped.\n");
95#endif
96
97 /*
98 * The real run.
99 */
100 for (i = 0; i < cEntries; i++)
101 {
102 const char *pszFmtStr = "Error #%u (%#x) in %s!\n";
103 bool fSkipped = true;
104 bool const fOnlyPaging = RT_BOOL(paEntries[i].fFlags & BS3TESTMODEBYONEENTRY_F_ONLY_PAGING);
105 bool const fMinimal = RT_BOOL(paEntries[i].fFlags & BS3TESTMODEBYONEENTRY_F_MINIMAL);
106 bool const fCurDoV86Modes = fDoV86Modes && !fMinimal;
107 bool const fCurDoWeirdV86Modes = fDoWeirdV86Modes && fCurDoV86Modes;
108 uint8_t bErrNo;
109 Bs3TestSub(paEntries[i].pszSubTest);
110
111#define PRE_DO_CALL(a_szModeName) do { if (fVerbose) Bs3TestPrintf("...%s\n", a_szModeName); } while (0)
112#define CHECK_RESULT(a_szModeName) \
113 do { \
114 if (bErrNo != BS3TESTDOMODE_SKIPPED) \
115 { \
116 /*Bs3Printf("bErrNo=%#x %s\n", bErrNo, a_szModeName);*/ \
117 fSkipped = false; \
118 if (bErrNo != 0) \
119 Bs3TestFailedF(pszFmtStr, bErrNo, bErrNo, a_szModeName); \
120 } \
121 } while (0)
122
123 g_pfnBs3TestDoModesByOneCurrent = paEntries[i].pfnWorker;
124
125#if ARCH_BITS != 64
126
127# if ARCH_BITS == 16
128 if (!fOnlyPaging)
129 {
130 PRE_DO_CALL(g_szBs3ModeName_rm);
131 bErrNo = TMPL_NM(Bs3TestCallDoerInRM)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
132 CHECK_RESULT(g_szBs3ModeName_rm);
133 }
134# endif
135
136 if (bCpuType < BS3CPU_80286)
137 {
138 if (fSkipped)
139 Bs3TestSkipped(NULL);
140 continue;
141 }
142
143 /*
144 * Unpaged prot mode.
145 */
146 if (!fOnlyPaging && (!fMinimal || bCpuType < BS3CPU_80386))
147 {
148 PRE_DO_CALL(g_szBs3ModeName_pe16);
149# if ARCH_BITS == 16
150 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
151# else
152 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
153# endif
154 CHECK_RESULT(g_szBs3ModeName_pe16);
155 }
156 if (bCpuType < BS3CPU_80386)
157 {
158 if (fSkipped)
159 Bs3TestSkipped(NULL);
160 continue;
161 }
162
163 if (!fOnlyPaging)
164 {
165 PRE_DO_CALL(g_szBs3ModeName_pe16_32);
166# if ARCH_BITS == 32
167 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PE16_32);
168# else
169 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PE16_32);
170# endif
171 CHECK_RESULT(g_szBs3ModeName_pe16_32);
172 }
173
174 if (fCurDoWeirdV86Modes && !fOnlyPaging)
175 {
176 PRE_DO_CALL(g_szBs3ModeName_pe16_v86);
177# if ARCH_BITS == 16
178 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
179# else
180 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_V86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
181# endif
182 CHECK_RESULT(g_szBs3ModeName_pe16_v86);
183 }
184
185 if (!fOnlyPaging)
186 {
187 PRE_DO_CALL(g_szBs3ModeName_pe32);
188# if ARCH_BITS == 32
189 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PE32);
190# else
191 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PE32);
192# endif
193 CHECK_RESULT(g_szBs3ModeName_pe32);
194 }
195
196 if (!fOnlyPaging && !fMinimal)
197 {
198 PRE_DO_CALL(g_szBs3ModeName_pe32_16);
199# if ARCH_BITS == 16
200 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
201# else
202 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32_16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
203# endif
204 CHECK_RESULT(g_szBs3ModeName_pe32_16);
205 }
206
207 if (fCurDoV86Modes && !fOnlyPaging)
208 {
209 PRE_DO_CALL(g_szBs3ModeName_pev86);
210# if ARCH_BITS == 16
211 bErrNo = TMPL_NM(Bs3TestCallDoerInPEV86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
212# else
213 bErrNo = TMPL_NM(Bs3TestCallDoerInPEV86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
214# endif
215 CHECK_RESULT(g_szBs3ModeName_pev86);
216 }
217
218 /*
219 * Paged protected mode.
220 */
221 if (!fMinimal)
222 {
223 PRE_DO_CALL(g_szBs3ModeName_pp16);
224# if ARCH_BITS == 16
225 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
226# else
227 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
228# endif
229 CHECK_RESULT(g_szBs3ModeName_pp16);
230 }
231
232 if (!fMinimal)
233 {
234 PRE_DO_CALL(g_szBs3ModeName_pp16_32);
235# if ARCH_BITS == 32
236 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PP16_32);
237# else
238 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PP16_32);
239# endif
240 CHECK_RESULT(g_szBs3ModeName_pp16_32);
241 }
242
243 if (fCurDoWeirdV86Modes)
244 {
245 PRE_DO_CALL(g_szBs3ModeName_pp16_v86);
246# if ARCH_BITS == 16
247 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
248# else
249 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_V86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
250# endif
251 CHECK_RESULT(g_szBs3ModeName_pp16_v86);
252 }
253
254 if (true)
255 {
256 PRE_DO_CALL(g_szBs3ModeName_pp32);
257# if ARCH_BITS == 32
258 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PP32);
259# else
260 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PP32);
261# endif
262 CHECK_RESULT(g_szBs3ModeName_pp32);
263 }
264
265 if (!fMinimal)
266 {
267 PRE_DO_CALL(g_szBs3ModeName_pp32_16);
268# if ARCH_BITS == 16
269 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
270# else
271 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32_16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
272# endif
273 CHECK_RESULT(g_szBs3ModeName_pp32_16);
274 }
275
276 if (fCurDoV86Modes)
277 {
278 PRE_DO_CALL(g_szBs3ModeName_ppv86);
279# if ARCH_BITS == 16
280 bErrNo = TMPL_NM(Bs3TestCallDoerInPPV86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
281# else
282 bErrNo = TMPL_NM(Bs3TestCallDoerInPPV86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
283# endif
284 CHECK_RESULT(g_szBs3ModeName_ppv86);
285 }
286
287
288 /*
289 * Protected mode with PAE paging.
290 */
291 if (!fMinimal)
292 {
293 PRE_DO_CALL(g_szBs3ModeName_pae16);
294# if ARCH_BITS == 16
295 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
296# else
297 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
298# endif
299 CHECK_RESULT(g_szBs3ModeName_pae16);
300 }
301
302 if (!fMinimal)
303 {
304 PRE_DO_CALL(g_szBs3ModeName_pae16_32);
305# if ARCH_BITS == 32
306 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PAE16_32);
307# else
308 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PAE16_32);
309# endif
310 CHECK_RESULT(g_szBs3ModeName_pae16_32);
311 }
312
313 if (fCurDoWeirdV86Modes)
314 {
315 PRE_DO_CALL(g_szBs3ModeName_pae16_v86);
316# if ARCH_BITS == 16
317 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
318# else
319 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_V86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
320# endif
321 CHECK_RESULT(g_szBs3ModeName_pae16_v86);
322 }
323
324 if (true)
325 {
326 PRE_DO_CALL(g_szBs3ModeName_pae32);
327# if ARCH_BITS == 32
328 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_PAE32);
329# else
330 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)), BS3_MODE_PAE32);
331# endif
332 CHECK_RESULT(g_szBs3ModeName_pae32);
333 }
334
335 if (!fMinimal)
336 {
337 PRE_DO_CALL(g_szBs3ModeName_pae32_16);
338# if ARCH_BITS == 16
339 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
340# else
341 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32_16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
342# endif
343 CHECK_RESULT(g_szBs3ModeName_pae32_16);
344 }
345
346 if (fCurDoV86Modes)
347 {
348 PRE_DO_CALL(g_szBs3ModeName_paev86);
349# if ARCH_BITS == 16
350 bErrNo = TMPL_NM(Bs3TestCallDoerInPAEV86)(CONV_TO_RM_FAR16(paEntries[i].pfnWorker));
351# else
352 bErrNo = TMPL_NM(Bs3TestCallDoerInPAEV86)(CONV_TO_RM_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
353# endif
354 CHECK_RESULT(g_szBs3ModeName_paev86);
355 }
356
357#endif /* ARCH_BITS != 64 */
358
359 /*
360 * Long mode.
361 */
362 if (!fHaveLongMode)
363 {
364 if (fSkipped)
365 Bs3TestSkipped(NULL);
366 continue;
367 }
368
369 if (!fMinimal)
370 {
371 PRE_DO_CALL(g_szBs3ModeName_lm16);
372#if ARCH_BITS == 16
373 bErrNo = TMPL_NM(Bs3TestCallDoerInLM16)(CONV_TO_PROT_FAR16(paEntries[i].pfnWorker));
374#else
375 bErrNo = TMPL_NM(Bs3TestCallDoerInLM16)(CONV_TO_PROT_FAR16(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_f16)));
376#endif
377 CHECK_RESULT(g_szBs3ModeName_lm16);
378 }
379
380 if (!fMinimal)
381 {
382 PRE_DO_CALL(g_szBs3ModeName_lm32);
383#if ARCH_BITS == 32
384 bErrNo = TMPL_NM(Bs3TestCallDoerInLM32)(CONV_TO_FLAT(paEntries[i].pfnWorker));
385#else
386 bErrNo = TMPL_NM(Bs3TestCallDoerInLM32)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c32)));
387#endif
388 CHECK_RESULT(g_szBs3ModeName_lm32);
389 }
390
391 if (true)
392 {
393 PRE_DO_CALL(g_szBs3ModeName_lm64);
394#if ARCH_BITS == 64
395 bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(paEntries[i].pfnWorker), BS3_MODE_LM64);
396#else
397 bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(RT_CONCAT3(Bs3TestCallDoerTo,ARCH_BITS,_c64)), BS3_MODE_LM64);
398#endif
399 CHECK_RESULT(g_szBs3ModeName_lm64);
400 }
401
402 if (fSkipped)
403 Bs3TestSkipped("skipped\n");
404 }
405 Bs3TestSubDone();
406}
407
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