aboutsummaryrefslogtreecommitdiffstats
path: root/src/acpi.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2024-09-30 11:08:46 -0400
committerClyne Sullivan <clyne@bitgloo.com>2024-09-30 11:08:46 -0400
commit19d9a04e36e7fb96eebe89e24311408460c29a70 (patch)
tree4d5f5ba595d5a5e2b59ce7b102c06b77c7be7721 /src/acpi.cpp
parent85c8fd05f1a0c0224882c4fafa60003d3ef56cf3 (diff)
reorganize files
Diffstat (limited to 'src/acpi.cpp')
-rw-r--r--src/acpi.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/acpi.cpp b/src/acpi.cpp
new file mode 100644
index 0000000..b74a7dc
--- /dev/null
+++ b/src/acpi.cpp
@@ -0,0 +1,51 @@
+#include "textoutput.hpp"
+
+#include <cstdint>
+
+extern TextOutput& term;
+extern std::uint32_t *acpiRsdp;
+extern std::uint32_t *acpiRsdpV2;
+
+struct XSDP {
+ char Signature[8];
+ std::uint8_t Checksum;
+ char OEMID[6];
+ std::uint8_t Revision;
+ std::uint32_t RsdtAddress; // deprecated since version 2.0
+
+ // v2 only!
+ std::uint32_t Length;
+ std::uint64_t XsdtAddress;
+ std::uint8_t ExtendedChecksum;
+ std::uint8_t reserved[3];
+} __attribute__ ((packed));
+
+struct SDTHeader {
+ char Signature[4];
+ std::uint32_t Length;
+ std::uint8_t Revision;
+ std::uint8_t Checksum;
+ char OEMID[6];
+ char OEMTableID[8];
+ std::uint32_t OEMRevision;
+ std::uint32_t CreatorID;
+ std::uint32_t CreatorRevision;
+};
+
+static XSDP *rsdp = nullptr;
+
+void acpi_initialize()
+{
+ if (acpiRsdp) {
+ term.write("ACPI v1 detected.\n");
+ rsdp = reinterpret_cast<XSDP *>(acpiRsdp);
+ } else if (acpiRsdpV2) {
+ term.write("ACPI v2 detected, treating as v1.\n");
+ rsdp = reinterpret_cast<XSDP *>(acpiRsdpV2);
+ }
+
+ //if (rsdp) {
+ // auto sdt = reinterpret_cast<SDTHeader *>(rsdp->RsdtAddress);
+ //}
+}
+