aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/interrupts
diff options
context:
space:
mode:
authorMarvin Borner2020-04-28 20:59:57 +0200
committerMarvin Borner2020-04-28 20:59:57 +0200
commit5f8b5ce7efb7738eaebad43f9648975788ae19ff (patch)
treeab8fc4d4baa4adb99dc90461df689650acf34cef /src/kernel/interrupts
parentbfe16de4be67565f1a1e7b1331fcbe3aedf9c54e (diff)
Fixed userspace entering...
Many other fixes too, but I won't mention them because I don't want to :)
Diffstat (limited to 'src/kernel/interrupts')
-rw-r--r--src/kernel/interrupts/isr.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/kernel/interrupts/isr.c b/src/kernel/interrupts/isr.c
index 2837239..9d92529 100644
--- a/src/kernel/interrupts/isr.c
+++ b/src/kernel/interrupts/isr.c
@@ -3,7 +3,10 @@
#include <kernel/system.h>
#include <kernel/lib/string.h>
#include <kernel/lib/stdio.h>
+#include <kernel/lib/lib.h>
#include <kernel/graphics/vesa.h>
+#include <kernel/tasks/process.h>
+#include <kernel/io/io.h>
// Install ISRs in IDT
void isrs_install()
@@ -107,6 +110,7 @@ void fault_handler(struct regs *r)
if (handler) {
handler(r);
} else {
+ cli();
uint32_t faulting_address;
asm("mov %%cr2, %0" : "=r"(faulting_address));
@@ -114,17 +118,22 @@ void fault_handler(struct regs *r)
r->eip, r->eax, r->ebx, r->ecx, r->edx, r->esp, faulting_address, r->eflags,
r->err_code, r->int_no, exception_messages[r->int_no]);
+ char *message;
if (r->int_no <= 32) {
- char *message = (char *)exception_messages[r->int_no];
+ message = (char *)exception_messages[r->int_no];
strcat(message, " Exception");
+ } else {
+ message = "Unknown Exception";
+ }
- // Show message if there wasn't an error in video memory
- if (faulting_address != (uint32_t)fb || fb == 0)
- panic(message);
- else
- halt_loop();
+ if (current_proc != NULL) {
+ memcpy(&current_proc->registers, r, sizeof(struct regs));
+ process_suspend(current_proc->pid);
+ warn("%s: Halting process %d", message, current_proc->pid);
+ scheduler(r);
+ sti();
} else {
- panic("Unknown Exception");
+ panic("Page fault before multitasking started!");
}
}
} \ No newline at end of file