1 | /** @file
|
---|
2 | * tstDevice: Shared definitions between the framework and the shim library.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2017-2022 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef VBOX_INCLUDED_SRC_testcase_tstDeviceInternal_h
|
---|
18 | #define VBOX_INCLUDED_SRC_testcase_tstDeviceInternal_h
|
---|
19 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
20 | # pragma once
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | #include <VBox/param.h>
|
---|
24 | #include <VBox/types.h>
|
---|
25 | #include <iprt/assert.h>
|
---|
26 | #include <iprt/list.h>
|
---|
27 | #include <iprt/semaphore.h>
|
---|
28 | #include <iprt/critsect.h>
|
---|
29 |
|
---|
30 | #include "tstDeviceCfg.h"
|
---|
31 | #include "tstDevicePlugin.h"
|
---|
32 |
|
---|
33 | RT_C_DECLS_BEGIN
|
---|
34 |
|
---|
35 | #define PDM_MAX_DEVICE_INSTANCE_SIZE _4M
|
---|
36 |
|
---|
37 | /** Converts PDM device instance to the device under test structure. */
|
---|
38 | #define TSTDEV_PDMDEVINS_2_DUT(a_pDevIns) ((a_pDevIns)->Internal.s.pDut)
|
---|
39 |
|
---|
40 | /** Forward declaration of internal test device instance data. */
|
---|
41 | typedef struct TSTDEVDUTINT *PTSTDEVDUTINT;
|
---|
42 |
|
---|
43 |
|
---|
44 | /** Pointer to a const PDM module descriptor. */
|
---|
45 | typedef const struct TSTDEVPDMMOD *PCTSTDEVPDMMOD;
|
---|
46 |
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * PDM device descriptor.
|
---|
50 | */
|
---|
51 | typedef struct TSTDEVPDMDEV
|
---|
52 | {
|
---|
53 | /** Node for the known device list. */
|
---|
54 | RTLISTNODE NdPdmDevs;
|
---|
55 | /** Pointer to the PDM module containing the device. */
|
---|
56 | PCTSTDEVPDMMOD pPdmMod;
|
---|
57 | /** Device registration structure. */
|
---|
58 | const struct PDMDEVREGR3 *pReg;
|
---|
59 | } TSTDEVPDMDEV;
|
---|
60 | /** Pointer to a PDM device descriptor .*/
|
---|
61 | typedef TSTDEVPDMDEV *PTSTDEVPDMDEV;
|
---|
62 | /** Pointer to a constant PDM device descriptor .*/
|
---|
63 | typedef const TSTDEVPDMDEV *PCTSTDEVPDMDEV;
|
---|
64 |
|
---|
65 |
|
---|
66 | /**
|
---|
67 | * CFGM node structure.
|
---|
68 | */
|
---|
69 | typedef struct CFGMNODE
|
---|
70 | {
|
---|
71 | /** Device under test this CFGM node is for. */
|
---|
72 | PTSTDEVDUTINT pDut;
|
---|
73 | /** @todo: */
|
---|
74 | } CFGMNODE;
|
---|
75 |
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Private device instance data.
|
---|
79 | */
|
---|
80 | typedef struct PDMDEVINSINTR3
|
---|
81 | {
|
---|
82 | /** Pointer to the device under test the PDM device instance is for. */
|
---|
83 | PTSTDEVDUTINT pDut;
|
---|
84 | } PDMDEVINSINTR3;
|
---|
85 | AssertCompile(sizeof(PDMDEVINSINTR3) <= (HC_ARCH_BITS == 32 ? 72 : 112 + 0x28));
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * Private device instance data.
|
---|
89 | */
|
---|
90 | typedef struct PDMDEVINSINTR0
|
---|
91 | {
|
---|
92 | /** Pointer to the device under test the PDM device instance is for. */
|
---|
93 | PTSTDEVDUTINT pDut;
|
---|
94 | } PDMDEVINSINTR0;
|
---|
95 | AssertCompile(sizeof(PDMDEVINSINTR0) <= (HC_ARCH_BITS == 32 ? 72 : 112 + 0x28));
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Private device instance data.
|
---|
99 | */
|
---|
100 | typedef struct PDMDEVINSINTRC
|
---|
101 | {
|
---|
102 | /** Pointer to the device under test the PDM device instance is for. */
|
---|
103 | PTSTDEVDUTINT pDut;
|
---|
104 | } PDMDEVINSINTRC;
|
---|
105 | AssertCompile(sizeof(PDMDEVINSINTRC) <= (HC_ARCH_BITS == 32 ? 72 : 112 + 0x28));
|
---|
106 |
|
---|
107 | typedef struct PDMPCIDEVINT
|
---|
108 | {
|
---|
109 | bool fRegistered;
|
---|
110 | } PDMPCIDEVINT;
|
---|
111 |
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Internal PDM critical section structure.
|
---|
115 | */
|
---|
116 | typedef struct PDMCRITSECTINT
|
---|
117 | {
|
---|
118 | /** The actual critical section used for emulation. */
|
---|
119 | RTCRITSECT CritSect;
|
---|
120 | } PDMCRITSECTINT;
|
---|
121 | AssertCompile(sizeof(PDMCRITSECTINT) <= (HC_ARCH_BITS == 32 ? 0x80 : 0xc0));
|
---|
122 |
|
---|
123 |
|
---|
124 | /**
|
---|
125 | * SSM handle state.
|
---|
126 | */
|
---|
127 | typedef struct SSMHANDLE
|
---|
128 | {
|
---|
129 | /** Pointer to the device under test the handle is for. */
|
---|
130 | PTSTDEVDUTINT pDut;
|
---|
131 | /** The saved state data buffer. */
|
---|
132 | uint8_t *pbSavedState;
|
---|
133 | /** Size of the saved state. */
|
---|
134 | size_t cbSavedState;
|
---|
135 | /** Current offset into the data buffer. */
|
---|
136 | uint32_t offDataBuffer;
|
---|
137 | /** Current unit version. */
|
---|
138 | uint32_t uCurUnitVer;
|
---|
139 | /** Status code. */
|
---|
140 | int rc;
|
---|
141 | } SSMHANDLE;
|
---|
142 |
|
---|
143 |
|
---|
144 | /**
|
---|
145 | * MM Heap allocation.
|
---|
146 | */
|
---|
147 | typedef struct TSTDEVMMHEAPALLOC
|
---|
148 | {
|
---|
149 | /** Node for the list of allocations. */
|
---|
150 | RTLISTNODE NdMmHeap;
|
---|
151 | /** Pointer to the device under test the allocation was made for. */
|
---|
152 | PTSTDEVDUTINT pDut;
|
---|
153 | /** Size of the allocation. */
|
---|
154 | size_t cbAlloc;
|
---|
155 | /** Start of the real allocation. */
|
---|
156 | RT_FLEXIBLE_ARRAY_EXTENSION
|
---|
157 | uint8_t abAlloc[RT_FLEXIBLE_ARRAY];
|
---|
158 | } TSTDEVMMHEAPALLOC;
|
---|
159 | /** Pointer to a MM Heap allocation. */
|
---|
160 | typedef TSTDEVMMHEAPALLOC *PTSTDEVMMHEAPALLOC;
|
---|
161 | /** Pointer to a const MM Heap allocation. */
|
---|
162 | typedef const TSTDEVMMHEAPALLOC *PCTSTDEVMMHEAPALLOC;
|
---|
163 |
|
---|
164 | AssertCompileMemberAlignment(TSTDEVMMHEAPALLOC, abAlloc, HC_ARCH_BITS == 64 ? 16 : 8);
|
---|
165 |
|
---|
166 |
|
---|
167 | /**
|
---|
168 | * The usual device/driver/internal/external stuff.
|
---|
169 | */
|
---|
170 | typedef enum
|
---|
171 | {
|
---|
172 | /** The usual invalid entry. */
|
---|
173 | PDMTHREADTYPE_INVALID = 0,
|
---|
174 | /** Device type. */
|
---|
175 | PDMTHREADTYPE_DEVICE,
|
---|
176 | /** USB Device type. */
|
---|
177 | PDMTHREADTYPE_USB,
|
---|
178 | /** Driver type. */
|
---|
179 | PDMTHREADTYPE_DRIVER,
|
---|
180 | /** Internal type. */
|
---|
181 | PDMTHREADTYPE_INTERNAL,
|
---|
182 | /** External type. */
|
---|
183 | PDMTHREADTYPE_EXTERNAL,
|
---|
184 | /** The usual 32-bit hack. */
|
---|
185 | PDMTHREADTYPE_32BIT_HACK = 0x7fffffff
|
---|
186 | } PDMTHREADTYPE;
|
---|
187 |
|
---|
188 |
|
---|
189 | /**
|
---|
190 | * The internal structure for the thread.
|
---|
191 | */
|
---|
192 | typedef struct PDMTHREADINT
|
---|
193 | {
|
---|
194 | /** Node for the list of threads. */
|
---|
195 | RTLISTNODE NdPdmThrds;
|
---|
196 | /** Pointer to the device under test the allocation was made for. */
|
---|
197 | PTSTDEVDUTINT pDut;
|
---|
198 | /** The event semaphore the thread blocks on when not running. */
|
---|
199 | RTSEMEVENTMULTI BlockEvent;
|
---|
200 | /** The event semaphore the thread sleeps on while running. */
|
---|
201 | RTSEMEVENTMULTI SleepEvent;
|
---|
202 | /** The thread type. */
|
---|
203 | PDMTHREADTYPE enmType;
|
---|
204 | } PDMTHREADINT;
|
---|
205 |
|
---|
206 |
|
---|
207 | #define PDMTHREADINT_DECLARED
|
---|
208 | #define PDMCRITSECTINT_DECLARED
|
---|
209 | #define PDMDEVINSINT_DECLARED
|
---|
210 | #define PDMPCIDEVINT_DECLARED
|
---|
211 | #define VMM_INCLUDED_SRC_include_VMInternal_h
|
---|
212 | #define VMM_INCLUDED_SRC_include_VMMInternal_h
|
---|
213 | RT_C_DECLS_END
|
---|
214 | #include <VBox/vmm/pdmcritsect.h>
|
---|
215 | #include <VBox/vmm/pdmthread.h>
|
---|
216 | #include <VBox/vmm/pdmdev.h>
|
---|
217 | #include <VBox/vmm/pdmpci.h>
|
---|
218 | #include <VBox/vmm/pdmdrv.h>
|
---|
219 | #include <VBox/vmm/tm.h>
|
---|
220 | RT_C_DECLS_BEGIN
|
---|
221 |
|
---|
222 |
|
---|
223 | /**
|
---|
224 | * TM timer structure.
|
---|
225 | */
|
---|
226 | typedef struct TMTIMER
|
---|
227 | {
|
---|
228 | /** List of timers created by the device. */
|
---|
229 | RTLISTNODE NdDevTimers;
|
---|
230 | /** Clock this timer belongs to. */
|
---|
231 | TMCLOCK enmClock;
|
---|
232 | /** Callback to call when the timer expires. */
|
---|
233 | PFNTMTIMERDEV pfnCallbackDev;
|
---|
234 | /** Opaque user data to pass to the callback. */
|
---|
235 | void *pvUser;
|
---|
236 | /** Flags. */
|
---|
237 | uint32_t fFlags;
|
---|
238 | /** Assigned critical section. */
|
---|
239 | PPDMCRITSECT pCritSect;
|
---|
240 | /** @todo: */
|
---|
241 | } TMTIMER;
|
---|
242 |
|
---|
243 |
|
---|
244 | /**
|
---|
245 | * PDM module descriptor type.
|
---|
246 | */
|
---|
247 | typedef enum TSTDEVPDMMODTYPE
|
---|
248 | {
|
---|
249 | /** Invalid module type. */
|
---|
250 | TSTDEVPDMMODTYPE_INVALID = 0,
|
---|
251 | /** Ring 3 module. */
|
---|
252 | TSTDEVPDMMODTYPE_R3,
|
---|
253 | /** Ring 0 module. */
|
---|
254 | TSTDEVPDMMODTYPE_R0,
|
---|
255 | /** Raw context module. */
|
---|
256 | TSTDEVPDMMODTYPE_RC,
|
---|
257 | /** 32bit hack. */
|
---|
258 | TSTDEVPDMMODTYPE_32BIT_HACK = 0x7fffffff
|
---|
259 | } TSTDEVPDMMODTYPE;
|
---|
260 |
|
---|
261 | /**
|
---|
262 | * Registered I/O port access handler.
|
---|
263 | */
|
---|
264 | typedef struct RTDEVDUTIOPORT
|
---|
265 | {
|
---|
266 | /** Node for the list of registered handlers. */
|
---|
267 | RTLISTNODE NdIoPorts;
|
---|
268 | /** Start I/O port the handler is for. */
|
---|
269 | RTIOPORT PortStart;
|
---|
270 | /** Number of ports handled. */
|
---|
271 | RTIOPORT cPorts;
|
---|
272 | /** Opaque user data - R3. */
|
---|
273 | void *pvUserR3;
|
---|
274 | /** Out handler - R3. */
|
---|
275 | PFNIOMIOPORTNEWOUT pfnOutR3;
|
---|
276 | /** In handler - R3. */
|
---|
277 | PFNIOMIOPORTNEWIN pfnInR3;
|
---|
278 | /** Out string handler - R3. */
|
---|
279 | PFNIOMIOPORTNEWOUTSTRING pfnOutStrR3;
|
---|
280 | /** In string handler - R3. */
|
---|
281 | PFNIOMIOPORTNEWINSTRING pfnInStrR3;
|
---|
282 |
|
---|
283 | /** Opaque user data - R0. */
|
---|
284 | void *pvUserR0;
|
---|
285 | /** Out handler - R0. */
|
---|
286 | PFNIOMIOPORTNEWOUT pfnOutR0;
|
---|
287 | /** In handler - R0. */
|
---|
288 | PFNIOMIOPORTNEWIN pfnInR0;
|
---|
289 | /** Out string handler - R0. */
|
---|
290 | PFNIOMIOPORTNEWOUTSTRING pfnOutStrR0;
|
---|
291 | /** In string handler - R0. */
|
---|
292 | PFNIOMIOPORTNEWINSTRING pfnInStrR0;
|
---|
293 |
|
---|
294 | #ifdef TSTDEV_SUPPORTS_RC
|
---|
295 | /** Opaque user data - RC. */
|
---|
296 | void *pvUserRC;
|
---|
297 | /** Out handler - RC. */
|
---|
298 | PFNIOMIOPORTNEWOUT pfnOutRC;
|
---|
299 | /** In handler - RC. */
|
---|
300 | PFNIOMIOPORTNEWIN pfnInRC;
|
---|
301 | /** Out string handler - RC. */
|
---|
302 | PFNIOMIOPORTNEWOUTSTRING pfnOutStrRC;
|
---|
303 | /** In string handler - RC. */
|
---|
304 | PFNIOMIOPORTNEWINSTRING pfnInStrRC;
|
---|
305 | #endif
|
---|
306 | } RTDEVDUTIOPORT;
|
---|
307 | /** Pointer to a registered I/O port handler. */
|
---|
308 | typedef RTDEVDUTIOPORT *PRTDEVDUTIOPORT;
|
---|
309 | /** Pointer to a const I/O port handler. */
|
---|
310 | typedef const RTDEVDUTIOPORT *PCRTDEVDUTIOPORT;
|
---|
311 |
|
---|
312 |
|
---|
313 | /**
|
---|
314 | * Registered MMIO port access handler.
|
---|
315 | */
|
---|
316 | typedef struct RTDEVDUTMMIO
|
---|
317 | {
|
---|
318 | /** Node for the list of registered handlers. */
|
---|
319 | RTLISTNODE NdMmio;
|
---|
320 | /** Start address of the MMIO region when mapped. */
|
---|
321 | RTGCPHYS GCPhysStart;
|
---|
322 | /** Size of the MMIO region in bytes. */
|
---|
323 | RTGCPHYS cbRegion;
|
---|
324 | /** Opaque user data - R3. */
|
---|
325 | void *pvUserR3;
|
---|
326 | /** Write handler - R3. */
|
---|
327 | PFNIOMMMIONEWWRITE pfnWriteR3;
|
---|
328 | /** Read handler - R3. */
|
---|
329 | PFNIOMMMIONEWREAD pfnReadR3;
|
---|
330 | /** Fill handler - R3. */
|
---|
331 | PFNIOMMMIONEWFILL pfnFillR3;
|
---|
332 |
|
---|
333 | /** Opaque user data - R0. */
|
---|
334 | void *pvUserR0;
|
---|
335 | /** Write handler - R0. */
|
---|
336 | PFNIOMMMIONEWWRITE pfnWriteR0;
|
---|
337 | /** Read handler - R0. */
|
---|
338 | PFNIOMMMIONEWREAD pfnReadR0;
|
---|
339 | /** Fill handler - R0. */
|
---|
340 | PFNIOMMMIONEWFILL pfnFillR0;
|
---|
341 |
|
---|
342 | #ifdef TSTDEV_SUPPORTS_RC
|
---|
343 | /** Opaque user data - RC. */
|
---|
344 | void *pvUserRC;
|
---|
345 | /** Write handler - RC. */
|
---|
346 | PFNIOMMMIONEWWRITE pfnWriteRC;
|
---|
347 | /** Read handler - RC. */
|
---|
348 | PFNIOMMMIONEWREAD pfnReadRC;
|
---|
349 | /** Fill handler - RC. */
|
---|
350 | PFNIOMMMIONEWFILL pfnFillRC;
|
---|
351 | #endif
|
---|
352 | } RTDEVDUTMMIO;
|
---|
353 | /** Pointer to a registered MMIO handler. */
|
---|
354 | typedef RTDEVDUTMMIO *PRTDEVDUTMMIO;
|
---|
355 | /** Pointer to a const MMIO handler. */
|
---|
356 | typedef const RTDEVDUTMMIO *PCRTDEVDUTMMIO;
|
---|
357 |
|
---|
358 |
|
---|
359 | #ifdef IN_RING3
|
---|
360 | /**
|
---|
361 | * Registered SSM handlers.
|
---|
362 | */
|
---|
363 | typedef struct TSTDEVDUTSSM
|
---|
364 | {
|
---|
365 | /** Node for the list of registered SSM handlers. */
|
---|
366 | RTLISTNODE NdSsm;
|
---|
367 | /** Version */
|
---|
368 | uint32_t uVersion;
|
---|
369 | PFNSSMDEVLIVEPREP pfnLivePrep;
|
---|
370 | PFNSSMDEVLIVEEXEC pfnLiveExec;
|
---|
371 | PFNSSMDEVLIVEVOTE pfnLiveVote;
|
---|
372 | PFNSSMDEVSAVEPREP pfnSavePrep;
|
---|
373 | PFNSSMDEVSAVEEXEC pfnSaveExec;
|
---|
374 | PFNSSMDEVSAVEDONE pfnSaveDone;
|
---|
375 | PFNSSMDEVLOADPREP pfnLoadPrep;
|
---|
376 | PFNSSMDEVLOADEXEC pfnLoadExec;
|
---|
377 | PFNSSMDEVLOADDONE pfnLoadDone;
|
---|
378 | } TSTDEVDUTSSM;
|
---|
379 | /** Pointer to the registered SSM handlers. */
|
---|
380 | typedef TSTDEVDUTSSM *PTSTDEVDUTSSM;
|
---|
381 | /** Pointer to a const SSM handler. */
|
---|
382 | typedef const TSTDEVDUTSSM *PCTSTDEVDUTSSM;
|
---|
383 | #endif
|
---|
384 |
|
---|
385 |
|
---|
386 | /**
|
---|
387 | * The Support Driver session state.
|
---|
388 | */
|
---|
389 | typedef struct TSTDEVSUPDRVSESSION
|
---|
390 | {
|
---|
391 | /** Pointer to the owning device under test instance. */
|
---|
392 | PTSTDEVDUTINT pDut;
|
---|
393 | /** List of event semaphores. */
|
---|
394 | RTLISTANCHOR LstSupSem;
|
---|
395 | } TSTDEVSUPDRVSESSION;
|
---|
396 | /** Pointer to the Support Driver session state. */
|
---|
397 | typedef TSTDEVSUPDRVSESSION *PTSTDEVSUPDRVSESSION;
|
---|
398 |
|
---|
399 | /** Converts a Support Driver session handle to the internal state. */
|
---|
400 | #define TSTDEV_PSUPDRVSESSION_2_PTSTDEVSUPDRVSESSION(a_pSession) ((PTSTDEVSUPDRVSESSION)(a_pSession))
|
---|
401 | /** Converts the internal session state to a Support Driver session handle. */
|
---|
402 | #define TSTDEV_PTSTDEVSUPDRVSESSION_2_PSUPDRVSESSION(a_pSession) ((PSUPDRVSESSION)(a_pSession))
|
---|
403 |
|
---|
404 | /**
|
---|
405 | * Support driver event semaphore.
|
---|
406 | */
|
---|
407 | typedef struct TSTDEVSUPSEMEVENT
|
---|
408 | {
|
---|
409 | /** Node for the event semaphore list. */
|
---|
410 | RTLISTNODE NdSupSem;
|
---|
411 | /** Flag whether this is multi event semaphore. */
|
---|
412 | bool fMulti;
|
---|
413 | /** Event smeaphore handles depending on the flag above. */
|
---|
414 | union
|
---|
415 | {
|
---|
416 | RTSEMEVENT hSemEvt;
|
---|
417 | RTSEMEVENTMULTI hSemEvtMulti;
|
---|
418 | } u;
|
---|
419 | } TSTDEVSUPSEMEVENT;
|
---|
420 | /** Pointer to a support event semaphore state. */
|
---|
421 | typedef TSTDEVSUPSEMEVENT *PTSTDEVSUPSEMEVENT;
|
---|
422 |
|
---|
423 | /** Converts a Support event semaphore handle to the internal state. */
|
---|
424 | #define TSTDEV_SUPSEMEVENT_2_PTSTDEVSUPSEMEVENT(a_pSupSemEvt) ((PTSTDEVSUPSEMEVENT)(a_pSupSemEvt))
|
---|
425 | /** Converts the internal session state to a Support event semaphore handle. */
|
---|
426 | #define TSTDEV_PTSTDEVSUPSEMEVENT_2_SUPSEMEVENT(a_pSupSemEvt) ((SUPSEMEVENT)(a_pSupSemEvt))
|
---|
427 |
|
---|
428 | /**
|
---|
429 | * The contex the device under test is currently in.
|
---|
430 | */
|
---|
431 | typedef enum TSTDEVDUTCTX
|
---|
432 | {
|
---|
433 | /** Invalid context. */
|
---|
434 | TSTDEVDUTCTX_INVALID = 0,
|
---|
435 | /** R3 context. */
|
---|
436 | TSTDEVDUTCTX_R3,
|
---|
437 | /** R0 context. */
|
---|
438 | TSTDEVDUTCTX_R0,
|
---|
439 | /** RC context. */
|
---|
440 | TSTDEVDUTCTX_RC,
|
---|
441 | /** 32bit hack. */
|
---|
442 | TSTDEVDUTCTX_32BIT_HACK = 0x7fffffff
|
---|
443 | } TSTDEVDUTCTX;
|
---|
444 |
|
---|
445 | /**
|
---|
446 | * PCI region descriptor.
|
---|
447 | */
|
---|
448 | typedef struct TSTDEVDUTPCIREGION
|
---|
449 | {
|
---|
450 | /** Size of the region. */
|
---|
451 | RTGCPHYS cbRegion;
|
---|
452 | /** Address space type. */
|
---|
453 | PCIADDRESSSPACE enmType;
|
---|
454 | /** Region mapping callback. */
|
---|
455 | PFNPCIIOREGIONMAP pfnRegionMap;
|
---|
456 | } TSTDEVDUTPCIREGION;
|
---|
457 | /** Pointer to a PCI region descriptor. */
|
---|
458 | typedef TSTDEVDUTPCIREGION *PTSTDEVDUTPCIREGION;
|
---|
459 | /** Pointer to a const PCI region descriptor. */
|
---|
460 | typedef const TSTDEVDUTPCIREGION *PCTSTDEVDUTPCIREGION;
|
---|
461 |
|
---|
462 | /**
|
---|
463 | * Device under test instance data.
|
---|
464 | */
|
---|
465 | typedef struct TSTDEVDUTINT
|
---|
466 | {
|
---|
467 | /** Pointer to the test this device is running under. */
|
---|
468 | PCTSTDEVTEST pTest;
|
---|
469 | /** The PDM device registration record. */
|
---|
470 | PCTSTDEVPDMDEV pPdmDev;
|
---|
471 | /** Pointer to the PDM device instance. */
|
---|
472 | struct PDMDEVINSR3 *pDevIns;
|
---|
473 | /** Pointer to the PDM R0 device instance. */
|
---|
474 | struct PDMDEVINSR0 *pDevInsR0;
|
---|
475 | /** CFGM root config node for the device. */
|
---|
476 | CFGMNODE Cfg;
|
---|
477 | /** Current device context. */
|
---|
478 | TSTDEVDUTCTX enmCtx;
|
---|
479 | /** Critical section protecting the lists below. */
|
---|
480 | RTCRITSECTRW CritSectLists;
|
---|
481 | /** List of registered I/O port handlers. */
|
---|
482 | RTLISTANCHOR LstIoPorts;
|
---|
483 | /** List of timers registered. */
|
---|
484 | RTLISTANCHOR LstTimers;
|
---|
485 | /** List of registered MMIO regions. */
|
---|
486 | RTLISTANCHOR LstMmio;
|
---|
487 | /** List of MM Heap allocations. */
|
---|
488 | RTLISTANCHOR LstMmHeap;
|
---|
489 | /** List of PDM threads. */
|
---|
490 | RTLISTANCHOR LstPdmThreads;
|
---|
491 | /** List of SSM handlers (just one normally). */
|
---|
492 | RTLISTANCHOR LstSsmHandlers;
|
---|
493 | /** The SUP session we emulate. */
|
---|
494 | TSTDEVSUPDRVSESSION SupSession;
|
---|
495 | /** The NOP critical section. */
|
---|
496 | PDMCRITSECT CritSectNop;
|
---|
497 | /** The VM state associated with this device. */
|
---|
498 | PVM pVm;
|
---|
499 | /** The registered PCI device instance if this is a PCI device. */
|
---|
500 | PPDMPCIDEV pPciDev;
|
---|
501 | /** PCI Region descriptors. */
|
---|
502 | TSTDEVDUTPCIREGION aPciRegions[VBOX_PCI_NUM_REGIONS];
|
---|
503 | /** The status port interface we implement. */
|
---|
504 | PDMIBASE IBaseSts;
|
---|
505 | /** */
|
---|
506 | } TSTDEVDUTINT;
|
---|
507 |
|
---|
508 |
|
---|
509 | #ifdef IN_RING3
|
---|
510 | extern const PDMDEVHLPR3 g_tstDevPdmDevHlpR3;
|
---|
511 | #endif
|
---|
512 | extern const PDMDEVHLPR0 g_tstDevPdmDevHlpR0;
|
---|
513 |
|
---|
514 | DECLHIDDEN(int) tstDevPdmLdrGetSymbol(PTSTDEVDUTINT pThis, const char *pszMod, TSTDEVPDMMODTYPE enmModType,
|
---|
515 | const char *pszSymbol, PFNRT *ppfn);
|
---|
516 |
|
---|
517 |
|
---|
518 | DECLINLINE(int) tstDevDutLockShared(PTSTDEVDUTINT pThis)
|
---|
519 | {
|
---|
520 | return RTCritSectRwEnterShared(&pThis->CritSectLists);
|
---|
521 | }
|
---|
522 |
|
---|
523 | DECLINLINE(int) tstDevDutUnlockShared(PTSTDEVDUTINT pThis)
|
---|
524 | {
|
---|
525 | return RTCritSectRwLeaveShared(&pThis->CritSectLists);
|
---|
526 | }
|
---|
527 |
|
---|
528 | DECLINLINE(int) tstDevDutLockExcl(PTSTDEVDUTINT pThis)
|
---|
529 | {
|
---|
530 | return RTCritSectRwEnterExcl(&pThis->CritSectLists);
|
---|
531 | }
|
---|
532 |
|
---|
533 | DECLINLINE(int) tstDevDutUnlockExcl(PTSTDEVDUTINT pThis)
|
---|
534 | {
|
---|
535 | return RTCritSectRwLeaveExcl(&pThis->CritSectLists);
|
---|
536 | }
|
---|
537 |
|
---|
538 | DECLHIDDEN(int) tstDevPdmR3ThreadCreateDevice(PTSTDEVDUTINT pDut, PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
|
---|
539 | PFNPDMTHREADWAKEUPDEV pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
|
---|
540 | DECLHIDDEN(int) tstDevPdmR3ThreadCreateUsb(PTSTDEVDUTINT pDut, PPDMUSBINS pUsbIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADUSB pfnThread,
|
---|
541 | PFNPDMTHREADWAKEUPUSB pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
|
---|
542 | DECLHIDDEN(int) tstDevPdmR3ThreadCreateDriver(PTSTDEVDUTINT pDut, PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
|
---|
543 | PFNPDMTHREADWAKEUPDRV pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
|
---|
544 | DECLHIDDEN(int) tstDevPdmR3ThreadCreate(PTSTDEVDUTINT pDut, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADINT pfnThread,
|
---|
545 | PFNPDMTHREADWAKEUPINT pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
|
---|
546 | DECLHIDDEN(int) tstDevPdmR3ThreadCreateExternal(PTSTDEVDUTINT pDut, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADEXT pfnThread,
|
---|
547 | PFNPDMTHREADWAKEUPEXT pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
|
---|
548 | DECLHIDDEN(int) tstDevPdmR3ThreadDestroy(PPDMTHREAD pThread, int *pRcThread);
|
---|
549 | DECLHIDDEN(int) tstDevPdmR3ThreadDestroyDevice(PTSTDEVDUTINT pDut, PPDMDEVINS pDevIns);
|
---|
550 | DECLHIDDEN(int) tstDevPdmR3ThreadDestroyUsb(PTSTDEVDUTINT pDut, PPDMUSBINS pUsbIns);
|
---|
551 | DECLHIDDEN(int) tstDevPdmR3ThreadDestroyDriver(PTSTDEVDUTINT pDut, PPDMDRVINS pDrvIns);
|
---|
552 | DECLHIDDEN(void) tstDevPdmR3ThreadDestroyAll(PTSTDEVDUTINT pDut);
|
---|
553 | DECLHIDDEN(int) tstDevPdmR3ThreadIAmSuspending(PPDMTHREAD pThread);
|
---|
554 | DECLHIDDEN(int) tstDevPdmR3ThreadIAmRunning(PPDMTHREAD pThread);
|
---|
555 | DECLHIDDEN(int) tstDevPdmR3ThreadSleep(PPDMTHREAD pThread, RTMSINTERVAL cMillies);
|
---|
556 | DECLHIDDEN(int) tstDevPdmR3ThreadSuspend(PPDMTHREAD pThread);
|
---|
557 | DECLHIDDEN(int) tstDevPdmR3ThreadResume(PPDMTHREAD pThread);
|
---|
558 |
|
---|
559 |
|
---|
560 | DECLHIDDEN(PCTSTDEVPDMDEV) tstDevPdmDeviceFind(const char *pszName, PCPDMDEVREGR0 *ppR0Reg);
|
---|
561 | DECLHIDDEN(int) tstDevPdmDeviceR3Construct(PTSTDEVDUTINT pDut);
|
---|
562 |
|
---|
563 | DECLHIDDEN(int) tstDevPdmDevR0R3Create(const char *pszName, bool fRCEnabled, PTSTDEVDUTINT pDut);
|
---|
564 |
|
---|
565 |
|
---|
566 | RT_C_DECLS_END
|
---|
567 |
|
---|
568 | #endif /* !VBOX_INCLUDED_SRC_testcase_tstDeviceInternal_h */
|
---|