summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/cpuinfo/Cpuinfo.cpp1
-rw-r--r--drivers/acpi/acpi.cpp71
-rw-r--r--drivers/acpi/acpi.h101
-rw-r--r--drivers/acpi/acpi.h.gchbin0 -> 1675700 bytes
4 files changed, 172 insertions, 1 deletions
diff --git a/arch/x86/cpuinfo/Cpuinfo.cpp b/arch/x86/cpuinfo/Cpuinfo.cpp
index 4db7c84..b246ef7 100644
--- a/arch/x86/cpuinfo/Cpuinfo.cpp
+++ b/arch/x86/cpuinfo/Cpuinfo.cpp
@@ -1,5 +1,4 @@
#include "Cpuinfo.h"
-#include "MemoryOperations.h"
inline Cpuinfo::cpuidFunctionIndex operator++(Cpuinfo::cpuidFunctionIndex& command)
diff --git a/drivers/acpi/acpi.cpp b/drivers/acpi/acpi.cpp
new file mode 100644
index 0000000..41a7aa7
--- /dev/null
+++ b/drivers/acpi/acpi.cpp
@@ -0,0 +1,71 @@
+#include "acpi.h"
+#include "StringOperations.h"
+
+
+Rsdp::Rsdp() : rsdpStruct(nullptr), rsdtObj(nullptr), xsdtObj(nullptr)
+{
+ rsdpStruct = (struct rsdp *)StringOperations::findInMemory(rsdpSign, rsdpRomMemArea);
+
+ if(rsdpStruct == nullptr)
+ {
+ rsdpStruct = (struct rsdp *)StringOperations::findInMemory(rsdpSign, rsdpEbdaMemArea);
+ }
+
+ if(rsdpStruct != nullptr)
+ {
+ rsdtObj = Rsdt(rsdpStruct->rsdtAddress);
+ if(rsdpStruct->revision >= validFieldRevision)
+ {
+ xsdtObj = Xsdt(rsdpStruct->xsdtAddress);
+ }
+ }
+};
+
+const Rsdt *Rsdp::getRsdt() const
+{
+ if(rsdpStruct != nullptr) return &rsdtObj;
+ else return nullptr;
+};
+
+Rsdt::Rsdt(const nulltype null) : entry(null)
+{
+ rsdtStruct = null;
+};
+
+Rsdt::Rsdt(const uint32 addrRsdt) : entry(nullptr)
+{
+ rsdtStruct = (const struct rsdt *)(addrRsdt);
+ if(rsdtStruct != nullptr)
+ {
+ entry = Entry(rsdtStruct->header.length,
+ (&rsdtStruct->firstEntryAddr));
+ }
+};
+
+const Xsdt *Rsdp::getXsdt() const
+{
+ if(rsdpStruct != nullptr) return &xsdtObj;
+ else return nullptr;
+};
+
+Xsdt::Xsdt(const nulltype null)
+{
+ xsdtStruct = nullptr;
+};
+
+Xsdt::Xsdt(const uint32 xsdt)
+{
+ xsdtStruct = (const struct xsdt *)(xsdt);
+};
+
+Entry::Entry(const uint32 rsdtLength, const uint32 *entryAddress)
+{
+ sizeHeadersInBytes = rsdtLength - sizeof(descHeader);
+ headers = (const struct descHeader **)(entryAddress);
+};
+
+Entry::Entry(const nulltype null)
+{
+ sizeHeadersInBytes = 0;
+ headers = null;
+};
diff --git a/drivers/acpi/acpi.h b/drivers/acpi/acpi.h
new file mode 100644
index 0000000..28221d7
--- /dev/null
+++ b/drivers/acpi/acpi.h
@@ -0,0 +1,101 @@
+#include <types.h>
+#include <StringOperations.h>
+
+
+typedef decltype(nullptr) nulltype;
+
+struct descHeader
+{
+ char signature[4];
+ uint32 length;
+ uint8 revision;
+ uint8 checksum;
+ char oemId[6];
+ uint64 oemTableId;
+ uint32 oemRevision;
+ uint32 creatorId;
+ uint32 creatorRevision;
+} __attribute__((packed));
+
+struct rsdt
+{
+ descHeader header;
+ uint32 firstEntryAddr;
+} __attribute__((packed, aligned(sizeof(uint32))));
+
+struct xsdt
+{
+ descHeader header;
+ uint64 firstEntryAddr;
+} __attribute__((packed, aligned(sizeof(uint32))));
+
+struct rsdp
+{
+ char signature[8];
+ uint8 checksum;
+ char oemId[6];
+ uint8 revision;
+ uint32 rsdtAddress;
+ uint32 length;
+ uint32 xsdtAddress;
+ uint8 extendedChecksum;
+ char reserved[3];
+} __attribute__((packed));
+
+class DescriptorTable
+{
+
+};
+
+class Entry
+{
+ private:
+ uint32 sizeHeadersInBytes;
+ const struct descHeader **headers;
+ // DescriptorTable &tables;
+ public:
+ Entry() = delete;
+ Entry(const uint32 sizeEntriesBytes, const uint32 *entryAddress);
+ Entry(const nulltype null);
+};
+
+class Rsdt
+{
+ private:
+ const struct rsdt* rsdtStruct;
+ Entry entry;
+ public:
+ Rsdt() = delete;
+ Rsdt(const uint32 addr);
+ Rsdt(const nulltype null);
+ const Entry& getEntries();
+};
+
+class Xsdt
+{
+ private:
+ const struct xsdt* xsdtStruct;
+ public:
+ Xsdt() = delete;
+ Xsdt(const uint32 addr);
+ Xsdt(const nulltype null);
+};
+
+class Rsdp
+{
+ private:
+ const uint8 validFieldRevision = 2;
+ // RSDP memory address areas in IA-PC systems
+ const char *rsdpSign = "RSD PTR ";
+ const MemArea rsdpRomMemArea = MemArea(0xe0000, 0xfffff);
+ const MemArea rsdpEbdaMemArea = MemArea(0x80000, 0x803ff);
+
+ const struct rsdp *rsdpStruct;
+ Rsdt rsdtObj;
+ Xsdt xsdtObj;
+ public:
+ Rsdp();
+ const Rsdt *getRsdt() const;
+ const Xsdt *getXsdt() const;
+
+};
diff --git a/drivers/acpi/acpi.h.gch b/drivers/acpi/acpi.h.gch
new file mode 100644
index 0000000..8cbaac5
--- /dev/null
+++ b/drivers/acpi/acpi.h.gch
Binary files differ