From da8eeb7695a4803d1d45c8c26c05a51fb1ba1e55 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Thu, 9 Jun 2022 23:50:14 +0300 Subject: continue documentation --- common/dmem.c | 2 +- common/elf.c | 12 ++++++------ common/mem_regions.c | 4 ++-- common/pmem.c | 4 ++-- common/proc.c | 2 +- common/sp_tree.c | 2 +- common/tcb.c | 14 +++++++------- common/timer.c | 2 +- common/uapi/conf.c | 7 ++++++- common/uapi/dispatch.c | 3 ++- common/uapi/ipc.c | 2 +- common/uapi/mem.c | 6 ++++-- common/uapi/proc.c | 8 ++++---- common/vmem.c | 4 ++-- 14 files changed, 40 insertions(+), 32 deletions(-) (limited to 'common') diff --git a/common/dmem.c b/common/dmem.c index 5d7a1d9..3faf4b3 100644 --- a/common/dmem.c +++ b/common/dmem.c @@ -39,7 +39,7 @@ static stat_t dev_alloc_wrapper(struct vmem *b, pm_t *offset, vm_t vaddr, void *data) { stat_t *status = (stat_t *)data; - /* TODO: remember to do something with this status info */ + /* \todo: remember to do something with this status info */ *status = map_vpage(b, *offset, vaddr, flags, order); *offset += order_size(order); return OK; diff --git a/common/elf.c b/common/elf.c index 88c5ddc..f947b60 100644 --- a/common/elf.c +++ b/common/elf.c @@ -30,13 +30,13 @@ static void __map_exec(struct tcb *t, vm_t bin, uint8_t ei_c, vm_t phstart, { hard_assert(t && is_proc(t), RETURN_VOID); - /* TODO: take alignment into consideration? */ - /* TODO: take overlapping memory regions into account, probably mostly + /* \todo: take alignment into consideration? */ + /* \todo: take overlapping memory regions into account, probably mostly * by keeping track of previously allocated area and seeing if the * segment fits into it */ - /* TODO: check if p_memsz is larger than p_filesz, the segment should be + /* \todo: check if p_memsz is larger than p_filesz, the segment should be * filled with zeroes. */ - /* TODO: in general, make this a low more clean. */ + /* \todo: in general, make this a low more clean. */ vm_t runner = phstart; vmflags_t default_flags = VM_V | VM_R | VM_W | VM_X | VM_U; for (size_t i = 0; i < phnum; ++i, runner += phsize) { @@ -61,7 +61,7 @@ static void __map_exec(struct tcb *t, vm_t bin, uint8_t ei_c, vm_t phstart, memcpy((void *)va, (void *)vo, vfz); /* skip while testing - * TODO: also fix, this modifies only the first region. Create new + * \todo: also fix, this modifies only the first region. Create new * function? * pm_t paddr = 0; @@ -74,7 +74,7 @@ static void __map_exec(struct tcb *t, vm_t bin, uint8_t ei_c, vm_t phstart, static vm_t __map_dyn(struct tcb *t, vm_t bin, uint8_t ei_c, vm_t phstart, size_t phnum, size_t phsize) { - /* TODO: this path should only be taken when no PT_INTERP is defined, as + /* \todo: this path should only be taken when no PT_INTERP is defined, as * making sure ld is loaded should be done in userspace. Maybe a bit * hacky, I know.*/ } diff --git a/common/mem_regions.c b/common/mem_regions.c index eb2346d..7547ab4 100644 --- a/common/mem_regions.c +++ b/common/mem_regions.c @@ -140,7 +140,7 @@ stat_t destroy_region(struct mem_region_root *r) { __destroy_region(sp_root(&r->free_regions)); __destroy_region(sp_root(&r->used_regions)); - /* TODO: error checking? */ + /* \todo: error checking? */ return OK; } @@ -178,7 +178,7 @@ static struct mem_region *__create_region(vm_t start, vm_t end, return m; } -/* TODO: should probably check if this actually works :D seems to do, but that's +/* \todo: should probably check if this actually works :D seems to do, but that's * just from really quick checking */ static size_t po_align(size_t s) { diff --git a/common/pmem.c b/common/pmem.c index e8aaba3..dae26ea 100644 --- a/common/pmem.c +++ b/common/pmem.c @@ -16,10 +16,10 @@ * certain page order and freeing it as another could easily be a * source of difficult to track bugs. * - * @todo More in depth documentation about the physical memory algorithms, + * \todo More in depth documentation about the physical memory algorithms, * unfortunately it is quite difficult to follow. * - * @todo See if there are improvements to be made, either to the implementation + * \todo See if there are improvements to be made, either to the implementation * or code in general. Could I use bitmaps, for example, and maybe calculate the * next pointer instead of storing it? */ diff --git a/common/proc.c b/common/proc.c index bf8a4d1..a660d68 100644 --- a/common/proc.c +++ b/common/proc.c @@ -27,7 +27,7 @@ stat_t init_proc(void *fdt) { init_tcbs(); - /* TODO: cleanup or something */ + /* \todo: cleanup or something */ struct tcb *t = create_proc(NULL); if (!t) return ERR_OOMEM; diff --git a/common/sp_tree.c b/common/sp_tree.c index 04b14c0..da2785b 100644 --- a/common/sp_tree.c +++ b/common/sp_tree.c @@ -86,7 +86,7 @@ static int_fast16_t __sp_balance(struct sp_node *n) /** * Get highest hint. - * + * * @param n Node to calculate highest hint for. * @return Highest hint. */ diff --git a/common/tcb.c b/common/tcb.c index c8fd811..a682b07 100644 --- a/common/tcb.c +++ b/common/tcb.c @@ -42,7 +42,7 @@ void destroy_tcbs() static id_t __alloc_tid(struct tcb *t) { - /* TODO: this would need some locking or something... */ + /* \todo: this would need some locking or something... */ for (size_t i = start_tid; i < num_tids; ++i) { if (tcbs[i]) continue; @@ -55,7 +55,7 @@ static id_t __alloc_tid(struct tcb *t) return ERR_NF; } -/* TODO: add error checking */ +/* \todo: add error checking */ static vm_t __setup_rpc_stack(struct tcb *t, size_t bytes) { pm_t offset = 0; @@ -86,11 +86,11 @@ stat_t alloc_stacks(struct tcb *t) return ERR_OOMEM; /* rpc stack always starts at the same place in vmem. - * TODO: is this a security issue? */ + * \todo: is this a security issue? */ if (!__setup_rpc_stack(p, __call_stack_size)) return ERR_OOMEM; - /* TODO: this only allows for a global stack size, what if a user wants + /* \todo: this only allows for a global stack size, what if a user wants * per thread stack sizes? */ t->thread_stack_top = t->thread_stack + __thread_stack_size; return OK; @@ -103,7 +103,7 @@ struct tcb *create_thread(struct tcb *p) vm_t bottom = alloc_page(MM_O0, 0); /* move tcb to top of kernel stack, keeping alignment in check * (hopefully) */ - /* TODO: check alignment */ + /* \todo: check alignment */ struct tcb *t = (struct tcb *)align_down( bottom + order_size(MM_O0) - sizeof(struct tcb), sizeof(long)); memset(t, 0, sizeof(struct tcb)); @@ -131,7 +131,7 @@ struct tcb *create_thread(struct tcb *p) static stat_t __clone_proc(struct tcb *p, struct tcb *n) { - /* TODO: clone memory regions, and mark them MR_COW, as well as copy + /* \todo: clone memory regions, and mark them MR_COW, as well as copy * bm_branch tree but with VM_W off, also at some point write COW * handler */ return OK; @@ -161,7 +161,7 @@ static stat_t __destroy_thread_data(struct tcb *t) vm_t bottom = align_down((vm_t)t, order_size(MM_O0)); free_page(MM_O0, (pm_t)bottom); - /* TODO: free stacks */ + /* \todo: free stacks */ return OK; } diff --git a/common/timer.c b/common/timer.c index 0b4e7a9..73b9125 100644 --- a/common/timer.c +++ b/common/timer.c @@ -156,5 +156,5 @@ void update_timers() struct timer *t = newest_timer(); remove_timer(t); - /* TODO: handle timer thread ID */ + /* \todo: handle timer thread ID */ } diff --git a/common/uapi/conf.c b/common/uapi/conf.c index 86846b2..26eb9cc 100644 --- a/common/uapi/conf.c +++ b/common/uapi/conf.c @@ -12,7 +12,12 @@ size_t __thread_stack_size = SZ_2M; size_t __call_stack_size = SZ_2M; -SYSCALL_DEFINE2(conf)(sys_arg_t param, sys_arg_t val) +SYSCALL_DEFINE1(conf_get)(sys_arg_t param) +{ + return (struct sys_ret){ OK, 0 }; +} + +SYSCALL_DEFINE2(conf_set)(sys_arg_t param, sys_arg_t val) { UNUSED(param); UNUSED(val); diff --git a/common/uapi/dispatch.c b/common/uapi/dispatch.c index df211d5..35c39c9 100644 --- a/common/uapi/dispatch.c +++ b/common/uapi/dispatch.c @@ -35,7 +35,8 @@ static const sys_t syscall_table[] = { [SYS_SWAP] = sys_swap, /* conf */ - [SYS_CONF] = sys_conf, + [SYS_CONF_SET] = sys_conf_set, + [SYS_CONF_GET] = sys_conf_get, [SYS_POWEROFF] = sys_poweroff, }; diff --git a/common/uapi/ipc.c b/common/uapi/ipc.c index 4327c90..0d79a92 100644 --- a/common/uapi/ipc.c +++ b/common/uapi/ipc.c @@ -19,7 +19,7 @@ SYSCALL_DEFINE1(ipc_server)(sys_arg_t callback) SYSCALL_DEFINE3(ipc_req)(sys_arg_t pid, sys_arg_t d0, sys_arg_t d1) { struct tcb *r = get_tcb(pid); - /* TODO: something like jump_to_callback(t) */ + /* \todo: something like jump_to_callback(t) */ /* remember difference between ipc_req and ipc_fwd! */ return (struct sys_ret){ d0, d1 }; } diff --git a/common/uapi/mem.c b/common/uapi/mem.c index 9d631ae..cc2818d 100644 --- a/common/uapi/mem.c +++ b/common/uapi/mem.c @@ -18,7 +18,7 @@ SYSCALL_DEFINE2(req_mem)(sys_arg_t size, sys_arg_t flags) SYSCALL_DEFINE3(req_fixmem)(sys_arg_t start, sys_arg_t size, sys_arg_t flags) { struct tcb *r = cur_proc(); - /* should probably check if the allocation succeeded...? TODO */ + /* should probably check if the allocation succeeded...? \todo */ return (struct sys_ret){ OK, alloc_fixed_uvmem(r, start, size, flags) }; } @@ -48,7 +48,7 @@ SYSCALL_DEFINE3(req_pmem)(sys_arg_t paddr, sys_arg_t size, sys_arg_t flags) SYSCALL_DEFINE2(req_sharedmem)(sys_arg_t size, sys_arg_t flags) { - /* TODO: check that requester is server */ + /* \todo: check that requester is server */ struct tcb *t = cur_proc(); vm_t start = 0; if ((start = alloc_shared_uvmem(t, size, flags))) @@ -69,3 +69,5 @@ SYSCALL_DEFINE3(ref_sharedmem)(sys_arg_t tid, sys_arg_t va, sys_arg_t flags) return (struct sys_ret){ OK, start }; } + +/** \todo add some way to specify who gets to access the shared memory? */ diff --git a/common/uapi/proc.c b/common/uapi/proc.c index f8ceaa5..604b862 100644 --- a/common/uapi/proc.c +++ b/common/uapi/proc.c @@ -28,7 +28,7 @@ SYSCALL_DEFINE0(fork)(){ } SYSCALL_DEFINE2(exec)(sys_arg_t bin, sys_arg_t interp){ - /* TODO: execute new process, probably with more sensible argc passing */ + /* \todo: execute new process, probably with more sensible argc passing */ struct tcb *r = cur_tcb(); /* mark binary to be kept */ @@ -58,13 +58,13 @@ SYSCALL_DEFINE2(exec)(sys_arg_t bin, sys_arg_t interp){ } SYSCALL_DEFINE2(signal)(sys_arg_t tid, sys_arg_t signal){ - /* TODO: signals? */ + /* \todo: signals? */ return (struct sys_ret){ OK, 0 }; } SYSCALL_DEFINE1(swap)(sys_arg_t tid){ - /* TODO: switch to process */ - /* TODO: should switch return the registers of the new thread that would + /* \todo: switch to process */ + /* \todo: should switch return the registers of the new thread that would * be used for message passing? */ return (struct sys_ret){ OK, 0 }; } diff --git a/common/vmem.c b/common/vmem.c index c9b8474..66c3d53 100644 --- a/common/vmem.c +++ b/common/vmem.c @@ -57,7 +57,7 @@ vm_t alloc_uvmem(struct tcb *t, size_t size, vmflags_t flags) stat_t status = OK; const vm_t v = alloc_region(&t->sp_r, size, &size, flags); const vm_t w = map_allocd_region(t->proc.vmem, v, size, flags, &status); - /* TODO: this could be changed so that each thread allocated the memory + /* \todo: this could be changed so that each thread allocated the memory * region for itself to start with, and only when someone tries to * access it from some other thread, is it actually cloned. Would likely * need some major reworkings, so this is good enough for now. */ @@ -122,7 +122,7 @@ vm_t ref_shared_uvmem(struct tcb *t1, struct tcb *t2, vm_t va, vmflags_t flags) return v; } -/* TODO: assume tcb is root tcb? */ +/* \todo: assume tcb is root tcb? */ stat_t free_uvmem(struct tcb *t, vm_t va) { struct mem_region *m = find_used_region(&t->sp_r, va); -- cgit v1.3