diff options
Diffstat (limited to 'arch/riscv64')
| -rw-r--r-- | arch/riscv64/kernel/proc.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/arch/riscv64/kernel/proc.c b/arch/riscv64/kernel/proc.c index f85f597..10f8bfa 100644 --- a/arch/riscv64/kernel/proc.c +++ b/arch/riscv64/kernel/proc.c @@ -8,10 +8,13 @@ #include <apos/tcb.h> #include <apos/elf.h> + +#include <arch/proc.h> + #include "regs.h" #include "csr.h" -stat_t run_init(struct tcb *t, void *fdt) +void run_init(struct tcb *t, void *fdt) { /** \todo actually map fdt into the target address space */ csr_write(CSR_SSCRATCH, t); @@ -20,18 +23,27 @@ stat_t run_init(struct tcb *t, void *fdt) __asm__ volatile ("mv a0, %0\n" : : "r" (fdt) : ); __asm__ volatile ("sret\n" ::: "memory"); /* we should never reach this */ - return ERR_ADDR; + unreachable(); } -stat_t set_ipc(struct tcb *t, id_t pid, id_t tid) +void set_args(struct tcb *t, struct sys_ret a) { struct riscv_regs *r = (struct riscv_regs *)(--t); - r->a2 = (long)pid; - r->a3 = (long)tid; - return OK; + r->a0 = a.s; + r->a1 = a.ar0; + r->a2 = a.ar1; + r->a3 = a.ar2; + r->a4 = a.ar3; + r->a5 = a.ar4; } -stat_t set_thread(struct tcb *t) +struct sys_ret get_args(struct tcb *t) +{ + struct riscv_regs *r = (struct riscv_regs *)(--t); + return (struct sys_ret){r->a0, r->a1, r->a2, r->a3, r->a4, r->a5}; +} + +void set_thread(struct tcb *t) { /* get location of registers in memory */ /** \todo check alignment, should be fine but just to be sure */ @@ -40,6 +52,4 @@ stat_t set_thread(struct tcb *t) /* insert important values into register slots */ r->sp = (long)t->thread_stack_top; r->tp = (long)t->thread_storage; - - return OK; } |
