diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-04-10 17:49:40 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-04-10 17:49:40 +0200 |
| commit | 21fd1281cf19572e202d583689b99c33ec68da50 (patch) | |
| tree | 3325e00e4ccfe95db42be7a38a48350681c1c79f | |
| parent | c3f7b747f02a79b34ed914c54ce74be973b17af1 (diff) | |
| download | teachos-21fd1281cf19572e202d583689b99c33ec68da50.tar.xz teachos-21fd1281cf19572e202d583689b99c33ec68da50.zip | |
kernel: let arch initialize the ACPI manager
| -rw-r--r-- | arch/x86_64/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | arch/x86_64/kapi/acpi.cpp | 32 | ||||
| -rw-r--r-- | arch/x86_64/src/devices/init.cpp | 41 | ||||
| -rw-r--r-- | kapi/include/kapi/acpi.hpp | 12 | ||||
| -rw-r--r-- | kernel/kapi/devices.cpp | 3 | ||||
| -rw-r--r-- | kernel/src/main.cpp | 10 |
6 files changed, 39 insertions, 60 deletions
diff --git a/arch/x86_64/CMakeLists.txt b/arch/x86_64/CMakeLists.txt index 62a2aad..f182651 100644 --- a/arch/x86_64/CMakeLists.txt +++ b/arch/x86_64/CMakeLists.txt @@ -12,7 +12,6 @@ target_link_libraries("x86_64" PUBLIC target_sources("x86_64" PRIVATE # Platform-dependent KAPI implementation - "kapi/acpi.cpp" "kapi/boot_modules.cpp" "kapi/cio.cpp" "kapi/cpu.cpp" diff --git a/arch/x86_64/kapi/acpi.cpp b/arch/x86_64/kapi/acpi.cpp deleted file mode 100644 index 40b7160..0000000 --- a/arch/x86_64/kapi/acpi.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "kapi/acpi.hpp" - -#include "arch/boot/boot.hpp" - -#include <kstd/memory> - -#include <acpi/acpi.hpp> - -namespace kapi::acpi -{ - - auto get_root_pointer() -> kstd::observer_ptr<::acpi::rsdp const> - { - auto const & mbi = kapi::boot::bootstrap_information.mbi; - auto system_description_pointer = static_cast<::acpi::rsdp const *>(nullptr); - - if (auto const & xsdp = mbi->maybe_acpi_xsdp()) - { - auto data = xsdp->pointer().data(); - - system_description_pointer = reinterpret_cast<::acpi::xsdp const *>(data); - } - else if (auto const & rsdp = mbi->maybe_acpi_rsdp()) - { - auto data = rsdp->pointer().data(); - system_description_pointer = reinterpret_cast<::acpi::rsdp const *>(data); - } - - return kstd::make_observer(system_description_pointer); - } - -} // namespace kapi::acpi
\ No newline at end of file diff --git a/arch/x86_64/src/devices/init.cpp b/arch/x86_64/src/devices/init.cpp index 6cba986..7f0faa4 100644 --- a/arch/x86_64/src/devices/init.cpp +++ b/arch/x86_64/src/devices/init.cpp @@ -1,13 +1,18 @@ #include "arch/devices/init.hpp" +#include "kapi/acpi.hpp" +#include "kapi/cpu.hpp" #include "kapi/devices.hpp" +#include "arch/boot/boot.hpp" #include "arch/bus/isa.hpp" #include "arch/devices/legacy_pit.hpp" #include <kstd/memory> #include <kstd/print> +#include <acpi/acpi.hpp> + #include <cstdint> #include <utility> @@ -17,9 +22,41 @@ namespace arch::devices namespace { constexpr auto pit_frequency_in_hz = std::uint32_t{100u}; - } - auto init_acpi_devices() -> void {} + auto get_acpi_root_pointer() -> kstd::observer_ptr<::acpi::rsdp const> + { + auto const & mbi = kapi::boot::bootstrap_information.mbi; + auto system_description_pointer = static_cast<::acpi::rsdp const *>(nullptr); + + if (auto const & xsdp = mbi->maybe_acpi_xsdp()) + { + auto data = xsdp->pointer().data(); + + system_description_pointer = reinterpret_cast<::acpi::xsdp const *>(data); + } + else if (auto const & rsdp = mbi->maybe_acpi_rsdp()) + { + auto data = rsdp->pointer().data(); + system_description_pointer = reinterpret_cast<::acpi::rsdp const *>(data); + } + + return kstd::make_observer(system_description_pointer); + } + } // namespace + + auto init_acpi_devices() -> void + { + auto acpi_root_pointer = get_acpi_root_pointer(); + if (acpi_root_pointer && acpi_root_pointer->validate()) + { + if (kapi::acpi::init(*acpi_root_pointer)) + { + kstd::println("[x86_64:DEV] ACPI subsystem initialized."); + } + } + + kapi::cpu::discover_topology(); + } auto init_legacy_devices() -> void { diff --git a/kapi/include/kapi/acpi.hpp b/kapi/include/kapi/acpi.hpp index 01fd113..2835496 100644 --- a/kapi/include/kapi/acpi.hpp +++ b/kapi/include/kapi/acpi.hpp @@ -35,18 +35,6 @@ namespace kapi::acpi return kstd::make_observer(static_cast<::acpi::table_type_t<Signature> const *>(get_table(Signature).get())); } - //! @} - - //! @addtogroup kapi-acpi-platform-defined - //! @{ - - //! Retrieve the RSDP or XSDP for this system. - //! - //! @return a pointer to either the RSDP or XSDP data structure, or @p nullptr if neither is present. - auto get_root_pointer() -> kstd::observer_ptr<::acpi::rsdp const>; - - //! @} - } // namespace kapi::acpi #endif diff --git a/kernel/kapi/devices.cpp b/kernel/kapi/devices.cpp index b8aa44b..2250319 100644 --- a/kernel/kapi/devices.cpp +++ b/kernel/kapi/devices.cpp @@ -1,6 +1,5 @@ #include "kapi/devices.hpp" -#include "kapi/cpu.hpp" #include "kapi/system.hpp" #include "kernel/devices/root_bus.hpp" @@ -35,8 +34,6 @@ namespace kapi::devices auto & bus = root_bus.emplace(); register_device(bus); bus.init(); - - kapi::cpu::discover_topology(); } auto get_root_bus() -> bus & diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp index 4b61948..b920674 100644 --- a/kernel/src/main.cpp +++ b/kernel/src/main.cpp @@ -1,4 +1,3 @@ -#include "kapi/acpi.hpp" #include "kapi/boot_modules.hpp" #include "kapi/cio.hpp" #include "kapi/cpu.hpp" @@ -184,15 +183,6 @@ auto main() -> int kapi::memory::init_mmio(kapi::memory::mmio_base, 1_GiB / kapi::memory::page::size); kstd::println("[OS] Memory subsystem initialized."); - auto acpi_root_pointer = kapi::acpi::get_root_pointer(); - if (acpi_root_pointer && acpi_root_pointer->validate()) - { - if (kapi::acpi::init(*acpi_root_pointer)) - { - kstd::println("[OS] ACPI subsystem initialized."); - } - } - kapi::devices::init(); kstd::println("[OS] System root bus initialized."); |
