From b933a9955a2a1eb0ab32b232e23d24dc207cba46 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 9 Aug 2020 18:50:17 +0200 Subject: Added syscall templates --- kernel/features/syscall.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'kernel') diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c index 3d012cf..1a43b9e 100644 --- a/kernel/features/syscall.c +++ b/kernel/features/syscall.c @@ -6,16 +6,33 @@ #include #include #include +#include int i = 0; void syscall_handler(struct regs *r) { - printf("[SYSCALL] %d\n", r->eax); + enum sys num = r->eax; + printf("[SYSCALL] %d\n", num); - struct proc *a = proc_make(); - bin_load(++i ? "/a" : "/b", a); - strcpy(a->name, "a"); - proc_print(); + switch (num) { + case SYS_HALT: { + loop(); + break; + } + case SYS_EXEC: { + char *path = (char *)r->ebx; + struct proc *proc = proc_make(); + bin_load(path, proc); + strcpy(proc->name, path); + proc_print(); + break; + } + default: { + printf("Unknown syscall!\n"); + loop(); + break; + } + } } void syscall_init() -- cgit v1.2.3