diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-11-12 10:10:10 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-11-12 14:41:29 +0100 |
| commit | ab8de113fb03736e49d89b2cccc31f9cae355500 (patch) | |
| tree | 3c2388fc07194725757f4182019460baa915b42b /libs | |
| parent | deb8f19936ead3e995d418d2c87ea030d7fe434d (diff) | |
| download | kernel-ab8de113fb03736e49d89b2cccc31f9cae355500.tar.xz kernel-ab8de113fb03736e49d89b2cccc31f9cae355500.zip | |
libs/acpi: improve data docs
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/acpi/acpi/data/madt.cpp | 4 | ||||
| -rw-r--r-- | libs/acpi/acpi/data/madt.hpp | 63 | ||||
| -rw-r--r-- | libs/acpi/acpi/data/mcfg.hpp | 2 | ||||
| -rw-r--r-- | libs/acpi/acpi/data/rsdt.hpp | 18 | ||||
| -rw-r--r-- | libs/acpi/acpi/data/xsdt.hpp | 20 |
5 files changed, 99 insertions, 8 deletions
diff --git a/libs/acpi/acpi/data/madt.cpp b/libs/acpi/acpi/data/madt.cpp index fe6bae16..64900bd0 100644 --- a/libs/acpi/acpi/data/madt.cpp +++ b/libs/acpi/acpi/data/madt.cpp @@ -13,7 +13,7 @@ namespace acpi struct madt_data { std::uint32_t local_interrupt_controller_address; - std::uint32_t flags; + enum madt::flags flags; }; static_assert(sizeof(madt_data) == 8); @@ -33,7 +33,7 @@ namespace acpi return value; } - auto madt::flags() const noexcept -> std::uint32_t + auto madt::flags() const noexcept -> enum madt::flags { using type = decltype(madt_data::flags); diff --git a/libs/acpi/acpi/data/madt.hpp b/libs/acpi/acpi/data/madt.hpp index 1fca05da..50fd09e1 100644 --- a/libs/acpi/acpi/data/madt.hpp +++ b/libs/acpi/acpi/data/madt.hpp @@ -9,7 +9,6 @@ #include <kstd/bitfield_enum.hpp> #include <kstd/os/error.hpp> -#include <kstd/units.hpp> #include <array> #include <cstddef> @@ -20,18 +19,23 @@ namespace acpi { + //! The MADT (Multiple APIC Description Table) table signature. template<> struct table_signature<struct madt> { constexpr char static const value[] = "APIC"; // NOLINT }; + //! The MADT table type. template<> struct table_type<table_signature_v<struct madt>> { using type = struct madt; }; + //! An entry in the MADT table. + //! + //! MADT entries have a variable size and describe various components of the system's interrupt controllers. struct madt_entry { //! Indicate that MADT entries have a variable size. @@ -57,8 +61,9 @@ namespace acpi //! Cast this entry to the given concrete entry type. //! - //! @warning This function will terminate execution if the desired target type does not match up with this entry's - //! actual type. + //! @warning This function will panic if the desired target type does not match up with this entry's actual type. + //! + //! @return A reference to the specific entry. template<typename EntryType> [[nodiscard]] auto as() const -> EntryType const & { @@ -70,17 +75,38 @@ namespace acpi } private: + //! The raw header data of an MADT entry. std::array<std::byte, 2> m_data{}; }; //! The Multiple APIC Description Table (MADT) + //! + //! This table provides information about the system's interrupt controllers, including local APICs and I/O APICs. struct madt : vla_table<madt_entry, madt> { - //! Get the physical address of the local interrupt controllers described by this entry. + //! The flag bits of the MADT table. + enum struct flags : std::uint32_t + { + //! Indicates the system has a PC-AT compatible dual 8259 interrupt controller setup. + //! + //! If this bit is set, the interrupts of the legacy PIC must be masked before enabling the APICs. + dual_8259_pic = 1, + }; + + //! Get the physical address of the local interrupt controller for each CPU. + //! + //! @return The physical address of the local interrupt controller. [[nodiscard]] auto local_interrupt_controller_address() const noexcept -> std::uintptr_t; - [[nodiscard]] auto flags() const noexcept -> std::uint32_t; + //! Get the flags of the MADT table. + //! + //! @return The flags of the MADT table. + [[nodiscard]] auto flags() const noexcept -> flags; + //! Get a view of all entries of the specified type in the MADT table. + //! + //! @tparam EntryType The type of MADT entries to filter. + //! @return A view of all entries of the specified type, if any exist. An empty view otherwise. template<typename EntryType> [[nodiscard]] auto only() const noexcept { @@ -89,29 +115,56 @@ namespace acpi } private: + //! The raw, post-header, data of the MADT table, excluding any table entries. std::array<std::byte, 8> m_data{}; }; + //! A processor local APIC entry in the MADT table. + //! + //! This entry describes a local APIC associated with a processor, including its ID, flags, and processor ID. struct processor_local_apic_entry : madt_entry { + //! The type of this MADT entry. constexpr auto static this_type = type::processor_local_apic; + //! The flag bits of the processor local APIC entry. enum struct flags : std::uint32_t { + //! Indicates that the processor is enabled. processor_enabled = 1, + //! Indicates that the processor is capable of being brought online. online_capable = 2, }; + //! Get the ID of the local APIC. + //! + //! @return The ID of the local APIC. [[nodiscard]] auto id() const noexcept -> std::uint8_t; + + //! Get the flags of the processor local APIC entry. + //! + //! @return The flags of the processor local APIC entry. [[nodiscard]] auto flags() const noexcept -> flags; + + //! Get the processor ID associated with this local APIC entry. + //! + //! @return The processor ID associated with this local APIC entry. [[nodiscard]] auto processor_id() const noexcept -> std::uint32_t; private: + //! The raw data of this entry. std::array<std::byte, 6> m_data{}; }; } // namespace acpi +//! Mark the MADT flags enum as a bitfield enum. +template<> +struct kstd::is_bitfield_enum<enum acpi::madt::flags> : std::true_type +{ +}; + +//! Mark the processor local APIC entry flags enum as a bitfield enum. template<> struct kstd::is_bitfield_enum<enum acpi::processor_local_apic_entry::flags> : std::true_type { diff --git a/libs/acpi/acpi/data/mcfg.hpp b/libs/acpi/acpi/data/mcfg.hpp index 24097b44..21f3293c 100644 --- a/libs/acpi/acpi/data/mcfg.hpp +++ b/libs/acpi/acpi/data/mcfg.hpp @@ -17,12 +17,14 @@ namespace acpi { + //! The Memory-Mapped Configuration Space (MCFG) table signature. template<> struct table_signature<struct mcfg> { constexpr char static const value[] = "MCFG"; // NOLINT(modernize-avoid-c-arrays) }; + //! The type of the MCFG table. template<> struct table_type<table_signature_v<struct mcfg>> { diff --git a/libs/acpi/acpi/data/rsdt.hpp b/libs/acpi/acpi/data/rsdt.hpp index c19a9ea4..ca36b33d 100644 --- a/libs/acpi/acpi/data/rsdt.hpp +++ b/libs/acpi/acpi/data/rsdt.hpp @@ -12,30 +12,48 @@ namespace acpi { + //! The RSDT (Root System Description Table) table signature. template<> struct table_signature<struct rsdt> { constexpr char static const value[] = "RSDT"; // NOLINT }; + //! The RSDT table type. template<> struct table_type<table_signature_v<struct rsdt>> { using type = struct rsdt; }; + //! An entry in the RSDT table. + //! + //! Each entry in the RSDT table points to another ACPI table, providing a way to locate all system description + //! tables. struct rsdt_entry { //! Indicate that all RSDT entries have a fixed size. constexpr auto static fixed_size = true; + //! Get the address of the ACPI table pointed to by this entry. + //! + //! @return A pointer to the ACPI table header of the referenced table. [[nodiscard]] auto address() const noexcept -> table_header *; + + //! Get the length of the ACPI table pointed to by this entry. + //! + //! @return The length of the referenced ACPI table. [[nodiscard]] auto length() const noexcept -> std::size_t; private: + //! The raw data of this RSDT entry. std::array<std::byte, 4> m_data{}; }; + //! The Root System Description Table (RSDT) + //! + //! This table provides a list of pointers to other ACPI tables, allowing the system to locate all system description + //! tables. struct rsdt : vla_table<rsdt_entry, rsdt> { }; diff --git a/libs/acpi/acpi/data/xsdt.hpp b/libs/acpi/acpi/data/xsdt.hpp index f09e2e5e..ef268d5f 100644 --- a/libs/acpi/acpi/data/xsdt.hpp +++ b/libs/acpi/acpi/data/xsdt.hpp @@ -12,30 +12,48 @@ namespace acpi { + //! The XSDT (Extended System Description Table) table signature. template<> struct table_signature<struct xsdt> { constexpr char static const value[] = "XSDT"; // NOLINT }; + //! The XSDT table type. template<> struct table_type<table_signature_v<struct xsdt>> { using type = struct xsdt; }; + //! An entry in the XSDT table. + //! + //! Each entry in the XSDT table points to another ACPI table, providing a way to locate all system description + //! tables. struct xsdt_entry { - //! Indicate that all RSDT entries have a fixed size. + //! Indicate that all XSDT entries have a fixed size. constexpr auto static fixed_size = true; + //! Get the address of the ACPI table pointed to by this entry. + //! + //! @return A pointer to the ACPI table header of the referenced table. [[nodiscard]] auto address() const noexcept -> table_header *; + + //! Get the length of the ACPI table pointed to by this entry. + //! + //! @return The length of the referenced ACPI table. [[nodiscard]] auto length() const noexcept -> std::size_t; private: + //! The raw data of this XSDT entry. std::array<std::byte, 8> m_data{}; }; + //! The Extended System Description Table (XSDT) + //! + //! This table provides a list of pointers to other ACPI tables, allowing the system to locate all system description + //! tables. struct xsdt : vla_table<xsdt_entry, xsdt> { }; |
