MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / PatchACPI_OtherOS

Function PatchACPI_OtherOS

rEFIt_UEFI/Platform/AcpiPatcher.cpp:2398–2534  ·  view source on GitHub ↗

* Patches UEFI ACPI tables with tables found in OsSubdir. */

Source from the content-addressed store, hash-verified

2396 * Patches UEFI ACPI tables with tables found in OsSubdir.
2397 */
2398EFI_STATUS PatchACPI_OtherOS(CONST CHAR16* OsSubdir, BOOLEAN DropSSDT)
2399{
2400 EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *RsdPointer;
2401 EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *FadtPointer;
2402
2403 EFI_STATUS Status; // = EFI_SUCCESS;
2404 // UINTN Index;
2405 REFIT_DIR_ITER DirIter;
2406 EFI_FILE_INFO *DirEntry;
2407
2408 //
2409 // Search for RSDP in UEFI SystemTable/ConfigTable (first Acpi 2.0, then 1.0)
2410 //
2411 RsdPointer = NULL;
2412
2413 Status = EfiGetSystemConfigurationTable (&gEfiAcpi20TableGuid, (VOID **) &RsdPointer);
2414 if (RsdPointer != NULL) {
2415 DBG("OtherOS: Found Acpi 2.0 RSDP 0x%llX\n", (uintptr_t)RsdPointer);
2416 } else {
2417 Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) &RsdPointer);
2418 if (RsdPointer != NULL) {
2419 DBG("Found Acpi 1.0 RSDP 0x%llX\n", (uintptr_t)RsdPointer);
2420 }
2421 }
2422 // if RSDP not found - quit
2423 if (!RsdPointer) {
2424 return Status;
2425 }
2426
2427 //
2428 // Find RSDT and/or XSDT
2429 //
2430 Rsdt = (RSDT_TABLE*)(UINTN)(RsdPointer->RsdtAddress);
2431 if (Rsdt != NULL && Rsdt->Header.Signature != EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {
2432 Rsdt = NULL;
2433 }
2434 DBG("RSDT at 0x%llX\n", (UINTN)Rsdt);
2435
2436 // check for XSDT
2437 Xsdt = NULL;
2438 if (RsdPointer->Revision >=2 && (RsdPointer->XsdtAddress < (UINT64)((UINTN)(-1)))) {
2439 Xsdt = (XSDT_TABLE*)(UINTN)RsdPointer->XsdtAddress;
2440 if (Xsdt != NULL && Xsdt->Header.Signature != EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {
2441 Xsdt = NULL;
2442 }
2443 }
2444 DBG("XSDT at 0x%llX\n", (UINTN)Xsdt);
2445
2446 // if RSDT and XSDT not found - quit
2447 if (Rsdt == NULL && Xsdt == NULL) {
2448 return EFI_UNSUPPORTED;
2449 }
2450
2451 //
2452 // Take FADT (FACP) from XSDT or RSDT (always first entry)
2453 //
2454 FadtPointer = NULL;
2455 if (Xsdt) {

Callers 1

StartLoaderMethod · 0.85

Calls 15

SWPrintfFunction · 0.85
FileExistsFunction · 0.85
LoadAndInjectDSDTFunction · 0.85
DbgHeaderFunction · 0.85
DropTableFromXSDTFunction · 0.85
DropTableFromRSDTFunction · 0.85
DirIterOpenFunction · 0.85
DirIterNextFunction · 0.85
StrStrFunction · 0.85
LoadAndInjectAcpiTableFunction · 0.85
DirIterCloseFunction · 0.85

Tested by

no test coverage detected