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

[tyndur-devel] [PATCH 1/2] kernel2: cpu_prepare_current_task



* kernel2: Architekturspezifischen Teil des Taskwechsels
  (TSS-Manipulationen) in eine eigene Funktion ausgelagert

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/kernel2/include/arch/i386/cpu.h |    5 +++++
 src/kernel2/src/arch/i386/cpu.c     |   19 +++++++++++++++++++
 src/kernel2/src/interrupts/im.c     |   12 +-----------
 3 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/src/kernel2/include/arch/i386/cpu.h b/src/kernel2/include/arch/i386/cpu.h
index bbc01b9..23c673b 100644
--- a/src/kernel2/include/arch/i386/cpu.h
+++ b/src/kernel2/include/arch/i386/cpu.h
@@ -137,5 +137,10 @@ uint64_t cpu_read_msr(uint32_t reg);
 cpu_t* cpu_get_current(void);
 void cpu_dump(machine_state_t* machine_state);
 
+/**
+ * Wird aufgerufen, nachdem zu einem neuen Task gewechselt wurde
+ */
+void cpu_prepare_current_task(void);
+
 #endif //ifndef _CPU_H_
 
diff --git a/src/kernel2/src/arch/i386/cpu.c b/src/kernel2/src/arch/i386/cpu.c
index 194b13a..c170755 100644
--- a/src/kernel2/src/arch/i386/cpu.c
+++ b/src/kernel2/src/arch/i386/cpu.c
@@ -153,3 +153,22 @@ void cpu_dump(machine_state_t* machine_state)
         machine_state->fs, machine_state->gs, machine_state->ss);
 }
 
+/**
+ * Wird aufgerufen, nachdem zu einem neuen Task gewechselt wurde
+ */
+void cpu_prepare_current_task(void)
+{
+    pm_thread_t* thread = current_thread;
+    interrupt_stack_frame_t* isf = thread->kernel_stack;
+
+    cpu_get_current()->tss.ss0 = 2 << 3;
+    if (isf->eflags & 0x20000) {
+        cpu_get_current()->tss.esp0 =
+            (uintptr_t) thread->user_isf
+            + sizeof(struct vm86_isf);
+    } else {
+        cpu_get_current()->tss.esp0 =
+            (uintptr_t) thread->user_isf
+            + sizeof(interrupt_stack_frame_t);
+    }
+}
diff --git a/src/kernel2/src/interrupts/im.c b/src/kernel2/src/interrupts/im.c
index 425d7bc..4472947 100644
--- a/src/kernel2/src/interrupts/im.c
+++ b/src/kernel2/src/interrupts/im.c
@@ -216,18 +216,8 @@ interrupt_stack_frame_t* im_prepare_current_thread(void)
     pm_thread_t* thread = current_thread;
     interrupt_stack_frame_t* isf = thread->kernel_stack;
 
-    cpu_get_current()->tss.ss0 = 2 << 3;
-    if (isf->eflags & 0x20000) {
-        cpu_get_current()->tss.esp0 =
-            (uintptr_t) thread->user_isf
-            + sizeof(struct vm86_isf);
-    } else {
-        cpu_get_current()->tss.esp0 =
-            (uintptr_t) thread->user_isf
-            + sizeof(interrupt_stack_frame_t);
-    }
-
     mmc_activate(&thread->process->context);
+    cpu_prepare_current_task();
 
     return isf;
 }
-- 
1.6.0.2