1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00

Kernel shell as a syscall

This commit is contained in:
Adrien Bourmault 2021-03-08 17:16:21 +01:00
parent c6e568990f
commit bb5a743ed4
Signed by: neox
GPG Key ID: 6EB408FE0ACEC664
3 changed files with 28 additions and 9 deletions

View File

@ -31,7 +31,7 @@
//----------------------------------------------------------------------------//
#define LATEST_SYSCALL_CODE 0
#define LATEST_SYSCALL_CODE 3
//----------------------------------------------------------------------------//

View File

@ -27,6 +27,7 @@
#include <ke/idt.h>
#include <ke/syscall.h>
#include <io/vga.h>
#include <sh/shell.h>
static error_t (*syscallTable[255])(void*, void*, void*, ISRFrame_t*) = {NULL};
@ -46,23 +47,37 @@ error_t _KeSyscallHandler( ulong code, void *rdi, void *rsi, void *rdx,
}
if (code > LATEST_SYSCALL_CODE) {
return EINVAL;
return ENOSYS;
}
return syscallTable[(uchar)code](rdi, rsi, rdx, regs);
return EOK;
return syscallTable[(uchar)code](rdi, rsi, rdx, regs);
}
//
// Syscalls
//
static error_t syscallRead(void *rdi, void *rsi, void *rdx, ISRFrame_t *regs)
static error_t syscallStub(void *rdi, void *rsi, void *rdx, ISRFrame_t *regs)
{
DebugLog("syscallRead attempted\n");
return EOK;
return ENOSYS;
}
static error_t syscallRead(void *rdi, void *rsi, void *rdx, ISRFrame_t *regs)
{
return ENOSYS;
}
static error_t syscallWrite(void *rdi, void *rsi, void *rdx, ISRFrame_t *regs)
{
return ENOSYS;
}
static error_t syscallKernelShell(void *rdi, void *rsi, void *rdx, ISRFrame_t *regs)
{
KeEnableIRQs();
ShStartShell(); //TODO : return from Shell
KePauseIRQs();
return EOK;
}
//
// Initializes the syscall table
@ -70,4 +85,8 @@ static error_t syscallRead(void *rdi, void *rsi, void *rdx, ISRFrame_t *regs)
void KeEnableSyscalls()
{
syscallTable[0] = syscallRead;
syscallTable[1] = syscallWrite;
syscallTable[2] = syscallStub;
syscallTable[3] = syscallStub;
syscallTable[4] = syscallKernelShell;
}

View File

@ -28,7 +28,7 @@ global UserTest
global EndOfUser
UserTest:
mov rdi, 45
mov rdi, 4
int 0x80
.clone: