aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/kapi
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-03-24 17:35:54 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-03-27 07:02:35 +0100
commitcb60cdebdc36dd2358fe1ce06eec197e213af491 (patch)
treee16c8aa92be11a1898dea4a955108085c2fe0239 /arch/x86_64/kapi
parent05269b10e50a80f557c2be475904ff15dc1bbec4 (diff)
downloadteachos-cb60cdebdc36dd2358fe1ce06eec197e213af491.tar.xz
teachos-cb60cdebdc36dd2358fe1ce06eec197e213af491.zip
kapi/cpu: introduce CPU API
Diffstat (limited to 'arch/x86_64/kapi')
-rw-r--r--arch/x86_64/kapi/cpu.cpp21
-rw-r--r--arch/x86_64/kapi/system.cpp10
2 files changed, 22 insertions, 9 deletions
diff --git a/arch/x86_64/kapi/cpu.cpp b/arch/x86_64/kapi/cpu.cpp
index 2a0f8f7..693d328 100644
--- a/arch/x86_64/kapi/cpu.cpp
+++ b/arch/x86_64/kapi/cpu.cpp
@@ -1,8 +1,29 @@
#include "kapi/cpu.hpp"
+#include "kapi/system.hpp"
+
+#include "arch/cpu/initialization.hpp"
+#include "arch/cpu/interrupts.hpp"
+
+#include <atomic>
+
namespace kapi::cpu
{
+ auto init() -> void
+ {
+ auto static constinit is_initialized = std::atomic_flag{};
+
+ if (is_initialized.test_and_set())
+ {
+ system::panic("[x86_64] CPU has already been initialized.");
+ }
+
+ arch::cpu::initialize_descriptors();
+ arch::cpu::initialize_legacy_interrupts();
+ arch::cpu::enable_interrupts();
+ }
+
auto halt() -> void
{
asm volatile("1: hlt\njmp 1b");
diff --git a/arch/x86_64/kapi/system.cpp b/arch/x86_64/kapi/system.cpp
index 301169f..09c7152 100644
--- a/arch/x86_64/kapi/system.cpp
+++ b/arch/x86_64/kapi/system.cpp
@@ -1,16 +1,8 @@
#include "kapi/system.hpp"
-#include "arch/cpu/initialization.hpp"
-#include "arch/cpu/interrupts.hpp"
-
namespace kapi::system
{
- auto memory_initialized() -> void
- {
- arch::cpu::initialize_descriptors();
- arch::cpu::initialize_legacy_interrupts();
- arch::cpu::enable_interrupts();
- }
+ auto memory_initialized() -> void {}
} // namespace kapi::system \ No newline at end of file