VirtualBox

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

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

bs3kit: More missing files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.7 KB
Line 
1/* $Id: bs3-mode-TestDoModes.c 59881 2016-03-01 07:21:46Z vboxsync $ */
2/** @file
3 * BS3Kit - Bs3TestDoModeTests
4 */
5
6/*
7 * Copyright (C) 2007-2015 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 offCallback);
61BS3_DECL(uint8_t) TMPL_NM(Bs3TestCallDoerInPE16_V86)(uint16_t offCallback);
62BS3_DECL(uint8_t) TMPL_NM(Bs3TestCallDoerInPE32)(uint32_t offCallback);
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 offCallback);
67BS3_DECL(uint8_t) TMPL_NM(Bs3TestCallDoerInPP16_V86)(uint16_t offCallback);
68BS3_DECL(uint8_t) TMPL_NM(Bs3TestCallDoerInPP32)(uint32_t offCallback);
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 offCallback);
73BS3_DECL(uint8_t) TMPL_NM(Bs3TestCallDoerInPAE16_V86)(uint16_t offCallback);
74BS3_DECL(uint8_t) TMPL_NM(Bs3TestCallDoerInPAE32)(uint32_t offCallback);
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 offCallback);
79BS3_DECL(uint8_t) TMPL_NM(Bs3TestCallDoerInLM64)(uint32_t offCallback);
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
171
172BS3_DECL(void) TMPL_NM(Bs3TestDoModeTests)(PCBS3TESTMODEENTRY paEntries, unsigned cEntries)
173{
174 uint8_t const bCpuType = BS3_DATA_NM(g_uBs3CpuDetected) & BS3CPU_TYPE_MASK;
175 bool const fHavePae = RT_BOOL(BS3_DATA_NM(g_uBs3CpuDetected) & BS3CPU_F_PAE);
176 bool const fHaveLongMode = RT_BOOL(BS3_DATA_NM(g_uBs3CpuDetected) & BS3CPU_F_LONG_MODE);
177 unsigned i;
178
179 bs3TestWarnAboutSkippedModes(paEntries, cEntries, bCpuType, fHavePae, fHaveLongMode);
180
181 /*
182 * The real run.
183 */
184 for (i = 0; i < cEntries; i++)
185 {
186 uint8_t bErrNo;
187 Bs3TestSub(paEntries[i].pszSubTest);
188
189 if (paEntries[i].pfnDoRM)
190 {
191 bErrNo = TMPL_NM(Bs3TestCallDoerInRM)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoRM));
192 if (bErrNo != 0)
193 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_rm));
194 }
195
196 if (bCpuType < BS3CPU_80286)
197 continue;
198
199 /*
200 * Unpaged prot mode.
201 */
202 if (paEntries[i].pfnDoPE16)
203 {
204 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPE16));
205 if (bErrNo != 0)
206 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pe16));
207 }
208
209 if (bCpuType < BS3CPU_80386)
210 continue;
211
212 if (paEntries[i].pfnDoPE16_32)
213 {
214 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPE16_32));
215 if (bErrNo != 0)
216 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pe16_32));
217 }
218
219 if (paEntries[i].pfnDoPE16_V86)
220 {
221 bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_V86)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPE16_V86));
222 if (bErrNo != 0)
223 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pe16_v86));
224 }
225
226 if (paEntries[i].pfnDoPE32)
227 {
228 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(paEntries[i].pfnDoPE32));
229 if (bErrNo != 0)
230 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pe32));
231 }
232
233 if (paEntries[i].pfnDoPE32_16)
234 {
235 bErrNo = TMPL_NM(Bs3TestCallDoerInPE32_16)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPE32_16));
236 if (bErrNo != 0)
237 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pe32_16));
238 }
239
240 if (paEntries[i].pfnDoPEV86)
241 {
242 bErrNo = TMPL_NM(Bs3TestCallDoerInPEV86)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPEV86));
243 if (bErrNo != 0)
244 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pev86));
245 }
246
247 /*
248 * Paged protected mode.
249 */
250 if (paEntries[i].pfnDoPP16)
251 {
252 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPP16));
253 if (bErrNo != 0)
254 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pp16));
255 }
256
257 if (paEntries[i].pfnDoPP16_32)
258 {
259 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPP16_32));
260 if (bErrNo != 0)
261 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pp16_32));
262 }
263
264 if (paEntries[i].pfnDoPP16_V86)
265 {
266 bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_V86)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPP16_V86));
267 if (bErrNo != 0)
268 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pp16_v86));
269 }
270
271 if (paEntries[i].pfnDoPP32)
272 {
273 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(paEntries[i].pfnDoPP32));
274 if (bErrNo != 0)
275 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pp32));
276 }
277
278 if (paEntries[i].pfnDoPP32_16)
279 {
280 bErrNo = TMPL_NM(Bs3TestCallDoerInPP32_16)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPP32_16));
281 if (bErrNo != 0)
282 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pp32_16));
283 }
284
285 if (paEntries[i].pfnDoPPV86)
286 {
287 bErrNo = TMPL_NM(Bs3TestCallDoerInPPV86)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPPV86));
288 if (bErrNo != 0)
289 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_ppv86));
290 }
291
292 /*
293 * Protected mode with PAE paging.
294 */
295 if (!fHavePae)
296 continue;
297
298 if (paEntries[i].pfnDoPAE16)
299 {
300 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPAE16));
301 if (bErrNo != 0)
302 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pae16));
303 }
304
305 if (paEntries[i].pfnDoPAE16_32)
306 {
307 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE16_32));
308 if (bErrNo != 0)
309 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pae16_32));
310 }
311
312 if (paEntries[i].pfnDoPAE16_V86)
313 {
314 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_V86)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPAE16_V86));
315 if (bErrNo != 0)
316 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pae16_v86));
317 }
318
319 if (paEntries[i].pfnDoPAE32)
320 {
321 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE32));
322 if (bErrNo != 0)
323 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pae32));
324 }
325
326 if (paEntries[i].pfnDoPAE32_16)
327 {
328 bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32_16)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPAE32_16));
329 if (bErrNo != 0)
330 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_pae32_16));
331 }
332
333 if (paEntries[i].pfnDoPAEV86)
334 {
335 bErrNo = TMPL_NM(Bs3TestCallDoerInPAEV86)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoPAEV86));
336 if (bErrNo != 0)
337 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_paev86));
338 }
339
340 /*
341 * Long mode.
342 */
343 if (!fHaveLongMode)
344 continue;
345
346 if (paEntries[i].pfnDoLM16)
347 {
348 bErrNo = TMPL_NM(Bs3TestCallDoerInLM16)(CONV_TO_BS3TEXT16(paEntries[i].pfnDoLM16));
349 if (bErrNo != 0)
350 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_lm16));
351 }
352
353 if (paEntries[i].pfnDoLM32)
354 {
355 bErrNo = TMPL_NM(Bs3TestCallDoerInLM32)(CONV_TO_FLAT(paEntries[i].pfnDoLM32));
356 if (bErrNo != 0)
357 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_lm32));
358 }
359
360 if (paEntries[i].pfnDoLM64)
361 {
362 bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(paEntries[i].pfnDoLM64));
363 if (bErrNo != 0)
364 Bs3TestFailedF("Error #%u (%#x) in %s!\n", bErrNo, bErrNo, BS3_DATA_NM(g_szBs3ModeName_lm64));
365 }
366 }
367}
368
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