diff options
| -rw-r--r-- | arch/riscv64/kernel/proc.c | 3 | ||||
| -rw-r--r-- | common/proc.c | 2 | ||||
| -rw-r--r-- | common/uapi/dispatch.c | 1 | ||||
| -rw-r--r-- | common/uapi/proc.c | 25 | ||||
| -rw-r--r-- | include/apos/syscalls.h | 3 | ||||
| -rw-r--r-- | include/apos/uapi.h | 15 | ||||
| -rw-r--r-- | include/arch/cpu.h | 3 |
7 files changed, 15 insertions, 37 deletions
diff --git a/arch/riscv64/kernel/proc.c b/arch/riscv64/kernel/proc.c index b047e2c..ed8bf93 100644 --- a/arch/riscv64/kernel/proc.c +++ b/arch/riscv64/kernel/proc.c @@ -20,7 +20,8 @@ void run_init(struct tcb *t, void *fdt) 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 ("mv a0, %0\n" : : "r" (t->tid) : ); + __asm__ volatile ("mv a1, %0\n" : : "r" (fdt) : ); __asm__ volatile ("sret\n" ::: "memory"); /* we should never reach this */ unreachable(); diff --git a/common/proc.c b/common/proc.c index 946078b..270ec0c 100644 --- a/common/proc.c +++ b/common/proc.c @@ -42,4 +42,6 @@ stat_t init_proc(void *fdt) /* allocate stacks after ELF file to make sure nothing of importance * clashes */ return prepare_proc(t, get_init_base(fdt), 0); + /** \todo start one thread per core, with special handling for init in + * that each thread starts at the entry point of init? */ } diff --git a/common/uapi/dispatch.c b/common/uapi/dispatch.c index 91fba83..27cc001 100644 --- a/common/uapi/dispatch.c +++ b/common/uapi/dispatch.c @@ -44,7 +44,6 @@ static const sys_t syscall_table[] = { [SYS_EXEC] = sys_exec, [SYS_SPAWN] = sys_spawn, [SYS_SWAP] = sys_swap, - [SYS_ASSIGN] = sys_assign, /* conf */ [SYS_CONF_SET] = sys_conf_set, diff --git a/common/uapi/proc.c b/common/uapi/proc.c index a60aa52..ea42a3a 100644 --- a/common/uapi/proc.c +++ b/common/uapi/proc.c @@ -24,7 +24,8 @@ * * @return \ref OK and 0. */ -SYSCALL_DEFINE2(create)(sys_arg_t func, sys_arg_t arg){ +SYSCALL_DEFINE5(create)(sys_arg_t func, + sys_arg_t d0, sys_arg_t d1, sys_arg_t d2, sys_arg_t d3){ return SYS_RET1(OK); } @@ -44,7 +45,14 @@ SYSCALL_DEFINE2(create)(sys_arg_t func, sys_arg_t arg){ * @return \ref OK and 0. */ SYSCALL_DEFINE0(fork)(){ - return SYS_RET1(OK); + struct tcb *t = create_proc(cur_proc()); + if (!t) + return SYS_RET1(ERR_OOMEM); + + /* prepare args for when we eventually swap to the new proc */ + set_args(t, SYS_RET2(OK, t->pid)); + + return SYS_RET2(OK, 0); } /** @@ -135,16 +143,3 @@ SYSCALL_DEFINE1(swap)(sys_arg_t tid){ return get_args(t); } - -/** - * Assign syscall handler. - * - * \todo Implement. - * @param tid Thread to assign to \p cpu. - * @param cpu Cpu to run \p tid on. - * @return \ref OK. - */ -SYSCALL_DEFINE2(assign)(sys_arg_t tid, sys_arg_t cpu) -{ - return SYS_RET1(OK); -} diff --git a/include/apos/syscalls.h b/include/apos/syscalls.h index a5b7e18..dd383c8 100644 --- a/include/apos/syscalls.h +++ b/include/apos/syscalls.h @@ -104,9 +104,6 @@ enum { /** Switch running process. */ SYS_SWAP, - /** Assign thread to cpu. */ - SYS_ASSIGN, - /** @} */ /** @name Kernel management. */ diff --git a/include/apos/uapi.h b/include/apos/uapi.h index 7da24c6..7d612b6 100644 --- a/include/apos/uapi.h +++ b/include/apos/uapi.h @@ -511,7 +511,7 @@ SYSCALL_DECLARE2(ipc_notify, tid, swap); * @return \ref OK and 0. * \todo Should this take stack size etc? */ -SYSCALL_DECLARE2(create, func, arg); +SYSCALL_DECLARE5(create, func, d0, d1, d2, d3); /** * Fork process syscall. @@ -583,19 +583,6 @@ SYSCALL_DECLARE1(kill, tid); */ SYSCALL_DECLARE1(swap, tid); -/** - * Assign syscall. - * - * Assign \p tid to \p cpu, immediately swaps from whetever was running on \p cpu. - * - * @param tid Thread to assign to \p cpu. - * @param cpu Cpu to run \p tid on. - * @param c Unused. - * @param d Unused. - * @param e Unused. - * @return \ref OK and 0. - */ -SYSCALL_DECLARE2(assign, tid, cpu); /** @} */ /** @name Configuration syscalls. */ diff --git a/include/arch/cpu.h b/include/arch/cpu.h index ddea2ac..66d5d45 100644 --- a/include/arch/cpu.h +++ b/include/arch/cpu.h @@ -36,7 +36,4 @@ id_t cpu_id(); */ void cpu_assign(struct tcb *t); -/** \todo Should init be assigned one thread per core, or how should I handle - * giving out CPU IDs? */ - #endif /* APOS_CPU_H */ |
