MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / FindSDT

Function FindSDT

Kernel/src/arch/x86_64/acpi.cpp:36–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34 char oem[7];
35
36 void* FindSDT(const char* signature, int index)
37 {
38 int entries = 0;
39
40 if(desc->revision == 2){
41 entries = (rsdtHeader->header.length - sizeof(acpi_header_t)) / sizeof(uint64_t); // ACPI 2.0
42 } else {
43 entries = (rsdtHeader->header.length - sizeof(acpi_header_t)) / sizeof(uint32_t); // ACPI 1.0
44 }
45
46 auto getEntry = [](unsigned index) -> uintptr_t { // This will handle differences in ACPI revisions
47 if(desc->revision == 2){
48 return xsdtHeader->tables[index];
49 } else {
50 return rsdtHeader->tables[index];
51 }
52 };
53
54 int _index = 0;
55
56 if(memcmp("DSDT", signature, 4) == 0) return (void*)Memory::GetIOMapping(fadt->dsdt);
57
58 for (int i = 0; i < entries; i++)
59 {
60 acpi_header_t* h = (acpi_header_t*)Memory::GetIOMapping(getEntry(i));
61 if (memcmp(h->signature, signature, 4) == 0 && _index++ == index)
62 return h;
63 }
64
65 // No SDT found
66 return NULL;
67 }
68
69 int ReadMADT(){
70 void* madt = FindSDT("APIC", 0);

Callers 3

ReadMADTFunction · 0.85
InitFunction · 0.85
laihost_scanFunction · 0.85

Calls 2

memcmpFunction · 0.85
GetIOMappingFunction · 0.85

Tested by

no test coverage detected