kernel: refactor syscall dispatch system

This commit is contained in:
2026-02-08 16:17:11 +00:00
parent c424e8127e
commit 9f7b7bdd2d
6 changed files with 30 additions and 23 deletions

21
syscall/dispatch.c Normal file
View File

@@ -0,0 +1,21 @@
#include <mango/machine/cpu.h>
#include <mango/printk.h>
#include <mango/syscall.h>
#define SYSCALL_TABLE_ENTRY(id, p) [SYS_##id] = (virt_addr_t)(sys_##p)
static const virt_addr_t syscall_table[] = {
SYSCALL_TABLE_ENTRY(EXIT, exit),
SYSCALL_TABLE_ENTRY(VM_OBJECT_CREATE, vm_object_create),
};
static const size_t syscall_table_count
= sizeof syscall_table / sizeof syscall_table[0];
virt_addr_t syscall_get_function(unsigned int sysid)
{
if (sysid >= syscall_table_count) {
return 0;
}
return syscall_table[sysid];
}