[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH 4/6] kernel2: cpu_halt eingeführt



+ cpu.h: cpu_halt zum anhalten der CPU
* init.c, im.c: verwendet jetzt cpu_halt statt direktem Inline-
  Assembler und wird so ein Stück architekturunabhängiger

Signed-off-by: Andreas Freimuth <m.nemo@xxxxxxx>
---
 src/kernel2/include/arch/amd64/cpu.h |    7 +++++++
 src/kernel2/include/arch/i386/cpu.h  |    7 +++++++
 src/kernel2/src/init.c               |    2 +-
 src/kernel2/src/interrupts/im.c      |    4 ++--
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/kernel2/include/arch/amd64/cpu.h b/src/kernel2/include/arch/amd64/cpu.h
index f4ab11e..ec13819 100644
--- a/src/kernel2/include/arch/amd64/cpu.h
+++ b/src/kernel2/include/arch/amd64/cpu.h
@@ -111,5 +111,12 @@ mmc_context_t cpu_get_context();
  */
 void io_activate_bitmap(pm_process_t* task);
 
+/**
+ * Hält die CPU an
+ */
+static inline void cpu_halt(void) {
+    asm volatile ("cli; hlt");
+}
+
 #endif //ifndef _CPU_H_
 
diff --git a/src/kernel2/include/arch/i386/cpu.h b/src/kernel2/include/arch/i386/cpu.h
index 1275496..db407bd 100644
--- a/src/kernel2/include/arch/i386/cpu.h
+++ b/src/kernel2/include/arch/i386/cpu.h
@@ -185,5 +185,12 @@ void cpu_prepare_current_task(void);
  */
 void io_activate_bitmap(pm_process_t* task);
 
+/**
+ * Hält die CPU an.
+ */
+static inline void cpu_halt(void) {
+    asm volatile ("cli; hlt");
+}
+
 #endif //ifndef _CPU_H_
 
diff --git a/src/kernel2/src/init.c b/src/kernel2/src/init.c
index bb3b182..f754122 100644
--- a/src/kernel2/src/init.c
+++ b/src/kernel2/src/init.c
@@ -291,6 +291,6 @@ __attribute__((noreturn)) void panic(char * message, ...)
     
 
     while(1) {
-      __asm__ __volatile__("cli; hlt");
+      cpu_halt();
     }
 }
diff --git a/src/kernel2/src/interrupts/im.c b/src/kernel2/src/interrupts/im.c
index 9879f98..4e95be2 100644
--- a/src/kernel2/src/interrupts/im.c
+++ b/src/kernel2/src/interrupts/im.c
@@ -137,12 +137,12 @@ interrupt_stack_frame_t* im_handler(interrupt_stack_frame_t* isf)
     } else if (int_num == 0xF0) {
         // Interrupt um Prozessor anzuhalten
         kprintf("\n[CPU%d] Angehalten", cpu_get_current()->id);
-        asm("cli; hlt");
+        cpu_halt();
     } else {
         kprintf("Interrupt %d\n", int_num);
         if (int_num == 252) {
             apic_ipi_broadcast(0xF0, true);
-            asm("cli; hlt");
+            cpu_halt();
         }
     }
 
-- 
1.7.4.4