diff options
Diffstat (limited to 'arch/x86_64/kapi')
| -rw-r--r-- | arch/x86_64/kapi/devices.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/arch/x86_64/kapi/devices.cpp b/arch/x86_64/kapi/devices.cpp index d9a0b2b9..888b6e20 100644 --- a/arch/x86_64/kapi/devices.cpp +++ b/arch/x86_64/kapi/devices.cpp @@ -2,11 +2,15 @@ #include <arch/bus/cpu.hpp> #include <arch/devices/init.hpp> -#include <arch/drivers/init.hpp> +#include <kapi/devices/driver_registry.hpp> #include <kapi/system.hpp> #include <kstd/memory.hpp> +#include <kstd/print.hpp> + +#include <ranges> +#include <span> namespace kapi::devices { @@ -16,9 +20,27 @@ namespace kapi::devices auto static constinit cpu_bus = kstd::shared_ptr<arch::bus::cpu>{}; } + extern "C" + { + // We need to suppress clang-tidy linting warnings here, since these symbols are generated by the linker and we + // cannot choose their names, unless we wanted to extend the linker script needlessly. + // NOLINTBEGIN(readability-identifier-naming) + extern kstd::observer_ptr<kapi::devices::driver_descriptor> const __start_platform_drivers; + extern kstd::observer_ptr<kapi::devices::driver_descriptor> const __stop_platform_drivers; + // NOLINTEND(readability-identifier-naming) + } + auto init_platform_drivers() -> void { - arch::drivers::init_legacy_drivers(); + auto descriptors = std::span{&__start_platform_drivers, &__stop_platform_drivers} | // + std::views::filter([](auto p) { return p != nullptr; }); + + for (auto driver : descriptors) + { + auto instance = driver->make_instance(); + kstd::println("[x86_64:DRV] registering driver '{}' ({})", instance->name(), driver->name()); + kapi::devices::driver_registry::get().add(driver->make_instance()); + } } auto init_platform_devices() -> void |
