From dd8dfa3e674d05927e9ed4b7efcb634a634bfdcc Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 10 Apr 2026 10:30:32 +0200 Subject: kapi: move CPU to kapi --- kapi/include/kapi/cpu.hpp | 16 +--------------- kapi/include/kapi/devices.hpp | 1 + kapi/include/kapi/devices/cpu.hpp | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 kapi/include/kapi/devices/cpu.hpp (limited to 'kapi') diff --git a/kapi/include/kapi/cpu.hpp b/kapi/include/kapi/cpu.hpp index c643cd7..e736be1 100644 --- a/kapi/include/kapi/cpu.hpp +++ b/kapi/include/kapi/cpu.hpp @@ -1,13 +1,11 @@ #ifndef TEACHOS_KAPI_CPU_HPP #define TEACHOS_KAPI_CPU_HPP -#include "kapi/devices.hpp" #include "kapi/memory.hpp" #include #include -#include #include namespace kapi::cpu @@ -75,17 +73,6 @@ namespace kapi::cpu //! @return Whether the exception was handled. [[nodiscard]] auto dispatch(exception const & context) -> bool; - //! A hook that is called when the platform detects a CPU core during topology discovery. - //! - //! @param bus The bus the CPU was detected on. - //! @param major The major number of the CPU device. - //! @param minor The minor number of the CPU device. - //! @param hardware_id The hardware specific ID of the CPU core. - //! @param is_bsp Whether the reported CPU is the the bootstrap processor. - //! @param core_interrupt_controller The local interrupt controller of this CPU core. - auto core_detected(kapi::devices::bus & bus, std::size_t major, std::size_t minor, std::uint64_t hardware_id, - bool is_bsp, kstd::unique_ptr core_interrupt_controller) -> bool; - //! @} //! @addtogroup kapi-cpu-platform-defined @@ -104,9 +91,8 @@ namespace kapi::cpu //! Discover the CPU topology of the platform and attach it to the given CPU bus. //! - //! @param bus The bus to attach the CPU topology to. //! @return true iff. the CPU topology was discovered successfully, false otherwise. - auto discover_topology(kapi::devices::bus & bus) -> bool; + auto discover_topology() -> bool; //! @} diff --git a/kapi/include/kapi/devices.hpp b/kapi/include/kapi/devices.hpp index c26efb9..ec154a5 100644 --- a/kapi/include/kapi/devices.hpp +++ b/kapi/include/kapi/devices.hpp @@ -2,6 +2,7 @@ #define TEACHOS_KAPI_DEVICES_HPP #include "kapi/devices/bus.hpp" // IWYU pragma: export +#include "kapi/devices/cpu.hpp" // IWYU pragma: export #include "kapi/devices/device.hpp" // IWYU pragma: export #include "kapi/devices/manager.hpp" // IWYU pragma: export diff --git a/kapi/include/kapi/devices/cpu.hpp b/kapi/include/kapi/devices/cpu.hpp new file mode 100644 index 0000000..00766b5 --- /dev/null +++ b/kapi/include/kapi/devices/cpu.hpp @@ -0,0 +1,37 @@ +#ifndef TEACHOS_KAPI_DEVICES_CPU_HPP +#define TEACHOS_KAPI_DEVICES_CPU_HPP + +#include "kapi/devices/bus.hpp" + +#include +#include + +namespace kapi::devices +{ + + //! A virtual CPU bus to host all CPUs in the system. + struct cpu final : kapi::devices::bus + { + //! A virtual CPU Core to host all core local devices. + struct core final : kapi::devices::bus + { + explicit core(std::size_t major_number, std::size_t minor_number, std::uint64_t hardware_id, bool is_bsp); + + [[nodiscard]] auto hardware_id() const -> std::uint64_t; + [[nodiscard]] auto is_bsp() const -> bool; + + private: + std::uint64_t m_hardware_id; + bool m_is_bsp; + }; + + //! Create a new CPU with the given major and minor numbers. + //! + //! @param major The major number of this CPU + //! @param minor The minor number of this CPU, identifying the physical CPU + cpu(std::size_t major, std::size_t minor); + }; + +} // namespace kapi::devices + +#endif \ No newline at end of file -- cgit v1.2.3