#include #include #include #include #include #include #include #include #include namespace kapi::devices { namespace { auto static constinit cpu_bus = kstd::shared_ptr{}; } 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 const __start_platform_drivers; extern kstd::observer_ptr const __stop_platform_drivers; // NOLINTEND(readability-identifier-naming) } auto init_platform_drivers() -> void { 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 { arch::devices::init_acpi_devices(); arch::devices::init_legacy_devices(); } auto get_cpu_bus() -> kstd::shared_ptr { if (!cpu_bus) { system::panic("[x86_64:DEV] The CPU topology has not yet been initialized!"); } return cpu_bus; } auto discover_cpu_topology() -> void { if (cpu_bus) { system::panic("[x86_64:DEV] The CPU topology has already been initialized!"); } cpu_bus = kstd::make_shared(); cpu_bus->facet()->enumerate(*cpu_bus); kapi::devices::get_root_bus()->add_child(cpu_bus); } } // namespace kapi::devices