kernel: refactor syscall dispatch system
This commit is contained in:
21
syscall/dispatch.c
Normal file
21
syscall/dispatch.c
Normal 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];
|
||||
}
|
||||
Reference in New Issue
Block a user