VirtualBox

Changeset 37446 in vbox


Ignore:
Timestamp:
Jun 14, 2011 2:46:33 PM (13 years ago)
Author:
vboxsync
Message:

DevACPI.cpp: More style cleanup.

File:
1 edited

Legend:

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

    r37444 r37446  
    678678     * Size of MADT for given ACPI config, useful to compute layout.
    679679     */
    680     static uint32_t sizeFor(ACPIState *s, uint32_t cIsos)
    681     {
    682         return AcpiTableMADT(s->cCpus, cIsos).size();
     680    static uint32_t sizeFor(ACPIState *pThis, uint32_t cIsos)
     681    {
     682        return AcpiTableMADT(pThis->cCpus, cIsos).size();
    683683    }
    684684
     
    713713RT_C_DECLS_END
    714714#ifdef IN_RING3
    715 static int acpiPlantTables(ACPIState *s);
     715static int acpiPlantTables(ACPIState *pThis);
    716716#endif
    717717
     
    719719
    720720/* SCI IRQ */
    721 DECLINLINE(void) acpiSetIrq(ACPIState *s, int level)
    722 {
    723     if (s->pm1a_ctl & SCI_EN)
    724         PDMDevHlpPCISetIrq(s->pDevIns, -1, level);
     721DECLINLINE(void) acpiSetIrq(ACPIState *pThis, int level)
     722{
     723    if (pThis->pm1a_ctl & SCI_EN)
     724        PDMDevHlpPCISetIrq(pThis->pDevIns, -1, level);
    725725}
    726726
     
    735735}
    736736
    737 DECLINLINE(int) pm1a_level(ACPIState *s)
    738 {
    739     return (pm1a_pure_en(s->pm1a_en) & pm1a_pure_sts(s->pm1a_sts)) != 0;
    740 }
    741 
    742 DECLINLINE(int) gpe0_level(ACPIState *s)
    743 {
    744     return (s->gpe0_en & s->gpe0_sts) != 0;
     737DECLINLINE(int) pm1a_level(ACPIState *pThis)
     738{
     739    return (pm1a_pure_en(pThis->pm1a_en) & pm1a_pure_sts(pThis->pm1a_sts)) != 0;
     740}
     741
     742DECLINLINE(int) gpe0_level(ACPIState *pThis)
     743{
     744    return (pThis->gpe0_en & pThis->gpe0_sts) != 0;
    745745}
    746746
     
    21002100 * Wrapper around PDMDevHlpPhysWrite used when planting ACPI tables.
    21012101 */
    2102 static void acpiPhyscpy(ACPIState *s, RTGCPHYS32 dst, const void * const src, size_t size)
    2103 {
    2104     PDMDevHlpPhysWrite(s->pDevIns, dst, src, size);
     2102static void acpiPhyscpy(ACPIState *pThis, RTGCPHYS32 dst, const void * const src, size_t size)
     2103{
     2104    PDMDevHlpPhysWrite(pThis->pDevIns, dst, src, size);
    21052105}
    21062106
     
    21082108 * Plant the Differentiated System Description Table (DSDT).
    21092109 */
    2110 static void acpiSetupDSDT(ACPIState *s, RTGCPHYS32 addr,
     2110static void acpiSetupDSDT(ACPIState *pThis, RTGCPHYS32 addr,
    21112111                            void* pPtr, size_t uDsdtLen)
    21122112{
    2113     acpiPhyscpy(s, addr, pPtr, uDsdtLen);
     2113    acpiPhyscpy(pThis, addr, pPtr, uDsdtLen);
    21142114}
    21152115
     
    21172117 * Plan the Secondary System Description Table (SSDT).
    21182118 */
    2119 static void acpiSetupSSDT(ACPIState *s, RTGCPHYS32 addr,
     2119static void acpiSetupSSDT(ACPIState *pThis, RTGCPHYS32 addr,
    21202120                            void* pPtr, size_t uSsdtLen)
    21212121{
    2122     acpiPhyscpy(s, addr, pPtr, uSsdtLen);
     2122    acpiPhyscpy(pThis, addr, pPtr, uSsdtLen);
    21232123}
    21242124
     
    21262126 * Plant the Firmware ACPI Control Structure (FACS).
    21272127 */
    2128 static void acpiSetupFACS(ACPIState *s, RTGCPHYS32 addr)
     2128static void acpiSetupFACS(ACPIState *pThis, RTGCPHYS32 addr)
    21292129{
    21302130    ACPITBLFACS facs;
     
    21402140    facs.u8Version            = 1;
    21412141
    2142     acpiPhyscpy(s, addr, (const uint8_t *)&facs, sizeof(facs));
     2142    acpiPhyscpy(pThis, addr, (const uint8_t *)&facs, sizeof(facs));
    21432143}
    21442144
     
    21462146 * Plant the Fixed ACPI Description Table (FADT aka FACP).
    21472147 */
    2148 static void acpiSetupFADT(ACPIState *s, RTGCPHYS32 GCPhysAcpi1, RTGCPHYS32 GCPhysAcpi2, RTGCPHYS32 GCPhysFacs, RTGCPHYS GCPhysDsdt)
     2148static void acpiSetupFADT(ACPIState *pThis, RTGCPHYS32 GCPhysAcpi1, RTGCPHYS32 GCPhysAcpi2, RTGCPHYS32 GCPhysFacs, RTGCPHYS GCPhysDsdt)
    21492149{
    21502150    ACPITBLFADT fadt;
     
    21632163    fadt.u8S4BIOSReq          = 0;
    21642164    fadt.u8PStateCnt          = 0;
    2165     fadt.u32PM1aEVTBLK        = RT_H2LE_U32(acpiCalcPmPort(s, PM1a_EVT_OFFSET));
    2166     fadt.u32PM1bEVTBLK        = RT_H2LE_U32(acpiCalcPmPort(s, PM1b_EVT_OFFSET));
    2167     fadt.u32PM1aCTLBLK        = RT_H2LE_U32(acpiCalcPmPort(s, PM1a_CTL_OFFSET));
    2168     fadt.u32PM1bCTLBLK        = RT_H2LE_U32(acpiCalcPmPort(s, PM1b_CTL_OFFSET));
    2169     fadt.u32PM2CTLBLK         = RT_H2LE_U32(acpiCalcPmPort(s, PM2_CTL_OFFSET));
    2170     fadt.u32PMTMRBLK          = RT_H2LE_U32(acpiCalcPmPort(s, PM_TMR_OFFSET));
    2171     fadt.u32GPE0BLK           = RT_H2LE_U32(acpiCalcPmPort(s, GPE0_OFFSET));
    2172     fadt.u32GPE1BLK           = RT_H2LE_U32(acpiCalcPmPort(s, GPE1_OFFSET));
     2165    fadt.u32PM1aEVTBLK        = RT_H2LE_U32(acpiCalcPmPort(pThis, PM1a_EVT_OFFSET));
     2166    fadt.u32PM1bEVTBLK        = RT_H2LE_U32(acpiCalcPmPort(pThis, PM1b_EVT_OFFSET));
     2167    fadt.u32PM1aCTLBLK        = RT_H2LE_U32(acpiCalcPmPort(pThis, PM1a_CTL_OFFSET));
     2168    fadt.u32PM1bCTLBLK        = RT_H2LE_U32(acpiCalcPmPort(pThis, PM1b_CTL_OFFSET));
     2169    fadt.u32PM2CTLBLK         = RT_H2LE_U32(acpiCalcPmPort(pThis, PM2_CTL_OFFSET));
     2170    fadt.u32PMTMRBLK          = RT_H2LE_U32(acpiCalcPmPort(pThis, PM_TMR_OFFSET));
     2171    fadt.u32GPE0BLK           = RT_H2LE_U32(acpiCalcPmPort(pThis, GPE0_OFFSET));
     2172    fadt.u32GPE1BLK           = RT_H2LE_U32(acpiCalcPmPort(pThis, GPE1_OFFSET));
    21732173    fadt.u8PM1EVTLEN          = 4;
    21742174    fadt.u8PM1CTLLEN          = 2;
     
    21962196
    21972197    /* We have to force physical APIC mode or Linux can't use more than 8 CPUs */
    2198     if (s->fCpuHotPlug)
     2198    if (pThis->fCpuHotPlug)
    21992199        fadt.u32Flags |= RT_H2LE_U32(FADT_FL_FORCE_APIC_PHYS_DEST_MODE);
    22002200
     
    22032203    fadt.u64XFACS             = RT_H2LE_U64((uint64_t)GCPhysFacs);
    22042204    fadt.u64XDSDT             = RT_H2LE_U64((uint64_t)GCPhysDsdt);
    2205     acpiWriteGenericAddr(&fadt.X_PM1aEVTBLK, 1, 32, 0, 2, acpiCalcPmPort(s, PM1a_EVT_OFFSET));
    2206     acpiWriteGenericAddr(&fadt.X_PM1bEVTBLK, 0,  0, 0, 0, acpiCalcPmPort(s, PM1b_EVT_OFFSET));
    2207     acpiWriteGenericAddr(&fadt.X_PM1aCTLBLK, 1, 16, 0, 2, acpiCalcPmPort(s, PM1a_CTL_OFFSET));
    2208     acpiWriteGenericAddr(&fadt.X_PM1bCTLBLK, 0,  0, 0, 0, acpiCalcPmPort(s, PM1b_CTL_OFFSET));
    2209     acpiWriteGenericAddr(&fadt.X_PM2CTLBLK,  0,  0, 0, 0, acpiCalcPmPort(s, PM2_CTL_OFFSET));
    2210     acpiWriteGenericAddr(&fadt.X_PMTMRBLK,   1, 32, 0, 3, acpiCalcPmPort(s, PM_TMR_OFFSET));
    2211     acpiWriteGenericAddr(&fadt.X_GPE0BLK,    1, 16, 0, 1, acpiCalcPmPort(s, GPE0_OFFSET));
    2212     acpiWriteGenericAddr(&fadt.X_GPE1BLK,    0,  0, 0, 0, acpiCalcPmPort(s, GPE1_OFFSET));
     2205    acpiWriteGenericAddr(&fadt.X_PM1aEVTBLK, 1, 32, 0, 2, acpiCalcPmPort(pThis, PM1a_EVT_OFFSET));
     2206    acpiWriteGenericAddr(&fadt.X_PM1bEVTBLK, 0,  0, 0, 0, acpiCalcPmPort(pThis, PM1b_EVT_OFFSET));
     2207    acpiWriteGenericAddr(&fadt.X_PM1aCTLBLK, 1, 16, 0, 2, acpiCalcPmPort(pThis, PM1a_CTL_OFFSET));
     2208    acpiWriteGenericAddr(&fadt.X_PM1bCTLBLK, 0,  0, 0, 0, acpiCalcPmPort(pThis, PM1b_CTL_OFFSET));
     2209    acpiWriteGenericAddr(&fadt.X_PM2CTLBLK,  0,  0, 0, 0, acpiCalcPmPort(pThis, PM2_CTL_OFFSET));
     2210    acpiWriteGenericAddr(&fadt.X_PMTMRBLK,   1, 32, 0, 3, acpiCalcPmPort(pThis, PM_TMR_OFFSET));
     2211    acpiWriteGenericAddr(&fadt.X_GPE0BLK,    1, 16, 0, 1, acpiCalcPmPort(pThis, GPE0_OFFSET));
     2212    acpiWriteGenericAddr(&fadt.X_GPE1BLK,    0,  0, 0, 0, acpiCalcPmPort(pThis, GPE1_OFFSET));
    22132213    fadt.header.u8Checksum    = acpiChecksum(&fadt, sizeof(fadt));
    2214     acpiPhyscpy(s, GCPhysAcpi2, &fadt, sizeof(fadt));
     2214    acpiPhyscpy(pThis, GCPhysAcpi2, &fadt, sizeof(fadt));
    22152215
    22162216    /* Now the ACPI 1.0 version. */
     
    22192219    fadt.header.u8Checksum    = 0;  /* Must be zeroed before recalculating checksum! */
    22202220    fadt.header.u8Checksum    = acpiChecksum(&fadt, ACPITBLFADT_VERSION1_SIZE);
    2221     acpiPhyscpy(s, GCPhysAcpi1, &fadt, ACPITBLFADT_VERSION1_SIZE);
     2221    acpiPhyscpy(pThis, GCPhysAcpi1, &fadt, ACPITBLFADT_VERSION1_SIZE);
    22222222}
    22232223
     
    22292229 * ACPI 2.0 and up.
    22302230 */
    2231 static int acpiSetupRSDT(ACPIState *s, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)
     2231static int acpiSetupRSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)
    22322232{
    22332233    ACPITBLRSDT *rsdt;
     
    22362236    rsdt = (ACPITBLRSDT*)RTMemAllocZ(size);
    22372237    if (!rsdt)
    2238         return PDMDEV_SET_ERROR(s->pDevIns, VERR_NO_TMP_MEMORY, N_("Cannot allocate RSDT"));
     2238        return PDMDEV_SET_ERROR(pThis->pDevIns, VERR_NO_TMP_MEMORY, N_("Cannot allocate RSDT"));
    22392239
    22402240    acpiPrepareHeader(&rsdt->header, "RSDT", (uint32_t)size, 1);
     
    22452245    }
    22462246    rsdt->header.u8Checksum = acpiChecksum(rsdt, size);
    2247     acpiPhyscpy(s, addr, rsdt, size);
     2247    acpiPhyscpy(pThis, addr, rsdt, size);
    22482248    RTMemFree(rsdt);
    22492249    return VINF_SUCCESS;
     
    22532253 * Plant the Extended System Description Table.
    22542254 */
    2255 static int acpiSetupXSDT(ACPIState *s, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)
     2255static int acpiSetupXSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)
    22562256{
    22572257    ACPITBLXSDT *xsdt;
     
    22692269    }
    22702270    xsdt->header.u8Checksum = acpiChecksum(xsdt, size);
    2271     acpiPhyscpy(s, addr, xsdt, size);
     2271    acpiPhyscpy(pThis, addr, xsdt, size);
    22722272    RTMemFree(xsdt);
    22732273    return VINF_SUCCESS;
     
    23012301 * @todo    All hardcoded, should set this up based on the actual VM config!!!!!
    23022302 */
    2303 static void acpiSetupMADT(ACPIState *s, RTGCPHYS32 addr)
    2304 {
    2305     uint16_t cpus = s->cCpus;
     2303static void acpiSetupMADT(ACPIState *pThis, RTGCPHYS32 addr)
     2304{
     2305    uint16_t cpus = pThis->cCpus;
    23062306    AcpiTableMADT madt(cpus, NUMBER_OF_IRQ_SOURCE_OVERRIDES);
    23072307
     
    23202320        /** Must match numbering convention in MPTABLES */
    23212321        lapic->u8ApicId    = i;
    2322         lapic->u32Flags    = VMCPUSET_IS_PRESENT(&s->CpuSetAttached, i) ? RT_H2LE_U32(LAPIC_ENABLED) : 0;
     2322        lapic->u32Flags    = VMCPUSET_IS_PRESENT(&pThis->CpuSetAttached, i) ? RT_H2LE_U32(LAPIC_ENABLED) : 0;
    23232323        lapic++;
    23242324    }
     
    23662366
    23672367    madt.header_addr()->u8Checksum = acpiChecksum(madt.data(), madt.size());
    2368     acpiPhyscpy(s, addr, madt.data(), madt.size());
     2368    acpiPhyscpy(pThis, addr, madt.data(), madt.size());
    23692369}
    23702370
     
    23722372 * Plant the High Performance Event Timer (HPET) descriptor.
    23732373 */
    2374 static void acpiSetupHPET(ACPIState *s, RTGCPHYS32 addr)
     2374static void acpiSetupHPET(ACPIState *pThis, RTGCPHYS32 addr)
    23752375{
    23762376    ACPITBLHPET hpet;
     
    23942394    hpet.aHeader.u8Checksum = acpiChecksum(&hpet, sizeof(hpet));
    23952395
    2396     acpiPhyscpy(s, addr, (const uint8_t *)&hpet, sizeof(hpet));
     2396    acpiPhyscpy(pThis, addr, (const uint8_t *)&hpet, sizeof(hpet));
    23972397}
    23982398
     
    24412441 * Create the ACPI tables in guest memory.
    24422442 */
    2443 static int acpiPlantTables(ACPIState *s)
     2443static int acpiPlantTables(ACPIState *pThis)
    24442444{
    24452445    int        rc;
     
    24612461
    24622462    cAddr = 1;                  /* FADT */
    2463     if (s->u8UseIOApic)
     2463    if (pThis->u8UseIOApic)
    24642464        iMadt = cAddr++;        /* MADT */
    24652465
    2466     if (s->fUseHpet)
     2466    if (pThis->fUseHpet)
    24672467        iHpet = cAddr++;        /* HPET */
    24682468
    2469     if (s->fUseMcfg)
     2469    if (pThis->fUseMcfg)
    24702470        iMcfg = cAddr++;        /* MCFG */
    24712471
     
    24782478    cbXsdt += cAddr*sizeof(uint64_t);  /* each entry: 64 bits phys. address. */
    24792479
    2480     rc = CFGMR3QueryU64(s->pDevIns->pCfg, "RamSize", &s->u64RamSize);
    2481     if (RT_FAILURE(rc))
    2482         return PDMDEV_SET_ERROR(s->pDevIns, rc,
     2480    rc = CFGMR3QueryU64(pThis->pDevIns->pCfg, "RamSize", &pThis->u64RamSize);
     2481    if (RT_FAILURE(rc))
     2482        return PDMDEV_SET_ERROR(pThis->pDevIns, rc,
    24832483                                N_("Configuration error: Querying \"RamSize\" as integer failed"));
    24842484
    24852485    uint32_t cbRamHole;
    2486     rc = CFGMR3QueryU32Def(s->pDevIns->pCfg, "RamHoleSize", &cbRamHole, MM_RAM_HOLE_SIZE_DEFAULT);
    2487     if (RT_FAILURE(rc))
    2488         return PDMDEV_SET_ERROR(s->pDevIns, rc,
     2486    rc = CFGMR3QueryU32Def(pThis->pDevIns->pCfg, "RamHoleSize", &cbRamHole, MM_RAM_HOLE_SIZE_DEFAULT);
     2487    if (RT_FAILURE(rc))
     2488        return PDMDEV_SET_ERROR(pThis->pDevIns, rc,
    24892489                                N_("Configuration error: Querying \"RamHoleSize\" as integer failed"));
    24902490
     
    24932493     */
    24942494    const uint64_t offRamHole = _4G - cbRamHole;
    2495     s->cbRamHigh = offRamHole < s->u64RamSize ? s->u64RamSize - offRamHole : 0;
    2496     uint64_t cbRamLow = offRamHole < s->u64RamSize ? offRamHole : s->u64RamSize;
     2495    pThis->cbRamHigh = offRamHole < pThis->u64RamSize ? pThis->u64RamSize - offRamHole : 0;
     2496    uint64_t cbRamLow = offRamHole < pThis->u64RamSize ? offRamHole : pThis->u64RamSize;
    24972497    if (cbRamLow > UINT32_C(0xffe00000)) /* See MEM3. */
    24982498    {
     
    25012501        cbRamLow = UINT32_C(0xffe00000);
    25022502    }
    2503     s->cbRamLow = (uint32_t)cbRamLow;
     2503    pThis->cbRamLow = (uint32_t)cbRamLow;
    25042504
    25052505    GCPhysCur = 0;
     
    25192519
    25202520    GCPhysCur = RT_ALIGN_32(GCPhysCur + sizeof(ACPITBLFACS), 16);
    2521     if (s->u8UseIOApic)
     2521    if (pThis->u8UseIOApic)
    25222522    {
    25232523        GCPhysApic = GCPhysCur;
    2524         GCPhysCur = RT_ALIGN_32(GCPhysCur + AcpiTableMADT::sizeFor(s, NUMBER_OF_IRQ_SOURCE_OVERRIDES), 16);
    2525     }
    2526     if (s->fUseHpet)
     2524        GCPhysCur = RT_ALIGN_32(GCPhysCur + AcpiTableMADT::sizeFor(pThis, NUMBER_OF_IRQ_SOURCE_OVERRIDES), 16);
     2525    }
     2526    if (pThis->fUseHpet)
    25272527    {
    25282528        GCPhysHpet = GCPhysCur;
    25292529        GCPhysCur = RT_ALIGN_32(GCPhysCur + sizeof(ACPITBLHPET), 16);
    25302530    }
    2531     if (s->fUseMcfg)
     2531    if (pThis->fUseMcfg)
    25322532    {
    25332533        GCPhysMcfg = GCPhysCur;
     
    25382538    void  *pvSsdtCode = NULL;
    25392539    size_t cbSsdtSize = 0;
    2540     rc = acpiPrepareSsdt(s->pDevIns, &pvSsdtCode, &cbSsdtSize);
     2540    rc = acpiPrepareSsdt(pThis->pDevIns, &pvSsdtCode, &cbSsdtSize);
    25412541    if (RT_FAILURE(rc))
    25422542        return rc;
     
    25492549    void  *pvDsdtCode = NULL;
    25502550    size_t cbDsdtSize = 0;
    2551     rc = acpiPrepareDsdt(s->pDevIns, &pvDsdtCode, &cbDsdtSize);
     2551    rc = acpiPrepareDsdt(pThis->pDevIns, &pvDsdtCode, &cbDsdtSize);
    25522552    if (RT_FAILURE(rc))
    25532553        return rc;
     
    25562556
    25572557    if (GCPhysCur > 0x10000)
    2558         return PDMDEV_SET_ERROR(s->pDevIns, VERR_TOO_MUCH_DATA,
     2558        return PDMDEV_SET_ERROR(pThis->pDevIns, VERR_TOO_MUCH_DATA,
    25592559                                N_("Error: ACPI tables bigger than 64KB"));
    25602560
    25612561    Log(("RSDP 0x%08X\n", find_rsdp_space()));
    2562     addend = s->cbRamLow - 0x10000;
     2562    addend = pThis->cbRamLow - 0x10000;
    25632563    Log(("RSDT 0x%08X XSDT 0x%08X\n", GCPhysRsdt + addend, GCPhysXsdt + addend));
    25642564    Log(("FACS 0x%08X FADT (1.0) 0x%08X, FADT (2+) 0x%08X\n", GCPhysFacs + addend, GCPhysFadtAcpi1 + addend, GCPhysFadtAcpi2 + addend));
    25652565    Log(("DSDT 0x%08X", GCPhysDsdt + addend));
    2566     if (s->u8UseIOApic)
     2566    if (pThis->u8UseIOApic)
    25672567        Log((" MADT 0x%08X", GCPhysApic + addend));
    2568     if (s->fUseHpet)
     2568    if (pThis->fUseHpet)
    25692569        Log((" HPET 0x%08X", GCPhysHpet + addend));
    2570     if (s->fUseMcfg)
     2570    if (pThis->fUseMcfg)
    25712571        Log((" MCFG 0x%08X", GCPhysMcfg + addend));
    25722572    Log((" SSDT 0x%08X", GCPhysSsdt + addend));
    25732573    Log(("\n"));
    25742574
    2575     acpiSetupRSDP((ACPITBLRSDP*)s->au8RSDPPage, GCPhysRsdt + addend, GCPhysXsdt + addend);
    2576     acpiSetupDSDT(s, GCPhysDsdt + addend, pvDsdtCode, cbDsdtSize);
    2577     acpiCleanupDsdt(s->pDevIns, pvDsdtCode);
    2578     acpiSetupFACS(s, GCPhysFacs + addend);
    2579     acpiSetupFADT(s, GCPhysFadtAcpi1 + addend, GCPhysFadtAcpi2 + addend, GCPhysFacs + addend, GCPhysDsdt + addend);
     2575    acpiSetupRSDP((ACPITBLRSDP *)pThis->au8RSDPPage, GCPhysRsdt + addend, GCPhysXsdt + addend);
     2576    acpiSetupDSDT(pThis, GCPhysDsdt + addend, pvDsdtCode, cbDsdtSize);
     2577    acpiCleanupDsdt(pThis->pDevIns, pvDsdtCode);
     2578    acpiSetupFACS(pThis, GCPhysFacs + addend);
     2579    acpiSetupFADT(pThis, GCPhysFadtAcpi1 + addend, GCPhysFadtAcpi2 + addend, GCPhysFacs + addend, GCPhysDsdt + addend);
    25802580
    25812581    aGCPhysRsdt[0] = GCPhysFadtAcpi1 + addend;
    25822582    aGCPhysXsdt[0] = GCPhysFadtAcpi2 + addend;
    2583     if (s->u8UseIOApic)
    2584     {
    2585         acpiSetupMADT(s, GCPhysApic + addend);
     2583    if (pThis->u8UseIOApic)
     2584    {
     2585        acpiSetupMADT(pThis, GCPhysApic + addend);
    25862586        aGCPhysRsdt[iMadt] = GCPhysApic + addend;
    25872587        aGCPhysXsdt[iMadt] = GCPhysApic + addend;
    25882588    }
    2589     if (s->fUseHpet)
    2590     {
    2591         acpiSetupHPET(s, GCPhysHpet + addend);
     2589    if (pThis->fUseHpet)
     2590    {
     2591        acpiSetupHPET(pThis, GCPhysHpet + addend);
    25922592        aGCPhysRsdt[iHpet] = GCPhysHpet + addend;
    25932593        aGCPhysXsdt[iHpet] = GCPhysHpet + addend;
    25942594    }
    2595     if (s->fUseMcfg)
    2596     {
    2597         acpiSetupMCFG(s, GCPhysMcfg + addend);
     2595    if (pThis->fUseMcfg)
     2596    {
     2597        acpiSetupMCFG(pThis, GCPhysMcfg + addend);
    25982598        aGCPhysRsdt[iMcfg] = GCPhysMcfg + addend;
    25992599        aGCPhysXsdt[iMcfg] = GCPhysMcfg + addend;
    26002600    }
    26012601
    2602     acpiSetupSSDT(s, GCPhysSsdt + addend, pvSsdtCode, cbSsdtSize);
    2603     acpiCleanupSsdt(s->pDevIns, pvSsdtCode);
     2602    acpiSetupSSDT(pThis, GCPhysSsdt + addend, pvSsdtCode, cbSsdtSize);
     2603    acpiCleanupSsdt(pThis->pDevIns, pvSsdtCode);
    26042604    aGCPhysRsdt[iSsdt] = GCPhysSsdt + addend;
    26052605    aGCPhysXsdt[iSsdt] = GCPhysSsdt + addend;
    26062606
    2607     rc = acpiSetupRSDT(s, GCPhysRsdt + addend, cAddr, aGCPhysRsdt);
     2607    rc = acpiSetupRSDT(pThis, GCPhysRsdt + addend, cAddr, aGCPhysRsdt);
    26082608    if (RT_FAILURE(rc))
    26092609        return rc;
    2610     return acpiSetupXSDT(s, GCPhysXsdt + addend, cAddr, aGCPhysXsdt);
     2610    return acpiSetupXSDT(pThis, GCPhysXsdt + addend, cAddr, aGCPhysXsdt);
    26112611}
    26122612
     
    26712671static DECLCALLBACK(int) acpiAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    26722672{
    2673     ACPIState *s = PDMINS_2_DATA(pDevIns, ACPIState *);
     2673    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
    26742674    LogFlow(("acpiAttach: pDevIns=%p iLUN=%u fFlags=%#x\n", pDevIns, iLUN, fFlags));
    26752675
     
    26812681    /* Check if it was already attached */
    26822682    int rc = VINF_SUCCESS;
    2683     DEVACPI_LOCK_R3(s);
    2684     if (!VMCPUSET_IS_PRESENT(&s->CpuSetAttached, iLUN))
     2683    DEVACPI_LOCK_R3(pThis);
     2684    if (!VMCPUSET_IS_PRESENT(&pThis->CpuSetAttached, iLUN))
    26852685    {
    26862686        PPDMIBASE IBaseTmp;
    2687         rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &s->IBase, &IBaseTmp, "ACPI CPU");
     2687        rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThis->IBase, &IBaseTmp, "ACPI CPU");
    26882688        if (RT_SUCCESS(rc))
    26892689        {
    26902690            /* Enable the CPU */
    2691             VMCPUSET_ADD(&s->CpuSetAttached, iLUN);
     2691            VMCPUSET_ADD(&pThis->CpuSetAttached, iLUN);
    26922692
    26932693            /*
     
    26952695             * Prevents ejection while the CPU is still used
    26962696             */
    2697             VMCPUSET_ADD(&s->CpuSetLocked, iLUN);
    2698             s->u32CpuEventType = CPU_EVENT_TYPE_ADD;
    2699             s->u32CpuEvent     = iLUN;
     2697            VMCPUSET_ADD(&pThis->CpuSetLocked, iLUN);
     2698            pThis->u32CpuEventType = CPU_EVENT_TYPE_ADD;
     2699            pThis->u32CpuEvent     = iLUN;
    27002700
    27012701            /* Notify the guest */
    2702             update_gpe0(s, s->gpe0_sts | 0x2, s->gpe0_en);
     2702            update_gpe0(pThis, pThis->gpe0_sts | 0x2, pThis->gpe0_en);
    27032703        }
    27042704    }
    2705     DEVACPI_UNLOCK(s);
     2705    DEVACPI_UNLOCK(pThis);
    27062706    return rc;
    27072707}
     
    27162716static DECLCALLBACK(void) acpiDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    27172717{
    2718     ACPIState *s = PDMINS_2_DATA(pDevIns, ACPIState *);
     2718    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
    27192719
    27202720    LogFlow(("acpiDetach: pDevIns=%p iLUN=%u fFlags=%#x\n", pDevIns, iLUN, fFlags));
     
    27242724
    27252725    /* Check if it was already detached */
    2726     DEVACPI_LOCK_R3(s);
    2727     if (VMCPUSET_IS_PRESENT(&s->CpuSetAttached, iLUN))
    2728     {
    2729         if (!VMCPUSET_IS_PRESENT(&s->CpuSetLocked, iLUN))
     2726    DEVACPI_LOCK_R3(pThis);
     2727    if (VMCPUSET_IS_PRESENT(&pThis->CpuSetAttached, iLUN))
     2728    {
     2729        if (!VMCPUSET_IS_PRESENT(&pThis->CpuSetLocked, iLUN))
    27302730        {
    27312731            /* Disable the CPU */
    2732             VMCPUSET_DEL(&s->CpuSetAttached, iLUN);
    2733             s->u32CpuEventType = CPU_EVENT_TYPE_REMOVE;
    2734             s->u32CpuEvent     = iLUN;
     2732            VMCPUSET_DEL(&pThis->CpuSetAttached, iLUN);
     2733            pThis->u32CpuEventType = CPU_EVENT_TYPE_REMOVE;
     2734            pThis->u32CpuEvent     = iLUN;
    27352735
    27362736            /* Notify the guest */
    2737             update_gpe0(s, s->gpe0_sts | 0x2, s->gpe0_en);
     2737            update_gpe0(pThis, pThis->gpe0_sts | 0x2, pThis->gpe0_en);
    27382738        }
    27392739        else
    27402740            AssertMsgFailed(("CPU is still locked by the guest\n"));
    27412741    }
    2742     DEVACPI_UNLOCK(s);
     2742    DEVACPI_UNLOCK(pThis);
    27432743}
    27442744
     
    27952795static DECLCALLBACK(int) acpiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
    27962796{
    2797     ACPIState *s   = PDMINS_2_DATA(pDevIns, ACPIState *);
    2798     PCIDevice *dev = &s->dev;
     2797    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
    27992798    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    28002799
     
    28042803    /** @todo move more of the code up! */
    28052804
     2805    pThis->pDevIns = pDevIns;
     2806    VMCPUSET_EMPTY(&pThis->CpuSetAttached);
     2807    VMCPUSET_EMPTY(&pThis->CpuSetLocked);
     2808    pThis->idCpuLockCheck  = UINT32_C(0xffffffff);
     2809    pThis->u32CpuEventType = 0;
     2810    pThis->u32CpuEvent     = UINT32_C(0xffffffff);
     2811
     2812    /* The first CPU can't be attached/detached */
     2813    VMCPUSET_ADD(&pThis->CpuSetAttached, 0);
     2814    VMCPUSET_ADD(&pThis->CpuSetLocked, 0);
     2815
     2816    /* IBase */
     2817    pThis->IBase.pfnQueryInterface              = acpiQueryInterface;
     2818    /* IACPIPort */
     2819    pThis->IACPIPort.pfnSleepButtonPress        = acpiPort_SleepButtonPress;
     2820    pThis->IACPIPort.pfnPowerButtonPress        = acpiPort_PowerButtonPress;
     2821    pThis->IACPIPort.pfnGetPowerButtonHandled   = acpiPort_GetPowerButtonHandled;
     2822    pThis->IACPIPort.pfnGetGuestEnteredACPIMode = acpiPort_GetGuestEnteredACPIMode;
     2823    pThis->IACPIPort.pfnGetCpuStatus            = acpiPort_GetCpuStatus;
     2824
     2825    /* Set the default critical section to NOP (related to the PM timer). */
    28062826    pDevIns->pCritSectR3 = PDMDevHlpCritSectGetNop(pDevIns);
    2807     int rc = PDMDevHlpCritSectInit(pDevIns, &s->CritSect, RT_SRC_POS, "acpi");
     2827    int rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, RT_SRC_POS, "acpi");
    28082828    AssertRCReturn(rc, rc);
    28092829
     
    28432863                                N_("Configuration error: Invalid config key for ACPI device"));
    28442864
    2845     s->pDevIns = pDevIns;
    2846 
    28472865    /* query whether we are supposed to present an IOAPIC */
    2848     rc = CFGMR3QueryU8Def(pCfg, "IOAPIC", &s->u8UseIOApic, 1);
     2866    rc = CFGMR3QueryU8Def(pCfg, "IOAPIC", &pThis->u8UseIOApic, 1);
    28492867    if (RT_FAILURE(rc))
    28502868        return PDMDEV_SET_ERROR(pDevIns, rc,
    28512869                                N_("Configuration error: Failed to read \"IOAPIC\""));
    28522870
    2853     rc = CFGMR3QueryU16Def(pCfg, "NumCPUs", &s->cCpus, 1);
     2871    rc = CFGMR3QueryU16Def(pCfg, "NumCPUs", &pThis->cCpus, 1);
    28542872    if (RT_FAILURE(rc))
    28552873        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    28572875
    28582876    /* query whether we are supposed to present an FDC controller */
    2859     rc = CFGMR3QueryBoolDef(pCfg, "FdcEnabled", &s->fUseFdc, true);
     2877    rc = CFGMR3QueryBoolDef(pCfg, "FdcEnabled", &pThis->fUseFdc, true);
    28602878    if (RT_FAILURE(rc))
    28612879        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    28632881
    28642882    /* query whether we are supposed to present HPET */
    2865     rc = CFGMR3QueryBoolDef(pCfg, "HpetEnabled", &s->fUseHpet, false);
     2883    rc = CFGMR3QueryBoolDef(pCfg, "HpetEnabled", &pThis->fUseHpet, false);
    28662884    if (RT_FAILURE(rc))
    28672885        return PDMDEV_SET_ERROR(pDevIns, rc,
    28682886                                N_("Configuration error: Failed to read \"HpetEnabled\""));
    28692887    /* query MCFG configuration */
    2870     rc = CFGMR3QueryU64Def(pCfg, "McfgBase", &s->u64PciConfigMMioAddress, 0);
     2888    rc = CFGMR3QueryU64Def(pCfg, "McfgBase", &pThis->u64PciConfigMMioAddress, 0);
    28712889    if (RT_FAILURE(rc))
    28722890        return PDMDEV_SET_ERROR(pDevIns, rc,
    28732891                                N_("Configuration error: Failed to read \"McfgBase\""));
    2874     rc = CFGMR3QueryU64Def(pCfg, "McfgLength", &s->u64PciConfigMMioLength, 0);
     2892    rc = CFGMR3QueryU64Def(pCfg, "McfgLength", &pThis->u64PciConfigMMioLength, 0);
    28752893    if (RT_FAILURE(rc))
    28762894        return PDMDEV_SET_ERROR(pDevIns, rc,
    28772895                                N_("Configuration error: Failed to read \"McfgLength\""));
    2878     s->fUseMcfg = (s->u64PciConfigMMioAddress != 0) && (s->u64PciConfigMMioLength != 0);
     2896    pThis->fUseMcfg = (pThis->u64PciConfigMMioAddress != 0) && (pThis->u64PciConfigMMioLength != 0);
    28792897
    28802898    /* query whether we are supposed to present SMC */
    2881     rc = CFGMR3QueryBoolDef(pCfg, "SmcEnabled", &s->fUseSmc, false);
     2899    rc = CFGMR3QueryBoolDef(pCfg, "SmcEnabled", &pThis->fUseSmc, false);
    28822900    if (RT_FAILURE(rc))
    28832901        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    28852903
    28862904    /* query whether we are supposed to present RTC object */
    2887     rc = CFGMR3QueryBoolDef(pCfg, "ShowRtc", &s->fShowRtc, false);
     2905    rc = CFGMR3QueryBoolDef(pCfg, "ShowRtc", &pThis->fShowRtc, false);
    28882906    if (RT_FAILURE(rc))
    28892907        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    28912909
    28922910    /* query whether we are supposed to present CPU objects */
    2893     rc = CFGMR3QueryBoolDef(pCfg, "ShowCpu", &s->fShowCpu, false);
     2911    rc = CFGMR3QueryBoolDef(pCfg, "ShowCpu", &pThis->fShowCpu, false);
    28942912    if (RT_FAILURE(rc))
    28952913        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    28972915
    28982916    /* query primary NIC PCI address */
    2899     rc = CFGMR3QueryU32Def(pCfg, "NicPciAddress", &s->u32NicPciAddress, 0);
     2917    rc = CFGMR3QueryU32Def(pCfg, "NicPciAddress", &pThis->u32NicPciAddress, 0);
    29002918    if (RT_FAILURE(rc))
    29012919        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    29032921
    29042922    /* query primary NIC PCI address */
    2905     rc = CFGMR3QueryU32Def(pCfg, "AudioPciAddress", &s->u32AudioPciAddress, 0);
     2923    rc = CFGMR3QueryU32Def(pCfg, "AudioPciAddress", &pThis->u32AudioPciAddress, 0);
    29062924    if (RT_FAILURE(rc))
    29072925        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    29092927
    29102928    /* query IO controller (southbridge) PCI address */
    2911     rc = CFGMR3QueryU32Def(pCfg, "IocPciAddress", &s->u32IocPciAddress, 0);
     2929    rc = CFGMR3QueryU32Def(pCfg, "IocPciAddress", &pThis->u32IocPciAddress, 0);
    29122930    if (RT_FAILURE(rc))
    29132931        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    29152933
    29162934    /* query host bus controller PCI address */
    2917     rc = CFGMR3QueryU32Def(pCfg, "HostBusPciAddress", &s->u32HbcPciAddress, 0);
     2935    rc = CFGMR3QueryU32Def(pCfg, "HostBusPciAddress", &pThis->u32HbcPciAddress, 0);
    29182936    if (RT_FAILURE(rc))
    29192937        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    29212939
    29222940    /* query whether S1 power state should be exposed */
    2923     rc = CFGMR3QueryBoolDef(pCfg, "PowerS1Enabled", &s->fS1Enabled, false);
     2941    rc = CFGMR3QueryBoolDef(pCfg, "PowerS1Enabled", &pThis->fS1Enabled, false);
    29242942    if (RT_FAILURE(rc))
    29252943        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    29272945
    29282946    /* query whether S4 power state should be exposed */
    2929     rc = CFGMR3QueryBoolDef(pCfg, "PowerS4Enabled", &s->fS4Enabled, false);
     2947    rc = CFGMR3QueryBoolDef(pCfg, "PowerS4Enabled", &pThis->fS4Enabled, false);
    29302948    if (RT_FAILURE(rc))
    29312949        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    29332951
    29342952    /* query whether S1 power state should save the VM state */
    2935     rc = CFGMR3QueryBoolDef(pCfg, "EnableSuspendToDisk", &s->fSuspendToSavedState, false);
     2953    rc = CFGMR3QueryBoolDef(pCfg, "EnableSuspendToDisk", &pThis->fSuspendToSavedState, false);
    29362954    if (RT_FAILURE(rc))
    29372955        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    29392957
    29402958    /* query whether we are allow CPU hot plugging */
    2941     rc = CFGMR3QueryBoolDef(pCfg, "CpuHotPlug", &s->fCpuHotPlug, false);
     2959    rc = CFGMR3QueryBoolDef(pCfg, "CpuHotPlug", &pThis->fCpuHotPlug, false);
    29422960    if (RT_FAILURE(rc))
    29432961        return PDMDEV_SET_ERROR(pDevIns, rc,
    29442962                                N_("Configuration error: Failed to read \"CpuHotPlug\""));
    29452963
    2946     rc = CFGMR3QueryBool(pCfg, "GCEnabled", &s->fGCEnabled);
     2964    rc = CFGMR3QueryBool(pCfg, "GCEnabled", &pThis->fGCEnabled);
    29472965    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    2948         s->fGCEnabled = true;
     2966        pThis->fGCEnabled = true;
    29492967    else if (RT_FAILURE(rc))
    29502968        return PDMDEV_SET_ERROR(pDevIns, rc,
    29512969                                N_("Configuration error: Failed to read \"GCEnabled\""));
    29522970
    2953     rc = CFGMR3QueryBool(pCfg, "R0Enabled", &s->fR0Enabled);
     2971    rc = CFGMR3QueryBool(pCfg, "R0Enabled", &pThis->fR0Enabled);
    29542972    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    2955         s->fR0Enabled = true;
     2973        pThis->fR0Enabled = true;
    29562974    else if (RT_FAILURE(rc))
    29572975        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    29592977
    29602978    /* query serial info */
    2961     rc = CFGMR3QueryU8Def(pCfg, "Serial0Irq", &s->uSerial0Irq, 4);
     2979    rc = CFGMR3QueryU8Def(pCfg, "Serial0Irq", &pThis->uSerial0Irq, 4);
    29622980    if (RT_FAILURE(rc))
    29632981        return PDMDEV_SET_ERROR(pDevIns, rc,
    29642982                                N_("Configuration error: Failed to read \"Serial0Irq\""));
    29652983
    2966     rc = CFGMR3QueryU16Def(pCfg, "Serial0IoPortBase", &s->uSerial0IoPortBase, 0x3f8);
     2984    rc = CFGMR3QueryU16Def(pCfg, "Serial0IoPortBase", &pThis->uSerial0IoPortBase, 0x3f8);
    29672985    if (RT_FAILURE(rc))
    29682986        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    29702988
    29712989    /* Serial 1 is enabled, get config data */
    2972     rc = CFGMR3QueryU8Def(pCfg, "Serial1Irq", &s->uSerial1Irq, 3);
     2990    rc = CFGMR3QueryU8Def(pCfg, "Serial1Irq", &pThis->uSerial1Irq, 3);
    29732991    if (RT_FAILURE(rc))
    29742992        return PDMDEV_SET_ERROR(pDevIns, rc,
    29752993                                N_("Configuration error: Failed to read \"Serial1Irq\""));
    29762994
    2977     rc = CFGMR3QueryU16Def(pCfg, "Serial1IoPortBase", &s->uSerial1IoPortBase, 0x2f8);
     2995    rc = CFGMR3QueryU16Def(pCfg, "Serial1IoPortBase", &pThis->uSerial1IoPortBase, 0x2f8);
    29782996    if (RT_FAILURE(rc))
    29792997        return PDMDEV_SET_ERROR(pDevIns, rc,
    29802998                                N_("Configuration error: Failed to read \"Serial1IoPortBase\""));
    29812999
    2982     /*
    2983      * Interfaces
    2984      */
    2985     /* IBase */
    2986     s->IBase.pfnQueryInterface              = acpiQueryInterface;
    2987     /* IACPIPort */
    2988     s->IACPIPort.pfnSleepButtonPress        = acpiPort_SleepButtonPress;
    2989     s->IACPIPort.pfnPowerButtonPress        = acpiPort_PowerButtonPress;
    2990     s->IACPIPort.pfnGetPowerButtonHandled   = acpiPort_GetPowerButtonHandled;
    2991     s->IACPIPort.pfnGetGuestEnteredACPIMode = acpiPort_GetGuestEnteredACPIMode;
    2992     s->IACPIPort.pfnGetCpuStatus            = acpiPort_GetCpuStatus;
    2993 
    2994     VMCPUSET_EMPTY(&s->CpuSetAttached);
    2995     VMCPUSET_EMPTY(&s->CpuSetLocked);
    2996     s->idCpuLockCheck = UINT32_C(0xffffffff);
    2997     s->u32CpuEventType = 0;
    2998     s->u32CpuEvent     = UINT32_C(0xffffffff);
    2999 
    3000     /* The first CPU can't be attached/detached */
    3001     VMCPUSET_ADD(&s->CpuSetAttached, 0);
    3002     VMCPUSET_ADD(&s->CpuSetLocked, 0);
    3003 
    30043000    /* Try to attach the other CPUs */
    3005     for (unsigned i = 1; i < s->cCpus; i++)
    3006     {
    3007         if (s->fCpuHotPlug)
     3001    for (unsigned i = 1; i < pThis->cCpus; i++)
     3002    {
     3003        if (pThis->fCpuHotPlug)
    30083004        {
    30093005            PPDMIBASE IBaseTmp;
    3010             rc = PDMDevHlpDriverAttach(pDevIns, i, &s->IBase, &IBaseTmp, "ACPI CPU");
     3006            rc = PDMDevHlpDriverAttach(pDevIns, i, &pThis->IBase, &IBaseTmp, "ACPI CPU");
    30113007
    30123008            if (RT_SUCCESS(rc))
    30133009            {
    3014                 VMCPUSET_ADD(&s->CpuSetAttached, i);
    3015                 VMCPUSET_ADD(&s->CpuSetLocked, i);
     3010                VMCPUSET_ADD(&pThis->CpuSetAttached, i);
     3011                VMCPUSET_ADD(&pThis->CpuSetLocked, i);
    30163012                Log(("acpi: Attached CPU %u\n", i));
    30173013            }
     
    30243020        {
    30253021            /* CPU is always attached if hot-plug is not enabled. */
    3026             VMCPUSET_ADD(&s->CpuSetAttached, i);
    3027             VMCPUSET_ADD(&s->CpuSetLocked, i);
     3022            VMCPUSET_ADD(&pThis->CpuSetAttached, i);
     3023            VMCPUSET_ADD(&pThis->CpuSetLocked, i);
    30283024        }
    30293025    }
     
    30313027
    30323028    /* Set default port base */
    3033     s->uPmIoPortBase = PM_PORT_BASE;
     3029    pThis->uPmIoPortBase = PM_PORT_BASE;
    30343030
    30353031    /*
     
    30373033     * enable only one device.
    30383034     */
    3039     if (s->fUseSmc)
    3040         s->fUseFdc = false;
    3041 
    3042     /* */
     3035    if (pThis->fUseSmc)
     3036        pThis->fUseFdc = false;
     3037
     3038    /*
     3039     * Plant ACPI tables.
     3040     */
    30433041    RTGCPHYS32 GCPhysRsdp = find_rsdp_space();
    30443042    if (!GCPhysRsdp)
     
    30463044                                N_("Can not find space for RSDP. ACPI is disabled"));
    30473045
    3048     rc = acpiPlantTables(s);
     3046    rc = acpiPlantTables(pThis);
    30493047    if (RT_FAILURE(rc))
    30503048        return rc;
    30513049
    3052     rc = PDMDevHlpROMRegister(pDevIns, GCPhysRsdp, 0x1000, s->au8RSDPPage, 0x1000,
     3050    rc = PDMDevHlpROMRegister(pDevIns, GCPhysRsdp, 0x1000, pThis->au8RSDPPage, 0x1000,
    30533051                              PGMPHYS_ROM_FLAGS_PERMANENT_BINARY, "ACPI RSDP");
    30543052    if (RT_FAILURE(rc))
    30553053        return rc;
    30563054
    3057     rc = acpiRegisterPmHandlers(s);
     3055    /*
     3056     * Register I/O ports.
     3057     */
     3058    rc = acpiRegisterPmHandlers(pThis);
    30583059    if (RT_FAILURE(rc))
    30593060        return rc;
     
    30613062#define R(addr, cnt, writer, reader, description)       \
    30623063    do { \
    3063         rc = PDMDevHlpIOPortRegister(pDevIns, addr, cnt, s, writer, reader, \
     3064        rc = PDMDevHlpIOPortRegister(pDevIns, addr, cnt, pThis, writer, reader, \
    30643065                                      NULL, NULL, description); \
    30653066        if (RT_FAILURE(rc)) \
     
    30783079#undef R
    30793080
    3080     rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, acpiPmTimer, dev,
    3081                                 TMTIMER_FLAGS_NO_CRIT_SECT, "ACPI PM Timer", &s->pPmTimerR3);
     3081    /*
     3082     * Create the PM timer.
     3083     */
     3084    rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, acpiPmTimer, &pThis->dev,
     3085                                TMTIMER_FLAGS_NO_CRIT_SECT, "ACPI PM Timer", &pThis->pPmTimerR3);
    30823086    if (RT_FAILURE(rc))
    30833087    {
     
    30863090    }
    30873091
    3088     s->pPmTimerR0 = TMTimerR0Ptr(s->pPmTimerR3);
    3089     s->pPmTimerRC = TMTimerRCPtr(s->pPmTimerR3);
    3090     s->u64PmTimerInitial = TMTimerGet(s->pPmTimerR3);
    3091     acpiPmTimerReset(s, s->u64PmTimerInitial);
    3092 
    3093     PCIDevSetVendorId(dev, 0x8086); /* Intel */
    3094     PCIDevSetDeviceId(dev, 0x7113); /* 82371AB */
     3092    pThis->pPmTimerR0 = TMTimerR0Ptr(pThis->pPmTimerR3);
     3093    pThis->pPmTimerRC = TMTimerRCPtr(pThis->pPmTimerR3);
     3094    pThis->u64PmTimerInitial = TMTimerGet(pThis->pPmTimerR3);
     3095    acpiPmTimerReset(pThis, pThis->u64PmTimerInitial);
     3096
     3097    /*
     3098     * Set up the PCI device.
     3099     */
     3100    PCIDevSetVendorId(&pThis->dev, 0x8086); /* Intel */
     3101    PCIDevSetDeviceId(&pThis->dev, 0x7113); /* 82371AB */
    30953102
    30963103    /* See p. 50 of PIIX4 manual */
    3097     PCIDevSetCommand(dev, 0x01);
    3098     PCIDevSetStatus(dev, 0x0280);
    3099 
    3100     PCIDevSetRevisionId(dev, 0x08);
    3101 
    3102     PCIDevSetClassProg(dev, 0x00);
    3103     PCIDevSetClassSub(dev, 0x80);
    3104     PCIDevSetClassBase(dev, 0x06);
    3105 
    3106     PCIDevSetHeaderType(dev, 0x80);
    3107 
    3108     PCIDevSetBIST(dev, 0x00);
    3109 
    3110     PCIDevSetInterruptLine(dev, SCI_INT);
    3111     PCIDevSetInterruptPin (dev, 0x01);
    3112 
    3113     dev->config[0x40] = 0x01; /* PM base address, this bit marks it as IO range, not PA */
     3104    PCIDevSetCommand(&pThis->dev, 0x01);
     3105    PCIDevSetStatus(&pThis->dev, 0x0280);
     3106
     3107    PCIDevSetRevisionId(&pThis->dev, 0x08);
     3108
     3109    PCIDevSetClassProg(&pThis->dev, 0x00);
     3110    PCIDevSetClassSub(&pThis->dev, 0x80);
     3111    PCIDevSetClassBase(&pThis->dev, 0x06);
     3112
     3113    PCIDevSetHeaderType(&pThis->dev, 0x80);
     3114
     3115    PCIDevSetBIST(&pThis->dev, 0x00);
     3116
     3117    PCIDevSetInterruptLine(&pThis->dev, SCI_INT);
     3118    PCIDevSetInterruptPin (&pThis->dev, 0x01);
     3119
     3120    pThis->dev.config[0x40] = 0x01; /* PM base address, this bit marks it as IO range, not PA */
    31143121
    31153122#if 0
     
    31193126#endif
    31203127
    3121     rc = PDMDevHlpPCIRegister(pDevIns, dev);
     3128    rc = PDMDevHlpPCIRegister(pDevIns, &pThis->dev);
    31223129    if (RT_FAILURE(rc))
    31233130        return rc;
    31243131
    3125     PDMDevHlpPCISetConfigCallbacks(pDevIns, dev,
    3126                                    acpiPciConfigRead,  &s->pfnAcpiPciConfigRead,
    3127                                    acpiPciConfigWrite, &s->pfnAcpiPciConfigWrite);
    3128 
    3129     rc = PDMDevHlpSSMRegister(pDevIns, 6, sizeof(*s), acpiSaveState, acpiLoadState);
     3132    PDMDevHlpPCISetConfigCallbacks(pDevIns, &pThis->dev,
     3133                                   acpiPciConfigRead,  &pThis->pfnAcpiPciConfigRead,
     3134                                   acpiPciConfigWrite, &pThis->pfnAcpiPciConfigWrite);
     3135
     3136    /*
     3137     * Register the saved state.
     3138     */
     3139    rc = PDMDevHlpSSMRegister(pDevIns, 6, sizeof(*pThis), acpiSaveState, acpiLoadState);
    31303140    if (RT_FAILURE(rc))
    31313141        return rc;
     
    31343144    * Get the corresponding connector interface
    31353145    */
    3136    rc = PDMDevHlpDriverAttach(pDevIns, 0, &s->IBase, &s->pDrvBase, "ACPI Driver Port");
     3146   rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "ACPI Driver Port");
    31373147   if (RT_SUCCESS(rc))
    31383148   {
    3139        s->pDrv = PDMIBASE_QUERY_INTERFACE(s->pDrvBase, PDMIACPICONNECTOR);
    3140        if (!s->pDrv)
     3149       pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIACPICONNECTOR);
     3150       if (!pThis->pDrv)
    31413151           return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_MISSING_INTERFACE,
    31423152                                   N_("LUN #0 doesn't have an ACPI connector interface"));
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