summaryrefslogtreecommitdiffhomepage
path: root/Kernel/Modules/ACPI
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Modules/ACPI')
-rw-r--r--Kernel/Modules/ACPI/.gitkeep0
-rw-r--r--Kernel/Modules/ACPI/ACPI.hxx88
-rw-r--r--Kernel/Modules/ACPI/ACPIFactoryInterface.hxx55
-rw-r--r--Kernel/Modules/ACPI/compile_flags.txt4
4 files changed, 147 insertions, 0 deletions
diff --git a/Kernel/Modules/ACPI/.gitkeep b/Kernel/Modules/ACPI/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Kernel/Modules/ACPI/.gitkeep
diff --git a/Kernel/Modules/ACPI/ACPI.hxx b/Kernel/Modules/ACPI/ACPI.hxx
new file mode 100644
index 00000000..019bcb11
--- /dev/null
+++ b/Kernel/Modules/ACPI/ACPI.hxx
@@ -0,0 +1,88 @@
+/* -------------------------------------------
+
+ Copyright Zeta Electronics Corporation
+
+------------------------------------------- */
+
+#ifndef __ACPI__
+#define __ACPI__
+
+/**
+ https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html
+*/
+
+#include <NewKit/Defines.hpp>
+
+namespace NewOS
+{
+ class PACKED SDT
+ {
+ public:
+ Char Signature[4];
+ UInt32 Length;
+ UInt8 Revision;
+ Char Checksum;
+ Char OemId[6];
+ Char OemTableId[8];
+ UInt32 OemRev;
+ UInt32 CreatorID;
+ UInt32 CreatorRevision;
+ };
+
+ class PACKED RSDP : public SDT
+ {
+ public:
+ UInt32 RsdtAddress;
+ UIntPtr XsdtAddress;
+ UInt8 ExtendedChecksum;
+ UInt8 Reserved0[3];
+ };
+
+ class PACKED ConfigHeader
+ {
+ public:
+ UInt64 BaseAddress;
+ UInt16 PciSegGroup;
+ UInt8 StartBus;
+ UInt8 EndBus;
+ UInt32 Reserved;
+ };
+
+ enum class AddressSpace : UInt8
+ {
+ SystemMemory = 0,
+ SystemIO = 1,
+ Pci = 2,
+ Controller = 3,
+ SmBus = 4,
+ Count = 5,
+ Invalid = 0xFF,
+ };
+
+ class PACKED Address
+ {
+ public:
+ AddressSpace AddressSpaceId;
+ UInt8 RegisterBitWidth;
+ UInt8 RegisterBitOffset;
+ UInt8 Reserved;
+ UIntPtr Address;
+ };
+
+ class PACKED RSDT
+ {
+ public:
+ Char Signature[4];
+ UInt32 Length;
+ UInt8 Revision;
+ Char Checksum;
+ Char OemId[6];
+ Char OemTableId[8];
+ UInt32 OemRev;
+ UInt32 CreatorID;
+ UInt32 CreatorRevision;
+ UInt32 AddressArr[];
+ };
+} // namespace NewOS
+
+#endif // !__ACPI__
diff --git a/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx b/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx
new file mode 100644
index 00000000..7fbe6192
--- /dev/null
+++ b/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx
@@ -0,0 +1,55 @@
+/* -------------------------------------------
+
+ Copyright Zeta Electronics Corporation
+
+------------------------------------------- */
+
+#ifndef __ACPI_MANAGER__
+#define __ACPI_MANAGER__
+
+#include <Modules/ACPI/ACPI.hxx>
+#include <KernelKit/DebugOutput.hpp>
+#include <NewKit/Defines.hpp>
+#include <NewKit/Ref.hpp>
+
+namespace NewOS
+{
+ class ACPIFactoryInterface final
+ {
+ public:
+ explicit ACPIFactoryInterface(voidPtr rsdPtr);
+ ~ACPIFactoryInterface() = default;
+
+ ACPIFactoryInterface& operator=(const ACPIFactoryInterface&) = default;
+ ACPIFactoryInterface(const ACPIFactoryInterface&) = default;
+
+ public:
+ void Shutdown(); // shutdown
+ void Reboot(); // soft-reboot
+
+ public:
+ /// @brief Descriptor find factory.
+ /// @param signature The signature of the descriptor table (MADT, ACPI...)
+ /// @return the blob inside an ErrorOr object.
+ ErrorOr<voidPtr> Find(const char* signature);
+
+ /// @brief Checksum factory.
+ /// @param checksum the data to checksum
+ /// @param len it's size
+ /// @return if it succeed
+ bool Checksum(const char* checksum, SSizeT len); // watch for collides!
+
+ public:
+ ErrorOr<voidPtr> operator[](const char* signature)
+ {
+ return this->Find(signature);
+ }
+
+ private:
+ VoidPtr fRsdp; // pointer to root descriptor.
+ SSizeT fEntries; // number of entries, -1 tells that no invalid entries were
+ // found.
+ };
+} // namespace NewOS
+
+#endif // !__ACPI_MANAGER__
diff --git a/Kernel/Modules/ACPI/compile_flags.txt b/Kernel/Modules/ACPI/compile_flags.txt
new file mode 100644
index 00000000..1bc51142
--- /dev/null
+++ b/Kernel/Modules/ACPI/compile_flags.txt
@@ -0,0 +1,4 @@
+-I./
+-I../
+-I../../
+-std=c++20