summaryrefslogtreecommitdiff
path: root/kernel/cpu
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-10-16 20:41:17 +0200
committerAnton Kling <anton@kling.gg>2024-10-16 20:41:17 +0200
commit4e817cecfa7328af34fb96db7f052352737cd07e (patch)
treee2470a6e3f9683ed83a1e4067dd0ab79a9b67be5 /kernel/cpu
parent6d4f0e917f638c0ab53d847037938d83497f53ea (diff)
kernel: Add RSOD(red screen of death)
This is not useful since 99% of the time I will have access to the serial output. But it does look cool.
Diffstat (limited to 'kernel/cpu')
-rw-r--r--kernel/cpu/idt.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/cpu/idt.c b/kernel/cpu/idt.c
index a7a93f6..474727f 100644
--- a/kernel/cpu/idt.c
+++ b/kernel/cpu/idt.c
@@ -1,6 +1,7 @@
#include <cpu/arch_inst.h>
#include <cpu/idt.h>
#include <interrupts.h>
+#include <log.h>
#include <sched/scheduler.h>
#include <stdio.h>
@@ -50,6 +51,14 @@ __attribute__((no_caller_saved_registers)) void EOI(u8 irq) {
}
void general_protection_fault(reg_t *regs) {
+ int is_userspace = (regs->error_code & (1 << 2));
+ if (is_userspace) {
+ signal_process(current_task, SIGSEGV);
+ return;
+ }
+
+ log_enable_screen();
+
klog(LOG_ERROR, "General Protetion Fault");
kprintf(" Error Code: %x\n", regs->error_code);
kprintf("Instruction Pointer: %x\n", regs->eip);
@@ -90,6 +99,8 @@ void page_fault(reg_t *regs) {
return;
}
+ log_enable_screen();
+
klog(LOG_ERROR, "Page Fault");
kprintf("CR2: %x\n", cr2);
if (current_task) {