diff options
Diffstat (limited to 'common')
| -rw-r--r-- | common/proc.c | 1 | ||||
| -rw-r--r-- | common/tcb.c | 21 | ||||
| -rw-r--r-- | common/uapi/dispatch.c | 7 |
3 files changed, 23 insertions, 6 deletions
diff --git a/common/proc.c b/common/proc.c index ea3ab5d..8793d00 100644 --- a/common/proc.c +++ b/common/proc.c @@ -37,6 +37,7 @@ stat_t init_proc(void *fdt, struct vm_branch *b) init_uvmem(t, UVMEM_START, UVMEM_END); + /* TODO: this stuff should be placed in __sys_exec */ /* the binary gets to choose first what memory regions it requires */ t->entry = load_elf(t, get_init_base(fdt)); if (!t->entry) diff --git a/common/tcb.c b/common/tcb.c index 5d6b8a2..326d9ac 100644 --- a/common/tcb.c +++ b/common/tcb.c @@ -19,8 +19,6 @@ static struct tcb *cpu_tcb[MAX_CPUS] = { 0 }; void init_tcbs() { - /* assumption: init_tcb called after memory subsystem is initialized */ - init_nodes(&root, sizeof(struct tcb)); /* MM_O1 is 2MiB on riscv64, so 262144 different possible thread ids. * Should be enough, if we're really strapped for memory I might try * something smaller but this is fine for now. */ @@ -55,8 +53,17 @@ struct tcb *new_thread() if (unlikely(!tcbs)) return 0; - struct tcb *t = (struct tcb *)get_node(&root); - t->tid = __alloc_tid(t); + vm_t bottom = alloc_page(MM_O0, 0); + /* move tcb to top of kernel stack, keeping alignment in check + * (hopefully) */ + /* TODO: check alignment */ + struct tcb *t = (struct tcb *)align_down(bottom + __o_size(MM_O0) - sizeof(struct tcb), sizeof(long)); + memset(t, 0, sizeof(struct tcb)); + + id_t tid = __alloc_tid(t); + tcbs[tid] = t; + t->tid = tid; + return t; } @@ -67,8 +74,10 @@ void destroy_thread(struct tcb *t) /* remove thread id from list */ tcbs[t->tid] = 0; - /* free node associated with tcb */ - free_node(&root, t); + + /* free associated kernel stack */ + vm_t bottom = align_down((vm_t)t, __o_size(MM_O0)); + free_page(MM_O0, (pm_t)bottom); } struct tcb *cur_tcb() diff --git a/common/uapi/dispatch.c b/common/uapi/dispatch.c index e6c334a..5522c9f 100644 --- a/common/uapi/dispatch.c +++ b/common/uapi/dispatch.c @@ -1,6 +1,8 @@ #include <apos/uapi.h> static const sys_t syscall_table[] = { + /* noop */ + [SYS_NOOP] = sys_noop, /* mem */ [SYS_REQ_MEM] = sys_req_mem, [SYS_REQ_PMEM] = sys_req_pmem, @@ -29,6 +31,11 @@ static const sys_t syscall_table[] = { [SYS_POWEROFF] = sys_poweroff, }; +SYSCALL_DEFINE0(noop)() +{ + return 0; +} + vm_t syscall_dispatch(vm_t syscall, vm_t a, vm_t b, vm_t c, vm_t d) { sys_t call = syscall_table[syscall]; |
