BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / d46e09a34ca8cd546f3a4312976cf3b6a5a55ccf / task / switch.S

// Related

Nucleus

Barry Improved context switching and interrupt handling d46e09a (3 years, 2 months ago)
diff --git a/task/switch.S b/task/switch.S
new file mode 100644
index 0000000..5ef5437
--- /dev/null
+++ b/task/switch.S
@@ -0,0 +1,21 @@
+/*
+ * This file contains the context switch routine.  This routine will switch the
+ * current context, but will not save any state, so it should only be called by
+ * the scheduler.  Since the stack and page directory will get switched, care
+ * must be taken to read and set the registers in the correct order.
+ */
+
+/* Perform a context switch */
+.globl context_switch
+context_switch:
+	cli
+	mov 4(%esp), %ecx
+	mov 8(%esp), %eax
+	mov 12(%esp), %esi
+	mov 16(%esp), %edi
+	mov 20(%esp), %ebx
+	mov 24(%esp), %ebp
+	mov 28(%esp), %esp
+	mov %eax, %cr3
+	sti
+	jmp *%ecx