PDMR0Device.cpp revision c50100d1513854735d4e3593b3b385c007f6d8b6
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/* $Id$ */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @file
c97989161fbe75bc14cea477a5443bbf474dd3advboxsync * PDM - Pluggable Device and Driver Manager, R0 Device parts.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/*
c97989161fbe75bc14cea477a5443bbf474dd3advboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * available from http://www.virtualbox.org. This file is free software;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * General Public License (GPL) as published by the Free Software
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
cf57145d4697dceca3f0542b370c20f7a2c5c6e8vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
cf57145d4697dceca3f0542b370c20f7a2c5c6e8vboxsync * additional information or have any questions.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
881b5ff6bc55e1fb0f4ef42f9782ccec79c0a138vboxsync/*******************************************************************************
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync* Header Files *
833f83ce101b6e9168f519decc0dc7a1079d35f7vboxsync*******************************************************************************/
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#define LOG_GROUP LOG_GROUP_PDM_DEVICE
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include "PDMInternal.h"
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include <VBox/pdm.h>
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include <VBox/pgm.h>
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include <VBox/mm.h>
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include <VBox/vm.h>
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include <VBox/patm.h>
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include <VBox/log.h>
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include <VBox/err.h>
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include <iprt/asm.h>
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include <iprt/assert.h>
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#include <iprt/string.h>
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/*******************************************************************************
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync* Defined Constants And Macros *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync*******************************************************************************/
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @def PDMDEV_ASSERT_DEVINS
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * Asserts the validity of the driver instance.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#ifdef VBOX_STRICT
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync# define PDMDEV_ASSERT_DEVINS(pDevIns) do { Assert(VALID_PTR(pDevIns)); \
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync Assert(pDevIns->u32Version == PDM_DEVINS_VERSION); \
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync Assert(pDevIns->pvInstanceDataR0 == (void *)&pDevIns->achInstanceData[0]); \
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync } while (0)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#else
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync# define PDMDEV_ASSERT_DEVINS(pDevIns) do { } while (0)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync#endif
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
c5d2523548cc57504b829f53f1362b848a84542cvboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/*******************************************************************************
c5d2523548cc57504b829f53f1362b848a84542cvboxsync* Global Variables *
c5d2523548cc57504b829f53f1362b848a84542cvboxsync*******************************************************************************/
c5d2523548cc57504b829f53f1362b848a84542cvboxsync__BEGIN_DECLS
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncextern DECLEXPORT(const PDMDEVHLPR0) g_pdmR0DevHlp;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncextern DECLEXPORT(const PDMPICHLPR0) g_pdmR0PicHlp;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncextern DECLEXPORT(const PDMAPICHLPR0) g_pdmR0ApicHlp;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncextern DECLEXPORT(const PDMIOAPICHLPR0) g_pdmR0IoApicHlp;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncextern DECLEXPORT(const PDMPCIHLPR0) g_pdmR0PciHlp;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync__END_DECLS
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/*******************************************************************************
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync* Internal Functions *
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync*******************************************************************************/
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @name GC Device Helpers
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0DevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0DevHlp_ISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(bool) pdmR0DevHlp_A20IsEnabled(PPDMDEVINS pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_VMSetErrorV(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_VMSetRuntimeError(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_VMSetRuntimeErrorV(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list va);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_PATMSetMMIOPatchInfo(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @} */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @name PIC GC Helpers
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0PicHlp_SetInterruptFF(PPDMDEVINS pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0PicHlp_ClearInterruptFF(PPDMDEVINS pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0PicHlp_Lock(PPDMDEVINS pDevIns, int rc);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0PicHlp_Unlock(PPDMDEVINS pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @} */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @name APIC GC Helpers
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0ApicHlp_SetInterruptFF(PPDMDEVINS pDevIns, VMCPUID idCpu);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0ApicHlp_ClearInterruptFF(PPDMDEVINS pDevIns, VMCPUID idCpu);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0ApicHlp_ChangeFeature(PPDMDEVINS pDevIns, PDMAPICVERSION enmVersion);
e5bfc5c34142a7550be3564a8e01a037b1db5b31vboxsyncstatic DECLCALLBACK(int) pdmR0ApicHlp_Lock(PPDMDEVINS pDevIns, int rc);
e5bfc5c34142a7550be3564a8e01a037b1db5b31vboxsyncstatic DECLCALLBACK(void) pdmR0ApicHlp_Unlock(PPDMDEVINS pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(VMCPUID) pdmR0ApicHlp_GetCpuId(PPDMDEVINS pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @} */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @name I/O APIC GC Helpers
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0IoApicHlp_ApicBusDeliver(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0IoApicHlp_Lock(PPDMDEVINS pDevIns, int rc);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0IoApicHlp_Unlock(PPDMDEVINS pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @} */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @name PCI Bus GC Helpers
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * @{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0PciHlp_IsaSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0PciHlp_IoApicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0PciHlp_Lock(PPDMDEVINS pDevIns, int rc);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0PciHlp_Unlock(PPDMDEVINS pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @} */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic void pdmR0IsaSetIrq(PVM pVM, int iIrq, int iLevel);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic void pdmR0IoApicSetIrq(PVM pVM, int iIrq, int iLevel);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * The Guest Context Device Helper Callbacks.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncextern DECLEXPORT(const PDMDEVHLPR0) g_pdmR0DevHlp =
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDM_DEVHLPR0_VERSION,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0DevHlp_PCISetIrq,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0DevHlp_ISASetIrq,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0DevHlp_PhysRead,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0DevHlp_PhysWrite,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0DevHlp_A20IsEnabled,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0DevHlp_VMSetError,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0DevHlp_VMSetErrorV,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0DevHlp_VMSetRuntimeError,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0DevHlp_VMSetRuntimeErrorV,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0DevHlp_PATMSetMMIOPatchInfo,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDM_DEVHLPR0_VERSION
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync};
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * The Guest Context PIC Helper Callbacks.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncextern DECLEXPORT(const PDMPICHLPR0) g_pdmR0PicHlp =
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDM_PICHLPR0_VERSION,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0PicHlp_SetInterruptFF,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0PicHlp_ClearInterruptFF,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0PicHlp_Lock,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0PicHlp_Unlock,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDM_PICHLPR0_VERSION
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync};
c5d2523548cc57504b829f53f1362b848a84542cvboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
c5d2523548cc57504b829f53f1362b848a84542cvboxsync/**
c5d2523548cc57504b829f53f1362b848a84542cvboxsync * The Guest Context APIC Helper Callbacks.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncextern DECLEXPORT(const PDMAPICHLPR0) g_pdmR0ApicHlp =
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
c5d2523548cc57504b829f53f1362b848a84542cvboxsync PDM_APICHLPR0_VERSION,
c5d2523548cc57504b829f53f1362b848a84542cvboxsync pdmR0ApicHlp_SetInterruptFF,
c5d2523548cc57504b829f53f1362b848a84542cvboxsync pdmR0ApicHlp_ClearInterruptFF,
c5d2523548cc57504b829f53f1362b848a84542cvboxsync pdmR0ApicHlp_ChangeFeature,
c5d2523548cc57504b829f53f1362b848a84542cvboxsync pdmR0ApicHlp_Lock,
c5d2523548cc57504b829f53f1362b848a84542cvboxsync pdmR0ApicHlp_Unlock,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0ApicHlp_GetCpuId,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDM_APICHLPR0_VERSION
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync};
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * The Guest Context I/O APIC Helper Callbacks.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncextern DECLEXPORT(const PDMIOAPICHLPR0) g_pdmR0IoApicHlp =
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDM_IOAPICHLPR0_VERSION,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0IoApicHlp_ApicBusDeliver,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0IoApicHlp_Lock,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0IoApicHlp_Unlock,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDM_IOAPICHLPR0_VERSION
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync};
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/**
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync * The Guest Context PCI Bus Helper Callbacks.
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncextern DECLEXPORT(const PDMPCIHLPR0) g_pdmR0PciHlp =
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDM_PCIHLPR0_VERSION,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0PciHlp_IsaSetIrq,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0PciHlp_IoApicSetIrq,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0PciHlp_Lock,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0PciHlp_Unlock,
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDM_PCIHLPR0_VERSION, /* the end */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync};
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMDEVHLPR0::pfnPCISetIrq */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0DevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync LogFlow(("pdmR0DevHlp_PCISetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync PVM pVM = pDevIns->Internal.s.pVMR0;
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync PPCIDEVICE pPciDev = pDevIns->Internal.s.pPciDeviceR0;
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync PPDMPCIBUS pPciBus = pDevIns->Internal.s.pPciBusR0;
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync if ( pPciDev
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync && pPciBus
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync && pPciBus->pDevInsR0)
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync {
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync pdmLock(pVM);
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync pPciBus->pfnSetIrqR0(pPciBus->pDevInsR0, pPciDev, iIrq, iLevel);
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync pdmUnlock(pVM);
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync }
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync else
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync {
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync /* queue for ring-3 execution. */
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pVM->pdm.s.pDevHlpQueueHC);
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync if (pTask)
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync {
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync pTask->enmOp = PDMDEVHLPTASKOP_PCI_SET_IRQ;
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync pTask->pDevInsHC = pDevIns;
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync pTask->u.SetIRQ.iIrq = iIrq;
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync pTask->u.SetIRQ.iLevel = iLevel;
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMQueueInsertEx(pVM->pdm.s.pDevHlpQueueHC, &pTask->Core, 0);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync }
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync else
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync AssertMsgFailed(("We're out of devhlp queue items!!!\n"));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync }
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync LogFlow(("pdmR0DevHlp_PCISetIrq: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMDEVHLPR0::pfnPCISetIrq */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0DevHlp_ISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync LogFlow(("pdmR0DevHlp_ISASetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmR0IsaSetIrq(pDevIns->Internal.s.pVMR0, iIrq, iLevel);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync LogFlow(("pdmR0DevHlp_ISASetIrq: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMDEVHLPR0::pfnPhysRead */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync LogFlow(("pdmR0DevHlp_PhysRead: caller=%p/%d: GCPhys=%VGp pvBuf=%p cbRead=%#x\n",
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pDevIns, pDevIns->iInstance, GCPhys, pvBuf, cbRead));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PGMPhysRead(pDevIns->Internal.s.pVMR0, GCPhys, pvBuf, cbRead);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync Log(("pdmR0DevHlp_PhysRead: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMDEVHLPR0::pfnPhysWrite */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync LogFlow(("pdmR0DevHlp_PhysWrite: caller=%p/%d: GCPhys=%VGp pvBuf=%p cbWrite=%#x\n",
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pDevIns, pDevIns->iInstance, GCPhys, pvBuf, cbWrite));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PGMPhysWrite(pDevIns->Internal.s.pVMR0, GCPhys, pvBuf, cbWrite);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync Log(("pdmR0DevHlp_PhysWrite: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMDEVHLPR0::pfnA20IsEnabled */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(bool) pdmR0DevHlp_A20IsEnabled(PPDMDEVINS pDevIns)
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync LogFlow(("pdmR0DevHlp_A20IsEnabled: caller=%p/%d:\n", pDevIns, pDevIns->iInstance));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
fa7c9928985ad8dc74ae6931809083c2af135250vboxsync bool fEnabled = PGMPhysIsA20Enabled(pDevIns->Internal.s.pVMR0);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync Log(("pdmR0DevHlp_A20IsEnabled: caller=%p/%d: returns %RTbool\n", pDevIns, pDevIns->iInstance, fEnabled));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync return fEnabled;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMDEVHLPR0::pfnVMSetError */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync va_list args;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync va_start(args, pszFormat);
c5d2523548cc57504b829f53f1362b848a84542cvboxsync int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMR0, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync va_end(args);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync return rc;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMDEVHLPR0::pfnVMSetErrorV */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_VMSetErrorV(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
c5d2523548cc57504b829f53f1362b848a84542cvboxsync int rc2 = VMSetErrorV(pDevIns->Internal.s.pVMR0, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
c5d2523548cc57504b829f53f1362b848a84542cvboxsync return rc;
c5d2523548cc57504b829f53f1362b848a84542cvboxsync}
c5d2523548cc57504b829f53f1362b848a84542cvboxsync
c5d2523548cc57504b829f53f1362b848a84542cvboxsync
c5d2523548cc57504b829f53f1362b848a84542cvboxsync/** @copydoc PDMDEVHLPR0::pfnVMSetRuntimeError */
c5d2523548cc57504b829f53f1362b848a84542cvboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_VMSetRuntimeError(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, ...)
c5d2523548cc57504b829f53f1362b848a84542cvboxsync{
c5d2523548cc57504b829f53f1362b848a84542cvboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
c5d2523548cc57504b829f53f1362b848a84542cvboxsync va_list args;
c5d2523548cc57504b829f53f1362b848a84542cvboxsync va_start(args, pszFormat);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync int rc = VMSetRuntimeErrorV(pDevIns->Internal.s.pVMR0, fFatal, pszErrorID, pszFormat, args);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync va_end(args);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync return rc;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMDEVHLPR0::pfnVMSetRuntimeErrorV */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_VMSetRuntimeErrorV(PPDMDEVINS pDevIns, bool fFatal, const char *pszErrorID, const char *pszFormat, va_list va)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync int rc = VMSetRuntimeErrorV(pDevIns->Internal.s.pVMR0, fFatal, pszErrorID, pszFormat, va);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync return rc;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMDEVHLPR0::pdmR0DevHlp_PATMSetMMIOPatchInfo*/
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0DevHlp_PATMSetMMIOPatchInfo(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync LogFlow(("pdmR0DevHlp_PATMSetMMIOPatchInfo: caller=%p/%d:\n", pDevIns, pDevIns->iInstance));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync AssertFailed();
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/* return PATMSetMMIOPatchInfo(pDevIns->Internal.s.pVMR0, GCPhys, pCachedData); */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync return VINF_SUCCESS;
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
c5d2523548cc57504b829f53f1362b848a84542cvboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
c5d2523548cc57504b829f53f1362b848a84542cvboxsync/** @copydoc PDMPICHLPR0::pfnSetInterruptFF */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0PicHlp_SetInterruptFF(PPDMDEVINS pDevIns)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync LogFlow(("pdmR0PicHlp_SetInterruptFF: caller=%p/%d: VM_FF_INTERRUPT_PIC %d -> 1\n",
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pDevIns, pDevIns->iInstance, VMCPU_FF_ISSET(pDevIns->Internal.s.pVMR0, 0, VM_FF_INTERRUPT_PIC)));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /* for PIC we always deliver to CPU 0, MP use APIC */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync VMCPU_FF_SET(pDevIns->Internal.s.pVMR0, 0, VM_FF_INTERRUPT_PIC);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMPICHLPR0::pfnClearInterruptFF */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0PicHlp_ClearInterruptFF(PPDMDEVINS pDevIns)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync LogFlow(("pdmR0PicHlp_ClearInterruptFF: caller=%p/%d: VM_FF_INTERRUPT_PIC %d -> 0\n",
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pDevIns, pDevIns->iInstance, VMCPU_FF_ISSET(pDevIns->Internal.s.pVMR0, 0, VM_FF_INTERRUPT_PIC)));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync /* for PIC we always deliver to CPU 0, MP use APIC */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync VMCPU_FF_CLEAR(pDevIns->Internal.s.pVMR0, 0, VM_FF_INTERRUPT_PIC);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
c5d2523548cc57504b829f53f1362b848a84542cvboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMPICHLPR0::pfnLock */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(int) pdmR0PicHlp_Lock(PPDMDEVINS pDevIns, int rc)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
c5d2523548cc57504b829f53f1362b848a84542cvboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync return pdmLockEx(pDevIns->Internal.s.pVMR0, rc);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMPICHLPR0::pfnUnlock */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0PicHlp_Unlock(PPDMDEVINS pDevIns)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync pdmUnlock(pDevIns->Internal.s.pVMR0);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
e5bfc5c34142a7550be3564a8e01a037b1db5b31vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync/** @copydoc PDMAPICHLPR0::pfnSetInterruptFF */
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsyncstatic DECLCALLBACK(void) pdmR0ApicHlp_SetInterruptFF(PPDMDEVINS pDevIns, VMCPUID idCpu)
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync{
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync PDMDEV_ASSERT_DEVINS(pDevIns);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync
833f83ce101b6e9168f519decc0dc7a1079d35f7vboxsync LogFlow(("pdmR0ApicHlp_SetInterruptFF: caller=%p/%d: VM_FF_INTERRUPT %d -> 1\n",
833f83ce101b6e9168f519decc0dc7a1079d35f7vboxsync pDevIns, pDevIns->iInstance, VMCPU_FF_ISSET(pDevIns->Internal.s.pVMR0, idCpu, VM_FF_INTERRUPT_APIC)));
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync VMCPU_FF_SET(pDevIns->Internal.s.pVMR0, idCpu, VM_FF_INTERRUPT_APIC);
b4f03aea544c9a58d8959658b31f7bd716a3f097vboxsync}
/** @copydoc PDMAPICHLPR0::pfnClearInterruptFF */
static DECLCALLBACK(void) pdmR0ApicHlp_ClearInterruptFF(PPDMDEVINS pDevIns, VMCPUID idCpu)
{
PDMDEV_ASSERT_DEVINS(pDevIns);
LogFlow(("pdmR0ApicHlp_ClearInterruptFF: caller=%p/%d: VM_FF_INTERRUPT %d -> 0\n",
pDevIns, pDevIns->iInstance, VMCPU_FF_ISSET(pDevIns->Internal.s.pVMR0, idCpu, VM_FF_INTERRUPT_APIC)));
VMCPU_FF_CLEAR(pDevIns->Internal.s.pVMR0, idCpu, VM_FF_INTERRUPT_APIC);
}
/** @copydoc PDMAPICHLPR0::pfnChangeFeature */
static DECLCALLBACK(void) pdmR0ApicHlp_ChangeFeature(PPDMDEVINS pDevIns, PDMAPICVERSION enmVersion)
{
PDMDEV_ASSERT_DEVINS(pDevIns);
LogFlow(("pdmR0ApicHlp_ChangeFeature: caller=%p/%d: version=%d\n", pDevIns, pDevIns->iInstance, (int)enmVersion));
switch (enmVersion)
{
case PDMAPICVERSION_NONE:
CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR0, CPUMCPUIDFEATURE_APIC);
CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR0, CPUMCPUIDFEATURE_X2APIC);
break;
case PDMAPICVERSION_APIC:
CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMR0, CPUMCPUIDFEATURE_APIC);
CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR0, CPUMCPUIDFEATURE_X2APIC);
break;
case PDMAPICVERSION_X2APIC:
CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMR0, CPUMCPUIDFEATURE_X2APIC);
CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMR0, CPUMCPUIDFEATURE_APIC);
break;
default:
AssertMsgFailed(("Unknown APIC version: %d\n", (int)enmVersion));
}
}
/** @copydoc PDMAPICHLPR0::pfnLock */
static DECLCALLBACK(int) pdmR0ApicHlp_Lock(PPDMDEVINS pDevIns, int rc)
{
PDMDEV_ASSERT_DEVINS(pDevIns);
return pdmLockEx(pDevIns->Internal.s.pVMR0, rc);
}
/** @copydoc PDMAPICHLPR0::pfnUnlock */
static DECLCALLBACK(void) pdmR0ApicHlp_Unlock(PPDMDEVINS pDevIns)
{
PDMDEV_ASSERT_DEVINS(pDevIns);
pdmUnlock(pDevIns->Internal.s.pVMR0);
}
/** @copydoc PDMAPICHLPR0::pfnGetCpuId */
static DECLCALLBACK(VMCPUID) pdmR0ApicHlp_GetCpuId(PPDMDEVINS pDevIns)
{
PDMDEV_ASSERT_DEVINS(pDevIns);
return VMMGetCpuId(pDevIns->Internal.s.pVMR0);
}
/** @copydoc PDMIOAPICHLPR0::pfnApicBusDeliver */
static DECLCALLBACK(void) pdmR0IoApicHlp_ApicBusDeliver(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode)
{
PDMDEV_ASSERT_DEVINS(pDevIns);
PVM pVM = pDevIns->Internal.s.pVMR0;
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));
Assert(pVM->pdm.s.Apic.pDevInsR0);
if (pVM->pdm.s.Apic.pfnBusDeliverR0)
pVM->pdm.s.Apic.pfnBusDeliverR0(pVM->pdm.s.Apic.pDevInsR0, u8Dest, u8DestMode, u8DeliveryMode, iVector, u8Polarity, u8TriggerMode);
}
/** @copydoc PDMIOAPICHLPR0::pfnLock */
static DECLCALLBACK(int) pdmR0IoApicHlp_Lock(PPDMDEVINS pDevIns, int rc)
{
PDMDEV_ASSERT_DEVINS(pDevIns);
return pdmLockEx(pDevIns->Internal.s.pVMR0, rc);
}
/** @copydoc PDMIOAPICHLPR0::pfnUnlock */
static DECLCALLBACK(void) pdmR0IoApicHlp_Unlock(PPDMDEVINS pDevIns)
{
PDMDEV_ASSERT_DEVINS(pDevIns);
pdmUnlock(pDevIns->Internal.s.pVMR0);
}
/** @copydoc PDMPCIHLPR0::pfnIsaSetIrq */
static DECLCALLBACK(void) pdmR0PciHlp_IsaSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
{
PDMDEV_ASSERT_DEVINS(pDevIns);
Log4(("pdmR0PciHlp_IsaSetIrq: iIrq=%d iLevel=%d\n", iIrq, iLevel));
pdmR0IsaSetIrq(pDevIns->Internal.s.pVMR0, iIrq, iLevel);
}
/** @copydoc PDMPCIHLPR0::pfnIoApicSetIrq */
static DECLCALLBACK(void) pdmR0PciHlp_IoApicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
{
PDMDEV_ASSERT_DEVINS(pDevIns);
Log4(("pdmR0PciHlp_IsaSetIrq: iIrq=%d iLevel=%d\n", iIrq, iLevel));
pdmR0IoApicSetIrq(pDevIns->Internal.s.pVMR0, iIrq, iLevel);
}
/** @copydoc PDMPCIHLPR0::pfnLock */
static DECLCALLBACK(int) pdmR0PciHlp_Lock(PPDMDEVINS pDevIns, int rc)
{
PDMDEV_ASSERT_DEVINS(pDevIns);
return pdmLockEx(pDevIns->Internal.s.pVMR0, rc);
}
/** @copydoc PDMPCIHLPR0::pfnUnlock */
static DECLCALLBACK(void) pdmR0PciHlp_Unlock(PPDMDEVINS pDevIns)
{
PDMDEV_ASSERT_DEVINS(pDevIns);
pdmUnlock(pDevIns->Internal.s.pVMR0);
}
/**
* Sets an irq on the I/O APIC.
*
* @param pVM The VM handle.
* @param iIrq The irq.
* @param iLevel The new level.
*/
static void pdmR0IsaSetIrq(PVM pVM, int iIrq, int iLevel)
{
if ( ( pVM->pdm.s.IoApic.pDevInsR0
|| !pVM->pdm.s.IoApic.pDevInsR3)
&& ( pVM->pdm.s.Pic.pDevInsR0
|| !pVM->pdm.s.Pic.pDevInsR3))
{
pdmLock(pVM);
if (pVM->pdm.s.Pic.pDevInsR0)
pVM->pdm.s.Pic.pfnSetIrqR0(pVM->pdm.s.Pic.pDevInsR0, iIrq, iLevel);
if (pVM->pdm.s.IoApic.pDevInsR0)
pVM->pdm.s.IoApic.pfnSetIrqR0(pVM->pdm.s.IoApic.pDevInsR0, iIrq, iLevel);
pdmUnlock(pVM);
}
else
{
/* queue for ring-3 execution. */
PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pVM->pdm.s.pDevHlpQueueHC);
if (pTask)
{
pTask->enmOp = PDMDEVHLPTASKOP_ISA_SET_IRQ;
pTask->pDevInsHC = 0; /* not required */
pTask->u.SetIRQ.iIrq = iIrq;
pTask->u.SetIRQ.iLevel = iLevel;
PDMQueueInsertEx(pVM->pdm.s.pDevHlpQueueHC, &pTask->Core, 0);
}
else
AssertMsgFailed(("We're out of devhlp queue items!!!\n"));
}
}
/**
* Sets an irq on the I/O APIC.
*
* @param pVM The VM handle.
* @param iIrq The irq.
* @param iLevel The new level.
*/
static void pdmR0IoApicSetIrq(PVM pVM, int iIrq, int iLevel)
{
if (pVM->pdm.s.IoApic.pDevInsR0)
{
pdmLock(pVM);
pVM->pdm.s.IoApic.pfnSetIrqR0(pVM->pdm.s.IoApic.pDevInsR0, iIrq, iLevel);
pdmUnlock(pVM);
}
else if (pVM->pdm.s.IoApic.pDevInsR3)
{
/* queue for ring-3 execution. */
PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pVM->pdm.s.pDevHlpQueueHC);
if (pTask)
{
pTask->enmOp = PDMDEVHLPTASKOP_IOAPIC_SET_IRQ;
pTask->pDevInsHC = 0; /* not required */
pTask->u.SetIRQ.iIrq = iIrq;
pTask->u.SetIRQ.iLevel = iLevel;
PDMQueueInsertEx(pVM->pdm.s.pDevHlpQueueHC, &pTask->Core, 0);
}
else
AssertMsgFailed(("We're out of devhlp queue items!!!\n"));
}
}