diff --git a/kernel/src/arch/CPU.h b/kernel/src/arch/CPU.h index abf826e3..9d973a3d 100644 --- a/kernel/src/arch/CPU.h +++ b/kernel/src/arch/CPU.h @@ -13,6 +13,8 @@ namespace CPU [[noreturn]] void efficient_halt(); + void idle_loop(); + void switch_kernel_stack(u64 top); void enable_interrupts(); diff --git a/kernel/src/arch/x86_64/CPU.cpp b/kernel/src/arch/x86_64/CPU.cpp index e3ef18a2..8a9346fb 100644 --- a/kernel/src/arch/x86_64/CPU.cpp +++ b/kernel/src/arch/x86_64/CPU.cpp @@ -1,14 +1,14 @@ #include "arch/CPU.h" -#include "arch/x86_64/CPU.h" #include "Log.h" #include "arch/Timer.h" +#include "arch/x86_64/CPU.h" #include "arch/x86_64/IO.h" #include +#include +#include #include #include #include -#include -#include extern "C" void enable_sse(); extern "C" void enable_write_protect(); @@ -430,6 +430,14 @@ namespace CPU goto loop; // Safeguard: if we ever wake up, start our low-power rest again } + void idle_loop() + { + asm volatile("sti"); + loop: + asm volatile("hlt"); + goto loop; + } + void switch_kernel_stack(u64 top) { task_state_segment.rsp[0] = top;