PDMRCDevice.cpp revision fa014762f649876c54d70f8e463b287c3b220a52
/* $Id$ */
/** @file
* PDM - Pluggable Device and Driver Manager, RC 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 *
*******************************************************************************/
/** @todo missing PDMPCIRAWHLPRC */
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
/** @name Raw-Mode Context Device Helpers
* @{
*/
/** @interface_method_impl{PDMDEVHLPRC,pfnPCIPhysRead} */
static DECLCALLBACK(int) pdmRCDevHlp_PCIPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
{
/*
* 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;
}
}
/** @interface_method_impl{PDMDEVHLPRC,pfnPCIPhysRead} */
static DECLCALLBACK(int) pdmRCDevHlp_PCIPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
{
/*
* 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;
}
}
/** @interface_method_impl{PDMDEVHLPRC,pfnPCISetIrq} */
{
LogFlow(("pdmRCDevHlp_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(("pdmRCDevHlp_PCISetIrq: caller=%p/%d: returns void; uTagSrc=%#x\n", pDevIns, pDevIns->iInstance, uTagSrc));
}
/** @interface_method_impl{PDMDRVHLPRC,pfnPCISetIrq} */
{
LogFlow(("pdmRCDevHlp_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(("pdmRCDevHlp_ISASetIrq: caller=%p/%d: returns void; uTagSrc=%#x\n", pDevIns, pDevIns->iInstance, uTagSrc));
}
/** @interface_method_impl{PDMDEVHLPRC,pfnPhysRead} */
static DECLCALLBACK(int) pdmRCDevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
{
LogFlow(("pdmRCDevHlp_PhysRead: caller=%p/%d: GCPhys=%RGp pvBuf=%p cbRead=%#x\n",
return rc;
}
/** @interface_method_impl{PDMDEVHLPRC,pfnPhysWrite} */
static DECLCALLBACK(int) pdmRCDevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
{
LogFlow(("pdmRCDevHlp_PhysWrite: caller=%p/%d: GCPhys=%RGp pvBuf=%p cbWrite=%#x\n",
return rc;
}
/** @interface_method_impl{PDMDEVHLPRC,pfnA20IsEnabled} */
{
Log(("pdmRCDevHlp_A20IsEnabled: caller=%p/%d: returns %RTbool\n", pDevIns, pDevIns->iInstance, fEnabled));
return fEnabled;
}
/** @interface_method_impl{PDMDEVHLPRC,pfnVMState} */
{
LogFlow(("pdmRCDevHlp_VMState: caller=%p/%d: returns %d\n", pDevIns, pDevIns->iInstance, enmVMState));
return enmVMState;
}
/** @interface_method_impl{PDMDEVHLPRC,pfnVMSetError} */
static DECLCALLBACK(int) pdmRCDevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
{
int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMRC, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
return rc;
}
/** @interface_method_impl{PDMDEVHLPRC,pfnVMSetErrorV} */
static DECLCALLBACK(int) pdmRCDevHlp_VMSetErrorV(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
{
int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMRC, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
return rc;
}
/** @interface_method_impl{PDMDEVHLPRC,pfnVMSetRuntimeError} */
static DECLCALLBACK(int) pdmRCDevHlp_VMSetRuntimeError(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
{
return rc;
}
/** @interface_method_impl{PDMDEVHLPRC,pfnVMSetErrorV} */
static DECLCALLBACK(int) pdmRCDevHlp_VMSetRuntimeErrorV(PPDMDEVINS pDevIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
{
return rc;
}
/** @interface_method_impl{PDMDEVHLPRC,pfnPATMSetMMIOPatchInfo} */
static DECLCALLBACK(int) pdmRCDevHlp_PATMSetMMIOPatchInfo(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData)
{
}
/** @interface_method_impl{PDMDEVHLPRC,pfnGetVM} */
{
}
/** @interface_method_impl{PDMDEVHLPRC,pfnGetVMCPU} */
{
}
/** @interface_method_impl{PDMDEVHLPRC,pfnTMTimeVirtGet} */
{
}
/** @interface_method_impl{PDMDEVHLPRC,pfnTMTimeVirtGetFreq} */
{
}
/** @interface_method_impl{PDMDEVHLPRC,pfnTMTimeVirtGetNano} */
{
}
/** @interface_method_impl{PDMDEVHLPRC,pfnDBGFTraceBuf} */
{
LogFlow(("pdmRCDevHlp_DBGFTraceBuf: caller='%p'/%d: returns %p\n", pDevIns, pDevIns->iInstance, hTraceBuf));
return hTraceBuf;
}
/**
* The Raw-Mode Context Device Helper Callbacks.
*/
{
};
/** @} */
/** @name PIC RC Helpers
* @{
*/
/** @interface_method_impl{PDMPICHLPGC,pfnSetInterruptFF} */
{
{
LogFlow(("pdmRCPicHlp_SetInterruptFF: caller='%p'/%d: Setting local interrupt on LAPIC\n",
/* Raise the LAPIC's LINT0 line instead of signaling the CPU directly. */
return;
}
LogFlow(("pdmRCPicHlp_SetInterruptFF: caller=%p/%d: VMMCPU_FF_INTERRUPT_PIC %d -> 1\n",
}
/** @interface_method_impl{PDMPICHLPGC,pfnClearInterruptFF} */
{
{
/* Raise the LAPIC's LINT0 line instead of signaling the CPU directly. */
LogFlow(("pdmRCPicHlp_ClearInterruptFF: caller='%s'/%d: Clearing local interrupt on LAPIC\n",
/* Lower the LAPIC's LINT0 line instead of signaling the CPU directly. */
return;
}
LogFlow(("pdmRCPicHlp_ClearInterruptFF: caller=%p/%d: VMCPU_FF_INTERRUPT_PIC %d -> 0\n",
}
/** @interface_method_impl{PDMPICHLPGC,pfnLock} */
{
}
/** @interface_method_impl{PDMPICHLPGC,pfnUnlock} */
{
}
/**
* The Raw-Mode Context PIC Helper Callbacks.
*/
{
};
/** @} */
/** @name APIC RC Helpers
* @{
*/
/** @interface_method_impl{PDMAPICHLPRC,pfnSetInterruptFF} */
static DECLCALLBACK(void) pdmRCApicHlp_SetInterruptFF(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu)
{
LogFlow(("pdmRCApicHlp_SetInterruptFF: caller=%p/%d: VM_FF_INTERRUPT %d -> 1\n",
switch (enmType)
{
case PDMAPICIRQ_HARDWARE:
break;
case PDMAPICIRQ_NMI:
break;
case PDMAPICIRQ_SMI:
break;
case PDMAPICIRQ_EXTINT:
break;
default:
break;
}
}
/** @interface_method_impl{PDMAPICHLPRC,pfnClearInterruptFF} */
static DECLCALLBACK(void) pdmRCApicHlp_ClearInterruptFF(PPDMDEVINS pDevIns, PDMAPICIRQ enmType, VMCPUID idCpu)
{
LogFlow(("pdmRCApicHlp_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{PDMAPICHLPRC,pfnCalcIrqTag} */
{
if (u8Level == PDM_IRQ_LEVEL_HIGH)
else
LogFlow(("pdmRCApicHlp_CalcIrqTag: caller=%p/%d: returns %#x (u8Level=%d)\n",
return uTagSrc;
}
/** @interface_method_impl{PDMAPICHLPRC,pfnChangeFeature} */
{
LogFlow(("pdmRCApicHlp_ChangeFeature: caller=%p/%d: version=%d\n", pDevIns, pDevIns->iInstance, (int)enmVersion));
switch (enmVersion)
{
case PDMAPICVERSION_NONE:
break;
case PDMAPICVERSION_APIC:
break;
case PDMAPICVERSION_X2APIC:
break;
default:
}
}
/** @interface_method_impl{PDMAPICHLPRC,pfnLock} */
{
}
/** @interface_method_impl{PDMAPICHLPRC,pfnUnlock} */
{
}
/** @interface_method_impl{PDMAPICHLPRC,pfnGetCpuId} */
{
}
/**
* The Raw-Mode Context APIC Helper Callbacks.
*/
{
};
/** @} */
/** @name I/O APIC RC Helpers
* @{
*/
/** @interface_method_impl{PDMIOAPICHLPRC,pfnApicBusDeliver} */
static DECLCALLBACK(int) pdmRCIoApicHlp_ApicBusDeliver(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
{
LogFlow(("pdmRCIoApicHlp_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.pfnBusDeliverRC(pVM->pdm.s.Apic.pDevInsRC, u8Dest, u8DestMode, u8DeliveryMode, iVector,
return VINF_SUCCESS;
}
/** @interface_method_impl{PDMIOAPICHLPRC,pfnLock} */
{
}
/** @interface_method_impl{PDMIOAPICHLPRC,pfnUnlock} */
{
}
/**
* The Raw-Mode Context I/O APIC Helper Callbacks.
*/
{
};
/** @} */
/** @name PCI Bus RC Helpers
* @{
*/
/** @interface_method_impl{PDMPCIHLPRC,pfnIsaSetIrq} */
static DECLCALLBACK(void) pdmRCPciHlp_IsaSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc)
{
}
/** @interface_method_impl{PDMPCIHLPRC,pfnIoApicSetIrq} */
static DECLCALLBACK(void) pdmRCPciHlp_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{PDMPCIHLPRC,pfnIoApicSendMsi} */
static DECLCALLBACK(void) pdmRCPciHlp_IoApicSendMsi(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t uValue, uint32_t uTagSrc)
{
{
}
else
{
AssertFatalMsgFailed(("Lazy bastarts!"));
}
}
/** @interface_method_impl{PDMPCIHLPRC,pfnLock} */
{
}
/** @interface_method_impl{PDMPCIHLPRC,pfnUnlock} */
{
}
/**
* The Raw-Mode Context PCI Bus Helper Callbacks.
*/
{
PDM_PCIHLPRC_VERSION, /* the end */
};
/** @} */
/** @name HPET RC Helpers
* @{
*/
/**
* The Raw-Mode Context HPET Helper Callbacks.
*/
{
PDM_HPETHLPRC_VERSION, /* the end */
};
/** @} */
/** @name Raw-Mode Context Driver Helpers
* @{
*/
/** @interface_method_impl{PDMDRVHLPRC,pfnVMSetError} */
static DECLCALLBACK(int) pdmRCDrvHlp_VMSetError(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
{
int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMRC, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
return rc;
}
/** @interface_method_impl{PDMDRVHLPRC,pfnVMSetErrorV} */
static DECLCALLBACK(int) pdmRCDrvHlp_VMSetErrorV(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
{
int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMRC, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
return rc;
}
/** @interface_method_impl{PDMDRVHLPRC,pfnVMSetRuntimeError} */
static DECLCALLBACK(int) pdmRCDrvHlp_VMSetRuntimeError(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
{
return rc;
}
/** @interface_method_impl{PDMDRVHLPRC,pfnVMSetErrorV} */
static DECLCALLBACK(int) pdmRCDrvHlp_VMSetRuntimeErrorV(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
{
return rc;
}
/** @interface_method_impl{PDMDRVHLPRC,pfnAssertEMT} */
static DECLCALLBACK(bool) pdmRCDrvHlp_AssertEMT(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
{
return true;
return false;
}
/** @interface_method_impl{PDMDRVHLPRC,pfnAssertOther} */
static DECLCALLBACK(bool) pdmRCDrvHlp_AssertOther(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
{
return true;
/* Note: While we don't have any other threads but EMT(0) in RC, might
still have drive code compiled in which it shouldn't execute. */
return false;
}
/** @interface_method_impl{PDMDRVHLPRC,pfnFTSetCheckpoint} */
{
}
/**
* The Raw-Mode 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;
}