summaryrefslogtreecommitdiff
path: root/kernel/src/scheduler/switch.S
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/src/scheduler/switch.S')
-rw-r--r--kernel/src/scheduler/switch.S18
1 files changed, 18 insertions, 0 deletions
diff --git a/kernel/src/scheduler/switch.S b/kernel/src/scheduler/switch.S
new file mode 100644
index 0000000..f4d0e79
--- /dev/null
+++ b/kernel/src/scheduler/switch.S
@@ -0,0 +1,18 @@
+#include "x86_64_regs.S"
+
+.global context_switch
+context_switch:
+ /* switch rsp to old task's %rsp */
+
+ /* save all old task's registers */
+ push_caller_saved
+ push_callee_saved
+
+ /* save old task's rsp & rip */
+ call schedule
+ /* get new task's rsp & rip */
+
+ /* restore all new task's registers */
+ pop_callee_saved
+ pop_caller_saved
+ iretq