Changeset 25817 in vbox
- Timestamp:
- Jan 13, 2010 10:08:17 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pdmifs.h
r25728 r25817 1738 1738 */ 1739 1739 DECLR3CALLBACKMEMBER(int, pfnGetGuestEnteredACPIMode,(PPDMIACPIPORT pInterface, bool *pfEntered)); 1740 1741 /** 1742 * Check if the given CPU is still locked by the guest. 1743 * 1744 * @returns VBox status code 1745 * @param pInterface Pointer to the interface structure containing the called function pointer. 1746 * @param uCpu The CPU to check for. 1747 * @param pfLocked Is set to true if the CPU is still locked by the guest, false otherwise. 1748 */ 1749 DECLR3CALLBACKMEMBER(int, pfnGetCpuStatus,(PPDMIACPIPORT pInterface, unsigned uCpu, bool *pfLocked)); 1740 1750 } PDMIACPIPORT; 1741 1751 -
trunk/src/VBox/Devices/Builtins.cpp
r22876 r25817 250 250 if (RT_FAILURE(rc)) 251 251 return rc; 252 rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvAcpiCpu); 253 if (RT_FAILURE(rc)) 254 return rc; 252 255 253 256 #ifdef VBOX_WITH_USB -
trunk/src/VBox/Devices/Builtins.h
r22866 r25817 112 112 extern const PDMDRVREG g_DrvAUDIO; 113 113 extern const PDMDRVREG g_DrvACPI; 114 extern const PDMDRVREG g_DrvAcpiCpu; 114 115 extern const PDMDRVREG g_DrvVUSBRootHub; 115 116 extern const PDMDRVREG g_DrvChar; -
trunk/src/VBox/Devices/Makefile.kmk
r25770 r25817 471 471 vboxaml.hex:: $$(PATH_DevicesR3)/vboxaml.hex 472 472 473 # CPU hotplug version 474 DevicesR3_CLEAN += $(PATH_DevicesR3)/vboxaml-cpuhotplug.hex $(PATH_DevicesR3)/vboxaml-cpuhotplug.hex.tmp $(PATH_DevicesR3)/vboxaml-cpuhotplug.aml 475 PC/ACPI/VBoxAcpi.cpp_DEPS = $(PATH_DevicesR3)/vboxaml-cpuhotplug.hex 476 477 $$(PATH_DevicesR3)/vboxaml-cpuhotplug.hex: $(PATH_SUB_CURRENT)/PC/vbox-cpuhotplug.dsl | $$(dir $$@) 478 $(call MSG_TOOL,iasl,DevicesR3,$<,$@) 479 $(QUIET)$(VBOX_IASLCMD) -tc -vs -p $@ $< 480 $(QUIET)$(MV) $@ [email protected] 481 $(QUIET)$(SED) -e 's/AmlCode/AmlCodeCpuHotplug/' \ 482 --output $@ [email protected] 483 484 vboxaml-cpuhotplug.hex:: $$(PATH_DevicesR3)/vboxaml-cpuhotplug.hex 485 473 486 endif # !VBOX_WITH_DYNAMIC_DSDT 474 487 PC/ACPI/VBoxAcpi.cpp_INCS = $(PATH_DevicesR3) … … 746 759 Network/DrvIntNet.cpp \ 747 760 PC/DrvACPI.cpp \ 761 PC/DrvAcpiCpu.cpp \ 748 762 Serial/DrvChar.cpp \ 749 763 Serial/DrvNamedPipe.cpp \ -
trunk/src/VBox/Devices/PC/ACPI/VBoxAcpi.cpp
r20920 r25817 29 29 #include <VBox/log.h> 30 30 #include <VBox/param.h> 31 #include <VBox/cfgm.h> 31 32 #include <iprt/assert.h> 32 33 #include <iprt/alloc.h> … … 39 40 /* Statically compiled AML */ 40 41 # include <vboxaml.hex> 42 # include <vboxaml-cpuhotplug.hex> 41 43 #endif 42 44 … … 140 142 return prepareDynamicDsdt(pDevIns, ppPtr, puDsdtLen); 141 143 #else 142 patchAml(pDevIns, AmlCode, sizeof(AmlCode)); 143 *ppPtr = AmlCode; 144 *puDsdtLen = sizeof(AmlCode); 144 unsigned char *pbAmlCode = NULL; 145 size_t cbAmlCode = 0; 146 bool fCpuHotplug = false; 147 int rc = CFGMR3QueryBoolDef(pDevIns->pCfgHandle, "CpuHotplug", &fCpuHotplug, false); 148 if (RT_FAILURE(rc)) 149 return PDMDEV_SET_ERROR(pDevIns, rc, 150 N_("Configuration error: Failed to read \"CpuHotplug\"")); 151 152 if (fCpuHotplug) 153 { 154 pbAmlCode = AmlCodeCpuHotplug; 155 cbAmlCode = sizeof(AmlCodeCpuHotplug); 156 } 157 else 158 { 159 pbAmlCode = AmlCode; 160 cbAmlCode = sizeof(AmlCode); 161 } 162 163 patchAml(pDevIns, pbAmlCode, cbAmlCode); 164 *ppPtr = pbAmlCode; 165 *puDsdtLen = cbAmlCode; 145 166 return 0; 146 167 #endif -
trunk/src/VBox/Devices/PC/DevACPI.cpp
r25226 r25817 149 149 SYSTEM_INFO_INDEX_HIGH_MEMORY_LENGTH= 9, 150 150 SYSTEM_INFO_INDEX_RTC_STATUS = 10, 151 SYSTEM_INFO_INDEX_END = 11, 151 SYSTEM_INFO_INDEX_CPU_LOCKED = 11, 152 SYSTEM_INFO_INDEX_MADT_ADDR = 12, 153 SYSTEM_INFO_INDEX_MADT_SIZE = 13, 154 SYSTEM_INFO_INDEX_END = 14, 152 155 SYSTEM_INFO_INDEX_INVALID = 0x80, 153 156 SYSTEM_INFO_INDEX_VALID = 0x200 … … 230 233 /** Flag whether the R0 part of the device is enabled. */ 231 234 bool fR0Enabled; 235 /** Physical base address of the MADT table. */ 236 RTGCPHYS32 GCPhysMADTBase; 237 /** Size of the MADT table */ 238 uint32_t cbMADT; 239 /** Array of flags of attached CPUs */ 240 bool afCpuAttached[32]; /* Maximum we support atm */ 241 /** Mask of locked CPUs (used by the guest) */ 242 uint32_t uCpusLocked; 243 /** Flag whether CPU hotplugging is enabled */ 244 bool fCpuHotplug; 232 245 /** Aligning IBase. */ 233 246 bool afAlignment[4]; … … 716 729 | FADT_FL_FIX_RTC 717 730 | FADT_FL_TMR_VAL_EXT); 731 732 /* We have to force physical APIC mode or Linux can't use more than 8 CPUs */ 733 if (s->fCpuHotplug) 734 fadt.u32Flags |= RT_H2LE_U32(FADT_FL_FORCE_APIC_PHYS_DEST_MODE); 735 718 736 acpiWriteGenericAddr(&fadt.ResetReg, 1, 8, 0, 1, ACPI_RESET_BLK); 719 737 fadt.u8ResetVal = ACPI_RESET_REG_VAL; … … 829 847 lapic->u8ProcId = i; 830 848 lapic->u8ApicId = i; 831 lapic->u32Flags = RT_H2LE_U32(LAPIC_ENABLED);849 lapic->u32Flags = s->afCpuAttached[i] ? RT_H2LE_U32(LAPIC_ENABLED) : 0; 832 850 lapic++; 833 851 } … … 845 863 madt.header_addr()->u8Checksum = acpiChecksum(madt.data(), madt.size()); 846 864 acpiPhyscpy(s, addr, madt.data(), madt.size()); 865 866 /* Save for attach/detach notifications. */ 867 s->GCPhysMADTBase = addr; 868 s->cbMADT = madt.size(); 847 869 } 848 870 … … 958 980 ACPIState *s = IACPIPORT_2_ACPISTATE(pInterface); 959 981 *pfEntered = (s->pm1a_ctl & SCI_EN) != 0; 982 return VINF_SUCCESS; 983 } 984 985 static DECLCALLBACK(int) acpiGetCpuStatus(PPDMIACPIPORT pInterface, unsigned uCpu, bool *pfLocked) 986 { 987 ACPIState *s = IACPIPORT_2_ACPISTATE(pInterface); 988 *pfLocked = (s->uCpusLocked & RT_BIT(uCpu)) != 0; 960 989 return VINF_SUCCESS; 961 990 } … … 1377 1406 *pu32 = s->fShowCpu 1378 1407 && s->uSystemInfoIndex - SYSTEM_INFO_INDEX_CPU0_STATUS < s->cCpus 1408 && s->afCpuAttached[s->uSystemInfoIndex - SYSTEM_INFO_INDEX_CPU0_STATUS] 1379 1409 ? 1380 1410 STA_DEVICE_PRESENT_MASK … … 1392 1422 break; 1393 1423 1424 case SYSTEM_INFO_INDEX_CPU_LOCKED: 1425 { 1426 *pu32 = s->uCpusLocked; 1427 break; 1428 } 1429 1430 case SYSTEM_INFO_INDEX_MADT_ADDR: 1431 { 1432 *pu32 = s->GCPhysMADTBase; 1433 break; 1434 } 1435 1436 case SYSTEM_INFO_INDEX_MADT_SIZE: 1437 { 1438 *pu32 = s->cbMADT; 1439 break; 1440 } 1441 1394 1442 /* Solaris 9 tries to read from this index */ 1395 1443 case SYSTEM_INFO_INDEX_INVALID: … … 1417 1465 Log(("addr=%#x cb=%d u32=%#x si=%#x\n", Port, cb, u32, s->uSystemInfoIndex)); 1418 1466 1419 if (cb == 4 && u32 == 0xbadc0de)1467 if (cb == 4) 1420 1468 { 1421 1469 switch (s->uSystemInfoIndex) 1422 1470 { 1423 1471 case SYSTEM_INFO_INDEX_INVALID: 1472 AssertMsg(u32 == 0xbadc0de, ("u32=%u\n", u32)); 1424 1473 s->u8IndexShift = 0; 1425 1474 break; 1426 1475 1427 1476 case SYSTEM_INFO_INDEX_VALID: 1477 AssertMsg(u32 == 0xbadc0de, ("u32=%u\n", u32)); 1428 1478 s->u8IndexShift = 2; 1479 break; 1480 1481 case SYSTEM_INFO_INDEX_CPU_LOCKED: 1482 s->uCpusLocked &= ~u32; /* Unlock the CPU */ 1429 1483 break; 1430 1484 … … 2009 2063 } 2010 2064 2065 /** 2066 * Attach a new CPU. 2067 * 2068 * @returns VBox status code. 2069 * @param pDevIns The device instance. 2070 * @param iLUN The logical unit which is being attached. 2071 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 2072 * 2073 * @remarks This code path is not used during construction. 2074 */ 2075 static DECLCALLBACK(int) acpiAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 2076 { 2077 ACPIState *s = PDMINS_2_DATA(pDevIns, ACPIState *); 2078 2079 LogFlow(("acpiAttach: pDevIns=%p iLUN=%u fFlags=%#x\n", pDevIns, iLUN, fFlags)); 2080 2081 /* Check if it was already attached */ 2082 if (s->afCpuAttached[iLUN]) 2083 return VINF_SUCCESS; 2084 2085 PPDMIBASE IBaseTmp; 2086 int rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &s->IBase, &IBaseTmp, "ACPI CPU"); 2087 2088 if (RT_SUCCESS(rc)) 2089 { 2090 /* Enable the CPU */ 2091 s->afCpuAttached[iLUN] = true; 2092 2093 /* Enable the lapic */ 2094 acpiSetupMADT(s, s->GCPhysMADTBase); 2095 /* 2096 * Lock the CPU because we don't know if the guest will use it or not. 2097 * Prevents ejection while the CPU is still used 2098 */ 2099 s->uCpusLocked |= RT_BIT(iLUN); 2100 2101 /* Notify the guest */ 2102 update_gpe0(s, s->gpe0_sts | 0x2, s->gpe0_en); 2103 } 2104 return rc; 2105 } 2106 2107 /** 2108 * Detach notification. 2109 * 2110 * @param pDevIns The device instance. 2111 * @param iLUN The logical unit which is being detached. 2112 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 2113 */ 2114 static DECLCALLBACK(void) acpiDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 2115 { 2116 ACPIState *s = PDMINS_2_DATA(pDevIns, ACPIState *); 2117 2118 LogFlow(("acpiDetach: pDevIns=%p iLUN=%u fFlags=%#x\n", pDevIns, iLUN, fFlags)); 2119 2120 /* Check if it was already detached */ 2121 if (s->afCpuAttached[iLUN]) 2122 { 2123 /* Disable the CPU */ 2124 s->afCpuAttached[iLUN] = false; 2125 2126 AssertMsg(!(s->uCpusLocked & RT_BIT(iLUN)), ("CPU is still locked by the guest\n")); 2127 2128 /* Update the lapic state */ 2129 acpiSetupMADT(s, s->GCPhysMADTBase); 2130 2131 /* Notify the guest */ 2132 update_gpe0(s, s->gpe0_sts | 0x2, s->gpe0_en); 2133 } 2134 } 2135 2011 2136 static DECLCALLBACK(void) acpiReset(PPDMDEVINS pDevIns) 2012 2137 { … … 2070 2195 "ShowRtc\0" 2071 2196 "ShowCpu\0" 2197 "CpuHotplug\0" 2072 2198 )) 2073 2199 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, … … 2116 2242 N_("Configuration error: Failed to read \"ShowCpu\"")); 2117 2243 2244 /* query whether we are allow CPU hotplugging */ 2245 rc = CFGMR3QueryBoolDef(pCfgHandle, "CpuHotplug", &s->fCpuHotplug, false); 2246 if (RT_FAILURE(rc)) 2247 return PDMDEV_SET_ERROR(pDevIns, rc, 2248 N_("Configuration error: Failed to read \"CpuHotplug\"")); 2249 2118 2250 rc = CFGMR3QueryBool(pCfgHandle, "GCEnabled", &s->fGCEnabled); 2119 2251 if (rc == VERR_CFGM_VALUE_NOT_FOUND) … … 2129 2261 return PDMDEV_SET_ERROR(pDevIns, rc, 2130 2262 N_("configuration error: failed to read R0Enabled as boolean")); 2263 2264 /* 2265 * Interfaces 2266 */ 2267 /* IBase */ 2268 s->IBase.pfnQueryInterface = acpiQueryInterface; 2269 /* IACPIPort */ 2270 s->IACPIPort.pfnSleepButtonPress = acpiSleepButtonPress; 2271 s->IACPIPort.pfnPowerButtonPress = acpiPowerButtonPress; 2272 s->IACPIPort.pfnGetPowerButtonHandled = acpiGetPowerButtonHandled; 2273 s->IACPIPort.pfnGetGuestEnteredACPIMode = acpiGetGuestEnteredACPIMode; 2274 s->IACPIPort.pfnGetCpuStatus = acpiGetCpuStatus; 2275 2276 /* The first CPU can't be attached/detached */ 2277 s->afCpuAttached[0] = true; 2278 s->uCpusLocked |= RT_BIT(0); 2279 2280 /* Try to attach the other CPUs */ 2281 for (unsigned i = 1; i < s->cCpus; i++) 2282 { 2283 PPDMIBASE IBaseTmp; 2284 rc = PDMDevHlpDriverAttach(pDevIns, i, &s->IBase, &IBaseTmp, "ACPI CPU"); 2285 2286 if (RT_SUCCESS(rc)) 2287 { 2288 s->afCpuAttached[i] = true; 2289 s->uCpusLocked |= RT_BIT(i); 2290 Log(("acpi: Attached CPU %u\n", i)); 2291 } 2292 else if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 2293 { 2294 Log(("acpi: CPU %u not attached yet\n", i)); 2295 s->afCpuAttached[i] = false; 2296 } 2297 else 2298 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to attach CPU object\n")); 2299 } 2300 2131 2301 2132 2302 /* Set default port base */ … … 2223 2393 if (RT_FAILURE(rc)) 2224 2394 return rc; 2225 2226 /*2227 * Interfaces2228 */2229 /* IBase */2230 s->IBase.pfnQueryInterface = acpiQueryInterface;2231 /* IACPIPort */2232 s->IACPIPort.pfnSleepButtonPress = acpiSleepButtonPress;2233 s->IACPIPort.pfnPowerButtonPress = acpiPowerButtonPress;2234 s->IACPIPort.pfnGetPowerButtonHandled = acpiGetPowerButtonHandled;2235 s->IACPIPort.pfnGetGuestEnteredACPIMode = acpiGetGuestEnteredACPIMode;2236 2395 2237 2396 /* … … 2298 2457 NULL, 2299 2458 /* pfnAttach */ 2300 NULL,2459 acpiAttach, 2301 2460 /* pfnDetach */ 2302 NULL,2461 acpiDetach, 2303 2462 /* pfnQueryInterface. */ 2304 2463 NULL, -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp
r25675 r25817 465 465 GEN_CHECK_OFF(ACPIState, fUseHpet); 466 466 GEN_CHECK_OFF(ACPIState, fUseSmc); 467 GEN_CHECK_OFF(ACPIState, GCPhysMADTBase); 468 GEN_CHECK_OFF(ACPIState, afCpuAttached); 469 GEN_CHECK_OFF(ACPIState, uCpusLocked); 470 GEN_CHECK_OFF(ACPIState, fCpuHotplug); 467 471 GEN_CHECK_OFF(ACPIState, IBase); 468 472 GEN_CHECK_OFF(ACPIState, IACPIPort);
Note:
See TracChangeset
for help on using the changeset viewer.