aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv/kernel/proc.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2021-12-19 17:10:36 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2021-12-19 17:10:36 +0200
commit9966b49db468de0168c7a455dfb5b4c66c413c4d (patch)
treedf31febe5e1ae52bae68ebe1df8b4469b97e0546 /arch/riscv/kernel/proc.c
parent8bb1e280280c2f30740defca68ea643c56a3d880 (diff)
downloadkmi-9966b49db468de0168c7a455dfb5b4c66c413c4d.tar.gz
kmi-9966b49db468de0168c7a455dfb5b4c66c413c4d.zip
Massive changes to jump to userspace
Diffstat (limited to 'arch/riscv/kernel/proc.c')
-rw-r--r--arch/riscv/kernel/proc.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/riscv/kernel/proc.c b/arch/riscv/kernel/proc.c
new file mode 100644
index 0000000..3a39dd3
--- /dev/null
+++ b/arch/riscv/kernel/proc.c
@@ -0,0 +1,15 @@
+#include <apos/tcb.h>
+#include <apos/elf.h>
+#include <csr.h>
+
+void jump_to_userspace(struct tcb *t, char **argv, int argc)
+{
+ csr_write(CSR_SEPC, bin_entry(t->bin));
+ __asm__("mv sp, %0\n" : "=r" (t->stack) :: "memory");
+ __asm__("sret\n" ::: "memory");
+}
+
+void return_to_userspace(struct tcb *t)
+{
+ /* lol */
+}