syscall: fix page fault on non-existent syscall
Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
This commit is contained in:
parent
9ed457728d
commit
cb288f547e
3 changed files with 8 additions and 3 deletions
|
|
@ -14,6 +14,7 @@
|
||||||
#define EFAULT 10
|
#define EFAULT 10
|
||||||
#define EAGAIN 11
|
#define EAGAIN 11
|
||||||
#define EBUSY 12
|
#define EBUSY 12
|
||||||
|
#define ENOSYS 13
|
||||||
|
|
||||||
const char *strerror(int errnum);
|
const char *strerror(int errnum);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ static const char *errno_str[] = {
|
||||||
[EFAULT] = "Bad address",
|
[EFAULT] = "Bad address",
|
||||||
[EAGAIN] = "Try again",
|
[EAGAIN] = "Try again",
|
||||||
[EBUSY] = "Device or resource busy",
|
[EBUSY] = "Device or resource busy",
|
||||||
|
[ENOSYS] = "Function not implemented",
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const char *strerror(int errnum)
|
inline const char *strerror(int errnum)
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,19 @@
|
||||||
|
|
||||||
#define SYSCALL_MAX 0x100
|
#define SYSCALL_MAX 0x100
|
||||||
|
|
||||||
typedef void (*syscall_t)(uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5);
|
typedef void *(*syscall_t)(uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5);
|
||||||
|
|
||||||
syscall_t syscall_table[SYSCALL_MAX];
|
syscall_t syscall_table[SYSCALL_MAX];
|
||||||
slab_t *fd_slab;
|
slab_t *fd_slab;
|
||||||
|
|
||||||
void syscall(uint64_t syscall_no, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5)
|
uint64_t syscall(uint64_t syscall_no, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5)
|
||||||
{
|
{
|
||||||
syscall_t syscall = (void *)syscall_table[syscall_no];
|
syscall_t syscall = (void *)syscall_table[syscall_no];
|
||||||
|
|
||||||
syscall(arg1, arg2, arg3, arg4, arg5);
|
if (syscall == NULL)
|
||||||
|
return -ENOSYS;
|
||||||
|
|
||||||
|
return (uint64_t)syscall(arg1, arg2, arg3, arg4, arg5);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t sys_read(int fd, void *buf, size_t count)
|
ssize_t sys_read(int fd, void *buf, size_t count)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue