diff options
39 files changed, 513 insertions, 113 deletions
diff --git a/arch/riscv64/config.h b/arch/riscv64/config.h index 3d70248..ba7fafe 100644 --- a/arch/riscv64/config.h +++ b/arch/riscv64/config.h @@ -11,8 +11,8 @@ * instead. First 4K is reserved for NULL, but I suppose it could be mapped * later if *absolutely* necessary. * - * @todo Consider separating user-specified and immutable parameters. - * @todo Write more thorough documentation, maybe a separate .md file? + * \todo Consider separating user-specified and immutable parameters. + * \todo Write more thorough documentation, maybe a separate .md file? */ #include <apos/sizes.h> @@ -75,7 +75,7 @@ #else /* 32bit */ -/* TODO: figure this stuff out */ +/* \todo: figure this stuff out */ #define VM_DMAP (0x000000000) #define VM_KERN (VM_DMAP + SZ_256K) #define ROOT_PTE (0UL) diff --git a/arch/riscv64/kernel/power.c b/arch/riscv64/kernel/power.c index 73500bb..160cf25 100644 --- a/arch/riscv64/kernel/power.c +++ b/arch/riscv64/kernel/power.c @@ -28,7 +28,7 @@ stat_t poweroff(enum poweroff_type type) { - /* TODO: this only shuts down the cpu itself, but may leave the SOC + /* \todo: this only shuts down the cpu itself, but may leave the SOC * active. Should read from fdt poweroff and syscon-poweroff etc */ switch (type) { case SHUTDOWN: diff --git a/arch/riscv64/kernel/proc.c b/arch/riscv64/kernel/proc.c index 85c7bb2..b3a1ca7 100644 --- a/arch/riscv64/kernel/proc.c +++ b/arch/riscv64/kernel/proc.c @@ -8,7 +8,7 @@ #include "regs.h" #include "csr.h" -/* TODO: actually map fdt into the target address space */ +/* \todo: actually map fdt into the target address space */ stat_t run_init(struct tcb *t, void *fdt) { csr_write(CSR_SSCRATCH, t); @@ -36,7 +36,7 @@ stat_t set_ipc(struct tcb *t, id_t pid, id_t tid) stat_t set_thread(struct tcb *t, vm_t stack) { /* get location of registers in memory */ - /* TODO: check alignment, should be fine but just to be sure */ + /* \todo: check alignment, should be fine but just to be sure */ struct riscv_regs *r = (struct riscv_regs *)(--t); /* insert important values into register slots */ diff --git a/arch/riscv64/kernel/regs.h b/arch/riscv64/kernel/regs.h index bda3c1d..fafc84d 100644 --- a/arch/riscv64/kernel/regs.h +++ b/arch/riscv64/kernel/regs.h @@ -7,7 +7,7 @@ * _save_context. Used in \ref arch/riscv64/gen/asm-offsets.c to generate a list * of offsets usable from assembly. * - * @todo Implement sacing floating point, vector, etc. registers. + * \todo Implement sacing floating point, vector, etc. registers. */ /** diff --git a/arch/riscv64/kernel/sbi.h b/arch/riscv64/kernel/sbi.h index 3ffac05..36497f1 100644 --- a/arch/riscv64/kernel/sbi.h +++ b/arch/riscv64/kernel/sbi.h @@ -50,7 +50,7 @@ enum sbi_ecodes { * @param arg4 Argument 4. * @param arg5 Argument 5. * @return SBI call return. \see sbiret. - * @todo Query which extensions are available. + * \todo Query which extensions are available. */ struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0, unsigned long arg1, unsigned long arg2, @@ -68,7 +68,7 @@ struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0, * * @param stime_value Absolute timepoint in ticks. * @return SBI call return. \see sbiret. - * @todo Read timebase from fdt, seems to be clocks/sec for accurate timers. + * \todo Read timebase from fdt, seems to be clocks/sec for accurate timers. */ static inline struct sbiret sbi_set_timer(uint64_t stime_value) { @@ -94,7 +94,7 @@ static inline struct sbiret sbi_set_timer(uint64_t stime_value) * @param reset_reason Reason for reset. Optional, probably won't be used by the * kernel. * @return SBI call return \see sbiret. - * @todo Should \ref SBI_SHUTDOWN etc. be defined in this file instead? + * \todo Should \ref SBI_SHUTDOWN etc. be defined in this file instead? */ static inline struct sbiret sbi_system_reset(uint32_t reset_type, uint32_t reset_reason) diff --git a/arch/riscv64/kernel/vmem.c b/arch/riscv64/kernel/vmem.c index 1c825e1..deafb6a 100644 --- a/arch/riscv64/kernel/vmem.c +++ b/arch/riscv64/kernel/vmem.c @@ -223,7 +223,7 @@ vm_t setup_kernel_io(struct vmem *b, vm_t paddr) stat_t clone_uvmem(struct vmem *r, struct vmem *b) { - /* TODO: error checking? */ + /* \todo: error checking? */ for (size_t i = 0; i <= CSTACK_PAGE; ++i) b->leaf[i] = r->leaf[i]; 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); diff --git a/include/apos/assert.h b/include/apos/assert.h index 81b267b..a6ae3c8 100644 --- a/include/apos/assert.h +++ b/include/apos/assert.h @@ -18,7 +18,7 @@ #include <apos/debug.h> #include <apos/utils.h> -/* TODO: should this exit or do something explosive like that? */ +/* \todo: should this exit or do something explosive like that? */ #if !defined(DNDEBUG) /** diff --git a/include/apos/atomic.h b/include/apos/atomic.h index 84e0f0f..aba7a3f 100644 --- a/include/apos/atomic.h +++ b/include/apos/atomic.h @@ -161,7 +161,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; /** * Kill dependency. - * @todo Figure out what it means. + * \todo Figure out what it means. * * @param y Value whose dependencies should be killed. * @return \c y diff --git a/include/apos/attrs.h b/include/apos/attrs.h index 9729000..76ef39f 100644 --- a/include/apos/attrs.h +++ b/include/apos/attrs.h @@ -12,7 +12,7 @@ * * @param x Attribute whose existence should be checked. * @return Non-zero when available, \c 0 when not available. - * @todo Figure out which attributes are necessary and which are good to have + * \todo Figure out which attributes are necessary and which are good to have */ #if !defined(__has_attribute) #define __has_attribute(x) 0 diff --git a/include/apos/conf.h b/include/apos/conf.h index 5b9bf10..3a00997 100644 --- a/include/apos/conf.h +++ b/include/apos/conf.h @@ -14,7 +14,7 @@ * \remark Note that runtime parameter passing is not yet implemented, and I might * implement per-thread stack sizes as well. * \global - * @todo This should probably be a function instead. + * \todo This should probably be a function instead. */ extern size_t __thread_stack_size; @@ -22,7 +22,7 @@ extern size_t __thread_stack_size; * Provides access to the runtime global parameter. * \see __thread_stack_size. * \global - * @todo This should probably also be a function instead. + * \todo This should probably also be a function instead. */ extern size_t __call_stack_size; diff --git a/include/apos/dmem.h b/include/apos/dmem.h index dace5f9..25976dc 100644 --- a/include/apos/dmem.h +++ b/include/apos/dmem.h @@ -4,7 +4,7 @@ /** * @file dmem.h * Device memory handling, i.e. anything outside of RAM. - * @todo Make global parameters functions instead. + * \todo Make global parameters functions instead. */ #include <apos/types.h> diff --git a/include/apos/mem.h b/include/apos/mem.h index 20293db..8932a2f 100644 --- a/include/apos/mem.h +++ b/include/apos/mem.h @@ -159,7 +159,7 @@ */ #define order_bit(idx) ((idx) & (MM_OINFO_WIDTH - 1)) -/** @todo Get rid of slightly ugly __* syntax, as these aren't static. */ +/** \todo Get rid of slightly ugly __* syntax, as these aren't static. */ /** * Convert physical address to virtual address in direct mapping. @@ -180,7 +180,7 @@ /** * Get page number of physical address. * - * @todo Isn't this the same as \ref pm_to_pnum()? + * \todo Isn't this the same as \ref pm_to_pnum()? * * @param x Physical address. * @return Corresponding page number. @@ -281,7 +281,7 @@ typedef ssize_t pnum_t; * @param max_order Maximum order the current system supports. * @param shifts Offsets to start of each memory order in address. * @param page_shift Width in bits of base page size. - * @todo Should likely also be stat_t? + * \todo Should likely also be stat_t? */ void init_mem(size_t max_order, size_t shifts[10], size_t page_shift); diff --git a/include/apos/mem_regions.h b/include/apos/mem_regions.h index 2eaef8c..0651bfe 100644 --- a/include/apos/mem_regions.h +++ b/include/apos/mem_regions.h @@ -96,7 +96,7 @@ struct mem_region { * @param start Start of memory arena. * @param arena_size Size of memory arena. * @return \ref OK on success. - * @todo Document error codes when I actually implement them properly. + * \todo Document error codes when I actually implement them properly. */ stat_t init_region(struct mem_region_root *r, vm_t start, size_t arena_size); @@ -156,7 +156,7 @@ stat_t free_region(struct mem_region_root *r, vm_t start); * @param r Memory region root. * @param m Memory region to free. * @return \ref OK. - * @todo Improve error checking. + * \todo Improve error checking. */ stat_t free_known_region(struct mem_region_root *r, struct mem_region *m); @@ -231,7 +231,7 @@ typedef stat_t region_callback_t(struct vmem *vmem, pm_t *offset, vm_t vaddr, * @param va Address that is within memory region. * @param flags Memory region flags. * @return \ref OK when succesful. - * @todo Implement. + * \todo Implement. */ stat_t stat_region(struct mem_region_root *r, vm_t va, vmflags_t *flags); @@ -242,7 +242,7 @@ stat_t stat_region(struct mem_region_root *r, vm_t va, vmflags_t *flags); * @param va Address that is within memory region. * @param flags New flags of region. * @return \ref OK when succesful. - * @todo Implement. + * \todo Implement. */ stat_t mod_region(struct mem_region_root *r, vm_t va, vmflags_t flags); diff --git a/include/apos/proc.h b/include/apos/proc.h index 8eaa647..c6346fc 100644 --- a/include/apos/proc.h +++ b/include/apos/proc.h @@ -18,7 +18,7 @@ * @param bin Address of binary to load. * @param interp Optional interpreter, mainly for PIE ELF binaries. * @return \ref OK on success, \ref ERR_INVAL if loading binary failed. - * @todo Handle out of memory better? + * \todo Handle out of memory better? */ stat_t prepare_proc(struct tcb *t, vm_t bin, vm_t interp); diff --git a/include/apos/sp_tree.h b/include/apos/sp_tree.h index a5fa2f8..8202033 100644 --- a/include/apos/sp_tree.h +++ b/include/apos/sp_tree.h @@ -21,7 +21,7 @@ * * @param n Node to read. * @return Left node of read node. - * @see sp_right(). + * \see sp_right(). */ #define sp_left(n) ((n)->left) @@ -30,7 +30,7 @@ * * @param n Node to read. * @return Right node of read node. - * @see sp_left(). + * \see sp_left(). */ #define sp_right(n) ((n)->right) @@ -41,7 +41,7 @@ * * @param n Node to read. * @return Parent of right node of read node. - * @see sp_lparen(). + * \see sp_lparen(). */ #define sp_rparen(n) (sp_right(n)->parent) @@ -50,7 +50,7 @@ * * @param n Node to read. * @return Parent of left node of read node. - * @see sp_rparen(). + * \see sp_rparen(). */ #define sp_lparen(n) (sp_left(n)->parent) @@ -67,7 +67,7 @@ * * @param n Node to read. * @return Grandparent of read node. - * @see sp_has_gparen(). + * \see sp_has_gparen(). */ #define sp_gparen(n) ((n)->parent->parent) @@ -75,7 +75,7 @@ * * @param n Node to read. * @return Non-zero if node has grandparent, \c 0 otherwise. - * @see sp_gparen(). + * \see sp_gparen(). */ #define sp_has_gparen(n) (sp_paren(n) && sp_gparen(n)) diff --git a/include/apos/syscalls.h b/include/apos/syscalls.h index b0d6423..98144c7 100644 --- a/include/apos/syscalls.h +++ b/include/apos/syscalls.h @@ -84,7 +84,10 @@ enum { /** @name Kernel management. */ /** @{ */ /** Configure system parameters (stack size etc.). */ - SYS_CONF, + SYS_CONF_SET, + + /** Get system parameters. */ + SYS_CONF_GET, /** Shutdown, reboot, etc. */ SYS_POWEROFF, diff --git a/include/apos/tcb.h b/include/apos/tcb.h index 4d4b3d5..83fbffa 100644 --- a/include/apos/tcb.h +++ b/include/apos/tcb.h @@ -97,7 +97,7 @@ struct tcb { /** Thread ID. */ id_t tid; - /* TODO: implement cpu_id to hardware cpu ID translation, first in + /* \todo: implement cpu_id to hardware cpu ID translation, first in * riscv. */ /** Cpu currently executing this thread. */ id_t cpu_id; @@ -111,7 +111,7 @@ struct tcb { /** Address of this thread's stack top. */ vm_t thread_stack_top; - /* TODO: Check if each thread should be allowed more than just one + /* \todo: Check if each thread should be allowed more than just one * region of thread local storage. */ /** Possible thread local storage. */ vm_t thread_storage; @@ -145,7 +145,7 @@ void destroy_tcbs(); * * Userspace stack is allocated with \ref alloc_stacks(). * - * @todo Thread local storage? + * \todo Thread local storage? * * @param p Process context within to create the thread. * @return Pointer to created \ref tcb. @@ -157,9 +157,9 @@ struct tcb *create_thread(struct tcb *p); * * Sets up a new thread in a new process context. If there is a parent thread, * its memory regions are copied but made COW. - * @see create_thread(). + * \see create_thread(). * - * @todo COW handling. + * \todo COW handling. * * @param p Parent process. * @return Pointer to created \ref tcb. @@ -172,7 +172,7 @@ struct tcb *create_proc(struct tcb *p); * Frees data associated with thread and frees up the thread ID. * At least currently does not allow \c t to be a process thread. * - * @todo Other return values? + * \todo Other return values? * * @param t Thread to destroy. * @return \ref OK on success, \ref ERR_NOINIT if called without initializing @@ -213,7 +213,7 @@ stat_t attach_rpc(struct tcb *r, struct tcb *t); * @param t Thread to detach. * @return \ref OK on success, \ref ERR_INVAL if pointers are the same. * - * @todo Should probably check that thread exists in the process? + * \todo Should probably check that thread exists in the process? */ stat_t detach_rpc(struct tcb *r, struct tcb *t); @@ -272,18 +272,18 @@ struct tcb *get_tcb(id_t tid); * * @param p Process whose memory mappings to clone. * @return \ref OK on success, something else otherwise. - * @todo Check up on return codes. + * \todo Check up on return codes. */ stat_t clone_proc_maps(struct tcb *p); /** * Clone RPC context memory mappings. * - * @see clone_proc_maps(). + * \see clone_proc_maps(). * * @param r Server whose memory mappings to clone to threads in RPC to it. * @return \ref OK on success, something else otherwise. - * @todo Check up on return codes. + * \todo Check up on return codes. */ stat_t clone_rpc_maps(struct tcb *r); diff --git a/include/apos/timer.h b/include/apos/timer.h index b21a182..98d9f36 100644 --- a/include/apos/timer.h +++ b/include/apos/timer.h @@ -126,7 +126,7 @@ static inline ticks_t msecs_to_ticks(tunit_t msecs) */ static inline ticks_t secs_to_ticks(tunit_t secs) { - /* TODO: likely not a problem on 64bit systems, not sure how to handle situation on + /* \todo: likely not a problem on 64bit systems, not sure how to handle situation on * 32bit */ return msecs_to_ticks(secs * 1000); } diff --git a/include/apos/uapi.h b/include/apos/uapi.h index f0cb9b7..9155c30 100644 --- a/include/apos/uapi.h +++ b/include/apos/uapi.h @@ -9,21 +9,98 @@ #include <apos/syscalls.h> #include <apos/vmem.h> -/* syscall function type, let's start with four arguments and see where that - * goes */ +/** + * Syscall function type. + * Let's start with four arguments and see where that goes + */ typedef struct sys_ret (*sys_t)(long, long, long, long); -/* TODO: should this be arch specific? should be the size of an integer register */ + +/** + * Syscall argument type. + * + * \todo: Should this be arch specific? should be the size of an integer + * register. + */ typedef long sys_arg_t; +/** + * Return structure of syscall. + * \note Field names are generic, and can be used for two values or two error + * codes, check documentation of whatever you're doing. + */ struct sys_ret { + /** Error code of syscall. */ sys_arg_t err; + + /** Value returned by syscall. */ sys_arg_t val; }; -#define SYSCALL_DECLARE(name) \ +/** + * Helper macro for declaring syscalls with zero arguments. + * + * The idea is that all syscalls externally have the same amount of arguments, + * but then by using some helper macros (see below) we can make actually + * implementing the syscall more intuitive and less noisy. + * + * @param name Name of syscall. + */ +#define SYSCALL_DECLARE0(name) \ + struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, \ + sys_arg_t c, \ + sys_arg_t d); + +/** + * Helper macro for declaring syscalls with one argument. + * + * @param name Name of syscall. + * @param a Name of argument. + */ +#define SYSCALL_DECLARE1(name, a) \ + struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ + sys_arg_t d); + +/** + * Helper macro for declaring syscalls with two arguments. + * + * @param name Name of syscall. + * @param a Name of first argument. + * @param b Name of second argument. + */ +#define SYSCALL_DECLARE2(name, a, b) \ + struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ + sys_arg_t d); + +/** + * Helper macro for declaring syscalls with three arguments. + * + * @param name Name of syscall. + * @param a Name of first argument. + * @param b Name of second argument. + * @param c Name of third argument. + */ +#define SYSCALL_DECLARE3(name, a, b, c) \ + struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ + sys_arg_t d); + +/** + * Helper macro for declaring syscalls with four arguments. + * + * @param name Name of syscall. + * @param a Name of first argument. + * @param b Name of second argument. + * @param c Name of third argument. + * @param d Name of fourth argument. + */ +#define SYSCALL_DECLARE4(name, a, b, c, d) \ struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ sys_arg_t d); +/** + * Helper macro for defining syscall with zero arguments. + * + * @param name Name of syscall. + */ #define SYSCALL_DEFINE0(name) \ static inline struct sys_ret __##name(); \ struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ @@ -37,6 +114,11 @@ struct sys_ret { } \ static struct sys_ret __##name +/** + * Helper macro for defining syscall with one argument. + * + * @param name Name of syscall. + */ #define SYSCALL_DEFINE1(name) \ static inline struct sys_ret __##name(sys_arg_t); \ struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ @@ -49,6 +131,11 @@ struct sys_ret { } \ static inline struct sys_ret __##name +/** + * Helper macro for defining syscall with two arguments. + * + * @param name Name of syscall. + */ #define SYSCALL_DEFINE2(name) \ static inline struct sys_ret __##name(sys_arg_t, sys_arg_t); \ struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ @@ -60,6 +147,11 @@ struct sys_ret { } \ static inline struct sys_ret __##name +/** + * Helper macro for defining syscall with three arguments. + * + * @param name Name of syscall. + */ #define SYSCALL_DEFINE3(name) \ static inline struct sys_ret __##name(sys_arg_t, sys_arg_t, \ sys_arg_t); \ @@ -71,6 +163,11 @@ struct sys_ret { } \ static inline struct sys_ret __##name +/** + * Helper macro for defining syscall with four arguments. + * + * @param name Name of syscall. + */ #define SYSCALL_DEFINE4(name) \ static inline struct sys_ret __##name(sys_arg_t, sys_arg_t, sys_arg_t, \ sys_arg_t); \ @@ -81,40 +178,332 @@ struct sys_ret { } \ static inline struct sys_ret __##name -/* noop */ -SYSCALL_DECLARE(noop); +/** + * Noop syscall. + * + * @param a Unused. + * @param b Unused. + * @param c Unused. + * @param d Unused. + * @return \ref OK and 0. + */ +SYSCALL_DECLARE0(noop); + +/* @name Memory handling syscalls. */ +/** @{ */ +/** + * Request memory syscall. + * + * Allocates at least the specified size of allocation to current effective + * process. + * + * @param size Size of allocation. + * @param flags Flags of allocation. + * @param c Unused. + * @param d Unused. + * @return \ref OK and start of memory allocation. + */ +SYSCALL_DECLARE2(req_mem, size, flags); + +/** + * Request physical memory syscall. + * + * Allocates at least the specified size of allocation which includes the + * physical start address somewhere in the allocation to the current effective + * process. + * + * @param paddr Start of physical allocation. + * @param size Size of physical allocation. + * @param flags Flags of physical allocation. + * @param d Unused. + * @return \ref OK and start of memory allocation. + */ +SYSCALL_DECLARE3(req_pmem, paddr, size, flags); + +/** + * Request fixed memory syscall. + * + * Allocates at least the specified size of allocation which includes the start + * address of allocation to the current effective process. + * + * @param start Start of allocation. + * @param size Size of allocation. + * @param flags Flags of allocation. + * @param d Unused. + * @return \ref OK and start of memory allocation. + */ +SYSCALL_DECLARE3(req_fixmem, start, size, flags); + +/** + * Request shared memory syscall. + * + * Allocates a region that can be shared between different processes, that is at + * least the specified size of allocation. When clients are freeing memory, the + * underlying physical allocation will not be freed unless the owning reference + * (server) frees it. + * + * @param size Size of allocation. + * @param flags Flags of allocation. + * @param c Unused. + * @param d Unused. + * @return \ref OK and start of memory allocation. + */ +SYSCALL_DECLARE2(req_sharedmem, size, flags); + +/** + * Reference shared memory syscall. + * + * \see sys_req_sharedmem(). + * + * @param tid Thread ID of owner of shared memory. + * @param va Start address of shared memory. + * @param flags Flags to use for reference. + * @param d Unused. + * @return \ref OK and start of shared memory. + */ +SYSCALL_DECLARE3(ref_sharedmem, tid, va, flags); + +/** + * Free memory syscall. + * + * Frees the memory region pointed to. + * + * @param start Start of memory. + * @param b Unused. + * @param c Unused. + * @param d Unused. + * @return \ref OK and 0. + */ +SYSCALL_DECLARE1(free_mem, start); +/** @} */ + +/** @name Timer syscalls. */ +/** @{ */ +/** + * Get timer accuracy in Hertz syscall. + * + * @param a Unused. + * @param b Unused. + * @param c Unused. + * @param d Unused. + * @return \ref OK and frequency. + * \todo Should this be some kind of config request instead of a separate + * syscall? + */ +SYSCALL_DECLARE0(timebase); + +/** + * Request relative timer syscall. + * + * Request timer that triggers a number of ticks in the future. + * + * @param ticks Number of ticks from now. + * @param repeat Number of times to trigger. + * @param c Unused. + * @param d Unused. + * @return \ref OK and ID of timer. + */ +SYSCALL_DECLARE2(req_rel_timer, ticks, repeat); + +/** + * Request absolute timer syscall. + * + * Request timer that triggers at some absolute timepoint. + * + * @param ticks Timepoint. + * @param repeat Number of times to trigger. (What? Why is this here?). + * @param c Unused. + * @param d Unused. + * @return \ref OK and ID of timer. + * \todo Check repeat value. + */ +SYSCALL_DECLARE2(req_abs_timer, ticks, repeat); + +/** + * Free timer syscall. + * + * @param cid ID of timer to free. + * @param b Unused. + * @param c Unused. + * @param d Unused. + * @return \ref OK and 0. + */ +SYSCALL_DECLARE1(free_timer, cid); +/** @} */ + +/** @name IPC syscalls. */ +/** @{ */ +/** + * Report process status as server syscall. + * + * @param callback Callback to request handler. + * @param b Unused. + * @param c Unused. + * @param d Unused. + * @return \ref OK and 0. + */ +SYSCALL_DECLARE1(ipc_server, callback); + +/** + * Request syscall. + * + * @param pid Request target process. + * @param d0 First request argument. + * @param d1 Second request argument. + * @param d Unused. + * @return \c d0 and \c d1. + */ +SYSCALL_DECLARE3(ipc_req, pid, d0, d1); + +/** + * Forwarding syscall. + * + * In a server request handler, do a request to some other server on behalf of + * whoever called us up. + * + * @param pid Forwarding target process. + * @param d0 First forwarding argument. + * @param d1 Second forwarding argument. + * @param d Unused. + * @return \c d0 and \c d1. + */ +SYSCALL_DECLARE3(ipc_fwd, pid, d0, d1); + +/** + * Response syscall. + * + * @param d0 First response argument. + * @param d1 Second response argument. + * @param c Unused. + * @param d Unused. + * @return \c d0 and \c d1. + */ +SYSCALL_DECLARE2(ipc_resp, d0, d1); +/** @} */ + +/** @name Process handling syscalls. */ +/** @{ */ +/** + * Create thread syscall. + * + * Creates thread in current effective process context. + * + * @param a Unused. + * @param b Unused. + * @param c Unused. + * @param d Unused. + * @return \ref OK and 0. + * \todo Should this take stack size etc? + */ +SYSCALL_DECLARE0(create); + +/** + * Fork process syscall. + * + * Forks a process, much like in *nix systems. + * + * @param a Unused. + * @param b Unused. + * @param c Unused. + * @param d Unused. + * @return \ref OK and 0. + */ +SYSCALL_DECLARE0(fork); + +/** + * Execute binary syscall. + * + * Executes a new binary in existing process space. + * + * @param bin Address of binary. + * @param interp Optional address of interpreter. + * @param c Unused. + * @param d Unused. + * @return \ref OK and 0. + * \todo Check other return codes. + */ +SYSCALL_DECLARE2(exec, bin, interp); -/* memory */ -SYSCALL_DECLARE(req_mem); -SYSCALL_DECLARE(req_pmem); -SYSCALL_DECLARE(req_fixmem); -SYSCALL_DECLARE(req_sharedmem); -SYSCALL_DECLARE(free_mem); +/** + * Signal process syscall. + * + * @param tid Thread ID to signal. + * @param signal Signal to send. + * @param c Unused. + * @param d Unused. + * @return \ref OK and 0. + */ +SYSCALL_DECLARE2(signal, tid, signal); -/* timers */ -SYSCALL_DECLARE(timebase); -SYSCALL_DECLARE(req_rel_timer); -SYSCALL_DECLARE(req_abs_timer); -SYSCALL_DECLARE(free_timer); +/** + * Swap syscall. + * + * Swap currently running thread. + * + * @param tid Thread to swap to. + * @param b Unused. + * @param c Unused. + * @param d Unused. + * @return \ref OK and 0. + */ +SYSCALL_DECLARE1(swap, tid); +/** @} */ -/* ipc */ -SYSCALL_DECLARE(ipc_server); -SYSCALL_DECLARE(ipc_req); -SYSCALL_DECLARE(ipc_fwd); -SYSCALL_DECLARE(ipc_resp); +/** @name Configuration syscalls. */ +/** @{ */ +/** + * Set configuration syscall. + * + * Set some runtime parameter. + * + * @param param Parameter to set. + * @param val Value to set parameter to. + * @param c Unused. + * @param d Unused. + * @return \ref OK and 0. + */ +SYSCALL_DECLARE2(conf_set, param, val); -/* proc */ -SYSCALL_DECLARE(create); -SYSCALL_DECLARE(fork); -SYSCALL_DECLARE(exec); -SYSCALL_DECLARE(signal); -SYSCALL_DECLARE(swap); +/** + * Get configuration syscall. + * + * Get some runtime parameter. + * + * @param param Parameter to get. + * @param b Unused. + * @param c Unused. + * @param d Unused. + * @return \ref OK and 0. + */ +SYSCALL_DECLARE1(conf_get, param); -/* conf */ -SYSCALL_DECLARE(conf); -SYSCALL_DECLARE(poweroff); +/** + * Power off syscall. + * + * Either shut down or reboot system. + * + * @param type Type of shutdown. \see poweroff_type. + * @param b Unused. + * @param c Unused. + * @param d Unused. + * @return Shouldn't return at all. + */ +SYSCALL_DECLARE1(poweroff, type); +/** @} */ +/** + * Dispatch to correct syscall handler. + * + * @param syscall Syscall number. + * @param a Syscall argument 0. + * @param b Syscall argument 1. + * @param c Syscall argument 2. + * @param d Syscall argument 3. + * @return Whatever the specified syscall returns. + */ struct sys_ret syscall_dispatch(sys_arg_t syscall, sys_arg_t a, sys_arg_t b, sys_arg_t c, sys_arg_t d); +/** \todo Should I add variable names as well, to make the documentation a bit + * more readable? */ #endif /* APOS_UAPI_H */ diff --git a/include/apos/utils.h b/include/apos/utils.h index c5cdaad..b75986e 100644 --- a/include/apos/utils.h +++ b/include/apos/utils.h @@ -512,7 +512,7 @@ DEFINE_ALIGN_DOWN(ull, unsigned long long); /** * Helper macro for defining type specific alignment checks. - * + * * @param name Name of type in function name. * @param type Actual type. */ diff --git a/include/arch/cpu.h b/include/arch/cpu.h index 763ebba..e63b90a 100644 --- a/include/arch/cpu.h +++ b/include/arch/cpu.h @@ -24,6 +24,6 @@ */ id_t cpu_id(); -/* TODO: add more cpu handling functions */ +/* \todo: add more cpu handling functions */ #endif /* APOS_CPU_H */ diff --git a/include/arch/irq.h b/include/arch/irq.h index 7c6a365..0c8ecf9 100644 --- a/include/arch/irq.h +++ b/include/arch/irq.h @@ -6,7 +6,7 @@ * Arch-specific interrupt handling, generally implemented in * arch/whatever/kernel/irq.c * - * @todo These should probably also be stat_t... + * \todo These should probably also be stat_t... */ #if defined(riscv64) diff --git a/include/arch/pmem.h b/include/arch/pmem.h index 21a721a..5022b89 100644 --- a/include/arch/pmem.h +++ b/include/arch/pmem.h @@ -47,7 +47,7 @@ * ... * @endcode * - * @todo Move documentation into its own .md + * \todo Move documentation into its own .md * * @param fdt Global FDT pointer. * @param max_order Highest order pages the arch supports. diff --git a/include/arch/proc.h b/include/arch/proc.h index 9af44c9..7c6ad5b 100644 --- a/include/arch/proc.h +++ b/include/arch/proc.h @@ -14,7 +14,7 @@ stat_t set_return(vm_t r); stat_t set_ipc(struct tcb *t, id_t pid, id_t tid); -/*TODO: should this be in arch/tcb.h or something? */ +/*\todo: should this be in arch/tcb.h or something? */ stat_t set_thread(struct tcb *t, vm_t stack); stat_t run_init(struct tcb *t, void *fdt); diff --git a/lib/ubsan.c b/lib/ubsan.c index 4ee360e..bbefdad 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -3,7 +3,7 @@ * Tiny undefined behaviour sanitizer, mostly lifted from * https://github.com/Abb1x/tinyubsan/blob/master/src/tinyubsan.c * - * @todo Add in more runtime info. + * \todo Add in more runtime info. * * Note that this file's documentation is pretty vague, as I don't know the ins * and outs of the undefined behaviour sanitizer subsystem. @@ -27,7 +27,7 @@ struct source_location { /** * Describes the type of undefined behaviour. * - * Currently largely unused, @todo implement better undefined behaviour bug + * Currently largely unused, \todo implement better undefined behaviour bug * messages. */ struct type_descriptor { |
