diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-05-09 00:42:44 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-05-09 00:42:44 +0200 |
| commit | af8a516fc22865abd80d6e26f1541fa3d6bebfdc (patch) | |
| tree | 96d42a10945fc03df022389aef54708383c1d616 /Kernel/Builtins/ACPI | |
| parent | a874e9cc98df994178d55996943fe81799c61d2f (diff) | |
MHR-23: :boom:, refactors.
- Move NewBoot to /Boot, thus making Kernel directory only containing the kernel.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Kernel/Builtins/ACPI')
| -rw-r--r-- | Kernel/Builtins/ACPI/.gitkeep | 0 | ||||
| -rw-r--r-- | Kernel/Builtins/ACPI/ACPI.hxx | 73 | ||||
| -rw-r--r-- | Kernel/Builtins/ACPI/ACPIFactoryInterface.hxx | 55 | ||||
| -rw-r--r-- | Kernel/Builtins/ACPI/compile_flags.txt | 4 |
4 files changed, 132 insertions, 0 deletions
diff --git a/Kernel/Builtins/ACPI/.gitkeep b/Kernel/Builtins/ACPI/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Kernel/Builtins/ACPI/.gitkeep diff --git a/Kernel/Builtins/ACPI/ACPI.hxx b/Kernel/Builtins/ACPI/ACPI.hxx new file mode 100644 index 00000000..d171bf3b --- /dev/null +++ b/Kernel/Builtins/ACPI/ACPI.hxx @@ -0,0 +1,73 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#ifndef __ACPI__ +#define __ACPI__ + +/** + https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html +*/ + +#include <NewKit/Defines.hpp> + +namespace NewOS +{ + class SDT + { + public: + Char Signature[4]; + UInt32 Length; + UInt8 Revision; + Char Checksum; + Char OemId[6]; + Char OemTableId[8]; + UInt32 OemRev; + UInt32 CreatorID; + UInt32 CreatorRevision; + }; + + class RSDP : public SDT + { + public: + UInt32 RsdtAddress; + UIntPtr XsdtAddress; + UInt8 ExtendedChecksum; + UInt8 Reserved0[3]; + }; + + class 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 Address + { + public: + AddressSpace AddressSpaceId; + UInt8 RegisterBitWidth; + UInt8 RegisterBitOffset; + UInt8 Reserved; + UIntPtr Address; + }; +} // namespace NewOS + +#endif // !__ACPI__ diff --git a/Kernel/Builtins/ACPI/ACPIFactoryInterface.hxx b/Kernel/Builtins/ACPI/ACPIFactoryInterface.hxx new file mode 100644 index 00000000..a2fa4fd8 --- /dev/null +++ b/Kernel/Builtins/ACPI/ACPIFactoryInterface.hxx @@ -0,0 +1,55 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#ifndef __ACPI_MANAGER__ +#define __ACPI_MANAGER__ + +#include <Builtins/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/Builtins/ACPI/compile_flags.txt b/Kernel/Builtins/ACPI/compile_flags.txt new file mode 100644 index 00000000..1bc51142 --- /dev/null +++ b/Kernel/Builtins/ACPI/compile_flags.txt @@ -0,0 +1,4 @@ +-I./ +-I../ +-I../../ +-std=c++20 |
