1 | /* $Id: PDMInternal.h 80531 2019-09-01 23:03:34Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PDM - Internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 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 |
|
---|
18 | #ifndef VMM_INCLUDED_SRC_include_PDMInternal_h
|
---|
19 | #define VMM_INCLUDED_SRC_include_PDMInternal_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include <VBox/types.h>
|
---|
25 | #include <VBox/param.h>
|
---|
26 | #include <VBox/vmm/cfgm.h>
|
---|
27 | #include <VBox/vmm/stam.h>
|
---|
28 | #include <VBox/vusb.h>
|
---|
29 | #include <VBox/vmm/pdmasynccompletion.h>
|
---|
30 | #ifdef VBOX_WITH_NETSHAPER
|
---|
31 | # include <VBox/vmm/pdmnetshaper.h>
|
---|
32 | #endif
|
---|
33 | #ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
|
---|
34 | # include <VBox/vmm/pdmasynccompletion.h>
|
---|
35 | #endif
|
---|
36 | #include <VBox/vmm/pdmblkcache.h>
|
---|
37 | #include <VBox/vmm/pdmcommon.h>
|
---|
38 | #include <VBox/sup.h>
|
---|
39 | #include <iprt/assert.h>
|
---|
40 | #include <iprt/critsect.h>
|
---|
41 | #ifdef IN_RING3
|
---|
42 | # include <iprt/thread.h>
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | RT_C_DECLS_BEGIN
|
---|
46 |
|
---|
47 |
|
---|
48 | /** @defgroup grp_pdm_int Internal
|
---|
49 | * @ingroup grp_pdm
|
---|
50 | * @internal
|
---|
51 | * @{
|
---|
52 | */
|
---|
53 |
|
---|
54 | /** @def PDM_WITH_R3R0_CRIT_SECT
|
---|
55 | * Enables or disabled ring-3/ring-0 critical sections. */
|
---|
56 | #if defined(DOXYGEN_RUNNING) || 1
|
---|
57 | # define PDM_WITH_R3R0_CRIT_SECT
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | /** @def PDMCRITSECT_STRICT
|
---|
61 | * Enables/disables PDM critsect strictness like deadlock detection. */
|
---|
62 | #if (defined(RT_LOCK_STRICT) && defined(IN_RING3) && !defined(PDMCRITSECT_STRICT)) \
|
---|
63 | || defined(DOXYGEN_RUNNING)
|
---|
64 | # define PDMCRITSECT_STRICT
|
---|
65 | #endif
|
---|
66 |
|
---|
67 | /** @def PDMCRITSECT_STRICT
|
---|
68 | * Enables/disables PDM read/write critsect strictness like deadlock
|
---|
69 | * detection. */
|
---|
70 | #if (defined(RT_LOCK_STRICT) && defined(IN_RING3) && !defined(PDMCRITSECTRW_STRICT)) \
|
---|
71 | || defined(DOXYGEN_RUNNING)
|
---|
72 | # define PDMCRITSECTRW_STRICT
|
---|
73 | #endif
|
---|
74 |
|
---|
75 |
|
---|
76 | /*******************************************************************************
|
---|
77 | * Structures and Typedefs *
|
---|
78 | *******************************************************************************/
|
---|
79 |
|
---|
80 | /** Pointer to a PDM Device. */
|
---|
81 | typedef struct PDMDEV *PPDMDEV;
|
---|
82 | /** Pointer to a pointer to a PDM Device. */
|
---|
83 | typedef PPDMDEV *PPPDMDEV;
|
---|
84 |
|
---|
85 | /** Pointer to a PDM USB Device. */
|
---|
86 | typedef struct PDMUSB *PPDMUSB;
|
---|
87 | /** Pointer to a pointer to a PDM USB Device. */
|
---|
88 | typedef PPDMUSB *PPPDMUSB;
|
---|
89 |
|
---|
90 | /** Pointer to a PDM Driver. */
|
---|
91 | typedef struct PDMDRV *PPDMDRV;
|
---|
92 | /** Pointer to a pointer to a PDM Driver. */
|
---|
93 | typedef PPDMDRV *PPPDMDRV;
|
---|
94 |
|
---|
95 | /** Pointer to a PDM Logical Unit. */
|
---|
96 | typedef struct PDMLUN *PPDMLUN;
|
---|
97 | /** Pointer to a pointer to a PDM Logical Unit. */
|
---|
98 | typedef PPDMLUN *PPPDMLUN;
|
---|
99 |
|
---|
100 | /** Pointer to a PDM PCI Bus instance. */
|
---|
101 | typedef struct PDMPCIBUS *PPDMPCIBUS;
|
---|
102 | /** Pointer to a DMAC instance. */
|
---|
103 | typedef struct PDMDMAC *PPDMDMAC;
|
---|
104 | /** Pointer to a RTC instance. */
|
---|
105 | typedef struct PDMRTC *PPDMRTC;
|
---|
106 |
|
---|
107 | /** Pointer to an USB HUB registration record. */
|
---|
108 | typedef struct PDMUSBHUB *PPDMUSBHUB;
|
---|
109 |
|
---|
110 | /**
|
---|
111 | * Supported asynchronous completion endpoint classes.
|
---|
112 | */
|
---|
113 | typedef enum PDMASYNCCOMPLETIONEPCLASSTYPE
|
---|
114 | {
|
---|
115 | /** File class. */
|
---|
116 | PDMASYNCCOMPLETIONEPCLASSTYPE_FILE = 0,
|
---|
117 | /** Number of supported classes. */
|
---|
118 | PDMASYNCCOMPLETIONEPCLASSTYPE_MAX,
|
---|
119 | /** 32bit hack. */
|
---|
120 | PDMASYNCCOMPLETIONEPCLASSTYPE_32BIT_HACK = 0x7fffffff
|
---|
121 | } PDMASYNCCOMPLETIONEPCLASSTYPE;
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * Private device instance data, ring-3.
|
---|
125 | */
|
---|
126 | typedef struct PDMDEVINSINTR3
|
---|
127 | {
|
---|
128 | /** Pointer to the next instance.
|
---|
129 | * (Head is pointed to by PDM::pDevInstances.) */
|
---|
130 | R3PTRTYPE(PPDMDEVINS) pNextR3;
|
---|
131 | /** Pointer to the next per device instance.
|
---|
132 | * (Head is pointed to by PDMDEV::pInstances.) */
|
---|
133 | R3PTRTYPE(PPDMDEVINS) pPerDeviceNextR3;
|
---|
134 | /** Pointer to device structure. */
|
---|
135 | R3PTRTYPE(PPDMDEV) pDevR3;
|
---|
136 | /** Pointer to the list of logical units associated with the device. (FIFO) */
|
---|
137 | R3PTRTYPE(PPDMLUN) pLunsR3;
|
---|
138 | /** Pointer to the asynchronous notification callback set while in
|
---|
139 | * FNPDMDEVSUSPEND or FNPDMDEVPOWEROFF. */
|
---|
140 | R3PTRTYPE(PFNPDMDEVASYNCNOTIFY) pfnAsyncNotify;
|
---|
141 | /** Configuration handle to the instance node. */
|
---|
142 | R3PTRTYPE(PCFGMNODE) pCfgHandle;
|
---|
143 |
|
---|
144 | /** R3 pointer to the VM this instance was created for. */
|
---|
145 | PVMR3 pVMR3;
|
---|
146 | /** Associated PCI device list head (first is default). */
|
---|
147 | R3PTRTYPE(PPDMPCIDEV) pHeadPciDevR3;
|
---|
148 |
|
---|
149 | /** Flags, see PDMDEVINSINT_FLAGS_XXX. */
|
---|
150 | uint32_t fIntFlags;
|
---|
151 | /** The last IRQ tag (for tracing it thru clearing). */
|
---|
152 | uint32_t uLastIrqTag;
|
---|
153 | /** The ring-0 device index (for making ring-0 calls). */
|
---|
154 | uint32_t idxR0Device;
|
---|
155 | } PDMDEVINSINTR3;
|
---|
156 |
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * Private device instance data, ring-0.
|
---|
160 | */
|
---|
161 | typedef struct PDMDEVINSINTR0
|
---|
162 | {
|
---|
163 | /** Pointer to the VM this instance was created for. */
|
---|
164 | R0PTRTYPE(PGVM) pGVM;
|
---|
165 | /** Associated PCI device list head (first is default). */
|
---|
166 | R0PTRTYPE(PPDMPCIDEV) pHeadPciDevR0;
|
---|
167 | /** Pointer to device structure. */
|
---|
168 | R0PTRTYPE(struct PDMDEVREGR0 const *) pRegR0;
|
---|
169 | /** The ring-0 module reference. */
|
---|
170 | RTR0PTR hMod;
|
---|
171 | /** Pointer to the ring-0 mapping of the ring-3 internal data (for uLastIrqTag). */
|
---|
172 | R0PTRTYPE(PDMDEVINSINTR3 *) pIntR3R0;
|
---|
173 | /** Pointer to the ring-0 mapping of the ring-3 instance (for idTracing). */
|
---|
174 | R0PTRTYPE(struct PDMDEVINSR3 *) pInsR3R0;
|
---|
175 | /** The device instance memory. */
|
---|
176 | RTR0MEMOBJ hMemObj;
|
---|
177 | /** The ring-3 mapping object. */
|
---|
178 | RTR0MEMOBJ hMapObj;
|
---|
179 | /** Index into PDMR0PERVM::apDevInstances. */
|
---|
180 | uint32_t idxR0Device;
|
---|
181 | } PDMDEVINSINTR0;
|
---|
182 |
|
---|
183 |
|
---|
184 | /**
|
---|
185 | * Private device instance data, raw-mode
|
---|
186 | */
|
---|
187 | typedef struct PDMDEVINSINTRC
|
---|
188 | {
|
---|
189 | /** Pointer to the VM this instance was created for. */
|
---|
190 | RGPTRTYPE(PVM) pVMRC;
|
---|
191 | } PDMDEVINSINTRC;
|
---|
192 |
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * Private device instance data.
|
---|
196 | */
|
---|
197 | typedef struct PDMDEVINSINT
|
---|
198 | {
|
---|
199 | /** Pointer to the next instance (HC Ptr).
|
---|
200 | * (Head is pointed to by PDM::pDevInstances.) */
|
---|
201 | R3PTRTYPE(PPDMDEVINS) pNextR3;
|
---|
202 | /** Pointer to the next per device instance (HC Ptr).
|
---|
203 | * (Head is pointed to by PDMDEV::pInstances.) */
|
---|
204 | R3PTRTYPE(PPDMDEVINS) pPerDeviceNextR3;
|
---|
205 | /** Pointer to device structure - HC Ptr. */
|
---|
206 | R3PTRTYPE(PPDMDEV) pDevR3;
|
---|
207 | /** Pointer to the list of logical units associated with the device. (FIFO) */
|
---|
208 | R3PTRTYPE(PPDMLUN) pLunsR3;
|
---|
209 | /** Pointer to the asynchronous notification callback set while in
|
---|
210 | * FNPDMDEVSUSPEND or FNPDMDEVPOWEROFF. */
|
---|
211 | R3PTRTYPE(PFNPDMDEVASYNCNOTIFY) pfnAsyncNotify;
|
---|
212 | /** Configuration handle to the instance node. */
|
---|
213 | R3PTRTYPE(PCFGMNODE) pCfgHandle;
|
---|
214 |
|
---|
215 | /** R3 pointer to the VM this instance was created for. */
|
---|
216 | PVMR3 pVMR3;
|
---|
217 | /** Associated PCI device list head (first is default). (R3 ptr) */
|
---|
218 | R3PTRTYPE(PPDMPCIDEV) pHeadPciDevR3;
|
---|
219 |
|
---|
220 | /** R0 pointer to the VM this instance was created for. */
|
---|
221 | R0PTRTYPE(PVMCC) pVMR0;
|
---|
222 | /** Associated PCI device list head (first is default). (R0 ptr) */
|
---|
223 | R0PTRTYPE(PPDMPCIDEV) pHeadPciDevR0;
|
---|
224 |
|
---|
225 | /** RC pointer to the VM this instance was created for. */
|
---|
226 | PVMRC pVMRC;
|
---|
227 | /** Associated PCI device list head (first is default). (RC ptr) */
|
---|
228 | RCPTRTYPE(PPDMPCIDEV) pHeadPciDevRC;
|
---|
229 |
|
---|
230 | /** Flags, see PDMDEVINSINT_FLAGS_XXX. */
|
---|
231 | uint32_t fIntFlags;
|
---|
232 | /** The last IRQ tag (for tracing it thru clearing). */
|
---|
233 | uint32_t uLastIrqTag;
|
---|
234 | } PDMDEVINSINT;
|
---|
235 |
|
---|
236 | /** @name PDMDEVINSINT::fIntFlags
|
---|
237 | * @{ */
|
---|
238 | /** Used by pdmR3Load to mark device instances it found in the saved state. */
|
---|
239 | #define PDMDEVINSINT_FLAGS_FOUND RT_BIT_32(0)
|
---|
240 | /** Indicates that the device hasn't been powered on or resumed.
|
---|
241 | * This is used by PDMR3PowerOn, PDMR3Resume, PDMR3Suspend and PDMR3PowerOff
|
---|
242 | * to make sure each device gets exactly one notification for each of those
|
---|
243 | * events. PDMR3Resume and PDMR3PowerOn also makes use of it to bail out on
|
---|
244 | * a failure (already resumed/powered-on devices are suspended).
|
---|
245 | * PDMR3PowerOff resets this flag once before going through the devices to make sure
|
---|
246 | * every device gets the power off notification even if it was suspended before with
|
---|
247 | * PDMR3Suspend.
|
---|
248 | */
|
---|
249 | #define PDMDEVINSINT_FLAGS_SUSPENDED RT_BIT_32(1)
|
---|
250 | /** Indicates that the device has been reset already. Used by PDMR3Reset. */
|
---|
251 | #define PDMDEVINSINT_FLAGS_RESET RT_BIT_32(2)
|
---|
252 | #define PDMDEVINSINT_FLAGS_R0_ENABLED RT_BIT_32(3)
|
---|
253 | #define PDMDEVINSINT_FLAGS_RC_ENABLED RT_BIT_32(4)
|
---|
254 | /** Set if we've called the ring-0 constructor. */
|
---|
255 | #define PDMDEVINSINT_FLAGS_R0_CONTRUCT RT_BIT_32(5)
|
---|
256 | /** Set if using non-default critical section. */
|
---|
257 | #define PDMDEVINSINT_FLAGS_CHANGED_CRITSECT RT_BIT_32(6)
|
---|
258 | /** @} */
|
---|
259 |
|
---|
260 |
|
---|
261 | /**
|
---|
262 | * Private USB device instance data.
|
---|
263 | */
|
---|
264 | typedef struct PDMUSBINSINT
|
---|
265 | {
|
---|
266 | /** The UUID of this instance. */
|
---|
267 | RTUUID Uuid;
|
---|
268 | /** Pointer to the next instance.
|
---|
269 | * (Head is pointed to by PDM::pUsbInstances.) */
|
---|
270 | R3PTRTYPE(PPDMUSBINS) pNext;
|
---|
271 | /** Pointer to the next per USB device instance.
|
---|
272 | * (Head is pointed to by PDMUSB::pInstances.) */
|
---|
273 | R3PTRTYPE(PPDMUSBINS) pPerDeviceNext;
|
---|
274 |
|
---|
275 | /** Pointer to device structure. */
|
---|
276 | R3PTRTYPE(PPDMUSB) pUsbDev;
|
---|
277 |
|
---|
278 | /** Pointer to the VM this instance was created for. */
|
---|
279 | PVMR3 pVM;
|
---|
280 | /** Pointer to the list of logical units associated with the device. (FIFO) */
|
---|
281 | R3PTRTYPE(PPDMLUN) pLuns;
|
---|
282 | /** The per instance device configuration. */
|
---|
283 | R3PTRTYPE(PCFGMNODE) pCfg;
|
---|
284 | /** Same as pCfg if the configuration should be deleted when detaching the device. */
|
---|
285 | R3PTRTYPE(PCFGMNODE) pCfgDelete;
|
---|
286 | /** The global device configuration. */
|
---|
287 | R3PTRTYPE(PCFGMNODE) pCfgGlobal;
|
---|
288 |
|
---|
289 | /** Pointer to the USB hub this device is attached to.
|
---|
290 | * This is NULL if the device isn't connected to any HUB. */
|
---|
291 | R3PTRTYPE(PPDMUSBHUB) pHub;
|
---|
292 | /** The port number that we're connected to. */
|
---|
293 | uint32_t iPort;
|
---|
294 | /** Indicates that the USB device hasn't been powered on or resumed.
|
---|
295 | * See PDMDEVINSINT_FLAGS_SUSPENDED. */
|
---|
296 | bool fVMSuspended;
|
---|
297 | /** Indicates that the USB device has been reset. */
|
---|
298 | bool fVMReset;
|
---|
299 | /** Pointer to the asynchronous notification callback set while in
|
---|
300 | * FNPDMDEVSUSPEND or FNPDMDEVPOWEROFF. */
|
---|
301 | R3PTRTYPE(PFNPDMUSBASYNCNOTIFY) pfnAsyncNotify;
|
---|
302 | } PDMUSBINSINT;
|
---|
303 |
|
---|
304 |
|
---|
305 | /**
|
---|
306 | * Private driver instance data.
|
---|
307 | */
|
---|
308 | typedef struct PDMDRVINSINT
|
---|
309 | {
|
---|
310 | /** Pointer to the driver instance above.
|
---|
311 | * This is NULL for the topmost drive. */
|
---|
312 | R3PTRTYPE(PPDMDRVINS) pUp;
|
---|
313 | /** Pointer to the driver instance below.
|
---|
314 | * This is NULL for the bottommost driver. */
|
---|
315 | R3PTRTYPE(PPDMDRVINS) pDown;
|
---|
316 | /** Pointer to the logical unit this driver chained on. */
|
---|
317 | R3PTRTYPE(PPDMLUN) pLun;
|
---|
318 | /** Pointer to driver structure from which this was instantiated. */
|
---|
319 | R3PTRTYPE(PPDMDRV) pDrv;
|
---|
320 | /** Pointer to the VM this instance was created for, ring-3 context. */
|
---|
321 | PVMR3 pVMR3;
|
---|
322 | /** Pointer to the VM this instance was created for, ring-0 context. */
|
---|
323 | R0PTRTYPE(PVMCC) pVMR0;
|
---|
324 | /** Pointer to the VM this instance was created for, raw-mode context. */
|
---|
325 | PVMRC pVMRC;
|
---|
326 | /** Flag indicating that the driver is being detached and destroyed.
|
---|
327 | * (Helps detect potential recursive detaching.) */
|
---|
328 | bool fDetaching;
|
---|
329 | /** Indicates that the driver hasn't been powered on or resumed.
|
---|
330 | * See PDMDEVINSINT_FLAGS_SUSPENDED. */
|
---|
331 | bool fVMSuspended;
|
---|
332 | /** Indicates that the driver has been reset already. */
|
---|
333 | bool fVMReset;
|
---|
334 | /** Set if allocated on the hyper heap, false if on the ring-3 heap. */
|
---|
335 | bool fHyperHeap;
|
---|
336 | /** Pointer to the asynchronous notification callback set while in
|
---|
337 | * PDMUSBREG::pfnVMSuspend or PDMUSBREG::pfnVMPowerOff. */
|
---|
338 | R3PTRTYPE(PFNPDMDRVASYNCNOTIFY) pfnAsyncNotify;
|
---|
339 | /** Configuration handle to the instance node. */
|
---|
340 | R3PTRTYPE(PCFGMNODE) pCfgHandle;
|
---|
341 | /** Pointer to the ring-0 request handler function. */
|
---|
342 | PFNPDMDRVREQHANDLERR0 pfnReqHandlerR0;
|
---|
343 | } PDMDRVINSINT;
|
---|
344 |
|
---|
345 |
|
---|
346 | /**
|
---|
347 | * Private critical section data.
|
---|
348 | */
|
---|
349 | typedef struct PDMCRITSECTINT
|
---|
350 | {
|
---|
351 | /** The critical section core which is shared with IPRT.
|
---|
352 | * @note The semaphore is a SUPSEMEVENT. */
|
---|
353 | RTCRITSECT Core;
|
---|
354 | /** Pointer to the next critical section.
|
---|
355 | * This chain is used for relocating pVMRC and device cleanup. */
|
---|
356 | R3PTRTYPE(struct PDMCRITSECTINT *) pNext;
|
---|
357 | /** Owner identifier.
|
---|
358 | * This is pDevIns if the owner is a device. Similarly for a driver or service.
|
---|
359 | * PDMR3CritSectInit() sets this to point to the critsect itself. */
|
---|
360 | RTR3PTR pvKey;
|
---|
361 | /** Pointer to the VM - R3Ptr. */
|
---|
362 | PVMR3 pVMR3;
|
---|
363 | /** Pointer to the VM - R0Ptr. */
|
---|
364 | R0PTRTYPE(PVMCC) pVMR0;
|
---|
365 | /** Pointer to the VM - GCPtr. */
|
---|
366 | PVMRC pVMRC;
|
---|
367 | /** Set if this critical section is the automatically created default
|
---|
368 | * section of a device. */
|
---|
369 | bool fAutomaticDefaultCritsect;
|
---|
370 | /** Set if the critical section is used by a timer or similar.
|
---|
371 | * See PDMR3DevGetCritSect. */
|
---|
372 | bool fUsedByTimerOrSimilar;
|
---|
373 | /** Alignment padding. */
|
---|
374 | bool afPadding[2];
|
---|
375 | /** Support driver event semaphore that is scheduled to be signaled upon leaving
|
---|
376 | * the critical section. This is only for Ring-3 and Ring-0. */
|
---|
377 | SUPSEMEVENT hEventToSignal;
|
---|
378 | /** The lock name. */
|
---|
379 | R3PTRTYPE(const char *) pszName;
|
---|
380 | /** R0/RC lock contention. */
|
---|
381 | STAMCOUNTER StatContentionRZLock;
|
---|
382 | /** R0/RC unlock contention. */
|
---|
383 | STAMCOUNTER StatContentionRZUnlock;
|
---|
384 | /** R3 lock contention. */
|
---|
385 | STAMCOUNTER StatContentionR3;
|
---|
386 | /** Profiling the time the section is locked. */
|
---|
387 | STAMPROFILEADV StatLocked;
|
---|
388 | } PDMCRITSECTINT;
|
---|
389 | AssertCompileMemberAlignment(PDMCRITSECTINT, StatContentionRZLock, 8);
|
---|
390 | /** Pointer to private critical section data. */
|
---|
391 | typedef PDMCRITSECTINT *PPDMCRITSECTINT;
|
---|
392 |
|
---|
393 | /** Indicates that the critical section is queued for unlock.
|
---|
394 | * PDMCritSectIsOwner and PDMCritSectIsOwned optimizations. */
|
---|
395 | #define PDMCRITSECT_FLAGS_PENDING_UNLOCK RT_BIT_32(17)
|
---|
396 |
|
---|
397 |
|
---|
398 | /**
|
---|
399 | * Private critical section data.
|
---|
400 | */
|
---|
401 | typedef struct PDMCRITSECTRWINT
|
---|
402 | {
|
---|
403 | /** The read/write critical section core which is shared with IPRT.
|
---|
404 | * @note The semaphores are SUPSEMEVENT and SUPSEMEVENTMULTI. */
|
---|
405 | RTCRITSECTRW Core;
|
---|
406 |
|
---|
407 | /** Pointer to the next critical section.
|
---|
408 | * This chain is used for relocating pVMRC and device cleanup. */
|
---|
409 | R3PTRTYPE(struct PDMCRITSECTRWINT *) pNext;
|
---|
410 | /** Owner identifier.
|
---|
411 | * This is pDevIns if the owner is a device. Similarly for a driver or service.
|
---|
412 | * PDMR3CritSectInit() sets this to point to the critsect itself. */
|
---|
413 | RTR3PTR pvKey;
|
---|
414 | /** Pointer to the VM - R3Ptr. */
|
---|
415 | PVMR3 pVMR3;
|
---|
416 | /** Pointer to the VM - R0Ptr. */
|
---|
417 | R0PTRTYPE(PVMCC) pVMR0;
|
---|
418 | /** Pointer to the VM - GCPtr. */
|
---|
419 | PVMRC pVMRC;
|
---|
420 | #if HC_ARCH_BITS == 64
|
---|
421 | /** Alignment padding. */
|
---|
422 | RTRCPTR RCPtrPadding;
|
---|
423 | #endif
|
---|
424 | /** The lock name. */
|
---|
425 | R3PTRTYPE(const char *) pszName;
|
---|
426 | /** R0/RC write lock contention. */
|
---|
427 | STAMCOUNTER StatContentionRZEnterExcl;
|
---|
428 | /** R0/RC write unlock contention. */
|
---|
429 | STAMCOUNTER StatContentionRZLeaveExcl;
|
---|
430 | /** R0/RC read lock contention. */
|
---|
431 | STAMCOUNTER StatContentionRZEnterShared;
|
---|
432 | /** R0/RC read unlock contention. */
|
---|
433 | STAMCOUNTER StatContentionRZLeaveShared;
|
---|
434 | /** R0/RC writes. */
|
---|
435 | STAMCOUNTER StatRZEnterExcl;
|
---|
436 | /** R0/RC reads. */
|
---|
437 | STAMCOUNTER StatRZEnterShared;
|
---|
438 | /** R3 write lock contention. */
|
---|
439 | STAMCOUNTER StatContentionR3EnterExcl;
|
---|
440 | /** R3 read lock contention. */
|
---|
441 | STAMCOUNTER StatContentionR3EnterShared;
|
---|
442 | /** R3 writes. */
|
---|
443 | STAMCOUNTER StatR3EnterExcl;
|
---|
444 | /** R3 reads. */
|
---|
445 | STAMCOUNTER StatR3EnterShared;
|
---|
446 | /** Profiling the time the section is write locked. */
|
---|
447 | STAMPROFILEADV StatWriteLocked;
|
---|
448 | } PDMCRITSECTRWINT;
|
---|
449 | AssertCompileMemberAlignment(PDMCRITSECTRWINT, StatContentionRZEnterExcl, 8);
|
---|
450 | AssertCompileMemberAlignment(PDMCRITSECTRWINT, Core.u64State, 8);
|
---|
451 | /** Pointer to private critical section data. */
|
---|
452 | typedef PDMCRITSECTRWINT *PPDMCRITSECTRWINT;
|
---|
453 |
|
---|
454 |
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * The usual device/driver/internal/external stuff.
|
---|
458 | */
|
---|
459 | typedef enum
|
---|
460 | {
|
---|
461 | /** The usual invalid entry. */
|
---|
462 | PDMTHREADTYPE_INVALID = 0,
|
---|
463 | /** Device type. */
|
---|
464 | PDMTHREADTYPE_DEVICE,
|
---|
465 | /** USB Device type. */
|
---|
466 | PDMTHREADTYPE_USB,
|
---|
467 | /** Driver type. */
|
---|
468 | PDMTHREADTYPE_DRIVER,
|
---|
469 | /** Internal type. */
|
---|
470 | PDMTHREADTYPE_INTERNAL,
|
---|
471 | /** External type. */
|
---|
472 | PDMTHREADTYPE_EXTERNAL,
|
---|
473 | /** The usual 32-bit hack. */
|
---|
474 | PDMTHREADTYPE_32BIT_HACK = 0x7fffffff
|
---|
475 | } PDMTHREADTYPE;
|
---|
476 |
|
---|
477 |
|
---|
478 | /**
|
---|
479 | * The internal structure for the thread.
|
---|
480 | */
|
---|
481 | typedef struct PDMTHREADINT
|
---|
482 | {
|
---|
483 | /** The VM pointer. */
|
---|
484 | PVMR3 pVM;
|
---|
485 | /** The event semaphore the thread blocks on when not running. */
|
---|
486 | RTSEMEVENTMULTI BlockEvent;
|
---|
487 | /** The event semaphore the thread sleeps on while running. */
|
---|
488 | RTSEMEVENTMULTI SleepEvent;
|
---|
489 | /** Pointer to the next thread. */
|
---|
490 | R3PTRTYPE(struct PDMTHREAD *) pNext;
|
---|
491 | /** The thread type. */
|
---|
492 | PDMTHREADTYPE enmType;
|
---|
493 | } PDMTHREADINT;
|
---|
494 |
|
---|
495 |
|
---|
496 |
|
---|
497 | /* Must be included after PDMDEVINSINT is defined. */
|
---|
498 | #define PDMDEVINSINT_DECLARED
|
---|
499 | #define PDMUSBINSINT_DECLARED
|
---|
500 | #define PDMDRVINSINT_DECLARED
|
---|
501 | #define PDMCRITSECTINT_DECLARED
|
---|
502 | #define PDMCRITSECTRWINT_DECLARED
|
---|
503 | #define PDMTHREADINT_DECLARED
|
---|
504 | #ifdef ___VBox_pdm_h
|
---|
505 | # error "Invalid header PDM order. Include PDMInternal.h before VBox/vmm/pdm.h!"
|
---|
506 | #endif
|
---|
507 | RT_C_DECLS_END
|
---|
508 | #include <VBox/vmm/pdm.h>
|
---|
509 | RT_C_DECLS_BEGIN
|
---|
510 |
|
---|
511 | /**
|
---|
512 | * PDM Logical Unit.
|
---|
513 | *
|
---|
514 | * This typically the representation of a physical port on a
|
---|
515 | * device, like for instance the PS/2 keyboard port on the
|
---|
516 | * keyboard controller device. The LUNs are chained on the
|
---|
517 | * device they belong to (PDMDEVINSINT::pLunsR3).
|
---|
518 | */
|
---|
519 | typedef struct PDMLUN
|
---|
520 | {
|
---|
521 | /** The LUN - The Logical Unit Number. */
|
---|
522 | RTUINT iLun;
|
---|
523 | /** Pointer to the next LUN. */
|
---|
524 | PPDMLUN pNext;
|
---|
525 | /** Pointer to the top driver in the driver chain. */
|
---|
526 | PPDMDRVINS pTop;
|
---|
527 | /** Pointer to the bottom driver in the driver chain. */
|
---|
528 | PPDMDRVINS pBottom;
|
---|
529 | /** Pointer to the device instance which the LUN belongs to.
|
---|
530 | * Either this is set or pUsbIns is set. Both is never set at the same time. */
|
---|
531 | PPDMDEVINS pDevIns;
|
---|
532 | /** Pointer to the USB device instance which the LUN belongs to. */
|
---|
533 | PPDMUSBINS pUsbIns;
|
---|
534 | /** Pointer to the device base interface. */
|
---|
535 | PPDMIBASE pBase;
|
---|
536 | /** Description of this LUN. */
|
---|
537 | const char *pszDesc;
|
---|
538 | } PDMLUN;
|
---|
539 |
|
---|
540 |
|
---|
541 | /**
|
---|
542 | * PDM Device, ring-3.
|
---|
543 | */
|
---|
544 | typedef struct PDMDEV
|
---|
545 | {
|
---|
546 | /** Pointer to the next device (R3 Ptr). */
|
---|
547 | R3PTRTYPE(PPDMDEV) pNext;
|
---|
548 | /** Device name length. (search optimization) */
|
---|
549 | uint32_t cchName;
|
---|
550 | /** Registration structure. */
|
---|
551 | R3PTRTYPE(const struct PDMDEVREGR3 *) pReg;
|
---|
552 | /** Number of instances. */
|
---|
553 | uint32_t cInstances;
|
---|
554 | /** Pointer to chain of instances (R3 Ptr). */
|
---|
555 | PPDMDEVINSR3 pInstances;
|
---|
556 | /** The search path for raw-mode context modules (';' as separator). */
|
---|
557 | char *pszRCSearchPath;
|
---|
558 | /** The search path for ring-0 context modules (';' as separator). */
|
---|
559 | char *pszR0SearchPath;
|
---|
560 | } PDMDEV;
|
---|
561 |
|
---|
562 |
|
---|
563 | #if 0
|
---|
564 | /**
|
---|
565 | * PDM Device, ring-0.
|
---|
566 | */
|
---|
567 | typedef struct PDMDEVR0
|
---|
568 | {
|
---|
569 | /** Pointer to the next device. */
|
---|
570 | R0PTRTYPE(PPDMDEVR0) pNext;
|
---|
571 | /** Device name length. (search optimization) */
|
---|
572 | uint32_t cchName;
|
---|
573 | /** Registration structure. */
|
---|
574 | R3PTRTYPE(const struct PDMDEVREGR0 *) pReg;
|
---|
575 | /** Number of instances. */
|
---|
576 | uint32_t cInstances;
|
---|
577 | /** Pointer to chain of instances. */
|
---|
578 | PPDMDEVINSR0 pInstances;
|
---|
579 | } PDMDEVR0;
|
---|
580 | #endif
|
---|
581 |
|
---|
582 |
|
---|
583 | /**
|
---|
584 | * PDM USB Device.
|
---|
585 | */
|
---|
586 | typedef struct PDMUSB
|
---|
587 | {
|
---|
588 | /** Pointer to the next device (R3 Ptr). */
|
---|
589 | R3PTRTYPE(PPDMUSB) pNext;
|
---|
590 | /** Device name length. (search optimization) */
|
---|
591 | RTUINT cchName;
|
---|
592 | /** Registration structure. */
|
---|
593 | R3PTRTYPE(const struct PDMUSBREG *) pReg;
|
---|
594 | /** Next instance number. */
|
---|
595 | uint32_t iNextInstance;
|
---|
596 | /** Pointer to chain of instances (R3 Ptr). */
|
---|
597 | R3PTRTYPE(PPDMUSBINS) pInstances;
|
---|
598 | } PDMUSB;
|
---|
599 |
|
---|
600 |
|
---|
601 | /**
|
---|
602 | * PDM Driver.
|
---|
603 | */
|
---|
604 | typedef struct PDMDRV
|
---|
605 | {
|
---|
606 | /** Pointer to the next device. */
|
---|
607 | PPDMDRV pNext;
|
---|
608 | /** Registration structure. */
|
---|
609 | const struct PDMDRVREG * pReg;
|
---|
610 | /** Current number of instances. */
|
---|
611 | uint32_t cInstances;
|
---|
612 | /** The next instance number. */
|
---|
613 | uint32_t iNextInstance;
|
---|
614 | /** The search path for raw-mode context modules (';' as separator). */
|
---|
615 | char *pszRCSearchPath;
|
---|
616 | /** The search path for ring-0 context modules (';' as separator). */
|
---|
617 | char *pszR0SearchPath;
|
---|
618 | } PDMDRV;
|
---|
619 |
|
---|
620 |
|
---|
621 | /**
|
---|
622 | * PDM registered PIC device.
|
---|
623 | */
|
---|
624 | typedef struct PDMPIC
|
---|
625 | {
|
---|
626 | /** Pointer to the PIC device instance - R3. */
|
---|
627 | PPDMDEVINSR3 pDevInsR3;
|
---|
628 | /** @copydoc PDMPICREG::pfnSetIrqR3 */
|
---|
629 | DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
630 | /** @copydoc PDMPICREG::pfnGetInterruptR3 */
|
---|
631 | DECLR3CALLBACKMEMBER(int, pfnGetInterruptR3,(PPDMDEVINS pDevIns, uint32_t *puTagSrc));
|
---|
632 |
|
---|
633 | /** Pointer to the PIC device instance - R0. */
|
---|
634 | PPDMDEVINSR0 pDevInsR0;
|
---|
635 | /** @copydoc PDMPICREG::pfnSetIrqR3 */
|
---|
636 | DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
637 | /** @copydoc PDMPICREG::pfnGetInterruptR3 */
|
---|
638 | DECLR0CALLBACKMEMBER(int, pfnGetInterruptR0,(PPDMDEVINS pDevIns, uint32_t *puTagSrc));
|
---|
639 |
|
---|
640 | /** Pointer to the PIC device instance - RC. */
|
---|
641 | PPDMDEVINSRC pDevInsRC;
|
---|
642 | /** @copydoc PDMPICREG::pfnSetIrqR3 */
|
---|
643 | DECLRCCALLBACKMEMBER(void, pfnSetIrqRC,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
644 | /** @copydoc PDMPICREG::pfnGetInterruptR3 */
|
---|
645 | DECLRCCALLBACKMEMBER(int, pfnGetInterruptRC,(PPDMDEVINS pDevIns, uint32_t *puTagSrc));
|
---|
646 | /** Alignment padding. */
|
---|
647 | RTRCPTR RCPtrPadding;
|
---|
648 | } PDMPIC;
|
---|
649 |
|
---|
650 |
|
---|
651 | /**
|
---|
652 | * PDM registered APIC device.
|
---|
653 | */
|
---|
654 | typedef struct PDMAPIC
|
---|
655 | {
|
---|
656 | /** Pointer to the APIC device instance - R3 Ptr. */
|
---|
657 | PPDMDEVINSR3 pDevInsR3;
|
---|
658 | /** Pointer to the APIC device instance - R0 Ptr. */
|
---|
659 | PPDMDEVINSR0 pDevInsR0;
|
---|
660 | /** Pointer to the APIC device instance - RC Ptr. */
|
---|
661 | PPDMDEVINSRC pDevInsRC;
|
---|
662 | uint8_t Alignment[4];
|
---|
663 | } PDMAPIC;
|
---|
664 |
|
---|
665 |
|
---|
666 | /**
|
---|
667 | * PDM registered I/O APIC device.
|
---|
668 | */
|
---|
669 | typedef struct PDMIOAPIC
|
---|
670 | {
|
---|
671 | /** Pointer to the APIC device instance - R3 Ptr. */
|
---|
672 | PPDMDEVINSR3 pDevInsR3;
|
---|
673 | /** @copydoc PDMIOAPICREG::pfnSetIrqR3 */
|
---|
674 | DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
675 | /** @copydoc PDMIOAPICREG::pfnSendMsiR3 */
|
---|
676 | DECLR3CALLBACKMEMBER(void, pfnSendMsiR3,(PPDMDEVINS pDevIns, RTGCPHYS GCAddr, uint32_t uValue, uint32_t uTagSrc));
|
---|
677 | /** @copydoc PDMIOAPICREG::pfnSetEoiR3 */
|
---|
678 | DECLR3CALLBACKMEMBER(int, pfnSetEoiR3,(PPDMDEVINS pDevIns, uint8_t u8Vector));
|
---|
679 |
|
---|
680 | /** Pointer to the PIC device instance - R0. */
|
---|
681 | PPDMDEVINSR0 pDevInsR0;
|
---|
682 | /** @copydoc PDMIOAPICREG::pfnSetIrqR3 */
|
---|
683 | DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
684 | /** @copydoc PDMIOAPICREG::pfnSendMsiR3 */
|
---|
685 | DECLR0CALLBACKMEMBER(void, pfnSendMsiR0,(PPDMDEVINS pDevIns, RTGCPHYS GCAddr, uint32_t uValue, uint32_t uTagSrc));
|
---|
686 | /** @copydoc PDMIOAPICREG::pfnSetEoiR3 */
|
---|
687 | DECLR0CALLBACKMEMBER(int, pfnSetEoiR0,(PPDMDEVINS pDevIns, uint8_t u8Vector));
|
---|
688 |
|
---|
689 | /** Pointer to the APIC device instance - RC Ptr. */
|
---|
690 | PPDMDEVINSRC pDevInsRC;
|
---|
691 | /** @copydoc PDMIOAPICREG::pfnSetIrqR3 */
|
---|
692 | DECLRCCALLBACKMEMBER(void, pfnSetIrqRC,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
693 | /** @copydoc PDMIOAPICREG::pfnSendMsiR3 */
|
---|
694 | DECLRCCALLBACKMEMBER(void, pfnSendMsiRC,(PPDMDEVINS pDevIns, RTGCPHYS GCAddr, uint32_t uValue, uint32_t uTagSrc));
|
---|
695 | /** @copydoc PDMIOAPICREG::pfnSendMsiR3 */
|
---|
696 | DECLRCCALLBACKMEMBER(int, pfnSetEoiRC,(PPDMDEVINS pDevIns, uint8_t u8Vector));
|
---|
697 | } PDMIOAPIC;
|
---|
698 |
|
---|
699 | /** Maximum number of PCI busses for a VM. */
|
---|
700 | #define PDM_PCI_BUSSES_MAX 8
|
---|
701 |
|
---|
702 |
|
---|
703 | #ifdef IN_RING3
|
---|
704 | /**
|
---|
705 | * PDM registered firmware device.
|
---|
706 | */
|
---|
707 | typedef struct PDMFW
|
---|
708 | {
|
---|
709 | /** Pointer to the firmware device instance. */
|
---|
710 | PPDMDEVINSR3 pDevIns;
|
---|
711 | /** Copy of the registration structure. */
|
---|
712 | PDMFWREG Reg;
|
---|
713 | } PDMFW;
|
---|
714 | /** Pointer to a firmware instance. */
|
---|
715 | typedef PDMFW *PPDMFW;
|
---|
716 | #endif
|
---|
717 |
|
---|
718 |
|
---|
719 | /**
|
---|
720 | * PDM PCI Bus instance.
|
---|
721 | */
|
---|
722 | typedef struct PDMPCIBUS
|
---|
723 | {
|
---|
724 | /** PCI bus number. */
|
---|
725 | RTUINT iBus;
|
---|
726 | RTUINT uPadding0; /**< Alignment padding.*/
|
---|
727 |
|
---|
728 | /** Pointer to PCI Bus device instance. */
|
---|
729 | PPDMDEVINSR3 pDevInsR3;
|
---|
730 | /** @copydoc PDMPCIBUSREG::pfnSetIrqR3 */
|
---|
731 | DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
732 | /** @copydoc PDMPCIBUSREG::pfnRegisterR3 */
|
---|
733 | DECLR3CALLBACKMEMBER(int, pfnRegisterR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t fFlags,
|
---|
734 | uint8_t uPciDevNo, uint8_t uPciFunNo, const char *pszName));
|
---|
735 | /** @copydoc PDMPCIBUSREG::pfnRegisterMsiR3 */
|
---|
736 | DECLR3CALLBACKMEMBER(int, pfnRegisterMsiR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PPDMMSIREG pMsiReg));
|
---|
737 | /** @copydoc PDMPCIBUSREG::pfnIORegionRegisterR3 */
|
---|
738 | DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iRegion, RTGCPHYS cbRegion,
|
---|
739 | PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
|
---|
740 | /** @copydoc PDMPCIBUSREG::pfnSetConfigCallbacksR3 */
|
---|
741 | DECLR3CALLBACKMEMBER(void, pfnSetConfigCallbacksR3,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, PFNPCICONFIGREAD pfnRead,
|
---|
742 | PPFNPCICONFIGREAD ppfnReadOld, PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
|
---|
743 |
|
---|
744 | /** Pointer to the PIC device instance - R0. */
|
---|
745 | R0PTRTYPE(PPDMDEVINS) pDevInsR0;
|
---|
746 | /** @copydoc PDMPCIBUSREG::pfnSetIrqR3 */
|
---|
747 | DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
748 |
|
---|
749 | /** Pointer to PCI Bus device instance. */
|
---|
750 | PPDMDEVINSRC pDevInsRC;
|
---|
751 | /** @copydoc PDMPCIBUSREG::pfnSetIrqR3 */
|
---|
752 | DECLRCCALLBACKMEMBER(void, pfnSetIrqRC,(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
753 | } PDMPCIBUS;
|
---|
754 |
|
---|
755 |
|
---|
756 | #ifdef IN_RING3
|
---|
757 | /**
|
---|
758 | * PDM registered DMAC (DMA Controller) device.
|
---|
759 | */
|
---|
760 | typedef struct PDMDMAC
|
---|
761 | {
|
---|
762 | /** Pointer to the DMAC device instance. */
|
---|
763 | PPDMDEVINSR3 pDevIns;
|
---|
764 | /** Copy of the registration structure. */
|
---|
765 | PDMDMACREG Reg;
|
---|
766 | } PDMDMAC;
|
---|
767 |
|
---|
768 |
|
---|
769 | /**
|
---|
770 | * PDM registered RTC (Real Time Clock) device.
|
---|
771 | */
|
---|
772 | typedef struct PDMRTC
|
---|
773 | {
|
---|
774 | /** Pointer to the RTC device instance. */
|
---|
775 | PPDMDEVINSR3 pDevIns;
|
---|
776 | /** Copy of the registration structure. */
|
---|
777 | PDMRTCREG Reg;
|
---|
778 | } PDMRTC;
|
---|
779 |
|
---|
780 | #endif /* IN_RING3 */
|
---|
781 |
|
---|
782 | /**
|
---|
783 | * Module type.
|
---|
784 | */
|
---|
785 | typedef enum PDMMODTYPE
|
---|
786 | {
|
---|
787 | /** Raw-mode (RC) context module. */
|
---|
788 | PDMMOD_TYPE_RC,
|
---|
789 | /** Ring-0 (host) context module. */
|
---|
790 | PDMMOD_TYPE_R0,
|
---|
791 | /** Ring-3 (host) context module. */
|
---|
792 | PDMMOD_TYPE_R3
|
---|
793 | } PDMMODTYPE;
|
---|
794 |
|
---|
795 |
|
---|
796 | /** The module name length including the terminator. */
|
---|
797 | #define PDMMOD_NAME_LEN 32
|
---|
798 |
|
---|
799 | /**
|
---|
800 | * Loaded module instance.
|
---|
801 | */
|
---|
802 | typedef struct PDMMOD
|
---|
803 | {
|
---|
804 | /** Module name. This is used for referring to
|
---|
805 | * the module internally, sort of like a handle. */
|
---|
806 | char szName[PDMMOD_NAME_LEN];
|
---|
807 | /** Module type. */
|
---|
808 | PDMMODTYPE eType;
|
---|
809 | /** Loader module handle. Not used for R0 modules. */
|
---|
810 | RTLDRMOD hLdrMod;
|
---|
811 | /** Loaded address.
|
---|
812 | * This is the 'handle' for R0 modules. */
|
---|
813 | RTUINTPTR ImageBase;
|
---|
814 | /** Old loaded address.
|
---|
815 | * This is used during relocation of GC modules. Not used for R0 modules. */
|
---|
816 | RTUINTPTR OldImageBase;
|
---|
817 | /** Where the R3 HC bits are stored.
|
---|
818 | * This can be equal to ImageBase but doesn't have to. Not used for R0 modules. */
|
---|
819 | void *pvBits;
|
---|
820 |
|
---|
821 | /** Pointer to next module. */
|
---|
822 | struct PDMMOD *pNext;
|
---|
823 | /** Module filename. */
|
---|
824 | char szFilename[1];
|
---|
825 | } PDMMOD;
|
---|
826 | /** Pointer to loaded module instance. */
|
---|
827 | typedef PDMMOD *PPDMMOD;
|
---|
828 |
|
---|
829 |
|
---|
830 |
|
---|
831 | /** Extra space in the free array. */
|
---|
832 | #define PDMQUEUE_FREE_SLACK 16
|
---|
833 |
|
---|
834 | /**
|
---|
835 | * Queue type.
|
---|
836 | */
|
---|
837 | typedef enum PDMQUEUETYPE
|
---|
838 | {
|
---|
839 | /** Device consumer. */
|
---|
840 | PDMQUEUETYPE_DEV = 1,
|
---|
841 | /** Driver consumer. */
|
---|
842 | PDMQUEUETYPE_DRV,
|
---|
843 | /** Internal consumer. */
|
---|
844 | PDMQUEUETYPE_INTERNAL,
|
---|
845 | /** External consumer. */
|
---|
846 | PDMQUEUETYPE_EXTERNAL
|
---|
847 | } PDMQUEUETYPE;
|
---|
848 |
|
---|
849 | /** Pointer to a PDM Queue. */
|
---|
850 | typedef struct PDMQUEUE *PPDMQUEUE;
|
---|
851 |
|
---|
852 | /**
|
---|
853 | * PDM Queue.
|
---|
854 | */
|
---|
855 | typedef struct PDMQUEUE
|
---|
856 | {
|
---|
857 | /** Pointer to the next queue in the list. */
|
---|
858 | R3PTRTYPE(PPDMQUEUE) pNext;
|
---|
859 | /** Type specific data. */
|
---|
860 | union
|
---|
861 | {
|
---|
862 | /** PDMQUEUETYPE_DEV */
|
---|
863 | struct
|
---|
864 | {
|
---|
865 | /** Pointer to consumer function. */
|
---|
866 | R3PTRTYPE(PFNPDMQUEUEDEV) pfnCallback;
|
---|
867 | /** Pointer to the device instance owning the queue. */
|
---|
868 | R3PTRTYPE(PPDMDEVINS) pDevIns;
|
---|
869 | } Dev;
|
---|
870 | /** PDMQUEUETYPE_DRV */
|
---|
871 | struct
|
---|
872 | {
|
---|
873 | /** Pointer to consumer function. */
|
---|
874 | R3PTRTYPE(PFNPDMQUEUEDRV) pfnCallback;
|
---|
875 | /** Pointer to the driver instance owning the queue. */
|
---|
876 | R3PTRTYPE(PPDMDRVINS) pDrvIns;
|
---|
877 | } Drv;
|
---|
878 | /** PDMQUEUETYPE_INTERNAL */
|
---|
879 | struct
|
---|
880 | {
|
---|
881 | /** Pointer to consumer function. */
|
---|
882 | R3PTRTYPE(PFNPDMQUEUEINT) pfnCallback;
|
---|
883 | } Int;
|
---|
884 | /** PDMQUEUETYPE_EXTERNAL */
|
---|
885 | struct
|
---|
886 | {
|
---|
887 | /** Pointer to consumer function. */
|
---|
888 | R3PTRTYPE(PFNPDMQUEUEEXT) pfnCallback;
|
---|
889 | /** Pointer to user argument. */
|
---|
890 | R3PTRTYPE(void *) pvUser;
|
---|
891 | } Ext;
|
---|
892 | } u;
|
---|
893 | /** Queue type. */
|
---|
894 | PDMQUEUETYPE enmType;
|
---|
895 | /** The interval between checking the queue for events.
|
---|
896 | * The realtime timer below is used to do the waiting.
|
---|
897 | * If 0, the queue will use the VM_FF_PDM_QUEUE forced action. */
|
---|
898 | uint32_t cMilliesInterval;
|
---|
899 | /** Interval timer. Only used if cMilliesInterval is non-zero. */
|
---|
900 | PTMTIMERR3 pTimer;
|
---|
901 | /** Pointer to the VM - R3. */
|
---|
902 | PVMR3 pVMR3;
|
---|
903 | /** LIFO of pending items - R3. */
|
---|
904 | R3PTRTYPE(PPDMQUEUEITEMCORE) volatile pPendingR3;
|
---|
905 | /** Pointer to the VM - R0. */
|
---|
906 | PVMR0 pVMR0;
|
---|
907 | /** LIFO of pending items - R0. */
|
---|
908 | R0PTRTYPE(PPDMQUEUEITEMCORE) volatile pPendingR0;
|
---|
909 | /** Pointer to the GC VM and indicator for GC enabled queue.
|
---|
910 | * If this is NULL, the queue cannot be used in GC.
|
---|
911 | */
|
---|
912 | PVMRC pVMRC;
|
---|
913 | /** LIFO of pending items - GC. */
|
---|
914 | RCPTRTYPE(PPDMQUEUEITEMCORE) volatile pPendingRC;
|
---|
915 |
|
---|
916 | /** Item size (bytes). */
|
---|
917 | uint32_t cbItem;
|
---|
918 | /** Number of items in the queue. */
|
---|
919 | uint32_t cItems;
|
---|
920 | /** Index to the free head (where we insert). */
|
---|
921 | uint32_t volatile iFreeHead;
|
---|
922 | /** Index to the free tail (where we remove). */
|
---|
923 | uint32_t volatile iFreeTail;
|
---|
924 |
|
---|
925 | /** Unique queue name. */
|
---|
926 | R3PTRTYPE(const char *) pszName;
|
---|
927 | #if HC_ARCH_BITS == 32
|
---|
928 | RTR3PTR Alignment1;
|
---|
929 | #endif
|
---|
930 | /** Stat: Times PDMQueueAlloc fails. */
|
---|
931 | STAMCOUNTER StatAllocFailures;
|
---|
932 | /** Stat: PDMQueueInsert calls. */
|
---|
933 | STAMCOUNTER StatInsert;
|
---|
934 | /** Stat: Queue flushes. */
|
---|
935 | STAMCOUNTER StatFlush;
|
---|
936 | /** Stat: Queue flushes with pending items left over. */
|
---|
937 | STAMCOUNTER StatFlushLeftovers;
|
---|
938 | #ifdef VBOX_WITH_STATISTICS
|
---|
939 | /** State: Profiling the flushing. */
|
---|
940 | STAMPROFILE StatFlushPrf;
|
---|
941 | /** State: Pending items. */
|
---|
942 | uint32_t volatile cStatPending;
|
---|
943 | uint32_t volatile cAlignment;
|
---|
944 | #endif
|
---|
945 |
|
---|
946 | /** Array of pointers to free items. Variable size. */
|
---|
947 | struct PDMQUEUEFREEITEM
|
---|
948 | {
|
---|
949 | /** Pointer to the free item - HC Ptr. */
|
---|
950 | R3PTRTYPE(PPDMQUEUEITEMCORE) volatile pItemR3;
|
---|
951 | /** Pointer to the free item - HC Ptr. */
|
---|
952 | R0PTRTYPE(PPDMQUEUEITEMCORE) volatile pItemR0;
|
---|
953 | /** Pointer to the free item - GC Ptr. */
|
---|
954 | RCPTRTYPE(PPDMQUEUEITEMCORE) volatile pItemRC;
|
---|
955 | #if HC_ARCH_BITS == 64
|
---|
956 | RTRCPTR Alignment0;
|
---|
957 | #endif
|
---|
958 | } aFreeItems[1];
|
---|
959 | } PDMQUEUE;
|
---|
960 |
|
---|
961 | /** @name PDM::fQueueFlushing
|
---|
962 | * @{ */
|
---|
963 | /** Used to make sure only one EMT will flush the queues.
|
---|
964 | * Set when an EMT is flushing queues, clear otherwise. */
|
---|
965 | #define PDM_QUEUE_FLUSH_FLAG_ACTIVE_BIT 0
|
---|
966 | /** Indicating there are queues with items pending.
|
---|
967 | * This is make sure we don't miss inserts happening during flushing. The FF
|
---|
968 | * cannot be used for this since it has to be cleared immediately to prevent
|
---|
969 | * other EMTs from spinning. */
|
---|
970 | #define PDM_QUEUE_FLUSH_FLAG_PENDING_BIT 1
|
---|
971 | /** @} */
|
---|
972 |
|
---|
973 |
|
---|
974 | /**
|
---|
975 | * Queue device helper task operation.
|
---|
976 | */
|
---|
977 | typedef enum PDMDEVHLPTASKOP
|
---|
978 | {
|
---|
979 | /** The usual invalid 0 entry. */
|
---|
980 | PDMDEVHLPTASKOP_INVALID = 0,
|
---|
981 | /** ISASetIrq */
|
---|
982 | PDMDEVHLPTASKOP_ISA_SET_IRQ,
|
---|
983 | /** PCISetIrq */
|
---|
984 | PDMDEVHLPTASKOP_PCI_SET_IRQ,
|
---|
985 | /** PCISetIrq */
|
---|
986 | PDMDEVHLPTASKOP_IOAPIC_SET_IRQ,
|
---|
987 | /** The usual 32-bit hack. */
|
---|
988 | PDMDEVHLPTASKOP_32BIT_HACK = 0x7fffffff
|
---|
989 | } PDMDEVHLPTASKOP;
|
---|
990 |
|
---|
991 | /**
|
---|
992 | * Queued Device Helper Task.
|
---|
993 | */
|
---|
994 | typedef struct PDMDEVHLPTASK
|
---|
995 | {
|
---|
996 | /** The queue item core (don't touch). */
|
---|
997 | PDMQUEUEITEMCORE Core;
|
---|
998 | /** Pointer to the device instance (R3 Ptr). */
|
---|
999 | PPDMDEVINSR3 pDevInsR3;
|
---|
1000 | /** This operation to perform. */
|
---|
1001 | PDMDEVHLPTASKOP enmOp;
|
---|
1002 | #if HC_ARCH_BITS == 64
|
---|
1003 | uint32_t Alignment0;
|
---|
1004 | #endif
|
---|
1005 | /** Parameters to the operation. */
|
---|
1006 | union PDMDEVHLPTASKPARAMS
|
---|
1007 | {
|
---|
1008 | /**
|
---|
1009 | * PDMDEVHLPTASKOP_ISA_SET_IRQ and PDMDEVHLPTASKOP_IOAPIC_SET_IRQ.
|
---|
1010 | */
|
---|
1011 | struct PDMDEVHLPTASKISASETIRQ
|
---|
1012 | {
|
---|
1013 | /** The IRQ */
|
---|
1014 | int iIrq;
|
---|
1015 | /** The new level. */
|
---|
1016 | int iLevel;
|
---|
1017 | /** The IRQ tag and source. */
|
---|
1018 | uint32_t uTagSrc;
|
---|
1019 | } IsaSetIRQ, IoApicSetIRQ;
|
---|
1020 |
|
---|
1021 | /**
|
---|
1022 | * PDMDEVHLPTASKOP_PCI_SET_IRQ
|
---|
1023 | */
|
---|
1024 | struct PDMDEVHLPTASKPCISETIRQ
|
---|
1025 | {
|
---|
1026 | /** Pointer to the PCI device (R3 Ptr). */
|
---|
1027 | R3PTRTYPE(PPDMPCIDEV) pPciDevR3;
|
---|
1028 | /** The IRQ */
|
---|
1029 | int iIrq;
|
---|
1030 | /** The new level. */
|
---|
1031 | int iLevel;
|
---|
1032 | /** The IRQ tag and source. */
|
---|
1033 | uint32_t uTagSrc;
|
---|
1034 | } PciSetIRQ;
|
---|
1035 |
|
---|
1036 | /** Expanding the structure. */
|
---|
1037 | uint64_t au64[3];
|
---|
1038 | } u;
|
---|
1039 | } PDMDEVHLPTASK;
|
---|
1040 | /** Pointer to a queued Device Helper Task. */
|
---|
1041 | typedef PDMDEVHLPTASK *PPDMDEVHLPTASK;
|
---|
1042 | /** Pointer to a const queued Device Helper Task. */
|
---|
1043 | typedef const PDMDEVHLPTASK *PCPDMDEVHLPTASK;
|
---|
1044 |
|
---|
1045 |
|
---|
1046 |
|
---|
1047 | /**
|
---|
1048 | * An USB hub registration record.
|
---|
1049 | */
|
---|
1050 | typedef struct PDMUSBHUB
|
---|
1051 | {
|
---|
1052 | /** The USB versions this hub support.
|
---|
1053 | * Note that 1.1 hubs can take on 2.0 devices. */
|
---|
1054 | uint32_t fVersions;
|
---|
1055 | /** The number of ports on the hub. */
|
---|
1056 | uint32_t cPorts;
|
---|
1057 | /** The number of available ports (0..cPorts). */
|
---|
1058 | uint32_t cAvailablePorts;
|
---|
1059 | /** The driver instance of the hub. */
|
---|
1060 | PPDMDRVINS pDrvIns;
|
---|
1061 | /** Copy of the to the registration structure. */
|
---|
1062 | PDMUSBHUBREG Reg;
|
---|
1063 |
|
---|
1064 | /** Pointer to the next hub in the list. */
|
---|
1065 | struct PDMUSBHUB *pNext;
|
---|
1066 | } PDMUSBHUB;
|
---|
1067 |
|
---|
1068 | /** Pointer to a const USB HUB registration record. */
|
---|
1069 | typedef const PDMUSBHUB *PCPDMUSBHUB;
|
---|
1070 |
|
---|
1071 | /** Pointer to a PDM Async I/O template. */
|
---|
1072 | typedef struct PDMASYNCCOMPLETIONTEMPLATE *PPDMASYNCCOMPLETIONTEMPLATE;
|
---|
1073 |
|
---|
1074 | /** Pointer to the main PDM Async completion endpoint class. */
|
---|
1075 | typedef struct PDMASYNCCOMPLETIONEPCLASS *PPDMASYNCCOMPLETIONEPCLASS;
|
---|
1076 |
|
---|
1077 | /** Pointer to the global block cache structure. */
|
---|
1078 | typedef struct PDMBLKCACHEGLOBAL *PPDMBLKCACHEGLOBAL;
|
---|
1079 |
|
---|
1080 | /**
|
---|
1081 | * PDM VMCPU Instance data.
|
---|
1082 | * Changes to this must checked against the padding of the pdm union in VMCPU!
|
---|
1083 | */
|
---|
1084 | typedef struct PDMCPU
|
---|
1085 | {
|
---|
1086 | /** The number of entries in the apQueuedCritSectsLeaves table that's currently
|
---|
1087 | * in use. */
|
---|
1088 | uint32_t cQueuedCritSectLeaves;
|
---|
1089 | uint32_t uPadding0; /**< Alignment padding.*/
|
---|
1090 | /** Critical sections queued in RC/R0 because of contention preventing leave to
|
---|
1091 | * complete. (R3 Ptrs)
|
---|
1092 | * We will return to Ring-3 ASAP, so this queue doesn't have to be very long. */
|
---|
1093 | R3PTRTYPE(PPDMCRITSECT) apQueuedCritSectLeaves[8];
|
---|
1094 |
|
---|
1095 | /** The number of entries in the apQueuedCritSectRwExclLeaves table that's
|
---|
1096 | * currently in use. */
|
---|
1097 | uint32_t cQueuedCritSectRwExclLeaves;
|
---|
1098 | uint32_t uPadding1; /**< Alignment padding.*/
|
---|
1099 | /** Read/write critical sections queued in RC/R0 because of contention
|
---|
1100 | * preventing exclusive leave to complete. (R3 Ptrs)
|
---|
1101 | * We will return to Ring-3 ASAP, so this queue doesn't have to be very long. */
|
---|
1102 | R3PTRTYPE(PPDMCRITSECTRW) apQueuedCritSectRwExclLeaves[8];
|
---|
1103 |
|
---|
1104 | /** The number of entries in the apQueuedCritSectsRwShrdLeaves table that's
|
---|
1105 | * currently in use. */
|
---|
1106 | uint32_t cQueuedCritSectRwShrdLeaves;
|
---|
1107 | uint32_t uPadding2; /**< Alignment padding.*/
|
---|
1108 | /** Read/write critical sections queued in RC/R0 because of contention
|
---|
1109 | * preventing shared leave to complete. (R3 Ptrs)
|
---|
1110 | * We will return to Ring-3 ASAP, so this queue doesn't have to be very long. */
|
---|
1111 | R3PTRTYPE(PPDMCRITSECTRW) apQueuedCritSectRwShrdLeaves[8];
|
---|
1112 | } PDMCPU;
|
---|
1113 |
|
---|
1114 |
|
---|
1115 | /**
|
---|
1116 | * PDM VM Instance data.
|
---|
1117 | * Changes to this must checked against the padding of the cfgm union in VM!
|
---|
1118 | */
|
---|
1119 | typedef struct PDM
|
---|
1120 | {
|
---|
1121 | /** The PDM lock.
|
---|
1122 | * This is used to protect everything that deals with interrupts, i.e.
|
---|
1123 | * the PIC, APIC, IOAPIC and PCI devices plus some PDM functions. */
|
---|
1124 | PDMCRITSECT CritSect;
|
---|
1125 | /** The NOP critical section.
|
---|
1126 | * This is a dummy critical section that will not do any thread
|
---|
1127 | * serialization but instead let all threads enter immediately and
|
---|
1128 | * concurrently. */
|
---|
1129 | PDMCRITSECT NopCritSect;
|
---|
1130 |
|
---|
1131 | /** List of registered devices. (FIFO) */
|
---|
1132 | R3PTRTYPE(PPDMDEV) pDevs;
|
---|
1133 | /** List of devices instances. (FIFO) */
|
---|
1134 | R3PTRTYPE(PPDMDEVINS) pDevInstances;
|
---|
1135 | /** List of registered USB devices. (FIFO) */
|
---|
1136 | R3PTRTYPE(PPDMUSB) pUsbDevs;
|
---|
1137 | /** List of USB devices instances. (FIFO) */
|
---|
1138 | R3PTRTYPE(PPDMUSBINS) pUsbInstances;
|
---|
1139 | /** List of registered drivers. (FIFO) */
|
---|
1140 | R3PTRTYPE(PPDMDRV) pDrvs;
|
---|
1141 | /** The registered firmware device (can be NULL). */
|
---|
1142 | R3PTRTYPE(PPDMFW) pFirmware;
|
---|
1143 | /** PCI Buses. */
|
---|
1144 | PDMPCIBUS aPciBuses[PDM_PCI_BUSSES_MAX];
|
---|
1145 | /** The register PIC device. */
|
---|
1146 | PDMPIC Pic;
|
---|
1147 | /** The registered APIC device. */
|
---|
1148 | PDMAPIC Apic;
|
---|
1149 | /** The registered I/O APIC device. */
|
---|
1150 | PDMIOAPIC IoApic;
|
---|
1151 | /** The registered DMAC device. */
|
---|
1152 | R3PTRTYPE(PPDMDMAC) pDmac;
|
---|
1153 | /** The registered RTC device. */
|
---|
1154 | R3PTRTYPE(PPDMRTC) pRtc;
|
---|
1155 | /** The registered USB HUBs. (FIFO) */
|
---|
1156 | R3PTRTYPE(PPDMUSBHUB) pUsbHubs;
|
---|
1157 |
|
---|
1158 | /** Queue in which devhlp tasks are queued for R3 execution - R3 Ptr. */
|
---|
1159 | R3PTRTYPE(PPDMQUEUE) pDevHlpQueueR3;
|
---|
1160 | /** Queue in which devhlp tasks are queued for R3 execution - R0 Ptr. */
|
---|
1161 | R0PTRTYPE(PPDMQUEUE) pDevHlpQueueR0;
|
---|
1162 | /** Queue in which devhlp tasks are queued for R3 execution - RC Ptr. */
|
---|
1163 | RCPTRTYPE(PPDMQUEUE) pDevHlpQueueRC;
|
---|
1164 | /** Pointer to the queue which should be manually flushed - RC Ptr.
|
---|
1165 | * Only touched by EMT. */
|
---|
1166 | RCPTRTYPE(struct PDMQUEUE *) pQueueFlushRC;
|
---|
1167 | /** Pointer to the queue which should be manually flushed - R0 Ptr.
|
---|
1168 | * Only touched by EMT. */
|
---|
1169 | R0PTRTYPE(struct PDMQUEUE *) pQueueFlushR0;
|
---|
1170 | /** Bitmask controlling the queue flushing.
|
---|
1171 | * See PDM_QUEUE_FLUSH_FLAG_ACTIVE and PDM_QUEUE_FLUSH_FLAG_PENDING. */
|
---|
1172 | uint32_t volatile fQueueFlushing;
|
---|
1173 |
|
---|
1174 | /** The current IRQ tag (tracing purposes). */
|
---|
1175 | uint32_t volatile uIrqTag;
|
---|
1176 |
|
---|
1177 | /** Pending reset flags (PDMVMRESET_F_XXX). */
|
---|
1178 | uint32_t volatile fResetFlags;
|
---|
1179 |
|
---|
1180 | /** Set by pdmR3LoadExec for use in assertions. */
|
---|
1181 | bool fStateLoaded;
|
---|
1182 | /** Alignment padding. */
|
---|
1183 | bool afPadding[3];
|
---|
1184 |
|
---|
1185 | /** The tracing ID of the next device instance.
|
---|
1186 | *
|
---|
1187 | * @remarks We keep the device tracing ID seperate from the rest as these are
|
---|
1188 | * then more likely to end up with the same ID from one run to
|
---|
1189 | * another, making analysis somewhat easier. Drivers and USB devices
|
---|
1190 | * are more volatile and can be changed at runtime, thus these are much
|
---|
1191 | * less likely to remain stable, so just heap them all together. */
|
---|
1192 | uint32_t idTracingDev;
|
---|
1193 | /** The tracing ID of the next driver instance, USB device instance or other
|
---|
1194 | * PDM entity requiring an ID. */
|
---|
1195 | uint32_t idTracingOther;
|
---|
1196 |
|
---|
1197 | /** @name VMM device heap
|
---|
1198 | * @{ */
|
---|
1199 | /** The heap size. */
|
---|
1200 | uint32_t cbVMMDevHeap;
|
---|
1201 | /** Free space. */
|
---|
1202 | uint32_t cbVMMDevHeapLeft;
|
---|
1203 | /** Pointer to the heap base (MMIO2 ring-3 mapping). NULL if not registered. */
|
---|
1204 | RTR3PTR pvVMMDevHeap;
|
---|
1205 | /** Ring-3 mapping/unmapping notification callback for the user. */
|
---|
1206 | PFNPDMVMMDEVHEAPNOTIFY pfnVMMDevHeapNotify;
|
---|
1207 | /** The current mapping. NIL_RTGCPHYS if not mapped or registered. */
|
---|
1208 | RTGCPHYS GCPhysVMMDevHeap;
|
---|
1209 | /** @} */
|
---|
1210 |
|
---|
1211 | /** Number of times a critical section leave request needed to be queued for ring-3 execution. */
|
---|
1212 | STAMCOUNTER StatQueuedCritSectLeaves;
|
---|
1213 | } PDM;
|
---|
1214 | AssertCompileMemberAlignment(PDM, GCPhysVMMDevHeap, sizeof(RTGCPHYS));
|
---|
1215 | AssertCompileMemberAlignment(PDM, CritSect, 8);
|
---|
1216 | AssertCompileMemberAlignment(PDM, StatQueuedCritSectLeaves, 8);
|
---|
1217 | /** Pointer to PDM VM instance data. */
|
---|
1218 | typedef PDM *PPDM;
|
---|
1219 |
|
---|
1220 |
|
---|
1221 | /**
|
---|
1222 | * PDM data kept in the ring-0 GVM.
|
---|
1223 | */
|
---|
1224 | typedef struct PDMR0PERVM
|
---|
1225 | {
|
---|
1226 | /** Number of valid ring-0 device instances (apDevInstances). */
|
---|
1227 | uint32_t cDevInstances;
|
---|
1228 | /** Pointer to ring-0 device instances. */
|
---|
1229 | R0PTRTYPE(struct PDMDEVINSR0 *) apDevInstances[190];
|
---|
1230 | } PDMR0PERVM;
|
---|
1231 |
|
---|
1232 |
|
---|
1233 | /**
|
---|
1234 | * PDM data kept in the UVM.
|
---|
1235 | */
|
---|
1236 | typedef struct PDMUSERPERVM
|
---|
1237 | {
|
---|
1238 | /** @todo move more stuff over here. */
|
---|
1239 |
|
---|
1240 | /** Linked list of timer driven PDM queues.
|
---|
1241 | * Currently serialized by PDM::CritSect. */
|
---|
1242 | R3PTRTYPE(struct PDMQUEUE *) pQueuesTimer;
|
---|
1243 | /** Linked list of force action driven PDM queues.
|
---|
1244 | * Currently serialized by PDM::CritSect. */
|
---|
1245 | R3PTRTYPE(struct PDMQUEUE *) pQueuesForced;
|
---|
1246 |
|
---|
1247 | /** Lock protecting the lists below it. */
|
---|
1248 | RTCRITSECT ListCritSect;
|
---|
1249 | /** Pointer to list of loaded modules. */
|
---|
1250 | PPDMMOD pModules;
|
---|
1251 | /** List of initialized critical sections. (LIFO) */
|
---|
1252 | R3PTRTYPE(PPDMCRITSECTINT) pCritSects;
|
---|
1253 | /** List of initialized read/write critical sections. (LIFO) */
|
---|
1254 | R3PTRTYPE(PPDMCRITSECTRWINT) pRwCritSects;
|
---|
1255 | /** Head of the PDM Thread list. (singly linked) */
|
---|
1256 | R3PTRTYPE(PPDMTHREAD) pThreads;
|
---|
1257 | /** Tail of the PDM Thread list. (singly linked) */
|
---|
1258 | R3PTRTYPE(PPDMTHREAD) pThreadsTail;
|
---|
1259 |
|
---|
1260 | /** @name PDM Async Completion
|
---|
1261 | * @{ */
|
---|
1262 | /** Pointer to the array of supported endpoint classes. */
|
---|
1263 | PPDMASYNCCOMPLETIONEPCLASS apAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_MAX];
|
---|
1264 | /** Head of the templates. Singly linked, protected by ListCritSect. */
|
---|
1265 | R3PTRTYPE(PPDMASYNCCOMPLETIONTEMPLATE) pAsyncCompletionTemplates;
|
---|
1266 | /** @} */
|
---|
1267 |
|
---|
1268 | /** Global block cache data. */
|
---|
1269 | R3PTRTYPE(PPDMBLKCACHEGLOBAL) pBlkCacheGlobal;
|
---|
1270 | #ifdef VBOX_WITH_NETSHAPER
|
---|
1271 | /** Pointer to network shaper instance. */
|
---|
1272 | R3PTRTYPE(PPDMNETSHAPER) pNetShaper;
|
---|
1273 | #endif /* VBOX_WITH_NETSHAPER */
|
---|
1274 |
|
---|
1275 | } PDMUSERPERVM;
|
---|
1276 | /** Pointer to the PDM data kept in the UVM. */
|
---|
1277 | typedef PDMUSERPERVM *PPDMUSERPERVM;
|
---|
1278 |
|
---|
1279 |
|
---|
1280 |
|
---|
1281 | /*******************************************************************************
|
---|
1282 | * Global Variables *
|
---|
1283 | *******************************************************************************/
|
---|
1284 | #ifdef IN_RING3
|
---|
1285 | extern const PDMDRVHLPR3 g_pdmR3DrvHlp;
|
---|
1286 | extern const PDMDEVHLPR3 g_pdmR3DevHlpTrusted;
|
---|
1287 | extern const PDMDEVHLPR3 g_pdmR3DevHlpUnTrusted;
|
---|
1288 | extern const PDMPICHLPR3 g_pdmR3DevPicHlp;
|
---|
1289 | extern const PDMIOAPICHLPR3 g_pdmR3DevIoApicHlp;
|
---|
1290 | extern const PDMFWHLPR3 g_pdmR3DevFirmwareHlp;
|
---|
1291 | extern const PDMPCIHLPR3 g_pdmR3DevPciHlp;
|
---|
1292 | extern const PDMDMACHLP g_pdmR3DevDmacHlp;
|
---|
1293 | extern const PDMRTCHLP g_pdmR3DevRtcHlp;
|
---|
1294 | extern const PDMHPETHLPR3 g_pdmR3DevHpetHlp;
|
---|
1295 | extern const PDMPCIRAWHLPR3 g_pdmR3DevPciRawHlp;
|
---|
1296 | #endif
|
---|
1297 |
|
---|
1298 |
|
---|
1299 | /*******************************************************************************
|
---|
1300 | * Defined Constants And Macros *
|
---|
1301 | *******************************************************************************/
|
---|
1302 | /** @def PDMDEV_ASSERT_DEVINS
|
---|
1303 | * Asserts the validity of the device instance.
|
---|
1304 | */
|
---|
1305 | #ifdef VBOX_STRICT
|
---|
1306 | # define PDMDEV_ASSERT_DEVINS(pDevIns) \
|
---|
1307 | do { \
|
---|
1308 | AssertPtr(pDevIns); \
|
---|
1309 | Assert(pDevIns->u32Version == PDM_DEVINS_VERSION); \
|
---|
1310 | Assert(pDevIns->CTX_SUFF(pvInstanceDataFor) == (void *)&pDevIns->achInstanceData[0]); \
|
---|
1311 | } while (0)
|
---|
1312 | #else
|
---|
1313 | # define PDMDEV_ASSERT_DEVINS(pDevIns) do { } while (0)
|
---|
1314 | #endif
|
---|
1315 |
|
---|
1316 | /** @def PDMDRV_ASSERT_DRVINS
|
---|
1317 | * Asserts the validity of the driver instance.
|
---|
1318 | */
|
---|
1319 | #ifdef VBOX_STRICT
|
---|
1320 | # define PDMDRV_ASSERT_DRVINS(pDrvIns) \
|
---|
1321 | do { \
|
---|
1322 | AssertPtr(pDrvIns); \
|
---|
1323 | Assert(pDrvIns->u32Version == PDM_DRVINS_VERSION); \
|
---|
1324 | Assert(pDrvIns->CTX_SUFF(pvInstanceData) == (void *)&pDrvIns->achInstanceData[0]); \
|
---|
1325 | } while (0)
|
---|
1326 | #else
|
---|
1327 | # define PDMDRV_ASSERT_DRVINS(pDrvIns) do { } while (0)
|
---|
1328 | #endif
|
---|
1329 |
|
---|
1330 |
|
---|
1331 | /*******************************************************************************
|
---|
1332 | * Internal Functions *
|
---|
1333 | *******************************************************************************/
|
---|
1334 | #ifdef IN_RING3
|
---|
1335 | bool pdmR3IsValidName(const char *pszName);
|
---|
1336 |
|
---|
1337 | int pdmR3CritSectBothInitStats(PVM pVM);
|
---|
1338 | void pdmR3CritSectBothRelocate(PVM pVM);
|
---|
1339 | int pdmR3CritSectBothDeleteDevice(PVM pVM, PPDMDEVINS pDevIns);
|
---|
1340 | int pdmR3CritSectBothDeleteDriver(PVM pVM, PPDMDRVINS pDrvIns);
|
---|
1341 | int pdmR3CritSectInitDevice( PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
|
---|
1342 | const char *pszNameFmt, va_list va);
|
---|
1343 | int pdmR3CritSectInitDeviceAuto( PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
|
---|
1344 | const char *pszNameFmt, ...);
|
---|
1345 | int pdmR3CritSectInitDriver( PVM pVM, PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
|
---|
1346 | const char *pszNameFmt, ...);
|
---|
1347 | int pdmR3CritSectRwInitDevice( PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECTRW pCritSect, RT_SRC_POS_DECL,
|
---|
1348 | const char *pszNameFmt, va_list va);
|
---|
1349 | int pdmR3CritSectRwInitDeviceAuto( PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECTRW pCritSect, RT_SRC_POS_DECL,
|
---|
1350 | const char *pszNameFmt, ...);
|
---|
1351 | int pdmR3CritSectRwInitDriver( PVM pVM, PPDMDRVINS pDrvIns, PPDMCRITSECTRW pCritSect, RT_SRC_POS_DECL,
|
---|
1352 | const char *pszNameFmt, ...);
|
---|
1353 |
|
---|
1354 | int pdmR3DevInit(PVM pVM);
|
---|
1355 | int pdmR3DevInitComplete(PVM pVM);
|
---|
1356 | PPDMDEV pdmR3DevLookup(PVM pVM, const char *pszName);
|
---|
1357 | int pdmR3DevFindLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMLUN *ppLun);
|
---|
1358 | DECLCALLBACK(bool) pdmR3DevHlpQueueConsumer(PVM pVM, PPDMQUEUEITEMCORE pItem);
|
---|
1359 |
|
---|
1360 | int pdmR3UsbLoadModules(PVM pVM);
|
---|
1361 | int pdmR3UsbInstantiateDevices(PVM pVM);
|
---|
1362 | PPDMUSB pdmR3UsbLookup(PVM pVM, const char *pszName);
|
---|
1363 | int pdmR3UsbRegisterHub(PVM pVM, PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp);
|
---|
1364 | int pdmR3UsbVMInitComplete(PVM pVM);
|
---|
1365 |
|
---|
1366 | int pdmR3DrvInit(PVM pVM);
|
---|
1367 | int pdmR3DrvInstantiate(PVM pVM, PCFGMNODE pNode, PPDMIBASE pBaseInterface, PPDMDRVINS pDrvAbove,
|
---|
1368 | PPDMLUN pLun, PPDMIBASE *ppBaseInterface);
|
---|
1369 | int pdmR3DrvDetach(PPDMDRVINS pDrvIns, uint32_t fFlags);
|
---|
1370 | void pdmR3DrvDestroyChain(PPDMDRVINS pDrvIns, uint32_t fFlags);
|
---|
1371 | PPDMDRV pdmR3DrvLookup(PVM pVM, const char *pszName);
|
---|
1372 |
|
---|
1373 | int pdmR3LdrInitU(PUVM pUVM);
|
---|
1374 | void pdmR3LdrTermU(PUVM pUVM);
|
---|
1375 | char *pdmR3FileR3(const char *pszFile, bool fShared);
|
---|
1376 | int pdmR3LoadR3U(PUVM pUVM, const char *pszFilename, const char *pszName);
|
---|
1377 |
|
---|
1378 | void pdmR3QueueRelocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
1379 |
|
---|
1380 | int pdmR3ThreadCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
|
---|
1381 | PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
|
---|
1382 | int pdmR3ThreadCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADUSB pfnThread,
|
---|
1383 | PFNPDMTHREADWAKEUPUSB pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
|
---|
1384 | int pdmR3ThreadCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
|
---|
1385 | PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
|
---|
1386 | int pdmR3ThreadDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
|
---|
1387 | int pdmR3ThreadDestroyUsb(PVM pVM, PPDMUSBINS pUsbIns);
|
---|
1388 | int pdmR3ThreadDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
|
---|
1389 | void pdmR3ThreadDestroyAll(PVM pVM);
|
---|
1390 | int pdmR3ThreadResumeAll(PVM pVM);
|
---|
1391 | int pdmR3ThreadSuspendAll(PVM pVM);
|
---|
1392 |
|
---|
1393 | #ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
|
---|
1394 | int pdmR3AsyncCompletionInit(PVM pVM);
|
---|
1395 | int pdmR3AsyncCompletionTerm(PVM pVM);
|
---|
1396 | void pdmR3AsyncCompletionResume(PVM pVM);
|
---|
1397 | int pdmR3AsyncCompletionTemplateCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEDEV pfnCompleted, const char *pszDesc);
|
---|
1398 | int pdmR3AsyncCompletionTemplateCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
|
---|
1399 | PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser, const char *pszDesc);
|
---|
1400 | int pdmR3AsyncCompletionTemplateCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEUSB pfnCompleted, const char *pszDesc);
|
---|
1401 | int pdmR3AsyncCompletionTemplateDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
|
---|
1402 | int pdmR3AsyncCompletionTemplateDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
|
---|
1403 | int pdmR3AsyncCompletionTemplateDestroyUsb(PVM pVM, PPDMUSBINS pUsbIns);
|
---|
1404 | #endif
|
---|
1405 |
|
---|
1406 | #ifdef VBOX_WITH_NETSHAPER
|
---|
1407 | int pdmR3NetShaperInit(PVM pVM);
|
---|
1408 | int pdmR3NetShaperTerm(PVM pVM);
|
---|
1409 | #endif
|
---|
1410 |
|
---|
1411 | int pdmR3BlkCacheInit(PVM pVM);
|
---|
1412 | void pdmR3BlkCacheTerm(PVM pVM);
|
---|
1413 | int pdmR3BlkCacheResume(PVM pVM);
|
---|
1414 |
|
---|
1415 | #endif /* IN_RING3 */
|
---|
1416 |
|
---|
1417 | void pdmLock(PVMCC pVM);
|
---|
1418 | int pdmLockEx(PVMCC pVM, int rc);
|
---|
1419 | void pdmUnlock(PVMCC pVM);
|
---|
1420 |
|
---|
1421 | #if defined(IN_RING3) || defined(IN_RING0)
|
---|
1422 | void pdmCritSectRwLeaveSharedQueued(PPDMCRITSECTRW pThis);
|
---|
1423 | void pdmCritSectRwLeaveExclQueued(PPDMCRITSECTRW pThis);
|
---|
1424 | #endif
|
---|
1425 |
|
---|
1426 | /** @} */
|
---|
1427 |
|
---|
1428 | RT_C_DECLS_END
|
---|
1429 |
|
---|
1430 | #endif /* !VMM_INCLUDED_SRC_include_PDMInternal_h */
|
---|
1431 |
|
---|