aboutsummaryrefslogtreecommitdiff
path: root/common/uapi
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2021-12-27 20:40:44 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2021-12-27 20:40:44 +0200
commita12e50e5a7dae52ed8bd5a24cc6576371e20985b (patch)
tree70ddf625029dbe1ca4d38ec4f1819fe5fe7e4291 /common/uapi
parentd98ec57128628b81fcd32269a92742a037b7f713 (diff)
downloadkmi-a12e50e5a7dae52ed8bd5a24cc6576371e20985b.tar.gz
kmi-a12e50e5a7dae52ed8bd5a24cc6576371e20985b.zip
Started work on syscalls
Diffstat (limited to 'common/uapi')
-rw-r--r--common/uapi/conf.c15
-rw-r--r--common/uapi/ipc.c28
-rw-r--r--common/uapi/mem.c45
-rw-r--r--common/uapi/proc.c47
4 files changed, 135 insertions, 0 deletions
diff --git a/common/uapi/conf.c b/common/uapi/conf.c
new file mode 100644
index 0000000..01c4ada
--- /dev/null
+++ b/common/uapi/conf.c
@@ -0,0 +1,15 @@
+#include <apos/uapi.h>
+
+vm_t sys_conf(vm_t param, vm_t val, vm_t u0, vm_t u1)
+{
+ UNUSED(u0); UNUSED(u1);
+ /* no parameters supported atm */
+ return 0;
+}
+
+vm_t sys_poweroff(vm_t type, vm_t u0, vm_t u1, vm_t u2)
+{
+ UNUSED(u0); UNUSED(u1); UNUSED(u2);
+ /* powering off not supported yet, you're stuck here >:D */
+ return 0;
+}
diff --git a/common/uapi/ipc.c b/common/uapi/ipc.c
new file mode 100644
index 0000000..5abbaeb
--- /dev/null
+++ b/common/uapi/ipc.c
@@ -0,0 +1,28 @@
+#include <apos/uapi.h>
+#include <apos/tcb.h>
+
+vm_t sys_ipc_server(vm_t callback, vm_t u0, vm_t u1, vm_t u2)
+{
+ UNUSED(u0); UNUSED(u1); UNUSED(u2);
+ struct tcb *r = cur_tcb();
+ if(r->callback) /* server can't be reinitialized */
+ return 1;
+
+ r->callback = callback;
+ return 0;
+}
+
+vm_t sys_ipc_req(vm_t pid, vm_t d0, vm_t d1, vm_t d2)
+{
+ struct tcb *t = get_tcb(pid);
+ /* something like jump_to_callback(t, d0, d1, d2) */
+ return 0;
+}
+
+vm_t sys_ipc_resp(vm_t pid, vm_t ret, vm_t u0, vm_t u1)
+{
+ UNUSED(u0); UNUSED(u1);
+ struct tcb *r = get_tcb(pid);
+ /* something like return_from_callback(t, r) */
+ return 0; /* oh yeah probably unreachable? */
+}
diff --git a/common/uapi/mem.c b/common/uapi/mem.c
new file mode 100644
index 0000000..34ddda2
--- /dev/null
+++ b/common/uapi/mem.c
@@ -0,0 +1,45 @@
+#include <apos/uapi.h>
+#include <apos/utils.h>
+#include <apos/vmem.h>
+
+vm_t sys_req_mem(vm_t size, vm_t flags, vm_t u0, vm_t u1)
+{
+ UNUSED(u0); UNUSED(u1);
+ /* proc_tcb should give the tcb of the TID currently running */
+ struct tcb *r = cur_tcb();
+ return alloc_uvmem(r, size, flags);
+}
+
+vm_t sys_req_fixmem(vm_t start, vm_t size, vm_t flags, vm_t u0)
+{
+ UNUSED(u0);
+ struct tcb *r = cur_tcb();
+ return alloc_fixed_uvmem(r, start, size, flags);
+}
+
+vm_t sys_free_mem(vm_t start, vm_t u0, vm_t u1, vm_t u2)
+{
+ UNUSED(u0); UNUSED(u1); UNUSED(u2);
+ struct tcb *r = cur_tcb();
+ free_uvmem(r, start);
+ return 0;
+}
+
+vm_t sys_req_pmem(vm_t paddr, vm_t size, vm_t flags, vm_t u0)
+{
+ UNUSED(u0);
+ /* this will require some pondering, but essentially this syscall should
+ * only be used for device access, so any addresses requested should be
+ * outside the RAM area, and I'll probably have to implement some method
+ * that keeps track of used regions outside of RAM. We'll see.
+ */
+ return 0;
+}
+
+vm_t sys_req_sharedmem(vm_t pid, vm_t start, vm_t size, vm_t flags)
+{
+ /* take memory in PID's vaddr and map it somewhere in our own memory
+ * region.
+ */
+ return 0;
+}
diff --git a/common/uapi/proc.c b/common/uapi/proc.c
new file mode 100644
index 0000000..dd05bad
--- /dev/null
+++ b/common/uapi/proc.c
@@ -0,0 +1,47 @@
+#include <apos/uapi.h>
+
+/* 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
+ * slight bit of delay.
+ *
+ * I suppose I could add in a runtime parameter
+ * that would allow them to be called directly, and then the process manager
+ * would have to periodically ask the kernel about all threads it is aware of
+ * via sys_sync. Dunno.
+ */
+vm_t sys_fork(vm_t pid, vm_t u0, vm_t u1, vm_t u2)
+{
+ UNUSED(u0); UNUSED(u1); UNUSED(u2);
+ /* TODO: create new thread in the same process family */
+ return 0;
+}
+
+vm_t sys_exec(vm_t pid, vm_t bin, vm_t argc, vm_t argv)
+{
+ /* TODO: execute new process */
+ return 0;
+}
+
+vm_t sys_signal(vm_t pid, vm_t signal, vm_t u0, vm_t u1)
+{
+ UNUSED(u0); UNUSED(u1);
+ /* TODO: signals? */
+ return 0;
+}
+
+vm_t sys_switch(vm_t pid, vm_t u0, vm_t u1, vm_t u2)
+{
+ UNUSED(u0); UNUSED(u1); UNUSED(u2);
+ /* TODO: switch to process */
+ return 0;
+}
+
+vm_t sys_sync(vm_t buf, vm_t size, vm_t u0, vm_t u1)
+{
+ UNUSED(u0); UNUSED(u1);
+ /* check that only the process manager can use this syscall, otherwise
+ * just dump process info into the buffer (I guess, not sure if this
+ * will be quite required */
+ return 0;
+}