diff options
author | Marvin Borner | 2020-04-28 18:32:36 +0200 |
---|---|---|
committer | Marvin Borner | 2020-04-28 18:32:36 +0200 |
commit | 4b8518b4e791c68154ec52badcc921b62afafb49 (patch) | |
tree | 9c855266cf7451f503bf3cb849e63ac72ae48e74 /src/kernel/memory | |
parent | 46007d2598b7aef13895b21669cfb6f24272e5fe (diff) |
Maaaany fixes...
Sorry for the increasingly worse-getting commit messages :D
Diffstat (limited to 'src/kernel/memory')
-rw-r--r-- | src/kernel/memory/paging.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/kernel/memory/paging.c b/src/kernel/memory/paging.c index 4192ba3..0789c2a 100644 --- a/src/kernel/memory/paging.c +++ b/src/kernel/memory/paging.c @@ -5,6 +5,8 @@ #include <kernel/lib/lib.h> #include <kernel/io/io.h> #include <kernel/acpi/acpi.h> +#include <kernel/tasks/process.h> +#include <kernel/interrupts/interrupts.h> struct page_directory *paging_current_directory = NULL; struct page_directory *paging_root_directory = NULL; @@ -100,6 +102,21 @@ void paging_map_user(struct page_directory *dir, uint32_t phys, uint32_t virt) } } +void page_fault(struct regs *regs) +{ + cli(); + if (current_proc != NULL) { + memcpy(¤t_proc->registers, regs, sizeof(struct regs)); + process_suspend(current_proc->pid); + warn("Segfault, halting process %d", current_proc->pid); + scheduler(regs); + } else { + warn("Page fault before multitasking started!"); + // fault_handler(regs); + halt_loop(); + } +} + void paging_install() { kheap_init(); @@ -107,8 +124,11 @@ void paging_install() paging_current_directory = paging_make_directory(); paging_root_directory = paging_current_directory; + isr_install_handler(14, page_fault); for (uint32_t i = 0; i < 0xF0000000; i += PAGE_S) paging_map(paging_root_directory, i, i); + paging_switch_directory(paging_root_directory); + info("Installed paging"); } void paging_convert_page(struct page_directory *kdir) |