Updated syscalls

This commit is contained in:
Alex 2022-12-11 14:34:30 +02:00
parent ab7f20d5f5
commit d540462e0a
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
2 changed files with 95 additions and 4 deletions

View File

@ -1,4 +1,5 @@
#include <syscalls.hpp>
#include <memory.hpp>
#include <debug.h>
@ -22,9 +23,23 @@ static int sys_print(SyscallsFrame *Frame, char Char, int Index)
return ret;
}
static uint64_t sys_request_pages(SyscallsFrame *Frame, uint64_t Count)
{
return (uint64_t)TaskManager->GetCurrentThread()->Memory->RequestPages(Count);
}
static uint64_t sys_free_pages(SyscallsFrame *Frame, uint64_t Address, uint64_t Count)
{
TaskManager->GetCurrentThread()->Memory->FreePages((void *)Address, Count);
return 0;
}
static void *NativeSyscallsTable[] = {
[_exit] = (void *)sys_exit,
[_print] = (void *)sys_print,
[_Exit] = (void *)sys_exit,
[_Print] = (void *)sys_print,
[_RequestPages] = (void *)sys_request_pages,
[_FreePages] = (void *)sys_free_pages,
};
uint64_t HandleNativeSyscalls(SyscallsFrame *Frame)

View File

@ -5,8 +5,84 @@
enum NativeSyscalls
{
_exit = 0,
_print,
_Exit = 0,
_Print,
_RequestPages,
_FreePages,
};
static inline long syscall0(long syscall)
{
unsigned long ret;
__asm__ __volatile__("syscall"
: "=a"(ret)
: "a"(syscall)
: "rcx", "r11", "memory");
return ret;
}
static inline long syscall1(long syscall, long arg1)
{
unsigned long ret;
__asm__ __volatile__("syscall"
: "=a"(ret)
: "a"(syscall), "D"(arg1)
: "rcx", "r11", "memory");
return ret;
}
static inline long syscall2(long syscall, long arg1, long arg2)
{
unsigned long ret;
__asm__ __volatile__("syscall"
: "=a"(ret)
: "a"(syscall), "D"(arg1), "S"(arg2)
: "rcx", "r11", "memory");
return ret;
}
static inline long syscall3(long syscall, long arg1, long arg2, long arg3)
{
unsigned long ret;
__asm__ __volatile__("syscall"
: "=a"(ret)
: "a"(syscall), "D"(arg1), "S"(arg2), "d"(arg3)
: "rcx", "r11", "memory");
return ret;
}
static inline long syscall4(long syscall, long arg1, long arg2, long arg3, long arg4)
{
unsigned long ret;
/* FIXME: matching constraint references invalid operand number */
// __asm__ __volatile__("syscall"
// : "=a"(ret)
// : "a"(syscall), "D"(arg1), "S"(arg2), "d"(arg3), "r10"(arg4)
// : "rcx", "r11", "memory");
return ret;
}
static inline long syscall5(long syscall, long arg1, long arg2, long arg3, long arg4, long arg5)
{
unsigned long ret;
/* FIXME: matching constraint references invalid operand number */
// __asm__ __volatile__("syscall"
// : "=a"(ret)
// : "a"(syscall), "D"(arg1), "S"(arg2), "d"(arg3), "r10"(arg4), "r8"(arg5)
// : "rcx", "r11", "memory");
return ret;
}
static inline long syscall6(long syscall, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6)
{
unsigned long ret;
/* FIXME: matching constraint references invalid operand number */
// __asm__ __volatile__("syscall"
// : "=a"(ret)
// : "a"(syscall), "D"(arg1), "S"(arg2), "d"(arg3), "r10"(arg4), "r8"(arg5), "r9"(arg6)
// : "rcx", "r11", "memory");
return ret;
}
#endif // !__FENNIX_KERNEL_SYSCALLS_LIST_H__