1 | /* $Id: PDMInternal.h 60397 2016-04-08 16:28:04Z 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, PVMCPU pVCpu, uint32_t *puTagSrc));
|
---|
568 | /** @copydoc PDMAPICREG::pfnHasPendingIrqR3 */
|
---|
569 | DECLR3CALLBACKMEMBER(bool, pfnHasPendingIrqR3,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint8_t *pu8PendingIrq));
|
---|
570 | /** @copydoc PDMAPICREG::pfnSetBaseMsrR3 */
|
---|
571 | DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnSetBaseMsrR3,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint64_t u64Base));
|
---|
572 | /** @copydoc PDMAPICREG::pfnGetBaseMsrR3 */
|
---|
573 | DECLR3CALLBACKMEMBER(uint64_t, pfnGetBaseMsrR3,(PPDMDEVINS pDevIns, PVMCPU pVCpu));
|
---|
574 | /** @copydoc PDMAPICREG::pfnSetTprR3 */
|
---|
575 | DECLR3CALLBACKMEMBER(void, pfnSetTprR3,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint8_t u8Tpr));
|
---|
576 | /** @copydoc PDMAPICREG::pfnGetTprR3 */
|
---|
577 | DECLR3CALLBACKMEMBER(uint8_t, pfnGetTprR3,(PPDMDEVINS pDevIns, PVMCPU pVCpu));
|
---|
578 | /** @copydoc PDMAPICREG::pfnWriteMsrR3 */
|
---|
579 | DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnWriteMsrR3, (PPDMDEVINS pDevIns, PVMCPU pVCpu, uint32_t u32Reg, uint64_t u64Value));
|
---|
580 | /** @copydoc PDMAPICREG::pfnReadMsrR3 */
|
---|
581 | DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnReadMsrR3, (PPDMDEVINS pDevIns, PVMCPU pVCpu, uint32_t u32Reg, uint64_t *pu64Value));
|
---|
582 | /** @copydoc PDMAPICREG::pfnBusDeliverR3 */
|
---|
583 | DECLR3CALLBACKMEMBER(int, pfnBusDeliverR3,(PPDMDEVINS pDevIns, uint8_t uDest, uint8_t uDestMode, uint8_t uDeliveryMode,
|
---|
584 | uint8_t uVector, uint8_t uPolarity, uint8_t uTriggerMode, uint32_t uTagSrc));
|
---|
585 | /** @copydoc PDMAPICREG::pfnLocalInterruptR3 */
|
---|
586 | DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnLocalInterruptR3,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint8_t u8Pin, uint8_t u8Level,
|
---|
587 | int rcRZ));
|
---|
588 | /** @copydoc PDMAPICREG::pfnGetTimerFreqR3 */
|
---|
589 | DECLR3CALLBACKMEMBER(uint64_t, pfnGetTimerFreqR3,(PPDMDEVINS pDevIns));
|
---|
590 |
|
---|
591 | /** Pointer to the APIC device instance - R0 Ptr. */
|
---|
592 | PPDMDEVINSR0 pDevInsR0;
|
---|
593 | /** @copydoc PDMAPICREG::pfnGetInterruptR3 */
|
---|
594 | DECLR0CALLBACKMEMBER(int, pfnGetInterruptR0,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint32_t *puTagSrc));
|
---|
595 | /** @copydoc PDMAPICREG::pfnHasPendingIrqR3 */
|
---|
596 | DECLR0CALLBACKMEMBER(bool, pfnHasPendingIrqR0,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint8_t *pu8PendingIrq));
|
---|
597 | /** @copydoc PDMAPICREG::pfnSetBaseMsrR3 */
|
---|
598 | DECLR0CALLBACKMEMBER(VBOXSTRICTRC, pfnSetBaseMsrR0,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint64_t u64Base));
|
---|
599 | /** @copydoc PDMAPICREG::pfnGetBaseMsrR3 */
|
---|
600 | DECLR0CALLBACKMEMBER(uint64_t, pfnGetBaseMsrR0,(PPDMDEVINS pDevIns, PVMCPU pVCpu));
|
---|
601 | /** @copydoc PDMAPICREG::pfnSetTprR3 */
|
---|
602 | DECLR0CALLBACKMEMBER(void, pfnSetTprR0,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint8_t u8Tpr));
|
---|
603 | /** @copydoc PDMAPICREG::pfnGetTprR3 */
|
---|
604 | DECLR0CALLBACKMEMBER(uint8_t, pfnGetTprR0,(PPDMDEVINS pDevIns, PVMCPU pVCpu));
|
---|
605 | /** @copydoc PDMAPICREG::pfnWriteMsrR3 */
|
---|
606 | DECLR0CALLBACKMEMBER(VBOXSTRICTRC, pfnWriteMsrR0, (PPDMDEVINS pDevIns, PVMCPU pVCpu, uint32_t u32Reg, uint64_t u64Value));
|
---|
607 | /** @copydoc PDMAPICREG::pfnReadMsrR3 */
|
---|
608 | DECLR0CALLBACKMEMBER(VBOXSTRICTRC, pfnReadMsrR0, (PPDMDEVINS pDevIns, PVMCPU pVCpu, uint32_t u32Reg, uint64_t *pu64Value));
|
---|
609 | /** @copydoc PDMAPICREG::pfnBusDeliverR3 */
|
---|
610 | DECLR0CALLBACKMEMBER(int, pfnBusDeliverR0,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
|
---|
611 | uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode, uint32_t uTagSrc));
|
---|
612 | /** @copydoc PDMAPICREG::pfnLocalInterruptR3 */
|
---|
613 | DECLR0CALLBACKMEMBER(VBOXSTRICTRC, pfnLocalInterruptR0,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint8_t u8Pin, uint8_t u8Level,
|
---|
614 | int rcRZ));
|
---|
615 | /** @copydoc PDMAPICREG::pfnGetTimerFreqR3 */
|
---|
616 | DECLR0CALLBACKMEMBER(uint64_t, pfnGetTimerFreqR0,(PPDMDEVINS pDevIns));
|
---|
617 |
|
---|
618 | /** Pointer to the APIC device instance - RC Ptr. */
|
---|
619 | PPDMDEVINSRC pDevInsRC;
|
---|
620 | /** @copydoc PDMAPICREG::pfnGetInterruptR3 */
|
---|
621 | DECLRCCALLBACKMEMBER(int, pfnGetInterruptRC,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint32_t *puTagSrc));
|
---|
622 | /** @copydoc PDMAPICREG::pfnHasPendingIrqR3 */
|
---|
623 | DECLRCCALLBACKMEMBER(bool, pfnHasPendingIrqRC,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint8_t *pu8PendingIrq));
|
---|
624 | /** @copydoc PDMAPICREG::pfnSetBaseMsrR3 */
|
---|
625 | DECLRCCALLBACKMEMBER(VBOXSTRICTRC, pfnSetBaseMsrRC,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint64_t u64Base));
|
---|
626 | /** @copydoc PDMAPICREG::pfnGetBaseMsrR3 */
|
---|
627 | DECLRCCALLBACKMEMBER(uint64_t, pfnGetBaseMsrRC,(PPDMDEVINS pDevIns, PVMCPU pVCpu));
|
---|
628 | /** @copydoc PDMAPICREG::pfnSetTprR3 */
|
---|
629 | DECLRCCALLBACKMEMBER(void, pfnSetTprRC,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint8_t u8Tpr));
|
---|
630 | /** @copydoc PDMAPICREG::pfnGetTprR3 */
|
---|
631 | DECLRCCALLBACKMEMBER(uint8_t, pfnGetTprRC,(PPDMDEVINS pDevIns, PVMCPU pVCpu));
|
---|
632 | /** @copydoc PDMAPICREG::pfnWriteMsrR3 */
|
---|
633 | DECLRCCALLBACKMEMBER(VBOXSTRICTRC, pfnWriteMsrRC, (PPDMDEVINS pDevIns, PVMCPU pVCpu, uint32_t u32Reg, uint64_t u64Value));
|
---|
634 | /** @copydoc PDMAPICREG::pfnReadMsrR3 */
|
---|
635 | DECLRCCALLBACKMEMBER(VBOXSTRICTRC, pfnReadMsrRC, (PPDMDEVINS pDevIns, PVMCPU pVCpu, uint32_t u32Reg, uint64_t *pu64Value));
|
---|
636 | /** @copydoc PDMAPICREG::pfnBusDeliverR3 */
|
---|
637 | DECLRCCALLBACKMEMBER(int, pfnBusDeliverRC,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
|
---|
638 | uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode, uint32_t uTagSrc));
|
---|
639 | /** @copydoc PDMAPICREG::pfnLocalInterruptR3 */
|
---|
640 | DECLRCCALLBACKMEMBER(VBOXSTRICTRC, pfnLocalInterruptRC,(PPDMDEVINS pDevIns, PVMCPU pVCpu, uint8_t u8Pin, uint8_t u8Level,
|
---|
641 | int rcRZ));
|
---|
642 | /** @copydoc PDMAPICREG::pfnGetTimerFreqR3 */
|
---|
643 | DECLRCCALLBACKMEMBER(uint64_t, pfnGetTimerFreqRC,(PPDMDEVINS pDevIns));
|
---|
644 | } PDMAPIC;
|
---|
645 |
|
---|
646 |
|
---|
647 | /**
|
---|
648 | * PDM registered I/O APIC device.
|
---|
649 | */
|
---|
650 | typedef struct PDMIOAPIC
|
---|
651 | {
|
---|
652 | /** Pointer to the APIC device instance - R3 Ptr. */
|
---|
653 | PPDMDEVINSR3 pDevInsR3;
|
---|
654 | /** @copydoc PDMIOAPICREG::pfnSetIrqR3 */
|
---|
655 | DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
656 | /** @copydoc PDMIOAPICREG::pfnSendMsiR3 */
|
---|
657 | DECLR3CALLBACKMEMBER(void, pfnSendMsiR3,(PPDMDEVINS pDevIns, RTGCPHYS GCAddr, uint32_t uValue, uint32_t uTagSrc));
|
---|
658 |
|
---|
659 | /** Pointer to the PIC device instance - R0. */
|
---|
660 | PPDMDEVINSR0 pDevInsR0;
|
---|
661 | /** @copydoc PDMIOAPICREG::pfnSetIrqR3 */
|
---|
662 | DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
663 | /** @copydoc PDMIOAPICREG::pfnSendMsiR3 */
|
---|
664 | DECLR0CALLBACKMEMBER(void, pfnSendMsiR0,(PPDMDEVINS pDevIns, RTGCPHYS GCAddr, uint32_t uValue, uint32_t uTagSrc));
|
---|
665 |
|
---|
666 | /** Pointer to the APIC device instance - RC Ptr. */
|
---|
667 | PPDMDEVINSRC pDevInsRC;
|
---|
668 | /** @copydoc PDMIOAPICREG::pfnSetIrqR3 */
|
---|
669 | DECLRCCALLBACKMEMBER(void, pfnSetIrqRC,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
670 | /** @copydoc PDMIOAPICREG::pfnSendMsiR3 */
|
---|
671 | DECLRCCALLBACKMEMBER(void, pfnSendMsiRC,(PPDMDEVINS pDevIns, RTGCPHYS GCAddr, uint32_t uValue, uint32_t uTagSrc));
|
---|
672 |
|
---|
673 | uint8_t Alignment[4];
|
---|
674 | } PDMIOAPIC;
|
---|
675 |
|
---|
676 | /** Maximum number of PCI busses for a VM. */
|
---|
677 | #define PDM_PCI_BUSSES_MAX 8
|
---|
678 |
|
---|
679 | /**
|
---|
680 | * PDM PCI Bus instance.
|
---|
681 | */
|
---|
682 | typedef struct PDMPCIBUS
|
---|
683 | {
|
---|
684 | /** PCI bus number. */
|
---|
685 | RTUINT iBus;
|
---|
686 | RTUINT uPadding0; /**< Alignment padding.*/
|
---|
687 |
|
---|
688 | /** Pointer to PCI Bus device instance. */
|
---|
689 | PPDMDEVINSR3 pDevInsR3;
|
---|
690 | /** @copydoc PDMPCIBUSREG::pfnSetIrqR3 */
|
---|
691 | DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
692 | /** @copydoc PDMPCIBUSREG::pfnRegisterR3 */
|
---|
693 | DECLR3CALLBACKMEMBER(int, pfnRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, const char *pszName, int iDev));
|
---|
694 | /** @copydoc PDMPCIBUSREG::pfnRegisterMsiR3 */
|
---|
695 | DECLR3CALLBACKMEMBER(int, pfnRegisterMsiR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PPDMMSIREG pMsiReg));
|
---|
696 | /** @copydoc PDMPCIBUSREG::pfnIORegionRegisterR3 */
|
---|
697 | DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iRegion, uint32_t cbRegion,
|
---|
698 | PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
|
---|
699 | /** @copydoc PDMPCIBUSREG::pfnSetConfigCallbacksR3 */
|
---|
700 | DECLR3CALLBACKMEMBER(void, pfnSetConfigCallbacksR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead,
|
---|
701 | PPFNPCICONFIGREAD ppfnReadOld, PFNPCICONFIGWRITE pfnWrite, PPFNPCICONFIGWRITE ppfnWriteOld));
|
---|
702 | /** @copydoc PDMPCIBUSREG::pfnFakePCIBIOSR3 */
|
---|
703 | DECLR3CALLBACKMEMBER(int, pfnFakePCIBIOSR3,(PPDMDEVINS pDevIns));
|
---|
704 |
|
---|
705 | /** Pointer to the PIC device instance - R0. */
|
---|
706 | R0PTRTYPE(PPDMDEVINS) pDevInsR0;
|
---|
707 | /** @copydoc PDMPCIBUSREG::pfnSetIrqR3 */
|
---|
708 | DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
709 |
|
---|
710 | /** Pointer to PCI Bus device instance. */
|
---|
711 | PPDMDEVINSRC pDevInsRC;
|
---|
712 | /** @copydoc PDMPCIBUSREG::pfnSetIrqR3 */
|
---|
713 | DECLRCCALLBACKMEMBER(void, pfnSetIrqRC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel, uint32_t uTagSrc));
|
---|
714 | } PDMPCIBUS;
|
---|
715 |
|
---|
716 |
|
---|
717 | #ifdef IN_RING3
|
---|
718 | /**
|
---|
719 | * PDM registered DMAC (DMA Controller) device.
|
---|
720 | */
|
---|
721 | typedef struct PDMDMAC
|
---|
722 | {
|
---|
723 | /** Pointer to the DMAC device instance. */
|
---|
724 | PPDMDEVINSR3 pDevIns;
|
---|
725 | /** Copy of the registration structure. */
|
---|
726 | PDMDMACREG Reg;
|
---|
727 | } PDMDMAC;
|
---|
728 |
|
---|
729 |
|
---|
730 | /**
|
---|
731 | * PDM registered RTC (Real Time Clock) device.
|
---|
732 | */
|
---|
733 | typedef struct PDMRTC
|
---|
734 | {
|
---|
735 | /** Pointer to the RTC device instance. */
|
---|
736 | PPDMDEVINSR3 pDevIns;
|
---|
737 | /** Copy of the registration structure. */
|
---|
738 | PDMRTCREG Reg;
|
---|
739 | } PDMRTC;
|
---|
740 |
|
---|
741 | #endif /* IN_RING3 */
|
---|
742 |
|
---|
743 | /**
|
---|
744 | * Module type.
|
---|
745 | */
|
---|
746 | typedef enum PDMMODTYPE
|
---|
747 | {
|
---|
748 | /** Raw-mode (RC) context module. */
|
---|
749 | PDMMOD_TYPE_RC,
|
---|
750 | /** Ring-0 (host) context module. */
|
---|
751 | PDMMOD_TYPE_R0,
|
---|
752 | /** Ring-3 (host) context module. */
|
---|
753 | PDMMOD_TYPE_R3
|
---|
754 | } PDMMODTYPE;
|
---|
755 |
|
---|
756 |
|
---|
757 | /** The module name length including the terminator. */
|
---|
758 | #define PDMMOD_NAME_LEN 32
|
---|
759 |
|
---|
760 | /**
|
---|
761 | * Loaded module instance.
|
---|
762 | */
|
---|
763 | typedef struct PDMMOD
|
---|
764 | {
|
---|
765 | /** Module name. This is used for referring to
|
---|
766 | * the module internally, sort of like a handle. */
|
---|
767 | char szName[PDMMOD_NAME_LEN];
|
---|
768 | /** Module type. */
|
---|
769 | PDMMODTYPE eType;
|
---|
770 | /** Loader module handle. Not used for R0 modules. */
|
---|
771 | RTLDRMOD hLdrMod;
|
---|
772 | /** Loaded address.
|
---|
773 | * This is the 'handle' for R0 modules. */
|
---|
774 | RTUINTPTR ImageBase;
|
---|
775 | /** Old loaded address.
|
---|
776 | * This is used during relocation of GC modules. Not used for R0 modules. */
|
---|
777 | RTUINTPTR OldImageBase;
|
---|
778 | /** Where the R3 HC bits are stored.
|
---|
779 | * This can be equal to ImageBase but doesn't have to. Not used for R0 modules. */
|
---|
780 | void *pvBits;
|
---|
781 |
|
---|
782 | /** Pointer to next module. */
|
---|
783 | struct PDMMOD *pNext;
|
---|
784 | /** Module filename. */
|
---|
785 | char szFilename[1];
|
---|
786 | } PDMMOD;
|
---|
787 | /** Pointer to loaded module instance. */
|
---|
788 | typedef PDMMOD *PPDMMOD;
|
---|
789 |
|
---|
790 |
|
---|
791 |
|
---|
792 | /** Extra space in the free array. */
|
---|
793 | #define PDMQUEUE_FREE_SLACK 16
|
---|
794 |
|
---|
795 | /**
|
---|
796 | * Queue type.
|
---|
797 | */
|
---|
798 | typedef enum PDMQUEUETYPE
|
---|
799 | {
|
---|
800 | /** Device consumer. */
|
---|
801 | PDMQUEUETYPE_DEV = 1,
|
---|
802 | /** Driver consumer. */
|
---|
803 | PDMQUEUETYPE_DRV,
|
---|
804 | /** Internal consumer. */
|
---|
805 | PDMQUEUETYPE_INTERNAL,
|
---|
806 | /** External consumer. */
|
---|
807 | PDMQUEUETYPE_EXTERNAL
|
---|
808 | } PDMQUEUETYPE;
|
---|
809 |
|
---|
810 | /** Pointer to a PDM Queue. */
|
---|
811 | typedef struct PDMQUEUE *PPDMQUEUE;
|
---|
812 |
|
---|
813 | /**
|
---|
814 | * PDM Queue.
|
---|
815 | */
|
---|
816 | typedef struct PDMQUEUE
|
---|
817 | {
|
---|
818 | /** Pointer to the next queue in the list. */
|
---|
819 | R3PTRTYPE(PPDMQUEUE) pNext;
|
---|
820 | /** Type specific data. */
|
---|
821 | union
|
---|
822 | {
|
---|
823 | /** PDMQUEUETYPE_DEV */
|
---|
824 | struct
|
---|
825 | {
|
---|
826 | /** Pointer to consumer function. */
|
---|
827 | R3PTRTYPE(PFNPDMQUEUEDEV) pfnCallback;
|
---|
828 | /** Pointer to the device instance owning the queue. */
|
---|
829 | R3PTRTYPE(PPDMDEVINS) pDevIns;
|
---|
830 | } Dev;
|
---|
831 | /** PDMQUEUETYPE_DRV */
|
---|
832 | struct
|
---|
833 | {
|
---|
834 | /** Pointer to consumer function. */
|
---|
835 | R3PTRTYPE(PFNPDMQUEUEDRV) pfnCallback;
|
---|
836 | /** Pointer to the driver instance owning the queue. */
|
---|
837 | R3PTRTYPE(PPDMDRVINS) pDrvIns;
|
---|
838 | } Drv;
|
---|
839 | /** PDMQUEUETYPE_INTERNAL */
|
---|
840 | struct
|
---|
841 | {
|
---|
842 | /** Pointer to consumer function. */
|
---|
843 | R3PTRTYPE(PFNPDMQUEUEINT) pfnCallback;
|
---|
844 | } Int;
|
---|
845 | /** PDMQUEUETYPE_EXTERNAL */
|
---|
846 | struct
|
---|
847 | {
|
---|
848 | /** Pointer to consumer function. */
|
---|
849 | R3PTRTYPE(PFNPDMQUEUEEXT) pfnCallback;
|
---|
850 | /** Pointer to user argument. */
|
---|
851 | R3PTRTYPE(void *) pvUser;
|
---|
852 | } Ext;
|
---|
853 | } u;
|
---|
854 | /** Queue type. */
|
---|
855 | PDMQUEUETYPE enmType;
|
---|
856 | /** The interval between checking the queue for events.
|
---|
857 | * The realtime timer below is used to do the waiting.
|
---|
858 | * If 0, the queue will use the VM_FF_PDM_QUEUE forced action. */
|
---|
859 | uint32_t cMilliesInterval;
|
---|
860 | /** Interval timer. Only used if cMilliesInterval is non-zero. */
|
---|
861 | PTMTIMERR3 pTimer;
|
---|
862 | /** Pointer to the VM - R3. */
|
---|
863 | PVMR3 pVMR3;
|
---|
864 | /** LIFO of pending items - R3. */
|
---|
865 | R3PTRTYPE(PPDMQUEUEITEMCORE) volatile pPendingR3;
|
---|
866 | /** Pointer to the VM - R0. */
|
---|
867 | PVMR0 pVMR0;
|
---|
868 | /** LIFO of pending items - R0. */
|
---|
869 | R0PTRTYPE(PPDMQUEUEITEMCORE) volatile pPendingR0;
|
---|
870 | /** Pointer to the GC VM and indicator for GC enabled queue.
|
---|
871 | * If this is NULL, the queue cannot be used in GC.
|
---|
872 | */
|
---|
873 | PVMRC pVMRC;
|
---|
874 | /** LIFO of pending items - GC. */
|
---|
875 | RCPTRTYPE(PPDMQUEUEITEMCORE) volatile pPendingRC;
|
---|
876 |
|
---|
877 | /** Item size (bytes). */
|
---|
878 | uint32_t cbItem;
|
---|
879 | /** Number of items in the queue. */
|
---|
880 | uint32_t cItems;
|
---|
881 | /** Index to the free head (where we insert). */
|
---|
882 | uint32_t volatile iFreeHead;
|
---|
883 | /** Index to the free tail (where we remove). */
|
---|
884 | uint32_t volatile iFreeTail;
|
---|
885 |
|
---|
886 | /** Unique queue name. */
|
---|
887 | R3PTRTYPE(const char *) pszName;
|
---|
888 | #if HC_ARCH_BITS == 32
|
---|
889 | RTR3PTR Alignment1;
|
---|
890 | #endif
|
---|
891 | /** Stat: Times PDMQueueAlloc fails. */
|
---|
892 | STAMCOUNTER StatAllocFailures;
|
---|
893 | /** Stat: PDMQueueInsert calls. */
|
---|
894 | STAMCOUNTER StatInsert;
|
---|
895 | /** Stat: Queue flushes. */
|
---|
896 | STAMCOUNTER StatFlush;
|
---|
897 | /** Stat: Queue flushes with pending items left over. */
|
---|
898 | STAMCOUNTER StatFlushLeftovers;
|
---|
899 | #ifdef VBOX_WITH_STATISTICS
|
---|
900 | /** State: Profiling the flushing. */
|
---|
901 | STAMPROFILE StatFlushPrf;
|
---|
902 | /** State: Pending items. */
|
---|
903 | uint32_t volatile cStatPending;
|
---|
904 | uint32_t volatile cAlignment;
|
---|
905 | #endif
|
---|
906 |
|
---|
907 | /** Array of pointers to free items. Variable size. */
|
---|
908 | struct PDMQUEUEFREEITEM
|
---|
909 | {
|
---|
910 | /** Pointer to the free item - HC Ptr. */
|
---|
911 | R3PTRTYPE(PPDMQUEUEITEMCORE) volatile pItemR3;
|
---|
912 | /** Pointer to the free item - HC Ptr. */
|
---|
913 | R0PTRTYPE(PPDMQUEUEITEMCORE) volatile pItemR0;
|
---|
914 | /** Pointer to the free item - GC Ptr. */
|
---|
915 | RCPTRTYPE(PPDMQUEUEITEMCORE) volatile pItemRC;
|
---|
916 | #if HC_ARCH_BITS == 64
|
---|
917 | RTRCPTR Alignment0;
|
---|
918 | #endif
|
---|
919 | } aFreeItems[1];
|
---|
920 | } PDMQUEUE;
|
---|
921 |
|
---|
922 | /** @name PDM::fQueueFlushing
|
---|
923 | * @{ */
|
---|
924 | /** Used to make sure only one EMT will flush the queues.
|
---|
925 | * Set when an EMT is flushing queues, clear otherwise. */
|
---|
926 | #define PDM_QUEUE_FLUSH_FLAG_ACTIVE_BIT 0
|
---|
927 | /** Indicating there are queues with items pending.
|
---|
928 | * This is make sure we don't miss inserts happening during flushing. The FF
|
---|
929 | * cannot be used for this since it has to be cleared immediately to prevent
|
---|
930 | * other EMTs from spinning. */
|
---|
931 | #define PDM_QUEUE_FLUSH_FLAG_PENDING_BIT 1
|
---|
932 | /** }@ */
|
---|
933 |
|
---|
934 |
|
---|
935 | /**
|
---|
936 | * Queue device helper task operation.
|
---|
937 | */
|
---|
938 | typedef enum PDMDEVHLPTASKOP
|
---|
939 | {
|
---|
940 | /** The usual invalid 0 entry. */
|
---|
941 | PDMDEVHLPTASKOP_INVALID = 0,
|
---|
942 | /** ISASetIrq */
|
---|
943 | PDMDEVHLPTASKOP_ISA_SET_IRQ,
|
---|
944 | /** PCISetIrq */
|
---|
945 | PDMDEVHLPTASKOP_PCI_SET_IRQ,
|
---|
946 | /** PCISetIrq */
|
---|
947 | PDMDEVHLPTASKOP_IOAPIC_SET_IRQ,
|
---|
948 | /** The usual 32-bit hack. */
|
---|
949 | PDMDEVHLPTASKOP_32BIT_HACK = 0x7fffffff
|
---|
950 | } PDMDEVHLPTASKOP;
|
---|
951 |
|
---|
952 | /**
|
---|
953 | * Queued Device Helper Task.
|
---|
954 | */
|
---|
955 | typedef struct PDMDEVHLPTASK
|
---|
956 | {
|
---|
957 | /** The queue item core (don't touch). */
|
---|
958 | PDMQUEUEITEMCORE Core;
|
---|
959 | /** Pointer to the device instance (R3 Ptr). */
|
---|
960 | PPDMDEVINSR3 pDevInsR3;
|
---|
961 | /** This operation to perform. */
|
---|
962 | PDMDEVHLPTASKOP enmOp;
|
---|
963 | #if HC_ARCH_BITS == 64
|
---|
964 | uint32_t Alignment0;
|
---|
965 | #endif
|
---|
966 | /** Parameters to the operation. */
|
---|
967 | union PDMDEVHLPTASKPARAMS
|
---|
968 | {
|
---|
969 | /**
|
---|
970 | * PDMDEVHLPTASKOP_ISA_SET_IRQ and PDMDEVHLPTASKOP_PCI_SET_IRQ.
|
---|
971 | */
|
---|
972 | struct PDMDEVHLPTASKSETIRQ
|
---|
973 | {
|
---|
974 | /** The IRQ */
|
---|
975 | int iIrq;
|
---|
976 | /** The new level. */
|
---|
977 | int iLevel;
|
---|
978 | /** The IRQ tag and source. */
|
---|
979 | uint32_t uTagSrc;
|
---|
980 | } SetIRQ;
|
---|
981 |
|
---|
982 | /** Expanding the structure. */
|
---|
983 | uint64_t au64[2];
|
---|
984 | } u;
|
---|
985 | } PDMDEVHLPTASK;
|
---|
986 | /** Pointer to a queued Device Helper Task. */
|
---|
987 | typedef PDMDEVHLPTASK *PPDMDEVHLPTASK;
|
---|
988 | /** Pointer to a const queued Device Helper Task. */
|
---|
989 | typedef const PDMDEVHLPTASK *PCPDMDEVHLPTASK;
|
---|
990 |
|
---|
991 |
|
---|
992 |
|
---|
993 | /**
|
---|
994 | * An USB hub registration record.
|
---|
995 | */
|
---|
996 | typedef struct PDMUSBHUB
|
---|
997 | {
|
---|
998 | /** The USB versions this hub support.
|
---|
999 | * Note that 1.1 hubs can take on 2.0 devices. */
|
---|
1000 | uint32_t fVersions;
|
---|
1001 | /** The number of ports on the hub. */
|
---|
1002 | uint32_t cPorts;
|
---|
1003 | /** The number of available ports (0..cPorts). */
|
---|
1004 | uint32_t cAvailablePorts;
|
---|
1005 | /** The driver instance of the hub. */
|
---|
1006 | PPDMDRVINS pDrvIns;
|
---|
1007 | /** Copy of the to the registration structure. */
|
---|
1008 | PDMUSBHUBREG Reg;
|
---|
1009 |
|
---|
1010 | /** Pointer to the next hub in the list. */
|
---|
1011 | struct PDMUSBHUB *pNext;
|
---|
1012 | } PDMUSBHUB;
|
---|
1013 |
|
---|
1014 | /** Pointer to a const USB HUB registration record. */
|
---|
1015 | typedef const PDMUSBHUB *PCPDMUSBHUB;
|
---|
1016 |
|
---|
1017 | /** Pointer to a PDM Async I/O template. */
|
---|
1018 | typedef struct PDMASYNCCOMPLETIONTEMPLATE *PPDMASYNCCOMPLETIONTEMPLATE;
|
---|
1019 |
|
---|
1020 | /** Pointer to the main PDM Async completion endpoint class. */
|
---|
1021 | typedef struct PDMASYNCCOMPLETIONEPCLASS *PPDMASYNCCOMPLETIONEPCLASS;
|
---|
1022 |
|
---|
1023 | /** Pointer to the global block cache structure. */
|
---|
1024 | typedef struct PDMBLKCACHEGLOBAL *PPDMBLKCACHEGLOBAL;
|
---|
1025 |
|
---|
1026 | /**
|
---|
1027 | * PDM VMCPU Instance data.
|
---|
1028 | * Changes to this must checked against the padding of the pdm union in VMCPU!
|
---|
1029 | */
|
---|
1030 | typedef struct PDMCPU
|
---|
1031 | {
|
---|
1032 | /** The number of entries in the apQueuedCritSectsLeaves table that's currently
|
---|
1033 | * in use. */
|
---|
1034 | uint32_t cQueuedCritSectLeaves;
|
---|
1035 | uint32_t uPadding0; /**< Alignment padding.*/
|
---|
1036 | /** Critical sections queued in RC/R0 because of contention preventing leave to
|
---|
1037 | * complete. (R3 Ptrs)
|
---|
1038 | * We will return to Ring-3 ASAP, so this queue doesn't have to be very long. */
|
---|
1039 | R3PTRTYPE(PPDMCRITSECT) apQueuedCritSectLeaves[8];
|
---|
1040 |
|
---|
1041 | /** The number of entries in the apQueuedCritSectRwExclLeaves table that's
|
---|
1042 | * currently in use. */
|
---|
1043 | uint32_t cQueuedCritSectRwExclLeaves;
|
---|
1044 | uint32_t uPadding1; /**< Alignment padding.*/
|
---|
1045 | /** Read/write critical sections queued in RC/R0 because of contention
|
---|
1046 | * preventing exclusive leave to complete. (R3 Ptrs)
|
---|
1047 | * We will return to Ring-3 ASAP, so this queue doesn't have to be very long. */
|
---|
1048 | R3PTRTYPE(PPDMCRITSECTRW) apQueuedCritSectRwExclLeaves[8];
|
---|
1049 |
|
---|
1050 | /** The number of entries in the apQueuedCritSectsRwShrdLeaves table that's
|
---|
1051 | * currently in use. */
|
---|
1052 | uint32_t cQueuedCritSectRwShrdLeaves;
|
---|
1053 | uint32_t uPadding2; /**< Alignment padding.*/
|
---|
1054 | /** Read/write critical sections queued in RC/R0 because of contention
|
---|
1055 | * preventing shared leave to complete. (R3 Ptrs)
|
---|
1056 | * We will return to Ring-3 ASAP, so this queue doesn't have to be very long. */
|
---|
1057 | R3PTRTYPE(PPDMCRITSECTRW) apQueuedCritSectRwShrdLeaves[8];
|
---|
1058 | } PDMCPU;
|
---|
1059 |
|
---|
1060 |
|
---|
1061 | /**
|
---|
1062 | * PDM VM Instance data.
|
---|
1063 | * Changes to this must checked against the padding of the cfgm union in VM!
|
---|
1064 | */
|
---|
1065 | typedef struct PDM
|
---|
1066 | {
|
---|
1067 | /** The PDM lock.
|
---|
1068 | * This is used to protect everything that deals with interrupts, i.e.
|
---|
1069 | * the PIC, APIC, IOAPIC and PCI devices plus some PDM functions. */
|
---|
1070 | PDMCRITSECT CritSect;
|
---|
1071 | /** The NOP critical section.
|
---|
1072 | * This is a dummy critical section that will not do any thread
|
---|
1073 | * serialization but instead let all threads enter immediately and
|
---|
1074 | * concurrently. */
|
---|
1075 | PDMCRITSECT NopCritSect;
|
---|
1076 |
|
---|
1077 | /** List of registered devices. (FIFO) */
|
---|
1078 | R3PTRTYPE(PPDMDEV) pDevs;
|
---|
1079 | /** List of devices instances. (FIFO) */
|
---|
1080 | R3PTRTYPE(PPDMDEVINS) pDevInstances;
|
---|
1081 | /** List of registered USB devices. (FIFO) */
|
---|
1082 | R3PTRTYPE(PPDMUSB) pUsbDevs;
|
---|
1083 | /** List of USB devices instances. (FIFO) */
|
---|
1084 | R3PTRTYPE(PPDMUSBINS) pUsbInstances;
|
---|
1085 | /** List of registered drivers. (FIFO) */
|
---|
1086 | R3PTRTYPE(PPDMDRV) pDrvs;
|
---|
1087 | /** PCI Buses. */
|
---|
1088 | PDMPCIBUS aPciBuses[PDM_PCI_BUSSES_MAX];
|
---|
1089 | /** The register PIC device. */
|
---|
1090 | PDMPIC Pic;
|
---|
1091 | /** The registered APIC device. */
|
---|
1092 | PDMAPIC Apic;
|
---|
1093 | /** The registered I/O APIC device. */
|
---|
1094 | PDMIOAPIC IoApic;
|
---|
1095 | /** The registered DMAC device. */
|
---|
1096 | R3PTRTYPE(PPDMDMAC) pDmac;
|
---|
1097 | /** The registered RTC device. */
|
---|
1098 | R3PTRTYPE(PPDMRTC) pRtc;
|
---|
1099 | /** The registered USB HUBs. (FIFO) */
|
---|
1100 | R3PTRTYPE(PPDMUSBHUB) pUsbHubs;
|
---|
1101 |
|
---|
1102 | /** Queue in which devhlp tasks are queued for R3 execution - R3 Ptr. */
|
---|
1103 | R3PTRTYPE(PPDMQUEUE) pDevHlpQueueR3;
|
---|
1104 | /** Queue in which devhlp tasks are queued for R3 execution - R0 Ptr. */
|
---|
1105 | R0PTRTYPE(PPDMQUEUE) pDevHlpQueueR0;
|
---|
1106 | /** Queue in which devhlp tasks are queued for R3 execution - RC Ptr. */
|
---|
1107 | RCPTRTYPE(PPDMQUEUE) pDevHlpQueueRC;
|
---|
1108 | /** Pointer to the queue which should be manually flushed - RC Ptr.
|
---|
1109 | * Only touched by EMT. */
|
---|
1110 | RCPTRTYPE(struct PDMQUEUE *) pQueueFlushRC;
|
---|
1111 | /** Pointer to the queue which should be manually flushed - R0 Ptr.
|
---|
1112 | * Only touched by EMT. */
|
---|
1113 | R0PTRTYPE(struct PDMQUEUE *) pQueueFlushR0;
|
---|
1114 | /** Bitmask controlling the queue flushing.
|
---|
1115 | * See PDM_QUEUE_FLUSH_FLAG_ACTIVE and PDM_QUEUE_FLUSH_FLAG_PENDING. */
|
---|
1116 | uint32_t volatile fQueueFlushing;
|
---|
1117 |
|
---|
1118 | /** The current IRQ tag (tracing purposes). */
|
---|
1119 | uint32_t volatile uIrqTag;
|
---|
1120 |
|
---|
1121 | /** The tracing ID of the next device instance.
|
---|
1122 | *
|
---|
1123 | * @remarks We keep the device tracing ID seperate from the rest as these are
|
---|
1124 | * then more likely to end up with the same ID from one run to
|
---|
1125 | * another, making analysis somewhat easier. Drivers and USB devices
|
---|
1126 | * are more volatile and can be changed at runtime, thus these are much
|
---|
1127 | * less likely to remain stable, so just heap them all together. */
|
---|
1128 | uint32_t idTracingDev;
|
---|
1129 | /** The tracing ID of the next driver instance, USB device instance or other
|
---|
1130 | * PDM entity requiring an ID. */
|
---|
1131 | uint32_t idTracingOther;
|
---|
1132 |
|
---|
1133 | /** @name VMM device heap
|
---|
1134 | * @{ */
|
---|
1135 | /** The heap size. */
|
---|
1136 | uint32_t cbVMMDevHeap;
|
---|
1137 | /** Free space. */
|
---|
1138 | uint32_t cbVMMDevHeapLeft;
|
---|
1139 | /** Pointer to the heap base (MMIO2 ring-3 mapping). NULL if not registered. */
|
---|
1140 | RTR3PTR pvVMMDevHeap;
|
---|
1141 | /** Ring-3 mapping/unmapping notification callback for the user. */
|
---|
1142 | PFNPDMVMMDEVHEAPNOTIFY pfnVMMDevHeapNotify;
|
---|
1143 | /** The current mapping. NIL_RTGCPHYS if not mapped or registered. */
|
---|
1144 | RTGCPHYS GCPhysVMMDevHeap;
|
---|
1145 | /** @} */
|
---|
1146 |
|
---|
1147 | /** Number of times a critical section leave request needed to be queued for ring-3 execution. */
|
---|
1148 | STAMCOUNTER StatQueuedCritSectLeaves;
|
---|
1149 | } PDM;
|
---|
1150 | AssertCompileMemberAlignment(PDM, GCPhysVMMDevHeap, sizeof(RTGCPHYS));
|
---|
1151 | AssertCompileMemberAlignment(PDM, CritSect, 8);
|
---|
1152 | AssertCompileMemberAlignment(PDM, StatQueuedCritSectLeaves, 8);
|
---|
1153 | /** Pointer to PDM VM instance data. */
|
---|
1154 | typedef PDM *PPDM;
|
---|
1155 |
|
---|
1156 |
|
---|
1157 |
|
---|
1158 | /**
|
---|
1159 | * PDM data kept in the UVM.
|
---|
1160 | */
|
---|
1161 | typedef struct PDMUSERPERVM
|
---|
1162 | {
|
---|
1163 | /** @todo move more stuff over here. */
|
---|
1164 |
|
---|
1165 | /** Linked list of timer driven PDM queues.
|
---|
1166 | * Currently serialized by PDM::CritSect. */
|
---|
1167 | R3PTRTYPE(struct PDMQUEUE *) pQueuesTimer;
|
---|
1168 | /** Linked list of force action driven PDM queues.
|
---|
1169 | * Currently serialized by PDM::CritSect. */
|
---|
1170 | R3PTRTYPE(struct PDMQUEUE *) pQueuesForced;
|
---|
1171 |
|
---|
1172 | /** Lock protecting the lists below it. */
|
---|
1173 | RTCRITSECT ListCritSect;
|
---|
1174 | /** Pointer to list of loaded modules. */
|
---|
1175 | PPDMMOD pModules;
|
---|
1176 | /** List of initialized critical sections. (LIFO) */
|
---|
1177 | R3PTRTYPE(PPDMCRITSECTINT) pCritSects;
|
---|
1178 | /** List of initialized read/write critical sections. (LIFO) */
|
---|
1179 | R3PTRTYPE(PPDMCRITSECTRWINT) pRwCritSects;
|
---|
1180 | /** Head of the PDM Thread list. (singly linked) */
|
---|
1181 | R3PTRTYPE(PPDMTHREAD) pThreads;
|
---|
1182 | /** Tail of the PDM Thread list. (singly linked) */
|
---|
1183 | R3PTRTYPE(PPDMTHREAD) pThreadsTail;
|
---|
1184 |
|
---|
1185 | /** @name PDM Async Completion
|
---|
1186 | * @{ */
|
---|
1187 | /** Pointer to the array of supported endpoint classes. */
|
---|
1188 | PPDMASYNCCOMPLETIONEPCLASS apAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_MAX];
|
---|
1189 | /** Head of the templates. Singly linked, protected by ListCritSect. */
|
---|
1190 | R3PTRTYPE(PPDMASYNCCOMPLETIONTEMPLATE) pAsyncCompletionTemplates;
|
---|
1191 | /** @} */
|
---|
1192 |
|
---|
1193 | /** Global block cache data. */
|
---|
1194 | R3PTRTYPE(PPDMBLKCACHEGLOBAL) pBlkCacheGlobal;
|
---|
1195 | #ifdef VBOX_WITH_NETSHAPER
|
---|
1196 | /** Pointer to network shaper instance. */
|
---|
1197 | R3PTRTYPE(PPDMNETSHAPER) pNetShaper;
|
---|
1198 | #endif /* VBOX_WITH_NETSHAPER */
|
---|
1199 |
|
---|
1200 | } PDMUSERPERVM;
|
---|
1201 | /** Pointer to the PDM data kept in the UVM. */
|
---|
1202 | typedef PDMUSERPERVM *PPDMUSERPERVM;
|
---|
1203 |
|
---|
1204 |
|
---|
1205 |
|
---|
1206 | /*******************************************************************************
|
---|
1207 | * Global Variables *
|
---|
1208 | *******************************************************************************/
|
---|
1209 | #ifdef IN_RING3
|
---|
1210 | extern const PDMDRVHLPR3 g_pdmR3DrvHlp;
|
---|
1211 | extern const PDMDEVHLPR3 g_pdmR3DevHlpTrusted;
|
---|
1212 | extern const PDMDEVHLPR3 g_pdmR3DevHlpUnTrusted;
|
---|
1213 | extern const PDMPICHLPR3 g_pdmR3DevPicHlp;
|
---|
1214 | extern const PDMAPICHLPR3 g_pdmR3DevApicHlp;
|
---|
1215 | extern const PDMIOAPICHLPR3 g_pdmR3DevIoApicHlp;
|
---|
1216 | extern const PDMPCIHLPR3 g_pdmR3DevPciHlp;
|
---|
1217 | extern const PDMDMACHLP g_pdmR3DevDmacHlp;
|
---|
1218 | extern const PDMRTCHLP g_pdmR3DevRtcHlp;
|
---|
1219 | extern const PDMHPETHLPR3 g_pdmR3DevHpetHlp;
|
---|
1220 | extern const PDMPCIRAWHLPR3 g_pdmR3DevPciRawHlp;
|
---|
1221 | #endif
|
---|
1222 |
|
---|
1223 |
|
---|
1224 | /*******************************************************************************
|
---|
1225 | * Defined Constants And Macros *
|
---|
1226 | *******************************************************************************/
|
---|
1227 | /** @def PDMDEV_ASSERT_DEVINS
|
---|
1228 | * Asserts the validity of the device instance.
|
---|
1229 | */
|
---|
1230 | #ifdef VBOX_STRICT
|
---|
1231 | # define PDMDEV_ASSERT_DEVINS(pDevIns) \
|
---|
1232 | do { \
|
---|
1233 | AssertPtr(pDevIns); \
|
---|
1234 | Assert(pDevIns->u32Version == PDM_DEVINS_VERSION); \
|
---|
1235 | Assert(pDevIns->CTX_SUFF(pvInstanceData) == (void *)&pDevIns->achInstanceData[0]); \
|
---|
1236 | } while (0)
|
---|
1237 | #else
|
---|
1238 | # define PDMDEV_ASSERT_DEVINS(pDevIns) do { } while (0)
|
---|
1239 | #endif
|
---|
1240 |
|
---|
1241 | /** @def PDMDRV_ASSERT_DRVINS
|
---|
1242 | * Asserts the validity of the driver instance.
|
---|
1243 | */
|
---|
1244 | #ifdef VBOX_STRICT
|
---|
1245 | # define PDMDRV_ASSERT_DRVINS(pDrvIns) \
|
---|
1246 | do { \
|
---|
1247 | AssertPtr(pDrvIns); \
|
---|
1248 | Assert(pDrvIns->u32Version == PDM_DRVINS_VERSION); \
|
---|
1249 | Assert(pDrvIns->CTX_SUFF(pvInstanceData) == (void *)&pDrvIns->achInstanceData[0]); \
|
---|
1250 | } while (0)
|
---|
1251 | #else
|
---|
1252 | # define PDMDRV_ASSERT_DRVINS(pDrvIns) do { } while (0)
|
---|
1253 | #endif
|
---|
1254 |
|
---|
1255 |
|
---|
1256 | /*******************************************************************************
|
---|
1257 | * Internal Functions *
|
---|
1258 | *******************************************************************************/
|
---|
1259 | #ifdef IN_RING3
|
---|
1260 | bool pdmR3IsValidName(const char *pszName);
|
---|
1261 |
|
---|
1262 | int pdmR3CritSectBothInitStats(PVM pVM);
|
---|
1263 | void pdmR3CritSectBothRelocate(PVM pVM);
|
---|
1264 | int pdmR3CritSectBothDeleteDevice(PVM pVM, PPDMDEVINS pDevIns);
|
---|
1265 | int pdmR3CritSectBothDeleteDriver(PVM pVM, PPDMDRVINS pDrvIns);
|
---|
1266 | int pdmR3CritSectInitDevice( PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
|
---|
1267 | const char *pszNameFmt, va_list va);
|
---|
1268 | int pdmR3CritSectInitDeviceAuto( PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
|
---|
1269 | const char *pszNameFmt, ...);
|
---|
1270 | int pdmR3CritSectInitDriver( PVM pVM, PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
|
---|
1271 | const char *pszNameFmt, ...);
|
---|
1272 | int pdmR3CritSectRwInitDevice( PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECTRW pCritSect, RT_SRC_POS_DECL,
|
---|
1273 | const char *pszNameFmt, va_list va);
|
---|
1274 | int pdmR3CritSectRwInitDeviceAuto( PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECTRW pCritSect, RT_SRC_POS_DECL,
|
---|
1275 | const char *pszNameFmt, ...);
|
---|
1276 | int pdmR3CritSectRwInitDriver( PVM pVM, PPDMDRVINS pDrvIns, PPDMCRITSECTRW pCritSect, RT_SRC_POS_DECL,
|
---|
1277 | const char *pszNameFmt, ...);
|
---|
1278 |
|
---|
1279 | int pdmR3DevInit(PVM pVM);
|
---|
1280 | int pdmR3DevInitComplete(PVM pVM);
|
---|
1281 | PPDMDEV pdmR3DevLookup(PVM pVM, const char *pszName);
|
---|
1282 | int pdmR3DevFindLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMLUN *ppLun);
|
---|
1283 | DECLCALLBACK(bool) pdmR3DevHlpQueueConsumer(PVM pVM, PPDMQUEUEITEMCORE pItem);
|
---|
1284 |
|
---|
1285 | int pdmR3UsbLoadModules(PVM pVM);
|
---|
1286 | int pdmR3UsbInstantiateDevices(PVM pVM);
|
---|
1287 | PPDMUSB pdmR3UsbLookup(PVM pVM, const char *pszName);
|
---|
1288 | int pdmR3UsbRegisterHub(PVM pVM, PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp);
|
---|
1289 | int pdmR3UsbVMInitComplete(PVM pVM);
|
---|
1290 |
|
---|
1291 | int pdmR3DrvInit(PVM pVM);
|
---|
1292 | int pdmR3DrvInstantiate(PVM pVM, PCFGMNODE pNode, PPDMIBASE pBaseInterface, PPDMDRVINS pDrvAbove,
|
---|
1293 | PPDMLUN pLun, PPDMIBASE *ppBaseInterface);
|
---|
1294 | int pdmR3DrvDetach(PPDMDRVINS pDrvIns, uint32_t fFlags);
|
---|
1295 | void pdmR3DrvDestroyChain(PPDMDRVINS pDrvIns, uint32_t fFlags);
|
---|
1296 | PPDMDRV pdmR3DrvLookup(PVM pVM, const char *pszName);
|
---|
1297 |
|
---|
1298 | int pdmR3LdrInitU(PUVM pUVM);
|
---|
1299 | void pdmR3LdrTermU(PUVM pUVM);
|
---|
1300 | char *pdmR3FileR3(const char *pszFile, bool fShared);
|
---|
1301 | int pdmR3LoadR3U(PUVM pUVM, const char *pszFilename, const char *pszName);
|
---|
1302 |
|
---|
1303 | void pdmR3QueueRelocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
1304 |
|
---|
1305 | int pdmR3ThreadCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
|
---|
1306 | PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
|
---|
1307 | int pdmR3ThreadCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADUSB pfnThread,
|
---|
1308 | PFNPDMTHREADWAKEUPUSB pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
|
---|
1309 | int pdmR3ThreadCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
|
---|
1310 | PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
|
---|
1311 | int pdmR3ThreadDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
|
---|
1312 | int pdmR3ThreadDestroyUsb(PVM pVM, PPDMUSBINS pUsbIns);
|
---|
1313 | int pdmR3ThreadDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
|
---|
1314 | void pdmR3ThreadDestroyAll(PVM pVM);
|
---|
1315 | int pdmR3ThreadResumeAll(PVM pVM);
|
---|
1316 | int pdmR3ThreadSuspendAll(PVM pVM);
|
---|
1317 |
|
---|
1318 | #ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
|
---|
1319 | int pdmR3AsyncCompletionInit(PVM pVM);
|
---|
1320 | int pdmR3AsyncCompletionTerm(PVM pVM);
|
---|
1321 | void pdmR3AsyncCompletionResume(PVM pVM);
|
---|
1322 | int pdmR3AsyncCompletionTemplateCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEDEV pfnCompleted, const char *pszDesc);
|
---|
1323 | int pdmR3AsyncCompletionTemplateCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
|
---|
1324 | PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser, const char *pszDesc);
|
---|
1325 | int pdmR3AsyncCompletionTemplateCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEUSB pfnCompleted, const char *pszDesc);
|
---|
1326 | int pdmR3AsyncCompletionTemplateDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
|
---|
1327 | int pdmR3AsyncCompletionTemplateDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
|
---|
1328 | int pdmR3AsyncCompletionTemplateDestroyUsb(PVM pVM, PPDMUSBINS pUsbIns);
|
---|
1329 | #endif
|
---|
1330 |
|
---|
1331 | #ifdef VBOX_WITH_NETSHAPER
|
---|
1332 | int pdmR3NetShaperInit(PVM pVM);
|
---|
1333 | int pdmR3NetShaperTerm(PVM pVM);
|
---|
1334 | #endif
|
---|
1335 |
|
---|
1336 | int pdmR3BlkCacheInit(PVM pVM);
|
---|
1337 | void pdmR3BlkCacheTerm(PVM pVM);
|
---|
1338 | int pdmR3BlkCacheResume(PVM pVM);
|
---|
1339 |
|
---|
1340 | #endif /* IN_RING3 */
|
---|
1341 |
|
---|
1342 | void pdmLock(PVM pVM);
|
---|
1343 | int pdmLockEx(PVM pVM, int rc);
|
---|
1344 | void pdmUnlock(PVM pVM);
|
---|
1345 |
|
---|
1346 | #if defined(IN_RING3) || defined(IN_RING0)
|
---|
1347 | void pdmCritSectRwLeaveSharedQueued(PPDMCRITSECTRW pThis);
|
---|
1348 | void pdmCritSectRwLeaveExclQueued(PPDMCRITSECTRW pThis);
|
---|
1349 | #endif
|
---|
1350 |
|
---|
1351 | /** @} */
|
---|
1352 |
|
---|
1353 | RT_C_DECLS_END
|
---|
1354 |
|
---|
1355 | #endif
|
---|
1356 |
|
---|