#include "kapi/boot_modules.hpp" #include "kapi/boot.hpp" #include "kapi/boot_module/boot_module.hpp" #include "kapi/boot_module/boot_module_registry.hpp" #include "kapi/memory.hpp" #include "kapi/system.hpp" #include "arch/boot/boot.hpp" #include "arch/boot/ld.hpp" #include #include #include #include #include #include #include namespace kapi::boot_modules { namespace { auto constinit registry = std::optional{}; } // namespace auto init() -> void { auto static constinit is_initialized = std::atomic_flag{}; if (is_initialized.test_and_set()) { system::panic("[x86_64] Boot module registry has already been initialized."); } kstd::println("[x86_64:BOOT_MODULES] Initializing boot module registry."); registry.emplace(kapi::boot_modules::boot_module_registry{}); auto modules = boot::bootstrap_information.mbi->modules(); std::ranges::for_each(modules, [](auto const & module) { registry->add_boot_module(kapi::boot_modules::boot_module{ .name = module.string(), .start_address = memory::linear_address{module.start_address + std::bit_cast(&arch::boot::TEACHOS_VMA)}, .size = module.end_address - module.start_address, }); }); set_boot_module_registry(*registry); } } // namespace kapi::boot_modules