1 | /* $Id: VMMDevTesting.cpp 46300 2013-05-28 15:31:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMMDev - Testing Extensions.
|
---|
4 | *
|
---|
5 | * To enable: VBoxManage setextradata vmname VBoxInternal/Devices/VMMDev/0/Config/TestingEnabled 1
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2010-2013 Oracle Corporation
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | */
|
---|
19 |
|
---|
20 |
|
---|
21 | /*******************************************************************************
|
---|
22 | * Header Files *
|
---|
23 | *******************************************************************************/
|
---|
24 | #define LOG_GROUP LOG_GROUP_DEV_VMM
|
---|
25 | #include <VBox/VMMDev.h>
|
---|
26 | #include <VBox/vmm/vmapi.h>
|
---|
27 | #include <VBox/log.h>
|
---|
28 | #include <VBox/err.h>
|
---|
29 |
|
---|
30 | #include <iprt/asm.h>
|
---|
31 | #include <iprt/assert.h>
|
---|
32 | #include <iprt/string.h>
|
---|
33 | #include <iprt/time.h>
|
---|
34 | #include <iprt/test.h>
|
---|
35 |
|
---|
36 | #include "VMMDevState.h"
|
---|
37 | #include "VMMDevTesting.h"
|
---|
38 |
|
---|
39 |
|
---|
40 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
41 |
|
---|
42 | #define VMMDEV_TESTING_OUTPUT(a) \
|
---|
43 | do \
|
---|
44 | { \
|
---|
45 | LogAlways(a);\
|
---|
46 | LogRel(a);\
|
---|
47 | } while (0)
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * @callback_method_impl{FNIOMMMIOWRITE}
|
---|
51 | */
|
---|
52 | PDMBOTHCBDECL(int) vmmdevTestingMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
|
---|
53 | {
|
---|
54 | switch (GCPhysAddr)
|
---|
55 | {
|
---|
56 | case VMMDEV_TESTING_MMIO_NOP:
|
---|
57 | switch (cb)
|
---|
58 | {
|
---|
59 | case 8:
|
---|
60 | case 4:
|
---|
61 | case 2:
|
---|
62 | case 1:
|
---|
63 | break;
|
---|
64 | default:
|
---|
65 | AssertFailed();
|
---|
66 | return VERR_INTERNAL_ERROR_5;
|
---|
67 | }
|
---|
68 | return VINF_SUCCESS;
|
---|
69 |
|
---|
70 | default:
|
---|
71 | break;
|
---|
72 | }
|
---|
73 | return VINF_SUCCESS;
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * @callback_method_impl{FNIOMMMIOREAD}
|
---|
79 | */
|
---|
80 | PDMBOTHCBDECL(int) vmmdevTestingMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
|
---|
81 | {
|
---|
82 | switch (GCPhysAddr)
|
---|
83 | {
|
---|
84 | case VMMDEV_TESTING_MMIO_NOP:
|
---|
85 | switch (cb)
|
---|
86 | {
|
---|
87 | case 8:
|
---|
88 | *(uint64_t *)pv = VMMDEV_TESTING_NOP_RET | ((uint64_t)VMMDEV_TESTING_NOP_RET << 32);
|
---|
89 | break;
|
---|
90 | case 4:
|
---|
91 | *(uint32_t *)pv = VMMDEV_TESTING_NOP_RET;
|
---|
92 | break;
|
---|
93 | case 2:
|
---|
94 | *(uint16_t *)pv = (uint16_t)VMMDEV_TESTING_NOP_RET;
|
---|
95 | break;
|
---|
96 | case 1:
|
---|
97 | *(uint8_t *)pv = (uint8_t)VMMDEV_TESTING_NOP_RET;
|
---|
98 | break;
|
---|
99 | default:
|
---|
100 | AssertFailed();
|
---|
101 | return VERR_INTERNAL_ERROR_5;
|
---|
102 | }
|
---|
103 | return VINF_SUCCESS;
|
---|
104 |
|
---|
105 |
|
---|
106 | default:
|
---|
107 | break;
|
---|
108 | }
|
---|
109 |
|
---|
110 | return VINF_IOM_MMIO_UNUSED_FF;
|
---|
111 | }
|
---|
112 |
|
---|
113 | #ifdef IN_RING3
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Executes the VMMDEV_TESTING_CMD_VALUE_REG command when the data is ready.
|
---|
117 | *
|
---|
118 | * @param pDevIns The PDM device instance.
|
---|
119 | * @param pThis The instance VMMDev data.
|
---|
120 | */
|
---|
121 | static void vmmdevTestingCmdExec_ValueReg(PPDMDEVINS pDevIns, VMMDevState *pThis)
|
---|
122 | {
|
---|
123 | char *pszRegNm = strchr(pThis->TestingData.String.sz, ':');
|
---|
124 | if (pszRegNm)
|
---|
125 | {
|
---|
126 | *pszRegNm++ = '\0';
|
---|
127 | pszRegNm = RTStrStrip(pszRegNm);
|
---|
128 | }
|
---|
129 | char *pszValueNm = RTStrStrip(pThis->TestingData.String.sz);
|
---|
130 | size_t const cchValueNm = strlen(pszValueNm);
|
---|
131 | if (cchValueNm && pszRegNm && *pszRegNm)
|
---|
132 | {
|
---|
133 | PUVM pUVM = PDMDevHlpGetUVM(pDevIns);
|
---|
134 | PVM pVM = PDMDevHlpGetVM(pDevIns);
|
---|
135 | VMCPUID idCpu = VMMGetCpuId(pVM);
|
---|
136 | uint64_t u64Value;
|
---|
137 | int rc2 = DBGFR3RegNmQueryU64(pUVM, idCpu, pszRegNm, &u64Value);
|
---|
138 | if (RT_SUCCESS(rc2))
|
---|
139 | {
|
---|
140 | const char *pszWarn = rc2 == VINF_DBGF_TRUNCATED_REGISTER ? " truncated" : "";
|
---|
141 | #if 1 /*!RTTestValue format*/
|
---|
142 | char szFormat[128], szValue[128];
|
---|
143 | RTStrPrintf(szFormat, sizeof(szFormat), "%%VR{%s}", pszRegNm);
|
---|
144 | rc2 = DBGFR3RegPrintf(pUVM, idCpu, szValue, sizeof(szValue), szFormat);
|
---|
145 | if (RT_SUCCESS(rc2))
|
---|
146 | VMMDEV_TESTING_OUTPUT(("testing: VALUE '%s'%*s: %16s {reg=%s}%s\n",
|
---|
147 | pszValueNm,
|
---|
148 | (ssize_t)cchValueNm - 12 > 48 ? 0 : 48 - ((ssize_t)cchValueNm - 12), "",
|
---|
149 | szValue, pszRegNm, pszWarn));
|
---|
150 | else
|
---|
151 | #endif
|
---|
152 | VMMDEV_TESTING_OUTPUT(("testing: VALUE '%s'%*s: %'9llu (%#llx) [0] {reg=%s}%s\n",
|
---|
153 | pszValueNm,
|
---|
154 | (ssize_t)cchValueNm - 12 > 48 ? 0 : 48 - ((ssize_t)cchValueNm - 12), "",
|
---|
155 | u64Value, u64Value, pszRegNm, pszWarn));
|
---|
156 | }
|
---|
157 | else
|
---|
158 | VMMDEV_TESTING_OUTPUT(("testing: error querying register '%s' for value '%s': %Rrc\n",
|
---|
159 | pszRegNm, pszValueNm, rc2));
|
---|
160 | }
|
---|
161 | else
|
---|
162 | VMMDEV_TESTING_OUTPUT(("testing: malformed register value '%s'/'%s'\n", pszValueNm, pszRegNm));
|
---|
163 | }
|
---|
164 |
|
---|
165 | #endif /* IN_RING3 */
|
---|
166 |
|
---|
167 | /**
|
---|
168 | * @callback_method_impl{FNIOMIOPORTOUT}
|
---|
169 | */
|
---|
170 | PDMBOTHCBDECL(int) vmmdevTestingIoWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
|
---|
171 | {
|
---|
172 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
173 |
|
---|
174 | switch (Port)
|
---|
175 | {
|
---|
176 | /*
|
---|
177 | * The NOP I/O ports are used for performance measurements.
|
---|
178 | */
|
---|
179 | case VMMDEV_TESTING_IOPORT_NOP:
|
---|
180 | switch (cb)
|
---|
181 | {
|
---|
182 | case 4:
|
---|
183 | case 2:
|
---|
184 | case 1:
|
---|
185 | break;
|
---|
186 | default:
|
---|
187 | AssertFailed();
|
---|
188 | return VERR_INTERNAL_ERROR_2;
|
---|
189 | }
|
---|
190 | return VINF_SUCCESS;
|
---|
191 |
|
---|
192 | /* The timestamp I/O ports are read-only. */
|
---|
193 | case VMMDEV_TESTING_IOPORT_TS_LOW:
|
---|
194 | case VMMDEV_TESTING_IOPORT_TS_HIGH:
|
---|
195 | break;
|
---|
196 |
|
---|
197 | /*
|
---|
198 | * The command port (DWORD write only).
|
---|
199 | */
|
---|
200 | case VMMDEV_TESTING_IOPORT_CMD:
|
---|
201 | if (cb == 4)
|
---|
202 | {
|
---|
203 | pThis->u32TestingCmd = u32;
|
---|
204 | pThis->offTestingData = 0;
|
---|
205 | RT_ZERO(pThis->TestingData);
|
---|
206 | return VINF_SUCCESS;
|
---|
207 | }
|
---|
208 | break;
|
---|
209 |
|
---|
210 | /*
|
---|
211 | * The data port. Used of providing data for a command.
|
---|
212 | */
|
---|
213 | case VMMDEV_TESTING_IOPORT_DATA:
|
---|
214 | {
|
---|
215 | uint32_t uCmd = pThis->u32TestingCmd;
|
---|
216 | uint32_t off = pThis->offTestingData;
|
---|
217 | switch (uCmd)
|
---|
218 | {
|
---|
219 | case VMMDEV_TESTING_CMD_INIT:
|
---|
220 | case VMMDEV_TESTING_CMD_SUB_NEW:
|
---|
221 | case VMMDEV_TESTING_CMD_FAILED:
|
---|
222 | case VMMDEV_TESTING_CMD_SKIPPED:
|
---|
223 | if ( off < sizeof(pThis->TestingData.String.sz) - 1
|
---|
224 | && cb == 1)
|
---|
225 | {
|
---|
226 | if (u32)
|
---|
227 | {
|
---|
228 | pThis->TestingData.String.sz[off] = u32;
|
---|
229 | pThis->offTestingData = off + 1;
|
---|
230 | }
|
---|
231 | else
|
---|
232 | {
|
---|
233 | #ifdef IN_RING3
|
---|
234 | pThis->TestingData.String.sz[off] = '\0';
|
---|
235 | switch (uCmd)
|
---|
236 | {
|
---|
237 | case VMMDEV_TESTING_CMD_INIT:
|
---|
238 | VMMDEV_TESTING_OUTPUT(("testing: INIT '%s'\n", pThis->TestingData.String.sz));
|
---|
239 | RTTestChangeName(pThis->hTestingTest, pThis->TestingData.String.sz);
|
---|
240 | RTTestBanner(pThis->hTestingTest);
|
---|
241 | break;
|
---|
242 | case VMMDEV_TESTING_CMD_SUB_NEW:
|
---|
243 | VMMDEV_TESTING_OUTPUT(("testing: SUB_NEW '%s'\n", pThis->TestingData.String.sz));
|
---|
244 | RTTestSub(pThis->hTestingTest, pThis->TestingData.String.sz);
|
---|
245 | break;
|
---|
246 | case VMMDEV_TESTING_CMD_FAILED:
|
---|
247 | RTTestFailed(pThis->hTestingTest, "%s", pThis->TestingData.String.sz);
|
---|
248 | VMMDEV_TESTING_OUTPUT(("testing: FAILED '%s'\n", pThis->TestingData.String.sz));
|
---|
249 | break;
|
---|
250 | case VMMDEV_TESTING_CMD_SKIPPED:
|
---|
251 | if (off)
|
---|
252 | RTTestSkipped(pThis->hTestingTest, "%s", pThis->TestingData.String.sz);
|
---|
253 | else
|
---|
254 | RTTestSkipped(pThis->hTestingTest, NULL);
|
---|
255 | VMMDEV_TESTING_OUTPUT(("testing: SKIPPED '%s'\n", pThis->TestingData.String.sz));
|
---|
256 | break;
|
---|
257 | }
|
---|
258 | #else
|
---|
259 | return VINF_IOM_R3_IOPORT_WRITE;
|
---|
260 | #endif
|
---|
261 | }
|
---|
262 | return VINF_SUCCESS;
|
---|
263 | }
|
---|
264 | break;
|
---|
265 |
|
---|
266 | case VMMDEV_TESTING_CMD_TERM:
|
---|
267 | case VMMDEV_TESTING_CMD_SUB_DONE:
|
---|
268 | if ( off == 0
|
---|
269 | && cb == 4)
|
---|
270 | {
|
---|
271 | #ifdef IN_RING3
|
---|
272 | pThis->TestingData.Error.c = u32;
|
---|
273 | if (uCmd == VMMDEV_TESTING_CMD_TERM)
|
---|
274 | {
|
---|
275 | while (RTTestErrorCount(pThis->hTestingTest) < u32)
|
---|
276 | RTTestErrorInc(pThis->hTestingTest); /* A bit stupid, but does the trick. */
|
---|
277 | RTTestSubDone(pThis->hTestingTest);
|
---|
278 | VMMDEV_TESTING_OUTPUT(("testing: TERM - %u errors\n", u32));
|
---|
279 | }
|
---|
280 | else
|
---|
281 | {
|
---|
282 | while (RTTestSubErrorCount(pThis->hTestingTest) < u32)
|
---|
283 | RTTestErrorInc(pThis->hTestingTest); /* A bit stupid, but does the trick. */
|
---|
284 | RTTestSubDone(pThis->hTestingTest);
|
---|
285 | VMMDEV_TESTING_OUTPUT(("testing: SUB_DONE - %u errors\n", u32));
|
---|
286 | }
|
---|
287 | return VINF_SUCCESS;
|
---|
288 | #else
|
---|
289 | return VINF_IOM_R3_IOPORT_WRITE;
|
---|
290 | #endif
|
---|
291 | }
|
---|
292 | break;
|
---|
293 |
|
---|
294 | case VMMDEV_TESTING_CMD_VALUE:
|
---|
295 | if (cb == 4)
|
---|
296 | {
|
---|
297 | if (off == 0)
|
---|
298 | pThis->TestingData.Value.u64Value.s.Lo = u32;
|
---|
299 | else if (off == 4)
|
---|
300 | pThis->TestingData.Value.u64Value.s.Hi = u32;
|
---|
301 | else if (off == 8)
|
---|
302 | pThis->TestingData.Value.u32Unit = u32;
|
---|
303 | else
|
---|
304 | break;
|
---|
305 | pThis->offTestingData = off + 4;
|
---|
306 | return VINF_SUCCESS;
|
---|
307 | }
|
---|
308 | if ( off >= 12
|
---|
309 | && cb == 1
|
---|
310 | && off - 12 < sizeof(pThis->TestingData.Value.szName) - 1)
|
---|
311 | {
|
---|
312 | if (u32)
|
---|
313 | {
|
---|
314 | pThis->TestingData.Value.szName[off - 12] = u32;
|
---|
315 | pThis->offTestingData = off + 1;
|
---|
316 | }
|
---|
317 | else
|
---|
318 | {
|
---|
319 | #ifdef IN_RING3
|
---|
320 | pThis->TestingData.Value.szName[off - 12] = '\0';
|
---|
321 |
|
---|
322 | RTTESTUNIT enmUnit = (RTTESTUNIT)pThis->TestingData.Value.u32Unit;
|
---|
323 | if (enmUnit <= RTTESTUNIT_INVALID || enmUnit >= RTTESTUNIT_END)
|
---|
324 | {
|
---|
325 | VMMDEV_TESTING_OUTPUT(("Invalid log value unit %#x\n", pThis->TestingData.Value.u32Unit));
|
---|
326 | enmUnit = RTTESTUNIT_NONE;
|
---|
327 | }
|
---|
328 | RTTestValue(pThis->hTestingTest, pThis->TestingData.Value.szName,
|
---|
329 | pThis->TestingData.Value.u64Value.u, enmUnit);
|
---|
330 |
|
---|
331 | VMMDEV_TESTING_OUTPUT(("testing: VALUE '%s'%*s: %'9llu (%#llx) [%u]\n",
|
---|
332 | pThis->TestingData.Value.szName,
|
---|
333 | off - 12 > 48 ? 0 : 48 - (off - 12), "",
|
---|
334 | pThis->TestingData.Value.u64Value.u, pThis->TestingData.Value.u64Value.u,
|
---|
335 | pThis->TestingData.Value.u32Unit));
|
---|
336 | #else
|
---|
337 | return VINF_IOM_R3_IOPORT_WRITE;
|
---|
338 | #endif
|
---|
339 | }
|
---|
340 | return VINF_SUCCESS;
|
---|
341 | }
|
---|
342 | break;
|
---|
343 |
|
---|
344 |
|
---|
345 | /*
|
---|
346 | * RTTestValue with the return from DBGFR3RegNmQuery.
|
---|
347 | */
|
---|
348 | case VMMDEV_TESTING_CMD_VALUE_REG:
|
---|
349 | {
|
---|
350 | if ( off < sizeof(pThis->TestingData.String.sz) - 1
|
---|
351 | && cb == 1)
|
---|
352 | {
|
---|
353 | pThis->TestingData.String.sz[off] = u32;
|
---|
354 | if (u32)
|
---|
355 | pThis->offTestingData = off + 1;
|
---|
356 | else
|
---|
357 | #ifdef IN_RING3
|
---|
358 | vmmdevTestingCmdExec_ValueReg(pDevIns, pThis);
|
---|
359 | #else
|
---|
360 | return VINF_IOM_R3_IOPORT_WRITE;
|
---|
361 | #endif
|
---|
362 | return VINF_SUCCESS;
|
---|
363 | }
|
---|
364 | break;
|
---|
365 |
|
---|
366 | }
|
---|
367 |
|
---|
368 | default:
|
---|
369 | break;
|
---|
370 | }
|
---|
371 | Log(("VMMDEV_TESTING_IOPORT_CMD: bad access; cmd=%#x off=%#x cb=%#x u32=%#x\n", uCmd, off, cb, u32));
|
---|
372 | return VINF_SUCCESS;
|
---|
373 | }
|
---|
374 |
|
---|
375 | default:
|
---|
376 | break;
|
---|
377 | }
|
---|
378 |
|
---|
379 | return VERR_IOM_IOPORT_UNUSED;
|
---|
380 | }
|
---|
381 |
|
---|
382 |
|
---|
383 | /**
|
---|
384 | * @callback_method_impl{FNIOMIOPORTIN}
|
---|
385 | */
|
---|
386 | PDMBOTHCBDECL(int) vmmdevTestingIoRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
|
---|
387 | {
|
---|
388 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
389 |
|
---|
390 | switch (Port)
|
---|
391 | {
|
---|
392 | /*
|
---|
393 | * The NOP I/O ports are used for performance measurements.
|
---|
394 | */
|
---|
395 | case VMMDEV_TESTING_IOPORT_NOP:
|
---|
396 | switch (cb)
|
---|
397 | {
|
---|
398 | case 4:
|
---|
399 | case 2:
|
---|
400 | case 1:
|
---|
401 | break;
|
---|
402 | default:
|
---|
403 | AssertFailed();
|
---|
404 | return VERR_INTERNAL_ERROR_2;
|
---|
405 | }
|
---|
406 | *pu32 = VMMDEV_TESTING_NOP_RET;
|
---|
407 | return VINF_SUCCESS;
|
---|
408 |
|
---|
409 | /*
|
---|
410 | * The timestamp I/O ports are obviously used for getting a good fix
|
---|
411 | * on the current time (as seen by the host?).
|
---|
412 | *
|
---|
413 | * The high word is latched when reading the low, so reading low + high
|
---|
414 | * gives you a 64-bit timestamp value.
|
---|
415 | */
|
---|
416 | case VMMDEV_TESTING_IOPORT_TS_LOW:
|
---|
417 | if (cb == 4)
|
---|
418 | {
|
---|
419 | uint64_t NowTS = RTTimeNanoTS();
|
---|
420 | *pu32 = (uint32_t)NowTS;
|
---|
421 | pThis->u32TestingHighTimestamp = (uint32_t)(NowTS >> 32);
|
---|
422 | return VINF_SUCCESS;
|
---|
423 | }
|
---|
424 | break;
|
---|
425 |
|
---|
426 | case VMMDEV_TESTING_IOPORT_TS_HIGH:
|
---|
427 | if (cb == 4)
|
---|
428 | {
|
---|
429 | *pu32 = pThis->u32TestingHighTimestamp;
|
---|
430 | return VINF_SUCCESS;
|
---|
431 | }
|
---|
432 | break;
|
---|
433 |
|
---|
434 | /*
|
---|
435 | * The command and data registers are write-only.
|
---|
436 | */
|
---|
437 | case VMMDEV_TESTING_IOPORT_CMD:
|
---|
438 | case VMMDEV_TESTING_IOPORT_DATA:
|
---|
439 | break;
|
---|
440 |
|
---|
441 | default:
|
---|
442 | break;
|
---|
443 | }
|
---|
444 |
|
---|
445 | return VERR_IOM_IOPORT_UNUSED;
|
---|
446 | }
|
---|
447 |
|
---|
448 |
|
---|
449 | #ifdef IN_RING3
|
---|
450 |
|
---|
451 | /**
|
---|
452 | * Initializes the testing part of the VMMDev if enabled.
|
---|
453 | *
|
---|
454 | * @returns VBox status code.
|
---|
455 | * @param pDevIns The VMMDev device instance.
|
---|
456 | */
|
---|
457 | void vmmdevTestingTerminate(PPDMDEVINS pDevIns)
|
---|
458 | {
|
---|
459 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
460 | if (!pThis->fTestingEnabled)
|
---|
461 | return;
|
---|
462 |
|
---|
463 | if (pThis->hTestingTest != NIL_RTTEST)
|
---|
464 | {
|
---|
465 | RTTestSummaryAndDestroy(pThis->hTestingTest);
|
---|
466 | pThis->hTestingTest = NIL_RTTEST;
|
---|
467 | }
|
---|
468 | }
|
---|
469 |
|
---|
470 |
|
---|
471 | /**
|
---|
472 | * Initializes the testing part of the VMMDev if enabled.
|
---|
473 | *
|
---|
474 | * @returns VBox status code.
|
---|
475 | * @param pDevIns The VMMDev device instance.
|
---|
476 | */
|
---|
477 | int vmmdevTestingInitialize(PPDMDEVINS pDevIns)
|
---|
478 | {
|
---|
479 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
480 | if (!pThis->fTestingEnabled)
|
---|
481 | return VINF_SUCCESS;
|
---|
482 |
|
---|
483 | /*
|
---|
484 | * Register a chunk of MMIO memory that we'll use for various
|
---|
485 | * tests interfaces.
|
---|
486 | */
|
---|
487 | int rc = PDMDevHlpMMIORegister(pDevIns, VMMDEV_TESTING_MMIO_BASE, VMMDEV_TESTING_MMIO_SIZE, NULL /*pvUser*/,
|
---|
488 | IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU,
|
---|
489 | vmmdevTestingMmioWrite, vmmdevTestingMmioRead, "VMMDev Testing");
|
---|
490 | AssertRCReturn(rc, rc);
|
---|
491 | if (pThis->fRZEnabled)
|
---|
492 | {
|
---|
493 | rc = PDMDevHlpMMIORegisterR0(pDevIns, VMMDEV_TESTING_MMIO_BASE, VMMDEV_TESTING_MMIO_SIZE, NIL_RTR0PTR /*pvUser*/,
|
---|
494 | "vmmdevTestingMmioWrite", "vmmdevTestingMmioRead");
|
---|
495 | AssertRCReturn(rc, rc);
|
---|
496 | rc = PDMDevHlpMMIORegisterRC(pDevIns, VMMDEV_TESTING_MMIO_BASE, VMMDEV_TESTING_MMIO_SIZE, NIL_RTRCPTR /*pvUser*/,
|
---|
497 | "vmmdevTestingMmioWrite", "vmmdevTestingMmioRead");
|
---|
498 | AssertRCReturn(rc, rc);
|
---|
499 | }
|
---|
500 |
|
---|
501 |
|
---|
502 | /*
|
---|
503 | * Register the I/O ports used for testing.
|
---|
504 | */
|
---|
505 | rc = PDMDevHlpIOPortRegister(pDevIns, VMMDEV_TESTING_IOPORT_BASE, VMMDEV_TESTING_IOPORT_COUNT, NULL,
|
---|
506 | vmmdevTestingIoWrite,
|
---|
507 | vmmdevTestingIoRead,
|
---|
508 | NULL /*pfnOutStr*/,
|
---|
509 | NULL /*pfnInStr*/,
|
---|
510 | "VMMDev Testing");
|
---|
511 | AssertRCReturn(rc, rc);
|
---|
512 | if (pThis->fRZEnabled)
|
---|
513 | {
|
---|
514 | rc = PDMDevHlpIOPortRegisterR0(pDevIns, VMMDEV_TESTING_IOPORT_BASE, VMMDEV_TESTING_IOPORT_COUNT, NIL_RTR0PTR /*pvUser*/,
|
---|
515 | "vmmdevTestingIoWrite",
|
---|
516 | "vmmdevTestingIoRead",
|
---|
517 | NULL /*pszOutStr*/,
|
---|
518 | NULL /*pszInStr*/,
|
---|
519 | "VMMDev Testing");
|
---|
520 | AssertRCReturn(rc, rc);
|
---|
521 | rc = PDMDevHlpIOPortRegisterRC(pDevIns, VMMDEV_TESTING_IOPORT_BASE, VMMDEV_TESTING_IOPORT_COUNT, NIL_RTRCPTR /*pvUser*/,
|
---|
522 | "vmmdevTestingIoWrite",
|
---|
523 | "vmmdevTestingIoRead",
|
---|
524 | NULL /*pszOutStr*/,
|
---|
525 | NULL /*pszInStr*/,
|
---|
526 | "VMMDev Testing");
|
---|
527 | AssertRCReturn(rc, rc);
|
---|
528 | }
|
---|
529 |
|
---|
530 | /*
|
---|
531 | * Open the XML output file(/pipe/whatever) if specfied.
|
---|
532 | */
|
---|
533 | rc = RTTestCreateEx("VMMDevTesting", RTTEST_C_USE_ENV | RTTEST_C_NO_TLS | RTTEST_C_XML_DELAY_TOP_TEST,
|
---|
534 | RTTESTLVL_INVALID, -1 /*iNativeTestPipe*/, pThis->pszTestingXmlOutput, &pThis->hTestingTest);
|
---|
535 | if (RT_FAILURE(rc))
|
---|
536 | return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, "Error creating testing instance");
|
---|
537 |
|
---|
538 | return VINF_SUCCESS;
|
---|
539 | }
|
---|
540 |
|
---|
541 | #endif /* IN_RING3 */
|
---|
542 | #endif /* !VBOX_WITHOUT_TESTING_FEATURES */
|
---|
543 |
|
---|