From 8fd53ea9b2559a63043f584f4320c834114096e3 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 27 Oct 2022 03:18:24 +0300 Subject: [PATCH] Improved CPU functions --- include/cpu.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/include/cpu.hpp b/include/cpu.hpp index d087330..0d43aea 100644 --- a/include/cpu.hpp +++ b/include/cpu.hpp @@ -136,13 +136,16 @@ namespace CPU /** * @brief Pause the CPU */ - __attribute__((no_stack_protector)) static inline void Pause() + __attribute__((no_stack_protector)) static inline void Pause(bool Loop = false) { + do + { #if defined(__amd64__) || defined(__i386__) - asmv("pause"); + asmv("pause"); #elif defined(__aarch64__) - asmv("yield"); + asmv("yield"); #endif + } while (Loop); } /** @@ -167,13 +170,16 @@ namespace CPU /** * @brief Halt the CPU */ - __attribute__((no_stack_protector)) static inline void Halt() + __attribute__((no_stack_protector)) static inline void Halt(bool Loop = false) { + do + { #if defined(__amd64__) || defined(__i386__) - asmv("hlt"); + asmv("hlt"); #elif defined(__aarch64__) - asmv("wfe"); + asmv("wfe"); #endif + } while (Loop); } /**