mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Syscall table
This commit is contained in:
parent
8d61c9b5e0
commit
c6e568990f
@ -31,6 +31,10 @@
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#define LATEST_SYSCALL_CODE 0
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
extern error_t KeSyscall(ulong code);
|
||||
|
||||
extern void KeJumpToUserspace(ulong args, void *entryPoint, void *stackAddr);
|
||||
@ -38,6 +42,8 @@ extern void KeJumpToUserspace(ulong args, void *entryPoint, void *stackAddr);
|
||||
error_t _KeSyscallHandler( ulong code, void *arg0, void *arg1, void *arg2,
|
||||
ISRFrame_t *regs );
|
||||
|
||||
void KeEnableSyscalls();
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#endif
|
||||
|
@ -77,6 +77,7 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
|
||||
KeEnableIRQs();
|
||||
KeEnableRTC();
|
||||
KeEnablePIT();
|
||||
KeEnableSyscalls();
|
||||
|
||||
// Interrupt handlers
|
||||
MmActivatePageHandler();
|
||||
|
@ -25,17 +25,49 @@
|
||||
#include <libbuf.h>
|
||||
#include <init/boot.h>
|
||||
#include <ke/idt.h>
|
||||
#include <ke/syscall.h>
|
||||
#include <io/vga.h>
|
||||
|
||||
error_t _KeSyscallHandler( ulong code, void *arg0, void *arg1, void *arg2,
|
||||
static error_t (*syscallTable[255])(void*, void*, void*, ISRFrame_t*) = {NULL};
|
||||
|
||||
|
||||
//
|
||||
// Syscall handler that dispatches calls depending of code value
|
||||
//
|
||||
error_t _KeSyscallHandler( ulong code, void *rdi, void *rsi, void *rdx,
|
||||
ISRFrame_t *regs )
|
||||
{
|
||||
DebugLog("Got a system call code %ld from cs %#x\n", code, regs->cs);
|
||||
|
||||
if ((ulong)regs->cs != (ulong)BtLoaderInfo.codeSegment) {
|
||||
bprintf(BStdOut, "Got a system call from userspace code %d\n", code);
|
||||
BStdOut->flusher(BStdOut);
|
||||
{
|
||||
if ((ulong)regs->cs >= (ulong)BtLoaderInfo.codeSegment) {
|
||||
DebugLog("System call code %ld from userspace (cs %#x)\n",
|
||||
code, regs->cs);
|
||||
} else {
|
||||
DebugLog("System call call code %ld from kernel (cs %#x)\n",
|
||||
code, regs->cs);
|
||||
}
|
||||
|
||||
if (code > LATEST_SYSCALL_CODE) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return syscallTable[(uchar)code](rdi, rsi, rdx, regs);
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
//
|
||||
// Syscalls
|
||||
//
|
||||
static error_t syscallRead(void *rdi, void *rsi, void *rdx, ISRFrame_t *regs)
|
||||
{
|
||||
DebugLog("syscallRead attempted\n");
|
||||
return EOK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Initializes the syscall table
|
||||
//
|
||||
void KeEnableSyscalls()
|
||||
{
|
||||
syscallTable[0] = syscallRead;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user