VirtualBox

Changeset 44514 in vbox for trunk/src/VBox/Devices/PC


Ignore:
Timestamp:
Feb 1, 2013 2:26:03 PM (12 years ago)
Author:
vboxsync
Message:

DevACPI cleanups.

Location:
trunk/src/VBox/Devices/PC
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/ACPI/VBoxAcpi.cpp

    r35346 r44514  
    55
    66/*
    7  * Copyright (C) 2009 Oracle Corporation
     7 * Copyright (C) 2009-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
     18
     19/*******************************************************************************
     20*   Header Files                                                               *
     21*******************************************************************************/
     22#include <iprt/cdefs.h>
    1823#if !defined(IN_RING3)
    19 #error Pure R3 code
     24# error Pure R3 code
    2025#endif
    2126
     
    4247#endif
    4348
     49#include "VBoxDD.h"
     50
     51
    4452#ifdef VBOX_WITH_DYNAMIC_DSDT
    45 static int prepareDynamicDsdt(PPDMDEVINS pDevIns,
    46                               void*      *ppPtr,
    47                               size_t     *puDsdtLen)
    48 {
    49   *ppPtr = NULL;
    50   *puDsdtLen = 0;
     53
     54static int prepareDynamicDsdt(PPDMDEVINS pDevIns, void **ppvPtr, size_t *pcbDsdt)
     55{
     56  *ppvPtr = NULL;
     57  *pcbDsdt = 0;
    5158  return 0;
    5259}
    5360
    54 static int cleanupDynamicDsdt(PPDMDEVINS pDevIns,
    55                               void*      pPtr)
     61static int cleanupDynamicDsdt(PPDMDEVINS pDevIns, void *pvPtr)
    5662{
    5763    return 0;
    5864}
    5965
    60 #else
    61 static int patchAml(PPDMDEVINS pDevIns, uint8_t* pAml, size_t uAmlLen)
     66#else  /* VBOX_WITH_DYNAMIC_DSDT */
     67
     68static int patchAml(PPDMDEVINS pDevIns, uint8_t *pabAml, size_t cbAml)
    6269{
    6370    uint16_t cNumCpus;
     
    8592     * for VCPU not configured
    8693     */
    87     for (uint32_t i = 0; i < uAmlLen - 7; i++)
     94    for (uint32_t i = 0; i < cbAml - 7; i++)
    8895    {
    8996        /*
     
    97104         * PblkLen      := ByteData
    98105         */
    99         if ((pAml[i] == 0x5b) && (pAml[i+1] == 0x83))
    100         {
    101             if ((pAml[i+3] != 'C') || (pAml[i+4] != 'P'))
     106        if (pabAml[i] == 0x5b && pabAml[i+1] == 0x83)
     107        {
     108            if (pabAml[i+3] != 'C' || pabAml[i+4] != 'P')
    102109                /* false alarm, not named starting CP */
    103110                continue;
    104111
    105112            /* Processor ID */
    106             if (pAml[i+7] < cNumCpus)
     113            if (pabAml[i+7] < cNumCpus)
    107114              continue;
    108115
     
    112119             * for full format
    113120             */
    114             uint32_t cBytes = pAml[i + 2];
     121            uint32_t cBytes = pabAml[i + 2];
    115122            AssertReleaseMsg((cBytes >> 6) == 0,
    116123                             ("So far, we only understand simple package length"));
     
    118125            /* including AML_PROCESSOR_OP itself */
    119126            for (uint32_t j = 0; j < cBytes + 2; j++)
    120                 pAml[i+j] = 0xa3;
     127                pabAml[i+j] = 0xa3;
    121128
    122129            /* Can increase i by cBytes + 1, but not really worth it */
     
    125132
    126133    /* now recompute checksum, whole file byte sum must be 0 */
    127     pAml[9] = 0;
    128     uint8_t         aSum = 0;
    129     for (uint32_t i = 0; i < uAmlLen; i++)
    130       aSum = aSum + (uint8_t)pAml[i];
    131     pAml[9] = (uint8_t) (0 - aSum);
     134    pabAml[9] = 0;
     135    uint8_t         bSum = 0;
     136    for (uint32_t i = 0; i < cbAml; i++)
     137      bSum = bSum + pabAml[i];
     138    pabAml[9] = (uint8_t)(0 - bSum);
    132139
    133140    return 0;
     
    138145 * only contain the ACPI containers which may have a CPU
    139146 */
    140 static int patchAmlCpuHotPlug(PPDMDEVINS pDevIns, uint8_t* pAml, size_t uAmlLen)
     147static int patchAmlCpuHotPlug(PPDMDEVINS pDevIns, uint8_t *pabAml, size_t cbAml)
    141148{
    142149    uint16_t cNumCpus;
     
    156163     * for VCPU not configured
    157164     */
    158     while (idxAml < uAmlLen - 7)
     165    while (idxAml < cbAml - 7)
    159166    {
    160167        /*
     
    164171         * DeviceOp     := ExtOpPrefix 0x82
    165172         */
    166         if ((pAml[idxAml] == 0x5b) && (pAml[idxAml+1] == 0x82))
     173        if (pabAml[idxAml] == 0x5b && pabAml[idxAml+1] == 0x82)
    167174        {
    168175            /* Check if the enclosed CPU device is configured. */
    169             uint8_t *pbAmlPkgLength = &pAml[idxAml+2];
     176            uint8_t *pabAmlPkgLength = &pabAml[idxAml+2];
    170177            uint32_t cBytes = 0;
    171             uint32_t cLengthBytesFollow = pbAmlPkgLength[0] >> 6;
     178            uint32_t cLengthBytesFollow = pabAmlPkgLength[0] >> 6;
    172179
    173180            if (cLengthBytesFollow == 0)
    174181            {
    175182                /* Simple package length */
    176                 cBytes = pbAmlPkgLength[0];
     183                cBytes = pabAmlPkgLength[0];
    177184            }
    178185            else
     
    180187                unsigned idxLengthByte = 1;
    181188
    182                 cBytes = pbAmlPkgLength[0] & 0xF;
     189                cBytes = pabAmlPkgLength[0] & 0xF;
    183190
    184191                while (idxLengthByte <= cLengthBytesFollow)
    185192                {
    186                     cBytes |= pbAmlPkgLength[idxLengthByte] << (4*idxLengthByte);
     193                    cBytes |= pabAmlPkgLength[idxLengthByte] << (4*idxLengthByte);
    187194                    idxLengthByte++;
    188195                }
    189196            }
    190197
    191             uint8_t *pbAmlDevName = &pbAmlPkgLength[cLengthBytesFollow+1];
    192             uint8_t *pbAmlCpu     = &pbAmlDevName[4];
     198            uint8_t *pabAmlDevName = &pabAmlPkgLength[cLengthBytesFollow+1];
     199            uint8_t *pabAmlCpu     = &pabAmlDevName[4];
    193200            bool fCpuConfigured = false;
    194201            bool fCpuFound      = false;
    195202
    196             if ((pbAmlDevName[0] != 'S') || (pbAmlDevName[1] != 'C') || (pbAmlDevName[2] != 'K'))
     203            if ((pabAmlDevName[0] != 'S') || (pabAmlDevName[1] != 'C') || (pabAmlDevName[2] != 'K'))
    197204            {
    198205                /* false alarm, not named starting SCK */
     
    213220                 * PblkLen      := ByteData
    214221                 */
    215                 if ((pbAmlCpu[idxAmlCpu] == 0x5b) && (pbAmlCpu[idxAmlCpu+1] == 0x83))
     222                if ((pabAmlCpu[idxAmlCpu] == 0x5b) && (pabAmlCpu[idxAmlCpu+1] == 0x83))
    216223                {
    217                     if ((pbAmlCpu[idxAmlCpu+4] != 'C') || (pbAmlCpu[idxAmlCpu+5] != 'P'))
     224                    if ((pabAmlCpu[idxAmlCpu+4] != 'C') || (pabAmlCpu[idxAmlCpu+5] != 'P'))
    218225                        /* false alarm, not named starting CP */
    219226                        continue;
     
    222229
    223230                    /* Processor ID */
    224                     if (pbAmlCpu[idxAmlCpu+8] < cNumCpus)
     231                    if (pabAmlCpu[idxAmlCpu+8] < cNumCpus)
    225232                    {
    226                         LogFlow(("CPU %d is configured\n", pbAmlCpu[idxAmlCpu+8]));
     233                        LogFlow(("CPU %d is configured\n", pabAmlCpu[idxAmlCpu+8]));
    227234                        fCpuConfigured = true;
    228235                        break;
     
    230237                    else
    231238                    {
    232                         LogFlow(("CPU %d is not configured\n", pbAmlCpu[idxAmlCpu+8]));
     239                        LogFlow(("CPU %d is not configured\n", pabAmlCpu[idxAmlCpu+8]));
    233240                        fCpuConfigured = false;
    234241                        break;
     
    249256                /* including AML_DEVICE_OP itself */
    250257                for (uint32_t j = 0; j < cBytes + 2; j++)
    251                     pAml[idxAml+j] = 0xa3;
     258                    pabAml[idxAml+j] = 0xa3;
    252259            }
    253260
     
    259266
    260267    /* now recompute checksum, whole file byte sum must be 0 */
    261     pAml[9] = 0;
    262     uint8_t         aSum = 0;
    263     for (uint32_t i = 0; i < uAmlLen; i++)
    264       aSum = aSum + (uint8_t)pAml[i];
    265     pAml[9] = (uint8_t) (0 - aSum);
     268    pabAml[9] = 0;
     269    uint8_t         bSum = 0;
     270    for (uint32_t i = 0; i < cbAml; i++)
     271      bSum = bSum + pabAml[i];
     272    pabAml[9] = (uint8_t)(0 - bSum);
    266273
    267274    return 0;
    268275}
    269 #endif
     276
     277#endif /* VBOX_WITH_DYNAMIC_DSDT */
    270278
    271279/**
     
    276284 * @param   pcszCfgName    The configuration key holding the file path
    277285 * @param   pcszSignature  The signature to check for
    278  * @param   ppbAmlCode     Where to store the pointer to the AML code on success.
     286 * @param   ppabAmlCode     Where to store the pointer to the AML code on success.
    279287 * @param   pcbAmlCode     Where to store the number of bytes of the AML code on success.
    280288 */
    281 static int acpiAmlLoadExternal(PPDMDEVINS pDevIns, const char *pcszCfgName, const char *pcszSignature, uint8_t **ppbAmlCode, size_t *pcbAmlCode)
    282 {
    283     uint8_t *pbAmlCode = NULL;
     289static int acpiAmlLoadExternal(PPDMDEVINS pDevIns, const char *pcszCfgName, const char *pcszSignature, uint8_t **ppabAmlCode, size_t *pcbAmlCode)
     290{
     291    uint8_t *pabAmlCode = NULL;
    284292    size_t cbAmlCode = 0;
    285293    char *pszAmlFilePath = NULL;
     
    307315                && ((uint64_t)cbAmlCode == cbAmlFile))
    308316            {
    309                 pbAmlCode = (uint8_t *)RTMemAllocZ(cbAmlCode);
    310                 if (pbAmlCode)
     317                pabAmlCode = (uint8_t *)RTMemAllocZ(cbAmlCode);
     318                if (pabAmlCode)
    311319                {
    312                     rc = RTFileReadAt(FileAml, 0, pbAmlCode, cbAmlCode, NULL);
     320                    rc = RTFileReadAt(FileAml, 0, pabAmlCode, cbAmlCode, NULL);
    313321
    314322                    /*
     
    317325                     */
    318326                    if (   RT_FAILURE(rc)
    319                         || strncmp((const char *)pbAmlCode, pcszSignature, 4))
     327                        || strncmp((const char *)pabAmlCode, pcszSignature, 4))
    320328                    {
    321                         RTMemFree(pbAmlCode);
    322                         pbAmlCode = NULL;
     329                        RTMemFree(pabAmlCode);
     330                        pabAmlCode = NULL;
    323331
    324332                        /* Return error if file header check failed */
     
    328336                    else
    329337                    {
    330                         *ppbAmlCode = pbAmlCode;
     338                        *ppabAmlCode = pabAmlCode;
    331339                        *pcbAmlCode = cbAmlCode;
    332340                        rc = VINF_SUCCESS;
     
    345353}
    346354
    347 /* Two only public functions */
    348 int acpiPrepareDsdt(PPDMDEVINS pDevIns,  void * *ppPtr, size_t *puDsdtLen)
     355
     356/** No docs, lazy coder. */
     357int acpiPrepareDsdt(PPDMDEVINS pDevIns,  void **ppvPtr, size_t *pcbDsdt)
    349358{
    350359#ifdef VBOX_WITH_DYNAMIC_DSDT
    351     return prepareDynamicDsdt(pDevIns, ppPtr, puDsdtLen);
     360    return prepareDynamicDsdt(pDevIns, ppvPtr, pcbDsdt);
    352361#else
    353     uint8_t *pbAmlCodeDsdt = NULL;
     362    uint8_t *pabAmlCodeDsdt = NULL;
    354363    size_t cbAmlCodeDsdt = 0;
    355     int rc = acpiAmlLoadExternal(pDevIns, "DsdtFilePath", "DSDT", &pbAmlCodeDsdt, &cbAmlCodeDsdt);
     364    int rc = acpiAmlLoadExternal(pDevIns, "DsdtFilePath", "DSDT", &pabAmlCodeDsdt, &cbAmlCodeDsdt);
    356365
    357366    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
     
    361370        /* Use the compiled in AML code */
    362371        cbAmlCodeDsdt = sizeof(AmlCode);
    363         pbAmlCodeDsdt = (uint8_t *)RTMemAllocZ(cbAmlCodeDsdt);
    364         if (pbAmlCodeDsdt)
    365             memcpy(pbAmlCodeDsdt, AmlCode, cbAmlCodeDsdt);
     372        pabAmlCodeDsdt = (uint8_t *)RTMemAllocZ(cbAmlCodeDsdt);
     373        if (pabAmlCodeDsdt)
     374            memcpy(pabAmlCodeDsdt, AmlCode, cbAmlCodeDsdt);
    366375        else
    367376            rc = VERR_NO_MEMORY;
     
    373382    if (RT_SUCCESS(rc))
    374383    {
    375         patchAml(pDevIns, pbAmlCodeDsdt, cbAmlCodeDsdt);
    376         *ppPtr = pbAmlCodeDsdt;
    377         *puDsdtLen = cbAmlCodeDsdt;
     384        patchAml(pDevIns, pabAmlCodeDsdt, cbAmlCodeDsdt);
     385        *ppvPtr = pabAmlCodeDsdt;
     386        *pcbDsdt = cbAmlCodeDsdt;
    378387    }
    379388    return rc;
     
    381390}
    382391
    383 int acpiCleanupDsdt(PPDMDEVINS pDevIns,  void * pPtr)
     392/** No docs, lazy coder. */
     393int acpiCleanupDsdt(PPDMDEVINS pDevIns,  void *pvPtr)
    384394{
    385395#ifdef VBOX_WITH_DYNAMIC_DSDT
    386     return cleanupDynamicDsdt(pDevIns, pPtr);
     396    return cleanupDynamicDsdt(pDevIns, pvPtr);
    387397#else
    388     if (pPtr)
    389         RTMemFree(pPtr);
     398    if (pvPtr)
     399        RTMemFree(pvPtr);
    390400    return VINF_SUCCESS;
    391401#endif
    392402}
    393403
    394 int acpiPrepareSsdt(PPDMDEVINS pDevIns, void* *ppPtr, size_t *puSsdtLen)
    395 {
    396     uint8_t *pbAmlCodeSsdt = NULL;
     404/** No docs, lazy coder. */
     405int acpiPrepareSsdt(PPDMDEVINS pDevIns, void **ppvPtr, size_t *pcbSsdt)
     406{
     407    uint8_t *pabAmlCodeSsdt = NULL;
    397408    size_t   cbAmlCodeSsdt = 0;
    398     int rc = acpiAmlLoadExternal(pDevIns, "SsdtFilePath", "SSDT", &pbAmlCodeSsdt, &cbAmlCodeSsdt);
     409    int rc = acpiAmlLoadExternal(pDevIns, "SsdtFilePath", "SSDT", &pabAmlCodeSsdt, &cbAmlCodeSsdt);
    399410
    400411    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    401412    {
    402413        bool fCpuHotPlug = false;
    403         uint8_t *pbAmlCode = NULL;
     414        uint8_t *pabAmlCode = NULL;
    404415        rc = CFGMR3QueryBoolDef(pDevIns->pCfg, "CpuHotPlug", &fCpuHotPlug, false);
    405416
     
    409420        if (fCpuHotPlug)
    410421        {
    411             pbAmlCode     = AmlCodeSsdtCpuHotPlug;
     422            pabAmlCode     = AmlCodeSsdtCpuHotPlug;
    412423            cbAmlCodeSsdt = sizeof(AmlCodeSsdtCpuHotPlug);
    413424        }
    414425        else
    415426        {
    416             pbAmlCode     = AmlCodeSsdtStandard;
     427            pabAmlCode     = AmlCodeSsdtStandard;
    417428            cbAmlCodeSsdt = sizeof(AmlCodeSsdtStandard);
    418429        }
    419430
    420         pbAmlCodeSsdt = (uint8_t *)RTMemAllocZ(cbAmlCodeSsdt);
    421         if (pbAmlCodeSsdt)
    422         {
    423             memcpy(pbAmlCodeSsdt, pbAmlCode, cbAmlCodeSsdt);
     431        pabAmlCodeSsdt = (uint8_t *)RTMemAllocZ(cbAmlCodeSsdt);
     432        if (pabAmlCodeSsdt)
     433        {
     434            memcpy(pabAmlCodeSsdt, pabAmlCode, cbAmlCodeSsdt);
    424435
    425436            if (fCpuHotPlug)
    426                 patchAmlCpuHotPlug(pDevIns, pbAmlCodeSsdt, cbAmlCodeSsdt);
     437                patchAmlCpuHotPlug(pDevIns, pabAmlCodeSsdt, cbAmlCodeSsdt);
    427438            else
    428                 patchAml(pDevIns, pbAmlCodeSsdt, cbAmlCodeSsdt);
     439                patchAml(pDevIns, pabAmlCodeSsdt, cbAmlCodeSsdt);
    429440        }
    430441        else
     
    437448    if (RT_SUCCESS(rc))
    438449    {
    439         *ppPtr = pbAmlCodeSsdt;
    440         *puSsdtLen = cbAmlCodeSsdt;
     450        *ppvPtr = pabAmlCodeSsdt;
     451        *pcbSsdt = cbAmlCodeSsdt;
    441452    }
    442453
     
    444455}
    445456
    446 int acpiCleanupSsdt(PPDMDEVINS pDevIns, void* pPtr)
    447 {
    448     if (pPtr)
    449         RTMemFree(pPtr);
     457/** No docs, lazy coder. */
     458int acpiCleanupSsdt(PPDMDEVINS pDevIns, void *pvPtr)
     459{
     460    if (pvPtr)
     461        RTMemFree(pvPtr);
    450462    return VINF_SUCCESS;
    451463}
  • trunk/src/VBox/Devices/PC/DevACPI.cpp

    r44447 r44514  
    55
    66/*
    7  * Copyright (C) 2006-2011 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4141# define DEBUG_ACPI
    4242#endif
    43 
    44 #if defined(IN_RING3) && !defined(VBOX_DEVICE_STRUCT_TESTCASE)
    45 int acpiPrepareDsdt(PPDMDEVINS pDevIns, void* *ppPtr, size_t *puDsdtLen);
    46 int acpiCleanupDsdt(PPDMDEVINS pDevIns, void* pPtr);
    47 
    48 int acpiPrepareSsdt(PPDMDEVINS pDevIns, void* *ppPtr, size_t *puSsdtLen);
    49 int acpiCleanupSsdt(PPDMDEVINS pDevIns, void* pPtr);
    50 #endif /* !IN_RING3 */
    5143
    5244
     
    249241     *  4. Note that the _STA method is sometimes called prior to the _INI method
    250242     *  (ACPI spec 6.3.7, _STA). See the special case for BAT_DEVICE_STATUS in
    251      *  acpiBatIndexWrite() for handling this. */
     243     *  acpiR3BatIndexWrite() for handling this. */
    252244    uint8_t             u8IndexShift;
    253245    /** provide an I/O-APIC */
     
    601593AssertCompileSize(ACPITBLMCFGENTRY, 16);
    602594
    603 # ifdef IN_RING3 /** @todo r=bird: Move this down to where it's used. */
    604 
    605 #  define PCAT_COMPAT   0x1                     /**< system has also a dual-8259 setup */
     595#define PCAT_COMPAT   0x1                       /**< system has also a dual-8259 setup */
    606596
    607597/** Custom Description Table */
     
    613603AssertCompileSize(ACPITBLCUST, 512);
    614604
    615 /**
    616  * Multiple APIC Description Table.
    617  *
    618  * This structure looks somewhat convoluted due layout of MADT table in MP case.
    619  * There extpected to be multiple LAPIC records for each CPU, thus we cannot
    620  * use regular C structure and proxy to raw memory instead.
    621  */
    622 class AcpiTableMADT
    623 {
    624     /**
    625      * All actual data stored in dynamically allocated memory pointed by this field.
    626      */
    627     uint8_t            *m_pbData;
    628     /**
    629      * Number of CPU entries in this MADT.
    630      */
    631     uint32_t            m_cCpus;
    632 
    633     /**
    634      * Number of interrupt overrides.
    635      */
    636      uint32_t            m_cIsos;
    637 
    638 public:
    639     /**
    640      * Address of ACPI header
    641      */
    642     inline ACPITBLHEADER *header_addr(void) const
    643     {
    644         return (ACPITBLHEADER *)m_pbData;
    645     }
    646 
    647     /**
    648      * Address of local APIC for each CPU. Note that different CPUs address different LAPICs,
    649      * although address is the same for all of them.
    650      */
    651     inline uint32_t *u32LAPIC_addr(void) const
    652     {
    653         return (uint32_t *)(header_addr() + 1);
    654     }
    655 
    656     /**
    657      * Address of APIC flags
    658      */
    659     inline uint32_t *u32Flags_addr(void) const
    660     {
    661         return (uint32_t *)(u32LAPIC_addr() + 1);
    662     }
    663 
    664     /**
    665      * Address of ISO description
    666      */
    667     inline ACPITBLISO *ISO_addr(void) const
    668     {
    669         return (ACPITBLISO *)(u32Flags_addr() + 1);
    670     }
    671 
    672     /**
    673      * Address of per-CPU LAPIC descriptions
    674      */
    675     inline ACPITBLLAPIC *LApics_addr(void) const
    676     {
    677         return (ACPITBLLAPIC *)(ISO_addr() + m_cIsos);
    678     }
    679 
    680     /**
    681      * Address of IO APIC description
    682      */
    683     inline ACPITBLIOAPIC *IOApic_addr(void) const
    684     {
    685         return (ACPITBLIOAPIC *)(LApics_addr() + m_cCpus);
    686     }
    687 
    688     /**
    689      * Size of MADT.
    690      * Note that this function assumes IOApic to be the last field in structure.
    691      */
    692     inline uint32_t size(void) const
    693     {
    694         return (uint8_t *)(IOApic_addr() + 1) - (uint8_t *)header_addr();
    695     }
    696 
    697     /**
    698      * Raw data of MADT.
    699      */
    700     inline const uint8_t *data(void) const
    701     {
    702         return m_pbData;
    703     }
    704 
    705     /**
    706      * Size of MADT for given ACPI config, useful to compute layout.
    707      */
    708     static uint32_t sizeFor(ACPIState *pThis, uint32_t cIsos)
    709     {
    710         return AcpiTableMADT(pThis->cCpus, cIsos).size();
    711     }
    712 
    713     /*
    714      * Constructor, only works in Ring 3, doesn't look like a big deal.
    715      */
    716     AcpiTableMADT(uint32_t cCpus, uint32_t cIsos)
    717     {
    718         m_cCpus  = cCpus;
    719         m_cIsos  = cIsos;
    720         m_pbData = NULL;                /* size() uses this and gcc will complain if not initialized. */
    721         uint32_t cb = size();
    722         m_pbData = (uint8_t *)RTMemAllocZ(cb);
    723     }
    724 
    725     ~AcpiTableMADT()
    726     {
    727         RTMemFree(m_pbData);
    728     }
    729 };
    730 # endif /* IN_RING3 */
    731605
    732606#pragma pack()
     
    741615RT_C_DECLS_END
    742616#ifdef IN_RING3
    743 static int acpiPlantTables(ACPIState *pThis);
     617static int acpiR3PlantTables(ACPIState *pThis);
    744618#endif
    745619
     
    747621
    748622/* SCI IRQ */
    749 DECLINLINE(void) acpiSetIrq(ACPIState *pThis, int level)
     623DECLINLINE(void) acpiR3SetIrq(ACPIState *pThis, int level)
    750624{
    751625    if (pThis->pm1a_ctl & SCI_EN)
     
    768642}
    769643
    770 DECLINLINE(int) gpe0_level(ACPIState *pThis)
     644DECLINLINE(bool) gpe0_level(ACPIState *pThis)
    771645{
    772646    return (pThis->gpe0_en & pThis->gpe0_sts) != 0;
     
    774648
    775649/**
    776  * Used by acpiPM1aStsWrite, acpiPM1aEnWrite, acpiPmTimer,
    777  * acpiPort_PowerBuffonPress and acpiPort_SleepButtonPress to
     650 * Used by acpiR3PM1aStsWrite, acpiR3PM1aEnWrite, acpiR3PmTimer,
     651 * acpiR3Port_PowerBuffonPress and acpiR3Port_SleepButtonPress to
    778652 * update the GPE0.STS and GPE0.EN registers and trigger IRQs.
    779653 *
     
    784658 * @param   en          The new GPE0.EN value.
    785659 */
    786 static void update_pm1a(ACPIState *pThis, uint32_t sts, uint32_t en)
     660static void apicR3UpdatePm1a(ACPIState *pThis, uint32_t sts, uint32_t en)
    787661{
    788662    Assert(PDMCritSectIsOwner(&pThis->CritSect));
     
    794668    int const new_level = (pm1a_pure_en(en) & pm1a_pure_sts(sts)) != 0;
    795669
    796     Log(("update_pm1a() old=%x new=%x\n", old_level, new_level));
     670    Log(("apicR3UpdatePm1a() old=%x new=%x\n", old_level, new_level));
    797671
    798672    pThis->pm1a_en = en;
     
    800674
    801675    if (new_level != old_level)
    802         acpiSetIrq(pThis, new_level);
    803 }
    804 
    805 /**
    806  * Used by acpiGpe0StsWrite, acpiGpe0EnWrite, acpiAttach and acpiDetach to
     676        acpiR3SetIrq(pThis, new_level);
     677}
     678
     679/**
     680 * Used by acpiR3Gpe0StsWrite, acpiR3Gpe0EnWrite, acpiAttach and acpiDetach to
    807681 * update the GPE0.STS and GPE0.EN registers and trigger IRQs.
    808682 *
     
    813687 * @param   en          The new GPE0.EN value.
    814688 */
    815 static void update_gpe0(ACPIState *pThis, uint32_t sts, uint32_t en)
     689static void apicR3UpdateGpe0(ACPIState *pThis, uint32_t sts, uint32_t en)
    816690{
    817691    Assert(PDMCritSectIsOwner(&pThis->CritSect));
     
    827701
    828702    if (new_level != old_level)
    829         acpiSetIrq(pThis, new_level);
    830 }
    831 
    832 /**
    833  * Used by acpiPM1aCtlWrite to power off the VM.
     703        acpiR3SetIrq(pThis, new_level);
     704}
     705
     706/**
     707 * Used by acpiR3PM1aCtlWrite to power off the VM.
    834708 *
    835709 * @param   pThis   The ACPI instance.
    836710 * @returns Strict VBox status code.
    837711 */
    838 static int acpiPowerOff(ACPIState *pThis)
     712static int acpiR3DoPowerOff(ACPIState *pThis)
    839713{
    840714    int rc = PDMDevHlpVMPowerOff(pThis->pDevIns);
     
    845719
    846720/**
    847  * Used by acpiPM1aCtlWrite to put the VM to sleep.
     721 * Used by acpiR3PM1aCtlWrite to put the VM to sleep.
    848722 *
    849723 * @param   pThis   The ACPI instance.
    850724 * @returns Strict VBox status code.
    851725 */
    852 static int acpiSleep(ACPIState *pThis)
     726static int acpiR3DoSleep(ACPIState *pThis)
    853727{
    854728    /* We must set WAK_STS on resume (includes restore) so the guest knows that
     
    881755 * @interface_method_impl{PDMIACPIPORT,pfnPowerButtonPress}
    882756 */
    883 static DECLCALLBACK(int) acpiPort_PowerButtonPress(PPDMIACPIPORT pInterface)
     757static DECLCALLBACK(int) acpiR3Port_PowerButtonPress(PPDMIACPIPORT pInterface)
    884758{
    885759    ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IACPIPort);
    886760    DEVACPI_LOCK_R3(pThis);
    887761
    888     Log(("acpiPort_PowerButtonPress: handled=%d status=%x\n", pThis->fPowerButtonHandled, pThis->pm1a_sts));
     762    Log(("acpiR3Port_PowerButtonPress: handled=%d status=%x\n", pThis->fPowerButtonHandled, pThis->pm1a_sts));
    889763    pThis->fPowerButtonHandled = false;
    890     update_pm1a(pThis, pThis->pm1a_sts | PWRBTN_STS, pThis->pm1a_en);
     764    apicR3UpdatePm1a(pThis, pThis->pm1a_sts | PWRBTN_STS, pThis->pm1a_en);
    891765
    892766    DEVACPI_UNLOCK(pThis);
     
    897771 * @interface_method_impl{PDMIACPIPORT,pfnGetPowerButtonHandled}
    898772 */
    899 static DECLCALLBACK(int) acpiPort_GetPowerButtonHandled(PPDMIACPIPORT pInterface, bool *pfHandled)
     773static DECLCALLBACK(int) acpiR3Port_GetPowerButtonHandled(PPDMIACPIPORT pInterface, bool *pfHandled)
    900774{
    901775    ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IACPIPort);
     
    912786 *                       Guest entered into G0 (working) or G1 (sleeping)}
    913787 */
    914 static DECLCALLBACK(int) acpiPort_GetGuestEnteredACPIMode(PPDMIACPIPORT pInterface, bool *pfEntered)
     788static DECLCALLBACK(int) acpiR3Port_GetGuestEnteredACPIMode(PPDMIACPIPORT pInterface, bool *pfEntered)
    915789{
    916790    ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IACPIPort);
     
    926800 * @interface_method_impl{PDMIACPIPORT,pfnGetCpuStatus}
    927801 */
    928 static DECLCALLBACK(int) acpiPort_GetCpuStatus(PPDMIACPIPORT pInterface, unsigned uCpu, bool *pfLocked)
     802static DECLCALLBACK(int) acpiR3Port_GetCpuStatus(PPDMIACPIPORT pInterface, unsigned uCpu, bool *pfLocked)
    929803{
    930804    ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IACPIPort);
     
    943817 * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    944818 */
    945 static DECLCALLBACK(int) acpiPort_SleepButtonPress(PPDMIACPIPORT pInterface)
     819static DECLCALLBACK(int) acpiR3Port_SleepButtonPress(PPDMIACPIPORT pInterface)
    946820{
    947821    ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IACPIPort);
    948822    DEVACPI_LOCK_R3(pThis);
    949823
    950     update_pm1a(pThis, pThis->pm1a_sts | SLPBTN_STS, pThis->pm1a_en);
     824    apicR3UpdatePm1a(pThis, pThis->pm1a_sts | SLPBTN_STS, pThis->pm1a_en);
    951825
    952826    DEVACPI_UNLOCK(pThis);
     
    955829
    956830/**
    957  * Used by acpiPmTimer to re-arm the PM timer.
     831 * Used by acpiR3PmTimer to re-arm the PM timer.
    958832 *
    959833 * The caller is expected to either hold the clock lock or to have made sure
     
    963837 * @param   uNow                The current time.
    964838 */
    965 static void acpiPmTimerReset(ACPIState *pThis, uint64_t uNow)
     839static void acpiR3PmTimerReset(ACPIState *pThis, uint64_t uNow)
    966840{
    967841    uint64_t uTimerFreq = TMTimerGetFreq(pThis->CTX_SUFF(pPmTimer));
     
    974848 * @callback_method_impl{FNTMTIMERDEV, PM Timer callback}
    975849 */
    976 static DECLCALLBACK(void) acpiPmTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
     850static DECLCALLBACK(void) acpiR3PmTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    977851{
    978852    ACPIState *pThis = (ACPIState *)pvUser;
     
    984858         pThis->pm1a_sts, (pThis->pm1a_sts & TMR_STS) != 0,
    985859         pThis->pm1a_en, (pThis->pm1a_en & TMR_EN) != 0));
    986     update_pm1a(pThis, pThis->pm1a_sts | TMR_STS, pThis->pm1a_en);
     860    apicR3UpdatePm1a(pThis, pThis->pm1a_sts | TMR_STS, pThis->pm1a_en);
    987861    DEVACPI_UNLOCK(pThis);
    988862
    989     acpiPmTimerReset(pThis, TMTimerGet(pTimer));
    990 }
    991 
    992 /**
    993  * _BST method - used by acpiBatDataRead to implement BAT_STATUS_STATE and
    994  * acpiLoadState.
     863    acpiR3PmTimerReset(pThis, TMTimerGet(pTimer));
     864}
     865
     866/**
     867 * _BST method - used by acpiR3BatDataRead to implement BAT_STATUS_STATE and
     868 * acpiR3LoadState.
    995869 *
    996870 * @returns VINF_SUCCESS.
    997871 * @param   pThis           The ACPI instance.
    998872 */
    999 static int acpiFetchBatteryStatus(ACPIState *pThis)
     873static int acpiR3FetchBatteryStatus(ACPIState *pThis)
    1000874{
    1001875    uint32_t           *p = pThis->au8BatteryInfo;
     
    1029903
    1030904/**
    1031  * _BIF method - used by acpiBatDataRead to implement BAT_INFO_UNITS and
    1032  * acpiLoadState.
     905 * _BIF method - used by acpiR3BatDataRead to implement BAT_INFO_UNITS and
     906 * acpiR3LoadState.
    1033907 *
    1034908 * @returns VINF_SUCCESS.
    1035909 * @param   pThis           The ACPI instance.
    1036910 */
    1037 static int acpiFetchBatteryInfo(ACPIState *pThis)
     911static int acpiR3FetchBatteryInfo(ACPIState *pThis)
    1038912{
    1039913    uint32_t *p = pThis->au8BatteryInfo;
     
    1053927
    1054928/**
    1055  * The _STA method - used by acpiBatDataRead to implement BAT_DEVICE_STATUS.
     929 * The _STA method - used by acpiR3BatDataRead to implement BAT_DEVICE_STATUS.
    1056930 *
    1057931 * @returns status mask or 0.
    1058932 * @param   pThis           The ACPI instance.
    1059933 */
    1060 static uint32_t acpiGetBatteryDeviceStatus(ACPIState *pThis)
     934static uint32_t acpiR3GetBatteryDeviceStatus(ACPIState *pThis)
    1061935{
    1062936    bool               fPresent;              /* battery present? */
     
    1082956
    1083957/**
    1084  * Used by acpiBatDataRead to implement BAT_POWER_SOURCE.
     958 * Used by acpiR3BatDataRead to implement BAT_POWER_SOURCE.
    1085959 *
    1086960 * @returns status.
    1087961 * @param   pThis           The ACPI instance.
    1088962 */
    1089 static uint32_t acpiGetPowerSource(ACPIState *pThis)
     963static uint32_t acpiR3GetPowerSource(ACPIState *pThis)
    1090964{
    1091965    /* query the current power source from the host driver */
     
    1102976 * @callback_method_impl{FNIOMIOPORTOUT, Battery status index}
    1103977 */
    1104 PDMBOTHCBDECL(int) acpiBatIndexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    1105 {
    1106     Log(("acpiBatIndexWrite: %#x (%#x)\n", u32, u32 >> 2));
     978PDMBOTHCBDECL(int) acpiR3BatIndexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     979{
     980    Log(("acpiR3BatIndexWrite: %#x (%#x)\n", u32, u32 >> 2));
    1107981    if (cb != 4)
    1108982        return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "cb=%d Port=%u u32=%#x\n", cb, Port, u32);
     
    11281002 * @callback_method_impl{FNIOMIOPORTIN, Battery status data}
    11291003 */
    1130 PDMBOTHCBDECL(int) acpiBatDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
     1004PDMBOTHCBDECL(int) acpiR3BatDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
    11311005{
    11321006    if (cb != 4)
     
    11401014    {
    11411015        case BAT_STATUS_STATE:
    1142             acpiFetchBatteryStatus(pThis);
     1016            acpiR3FetchBatteryStatus(pThis);
    11431017            /* fall thru */
    11441018        case BAT_STATUS_PRESENT_RATE:
     
    11491023
    11501024        case BAT_INFO_UNITS:
    1151             acpiFetchBatteryInfo(pThis);
     1025            acpiR3FetchBatteryInfo(pThis);
    11521026            /* fall thru */
    11531027        case BAT_INFO_DESIGN_CAPACITY:
     
    11631037
    11641038        case BAT_DEVICE_STATUS:
    1165             *pu32 = acpiGetBatteryDeviceStatus(pThis);
     1039            *pu32 = acpiR3GetBatteryDeviceStatus(pThis);
    11661040            break;
    11671041
    11681042        case BAT_POWER_SOURCE:
    1169             *pu32 = acpiGetPowerSource(pThis);
     1043            *pu32 = acpiR3GetPowerSource(pThis);
    11701044            break;
    11711045
     
    11831057 * @callback_method_impl{FNIOMIOPORTOUT, System info index}
    11841058 */
    1185 PDMBOTHCBDECL(int) acpiSysInfoIndexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    1186 {
    1187     Log(("acpiSysInfoIndexWrite: %#x (%#x)\n", u32, u32 >> 2));
     1059PDMBOTHCBDECL(int) acpiR3SysInfoIndexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     1060{
     1061    Log(("acpiR3SysInfoIndexWrite: %#x (%#x)\n", u32, u32 >> 2));
    11881062    if (cb != 4)
    11891063        return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "cb=%d Port=%u u32=%#x\n", cb, Port, u32);
     
    12151089 * @callback_method_impl{FNIOMIOPORTIN, System info data}
    12161090 */
    1217 PDMBOTHCBDECL(int) acpiSysInfoDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
     1091PDMBOTHCBDECL(int) acpiR3SysInfoDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
    12181092{
    12191093    if (cb != 4)
     
    13851259
    13861260    DEVACPI_UNLOCK(pThis);
    1387     Log(("acpiSysInfoDataRead: idx=%d val=%#x (%d) rc=%Rrc\n", uSystemInfoIndex, *pu32, *pu32, rc));
     1261    Log(("acpiR3SysInfoDataRead: idx=%d val=%#x (%d) rc=%Rrc\n", uSystemInfoIndex, *pu32, *pu32, rc));
    13881262    return rc;
    13891263}
     
    13921266 * @callback_method_impl{FNIOMIOPORTOUT, System info data}
    13931267 */
    1394 PDMBOTHCBDECL(int) acpiSysInfoDataWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     1268PDMBOTHCBDECL(int) acpiR3SysInfoDataWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    13951269{
    13961270    ACPIState *pThis = (ACPIState *)pvUser;
     
    14371311 * @callback_method_impl{FNIOMIOPORTIN, PM1a Enable}
    14381312 */
    1439 PDMBOTHCBDECL(int) acpiPm1aEnRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
     1313PDMBOTHCBDECL(int) acpiR3Pm1aEnRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
    14401314{
    14411315    NOREF(pDevIns); NOREF(Port);
     
    14491323
    14501324    DEVACPI_UNLOCK(pThis);
    1451     Log(("acpiPm1aEnRead -> %#x\n", *pu32));
     1325    Log(("acpiR3Pm1aEnRead -> %#x\n", *pu32));
    14521326    return VINF_SUCCESS;
    14531327}
     
    14561330 * @callback_method_impl{FNIOMIOPORTOUT, PM1a Enable}
    14571331 */
    1458 PDMBOTHCBDECL(int) acpiPM1aEnWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     1332PDMBOTHCBDECL(int) acpiR3PM1aEnWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    14591333{
    14601334    if (cb != 2 && cb != 4)
     
    14641338    DEVACPI_LOCK_R3(pThis);
    14651339
    1466     Log(("acpiPM1aEnWrite: %#x (%#x)\n", u32, u32 & ~(RSR_EN | IGN_EN) & 0xffff));
     1340    Log(("acpiR3PM1aEnWrite: %#x (%#x)\n", u32, u32 & ~(RSR_EN | IGN_EN) & 0xffff));
    14671341    u32 &= ~(RSR_EN | IGN_EN);
    14681342    u32 &= 0xffff;
    1469     update_pm1a(pThis, pThis->pm1a_sts, u32);
     1343    apicR3UpdatePm1a(pThis, pThis->pm1a_sts, u32);
    14701344
    14711345    DEVACPI_UNLOCK(pThis);
     
    14761350 * @callback_method_impl{FNIOMIOPORTIN, PM1a Status}
    14771351 */
    1478 PDMBOTHCBDECL(int) acpiPm1aStsRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
     1352PDMBOTHCBDECL(int) acpiR3Pm1aStsRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
    14791353{
    14801354    if (cb != 2)
     
    14901364
    14911365    DEVACPI_UNLOCK(pThis);
    1492     Log(("acpiPm1aStsRead: %#x\n", *pu32));
     1366    Log(("acpiR3Pm1aStsRead: %#x\n", *pu32));
    14931367    return VINF_SUCCESS;
    14941368}
     
    14971371 * @callback_method_impl{FNIOMIOPORTOUT, PM1a Status}
    14981372 */
    1499 PDMBOTHCBDECL(int) acpiPM1aStsWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     1373PDMBOTHCBDECL(int) acpiR3PM1aStsWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    15001374{
    15011375    if (cb != 2 && cb != 4)
     
    15051379    DEVACPI_LOCK_R3(pThis);
    15061380
    1507     Log(("acpiPM1aStsWrite: %#x (%#x)\n", u32, u32 & ~(RSR_STS | IGN_STS) & 0xffff));
     1381    Log(("acpiR3PM1aStsWrite: %#x (%#x)\n", u32, u32 & ~(RSR_STS | IGN_STS) & 0xffff));
    15081382    u32 &= 0xffff;
    15091383    if (u32 & PWRBTN_STS)
    15101384        pThis->fPowerButtonHandled = true; /* Remember that the guest handled the last power button event */
    15111385    u32 = pThis->pm1a_sts & ~(u32 & ~(RSR_STS | IGN_STS));
    1512     update_pm1a(pThis, u32, pThis->pm1a_en);
     1386    apicR3UpdatePm1a(pThis, u32, pThis->pm1a_en);
    15131387
    15141388    DEVACPI_UNLOCK(pThis);
     
    15191393 * @callback_method_impl{FNIOMIOPORTIN, PM1a Control}
    15201394 */
    1521 PDMBOTHCBDECL(int) acpiPm1aCtlRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
     1395PDMBOTHCBDECL(int) acpiR3Pm1aCtlRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
    15221396{
    15231397    if (cb != 2)
     
    15331407
    15341408    DEVACPI_UNLOCK(pThis);
    1535     Log(("acpiPm1aCtlRead: %#x\n", *pu32));
     1409    Log(("acpiR3Pm1aCtlRead: %#x\n", *pu32));
    15361410    return VINF_SUCCESS;
    15371411}
     
    15401414 * @callback_method_impl{FNIOMIOPORTOUT, PM1a Control}
    15411415 */
    1542 PDMBOTHCBDECL(int) acpiPM1aCtlWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     1416PDMBOTHCBDECL(int) acpiR3PM1aCtlWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    15431417{
    15441418    if (cb != 2 && cb != 4)
     
    15481422    DEVACPI_LOCK_R3(pThis);
    15491423
    1550     Log(("acpiPM1aCtlWrite: %#x (%#x)\n", u32, u32 & ~(RSR_CNT | IGN_CNT) & 0xffff));
     1424    Log(("acpiR3PM1aCtlWrite: %#x (%#x)\n", u32, u32 & ~(RSR_CNT | IGN_CNT) & 0xffff));
    15511425    u32 &= 0xffff;
    15521426    pThis->pm1a_ctl = u32 & ~(RSR_CNT | IGN_CNT);
     
    15661440                {
    15671441                    LogRel(("Entering S1 power state (powered-on suspend)\n"));
    1568                     rc = acpiSleep(pThis);
     1442                    rc = acpiR3DoSleep(pThis);
    15691443                    break;
    15701444                }
     
    15761450                {
    15771451                    LogRel(("Entering S4 power state (suspend to disk)\n"));
    1578                     rc = acpiPowerOff(pThis);/* Same behavior as S5 */
     1452                    rc = acpiR3DoPowerOff(pThis);/* Same behavior as S5 */
    15791453                    break;
    15801454                }
     
    15841458            case 0x05:                  /* S5 */
    15851459                LogRel(("Entering S5 power state (power down)\n"));
    1586                 rc = acpiPowerOff(pThis);
     1460                rc = acpiR3DoPowerOff(pThis);
    15871461                break;
    15881462
     
    15941468
    15951469    DEVACPI_UNLOCK(pThis);
    1596     Log(("acpiPM1aCtlWrite: rc=%Rrc\n", rc));
     1470    Log(("acpiR3PM1aCtlWrite: rc=%Rrc\n", rc));
    15971471    return rc;
    15981472}
     
    16411515 * @callback_method_impl{FNIOMIOPORTIN, GPE0 Status}
    16421516 */
    1643 PDMBOTHCBDECL(int) acpiGpe0StsRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
     1517PDMBOTHCBDECL(int) acpiR3Gpe0StsRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
    16441518{
    16451519    if (cb != 1)
     
    16551529
    16561530    DEVACPI_UNLOCK(pThis);
    1657     Log(("acpiGpe0StsRead: %#x\n", *pu32));
     1531    Log(("acpiR3Gpe0StsRead: %#x\n", *pu32));
    16581532    return VINF_SUCCESS;
    16591533}
     
    16621536 * @callback_method_impl{FNIOMIOPORTOUT, GPE0 Status}
    16631537 */
    1664 PDMBOTHCBDECL(int) acpiGpe0StsWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     1538PDMBOTHCBDECL(int) acpiR3Gpe0StsWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    16651539{
    16661540    if (cb != 1)
     
    16701544    DEVACPI_LOCK_R3(pThis);
    16711545
    1672     Log(("acpiGpe0StsWrite: %#x (%#x)\n", u32, pThis->gpe0_sts & ~u32));
     1546    Log(("acpiR3Gpe0StsWrite: %#x (%#x)\n", u32, pThis->gpe0_sts & ~u32));
    16731547    u32 = pThis->gpe0_sts & ~u32;
    1674     update_gpe0(pThis, u32, pThis->gpe0_en);
     1548    apicR3UpdateGpe0(pThis, u32, pThis->gpe0_en);
    16751549
    16761550    DEVACPI_UNLOCK(pThis);
     
    16811555 * @callback_method_impl{FNIOMIOPORTIN, GPE0 Enable}
    16821556 */
    1683 PDMBOTHCBDECL(int) acpiGpe0EnRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
     1557PDMBOTHCBDECL(int) acpiR3Gpe0EnRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
    16841558{
    16851559    if (cb != 1)
     
    16951569
    16961570    DEVACPI_UNLOCK(pThis);
    1697     Log(("acpiGpe0EnRead: %#x\n", *pu32));
     1571    Log(("acpiR3Gpe0EnRead: %#x\n", *pu32));
    16981572    return VINF_SUCCESS;
    16991573}
     
    17021576 * @callback_method_impl{FNIOMIOPORTOUT, GPE0 Enable}
    17031577 */
    1704 PDMBOTHCBDECL(int) acpiGpe0EnWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     1578PDMBOTHCBDECL(int) acpiR3Gpe0EnWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    17051579{
    17061580    if (cb != 1)
     
    17101584    DEVACPI_LOCK_R3(pThis);
    17111585
    1712     Log(("acpiGpe0EnWrite: %#x\n", u32));
    1713     update_gpe0(pThis, pThis->gpe0_sts, u32);
     1586    Log(("acpiR3Gpe0EnWrite: %#x\n", u32));
     1587    apicR3UpdateGpe0(pThis, pThis->gpe0_sts, u32);
    17141588
    17151589    DEVACPI_UNLOCK(pThis);
     
    17201594 * @callback_method_impl{FNIOMIOPORTOUT, SMI_CMD}
    17211595 */
    1722 PDMBOTHCBDECL(int) acpiSmiWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    1723 {
    1724     Log(("acpiSmiWrite %#x\n", u32));
     1596PDMBOTHCBDECL(int) acpiR3SmiWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     1597{
     1598    Log(("acpiR3SmiWrite %#x\n", u32));
    17251599    if (cb != 1)
    17261600        return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "cb=%d Port=%u u32=%#x\n", cb, Port, u32);
     
    17341608        pThis->pm1a_ctl &= ~SCI_EN;
    17351609    else
    1736         Log(("acpiSmiWrite: %#x <- unknown value\n", u32));
     1610        Log(("acpiR3SmiWrite: %#x <- unknown value\n", u32));
    17371611
    17381612    DEVACPI_UNLOCK(pThis);
     
    17431617 * @{FNIOMIOPORTOUT, ACPI_RESET_BLK}
    17441618 */
    1745 PDMBOTHCBDECL(int) acpiResetWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    1746 {
    1747     Log(("acpiResetWrite: %#x\n", u32));
     1619PDMBOTHCBDECL(int) acpiR3ResetWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     1620{
     1621    Log(("acpiR3ResetWrite: %#x\n", u32));
    17481622    NOREF(pvUser);
    17491623    if (cb != 1)
     
    17581632    }
    17591633    else
    1760         Log(("acpiResetWrite: %#x <- unknown value\n", u32));
     1634        Log(("acpiR3ResetWrite: %#x <- unknown value\n", u32));
    17611635
    17621636    return rc;
     
    17681642 * @callback_method_impl{FNIOMIOPORTOUT, Debug hex value logger}
    17691643 */
    1770 PDMBOTHCBDECL(int) acpiDhexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     1644PDMBOTHCBDECL(int) acpiR3DhexWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    17711645{
    17721646    NOREF(pvUser);
     
    17901664 * @callback_method_impl{FNIOMIOPORTOUT, Debug char logger}
    17911665 */
    1792 PDMBOTHCBDECL(int) acpiDchrWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     1666PDMBOTHCBDECL(int) acpiR3DchrWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    17931667{
    17941668    NOREF(pvUser);
     
    18131687 * @param   offset              The offset into the I/O space, or -1 if invalid.
    18141688 */
    1815 static RTIOPORT acpiCalcPmPort(ACPIState *pThis, int32_t offset)
     1689static RTIOPORT acpiR3CalcPmPort(ACPIState *pThis, int32_t offset)
    18161690{
    18171691    Assert(pThis->uPmIoPortBase != 0);
     
    18241698
    18251699/**
    1826  * Called by acpiLoadState and acpiUpdatePmHandlers to register the PM1a, PM
     1700 * Called by acpiR3LoadState and acpiR3UpdatePmHandlers to register the PM1a, PM
    18271701 * timer and GPE0 I/O ports.
    18281702 *
     
    18301704 * @param   pThis           The ACPI instance.
    18311705 */
    1832 static int acpiRegisterPmHandlers(ACPIState *pThis)
     1706static int acpiR3RegisterPmHandlers(ACPIState *pThis)
    18331707{
    18341708    int   rc = VINF_SUCCESS;
     
    18361710#define R(offset, cnt, writer, reader, description) \
    18371711    do { \
    1838         rc = PDMDevHlpIOPortRegister(pThis->pDevIns, acpiCalcPmPort(pThis, offset), cnt, pThis, writer, reader, \
     1712        rc = PDMDevHlpIOPortRegister(pThis->pDevIns, acpiR3CalcPmPort(pThis, offset), cnt, pThis, writer, reader, \
    18391713                                      NULL, NULL, description); \
    18401714        if (RT_FAILURE(rc)) \
     
    18431717#define L       (GPE0_BLK_LEN / 2)
    18441718
    1845     R(PM1a_EVT_OFFSET+2, 1, acpiPM1aEnWrite,       acpiPm1aEnRead,      "ACPI PM1a Enable");
    1846     R(PM1a_EVT_OFFSET,   1, acpiPM1aStsWrite,      acpiPm1aStsRead,     "ACPI PM1a Status");
    1847     R(PM1a_CTL_OFFSET,   1, acpiPM1aCtlWrite,      acpiPm1aCtlRead,     "ACPI PM1a Control");
     1719    R(PM1a_EVT_OFFSET+2, 1, acpiR3PM1aEnWrite,       acpiR3Pm1aEnRead,      "ACPI PM1a Enable");
     1720    R(PM1a_EVT_OFFSET,   1, acpiR3PM1aStsWrite,      acpiR3Pm1aStsRead,     "ACPI PM1a Status");
     1721    R(PM1a_CTL_OFFSET,   1, acpiR3PM1aCtlWrite,      acpiR3Pm1aCtlRead,     "ACPI PM1a Control");
    18481722    R(PM_TMR_OFFSET,     1, NULL,                  acpiPMTmrRead,       "ACPI PM Timer");
    1849     R(GPE0_OFFSET + L,   L, acpiGpe0EnWrite,       acpiGpe0EnRead,      "ACPI GPE0 Enable");
    1850     R(GPE0_OFFSET,       L, acpiGpe0StsWrite,      acpiGpe0StsRead,     "ACPI GPE0 Status");
     1723    R(GPE0_OFFSET + L,   L, acpiR3Gpe0EnWrite,       acpiR3Gpe0EnRead,      "ACPI GPE0 Enable");
     1724    R(GPE0_OFFSET,       L, acpiR3Gpe0StsWrite,      acpiR3Gpe0StsRead,     "ACPI GPE0 Status");
    18511725#undef L
    18521726#undef R
     
    18551729    if (pThis->fGCEnabled)
    18561730    {
    1857         rc = PDMDevHlpIOPortRegisterRC(pThis->pDevIns, acpiCalcPmPort(pThis, PM_TMR_OFFSET),
     1731        rc = PDMDevHlpIOPortRegisterRC(pThis->pDevIns, acpiR3CalcPmPort(pThis, PM_TMR_OFFSET),
    18581732                                       1, 0, NULL, "acpiPMTmrRead",
    18591733                                       NULL, NULL, "ACPI PM Timer");
     
    18641738    if (pThis->fR0Enabled)
    18651739    {
    1866         rc = PDMDevHlpIOPortRegisterR0(pThis->pDevIns, acpiCalcPmPort(pThis, PM_TMR_OFFSET),
     1740        rc = PDMDevHlpIOPortRegisterR0(pThis->pDevIns, acpiR3CalcPmPort(pThis, PM_TMR_OFFSET),
    18671741                                       1, 0, NULL, "acpiPMTmrRead",
    18681742                                       NULL, NULL, "ACPI PM Timer");
     
    18741748
    18751749/**
    1876  * Called by acpiLoadState and acpiUpdatePmHandlers to unregister the PM1a, PM
     1750 * Called by acpiR3LoadState and acpiR3UpdatePmHandlers to unregister the PM1a, PM
    18771751 * timer and GPE0 I/O ports.
    18781752 *
     
    18801754 * @param   pThis           The ACPI instance.
    18811755 */
    1882 static int acpiUnregisterPmHandlers(ACPIState *pThis)
     1756static int acpiR3UnregisterPmHandlers(ACPIState *pThis)
    18831757{
    18841758#define U(offset, cnt) \
    18851759    do { \
    1886         int rc = PDMDevHlpIOPortDeregister(pThis->pDevIns, acpiCalcPmPort(pThis, offset), cnt); \
     1760        int rc = PDMDevHlpIOPortDeregister(pThis->pDevIns, acpiR3CalcPmPort(pThis, offset), cnt); \
    18871761        AssertRCReturn(rc, rc); \
    18881762    } while (0)
     
    19021776
    19031777/**
    1904  * Called by acpiPciConfigWrite and acpiReset to change the location of the
     1778 * Called by acpiR3PciConfigWrite and acpiReset to change the location of the
    19051779 * PM1a, PM timer and GPE0 ports.
    19061780 *
     
    19101784 * @param   NewIoPortBase   The new base address of the I/O ports.
    19111785 */
    1912 static int acpiUpdatePmHandlers(ACPIState *pThis, RTIOPORT NewIoPortBase)
     1786static int acpiR3UpdatePmHandlers(ACPIState *pThis, RTIOPORT NewIoPortBase)
    19131787{
    19141788    Log(("acpi: rebasing PM 0x%x -> 0x%x\n", pThis->uPmIoPortBase, NewIoPortBase));
    19151789    if (NewIoPortBase != pThis->uPmIoPortBase)
    19161790    {
    1917         int rc = acpiUnregisterPmHandlers(pThis);
     1791        int rc = acpiR3UnregisterPmHandlers(pThis);
    19181792        if (RT_FAILURE(rc))
    19191793            return rc;
     
    19211795        pThis->uPmIoPortBase = NewIoPortBase;
    19221796
    1923         rc = acpiRegisterPmHandlers(pThis);
     1797        rc = acpiR3RegisterPmHandlers(pThis);
    19241798        if (RT_FAILURE(rc))
    19251799            return rc;
    19261800
    19271801        /* We have to update FADT table acccording to the new base */
    1928         rc = acpiPlantTables(pThis);
     1802        rc = acpiR3PlantTables(pThis);
    19291803        AssertRC(rc);
    19301804        if (RT_FAILURE(rc))
     
    19991873 * @callback_method_impl{FNSSMDEVSAVEEXEC}
    20001874 */
    2001 static DECLCALLBACK(int) acpiSaveState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
     1875static DECLCALLBACK(int) acpiR3SaveState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
    20021876{
    20031877    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
     
    20081882 * @callback_method_impl{FNSSMDEVLOADEXEC}
    20091883 */
    2010 static DECLCALLBACK(int) acpiLoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle,
    2011                                        uint32_t uVersion, uint32_t uPass)
     1884static DECLCALLBACK(int) acpiR3LoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, uint32_t uVersion, uint32_t uPass)
    20121885{
    20131886    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
     
    20181891     * successfully loaded.
    20191892     */
    2020     int rc = acpiUnregisterPmHandlers(pThis);
     1893    int rc = acpiR3UnregisterPmHandlers(pThis);
    20211894    if (RT_FAILURE(rc))
    20221895        return rc;
     
    20391912    if (RT_SUCCESS(rc))
    20401913    {
    2041         rc = acpiRegisterPmHandlers(pThis);
     1914        rc = acpiR3RegisterPmHandlers(pThis);
    20421915        if (RT_FAILURE(rc))
    20431916            return rc;
    2044         rc = acpiFetchBatteryStatus(pThis);
     1917        rc = acpiR3FetchBatteryStatus(pThis);
    20451918        if (RT_FAILURE(rc))
    20461919            return rc;
    2047         rc = acpiFetchBatteryInfo(pThis);
     1920        rc = acpiR3FetchBatteryInfo(pThis);
    20481921        if (RT_FAILURE(rc))
    20491922            return rc;
    20501923        TMTimerLock(pThis->pPmTimerR3, VERR_IGNORED);
    2051         acpiPmTimerReset(pThis, TMTimerGet(pThis->pPmTimerR3));
     1924        acpiR3PmTimerReset(pThis, TMTimerGet(pThis->pPmTimerR3));
    20521925        TMTimerUnlock(pThis->pPmTimerR3);
    20531926    }
     
    20581931 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    20591932 */
    2060 static DECLCALLBACK(void *) acpiQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     1933static DECLCALLBACK(void *) acpiR3QueryInterface(PPDMIBASE pInterface, const char *pszIID)
    20611934{
    20621935    ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IBase);
     
    20751948 * @param   cbData      The amount of data to checksum.
    20761949 */
    2077 static uint8_t acpiChecksum(const void * const pvSrc, size_t cbData)
     1950static uint8_t acpiR3Checksum(const void * const pvSrc, size_t cbData)
    20781951{
    20791952    uint8_t const *pbSrc = (uint8_t const *)pvSrc;
     
    20871960 * Prepare a ACPI table header.
    20881961 */
    2089 static void acpiPrepareHeader(ACPIState *pThis, ACPITBLHEADER *header,
    2090                               const char au8Signature[4],
    2091                               uint32_t u32Length, uint8_t u8Revision)
     1962static void acpiR3PrepareHeader(ACPIState *pThis, ACPITBLHEADER *header,
     1963                                const char au8Signature[4],
     1964                                uint32_t u32Length, uint8_t u8Revision)
    20921965{
    20931966    memcpy(header->au8Signature, au8Signature, 4);
     
    21051978 * Initialize a generic address structure (ACPIGENADDR).
    21061979 */
    2107 static void acpiWriteGenericAddr(ACPIGENADDR *g, uint8_t u8AddressSpaceId,
    2108                                  uint8_t u8RegisterBitWidth, uint8_t u8RegisterBitOffset,
    2109                                  uint8_t u8AccessSize, uint64_t u64Address)
     1980static void acpiR3WriteGenericAddr(ACPIGENADDR *g, uint8_t u8AddressSpaceId,
     1981                                   uint8_t u8RegisterBitWidth, uint8_t u8RegisterBitOffset,
     1982                                   uint8_t u8AccessSize, uint64_t u64Address)
    21101983{
    21111984    g->u8AddressSpaceId    = u8AddressSpaceId;
     
    21191992 * Wrapper around PDMDevHlpPhysWrite used when planting ACPI tables.
    21201993 */
    2121 static void acpiPhyscpy(ACPIState *pThis, RTGCPHYS32 dst, const void * const src, size_t size)
    2122 {
    2123     PDMDevHlpPhysWrite(pThis->pDevIns, dst, src, size);
     1994DECLINLINE(void) acpiR3PhysCopy(ACPIState *pThis, RTGCPHYS32 GCPhys32Dst, const void *pvSrc, size_t cbToCopy)
     1995{
     1996    PDMDevHlpPhysWrite(pThis->pDevIns, GCPhys32Dst, pvSrc, cbToCopy);
    21241997}
    21251998
     
    21272000 * Plant the Differentiated System Description Table (DSDT).
    21282001 */
    2129 static void acpiSetupDSDT(ACPIState *pThis, RTGCPHYS32 addr,
    2130                             void* pPtr, size_t uDsdtLen)
    2131 {
    2132     acpiPhyscpy(pThis, addr, pPtr, uDsdtLen);
     2002static void acpiR3SetupDsdt(ACPIState *pThis, RTGCPHYS32 GCPhys32, void *pvPtr, size_t cbDsdt)
     2003{
     2004    acpiR3PhysCopy(pThis, GCPhys32, pvPtr, cbDsdt);
    21332005}
    21342006
     
    21362008 * Plan the Secondary System Description Table (SSDT).
    21372009 */
    2138 static void acpiSetupSSDT(ACPIState *pThis, RTGCPHYS32 addr,
     2010static void acpiR3SetupSsdt(ACPIState *pThis, RTGCPHYS32 addr,
    21392011                            void* pPtr, size_t uSsdtLen)
    21402012{
    2141     acpiPhyscpy(pThis, addr, pPtr, uSsdtLen);
     2013    acpiR3PhysCopy(pThis, addr, pPtr, uSsdtLen);
    21422014}
    21432015
     
    21452017 * Plant the Firmware ACPI Control Structure (FACS).
    21462018 */
    2147 static void acpiSetupFACS(ACPIState *pThis, RTGCPHYS32 addr)
     2019static void acpiR3SetupFacs(ACPIState *pThis, RTGCPHYS32 addr)
    21482020{
    21492021    ACPITBLFACS facs;
     
    21592031    facs.u8Version            = 1;
    21602032
    2161     acpiPhyscpy(pThis, addr, (const uint8_t *)&facs, sizeof(facs));
     2033    acpiR3PhysCopy(pThis, addr, (const uint8_t *)&facs, sizeof(facs));
    21622034}
    21632035
     
    21652037 * Plant the Fixed ACPI Description Table (FADT aka FACP).
    21662038 */
    2167 static void acpiSetupFADT(ACPIState *pThis, RTGCPHYS32 GCPhysAcpi1, RTGCPHYS32 GCPhysAcpi2, RTGCPHYS32 GCPhysFacs, RTGCPHYS GCPhysDsdt)
     2039static void acpiR3SetupFadt(ACPIState *pThis, RTGCPHYS32 GCPhysAcpi1, RTGCPHYS32 GCPhysAcpi2,
     2040                            RTGCPHYS32 GCPhysFacs, RTGCPHYS GCPhysDsdt)
    21682041{
    21692042    ACPITBLFADT fadt;
     
    21712044    /* First the ACPI version 2+ version of the structure. */
    21722045    memset(&fadt, 0, sizeof(fadt));
    2173     acpiPrepareHeader(pThis, &fadt.header, "FACP", sizeof(fadt), 4);
     2046    acpiR3PrepareHeader(pThis, &fadt.header, "FACP", sizeof(fadt), 4);
    21742047    fadt.u32FACS              = RT_H2LE_U32(GCPhysFacs);
    21752048    fadt.u32DSDT              = RT_H2LE_U32(GCPhysDsdt);
     
    21822055    fadt.u8S4BIOSReq          = 0;
    21832056    fadt.u8PStateCnt          = 0;
    2184     fadt.u32PM1aEVTBLK        = RT_H2LE_U32(acpiCalcPmPort(pThis, PM1a_EVT_OFFSET));
    2185     fadt.u32PM1bEVTBLK        = RT_H2LE_U32(acpiCalcPmPort(pThis, PM1b_EVT_OFFSET));
    2186     fadt.u32PM1aCTLBLK        = RT_H2LE_U32(acpiCalcPmPort(pThis, PM1a_CTL_OFFSET));
    2187     fadt.u32PM1bCTLBLK        = RT_H2LE_U32(acpiCalcPmPort(pThis, PM1b_CTL_OFFSET));
    2188     fadt.u32PM2CTLBLK         = RT_H2LE_U32(acpiCalcPmPort(pThis, PM2_CTL_OFFSET));
    2189     fadt.u32PMTMRBLK          = RT_H2LE_U32(acpiCalcPmPort(pThis, PM_TMR_OFFSET));
    2190     fadt.u32GPE0BLK           = RT_H2LE_U32(acpiCalcPmPort(pThis, GPE0_OFFSET));
    2191     fadt.u32GPE1BLK           = RT_H2LE_U32(acpiCalcPmPort(pThis, GPE1_OFFSET));
     2057    fadt.u32PM1aEVTBLK        = RT_H2LE_U32(acpiR3CalcPmPort(pThis, PM1a_EVT_OFFSET));
     2058    fadt.u32PM1bEVTBLK        = RT_H2LE_U32(acpiR3CalcPmPort(pThis, PM1b_EVT_OFFSET));
     2059    fadt.u32PM1aCTLBLK        = RT_H2LE_U32(acpiR3CalcPmPort(pThis, PM1a_CTL_OFFSET));
     2060    fadt.u32PM1bCTLBLK        = RT_H2LE_U32(acpiR3CalcPmPort(pThis, PM1b_CTL_OFFSET));
     2061    fadt.u32PM2CTLBLK         = RT_H2LE_U32(acpiR3CalcPmPort(pThis, PM2_CTL_OFFSET));
     2062    fadt.u32PMTMRBLK          = RT_H2LE_U32(acpiR3CalcPmPort(pThis, PM_TMR_OFFSET));
     2063    fadt.u32GPE0BLK           = RT_H2LE_U32(acpiR3CalcPmPort(pThis, GPE0_OFFSET));
     2064    fadt.u32GPE1BLK           = RT_H2LE_U32(acpiR3CalcPmPort(pThis, GPE1_OFFSET));
    21922065    fadt.u8PM1EVTLEN          = 4;
    21932066    fadt.u8PM1CTLLEN          = 2;
     
    22182091        fadt.u32Flags |= RT_H2LE_U32(FADT_FL_FORCE_APIC_PHYS_DEST_MODE);
    22192092
    2220     acpiWriteGenericAddr(&fadt.ResetReg,     1,  8, 0, 1, ACPI_RESET_BLK);
     2093    acpiR3WriteGenericAddr(&fadt.ResetReg,     1,  8, 0, 1, ACPI_RESET_BLK);
    22212094    fadt.u8ResetVal           = ACPI_RESET_REG_VAL;
    22222095    fadt.u64XFACS             = RT_H2LE_U64((uint64_t)GCPhysFacs);
    22232096    fadt.u64XDSDT             = RT_H2LE_U64((uint64_t)GCPhysDsdt);
    2224     acpiWriteGenericAddr(&fadt.X_PM1aEVTBLK, 1, 32, 0, 2, acpiCalcPmPort(pThis, PM1a_EVT_OFFSET));
    2225     acpiWriteGenericAddr(&fadt.X_PM1bEVTBLK, 0,  0, 0, 0, acpiCalcPmPort(pThis, PM1b_EVT_OFFSET));
    2226     acpiWriteGenericAddr(&fadt.X_PM1aCTLBLK, 1, 16, 0, 2, acpiCalcPmPort(pThis, PM1a_CTL_OFFSET));
    2227     acpiWriteGenericAddr(&fadt.X_PM1bCTLBLK, 0,  0, 0, 0, acpiCalcPmPort(pThis, PM1b_CTL_OFFSET));
    2228     acpiWriteGenericAddr(&fadt.X_PM2CTLBLK,  0,  0, 0, 0, acpiCalcPmPort(pThis, PM2_CTL_OFFSET));
    2229     acpiWriteGenericAddr(&fadt.X_PMTMRBLK,   1, 32, 0, 3, acpiCalcPmPort(pThis, PM_TMR_OFFSET));
    2230     acpiWriteGenericAddr(&fadt.X_GPE0BLK,    1, 16, 0, 1, acpiCalcPmPort(pThis, GPE0_OFFSET));
    2231     acpiWriteGenericAddr(&fadt.X_GPE1BLK,    0,  0, 0, 0, acpiCalcPmPort(pThis, GPE1_OFFSET));
    2232     fadt.header.u8Checksum    = acpiChecksum(&fadt, sizeof(fadt));
    2233     acpiPhyscpy(pThis, GCPhysAcpi2, &fadt, sizeof(fadt));
     2097    acpiR3WriteGenericAddr(&fadt.X_PM1aEVTBLK, 1, 32, 0, 2, acpiR3CalcPmPort(pThis, PM1a_EVT_OFFSET));
     2098    acpiR3WriteGenericAddr(&fadt.X_PM1bEVTBLK, 0,  0, 0, 0, acpiR3CalcPmPort(pThis, PM1b_EVT_OFFSET));
     2099    acpiR3WriteGenericAddr(&fadt.X_PM1aCTLBLK, 1, 16, 0, 2, acpiR3CalcPmPort(pThis, PM1a_CTL_OFFSET));
     2100    acpiR3WriteGenericAddr(&fadt.X_PM1bCTLBLK, 0,  0, 0, 0, acpiR3CalcPmPort(pThis, PM1b_CTL_OFFSET));
     2101    acpiR3WriteGenericAddr(&fadt.X_PM2CTLBLK,  0,  0, 0, 0, acpiR3CalcPmPort(pThis, PM2_CTL_OFFSET));
     2102    acpiR3WriteGenericAddr(&fadt.X_PMTMRBLK,   1, 32, 0, 3, acpiR3CalcPmPort(pThis, PM_TMR_OFFSET));
     2103    acpiR3WriteGenericAddr(&fadt.X_GPE0BLK,    1, 16, 0, 1, acpiR3CalcPmPort(pThis, GPE0_OFFSET));
     2104    acpiR3WriteGenericAddr(&fadt.X_GPE1BLK,    0,  0, 0, 0, acpiR3CalcPmPort(pThis, GPE1_OFFSET));
     2105    fadt.header.u8Checksum    = acpiR3Checksum(&fadt, sizeof(fadt));
     2106    acpiR3PhysCopy(pThis, GCPhysAcpi2, &fadt, sizeof(fadt));
    22342107
    22352108    /* Now the ACPI 1.0 version. */
     
    22372110    fadt.u8IntModel           = INT_MODEL_DUAL_PIC;
    22382111    fadt.header.u8Checksum    = 0;  /* Must be zeroed before recalculating checksum! */
    2239     fadt.header.u8Checksum    = acpiChecksum(&fadt, ACPITBLFADT_VERSION1_SIZE);
    2240     acpiPhyscpy(pThis, GCPhysAcpi1, &fadt, ACPITBLFADT_VERSION1_SIZE);
     2112    fadt.header.u8Checksum    = acpiR3Checksum(&fadt, ACPITBLFADT_VERSION1_SIZE);
     2113    acpiR3PhysCopy(pThis, GCPhysAcpi1, &fadt, ACPITBLFADT_VERSION1_SIZE);
    22412114}
    22422115
     
    22482121 * ACPI 2.0 and up.
    22492122 */
    2250 static int acpiSetupRSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)
     2123static int acpiR3SetupRsdt(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)
    22512124{
    22522125    ACPITBLRSDT *rsdt;
     
    22572130        return PDMDEV_SET_ERROR(pThis->pDevIns, VERR_NO_TMP_MEMORY, N_("Cannot allocate RSDT"));
    22582131
    2259     acpiPrepareHeader(pThis, &rsdt->header, "RSDT", (uint32_t)size, 1);
     2132    acpiR3PrepareHeader(pThis, &rsdt->header, "RSDT", (uint32_t)size, 1);
    22602133    for (unsigned int i = 0; i < nb_entries; ++i)
    22612134    {
     
    22632136        Log(("Setup RSDT: [%d] = %x\n", i, rsdt->u32Entry[i]));
    22642137    }
    2265     rsdt->header.u8Checksum = acpiChecksum(rsdt, size);
    2266     acpiPhyscpy(pThis, addr, rsdt, size);
     2138    rsdt->header.u8Checksum = acpiR3Checksum(rsdt, size);
     2139    acpiR3PhysCopy(pThis, addr, rsdt, size);
    22672140    RTMemFree(rsdt);
    22682141    return VINF_SUCCESS;
     
    22722145 * Plant the Extended System Description Table.
    22732146 */
    2274 static int acpiSetupXSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)
     2147static int acpiR3SetupXsdt(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)
    22752148{
    22762149    ACPITBLXSDT *xsdt;
     
    22812154        return VERR_NO_TMP_MEMORY;
    22822155
    2283     acpiPrepareHeader(pThis, &xsdt->header, "XSDT", (uint32_t)size, 1 /* according to ACPI 3.0 specs */);
     2156    acpiR3PrepareHeader(pThis, &xsdt->header, "XSDT", (uint32_t)size, 1 /* according to ACPI 3.0 specs */);
    22842157
    22852158    if (pThis->fUseCust)
     
    22912164        Log(("Setup XSDT: [%d] = %RX64\n", i, xsdt->u64Entry[i]));
    22922165    }
    2293     xsdt->header.u8Checksum = acpiChecksum(xsdt, size);
    2294     acpiPhyscpy(pThis, addr, xsdt, size);
     2166    xsdt->header.u8Checksum = acpiR3Checksum(xsdt, size);
     2167    acpiR3PhysCopy(pThis, addr, xsdt, size);
    22952168    RTMemFree(xsdt);
    22962169    return VINF_SUCCESS;
     
    23002173 * Plant the Root System Description Pointer (RSDP).
    23012174 */
    2302 static void acpiSetupRSDP(ACPIState *pThis, ACPITBLRSDP *rsdp, RTGCPHYS32 GCPhysRsdt, RTGCPHYS GCPhysXsdt)
     2175static void acpiR3SetupRsdp(ACPIState *pThis, ACPITBLRSDP *rsdp, RTGCPHYS32 GCPhysRsdt, RTGCPHYS GCPhysXsdt)
    23032176{
    23042177    memset(rsdp, 0, sizeof(*rsdp));
    23052178
    2306     /* ACPI 1.0 part (RSDT */
     2179    /* ACPI 1.0 part (RSDT) */
    23072180    memcpy(rsdp->au8Signature, "RSD PTR ", 8);
    23082181    memcpy(rsdp->au8OemId, pThis->au8OemId, 6);
    23092182    rsdp->u8Revision    = ACPI_REVISION;
    23102183    rsdp->u32RSDT       = RT_H2LE_U32(GCPhysRsdt);
    2311     rsdp->u8Checksum    = acpiChecksum(rsdp, RT_OFFSETOF(ACPITBLRSDP, u32Length));
     2184    rsdp->u8Checksum    = acpiR3Checksum(rsdp, RT_OFFSETOF(ACPITBLRSDP, u32Length));
    23122185
    23132186    /* ACPI 2.0 part (XSDT) */
    23142187    rsdp->u32Length     = RT_H2LE_U32(sizeof(ACPITBLRSDP));
    23152188    rsdp->u64XSDT       = RT_H2LE_U64(GCPhysXsdt);
    2316     rsdp->u8ExtChecksum = acpiChecksum(rsdp, sizeof(ACPITBLRSDP));
    2317 }
     2189    rsdp->u8ExtChecksum = acpiR3Checksum(rsdp, sizeof(ACPITBLRSDP));
     2190}
     2191
     2192/**
     2193 * Multiple APIC Description Table.
     2194 *
     2195 * This structure looks somewhat convoluted due layout of MADT table in MP case.
     2196 * There extpected to be multiple LAPIC records for each CPU, thus we cannot
     2197 * use regular C structure and proxy to raw memory instead.
     2198 */
     2199class AcpiTableMadt
     2200{
     2201    /**
     2202     * All actual data stored in dynamically allocated memory pointed by this field.
     2203     */
     2204    uint8_t            *m_pbData;
     2205    /**
     2206     * Number of CPU entries in this MADT.
     2207     */
     2208    uint32_t            m_cCpus;
     2209
     2210    /**
     2211     * Number of interrupt overrides.
     2212     */
     2213     uint32_t            m_cIsos;
     2214
     2215public:
     2216    /**
     2217     * Address of ACPI header
     2218     */
     2219    inline ACPITBLHEADER *header_addr(void) const
     2220    {
     2221        return (ACPITBLHEADER *)m_pbData;
     2222    }
     2223
     2224    /**
     2225     * Address of local APIC for each CPU. Note that different CPUs address different LAPICs,
     2226     * although address is the same for all of them.
     2227     */
     2228    inline uint32_t *u32LAPIC_addr(void) const
     2229    {
     2230        return (uint32_t *)(header_addr() + 1);
     2231    }
     2232
     2233    /**
     2234     * Address of APIC flags
     2235     */
     2236    inline uint32_t *u32Flags_addr(void) const
     2237    {
     2238        return (uint32_t *)(u32LAPIC_addr() + 1);
     2239    }
     2240
     2241    /**
     2242     * Address of ISO description
     2243     */
     2244    inline ACPITBLISO *ISO_addr(void) const
     2245    {
     2246        return (ACPITBLISO *)(u32Flags_addr() + 1);
     2247    }
     2248
     2249    /**
     2250     * Address of per-CPU LAPIC descriptions
     2251     */
     2252    inline ACPITBLLAPIC *LApics_addr(void) const
     2253    {
     2254        return (ACPITBLLAPIC *)(ISO_addr() + m_cIsos);
     2255    }
     2256
     2257    /**
     2258     * Address of IO APIC description
     2259     */
     2260    inline ACPITBLIOAPIC *IOApic_addr(void) const
     2261    {
     2262        return (ACPITBLIOAPIC *)(LApics_addr() + m_cCpus);
     2263    }
     2264
     2265    /**
     2266     * Size of MADT.
     2267     * Note that this function assumes IOApic to be the last field in structure.
     2268     */
     2269    inline uint32_t size(void) const
     2270    {
     2271        return (uint8_t *)(IOApic_addr() + 1) - (uint8_t *)header_addr();
     2272    }
     2273
     2274    /**
     2275     * Raw data of MADT.
     2276     */
     2277    inline const uint8_t *data(void) const
     2278    {
     2279        return m_pbData;
     2280    }
     2281
     2282    /**
     2283     * Size of MADT for given ACPI config, useful to compute layout.
     2284     */
     2285    static uint32_t sizeFor(ACPIState *pThis, uint32_t cIsos)
     2286    {
     2287        return AcpiTableMadt(pThis->cCpus, cIsos).size();
     2288    }
     2289
     2290    /*
     2291     * Constructor, only works in Ring 3, doesn't look like a big deal.
     2292     */
     2293    AcpiTableMadt(uint32_t cCpus, uint32_t cIsos)
     2294    {
     2295        m_cCpus  = cCpus;
     2296        m_cIsos  = cIsos;
     2297        m_pbData = NULL;                /* size() uses this and gcc will complain if not initialized. */
     2298        uint32_t cb = size();
     2299        m_pbData = (uint8_t *)RTMemAllocZ(cb);
     2300    }
     2301
     2302    ~AcpiTableMadt()
     2303    {
     2304        RTMemFree(m_pbData);
     2305    }
     2306};
     2307
    23182308
    23192309/**
     
    23242314 * @todo    All hardcoded, should set this up based on the actual VM config!!!!!
    23252315 */
    2326 static void acpiSetupMADT(ACPIState *pThis, RTGCPHYS32 addr)
     2316static void acpiR3SetupMadt(ACPIState *pThis, RTGCPHYS32 addr)
    23272317{
    23282318    uint16_t cpus = pThis->cCpus;
    2329     AcpiTableMADT madt(cpus, NUMBER_OF_IRQ_SOURCE_OVERRIDES);
    2330 
    2331     acpiPrepareHeader(pThis, madt.header_addr(), "APIC", madt.size(), 2);
     2319    AcpiTableMadt madt(cpus, NUMBER_OF_IRQ_SOURCE_OVERRIDES);
     2320
     2321    acpiR3PrepareHeader(pThis, madt.header_addr(), "APIC", madt.size(), 2);
    23322322
    23332323    *madt.u32LAPIC_addr()          = RT_H2LE_U32(0xfee00000);
     
    23882378    Assert(NUMBER_OF_IRQ_SOURCE_OVERRIDES == 2);
    23892379
    2390     madt.header_addr()->u8Checksum = acpiChecksum(madt.data(), madt.size());
    2391     acpiPhyscpy(pThis, addr, madt.data(), madt.size());
     2380    madt.header_addr()->u8Checksum = acpiR3Checksum(madt.data(), madt.size());
     2381    acpiR3PhysCopy(pThis, addr, madt.data(), madt.size());
    23922382}
    23932383
     
    23952385 * Plant the High Performance Event Timer (HPET) descriptor.
    23962386 */
    2397 static void acpiSetupHPET(ACPIState *pThis, RTGCPHYS32 addr)
     2387static void acpiR3SetupHpet(ACPIState *pThis, RTGCPHYS32 addr)
    23982388{
    23992389    ACPITBLHPET hpet;
     
    24012391    memset(&hpet, 0, sizeof(hpet));
    24022392
    2403     acpiPrepareHeader(pThis, &hpet.aHeader, "HPET", sizeof(hpet), 1);
     2393    acpiR3PrepareHeader(pThis, &hpet.aHeader, "HPET", sizeof(hpet), 1);
    24042394    /* Keep base address consistent with appropriate DSDT entry  (vbox.dsl) */
    2405     acpiWriteGenericAddr(&hpet.HpetAddr,
     2395    acpiR3WriteGenericAddr(&hpet.HpetAddr,
    24062396                         0  /* Memory address space */,
    24072397                         64 /* Register bit width */,
     
    24152405    hpet.u8Attributes = 0;
    24162406
    2417     hpet.aHeader.u8Checksum = acpiChecksum(&hpet, sizeof(hpet));
    2418 
    2419     acpiPhyscpy(pThis, addr, (const uint8_t *)&hpet, sizeof(hpet));
     2407    hpet.aHeader.u8Checksum = acpiR3Checksum(&hpet, sizeof(hpet));
     2408
     2409    acpiR3PhysCopy(pThis, addr, (const uint8_t *)&hpet, sizeof(hpet));
    24202410}
    24212411
    24222412
    24232413/** Custom Description Table */
    2424 static void acpiSetupCUST(ACPIState *pThis, RTGCPHYS32 addr)
     2414static void acpiR3SetupCust(ACPIState *pThis, RTGCPHYS32 addr)
    24252415{
    24262416    ACPITBLCUST cust;
     
    24282418    /* First the ACPI version 1 version of the structure. */
    24292419    memset(&cust, 0, sizeof(cust));
    2430     acpiPrepareHeader(pThis, &cust.header, "CUST", sizeof(cust), 1);
     2420    acpiR3PrepareHeader(pThis, &cust.header, "CUST", sizeof(cust), 1);
    24312421
    24322422    memcpy(cust.header.au8OemTabId, pThis->au8OemTabId, 8);
    24332423    cust.header.u32OemRevision = RT_H2LE_U32(pThis->u32OemRevision);
    2434     cust.header.u8Checksum = acpiChecksum((uint8_t *)&cust, sizeof(cust));
    2435 
    2436     acpiPhyscpy(pThis, addr, pThis->pu8CustBin, pThis->cbCustBin);
    2437 }
    2438 
    2439 /**
    2440  * Used by acpiPlantTables to plant a MMCONFIG PCI config space access (MCFG)
     2424    cust.header.u8Checksum = acpiR3Checksum((uint8_t *)&cust, sizeof(cust));
     2425
     2426    acpiR3PhysCopy(pThis, addr, pThis->pu8CustBin, pThis->cbCustBin);
     2427}
     2428
     2429/**
     2430 * Used by acpiR3PlantTables to plant a MMCONFIG PCI config space access (MCFG)
    24412431 * descriptor.
    24422432 *
     
    24442434 * @param   GCPhysDst   Where to plant it.
    24452435 */
    2446 static void acpiSetupMCFG(ACPIState *pThis, RTGCPHYS32 GCPhysDst)
     2436static void acpiR3SetupMcfg(ACPIState *pThis, RTGCPHYS32 GCPhysDst)
    24472437{
    24482438    struct
     
    24562446    RT_ZERO(tbl);
    24572447
    2458     acpiPrepareHeader(pThis, &tbl.hdr.aHeader, "MCFG", sizeof(tbl), 1);
     2448    acpiR3PrepareHeader(pThis, &tbl.hdr.aHeader, "MCFG", sizeof(tbl), 1);
    24592449    tbl.entry.u64BaseAddress = pThis->u64PciConfigMMioAddress;
    24602450    tbl.entry.u8StartBus     = u8StartBus;
     
    24622452    // u16PciSegmentGroup must match _SEG in ACPI table
    24632453
    2464     tbl.hdr.aHeader.u8Checksum = acpiChecksum(&tbl, sizeof(tbl));
    2465 
    2466     acpiPhyscpy(pThis, GCPhysDst, (const uint8_t *)&tbl, sizeof(tbl));
    2467 }
    2468 
    2469 /**
    2470  * Used by acpiPlantTables and acpiConstruct.
     2454    tbl.hdr.aHeader.u8Checksum = acpiR3Checksum(&tbl, sizeof(tbl));
     2455
     2456    acpiR3PhysCopy(pThis, GCPhysDst, (const uint8_t *)&tbl, sizeof(tbl));
     2457}
     2458
     2459/**
     2460 * Used by acpiR3PlantTables and acpiConstruct.
    24712461 *
    24722462 * @returns Guest memory address.
    24732463 */
    2474 static uint32_t find_rsdp_space(void)
     2464static uint32_t apicR3FindRsdpSpace(void)
    24752465{
    24762466    return 0xe0000;
     
    24802470 * Create the ACPI tables in guest memory.
    24812471 */
    2482 static int acpiPlantTables(ACPIState *pThis)
     2472static int acpiR3PlantTables(ACPIState *pThis)
    24832473{
    24842474    int        rc;
     
    25662556    {
    25672557        GCPhysApic = GCPhysCur;
    2568         GCPhysCur = RT_ALIGN_32(GCPhysCur + AcpiTableMADT::sizeFor(pThis, NUMBER_OF_IRQ_SOURCE_OVERRIDES), 16);
     2558        GCPhysCur = RT_ALIGN_32(GCPhysCur + AcpiTableMadt::sizeFor(pThis, NUMBER_OF_IRQ_SOURCE_OVERRIDES), 16);
    25692559    }
    25702560    if (pThis->fUseHpet)
     
    25862576
    25872577    void  *pvSsdtCode = NULL;
    2588     size_t cbSsdtSize = 0;
    2589     rc = acpiPrepareSsdt(pThis->pDevIns, &pvSsdtCode, &cbSsdtSize);
     2578    size_t cbSsdt = 0;
     2579    rc = acpiPrepareSsdt(pThis->pDevIns, &pvSsdtCode, &cbSsdt);
    25902580    if (RT_FAILURE(rc))
    25912581        return rc;
    25922582
    25932583    GCPhysSsdt = GCPhysCur;
    2594     GCPhysCur = RT_ALIGN_32(GCPhysCur + cbSsdtSize, 16);
     2584    GCPhysCur = RT_ALIGN_32(GCPhysCur + cbSsdt, 16);
    25952585
    25962586    GCPhysDsdt = GCPhysCur;
    25972587
    25982588    void  *pvDsdtCode = NULL;
    2599     size_t cbDsdtSize = 0;
    2600     rc = acpiPrepareDsdt(pThis->pDevIns, &pvDsdtCode, &cbDsdtSize);
     2589    size_t cbDsdt = 0;
     2590    rc = acpiPrepareDsdt(pThis->pDevIns, &pvDsdtCode, &cbDsdt);
    26012591    if (RT_FAILURE(rc))
    26022592        return rc;
    26032593
    2604     GCPhysCur = RT_ALIGN_32(GCPhysCur + cbDsdtSize, 16);
     2594    GCPhysCur = RT_ALIGN_32(GCPhysCur + cbDsdt, 16);
    26052595
    26062596    if (GCPhysCur > 0x10000)
     
    26082598                                N_("Error: ACPI tables bigger than 64KB"));
    26092599
    2610     Log(("RSDP 0x%08X\n", find_rsdp_space()));
     2600    Log(("RSDP 0x%08X\n", apicR3FindRsdpSpace()));
    26112601    addend = pThis->cbRamLow - 0x10000;
    26122602    Log(("RSDT 0x%08X XSDT 0x%08X\n", GCPhysRsdt + addend, GCPhysXsdt + addend));
     
    26242614    Log(("\n"));
    26252615
    2626     acpiSetupRSDP(pThis, (ACPITBLRSDP *)pThis->au8RSDPPage, GCPhysRsdt + addend, GCPhysXsdt + addend);
    2627     acpiSetupDSDT(pThis, GCPhysDsdt + addend, pvDsdtCode, cbDsdtSize);
     2616    acpiR3SetupRsdp(pThis, (ACPITBLRSDP *)pThis->au8RSDPPage, GCPhysRsdt + addend, GCPhysXsdt + addend);
     2617    acpiR3SetupDsdt(pThis, GCPhysDsdt + addend, pvDsdtCode, cbDsdt);
    26282618    acpiCleanupDsdt(pThis->pDevIns, pvDsdtCode);
    2629     acpiSetupFACS(pThis, GCPhysFacs + addend);
    2630     acpiSetupFADT(pThis, GCPhysFadtAcpi1 + addend, GCPhysFadtAcpi2 + addend, GCPhysFacs + addend, GCPhysDsdt + addend);
     2619    acpiR3SetupFacs(pThis, GCPhysFacs + addend);
     2620    acpiR3SetupFadt(pThis, GCPhysFadtAcpi1 + addend, GCPhysFadtAcpi2 + addend, GCPhysFacs + addend, GCPhysDsdt + addend);
    26312621
    26322622    aGCPhysRsdt[0] = GCPhysFadtAcpi1 + addend;
     
    26342624    if (pThis->u8UseIOApic)
    26352625    {
    2636         acpiSetupMADT(pThis, GCPhysApic + addend);
     2626        acpiR3SetupMadt(pThis, GCPhysApic + addend);
    26372627        aGCPhysRsdt[iMadt] = GCPhysApic + addend;
    26382628        aGCPhysXsdt[iMadt] = GCPhysApic + addend;
     
    26402630    if (pThis->fUseHpet)
    26412631    {
    2642         acpiSetupHPET(pThis, GCPhysHpet + addend);
     2632        acpiR3SetupHpet(pThis, GCPhysHpet + addend);
    26432633        aGCPhysRsdt[iHpet] = GCPhysHpet + addend;
    26442634        aGCPhysXsdt[iHpet] = GCPhysHpet + addend;
     
    26462636    if (pThis->fUseMcfg)
    26472637    {
    2648         acpiSetupMCFG(pThis, GCPhysMcfg + addend);
     2638        acpiR3SetupMcfg(pThis, GCPhysMcfg + addend);
    26492639        aGCPhysRsdt[iMcfg] = GCPhysMcfg + addend;
    26502640        aGCPhysXsdt[iMcfg] = GCPhysMcfg + addend;
     
    26522642    if (pThis->fUseCust)
    26532643    {
    2654         acpiSetupCUST(pThis, GCPhysCust + addend);
     2644        acpiR3SetupCust(pThis, GCPhysCust + addend);
    26552645        aGCPhysRsdt[iCust] = GCPhysCust + addend;
    26562646        aGCPhysXsdt[iCust] = GCPhysCust + addend;
    26572647    }
    26582648
    2659     acpiSetupSSDT(pThis, GCPhysSsdt + addend, pvSsdtCode, cbSsdtSize);
     2649    acpiR3SetupSsdt(pThis, GCPhysSsdt + addend, pvSsdtCode, cbSsdt);
    26602650    acpiCleanupSsdt(pThis->pDevIns, pvSsdtCode);
    26612651    aGCPhysRsdt[iSsdt] = GCPhysSsdt + addend;
    26622652    aGCPhysXsdt[iSsdt] = GCPhysSsdt + addend;
    26632653
    2664     rc = acpiSetupRSDT(pThis, GCPhysRsdt + addend, cAddr, aGCPhysRsdt);
     2654    rc = acpiR3SetupRsdt(pThis, GCPhysRsdt + addend, cAddr, aGCPhysRsdt);
    26652655    if (RT_FAILURE(rc))
    26662656        return rc;
    2667     return acpiSetupXSDT(pThis, GCPhysXsdt + addend, cAddr, aGCPhysXsdt);
     2657    return acpiR3SetupXsdt(pThis, GCPhysXsdt + addend, cAddr, aGCPhysXsdt);
    26682658}
    26692659
     
    26712661 * @callback_method_impl{FNPCICONFIGREAD}
    26722662 */
    2673 static DECLCALLBACK(uint32_t) acpiPciConfigRead(PPCIDEVICE pPciDev, uint32_t Address, unsigned cb)
     2663static DECLCALLBACK(uint32_t) acpiR3PciConfigRead(PPCIDEVICE pPciDev, uint32_t Address, unsigned cb)
    26742664{
    26752665    PPDMDEVINS pDevIns = pPciDev->pDevIns;
     
    26832673 * @callback_method_impl{FNPCICONFIGWRITE}
    26842674 */
    2685 static DECLCALLBACK(void) acpiPciConfigWrite(PPCIDEVICE pPciDev, uint32_t Address, uint32_t u32Value, unsigned cb)
     2675static DECLCALLBACK(void) acpiR3PciConfigWrite(PPCIDEVICE pPciDev, uint32_t Address, uint32_t u32Value, unsigned cb)
    26862676{
    26872677    PPDMDEVINS  pDevIns = pPciDev->pDevIns;
     
    27082698            NewIoPortBase &= 0xffc0;
    27092699
    2710             int rc = acpiUpdatePmHandlers(pThis, NewIoPortBase);
     2700            int rc = acpiR3UpdatePmHandlers(pThis, NewIoPortBase);
    27112701            AssertRC(rc);
    27122702        }
     
    27262716 * @remarks This code path is not used during construction.
    27272717 */
    2728 static DECLCALLBACK(int) acpiAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
     2718static DECLCALLBACK(int) acpiR3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    27292719{
    27302720    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
     
    27572747
    27582748            /* Notify the guest */
    2759             update_gpe0(pThis, pThis->gpe0_sts | 0x2, pThis->gpe0_en);
     2749            apicR3UpdateGpe0(pThis, pThis->gpe0_sts | 0x2, pThis->gpe0_en);
    27602750        }
    27612751    }
     
    27712761 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    27722762 */
    2773 static DECLCALLBACK(void) acpiDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
     2763static DECLCALLBACK(void) acpiR3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    27742764{
    27752765    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
     
    27922782
    27932783            /* Notify the guest */
    2794             update_gpe0(pThis, pThis->gpe0_sts | 0x2, pThis->gpe0_en);
     2784            apicR3UpdateGpe0(pThis, pThis->gpe0_sts | 0x2, pThis->gpe0_en);
    27952785        }
    27962786        else
     
    28032793 * @interface_method_impl{PDMDEVREG,pfnResume}
    28042794 */
    2805 static DECLCALLBACK(void) acpiResume(PPDMDEVINS pDevIns)
     2795static DECLCALLBACK(void) acpiR3Resume(PPDMDEVINS pDevIns)
    28062796{
    28072797    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
     
    28172807 * @interface_method_impl{PDMDEVREG,pfnReset}
    28182808 */
    2819 static DECLCALLBACK(void) acpiReset(PPDMDEVINS pDevIns)
     2809static DECLCALLBACK(void) acpiR3Reset(PPDMDEVINS pDevIns)
    28202810{
    28212811    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
     
    28262816    pThis->pm1a_ctl          = 0;
    28272817    pThis->u64PmTimerInitial = TMTimerGet(pThis->pPmTimerR3);
    2828     acpiPmTimerReset(pThis, pThis->u64PmTimerInitial);
     2818    acpiR3PmTimerReset(pThis, pThis->u64PmTimerInitial);
    28292819    pThis->uBatteryIndex     = 0;
    28302820    pThis->uSystemInfoIndex  = 0;
     
    28352825
    28362826    /** @todo Should we really reset PM base? */
    2837     acpiUpdatePmHandlers(pThis, PM_PORT_BASE);
    2838 
    2839     acpiPlantTables(pThis);
     2827    acpiR3UpdatePmHandlers(pThis, PM_PORT_BASE);
     2828
     2829    acpiR3PlantTables(pThis);
    28402830}
    28412831
     
    28432833 * @interface_method_impl{PDMDEVREG,pfnRelocate}
    28442834 */
    2845 static DECLCALLBACK(void) acpiRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
     2835static DECLCALLBACK(void) acpiR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    28462836{
    28472837    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
     
    28532843 * @interface_methid_impl{PDMDEVREG,pfnDestruct}
    28542844 */
    2855 static DECLCALLBACK(int) acpiDestruct(PPDMDEVINS pDevIns)
     2845static DECLCALLBACK(int) acpiR3Destruct(PPDMDEVINS pDevIns)
    28562846{
    28572847    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
     
    28672857 * @interface_method_impl{PDMDEVREG,pfnConstruct}
    28682858 */
    2869 static DECLCALLBACK(int) acpiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
     2859static DECLCALLBACK(int) acpiR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
    28702860{
    28712861    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
     
    28892879
    28902880    /* IBase */
    2891     pThis->IBase.pfnQueryInterface              = acpiQueryInterface;
     2881    pThis->IBase.pfnQueryInterface              = acpiR3QueryInterface;
    28922882    /* IACPIPort */
    2893     pThis->IACPIPort.pfnSleepButtonPress        = acpiPort_SleepButtonPress;
    2894     pThis->IACPIPort.pfnPowerButtonPress        = acpiPort_PowerButtonPress;
    2895     pThis->IACPIPort.pfnGetPowerButtonHandled   = acpiPort_GetPowerButtonHandled;
    2896     pThis->IACPIPort.pfnGetGuestEnteredACPIMode = acpiPort_GetGuestEnteredACPIMode;
    2897     pThis->IACPIPort.pfnGetCpuStatus            = acpiPort_GetCpuStatus;
     2883    pThis->IACPIPort.pfnSleepButtonPress        = acpiR3Port_SleepButtonPress;
     2884    pThis->IACPIPort.pfnPowerButtonPress        = acpiR3Port_PowerButtonPress;
     2885    pThis->IACPIPort.pfnGetPowerButtonHandled   = acpiR3Port_GetPowerButtonHandled;
     2886    pThis->IACPIPort.pfnGetGuestEnteredACPIMode = acpiR3Port_GetGuestEnteredACPIMode;
     2887    pThis->IACPIPort.pfnGetCpuStatus            = acpiR3Port_GetCpuStatus;
    28982888
    28992889    /*
     
    32273217     * Plant ACPI tables.
    32283218     */
    3229     RTGCPHYS32 GCPhysRsdp = find_rsdp_space();
     3219    RTGCPHYS32 GCPhysRsdp = apicR3FindRsdpSpace();
    32303220    if (!GCPhysRsdp)
    32313221        return PDMDEV_SET_ERROR(pDevIns, VERR_NO_MEMORY,
    32323222                                N_("Can not find space for RSDP. ACPI is disabled"));
    32333223
    3234     rc = acpiPlantTables(pThis);
     3224    rc = acpiR3PlantTables(pThis);
    32353225    if (RT_FAILURE(rc))
    32363226        return rc;
     
    32443234     * Register I/O ports.
    32453235     */
    3246     rc = acpiRegisterPmHandlers(pThis);
     3236    rc = acpiR3RegisterPmHandlers(pThis);
    32473237    if (RT_FAILURE(rc))
    32483238        return rc;
     
    32553245            return rc; \
    32563246    } while (0)
    3257     R(SMI_CMD,        1, acpiSmiWrite,          NULL,                "ACPI SMI");
     3247    R(SMI_CMD,        1, acpiR3SmiWrite,          NULL,                "ACPI SMI");
    32583248#ifdef DEBUG_ACPI
    3259     R(DEBUG_HEX,      1, acpiDhexWrite,         NULL,                "ACPI Debug hex");
    3260     R(DEBUG_CHR,      1, acpiDchrWrite,         NULL,                "ACPI Debug char");
     3249    R(DEBUG_HEX,      1, acpiR3DhexWrite,         NULL,                "ACPI Debug hex");
     3250    R(DEBUG_CHR,      1, acpiR3DchrWrite,         NULL,                "ACPI Debug char");
    32613251#endif
    3262     R(BAT_INDEX,      1, acpiBatIndexWrite,     NULL,                "ACPI Battery status index");
    3263     R(BAT_DATA,       1, NULL,                  acpiBatDataRead,     "ACPI Battery status data");
    3264     R(SYSI_INDEX,     1, acpiSysInfoIndexWrite, NULL,                "ACPI system info index");
    3265     R(SYSI_DATA,      1, acpiSysInfoDataWrite,  acpiSysInfoDataRead, "ACPI system info data");
    3266     R(ACPI_RESET_BLK, 1, acpiResetWrite,        NULL,                "ACPI Reset");
     3252    R(BAT_INDEX,      1, acpiR3BatIndexWrite,     NULL,                "ACPI Battery status index");
     3253    R(BAT_DATA,       1, NULL,                  acpiR3BatDataRead,     "ACPI Battery status data");
     3254    R(SYSI_INDEX,     1, acpiR3SysInfoIndexWrite, NULL,                "ACPI system info index");
     3255    R(SYSI_DATA,      1, acpiR3SysInfoDataWrite,  acpiR3SysInfoDataRead, "ACPI system info data");
     3256    R(ACPI_RESET_BLK, 1, acpiR3ResetWrite,        NULL,                "ACPI Reset");
    32673257#undef R
    32683258
     
    32713261     */
    32723262    PTMTIMER pTimer;
    3273     rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, acpiPmTimer, &pThis->dev,
     3263    rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, acpiR3PmTimer, &pThis->dev,
    32743264                                TMTIMER_FLAGS_NO_CRIT_SECT, "ACPI PM Timer", &pTimer);
    32753265    AssertRCReturn(rc, rc);
     
    32813271    AssertRCReturn(rc, rc);
    32823272    pThis->u64PmTimerInitial = TMTimerGet(pTimer);
    3283     acpiPmTimerReset(pThis, pThis->u64PmTimerInitial);
     3273    acpiR3PmTimerReset(pThis, pThis->u64PmTimerInitial);
    32843274    TMTimerUnlock(pTimer);
    32853275
     
    33203310
    33213311    PDMDevHlpPCISetConfigCallbacks(pDevIns, &pThis->dev,
    3322                                    acpiPciConfigRead,  &pThis->pfnAcpiPciConfigRead,
    3323                                    acpiPciConfigWrite, &pThis->pfnAcpiPciConfigWrite);
     3312                                   acpiR3PciConfigRead,  &pThis->pfnAcpiPciConfigRead,
     3313                                   acpiR3PciConfigWrite, &pThis->pfnAcpiPciConfigWrite);
    33243314
    33253315    /*
    33263316     * Register the saved state.
    33273317     */
    3328     rc = PDMDevHlpSSMRegister(pDevIns, 6, sizeof(*pThis), acpiSaveState, acpiLoadState);
     3318    rc = PDMDevHlpSSMRegister(pDevIns, 6, sizeof(*pThis), acpiR3SaveState, acpiR3LoadState);
    33293319    if (RT_FAILURE(rc))
    33303320        return rc;
     
    33773367    sizeof(ACPIState),
    33783368    /* pfnConstruct */
    3379     acpiConstruct,
     3369    acpiR3Construct,
    33803370    /* pfnDestruct */
    3381     acpiDestruct,
     3371    acpiR3Destruct,
    33823372    /* pfnRelocate */
    3383     acpiRelocate,
     3373    acpiR3Relocate,
    33843374    /* pfnIOCtl */
    33853375    NULL,
     
    33873377    NULL,
    33883378    /* pfnReset */
    3389     acpiReset,
     3379    acpiR3Reset,
    33903380    /* pfnSuspend */
    33913381    NULL,
    33923382    /* pfnResume */
    3393     acpiResume,
     3383    acpiR3Resume,
    33943384    /* pfnAttach */
    3395     acpiAttach,
     3385    acpiR3Attach,
    33963386    /* pfnDetach */
    3397     acpiDetach,
     3387    acpiR3Detach,
    33983388    /* pfnQueryInterface. */
    33993389    NULL,
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette