diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-10-21 16:06:00 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-10-21 16:06:00 +0300 |
| commit | a06dbb8a63d825ebb1ad65372ce1ce1f572891bc (patch) | |
| tree | 342f74db0777a76eed64830ded71db16399e983d /arch/riscv64 | |
| parent | 00d3ae26dfd7c91c0817e71d71636982680d0b28 (diff) | |
| download | kmi-a06dbb8a63d825ebb1ad65372ce1ce1f572891bc.tar.gz kmi-a06dbb8a63d825ebb1ad65372ce1ce1f572891bc.zip | |
initial spawn implementation
Diffstat (limited to 'arch/riscv64')
| -rw-r--r-- | arch/riscv64/kernel/entry.S | 6 | ||||
| -rw-r--r-- | arch/riscv64/kernel/proc.c | 7 |
2 files changed, 6 insertions, 7 deletions
diff --git a/arch/riscv64/kernel/entry.S b/arch/riscv64/kernel/entry.S index 8ff642a..db662bb 100644 --- a/arch/riscv64/kernel/entry.S +++ b/arch/riscv64/kernel/entry.S @@ -87,7 +87,8 @@ handle_syscall: * twice */ csrr s0, CSR_SEPC addi s0, s0, 4 - csrw CSR_SEPC, s0 + /* store execution continuation point */ + sr s0, 0(tp) /* allocate space for sys_ret structure on stack and shift argument * registers down one to make room for the pointer to this structure */ addi sp, sp, -sizeof_sys_ret @@ -112,6 +113,9 @@ handle_syscall: /* get associated kernel stack */ mv sp, tp addi sp, sp, -sizeof_registers + /* set execution continuation */ + lr s0, 0(tp) + csrw CSR_SEPC, s0 /* restore system call result */ j restore_noreturn diff --git a/arch/riscv64/kernel/proc.c b/arch/riscv64/kernel/proc.c index ab833b2..f85f597 100644 --- a/arch/riscv64/kernel/proc.c +++ b/arch/riscv64/kernel/proc.c @@ -15,6 +15,7 @@ stat_t run_init(struct tcb *t, void *fdt) { /** \todo actually map fdt into the target address space */ csr_write(CSR_SSCRATCH, t); + csr_write(CSR_SEPC, t->exec); __asm__ volatile ("mv sp, %0\n" : : "r" (t->thread_stack_top) : "memory"); __asm__ volatile ("mv a0, %0\n" : : "r" (fdt) : ); __asm__ volatile ("sret\n" ::: "memory"); @@ -22,12 +23,6 @@ stat_t run_init(struct tcb *t, void *fdt) return ERR_ADDR; } -stat_t set_return(vm_t v) -{ - csr_write(CSR_SEPC, v); - return OK; -} - stat_t set_ipc(struct tcb *t, id_t pid, id_t tid) { struct riscv_regs *r = (struct riscv_regs *)(--t); |
