aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/kapi/devices.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/kapi/devices.cpp')
-rw-r--r--arch/x86_64/kapi/devices.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/arch/x86_64/kapi/devices.cpp b/arch/x86_64/kapi/devices.cpp
index 748e0a6a..04b6fa2d 100644
--- a/arch/x86_64/kapi/devices.cpp
+++ b/arch/x86_64/kapi/devices.cpp
@@ -1,11 +1,21 @@
#include <kapi/devices.hpp>
+#include <arch/bus/cpu.hpp>
#include <arch/devices/init.hpp>
#include <arch/drivers/init.hpp>
+#include <kapi/system.hpp>
+
+#include <kstd/memory.hpp>
+
namespace kapi::devices
{
+ namespace
+ {
+ auto static constinit cpu_bus = kstd::shared_ptr<arch::bus::cpu>{};
+ }
+
auto init_platform_drivers() -> void
{
arch::drivers::init_legacy_drivers();
@@ -17,4 +27,25 @@ namespace kapi::devices
arch::devices::init_legacy_devices();
}
+ auto get_cpu_bus() -> kstd::shared_ptr<bus>
+ {
+ 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<arch::bus::cpu>();
+ cpu_bus->facet<kapi::devices::bus_protocol>()->enumerate(*cpu_bus);
+ }
+
} // namespace kapi::devices \ No newline at end of file