fix userspace?
This commit is contained in:
35
syscall.c
35
syscall.c
@@ -7,26 +7,31 @@
|
||||
#include "tty.h"
|
||||
#include "timer.h"
|
||||
#include "rtc.h"
|
||||
|
||||
#define NB_SYSCALL 3
|
||||
#include "shell.h"
|
||||
#define NB_SYSCALL 7
|
||||
|
||||
void *syscalls[NB_SYSCALL] = {
|
||||
keyboard_getchar,
|
||||
get_rtc_time,
|
||||
|
||||
sys_halt};
|
||||
sys_halt,
|
||||
terminal_printf,
|
||||
delay,
|
||||
terminal_clear,
|
||||
shell_init
|
||||
};
|
||||
|
||||
void syscall_handler(Stack *registers)
|
||||
{
|
||||
if ((registers->cs & 0x3) != 0x3) return;
|
||||
|
||||
int sys_index = registers->eax;
|
||||
|
||||
if (sys_index >= NB_SYSCALL)
|
||||
return;
|
||||
if (sys_index >= NB_SYSCALL) return;
|
||||
|
||||
void *function = syscalls[sys_index];
|
||||
|
||||
int ret;
|
||||
asm volatile(" push %1; \
|
||||
int ret;
|
||||
asm volatile("sti");
|
||||
asm volatile (" push %1; \
|
||||
push %2; \
|
||||
push %3; \
|
||||
push %4; \
|
||||
@@ -37,10 +42,14 @@ void syscall_handler(Stack *registers)
|
||||
pop %%ebx; \
|
||||
pop %%ebx; \
|
||||
pop %%ebx; \
|
||||
" : "=a"(ret) : "r"(registers->edi), "r"(registers->esi),
|
||||
"r"(registers->edx), "r"(registers->ecx),
|
||||
"r"(registers->ebx), "r"(function));
|
||||
registers->eax = ret;
|
||||
" : "=a" (ret) :
|
||||
"r" (registers->edi), "r" (registers->esi),
|
||||
"r" (registers->edx), "r" (registers->ecx),
|
||||
"r" (registers->ebx), "r" (function));
|
||||
|
||||
asm volatile("cli");
|
||||
|
||||
registers->eax = ret;
|
||||
}
|
||||
|
||||
void syscall_init(void)
|
||||
|
||||
Reference in New Issue
Block a user