diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-07-28 13:38:22 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-07-28 13:38:22 +0200 |
| commit | c2f5b9258b3e151e20452f964d63ade6c6378daa (patch) | |
| tree | 7bf748e09e34d1484a2fdc550995522718f89844 | |
| parent | 36248bb63a396dfea762d5b2cf028bf4b7a2b62e (diff) | |
| download | kernel-c2f5b9258b3e151e20452f964d63ade6c6378daa.tar.xz kernel-c2f5b9258b3e151e20452f964d63ade6c6378daa.zip | |
chore: post refactoring cleanup
| -rw-r--r-- | arch/x86_64/arch/bus/cpu.cpp | 6 | ||||
| -rw-r--r-- | arch/x86_64/arch/bus/cpu.hpp | 2 | ||||
| -rw-r--r-- | arch/x86_64/arch/devices/cpu/core.hpp | 2 | ||||
| -rw-r--r-- | arch/x86_64/arch/devices/cpu/lapic.cpp | 8 | ||||
| -rw-r--r-- | arch/x86_64/arch/devices/cpu/lapic.hpp | 6 | ||||
| -rw-r--r-- | arch/x86_64/arch/drivers/lapic.cpp | 2 | ||||
| -rw-r--r-- | arch/x86_64/kapi/devices.cpp | 2 | ||||
| -rw-r--r-- | kernel/kernel/test_support/kapi/cpu.cpp | 6 |
8 files changed, 15 insertions, 19 deletions
diff --git a/arch/x86_64/arch/bus/cpu.cpp b/arch/x86_64/arch/bus/cpu.cpp index 3b5f9804..0a0e94ec 100644 --- a/arch/x86_64/arch/bus/cpu.cpp +++ b/arch/x86_64/arch/bus/cpu.cpp @@ -15,6 +15,7 @@ #include <kstd/result.hpp> #include <kstd/units.hpp> +#include <cstddef> #include <cstdint> #include <ranges> @@ -52,11 +53,12 @@ namespace arch::bus { auto [index, apic] = entry; auto is_bsp = !bsp_found; + auto core_number = static_cast<std::size_t>(index); - auto core = kstd::make_shared<devices::cpu::core>(index, apic.processor_id(), is_bsp); + auto core = kstd::make_shared<devices::cpu::core>(core_number, apic.processor_id(), is_bsp); bus.add_child(core); - auto lapic = kstd::make_shared<devices::cpu::lapic>(index, apic.id(), is_bsp); + auto lapic = kstd::make_shared<devices::cpu::lapic>(core_number, apic.id(), is_bsp); auto lapic_range = kapi::devices::mmio_range{.start = local_apic_address, .size = lapic_mmio_range_size}; lapic->set_resources({kapi::devices::resource{lapic_range}}); bus.add_child(lapic); diff --git a/arch/x86_64/arch/bus/cpu.hpp b/arch/x86_64/arch/bus/cpu.hpp index c4378493..22afb4ae 100644 --- a/arch/x86_64/arch/bus/cpu.hpp +++ b/arch/x86_64/arch/bus/cpu.hpp @@ -51,7 +51,7 @@ namespace arch::bus [[nodiscard]] virtual auto hardware_id() const noexcept -> std::uint64_t = 0; //! Whether this local APIC belongs to the bootstrap processor. - [[nodiscard]] virtual auto belongs_to_bsp() const noexcept -> bool = 0; + [[nodiscard]] virtual auto is_bsp() const noexcept -> bool = 0; }; //! The claim facet used to match the local APIC driver against a local APIC device. diff --git a/arch/x86_64/arch/devices/cpu/core.hpp b/arch/x86_64/arch/devices/cpu/core.hpp index 64c3ed17..cd5ac65c 100644 --- a/arch/x86_64/arch/devices/cpu/core.hpp +++ b/arch/x86_64/arch/devices/cpu/core.hpp @@ -25,8 +25,6 @@ namespace arch::devices::cpu private: std::uint64_t m_id; bool m_is_bsp; - - public: }; } // namespace arch::devices::cpu diff --git a/arch/x86_64/arch/devices/cpu/lapic.cpp b/arch/x86_64/arch/devices/cpu/lapic.cpp index 3abb18e6..280ebbca 100644 --- a/arch/x86_64/arch/devices/cpu/lapic.cpp +++ b/arch/x86_64/arch/devices/cpu/lapic.cpp @@ -13,10 +13,10 @@ namespace arch::devices::cpu { - lapic::lapic(std::size_t index, std::uint64_t id, bool on_bsp) + lapic::lapic(std::size_t index, std::uint64_t id, bool is_bsp) : device{kstd::format("lapic{}", index)} , m_id{id} - , m_belongs_to_bsp{on_bsp} + , m_is_bsp{is_bsp} {} auto lapic::hardware_id() const noexcept -> std::uint64_t @@ -24,9 +24,9 @@ namespace arch::devices::cpu return m_id; } - auto lapic::belongs_to_bsp() const noexcept -> bool + auto lapic::is_bsp() const noexcept -> bool { - return m_belongs_to_bsp; + return m_is_bsp; } auto lapic::query_facet(kapi::capabilities::facet_id facet) -> void * diff --git a/arch/x86_64/arch/devices/cpu/lapic.hpp b/arch/x86_64/arch/devices/cpu/lapic.hpp index 10dc71f3..52ae40ae 100644 --- a/arch/x86_64/arch/devices/cpu/lapic.hpp +++ b/arch/x86_64/arch/devices/cpu/lapic.hpp @@ -14,17 +14,17 @@ namespace arch::devices::cpu struct lapic final : kapi::devices::device, arch::bus::lapic_signature { - lapic(std::size_t index, std::uint64_t id, bool on_bsp); + lapic(std::size_t index, std::uint64_t id, bool is_bsp); [[nodiscard]] auto hardware_id() const noexcept -> std::uint64_t override; - [[nodiscard]] auto belongs_to_bsp() const noexcept -> bool override; + [[nodiscard]] auto is_bsp() const noexcept -> bool override; protected: auto query_facet(kapi::capabilities::facet_id facet) -> void * override; private: std::uint64_t m_id; - bool m_belongs_to_bsp; + bool m_is_bsp; }; } // namespace arch::devices::cpu diff --git a/arch/x86_64/arch/drivers/lapic.cpp b/arch/x86_64/arch/drivers/lapic.cpp index 86d851f9..270c04ce 100644 --- a/arch/x86_64/arch/drivers/lapic.cpp +++ b/arch/x86_64/arch/drivers/lapic.cpp @@ -115,7 +115,7 @@ namespace arch::drivers m_is_mapped = true; } - if (signature->belongs_to_bsp()) + if (signature->is_bsp()) { auto raw_version = read_register(registers::version); auto version = (raw_version >> offset_of_version) & 0xff; diff --git a/arch/x86_64/kapi/devices.cpp b/arch/x86_64/kapi/devices.cpp index 04b6fa2d..62754f08 100644 --- a/arch/x86_64/kapi/devices.cpp +++ b/arch/x86_64/kapi/devices.cpp @@ -44,6 +44,8 @@ namespace kapi::devices system::panic("[x86_64:DEV] The CPU topology has already been initialized!"); } + kapi::devices::get_root_bus()->add_child(cpu_bus); + cpu_bus = kstd::make_shared<arch::bus::cpu>(); cpu_bus->facet<kapi::devices::bus_protocol>()->enumerate(*cpu_bus); } diff --git a/kernel/kernel/test_support/kapi/cpu.cpp b/kernel/kernel/test_support/kapi/cpu.cpp index a82dc348..b9c858d7 100644 --- a/kernel/kernel/test_support/kapi/cpu.cpp +++ b/kernel/kernel/test_support/kapi/cpu.cpp @@ -30,12 +30,6 @@ namespace kapi::cpu throw kernel::tests::cpu::halt{}; } - auto discover_topology() -> bool - { - // TODO: implement more meaningful simulated CPU topology discovery - return true; - } - auto current_id() -> id { return id{.value = std::hash<std::thread::id>{}(std::this_thread::get_id())}; |
