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

Function ScanXSDT2

rEFIt_UEFI/Platform/AcpiPatcher.cpp:200–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200UINT64* ScanXSDT2(UINT32 Signature, UINT64 TableId, UINTN MatchIndex)
201{
202 if (!Xsdt || (0 == Signature && 0 == TableId)) {
203 return NULL;
204 }
205
206 UINT32 Count = XsdtTableCount();
207 UINTN MatchingCount = 0;
208 UINT64* Ptr = XsdtEntryPtrFromIndex(0);
209 UINT64* EndPtr = XsdtEntryPtrFromIndex(Count);
210 for (; Ptr < EndPtr; Ptr++) {
211 EFI_ACPI_DESCRIPTION_HEADER* Table = (EFI_ACPI_DESCRIPTION_HEADER*)(UINTN)ReadUnaligned64(Ptr);
212 if (!Table) {
213 // skip NULL entry
214 continue;
215 }
216 if (0 == Signature || Table->Signature == Signature) {
217 if ((0 == TableId || Table->OemTableId == TableId) && (IGNORE_INDEX == MatchIndex || MatchingCount == MatchIndex)) {
218 return Ptr; // pointer to the matching entry
219 }
220 ++MatchingCount;
221 }
222 }
223 return NULL;
224}
225
226UINT64* ScanXSDT(UINT32 Signature, UINT64 TableId)
227{

Callers 2

ScanXSDTFunction · 0.85
ReplaceOrInsertTableFunction · 0.85

Calls 1

ReadUnaligned64Function · 0.50

Tested by

no test coverage detected