VirtualBox

Changeset 82020 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Nov 20, 2019 11:36:21 AM (5 years ago)
Author:
vboxsync
Message:

DevACPI: Split the state structure. bugref:9218

File:
1 edited

Legend:

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

    r82019 r82020  
    281281*********************************************************************************************************************************/
    282282/**
    283  * The ACPI device state.
     283 * The shared ACPI device state.
    284284 */
    285285typedef struct ACPISTATE
     
    308308
    309309    uint32_t            uSystemInfoIndex;
     310    uint32_t            u32Alignment0;
    310311    uint64_t            u64RamSize;
    311312    /** Offset of the 64-bit prefetchable memory window. */
     
    345346    /** I/O port address of SMBus device. */
    346347    RTIOPORT            uSMBusIoPortBase;
     348    /** Which CPU to check for the locked status. */
     349    uint32_t            idCpuLockCheck;
    347350    /** Array of flags of attached CPUs */
    348351    VMCPUSET            CpuSetAttached;
    349     /** Which CPU to check for the locked status. */
    350     uint32_t            idCpuLockCheck;
    351352    /** Mask of locked CPUs (used by the guest). */
    352353    VMCPUSET            CpuSetLocked;
     
    361362    /** if the 64-bit prefetchable memory window is shown to the guest */
    362363    bool                fPciPref64Enabled;
     364    bool                afAlignment1;
    363365    /** Primary NIC PCI address. */
    364366    uint32_t            u32NicPciAddress;
     
    401403    /** @name Parallel port config bits
    402404     * @{ */
     405    /** Parallel 0 IO port base */
     406    RTIOPORT            uParallel0IoPortBase;
     407    /** Parallel 1 IO port base */
     408    RTIOPORT            uParallel1IoPortBase;
    403409    /** Parallel 0 IRQ number */
    404410    uint8_t             uParallel0Irq;
    405411    /** Parallel 1 IRQ number */
    406412    uint8_t             uParallel1Irq;
    407     /** Parallel 0 IO port base */
    408     RTIOPORT            uParallel0IoPortBase;
    409     /** Parallel 1 IO port base */
    410     RTIOPORT            uParallel1IoPortBase;
    411413    /** @} */
    412 
    413     uint32_t            Alignment2;
    414 
    415     /** ACPI port base interface. */
    416     PDMIBASE            IBase;
    417     /** ACPI port interface. */
    418     PDMIACPIPORT        IACPIPort;
    419     /** Pointer to the device instance so we can get our bearings from
    420      *  interface functions. */
    421     PPDMDEVINSR3        pDevIns;
    422 
    423     /** Pointer to the driver base interface. */
    424     R3PTRTYPE(PPDMIBASE) pDrvBase;
    425     /** Pointer to the driver connector interface. */
    426     R3PTRTYPE(PPDMIACPICONNECTOR) pDrv;
    427414
    428415    /** Number of custom ACPI tables */
     
    432419    /** ACPI Crator ID */
    433420    uint8_t             au8CreatorId[4];
     421    uint8_t             abAlignment2[3];
    434422    /** ACPI Crator Rev */
    435423    uint32_t            u32CreatorRev;
     
    438426    /** ACPI custom OEM Rev */
    439427    uint32_t            u32OemRevision;
    440     uint32_t            Alignment4;
    441 
    442     /** Custom ACPI tables binary data. */
    443     R3PTRTYPE(uint8_t *) apu8CustBin[MAX_CUST_TABLES];
    444     /** The size of the custom table binary. */
    445     uint64_t            acbCustBin[MAX_CUST_TABLES];
    446428
    447429    /** SMBus Host Status Register */
     
    461443    /** SMBus Slave Control Register */
    462444    uint8_t             u8SMBusSlvCnt;
    463     /** SMBus Shadow Command Register */
    464     uint8_t             u8SMBusShdwCmd;
    465445    /** SMBus Slave Event Register */
    466446    uint16_t            u16SMBusSlvEvt;
    467447    /** SMBus Slave Data Register */
    468448    uint16_t            u16SMBusSlvDat;
     449    /** SMBus Shadow Command Register */
     450    uint8_t             u8SMBusShdwCmd;
     451    /** SMBus Host Block Index */
     452    uint8_t             u8SMBusBlkIdx;
     453    uint8_t             abAlignment3[2];
    469454    /** SMBus Host Block Data Buffer */
    470455    uint8_t             au8SMBusBlkDat[32];
    471     /** SMBus Host Block Index */
    472     uint8_t             u8SMBusBlkIdx;
    473456
    474457    /** @todo DEBUGGING */
     
    514497/** Pointer to the shared ACPI device state. */
    515498typedef ACPISTATE *PACPISTATE;
     499
     500
     501/**
     502 * The ring-3 ACPI device state.
     503 */
     504typedef struct ACPISTATER3
     505{
     506    /** ACPI port base interface. */
     507    PDMIBASE            IBase;
     508    /** ACPI port interface. */
     509    PDMIACPIPORT        IACPIPort;
     510    /** Pointer to the device instance so we can get our bearings from
     511     *  interface functions. */
     512    PPDMDEVINSR3        pDevIns;
     513
     514    /** Pointer to the driver base interface. */
     515    R3PTRTYPE(PPDMIBASE) pDrvBase;
     516    /** Pointer to the driver connector interface. */
     517    R3PTRTYPE(PPDMIACPICONNECTOR) pDrv;
     518
     519    /** Custom ACPI tables binary data. */
     520    R3PTRTYPE(uint8_t *) apu8CustBin[MAX_CUST_TABLES];
     521    /** The size of the custom table binary. */
     522    uint64_t            acbCustBin[MAX_CUST_TABLES];
     523} ACPISTATER3;
     524/** Pointer to the ring-3 ACPI device state. */
     525typedef ACPISTATER3 *PACPISTATER3;
     526
    516527
    517528#pragma pack(1)
     
    801812*********************************************************************************************************************************/
    802813#ifdef IN_RING3
    803 static int acpiR3PlantTables(PPDMDEVINS pDevIns, PACPISTATE pThis);
     814static int acpiR3PlantTables(PPDMDEVINS pDevIns, PACPISTATE pThis, PACPISTATER3 pThisCC);
    804815#endif
    805816
     
    944955static DECLCALLBACK(int) acpiR3Port_PowerButtonPress(PPDMIACPIPORT pInterface)
    945956{
    946     PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
    947     PPDMDEVINS pDevIns = pThis->pDevIns;
     957    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
     958    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
     959    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
    948960    DEVACPI_LOCK_R3(pDevIns, pThis);
    949961
     
    961973static DECLCALLBACK(int) acpiR3Port_GetPowerButtonHandled(PPDMIACPIPORT pInterface, bool *pfHandled)
    962974{
    963     PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
    964     PPDMDEVINS pDevIns = pThis->pDevIns;
     975    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
     976    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
     977    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
    965978    DEVACPI_LOCK_R3(pDevIns, pThis);
    966979
     
    977990static DECLCALLBACK(int) acpiR3Port_GetGuestEnteredACPIMode(PPDMIACPIPORT pInterface, bool *pfEntered)
    978991{
    979     PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
    980     PPDMDEVINS pDevIns = pThis->pDevIns;
     992    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
     993    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
     994    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
    981995    DEVACPI_LOCK_R3(pDevIns, pThis);
    982996
     
    9921006static DECLCALLBACK(int) acpiR3Port_GetCpuStatus(PPDMIACPIPORT pInterface, unsigned uCpu, bool *pfLocked)
    9931007{
    994     PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
    995     PPDMDEVINS pDevIns = pThis->pDevIns;
     1008    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
     1009    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
     1010    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
    9961011    DEVACPI_LOCK_R3(pDevIns, pThis);
    9971012
     
    10101025static DECLCALLBACK(int) acpiR3Port_SleepButtonPress(PPDMIACPIPORT pInterface)
    10111026{
    1012     PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
    1013     PPDMDEVINS pDevIns = pThis->pDevIns;
     1027    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
     1028    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
     1029    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
    10141030    DEVACPI_LOCK_R3(pDevIns, pThis);
    10151031
     
    10291045static DECLCALLBACK(int) acpiR3Port_MonitorHotPlugEvent(PPDMIACPIPORT pInterface)
    10301046{
    1031     PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
    1032     PPDMDEVINS pDevIns = pThis->pDevIns;
     1047    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
     1048    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
     1049    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
    10331050    DEVACPI_LOCK_R3(pDevIns, pThis);
    10341051
     
    10481065static DECLCALLBACK(int) acpiR3Port_BatteryStatusChangeEvent(PPDMIACPIPORT pInterface)
    10491066{
    1050     PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IACPIPort);
    1051     PPDMDEVINS pDevIns = pThis->pDevIns;
     1067    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IACPIPort);
     1068    PPDMDEVINS   pDevIns = pThisCC->pDevIns;
     1069    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
    10521070    DEVACPI_LOCK_R3(pDevIns, pThis);
    10531071
     
    11311149 * @returns VINF_SUCCESS.
    11321150 * @param   pThis           The ACPI shared instance data.
    1133  */
    1134 static int acpiR3FetchBatteryStatus(PACPISTATE pThis)
     1151 * @param   pThisCC         The ACPI instance data for ring-3.
     1152 */
     1153static int acpiR3FetchBatteryStatus(PACPISTATE pThis, PACPISTATER3 pThisCC)
    11351154{
    11361155    uint32_t           *p = pThis->au8BatteryInfo;
     
    11411160    int                rc;
    11421161
    1143     if (!pThis->pDrv)
     1162    if (!pThisCC->pDrv)
    11441163        return VINF_SUCCESS;
    1145     rc = pThis->pDrv->pfnQueryBatteryStatus(pThis->pDrv, &fPresent, &hostRemainingCapacity,
    1146                                             &hostBatteryState, &hostPresentRate);
     1164    rc = pThisCC->pDrv->pfnQueryBatteryStatus(pThisCC->pDrv, &fPresent, &hostRemainingCapacity,
     1165                                              &hostBatteryState, &hostPresentRate);
    11471166    AssertRC(rc);
    11481167
     
    11911210 *
    11921211 * @returns status mask or 0.
    1193  * @param   pThis           The ACPI shared instance data.
    1194  */
    1195 static uint32_t acpiR3GetBatteryDeviceStatus(PACPISTATE pThis)
     1212 * @param   pThisCC         The ACPI instance data for ring-3.
     1213 */
     1214static uint32_t acpiR3GetBatteryDeviceStatus(PACPISTATER3 pThisCC)
    11961215{
    11971216    bool               fPresent;              /* battery present? */
     
    12011220    int                rc;
    12021221
    1203     if (!pThis->pDrv)
     1222    if (!pThisCC->pDrv)
    12041223        return 0;
    1205     rc = pThis->pDrv->pfnQueryBatteryStatus(pThis->pDrv, &fPresent, &hostRemainingCapacity,
    1206                                             &hostBatteryState, &hostPresentRate);
     1224    rc = pThisCC->pDrv->pfnQueryBatteryStatus(pThisCC->pDrv, &fPresent, &hostRemainingCapacity,
     1225                                              &hostBatteryState, &hostPresentRate);
    12071226    AssertRC(rc);
    12081227
    12091228    return fPresent
    1210         ?   STA_DEVICE_PRESENT_MASK                     /* present */
    1211           | STA_DEVICE_ENABLED_MASK                     /* enabled and decodes its resources */
    1212           | STA_DEVICE_SHOW_IN_UI_MASK                  /* should be shown in UI */
    1213           | STA_DEVICE_FUNCTIONING_PROPERLY_MASK        /* functioning properly */
    1214           | STA_BATTERY_PRESENT_MASK                    /* battery is present */
    1215         : 0;                                            /* device not present */
     1229         ?   STA_DEVICE_PRESENT_MASK                     /* present */
     1230           | STA_DEVICE_ENABLED_MASK                     /* enabled and decodes its resources */
     1231           | STA_DEVICE_SHOW_IN_UI_MASK                  /* should be shown in UI */
     1232           | STA_DEVICE_FUNCTIONING_PROPERLY_MASK        /* functioning properly */
     1233           | STA_BATTERY_PRESENT_MASK                    /* battery is present */
     1234         : 0;                                            /* device not present */
    12161235}
    12171236
     
    12201239 *
    12211240 * @returns status.
    1222  * @param   pThis           The ACPI shared instance data.
    1223  */
    1224 static uint32_t acpiR3GetPowerSource(PACPISTATE pThis)
     1241 * @param   pThisCC         The ACPI instance data for ring-3.
     1242 */
     1243static uint32_t acpiR3GetPowerSource(PACPISTATER3 pThisCC)
    12251244{
    12261245    /* query the current power source from the host driver */
    1227     if (!pThis->pDrv)
     1246    if (!pThisCC->pDrv)
    12281247        return AC_ONLINE;
    12291248
    12301249    PDMACPIPOWERSOURCE ps;
    1231     int rc = pThis->pDrv->pfnQueryPowerSource(pThis->pDrv, &ps);
     1250    int rc = pThisCC->pDrv->pfnQueryPowerSource(pThisCC->pDrv, &ps);
    12321251    AssertRC(rc);
    12331252    return ps == PDM_ACPI_POWER_SOURCE_BATTERY ? AC_OFFLINE : AC_ONLINE;
     
    12701289        return VERR_IOM_IOPORT_UNUSED;
    12711290
    1272     PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     1291    PACPISTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     1292    PACPISTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
    12731293    DEVACPI_LOCK_R3(pDevIns, pThis);
    12741294
     
    12771297    {
    12781298        case BAT_STATUS_STATE:
    1279             acpiR3FetchBatteryStatus(pThis);
     1299            acpiR3FetchBatteryStatus(pThis, pThisCC);
    12801300            RT_FALL_THRU();
    12811301        case BAT_STATUS_PRESENT_RATE:
     
    13001320
    13011321        case BAT_DEVICE_STATUS:
    1302             *pu32 = acpiR3GetBatteryDeviceStatus(pThis);
     1322            *pu32 = acpiR3GetBatteryDeviceStatus(pThisCC);
    13031323            break;
    13041324
    13051325        case BAT_POWER_SOURCE:
    1306             *pu32 = acpiR3GetPowerSource(pThis);
     1326            *pu32 = acpiR3GetPowerSource(pThisCC);
    13071327            break;
    13081328
     
    21072127 * @param   pDevIns         The device instance.
    21082128 * @param   pThis           The ACPI shared instance data.
     2129 * @param   pThisCC         The ACPI instance data for ring-3.
    21092130 * @param   NewIoPortBase   The new base address of the I/O ports.
    21102131 */
    2111 static int acpiR3UpdatePmHandlers(PPDMDEVINS pDevIns, PACPISTATE pThis, RTIOPORT NewIoPortBase)
     2132static int acpiR3UpdatePmHandlers(PPDMDEVINS pDevIns, PACPISTATE pThis, PACPISTATER3 pThisCC, RTIOPORT NewIoPortBase)
    21122133{
    21132134    Log(("acpi: rebasing PM 0x%x -> 0x%x\n", pThis->uPmIoPortBase, NewIoPortBase));
     
    21252146
    21262147        /* We have to update FADT table acccording to the new base */
    2127         rc = acpiR3PlantTables(pDevIns, pThis);
     2148        rc = acpiR3PlantTables(pDevIns, pThis, pThisCC);
    21282149        AssertRC(rc);
    21292150        if (RT_FAILURE(rc))
     
    25322553static DECLCALLBACK(int) acpiR3LoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    25332554{
    2534     PACPISTATE      pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
    2535     PCPDMDEVHLPR3   pHlp  = pDevIns->pHlpR3;
     2555    PACPISTATE      pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     2556    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
     2557    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
    25362558    Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
    25372559
     
    25802602        rc = acpiR3MapSMBusIoPorts(pDevIns, pThis);
    25812603        AssertRCReturn(rc, rc);
    2582         rc = acpiR3FetchBatteryStatus(pThis);
     2604        rc = acpiR3FetchBatteryStatus(pThis, pThisCC);
    25832605        AssertRCReturn(rc, rc);
    25842606        rc = acpiR3FetchBatteryInfo(pThis);
     
    26022624static DECLCALLBACK(void *) acpiR3QueryInterface(PPDMIBASE pInterface, const char *pszIID)
    26032625{
    2604     PACPISTATE pThis = RT_FROM_MEMBER(pInterface, ACPISTATE, IBase);
    2605     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
    2606     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIACPIPORT, &pThis->IACPIPort);
     2626    PACPISTATER3 pThisCC = RT_FROM_MEMBER(pInterface, ACPISTATER3, IBase);
     2627    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->IBase);
     2628    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIACPIPORT, &pThisCC->IACPIPort);
    26072629    return NULL;
    26082630}
     
    28162838{
    28172839    ACPITBLXSDT *xsdt;
    2818     const size_t size = sizeof(ACPITBLHEADER) + nb_entries * sizeof(xsdt->u64Entry[0]);
    2819 
    2820     xsdt = (ACPITBLXSDT*)RTMemAllocZ(size);
     2840    const size_t cbXsdt = sizeof(ACPITBLHEADER) + nb_entries * sizeof(xsdt->u64Entry[0]);
     2841    xsdt = (ACPITBLXSDT *)RTMemAllocZ(cbXsdt);
    28212842    if (!xsdt)
    28222843        return VERR_NO_TMP_MEMORY;
    28232844
    2824     acpiR3PrepareHeader(pThis, &xsdt->header, "XSDT", (uint32_t)size, 1 /* according to ACPI 3.0 specs */);
     2845    acpiR3PrepareHeader(pThis, &xsdt->header, "XSDT", (uint32_t)cbXsdt, 1 /* according to ACPI 3.0 specs */);
    28252846
    28262847    if (pThis->cCustTbls > 0)
     
    28322853        Log(("Setup XSDT: [%d] = %RX64\n", i, xsdt->u64Entry[i]));
    28332854    }
    2834     xsdt->header.u8Checksum = acpiR3Checksum(xsdt, size);
    2835     acpiR3PhysCopy(pDevIns, addr, xsdt, size);
     2855    xsdt->header.u8Checksum = acpiR3Checksum(xsdt, cbXsdt);
     2856    acpiR3PhysCopy(pDevIns, addr, xsdt, cbXsdt);
     2857
    28362858    RTMemFree(xsdt);
    28372859    return VINF_SUCCESS;
     
    31723194 * Create the ACPI tables in guest memory.
    31733195 */
    3174 static int acpiR3PlantTables(PPDMDEVINS pDevIns, PACPISTATE pThis)
     3196static int acpiR3PlantTables(PPDMDEVINS pDevIns, PACPISTATE pThis, PACPISTATER3 pThisCC)
    31753197{
    31763198    int        rc;
     
    32843306    {
    32853307        aGCPhysCust[i] = GCPhysCur;
    3286         GCPhysCur = RT_ALIGN_32(GCPhysCur + pThis->acbCustBin[i], 16);
     3308        GCPhysCur = RT_ALIGN_32(GCPhysCur + pThisCC->acbCustBin[i], 16);
    32873309    }
    32883310
     
    33553377    {
    33563378        Assert(i < MAX_CUST_TABLES);
    3357         acpiR3PhysCopy(pDevIns, aGCPhysCust[i] + addend, pThis->apu8CustBin[i], pThis->acbCustBin[i]);
     3379        acpiR3PhysCopy(pDevIns, aGCPhysCust[i] + addend, pThisCC->apu8CustBin[i], pThisCC->acbCustBin[i]);
    33583380        aGCPhysRsdt[iCust + i] = aGCPhysCust[i] + addend;
    33593381        aGCPhysXsdt[iCust + i] = aGCPhysCust[i] + addend;
    3360         uint8_t* pSig = pThis->apu8CustBin[i];
     3382        uint8_t* pSig = pThisCC->apu8CustBin[i];
    33613383        LogRel(("ACPI: Planted custom table '%c%c%c%c' at 0x%08X\n",
    33623384               pSig[0], pSig[1], pSig[2], pSig[3], aGCPhysCust[i] + addend));
     
    33913413                                                       uint32_t uAddress, unsigned cb, uint32_t u32Value)
    33923414{
    3393     PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     3415    PACPISTATE      pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     3416    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
    33943417
    33953418    Log2(("acpi: PCI config write: 0x%x -> 0x%x (%d)\n", u32Value, uAddress, cb));
     
    34183441        }
    34193442
    3420         int rc = acpiR3UpdatePmHandlers(pDevIns, pThis, NewIoPortBase);
     3443        int rc = acpiR3UpdatePmHandlers(pDevIns, pThis, pThisCC, NewIoPortBase);
    34213444        AssertRC(rc);
    34223445    }
     
    34523475static DECLCALLBACK(int) acpiR3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    34533476{
    3454     PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     3477    PACPISTATE      pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     3478    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
    34553479    LogFlow(("acpiAttach: pDevIns=%p iLUN=%u fFlags=%#x\n", pDevIns, iLUN, fFlags));
    34563480
     
    34663490    {
    34673491        PPDMIBASE IBaseTmp;
    3468         rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThis->IBase, &IBaseTmp, "ACPI CPU");
     3492        rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThisCC->IBase, &IBaseTmp, "ACPI CPU");
    34693493        if (RT_SUCCESS(rc))
    34703494        {
     
    35433567static DECLCALLBACK(void) acpiR3MemSetup(PPDMDEVINS pDevIns, PDMDEVMEMSETUPCTX enmCtx)
    35443568{
    3545     RT_NOREF1(enmCtx);
    3546     PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
    3547     acpiR3PlantTables(pDevIns, pThis);
     3569    RT_NOREF(enmCtx);
     3570    PACPISTATE      pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     3571    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
     3572    acpiR3PlantTables(pDevIns, pThis, pThisCC);
    35483573}
    35493574
     
    35533578static DECLCALLBACK(void) acpiR3Reset(PPDMDEVINS pDevIns)
    35543579{
    3555     PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     3580    PACPISTATE      pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     3581    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
    35563582
    35573583    /* Play safe: make sure that the IRQ isn't stuck after a reset. */
     
    35753601    /* Real device behavior is resetting only the PM controller state,
    35763602     * but we're additionally doing the job of the BIOS. */
    3577     acpiR3UpdatePmHandlers(pDevIns, pThis, PM_PORT_BASE);
     3603    acpiR3UpdatePmHandlers(pDevIns, pThis, pThisCC, PM_PORT_BASE);
    35783604    acpiR3PmPCIBIOSFake(pDevIns, pThis);
    35793605
     
    35923618{
    35933619    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    3594     PACPISTATE pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     3620    PACPISTATE      pThis = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     3621    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
     3622
    35953623    for (uint8_t i = 0; i < pThis->cCustTbls; i++)
    35963624    {
    3597         if (pThis->apu8CustBin[i])
     3625        if (pThisCC->apu8CustBin[i])
    35983626        {
    3599             PDMDevHlpMMHeapFree(pDevIns, pThis->apu8CustBin[i]);
    3600             pThis->apu8CustBin[i] = NULL;
     3627            PDMDevHlpMMHeapFree(pDevIns, pThisCC->apu8CustBin[i]);
     3628            pThisCC->apu8CustBin[i] = NULL;
    36013629        }
    36023630    }
     
    36113639    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    36123640    PACPISTATE      pThis   = PDMDEVINS_2_DATA(pDevIns, PACPISTATE);
     3641    PACPISTATER3    pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PACPISTATER3);
    36133642    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
    36143643
     
    36183647    /** @todo move more of the code up! */
    36193648
    3620     pThis->pDevIns         = pDevIns;
     3649    pThisCC->pDevIns       = pDevIns;
    36213650    VMCPUSET_EMPTY(&pThis->CpuSetAttached);
    36223651    VMCPUSET_EMPTY(&pThis->CpuSetLocked);
     
    36303659
    36313660    /* IBase */
    3632     pThis->IBase.pfnQueryInterface               = acpiR3QueryInterface;
     3661    pThisCC->IBase.pfnQueryInterface               = acpiR3QueryInterface;
    36333662    /* IACPIPort */
    3634     pThis->IACPIPort.pfnSleepButtonPress         = acpiR3Port_SleepButtonPress;
    3635     pThis->IACPIPort.pfnPowerButtonPress         = acpiR3Port_PowerButtonPress;
    3636     pThis->IACPIPort.pfnGetPowerButtonHandled    = acpiR3Port_GetPowerButtonHandled;
    3637     pThis->IACPIPort.pfnGetGuestEnteredACPIMode  = acpiR3Port_GetGuestEnteredACPIMode;
    3638     pThis->IACPIPort.pfnGetCpuStatus             = acpiR3Port_GetCpuStatus;
    3639     pThis->IACPIPort.pfnMonitorHotPlugEvent      = acpiR3Port_MonitorHotPlugEvent;
    3640     pThis->IACPIPort.pfnBatteryStatusChangeEvent = acpiR3Port_BatteryStatusChangeEvent;
     3663    pThisCC->IACPIPort.pfnSleepButtonPress         = acpiR3Port_SleepButtonPress;
     3664    pThisCC->IACPIPort.pfnPowerButtonPress         = acpiR3Port_PowerButtonPress;
     3665    pThisCC->IACPIPort.pfnGetPowerButtonHandled    = acpiR3Port_GetPowerButtonHandled;
     3666    pThisCC->IACPIPort.pfnGetGuestEnteredACPIMode  = acpiR3Port_GetGuestEnteredACPIMode;
     3667    pThisCC->IACPIPort.pfnGetCpuStatus             = acpiR3Port_GetCpuStatus;
     3668    pThisCC->IACPIPort.pfnMonitorHotPlugEvent      = acpiR3Port_MonitorHotPlugEvent;
     3669    pThisCC->IACPIPort.pfnBatteryStatusChangeEvent = acpiR3Port_BatteryStatusChangeEvent;
    36413670
    36423671    /*
     
    38513880        {
    38523881            PPDMIBASE IBaseTmp;
    3853             rc = PDMDevHlpDriverAttach(pDevIns, i, &pThis->IBase, &IBaseTmp, "ACPI CPU");
     3882            rc = PDMDevHlpDriverAttach(pDevIns, i, &pThisCC->IBase, &IBaseTmp, "ACPI CPU");
    38543883
    38553884            if (RT_SUCCESS(rc))
     
    39083937
    39093938    static const char *s_apszCustTblConfigKeys[] = {"CustomTable0", "CustomTable1", "CustomTable2", "CustomTable3"};
    3910     AssertCompile(RT_ELEMENTS(s_apszCustTblConfigKeys) <= RT_ELEMENTS(pThis->apu8CustBin));
     3939    AssertCompile(RT_ELEMENTS(s_apszCustTblConfigKeys) <= RT_ELEMENTS(pThisCC->apu8CustBin));
    39113940    for (unsigned i = 0; i < RT_ELEMENTS(s_apszCustTblConfigKeys); ++i)
    39123941    {
     
    39303959        else if (!*pszCustBinFile)
    39313960        {
    3932             MMR3HeapFree(pszCustBinFile);
     3961            PDMDevHlpMMHeapFree(pDevIns, pszCustBinFile);
    39333962            pszCustBinFile = NULL;
    39343963        }
     
    39403969        {
    39413970            uint32_t idxCust = pThis->cCustTbls;
    3942             rc = acpiR3ReadCustomTable(pDevIns, &pThis->apu8CustBin[idxCust],
    3943                                        &pThis->acbCustBin[idxCust], pszCustBinFile, cbBufAvail);
     3971            rc = acpiR3ReadCustomTable(pDevIns, &pThisCC->apu8CustBin[idxCust],
     3972                                       &pThisCC->acbCustBin[idxCust], pszCustBinFile, cbBufAvail);
    39443973            LogRel(("ACPI: Reading custom ACPI table(%u) from file '%s' (%d bytes)\n",
    3945                     idxCust, pszCustBinFile, pThis->acbCustBin[idxCust]));
    3946             MMR3HeapFree(pszCustBinFile);
     3974                    idxCust, pszCustBinFile, pThisCC->acbCustBin[idxCust]));
     3975            PDMDevHlpMMHeapFree(pDevIns, pszCustBinFile);
    39473976            if (RT_FAILURE(rc))
    39483977                return PDMDEV_SET_ERROR(pDevIns, rc, N_("Error reading custom ACPI table."));
    3949             cbBufAvail -= pThis->acbCustBin[idxCust];
     3978            cbBufAvail -= pThisCC->acbCustBin[idxCust];
    39503979
    39513980            /* Update custom OEM attributes based on custom table */
    39523981            /** @todo is it intended for custom tables to overwrite user provided values above? */
    3953             ACPITBLHEADER *pTblHdr = (ACPITBLHEADER*)pThis->apu8CustBin[idxCust];
     3982            ACPITBLHEADER *pTblHdr = (ACPITBLHEADER*)pThisCC->apu8CustBin[idxCust];
    39543983            memcpy(&pThis->au8OemId[0], &pTblHdr->au8OemId[0], 6);
    39553984            memcpy(&pThis->au8OemTabId[0], &pTblHdr->au8OemTabId[0], 8);
     
    39864015        return PDMDEV_SET_ERROR(pDevIns, VERR_NO_MEMORY, N_("Can not find space for RSDP. ACPI is disabled"));
    39874016
    3988     rc = acpiR3PlantTables(pDevIns, pThis);
     4017    rc = acpiR3PlantTables(pDevIns, pThis, pThisCC);
    39894018    AssertRCReturn(rc, rc);
    39904019
     
    41174146    * Get the corresponding connector interface
    41184147    */
    4119    rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "ACPI Driver Port");
     4148   rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThisCC->IBase, &pThisCC->pDrvBase, "ACPI Driver Port");
    41204149   if (RT_SUCCESS(rc))
    41214150   {
    4122        pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIACPICONNECTOR);
    4123        if (!pThis->pDrv)
    4124            return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_MISSING_INTERFACE,
    4125                                    N_("LUN #0 doesn't have an ACPI connector interface"));
     4151       pThisCC->pDrv = PDMIBASE_QUERY_INTERFACE(pThisCC->pDrvBase, PDMIACPICONNECTOR);
     4152       if (!pThisCC->pDrv)
     4153           return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_MISSING_INTERFACE, N_("LUN #0 doesn't have an ACPI connector interface"));
    41264154   }
    41274155   else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    41284156   {
    4129        Log(("acpi: %s/%d: warning: no driver attached to LUN #0!\n",
    4130             pDevIns->pReg->szName, pDevIns->iInstance));
     4157       Log(("acpi: %s/%d: warning: no driver attached to LUN #0!\n", pDevIns->pReg->szName, pDevIns->iInstance));
    41314158       rc = VINF_SUCCESS;
    41324159   }
     
    41744201    /* .uSharedVersion = */         42,
    41754202    /* .cbInstanceShared = */       sizeof(ACPISTATE),
    4176     /* .cbInstanceCC = */           0,
     4203    /* .cbInstanceCC = */           CTX_EXPR(sizeof(ACPISTATER3), 0, 0),
    41774204    /* .cbInstanceRC = */           0,
    41784205    /* .cMaxPciDevices = */         1,
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