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

Function LoadPatchedAML

rEFIt_UEFI/Platform/AcpiPatcher.cpp:1570–1609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1568}
1569
1570BOOLEAN LoadPatchedAML(CONST CHAR16* AcpiOemPath, CONST CHAR16* PartName, UINTN Pass)
1571{
1572 CHAR16 FullName[256];
1573 // pass1 prefilter based on file names (optimization that avoids loading same files twice)
1574 UINTN Index = IGNORE_INDEX;
1575 if (AUTOMERGE_PASS1 == Pass) {
1576 Index = IndexFromFileName(PartName);
1577 // gSettings.AutoMerge always true in this case
1578 // file names such as: ECDT.aml, SSDT-0.aml, SSDT-1-CpuPm.aml, attempt merge on pass1
1579 // others: no attempt for merge
1580 // special case for SSDT.aml: no attempt to merge
1581 if (0 == StriCmp(PartName, L"SSDT.aml") || (8 != StrLen(PartName) && IGNORE_INDEX == Index)) {
1582 DBG("ignore on pass 1\n");
1583 return FALSE;
1584 }
1585 }
1586 snwprintf(FullName, sizeof(FullName), "%ls\\%ls", AcpiOemPath, PartName);
1587 UINT8 *buffer = NULL;
1588 UINTN bufferLen = 0;
1589 EFI_STATUS Status = egLoadFile(SelfRootDir, FullName, &buffer, &bufferLen);
1590 if (!EFI_ERROR(Status)) {
1591 if (buffer) {
1592 EFI_ACPI_DESCRIPTION_HEADER* TableHeader = (EFI_ACPI_DESCRIPTION_HEADER*)buffer;
1593 if (TableHeader->Length > 500 * kilo) {
1594 DBG("wrong table\n");
1595 return FALSE;
1596 }
1597 }
1598 DBG("size=%lld ", (UINT64)bufferLen);
1599 if (!gSettings.AutoMerge) {
1600 // Note: with AutoMerge=false, Pass is only AUTOMERGE_PASS2 here
1601 Status = InsertTable(buffer, bufferLen);
1602 } else {
1603 Status = ReplaceOrInsertTable(buffer, bufferLen, Index, Pass);
1604 }
1605 FreePool(buffer);
1606 }
1607 DBG("... %s\n", efiStrError(Status));
1608 return !EFI_ERROR(Status);
1609}
1610
1611#define BVALUE_ATTEMPTED 2 // special value for MenuItem.BValue to avoid excessive log output
1612

Callers 1

LoadAllPatchedAMLFunction · 0.85

Calls 8

IndexFromFileNameFunction · 0.85
egLoadFileFunction · 0.85
InsertTableFunction · 0.85
ReplaceOrInsertTableFunction · 0.85
StriCmpFunction · 0.50
StrLenFunction · 0.50
FreePoolFunction · 0.50
efiStrErrorFunction · 0.50

Tested by

no test coverage detected