1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-10-30 12:03:52 -04:00

Start implementing syscalls

This commit is contained in:
Braiden Vasco 2017-11-05 17:15:34 +00:00
parent 1afdbaa6fe
commit 5b3974c93f
3 changed files with 34 additions and 4 deletions

View file

@ -1,9 +1,22 @@
#include "interrupt.h" #include "interrupt.h"
#include "kprintf.h" #include "kprintf.h"
void syscall_handler(struct IsrRegisters regs) #include <kernelmq/syscall.h>
static void syscall_do_exit(struct IsrRegisters regs);
void syscall_handler(const struct IsrRegisters regs)
{ {
const unsigned int id = regs.eax & 0xFFFF; const unsigned int id = regs.eax & 0xFFFF;
switch (id) {
case KERNELMQ_SYSCALL_EXIT: return syscall_do_exit(regs);
}
kprintf("syscall %u\n", id); kprintf("syscall %u\n", id);
} }
void syscall_do_exit(const struct IsrRegisters regs)
{
kprintf("process try to exit with error code %u, haha\n", regs.ebx & 0xFFFF);
}

View file

@ -0,0 +1,16 @@
#ifndef KERNELMQ_INCLUDED_SYSCALL
#define KERNELMQ_INCLUDED_SYSCALL 1
#ifdef __cplusplus
extern "C" {
#endif
enum KernelMQ_Syscall_Number {
KERNELMQ_SYSCALL_EXIT = 0,
};
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,11 +1,12 @@
main: main:
mov eax, 0
int 0x80
mov eax, 512 mov eax, 512
int 0x80 int 0x80
mov eax, 35000 mov eax, 35000
int 0x80 int 0x80
mov eax, 0 ; exit
mov ebx, 0 ; error code
int 0x80
ret ret