diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-03-24 17:35:54 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-03-27 07:02:35 +0100 |
| commit | cb60cdebdc36dd2358fe1ce06eec197e213af491 (patch) | |
| tree | e16c8aa92be11a1898dea4a955108085c2fe0239 /arch/x86_64/kapi/cpu.cpp | |
| parent | 05269b10e50a80f557c2be475904ff15dc1bbec4 (diff) | |
| download | teachos-cb60cdebdc36dd2358fe1ce06eec197e213af491.tar.xz teachos-cb60cdebdc36dd2358fe1ce06eec197e213af491.zip | |
kapi/cpu: introduce CPU API
Diffstat (limited to 'arch/x86_64/kapi/cpu.cpp')
| -rw-r--r-- | arch/x86_64/kapi/cpu.cpp | 21 |
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"); |
