diff options
| author | Lukas Oesch <lukas.oesch@ost.ch> | 2026-06-10 10:40:46 +0200 |
|---|---|---|
| committer | Lukas Oesch <lukas.oesch@ost.ch> | 2026-06-10 10:40:46 +0200 |
| commit | 33abd5cf264cb9e34121082105b0bc17b3cf7a36 (patch) | |
| tree | 36b15d53fea04f4f9d9af817100f7ad013bd9b5c /arch/x86_64/kapi/boot_modules.cpp | |
| parent | d01caf1c4aef3c89c68b9d1cc9fe56445f0860b5 (diff) | |
| parent | 7e27130c342b7299a1d2188a7192a7f17b5ac2ad (diff) | |
| download | kernel-33abd5cf264cb9e34121082105b0bc17b3cf7a36.tar.xz kernel-33abd5cf264cb9e34121082105b0bc17b3cf7a36.zip | |
Merge of BA-FS26 branch into develop
See merge request teachos/kernel!49
Diffstat (limited to 'arch/x86_64/kapi/boot_modules.cpp')
| -rw-r--r-- | arch/x86_64/kapi/boot_modules.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/arch/x86_64/kapi/boot_modules.cpp b/arch/x86_64/kapi/boot_modules.cpp new file mode 100644 index 0000000..fb6bf46 --- /dev/null +++ b/arch/x86_64/kapi/boot_modules.cpp @@ -0,0 +1,53 @@ +#include <kapi/boot_modules.hpp> + +#include <arch/boot/boot.hpp> +#include <arch/boot/ld.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 <kstd/print> + +#include <multiboot2/information.hpp> + +#include <algorithm> +#include <atomic> +#include <bit> +#include <cstdint> +#include <optional> + +namespace kapi::boot_modules +{ + namespace + { + auto constinit registry = std::optional<kapi::boot_modules::boot_module_registry>{}; + } // 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<std::uintptr_t>(&arch::boot::TEACHOS_VMA)}, + .size = module.end_address - module.start_address, + }); + }); + + set_boot_module_registry(*registry); + } +} // namespace kapi::boot_modules
\ No newline at end of file |
