aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/syscall
diff options
context:
space:
mode:
authorMarvin Borner2019-12-04 22:15:27 +0100
committerMarvin Borner2019-12-04 22:15:27 +0100
commit3e14c632b3b9c39d27693f2538f377fb52de193a (patch)
tree688b7e365560ca61485a54a4576a61982c8c5f29 /src/kernel/syscall
parented3da12bb378d82878fff1d50e5e9e7af3d7265d (diff)
Fully working syscall interface
Diffstat (limited to 'src/kernel/syscall')
-rw-r--r--src/kernel/syscall/actions/sys_write.c9
-rw-r--r--src/kernel/syscall/syscall.c15
2 files changed, 14 insertions, 10 deletions
diff --git a/src/kernel/syscall/actions/sys_write.c b/src/kernel/syscall/actions/sys_write.c
index 19c35fa..882ff19 100644
--- a/src/kernel/syscall/actions/sys_write.c
+++ b/src/kernel/syscall/actions/sys_write.c
@@ -1,12 +1,9 @@
#include <stdint-gcc.h>
#include <mlibc/stdio.h>
-#include <kernel/io/io.h>
-uint32_t sys_write(unsigned int buf, unsigned int count)
+uint32_t sys_write(unsigned int fd, unsigned int buf, unsigned int count)
{
- serial_write("\n");
- serial_write_dec(count);
- serial_write("WRITE: \n");
- serial_write((const char *) buf);
+ for (uint32_t i = 0; i < count; i++)
+ writec(*((char *) buf++));
return count;
} \ No newline at end of file
diff --git a/src/kernel/syscall/syscall.c b/src/kernel/syscall/syscall.c
index 08b4d49..0eac619 100644
--- a/src/kernel/syscall/syscall.c
+++ b/src/kernel/syscall/syscall.c
@@ -5,13 +5,20 @@
typedef uint32_t (*syscall_func)(unsigned int, ...);
+uint32_t (*syscalls[])() = {
+ [1] = sys_write
+};
+
void syscall_handler(struct regs *r)
{
+ if (r->eax >= sizeof(syscalls) / sizeof(*syscalls))
+ return;
+
+ syscall_func location = (syscall_func) syscalls[r->eax];
+ if (!location)
+ return;
+
serial_write("Received syscall!\n");
- serial_write_dec(r->eax);
- serial_write("\n");
- serial_write_dec(r->ecx);
- syscall_func location = (syscall_func) sys_write;
location(r->ebx, r->ecx, r->edx, r->esi, r->edi);
}