PDMInternal.h revision ea0316554d23852601ee840c4a856339501411a4
/* $Id$ */
/** @file
* PDM - Internal header file.
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ___PDMInternal_h
#define ___PDMInternal_h
#include <VBox/pdmasynccompletion.h>
#include <VBox/pdmcommon.h>
#include <iprt/critsect.h>
#ifdef IN_RING3
#endif
/** @defgroup grp_pdm_int Internal
* @ingroup grp_pdm
* @internal
* @{
*/
/** @def PDM_WITH_R3R0_CRIT_SECT
#if defined(DOXYGEN_RUNNING) || 1
# define PDM_WITH_R3R0_CRIT_SECT
#endif
/** @def PDMCRITSECT_STRICT
# define PDMCRITSECT_STRICT
#endif
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/** Pointer to a PDM Device. */
/** Pointer to a pointer to a PDM Device. */
/** Pointer to a PDM USB Device. */
/** Pointer to a pointer to a PDM USB Device. */
/** Pointer to a PDM Driver. */
/** Pointer to a pointer to a PDM Driver. */
/** Pointer to a PDM Logical Unit. */
/** Pointer to a pointer to a PDM Logical Unit. */
/** Pointer to a PDM PCI Bus instance. */
typedef struct PDMPCIBUS *PPDMPCIBUS;
/** Pointer to a DMAC instance. */
/** Pointer to a RTC instance. */
/** Pointer to an USB HUB registration record. */
typedef struct PDMUSBHUB *PPDMUSBHUB;
/**
* Supported asynchronous completion endpoint classes.
*/
typedef enum PDMASYNCCOMPLETIONEPCLASSTYPE
{
/** File class. */
/** Number of supported classes. */
/** 32bit hack. */
PDMASYNCCOMPLETIONEPCLASSTYPE_32BIT_HACK = 0x7fffffff
/**
* Private device instance data.
*/
typedef struct PDMDEVINSINT
{
/** Pointer to the next instance (HC Ptr).
* (Head is pointed to by PDM::pDevInstances.) */
/** Pointer to the next per device instance (HC Ptr).
* (Head is pointed to by PDMDEV::pInstances.) */
/** Pointer to device structure - HC Ptr. */
/** Pointer to the list of logical units associated with the device. (FIFO) */
/** Pointer to the asynchronous notification callback set while in
* FNPDMDEVSUSPEND or FNPDMDEVPOWEROFF. */
/** Configuration handle to the instance node. */
/** R3 pointer to the VM this instance was created for. */
/** R3 pointer to associated PCI device structure. */
/** R3 pointer to associated PCI bus structure. */
/** R0 pointer to the VM this instance was created for. */
/** R0 pointer to associated PCI device structure. */
/** R0 pointer to associated PCI bus structure. */
/** RC pointer to the VM this instance was created for. */
/** RC pointer to associated PCI device structure. */
/** RC pointer to associated PCI bus structure. */
/** Flags, see PDMDEVINSINT_FLAGS_XXX. */
} PDMDEVINSINT;
/** @name PDMDEVINSINT::fIntFlags
* @{ */
/** Used by pdmR3Load to mark device instances it found in the saved state. */
#define PDMDEVINSINT_FLAGS_FOUND RT_BIT_32(0)
/** Indicates that the device hasn't been powered on or resumed.
* This is used by PDMR3PowerOn, PDMR3Resume, PDMR3Suspend and PDMR3PowerOff
* to make sure each device gets exactly one notification for each of those
* events. PDMR3Resume and PDMR3PowerOn also makes use of it to bail out on
* a failure (already resumed/powered-on devices are suspended). */
/** Indicates that the device has been reset already. Used by PDMR3Reset. */
/** @} */
/**
* Private USB device instance data.
*/
typedef struct PDMUSBINSINT
{
/** The UUID of this instance. */
/** Pointer to the next instance.
* (Head is pointed to by PDM::pUsbInstances.) */
/** Pointer to the next per USB device instance.
* (Head is pointed to by PDMUSB::pInstances.) */
/** Pointer to device structure. */
/** Pointer to the VM this instance was created for. */
/** Pointer to the list of logical units associated with the device. (FIFO) */
/** The per instance device configuration. */
/** Same as pCfg if the configuration should be deleted when detaching the device. */
/** The global device configuration. */
/** Pointer to the USB hub this device is attached to.
* This is NULL if the device isn't connected to any HUB. */
/** The port number that we're connected to. */
/** Indicates that the USB device hasn't been powered on or resumed.
* See PDMDEVINSINT_FLAGS_SUSPENDED. */
bool fVMSuspended;
/** Indicates that the USB device has been reset. */
bool fVMReset;
/** Pointer to the asynchronous notification callback set while in
* FNPDMDEVSUSPEND or FNPDMDEVPOWEROFF. */
} PDMUSBINSINT;
/**
* Private driver instance data.
*/
typedef struct PDMDRVINSINT
{
/** Pointer to the driver instance above.
* This is NULL for the topmost drive. */
/** Pointer to the driver instance below.
* This is NULL for the bottommost driver. */
/** Pointer to the logical unit this driver chained on. */
/** Pointer to driver structure from which this was instantiated. */
/** Pointer to the VM this instance was created for, ring-3 context. */
/** Pointer to the VM this instance was created for, ring-0 context. */
/** Pointer to the VM this instance was created for, raw-mode context. */
/** Flag indicating that the driver is being detached and destroyed.
* (Helps detect potential recursive detaching.) */
bool fDetaching;
/** Indicates that the driver hasn't been powered on or resumed.
* See PDMDEVINSINT_FLAGS_SUSPENDED. */
bool fVMSuspended;
/** Indicates that the driver has been reset already. */
bool fVMReset;
/** Set if allocated on the hyper heap, false if on the ring-3 heap. */
bool fHyperHeap;
/** Pointer to the asynchronous notification callback set while in
* PDMUSBREG::pfnVMSuspend or PDMUSBREG::pfnVMPowerOff. */
/** Configuration handle to the instance node. */
/** Pointer to the ring-0 request handler function. */
} PDMDRVINSINT;
/**
* Private critical section data.
*/
typedef struct PDMCRITSECTINT
{
/** The critical section core which is shared with IPRT. */
/** Pointer to the next critical section.
* This chain is used for relocating pVMRC and device cleanup. */
/** Owner identifier.
* This is pDevIns if the owner is a device. Similarily for a driver or service.
* PDMR3CritSectInit() sets this to point to the critsect itself. */
/** Pointer to the VM - R3Ptr. */
/** Pointer to the VM - R0Ptr. */
/** Pointer to the VM - GCPtr. */
/** Alignment padding. */
/** Event semaphore that is scheduled to be signaled upon leaving the
* critical section. This is Ring-3 only of course. */
/** The lock name. */
/** R3 lock contention. */
/** Profiling the time the section is locked. */
/** Pointer to private critical section data. */
typedef PDMCRITSECTINT *PPDMCRITSECTINT;
/** Indicates that the critical section is queued for unlock.
* PDMCritSectIsOwner and PDMCritSectIsOwned optimizations. */
/**
*/
typedef enum
{
/** The usual invalid entry. */
/** Device type. */
/** USB Device type. */
/** Driver type. */
/** Internal type. */
/** External type. */
/** The usual 32-bit hack. */
PDMTHREADTYPE_32BIT_HACK = 0x7fffffff
/**
* The internal structure for the thread.
*/
typedef struct PDMTHREADINT
{
/** The VM pointer. */
/** The event semaphore the thread blocks on when not running. */
/** The event semaphore the thread sleeps on while running. */
/** Pointer to the next thread. */
/** The thread type. */
} PDMTHREADINT;
/* Must be included after PDMDEVINSINT is defined. */
#define PDMDEVINSINT_DECLARED
#define PDMUSBINSINT_DECLARED
#define PDMDRVINSINT_DECLARED
#define PDMCRITSECTINT_DECLARED
#define PDMTHREADINT_DECLARED
#ifdef ___VBox_pdm_h
# error "Invalid header PDM order. Include PDMInternal.h before VBox/pdm.h!"
#endif
/**
* PDM Logical Unit.
*
* This typically the representation of a physical port on a
* device, like for instance the PS/2 keyboard port on the
* keyboard controller device. The LUNs are chained on the
* device the belong to (PDMDEVINSINT::pLunsR3).
*/
typedef struct PDMLUN
{
/** The LUN - The Logical Unit Number. */
/** Pointer to the next LUN. */
/** Pointer to the top driver in the driver chain. */
/** Pointer to the bottom driver in the driver chain. */
/** Pointer to the device instance which the LUN belongs to.
* Either this is set or pUsbIns is set. Both is never set at the same time. */
/** Pointer to the USB device instance which the LUN belongs to. */
/** Pointer to the device base interface. */
/** Description of this LUN. */
const char *pszDesc;
} PDMLUN;
/**
* PDM Device.
*/
typedef struct PDMDEV
{
/** Pointer to the next device (R3 Ptr). */
/** Device name length. (search optimization) */
/** Registration structure. */
/** Number of instances. */
/** Pointer to chain of instances (R3 Ptr). */
} PDMDEV;
/**
* PDM USB Device.
*/
typedef struct PDMUSB
{
/** Pointer to the next device (R3 Ptr). */
/** Device name length. (search optimization) */
/** Registration structure. */
/** Next instance number. */
/** Pointer to chain of instances (R3 Ptr). */
} PDMUSB;
/**
* PDM Driver.
*/
typedef struct PDMDRV
{
/** Pointer to the next device. */
/** Registration structure. */
/** Current number of instances. */
/** The next instance number. */
} PDMDRV;
/**
* PDM registered PIC device.
*/
typedef struct PDMPIC
{
/** Pointer to the PIC device instance - R3. */
/** @copydoc PDMPICREG::pfnSetIrqR3 */
/** @copydoc PDMPICREG::pfnGetInterruptR3 */
/** Pointer to the PIC device instance - R0. */
/** @copydoc PDMPICREG::pfnSetIrqR3 */
/** @copydoc PDMPICREG::pfnGetInterruptR3 */
/** Pointer to the PIC device instance - RC. */
/** @copydoc PDMPICREG::pfnSetIrqR3 */
/** @copydoc PDMPICREG::pfnGetInterruptR3 */
/** Alignment padding. */
} PDMPIC;
/**
* PDM registered APIC device.
*/
typedef struct PDMAPIC
{
/** Pointer to the APIC device instance - R3 Ptr. */
/** @copydoc PDMAPICREG::pfnGetInterruptR3 */
/** @copydoc PDMAPICREG::pfnHasPendingIrqR3 */
/** @copydoc PDMAPICREG::pfnSetBaseR3 */
/** @copydoc PDMAPICREG::pfnGetBaseR3 */
/** @copydoc PDMAPICREG::pfnSetTPRR3 */
/** @copydoc PDMAPICREG::pfnGetTPRR3 */
/** @copydoc PDMAPICREG::pfnWriteMSRR3 */
DECLR3CALLBACKMEMBER(int, pfnWriteMSRR3, (PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t u32Reg, uint64_t u64Value));
/** @copydoc PDMAPICREG::pfnReadMSRR3 */
DECLR3CALLBACKMEMBER(int, pfnReadMSRR3, (PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t u32Reg, uint64_t *pu64Value));
/** @copydoc PDMAPICREG::pfnBusDeliverR3 */
DECLR3CALLBACKMEMBER(int, pfnBusDeliverR3,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
/** @copydoc PDMAPICREG::pfnLocalInterruptR3 */
DECLR3CALLBACKMEMBER(int, pfnLocalInterruptR3,(PPDMDEVINS pDevIns, uint8_t u8Pin, uint8_t u8Level));
/** Pointer to the APIC device instance - R0 Ptr. */
/** @copydoc PDMAPICREG::pfnGetInterruptR3 */
/** @copydoc PDMAPICREG::pfnHasPendingIrqR3 */
/** @copydoc PDMAPICREG::pfnSetBaseR3 */
/** @copydoc PDMAPICREG::pfnGetBaseR3 */
/** @copydoc PDMAPICREG::pfnSetTPRR3 */
/** @copydoc PDMAPICREG::pfnGetTPRR3 */
/** @copydoc PDMAPICREG::pfnWriteMSRR3 */
DECLR0CALLBACKMEMBER(uint32_t, pfnWriteMSRR0, (PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t u32Reg, uint64_t u64Value));
/** @copydoc PDMAPICREG::pfnReadMSRR3 */
DECLR0CALLBACKMEMBER(uint32_t, pfnReadMSRR0, (PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t u32Reg, uint64_t *pu64Value));
/** @copydoc PDMAPICREG::pfnBusDeliverR3 */
DECLR0CALLBACKMEMBER(int, pfnBusDeliverR0,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
/** @copydoc PDMAPICREG::pfnLocalInterruptR3 */
DECLR0CALLBACKMEMBER(int, pfnLocalInterruptR0,(PPDMDEVINS pDevIns, uint8_t u8Pin, uint8_t u8Level));
/** Pointer to the APIC device instance - RC Ptr. */
/** @copydoc PDMAPICREG::pfnGetInterruptR3 */
/** @copydoc PDMAPICREG::pfnHasPendingIrqR3 */
/** @copydoc PDMAPICREG::pfnSetBaseR3 */
/** @copydoc PDMAPICREG::pfnGetBaseR3 */
/** @copydoc PDMAPICREG::pfnSetTPRR3 */
/** @copydoc PDMAPICREG::pfnGetTPRR3 */
/** @copydoc PDMAPICREG::pfnWriteMSRR3 */
DECLRCCALLBACKMEMBER(uint32_t, pfnWriteMSRRC, (PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t u32Reg, uint64_t u64Value));
/** @copydoc PDMAPICREG::pfnReadMSRR3 */
DECLRCCALLBACKMEMBER(uint32_t, pfnReadMSRRC, (PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t u32Reg, uint64_t *pu64Value));
/** @copydoc PDMAPICREG::pfnBusDeliverR3 */
DECLRCCALLBACKMEMBER(int, pfnBusDeliverRC,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
/** @copydoc PDMAPICREG::pfnLocalInterruptR3 */
DECLRCCALLBACKMEMBER(int, pfnLocalInterruptRC,(PPDMDEVINS pDevIns, uint8_t u8Pin, uint8_t u8Level));
} PDMAPIC;
/**
* PDM registered I/O APIC device.
*/
typedef struct PDMIOAPIC
{
/** Pointer to the APIC device instance - R3 Ptr. */
/** @copydoc PDMIOAPICREG::pfnSetIrqR3 */
/** Pointer to the PIC device instance - R0. */
/** @copydoc PDMIOAPICREG::pfnSetIrqR3 */
/** Pointer to the APIC device instance - RC Ptr. */
/** @copydoc PDMIOAPICREG::pfnSetIrqR3 */
} PDMIOAPIC;
/** Maximum number of PCI busses for a VM. */
#define PDM_PCI_BUSSES_MAX 8
/**
* PDM PCI Bus instance.
*/
typedef struct PDMPCIBUS
{
/** PCI bus number. */
/** Pointer to PCI Bus device instance. */
/** @copydoc PDMPCIBUSREG::pfnSetIrqR3 */
DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
/** @copydoc PDMPCIBUSREG::pfnRegisterR3 */
DECLR3CALLBACKMEMBER(int, pfnRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, const char *pszName, int iDev));
/** @copydoc PDMPCIBUSREG::pfnPCIRegisterMsiR3 */
DECLR3CALLBACKMEMBER(int, pfnRegisterMsiR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PPDMMSIREG pMsiReg));
/** @copydoc PDMPCIBUSREG::pfnIORegionRegisterR3 */
DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iRegion, uint32_t cbRegion,
/** @copydoc PDMPCIBUSREG::pfnSetConfigCallbacksR3 */
DECLR3CALLBACKMEMBER(void, pfnSetConfigCallbacksR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PFNPCICONFIGREAD pfnRead,
/** @copydoc PDMPCIBUSREG::pfnSaveExecR3 */
DECLR3CALLBACKMEMBER(int, pfnSaveExecR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
/** @copydoc PDMPCIBUSREG::pfnLoadExecR3 */
DECLR3CALLBACKMEMBER(int, pfnLoadExecR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
/** @copydoc PDMPCIBUSREG::pfnFakePCIBIOSR3 */
/** Pointer to the PIC device instance - R0. */
/** @copydoc PDMPCIBUSREG::pfnSetIrqR3 */
DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
/** Pointer to PCI Bus device instance. */
/** @copydoc PDMPCIBUSREG::pfnSetIrqR3 */
DECLRCCALLBACKMEMBER(void, pfnSetIrqRC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
} PDMPCIBUS;
#ifdef IN_RING3
/**
* PDM registered DMAC (DMA Controller) device.
*/
typedef struct PDMDMAC
{
/** Pointer to the DMAC device instance. */
/** Copy of the registration structure. */
} PDMDMAC;
/**
* PDM registered RTC (Real Time Clock) device.
*/
typedef struct PDMRTC
{
/** Pointer to the RTC device instance. */
/** Copy of the registration structure. */
} PDMRTC;
#endif /* IN_RING3 */
/**
* Module type.
*/
typedef enum PDMMODTYPE
{
/** Raw-mode (RC) context module. */
/** Ring-0 (host) context module. */
/** Ring-3 (host) context module. */
} PDMMODTYPE;
/** The module name length including the terminator. */
#define PDMMOD_NAME_LEN 32
/**
* Loaded module instance.
*/
typedef struct PDMMOD
{
/** Module name. This is used for refering to
* the module internally, sort of like a handle. */
char szName[PDMMOD_NAME_LEN];
/** Module type. */
/** Loader module handle. Not used for R0 modules. */
/** Loaded address.
* This is the 'handle' for R0 modules. */
/** Old loaded address.
* This is used during relocation of GC modules. Not used for R0 modules. */
/** Where the R3 HC bits are stored.
* This can be equal to ImageBase but doesn't have to. Not used for R0 modules. */
void *pvBits;
/** Pointer to next module. */
/** Module filename. */
char szFilename[1];
} PDMMOD;
/** Pointer to loaded module instance. */
/** Extra space in the free array. */
#define PDMQUEUE_FREE_SLACK 16
/**
* Queue type.
*/
typedef enum PDMQUEUETYPE
{
/** Device consumer. */
PDMQUEUETYPE_DEV = 1,
/** Driver consumer. */
/** Internal consumer. */
/** External consumer. */
} PDMQUEUETYPE;
/** Pointer to a PDM Queue. */
/**
* PDM Queue.
*/
typedef struct PDMQUEUE
{
/** Pointer to the next queue in the list. */
/** Type specific data. */
union
{
/** PDMQUEUETYPE_DEV */
struct
{
/** Pointer to consumer function. */
/** Pointer to the device instance owning the queue. */
} Dev;
/** PDMQUEUETYPE_DRV */
struct
{
/** Pointer to consumer function. */
/** Pointer to the driver instance owning the queue. */
} Drv;
/** PDMQUEUETYPE_INTERNAL */
struct
{
/** Pointer to consumer function. */
} Int;
/** PDMQUEUETYPE_EXTERNAL */
struct
{
/** Pointer to consumer function. */
/** Pointer to user argument. */
} Ext;
} u;
/** Queue type. */
/** The interval between checking the queue for events.
* The realtime timer below is used to do the waiting.
* If 0, the queue will use the VM_FF_PDM_QUEUE forced action. */
/** Interval timer. Only used if cMilliesInterval is non-zero. */
/** Pointer to the VM - R3. */
/** LIFO of pending items - R3. */
/** Pointer to the VM - R0. */
/** LIFO of pending items - R0. */
/** Pointer to the GC VM and indicator for GC enabled queue.
* If this is NULL, the queue cannot be used in GC.
*/
/** LIFO of pending items - GC. */
/** Item size (bytes). */
/** Number of items in the queue. */
/** Index to the free head (where we insert). */
/** Index to the free tail (where we remove). */
/** Unqiue queue name. */
#if HC_ARCH_BITS == 32
#endif
/** Stat: Times PDMQueueAlloc fails. */
/** Stat: PDMQueueInsert calls. */
/** Stat: Queue flushes. */
/** Stat: Queue flushes with pending items left over. */
#ifdef VBOX_WITH_STATISTICS
/** State: Profiling the flushing. */
/** State: Pending items. */
uint32_t volatile cStatPending;
uint32_t volatile cAlignment;
#endif
/** Array of pointers to free items. Variable size. */
struct PDMQUEUEFREEITEM
{
/** Pointer to the free item - HC Ptr. */
/** Pointer to the free item - HC Ptr. */
/** Pointer to the free item - GC Ptr. */
#if HC_ARCH_BITS == 64
#endif
} aFreeItems[1];
} PDMQUEUE;
/** @name PDM::fQueueFlushing
* @{ */
/** Used to make sure only one EMT will flush the queues.
* Set when an EMT is flushing queues, clear otherwise. */
#define PDM_QUEUE_FLUSH_FLAG_ACTIVE_BIT 0
/** Indicating there are queues with items pending.
* This is make sure we don't miss inserts happening during flushing. The FF
* cannot be used for this since it has to be cleared immediately to prevent
* other EMTs from spinning. */
#define PDM_QUEUE_FLUSH_FLAG_PENDING_BIT 1
/** }@ */
/**
* Queue device helper task operation.
*/
typedef enum PDMDEVHLPTASKOP
{
/** The usual invalid 0 entry. */
/** ISASetIrq */
/** PCISetIrq */
/** PCISetIrq */
/** The usual 32-bit hack. */
PDMDEVHLPTASKOP_32BIT_HACK = 0x7fffffff
/**
* Queued Device Helper Task.
*/
typedef struct PDMDEVHLPTASK
{
/** The queue item core (don't touch). */
/** Pointer to the device instance (R3 Ptr). */
/** This operation to perform. */
#if HC_ARCH_BITS == 64
#endif
/** Parameters to the operation. */
union PDMDEVHLPTASKPARAMS
{
/**
* PDMDEVHLPTASKOP_ISA_SET_IRQ and PDMDEVHLPTASKOP_PCI_SET_IRQ.
*/
struct PDMDEVHLPTASKSETIRQ
{
/** The IRQ */
int iIrq;
/** The new level. */
int iLevel;
} SetIRQ;
} u;
/** Pointer to a queued Device Helper Task. */
typedef PDMDEVHLPTASK *PPDMDEVHLPTASK;
/** Pointer to a const queued Device Helper Task. */
typedef const PDMDEVHLPTASK *PCPDMDEVHLPTASK;
/**
* An USB hub registration record.
*/
typedef struct PDMUSBHUB
{
/** The USB versions this hub support.
* Note that 1.1 hubs can take on 2.0 devices. */
/** The number of ports on the hub. */
/** The number of available ports (0..cPorts). */
/** The driver instance of the hub. */
/** Copy of the to the registration structure. */
/** Pointer to the next hub in the list. */
} PDMUSBHUB;
/** Pointer to a const USB HUB registration record. */
typedef const PDMUSBHUB *PCPDMUSBHUB;
/** Pointer to a PDM Async I/O template. */
typedef struct PDMASYNCCOMPLETIONTEMPLATE *PPDMASYNCCOMPLETIONTEMPLATE;
/** Pointer to the main PDM Async completion endpoint class. */
typedef struct PDMASYNCCOMPLETIONEPCLASS *PPDMASYNCCOMPLETIONEPCLASS;
/**
* PDM VMCPU Instance data.
* Changes to this must checked against the padding of the cfgm union in VMCPU!
*/
typedef struct PDMCPU
{
/** The number of entries in the apQueuedCritSectsLeaves table that's currnetly in use. */
* We will return to Ring-3 ASAP, so this queue doesn't have to be very long. */
} PDMCPU;
/**
* Converts a PDM pointer into a VM pointer.
* @returns Pointer to the VM structure the PDM is part of.
* @param pPDM Pointer to PDM instance data.
*/
/**
* PDM VM Instance data.
* Changes to this must checked against the padding of the cfgm union in VM!
*/
typedef struct PDM
{
/** Offset to the VM structure.
* See PDM2VM(). */
/** List of registered devices. (FIFO) */
/** List of devices instances. (FIFO) */
/** List of registered USB devices. (FIFO) */
/** List of USB devices instances. (FIFO) */
/** List of registered drivers. (FIFO) */
/** PCI Buses. */
/** The register PIC device. */
/** The registerd APIC device. */
/** The registerd I/O APIC device. */
/** The registered DMAC device. */
/** The registered RTC device. */
/** The registered USB HUBs. (FIFO) */
/** Queue in which devhlp tasks are queued for R3 execution - R3 Ptr. */
/** Queue in which devhlp tasks are queued for R3 execution - R0 Ptr. */
/** Queue in which devhlp tasks are queued for R3 execution - RC Ptr. */
/** Pointer to the queue which should be manually flushed - RC Ptr.
* Only touched by EMT. */
/** Pointer to the queue which should be manually flushed - R0 Ptr.
* Only touched by EMT. */
/** Bitmask controlling the queue flushing.
* See PDM_QUEUE_FLUSH_FLAG_ACTIVE and PDM_QUEUE_FLUSH_FLAG_PENDING. */
uint32_t volatile fQueueFlushing;
/** Alignment padding. */
/** @name VMM device heap
* @{ */
/** Pointer to the heap base (MMIO2 ring-3 mapping). NULL if not registered. */
/** The heap size. */
/** Free space. */
/** The current mapping. NIL_RTGCPHYS if not mapped or registered. */
/** @} */
/** The PDM lock.
* This is used to protect everything that deals with interrupts, i.e.
* the PIC, APIC, IOAPIC and PCI devices pluss some PDM functions. */
/** Number of times a critical section leave requesed needed to be queued for ring-3 execution. */
} PDM;
/** Pointer to PDM VM instance data. */
/**
* PDM data kept in the UVM.
*/
typedef struct PDMUSERPERVM
{
/** @todo move more stuff over here. */
/** Linked list of timer driven PDM queues.
* Currently serialized by PDM::CritSect. */
/** Linked list of force action driven PDM queues.
* Currently serialized by PDM::CritSect. */
/** Lock protecting the lists below it. */
/** Pointer to list of loaded modules. */
/** List of initialized critical sections. (LIFO) */
/** Head of the PDM Thread list. (singly linked) */
/** Tail of the PDM Thread list. (singly linked) */
/** @name PDM Async Completion
* @{ */
/** Pointer to the array of supported endpoint classes. */
/** Head of the templates. Singly linked, protected by ListCritSect. */
/** @} */
} PDMUSERPERVM;
/** Pointer to the PDM data kept in the UVM. */
typedef PDMUSERPERVM *PPDMUSERPERVM;
/*******************************************************************************
* Global Variables *
*******************************************************************************/
#ifdef IN_RING3
extern const PDMDRVHLPR3 g_pdmR3DrvHlp;
extern const PDMDEVHLPR3 g_pdmR3DevHlpTrusted;
extern const PDMDEVHLPR3 g_pdmR3DevHlpUnTrusted;
extern const PDMPICHLPR3 g_pdmR3DevPicHlp;
extern const PDMAPICHLPR3 g_pdmR3DevApicHlp;
extern const PDMIOAPICHLPR3 g_pdmR3DevIoApicHlp;
extern const PDMPCIHLPR3 g_pdmR3DevPciHlp;
extern const PDMDMACHLP g_pdmR3DevDmacHlp;
extern const PDMRTCHLP g_pdmR3DevRtcHlp;
extern const PDMHPETHLPR3 g_pdmR3DevHpetHlp;
#endif
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** @def PDMDEV_ASSERT_DEVINS
* Asserts the validity of the device instance.
*/
#ifdef VBOX_STRICT
# define PDMDEV_ASSERT_DEVINS(pDevIns) \
do { \
} while (0)
#else
# define PDMDEV_ASSERT_DEVINS(pDevIns) do { } while (0)
#endif
/** @def PDMDRV_ASSERT_DRVINS
* Asserts the validity of the driver instance.
*/
#ifdef VBOX_STRICT
# define PDMDRV_ASSERT_DRVINS(pDrvIns) \
do { \
} while (0)
#else
# define PDMDRV_ASSERT_DRVINS(pDrvIns) do { } while (0)
#endif
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
#ifdef IN_RING3
int pdmR3CritSectInitDevice(PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszNameFmt, va_list va);
int pdmR3CritSectInitDriver(PVM pVM, PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszNameFmt, ...);
int pdmR3DevFindLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMLUN *ppLun);
int pdmR3UsbFindLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMLUN *ppLun);
int pdmR3UsbRegisterHub(PVM pVM, PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp);
int pdmR3ThreadCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
int pdmR3ThreadCreateUsb(PVM pVM, PPDMDRVINS pUsbIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADUSB pfnThread,
int pdmR3ThreadCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
#endif
#endif /* IN_RING3 */
/** @} */
#endif