aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-04-10 17:49:40 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-04-10 17:49:40 +0200
commit21fd1281cf19572e202d583689b99c33ec68da50 (patch)
tree3325e00e4ccfe95db42be7a38a48350681c1c79f /arch/x86_64/src
parentc3f7b747f02a79b34ed914c54ce74be973b17af1 (diff)
downloadteachos-21fd1281cf19572e202d583689b99c33ec68da50.tar.xz
teachos-21fd1281cf19572e202d583689b99c33ec68da50.zip
kernel: let arch initialize the ACPI manager
Diffstat (limited to 'arch/x86_64/src')
-rw-r--r--arch/x86_64/src/devices/init.cpp41
1 files changed, 39 insertions, 2 deletions
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
{