diff --git a/include/sys/syscall.h b/include/sys/syscall.h new file mode 100644 index 0000000..88c3b05 --- /dev/null +++ b/include/sys/syscall.h @@ -0,0 +1,10 @@ +#pragma once + +#define SYSCALL_NR_FORK 57 +int sys_fork(void *ctx); + +#define SYSCALL_NR_EXIT 60 +__attribute__((noreturn)) void sys_exit(int status); + +#define SYSCALL_NR_DEBUG_TRACE 255 +void sys_debug_trace(const char *msg); diff --git a/sys/amd64/syscall.c b/sys/amd64/syscall.c index f2343e5..e8d980a 100644 --- a/sys/amd64/syscall.c +++ b/sys/amd64/syscall.c @@ -1,4 +1,5 @@ #include "sys/amd64/cpu.h" +#include "sys/syscall.h" #include "sys/debug.h" #define MSR_IA32_STAR 0xC0000081 @@ -7,11 +8,16 @@ extern void syscall_entry(void); -extern __attribute__((noreturn)) void sys_exit(int status); +void sys_debug_trace(const char *msg) { + kdebug("Trace message: %s\n", msg); +} void *syscall_table[256] = { NULL, - [60] = sys_exit, + + [SYSCALL_NR_EXIT] = sys_exit, + + [SYSCALL_NR_DEBUG_TRACE] = sys_debug_trace, }; void syscall_undefined(uint64_t rax) {