From 3e14c632b3b9c39d27693f2538f377fb52de193a Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 4 Dec 2019 22:15:27 +0100 Subject: Fully working syscall interface --- src/kernel/syscall/syscall.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/kernel/syscall/syscall.c') 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); } -- cgit v1.2.3