Changeset 37446 in vbox
- Timestamp:
- Jun 14, 2011 2:46:33 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevACPI.cpp
r37444 r37446 678 678 * Size of MADT for given ACPI config, useful to compute layout. 679 679 */ 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(); 683 683 } 684 684 … … 713 713 RT_C_DECLS_END 714 714 #ifdef IN_RING3 715 static int acpiPlantTables(ACPIState * s);715 static int acpiPlantTables(ACPIState *pThis); 716 716 #endif 717 717 … … 719 719 720 720 /* SCI IRQ */ 721 DECLINLINE(void) acpiSetIrq(ACPIState * s, int level)722 { 723 if ( s->pm1a_ctl & SCI_EN)724 PDMDevHlpPCISetIrq( s->pDevIns, -1, level);721 DECLINLINE(void) acpiSetIrq(ACPIState *pThis, int level) 722 { 723 if (pThis->pm1a_ctl & SCI_EN) 724 PDMDevHlpPCISetIrq(pThis->pDevIns, -1, level); 725 725 } 726 726 … … 735 735 } 736 736 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;737 DECLINLINE(int) pm1a_level(ACPIState *pThis) 738 { 739 return (pm1a_pure_en(pThis->pm1a_en) & pm1a_pure_sts(pThis->pm1a_sts)) != 0; 740 } 741 742 DECLINLINE(int) gpe0_level(ACPIState *pThis) 743 { 744 return (pThis->gpe0_en & pThis->gpe0_sts) != 0; 745 745 } 746 746 … … 2100 2100 * Wrapper around PDMDevHlpPhysWrite used when planting ACPI tables. 2101 2101 */ 2102 static void acpiPhyscpy(ACPIState * s, RTGCPHYS32 dst, const void * const src, size_t size)2103 { 2104 PDMDevHlpPhysWrite( s->pDevIns, dst, src, size);2102 static void acpiPhyscpy(ACPIState *pThis, RTGCPHYS32 dst, const void * const src, size_t size) 2103 { 2104 PDMDevHlpPhysWrite(pThis->pDevIns, dst, src, size); 2105 2105 } 2106 2106 … … 2108 2108 * Plant the Differentiated System Description Table (DSDT). 2109 2109 */ 2110 static void acpiSetupDSDT(ACPIState * s, RTGCPHYS32 addr,2110 static void acpiSetupDSDT(ACPIState *pThis, RTGCPHYS32 addr, 2111 2111 void* pPtr, size_t uDsdtLen) 2112 2112 { 2113 acpiPhyscpy( s, addr, pPtr, uDsdtLen);2113 acpiPhyscpy(pThis, addr, pPtr, uDsdtLen); 2114 2114 } 2115 2115 … … 2117 2117 * Plan the Secondary System Description Table (SSDT). 2118 2118 */ 2119 static void acpiSetupSSDT(ACPIState * s, RTGCPHYS32 addr,2119 static void acpiSetupSSDT(ACPIState *pThis, RTGCPHYS32 addr, 2120 2120 void* pPtr, size_t uSsdtLen) 2121 2121 { 2122 acpiPhyscpy( s, addr, pPtr, uSsdtLen);2122 acpiPhyscpy(pThis, addr, pPtr, uSsdtLen); 2123 2123 } 2124 2124 … … 2126 2126 * Plant the Firmware ACPI Control Structure (FACS). 2127 2127 */ 2128 static void acpiSetupFACS(ACPIState * s, RTGCPHYS32 addr)2128 static void acpiSetupFACS(ACPIState *pThis, RTGCPHYS32 addr) 2129 2129 { 2130 2130 ACPITBLFACS facs; … … 2140 2140 facs.u8Version = 1; 2141 2141 2142 acpiPhyscpy( s, addr, (const uint8_t *)&facs, sizeof(facs));2142 acpiPhyscpy(pThis, addr, (const uint8_t *)&facs, sizeof(facs)); 2143 2143 } 2144 2144 … … 2146 2146 * Plant the Fixed ACPI Description Table (FADT aka FACP). 2147 2147 */ 2148 static void acpiSetupFADT(ACPIState * s, RTGCPHYS32 GCPhysAcpi1, RTGCPHYS32 GCPhysAcpi2, RTGCPHYS32 GCPhysFacs, RTGCPHYS GCPhysDsdt)2148 static void acpiSetupFADT(ACPIState *pThis, RTGCPHYS32 GCPhysAcpi1, RTGCPHYS32 GCPhysAcpi2, RTGCPHYS32 GCPhysFacs, RTGCPHYS GCPhysDsdt) 2149 2149 { 2150 2150 ACPITBLFADT fadt; … … 2163 2163 fadt.u8S4BIOSReq = 0; 2164 2164 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)); 2173 2173 fadt.u8PM1EVTLEN = 4; 2174 2174 fadt.u8PM1CTLLEN = 2; … … 2196 2196 2197 2197 /* We have to force physical APIC mode or Linux can't use more than 8 CPUs */ 2198 if ( s->fCpuHotPlug)2198 if (pThis->fCpuHotPlug) 2199 2199 fadt.u32Flags |= RT_H2LE_U32(FADT_FL_FORCE_APIC_PHYS_DEST_MODE); 2200 2200 … … 2203 2203 fadt.u64XFACS = RT_H2LE_U64((uint64_t)GCPhysFacs); 2204 2204 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)); 2213 2213 fadt.header.u8Checksum = acpiChecksum(&fadt, sizeof(fadt)); 2214 acpiPhyscpy( s, GCPhysAcpi2, &fadt, sizeof(fadt));2214 acpiPhyscpy(pThis, GCPhysAcpi2, &fadt, sizeof(fadt)); 2215 2215 2216 2216 /* Now the ACPI 1.0 version. */ … … 2219 2219 fadt.header.u8Checksum = 0; /* Must be zeroed before recalculating checksum! */ 2220 2220 fadt.header.u8Checksum = acpiChecksum(&fadt, ACPITBLFADT_VERSION1_SIZE); 2221 acpiPhyscpy( s, GCPhysAcpi1, &fadt, ACPITBLFADT_VERSION1_SIZE);2221 acpiPhyscpy(pThis, GCPhysAcpi1, &fadt, ACPITBLFADT_VERSION1_SIZE); 2222 2222 } 2223 2223 … … 2229 2229 * ACPI 2.0 and up. 2230 2230 */ 2231 static int acpiSetupRSDT(ACPIState * s, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)2231 static int acpiSetupRSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs) 2232 2232 { 2233 2233 ACPITBLRSDT *rsdt; … … 2236 2236 rsdt = (ACPITBLRSDT*)RTMemAllocZ(size); 2237 2237 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")); 2239 2239 2240 2240 acpiPrepareHeader(&rsdt->header, "RSDT", (uint32_t)size, 1); … … 2245 2245 } 2246 2246 rsdt->header.u8Checksum = acpiChecksum(rsdt, size); 2247 acpiPhyscpy( s, addr, rsdt, size);2247 acpiPhyscpy(pThis, addr, rsdt, size); 2248 2248 RTMemFree(rsdt); 2249 2249 return VINF_SUCCESS; … … 2253 2253 * Plant the Extended System Description Table. 2254 2254 */ 2255 static int acpiSetupXSDT(ACPIState * s, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs)2255 static int acpiSetupXSDT(ACPIState *pThis, RTGCPHYS32 addr, unsigned int nb_entries, uint32_t *addrs) 2256 2256 { 2257 2257 ACPITBLXSDT *xsdt; … … 2269 2269 } 2270 2270 xsdt->header.u8Checksum = acpiChecksum(xsdt, size); 2271 acpiPhyscpy( s, addr, xsdt, size);2271 acpiPhyscpy(pThis, addr, xsdt, size); 2272 2272 RTMemFree(xsdt); 2273 2273 return VINF_SUCCESS; … … 2301 2301 * @todo All hardcoded, should set this up based on the actual VM config!!!!! 2302 2302 */ 2303 static void acpiSetupMADT(ACPIState * s, RTGCPHYS32 addr)2304 { 2305 uint16_t cpus = s->cCpus;2303 static void acpiSetupMADT(ACPIState *pThis, RTGCPHYS32 addr) 2304 { 2305 uint16_t cpus = pThis->cCpus; 2306 2306 AcpiTableMADT madt(cpus, NUMBER_OF_IRQ_SOURCE_OVERRIDES); 2307 2307 … … 2320 2320 /** Must match numbering convention in MPTABLES */ 2321 2321 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; 2323 2323 lapic++; 2324 2324 } … … 2366 2366 2367 2367 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()); 2369 2369 } 2370 2370 … … 2372 2372 * Plant the High Performance Event Timer (HPET) descriptor. 2373 2373 */ 2374 static void acpiSetupHPET(ACPIState * s, RTGCPHYS32 addr)2374 static void acpiSetupHPET(ACPIState *pThis, RTGCPHYS32 addr) 2375 2375 { 2376 2376 ACPITBLHPET hpet; … … 2394 2394 hpet.aHeader.u8Checksum = acpiChecksum(&hpet, sizeof(hpet)); 2395 2395 2396 acpiPhyscpy( s, addr, (const uint8_t *)&hpet, sizeof(hpet));2396 acpiPhyscpy(pThis, addr, (const uint8_t *)&hpet, sizeof(hpet)); 2397 2397 } 2398 2398 … … 2441 2441 * Create the ACPI tables in guest memory. 2442 2442 */ 2443 static int acpiPlantTables(ACPIState * s)2443 static int acpiPlantTables(ACPIState *pThis) 2444 2444 { 2445 2445 int rc; … … 2461 2461 2462 2462 cAddr = 1; /* FADT */ 2463 if ( s->u8UseIOApic)2463 if (pThis->u8UseIOApic) 2464 2464 iMadt = cAddr++; /* MADT */ 2465 2465 2466 if ( s->fUseHpet)2466 if (pThis->fUseHpet) 2467 2467 iHpet = cAddr++; /* HPET */ 2468 2468 2469 if ( s->fUseMcfg)2469 if (pThis->fUseMcfg) 2470 2470 iMcfg = cAddr++; /* MCFG */ 2471 2471 … … 2478 2478 cbXsdt += cAddr*sizeof(uint64_t); /* each entry: 64 bits phys. address. */ 2479 2479 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, 2483 2483 N_("Configuration error: Querying \"RamSize\" as integer failed")); 2484 2484 2485 2485 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, 2489 2489 N_("Configuration error: Querying \"RamHoleSize\" as integer failed")); 2490 2490 … … 2493 2493 */ 2494 2494 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; 2497 2497 if (cbRamLow > UINT32_C(0xffe00000)) /* See MEM3. */ 2498 2498 { … … 2501 2501 cbRamLow = UINT32_C(0xffe00000); 2502 2502 } 2503 s->cbRamLow = (uint32_t)cbRamLow;2503 pThis->cbRamLow = (uint32_t)cbRamLow; 2504 2504 2505 2505 GCPhysCur = 0; … … 2519 2519 2520 2520 GCPhysCur = RT_ALIGN_32(GCPhysCur + sizeof(ACPITBLFACS), 16); 2521 if ( s->u8UseIOApic)2521 if (pThis->u8UseIOApic) 2522 2522 { 2523 2523 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) 2527 2527 { 2528 2528 GCPhysHpet = GCPhysCur; 2529 2529 GCPhysCur = RT_ALIGN_32(GCPhysCur + sizeof(ACPITBLHPET), 16); 2530 2530 } 2531 if ( s->fUseMcfg)2531 if (pThis->fUseMcfg) 2532 2532 { 2533 2533 GCPhysMcfg = GCPhysCur; … … 2538 2538 void *pvSsdtCode = NULL; 2539 2539 size_t cbSsdtSize = 0; 2540 rc = acpiPrepareSsdt( s->pDevIns, &pvSsdtCode, &cbSsdtSize);2540 rc = acpiPrepareSsdt(pThis->pDevIns, &pvSsdtCode, &cbSsdtSize); 2541 2541 if (RT_FAILURE(rc)) 2542 2542 return rc; … … 2549 2549 void *pvDsdtCode = NULL; 2550 2550 size_t cbDsdtSize = 0; 2551 rc = acpiPrepareDsdt( s->pDevIns, &pvDsdtCode, &cbDsdtSize);2551 rc = acpiPrepareDsdt(pThis->pDevIns, &pvDsdtCode, &cbDsdtSize); 2552 2552 if (RT_FAILURE(rc)) 2553 2553 return rc; … … 2556 2556 2557 2557 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, 2559 2559 N_("Error: ACPI tables bigger than 64KB")); 2560 2560 2561 2561 Log(("RSDP 0x%08X\n", find_rsdp_space())); 2562 addend = s->cbRamLow - 0x10000;2562 addend = pThis->cbRamLow - 0x10000; 2563 2563 Log(("RSDT 0x%08X XSDT 0x%08X\n", GCPhysRsdt + addend, GCPhysXsdt + addend)); 2564 2564 Log(("FACS 0x%08X FADT (1.0) 0x%08X, FADT (2+) 0x%08X\n", GCPhysFacs + addend, GCPhysFadtAcpi1 + addend, GCPhysFadtAcpi2 + addend)); 2565 2565 Log(("DSDT 0x%08X", GCPhysDsdt + addend)); 2566 if ( s->u8UseIOApic)2566 if (pThis->u8UseIOApic) 2567 2567 Log((" MADT 0x%08X", GCPhysApic + addend)); 2568 if ( s->fUseHpet)2568 if (pThis->fUseHpet) 2569 2569 Log((" HPET 0x%08X", GCPhysHpet + addend)); 2570 if ( s->fUseMcfg)2570 if (pThis->fUseMcfg) 2571 2571 Log((" MCFG 0x%08X", GCPhysMcfg + addend)); 2572 2572 Log((" SSDT 0x%08X", GCPhysSsdt + addend)); 2573 2573 Log(("\n")); 2574 2574 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); 2580 2580 2581 2581 aGCPhysRsdt[0] = GCPhysFadtAcpi1 + addend; 2582 2582 aGCPhysXsdt[0] = GCPhysFadtAcpi2 + addend; 2583 if ( s->u8UseIOApic)2584 { 2585 acpiSetupMADT( s, GCPhysApic + addend);2583 if (pThis->u8UseIOApic) 2584 { 2585 acpiSetupMADT(pThis, GCPhysApic + addend); 2586 2586 aGCPhysRsdt[iMadt] = GCPhysApic + addend; 2587 2587 aGCPhysXsdt[iMadt] = GCPhysApic + addend; 2588 2588 } 2589 if ( s->fUseHpet)2590 { 2591 acpiSetupHPET( s, GCPhysHpet + addend);2589 if (pThis->fUseHpet) 2590 { 2591 acpiSetupHPET(pThis, GCPhysHpet + addend); 2592 2592 aGCPhysRsdt[iHpet] = GCPhysHpet + addend; 2593 2593 aGCPhysXsdt[iHpet] = GCPhysHpet + addend; 2594 2594 } 2595 if ( s->fUseMcfg)2596 { 2597 acpiSetupMCFG( s, GCPhysMcfg + addend);2595 if (pThis->fUseMcfg) 2596 { 2597 acpiSetupMCFG(pThis, GCPhysMcfg + addend); 2598 2598 aGCPhysRsdt[iMcfg] = GCPhysMcfg + addend; 2599 2599 aGCPhysXsdt[iMcfg] = GCPhysMcfg + addend; 2600 2600 } 2601 2601 2602 acpiSetupSSDT( s, GCPhysSsdt + addend, pvSsdtCode, cbSsdtSize);2603 acpiCleanupSsdt( s->pDevIns, pvSsdtCode);2602 acpiSetupSSDT(pThis, GCPhysSsdt + addend, pvSsdtCode, cbSsdtSize); 2603 acpiCleanupSsdt(pThis->pDevIns, pvSsdtCode); 2604 2604 aGCPhysRsdt[iSsdt] = GCPhysSsdt + addend; 2605 2605 aGCPhysXsdt[iSsdt] = GCPhysSsdt + addend; 2606 2606 2607 rc = acpiSetupRSDT( s, GCPhysRsdt + addend, cAddr, aGCPhysRsdt);2607 rc = acpiSetupRSDT(pThis, GCPhysRsdt + addend, cAddr, aGCPhysRsdt); 2608 2608 if (RT_FAILURE(rc)) 2609 2609 return rc; 2610 return acpiSetupXSDT( s, GCPhysXsdt + addend, cAddr, aGCPhysXsdt);2610 return acpiSetupXSDT(pThis, GCPhysXsdt + addend, cAddr, aGCPhysXsdt); 2611 2611 } 2612 2612 … … 2671 2671 static DECLCALLBACK(int) acpiAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 2672 2672 { 2673 ACPIState * s = PDMINS_2_DATA(pDevIns, ACPIState *);2673 ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *); 2674 2674 LogFlow(("acpiAttach: pDevIns=%p iLUN=%u fFlags=%#x\n", pDevIns, iLUN, fFlags)); 2675 2675 … … 2681 2681 /* Check if it was already attached */ 2682 2682 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)) 2685 2685 { 2686 2686 PPDMIBASE IBaseTmp; 2687 rc = PDMDevHlpDriverAttach(pDevIns, iLUN, & s->IBase, &IBaseTmp, "ACPI CPU");2687 rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThis->IBase, &IBaseTmp, "ACPI CPU"); 2688 2688 if (RT_SUCCESS(rc)) 2689 2689 { 2690 2690 /* Enable the CPU */ 2691 VMCPUSET_ADD(& s->CpuSetAttached, iLUN);2691 VMCPUSET_ADD(&pThis->CpuSetAttached, iLUN); 2692 2692 2693 2693 /* … … 2695 2695 * Prevents ejection while the CPU is still used 2696 2696 */ 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; 2700 2700 2701 2701 /* 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); 2703 2703 } 2704 2704 } 2705 DEVACPI_UNLOCK( s);2705 DEVACPI_UNLOCK(pThis); 2706 2706 return rc; 2707 2707 } … … 2716 2716 static DECLCALLBACK(void) acpiDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 2717 2717 { 2718 ACPIState * s = PDMINS_2_DATA(pDevIns, ACPIState *);2718 ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *); 2719 2719 2720 2720 LogFlow(("acpiDetach: pDevIns=%p iLUN=%u fFlags=%#x\n", pDevIns, iLUN, fFlags)); … … 2724 2724 2725 2725 /* 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)) 2730 2730 { 2731 2731 /* 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; 2735 2735 2736 2736 /* 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); 2738 2738 } 2739 2739 else 2740 2740 AssertMsgFailed(("CPU is still locked by the guest\n")); 2741 2741 } 2742 DEVACPI_UNLOCK( s);2742 DEVACPI_UNLOCK(pThis); 2743 2743 } 2744 2744 … … 2795 2795 static DECLCALLBACK(int) acpiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 2796 2796 { 2797 ACPIState *s = PDMINS_2_DATA(pDevIns, ACPIState *); 2798 PCIDevice *dev = &s->dev; 2797 ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *); 2799 2798 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 2800 2799 … … 2804 2803 /** @todo move more of the code up! */ 2805 2804 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). */ 2806 2826 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"); 2808 2828 AssertRCReturn(rc, rc); 2809 2829 … … 2843 2863 N_("Configuration error: Invalid config key for ACPI device")); 2844 2864 2845 s->pDevIns = pDevIns;2846 2847 2865 /* 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); 2849 2867 if (RT_FAILURE(rc)) 2850 2868 return PDMDEV_SET_ERROR(pDevIns, rc, 2851 2869 N_("Configuration error: Failed to read \"IOAPIC\"")); 2852 2870 2853 rc = CFGMR3QueryU16Def(pCfg, "NumCPUs", & s->cCpus, 1);2871 rc = CFGMR3QueryU16Def(pCfg, "NumCPUs", &pThis->cCpus, 1); 2854 2872 if (RT_FAILURE(rc)) 2855 2873 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2857 2875 2858 2876 /* 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); 2860 2878 if (RT_FAILURE(rc)) 2861 2879 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2863 2881 2864 2882 /* query whether we are supposed to present HPET */ 2865 rc = CFGMR3QueryBoolDef(pCfg, "HpetEnabled", & s->fUseHpet, false);2883 rc = CFGMR3QueryBoolDef(pCfg, "HpetEnabled", &pThis->fUseHpet, false); 2866 2884 if (RT_FAILURE(rc)) 2867 2885 return PDMDEV_SET_ERROR(pDevIns, rc, 2868 2886 N_("Configuration error: Failed to read \"HpetEnabled\"")); 2869 2887 /* query MCFG configuration */ 2870 rc = CFGMR3QueryU64Def(pCfg, "McfgBase", & s->u64PciConfigMMioAddress, 0);2888 rc = CFGMR3QueryU64Def(pCfg, "McfgBase", &pThis->u64PciConfigMMioAddress, 0); 2871 2889 if (RT_FAILURE(rc)) 2872 2890 return PDMDEV_SET_ERROR(pDevIns, rc, 2873 2891 N_("Configuration error: Failed to read \"McfgBase\"")); 2874 rc = CFGMR3QueryU64Def(pCfg, "McfgLength", & s->u64PciConfigMMioLength, 0);2892 rc = CFGMR3QueryU64Def(pCfg, "McfgLength", &pThis->u64PciConfigMMioLength, 0); 2875 2893 if (RT_FAILURE(rc)) 2876 2894 return PDMDEV_SET_ERROR(pDevIns, rc, 2877 2895 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); 2879 2897 2880 2898 /* query whether we are supposed to present SMC */ 2881 rc = CFGMR3QueryBoolDef(pCfg, "SmcEnabled", & s->fUseSmc, false);2899 rc = CFGMR3QueryBoolDef(pCfg, "SmcEnabled", &pThis->fUseSmc, false); 2882 2900 if (RT_FAILURE(rc)) 2883 2901 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2885 2903 2886 2904 /* 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); 2888 2906 if (RT_FAILURE(rc)) 2889 2907 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2891 2909 2892 2910 /* 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); 2894 2912 if (RT_FAILURE(rc)) 2895 2913 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2897 2915 2898 2916 /* query primary NIC PCI address */ 2899 rc = CFGMR3QueryU32Def(pCfg, "NicPciAddress", & s->u32NicPciAddress, 0);2917 rc = CFGMR3QueryU32Def(pCfg, "NicPciAddress", &pThis->u32NicPciAddress, 0); 2900 2918 if (RT_FAILURE(rc)) 2901 2919 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2903 2921 2904 2922 /* query primary NIC PCI address */ 2905 rc = CFGMR3QueryU32Def(pCfg, "AudioPciAddress", & s->u32AudioPciAddress, 0);2923 rc = CFGMR3QueryU32Def(pCfg, "AudioPciAddress", &pThis->u32AudioPciAddress, 0); 2906 2924 if (RT_FAILURE(rc)) 2907 2925 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2909 2927 2910 2928 /* query IO controller (southbridge) PCI address */ 2911 rc = CFGMR3QueryU32Def(pCfg, "IocPciAddress", & s->u32IocPciAddress, 0);2929 rc = CFGMR3QueryU32Def(pCfg, "IocPciAddress", &pThis->u32IocPciAddress, 0); 2912 2930 if (RT_FAILURE(rc)) 2913 2931 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2915 2933 2916 2934 /* query host bus controller PCI address */ 2917 rc = CFGMR3QueryU32Def(pCfg, "HostBusPciAddress", & s->u32HbcPciAddress, 0);2935 rc = CFGMR3QueryU32Def(pCfg, "HostBusPciAddress", &pThis->u32HbcPciAddress, 0); 2918 2936 if (RT_FAILURE(rc)) 2919 2937 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2921 2939 2922 2940 /* query whether S1 power state should be exposed */ 2923 rc = CFGMR3QueryBoolDef(pCfg, "PowerS1Enabled", & s->fS1Enabled, false);2941 rc = CFGMR3QueryBoolDef(pCfg, "PowerS1Enabled", &pThis->fS1Enabled, false); 2924 2942 if (RT_FAILURE(rc)) 2925 2943 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2927 2945 2928 2946 /* query whether S4 power state should be exposed */ 2929 rc = CFGMR3QueryBoolDef(pCfg, "PowerS4Enabled", & s->fS4Enabled, false);2947 rc = CFGMR3QueryBoolDef(pCfg, "PowerS4Enabled", &pThis->fS4Enabled, false); 2930 2948 if (RT_FAILURE(rc)) 2931 2949 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2933 2951 2934 2952 /* 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); 2936 2954 if (RT_FAILURE(rc)) 2937 2955 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2939 2957 2940 2958 /* query whether we are allow CPU hot plugging */ 2941 rc = CFGMR3QueryBoolDef(pCfg, "CpuHotPlug", & s->fCpuHotPlug, false);2959 rc = CFGMR3QueryBoolDef(pCfg, "CpuHotPlug", &pThis->fCpuHotPlug, false); 2942 2960 if (RT_FAILURE(rc)) 2943 2961 return PDMDEV_SET_ERROR(pDevIns, rc, 2944 2962 N_("Configuration error: Failed to read \"CpuHotPlug\"")); 2945 2963 2946 rc = CFGMR3QueryBool(pCfg, "GCEnabled", & s->fGCEnabled);2964 rc = CFGMR3QueryBool(pCfg, "GCEnabled", &pThis->fGCEnabled); 2947 2965 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 2948 s->fGCEnabled = true;2966 pThis->fGCEnabled = true; 2949 2967 else if (RT_FAILURE(rc)) 2950 2968 return PDMDEV_SET_ERROR(pDevIns, rc, 2951 2969 N_("Configuration error: Failed to read \"GCEnabled\"")); 2952 2970 2953 rc = CFGMR3QueryBool(pCfg, "R0Enabled", & s->fR0Enabled);2971 rc = CFGMR3QueryBool(pCfg, "R0Enabled", &pThis->fR0Enabled); 2954 2972 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 2955 s->fR0Enabled = true;2973 pThis->fR0Enabled = true; 2956 2974 else if (RT_FAILURE(rc)) 2957 2975 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2959 2977 2960 2978 /* query serial info */ 2961 rc = CFGMR3QueryU8Def(pCfg, "Serial0Irq", & s->uSerial0Irq, 4);2979 rc = CFGMR3QueryU8Def(pCfg, "Serial0Irq", &pThis->uSerial0Irq, 4); 2962 2980 if (RT_FAILURE(rc)) 2963 2981 return PDMDEV_SET_ERROR(pDevIns, rc, 2964 2982 N_("Configuration error: Failed to read \"Serial0Irq\"")); 2965 2983 2966 rc = CFGMR3QueryU16Def(pCfg, "Serial0IoPortBase", & s->uSerial0IoPortBase, 0x3f8);2984 rc = CFGMR3QueryU16Def(pCfg, "Serial0IoPortBase", &pThis->uSerial0IoPortBase, 0x3f8); 2967 2985 if (RT_FAILURE(rc)) 2968 2986 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2970 2988 2971 2989 /* Serial 1 is enabled, get config data */ 2972 rc = CFGMR3QueryU8Def(pCfg, "Serial1Irq", & s->uSerial1Irq, 3);2990 rc = CFGMR3QueryU8Def(pCfg, "Serial1Irq", &pThis->uSerial1Irq, 3); 2973 2991 if (RT_FAILURE(rc)) 2974 2992 return PDMDEV_SET_ERROR(pDevIns, rc, 2975 2993 N_("Configuration error: Failed to read \"Serial1Irq\"")); 2976 2994 2977 rc = CFGMR3QueryU16Def(pCfg, "Serial1IoPortBase", & s->uSerial1IoPortBase, 0x2f8);2995 rc = CFGMR3QueryU16Def(pCfg, "Serial1IoPortBase", &pThis->uSerial1IoPortBase, 0x2f8); 2978 2996 if (RT_FAILURE(rc)) 2979 2997 return PDMDEV_SET_ERROR(pDevIns, rc, 2980 2998 N_("Configuration error: Failed to read \"Serial1IoPortBase\"")); 2981 2999 2982 /*2983 * Interfaces2984 */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 3004 3000 /* 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) 3008 3004 { 3009 3005 PPDMIBASE IBaseTmp; 3010 rc = PDMDevHlpDriverAttach(pDevIns, i, & s->IBase, &IBaseTmp, "ACPI CPU");3006 rc = PDMDevHlpDriverAttach(pDevIns, i, &pThis->IBase, &IBaseTmp, "ACPI CPU"); 3011 3007 3012 3008 if (RT_SUCCESS(rc)) 3013 3009 { 3014 VMCPUSET_ADD(& s->CpuSetAttached, i);3015 VMCPUSET_ADD(& s->CpuSetLocked, i);3010 VMCPUSET_ADD(&pThis->CpuSetAttached, i); 3011 VMCPUSET_ADD(&pThis->CpuSetLocked, i); 3016 3012 Log(("acpi: Attached CPU %u\n", i)); 3017 3013 } … … 3024 3020 { 3025 3021 /* 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); 3028 3024 } 3029 3025 } … … 3031 3027 3032 3028 /* Set default port base */ 3033 s->uPmIoPortBase = PM_PORT_BASE;3029 pThis->uPmIoPortBase = PM_PORT_BASE; 3034 3030 3035 3031 /* … … 3037 3033 * enable only one device. 3038 3034 */ 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 */ 3043 3041 RTGCPHYS32 GCPhysRsdp = find_rsdp_space(); 3044 3042 if (!GCPhysRsdp) … … 3046 3044 N_("Can not find space for RSDP. ACPI is disabled")); 3047 3045 3048 rc = acpiPlantTables( s);3046 rc = acpiPlantTables(pThis); 3049 3047 if (RT_FAILURE(rc)) 3050 3048 return rc; 3051 3049 3052 rc = PDMDevHlpROMRegister(pDevIns, GCPhysRsdp, 0x1000, s->au8RSDPPage, 0x1000,3050 rc = PDMDevHlpROMRegister(pDevIns, GCPhysRsdp, 0x1000, pThis->au8RSDPPage, 0x1000, 3053 3051 PGMPHYS_ROM_FLAGS_PERMANENT_BINARY, "ACPI RSDP"); 3054 3052 if (RT_FAILURE(rc)) 3055 3053 return rc; 3056 3054 3057 rc = acpiRegisterPmHandlers(s); 3055 /* 3056 * Register I/O ports. 3057 */ 3058 rc = acpiRegisterPmHandlers(pThis); 3058 3059 if (RT_FAILURE(rc)) 3059 3060 return rc; … … 3061 3062 #define R(addr, cnt, writer, reader, description) \ 3062 3063 do { \ 3063 rc = PDMDevHlpIOPortRegister(pDevIns, addr, cnt, s, writer, reader, \3064 rc = PDMDevHlpIOPortRegister(pDevIns, addr, cnt, pThis, writer, reader, \ 3064 3065 NULL, NULL, description); \ 3065 3066 if (RT_FAILURE(rc)) \ … … 3078 3079 #undef R 3079 3080 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); 3082 3086 if (RT_FAILURE(rc)) 3083 3087 { … … 3086 3090 } 3087 3091 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 */ 3095 3102 3096 3103 /* 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 */ 3114 3121 3115 3122 #if 0 … … 3119 3126 #endif 3120 3127 3121 rc = PDMDevHlpPCIRegister(pDevIns, dev);3128 rc = PDMDevHlpPCIRegister(pDevIns, &pThis->dev); 3122 3129 if (RT_FAILURE(rc)) 3123 3130 return rc; 3124 3131 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); 3130 3140 if (RT_FAILURE(rc)) 3131 3141 return rc; … … 3134 3144 * Get the corresponding connector interface 3135 3145 */ 3136 rc = PDMDevHlpDriverAttach(pDevIns, 0, & s->IBase, &s->pDrvBase, "ACPI Driver Port");3146 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "ACPI Driver Port"); 3137 3147 if (RT_SUCCESS(rc)) 3138 3148 { 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) 3141 3151 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_MISSING_INTERFACE, 3142 3152 N_("LUN #0 doesn't have an ACPI connector interface"));
Note:
See TracChangeset
for help on using the changeset viewer.