| 1568 | } |
| 1569 | |
| 1570 | BOOLEAN 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 |
no test coverage detected