* Searches for DSDT in AcpiOemPath or PathPatched dirs and inserts it * to FadtPointer if found. */
| 2296 | * to FadtPointer if found. |
| 2297 | */ |
| 2298 | EFI_STATUS LoadAndInjectDSDT(CONST CHAR16 *PathPatched, |
| 2299 | EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *FadtPointer) |
| 2300 | { |
| 2301 | EFI_STATUS Status; |
| 2302 | UINT8 *Buffer = NULL; |
| 2303 | UINTN BufferLen = 0; |
| 2304 | EFI_PHYSICAL_ADDRESS Dsdt; |
| 2305 | |
| 2306 | // load if exists |
| 2307 | Status = LoadAcpiTable(PathPatched, gSettings.DsdtName.wc_str(), &Buffer, &BufferLen); |
| 2308 | |
| 2309 | if (!EFI_ERROR(Status)) { |
| 2310 | // loaded - allocate EfiACPIReclaim |
| 2311 | DBG("Loaded DSDT at %ls\\%ls\n", PathPatched, gSettings.DsdtName.wc_str()); |
| 2312 | Dsdt = EFI_SYSTEM_TABLE_MAX_ADDRESS; //0xFE000000; |
| 2313 | Status = gBS->AllocatePages ( |
| 2314 | AllocateMaxAddress, |
| 2315 | EfiACPIReclaimMemory, |
| 2316 | EFI_SIZE_TO_PAGES(BufferLen), |
| 2317 | &Dsdt |
| 2318 | ); |
| 2319 | |
| 2320 | if(!EFI_ERROR(Status)) { |
| 2321 | // copy DSDT into EfiACPIReclaim block |
| 2322 | CopyMem((VOID*)(UINTN)Dsdt, Buffer, BufferLen); |
| 2323 | |
| 2324 | // update FADT |
| 2325 | FadtPointer->Dsdt = (UINT32)Dsdt; |
| 2326 | FadtPointer->XDsdt = Dsdt; |
| 2327 | FixChecksum(&FadtPointer->Header); |
| 2328 | DBG("DSDT at 0x%llX injected to FADT 0x%p\n", Dsdt, FadtPointer); |
| 2329 | } |
| 2330 | |
| 2331 | FreePool(Buffer); |
| 2332 | } |
| 2333 | |
| 2334 | return Status; |
| 2335 | } |
| 2336 | |
| 2337 | /** |
| 2338 | * Searches for TableName in AcpiOemPath or PathPatched dirs and inserts it |
no test coverage detected