diff options
Diffstat (limited to 'arch/x86_64')
| -rw-r--r-- | arch/x86_64/arch/devices/local_apic.cpp | 8 | ||||
| -rw-r--r-- | arch/x86_64/arch/devices/local_apic.hpp | 7 | ||||
| -rw-r--r-- | arch/x86_64/kapi/cpu.cpp | 7 |
3 files changed, 16 insertions, 6 deletions
diff --git a/arch/x86_64/arch/devices/local_apic.cpp b/arch/x86_64/arch/devices/local_apic.cpp index b481a667..f3ab8d32 100644 --- a/arch/x86_64/arch/devices/local_apic.cpp +++ b/arch/x86_64/arch/devices/local_apic.cpp @@ -74,9 +74,10 @@ namespace arch::devices divide_configuration = 0x3e0, }; - local_apic::local_apic(std::size_t major, std::size_t minor, std::uint64_t hardware_id, + local_apic::local_apic(std::size_t major, std::size_t minor, std::uint64_t core_index, std::uint64_t hardware_id, kapi::memory::physical_address base, bool is_bsp) : kapi::devices::device{major, minor, "lapic"} + , m_core_index{core_index} , m_hardware_id{hardware_id} , m_base{base} , m_is_bsp{is_bsp} @@ -119,6 +120,11 @@ namespace arch::devices return true; } + auto local_apic::core_index() const noexcept -> std::uint64_t + { + return m_core_index; + } + auto local_apic::read_register(registers id) const -> std::uint32_t { auto reg = static_cast<std::uint32_t volatile *>(m_mapped_region.first + std::to_underlying(id)); diff --git a/arch/x86_64/arch/devices/local_apic.hpp b/arch/x86_64/arch/devices/local_apic.hpp index f8f080dc..3a2d5417 100644 --- a/arch/x86_64/arch/devices/local_apic.hpp +++ b/arch/x86_64/arch/devices/local_apic.hpp @@ -12,17 +12,20 @@ namespace arch::devices struct local_apic : kapi::devices::device { - local_apic(std::size_t major, std::size_t minor, std::uint64_t hardware_id, kapi::memory::physical_address base, - bool is_bsp); + local_apic(std::size_t major, std::size_t minor, std::uint64_t core_index, std::uint64_t hardware_id, + kapi::memory::physical_address base, bool is_bsp); auto init() -> bool override; + [[nodiscard]] auto core_index() const noexcept -> std::uint64_t; + private: enum struct registers : std::ptrdiff_t; [[nodiscard]] auto read_register(registers id) const -> std::uint32_t; auto write_register(registers id, std::uint32_t value) -> void; + std::uint64_t m_core_index{}; std::uint64_t m_hardware_id{}; kapi::memory::physical_address m_base{}; kapi::memory::mmio_region m_mapped_region{}; diff --git a/arch/x86_64/kapi/cpu.cpp b/arch/x86_64/kapi/cpu.cpp index 70cd3635..c51e08b3 100644 --- a/arch/x86_64/kapi/cpu.cpp +++ b/arch/x86_64/kapi/cpu.cpp @@ -74,9 +74,10 @@ namespace kapi::cpu { auto is_bsp = !bsp_found; bsp_found = true; - auto core = kstd::make_unique<devices::cpu::core>(core_major, core_count, apic.processor_id(), is_bsp); - core->add_child(kstd::make_unique<arch::devices::local_apic>(interrupt_controller_major, core_count, apic.id(), - local_apic_address, is_bsp)); + auto core = + kstd::make_unique<devices::cpu::core>(core_major, core_count, core_count, apic.processor_id(), is_bsp); + core->add_child(kstd::make_unique<arch::devices::local_apic>(interrupt_controller_major, core_count, core_count, + apic.id(), local_apic_address, is_bsp)); cpu_bus->add_child(std::move(core)); ++core_count; } |
