From 465bb105e67a64957761e2d31a1afe982e895e61 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Fri, 6 Sep 2019 17:48:54 +0900 Subject: [PATCH] Add stub code to handle POSIX interrupts in _sys_handle() --- kernel/arch/interrupt.c | 42 ++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/kernel/arch/interrupt.c b/kernel/arch/interrupt.c index 05023fd..ecd0402 100644 --- a/kernel/arch/interrupt.c +++ b/kernel/arch/interrupt.c @@ -1,6 +1,6 @@ /* * This file is part of the Corax operating system. - * Copyright (C) 2016 Matthias Kruk + * Copyright (C) 2016-2019 Matthias Kruk * * Corax is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ #include #include +#include #include #include "cpu.h" #include "defs.h" @@ -65,17 +66,18 @@ int _int_handle(stack_frame_t ctx) extern struct cpu _cpu[CONFIG_SMP_CPUS]; dbg_printf("Keyboard interrupt\n"); + #if 0 - /* hacky reboot: clear IDT entries for - * #DF and #GP, then cause a #GP */ - _cpu[CPU_ID].cpu_idt[EXC_DOUBLEFAULT].sd_low = 0; - _cpu[CPU_ID].cpu_idt[EXC_DOUBLEFAULT].sd_high = 0; - _cpu[CPU_ID].cpu_idt[EXC_PROTECTION].sd_low = 0; - _cpu[CPU_ID].cpu_idt[EXC_PROTECTION].sd_high = 0; - - /* this is such a retarded thing to do, I don't see how this - * could not cause a triple fault */ - asm volatile("ljmp $0x30, $0xfee00020"); /* LEEROY JENKINS!!! */ + /* hacky reboot: clear IDT entries for + * #DF and #GP, then cause a #GP */ + _cpu[CPU_ID].cpu_idt[EXC_DOUBLEFAULT].sd_low = 0; + _cpu[CPU_ID].cpu_idt[EXC_DOUBLEFAULT].sd_high = 0; + _cpu[CPU_ID].cpu_idt[EXC_PROTECTION].sd_low = 0; + _cpu[CPU_ID].cpu_idt[EXC_PROTECTION].sd_high = 0; + + /* this is such a retarded thing to do, I don't see how this + * could not cause a triple fault */ + asm volatile("ljmp $0x30, $0xfee00020"); /* LEEROY JENKINS!!! */ #endif } else if(ctx.intn != INT_TIMER) { dbg_printf("Interrupt %u occurred\n", ctx.intn); @@ -110,11 +112,21 @@ int _exc_handle(stack_frame_t ctx) } int _sys_handle(stack_frame_t ctx) { -/* dbg_printf("Syscall 0x%X occurred.\n", ctx.intn); */ -/* dbg_printf("CS = 0x%02x; EIP = 0x%08x; EFLAGS = 0x%08x\n", ctx.cs, ctx.eip, ctx.eflags); */ -/* PANIC("Unhandled syscall"); */ + switch(ctx.intn) { + case SYS_VECTOR_CORAX: + dbg_printf("_corax_call(0x%x, 0x%x, 0x%x);\n", ctx.eax, ctx.ebx, ctx.ecx); + break; + +#if FEATURE(POSIX) + case SYS_VECTOR_POSIX: + dbg_printf("_posix_call(0x%x, 0x%x, 0x%x);\n", ctx.eax, ctx.ebx, ctx.ecx); + break; +#endif /* FEATURE(POSIX) */ - dbg_printf("_corax_call(0x%x, 0x%x, 0x%x);\n", ctx.eax, ctx.ebx, ctx.ecx); + default: + dbg_printf("Unhandled syscall (vec=%u)\n", ctx.intn); + break; + } return(0); } -- 2.47.3