26 lines
665 B
C
26 lines
665 B
C
#include <zinnia/compiler.h>
|
|
#include <zinnia/errno.h>
|
|
#include <zinnia/print.h>
|
|
#include <zinnia/sched.h>
|
|
#include <zinnia/syscall.h>
|
|
#include <zinnia/types.h>
|
|
#include <zinnia/utils.h>
|
|
|
|
static const syscall_fn_t dispatch_table[] = {
|
|
#undef __ZINNIA_UAPI_SYSCALL_NUMBERS_H // We want to include the header again
|
|
#define __SYSCALL_DEFINE(idx, name) [idx] = syscall_##name,
|
|
#include <uapi/syscall_numbers.h>
|
|
#undef __SYSCALL_DEFINE
|
|
};
|
|
|
|
void syscall_dispatch(struct arch_context* ctx) {
|
|
const size_t num = ctx->ARCH_CTX_NUM;
|
|
|
|
if (num >= ARRAY_SIZE(dispatch_table)) {
|
|
ctx->ARCH_CTX_RET0 = ENOSYS;
|
|
return;
|
|
}
|
|
|
|
dispatch_table[num](ctx);
|
|
}
|