summaryrefslogtreecommitdiff
path: root/src/VBox/Devices/PC/DevACPI.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-03-26 19:21:20 +0000
committer <>2014-05-08 15:03:54 +0000
commitfb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch)
treec2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Devices/PC/DevACPI.cpp
parent58ed4748338f9466599adfc8a9171280ed99e23f (diff)
downloadVirtualBox-master.tar.gz
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Devices/PC/DevACPI.cpp')
-rw-r--r--src/VBox/Devices/PC/DevACPI.cpp774
1 files changed, 389 insertions, 385 deletions
diff --git a/src/VBox/Devices/PC/DevACPI.cpp b/src/VBox/Devices/PC/DevACPI.cpp
index 3557081b..d2a3add5 100644
--- a/src/VBox/Devices/PC/DevACPI.cpp
+++ b/src/VBox/Devices/PC/DevACPI.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2011 Oracle Corporation
+ * 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;
@@ -41,14 +41,6 @@
# define DEBUG_ACPI
#endif
-#if defined(IN_RING3) && !defined(VBOX_DEVICE_STRUCT_TESTCASE)
-int acpiPrepareDsdt(PPDMDEVINS pDevIns, void* *ppPtr, size_t *puDsdtLen);
-int acpiCleanupDsdt(PPDMDEVINS pDevIns, void* pPtr);
-
-int acpiPrepareSsdt(PPDMDEVINS pDevIns, void* *ppPtr, size_t *puSsdtLen);
-int acpiCleanupSsdt(PPDMDEVINS pDevIns, void* pPtr);
-#endif /* !IN_RING3 */
-
/*******************************************************************************
@@ -248,7 +240,7 @@ typedef struct ACPIState
* write request to offset 0x200 (in that case we divide the index value by
* 4. Note that the _STA method is sometimes called prior to the _INI method
* (ACPI spec 6.3.7, _STA). See the special case for BAT_DEVICE_STATUS in
- * acpiBatIndexWrite() for handling this. */
+ * acpiR3BatIndexWrite() for handling this. */
uint8_t u8IndexShift;
/** provide an I/O-APIC */
uint8_t u8UseIOApic;
@@ -467,6 +459,8 @@ struct ACPITBLFADT
(COM too?) */
#define IAPC_BOOT_ARCH_8042 RT_BIT(1) /**< legacy keyboard device present */
#define IAPC_BOOT_ARCH_NO_VGA RT_BIT(2) /**< VGA not present */
+#define IAPC_BOOT_ARCH_NO_MSI RT_BIT(3) /**< OSPM must not enable MSIs on this platform */
+#define IAPC_BOOT_ARCH_NO_ASPM RT_BIT(4) /**< OSPM must not enable ASPM on this platform */
uint8_t u8Must0_0; /**< must be 0 */
uint32_t u32Flags; /**< fixed feature flags */
#define FADT_FL_WBINVD RT_BIT(0) /**< emulation of WBINVD available */
@@ -600,9 +594,7 @@ typedef struct ACPITBLMCFGENTRY
} ACPITBLMCFGENTRY;
AssertCompileSize(ACPITBLMCFGENTRY, 16);
-# ifdef IN_RING3 /** @todo r=bird: Move this down to where it's used. */
-
-# define PCAT_COMPAT 0x1 /**< system has also a dual-8259 setup */
+#define PCAT_COMPAT 0x1 /**< system has also a dual-8259 setup */
/** Custom Description Table */
struct ACPITBLCUST
@@ -612,122 +604,6 @@ struct ACPITBLCUST
};
AssertCompileSize(ACPITBLCUST, 512);
-/**
- * Multiple APIC Description Table.
- *
- * This structure looks somewhat convoluted due layout of MADT table in MP case.
- * There extpected to be multiple LAPIC records for each CPU, thus we cannot
- * use regular C structure and proxy to raw memory instead.
- */
-class AcpiTableMADT
-{
- /**
- * All actual data stored in dynamically allocated memory pointed by this field.
- */
- uint8_t *m_pbData;
- /**
- * Number of CPU entries in this MADT.
- */
- uint32_t m_cCpus;
-
- /**
- * Number of interrupt overrides.
- */
- uint32_t m_cIsos;
-
-public:
- /**
- * Address of ACPI header
- */
- inline ACPITBLHEADER *header_addr(void) const
- {
- return (ACPITBLHEADER *)m_pbData;
- }
-
- /**
- * Address of local APIC for each CPU. Note that different CPUs address different LAPICs,
- * although address is the same for all of them.
- */
- inline uint32_t *u32LAPIC_addr(void) const
- {
- return (uint32_t *)(header_addr() + 1);
- }
-
- /**
- * Address of APIC flags
- */
- inline uint32_t *u32Flags_addr(void) const
- {
- return (uint32_t *)(u32LAPIC_addr() + 1);
- }
-
- /**
- * Address of ISO description
- */
- inline ACPITBLISO *ISO_addr(void) const
- {
- return (ACPITBLISO *)(u32Flags_addr() + 1);
- }
-
- /**
- * Address of per-CPU LAPIC descriptions
- */
- inline ACPITBLLAPIC *LApics_addr(void) const
- {
- return (ACPITBLLAPIC *)(ISO_addr() + m_cIsos);
- }
-
- /**
- * Address of IO APIC description
- */
- inline ACPITBLIOAPIC *IOApic_addr(void) const
- {
- return (ACPITBLIOAPIC *)(LApics_addr() + m_cCpus);
- }
-
- /**
- * Size of MADT.
- * Note that this function assumes IOApic to be the last field in structure.
- */
- inline uint32_t size(void) const
- {
- return (uint8_t *)(IOApic_addr() + 1) - (uint8_t *)header_addr();
- }
-
- /**
- * Raw data of MADT.
- */
- inline const uint8_t *data(void) const
- {
- return m_pbData;
- }
-
- /**
- * Size of MADT for given ACPI config, useful to compute layout.
- */
- static uint32_t sizeFor(ACPIState *pThis, uint32_t cIsos)
- {
- return AcpiTableMADT(pThis->cCpus, cIsos).size();
- }
-
- /*
- * Constructor, only works in Ring 3, doesn't look like a big deal.
- */
- AcpiTableMADT(uint32_t cCpus, uint32_t cIsos)
- {
- m_cCpus = cCpus;
- m_cIsos = cIsos;
- m_pbData = NULL; /* size() uses this and gcc will complain if not initialized. */
- uint32_t cb = size();
- m_pbData = (uint8_t *)RTMemAllocZ(cb);
- }
-
- ~AcpiTableMADT()
- {
- RTMemFree(m_pbData);
- }
-};
-# endif /* IN_RING3 */
#pragma pack()
@@ -740,13 +616,13 @@ RT_C_DECLS_BEGIN
PDMBOTHCBDECL(int) acpiPMTmrRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb);
RT_C_DECLS_END
#ifdef IN_RING3
-static int acpiPlantTables(ACPIState *pThis);
+static int acpiR3PlantTables(ACPIState *pThis);
#endif
#ifdef IN_RING3
/* SCI IRQ */
-DECLINLINE(void) acpiSetIrq(ACPIState *pThis, int level)
+DECLINLINE(void) acpiR3SetIrq(ACPIState *pThis, int level)
{
if (pThis->pm1a_ctl & SCI_EN)
PDMDevHlpPCISetIrq(pThis->pDevIns, 0, level);
@@ -767,14 +643,14 @@ DECLINLINE(int) pm1a_level(ACPIState *pThis)
return (pm1a_pure_en(pThis->pm1a_en) & pm1a_pure_sts(pThis->pm1a_sts)) != 0;
}
-DECLINLINE(int) gpe0_level(ACPIState *pThis)
+DECLINLINE(bool) gpe0_level(ACPIState *pThis)
{
return (pThis->gpe0_en & pThis->gpe0_sts) != 0;
}
/**
- * Used by acpiPM1aStsWrite, acpiPM1aEnWrite, acpiPmTimer,
- * acpiPort_PowerBuffonPress and acpiPort_SleepButtonPress to
+ * Used by acpiR3PM1aStsWrite, acpiR3PM1aEnWrite, acpiR3PmTimer,
+ * acpiR3Port_PowerBuffonPress and acpiR3Port_SleepButtonPress to
* update the GPE0.STS and GPE0.EN registers and trigger IRQs.
*
* Caller must hold the state lock.
@@ -783,7 +659,7 @@ DECLINLINE(int) gpe0_level(ACPIState *pThis)
* @param sts The new GPE0.STS value.
* @param en The new GPE0.EN value.
*/
-static void update_pm1a(ACPIState *pThis, uint32_t sts, uint32_t en)
+static void apicR3UpdatePm1a(ACPIState *pThis, uint32_t sts, uint32_t en)
{
Assert(PDMCritSectIsOwner(&pThis->CritSect));
@@ -793,17 +669,17 @@ static void update_pm1a(ACPIState *pThis, uint32_t sts, uint32_t en)
int const old_level = pm1a_level(pThis);
int const new_level = (pm1a_pure_en(en) & pm1a_pure_sts(sts)) != 0;
- Log(("update_pm1a() old=%x new=%x\n", old_level, new_level));
+ Log(("apicR3UpdatePm1a() old=%x new=%x\n", old_level, new_level));
pThis->pm1a_en = en;
pThis->pm1a_sts = sts;
if (new_level != old_level)
- acpiSetIrq(pThis, new_level);
+ acpiR3SetIrq(pThis, new_level);
}
/**
- * Used by acpiGpe0StsWrite, acpiGpe0EnWrite, acpiAttach and acpiDetach to
+ * Used by acpiR3Gpe0StsWrite, acpiR3Gpe0EnWrite, acpiAttach and acpiDetach to
* update the GPE0.STS and GPE0.EN registers and trigger IRQs.
*
* Caller must hold the state lock.
@@ -812,7 +688,7 @@ static void update_pm1a(ACPIState *pThis, uint32_t sts, uint32_t en)
* @param sts The new GPE0.STS value.
* @param en The new GPE0.EN value.
*/
-static void update_gpe0(ACPIState *pThis, uint32_t sts, uint32_t en)
+static void apicR3UpdateGpe0(ACPIState *pThis, uint32_t sts, uint32_t en)
{
Assert(PDMCritSectIsOwner(&pThis->CritSect));
@@ -826,16 +702,16 @@ static void update_gpe0(ACPIState *pThis, uint32_t sts, uint32_t en)
pThis->gpe0_sts = sts;
if (new_level != old_level)
- acpiSetIrq(pThis, new_level);
+ acpiR3SetIrq(pThis, new_level);
}
/**
- * Used by acpiPM1aCtlWrite to power off the VM.
+ * Used by acpiR3PM1aCtlWrite to power off the VM.
*
* @param pThis The ACPI instance.
* @returns Strict VBox status code.
*/
-static int acpiPowerOff(ACPIState *pThis)
+static int acpiR3DoPowerOff(ACPIState *pThis)
{
int rc = PDMDevHlpVMPowerOff(pThis->pDevIns);
if (RT_FAILURE(rc))
@@ -844,12 +720,12 @@ static int acpiPowerOff(ACPIState *pThis)
}
/**
- * Used by acpiPM1aCtlWrite to put the VM to sleep.
+ * Used by acpiR3PM1aCtlWrite to put the VM to sleep.
*
* @param pThis The ACPI instance.
* @returns Strict VBox status code.
*/
-static int acpiSleep(ACPIState *pThis)
+static int acpiR3DoSleep(ACPIState *pThis)
{
/* We must set WAK_STS on resume (includes restore) so the guest knows that
we've woken up and can continue executing code. The guest is probably
@@ -880,14 +756,14 @@ static int acpiSleep(ACPIState *pThis)
/**
* @interface_method_impl{PDMIACPIPORT,pfnPowerButtonPress}
*/
-static DECLCALLBACK(int) acpiPort_PowerButtonPress(PPDMIACPIPORT pInterface)
+static DECLCALLBACK(int) acpiR3Port_PowerButtonPress(PPDMIACPIPORT pInterface)
{
ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IACPIPort);
DEVACPI_LOCK_R3(pThis);
- Log(("acpiPort_PowerButtonPress: handled=%d status=%x\n", pThis->fPowerButtonHandled, pThis->pm1a_sts));
+ Log(("acpiR3Port_PowerButtonPress: handled=%d status=%x\n", pThis->fPowerButtonHandled, pThis->pm1a_sts));
pThis->fPowerButtonHandled = false;
- update_pm1a(pThis, pThis->pm1a_sts | PWRBTN_STS, pThis->pm1a_en);
+ apicR3UpdatePm1a(pThis, pThis->pm1a_sts | PWRBTN_STS, pThis->pm1a_en);
DEVACPI_UNLOCK(pThis);
return VINF_SUCCESS;
@@ -896,7 +772,7 @@ static DECLCALLBACK(int) acpiPort_PowerButtonPress(PPDMIACPIPORT pInterface)
/**
* @interface_method_impl{PDMIACPIPORT,pfnGetPowerButtonHandled}
*/
-static DECLCALLBACK(int) acpiPort_GetPowerButtonHandled(PPDMIACPIPORT pInterface, bool *pfHandled)
+static DECLCALLBACK(int) acpiR3Port_GetPowerButtonHandled(PPDMIACPIPORT pInterface, bool *pfHandled)
{
ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IACPIPort);
DEVACPI_LOCK_R3(pThis);
@@ -911,7 +787,7 @@ static DECLCALLBACK(int) acpiPort_GetPowerButtonHandled(PPDMIACPIPORT pInterface
* @interface_method_impl{PDMIACPIPORT,pfnGetGuestEnteredACPIMode, Check if the
* Guest entered into G0 (working) or G1 (sleeping)}
*/
-static DECLCALLBACK(int) acpiPort_GetGuestEnteredACPIMode(PPDMIACPIPORT pInterface, bool *pfEntered)
+static DECLCALLBACK(int) acpiR3Port_GetGuestEnteredACPIMode(PPDMIACPIPORT pInterface, bool *pfEntered)
{
ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IACPIPort);
DEVACPI_LOCK_R3(pThis);
@@ -925,7 +801,7 @@ static DECLCALLBACK(int) acpiPort_GetGuestEnteredACPIMode(PPDMIACPIPORT pInterfa
/**
* @interface_method_impl{PDMIACPIPORT,pfnGetCpuStatus}
*/
-static DECLCALLBACK(int) acpiPort_GetCpuStatus(PPDMIACPIPORT pInterface, unsigned uCpu, bool *pfLocked)
+static DECLCALLBACK(int) acpiR3Port_GetCpuStatus(PPDMIACPIPORT pInterface, unsigned uCpu, bool *pfLocked)
{
ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IACPIPort);
DEVACPI_LOCK_R3(pThis);
@@ -942,19 +818,19 @@ static DECLCALLBACK(int) acpiPort_GetCpuStatus(PPDMIACPIPORT pInterface, unsigne
* @returns VBox status code
* @param pInterface Pointer to the interface structure containing the called function pointer.
*/
-static DECLCALLBACK(int) acpiPort_SleepButtonPress(PPDMIACPIPORT pInterface)
+static DECLCALLBACK(int) acpiR3Port_SleepButtonPress(PPDMIACPIPORT pInterface)
{
ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IACPIPort);
DEVACPI_LOCK_R3(pThis);
- update_pm1a(pThis, pThis->pm1a_sts | SLPBTN_STS, pThis->pm1a_en);
+ apicR3UpdatePm1a(pThis, pThis->pm1a_sts | SLPBTN_STS, pThis->pm1a_en);
DEVACPI_UNLOCK(pThis);
return VINF_SUCCESS;
}
/**
- * Used by acpiPmTimer to re-arm the PM timer.
+ * Used by acpiR3PmTimer to re-arm the PM timer.
*
* The caller is expected to either hold the clock lock or to have made sure
* the VM is resetting or loading state.
@@ -962,7 +838,7 @@ static DECLCALLBACK(int) acpiPort_SleepButtonPress(PPDMIACPIPORT pInterface)
* @param pThis The ACPI instance.
* @param uNow The current time.
*/
-static void acpiPmTimerReset(ACPIState *pThis, uint64_t uNow)
+static void acpiR3PmTimerReset(ACPIState *pThis, uint64_t uNow)
{
uint64_t uTimerFreq = TMTimerGetFreq(pThis->CTX_SUFF(pPmTimer));
uint64_t uInterval = ASMMultU64ByU32DivByU32(0xffffffff, uTimerFreq, PM_TMR_FREQ);
@@ -973,7 +849,7 @@ static void acpiPmTimerReset(ACPIState *pThis, uint64_t uNow)
/**
* @callback_method_impl{FNTMTIMERDEV, PM Timer callback}
*/
-static DECLCALLBACK(void) acpiPmTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
+static DECLCALLBACK(void) acpiR3PmTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
{
ACPIState *pThis = (ACPIState *)pvUser;
Assert(TMTimerIsLockOwner(pTimer));
@@ -983,20 +859,20 @@ static DECLCALLBACK(void) acpiPmTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void
Log(("acpi: pm timer sts %#x (%d), en %#x (%d)\n",
pThis->pm1a_sts, (pThis->pm1a_sts & TMR_STS) != 0,
pThis->pm1a_en, (pThis->pm1a_en & TMR_EN) != 0));
- update_pm1a(pThis, pThis->pm1a_sts | TMR_STS, pThis->pm1a_en);
+ apicR3UpdatePm1a(pThis, pThis->pm1a_sts | TMR_STS, pThis->pm1a_en);
DEVACPI_UNLOCK(pThis);
- acpiPmTimerReset(pThis, TMTimerGet(pTimer));
+ acpiR3PmTimerReset(pThis, TMTimerGet(pTimer));
}
/**
- * _BST method - used by acpiBatDataRead to implement BAT_STATUS_STATE and
- * acpiLoadState.
+ * _BST method - used by acpiR3BatDataRead to implement BAT_STATUS_STATE and
+ * acpiR3LoadState.
*
* @returns VINF_SUCCESS.
* @param pThis The ACPI instance.
*/
-static int acpiFetchBatteryStatus(ACPIState *pThis)
+static int acpiR3FetchBatteryStatus(ACPIState *pThis)
{
uint32_t *p = pThis->au8BatteryInfo;
bool fPresent; /* battery present? */
@@ -1028,13 +904,13 @@ static int acpiFetchBatteryStatus(ACPIState *pThis)
}
/**
- * _BIF method - used by acpiBatDataRead to implement BAT_INFO_UNITS and
- * acpiLoadState.
+ * _BIF method - used by acpiR3BatDataRead to implement BAT_INFO_UNITS and
+ * acpiR3LoadState.
*
* @returns VINF_SUCCESS.
* @param pThis The ACPI instance.
*/
-static int acpiFetchBatteryInfo(ACPIState *pThis)
+static int acpiR3FetchBatteryInfo(ACPIState *pThis)
{
uint32_t *p = pThis->au8BatteryInfo;
@@ -1052,12 +928,12 @@ static int acpiFetchBatteryInfo(ACPIState *pThis)
}
/**
- * The _STA method - used by acpiBatDataRead to implement BAT_DEVICE_STATUS.
+ * The _STA method - used by acpiR3BatDataRead to implement BAT_DEVICE_STATUS.
*
* @returns status mask or 0.
* @param pThis The ACPI instance.
*/
-static uint32_t acpiGetBatteryDeviceStatus(ACPIState *pThis)
+static uint32_t acpiR3GetBatteryDeviceStatus(ACPIState *pThis)
{
bool fPresent; /* battery present? */
PDMACPIBATCAPACITY hostRemainingCapacity; /* 0..100 */
@@ -1081,12 +957,12 @@ static uint32_t acpiGetBatteryDeviceStatus(ACPIState *pThis)
}
/**
- * Used by acpiBatDataRead to implement BAT_POWER_SOURCE.
+ * Used by acpiR3BatDataRead to implement BAT_POWER_SOURCE.
*
* @returns status.
* @param pThis The ACPI instance.
*/
-static uint32_t acpiGetPowerSource(ACPIState *pThis)
+static uint32_t acpiR3GetPowerSource(ACPIState *pThis)
{
/* query the current power source from the host driver */
if (!pThis->pDrv)
@@ -1101,9 +977,9 @@ static uint32_t acpiGetPowerSource(ACPIState *pThis)
/**
* @callback_method_impl{FNIOMIOPORTOUT, Battery status index}
*/
-PDMBOTHCBDECL(int) acpiBatIndexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3BatIndexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
- Log(("acpiBatIndexWrite: %#x (%#x)\n", u32, u32 >> 2));
+ Log(("acpiR3BatIndexWrite: %#x (%#x)\n", u32, u32 >> 2));
if (cb != 4)
return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "cb=%d Port=%u u32=%#x\n", cb, Port, u32);
@@ -1127,7 +1003,7 @@ PDMBOTHCBDECL(int) acpiBatIndexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT
/**
* @callback_method_impl{FNIOMIOPORTIN, Battery status data}
*/
-PDMBOTHCBDECL(int) acpiBatDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3BatDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
if (cb != 4)
return VERR_IOM_IOPORT_UNUSED;
@@ -1139,7 +1015,7 @@ PDMBOTHCBDECL(int) acpiBatDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Po
switch (pThis->uBatteryIndex)
{
case BAT_STATUS_STATE:
- acpiFetchBatteryStatus(pThis);
+ acpiR3FetchBatteryStatus(pThis);
/* fall thru */
case BAT_STATUS_PRESENT_RATE:
case BAT_STATUS_REMAINING_CAPACITY:
@@ -1148,7 +1024,7 @@ PDMBOTHCBDECL(int) acpiBatDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Po
break;
case BAT_INFO_UNITS:
- acpiFetchBatteryInfo(pThis);
+ acpiR3FetchBatteryInfo(pThis);
/* fall thru */
case BAT_INFO_DESIGN_CAPACITY:
case BAT_INFO_LAST_FULL_CHARGE_CAPACITY:
@@ -1162,11 +1038,11 @@ PDMBOTHCBDECL(int) acpiBatDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Po
break;
case BAT_DEVICE_STATUS:
- *pu32 = acpiGetBatteryDeviceStatus(pThis);
+ *pu32 = acpiR3GetBatteryDeviceStatus(pThis);
break;
case BAT_POWER_SOURCE:
- *pu32 = acpiGetPowerSource(pThis);
+ *pu32 = acpiR3GetPowerSource(pThis);
break;
default:
@@ -1182,9 +1058,9 @@ PDMBOTHCBDECL(int) acpiBatDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Po
/**
* @callback_method_impl{FNIOMIOPORTOUT, System info index}
*/
-PDMBOTHCBDECL(int) acpiSysInfoIndexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3SysInfoIndexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
- Log(("acpiSysInfoIndexWrite: %#x (%#x)\n", u32, u32 >> 2));
+ Log(("acpiR3SysInfoIndexWrite: %#x (%#x)\n", u32, u32 >> 2));
if (cb != 4)
return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "cb=%d Port=%u u32=%#x\n", cb, Port, u32);
@@ -1214,7 +1090,7 @@ PDMBOTHCBDECL(int) acpiSysInfoIndexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOP
/**
* @callback_method_impl{FNIOMIOPORTIN, System info data}
*/
-PDMBOTHCBDECL(int) acpiSysInfoDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3SysInfoDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
if (cb != 4)
return VERR_IOM_IOPORT_UNUSED;
@@ -1384,14 +1260,14 @@ PDMBOTHCBDECL(int) acpiSysInfoDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPOR
}
DEVACPI_UNLOCK(pThis);
- Log(("acpiSysInfoDataRead: idx=%d val=%#x (%d) rc=%Rrc\n", uSystemInfoIndex, *pu32, *pu32, rc));
+ Log(("acpiR3SysInfoDataRead: idx=%d val=%#x (%d) rc=%Rrc\n", uSystemInfoIndex, *pu32, *pu32, rc));
return rc;
}
/**
* @callback_method_impl{FNIOMIOPORTOUT, System info data}
*/
-PDMBOTHCBDECL(int) acpiSysInfoDataWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3SysInfoDataWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
ACPIState *pThis = (ACPIState *)pvUser;
if (cb != 4)
@@ -1436,7 +1312,7 @@ PDMBOTHCBDECL(int) acpiSysInfoDataWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPO
/**
* @callback_method_impl{FNIOMIOPORTIN, PM1a Enable}
*/
-PDMBOTHCBDECL(int) acpiPm1aEnRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3Pm1aEnRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
NOREF(pDevIns); NOREF(Port);
if (cb != 2)
@@ -1448,14 +1324,14 @@ PDMBOTHCBDECL(int) acpiPm1aEnRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Por
*pu32 = pThis->pm1a_en;
DEVACPI_UNLOCK(pThis);
- Log(("acpiPm1aEnRead -> %#x\n", *pu32));
+ Log(("acpiR3Pm1aEnRead -> %#x\n", *pu32));
return VINF_SUCCESS;
}
/**
* @callback_method_impl{FNIOMIOPORTOUT, PM1a Enable}
*/
-PDMBOTHCBDECL(int) acpiPM1aEnWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3PM1aEnWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (cb != 2 && cb != 4)
return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "cb=%d Port=%u u32=%#x\n", cb, Port, u32);
@@ -1463,10 +1339,10 @@ PDMBOTHCBDECL(int) acpiPM1aEnWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Po
ACPIState *pThis = (ACPIState *)pvUser;
DEVACPI_LOCK_R3(pThis);
- Log(("acpiPM1aEnWrite: %#x (%#x)\n", u32, u32 & ~(RSR_EN | IGN_EN) & 0xffff));
+ Log(("acpiR3PM1aEnWrite: %#x (%#x)\n", u32, u32 & ~(RSR_EN | IGN_EN) & 0xffff));
u32 &= ~(RSR_EN | IGN_EN);
u32 &= 0xffff;
- update_pm1a(pThis, pThis->pm1a_sts, u32);
+ apicR3UpdatePm1a(pThis, pThis->pm1a_sts, u32);
DEVACPI_UNLOCK(pThis);
return VINF_SUCCESS;
@@ -1475,7 +1351,7 @@ PDMBOTHCBDECL(int) acpiPM1aEnWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Po
/**
* @callback_method_impl{FNIOMIOPORTIN, PM1a Status}
*/
-PDMBOTHCBDECL(int) acpiPm1aStsRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3Pm1aStsRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
if (cb != 2)
{
@@ -1489,14 +1365,14 @@ PDMBOTHCBDECL(int) acpiPm1aStsRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Po
*pu32 = pThis->pm1a_sts;
DEVACPI_UNLOCK(pThis);
- Log(("acpiPm1aStsRead: %#x\n", *pu32));
+ Log(("acpiR3Pm1aStsRead: %#x\n", *pu32));
return VINF_SUCCESS;
}
/**
* @callback_method_impl{FNIOMIOPORTOUT, PM1a Status}
*/
-PDMBOTHCBDECL(int) acpiPM1aStsWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3PM1aStsWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (cb != 2 && cb != 4)
return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "cb=%d Port=%u u32=%#x\n", cb, Port, u32);
@@ -1504,12 +1380,12 @@ PDMBOTHCBDECL(int) acpiPM1aStsWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT P
ACPIState *pThis = (ACPIState *)pvUser;
DEVACPI_LOCK_R3(pThis);
- Log(("acpiPM1aStsWrite: %#x (%#x)\n", u32, u32 & ~(RSR_STS | IGN_STS) & 0xffff));
+ Log(("acpiR3PM1aStsWrite: %#x (%#x)\n", u32, u32 & ~(RSR_STS | IGN_STS) & 0xffff));
u32 &= 0xffff;
if (u32 & PWRBTN_STS)
pThis->fPowerButtonHandled = true; /* Remember that the guest handled the last power button event */
u32 = pThis->pm1a_sts & ~(u32 & ~(RSR_STS | IGN_STS));
- update_pm1a(pThis, u32, pThis->pm1a_en);
+ apicR3UpdatePm1a(pThis, u32, pThis->pm1a_en);
DEVACPI_UNLOCK(pThis);
return VINF_SUCCESS;
@@ -1518,7 +1394,7 @@ PDMBOTHCBDECL(int) acpiPM1aStsWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT P
/**
* @callback_method_impl{FNIOMIOPORTIN, PM1a Control}
*/
-PDMBOTHCBDECL(int) acpiPm1aCtlRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3Pm1aCtlRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
if (cb != 2)
{
@@ -1532,14 +1408,14 @@ PDMBOTHCBDECL(int) acpiPm1aCtlRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Po
*pu32 = pThis->pm1a_ctl;
DEVACPI_UNLOCK(pThis);
- Log(("acpiPm1aCtlRead: %#x\n", *pu32));
+ Log(("acpiR3Pm1aCtlRead: %#x\n", *pu32));
return VINF_SUCCESS;
}
/**
* @callback_method_impl{FNIOMIOPORTOUT, PM1a Control}
*/
-PDMBOTHCBDECL(int) acpiPM1aCtlWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3PM1aCtlWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (cb != 2 && cb != 4)
return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "cb=%d Port=%u u32=%#x\n", cb, Port, u32);
@@ -1547,7 +1423,7 @@ PDMBOTHCBDECL(int) acpiPM1aCtlWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT P
ACPIState *pThis = (ACPIState *)pvUser;
DEVACPI_LOCK_R3(pThis);
- Log(("acpiPM1aCtlWrite: %#x (%#x)\n", u32, u32 & ~(RSR_CNT | IGN_CNT) & 0xffff));
+ Log(("acpiR3PM1aCtlWrite: %#x (%#x)\n", u32, u32 & ~(RSR_CNT | IGN_CNT) & 0xffff));
u32 &= 0xffff;
pThis->pm1a_ctl = u32 & ~(RSR_CNT | IGN_CNT);
@@ -1565,7 +1441,7 @@ PDMBOTHCBDECL(int) acpiPM1aCtlWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT P
if (pThis->fS1Enabled)
{
LogRel(("Entering S1 power state (powered-on suspend)\n"));
- rc = acpiSleep(pThis);
+ rc = acpiR3DoSleep(pThis);
break;
}
LogRel(("Ignoring guest attempt to enter S1 power state (powered-on suspend)!\n"));
@@ -1575,7 +1451,7 @@ PDMBOTHCBDECL(int) acpiPM1aCtlWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT P
if (pThis->fS4Enabled)
{
LogRel(("Entering S4 power state (suspend to disk)\n"));
- rc = acpiPowerOff(pThis);/* Same behavior as S5 */
+ rc = acpiR3DoPowerOff(pThis);/* Same behavior as S5 */
break;
}
LogRel(("Ignoring guest attempt to enter S4 power state (suspend to disk)!\n"));
@@ -1583,7 +1459,7 @@ PDMBOTHCBDECL(int) acpiPM1aCtlWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT P
case 0x05: /* S5 */
LogRel(("Entering S5 power state (power down)\n"));
- rc = acpiPowerOff(pThis);
+ rc = acpiR3DoPowerOff(pThis);
break;
default:
@@ -1593,7 +1469,7 @@ PDMBOTHCBDECL(int) acpiPM1aCtlWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT P
}
DEVACPI_UNLOCK(pThis);
- Log(("acpiPM1aCtlWrite: rc=%Rrc\n", rc));
+ Log(("acpiR3PM1aCtlWrite: rc=%Rrc\n", rc));
return rc;
}
@@ -1640,7 +1516,7 @@ PDMBOTHCBDECL(int) acpiPMTmrRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port
/**
* @callback_method_impl{FNIOMIOPORTIN, GPE0 Status}
*/
-PDMBOTHCBDECL(int) acpiGpe0StsRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3Gpe0StsRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
if (cb != 1)
{
@@ -1654,14 +1530,14 @@ PDMBOTHCBDECL(int) acpiGpe0StsRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Po
*pu32 = pThis->gpe0_sts & 0xff;
DEVACPI_UNLOCK(pThis);
- Log(("acpiGpe0StsRead: %#x\n", *pu32));
+ Log(("acpiR3Gpe0StsRead: %#x\n", *pu32));
return VINF_SUCCESS;
}
/**
* @callback_method_impl{FNIOMIOPORTOUT, GPE0 Status}
*/
-PDMBOTHCBDECL(int) acpiGpe0StsWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3Gpe0StsWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (cb != 1)
return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "cb=%d Port=%u u32=%#x\n", cb, Port, u32);
@@ -1669,9 +1545,9 @@ PDMBOTHCBDECL(int) acpiGpe0StsWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT P
ACPIState *pThis = (ACPIState *)pvUser;
DEVACPI_LOCK_R3(pThis);
- Log(("acpiGpe0StsWrite: %#x (%#x)\n", u32, pThis->gpe0_sts & ~u32));
+ Log(("acpiR3Gpe0StsWrite: %#x (%#x)\n", u32, pThis->gpe0_sts & ~u32));
u32 = pThis->gpe0_sts & ~u32;
- update_gpe0(pThis, u32, pThis->gpe0_en);
+ apicR3UpdateGpe0(pThis, u32, pThis->gpe0_en);
DEVACPI_UNLOCK(pThis);
return VINF_SUCCESS;
@@ -1680,7 +1556,7 @@ PDMBOTHCBDECL(int) acpiGpe0StsWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT P
/**
* @callback_method_impl{FNIOMIOPORTIN, GPE0 Enable}
*/
-PDMBOTHCBDECL(int) acpiGpe0EnRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3Gpe0EnRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
if (cb != 1)
{
@@ -1694,14 +1570,14 @@ PDMBOTHCBDECL(int) acpiGpe0EnRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Por
*pu32 = pThis->gpe0_en & 0xff;
DEVACPI_UNLOCK(pThis);
- Log(("acpiGpe0EnRead: %#x\n", *pu32));
+ Log(("acpiR3Gpe0EnRead: %#x\n", *pu32));
return VINF_SUCCESS;
}
/**
* @callback_method_impl{FNIOMIOPORTOUT, GPE0 Enable}
*/
-PDMBOTHCBDECL(int) acpiGpe0EnWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3Gpe0EnWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (cb != 1)
return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "cb=%d Port=%u u32=%#x\n", cb, Port, u32);
@@ -1709,8 +1585,8 @@ PDMBOTHCBDECL(int) acpiGpe0EnWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Po
ACPIState *pThis = (ACPIState *)pvUser;
DEVACPI_LOCK_R3(pThis);
- Log(("acpiGpe0EnWrite: %#x\n", u32));
- update_gpe0(pThis, pThis->gpe0_sts, u32);
+ Log(("acpiR3Gpe0EnWrite: %#x\n", u32));
+ apicR3UpdateGpe0(pThis, pThis->gpe0_sts, u32);
DEVACPI_UNLOCK(pThis);
return VINF_SUCCESS;
@@ -1719,9 +1595,9 @@ PDMBOTHCBDECL(int) acpiGpe0EnWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Po
/**
* @callback_method_impl{FNIOMIOPORTOUT, SMI_CMD}
*/
-PDMBOTHCBDECL(int) acpiSmiWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3SmiWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
- Log(("acpiSmiWrite %#x\n", u32));
+ Log(("acpiR3SmiWrite %#x\n", u32));
if (cb != 1)
return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "cb=%d Port=%u u32=%#x\n", cb, Port, u32);
@@ -1733,7 +1609,7 @@ PDMBOTHCBDECL(int) acpiSmiWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port,
else if (u32 == ACPI_DISABLE)
pThis->pm1a_ctl &= ~SCI_EN;
else
- Log(("acpiSmiWrite: %#x <- unknown value\n", u32));
+ Log(("acpiR3SmiWrite: %#x <- unknown value\n", u32));
DEVACPI_UNLOCK(pThis);
return VINF_SUCCESS;
@@ -1742,9 +1618,9 @@ PDMBOTHCBDECL(int) acpiSmiWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port,
/**
* @{FNIOMIOPORTOUT, ACPI_RESET_BLK}
*/
-PDMBOTHCBDECL(int) acpiResetWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3ResetWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
- Log(("acpiResetWrite: %#x\n", u32));
+ Log(("acpiR3ResetWrite: %#x\n", u32));
NOREF(pvUser);
if (cb != 1)
return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "cb=%d Port=%u u32=%#x\n", cb, Port, u32);
@@ -1757,7 +1633,7 @@ PDMBOTHCBDECL(int) acpiResetWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Por
rc = PDMDevHlpVMReset(pDevIns);
}
else
- Log(("acpiResetWrite: %#x <- unknown value\n", u32));
+ Log(("acpiR3ResetWrite: %#x <- unknown value\n", u32));
return rc;
}
@@ -1767,7 +1643,7 @@ PDMBOTHCBDECL(int) acpiResetWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Por
/**
* @callback_method_impl{FNIOMIOPORTOUT, Debug hex value logger}
*/
-PDMBOTHCBDECL(int) acpiDhexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3DhexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
NOREF(pvUser);
switch (cb)
@@ -1789,7 +1665,7 @@ PDMBOTHCBDECL(int) acpiDhexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port
/**
* @callback_method_impl{FNIOMIOPORTOUT, Debug char logger}
*/
-PDMBOTHCBDECL(int) acpiDchrWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
+PDMBOTHCBDECL(int) acpiR3DchrWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
NOREF(pvUser);
switch (cb)
@@ -1812,7 +1688,7 @@ PDMBOTHCBDECL(int) acpiDchrWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port
* @param pThis The ACPI instance.
* @param offset The offset into the I/O space, or -1 if invalid.
*/
-static RTIOPORT acpiCalcPmPort(ACPIState *pThis, int32_t offset)
+static RTIOPORT acpiR3CalcPmPort(ACPIState *pThis, int32_t offset)
{
Assert(pThis->uPmIoPortBase != 0);
@@ -1823,38 +1699,38 @@ static RTIOPORT acpiCalcPmPort(ACPIState *pThis, int32_t offset)
}
/**
- * Called by acpiLoadState and acpiUpdatePmHandlers to register the PM1a, PM
+ * Called by acpiR3LoadState and acpiR3UpdatePmHandlers to register the PM1a, PM
* timer and GPE0 I/O ports.
*
* @returns VBox status code.
* @param pThis The ACPI instance.
*/
-static int acpiRegisterPmHandlers(ACPIState *pThis)
+static int acpiR3RegisterPmHandlers(ACPIState *pThis)
{
int rc = VINF_SUCCESS;
#define R(offset, cnt, writer, reader, description) \
do { \
- rc = PDMDevHlpIOPortRegister(pThis->pDevIns, acpiCalcPmPort(pThis, offset), cnt, pThis, writer, reader, \
+ rc = PDMDevHlpIOPortRegister(pThis->pDevIns, acpiR3CalcPmPort(pThis, offset), cnt, pThis, writer, reader, \
NULL, NULL, description); \
if (RT_FAILURE(rc)) \
return rc; \
} while (0)
#define L (GPE0_BLK_LEN / 2)
- R(PM1a_EVT_OFFSET+2, 1, acpiPM1aEnWrite, acpiPm1aEnRead, "ACPI PM1a Enable");
- R(PM1a_EVT_OFFSET, 1, acpiPM1aStsWrite, acpiPm1aStsRead, "ACPI PM1a Status");
- R(PM1a_CTL_OFFSET, 1, acpiPM1aCtlWrite, acpiPm1aCtlRead, "ACPI PM1a Control");
- R(PM_TMR_OFFSET, 1, NULL, acpiPMTmrRead, "ACPI PM Timer");
- R(GPE0_OFFSET + L, L, acpiGpe0EnWrite, acpiGpe0EnRead, "ACPI GPE0 Enable");
- R(GPE0_OFFSET, L, acpiGpe0StsWrite, acpiGpe0StsRead, "ACPI GPE0 Status");
+ R(PM1a_EVT_OFFSET+2, 1, acpiR3PM1aEnWrite, acpiR3Pm1aEnRead, "ACPI PM1a Enable");
+ R(PM1a_EVT_OFFSET, 1, acpiR3PM1aStsWrite, acpiR3Pm1aStsRead, "ACPI PM1a Status");
+ R(PM1a_CTL_OFFSET, 1, acpiR3PM1aCtlWrite, acpiR3Pm1aCtlRead, "ACPI PM1a Control");
+ R(PM_TMR_OFFSET, 1, NULL, acpiPMTmrRead, "ACPI PM Timer");
+ R(GPE0_OFFSET + L, L, acpiR3Gpe0EnWrite, acpiR3Gpe0EnRead, "ACPI GPE0 Enable");
+ R(GPE0_OFFSET, L, acpiR3Gpe0StsWrite, acpiR3Gpe0StsRead, "ACPI GPE0 Status");
#undef L
#undef R
/* register RC stuff */
if (pThis->fGCEnabled)
{
- rc = PDMDevHlpIOPortRegisterRC(pThis->pDevIns, acpiCalcPmPort(pThis, PM_TMR_OFFSET),
+ rc = PDMDevHlpIOPortRegisterRC(pThis->pDevIns, acpiR3CalcPmPort(pThis, PM_TMR_OFFSET),
1, 0, NULL, "acpiPMTmrRead",
NULL, NULL, "ACPI PM Timer");
AssertRCReturn(rc, rc);
@@ -1863,7 +1739,7 @@ static int acpiRegisterPmHandlers(ACPIState *pThis)
/* register R0 stuff */
if (pThis->fR0Enabled)
{
- rc = PDMDevHlpIOPortRegisterR0(pThis->pDevIns, acpiCalcPmPort(pThis, PM_TMR_OFFSET),
+ rc = PDMDevHlpIOPortRegisterR0(pThis->pDevIns, acpiR3CalcPmPort(pThis, PM_TMR_OFFSET),
1, 0, NULL, "acpiPMTmrRead",
NULL, NULL, "ACPI PM Timer");
AssertRCReturn(rc, rc);
@@ -1873,17 +1749,17 @@ static int acpiRegisterPmHandlers(ACPIState *pThis)
}
/**
- * Called by acpiLoadState and acpiUpdatePmHandlers to unregister the PM1a, PM
+ * Called by acpiR3LoadState and acpiR3UpdatePmHandlers to unregister the PM1a, PM
* timer and GPE0 I/O ports.
*
* @returns VBox status code.
* @param pThis The ACPI instance.
*/
-static int acpiUnregisterPmHandlers(ACPIState *pThis)
+static int acpiR3UnregisterPmHandlers(ACPIState *pThis)
{
#define U(offset, cnt) \
do { \
- int rc = PDMDevHlpIOPortDeregister(pThis->pDevIns, acpiCalcPmPort(pThis, offset), cnt); \
+ int rc = PDMDevHlpIOPortDeregister(pThis->pDevIns, acpiR3CalcPmPort(pThis, offset), cnt); \
AssertRCReturn(rc, rc); \
} while (0)
#define L (GPE0_BLK_LEN / 2)
@@ -1901,7 +1777,7 @@ static int acpiUnregisterPmHandlers(ACPIState *pThis)
}
/**
- * Called by acpiPciConfigWrite and acpiReset to change the location of the
+ * Called by acpiR3PciConfigWrite and acpiReset to change the location of the
* PM1a, PM timer and GPE0 ports.
*
* @returns VBox status code.
@@ -1909,23 +1785,23 @@ static int acpiUnregisterPmHandlers(ACPIState *pThis)
* @param pThis The ACPI instance.
* @param NewIoPortBase The new base address of the I/O ports.
*/
-static int acpiUpdatePmHandlers(ACPIState *pThis, RTIOPORT NewIoPortBase)
+static int acpiR3UpdatePmHandlers(ACPIState *pThis, RTIOPORT NewIoPortBase)
{
Log(("acpi: rebasing PM 0x%x -> 0x%x\n", pThis->uPmIoPortBase, NewIoPortBase));
if (NewIoPortBase != pThis->uPmIoPortBase)
{
- int rc = acpiUnregisterPmHandlers(pThis);
+ int rc = acpiR3UnregisterPmHandlers(pThis);
if (RT_FAILURE(rc))
return rc;
pThis->uPmIoPortBase = NewIoPortBase;
- rc = acpiRegisterPmHandlers(pThis);
+ rc = acpiR3RegisterPmHandlers(pThis);
if (RT_FAILURE(rc))
return rc;
/* We have to update FADT table acccording to the new base */
- rc = acpiPlantTables(pThis);
+ rc = acpiR3PlantTables(pThis);
AssertRC(rc);
if (RT_FAILURE(rc))
return rc;
@@ -1998,7 +1874,7 @@ static const SSMFIELD g_AcpiSavedStateFields6[] =
/**
* @callback_method_impl{FNSSMDEVSAVEEXEC}
*/
-static DECLCALLBACK(int) acpiSaveState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
+static DECLCALLBACK(int) acpiR3SaveState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
{
ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
return SSMR3PutStruct(pSSMHandle, pThis, &g_AcpiSavedStateFields6[0]);
@@ -2007,8 +1883,7 @@ static DECLCALLBACK(int) acpiSaveState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle
/**
* @callback_method_impl{FNSSMDEVLOADEXEC}
*/
-static DECLCALLBACK(int) acpiLoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle,
- uint32_t uVersion, uint32_t uPass)
+static DECLCALLBACK(int) acpiR3LoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, uint32_t uVersion, uint32_t uPass)
{
ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
@@ -2017,7 +1892,7 @@ static DECLCALLBACK(int) acpiLoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle
* Unregister PM handlers, will register with actual base after state
* successfully loaded.
*/
- int rc = acpiUnregisterPmHandlers(pThis);
+ int rc = acpiR3UnregisterPmHandlers(pThis);
if (RT_FAILURE(rc))
return rc;
@@ -2038,17 +1913,17 @@ static DECLCALLBACK(int) acpiLoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle
}
if (RT_SUCCESS(rc))
{
- rc = acpiRegisterPmHandlers(pThis);
+ rc = acpiR3RegisterPmHandlers(pThis);
if (RT_FAILURE(rc))
return rc;
- rc = acpiFetchBatteryStatus(pThis);
+ rc = acpiR3FetchBatteryStatus(pThis);
if (RT_FAILURE(rc))
return rc;
- rc = acpiFetchBatteryInfo(pThis);
+ rc = acpiR3FetchBatteryInfo(pThis);
if (RT_FAILURE(rc))
return rc;
TMTimerLock(pThis->pPmTimerR3, VERR_IGNORED);
- acpiPmTimerReset(pThis, TMTimerGet(pThis->pPmTimerR3));
+ acpiR3PmTimerReset(pThis, TMTimerGet(pThis->pPmTimerR3));
TMTimerUnlock(pThis->pPmTimerR3);
}
return rc;
@@ -2057,7 +1932,7 @@ static DECLCALLBACK(int) acpiLoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
-static DECLCALLBACK(void *) acpiQueryInterface(PPDMIBASE pInterface, const char *pszIID)
+static DECLCALLBACK(void *) acpiR3QueryInterface(PPDMIBASE pInterface, const char *pszIID)
{
ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IBase);
PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
@@ -2074,7 +1949,7 @@ static DECLCALLBACK(void *) acpiQueryInterface(PPDMIBASE pInterface, const char
* @param pvSrc What to check sum.
* @param cbData The amount of data to checksum.
*/
-static uint8_t acpiChecksum(const void * const pvSrc, size_t cbData)
+static uint8_t acpiR3Checksum(const void * const pvSrc, size_t cbData)
{
uint8_t const *pbSrc = (uint8_t const *)pvSrc;
uint8_t uSum = 0;
@@ -2086,9 +1961,9 @@ static uint8_t acpiChecksum(const void * const pvSrc, size_t cbData)
/**
* Prepare a ACPI table header.
*/
-static void acpiPrepareHeader(ACPIState *pThis, ACPITBLHEADER *header,
- const char au8Signature[4],
- uint32_t u32Length, uint8_t u8Revision)
+static void acpiR3PrepareHeader(ACPIState *pThis, ACPITBLHEADER *header,
+ const char au8Signature[4],
+ uint32_t u32Length, uint8_t u8Revision)
{
memcpy(header->au8Signature, au8Signature, 4);
header->u32Length = RT_H2LE_U32(u32Length);
@@ -2104,9 +1979,9 @@ static void acpiPrepareHeader(ACPIState *pThis, ACPITBLHEADER *header,
/**
* Initialize a generic address structure (ACPIGENADDR).
*/
-static void acpiWriteGenericAddr(ACPIGENADDR *g, uint8_t u8AddressSpaceId,
- uint8_t u8RegisterBitWidth, uint8_t u8RegisterBitOffset,
- uint8_t u8AccessSize, uint64_t u64Address)
+static void acpiR3WriteGenericAddr(ACPIGENADDR *g, uint8_t u8AddressSpaceId,
+ uint8_t u8RegisterBitWidth, uint8_t u8RegisterBitOffset,
+ uint8_t u8AccessSize, uint64_t u64Address)
{
g->u8AddressSpaceId = u8AddressSpaceId;
g->u8RegisterBitWidth = u8RegisterBitWidth;
@@ -2118,33 +1993,32 @@ static void acpiWriteGenericAddr(ACPIGENADDR *g, uint8_t u8AddressSpaceId,
/**
* Wrapper around PDMDevHlpPhysWrite used when planting ACPI tables.
*/
-static void acpiPhyscpy(ACPIState *pThis, RTGCPHYS32 dst, const void * const src, size_t size)
+DECLINLINE(void) acpiR3PhysCopy(ACPIState *pThis, RTGCPHYS32 GCPhys32Dst, const void *pvSrc, size_t cbToCopy)
{
- PDMDevHlpPhysWrite(pThis->pDevIns, dst, src, size);
+ PDMDevHlpPhysWrite(pThis->pDevIns, GCPhys32Dst, pvSrc, cbToCopy);
}
/**
* Plant the Differentiated System Description Table (DSDT).
*/
-static void acpiSetupDSDT(ACPIState *pThis, RTGCPHYS32 addr,
- void* pPtr, size_t uDsdtLen)
+static void acpiR3SetupDsdt(ACPIState *pThis, RTGCPHYS32 GCPhys32, void *pvPtr, size_t cbDsdt)
{
- acpiPhyscpy(pThis, addr, pPtr, uDsdtLen);
+ acpiR3PhysCopy(pThis, GCPhys32, pvPtr, cbDsdt);
}
/**
* Plan the Secondary System Description Table (SSDT).
*/
-static void acpiSetupSSDT(ACPIState *pThis, RTGCPHYS32 addr,
+static void acpiR3SetupSsdt(ACPIState *pThis, RTGCPHYS32 addr,
void* pPtr, size_t uSsdtLen)
{
- acpiPhyscpy(pThis, addr, pPtr, uSsdtLen);
+ acpiR3PhysCopy(pThis, addr, pPtr, uSsdtLen);
}
/**
* Plant the Firmware ACPI Control Structure (FACS).
*/
-static void acpiSetupFACS(ACPIState *pThis, RTGCPHYS32 addr)
+static void acpiR3SetupFacs(ACPIState *pThis, RTGCPHYS32 addr)
{
ACPITBLFACS facs;
@@ -2158,19 +2032,20 @@ static void acpiSetupFACS(ACPIState *pThis, RTGCPHYS32 addr)
facs.u64X_FWVector = RT_H2LE_U64(0);
facs.u8Version = 1;
- acpiPhyscpy(pThis, addr, (const uint8_t *)&facs, sizeof(facs));
+ acpiR3PhysCopy(pThis, addr, (const uint8_t *)&facs, sizeof(facs));
}
/**
* Plant the Fixed ACPI Description Table (FADT aka FACP).
*/
-static void acpiSetupFADT(ACPIState *pThis, RTGCPHYS32 GCPhysAcpi1, RTGCPHYS32 GCPhysAcpi2, RTGCPHYS32 GCPhysFacs, RTGCPHYS GCPhysDsdt)
+static void acpiR3SetupFadt(ACPIState *pThis, RTGCPHYS32 GCPhysAcpi1, RTGCPHYS32 GCPhysAcpi2,
+ RTGCPHYS32 GCPhysFacs, RTGCPHYS GCPhysDsdt)
{
ACPITBLFADT fadt;
/* First the ACPI version 2+ version of the structure. */
memset(&fadt, 0, sizeof(fadt));
- acpiPrepareHeader(pThis, &fadt.header, "FACP", sizeof(fadt), 4);
+ acpiR3PrepareHeader(pThis, &fadt.header, "FACP", sizeof(fadt), 4);
fadt.u32FACS = RT_H2LE_U32(GCPhysFacs);
fadt.u32DSDT = RT_H2LE_U32(GCPhysDsdt);
fadt.u8IntModel = 0; /* dropped from the ACPI 2.0 spec. */
@@ -2181,14 +2056,14 @@ static void acpiSetupFADT(ACPIState *pThis, RTGCPHYS32 GCPhysAcpi1, RTGCPHYS32 G
fadt.u8AcpiDisable = ACPI_DISABLE;
fadt.u8S4BIOSReq = 0;
fadt.u8PStateCnt = 0;
- fadt.u32PM1aEVTBLK = RT_H2LE_U32(acpiCalcPmPort(pThis, PM1a_EVT_OFFSET));
- fadt.u32PM1bEVTBLK = RT_H2LE_U32(acpiCalcPmPort(pThis, PM1b_EVT_OFFSET));
- fadt.u32PM1aCTLBLK = RT_H2LE_U32(acpiCalcPmPort(pThis, PM1a_CTL_OFFSET));
- fadt.u32PM1bCTLBLK = RT_H2LE_U32(acpiCalcPmPort(pThis, PM1b_CTL_OFFSET));
- fadt.u32PM2CTLBLK = RT_H2LE_U32(acpiCalcPmPort(pThis, PM2_CTL_OFFSET));
- fadt.u32PMTMRBLK = RT_H2LE_U32(acpiCalcPmPort(pThis, PM_TMR_OFFSET));
- fadt.u32GPE0BLK = RT_H2LE_U32(acpiCalcPmPort(pThis, GPE0_OFFSET));
- fadt.u32GPE1BLK = RT_H2LE_U32(acpiCalcPmPort(pThis, GPE1_OFFSET));
+ fadt.u32PM1aEVTBLK = RT_H2LE_U32(acpiR3CalcPmPort(pThis, PM1a_EVT_OFFSET));
+ fadt.u32PM1bEVTBLK = RT_H2LE_U32(acpiR3CalcPmPort(pThis, PM1b_EVT_OFFSET));
+ fadt.u32PM1aCTLBLK = RT_H2LE_U32(acpiR3CalcPmPort(pThis, PM1a_CTL_OFFSET));
+ fadt.u32PM1bCTLBLK = RT_H2LE_U32(acpiR3CalcPmPort(pThis, PM1b_CTL_OFFSET));
+ fadt.u32PM2CTLBLK = RT_H2LE_U32(acpiR3CalcPmPort(pThis, PM2_CTL_OFFSET));
+ fadt.u32PMTMRBLK = RT_H2LE_U32(acpiR3CalcPmPort(pThis, PM_TMR_OFFSET));
+ fadt.u32GPE0BLK = RT_H2LE_U32(acpiR3CalcPmPort(pThis, GPE0_OFFSET));
+ fadt.u32GPE1BLK = RT_H2LE_U32(acpiR3CalcPmPort(pThis, GPE1_OFFSET));
fadt.u8PM1EVTLEN = 4;
fadt.u8PM1CTLLEN = 2;
fadt.u8PM2CTLLEN = 0;
@@ -2217,27 +2092,27 @@ static void acpiSetupFADT(ACPIState *pThis, RTGCPHYS32 GCPhysAcpi1, RTGCPHYS32 G
if (pThis->fCpuHotPlug)
fadt.u32Flags |= RT_H2LE_U32(FADT_FL_FORCE_APIC_PHYS_DEST_MODE);
- acpiWriteGenericAddr(&fadt.ResetReg, 1, 8, 0, 1, ACPI_RESET_BLK);
+ acpiR3WriteGenericAddr(&fadt.ResetReg, 1, 8, 0, 1, ACPI_RESET_BLK);
fadt.u8ResetVal = ACPI_RESET_REG_VAL;
fadt.u64XFACS = RT_H2LE_U64((uint64_t)GCPhysFacs);
fadt.u64XDSDT = RT_H2LE_U64((uint64_t)GCPhysDsdt);
- acpiWriteGenericAddr(&fadt.X_PM1aEVTBLK, 1, 32, 0, 2, acpiCalcPmPort(pThis, PM1a_EVT_OFFSET));
- acpiWriteGenericAddr(&fadt.X_PM1bEVTBLK, 0, 0, 0, 0, acpiCalcPmPort(pThis, PM1b_EVT_OFFSET));
- acpiWriteGenericAddr(&fadt.X_PM1aCTLBLK, 1, 16, 0, 2, acpiCalcPmPort(pThis, PM1a_CTL_OFFSET));
- acpiWriteGenericAddr(&fadt.X_PM1bCTLBLK, 0, 0, 0, 0, acpiCalcPmPort(pThis, PM1b_CTL_OFFSET));
- acpiWriteGenericAddr(&fadt.X_PM2CTLBLK, 0, 0, 0, 0, acpiCalcPmPort(pThis, PM2_CTL_OFFSET));
- acpiWriteGenericAddr(&fadt.X_PMTMRBLK, 1, 32, 0, 3, acpiCalcPmPort(pThis, PM_TMR_OFFSET));
- acpiWriteGenericAddr(&fadt.X_GPE0BLK, 1, 16, 0, 1, acpiCalcPmPort(pThis, GPE0_OFFSET));
- acpiWriteGenericAddr(&fadt.X_GPE1BLK, 0, 0, 0, 0, acpiCalcPmPort(pThis, GPE1_OFFSET));
- fadt.header.u8Checksum = acpiChecksum(&fadt, sizeof(fadt));
- acpiPhyscpy(pThis, GCPhysAcpi2, &fadt, sizeof(fadt));
+ acpiR3WriteGenericAddr(&fadt.X_PM1aEVTBLK, 1, 32, 0, 2, acpiR3CalcPmPort(pThis, PM1a_EVT_OFFSET));
+ acpiR3WriteGenericAddr(&fadt.X_PM1bEVTBLK, 0, 0, 0, 0, acpiR3CalcPmPort(pThis, PM1b_EVT_OFFSET));
+ acpiR3WriteGenericAddr(&fadt.X_PM1aCTLBLK, 1, 16, 0, 2, acpiR3CalcPmPort(pThis, PM1a_CTL_OFFSET));
+ acpiR3WriteGenericAddr(&fadt.X_PM1bCTLBLK, 0, 0, 0, 0, acpiR3CalcPmPort(pThis, PM1b_CTL_OFFSET));
+ acpiR3WriteGenericAddr(&fadt.X_PM2CTLBLK, 0, 0, 0, 0, acpiR3CalcPmPort(pThis, PM2_CTL_OFFSET));
+ acpiR3WriteGenericAddr(&fadt.X_PMTMRBLK, 1, 32, 0, 3, acpiR3CalcPmPort(pThis, PM_TMR_OFFSET));
+ acpiR3WriteGenericAddr(&fadt.X_GPE0BLK, 1, 16, 0, 1, acpiR3CalcPmPort(pThis, GPE0_OFFSET));
+ acpiR3WriteGenericAddr(&fadt.X_GPE1BLK, 0, 0, 0, 0, acpiR3CalcPmPort(pThis, GPE1_OFFSET));
+ fadt.header.u8Checksum = acpiR3Checksum(&fadt, sizeof(fadt));
+ acpiR3PhysCopy(pThis, GCPhysAcpi2, &fadt, sizeof(fadt));
/* Now the ACPI 1.0 version. */
fadt.header.u32Length = ACPITBLFADT_VERSION1_SIZE;
fadt.u8IntModel = INT_MODEL_DUAL_PIC;
fadt.header.u8Checksum = 0; /* Must be zeroed before recalculating checksum! */
- fadt.header.u8Checksum = acpiChecksum(&fadt, ACPITBLFADT_VERSION1_SIZE);
- acpiPhyscpy(pThis, GCPhysAcpi1, &fadt, ACPITBLFADT_VERSION1_SIZE);
+ fadt.header.u8Checksum = acpiR3Checksum(&fadt, ACPITBLFADT_VERSION1_SIZE);
+ acpiR3PhysCopy(pThis, GCPhysAcpi1, &fadt, ACPITBLFADT_VERSION1_SIZE);
}
/**
@@ -2247,7 +2122,7 @@ static void acpiSetupFADT(ACPIState *pThis, RTGCPHYS32 GCPhysAcpi1, RTGCPHYS32 G
* vs 64 bits addresses for description headers. RSDT is for ACPI 1.0. XSDT for
* ACPI 2.0 and up.
*/
-static int acpiSetupRSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)
+static int acpiR3SetupRsdt(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)
{
ACPITBLRSDT *rsdt;
const size_t size = sizeof(ACPITBLHEADER) + nb_entries * sizeof(rsdt->u32Entry[0]);
@@ -2256,14 +2131,14 @@ static int acpiSetupRSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entr
if (!rsdt)
return PDMDEV_SET_ERROR(pThis->pDevIns, VERR_NO_TMP_MEMORY, N_("Cannot allocate RSDT"));
- acpiPrepareHeader(pThis, &rsdt->header, "RSDT", (uint32_t)size, 1);
+ acpiR3PrepareHeader(pThis, &rsdt->header, "RSDT", (uint32_t)size, 1);
for (unsigned int i = 0; i < nb_entries; ++i)
{
rsdt->u32Entry[i] = RT_H2LE_U32(addrs[i]);
Log(("Setup RSDT: [%d] = %x\n", i, rsdt->u32Entry[i]));
}
- rsdt->header.u8Checksum = acpiChecksum(rsdt, size);
- acpiPhyscpy(pThis, addr, rsdt, size);
+ rsdt->header.u8Checksum = acpiR3Checksum(rsdt, size);
+ acpiR3PhysCopy(pThis, addr, rsdt, size);
RTMemFree(rsdt);
return VINF_SUCCESS;
}
@@ -2271,7 +2146,7 @@ static int acpiSetupRSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entr
/**
* Plant the Extended System Description Table.
*/
-static int acpiSetupXSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)
+static int acpiR3SetupXsdt(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)
{
ACPITBLXSDT *xsdt;
const size_t size = sizeof(ACPITBLHEADER) + nb_entries * sizeof(xsdt->u64Entry[0]);
@@ -2280,7 +2155,7 @@ static int acpiSetupXSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entr
if (!xsdt)
return VERR_NO_TMP_MEMORY;
- acpiPrepareHeader(pThis, &xsdt->header, "XSDT", (uint32_t)size, 1 /* according to ACPI 3.0 specs */);
+ acpiR3PrepareHeader(pThis, &xsdt->header, "XSDT", (uint32_t)size, 1 /* according to ACPI 3.0 specs */);
if (pThis->fUseCust)
memcpy(xsdt->header.au8OemTabId, pThis->au8OemTabId, 8);
@@ -2290,8 +2165,8 @@ static int acpiSetupXSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entr
xsdt->u64Entry[i] = RT_H2LE_U64((uint64_t)addrs[i]);
Log(("Setup XSDT: [%d] = %RX64\n", i, xsdt->u64Entry[i]));
}
- xsdt->header.u8Checksum = acpiChecksum(xsdt, size);
- acpiPhyscpy(pThis, addr, xsdt, size);
+ xsdt->header.u8Checksum = acpiR3Checksum(xsdt, size);
+ acpiR3PhysCopy(pThis, addr, xsdt, size);
RTMemFree(xsdt);
return VINF_SUCCESS;
}
@@ -2299,36 +2174,153 @@ static int acpiSetupXSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entr
/**
* Plant the Root System Description Pointer (RSDP).
*/
-static void acpiSetupRSDP(ACPIState *pThis, ACPITBLRSDP *rsdp, RTGCPHYS32 GCPhysRsdt, RTGCPHYS GCPhysXsdt)
+static void acpiR3SetupRsdp(ACPIState *pThis, ACPITBLRSDP *rsdp, RTGCPHYS32 GCPhysRsdt, RTGCPHYS GCPhysXsdt)
{
memset(rsdp, 0, sizeof(*rsdp));
- /* ACPI 1.0 part (RSDT */
+ /* ACPI 1.0 part (RSDT) */
memcpy(rsdp->au8Signature, "RSD PTR ", 8);
memcpy(rsdp->au8OemId, pThis->au8OemId, 6);
rsdp->u8Revision = ACPI_REVISION;
rsdp->u32RSDT = RT_H2LE_U32(GCPhysRsdt);
- rsdp->u8Checksum = acpiChecksum(rsdp, RT_OFFSETOF(ACPITBLRSDP, u32Length));
+ rsdp->u8Checksum = acpiR3Checksum(rsdp, RT_OFFSETOF(ACPITBLRSDP, u32Length));
/* ACPI 2.0 part (XSDT) */
rsdp->u32Length = RT_H2LE_U32(sizeof(ACPITBLRSDP));
rsdp->u64XSDT = RT_H2LE_U64(GCPhysXsdt);
- rsdp->u8ExtChecksum = acpiChecksum(rsdp, sizeof(ACPITBLRSDP));
+ rsdp->u8ExtChecksum = acpiR3Checksum(rsdp, sizeof(ACPITBLRSDP));
}
/**
+ * Multiple APIC Description Table.
+ *
+ * This structure looks somewhat convoluted due layout of MADT table in MP case.
+ * There extpected to be multiple LAPIC records for each CPU, thus we cannot
+ * use regular C structure and proxy to raw memory instead.
+ */
+class AcpiTableMadt
+{
+ /**
+ * All actual data stored in dynamically allocated memory pointed by this field.
+ */
+ uint8_t *m_pbData;
+ /**
+ * Number of CPU entries in this MADT.
+ */
+ uint32_t m_cCpus;
+
+ /**
+ * Number of interrupt overrides.
+ */
+ uint32_t m_cIsos;
+
+public:
+ /**
+ * Address of ACPI header
+ */
+ inline ACPITBLHEADER *header_addr(void) const
+ {
+ return (ACPITBLHEADER *)m_pbData;
+ }
+
+ /**
+ * Address of local APIC for each CPU. Note that different CPUs address different LAPICs,
+ * although address is the same for all of them.
+ */
+ inline uint32_t *u32LAPIC_addr(void) const
+ {
+ return (uint32_t *)(header_addr() + 1);
+ }
+
+ /**
+ * Address of APIC flags
+ */
+ inline uint32_t *u32Flags_addr(void) const
+ {
+ return (uint32_t *)(u32LAPIC_addr() + 1);
+ }
+
+ /**
+ * Address of ISO description
+ */
+ inline ACPITBLISO *ISO_addr(void) const
+ {
+ return (ACPITBLISO *)(u32Flags_addr() + 1);
+ }
+
+ /**
+ * Address of per-CPU LAPIC descriptions
+ */
+ inline ACPITBLLAPIC *LApics_addr(void) const
+ {
+ return (ACPITBLLAPIC *)(ISO_addr() + m_cIsos);
+ }
+
+ /**
+ * Address of IO APIC description
+ */
+ inline ACPITBLIOAPIC *IOApic_addr(void) const
+ {
+ return (ACPITBLIOAPIC *)(LApics_addr() + m_cCpus);
+ }
+
+ /**
+ * Size of MADT.
+ * Note that this function assumes IOApic to be the last field in structure.
+ */
+ inline uint32_t size(void) const
+ {
+ return (uint8_t *)(IOApic_addr() + 1) - (uint8_t *)header_addr();
+ }
+
+ /**
+ * Raw data of MADT.
+ */
+ inline const uint8_t *data(void) const
+ {
+ return m_pbData;
+ }
+
+ /**
+ * Size of MADT for given ACPI config, useful to compute layout.
+ */
+ static uint32_t sizeFor(ACPIState *pThis, uint32_t cIsos)
+ {
+ return AcpiTableMadt(pThis->cCpus, cIsos).size();
+ }
+
+ /*
+ * Constructor, only works in Ring 3, doesn't look like a big deal.
+ */
+ AcpiTableMadt(uint32_t cCpus, uint32_t cIsos)
+ {
+ m_cCpus = cCpus;
+ m_cIsos = cIsos;
+ m_pbData = NULL; /* size() uses this and gcc will complain if not initialized. */
+ uint32_t cb = size();
+ m_pbData = (uint8_t *)RTMemAllocZ(cb);
+ }
+
+ ~AcpiTableMadt()
+ {
+ RTMemFree(m_pbData);
+ }
+};
+
+
+/**
* Plant the Multiple APIC Description Table (MADT).
*
* @note APIC without IO-APIC hangs Windows Vista therefore we setup both.
*
* @todo All hardcoded, should set this up based on the actual VM config!!!!!
*/
-static void acpiSetupMADT(ACPIState *pThis, RTGCPHYS32 addr)
+static void acpiR3SetupMadt(ACPIState *pThis, RTGCPHYS32 addr)
{
uint16_t cpus = pThis->cCpus;
- AcpiTableMADT madt(cpus, NUMBER_OF_IRQ_SOURCE_OVERRIDES);
+ AcpiTableMadt madt(cpus, NUMBER_OF_IRQ_SOURCE_OVERRIDES);
- acpiPrepareHeader(pThis, madt.header_addr(), "APIC", madt.size(), 2);
+ acpiR3PrepareHeader(pThis, madt.header_addr(), "APIC", madt.size(), 2);
*madt.u32LAPIC_addr() = RT_H2LE_U32(0xfee00000);
*madt.u32Flags_addr() = RT_H2LE_U32(PCAT_COMPAT);
@@ -2387,22 +2379,22 @@ static void acpiSetupMADT(ACPIState *pThis, RTGCPHYS32 addr)
isos[1].u16Flags = 0xd; /* active high, level triggered */
Assert(NUMBER_OF_IRQ_SOURCE_OVERRIDES == 2);
- madt.header_addr()->u8Checksum = acpiChecksum(madt.data(), madt.size());
- acpiPhyscpy(pThis, addr, madt.data(), madt.size());
+ madt.header_addr()->u8Checksum = acpiR3Checksum(madt.data(), madt.size());
+ acpiR3PhysCopy(pThis, addr, madt.data(), madt.size());
}
/**
* Plant the High Performance Event Timer (HPET) descriptor.
*/
-static void acpiSetupHPET(ACPIState *pThis, RTGCPHYS32 addr)
+static void acpiR3SetupHpet(ACPIState *pThis, RTGCPHYS32 addr)
{
ACPITBLHPET hpet;
memset(&hpet, 0, sizeof(hpet));
- acpiPrepareHeader(pThis, &hpet.aHeader, "HPET", sizeof(hpet), 1);
+ acpiR3PrepareHeader(pThis, &hpet.aHeader, "HPET", sizeof(hpet), 1);
/* Keep base address consistent with appropriate DSDT entry (vbox.dsl) */
- acpiWriteGenericAddr(&hpet.HpetAddr,
+ acpiR3WriteGenericAddr(&hpet.HpetAddr,
0 /* Memory address space */,
64 /* Register bit width */,
0 /* Bit offset */,
@@ -2414,36 +2406,36 @@ static void acpiSetupHPET(ACPIState *pThis, RTGCPHYS32 addr)
hpet.u32MinTick = 4096;
hpet.u8Attributes = 0;
- hpet.aHeader.u8Checksum = acpiChecksum(&hpet, sizeof(hpet));
+ hpet.aHeader.u8Checksum = acpiR3Checksum(&hpet, sizeof(hpet));
- acpiPhyscpy(pThis, addr, (const uint8_t *)&hpet, sizeof(hpet));
+ acpiR3PhysCopy(pThis, addr, (const uint8_t *)&hpet, sizeof(hpet));
}
/** Custom Description Table */
-static void acpiSetupCUST(ACPIState *pThis, RTGCPHYS32 addr)
+static void acpiR3SetupCust(ACPIState *pThis, RTGCPHYS32 addr)
{
ACPITBLCUST cust;
/* First the ACPI version 1 version of the structure. */
memset(&cust, 0, sizeof(cust));
- acpiPrepareHeader(pThis, &cust.header, "CUST", sizeof(cust), 1);
+ acpiR3PrepareHeader(pThis, &cust.header, "CUST", sizeof(cust), 1);
memcpy(cust.header.au8OemTabId, pThis->au8OemTabId, 8);
cust.header.u32OemRevision = RT_H2LE_U32(pThis->u32OemRevision);
- cust.header.u8Checksum = acpiChecksum((uint8_t *)&cust, sizeof(cust));
+ cust.header.u8Checksum = acpiR3Checksum((uint8_t *)&cust, sizeof(cust));
- acpiPhyscpy(pThis, addr, pThis->pu8CustBin, pThis->cbCustBin);
+ acpiR3PhysCopy(pThis, addr, pThis->pu8CustBin, pThis->cbCustBin);
}
/**
- * Used by acpiPlantTables to plant a MMCONFIG PCI config space access (MCFG)
+ * Used by acpiR3PlantTables to plant a MMCONFIG PCI config space access (MCFG)
* descriptor.
*
* @param pThis The ACPI instance.
* @param GCPhysDst Where to plant it.
*/
-static void acpiSetupMCFG(ACPIState *pThis, RTGCPHYS32 GCPhysDst)
+static void acpiR3SetupMcfg(ACPIState *pThis, RTGCPHYS32 GCPhysDst)
{
struct
{
@@ -2455,23 +2447,23 @@ static void acpiSetupMCFG(ACPIState *pThis, RTGCPHYS32 GCPhysDst)
RT_ZERO(tbl);
- acpiPrepareHeader(pThis, &tbl.hdr.aHeader, "MCFG", sizeof(tbl), 1);
+ acpiR3PrepareHeader(pThis, &tbl.hdr.aHeader, "MCFG", sizeof(tbl), 1);
tbl.entry.u64BaseAddress = pThis->u64PciConfigMMioAddress;
tbl.entry.u8StartBus = u8StartBus;
tbl.entry.u8EndBus = u8EndBus;
// u16PciSegmentGroup must match _SEG in ACPI table
- tbl.hdr.aHeader.u8Checksum = acpiChecksum(&tbl, sizeof(tbl));
+ tbl.hdr.aHeader.u8Checksum = acpiR3Checksum(&tbl, sizeof(tbl));
- acpiPhyscpy(pThis, GCPhysDst, (const uint8_t *)&tbl, sizeof(tbl));
+ acpiR3PhysCopy(pThis, GCPhysDst, (const uint8_t *)&tbl, sizeof(tbl));
}
/**
- * Used by acpiPlantTables and acpiConstruct.
+ * Used by acpiR3PlantTables and acpiConstruct.
*
* @returns Guest memory address.
*/
-static uint32_t find_rsdp_space(void)
+static uint32_t apicR3FindRsdpSpace(void)
{
return 0xe0000;
}
@@ -2479,7 +2471,7 @@ static uint32_t find_rsdp_space(void)
/**
* Create the ACPI tables in guest memory.
*/
-static int acpiPlantTables(ACPIState *pThis)
+static int acpiR3PlantTables(ACPIState *pThis)
{
int rc;
RTGCPHYS32 GCPhysCur, GCPhysRsdt, GCPhysXsdt, GCPhysFadtAcpi1, GCPhysFadtAcpi2, GCPhysFacs, GCPhysDsdt;
@@ -2565,7 +2557,7 @@ static int acpiPlantTables(ACPIState *pThis)
if (pThis->u8UseIOApic)
{
GCPhysApic = GCPhysCur;
- GCPhysCur = RT_ALIGN_32(GCPhysCur + AcpiTableMADT::sizeFor(pThis, NUMBER_OF_IRQ_SOURCE_OVERRIDES), 16);
+ GCPhysCur = RT_ALIGN_32(GCPhysCur + AcpiTableMadt::sizeFor(pThis, NUMBER_OF_IRQ_SOURCE_OVERRIDES), 16);
}
if (pThis->fUseHpet)
{
@@ -2585,29 +2577,29 @@ static int acpiPlantTables(ACPIState *pThis)
}
void *pvSsdtCode = NULL;
- size_t cbSsdtSize = 0;
- rc = acpiPrepareSsdt(pThis->pDevIns, &pvSsdtCode, &cbSsdtSize);
+ size_t cbSsdt = 0;
+ rc = acpiPrepareSsdt(pThis->pDevIns, &pvSsdtCode, &cbSsdt);
if (RT_FAILURE(rc))
return rc;
GCPhysSsdt = GCPhysCur;
- GCPhysCur = RT_ALIGN_32(GCPhysCur + cbSsdtSize, 16);
+ GCPhysCur = RT_ALIGN_32(GCPhysCur + cbSsdt, 16);
GCPhysDsdt = GCPhysCur;
void *pvDsdtCode = NULL;
- size_t cbDsdtSize = 0;
- rc = acpiPrepareDsdt(pThis->pDevIns, &pvDsdtCode, &cbDsdtSize);
+ size_t cbDsdt = 0;
+ rc = acpiPrepareDsdt(pThis->pDevIns, &pvDsdtCode, &cbDsdt);
if (RT_FAILURE(rc))
return rc;
- GCPhysCur = RT_ALIGN_32(GCPhysCur + cbDsdtSize, 16);
+ GCPhysCur = RT_ALIGN_32(GCPhysCur + cbDsdt, 16);
if (GCPhysCur > 0x10000)
return PDMDEV_SET_ERROR(pThis->pDevIns, VERR_TOO_MUCH_DATA,
N_("Error: ACPI tables bigger than 64KB"));
- Log(("RSDP 0x%08X\n", find_rsdp_space()));
+ Log(("RSDP 0x%08X\n", apicR3FindRsdpSpace()));
addend = pThis->cbRamLow - 0x10000;
Log(("RSDT 0x%08X XSDT 0x%08X\n", GCPhysRsdt + addend, GCPhysXsdt + addend));
Log(("FACS 0x%08X FADT (1.0) 0x%08X, FADT (2+) 0x%08X\n", GCPhysFacs + addend, GCPhysFadtAcpi1 + addend, GCPhysFadtAcpi2 + addend));
@@ -2623,54 +2615,54 @@ static int acpiPlantTables(ACPIState *pThis)
Log((" SSDT 0x%08X", GCPhysSsdt + addend));
Log(("\n"));
- acpiSetupRSDP(pThis, (ACPITBLRSDP *)pThis->au8RSDPPage, GCPhysRsdt + addend, GCPhysXsdt + addend);
- acpiSetupDSDT(pThis, GCPhysDsdt + addend, pvDsdtCode, cbDsdtSize);
+ acpiR3SetupRsdp(pThis, (ACPITBLRSDP *)pThis->au8RSDPPage, GCPhysRsdt + addend, GCPhysXsdt + addend);
+ acpiR3SetupDsdt(pThis, GCPhysDsdt + addend, pvDsdtCode, cbDsdt);
acpiCleanupDsdt(pThis->pDevIns, pvDsdtCode);
- acpiSetupFACS(pThis, GCPhysFacs + addend);
- acpiSetupFADT(pThis, GCPhysFadtAcpi1 + addend, GCPhysFadtAcpi2 + addend, GCPhysFacs + addend, GCPhysDsdt + addend);
+ acpiR3SetupFacs(pThis, GCPhysFacs + addend);
+ acpiR3SetupFadt(pThis, GCPhysFadtAcpi1 + addend, GCPhysFadtAcpi2 + addend, GCPhysFacs + addend, GCPhysDsdt + addend);
aGCPhysRsdt[0] = GCPhysFadtAcpi1 + addend;
aGCPhysXsdt[0] = GCPhysFadtAcpi2 + addend;
if (pThis->u8UseIOApic)
{
- acpiSetupMADT(pThis, GCPhysApic + addend);
+ acpiR3SetupMadt(pThis, GCPhysApic + addend);
aGCPhysRsdt[iMadt] = GCPhysApic + addend;
aGCPhysXsdt[iMadt] = GCPhysApic + addend;
}
if (pThis->fUseHpet)
{
- acpiSetupHPET(pThis, GCPhysHpet + addend);
+ acpiR3SetupHpet(pThis, GCPhysHpet + addend);
aGCPhysRsdt[iHpet] = GCPhysHpet + addend;
aGCPhysXsdt[iHpet] = GCPhysHpet + addend;
}
if (pThis->fUseMcfg)
{
- acpiSetupMCFG(pThis, GCPhysMcfg + addend);
+ acpiR3SetupMcfg(pThis, GCPhysMcfg + addend);
aGCPhysRsdt[iMcfg] = GCPhysMcfg + addend;
aGCPhysXsdt[iMcfg] = GCPhysMcfg + addend;
}
if (pThis->fUseCust)
{
- acpiSetupCUST(pThis, GCPhysCust + addend);
+ acpiR3SetupCust(pThis, GCPhysCust + addend);
aGCPhysRsdt[iCust] = GCPhysCust + addend;
aGCPhysXsdt[iCust] = GCPhysCust + addend;
}
- acpiSetupSSDT(pThis, GCPhysSsdt + addend, pvSsdtCode, cbSsdtSize);
+ acpiR3SetupSsdt(pThis, GCPhysSsdt + addend, pvSsdtCode, cbSsdt);
acpiCleanupSsdt(pThis->pDevIns, pvSsdtCode);
aGCPhysRsdt[iSsdt] = GCPhysSsdt + addend;
aGCPhysXsdt[iSsdt] = GCPhysSsdt + addend;
- rc = acpiSetupRSDT(pThis, GCPhysRsdt + addend, cAddr, aGCPhysRsdt);
+ rc = acpiR3SetupRsdt(pThis, GCPhysRsdt + addend, cAddr, aGCPhysRsdt);
if (RT_FAILURE(rc))
return rc;
- return acpiSetupXSDT(pThis, GCPhysXsdt + addend, cAddr, aGCPhysXsdt);
+ return acpiR3SetupXsdt(pThis, GCPhysXsdt + addend, cAddr, aGCPhysXsdt);
}
/**
* @callback_method_impl{FNPCICONFIGREAD}
*/
-static DECLCALLBACK(uint32_t) acpiPciConfigRead(PPCIDEVICE pPciDev, uint32_t Address, unsigned cb)
+static DECLCALLBACK(uint32_t) acpiR3PciConfigRead(PPCIDEVICE pPciDev, uint32_t Address, unsigned cb)
{
PPDMDEVINS pDevIns = pPciDev->pDevIns;
ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
@@ -2682,7 +2674,7 @@ static DECLCALLBACK(uint32_t) acpiPciConfigRead(PPCIDEVICE pPciDev, uint32_t Add
/**
* @callback_method_impl{FNPCICONFIGWRITE}
*/
-static DECLCALLBACK(void) acpiPciConfigWrite(PPCIDEVICE pPciDev, uint32_t Address, uint32_t u32Value, unsigned cb)
+static DECLCALLBACK(void) acpiR3PciConfigWrite(PPCIDEVICE pPciDev, uint32_t Address, uint32_t u32Value, unsigned cb)
{
PPDMDEVINS pDevIns = pPciDev->pDevIns;
ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
@@ -2707,7 +2699,7 @@ static DECLCALLBACK(void) acpiPciConfigWrite(PPCIDEVICE pPciDev, uint32_t Addres
RTIOPORT NewIoPortBase = (RTIOPORT)PCIDevGetDWord(pPciDev, 0x40);
NewIoPortBase &= 0xffc0;
- int rc = acpiUpdatePmHandlers(pThis, NewIoPortBase);
+ int rc = acpiR3UpdatePmHandlers(pThis, NewIoPortBase);
AssertRC(rc);
}
}
@@ -2725,7 +2717,7 @@ static DECLCALLBACK(void) acpiPciConfigWrite(PPCIDEVICE pPciDev, uint32_t Addres
*
* @remarks This code path is not used during construction.
*/
-static DECLCALLBACK(int) acpiAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
+static DECLCALLBACK(int) acpiR3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
{
ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
LogFlow(("acpiAttach: pDevIns=%p iLUN=%u fFlags=%#x\n", pDevIns, iLUN, fFlags));
@@ -2756,7 +2748,7 @@ static DECLCALLBACK(int) acpiAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t
pThis->u32CpuEvent = iLUN;
/* Notify the guest */
- update_gpe0(pThis, pThis->gpe0_sts | 0x2, pThis->gpe0_en);
+ apicR3UpdateGpe0(pThis, pThis->gpe0_sts | 0x2, pThis->gpe0_en);
}
}
DEVACPI_UNLOCK(pThis);
@@ -2770,7 +2762,7 @@ static DECLCALLBACK(int) acpiAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t
* @param iLUN The logical unit which is being detached.
* @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
*/
-static DECLCALLBACK(void) acpiDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
+static DECLCALLBACK(void) acpiR3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
{
ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
@@ -2791,7 +2783,7 @@ static DECLCALLBACK(void) acpiDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t
pThis->u32CpuEvent = iLUN;
/* Notify the guest */
- update_gpe0(pThis, pThis->gpe0_sts | 0x2, pThis->gpe0_en);
+ apicR3UpdateGpe0(pThis, pThis->gpe0_sts | 0x2, pThis->gpe0_en);
}
else
AssertMsgFailed(("CPU is still locked by the guest\n"));
@@ -2802,7 +2794,7 @@ static DECLCALLBACK(void) acpiDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t
/**
* @interface_method_impl{PDMDEVREG,pfnResume}
*/
-static DECLCALLBACK(void) acpiResume(PPDMDEVINS pDevIns)
+static DECLCALLBACK(void) acpiR3Resume(PPDMDEVINS pDevIns)
{
ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
if (pThis->fSetWakeupOnResume)
@@ -2814,9 +2806,18 @@ static DECLCALLBACK(void) acpiResume(PPDMDEVINS pDevIns)
}
/**
+ * @interface_method_impl{PDMDEVREG,pfnMemSetup}
+ */
+static DECLCALLBACK(void) acpiR3MemSetup(PPDMDEVINS pDevIns, PDMDEVMEMSETUPCTX enmCtx)
+{
+ ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
+ acpiR3PlantTables(pThis);
+}
+
+/**
* @interface_method_impl{PDMDEVREG,pfnReset}
*/
-static DECLCALLBACK(void) acpiReset(PPDMDEVINS pDevIns)
+static DECLCALLBACK(void) acpiR3Reset(PPDMDEVINS pDevIns)
{
ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
@@ -2825,7 +2826,7 @@ static DECLCALLBACK(void) acpiReset(PPDMDEVINS pDevIns)
pThis->pm1a_sts = 0;
pThis->pm1a_ctl = 0;
pThis->u64PmTimerInitial = TMTimerGet(pThis->pPmTimerR3);
- acpiPmTimerReset(pThis, pThis->u64PmTimerInitial);
+ acpiR3PmTimerReset(pThis, pThis->u64PmTimerInitial);
pThis->uBatteryIndex = 0;
pThis->uSystemInfoIndex = 0;
pThis->gpe0_en = 0;
@@ -2834,15 +2835,13 @@ static DECLCALLBACK(void) acpiReset(PPDMDEVINS pDevIns)
TMTimerUnlock(pThis->pPmTimerR3);
/** @todo Should we really reset PM base? */
- acpiUpdatePmHandlers(pThis, PM_PORT_BASE);
-
- acpiPlantTables(pThis);
+ acpiR3UpdatePmHandlers(pThis, PM_PORT_BASE);
}
/**
* @interface_method_impl{PDMDEVREG,pfnRelocate}
*/
-static DECLCALLBACK(void) acpiRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
+static DECLCALLBACK(void) acpiR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
{
ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
pThis->pPmTimerRC = TMTimerRCPtr(pThis->pPmTimerR3);
@@ -2852,7 +2851,7 @@ static DECLCALLBACK(void) acpiRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
/**
* @interface_methid_impl{PDMDEVREG,pfnDestruct}
*/
-static DECLCALLBACK(int) acpiDestruct(PPDMDEVINS pDevIns)
+static DECLCALLBACK(int) acpiR3Destruct(PPDMDEVINS pDevIns)
{
ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
if (pThis->pu8CustBin)
@@ -2866,7 +2865,7 @@ static DECLCALLBACK(int) acpiDestruct(PPDMDEVINS pDevIns)
/**
* @interface_method_impl{PDMDEVREG,pfnConstruct}
*/
-static DECLCALLBACK(int) acpiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
+static DECLCALLBACK(int) acpiR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
{
ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
@@ -2888,19 +2887,21 @@ static DECLCALLBACK(int) acpiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMN
VMCPUSET_ADD(&pThis->CpuSetLocked, 0);
/* IBase */
- pThis->IBase.pfnQueryInterface = acpiQueryInterface;
+ pThis->IBase.pfnQueryInterface = acpiR3QueryInterface;
/* IACPIPort */
- pThis->IACPIPort.pfnSleepButtonPress = acpiPort_SleepButtonPress;
- pThis->IACPIPort.pfnPowerButtonPress = acpiPort_PowerButtonPress;
- pThis->IACPIPort.pfnGetPowerButtonHandled = acpiPort_GetPowerButtonHandled;
- pThis->IACPIPort.pfnGetGuestEnteredACPIMode = acpiPort_GetGuestEnteredACPIMode;
- pThis->IACPIPort.pfnGetCpuStatus = acpiPort_GetCpuStatus;
+ pThis->IACPIPort.pfnSleepButtonPress = acpiR3Port_SleepButtonPress;
+ pThis->IACPIPort.pfnPowerButtonPress = acpiR3Port_PowerButtonPress;
+ pThis->IACPIPort.pfnGetPowerButtonHandled = acpiR3Port_GetPowerButtonHandled;
+ pThis->IACPIPort.pfnGetGuestEnteredACPIMode = acpiR3Port_GetGuestEnteredACPIMode;
+ pThis->IACPIPort.pfnGetCpuStatus = acpiR3Port_GetCpuStatus;
- /* Set the default critical section to NOP (related to the PM timer). */
+ /*
+ * Set the default critical section to NOP (related to the PM timer).
+ */
int rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns));
AssertRCReturn(rc, rc);
- rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, RT_SRC_POS, "acpi%u", iInstance);
+ rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, RT_SRC_POS, "acpi#%u", iInstance);
AssertRCReturn(rc, rc);
/*
@@ -3224,12 +3225,15 @@ static DECLCALLBACK(int) acpiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMN
/*
* Plant ACPI tables.
*/
- RTGCPHYS32 GCPhysRsdp = find_rsdp_space();
+ /** @todo Part of this is redone by acpiR3MemSetup, we only need to init the
+ * au8RSDPPage here. However, there should be no harm in doing it
+ * twice, so the lazy bird is taking the quick way out for now. */
+ RTGCPHYS32 GCPhysRsdp = apicR3FindRsdpSpace();
if (!GCPhysRsdp)
return PDMDEV_SET_ERROR(pDevIns, VERR_NO_MEMORY,
N_("Can not find space for RSDP. ACPI is disabled"));
- rc = acpiPlantTables(pThis);
+ rc = acpiR3PlantTables(pThis);
if (RT_FAILURE(rc))
return rc;
@@ -3241,7 +3245,7 @@ static DECLCALLBACK(int) acpiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMN
/*
* Register I/O ports.
*/
- rc = acpiRegisterPmHandlers(pThis);
+ rc = acpiR3RegisterPmHandlers(pThis);
if (RT_FAILURE(rc))
return rc;
@@ -3252,23 +3256,23 @@ static DECLCALLBACK(int) acpiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMN
if (RT_FAILURE(rc)) \
return rc; \
} while (0)
- R(SMI_CMD, 1, acpiSmiWrite, NULL, "ACPI SMI");
+ R(SMI_CMD, 1, acpiR3SmiWrite, NULL, "ACPI SMI");
#ifdef DEBUG_ACPI
- R(DEBUG_HEX, 1, acpiDhexWrite, NULL, "ACPI Debug hex");
- R(DEBUG_CHR, 1, acpiDchrWrite, NULL, "ACPI Debug char");
+ R(DEBUG_HEX, 1, acpiR3DhexWrite, NULL, "ACPI Debug hex");
+ R(DEBUG_CHR, 1, acpiR3DchrWrite, NULL, "ACPI Debug char");
#endif
- R(BAT_INDEX, 1, acpiBatIndexWrite, NULL, "ACPI Battery status index");
- R(BAT_DATA, 1, NULL, acpiBatDataRead, "ACPI Battery status data");
- R(SYSI_INDEX, 1, acpiSysInfoIndexWrite, NULL, "ACPI system info index");
- R(SYSI_DATA, 1, acpiSysInfoDataWrite, acpiSysInfoDataRead, "ACPI system info data");
- R(ACPI_RESET_BLK, 1, acpiResetWrite, NULL, "ACPI Reset");
+ R(BAT_INDEX, 1, acpiR3BatIndexWrite, NULL, "ACPI Battery status index");
+ R(BAT_DATA, 1, NULL, acpiR3BatDataRead, "ACPI Battery status data");
+ R(SYSI_INDEX, 1, acpiR3SysInfoIndexWrite, NULL, "ACPI system info index");
+ R(SYSI_DATA, 1, acpiR3SysInfoDataWrite, acpiR3SysInfoDataRead, "ACPI system info data");
+ R(ACPI_RESET_BLK, 1, acpiR3ResetWrite, NULL, "ACPI Reset");
#undef R
/*
* Create the PM timer.
*/
PTMTIMER pTimer;
- rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, acpiPmTimer, &pThis->dev,
+ rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, acpiR3PmTimer, &pThis->dev,
TMTIMER_FLAGS_NO_CRIT_SECT, "ACPI PM Timer", &pTimer);
AssertRCReturn(rc, rc);
pThis->pPmTimerR3 = pTimer;
@@ -3278,7 +3282,7 @@ static DECLCALLBACK(int) acpiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMN
rc = TMTimerLock(pTimer, VERR_IGNORED);
AssertRCReturn(rc, rc);
pThis->u64PmTimerInitial = TMTimerGet(pTimer);
- acpiPmTimerReset(pThis, pThis->u64PmTimerInitial);
+ acpiR3PmTimerReset(pThis, pThis->u64PmTimerInitial);
TMTimerUnlock(pTimer);
/*
@@ -3317,13 +3321,13 @@ static DECLCALLBACK(int) acpiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMN
return rc;
PDMDevHlpPCISetConfigCallbacks(pDevIns, &pThis->dev,
- acpiPciConfigRead, &pThis->pfnAcpiPciConfigRead,
- acpiPciConfigWrite, &pThis->pfnAcpiPciConfigWrite);
+ acpiR3PciConfigRead, &pThis->pfnAcpiPciConfigRead,
+ acpiR3PciConfigWrite, &pThis->pfnAcpiPciConfigWrite);
/*
* Register the saved state.
*/
- rc = PDMDevHlpSSMRegister(pDevIns, 6, sizeof(*pThis), acpiSaveState, acpiLoadState);
+ rc = PDMDevHlpSSMRegister(pDevIns, 6, sizeof(*pThis), acpiR3SaveState, acpiR3LoadState);
if (RT_FAILURE(rc))
return rc;
@@ -3374,25 +3378,25 @@ const PDMDEVREG g_DeviceACPI =
/* cbInstance */
sizeof(ACPIState),
/* pfnConstruct */
- acpiConstruct,
+ acpiR3Construct,
/* pfnDestruct */
- acpiDestruct,
+ acpiR3Destruct,
/* pfnRelocate */
- acpiRelocate,
- /* pfnIOCtl */
- NULL,
+ acpiR3Relocate,
+ /* pfnMemSetup */
+ acpiR3MemSetup,
/* pfnPowerOn */
NULL,
/* pfnReset */
- acpiReset,
+ acpiR3Reset,
/* pfnSuspend */
NULL,
/* pfnResume */
- acpiResume,
+ acpiR3Resume,
/* pfnAttach */
- acpiAttach,
+ acpiR3Attach,
/* pfnDetach */
- acpiDetach,
+ acpiR3Detach,
/* pfnQueryInterface. */
NULL,
/* pfnInitComplete */