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