diff options
| author | Alexey Gavrilov <rebovas@yahoo.com> | 2024-03-19 16:44:56 +0700 |
|---|---|---|
| committer | Alexey Gavrilov <rebovas@yahoo.com> | 2024-03-19 16:44:56 +0700 |
| commit | 3678f5d1970feea92f787928ceb9f53ed0b4c1e2 (patch) | |
| tree | e2e5ff20d9144cda59b7a651d9622ad22ee89e86 /drivers | |
| parent | 32e05e127197275bc4931e0beb6e1f7f29fb5d4d (diff) | |
Implementation acpi tables through structs
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/acpi/acpi.cpp | 71 | ||||
| -rw-r--r-- | drivers/acpi/acpi.h | 101 | ||||
| -rw-r--r-- | drivers/acpi/acpi.h.gch | bin | 0 -> 1675700 bytes |
3 files changed, 172 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 0000000..8cbaac5 --- /dev/null +++ b/drivers/acpi/acpi.h.gch |
