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

Function PreCleanupRSDT

rEFIt_UEFI/Platform/AcpiPatcher.cpp:626–662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624}
625
626void PreCleanupRSDT()
627{
628 if (!Rsdt) {
629 return;
630 }
631
632 //REVIEW: really?
633 // Если адрес RSDT < адреса XSDT и хвост RSDT наползает на XSDT, то подрезаем хвост RSDT до начала XSDT
634 // English: If the RSDT address of the XSDT address and the tail of the RSDT crawls onto the XSDT, then we
635 // trim the RSDT tail before the XSDT starts
636 if ((UINTN)Rsdt < (UINTN)Xsdt && (UINTN)Rsdt + Rsdt->Header.Length > (UINTN)Xsdt) {
637 UINTN v = ((UINTN)Xsdt - (UINTN)Rsdt) & ~3;
638 if ( v > MAX_UINT32 ) panic("((UINTN)Xsdt - (UINTN)Rsdt) & ~3 > MAX_UINT32");
639 Rsdt->Header.Length = (UINT32)v;
640 DBG("Cropped Rsdt->Header.Length=%d\n", (UINT32)Rsdt->Header.Length);
641 }
642
643 //REVIEW: why?
644 // terminate RSDT table at first double zero, if present
645 UINT32 Count = RsdtTableCount();
646 if (Count <= 2) {
647 return;
648 }
649
650 DBG("PreCleanup RSDT: count=%d, length=%d\n", Count, (UINT32)Rsdt->Header.Length);
651 UINT32* Ptr = RsdtEntryPtrFromIndex(0);
652 UINT32* EndPtr = RsdtEntryPtrFromIndex(Count-1);
653 for (; Ptr < EndPtr; Ptr++) {
654 if (0 == Ptr[0] && 0 == Ptr[1]) {
655 // double zero found, terminate RSDT entry table here
656 DBG("DoubleZero in RSDT table\n");
657 Rsdt->Header.Length = (UINT32)((CHAR8*)Ptr - (CHAR8*)Rsdt);
658 break;
659 }
660 }
661 DBG("PreCleanup RSDT, corrected RSDT: count=%d, length=%d\n", Count, (UINT32)Rsdt->Header.Length);
662}
663
664void PostCleanupRSDT()
665{

Callers 1

PatchACPIFunction · 0.85

Calls 1

panicFunction · 0.50

Tested by

no test coverage detected