signals: handle SIGBUS, SIGSEGV, SIGILL etc

This commit is contained in:
Matheus
2024-05-29 11:06:15 -03:00
parent d689766a44
commit c81bdac897
4 changed files with 33 additions and 4 deletions
+18
View File
@@ -7,6 +7,21 @@
#define EFER_SYSCALLENABLE 1
void arch_syscall_entry();
static void illisr(isr_t *self, context_t *ctx) {
if (ARCH_CONTEXT_ISUSER(ctx)) {
signal_signalthread(_cpu()->thread, SIGILL, true);
} else {
_panic("Invalid Opcode", ctx);
}
}
static void div0isr(isr_t *self, context_t *ctx) {
if (ARCH_CONTEXT_ISUSER(ctx)) {
signal_signalthread(_cpu()->thread, SIGFPE, true);
} else {
_panic("Division by 0", ctx);
}
}
void cpu_initstate() {
arch_apic_initap();
@@ -49,4 +64,7 @@ void cpu_initstate() {
"mov %%rax, %%cr0;"
: : : "rax"
);
interrupt_register(0, div0isr, NULL, IPL_IGNORE);
interrupt_register(6, illisr, NULL, IPL_IGNORE);
}