Changeset 26115 in vbox for trunk/src/VBox/Devices/PC/ACPI
- Timestamp:
- Feb 1, 2010 11:19:57 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57104
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/ACPI/VBoxAcpi.cpp
r26095 r26115 42 42 /* Statically compiled AML */ 43 43 # include <vboxaml.hex> 44 # include <vboxssdt-standard.hex>45 # include <vboxssdt-cpuhotplug.hex>46 44 #endif 47 45 … … 139 137 #endif 140 138 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 { 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 153 145 uint8_t *pbAmlCode = NULL; 154 146 size_t cbAmlCode = 0; 155 147 char *pszAmlFilePath = NULL; 156 int rc = CFGMR3QueryStringAlloc(pDevIns->pCfgHandle, pcszCfgName, &pszAmlFilePath); 157 148 int rc = CFGMR3QueryStringAlloc(pDevIns->pCfgHandle, "AmlFilePath", &pszAmlFilePath); 158 149 if (RT_SUCCESS(rc)) 159 150 { … … 187 178 */ 188 179 if ( RT_FAILURE(rc) 189 || strncmp((const char *)pbAmlCode, pcszSignature, 4))180 || strncmp((const char *)pbAmlCode, "DSDT", 4)) 190 181 { 191 182 RTMemFree(pbAmlCode); … … 195 186 if (RT_SUCCESS(rc)) 196 187 rc = VERR_PARSE_ERROR; 197 }198 else199 {200 *ppbAmlCode = pbAmlCode;201 *pcbAmlCode = cbAmlCode;202 rc = VINF_SUCCESS;203 188 } 204 189 } … … 211 196 MMR3HeapFree(pszAmlFilePath); 212 197 } 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) 198 else if (rc == VERR_CFGM_VALUE_NOT_FOUND) 228 199 { 229 200 rc = VINF_SUCCESS; 230 201 231 202 /* Use the compiled in AML code */ 232 cbAmlCode Dsdt= sizeof(AmlCode);233 pbAmlCode Dsdt = (uint8_t *)RTMemAllocZ(cbAmlCodeDsdt);234 if (pbAmlCode Dsdt)235 memcpy(pbAmlCode Dsdt, AmlCode, cbAmlCodeDsdt);203 cbAmlCode = sizeof(AmlCode); 204 pbAmlCode = (uint8_t *)RTMemAllocZ(cbAmlCode); 205 if (pbAmlCode) 206 memcpy(pbAmlCode, AmlCode, cbAmlCode); 236 207 else 237 208 rc = VERR_NO_MEMORY; … … 239 210 else if (RT_FAILURE(rc)) 240 211 return PDMDEV_SET_ERROR(pDevIns, rc, 241 N_("Configuration error: Failed to read \" DsdtFilePath\""));212 N_("Configuration error: Failed to read \"AmlFilePath\"")); 242 213 243 214 if (RT_SUCCESS(rc)) 244 215 { 245 patchAml(pDevIns, pbAmlCode Dsdt, cbAmlCodeDsdt);246 *ppPtr = pbAmlCode Dsdt;247 *puDsdtLen = cbAmlCode Dsdt;216 patchAml(pDevIns, pbAmlCode, cbAmlCode); 217 *ppPtr = pbAmlCode; 218 *puDsdtLen = cbAmlCode; 248 219 } 249 220 return rc; … … 262 233 } 263 234 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 else285 {286 pbAmlCode = AmlCodeSsdtStandard;287 cbAmlCodeSsdt = sizeof(AmlCodeSsdtStandard);288 }289 290 pbAmlCodeSsdt = (uint8_t *)RTMemAllocZ(cbAmlCodeSsdt);291 if (pbAmlCodeSsdt)292 memcpy(pbAmlCodeSsdt, pbAmlCode, cbAmlCodeSsdt);293 else294 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.