]> git.ameliathe1st.gay Git - voyage-au-centre-des-fichiers.git/commitdiff
Changed os::halt to use inline asm instead of an asm routine, and moved the cli instr...
authorAmelia Coutard <eliottulio.coutard@gmail.com>
Thu, 5 May 2022 23:25:12 +0000 (01:25 +0200)
committerAmelia Coutard <eliottulio.coutard@gmail.com>
Thu, 5 May 2022 23:25:12 +0000 (01:25 +0200)
src/boot.S
src/utils.S [deleted file]
src/utils.cpp [new file with mode: 0644]
src/utils.hpp

index 2be4f42325942fceb7937825bb9608f6a440b2ec..5c331ef4b51519e874cf659c835d504b85db9cfd 100644 (file)
@@ -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 (file)
index f1287d8..0000000
+++ /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 (file)
index 0000000..6c501aa
--- /dev/null
@@ -0,0 +1,9 @@
+#include "utils.hpp"
+
+void os::halt() {
+       asm(
+               "cli\n"
+               "\t1:\thlt\n"
+               "\tjmp 1b"
+       );
+}
index 82abfb6a7781d1fe312860730a3bebc0a0a3e6ae..486d7f62a7b9d7e05abfd843c20b890ad4b7d26d 100644 (file)
@@ -1,6 +1,7 @@
 #pragma once
 
 #include <stddef.h>
+#include <stdint.h>
 
 namespace os {
 
@@ -38,5 +39,5 @@ namespace os {
                uintptr_t phys_addr;
        };
 
-       extern "C" void halt();
+       void halt();
 } // namespace os