summaryrefslogtreecommitdiff
path: root/user/uthread_switch.S
diff options
context:
space:
mode:
authorMole Shang <[email protected]>2024-02-19 14:10:32 +0800
committerMole Shang <[email protected]>2024-02-19 14:36:21 +0800
commitd86118fc80267649b4791c8c0c72ebd60edf1ef2 (patch)
treeb792b617b4df80a5803a9c1164d0e3fdfe9cfe31 /user/uthread_switch.S
parentb20ef9d0210fd7d9403acde1857eed1b9880c0b2 (diff)
parent0cf897cbe05fd8485162619db4244f4159d0eb52 (diff)
downloadxv6-labs-d86118fc80267649b4791c8c0c72ebd60edf1ef2.tar.gz
xv6-labs-d86118fc80267649b4791c8c0c72ebd60edf1ef2.tar.bz2
xv6-labs-d86118fc80267649b4791c8c0c72ebd60edf1ef2.zip
Merge branch 'fs' into mmap
Conflicts: .gitignore Makefile conf/lab.mk kernel/defs.h user/user.h
Diffstat (limited to 'user/uthread_switch.S')
-rw-r--r--user/uthread_switch.S39
1 files changed, 39 insertions, 0 deletions
diff --git a/user/uthread_switch.S b/user/uthread_switch.S
new file mode 100644
index 0000000..19cc400
--- /dev/null
+++ b/user/uthread_switch.S
@@ -0,0 +1,39 @@
+ .text
+
+ /*
+ * save the old thread's registers,
+ * restore the new thread's registers.
+ */
+
+ .globl thread_switch
+thread_switch:
+ sd ra, 0(a0)
+ sd sp, 8(a0)
+ sd s0, 16(a0)
+ sd s1, 24(a0)
+ sd s2, 32(a0)
+ sd s3, 40(a0)
+ sd s4, 48(a0)
+ sd s5, 56(a0)
+ sd s6, 64(a0)
+ sd s7, 72(a0)
+ sd s8, 80(a0)
+ sd s9, 88(a0)
+ sd s10, 96(a0)
+ sd s11, 104(a0)
+
+ ld ra, 0(a1)
+ ld sp, 8(a1)
+ ld s0, 16(a1)
+ ld s1, 24(a1)
+ ld s2, 32(a1)
+ ld s3, 40(a1)
+ ld s4, 48(a1)
+ ld s5, 56(a1)
+ ld s6, 64(a1)
+ ld s7, 72(a1)
+ ld s8, 80(a1)
+ ld s9, 88(a1)
+ ld s10, 96(a1)
+ ld s11, 104(a1)
+ ret /* return to ra */