PDMGCDevice.cpp revision 17c6e5e8177d068d1bc6af875d1610718efcfdb4
d29b2c4438482eb00488be49a1f5d6835f455546ab/* $Id$ */
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @file
d29b2c4438482eb00488be49a1f5d6835f455546ab * PDM - Pluggable Device and Driver Manager, GC Device parts.
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/*
d29b2c4438482eb00488be49a1f5d6835f455546ab * Copyright (C) 2006-2007 Sun Microsystems, Inc.
d29b2c4438482eb00488be49a1f5d6835f455546ab *
d29b2c4438482eb00488be49a1f5d6835f455546ab * This file is part of VirtualBox Open Source Edition (OSE), as
d29b2c4438482eb00488be49a1f5d6835f455546ab * available from http://www.virtualbox.org. This file is free software;
d29b2c4438482eb00488be49a1f5d6835f455546ab * you can redistribute it and/or modify it under the terms of the GNU
d29b2c4438482eb00488be49a1f5d6835f455546ab * General Public License (GPL) as published by the Free Software
d29b2c4438482eb00488be49a1f5d6835f455546ab * Foundation, in version 2 as it comes in the "COPYING" file of the
d29b2c4438482eb00488be49a1f5d6835f455546ab * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
d29b2c4438482eb00488be49a1f5d6835f455546ab * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
d29b2c4438482eb00488be49a1f5d6835f455546ab *
d29b2c4438482eb00488be49a1f5d6835f455546ab * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
d29b2c4438482eb00488be49a1f5d6835f455546ab * Clara, CA 95054 USA or visit http://www.sun.com if you need
d29b2c4438482eb00488be49a1f5d6835f455546ab * additional information or have any questions.
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
69112edd987c28fa551d4f8d9362a84a45365f17Ali Bahrami/*******************************************************************************
d29b2c4438482eb00488be49a1f5d6835f455546ab* Header Files *
d29b2c4438482eb00488be49a1f5d6835f455546ab*******************************************************************************/
d29b2c4438482eb00488be49a1f5d6835f455546ab#define LOG_GROUP LOG_GROUP_PDM_DEVICE
d29b2c4438482eb00488be49a1f5d6835f455546ab#include "PDMInternal.h"
d29b2c4438482eb00488be49a1f5d6835f455546ab#include <VBox/pdm.h>
d29b2c4438482eb00488be49a1f5d6835f455546ab#include <VBox/pgm.h>
d29b2c4438482eb00488be49a1f5d6835f455546ab#include <VBox/mm.h>
d29b2c4438482eb00488be49a1f5d6835f455546ab#include <VBox/vm.h>
d29b2c4438482eb00488be49a1f5d6835f455546ab#include <VBox/patm.h>
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab#include <VBox/log.h>
d29b2c4438482eb00488be49a1f5d6835f455546ab#include <VBox/err.h>
d29b2c4438482eb00488be49a1f5d6835f455546ab#include <iprt/asm.h>
d29b2c4438482eb00488be49a1f5d6835f455546ab#include <iprt/assert.h>
d29b2c4438482eb00488be49a1f5d6835f455546ab#include <iprt/string.h>
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/*******************************************************************************
d29b2c4438482eb00488be49a1f5d6835f455546ab* Global Variables *
d29b2c4438482eb00488be49a1f5d6835f455546ab*******************************************************************************/
d29b2c4438482eb00488be49a1f5d6835f455546ab__BEGIN_DECLS
d29b2c4438482eb00488be49a1f5d6835f455546abextern DECLEXPORT(const PDMDEVHLPRC) g_pdmRCDevHlp;
d29b2c4438482eb00488be49a1f5d6835f455546abextern DECLEXPORT(const PDMPICHLPRC) g_pdmRCPicHlp;
d29b2c4438482eb00488be49a1f5d6835f455546abextern DECLEXPORT(const PDMAPICHLPRC) g_pdmRCApicHlp;
d29b2c4438482eb00488be49a1f5d6835f455546abextern DECLEXPORT(const PDMIOAPICHLPRC) g_pdmRCIoApicHlp;
d29b2c4438482eb00488be49a1f5d6835f455546abextern DECLEXPORT(const PDMPCIHLPRC) g_pdmRCPciHlp;
d29b2c4438482eb00488be49a1f5d6835f455546ab__END_DECLS
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/*******************************************************************************
d29b2c4438482eb00488be49a1f5d6835f455546ab* Internal Functions *
d29b2c4438482eb00488be49a1f5d6835f455546ab*******************************************************************************/
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @name GC Device Helpers
d29b2c4438482eb00488be49a1f5d6835f455546ab * @{
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmGCDevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmGCDevHlp_ISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(bool) pdmGCDevHlp_A20IsEnabled(PPDMDEVINS pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_VMSetErrorV(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_VMSetRuntimeError(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_VMSetRuntimeErrorV(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list va);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_PATMSetMMIOPatchInfo(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(PVM) pdmGCDevHlp_GetVM(PPDMDEVINS pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @} */
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @name PIC GC Helpers
d29b2c4438482eb00488be49a1f5d6835f455546ab * @{
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCPicHlp_SetInterruptFF(PPDMDEVINS pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCPicHlp_ClearInterruptFF(PPDMDEVINS pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmRCPicHlp_Lock(PPDMDEVINS pDevIns, int rc);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCPicHlp_Unlock(PPDMDEVINS pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @} */
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @name APIC RC Helpers
d29b2c4438482eb00488be49a1f5d6835f455546ab * @{
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCApicHlp_SetInterruptFF(PPDMDEVINS pDevIns, VMCPUID idCpu);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCApicHlp_ClearInterruptFF(PPDMDEVINS pDevIns, VMCPUID idCpu);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCApicHlp_ChangeFeature(PPDMDEVINS pDevIns, PDMAPICVERSION enmVersion);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmRCApicHlp_Lock(PPDMDEVINS pDevIns, int rc);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCApicHlp_Unlock(PPDMDEVINS pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(VMCPUID) pdmRCApicHlp_GetCpuId(PPDMDEVINS pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @} */
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @name I/O APIC RC Helpers
d29b2c4438482eb00488be49a1f5d6835f455546ab * @{
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCIoApicHlp_ApicBusDeliver(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
d29b2c4438482eb00488be49a1f5d6835f455546ab uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmRCIoApicHlp_Lock(PPDMDEVINS pDevIns, int rc);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCIoApicHlp_Unlock(PPDMDEVINS pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @} */
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @name PCI Bus RC Helpers
d29b2c4438482eb00488be49a1f5d6835f455546ab * @{
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCPciHlp_IsaSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCPciHlp_IoApicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmRCPciHlp_Lock(PPDMDEVINS pDevIns, int rc);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCPciHlp_Unlock(PPDMDEVINS pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @} */
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546abstatic void pdmGCIsaSetIrq(PVM pVM, int iIrq, int iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546abstatic void pdmGCIoApicSetIrq(PVM pVM, int iIrq, int iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/**
d29b2c4438482eb00488be49a1f5d6835f455546ab * The Guest Context Device Helper Callbacks.
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546abextern DECLEXPORT(const PDMDEVHLPRC) g_pdmRCDevHlp =
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDM_DEVHLPRC_VERSION,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCDevHlp_PCISetIrq,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCDevHlp_ISASetIrq,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCDevHlp_PhysRead,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCDevHlp_PhysWrite,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCDevHlp_A20IsEnabled,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCDevHlp_VMSetError,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCDevHlp_VMSetErrorV,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCDevHlp_VMSetRuntimeError,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCDevHlp_VMSetRuntimeErrorV,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCDevHlp_PATMSetMMIOPatchInfo,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCDevHlp_GetVM,
d29b2c4438482eb00488be49a1f5d6835f455546ab PDM_DEVHLPRC_VERSION
d29b2c4438482eb00488be49a1f5d6835f455546ab};
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/**
d29b2c4438482eb00488be49a1f5d6835f455546ab * The Raw-Mode Context PIC Helper Callbacks.
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546abextern DECLEXPORT(const PDMPICHLPRC) g_pdmRCPicHlp =
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDM_PICHLPRC_VERSION,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCPicHlp_SetInterruptFF,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCPicHlp_ClearInterruptFF,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCPicHlp_Lock,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCPicHlp_Unlock,
d29b2c4438482eb00488be49a1f5d6835f455546ab PDM_PICHLPRC_VERSION
d29b2c4438482eb00488be49a1f5d6835f455546ab};
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/**
d29b2c4438482eb00488be49a1f5d6835f455546ab * The Raw-Mode Context APIC Helper Callbacks.
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546abextern DECLEXPORT(const PDMAPICHLPRC) g_pdmRCApicHlp =
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDM_APICHLPRC_VERSION,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCApicHlp_SetInterruptFF,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCApicHlp_ClearInterruptFF,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCApicHlp_ChangeFeature,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCApicHlp_Lock,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCApicHlp_Unlock,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCApicHlp_GetCpuId,
d29b2c4438482eb00488be49a1f5d6835f455546ab PDM_APICHLPRC_VERSION
d29b2c4438482eb00488be49a1f5d6835f455546ab};
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/**
d29b2c4438482eb00488be49a1f5d6835f455546ab * The Raw-Mode Context I/O APIC Helper Callbacks.
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546abextern DECLEXPORT(const PDMIOAPICHLPRC) g_pdmRCIoApicHlp =
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDM_IOAPICHLPRC_VERSION,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCIoApicHlp_ApicBusDeliver,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCIoApicHlp_Lock,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCIoApicHlp_Unlock,
d29b2c4438482eb00488be49a1f5d6835f455546ab PDM_IOAPICHLPRC_VERSION
d29b2c4438482eb00488be49a1f5d6835f455546ab};
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/**
d29b2c4438482eb00488be49a1f5d6835f455546ab * The Raw-Mode Context PCI Bus Helper Callbacks.
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546abextern DECLEXPORT(const PDMPCIHLPRC) g_pdmRCPciHlp =
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDM_PCIHLPRC_VERSION,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCPciHlp_IsaSetIrq,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCPciHlp_IoApicSetIrq,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCPciHlp_Lock,
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmRCPciHlp_Unlock,
d29b2c4438482eb00488be49a1f5d6835f455546ab PDM_PCIHLPRC_VERSION, /* the end */
d29b2c4438482eb00488be49a1f5d6835f455546ab};
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMDEVHLPRC::pfnPCISetIrq */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmGCDevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmGCDevHlp_PCISetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab PVM pVM = pDevIns->Internal.s.pVMRC;
d29b2c4438482eb00488be49a1f5d6835f455546ab PPCIDEVICE pPciDev = pDevIns->Internal.s.pPciDeviceRC;
d29b2c4438482eb00488be49a1f5d6835f455546ab PPDMPCIBUS pPciBus = pDevIns->Internal.s.pPciBusRC;
d29b2c4438482eb00488be49a1f5d6835f455546ab if ( pPciDev
d29b2c4438482eb00488be49a1f5d6835f455546ab && pPciBus
d29b2c4438482eb00488be49a1f5d6835f455546ab && pPciBus->pDevInsRC)
d29b2c4438482eb00488be49a1f5d6835f455546ab {
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmLock(pVM);
d29b2c4438482eb00488be49a1f5d6835f455546ab pPciBus->pfnSetIrqRC(pPciBus->pDevInsRC, pPciDev, iIrq, iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmUnlock(pVM);
d29b2c4438482eb00488be49a1f5d6835f455546ab }
d29b2c4438482eb00488be49a1f5d6835f455546ab else
d29b2c4438482eb00488be49a1f5d6835f455546ab {
d29b2c4438482eb00488be49a1f5d6835f455546ab /* queue for ring-3 execution. */
d29b2c4438482eb00488be49a1f5d6835f455546ab PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pVM->pdm.s.pDevHlpQueueRC);
d29b2c4438482eb00488be49a1f5d6835f455546ab if (pTask)
d29b2c4438482eb00488be49a1f5d6835f455546ab {
d29b2c4438482eb00488be49a1f5d6835f455546ab pTask->enmOp = PDMDEVHLPTASKOP_PCI_SET_IRQ;
d29b2c4438482eb00488be49a1f5d6835f455546ab pTask->pDevInsR3 = PDMDEVINS_2_R3PTR(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab pTask->u.SetIRQ.iIrq = iIrq;
d29b2c4438482eb00488be49a1f5d6835f455546ab pTask->u.SetIRQ.iLevel = iLevel;
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMQueueInsertEx(pVM->pdm.s.pDevHlpQueueRC, &pTask->Core, 0);
d29b2c4438482eb00488be49a1f5d6835f455546ab }
d29b2c4438482eb00488be49a1f5d6835f455546ab else
d29b2c4438482eb00488be49a1f5d6835f455546ab AssertMsgFailed(("We're out of devhlp queue items!!!\n"));
d29b2c4438482eb00488be49a1f5d6835f455546ab }
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmGCDevHlp_PCISetIrq: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMDEVHLPRC::pfnPCISetIrq */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmGCDevHlp_ISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmGCDevHlp_ISASetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCIsaSetIrq(pDevIns->Internal.s.pVMRC, iIrq, iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmGCDevHlp_ISASetIrq: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMDEVHLPRC::pfnPhysRead */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmGCDevHlp_PhysRead: caller=%p/%d: GCPhys=%RGp pvBuf=%p cbRead=%#x\n",
d29b2c4438482eb00488be49a1f5d6835f455546ab pDevIns, pDevIns->iInstance, GCPhys, pvBuf, cbRead));
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab#ifdef VBOX_WITH_NEW_PHYS_CODE
d29b2c4438482eb00488be49a1f5d6835f455546ab int rc = PGMPhysRead(pDevIns->Internal.s.pVMRC, GCPhys, pvBuf, cbRead);
d29b2c4438482eb00488be49a1f5d6835f455546ab AssertRC(rc); /** @todo track down the users for this bugger. */
d29b2c4438482eb00488be49a1f5d6835f455546ab#else
d29b2c4438482eb00488be49a1f5d6835f455546ab PGMPhysRead(pDevIns->Internal.s.pVMRC, GCPhys, pvBuf, cbRead);
d29b2c4438482eb00488be49a1f5d6835f455546ab int rc = VINF_SUCCESS;
d29b2c4438482eb00488be49a1f5d6835f455546ab#endif
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab Log(("pdmGCDevHlp_PhysRead: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc));
d29b2c4438482eb00488be49a1f5d6835f455546ab return rc;
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMDEVHLPRC::pfnPhysWrite */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmGCDevHlp_PhysWrite: caller=%p/%d: GCPhys=%RGp pvBuf=%p cbWrite=%#x\n",
d29b2c4438482eb00488be49a1f5d6835f455546ab pDevIns, pDevIns->iInstance, GCPhys, pvBuf, cbWrite));
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab#ifdef VBOX_WITH_NEW_PHYS_CODE
d29b2c4438482eb00488be49a1f5d6835f455546ab int rc = PGMPhysWrite(pDevIns->Internal.s.pVMRC, GCPhys, pvBuf, cbWrite);
d29b2c4438482eb00488be49a1f5d6835f455546ab AssertRC(rc); /** @todo track down the users for this bugger. */
d29b2c4438482eb00488be49a1f5d6835f455546ab#else
d29b2c4438482eb00488be49a1f5d6835f455546ab PGMPhysWrite(pDevIns->Internal.s.pVMRC, GCPhys, pvBuf, cbWrite);
d29b2c4438482eb00488be49a1f5d6835f455546ab int rc = VINF_SUCCESS;
d29b2c4438482eb00488be49a1f5d6835f455546ab#endif
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab Log(("pdmGCDevHlp_PhysWrite: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc));
d29b2c4438482eb00488be49a1f5d6835f455546ab return rc;
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMDEVHLPRC::pfnA20IsEnabled */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(bool) pdmGCDevHlp_A20IsEnabled(PPDMDEVINS pDevIns)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmGCDevHlp_A20IsEnabled: caller=%p/%d:\n", pDevIns, pDevIns->iInstance));
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab bool fEnabled = PGMPhysIsA20Enabled(pDevIns->Internal.s.pVMRC);
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab Log(("pdmGCDevHlp_A20IsEnabled: caller=%p/%d: returns %RTbool\n", pDevIns, pDevIns->iInstance, fEnabled));
d29b2c4438482eb00488be49a1f5d6835f455546ab return fEnabled;
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMDEVHLPRC::pfnVMSetError */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab va_list args;
d29b2c4438482eb00488be49a1f5d6835f455546ab va_start(args, pszFormat);
d29b2c4438482eb00488be49a1f5d6835f455546ab int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMRC, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
d29b2c4438482eb00488be49a1f5d6835f455546ab va_end(args);
d29b2c4438482eb00488be49a1f5d6835f455546ab return rc;
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMDEVHLPRC::pfnVMSetErrorV */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_VMSetErrorV(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMRC, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
d29b2c4438482eb00488be49a1f5d6835f455546ab return rc;
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMDEVHLPRC::pfnVMSetRuntimeError */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_VMSetRuntimeError(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab va_list args;
d29b2c4438482eb00488be49a1f5d6835f455546ab va_start(args, pszFormat);
d29b2c4438482eb00488be49a1f5d6835f455546ab int rc = VMSetRuntimeErrorV(pDevIns->Internal.s.pVMRC, fFatal, pszErrorID, pszFormat, args);
d29b2c4438482eb00488be49a1f5d6835f455546ab va_end(args);
d29b2c4438482eb00488be49a1f5d6835f455546ab return rc;
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMDEVHLPRC::pfnVMSetErrorV */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_VMSetRuntimeErrorV(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list va)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab int rc = VMSetRuntimeErrorV(pDevIns->Internal.s.pVMRC, fFatal, pszErrorID, pszFormat, va);
d29b2c4438482eb00488be49a1f5d6835f455546ab return rc;
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMDEVHLPRC::pfnPATMSetMMIOPatchInfo */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmGCDevHlp_PATMSetMMIOPatchInfo(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmGCDevHlp_PATMSetMMIOPatchInfo: caller=%p/%d:\n", pDevIns, pDevIns->iInstance));
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab return PATMSetMMIOPatchInfo(pDevIns->Internal.s.pVMRC, GCPhys, (RTRCPTR)pCachedData);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMDEVHLPRC::pfnGetVM */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(PVM) pdmGCDevHlp_GetVM(PPDMDEVINS pDevIns)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmGCDevHlp_GetVM: caller='%p'/%d\n", pDevIns, pDevIns->iInstance));
d29b2c4438482eb00488be49a1f5d6835f455546ab return pDevIns->Internal.s.pVMRC;
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMPICHLPGC::pfnSetInterruptFF */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCPicHlp_SetInterruptFF(PPDMDEVINS pDevIns)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmRCPicHlp_SetInterruptFF: caller=%p/%d: VM_FF_INTERRUPT_PIC %d -> 1\n",
d29b2c4438482eb00488be49a1f5d6835f455546ab pDevIns, pDevIns->iInstance, VMCPU_FF_ISSET(pDevIns->Internal.s.pVMRC, 0, VM_FF_INTERRUPT_PIC)));
d29b2c4438482eb00488be49a1f5d6835f455546ab /* for PIC we always deliver to CPU 0, MP use APIC */
d29b2c4438482eb00488be49a1f5d6835f455546ab VMCPU_FF_SET(pDevIns->Internal.s.pVMRC, 0, VM_FF_INTERRUPT_PIC);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMPICHLPGC::pfnClearInterruptFF */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCPicHlp_ClearInterruptFF(PPDMDEVINS pDevIns)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmRCPicHlp_ClearInterruptFF: caller=%p/%d: VM_FF_INTERRUPT_PIC %d -> 0\n",
d29b2c4438482eb00488be49a1f5d6835f455546ab pDevIns, pDevIns->iInstance, VMCPU_FF_ISSET(pDevIns->Internal.s.pVMRC, 0, VM_FF_INTERRUPT_PIC)));
d29b2c4438482eb00488be49a1f5d6835f455546ab /* for PIC we always deliver to CPU 0, MP use APIC */
d29b2c4438482eb00488be49a1f5d6835f455546ab VMCPU_FF_CLEAR(pDevIns->Internal.s.pVMRC, 0, VM_FF_INTERRUPT_PIC);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMPICHLPGC::pfnLock */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmRCPicHlp_Lock(PPDMDEVINS pDevIns, int rc)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab return pdmLockEx(pDevIns->Internal.s.pVMRC, rc);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMPICHLPGC::pfnUnlock */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCPicHlp_Unlock(PPDMDEVINS pDevIns)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmUnlock(pDevIns->Internal.s.pVMRC);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMAPICHLPRC::pfnSetInterruptFF */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCApicHlp_SetInterruptFF(PPDMDEVINS pDevIns, VMCPUID idCpu)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmRCApicHlp_SetInterruptFF: caller=%p/%d: VM_FF_INTERRUPT %d -> 1\n",
d29b2c4438482eb00488be49a1f5d6835f455546ab pDevIns, pDevIns->iInstance, VMCPU_FF_ISSET(pDevIns->Internal.s.pVMRC, idCpu, VM_FF_INTERRUPT_APIC)));
d29b2c4438482eb00488be49a1f5d6835f455546ab VMCPU_FF_SET(pDevIns->Internal.s.pVMRC, idCpu, VM_FF_INTERRUPT_APIC);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMAPICHLPRC::pfnClearInterruptFF */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCApicHlp_ClearInterruptFF(PPDMDEVINS pDevIns, VMCPUID idCpu)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmRCApicHlp_ClearInterruptFF: caller=%p/%d: VM_FF_INTERRUPT %d -> 0\n",
d29b2c4438482eb00488be49a1f5d6835f455546ab pDevIns, pDevIns->iInstance, VMCPU_FF_ISSET(pDevIns->Internal.s.pVMRC, idCpu, VM_FF_INTERRUPT_APIC)));
d29b2c4438482eb00488be49a1f5d6835f455546ab VMCPU_FF_CLEAR(pDevIns->Internal.s.pVMRC, idCpu, VM_FF_INTERRUPT_APIC);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMAPICHLPRC::pfnChangeFeature */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCApicHlp_ChangeFeature(PPDMDEVINS pDevIns, PDMAPICVERSION enmVersion)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmRCApicHlp_ChangeFeature: caller=%p/%d: version=%d\n", pDevIns, pDevIns->iInstance, (int)enmVersion));
d29b2c4438482eb00488be49a1f5d6835f455546ab switch (enmVersion)
d29b2c4438482eb00488be49a1f5d6835f455546ab {
d29b2c4438482eb00488be49a1f5d6835f455546ab case PDMAPICVERSION_NONE:
d29b2c4438482eb00488be49a1f5d6835f455546ab CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMRC, CPUMCPUIDFEATURE_APIC);
d29b2c4438482eb00488be49a1f5d6835f455546ab CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMRC, CPUMCPUIDFEATURE_X2APIC);
d29b2c4438482eb00488be49a1f5d6835f455546ab break;
d29b2c4438482eb00488be49a1f5d6835f455546ab case PDMAPICVERSION_APIC:
d29b2c4438482eb00488be49a1f5d6835f455546ab CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMRC, CPUMCPUIDFEATURE_APIC);
d29b2c4438482eb00488be49a1f5d6835f455546ab CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMRC, CPUMCPUIDFEATURE_X2APIC);
d29b2c4438482eb00488be49a1f5d6835f455546ab break;
d29b2c4438482eb00488be49a1f5d6835f455546ab case PDMAPICVERSION_X2APIC:
d29b2c4438482eb00488be49a1f5d6835f455546ab CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMRC, CPUMCPUIDFEATURE_X2APIC);
d29b2c4438482eb00488be49a1f5d6835f455546ab CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMRC, CPUMCPUIDFEATURE_APIC);
d29b2c4438482eb00488be49a1f5d6835f455546ab break;
d29b2c4438482eb00488be49a1f5d6835f455546ab default:
d29b2c4438482eb00488be49a1f5d6835f455546ab AssertMsgFailed(("Unknown APIC version: %d\n", (int)enmVersion));
d29b2c4438482eb00488be49a1f5d6835f455546ab }
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMAPICHLPRC::pfnLock */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmRCApicHlp_Lock(PPDMDEVINS pDevIns, int rc)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab return pdmLockEx(pDevIns->Internal.s.pVMRC, rc);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMAPICHLPRC::pfnUnlock */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCApicHlp_Unlock(PPDMDEVINS pDevIns)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmUnlock(pDevIns->Internal.s.pVMRC);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMAPICHLPRC::pfnGetCpuId */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(VMCPUID) pdmRCApicHlp_GetCpuId(PPDMDEVINS pDevIns)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab return VMMGetCpuId(pDevIns->Internal.s.pVMRC);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMIOAPICHLPRC::pfnApicBusDeliver */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCIoApicHlp_ApicBusDeliver(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
d29b2c4438482eb00488be49a1f5d6835f455546ab uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab PVM pVM = pDevIns->Internal.s.pVMRC;
d29b2c4438482eb00488be49a1f5d6835f455546ab LogFlow(("pdmRCIoApicHlp_ApicBusDeliver: caller=%p/%d: u8Dest=%RX8 u8DestMode=%RX8 u8DeliveryMode=%RX8 iVector=%RX8 u8Polarity=%RX8 u8TriggerMode=%RX8\n",
d29b2c4438482eb00488be49a1f5d6835f455546ab pDevIns, pDevIns->iInstance, u8Dest, u8DestMode, u8DeliveryMode, iVector, u8Polarity, u8TriggerMode));
d29b2c4438482eb00488be49a1f5d6835f455546ab if (pVM->pdm.s.Apic.pfnBusDeliverRC)
d29b2c4438482eb00488be49a1f5d6835f455546ab pVM->pdm.s.Apic.pfnBusDeliverRC(pVM->pdm.s.Apic.pDevInsRC, u8Dest, u8DestMode, u8DeliveryMode, iVector, u8Polarity, u8TriggerMode);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMIOAPICHLPRC::pfnLock */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmRCIoApicHlp_Lock(PPDMDEVINS pDevIns, int rc)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab return pdmLockEx(pDevIns->Internal.s.pVMRC, rc);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMIOAPICHLPRC::pfnUnlock */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCIoApicHlp_Unlock(PPDMDEVINS pDevIns)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmUnlock(pDevIns->Internal.s.pVMRC);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMPCIHLPRC::pfnIsaSetIrq */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCPciHlp_IsaSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab Log4(("pdmRCPciHlp_IsaSetIrq: iIrq=%d iLevel=%d\n", iIrq, iLevel));
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCIsaSetIrq(pDevIns->Internal.s.pVMRC, iIrq, iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMPCIHLPRC::pfnIoApicSetIrq */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCPciHlp_IoApicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab Log4(("pdmRCPciHlp_IsaSetIrq: iIrq=%d iLevel=%d\n", iIrq, iLevel));
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmGCIoApicSetIrq(pDevIns->Internal.s.pVMRC, iIrq, iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMPCIHLPRC::pfnLock */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(int) pdmRCPciHlp_Lock(PPDMDEVINS pDevIns, int rc)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab return pdmLockEx(pDevIns->Internal.s.pVMRC, rc);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/** @copydoc PDMPCIHLPRC::pfnUnlock */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic DECLCALLBACK(void) pdmRCPciHlp_Unlock(PPDMDEVINS pDevIns)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMDEV_ASSERT_DEVINS(pDevIns);
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmUnlock(pDevIns->Internal.s.pVMRC);
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/**
d29b2c4438482eb00488be49a1f5d6835f455546ab * Sets an irq on the I/O APIC.
d29b2c4438482eb00488be49a1f5d6835f455546ab *
d29b2c4438482eb00488be49a1f5d6835f455546ab * @param pVM The VM handle.
d29b2c4438482eb00488be49a1f5d6835f455546ab * @param iIrq The irq.
d29b2c4438482eb00488be49a1f5d6835f455546ab * @param iLevel The new level.
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic void pdmGCIsaSetIrq(PVM pVM, int iIrq, int iLevel)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab if ( ( pVM->pdm.s.IoApic.pDevInsRC
d29b2c4438482eb00488be49a1f5d6835f455546ab || !pVM->pdm.s.IoApic.pDevInsR3)
d29b2c4438482eb00488be49a1f5d6835f455546ab && ( pVM->pdm.s.Pic.pDevInsRC
d29b2c4438482eb00488be49a1f5d6835f455546ab || !pVM->pdm.s.Pic.pDevInsR3))
d29b2c4438482eb00488be49a1f5d6835f455546ab {
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmLock(pVM);
d29b2c4438482eb00488be49a1f5d6835f455546ab if (pVM->pdm.s.Pic.pDevInsRC)
d29b2c4438482eb00488be49a1f5d6835f455546ab pVM->pdm.s.Pic.pfnSetIrqRC(pVM->pdm.s.Pic.pDevInsRC, iIrq, iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546ab if (pVM->pdm.s.IoApic.pDevInsRC)
d29b2c4438482eb00488be49a1f5d6835f455546ab pVM->pdm.s.IoApic.pfnSetIrqRC(pVM->pdm.s.IoApic.pDevInsRC, iIrq, iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmUnlock(pVM);
d29b2c4438482eb00488be49a1f5d6835f455546ab }
d29b2c4438482eb00488be49a1f5d6835f455546ab else
d29b2c4438482eb00488be49a1f5d6835f455546ab {
d29b2c4438482eb00488be49a1f5d6835f455546ab /* queue for ring-3 execution. */
d29b2c4438482eb00488be49a1f5d6835f455546ab PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pVM->pdm.s.pDevHlpQueueRC);
d29b2c4438482eb00488be49a1f5d6835f455546ab if (pTask)
d29b2c4438482eb00488be49a1f5d6835f455546ab {
d29b2c4438482eb00488be49a1f5d6835f455546ab pTask->enmOp = PDMDEVHLPTASKOP_ISA_SET_IRQ;
d29b2c4438482eb00488be49a1f5d6835f455546ab pTask->pDevInsR3 = NIL_RTR3PTR; /* not required */
d29b2c4438482eb00488be49a1f5d6835f455546ab pTask->u.SetIRQ.iIrq = iIrq;
d29b2c4438482eb00488be49a1f5d6835f455546ab pTask->u.SetIRQ.iLevel = iLevel;
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab PDMQueueInsertEx(pVM->pdm.s.pDevHlpQueueRC, &pTask->Core, 0);
d29b2c4438482eb00488be49a1f5d6835f455546ab }
d29b2c4438482eb00488be49a1f5d6835f455546ab else
d29b2c4438482eb00488be49a1f5d6835f455546ab AssertMsgFailed(("We're out of devhlp queue items!!!\n"));
d29b2c4438482eb00488be49a1f5d6835f455546ab }
d29b2c4438482eb00488be49a1f5d6835f455546ab}
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab
d29b2c4438482eb00488be49a1f5d6835f455546ab/**
d29b2c4438482eb00488be49a1f5d6835f455546ab * Sets an irq on the I/O APIC.
d29b2c4438482eb00488be49a1f5d6835f455546ab *
d29b2c4438482eb00488be49a1f5d6835f455546ab * @param pVM The VM handle.
d29b2c4438482eb00488be49a1f5d6835f455546ab * @param iIrq The irq.
d29b2c4438482eb00488be49a1f5d6835f455546ab * @param iLevel The new level.
d29b2c4438482eb00488be49a1f5d6835f455546ab */
d29b2c4438482eb00488be49a1f5d6835f455546abstatic void pdmGCIoApicSetIrq(PVM pVM, int iIrq, int iLevel)
d29b2c4438482eb00488be49a1f5d6835f455546ab{
d29b2c4438482eb00488be49a1f5d6835f455546ab if (pVM->pdm.s.IoApic.pDevInsRC)
d29b2c4438482eb00488be49a1f5d6835f455546ab {
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmLock(pVM);
d29b2c4438482eb00488be49a1f5d6835f455546ab pVM->pdm.s.IoApic.pfnSetIrqRC(pVM->pdm.s.IoApic.pDevInsRC, iIrq, iLevel);
d29b2c4438482eb00488be49a1f5d6835f455546ab pdmUnlock(pVM);
d29b2c4438482eb00488be49a1f5d6835f455546ab }
d29b2c4438482eb00488be49a1f5d6835f455546ab else if (pVM->pdm.s.IoApic.pDevInsR3)
d29b2c4438482eb00488be49a1f5d6835f455546ab {
cce0e03bb2d07f0fe27cabb93acae9c23655859fab /* queue for ring-3 execution. */
cce0e03bb2d07f0fe27cabb93acae9c23655859fab PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pVM->pdm.s.pDevHlpQueueRC);
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab if (pTask)
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab {
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab pTask->enmOp = PDMDEVHLPTASKOP_IOAPIC_SET_IRQ;
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab pTask->pDevInsR3 = NIL_RTR3PTR; /* not required */
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab pTask->u.SetIRQ.iIrq = iIrq;
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab pTask->u.SetIRQ.iLevel = iLevel;
cce0e03bb2d07f0fe27cabb93acae9c23655859fab
cce0e03bb2d07f0fe27cabb93acae9c23655859fab PDMQueueInsertEx(pVM->pdm.s.pDevHlpQueueRC, &pTask->Core, 0);
cce0e03bb2d07f0fe27cabb93acae9c23655859fab }
cce0e03bb2d07f0fe27cabb93acae9c23655859fab else
cce0e03bb2d07f0fe27cabb93acae9c23655859fab AssertMsgFailed(("We're out of devhlp queue items!!!\n"));
cce0e03bb2d07f0fe27cabb93acae9c23655859fab }
cce0e03bb2d07f0fe27cabb93acae9c23655859fab}
cce0e03bb2d07f0fe27cabb93acae9c23655859fab