VirtualBox

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

Last change on this file since 24912 was 24744, checked in by vboxsync, 15 years ago

PDM: Async reset notification handling as well.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use