diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-12-27 20:40:44 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-12-27 20:40:44 +0200 |
| commit | a12e50e5a7dae52ed8bd5a24cc6576371e20985b (patch) | |
| tree | 70ddf625029dbe1ca4d38ec4f1819fe5fe7e4291 /include | |
| parent | d98ec57128628b81fcd32269a92742a037b7f713 (diff) | |
| download | kmi-a12e50e5a7dae52ed8bd5a24cc6576371e20985b.tar.gz kmi-a12e50e5a7dae52ed8bd5a24cc6576371e20985b.zip | |
Started work on syscalls
Diffstat (limited to 'include')
| -rw-r--r-- | include/apos/cpu.h | 7 | ||||
| -rw-r--r-- | include/apos/syscalls.h | 36 | ||||
| -rw-r--r-- | include/apos/tcb.h | 9 | ||||
| -rw-r--r-- | include/apos/uapi.h | 29 | ||||
| -rw-r--r-- | include/apos/utils.h | 2 | ||||
| -rw-r--r-- | include/apos/vmem.h | 1 |
6 files changed, 81 insertions, 3 deletions
diff --git a/include/apos/cpu.h b/include/apos/cpu.h new file mode 100644 index 0000000..a55fbad --- /dev/null +++ b/include/apos/cpu.h @@ -0,0 +1,7 @@ +#ifndef APOS_CPU_H +#define APOS_CPU_H + +unsigned cpu_id(); +/* TODO: add more cpu handling functions */ + +#endif /* APOS_CPU_H */ diff --git a/include/apos/syscalls.h b/include/apos/syscalls.h new file mode 100644 index 0000000..d2427cf --- /dev/null +++ b/include/apos/syscalls.h @@ -0,0 +1,36 @@ +#ifndef APOS_SYSCALLS_H +#define APOS_SYSCALLS_H + +/* enum for now, possibly macros in the future once I get an approximate idea of + * which syscalls are necessary etc. */ +enum { + /* memory management */ + SYS_REQ_MEM, /* request memory from anywhere */ + SYS_REQ_PMEM, /* request physical address */ + SYS_REQ_FIXMEM, /* request memory at fixed address */ + SYS_FREE_MEM, /* free memory */ + + /* IPC */ + /* I really should try to find my notes about the server/client + * structure of the OS, but these following syscalls are probably + * required */ + SYS_IPC_SERVER, /* inform kernel that process should be treated as a server */ + SYS_IPC_REQ, /* IPC request to server */ + SYS_IPC_RESP, /* IPC response from server */ + + /* process management */ + SYS_FORK, /* duplicate process */ + SYS_EXEC, /* execute new binary in process space */ + SYS_SIGNAL, /* send signal to process (kill etc.) */ + SYS_SWITCH, /* switch running process */ + SYS_SYNC, /* used by init process to synchronize running processes, maybe not used */ + + /* kernel management */ + SYS_CONF, /* config system parameters (stack size etc.) */ + SYS_POWEROFF, /* shutdown/reboot etc. */ +} + +/* function declarations should be somewhere else, this file could be used in + * userspace applications as well */ + +#endif /* APOS_SYSCALLS_H */ diff --git a/include/apos/tcb.h b/include/apos/tcb.h index f987b43..714d750 100644 --- a/include/apos/tcb.h +++ b/include/apos/tcb.h @@ -4,6 +4,7 @@ struct tcb; struct sp_reg_root; +#include <tcb.h> #include <vmem.h> #include <apos/vmem.h> #include <apos/types.h> @@ -18,18 +19,20 @@ struct sp_reg_root { struct tcb { struct sp_node sp_n; + struct sp_reg_root sp_r; + struct arch_tcbd tcbd; id_t pid; id_t tid; + vm_t callback; vm_t stack; - vm_t heap; - vm_t bin; struct vm_branch_t *b_r; - struct sp_reg_root sp_r; }; void threads_insert(struct tcb *t); +struct tcb *cur_tcb(); +struct tcb *get_tcb(id_t tid); #endif /* APOS_TCB_H */ diff --git a/include/apos/uapi.h b/include/apos/uapi.h new file mode 100644 index 0000000..74fd846 --- /dev/null +++ b/include/apos/uapi.h @@ -0,0 +1,29 @@ +#ifndef APOS_UAPI_H +#define APOS_UAPI_H + +#include <apos/vmem.h> + +/* syscall function type, let's start with four arguments and see where that + * goes */ +typedef vm_t (*sys_t)(vm_t a0, vm_t a1, vm_t a2, vm_t a3); + +vm_t sys_req_mem(vm_t size, vm_t flags, vm_t u0, vm_t u1); +vm_t sys_req_pmem(vm_t paddr, vm_t size, vm_t flags, vm_t u0); +vm_t sys_req_fixmem(vm_t start, vm_t size, vm_t flags, vm_t u0); +vm_t sys_req_sharedmem(vm_t pid, vm_t start, vm_t size, vm_t flags); +vm_t sys_free_mem(vm_t start, vm_t u0, vm_t u1, vm_t u2); + +vm_t sys_ipc_server(vm_t callback, vm_t u0, vm_t u1, vm_t u2); +vm_t sys_ipc_req(vm_t tgt_pid, vm_t d0, vm_t d1, vm_t d2); +vm_t sys_ipc_resp(vm_t tgt_pid, vm_t ret, vm_t u0, vm_t u1); + +vm_t sys_fork(vm_t pid, vm_t u1, vm_t u2, vm_t u3); +vm_t sys_exec(vm_t pid, vm_t bin, vm_t argc, vm_t argv); +vm_t sys_signal(vm_t pid, vm_t signal, vm_t u0, vm_t u1); +vm_t sys_switch(vm_t pid, vm_t u0, vm_t u1, vm_t u2); +vm_t sys_sync(vm_t buf, vm_t size, vm_t u1, vm_t u2); + +vm_t sys_conf(vm_t param, vm_t val, vm_t u0, vm_t u1); +vm_t sys_poweroff(vm_t type, vm_t u0, vm_t u1, vm_t u2); + +#endif /* APOS_UAPI_H */ diff --git a/include/apos/utils.h b/include/apos/utils.h index eff473f..c2cff2c 100644 --- a/include/apos/utils.h +++ b/include/apos/utils.h @@ -19,6 +19,8 @@ #define QUOTE2(x) #x #define QUOTE(x) QUOTE2(x) +#define UNUSED(x) ((void)(x)) + #include <apos/builtin.h> #if __has_builtin(__builtin_offsetof) diff --git a/include/apos/vmem.h b/include/apos/vmem.h index b7522d2..93d2ed7 100644 --- a/include/apos/vmem.h +++ b/include/apos/vmem.h @@ -54,6 +54,7 @@ vm_t alloc_fixed_region(struct sp_reg_root *r, vm_t start, size_t size, size_t * void free_region(struct sp_reg_root *r, vm_t start); vm_t alloc_uvmem(struct tcb *r, size_t size, uint8_t flags); +vm_t alloc_fixed_uvmem(struct tcb *r, vm_t start, size_t size, uint8_t flags); void free_uvmem(struct tcb *r, vm_t a); vm_t map_fill_region(struct vm_branch_t *b, vm_t start, size_t bytes, uint8_t flags); |
