proc_quit () and proc_test () syscalls
All checks were successful
Build documentation / build-and-deploy (push) Successful in 43s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 43s
This commit is contained in:
1
kernel/syscall/.gitignore
vendored
Normal file
1
kernel/syscall/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.o
|
||||
10
kernel/syscall/defs.h
Normal file
10
kernel/syscall/defs.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef _KERNEL_SYSCALL_DEFS_H
|
||||
#define _KERNEL_SYSCALL_DEFS_H
|
||||
|
||||
#define SYS_PROC_QUIT 1
|
||||
#define SYS_PROC_TEST 2
|
||||
|
||||
#define SR_OK 0
|
||||
#define SR_SYSCALL_NOT_FOUND 1
|
||||
|
||||
#endif // _KERNEL_SYSCALL_DEFS_H
|
||||
3
kernel/syscall/src.mk
Normal file
3
kernel/syscall/src.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
c += syscall/syscall.c
|
||||
|
||||
o += syscall/syscall.o
|
||||
34
kernel/syscall/syscall.c
Normal file
34
kernel/syscall/syscall.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <aux/compiler.h>
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
#include <sys/debug.h>
|
||||
#include <syscall/defs.h>
|
||||
#include <syscall/syscall.h>
|
||||
|
||||
#define DEFINE_SYSCALL(name) \
|
||||
int name (struct proc* proc, uintptr_t UNUSED a1, uintptr_t UNUSED a2, uintptr_t UNUSED a3, \
|
||||
uintptr_t UNUSED a4, uintptr_t UNUSED a5, uintptr_t UNUSED a6)
|
||||
|
||||
DEFINE_SYSCALL (sys_proc_quit) {
|
||||
proc_kill (proc);
|
||||
proc_sched ();
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
DEFINE_SYSCALL (sys_proc_test) {
|
||||
DEBUG ("test syscall message!\n");
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static syscall_handler_func_t handler_table[] = {
|
||||
[SYS_PROC_QUIT] = &sys_proc_quit,
|
||||
[SYS_PROC_TEST] = &sys_proc_test,
|
||||
};
|
||||
|
||||
syscall_handler_func_t syscall_find_handler (int syscall_num) {
|
||||
if (!(syscall_num >= 0 && syscall_num < (sizeof (handler_table) / sizeof (handler_table[0])))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return handler_table[syscall_num];
|
||||
}
|
||||
12
kernel/syscall/syscall.h
Normal file
12
kernel/syscall/syscall.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef _KERNEL_SYSCALL_SYSCALL_H
|
||||
#define _KERNEL_SYSCALL_SYSCALL_H
|
||||
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
|
||||
typedef int (*syscall_handler_func_t) (struct proc* proc, uintptr_t a1, uintptr_t a2, uintptr_t a3,
|
||||
uintptr_t a4, uintptr_t a5, uintptr_t a6);
|
||||
|
||||
syscall_handler_func_t syscall_find_handler (int syscall_num);
|
||||
|
||||
#endif // _KERNEL_SYSCALL_SYSCALL_H
|
||||
Reference in New Issue
Block a user