1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
|
/* $Id: bs3-mode-TestDoModes.c $ */
/** @file
* BS3Kit - Bs3TestDoModes
*/
/*
* Copyright (C) 2007-2023 Oracle and/or its affiliates.
*
* This file is part of VirtualBox base platform packages, as
* available from https://www.virtualbox.org.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, in version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses>.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
* in the VirtualBox distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*
* SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
*/
/*********************************************************************************************************************************
* Header Files *
*********************************************************************************************************************************/
#if TMPL_MODE == BS3_MODE_RM
# define BS3_USE_RM_TEXT_SEG 1 /* Real mode version in RMTEXT16 segment to save space. */
# include "bs3kit-template-header.h"
# include "bs3-cmn-test.h"
#else
# include "bs3kit-template-header.h"
# include "bs3-cmn-test.h"
#endif
#include "bs3-mode-TestDoModes.h"
/**
* Warns about CPU modes that must be skipped.
*
* It will try not warn about modes for which there are no tests.
*
* @param paEntries The mode test entries.
* @param cEntries The number of tests.
* @param bCpuType The CPU type byte (see #BS3CPU_TYPE_MASK).
* @param fHavePae Whether the CPU has PAE.
* @param fHaveLongMode Whether the CPU does long mode.
*/
static void bs3TestWarnAboutSkippedModes(PCBS3TESTMODEENTRY paEntries, unsigned cEntries,
uint8_t bCpuType, bool fHavePae, bool fHaveLongMode)
{
bool fComplained286 = false;
bool fComplained386 = false;
bool fComplainedPAE = false;
bool fComplainedAMD64 = false;
unsigned i;
/*
* Complaint run.
*/
for (i = 0; i < cEntries; i++)
{
if ( !fComplained286
&& paEntries[i].pfnDoPE16)
{
if (bCpuType < BS3CPU_80286)
{
Bs3Printf("Only executing real-mode tests as no 80286+ CPU was detected.\n");
break;
}
fComplained286 = true;
}
if ( !fComplained386
&& ( paEntries[i].pfnDoPE16_32
|| paEntries[i].pfnDoPE16_V86
|| paEntries[i].pfnDoPE32
|| paEntries[i].pfnDoPE32_16
|| paEntries[i].pfnDoPEV86
|| paEntries[i].pfnDoPP16
|| paEntries[i].pfnDoPP16_32
|| paEntries[i].pfnDoPP16_V86
|| paEntries[i].pfnDoPP32
|| paEntries[i].pfnDoPP32_16
|| paEntries[i].pfnDoPPV86) )
{
if (bCpuType < BS3CPU_80386)
{
Bs3Printf("80286 CPU: Only executing 16-bit protected and real mode tests.\n");
break;
}
fComplained386 = true;
}
if ( !fComplainedPAE
&& ( paEntries[i].pfnDoPAE16
|| paEntries[i].pfnDoPAE16_32
|| paEntries[i].pfnDoPAE16_V86
|| paEntries[i].pfnDoPAE32
|| paEntries[i].pfnDoPAE32_16
|| paEntries[i].pfnDoPAEV86) )
{
if (!fHavePae)
{
Bs3Printf("PAE and long mode tests will be skipped.\n");
break;
}
fComplainedPAE = true;
}
if ( !fComplainedAMD64
&& ( paEntries[i].pfnDoLM16
|| paEntries[i].pfnDoLM32
|| paEntries[i].pfnDoLM64) )
{
if (!fHaveLongMode)
{
Bs3Printf("Long mode tests will be skipped.\n");
break;
}
fComplainedAMD64 = true;
}
}
}
#undef Bs3TestDoModes
BS3_MODE_DEF(void, Bs3TestDoModes,(PCBS3TESTMODEENTRY paEntries, size_t cEntries))
{
bool const fVerbose = true;
bool const fDoV86Modes = true;
bool const fDoWeirdV86Modes = true;
uint16_t const uCpuDetected = g_uBs3CpuDetected;
uint8_t const bCpuType = uCpuDetected & BS3CPU_TYPE_MASK;
bool const fHavePae = RT_BOOL(uCpuDetected & BS3CPU_F_PAE);
bool const fHaveLongMode = RT_BOOL(uCpuDetected & BS3CPU_F_LONG_MODE);
unsigned i;
#if 1 /* debug. */
Bs3Printf("Bs3TestDoModes: uCpuDetected=%#x fHavePae=%d fHaveLongMode=%d\n", uCpuDetected, fHavePae, fHaveLongMode);
#endif
bs3TestWarnAboutSkippedModes(paEntries, cEntries, bCpuType, fHavePae, fHaveLongMode);
/*
* The real run.
*/
for (i = 0; i < cEntries; i++)
{
const char *pszFmtStr = "Error #%u (%#x) in %s!\n";
bool fSkipped = true;
uint8_t bErrNo;
if (paEntries[i].pszSubTest != NULL)
Bs3TestSub(paEntries[i].pszSubTest);
#define PRE_DO_CALL(a_szModeName) do { if (fVerbose) Bs3TestPrintf("...%s\n", a_szModeName); } while (0)
#define CHECK_RESULT(a_szModeName) \
do { \
if (bErrNo != BS3TESTDOMODE_SKIPPED) \
{ \
/*Bs3Printf("bErrNo=%#x %s\n", bErrNo, a_szModeName);*/ \
fSkipped = false; \
if (bErrNo != 0) \
Bs3TestFailedF(pszFmtStr, bErrNo, bErrNo, a_szModeName); \
} \
} while (0)
if (paEntries[i].pfnDoRM)
{
PRE_DO_CALL(g_szBs3ModeName_rm);
bErrNo = TMPL_NM(Bs3TestCallDoerInRM)(CONV_TO_RM_FAR16(paEntries[i].pfnDoRM));
CHECK_RESULT(g_szBs3ModeName_rm);
}
if (bCpuType < BS3CPU_80286)
{
if (fSkipped)
Bs3TestSkipped(NULL);
continue;
}
/*
* Unpaged prot mode.
*/
if (paEntries[i].pfnDoPE16)
{
PRE_DO_CALL(g_szBs3ModeName_pe16);
bErrNo = TMPL_NM(Bs3TestCallDoerInPE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPE16));
CHECK_RESULT(g_szBs3ModeName_pe16);
}
if (bCpuType < BS3CPU_80386)
{
if (fSkipped)
Bs3TestSkipped(NULL);
continue;
}
if (paEntries[i].pfnDoPE16_32)
{
PRE_DO_CALL(g_szBs3ModeName_pe16_32);
bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPE16_32), BS3_MODE_PE16_32);
CHECK_RESULT(g_szBs3ModeName_pe16_32);
}
if (paEntries[i].pfnDoPE16_V86 && fDoWeirdV86Modes)
{
PRE_DO_CALL(g_szBs3ModeName_pe16_v86);
bErrNo = TMPL_NM(Bs3TestCallDoerInPE16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPE16_V86));
CHECK_RESULT(g_szBs3ModeName_pe16_v86);
}
if (paEntries[i].pfnDoPE32)
{
PRE_DO_CALL(g_szBs3ModeName_pe32);
bErrNo = TMPL_NM(Bs3TestCallDoerInPE32)(CONV_TO_FLAT(paEntries[i].pfnDoPE32), BS3_MODE_PE32);
CHECK_RESULT(g_szBs3ModeName_pe32);
}
if (paEntries[i].pfnDoPE32_16)
{
PRE_DO_CALL(g_szBs3ModeName_pe32_16);
bErrNo = TMPL_NM(Bs3TestCallDoerInPE32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPE32_16));
CHECK_RESULT(g_szBs3ModeName_pe32_16);
}
if (paEntries[i].pfnDoPEV86 && fDoV86Modes)
{
PRE_DO_CALL(g_szBs3ModeName_pev86);
bErrNo = TMPL_NM(Bs3TestCallDoerInPEV86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPEV86));
CHECK_RESULT(g_szBs3ModeName_pev86);
}
/*
* Paged protected mode.
*/
if (paEntries[i].pfnDoPP16)
{
PRE_DO_CALL(g_szBs3ModeName_pp16);
bErrNo = TMPL_NM(Bs3TestCallDoerInPP16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPP16));
CHECK_RESULT(g_szBs3ModeName_pp16);
}
if (paEntries[i].pfnDoPP16_32)
{
PRE_DO_CALL(g_szBs3ModeName_pp16_32);
bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPP16_32), BS3_MODE_PP16_32);
CHECK_RESULT(g_szBs3ModeName_pp16_32);
}
if (paEntries[i].pfnDoPP16_V86 && fDoWeirdV86Modes)
{
PRE_DO_CALL(g_szBs3ModeName_pp16_v86);
bErrNo = TMPL_NM(Bs3TestCallDoerInPP16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPP16_V86));
CHECK_RESULT(g_szBs3ModeName_pp16_v86);
}
if (paEntries[i].pfnDoPP32)
{
PRE_DO_CALL(g_szBs3ModeName_pp32);
bErrNo = TMPL_NM(Bs3TestCallDoerInPP32)(CONV_TO_FLAT(paEntries[i].pfnDoPP32), BS3_MODE_PP32);
CHECK_RESULT(g_szBs3ModeName_pp32);
}
if (paEntries[i].pfnDoPP32_16)
{
PRE_DO_CALL(g_szBs3ModeName_pp32_16);
bErrNo = TMPL_NM(Bs3TestCallDoerInPP32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPP32_16));
CHECK_RESULT(g_szBs3ModeName_pp32_16);
}
if (paEntries[i].pfnDoPPV86 && fDoV86Modes)
{
PRE_DO_CALL(g_szBs3ModeName_ppv86);
bErrNo = TMPL_NM(Bs3TestCallDoerInPPV86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPPV86));
CHECK_RESULT(g_szBs3ModeName_ppv86);
}
/*
* Protected mode with PAE paging.
*/
if (!fHavePae)
{
if (fSkipped)
Bs3TestSkipped(NULL);
continue;
}
if (paEntries[i].pfnDoPAE16)
{
PRE_DO_CALL(g_szBs3ModeName_pae16);
bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPAE16));
CHECK_RESULT(g_szBs3ModeName_pae16);
}
if (paEntries[i].pfnDoPAE16_32)
{
PRE_DO_CALL(g_szBs3ModeName_pae16_32);
bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE16_32), BS3_MODE_PAE16_32);
CHECK_RESULT(g_szBs3ModeName_pae16_32);
}
if (paEntries[i].pfnDoPAE16_V86 && fDoWeirdV86Modes)
{
PRE_DO_CALL(g_szBs3ModeName_pae16_v86);
bErrNo = TMPL_NM(Bs3TestCallDoerInPAE16_V86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPAE16_V86));
CHECK_RESULT(g_szBs3ModeName_pae16_v86);
}
if (paEntries[i].pfnDoPAE32)
{
PRE_DO_CALL(g_szBs3ModeName_pae32);
bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32)(CONV_TO_FLAT(paEntries[i].pfnDoPAE32), BS3_MODE_PAE32);
CHECK_RESULT(g_szBs3ModeName_pae32);
}
if (paEntries[i].pfnDoPAE32_16)
{
PRE_DO_CALL(g_szBs3ModeName_pae32_16);
bErrNo = TMPL_NM(Bs3TestCallDoerInPAE32_16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoPAE32_16));
CHECK_RESULT(g_szBs3ModeName_pae32_16);
}
if (paEntries[i].pfnDoPAEV86 && fDoV86Modes)
{
PRE_DO_CALL(g_szBs3ModeName_paev86);
bErrNo = TMPL_NM(Bs3TestCallDoerInPAEV86)(CONV_TO_RM_FAR16(paEntries[i].pfnDoPAEV86));
CHECK_RESULT(g_szBs3ModeName_paev86);
}
/*
* Long mode.
*/
if (!fHaveLongMode)
{
if (fSkipped)
Bs3TestSkipped(NULL);
continue;
}
if (paEntries[i].pfnDoLM16)
{
PRE_DO_CALL(g_szBs3ModeName_lm16);
bErrNo = TMPL_NM(Bs3TestCallDoerInLM16)(CONV_TO_PROT_FAR16(paEntries[i].pfnDoLM16));
CHECK_RESULT(g_szBs3ModeName_lm16);
}
if (paEntries[i].pfnDoLM32)
{
PRE_DO_CALL(g_szBs3ModeName_lm32);
bErrNo = TMPL_NM(Bs3TestCallDoerInLM32)(CONV_TO_FLAT(paEntries[i].pfnDoLM32));
CHECK_RESULT(g_szBs3ModeName_lm32);
}
if (paEntries[i].pfnDoLM64)
{
PRE_DO_CALL(g_szBs3ModeName_lm64);
bErrNo = TMPL_NM(Bs3TestCallDoerInLM64)(CONV_TO_FLAT(paEntries[i].pfnDoLM64), BS3_MODE_LM64);
CHECK_RESULT(g_szBs3ModeName_lm64);
}
if (fSkipped)
Bs3TestSkipped("skipped\n");
}
Bs3TestSubDone();
}
|