kernel: refactor syscall dispatch system
This commit is contained in:
@@ -12,7 +12,7 @@ set(kernel_arch x86_64)
|
|||||||
set(kernel_name "Mango")
|
set(kernel_name "Mango")
|
||||||
set(kernel_exe_name "mango_kernel")
|
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_sources "")
|
||||||
set(kernel_headers "")
|
set(kernel_headers "")
|
||||||
|
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ void irq_dispatch(struct ml_cpu_context *regs)
|
|||||||
void syscall_dispatch(struct ml_cpu_context *regs)
|
void syscall_dispatch(struct ml_cpu_context *regs)
|
||||||
{
|
{
|
||||||
unsigned int sysid = regs->rax;
|
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) {
|
if (syscall_impl == 0) {
|
||||||
regs->rax = KERN_UNSUPPORTED;
|
regs->rax = KERN_UNSUPPORTED;
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ extern kern_status_t sys_vm_object_create(
|
|||||||
enum vm_prot prot,
|
enum vm_prot prot,
|
||||||
kern_handle_t *out_handle);
|
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
|
#endif
|
||||||
|
|||||||
@@ -2,25 +2,6 @@
|
|||||||
#include <mango/printk.h>
|
#include <mango/printk.h>
|
||||||
#include <mango/syscall.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)
|
#define SYSCALL_TABLE_ENTRY(id, p) [SYS_##id] = (virt_addr_t)(sys_##p)
|
||||||
|
|
||||||
static const virt_addr_t syscall_table[] = {
|
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
|
static const size_t syscall_table_count
|
||||||
= sizeof syscall_table / sizeof syscall_table[0];
|
= 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) {
|
if (sysid >= syscall_table_count) {
|
||||||
return 0;
|
return 0;
|
||||||
13
syscall/task.c
Normal file
13
syscall/task.c
Normal 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
13
syscall/vm-object.c
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user