From 34ab1bd020ad5567955654ae5f0f8f0a10e62b1e Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Sun, 26 Nov 2023 18:36:26 -0600 Subject: arch: i386: syscall.c: replace function calls with single switch Replace individual function calls with a single switch-case structure for system calls. The new function, handle_syscall, will construct and call the interrupt without input from the programmer. Signed-off-by: Danny Holman --- arch/i386/kernel/syscall.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'arch/i386/kernel') diff --git a/arch/i386/kernel/syscall.c b/arch/i386/kernel/syscall.c index 18f36ad..593bb64 100644 --- a/arch/i386/kernel/syscall.c +++ b/arch/i386/kernel/syscall.c @@ -2,27 +2,15 @@ #include #include -void *(*syscall_handlers[30])(struct isr_frame *frame); - -void syscall_dispatch(struct isr_frame *frame) { - if (syscall_handlers[frame->eax] != NULL) - syscall_handlers[frame->eax](frame); - else - kprintf("Error: Invalid system call number: %d\n", frame->eax); -} - -void register_syscall(void *handler(struct isr_frame*), int num) { - syscall_handlers[num] = handler; -} - -void sys_stop(struct isr_frame *frame) { - kprintf("SYSTEM CALL: STOP\n"); - halt_catch_fire(frame); -} - -void sys_status(struct isr_frame *frame) { - kprintf("SYSTEM CALL: STATUS\n"); - dump_reg(frame); +int handle_syscall(struct isr_frame *frame) { + switch (frame->eax) { + case SYS_REBOOT: + kprintf("REBOOT NOT SUPPORTED\n"); + break; + default: + kprintf("Error: Invalid system call number: %d\n", frame->eax); + } + return 0; } void dump_reg(struct isr_frame *frame) { -- cgit v1.2.3