Changeset 26095 in vbox for trunk/src/VBox/Devices/PC/ACPI
- Timestamp:
- Jan 29, 2010 10:27:05 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/ACPI/VBoxAcpi.cpp
r25838 r26095 42 42 /* Statically compiled AML */ 43 43 # include <vboxaml.hex> 44 # include <vboxssdt-standard.hex> 45 # include <vboxssdt-cpuhotplug.hex> 44 46 #endif 45 47 … … 137 139 #endif 138 140 139 /* Two only public functions */ 140 int acpiPrepareDsdt(PPDMDEVINS pDevIns, void * *ppPtr, size_t *puDsdtLen) 141 { 142 #ifdef VBOX_WITH_DYNAMIC_DSDT 143 return prepareDynamicDsdt(pDevIns, ppPtr, puDsdtLen); 144 #else 141 /** 142 * Loads an AML file if present in CFGM 143 * 144 * @returns VBox status code 145 * @param pDevIns The device instance 146 * @param pcszCfgName The configuration key holding the file path 147 * @param pcszSignature The signature to check for 148 * @param ppbAmlCode Where to store the pointer to the AML code on success. 149 * @param pcbAmlCode Where to store the number of bytes of the AML code on success. 150 */ 151 static int acpiAmlLoadExternal(PPDMDEVINS pDevIns, const char *pcszCfgName, const char *pcszSignature, uint8_t **ppbAmlCode, size_t *pcbAmlCode) 152 { 145 153 uint8_t *pbAmlCode = NULL; 146 154 size_t cbAmlCode = 0; 147 155 char *pszAmlFilePath = NULL; 148 int rc = CFGMR3QueryStringAlloc(pDevIns->pCfgHandle, "AmlFilePath", &pszAmlFilePath); 156 int rc = CFGMR3QueryStringAlloc(pDevIns->pCfgHandle, pcszCfgName, &pszAmlFilePath); 157 149 158 if (RT_SUCCESS(rc)) 150 159 { … … 178 187 */ 179 188 if ( RT_FAILURE(rc) 180 || strncmp((const char *)pbAmlCode, "DSDT", 4))189 || strncmp((const char *)pbAmlCode, pcszSignature, 4)) 181 190 { 182 191 RTMemFree(pbAmlCode); … … 186 195 if (RT_SUCCESS(rc)) 187 196 rc = VERR_PARSE_ERROR; 197 } 198 else 199 { 200 *ppbAmlCode = pbAmlCode; 201 *pcbAmlCode = cbAmlCode; 202 rc = VINF_SUCCESS; 188 203 } 189 204 } … … 196 211 MMR3HeapFree(pszAmlFilePath); 197 212 } 198 else if (rc == VERR_CFGM_VALUE_NOT_FOUND) 213 214 return rc; 215 } 216 217 /* Two only public functions */ 218 int acpiPrepareDsdt(PPDMDEVINS pDevIns, void * *ppPtr, size_t *puDsdtLen) 219 { 220 #ifdef VBOX_WITH_DYNAMIC_DSDT 221 return prepareDynamicDsdt(pDevIns, ppPtr, puDsdtLen); 222 #else 223 uint8_t *pbAmlCodeDsdt = NULL; 224 size_t cbAmlCodeDsdt = 0; 225 int rc = acpiAmlLoadExternal(pDevIns, "DsdtFilePath", "DSDT", &pbAmlCodeDsdt, &cbAmlCodeDsdt); 226 227 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 199 228 { 200 229 rc = VINF_SUCCESS; 201 230 202 231 /* Use the compiled in AML code */ 203 cbAmlCode = sizeof(AmlCode);204 pbAmlCode = (uint8_t *)RTMemAllocZ(cbAmlCode);205 if (pbAmlCode )206 memcpy(pbAmlCode , AmlCode, cbAmlCode);232 cbAmlCodeDsdt = sizeof(AmlCode); 233 pbAmlCodeDsdt = (uint8_t *)RTMemAllocZ(cbAmlCodeDsdt); 234 if (pbAmlCodeDsdt) 235 memcpy(pbAmlCodeDsdt, AmlCode, cbAmlCodeDsdt); 207 236 else 208 237 rc = VERR_NO_MEMORY; … … 210 239 else if (RT_FAILURE(rc)) 211 240 return PDMDEV_SET_ERROR(pDevIns, rc, 212 N_("Configuration error: Failed to read \" AmlFilePath\""));241 N_("Configuration error: Failed to read \"DsdtFilePath\"")); 213 242 214 243 if (RT_SUCCESS(rc)) 215 244 { 216 patchAml(pDevIns, pbAmlCode , cbAmlCode);217 *ppPtr = pbAmlCode ;218 *puDsdtLen = cbAmlCode ;245 patchAml(pDevIns, pbAmlCodeDsdt, cbAmlCodeDsdt); 246 *ppPtr = pbAmlCodeDsdt; 247 *puDsdtLen = cbAmlCodeDsdt; 219 248 } 220 249 return rc; … … 233 262 } 234 263 264 int acpiPrepareSsdt(PPDMDEVINS pDevIns, void* *ppPtr, size_t *puSsdtLen) 265 { 266 uint8_t *pbAmlCodeSsdt = NULL; 267 size_t cbAmlCodeSsdt = 0; 268 int rc = acpiAmlLoadExternal(pDevIns, "SsdtFilePath", "SSDT", &pbAmlCodeSsdt, &cbAmlCodeSsdt); 269 270 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 271 { 272 bool fCpuHotPlug = false; 273 uint8_t *pbAmlCode = NULL; 274 rc = CFGMR3QueryBoolDef(pDevIns->pCfgHandle, "CpuHotPlug", &fCpuHotPlug, false); 275 276 if (RT_FAILURE(rc)) 277 return rc; 278 279 if (fCpuHotPlug) 280 { 281 pbAmlCode = AmlCodeSsdtCpuHotPlug; 282 cbAmlCodeSsdt = sizeof(AmlCodeSsdtCpuHotPlug); 283 } 284 else 285 { 286 pbAmlCode = AmlCodeSsdtStandard; 287 cbAmlCodeSsdt = sizeof(AmlCodeSsdtStandard); 288 } 289 290 pbAmlCodeSsdt = (uint8_t *)RTMemAllocZ(cbAmlCodeSsdt); 291 if (pbAmlCodeSsdt) 292 memcpy(pbAmlCodeSsdt, pbAmlCode, cbAmlCodeSsdt); 293 else 294 rc = VERR_NO_MEMORY; 295 } 296 else if (RT_FAILURE(rc)) 297 return PDMDEV_SET_ERROR(pDevIns, rc, 298 N_("Configuration error: Failed to read \"SsdtFilePath\"")); 299 300 if (RT_SUCCESS(rc)) 301 { 302 patchAml(pDevIns, pbAmlCodeSsdt, cbAmlCodeSsdt); 303 *ppPtr = pbAmlCodeSsdt; 304 *puSsdtLen = cbAmlCodeSsdt; 305 } 306 307 return VINF_SUCCESS; 308 } 309 310 int acpiCleanupSsdt(PPDMDEVINS pDevIns, void* pPtr) 311 { 312 if (pPtr) 313 RTMemFree(pPtr); 314 return VINF_SUCCESS; 315 } 316
Note:
See TracChangeset
for help on using the changeset viewer.