VirtualBox

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

Last change on this file since 66112 was 65959, checked in by vboxsync, 8 years ago

bs3-cpu-generated-1: updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.1 KB
Line 
1/* $Id: bs3-mode-TestDoModes.c 65959 2017-03-06 21:24:32Z vboxsync $ */
2/** @file
3 * BS3Kit - Bs3TestDoModeTests
4 */
5
6/*
7 * Copyright (C) 2007-2016 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
40
41/*********************************************************************************************************************************
42* Defined Constants And Macros *
43*********************************************************************************************************************************/
44/** @def CONV_TO_FLAT
45 * Get flat address. In 16-bit the parameter is a real mode far address, while
46 * in 32-bit and 64-bit modes it is already flat.
47 */
48/** @def CONV_TO_PROT_FAR16
49 * Get a 32-bit value that makes a protected mode far 16:16 address.
50 */
51/** @def CONV_TO_RM_FAR16
52 * Get a 32-bit value that makes a real mode far 16:16 address. In 16-bit mode
53 * this is already what we've got, except must be converted to uint32_t.
54 */
55#if ARCH_BITS == 16
56# define CONV_TO_FLAT(a_fpfn) (((uint32_t)BS3_FP_SEG(a_fpfn) << 4) + BS3_FP_OFF(a_fpfn))
57# define CONV_TO_PROT_FAR16(a_fpfn) RT_MAKE_U32(BS3_FP_OFF(a_fpfn), Bs3SelRealModeCodeToProtMode(BS3_FP_SEG(a_fpfn)))
58# define CONV_TO_RM_FAR16(a_fpfn) RT_MAKE_U32(BS3_FP_OFF(a_fpfn), BS3_FP_SEG(a_fpfn))
59#else
60# define CONV_TO_FLAT(a_fpfn) ((uint32_t)(uintptr_t)(a_fpfn))
61# define CONV_TO_PROT_FAR16(a_fpfn) Bs3SelFlatCodeToProtFar16((uint32_t)(uintptr_t)(a_fpfn))
62# define CONV_TO_RM_FAR16(a_fpfn) Bs3SelFlatCodeToRealMode( (uint32_t)(uintptr_t)(a_fpfn))
63#endif
64
65
66/*********************************************************************************************************************************
67* Assembly Symbols *
68*********************************************************************************************************************************/
69/* These are in the same code segment as this code, so no FAR necessary. */
70BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInRM)(uint32_t uCallbackFarPtr);
71BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPE16)(uint32_t uCallbackFarPtr);
72BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPE16_32)(uint32_t uFlatAddrCallback);
73BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPE16_V86)(uint32_t uCallbackFarPtr);
74BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPE32)(uint32_t uFlatAddrCallback);
75BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPE32_16)(uint32_t uCallbackFarPtr);
76BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPEV86)(uint32_t uCallbackFarPtr);
77BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPP16)(uint32_t uCallbackFarPtr);
78BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPP16_32)(uint32_t uFlatAddrCallback);
79BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPP16_V86)(uint32_t uCallbackFarPtr);
80BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPP32)(uint32_t uFlatAddrCallback);
81BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPP32_16)(uint32_t uCallbackFarPtr);
82BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPPV86)(uint32_t uCallbackFarPtr);
83BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPAE16)(uint32_t uCallbackFarPtr);
84BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPAE16_32)(uint32_t uFlatAddrCallback);
85BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPAE16_V86)(uint32_t uCallbackFarPtr);
86BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPAE32)(uint32_t uFlatAddrCallback);
87BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPAE32_16)(uint32_t uCallbackFarPtr);
88BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInPAEV86)(uint32_t uCallbackFarPtr);
89BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInLM16)(uint32_t uCallbackFarPtr);
90BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInLM32)(uint32_t uFlatAddrCallback);
91BS3_DECL_NEAR(uint8_t) TMPL_NM(Bs3TestCallDoerInLM64)(uint32_t uFlatAddrCallback);
92
93
94
95/**
96 * Warns about CPU modes that must be skipped.
97 *
98 * It will try not warn about modes for which there are no tests.
99 *
100 * @param paEntries The mode test entries.
101 * @param cEntries The number of tests.
102 * @param bCpuType The CPU type byte (see #BS3CPU_TYPE_MASK).
103 * @param fHavePae Whether the CPU has PAE.
104 * @param fHaveLongMode Whether the CPU does long mode.
105 */
106static void bs3TestWarnAboutSkippedModes(PCBS3TESTMODEENTRY paEntries, unsigned cEntries,
107 uint8_t bCpuType, bool fHavePae, bool fHaveLongMode)
108{
109 bool fComplained286 = false;
110 bool fComplained386 = false;
111 bool fComplainedPAE = false;
112 bool fComplainedAMD64 = false;
113 unsigned i;
114
115 /*
116 * Complaint run.
117 */
118 for (i = 0; i < cEntries; i++)
119 {
120 if ( !fComplained286
121 && paEntries[i].pfnDoPE16)
122 {
123 if (bCpuType < BS3CPU_80286)
124 {
125 Bs3Printf("Only executing real-mode tests as no 80286+ CPU was detected.\n");
126 break;
127 }
128 fComplained286 = true;
129 }
130
131 if ( !fComplained386
132 && ( paEntries[i].pfnDoPE16_32
133 || paEntries[i].pfnDoPE16_V86
134 || paEntries[i].pfnDoPE32
135 || paEntries[i].pfnDoPE32_16
136 || paEntries[i].pfnDoPEV86
137 || paEntries[i].pfnDoPP16
138 || paEntries[i].pfnDoPP16_32
139 || paEntries[i].pfnDoPP16_V86
140 || paEntries[i].pfnDoPP32
141 || paEntries[i].pfnDoPP32_16
142 || paEntries[i].pfnDoPPV86) )
143 {
144 if (bCpuType < BS3CPU_80386)
145 {
146 Bs3Printf("80286 CPU: Only executing 16-bit protected and real mode tests.\n");
147 break;
148 }
149 fComplained386 = true;
150 }
151
152 if ( !fComplainedPAE
153 && ( paEntries[i].pfnDoPAE16
154 || paEntries[i].pfnDoPAE16_32
155 || paEntries[i].pfnDoPAE16_V86
156 || paEntries[i].pfnDoPAE32
157 || paEntries[i].pfnDoPAE32_16
158 || paEntries[i].pfnDoPAEV86) )
159 {
160 if (!fHavePae)
161 {
162 Bs3Printf("PAE and long mode tests will be skipped.\n");
163 break;
164 }
165 fComplainedPAE = true;
166 }
167
168 if ( !fComplainedAMD64
169 && ( paEntries[i].pfnDoLM16
170 || paEntries[i].pfnDoLM32
171 || paEntries[i].pfnDoLM64) )
172 {
173 if (!fHaveLongMode)
174 {
175 Bs3Printf("Long mode tests will be skipped.\n");
176 break;
177 }
178 fComplainedAMD64 = true;
179 }
180 }
181}
182
183#undef Bs3TestDoModes
184BS3_MODE_DEF(void, Bs3TestDoModes,(PCBS3TESTMODEENTRY paEntries, size_t cEntries))
185{
186 bool const fVerbose = true;
187 bool const fDoV86Modes = true;
188 bool const fDoWeirdV86Modes = true;
189 uint16_t const uCpuDetected = g_uBs3CpuDetected;
190 uint8_t const bCpuType = uCpuDetected & BS3CPU_TYPE_MASK;
191 bool const fHavePae = RT_BOOL(uCpuDetected & BS3CPU_F_PAE);
192 bool const fHaveLongMode = RT_BOOL(uCpuDetected & BS3CPU_F_LONG_MODE);
193 unsigned i;
194
195#if 1 /* debug. */
196 Bs3Printf("Bs3TestDoModes: uCpuDetected=%#x fHavePae=%d fHaveLongMode=%d\n", uCpuDetected, fHavePae, fHaveLongMode);
197#endif
198 bs3TestWarnAboutSkippedModes(paEntries, cEntries, bCpuType, fHavePae, fHaveLongMode);
199
200 /*
201 * The real run.
202 */
203 for (i = 0; i < cEntries; i++)
204 {
205 const char *pszFmtStr = "Error #%u (%#x) in %s!\n";
206 bool fSkipped = true;
207 uint8_t bErrNo;
208
209 if (paEntries[i].pszSubTest != NULL)
210 Bs3TestSub(paEntries[i].pszSubTest);
211
212#define PRE_DO_CALL(a_szModeName) do { if (fVerbose) Bs3TestPrintf("...%s\n", a_szModeName); } while (0)
213#define CHECK_RESULT(a_szModeName) \
214 do { \
215 if (bErrNo != BS3TESTDOMODE_SKIPPED) \
216 { \
217 /*Bs3Printf("bErrNo=%#x %s\n", bErrNo, a_szModeName);*/ \
218 fSkipped = false; \
219 if (bErrNo != 0) \
220 Bs3TestFailedF(pszFmtStr, bErrNo, bErrNo, a_szModeName); \
221 } \
222 } while (0)
223
224 if (paEntries[i].pfnDoRM)
225 {
226 PRE_DO_CALL(g_szBs3ModeName_rm);
227 bErrNo = TMPL_NM(Bs3TestCallDoerInRM)(CONV_TO_RM_FAR16(paEntries[i].pfnDoRM));
228 CHECK_RESULT(g_szBs3ModeName_rm);
229 }
230
231 if (bCpuType < BS3CPU_80286)
232 {
233 if (fSkipped)
234 Bs3TestSkipped(NULL);
235 continue;
236 }
237
238 /*
239 * Unpaged prot mode.
240 */
241 if (paEntries[i].pfnDoPE16)
242 {
243 PRE_DO_CALL(g_szBs3ModeName_pe16);
244 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPE16));
245 CHECK_RESULT(g_szBs3ModeName_pe16);
246 }
247 if (bCpuType < BS3CPU_80386)
248 {
249 if (fSkipped)
250 Bs3TestSkipped(NULL);
251 continue;
252 }
253
254 if (paEntries[i].pfnDoPE16_32)
255 {
256 PRE_DO_CALL(g_szBs3ModeName_pe16_32);
257 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPE16_32));
258 CHECK_RESULT(g_szBs3ModeName_pe16_32);
259 }
260
261 if (paEntries[i].pfnDoPE16_V86 && fDoWeirdV86Modes)
262 {
263 PRE_DO_CALL(g_szBs3ModeName_pe16_v86);
264 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPE16_V86));
265 CHECK_RESULT(g_szBs3ModeName_pe16_v86);
266 }
267
268 if (paEntries[i].pfnDoPE32)
269 {
270 PRE_DO_CALL(g_szBs3ModeName_pe32);
271 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(paEntries[i].pfnDoPE32));
272 CHECK_RESULT(g_szBs3ModeName_pe32);
273 }
274
275 if (paEntries[i].pfnDoPE32_16)
276 {
277 PRE_DO_CALL(g_szBs3ModeName_pe32_16);
278 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPE32_16));
279 CHECK_RESULT(g_szBs3ModeName_pe32_16);
280 }
281
282 if (paEntries[i].pfnDoPEV86 && fDoV86Modes)
283 {
284 PRE_DO_CALL(g_szBs3ModeName_pev86);
285 bErrNo = TMPL_NM(Bs3TestCallDoerInPEV86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPEV86));
286 CHECK_RESULT(g_szBs3ModeName_pev86);
287 }
288
289 /*
290 * Paged protected mode.
291 */
292 if (paEntries[i].pfnDoPP16)
293 {
294 PRE_DO_CALL(g_szBs3ModeName_pp16);
295 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPP16));
296 CHECK_RESULT(g_szBs3ModeName_pp16);
297 }
298
299 if (paEntries[i].pfnDoPP16_32)
300 {
301 PRE_DO_CALL(g_szBs3ModeName_pp16_32);
302 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPP16_32));
303 CHECK_RESULT(g_szBs3ModeName_pp16_32);
304 }
305
306 if (paEntries[i].pfnDoPP16_V86 && fDoWeirdV86Modes)
307 {
308 PRE_DO_CALL(g_szBs3ModeName_pp16_v86);
309 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPP16_V86));
310 CHECK_RESULT(g_szBs3ModeName_pp16_v86);
311 }
312
313 if (paEntries[i].pfnDoPP32)
314 {
315 PRE_DO_CALL(g_szBs3ModeName_pp32);
316 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(paEntries[i].pfnDoPP32));
317 CHECK_RESULT(g_szBs3ModeName_pp32);
318 }
319
320 if (paEntries[i].pfnDoPP32_16)
321 {
322 PRE_DO_CALL(g_szBs3ModeName_pp32_16);
323 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPP32_16));
324 CHECK_RESULT(g_szBs3ModeName_pp32_16);
325 }
326
327 if (paEntries[i].pfnDoPPV86 && fDoV86Modes)
328 {
329 PRE_DO_CALL(g_szBs3ModeName_ppv86);
330 bErrNo = TMPL_NM(Bs3TestCallDoerInPPV86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPPV86));
331 CHECK_RESULT(g_szBs3ModeName_ppv86);
332 }
333
334 /*
335 * Protected mode with PAE paging.
336 */
337 if (!fHavePae)
338 {
339 if (fSkipped)
340 Bs3TestSkipped(NULL);
341 continue;
342 }
343
344 if (paEntries[i].pfnDoPAE16)
345 {
346 PRE_DO_CALL(g_szBs3ModeName_pae16);
347 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPAE16));
348 CHECK_RESULT(g_szBs3ModeName_pae16);
349 }
350
351 if (paEntries[i].pfnDoPAE16_32)
352 {
353 PRE_DO_CALL(g_szBs3ModeName_pae16_32);
354 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE16_32));
355 CHECK_RESULT(g_szBs3ModeName_pae16_32);
356 }
357
358 if (paEntries[i].pfnDoPAE16_V86 && fDoWeirdV86Modes)
359 {
360 PRE_DO_CALL(g_szBs3ModeName_pae16_v86);
361 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPAE16_V86));
362 CHECK_RESULT(g_szBs3ModeName_pae16_v86);
363 }
364
365 if (paEntries[i].pfnDoPAE32)
366 {
367 PRE_DO_CALL(g_szBs3ModeName_pae32);
368 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE32));
369 CHECK_RESULT(g_szBs3ModeName_pae32);
370 }
371
372 if (paEntries[i].pfnDoPAE32_16)
373 {
374 PRE_DO_CALL(g_szBs3ModeName_pae32_16);
375 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPAE32_16));
376 CHECK_RESULT(g_szBs3ModeName_pae32_16);
377 }
378
379 if (paEntries[i].pfnDoPAEV86 && fDoV86Modes)
380 {
381 PRE_DO_CALL(g_szBs3ModeName_paev86);
382 bErrNo = TMPL_NM(Bs3TestCallDoerInPAEV86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPAEV86));
383 CHECK_RESULT(g_szBs3ModeName_paev86);
384 }
385
386 /*
387 * Long mode.
388 */
389 if (!fHaveLongMode)
390 {
391 if (fSkipped)
392 Bs3TestSkipped(NULL);
393 continue;
394 }
395
396 if (paEntries[i].pfnDoLM16)
397 {
398 PRE_DO_CALL(g_szBs3ModeName_lm16);
399 bErrNo = TMPL_NM(Bs3TestCallDoerInLM16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoLM16));
400 CHECK_RESULT(g_szBs3ModeName_lm16);
401 }
402
403 if (paEntries[i].pfnDoLM32)
404 {
405 PRE_DO_CALL(g_szBs3ModeName_lm32);
406 bErrNo = TMPL_NM(Bs3TestCallDoerInLM32)(CONV_TO_FLAT(paEntries[i].pfnDoLM32));
407 CHECK_RESULT(g_szBs3ModeName_lm32);
408 }
409
410 if (paEntries[i].pfnDoLM64)
411 {
412 PRE_DO_CALL(g_szBs3ModeName_lm64);
413 bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(paEntries[i].pfnDoLM64));
414 CHECK_RESULT(g_szBs3ModeName_lm64);
415 }
416
417 if (fSkipped)
418 Bs3TestSkipped("skipped\n");
419 }
420 Bs3TestSubDone();
421}
422
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