summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/Modules/ACPI
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-15 18:35:34 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-15 18:35:34 +0200
commitf3d931aa7cfaf96baef8383b59a8938779541ee7 (patch)
treefdb9fc51badb3dbd03e46ab0766a49d9522e13e2 /dev/Kernel/Modules/ACPI
parent86640816e8b1d3595365f1fcc8a2a9e61fb40ff1 (diff)
[IMP] Moved source code into dev/ folder.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/Modules/ACPI')
-rw-r--r--dev/Kernel/Modules/ACPI/.gitkeep0
-rw-r--r--dev/Kernel/Modules/ACPI/ACPI.hxx88
-rw-r--r--dev/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx60
-rw-r--r--dev/Kernel/Modules/ACPI/compile_flags.txt4
4 files changed, 152 insertions, 0 deletions
diff --git a/dev/Kernel/Modules/ACPI/.gitkeep b/dev/Kernel/Modules/ACPI/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/dev/Kernel/Modules/ACPI/.gitkeep
diff --git a/dev/Kernel/Modules/ACPI/ACPI.hxx b/dev/Kernel/Modules/ACPI/ACPI.hxx
new file mode 100644
index 00000000..7ea34bd0
--- /dev/null
+++ b/dev/Kernel/Modules/ACPI/ACPI.hxx
@@ -0,0 +1,88 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#ifndef __ACPI__
+#define __ACPI__
+
+/**
+ https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html
+*/
+
+#include <NewKit/Defines.hxx>
+
+namespace Kernel
+{
+ 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 Kernel
+
+#endif // !__ACPI__
diff --git a/dev/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx b/dev/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx
new file mode 100644
index 00000000..6405dc1b
--- /dev/null
+++ b/dev/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx
@@ -0,0 +1,60 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#ifndef __MOD_ACPI_HXX__
+#define __MOD_ACPI_HXX__
+
+#include <KernelKit/DebugOutput.hxx>
+#include <Modules/ACPI/ACPI.hxx>
+#include <NewKit/ErrorOr.hxx>
+#include <NewKit/Defines.hxx>
+#include <NewKit/Ref.hxx>
+
+namespace Kernel
+{
+ class ACPIFactoryInterface;
+
+ typedef ACPIFactoryInterface PowerFactoryInterface;
+
+ 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 Kernel
+
+#endif // !__MOD_ACPI_HXX__
diff --git a/dev/Kernel/Modules/ACPI/compile_flags.txt b/dev/Kernel/Modules/ACPI/compile_flags.txt
new file mode 100644
index 00000000..1bc51142
--- /dev/null
+++ b/dev/Kernel/Modules/ACPI/compile_flags.txt
@@ -0,0 +1,4 @@
+-I./
+-I../
+-I../../
+-std=c++20