VirtualBox

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

Last change on this file since 59946 was 59946, checked in by vboxsync, 9 years ago

bs3kit: fixes (can switch to every weird mode now, though v86 requires some additional work).

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