From: Amelia Coutard Date: Thu, 5 May 2022 23:25:12 +0000 (+0200) Subject: Changed os::halt to use inline asm instead of an asm routine, and moved the cli instr... X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=1d8bc204e2d384c3a3299805beea19adebd6e7cb;p=voyage-au-centre-des-fichiers.git Changed os::halt to use inline asm instead of an asm routine, and moved the cli instructions around --- diff --git a/src/boot.S b/src/boot.S index 2be4f42..5c331ef 100644 --- a/src/boot.S +++ b/src/boot.S @@ -110,6 +110,7 @@ stack_top: .code32 .globl _start _start: + cli mov $stack_top - KERNEL_VMA, %esp # Save multiboot info: @@ -131,7 +132,6 @@ _start: popfl xor %ecx, %eax jnz .has_cpuid - cli 1: hlt jmp 1b .has_cpuid: @@ -151,7 +151,6 @@ _start: jz .no_long_mode jmp .has_long_mode .no_long_mode: - cli 1: hlt jmp 1b .has_long_mode: diff --git a/src/utils.S b/src/utils.S deleted file mode 100644 index f1287d8..0000000 --- a/src/utils.S +++ /dev/null @@ -1,6 +0,0 @@ -.section .text -.globl halt -halt: - cli -1: hlt - jmp 1b diff --git a/src/utils.cpp b/src/utils.cpp new file mode 100644 index 0000000..6c501aa --- /dev/null +++ b/src/utils.cpp @@ -0,0 +1,9 @@ +#include "utils.hpp" + +void os::halt() { + asm( + "cli\n" + "\t1:\thlt\n" + "\tjmp 1b" + ); +} diff --git a/src/utils.hpp b/src/utils.hpp index 82abfb6..486d7f6 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include namespace os { @@ -38,5 +39,5 @@ namespace os { uintptr_t phys_addr; }; - extern "C" void halt(); + void halt(); } // namespace os