kernel/src/interrupts/syscall.c

24 lines
610 B
C
Raw Normal View History

#include "main.h"
2017-11-05 09:50:04 +00:00
2022-06-23 10:51:42 +00:00
#include <kernaux/drivers/console.h>
2020-12-06 03:04:34 +00:00
2017-11-05 17:15:34 +00:00
static void syscall_do_exit(struct IsrRegisters regs);
void syscall_handler(const struct IsrRegisters regs)
2017-11-05 09:50:04 +00:00
{
2020-11-25 08:14:21 +00:00
const unsigned int id = regs.eax << 16 >> 16;
2022-06-23 10:51:42 +00:00
kernaux_drivers_console_printf("[INFO] syscall: number %u\n", id);
2017-11-05 09:50:04 +00:00
2017-11-05 17:15:34 +00:00
switch (id) {
2021-12-14 19:44:57 +00:00
case KERNEL_SYSCALL_EXIT: syscall_do_exit(regs); break;
2017-11-05 17:15:34 +00:00
}
2017-11-05 09:50:04 +00:00
}
2017-11-05 17:15:34 +00:00
void syscall_do_exit(const struct IsrRegisters regs)
{
2020-11-25 08:14:21 +00:00
const unsigned int exit_code = regs.ebx << 16 >> 16;
2022-06-23 10:51:42 +00:00
kernaux_drivers_console_printf("[WARN] syscall: process try to exit with error code %u, haha\n", exit_code);
2017-11-05 17:15:34 +00:00
}