aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/kapi/platform.cpp17
-rw-r--r--kapi/include/kapi/platform.hpp7
-rw-r--r--kernel/kapi/platform.cpp15
3 files changed, 16 insertions, 23 deletions
diff --git a/arch/x86_64/kapi/platform.cpp b/arch/x86_64/kapi/platform.cpp
index 2e7c7e4..380fc66 100644
--- a/arch/x86_64/kapi/platform.cpp
+++ b/arch/x86_64/kapi/platform.cpp
@@ -10,7 +10,7 @@
#include <kstd/print>
#include <cstddef>
-#include <cstdint>
+#include <utility>
namespace kapi::platform
{
@@ -22,6 +22,10 @@ namespace kapi::platform
auto discover_cpu_topology(kapi::devices::bus & bus) -> bool
{
+ auto static const core_major = kapi::devices::allocate_major_number();
+ auto static const interrupt_controller_major = kapi::devices::allocate_major_number();
+ auto static core_index = 0uz;
+
auto madt = kapi::acpi::get_table("APIC");
if (!madt)
{
@@ -46,7 +50,10 @@ namespace kapi::platform
auto is_bsp = !bsp_found;
bsp_found = true;
- if (kapi::platform::cpu_detected(bus, local_apic->processor_id(), is_bsp))
+ auto lapic = kstd::make_unique<arch::devices::local_apic>(interrupt_controller_major, core_index,
+ local_apic->apic_id(), default_lapic_address);
+ if (kapi::platform::cpu_detected(bus, core_major, core_index, local_apic->processor_id(), is_bsp,
+ std::move(lapic)))
{
++core_count;
}
@@ -61,10 +68,4 @@ namespace kapi::platform
return core_count > 0;
}
- auto create_core_interrupt_controller(std::size_t major, std::size_t minor, std::uint64_t hardware_id)
- -> kstd::unique_ptr<devices::device>
- {
- return kstd::make_unique<arch::devices::local_apic>(major, minor, hardware_id, default_lapic_address);
- }
-
} // namespace kapi::platform \ No newline at end of file
diff --git a/kapi/include/kapi/platform.hpp b/kapi/include/kapi/platform.hpp
index 6aae795..e1e267e 100644
--- a/kapi/include/kapi/platform.hpp
+++ b/kapi/include/kapi/platform.hpp
@@ -14,8 +14,8 @@ namespace kapi::platform
//! @addtogroup kapi-platform-kernel-defined
//! @{
- auto cpu_detected(kapi::devices::bus & bus, std::uint64_t hardware_id, bool is_bsp) -> bool;
-
+ auto cpu_detected(kapi::devices::bus & bus, std::size_t major, std::size_t minor, std::uint64_t hardware_id,
+ bool is_bsp, kstd::unique_ptr<devices::device> core_interrupt_controller) -> bool;
//! @}
//! @addtogroup kapi-platform-platform-defined
@@ -27,9 +27,6 @@ namespace kapi::platform
//! @return true iff. the CPU topology was discovered successfully, false otherwise.
auto discover_cpu_topology(kapi::devices::bus & bus) -> bool;
- auto create_core_interrupt_controller(std::size_t major, std::size_t minor, std::uint64_t hardware_id)
- -> kstd::unique_ptr<devices::device>;
-
//! @}
} // namespace kapi::platform
diff --git a/kernel/kapi/platform.cpp b/kernel/kapi/platform.cpp
index deb72de..7638cf9 100644
--- a/kernel/kapi/platform.cpp
+++ b/kernel/kapi/platform.cpp
@@ -6,26 +6,21 @@
#include <kstd/memory>
+#include <cstddef>
#include <cstdint>
#include <utility>
namespace kapi::platform
{
- auto cpu_detected(kapi::devices::bus & bus, std::uint64_t hardware_id, bool is_bsp) -> bool
+ auto cpu_detected(kapi::devices::bus & bus, std::size_t major, std::size_t minor, std::uint64_t hardware_id,
+ bool is_bsp, kstd::unique_ptr<devices::device> core_interrupt_controller) -> bool
{
- auto static const core_major = kapi::devices::allocate_major_number();
- auto static const interrupt_controller_major = kapi::devices::allocate_major_number();
- auto static core_index = 0uz;
+ auto core = kstd::make_unique<kernel::devices::cpu::core>(major, minor, hardware_id, is_bsp);
- auto core = kstd::make_unique<kernel::devices::cpu::core>(core_major, core_index, hardware_id, is_bsp);
- auto lapic = kapi::platform::create_core_interrupt_controller(interrupt_controller_major, core_index, hardware_id);
-
- core->add_child(std::move(lapic));
+ core->add_child(std::move(core_interrupt_controller));
bus.add_child(std::move(core));
- ++core_index;
-
return true;
}