aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/kapi/cpu.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-03-30 11:20:08 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-03-30 11:20:08 +0200
commit706f529722520429860ce60237d4ef71b2b27601 (patch)
treea5a4e89ae3ed25b0af521249134e524a0142814f /arch/x86_64/kapi/cpu.cpp
parent2864e0b061f923a3c73c608b9c27ca4a7116e27c (diff)
parent3070bb45b9741165d786b2c5a018ee55c1a82db8 (diff)
downloadteachos-706f529722520429860ce60237d4ef71b2b27601.tar.xz
teachos-706f529722520429860ce60237d4ef71b2b27601.zip
Merge branch 'fmorgner/interrupt-handling' into develop-BA-FS26
Diffstat (limited to 'arch/x86_64/kapi/cpu.cpp')
-rw-r--r--arch/x86_64/kapi/cpu.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/arch/x86_64/kapi/cpu.cpp b/arch/x86_64/kapi/cpu.cpp
index 2a0f8f7..12edb0f 100644
--- a/arch/x86_64/kapi/cpu.cpp
+++ b/arch/x86_64/kapi/cpu.cpp
@@ -1,8 +1,27 @@
#include "kapi/cpu.hpp"
+#include "kapi/system.hpp"
+
+#include "arch/cpu/initialization.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();
+ }
+
auto halt() -> void
{
asm volatile("1: hlt\njmp 1b");