From c3f7b747f02a79b34ed914c54ce74be973b17af1 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 10 Apr 2026 17:39:14 +0200 Subject: kapi: extract ACPI functionality to libs --- kernel/kapi/acpi.cpp | 18 ++---- .../kapi/acpi/multiple_apic_description_table.cpp | 70 ---------------------- kernel/kapi/acpi/pointers.cpp | 55 ----------------- .../kapi/acpi/system_description_table_header.cpp | 51 ---------------- 4 files changed, 4 insertions(+), 190 deletions(-) delete mode 100644 kernel/kapi/acpi/multiple_apic_description_table.cpp delete mode 100644 kernel/kapi/acpi/pointers.cpp delete mode 100644 kernel/kapi/acpi/system_description_table_header.cpp (limited to 'kernel/kapi') diff --git a/kernel/kapi/acpi.cpp b/kernel/kapi/acpi.cpp index e7c4921..df2bf05 100644 --- a/kernel/kapi/acpi.cpp +++ b/kernel/kapi/acpi.cpp @@ -6,12 +6,10 @@ #include -#include +#include + #include -#include -#include #include -#include #include namespace kapi::acpi @@ -22,7 +20,7 @@ namespace kapi::acpi auto constinit manager = std::optional{}; } // namespace - auto init(root_system_description_pointer const & sdp) -> bool + auto init(::acpi::rsdp const & sdp) -> bool { auto static constinit initialized = std::atomic_flag{}; if (initialized.test_and_set()) @@ -34,15 +32,7 @@ namespace kapi::acpi return manager->load_tables(); } - auto validate_checksum(std::span data) -> bool - { - auto sum = std::ranges::fold_left(data, std::uint8_t{}, [](auto acc, auto byte) { - return static_cast(acc + static_cast(byte)); - }); - return sum == 0; - } - - auto get_table(std::string_view signature) -> kstd::observer_ptr + auto get_table(std::string_view signature) -> kstd::observer_ptr<::acpi::sdt const> { return manager->get_table(signature); } diff --git a/kernel/kapi/acpi/multiple_apic_description_table.cpp b/kernel/kapi/acpi/multiple_apic_description_table.cpp deleted file mode 100644 index c0360a3..0000000 --- a/kernel/kapi/acpi/multiple_apic_description_table.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "kapi/acpi.hpp" -#include "kapi/memory.hpp" - -#include -#include - -namespace kapi::acpi -{ - - auto multiple_apic_description_table::local_interrupt_controller_address() const noexcept -> memory::physical_address - { - return memory::physical_address{static_cast(m_local_interrupt_controller_address)}; - } - - auto multiple_apic_description_table::flags() const noexcept -> std::uint32_t - { - return m_flags; - } - - auto multiple_apic_description_table_entry::type() const noexcept -> types - { - return static_cast(m_type); - } - - auto multiple_apic_description_table_entry::length() const noexcept -> std::size_t - { - return m_length; - } - - auto processor_local_apic::apic_id() const noexcept -> std::uint8_t - { - return m_apic_id; - } - - auto processor_local_apic::active_flags() const noexcept -> flags - { - return static_cast(m_flags); - } - - auto processor_local_apic::processor_id() const noexcept -> std::uint32_t - { - return m_processor_id; - } - - auto multiple_apic_description_table::begin() const noexcept -> iterator - { - auto base = reinterpret_cast(this); - base += sizeof(multiple_apic_description_table); - auto limit = reinterpret_cast(this); - limit += length().value; - return iterator{reinterpret_cast(base), - reinterpret_cast(limit)}; - } - - auto multiple_apic_description_table::cbegin() const noexcept -> iterator - { - return begin(); - } - - auto multiple_apic_description_table::end() const noexcept -> iterator - { - return {}; - } - - auto multiple_apic_description_table::cend() const noexcept -> iterator - { - return end(); - } - -} // namespace kapi::acpi diff --git a/kernel/kapi/acpi/pointers.cpp b/kernel/kapi/acpi/pointers.cpp deleted file mode 100644 index 63831e9..0000000 --- a/kernel/kapi/acpi/pointers.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "kapi/acpi.hpp" -#include "kapi/memory.hpp" - -#include - -#include -#include -#include -#include - -namespace kapi::acpi -{ - - auto root_system_description_pointer::oem_id() const noexcept -> std::string_view - { - return {m_oem_id.data(), m_oem_id.size()}; - } - - auto root_system_description_pointer::revision() const noexcept -> std::uint8_t - { - return m_revision; - } - - auto root_system_description_pointer::signature() const noexcept -> std::string_view - { - return {m_signature.data(), m_signature.size()}; - } - - auto root_system_description_pointer::table_address() const noexcept -> memory::physical_address - { - auto raw = std::bit_cast(m_rsdt_address); - return memory::physical_address{static_cast(raw)}; - } - - auto root_system_description_pointer::validate() const noexcept -> bool - { - return validate_checksum({reinterpret_cast(this), sizeof(root_system_description_pointer)}); - } - - auto extended_system_description_pointer::length() const noexcept -> kstd::units::bytes - { - return kstd::units::bytes{m_length}; - } - - auto extended_system_description_pointer::table_address() const noexcept -> memory::physical_address - { - return memory::physical_address{std::bit_cast(m_xsdt_address)}; - } - - auto extended_system_description_pointer::validate() const noexcept -> bool - { - return validate_checksum({reinterpret_cast(this), m_length}); - } - -} // namespace kapi::acpi diff --git a/kernel/kapi/acpi/system_description_table_header.cpp b/kernel/kapi/acpi/system_description_table_header.cpp deleted file mode 100644 index f688b4d..0000000 --- a/kernel/kapi/acpi/system_description_table_header.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "kapi/acpi.hpp" - -#include - -#include -#include - -namespace kapi::acpi -{ - - [[nodiscard]] auto system_description_table_header::creator_revision() const noexcept -> std::uint32_t - { - return m_creator_revision; - } - - [[nodiscard]] auto system_description_table_header::creator_id() const noexcept -> std::uint32_t - { - return m_creator_id; - } - - [[nodiscard]] auto system_description_table_header::length() const noexcept -> kstd::units::bytes - { - return kstd::units::bytes{m_length}; - } - - [[nodiscard]] auto system_description_table_header::oem_id() const noexcept -> std::string_view - { - return {m_oem_id.data(), m_oem_id.size()}; - } - - [[nodiscard]] auto system_description_table_header::oem_revision() const noexcept -> std::uint32_t - { - return m_oem_revision; - } - - [[nodiscard]] auto system_description_table_header::oem_table_id() const noexcept -> std::string_view - { - return {m_oem_table_id.data(), m_oem_table_id.size()}; - } - - [[nodiscard]] auto system_description_table_header::revision() const noexcept -> std::uint8_t - { - return m_revision; - } - - [[nodiscard]] auto system_description_table_header::signature() const noexcept -> std::string_view - { - return {m_signature.data(), m_signature.size()}; - } - -} // namespace kapi::acpi -- cgit v1.2.3