aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/kapi/cpu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/kapi/cpu.cpp')
-rw-r--r--arch/x86_64/kapi/cpu.cpp21
1 files changed, 21 insertions, 0 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");