diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-05-21 21:23:12 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-05-21 21:23:12 +0300 |
| commit | a4851206bef5ceecef18b3fde5be6918a67cca21 (patch) | |
| tree | 6d9a817a8e59687ef4e45388d310b9beda2ba335 | |
| parent | 8da0171e5ca3492cdb34422184a1c96acd0b5165 (diff) | |
| download | kmi-a4851206bef5ceecef18b3fde5be6918a67cca21.tar.gz kmi-a4851206bef5ceecef18b3fde5be6918a67cca21.zip | |
add create syscall for threads
| -rw-r--r-- | common/uapi/dispatch.c | 1 | ||||
| -rw-r--r-- | common/uapi/proc.c | 6 | ||||
| -rw-r--r-- | common/vmem.c | 17 | ||||
| -rw-r--r-- | include/apos/syscalls.h | 2 | ||||
| -rw-r--r-- | include/apos/uapi.h | 1 |
5 files changed, 19 insertions, 8 deletions
diff --git a/common/uapi/dispatch.c b/common/uapi/dispatch.c index 8ffaffb..97fc0d8 100644 --- a/common/uapi/dispatch.c +++ b/common/uapi/dispatch.c @@ -21,6 +21,7 @@ static const sys_t syscall_table[] = { [SYS_IPC_RESP] = sys_ipc_resp, /* proc */ + [SYS_CREATE] = sys_create, [SYS_FORK] = sys_fork, [SYS_EXEC] = sys_exec, [SYS_SIGNAL] = sys_signal, diff --git a/common/uapi/proc.c b/common/uapi/proc.c index bd5874d..3ce3bcb 100644 --- a/common/uapi/proc.c +++ b/common/uapi/proc.c @@ -1,5 +1,10 @@ #include <apos/uapi.h> +SYSCALL_DEFINE0(create)() +{ + return (struct sys_ret){ OK, 0 }; +} + /* Not entirely sure how I should handle forks/execs etc, mostly whether I * should allow forks/execs to be called directly or only though the process * manager. Probably though the process manager, although that will add in a @@ -12,7 +17,6 @@ */ SYSCALL_DEFINE0(fork)() { - /* TODO: create new thread in the same process family */ return (struct sys_ret){ OK, 0 }; } diff --git a/common/vmem.c b/common/vmem.c index 817f851..ff27ed8 100644 --- a/common/vmem.c +++ b/common/vmem.c @@ -106,8 +106,9 @@ stat_t alloc_uvmem_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, if (!*offset) return INFO_TRGN; /* try again */ - stat_t ret = map_vpage(b, *offset, vaddr, flags, order); - return ret; + stat_t *status = (stat_t *)data, ret; + ret = *status = map_vpage(b, *offset, vaddr, flags, order); + return (ret == INFO_SEFF) ? OK : ret; } stat_t alloc_shared_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, @@ -117,8 +118,10 @@ stat_t alloc_shared_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, return INFO_TRGN; *offset = alloc_page(MM_O0, *offset); - map_vpage(b, *offset, vaddr, flags, order); - return OK; + + stat_t *status = (stat_t *)data, ret; + ret = *status = map_vpage(b, *offset, vaddr, flags, order); + return (ret == INFO_SEFF) ? OK : ret; } stat_t free_uvmem_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, @@ -133,11 +136,11 @@ stat_t free_uvmem_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, if (order != v_order) return INFO_TRGN; - stat_t *status = (stat_t *)data; - *status = unmap_vpage(b, vaddr); + stat_t *status = (stat_t *)data, ret; + ret = *status = unmap_vpage(b, vaddr); /* don't free shared pages, unless they're owned */ if (!__is_set(flags, MR_SHARED) || __is_set(flags, MR_OWNED)) free_page(order, paddr); - return OK; + return (ret == INFO_SEFF) ? OK : ret; } diff --git a/include/apos/syscalls.h b/include/apos/syscalls.h index b8553bc..9346da3 100644 --- a/include/apos/syscalls.h +++ b/include/apos/syscalls.h @@ -29,8 +29,10 @@ enum { SYS_IPC_RESP, /* IPC response from server */ /* process management */ + SYS_CREATE, /* create new thread */ SYS_FORK, /* duplicate process */ SYS_EXEC, /* execute new binary in process space */ + SYS_KILL, /* kill thread */ SYS_SIGNAL, /* send signal to process (kill etc.) */ SYS_SWITCH, /* switch running process */ diff --git a/include/apos/uapi.h b/include/apos/uapi.h index ff3f4d0..a3b54d5 100644 --- a/include/apos/uapi.h +++ b/include/apos/uapi.h @@ -98,6 +98,7 @@ SYSCALL_DECLARE(ipc_req); SYSCALL_DECLARE(ipc_resp); /* proc */ +SYSCALL_DECLARE(create); SYSCALL_DECLARE(fork); SYSCALL_DECLARE(exec); SYSCALL_DECLARE(signal); |
