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