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

View File

@@ -12,7 +12,7 @@ set(kernel_arch x86_64)
set(kernel_name "Mango")
set(kernel_exe_name "mango_kernel")
set(generic_src_dirs ds init kernel libc sched util vm)
set(generic_src_dirs ds init kernel libc sched util vm syscall)
set(kernel_sources "")
set(kernel_headers "")

View File

@@ -206,7 +206,7 @@ void irq_dispatch(struct ml_cpu_context *regs)
void syscall_dispatch(struct ml_cpu_context *regs)
{
unsigned int sysid = regs->rax;
virt_addr_t syscall_impl = syscall_get_func(sysid);
virt_addr_t syscall_impl = syscall_get_function(sysid);
if (syscall_impl == 0) {
regs->rax = KERN_UNSUPPORTED;

View File

@@ -15,6 +15,6 @@ extern kern_status_t sys_vm_object_create(
enum vm_prot prot,
kern_handle_t *out_handle);
extern virt_addr_t syscall_get_func(unsigned int sysid);
extern virt_addr_t syscall_get_function(unsigned int sysid);
#endif

View File

@@ -2,25 +2,6 @@
#include <mango/printk.h>
#include <mango/syscall.h>
kern_status_t sys_exit(int status)
{
printk("sys_exit(%d)", status);
while (1) {
ml_cpu_pause();
}
return KERN_UNIMPLEMENTED;
}
kern_status_t sys_vm_object_create(
const char *name,
size_t len,
enum vm_prot prot,
kern_handle_t *out_handle)
{
printk("sys_vm_object_create()");
return KERN_UNIMPLEMENTED;
}
#define SYSCALL_TABLE_ENTRY(id, p) [SYS_##id] = (virt_addr_t)(sys_##p)
static const virt_addr_t syscall_table[] = {
@@ -30,7 +11,7 @@ static const virt_addr_t syscall_table[] = {
static const size_t syscall_table_count
= sizeof syscall_table / sizeof syscall_table[0];
virt_addr_t syscall_get_func(unsigned int sysid)
virt_addr_t syscall_get_function(unsigned int sysid)
{
if (sysid >= syscall_table_count) {
return 0;

13
syscall/task.c Normal file
View File

@@ -0,0 +1,13 @@
#include <mango/machine/cpu.h>
#include <mango/printk.h>
#include <mango/sched.h>
extern kern_status_t sys_exit(int status)
{
printk("sys_exit(%d)", status);
while (1) {
ml_cpu_pause();
}
return KERN_UNIMPLEMENTED;
}

13
syscall/vm-object.c Normal file
View File

@@ -0,0 +1,13 @@
#include <mango/handle.h>
#include <mango/printk.h>
#include <mango/vm-region.h>
kern_status_t sys_vm_object_create(
const char *name,
size_t len,
enum vm_prot prot,
kern_handle_t *out_handle)
{
printk("sys_vm_object_create()");
return KERN_UNIMPLEMENTED;
}