diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-04-06 14:47:37 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-04-06 15:11:47 +0200 |
| commit | 3dcd14a0570fef3bcc68d7df42fe3ff4cd496f93 (patch) | |
| tree | f778c1b23cf63296aab769a02781f83fb7f1ac53 /kernel/src/acpi | |
| parent | 6e54333bcc08ddd8dbcb6aa9c3404001c309ec74 (diff) | |
| download | teachos-3dcd14a0570fef3bcc68d7df42fe3ff4cd496f93.tar.xz teachos-3dcd14a0570fef3bcc68d7df42fe3ff4cd496f93.zip | |
kapi: hook ACPI initialization up to boot process
Diffstat (limited to 'kernel/src/acpi')
| -rw-r--r-- | kernel/src/acpi/manager.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/kernel/src/acpi/manager.cpp b/kernel/src/acpi/manager.cpp new file mode 100644 index 0000000..6a17920 --- /dev/null +++ b/kernel/src/acpi/manager.cpp @@ -0,0 +1,54 @@ +#include "kernel/acpi/manager.hpp" + +#include "kapi/acpi.hpp" +#include "kapi/memory.hpp" +#include "kapi/system.hpp" + +#include <cstddef> + +namespace kernel::acpi +{ + + manager::manager(kapi::acpi::root_system_description_pointer const & sdp) + : m_sdp{&sdp} + { + if (m_sdp->signature() != "RSD PTR ") + { + kapi::system::panic("[OS:ACPI] Invalid RSDP signature!"); + } + + if (m_sdp->revision() >= 2) + { + auto const xsdp = static_cast<kapi::acpi::extended_system_description_pointer const *>(m_sdp); + if (!xsdp->validate()) + { + kapi::system::panic("[OS:ACPI] Invalid XSDP signature!"); + } + auto physical_extended_table_address = xsdp->table_address(); + auto linear_extended_table_address = kapi::memory::hhdm_to_linear(physical_extended_table_address); + m_rsdt = static_cast<kapi::acpi::system_description_table_header const *>(linear_extended_table_address); + m_extended = true; + } + else + { + if (!m_sdp->validate()) + { + kapi::system::panic("[OS:ACPI] Invalid RSDP checksum!"); + } + auto physical_root_table_address = m_sdp->table_address(); + auto linear_root_table_address = kapi::memory::hhdm_to_linear(physical_root_table_address); + m_rsdt = static_cast<kapi::acpi::system_description_table_header const *>(linear_root_table_address); + } + } + + auto manager::load_tables() -> bool + { + if (!kapi::acpi::validate_checksum({reinterpret_cast<std::byte const *>(m_rsdt), m_rsdt->length})) + { + kapi::system::panic("[OS:ACPI] Invalid RSDT checksum!"); + } + + return false; + } + +} // namespace kernel::acpi |
