aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/core
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-13 19:23:28 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-13 19:23:28 +0100
commite484c92ff08e54e7cbfdb815a5b254507dade003 (patch)
tree21f843225c5b2ba7a2e794ed16a1aa06afe9ecd3 /src/kernel/core
parent0ea68568372b7b7b20bca6985ae4b36e8c99c0e9 (diff)
downloadkogata-e484c92ff08e54e7cbfdb815a5b254507dade003.tar.gz
kogata-e484c92ff08e54e7cbfdb815a5b254507dade003.zip
Implement some handling of user stuff...
Diffstat (limited to 'src/kernel/core')
-rw-r--r--src/kernel/core/idt.c13
-rw-r--r--src/kernel/core/paging.c4
-rw-r--r--src/kernel/core/thread.c2
3 files changed, 12 insertions, 7 deletions
diff --git a/src/kernel/core/idt.c b/src/kernel/core/idt.c
index cb02bf9..e1862c9 100644
--- a/src/kernel/core/idt.c
+++ b/src/kernel/core/idt.c
@@ -3,6 +3,7 @@
#include <sys.h>
#include <string.h>
#include <dbglog.h>
+#include <thread.h>
struct idt_entry {
uint16_t base_lo; //Low part of address to jump to
@@ -92,10 +93,14 @@ void idt_exHandler(registers_t *regs) {
if (ex_handlers[regs->int_no] != 0) {
ex_handlers[regs->int_no](regs);
} else {
- //TODO: make sure all exceptions happenning in userspace do not cause kernel panic...
- dbg_printf("Unhandled exception: %i\n", regs->int_no);
- dbg_dump_registers(regs);
- PANIC("Unhandled exception");
+ if (regs->eip >= K_HIGHHALF_ADDR) {
+ dbg_printf("Unhandled exception in kernel code: %i\n", regs->int_no);
+ dbg_dump_registers(regs);
+ PANIC("Unhandled exception");
+ } else {
+ ASSERT(current_thread != 0 && current_thread->user_ex_handler != 0);
+ current_thread->user_ex_handler(regs);
+ }
}
}
diff --git a/src/kernel/core/paging.c b/src/kernel/core/paging.c
index e39a872..74331c0 100644
--- a/src/kernel/core/paging.c
+++ b/src/kernel/core/paging.c
@@ -65,8 +65,8 @@ void page_fault_handler(registers_t *regs) {
// remark : sti should always be executed, it is stupid to run user code with interrupts disabled
if ((size_t)vaddr >= K_HIGHHALF_ADDR) {
- ASSERT(current_thread->kmem_violation_handler != 0);
- current_thread->kmem_violation_handler(regs);
+ ASSERT(current_thread->user_ex_handler != 0);
+ current_thread->user_ex_handler(regs);
} else {
ASSERT(pd->user_pfh != 0);
pd->user_pfh(pd->user_pfh_data, regs, vaddr);
diff --git a/src/kernel/core/thread.c b/src/kernel/core/thread.c
index 519ba41..4ca3f63 100644
--- a/src/kernel/core/thread.c
+++ b/src/kernel/core/thread.c
@@ -148,7 +148,7 @@ thread_t *new_thread(entry_t entry, void* data) {
// used by user processes
t->proc = 0;
- t->kmem_violation_handler = 0;
+ t->user_ex_handler = 0;
return t;
}