PDMR0Device.cpp revision c97989161fbe75bc14cea477a5443bbf474dd3ad
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * PDM - Pluggable Device and Driver Manager, R0 Device parts.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * Copyright (C) 2006-2007 innotek GmbH
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * available from http://www.virtualbox.org. This file is free software;
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * you can redistribute it and/or modify it under the terms of the GNU
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * General Public License as published by the Free Software Foundation,
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * If you received this file as part of a commercial VirtualBox
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * distribution, then only the terms of your commercial VirtualBox
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * license agreement apply instead of the previous paragraph.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync/*******************************************************************************
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync* Header Files *
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync*******************************************************************************/
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync/*******************************************************************************
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync* Defined Constants And Macros *
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync*******************************************************************************/
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync/** @def PDMDEV_ASSERT_DEVINS
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * Asserts the validity of the driver instance.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync# define PDMDEV_ASSERT_DEVINS(pDevIns) do { Assert(VALID_PTR(pDevIns)); \
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync Assert(pDevIns->u32Version == PDM_DEVINS_VERSION); \
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync Assert(pDevIns->pvInstanceDataR0 == (void *)&pDevIns->achInstanceData[0]); \
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync } while (0)
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync# define PDMDEV_ASSERT_DEVINS(pDevIns) do { } while (0)
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync/*******************************************************************************
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync* Global Variables *
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync*******************************************************************************/
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncextern DECLEXPORT(const PDMAPICHLPR0) g_pdmR0ApicHlp;
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncextern DECLEXPORT(const PDMIOAPICHLPR0) g_pdmR0IoApicHlp;
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync/*******************************************************************************
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync* Internal Functions *
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync*******************************************************************************/
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync/** @name GC Device Helpers
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0DevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0DevHlp_ISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(bool) pdmR0DevHlp_A20IsEnabled(PPDMDEVINS pDevIns);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_VMSetErrorV(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_PATMSetMMIOPatchInfo(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync/** @name PIC GC Helpers
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0PicHlp_SetInterruptFF(PPDMDEVINS pDevIns);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0PicHlp_ClearInterruptFF(PPDMDEVINS pDevIns);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(int) pdmR0PicHlp_Lock(PPDMDEVINS pDevIns, int rc);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0PicHlp_Unlock(PPDMDEVINS pDevIns);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync/** @name APIC GC Helpers
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0ApicHlp_SetInterruptFF(PPDMDEVINS pDevIns);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0ApicHlp_ClearInterruptFF(PPDMDEVINS pDevIns);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0ApicHlp_ChangeFeature(PPDMDEVINS pDevIns, bool fEnabled);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(int) pdmR0ApicHlp_Lock(PPDMDEVINS pDevIns, int rc);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0ApicHlp_Unlock(PPDMDEVINS pDevIns);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync/** @name I/O APIC GC Helpers
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0IoApicHlp_ApicBusDeliver(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(int) pdmR0IoApicHlp_Lock(PPDMDEVINS pDevIns, int rc);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0IoApicHlp_Unlock(PPDMDEVINS pDevIns);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync/** @name PCI Bus GC Helpers
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0PciHlp_IsaSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0PciHlp_IoApicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(int) pdmR0PciHlp_Lock(PPDMDEVINS pDevIns, int rc);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic DECLCALLBACK(void) pdmR0PciHlp_Unlock(PPDMDEVINS pDevIns);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic void pdmR0IsaSetIrq(PVM pVM, int iIrq, int iLevel);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncstatic void pdmR0IoApicSetIrq(PVM pVM, int iIrq, int iLevel);
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * The Guest Context Device Helper Callbacks.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsyncextern DECLEXPORT(const PDMDEVHLPR0) g_pdmR0DevHlp =
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync * The Guest Context PIC Helper Callbacks.
#ifdef VBOX_WITH_PDM_LOCK
#ifdef VBOX_WITH_PDM_LOCK
#ifdef VBOX_WITH_PDM_LOCK
#ifdef VBOX_WITH_PDM_LOCK
LogFlow(("pdmR0DevHlp_PCISetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
if ( pPciDev
&& pPciBus
if (pTask)
LogFlow(("pdmR0DevHlp_ISASetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
static DECLCALLBACK(void) pdmR0DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
static DECLCALLBACK(void) pdmR0DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
Log(("pdmR0DevHlp_A20IsEnabled: caller=%p/%d: returns %RTbool\n", pDevIns, pDevIns->iInstance, fEnabled));
return fEnabled;
static DECLCALLBACK(int) pdmR0DevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMHC, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
return rc;
static DECLCALLBACK(int) pdmR0DevHlp_VMSetErrorV(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMHC, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
return rc;
static DECLCALLBACK(int) pdmR0DevHlp_PATMSetMMIOPatchInfo(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData)
#ifdef VBOX_WITH_PDM_LOCK
LogFlow(("pdmR0ApicHlp_ChangeFeature: caller=%p/%d: fEnabled=%RTbool\n", pDevIns, pDevIns->iInstance, fEnabled));
if (fEnabled)
#ifdef VBOX_WITH_PDM_LOCK
static DECLCALLBACK(void) pdmR0IoApicHlp_ApicBusDeliver(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
LogFlow(("pdmR0IoApicHlp_ApicBusDeliver: caller=%p/%d: u8Dest=%RX8 u8DestMode=%RX8 u8DeliveryMode=%RX8 iVector=%RX8 u8Polarity=%RX8 u8TriggerMode=%RX8\n",
pDevIns, pDevIns->iInstance, u8Dest, u8DestMode, u8DeliveryMode, iVector, u8Polarity, u8TriggerMode));
pVM->pdm.s.Apic.pfnBusDeliverR0(pVM->pdm.s.Apic.pDevInsR0, u8Dest, u8DestMode, u8DeliveryMode, iVector, u8Polarity, u8TriggerMode);
#ifdef VBOX_WITH_PDM_LOCK
#ifdef VBOX_WITH_PDM_LOCK
if (pTask)
if (pTask)