summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-05-13 16:22:01 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-05-13 16:22:01 +0800
commite7314f76d9edfbee2f676fad90ae6a727403263f (patch)
treea7fac37297ace41cdfef54f49b24ede42f152542
parent6831a609f505ce26db4c5dddad5039c9c3e6747a (diff)
downloadlume-e7314f76d9edfbee2f676fad90ae6a727403263f.tar.gz
lume-e7314f76d9edfbee2f676fad90ae6a727403263f.tar.xz
feat: add ret_from_fork trampoline for newly forked processes
-rw-r--r--na/arch/riscv/trap/swtch.S19
1 files changed, 18 insertions, 1 deletions
diff --git a/na/arch/riscv/trap/swtch.S b/na/arch/riscv/trap/swtch.S
index 8be7904..dbae43d 100644
--- a/na/arch/riscv/trap/swtch.S
+++ b/na/arch/riscv/trap/swtch.S
@@ -76,4 +76,21 @@ kthread_entry_trampoline:
/* kthread_entry should never return, but if it does: */
wfi
- j kthread_entry_trampoline + 12 /* loop on wfi */ \ No newline at end of file
+ j kthread_entry_trampoline + 12 /* loop on wfi */
+
+/* ========================================================================
+ * ret_from_fork
+ *
+ * Trampoline for newly forked processes.
+ * Context is set up by fork() so that s0 contains the TrapFrame pointer.
+ *
+ * Calls the MI-layer C++ function:
+ * void fork_child_entry(TrapFrame* tf);
+ * ======================================================================== */
+ .globl ret_from_fork
+ .align 2
+ret_from_fork:
+ mv a0, s0 /* a0 = TrapFrame pointer */
+ call fork_child_entry /* does not return, eventually calls userret */
+ wfi
+ j ret_from_fork + 8 \ No newline at end of file