From 07d6fe388dbeaa79ca5dd786174116a3f947d964 Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 25 Sep 2022 21:43:28 +0200 Subject: [PATCH] Fix naming --- kernel/include/acpi/RSDT.h | 12 ++++++------ kernel/include/acpi/SDT.h | 2 +- kernel/src/acpi/RSDT.cpp | 36 ++++++++++++++---------------------- kernel/src/acpi/SDT.cpp | 2 +- kernel/src/main.cpp | 6 +++--- kernel/src/misc/reboot.cpp | 6 +++--- 6 files changed, 28 insertions(+), 36 deletions(-) diff --git a/kernel/include/acpi/RSDT.h b/kernel/include/acpi/RSDT.h index 00a3128b..9e136cb7 100644 --- a/kernel/include/acpi/RSDT.h +++ b/kernel/include/acpi/RSDT.h @@ -6,20 +6,20 @@ namespace ACPI struct XSDT { SDTHeader header; - uint64_t PointerToOtherSDT[1]; + uint64_t other_sdt[1]; }; struct RSDT { SDTHeader header; - uint32_t PointerToOtherSDT[1]; + uint32_t other_sdt[1]; }; - SDTHeader* GetRSDTOrXSDT(); + SDTHeader* get_rsdt_or_xsdt(); - bool ValidateRSDTOrXSDT(SDTHeader* rootSDT); + bool validate_rsdt_or_xsdt(SDTHeader* root_sdt); - bool IsXSDT(); + bool is_xsdt(); - void* FindTable(SDTHeader* rootSDT, const char* signature); + void* find_table(SDTHeader* root_sdt, const char* signature); } \ No newline at end of file diff --git a/kernel/include/acpi/SDT.h b/kernel/include/acpi/SDT.h index a07b343b..b757203c 100644 --- a/kernel/include/acpi/SDT.h +++ b/kernel/include/acpi/SDT.h @@ -16,5 +16,5 @@ namespace ACPI uint32_t CreatorRevision; }; - bool ValidateSDTHeader(SDTHeader* header); + bool validate_sdt_header(SDTHeader* header); } \ No newline at end of file diff --git a/kernel/src/acpi/RSDT.cpp b/kernel/src/acpi/RSDT.cpp index 9fc02b87..21fdb89d 100644 --- a/kernel/src/acpi/RSDT.cpp +++ b/kernel/src/acpi/RSDT.cpp @@ -9,7 +9,7 @@ extern BOOTBOOT bootboot; -ACPI::SDTHeader* ACPI::GetRSDTOrXSDT() +ACPI::SDTHeader* ACPI::get_rsdt_or_xsdt() { static void* cache = nullptr; if (cache) return (SDTHeader*)cache; @@ -28,42 +28,34 @@ ACPI::SDTHeader* ACPI::GetRSDTOrXSDT() } kdbgln("Mapped RSDT/XSDT to virtual address %lx, uses %ld pages", (uint64_t)cache, numPages); SDTHeader* result = (SDTHeader*)cache; - char OEMID[7]; - memcpy(OEMID, result->OEMID, 6); - OEMID[6] = 0; - kdbgln("OEMID: %s", OEMID); - char OEMTableID[9]; - memcpy(OEMTableID, result->OEMTableID, 8); - OEMTableID[8] = 0; - kdbgln("OEMTableID: %s", OEMTableID); return result; } -bool ACPI::ValidateRSDTOrXSDT(ACPI::SDTHeader* rootSDT) +bool ACPI::validate_rsdt_or_xsdt(ACPI::SDTHeader* root_sdt) { - if (!ValidateSDTHeader(rootSDT)) return false; - if (strncmp(rootSDT->Signature, "XSDT", 4) == 0) return true; - if (strncmp(rootSDT->Signature, "RSDT", 4) == 0) return true; + if (!validate_sdt_header(root_sdt)) return false; + if (strncmp(root_sdt->Signature, "XSDT", 4) == 0) return true; + if (strncmp(root_sdt->Signature, "RSDT", 4) == 0) return true; return false; } -bool ACPI::IsXSDT() +bool ACPI::is_xsdt() { static bool cached = false; static bool cache = false; if (cached) return cache; - SDTHeader* rootSDT = GetRSDTOrXSDT(); + SDTHeader* rootSDT = get_rsdt_or_xsdt(); cache = (strncmp(rootSDT->Signature, "XSDT", 4) == 0); cached = true; return cache; } -void* ACPI::FindTable(ACPI::SDTHeader* rootSDT, const char* signature) +void* ACPI::find_table(ACPI::SDTHeader* root_sdt, const char* signature) { - bool isXSDT = IsXSDT(); - int entries = (rootSDT->Length - sizeof(SDTHeader)) / (isXSDT ? 8 : 4); + bool isXSDT = is_xsdt(); + int entries = (root_sdt->Length - sizeof(SDTHeader)) / (isXSDT ? 8 : 4); kdbgln("Searching for table %s in the %s at %lx (table contains %d entries)", signature, isXSDT ? "XSDT" : "RSDT", - (uint64_t)rootSDT, entries); + (uint64_t)root_sdt, entries); for (int i = 0; i < entries; i++) { @@ -71,13 +63,13 @@ void* ACPI::FindTable(ACPI::SDTHeader* rootSDT, const char* signature) SDTHeader* h; if (isXSDT) { - uint64_t reversedAddress = (uint64_t)((XSDT*)rootSDT)->PointerToOtherSDT[i]; + uint64_t reversedAddress = (uint64_t)((XSDT*)root_sdt)->other_sdt[i]; uint64_t correctAddress = reversedAddress >> 32 | reversedAddress << 32; h = (SDTHeader*)correctAddress; } else { - uint32_t entry = ((RSDT*)rootSDT)->PointerToOtherSDT[i]; + uint32_t entry = ((RSDT*)root_sdt)->other_sdt[i]; h = (SDTHeader*)(uint64_t)entry; } if (!h) @@ -88,7 +80,7 @@ void* ACPI::FindTable(ACPI::SDTHeader* rootSDT, const char* signature) kdbgln("Physical address of entry: %lx", (uint64_t)h); SDTHeader* realHeader = (SDTHeader*)MemoryManager::get_unaligned_mapping(h); kdbgln("Mapped entry to virtual address %lx", (uint64_t)realHeader); - if (!ValidateSDTHeader(realHeader)) + if (!validate_sdt_header(realHeader)) { kwarnln("Header of entry %d is not valid, skipping this entry", i); MemoryManager::release_unaligned_mapping(realHeader); diff --git a/kernel/src/acpi/SDT.cpp b/kernel/src/acpi/SDT.cpp index dc75e8a1..6aedcde3 100644 --- a/kernel/src/acpi/SDT.cpp +++ b/kernel/src/acpi/SDT.cpp @@ -1,6 +1,6 @@ #include "acpi/SDT.h" -bool ACPI::ValidateSDTHeader(ACPI::SDTHeader* header) +bool ACPI::validate_sdt_header(ACPI::SDTHeader* header) { uint8_t sum = 0; diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp index 823d9e94..32b6f36a 100644 --- a/kernel/src/main.cpp +++ b/kernel/src/main.cpp @@ -132,9 +132,9 @@ extern "C" void _start() kinfoln("Prepared scheduler tasks"); - ACPI::SDTHeader* rootSDT = ACPI::GetRSDTOrXSDT(); - bool isXSDT = ACPI::IsXSDT(); - if (!ACPI::ValidateRSDTOrXSDT(rootSDT)) kerrorln("Invalid %s", isXSDT ? "XSDT" : "RSDT"); + ACPI::SDTHeader* rootSDT = ACPI::get_rsdt_or_xsdt(); + bool isXSDT = ACPI::is_xsdt(); + if (!ACPI::validate_rsdt_or_xsdt(rootSDT)) kerrorln("Invalid %s", isXSDT ? "XSDT" : "RSDT"); framebuffer0.clear(Color::Cyan); diff --git a/kernel/src/misc/reboot.cpp b/kernel/src/misc/reboot.cpp index 08742f29..add7df72 100644 --- a/kernel/src/misc/reboot.cpp +++ b/kernel/src/misc/reboot.cpp @@ -14,19 +14,19 @@ static void try_acpi_reboot() { kdbgln("Fetching pointer to RSDT/XSDT"); - ACPI::SDTHeader* rootSDT = ACPI::GetRSDTOrXSDT(); + ACPI::SDTHeader* rootSDT = ACPI::get_rsdt_or_xsdt(); if (!rootSDT) { kwarnln("The pointer to the RSDT/XSDT is null"); return; } - if (!ACPI::ValidateRSDTOrXSDT(rootSDT)) + if (!ACPI::validate_rsdt_or_xsdt(rootSDT)) { kwarnln("The RSDT/XSDT is invalid"); return; } kdbgln("Searching for the FADT"); - ACPI::FADT* fadt = (ACPI::FADT*)ACPI::FindTable(rootSDT, "FACP"); + ACPI::FADT* fadt = (ACPI::FADT*)ACPI::find_table(rootSDT, "FACP"); if (!fadt) { kwarnln("Unable to find the FADT");