PDMR0Device.cpp revision 1024e3997d914b90f985856aa9e9eefac514762e
/* $Id$ */
/** @file
* PDM - Pluggable Device and Driver Manager, R0 Device parts.
*/
/*
* Copyright (C) 2006-2013 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_PDM_DEVICE
#include "PDMInternal.h"
#include "PDMInline.h"
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
/** @name Ring-0 Device Helpers
* @{
*/
/** @interface_method_impl{PDMDEVHLPR0,pfnPCIPhysRead} */
static DECLCALLBACK(int) pdmR0DevHlp_PCIPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
{
#ifndef PDM_DO_NOT_RESPECT_PCI_BM_BIT
/*
* Just check the busmaster setting here and forward the request to the generic read helper.
*/
if (!PCIDevIsBusmaster(pPciDev))
{
Log(("pdmRCDevHlp_PCIPhysRead: caller=%p/%d: returns %Rrc - Not bus master! GCPhys=%RGp cbRead=%#zx\n",
return VERR_PDM_NOT_PCI_BUS_MASTER;
}
#endif
}
/** @interface_method_impl{PDMDEVHLPR0,pfnPCIPhysRead} */
static DECLCALLBACK(int) pdmR0DevHlp_PCIPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
{
#ifndef PDM_DO_NOT_RESPECT_PCI_BM_BIT
/*
* Just check the busmaster setting here and forward the request to the generic read helper.
*/
if (!PCIDevIsBusmaster(pPciDev))
{
Log(("pdmRCDevHlp_PCIPhysWrite: caller=%p/%d: returns %Rrc - Not bus master! GCPhys=%RGp cbWrite=%#zx\n",
return VERR_PDM_NOT_PCI_BUS_MASTER;
}
#endif
}
/** @interface_method_impl{PDMDEVHLPR0,pfnPCISetIrq} */
{
LogFlow(("pdmR0DevHlp_PCISetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
if (iLevel & PDM_IRQ_LEVEL_HIGH)
{
if (iLevel == PDM_IRQ_LEVEL_HIGH)
else
}
else
if ( pPciDev
&& pPciBus
{
if (iLevel == PDM_IRQ_LEVEL_LOW)
}
else
{
/* queue for ring-3 execution. */
}
LogFlow(("pdmR0DevHlp_PCISetIrq: caller=%p/%d: returns void; uTagSrc=%#x\n", pDevIns, pDevIns->iInstance, uTagSrc));
}
/** @interface_method_impl{PDMDEVHLPR0,pfnPCISetIrq} */
{
LogFlow(("pdmR0DevHlp_ISASetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
if (iLevel & PDM_IRQ_LEVEL_HIGH)
{
if (iLevel == PDM_IRQ_LEVEL_HIGH)
else
}
else
LogFlow(("pdmR0DevHlp_ISASetIrq: caller=%p/%d: returns void; uTagSrc=%#x\n", pDevIns, pDevIns->iInstance, uTagSrc));
}
/** @interface_method_impl{PDMDEVHLPR0,pfnPhysRead} */
static DECLCALLBACK(int) pdmR0DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
{
LogFlow(("pdmR0DevHlp_PhysRead: caller=%p/%d: GCPhys=%RGp pvBuf=%p cbRead=%#x\n",
return rc;
}
/** @interface_method_impl{PDMDEVHLPR0,pfnPhysWrite} */
static DECLCALLBACK(int) pdmR0DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
{
LogFlow(("pdmR0DevHlp_PhysWrite: caller=%p/%d: GCPhys=%RGp pvBuf=%p cbWrite=%#x\n",
return rc;
}
/** @interface_method_impl{PDMDEVHLPR0,pfnA20IsEnabled} */
{
Log(("pdmR0DevHlp_A20IsEnabled: caller=%p/%d: returns %RTbool\n", pDevIns, pDevIns->iInstance, fEnabled));
return fEnabled;
}
/** @interface_method_impl{PDMDEVHLPR0,pfnVMState} */
{
LogFlow(("pdmR0DevHlp_VMState: caller=%p/%d: returns %d\n", pDevIns, pDevIns->iInstance, enmVMState));
return enmVMState;
}
/** @interface_method_impl{PDMDEVHLPR0,pfnVMSetError} */
static DECLCALLBACK(int) pdmR0DevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
{
int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMR0, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
return rc;
}
/** @interface_method_impl{PDMDEVHLPR0,pfnVMSetErrorV} */
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.pVMR0, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
return rc;
}
/** @interface_method_impl{PDMDEVHLPR0,pfnVMSetRuntimeError} */
static DECLCALLBACK(int) pdmR0DevHlp_VMSetRuntimeError(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
{
return rc;
}
/** @interface_method_impl{PDMDEVHLPR0,pfnVMSetRuntimeErrorV} */
static DECLCALLBACK(int) pdmR0DevHlp_VMSetRuntimeErrorV(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
{
return rc;
}
/** @interface_method_impl{PDMDEVHLPR0,pfnPATMSetMMIOPatchInfo} */
static DECLCALLBACK(int) pdmR0DevHlp_PATMSetMMIOPatchInfo(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData)
{
AssertFailed();
/* return PATMSetMMIOPatchInfo(pDevIns->Internal.s.pVMR0, GCPhys, pCachedData); */
return VINF_SUCCESS;
}
/** @interface_method_impl{PDMDEVHLPR0,pfnGetVM} */
{
}
/** @interface_method_impl{PDMDEVHLPR0,pfnGetVMCPU} */
{
}
/** @interface_method_impl{PDMDEVHLPR0,pfnTMTimeVirtGet} */
{
}
/** @interface_method_impl{PDMDEVHLPR0,pfnTMTimeVirtGetFreq} */
{
}
/** @interface_method_impl{PDMDEVHLPR0,pfnTMTimeVirtGetNano} */
{
}
/** @interface_method_impl{PDMDEVHLPR0,pfnDBGFTraceBuf} */
{
LogFlow(("pdmR3DevHlp_DBGFTraceBuf: caller='%p'/%d: returns %p\n", pDevIns, pDevIns->iInstance, hTraceBuf));
return hTraceBuf;
}
/** @interface_method_impl{PDMDEVHLPR0,pfnCanEmulateIoBlock} */
{
}
/**
* The Ring-0 Device Helper Callbacks.
*/
{
};
/** @} */
/** @name PIC Ring-0 Helpers
* @{
*/
/** @interface_method_impl{PDMPICHLPR0,pfnSetInterruptFF} */
{
{
LogFlow(("pdmR0PicHlp_SetInterruptFF: caller='%p'/%d: Setting local interrupt on LAPIC\n",
/* Raise the LAPIC's LINT0 line instead of signaling the CPU directly. */
return;
}
LogFlow(("pdmR0PicHlp_SetInterruptFF: caller=%p/%d: VMCPU_FF_INTERRUPT_PIC %d -> 1\n",
}
/** @interface_method_impl{PDMPICHLPR0,pfnClearInterruptFF} */
{
{
/* Raise the LAPIC's LINT0 line instead of signaling the CPU directly. */
LogFlow(("pdmR0PicHlp_ClearInterruptFF: caller='%s'/%d: Clearing local interrupt on LAPIC\n",
/* Lower the LAPIC's LINT0 line instead of signaling the CPU directly. */
return;
}
LogFlow(("pdmR0PicHlp_ClearInterruptFF: caller=%p/%d: VMCPU_FF_INTERRUPT_PIC %d -> 0\n",
}
/** @interface_method_impl{PDMPICHLPR0,pfnLock} */
{
}
/** @interface_method_impl{PDMPICHLPR0,pfnUnlock} */
{
}
/**
* The Ring-0 PIC Helper Callbacks.
*/
{
};
/** @} */
/** @name APIC Ring-0 Helpers
* @{
*/
/** @interface_method_impl{PDMAPICHLPR0,pfnSetInterruptFF} */
static DECLCALLBACK(void) pdmR0ApicHlp_SetInterruptFF(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu)
{
LogFlow(("pdmR0ApicHlp_SetInterruptFF: CPU%d=caller=%p/%d: VM_FF_INTERRUPT %d -> 1 (CPU%d)\n",
VMMGetCpuId(pVM), pDevIns, pDevIns->iInstance, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_APIC), idCpu));
switch (enmType)
{
case PDMAPICIRQ_HARDWARE:
break;
case PDMAPICIRQ_NMI:
break;
case PDMAPICIRQ_SMI:
break;
case PDMAPICIRQ_EXTINT:
break;
default:
break;
}
/* We need to wake up the target CPU. */
{
switch (VMCPU_GET_STATE(pVCpu))
{
case VMCPUSTATE_STARTED_EXEC:
break;
break;
default:
break; /* nothing to do in other states. */
}
}
}
/** @interface_method_impl{PDMAPICHLPR0,pfnClearInterruptFF} */
static DECLCALLBACK(void) pdmR0ApicHlp_ClearInterruptFF(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu)
{
LogFlow(("pdmR0ApicHlp_ClearInterruptFF: caller=%p/%d: VM_FF_INTERRUPT %d -> 0\n",
switch (enmType)
{
case PDMAPICIRQ_HARDWARE:
break;
case PDMAPICIRQ_EXTINT:
break;
default:
break;
}
}
/** @interface_method_impl{PDMAPICHLPR0,pfnCalcIrqTag} */
{
if (u8Level == PDM_IRQ_LEVEL_HIGH)
else
LogFlow(("pdmR0ApicHlp_CalcIrqTag: caller=%p/%d: returns %#x (u8Level=%d)\n",
return uTagSrc;
}
/** @interface_method_impl{PDMAPICHLPR0,pfnLock} */
{
}
/** @interface_method_impl{PDMAPICHLPR0,pfnUnlock} */
{
}
/** @interface_method_impl{PDMAPICHLPR0,pfnGetCpuId} */
{
}
/**
* The Ring-0 APIC Helper Callbacks.
*/
{
};
/** @} */
/** @name I/O APIC Ring-0 Helpers
* @{
*/
/** @interface_method_impl{PDMIOAPICHLPR0,pfnApicBusDeliver} */
static DECLCALLBACK(int) 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 uTagSrc=%#x\n",
pDevIns, pDevIns->iInstance, u8Dest, u8DestMode, u8DeliveryMode, iVector, u8Polarity, u8TriggerMode, uTagSrc));
return pVM->pdm.s.Apic.pfnBusDeliverR0(pVM->pdm.s.Apic.pDevInsR0, u8Dest, u8DestMode, u8DeliveryMode, iVector,
return VINF_SUCCESS;
}
/** @interface_method_impl{PDMIOAPICHLPR0,pfnLock} */
{
}
/** @interface_method_impl{PDMIOAPICHLPR0,pfnUnlock} */
{
}
/**
* The Ring-0 I/O APIC Helper Callbacks.
*/
{
};
/** @} */
/** @name PCI Bus Ring-0 Helpers
* @{
*/
/** @interface_method_impl{PDMPCIHLPR0,pfnIsaSetIrq} */
static DECLCALLBACK(void) pdmR0PciHlp_IsaSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc)
{
}
/** @interface_method_impl{PDMPCIHLPR0,pfnIoApicSetIrq} */
static DECLCALLBACK(void) pdmR0PciHlp_IoApicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc)
{
{
}
{
/* queue for ring-3 execution. */
if (pTask)
{
}
else
AssertMsgFailed(("We're out of devhlp queue items!!!\n"));
}
}
/** @interface_method_impl{PDMPCIHLPR0,pfnIoApicSendMsi} */
static DECLCALLBACK(void) pdmR0PciHlp_IoApicSendMsi(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue, uint32_t uTagSrc)
{
{
}
else
{
AssertFatalMsgFailed(("Lazy bastards!"));
}
}
/** @interface_method_impl{PDMPCIHLPR0,pfnLock} */
{
}
/** @interface_method_impl{PDMPCIHLPR0,pfnUnlock} */
{
}
/**
* The Ring-0 PCI Bus Helper Callbacks.
*/
{
PDM_PCIHLPR0_VERSION, /* the end */
};
/** @} */
/** @name HPET Ring-0 Helpers
* @{
*/
/* none */
/**
* The Ring-0 HPET Helper Callbacks.
*/
{
PDM_HPETHLPR0_VERSION, /* the end */
};
/** @} */
/** @name Raw PCI Ring-0 Helpers
* @{
*/
/* none */
/**
* The Ring-0 PCI raw Helper Callbacks.
*/
{
PDM_PCIRAWHLPR0_VERSION, /* the end */
};
/** @} */
/** @name Ring-0 Context Driver Helpers
* @{
*/
/** @interface_method_impl{PDMDRVHLPR0,pfnVMSetError} */
static DECLCALLBACK(int) pdmR0DrvHlp_VMSetError(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
{
int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMR0, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
return rc;
}
/** @interface_method_impl{PDMDRVHLPR0,pfnVMSetErrorV} */
static DECLCALLBACK(int) pdmR0DrvHlp_VMSetErrorV(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
{
int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMR0, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
return rc;
}
/** @interface_method_impl{PDMDRVHLPR0,pfnVMSetRuntimeError} */
static DECLCALLBACK(int) pdmR0DrvHlp_VMSetRuntimeError(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
{
return rc;
}
/** @interface_method_impl{PDMDRVHLPR0,pfnVMSetErrorV} */
static DECLCALLBACK(int) pdmR0DrvHlp_VMSetRuntimeErrorV(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
{
return rc;
}
/** @interface_method_impl{PDMDRVHLPR0,pfnAssertEMT} */
static DECLCALLBACK(bool) pdmR0DrvHlp_AssertEMT(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
{
return true;
return false;
}
/** @interface_method_impl{PDMDRVHLPR0,pfnAssertOther} */
static DECLCALLBACK(bool) pdmR0DrvHlp_AssertOther(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
{
return true;
return false;
}
/** @interface_method_impl{PDMDRVHLPR0,pfnFTSetCheckpoint} */
{
}
/**
* The Ring-0 Context Driver Helper Callbacks.
*/
{
};
/** @} */
/**
* Sets an irq on the PIC and I/O APIC.
*
* @returns true if delivered, false if postponed.
* @param pVM Pointer to the VM.
* @param iIrq The irq.
* @param iLevel The new level.
* @param uTagSrc The IRQ tag and source.
*
* @remarks The caller holds the PDM lock.
*/
{
{
return true;
}
/* queue for ring-3 execution. */
AssertReturn(pTask, false);
return false;
}
/**
* PDMDevHlpCallR0 helper.
*
* @returns See PFNPDMDEVREQHANDLERR0.
* @param pVM Pointer to the VM (for validation).
* @param pReq Pointer to the request buffer.
*/
{
/*
* Validate input and make the call.
*/
AssertMsgReturn(pReq->Hdr.cbReq == sizeof(*pReq), ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(*pReq)), VERR_INVALID_PARAMETER);
}