summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlexey Gavrilov <rebovas@yahoo.com>2024-03-26 13:51:05 +0700
committerAlexey Gavrilov <rebovas@yahoo.com>2024-03-26 13:51:05 +0700
commite0bac2387b373316337b177fe8aa9851b0d5e870 (patch)
treea829ca7f1b8b766700f32f975477d49535354c24 /drivers
parent91b4d8fa6bed598e2969f16a7a953e293a1b7f89 (diff)
Implement MADT table
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Acpi.cpp (renamed from drivers/acpi/acpi.cpp)28
-rw-r--r--drivers/acpi/Acpi.h (renamed from drivers/acpi/acpi.h)29
-rw-r--r--drivers/acpi/Ics.cpp7
-rw-r--r--drivers/acpi/Ics.h231
4 files changed, 284 insertions, 11 deletions
diff --git a/drivers/acpi/acpi.cpp b/drivers/acpi/Acpi.cpp
index 25dad9d..207c9bb 100644
--- a/drivers/acpi/acpi.cpp
+++ b/drivers/acpi/Acpi.cpp
@@ -1,4 +1,4 @@
-#include "acpi.h"
+#include "Acpi.h"
const char *Rsdp::signatureString = "RSD PTR ";
@@ -8,7 +8,8 @@ const memAddr Rsdp::romAreaEnd = 0xfffff;
const memAddr Rsdp::ebdaAreaStart = 0x80000;
const memAddr Rsdp::ebdaAreaEnd = 0x803ff;
const uint8 Rsdp::checksunFieldSize = 20;
-// Entry **Rsdt::entries = nullptr;
+const uint8 Entry::size = 4;
+const uint8 sizeWithoutIcs = 44;
Rsdt *Rsdp::getRsdt() const
{
@@ -30,12 +31,11 @@ const uint32 DescHeader::getLength() const
return length;
};
-const Entry *Rsdt::getEntry(uint8 index)
+const Entry *Rsdt::getEntry(uint8 index) const
{
uint32 entriesAmount = (header.getLength() - sizeof(DescHeader)) / Entry::size;
if(index >= entriesAmount
- or entries == nullptr
or header.checksumCheck()) return nullptr;
else return ((const Entry **)&entries)[index];
};
@@ -59,3 +59,23 @@ uint8 DescHeader::checksumCheck() const
}
return check;
};
+
+const Ics *Madt::getIcs(uint8 index) const
+{
+ uint32 icsBytesRemain = header.getLength() - ::sizeWithoutIcs;
+ uint16 indexAmass = 0;
+ const Ics *icsPtr = (Ics *)(&icsBegin);
+
+ while(icsBytesRemain > 0)
+ {
+ if(indexAmass == index) return icsPtr;
+ else
+ {
+ icsBytesRemain -= icsPtr->getLength();
+ indexAmass++;
+ icsPtr = (Ics *)((memAddr)icsPtr + icsPtr->getLength());
+ }
+ }
+
+ return nullptr;
+};
diff --git a/drivers/acpi/acpi.h b/drivers/acpi/Acpi.h
index 069c954..6a5c806 100644
--- a/drivers/acpi/acpi.h
+++ b/drivers/acpi/Acpi.h
@@ -1,5 +1,6 @@
#include <types.h>
#include <StringOperations.h>
+#include "Ics.h"
typedef decltype(nullptr) nulltype;
@@ -15,7 +16,7 @@ class Gas
public:
Gas();
Gas(const Gas &) = default;
-};
+} __attribute__((packed));
class DescHeader
{
@@ -41,7 +42,7 @@ class Entry
{
public:
// In bytes
- static const uint8 size = 4;
+ static const uint8 size;
protected:
const DescHeader header;
public:
@@ -49,7 +50,7 @@ class Entry
Entry(const Entry &) = delete;
} __attribute__((packed));
-class FadtEntry : public Entry
+class Fadt : public Entry
{
private:
const uint32 firmwareCtrl;
@@ -108,19 +109,33 @@ class FadtEntry : public Entry
const Gas sleepStatusReg;
const uint64 hypervisorVendorIdentity;
public:
- FadtEntry() = delete;
- FadtEntry(const FadtEntry &) = delete;
+ Fadt() = delete;
+ Fadt(const Fadt &) = delete;
+} __attribute__((packed));
+
+class Madt : Entry
+{
+ public:
+ const static uint8 sizeWithoutIcs;
+ private:
+ const uint32 localIntControlerAddr;
+ const uint32 flags;
+ const uint8 icsBegin;
+ public:
+ Madt() = delete;
+ Madt(const Madt &) = delete;
+ const Ics *getIcs(uint8 index) const;
} __attribute__((packed));
class Rsdt
{
private:
const DescHeader header;
- const Entry **entries;
+ const uint8 entries;
public:
Rsdt() = delete;
Rsdt(const Rsdt &) = delete;
- const Entry *getEntry(uint8 index);
+ const Entry *getEntry(uint8 index) const;
} __attribute__((packed, aligned(sizeof(uint32))));
class Xsdt
diff --git a/drivers/acpi/Ics.cpp b/drivers/acpi/Ics.cpp
new file mode 100644
index 0000000..754b9f0
--- /dev/null
+++ b/drivers/acpi/Ics.cpp
@@ -0,0 +1,7 @@
+#include "Ics.h"
+
+
+uint8 Ics::getLength() const
+{
+ return length;
+};
diff --git a/drivers/acpi/Ics.h b/drivers/acpi/Ics.h
new file mode 100644
index 0000000..8289c90
--- /dev/null
+++ b/drivers/acpi/Ics.h
@@ -0,0 +1,231 @@
+#include <types.h>
+
+
+class Ics
+{
+ protected:
+ const uint8 type;
+ const uint8 length;
+ public:
+ Ics() = delete;
+ Ics(const Ics &) = delete;
+ uint8 getLength() const;
+};
+
+class LapicStruct : public Ics
+{
+ private:
+ const uint8 acpiProcUid;
+ const uint8 apicId;
+ const uint32 flags;
+ public:
+ LapicStruct() = delete;
+ LapicStruct(const LapicStruct &) = delete;
+};
+
+class IoapicStruct : public Ics
+{
+ private:
+ const uint8 ioapicId;
+ const uint8 reserved;
+ const uint32 ioapicAddr;
+ const uint32 globalSysIntBase;
+ public:
+ IoapicStruct() = delete;
+ IoapicStruct(const IoapicStruct &) = delete;
+};
+
+class IsoStruct : public Ics
+{
+ private:
+ const uint8 bus;
+ const uint8 source;
+ const uint32 globalSysInt;
+ const uint16 flags;
+ public:
+ IsoStruct() = delete;
+ IsoStruct(const IsoStruct &) = delete;
+};
+
+class NmiSourceStruct: public Ics
+{
+ private:
+ const uint16 flags;
+ const uint32 globalSysInt;
+ public:
+ NmiSourceStruct() = delete;
+ NmiSourceStruct(const NmiSourceStruct &) = delete;
+};
+
+class LapicNmiStruct : public Ics
+{
+ private:
+ const uint8 acpiProcUid;
+ const uint16 flags;
+ const uint8 localApicLint;
+ public:
+ LapicNmiStruct() = delete;
+ LapicNmiStruct(const LapicNmiStruct &) = delete;
+};
+
+class LapicAddrOverrrideStruct : public Ics
+{
+ private:
+ const uint16 reserved;
+ const uint64 lapicAddr;
+ public:
+ LapicAddrOverrrideStruct() = delete;
+ LapicAddrOverrrideStruct(const LapicAddrOverrrideStruct &) = delete;
+};
+
+class IosapicStruct : public Ics
+{
+ private:
+ const uint8 ioapicId;
+ const uint8 reserved;
+ const uint32 globSysIntBase;
+ const uint64 iosapicAddr;
+ public:
+ IosapicStruct() = delete;
+ IosapicStruct(const IosapicStruct &) = delete;
+};
+
+class LsapicStruct : public Ics
+{
+ private:
+ const uint8 acpiProcId;
+ const uint8 lsapicId;
+ const uint8 lsapicUid;
+ const uint8 reserved[3];
+ const uint32 flags;
+ const uint32 acpiProcUidValue;
+ const uint8 acpiProcUidStringBegin;
+ public:
+ LsapicStruct() = delete;
+ LsapicStruct(const LsapicStruct &) = delete;
+};
+
+class PlatformIntSourceStruct : public Ics
+{
+ private:
+ const uint16 flags;
+ const uint8 intType;
+ const uint8 procId;
+ const uint8 procEid;
+ const uint8 iosapicVector;
+ const uint32 globSysInt;
+ const uint32 platformIntSourceFlags;
+ public:
+ PlatformIntSourceStruct() = delete;
+ PlatformIntSourceStruct(const PlatformIntSourceStruct &) = delete;
+};
+
+class ProcLxapicStruct : public Ics
+{
+ private:
+ const uint16 reserved;
+ const uint32 xapicId;
+ const uint32 flags;
+ const uint32 acpiProcUid;
+ public:
+ ProcLxapicStruct() = delete;
+ ProcLxapicStruct(const ProcLxapicStruct &) = delete;
+};
+
+class LocalXapicNmiStruct : public Ics
+{
+ private:
+ const uint16 flags;
+ const uint32 acpiProcUid;
+ const uint8 localXapicLint;
+ const uint8 reserved[3];
+ public:
+ LocalXapicNmiStruct() = delete;
+ LocalXapicNmiStruct(const LocalXapicNmiStruct &) = delete;
+};
+
+class GiccStruct : public Ics
+{
+ private:
+ const uint16 reservedBegin;
+ const uint32 cpuInterfaceNumber;
+ const uint32 acpiProcUid;
+ const uint32 flags;
+ const uint32 parkingProtocolVersion;
+ const uint32 performanceIntGsiv;
+ const uint64 parkedAddr;
+ const uint64 physBaseAddr;
+ const uint64 gicv;
+ const uint64 gich;
+ const uint32 vgicMaintenanceInt;
+ const uint64 gicrBaseAddr;
+ const uint64 mpidr;
+ const uint8 ProcPowerEfficiencyClass;
+ const uint8 reservedEnd;
+ const uint16 speOverflowInterrupt;
+ public:
+ GiccStruct() = delete;
+ GiccStruct(const GiccStruct &) = delete;
+};
+
+class GicdStruct : public Ics
+{
+ private:
+ const uint16 reservedBegin;
+ const uint32 gicId;
+ const uint64 physBaseAddr;
+ const uint32 sysVectorBase;
+ const uint8 gicVersion;
+ const uint8 reservedEnd[3];
+ public:
+ GicdStruct() = delete;
+ GicdStruct(const GicdStruct &) = delete;
+};
+
+class GisMsiFrameStruct : public Ics
+{
+ private:
+ const uint16 reserved;
+ const uint32 gicMsiFrameId;
+ const uint64 physBaseAddr;
+ const uint32 flags;
+ const uint16 spiCount;
+ const uint16 spiBase;
+ public:
+ GisMsiFrameStruct() = delete;
+ GisMsiFrameStruct(const GisMsiFrameStruct &) = delete;
+};
+
+class GicrStruct : public Ics
+{
+ private:
+ const uint16 reserved;
+ const uint64 discoveryRangeBaseAddr;
+ const uint32 discoveryRangeLength;
+ public:
+ GicrStruct() = delete;
+ GicrStruct(const GicrStruct &) = delete;
+};
+
+class ItsStruct : public Ics
+{
+ private:
+ const uint16 reserved;
+ const uint32 GicItsId;
+ const uint64 physBaseAddr;
+ const uint32 reservedEnd;
+ public:
+ ItsStruct() = delete;
+ ItsStruct(const ItsStruct &) = delete;
+};
+
+class MprocWakeupStruct : Ics
+{
+ private:
+ const uint16 mailBoxVersion;
+ const uint32 reserved;
+ const uint64 mailBoxAddr;
+ public:
+ MprocWakeupStruct() = delete;
+ MprocWakeupStruct(const MprocWakeupStruct &) = delete;
+};