VirtualBox

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

Last change on this file since 96407 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.0 KB
Line 
1/* $Id: bs3-mode-TestDoModesByMax.c 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * BS3Kit - Bs3TestDoModesByMax
4 */
5
6/*
7 * Copyright (C) 2007-2022 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/**
54 * Warns about CPU modes that must be skipped.
55 *
56 * It will try not warn about modes for which there are no tests.
57 *
58 * @param paEntries The mode test entries.
59 * @param cEntries The number of tests.
60 * @param bCpuType The CPU type byte (see #BS3CPU_TYPE_MASK).
61 * @param fHavePae Whether the CPU has PAE.
62 * @param fHaveLongMode Whether the CPU does long mode.
63 */
64static void bs3TestWarnAboutSkippedModes(PCBS3TESTMODEBYMAXENTRY paEntries, unsigned cEntries,
65 uint8_t bCpuType, bool fHavePae, bool fHaveLongMode)
66{
67 bool fComplained286 = false;
68 bool fComplained386 = false;
69 bool fComplainedPAE = false;
70 bool fComplainedAMD64 = false;
71 unsigned i;
72
73 /*
74 * Complaint run.
75 */
76 for (i = 0; i < cEntries; i++)
77 {
78 if ( !fComplained286
79 && paEntries[i].pfnDoPE16)
80 {
81 if (bCpuType < BS3CPU_80286)
82 {
83 Bs3Printf("Only executing real-mode tests as no 80286+ CPU was detected.\n");
84 break;
85 }
86 fComplained286 = true;
87 }
88
89 if ( !fComplained386
90 && ( paEntries[i].fDoPE16_32
91 || paEntries[i].fDoPE16_V86
92 || paEntries[i].fDoPE32
93 || paEntries[i].fDoPE32_16
94 || paEntries[i].fDoPEV86
95 || paEntries[i].fDoPP16
96 || paEntries[i].fDoPP16_32
97 || paEntries[i].fDoPP16_V86
98 || paEntries[i].fDoPP32
99 || paEntries[i].fDoPP32_16
100 || paEntries[i].fDoPPV86) )
101 {
102 if (bCpuType < BS3CPU_80386)
103 {
104 Bs3Printf("80286 CPU: Only executing 16-bit protected and real mode tests.\n");
105 break;
106 }
107 fComplained386 = true;
108 }
109
110 if ( !fComplainedPAE
111 && ( paEntries[i].fDoPAE16
112 || paEntries[i].fDoPAE16_32
113 || paEntries[i].fDoPAE16_V86
114 || paEntries[i].fDoPAE32
115 || paEntries[i].fDoPAE32_16
116 || paEntries[i].fDoPAEV86) )
117 {
118 if (!fHavePae)
119 {
120 Bs3Printf("PAE and long mode tests will be skipped.\n");
121 break;
122 }
123 fComplainedPAE = true;
124 }
125
126 if ( !fComplainedAMD64
127 && ( paEntries[i].fDoLM16
128 || paEntries[i].fDoLM32
129 || paEntries[i].fDoLM64) )
130 {
131 if (!fHaveLongMode)
132 {
133 Bs3Printf("Long mode tests will be skipped.\n");
134 break;
135 }
136 fComplainedAMD64 = true;
137 }
138 }
139}
140
141#undef Bs3TestDoModesByMax
142BS3_MODE_DEF(void, Bs3TestDoModesByMax,(PCBS3TESTMODEBYMAXENTRY paEntries, size_t cEntries))
143{
144 bool const fVerbose = true;
145 bool const fDoV86Modes = true;
146 bool const fDoWeirdV86Modes = true;
147 uint16_t const uCpuDetected = g_uBs3CpuDetected;
148 uint8_t const bCpuType = uCpuDetected & BS3CPU_TYPE_MASK;
149 bool const fHavePae = RT_BOOL(uCpuDetected & BS3CPU_F_PAE);
150 bool const fHaveLongMode = RT_BOOL(uCpuDetected & BS3CPU_F_LONG_MODE);
151 unsigned i;
152
153#if 1 /* debug. */
154 Bs3Printf("Bs3TestDoModes: uCpuDetected=%#x fHavePae=%d fHaveLongMode=%d\n", uCpuDetected, fHavePae, fHaveLongMode);
155#endif
156 bs3TestWarnAboutSkippedModes(paEntries, cEntries, bCpuType, fHavePae, fHaveLongMode);
157
158 /*
159 * The real run.
160 */
161 for (i = 0; i < cEntries; i++)
162 {
163 const char *pszFmtStr = "Error #%u (%#x) in %s!\n";
164 bool fSkipped = true;
165 uint8_t bErrNo;
166
167 if (paEntries[i].pszSubTest != NULL)
168 Bs3TestSub(paEntries[i].pszSubTest);
169
170#define PRE_DO_CALL(a_szModeName) do { if (fVerbose) Bs3TestPrintf("...%s\n", a_szModeName); } while (0)
171#define CHECK_RESULT(a_szModeName) \
172 do { \
173 if (bErrNo != BS3TESTDOMODE_SKIPPED) \
174 { \
175 /*Bs3Printf("bErrNo=%#x %s\n", bErrNo, a_szModeName);*/ \
176 fSkipped = false; \
177 if (bErrNo != 0) \
178 Bs3TestFailedF(pszFmtStr, bErrNo, bErrNo, a_szModeName); \
179 } \
180 } while (0)
181
182 if (paEntries[i].fDoRM)
183 {
184 PRE_DO_CALL(g_szBs3ModeName_rm);
185 bErrNo = TMPL_NM(Bs3TestCallDoerInRM)(CONV_TO_RM_FAR16(paEntries[i].pfnDoRM));
186 CHECK_RESULT(g_szBs3ModeName_rm);
187 }
188
189 if (bCpuType < BS3CPU_80286)
190 {
191 if (fSkipped)
192 Bs3TestSkipped(NULL);
193 continue;
194 }
195
196 /*
197 * Unpaged prot mode.
198 */
199 if (paEntries[i].fDoPE16)
200 {
201 PRE_DO_CALL(g_szBs3ModeName_pe16);
202 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPE16));
203 CHECK_RESULT(g_szBs3ModeName_pe16);
204 }
205 if (bCpuType < BS3CPU_80386)
206 {
207 if (fSkipped)
208 Bs3TestSkipped(NULL);
209 continue;
210 }
211
212 if (paEntries[i].fDoPE16_32)
213 {
214 PRE_DO_CALL(g_szBs3ModeName_pe16_32);
215 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPE16_32), BS3_MODE_PE16_32);
216 CHECK_RESULT(g_szBs3ModeName_pe16_32);
217 }
218
219 if (paEntries[i].fDoPE16_V86 && fDoWeirdV86Modes)
220 {
221 PRE_DO_CALL(g_szBs3ModeName_pe16_v86);
222 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPE16_32), BS3_MODE_PE16_V86);
223 CHECK_RESULT(g_szBs3ModeName_pe16_v86);
224 }
225
226 if (paEntries[i].fDoPE32)
227 {
228 PRE_DO_CALL(g_szBs3ModeName_pe32);
229 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(paEntries[i].pfnDoPE32), BS3_MODE_PE32);
230 CHECK_RESULT(g_szBs3ModeName_pe32);
231 }
232
233 if (paEntries[i].fDoPE32_16)
234 {
235 PRE_DO_CALL(g_szBs3ModeName_pe32_16);
236 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(paEntries[i].pfnDoPE32), BS3_MODE_PE32_16);
237 CHECK_RESULT(g_szBs3ModeName_pe32_16);
238 }
239
240 if (paEntries[i].fDoPEV86 && fDoV86Modes)
241 {
242 PRE_DO_CALL(g_szBs3ModeName_pev86);
243 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(paEntries[i].pfnDoPE32), BS3_MODE_PEV86);
244 CHECK_RESULT(g_szBs3ModeName_pev86);
245 }
246
247 /*
248 * Paged protected mode.
249 */
250 if (paEntries[i].fDoPP16)
251 {
252 PRE_DO_CALL(g_szBs3ModeName_pp16);
253 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPP16_32), BS3_MODE_PP16);
254 CHECK_RESULT(g_szBs3ModeName_pp16);
255 }
256
257 if (paEntries[i].fDoPP16_32)
258 {
259 PRE_DO_CALL(g_szBs3ModeName_pp16_32);
260 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPP16_32), BS3_MODE_PP16_32);
261 CHECK_RESULT(g_szBs3ModeName_pp16_32);
262 }
263
264 if (paEntries[i].fDoPP16_V86 && fDoWeirdV86Modes)
265 {
266 PRE_DO_CALL(g_szBs3ModeName_pp16_v86);
267 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPP16_32), BS3_MODE_PP16_V86);
268 CHECK_RESULT(g_szBs3ModeName_pp16_v86);
269 }
270
271 if (paEntries[i].fDoPP32)
272 {
273 PRE_DO_CALL(g_szBs3ModeName_pp32);
274 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(paEntries[i].pfnDoPP32), BS3_MODE_PP32);
275 CHECK_RESULT(g_szBs3ModeName_pp32);
276 }
277
278 if (paEntries[i].fDoPP32_16)
279 {
280 PRE_DO_CALL(g_szBs3ModeName_pp32_16);
281 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(paEntries[i].pfnDoPP32), BS3_MODE_PP32_16);
282 CHECK_RESULT(g_szBs3ModeName_pp32_16);
283 }
284
285 if (paEntries[i].fDoPPV86 && fDoV86Modes)
286 {
287 PRE_DO_CALL(g_szBs3ModeName_ppv86);
288 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(paEntries[i].pfnDoPP32), BS3_MODE_PPV86);
289 CHECK_RESULT(g_szBs3ModeName_ppv86);
290 }
291
292 /*
293 * Protected mode with PAE paging.
294 */
295 if (!fHavePae)
296 {
297 if (fSkipped)
298 Bs3TestSkipped(NULL);
299 continue;
300 }
301
302 if (paEntries[i].fDoPAE16)
303 {
304 PRE_DO_CALL(g_szBs3ModeName_pae16);
305 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE16_32), BS3_MODE_PAE16);
306 CHECK_RESULT(g_szBs3ModeName_pae16);
307 }
308
309 if (paEntries[i].fDoPAE16_32)
310 {
311 PRE_DO_CALL(g_szBs3ModeName_pae16_32);
312 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE16_32), BS3_MODE_PAE16_32);
313 CHECK_RESULT(g_szBs3ModeName_pae16_32);
314 }
315
316 if (paEntries[i].fDoPAE16_V86 && fDoWeirdV86Modes)
317 {
318 PRE_DO_CALL(g_szBs3ModeName_pae16_v86);
319 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE16_32), BS3_MODE_PAE16_V86);
320 CHECK_RESULT(g_szBs3ModeName_pae16_v86);
321 }
322
323 if (paEntries[i].fDoPAE32)
324 {
325 PRE_DO_CALL(g_szBs3ModeName_pae32);
326 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE32), BS3_MODE_PAE32);
327 CHECK_RESULT(g_szBs3ModeName_pae32);
328 }
329
330 if (paEntries[i].fDoPAE32_16)
331 {
332 PRE_DO_CALL(g_szBs3ModeName_pae32_16);
333 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE32), BS3_MODE_PAE32_16);
334 CHECK_RESULT(g_szBs3ModeName_pae32_16);
335 }
336
337 if (paEntries[i].fDoPAEV86 && fDoV86Modes)
338 {
339 PRE_DO_CALL(g_szBs3ModeName_paev86);
340 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE32), BS3_MODE_PAEV86);
341 CHECK_RESULT(g_szBs3ModeName_paev86);
342 }
343
344 /*
345 * Long mode.
346 */
347 if (!fHaveLongMode)
348 {
349 if (fSkipped)
350 Bs3TestSkipped(NULL);
351 continue;
352 }
353
354 if (paEntries[i].fDoLM16)
355 {
356 PRE_DO_CALL(g_szBs3ModeName_lm16);
357 bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(paEntries[i].pfnDoLM64), BS3_MODE_LM16);
358 CHECK_RESULT(g_szBs3ModeName_lm16);
359 }
360
361 if (paEntries[i].fDoLM32)
362 {
363 PRE_DO_CALL(g_szBs3ModeName_lm32);
364 bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(paEntries[i].pfnDoLM64), BS3_MODE_LM32);
365 CHECK_RESULT(g_szBs3ModeName_lm32);
366 }
367
368 if (paEntries[i].fDoLM64)
369 {
370 PRE_DO_CALL(g_szBs3ModeName_lm64);
371 bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(paEntries[i].pfnDoLM64), BS3_MODE_LM64);
372 CHECK_RESULT(g_szBs3ModeName_lm64);
373 }
374
375 if (fSkipped)
376 Bs3TestSkipped("skipped\n");
377 }
378 Bs3TestSubDone();
379}
380
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