VirtualBox

source: vbox/trunk/src/VBox/VMM/PDMInternal.h@ 25414

Last change on this file since 25414 was 25406, checked in by vboxsync, 14 years ago

IPRT,PDMCritSect: Lock validation can only be performed in ring-3; fixed #PF on 32-bit darwin with debug builds. Hopefully fixed the recursion issue on windows.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use