PDMInternal.h revision cee5f4e7e4f238fc5b3436abdf3c915275017f6e
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/* $Id$ */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/** @file
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * PDM - Internal header file.
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/*
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * Copyright (C) 2006 InnoTek Systemberatung GmbH
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync *
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * available from http://www.virtualbox.org. This file is free software;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * you can redistribute it and/or modify it under the terms of the GNU
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * General Public License as published by the Free Software Foundation,
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync *
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * If you received this file as part of a commercial VirtualBox
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * distribution, then only the terms of your commercial VirtualBox
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * license agreement apply instead of the previous paragraph.
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync#ifndef __PDMInternal_h__
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#define __PDMInternal_h__
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#include <VBox/cdefs.h>
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#include <VBox/types.h>
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#include <VBox/param.h>
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#include <VBox/cfgm.h>
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#include <VBox/stam.h>
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#include <iprt/critsect.h>
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync__BEGIN_DECLS
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/** @defgroup grp_pdm_int Internal
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * @ingroup grp_pdm
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * @internal
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * @{
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync */
4bfa7b58e362a1bca0628643c352c137900bf01avboxsync
63a23b6d96aca4c8545d3c3e89cc454af7ba3da6vboxsync/** Pointer to a PDM Device. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsynctypedef struct PDMDEV *PPDMDEV;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/** Pointer to a pointer to a PDM Device. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsynctypedef PPDMDEV *PPPDMDEV;
ebe097ee2ebebb775a1e816af91b4ea67c52b0bdvboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/** Pointer to a PDM Driver. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsynctypedef struct PDMDRV *PPDMDRV;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/** Pointer to a pointer to a PDM Driver. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsynctypedef PPDMDRV *PPPDMDRV;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/** Pointer to a PDM Logical Unit. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsynctypedef struct PDMLUN *PPDMLUN;
ebe097ee2ebebb775a1e816af91b4ea67c52b0bdvboxsync/** Pointer to a pointer to a PDM Logical Unit. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsynctypedef PPDMLUN *PPPDMLUN;
68625073d1badad56ca7538c636ce54db566f07avboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/** Pointer to a PDM PCI Bus instance. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsynctypedef struct PDMPCIBUS *PPDMPCIBUS;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/** Pointer to a DMAC instance. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsynctypedef struct PDMDMAC *PPDMDMAC;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/** Pointer to a RTC instance. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsynctypedef struct PDMRTC *PPDMRTC;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/**
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * Private instance data.
ebe097ee2ebebb775a1e816af91b4ea67c52b0bdvboxsync */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsynctypedef struct PDMDEVINSINT
68625073d1badad56ca7538c636ce54db566f07avboxsync{
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to the next instance (HC Ptr).
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * (Head is pointed to by PDM::pDevInstances.) */
ebe097ee2ebebb775a1e816af91b4ea67c52b0bdvboxsync HCPTRTYPE(PPDMDEVINS) pNextHC;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to the next per device instance (HC Ptr).
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * (Head is pointed to by PDMDEV::pInstances.) */
ebe097ee2ebebb775a1e816af91b4ea67c52b0bdvboxsync HCPTRTYPE(PPDMDEVINS) pPerDeviceNextHC;
ebe097ee2ebebb775a1e816af91b4ea67c52b0bdvboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to device structure - HC Ptr. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync HCPTRTYPE(PPDMDEV) pDevHC;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to the VM this instance was created for - HC Ptr. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync HCPTRTYPE(PVM) pVMHC;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to the VM this instance was created for - GC Ptr. */
8a179f8f39b6114b304505d4fb79a987d5e5a623vboxsync GCPTRTYPE(PVM) pVMGC;
8a179f8f39b6114b304505d4fb79a987d5e5a623vboxsync
683371bbf37760161d1b8454ce978acf89bbb04fvboxsync /** Pointer to the list of logical units associated with the device. (FIFO) */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync HCPTRTYPE(PPDMLUN) pLunsHC;
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Configuration handle to the instance node. */
8a179f8f39b6114b304505d4fb79a987d5e5a623vboxsync HCPTRTYPE(PCFGMNODE) pCfgHandle;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** HC pointer to associated PCI device structure. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync HCPTRTYPE(struct PCIDevice *) pPciDeviceHC;
8a179f8f39b6114b304505d4fb79a987d5e5a623vboxsync /** GC pointer to associated PCI device structure. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync GCPTRTYPE(struct PCIDevice *) pPciDeviceGC;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** HC pointer to associated PCI bus structure. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync HCPTRTYPE(PPDMPCIBUS) pPciBusHC;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** GC pointer to associated PCI bus structure. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync GCPTRTYPE(PPDMPCIBUS) pPciBusGC;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync} PDMDEVINSINT;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/**
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * Private instance data.
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync */
4bfa7b58e362a1bca0628643c352c137900bf01avboxsynctypedef struct PDMDRVINSINT
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync{
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to the driver instance above.
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * This is NULL for the topmost drive. */
ebe097ee2ebebb775a1e816af91b4ea67c52b0bdvboxsync PPDMDRVINS pUp;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to the driver instance below.
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * This is NULL for the bottommost driver. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync PPDMDRVINS pDown;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to the logical unit this driver chained on. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync PPDMLUN pLun;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to driver structure from which this was instantiated. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync PPDMDRV pDrv;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to the VM this instance was created for. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync PVM pVM;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Flag indicating that the driver is being detached and destroyed.
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * (Helps detect potential recursive detaching.) */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync bool fDetaching;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Configuration handle to the instance node. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync PCFGMNODE pCfgHandle;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync} PDMDRVINSINT;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
97935332ee43e27b4b0448a9fab59374e4ed148avboxsync
97935332ee43e27b4b0448a9fab59374e4ed148avboxsync/**
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * Private critical section data.
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsynctypedef struct PDMCRITSECTINT
97935332ee43e27b4b0448a9fab59374e4ed148avboxsync{
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** The critical section core which is shared with IPRT. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync RTCRITSECT Core;
97935332ee43e27b4b0448a9fab59374e4ed148avboxsync /** Pointer to the next critical section.
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * This chain is used for relocating pVMGC and device cleanup. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync R3PTRTYPE(struct PDMCRITSECTINT *) pNext;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Owner identifier.
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * This is pDevIns if the owner is a device. Similarily for a driver or service.
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * PDMR3CritSectInit() sets this to point to the critsect itself. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync RTR3PTR pvKey;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to the VM - R3Ptr. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync R3PTRTYPE(PVM) pVMR3;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to the VM - R0Ptr. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync R0PTRTYPE(PVM) pVMR0;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Pointer to the VM - GCPtr. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync GCPTRTYPE(PVM) pVMGC;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#if GC_ARCH_BITS == 32
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync uint32_t u32Padding;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#endif
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** R0/GC lock contention. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync STAMCOUNTER StatContentionR0GCLock;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** R0/GC unlock contention. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync STAMCOUNTER StatContentionR0GCUnlock;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** R3 lock contention. */
97935332ee43e27b4b0448a9fab59374e4ed148avboxsync STAMCOUNTER StatContentionR3;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync /** Profiling the time the section is locked. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync STAMPROFILEADV StatLocked;
97935332ee43e27b4b0448a9fab59374e4ed148avboxsync} PDMCRITSECTINT, *PPDMCRITSECTINT;
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/* Must be included after PDMDEVINSINT is defined. */
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#define PDMDEVINSINT_DECLARED
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#define PDMDRVINSINT_DECLARED
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#define PDMCRITSECTINT_DECLARED
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#ifdef __VBox_pdm_h__
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync# error "Invalid header PDM order. Include PDMInternal.h before VBox/pdm.h!"
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#endif
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync#include <VBox/pdm.h>
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync/**
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * PDM Logical Unit.
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync *
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * This typically the representation of a physical port on a
18e02d8d60d50fb098bbf009186f36bfb430a780vboxsync * 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::pLunsHC).
*/
typedef struct PDMLUN
{
/** The LUN - The Logical Unit Number. */
RTUINT iLun;
/** Pointer to the next LUN. */
PPDMLUN pNext;
/** Pointer to the top driver in the driver chain. */
PPDMDRVINS pTop;
/** Pointer to the device instance which the LUN belongs to. */
PPDMDEVINS pDevIns;
/** Pointer to the device base interface. */
PPDMIBASE pBase;
/** Description of this LUN. */
const char *pszDesc;
} PDMLUN;
/**
* PDM Device.
*/
typedef struct PDMDEV
{
/** Pointer to the next device (HC Ptr). */
HCPTRTYPE(PPDMDEV) pNext;
/** Device name length. (search optimization) */
RTUINT cchName;
/** Registration structure. */
HCPTRTYPE(const struct PDMDEVREG *) pDevReg;
/** Number of instances. */
RTUINT cInstances;
/** Pointer to chain of instances (HC Ptr). */
HCPTRTYPE(PPDMDEVINS) pInstances;
} PDMDEV;
/**
* PDM Driver.
*/
typedef struct PDMDRV
{
/** Pointer to the next device. */
PPDMDRV pNext;
/** Registration structure. */
const struct PDMDRVREG *pDrvReg;
/** Number of instances. */
RTUINT cInstances;
} PDMDRV;
/**
* PDM registered PIC device.
*/
typedef struct PDMPIC
{
/** Pointer to the PIC device instance - HC. */
HCPTRTYPE(PPDMDEVINS) pDevInsR3;
/** @copydoc PDMPICREG::pfnSetIrqHC */
DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
/** @copydoc PDMPICREG::pfnGetInterruptHC */
DECLR3CALLBACKMEMBER(int, pfnGetInterruptR3,(PPDMDEVINS pDevIns));
/** Pointer to the PIC device instance - R0. */
R0PTRTYPE(PPDMDEVINS) pDevInsR0;
/** @copydoc PDMPICREG::pfnSetIrqHC */
DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
/** @copydoc PDMPICREG::pfnGetInterruptHC */
DECLR0CALLBACKMEMBER(int, pfnGetInterruptR0,(PPDMDEVINS pDevIns));
/** Pointer to the PIC device instance - GC. */
GCPTRTYPE(PPDMDEVINS) pDevInsGC;
/** @copydoc PDMPICREG::pfnSetIrqHC */
DECLGCCALLBACKMEMBER(void, pfnSetIrqGC,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
/** @copydoc PDMPICREG::pfnGetInterruptHC */
DECLGCCALLBACKMEMBER(int, pfnGetInterruptGC,(PPDMDEVINS pDevIns));
#if GC_ARCH_BITS == 32
RTGCPTR GCPtrPadding; /**< Alignment padding. */
#endif
} PDMPIC;
/**
* PDM registered APIC device.
*/
typedef struct PDMAPIC
{
/** Pointer to the APIC device instance - HC Ptr. */
PPDMDEVINSHC pDevInsR3;
/** @copydoc PDMAPICREG::pfnGetInterruptHC */
DECLR3CALLBACKMEMBER(int, pfnGetInterruptR3,(PPDMDEVINS pDevIns));
/** @copydoc PDMAPICREG::pfnSetBaseHC */
DECLR3CALLBACKMEMBER(void, pfnSetBaseR3,(PPDMDEVINS pDevIns, uint64_t u64Base));
/** @copydoc PDMAPICREG::pfnGetBaseHC */
DECLR3CALLBACKMEMBER(uint64_t, pfnGetBaseR3,(PPDMDEVINS pDevIns));
/** @copydoc PDMAPICREG::pfnSetTPRHC */
DECLR3CALLBACKMEMBER(void, pfnSetTPRR3,(PPDMDEVINS pDevIns, uint8_t u8TPR));
/** @copydoc PDMAPICREG::pfnGetTPRHC */
DECLR3CALLBACKMEMBER(uint8_t, pfnGetTPRR3,(PPDMDEVINS pDevIns));
/** @copydoc PDMAPICREG::pfnBusDeliverHC */
DECLR3CALLBACKMEMBER(void, pfnBusDeliverR3,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
/** Pointer to the PIC device instance - R0. */
R0PTRTYPE(PPDMDEVINS) pDevInsR0;
/** @copydoc PDMAPICREG::pfnGetInterruptHC */
DECLR0CALLBACKMEMBER(int, pfnGetInterruptR0,(PPDMDEVINS pDevIns));
/** @copydoc PDMAPICREG::pfnSetBaseHC */
DECLR0CALLBACKMEMBER(void, pfnSetBaseR0,(PPDMDEVINS pDevIns, uint64_t u64Base));
/** @copydoc PDMAPICREG::pfnGetBaseHC */
DECLR0CALLBACKMEMBER(uint64_t, pfnGetBaseR0,(PPDMDEVINS pDevIns));
/** @copydoc PDMAPICREG::pfnSetTPRHC */
DECLR0CALLBACKMEMBER(void, pfnSetTPRR0,(PPDMDEVINS pDevIns, uint8_t u8TPR));
/** @copydoc PDMAPICREG::pfnGetTPRHC */
DECLR0CALLBACKMEMBER(uint8_t, pfnGetTPRR0,(PPDMDEVINS pDevIns));
/** @copydoc PDMAPICREG::pfnBusDeliverHC */
DECLR0CALLBACKMEMBER(void, pfnBusDeliverR0,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
/** Pointer to the APIC device instance - GC Ptr. */
PPDMDEVINSGC pDevInsGC;
/** @copydoc PDMAPICREG::pfnGetInterruptHC */
DECLGCCALLBACKMEMBER(int, pfnGetInterruptGC,(PPDMDEVINS pDevIns));
/** @copydoc PDMAPICREG::pfnSetBaseHC */
DECLGCCALLBACKMEMBER(void, pfnSetBaseGC,(PPDMDEVINS pDevIns, uint64_t u64Base));
/** @copydoc PDMAPICREG::pfnGetBaseHC */
DECLGCCALLBACKMEMBER(uint64_t, pfnGetBaseGC,(PPDMDEVINS pDevIns));
/** @copydoc PDMAPICREG::pfnSetTPRHC */
DECLGCCALLBACKMEMBER(void, pfnSetTPRGC,(PPDMDEVINS pDevIns, uint8_t u8TPR));
/** @copydoc PDMAPICREG::pfnGetTPRHC */
DECLGCCALLBACKMEMBER(uint8_t, pfnGetTPRGC,(PPDMDEVINS pDevIns));
/** @copydoc PDMAPICREG::pfnBusDeliverHC */
DECLGCCALLBACKMEMBER(void, pfnBusDeliverGC,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
#if GC_ARCH_BITS == 32
RTGCPTR GCPtrPadding; /**< Alignment padding. */
#endif
} PDMAPIC;
/**
* PDM registered I/O APIC device.
*/
typedef struct PDMIOAPIC
{
/** Pointer to the APIC device instance - HC Ptr. */
PPDMDEVINSHC pDevInsR3;
/** @copydoc PDMIOAPICREG::pfnSetIrqHC */
DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
/** Pointer to the PIC device instance - R0. */
R0PTRTYPE(PPDMDEVINS) pDevInsR0;
/** @copydoc PDMIOAPICREG::pfnSetIrqHC */
DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
/** Pointer to the APIC device instance - GC Ptr. */
PPDMDEVINSGC pDevInsGC;
/** @copydoc PDMIOAPICREG::pfnSetIrqHC */
DECLGCCALLBACKMEMBER(void, pfnSetIrqGC,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
} PDMIOAPIC;
/**
* PDM PCI Bus instance.
*/
typedef struct PDMPCIBUS
{
/** PCI bus number. */
RTUINT iBus;
RTUINT uPadding0; /**< Alignment padding.*/
/** Pointer to PCI Bus device instance. */
PPDMDEVINSHC pDevInsR3;
/** @copydoc PDMPCIBUSREG::pfnSetIrqHC */
DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
/** @copydoc PDMPCIBUSREG::pfnRegisterHC */
DECLR3CALLBACKMEMBER(int, pfnRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, const char *pszName, int iDev));
/** @copydoc PDMPCIBUSREG::pfnIORegionRegisterHC */
DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iRegion, uint32_t cbRegion,
PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
/** @copydoc PDMPCIBUSREG::pfnSaveExecHC */
DECLR3CALLBACKMEMBER(int, pfnSaveExecR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
/** @copydoc PDMPCIBUSREG::pfnLoadExecHC */
DECLR3CALLBACKMEMBER(int, pfnLoadExecR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
/** @copydoc PDMPCIBUSREG::pfnFakePCIBIOSHC */
DECLR3CALLBACKMEMBER(int, pfnFakePCIBIOSR3,(PPDMDEVINS pDevIns));
/** Pointer to the PIC device instance - R0. */
R0PTRTYPE(PPDMDEVINS) pDevInsR0;
/** @copydoc PDMPCIBUSREG::pfnSetIrqHC */
DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
/** Pointer to PCI Bus device instance. */
PPDMDEVINSGC pDevInsGC;
/** @copydoc PDMPCIBUSREG::pfnSetIrqHC */
DECLGCCALLBACKMEMBER(void, pfnSetIrqGC,(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. */
PPDMDEVINS pDevIns;
/** Copy of the registration structure. */
PDMDMACREG Reg;
} PDMDMAC;
/**
* PDM registered RTC (Real Time Clock) device.
*/
typedef struct PDMRTC
{
/** Pointer to the RTC device instance. */
PPDMDEVINS pDevIns;
/** Copy of the registration structure. */
PDMRTCREG Reg;
} PDMRTC;
#endif /* IN_RING3 */
/**
* Module type.
*/
typedef enum PDMMODTYPE
{
/** Guest context module. */
PDMMOD_TYPE_GC,
/** Ring-0 (host) context module. */
PDMMOD_TYPE_R0,
/** Ring-3 (host) context module. */
PDMMOD_TYPE_R3
} PDMMODTYPE, *PPDMMODTYPE;
/** 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. */
PDMMODTYPE eType;
/** Loader module handle. Not used for R0 modules. */
RTLDRMOD hLdrMod;
/** Loaded address.
* This is the 'handle' for R0 modules. */
RTUINTPTR ImageBase;
/** Old loaded address.
* This is used during relocation of GC modules. Not used for R0 modules. */
RTUINTPTR OldImageBase;
/** 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. */
struct PDMMOD *pNext;
/** Module filename. */
char szFilename[1];
} PDMMOD;
/** Pointer to loaded module instance. */
typedef PDMMOD *PPDMMOD;
/** Extra space in the free array. */
#define PDMQUEUE_FREE_SLACK 16
/**
* Queue type.
*/
typedef enum PDMQUEUETYPE
{
/** Device consumer. */
PDMQUEUETYPE_DEV = 1,
/** Driver consumer. */
PDMQUEUETYPE_DRV,
/** Internal consumer. */
PDMQUEUETYPE_INTERNAL,
/** External consumer. */
PDMQUEUETYPE_EXTERNAL
} PDMQUEUETYPE;
/** Pointer to a PDM Queue. */
typedef struct PDMQUEUE *PPDMQUEUE;
/**
* PDM Queue.
*/
typedef struct PDMQUEUE
{
/** Pointer to the next queue in the list. */
HCPTRTYPE(PPDMQUEUE) pNext;
/** Queue type. */
PDMQUEUETYPE enmType;
/** Type specific data. */
union
{
/** PDMQUEUETYPE_DEV */
struct
{
/** Pointer to consumer function. */
HCPTRTYPE(PFNPDMQUEUEDEV) pfnCallback;
/** Pointer to the device instance owning the queue. */
HCPTRTYPE(PPDMDEVINS) pDevIns;
} Dev;
/** PDMQUEUETYPE_DRV */
struct
{
/** Pointer to consumer function. */
HCPTRTYPE(PFNPDMQUEUEDRV) pfnCallback;
/** Pointer to the driver instance owning the queue. */
HCPTRTYPE(PPDMDRVINS) pDrvIns;
} Drv;
/** PDMQUEUETYPE_INTERNAL */
struct
{
/** Pointer to consumer function. */
HCPTRTYPE(PFNPDMQUEUEINT) pfnCallback;
} Int;
/** PDMQUEUETYPE_EXTERNAL */
struct
{
/** Pointer to consumer function. */
HCPTRTYPE(PFNPDMQUEUEEXT) pfnCallback;
/** Pointer to user argument. */
HCPTRTYPE(void *) pvUser;
} Ext;
} u;
/** Pointer to the VM. */
HCPTRTYPE(PVM) pVMHC;
/** Pointer to the GC VM and indicator for GC enabled queue.
* If this is NULL, the queue cannot be used in GC.
*/
GCPTRTYPE(PVM) pVMGC;
/** 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. */
uint32_t cMilliesInterval;
/** Interval timer. Only used if cMilliesInterval is non-zero. */
PTMTIMERHC pTimer;
/** Item size (bytes). */
RTUINT cbItem;
/** Number of items in the queue. */
RTUINT cItems;
/** LIFO of pending items - HC. */
HCPTRTYPE(PPDMQUEUEITEMCORE) volatile pPendingHC;
/** LIFO of pending items - GC. */
GCPTRTYPE(PPDMQUEUEITEMCORE) pPendingGC;
/** Index to the free head (where we insert). */
uint32_t volatile iFreeHead;
/** Index to the free tail (where we remove). */
uint32_t volatile iFreeTail;
/** Array of pointers to free items. Variable size. */
struct PDMQUEUEFREEITEM
{
/** Pointer to the free item - HC Ptr. */
HCPTRTYPE(PPDMQUEUEITEMCORE) volatile pItemHC;
/** Pointer to the free item - GC Ptr. */
GCPTRTYPE(PPDMQUEUEITEMCORE) volatile pItemGC;
} aFreeItems[1];
} PDMQUEUE;
/**
* Queue device helper task operation.
*/
typedef enum PDMDEVHLPTASKOP
{
/** The usual invalid 0 entry. */
PDMDEVHLPTASKOP_INVALID = 0,
/** ISASetIrq */
PDMDEVHLPTASKOP_ISA_SET_IRQ,
/** PCISetIrq */
PDMDEVHLPTASKOP_PCI_SET_IRQ,
/** PCISetIrq */
PDMDEVHLPTASKOP_IOAPIC_SET_IRQ,
/** The usual 32-bit hack. */
PDMDEVHLPTASKOP_32BIT_HACK = 0x7fffffff
} PDMDEVHLPTASKOP;
/**
* Queued Device Helper Task.
*/
typedef struct PDMDEVHLPTASK
{
/** The queue item core (don't touch). */
PDMQUEUEITEMCORE Core;
/** Pointer to the device instance (HC Ptr). */
HCPTRTYPE(PPDMDEVINS) pDevInsHC;
/** This operation to perform. */
PDMDEVHLPTASKOP enmOp;
/** 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;
} PDMDEVHLPTASK;
/** Pointer to a queued Device Helper Task. */
typedef PDMDEVHLPTASK *PPDMDEVHLPTASK;
/** Pointer to a const queued Device Helper Task. */
typedef const PDMDEVHLPTASK *PCPDMDEVHLPTASK;
/**
* 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.
*/
#define PDM2VM(pPDM) ( (PVM)((char*)pPDM - pPDM->offVM) )
/**
* 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(). */
RTUINT offVM;
RTUINT uPadding0; /**< Alignment padding.*/
/** Pointer to list of loaded modules. This is HC only! */
HCPTRTYPE(PPDMMOD) pModules;
/** List of registered devices. (FIFO) */
HCPTRTYPE(PPDMDEV) pDevs;
/** List of devices instances. (FIFO) */
HCPTRTYPE(PPDMDEVINS) pDevInstances;
/** List of registered drivers. (FIFO) */
HCPTRTYPE(PPDMDRV) pDrvs;
/** List of initialized critical sections. (LIFO) */
HCPTRTYPE(PPDMCRITSECTINT) pCritSects;
/** PCI Buses. */
PDMPCIBUS aPciBuses[1];
/** The register PIC device. */
PDMPIC Pic;
/** The registerd APIC device. */
PDMAPIC Apic;
/** The registerd I/O APIC device. */
PDMIOAPIC IoApic;
/** The registered DMAC device. */
HCPTRTYPE(PPDMDMAC) pDmac;
/** The registered RTC device. */
HCPTRTYPE(PPDMRTC) pRtc;
/** Queue in which devhlp tasks are queued for R3 execution - HC Ptr. */
HCPTRTYPE(PPDMQUEUE) pDevHlpQueueHC;
/** Queue in which devhlp tasks are queued for R3 execution - GC Ptr. */
GCPTRTYPE(PPDMQUEUE) pDevHlpQueueGC;
/** The number of entries in the apQueuedCritSectsLeaves table that's currnetly in use. */
RTUINT cQueuedCritSectLeaves;
/** Critical sections queued in GC/R0 because of contention preventing leave to complete. (R3 Ptrs)
* We will return to Ring-3 ASAP, so this queue doesn't has to be very long. */
R3PTRTYPE(PPDMCRITSECT) apQueuedCritSectsLeaves[8];
/** Linked list of timer driven PDM queues. */
HCPTRTYPE(struct PDMQUEUE *) pQueuesTimer;
/** Linked list of force action driven PDM queues. */
HCPTRTYPE(struct PDMQUEUE *) pQueuesForced;
/** Pointer to the queue which should be manually flushed - HCPtr.
* Only touched by EMT. */
HCPTRTYPE(struct PDMQUEUE *) pQueueFlushHC;
/** Pointer to the queue which should be manually flushed - GCPtr. */
GCPTRTYPE(struct PDMQUEUE *) pQueueFlushGC;
/** TEMPORARY HACKS FOR NETWORK POLLING.
* @todo fix NAT and kill this!
* @{ */
RTUINT cPollers;
HCPTRTYPE(PFNPDMDRVPOLLER) apfnPollers[16];
HCPTRTYPE(PPDMDRVINS) aDrvInsPollers[16];
PTMTIMERHC pTimerPollers;
/** @} */
#ifdef VBOX_WITH_PDM_LOCK
/** 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. */
PDMCRITSECT CritSect;
#endif
/** Number of times a critical section leave requesed needed to be queued for ring-3 execution. */
STAMCOUNTER StatQueuedCritSectLeaves;
} PDM;
/** Pointer to PDM VM instance data. */
typedef PDM *PPDM;
/*******************************************************************************
* Global Variables *
*******************************************************************************/
#ifdef IN_RING3
extern const PDMDRVHLP g_pdmR3DrvHlp;
#endif
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
int pdmR3CritSectInit(PVM pVM);
int pdmR3CritSectTerm(PVM pVM);
void pdmR3CritSectRelocate(PVM pVM);
int pdmR3CritSectInitDevice(PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName);
int pdmR3CritSectDeleteDevice(PVM pVM, PPDMDEVINS pDevIns);
int pdmR3DevInit(PVM pVM);
PPDMDEV pdmR3DevLookup(PVM pVM, const char *pszName);
int pdmR3DevFindLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMLUN *ppLun);
int pdmR3DrvInit(PVM pVM);
int pdmR3DrvDetach(PPDMDRVINS pDrvIns);
PPDMDRV pdmR3DrvLookup(PVM pVM, const char *pszName);
int pdmR3LdrInit(PVM pVM);
void pdmR3LdrTerm(PVM pVM);
char * pdmR3FileR3(const char *pszFile);
int pdmR3LoadR3(PVM pVM, const char *pszFilename, const char *pszName);
void pdmR3QueueRelocate(PVM pVM, RTGCINTPTR offDelta);
#ifdef VBOX_WITH_PDM_LOCK
void pdmLock(PVM pVM);
int pdmLockEx(PVM pVM, int rc);
void pdmUnlock(PVM pVM);
#else
# define pdmLock(pVM) do {} while (0)
# define pdmLockEx(pVM, rc) (VINF_SUCCESS)
# define pdmUnlock(pVM) do {} while (0)
#endif
/** @} */
__END_DECLS
#endif