Vhex-kernel/src/kernel/syscall/handler.c

61 lines
1.3 KiB
C
Raw Normal View History

2019-12-29 16:39:30 +01:00
#include <kernel/syscall.h>
2020-03-15 00:56:31 +01:00
#include <kernel/devices/earlyterm.h>
#include <asm/unistd_32.h>
2019-12-29 16:39:30 +01:00
2020-01-01 14:19:18 +01:00
static void sys_test(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
{
2020-03-15 00:56:31 +01:00
earlyterm_clear();
earlyterm_write("Syscall test entry:\n");
earlyterm_write("* a = %#x\n", a);
earlyterm_write("* b = %#x\n", b);
earlyterm_write("* c = %#x\n", c);
earlyterm_write("* d = %#x\n", d);
2020-05-03 23:10:49 +02:00
while (1);
2020-01-01 14:19:18 +01:00
}
static const void *sys_handler[__NR_MAX] = {
// Kernel Test
sys_test, // test
// Process
sys_exit, // exit
sys_fexecve, // fexecve
sys_waitpid, // waitpid
sys_wait, // wait
sys_getpid, // getpid
sys_getppid, // getppid
sys_getpgid, // getpgid
sys_setpgid, // setpgid
// VFS
sys_read, // read
sys_write, // write
sys_open, // open
sys_close, // close
sys_lseek, // lseek
sys_pread, // pread
sys_pwrite, // pwrite
// Memory
sys_mmap, // mmap
NULL, // munmap
sys_proc_heap_alloc, // (custom) process heap alloc
sys_proc_heap_free, // (custom) process heap free
sys_proc_heap_realloc // (custom) process heap realloc
2019-12-29 16:39:30 +01:00
};
void *sys_get_handler(int sysno)
{
2020-01-01 14:19:18 +01:00
// Check sysno validity
if (sysno < 0 || sysno >= __NR_MAX)
return (NULL);
2020-01-01 14:19:18 +01:00
// DEBUG
//earlyterm_write("syscall (%d)!!\n", sysno);
//DBG_WAIT;
//DBG_WAIT;
2020-01-10 17:21:44 +01:00
2020-01-01 14:19:18 +01:00
// Return syscall
2019-12-29 16:39:30 +01:00
return ((void *)sys_handler[sysno]);
}