diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2014-12-02 20:12:42 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2014-12-02 20:12:42 +0100 |
commit | 6a56675851c16a0cefcf5a2d10a1227c37e9d886 (patch) | |
tree | aebd4784159999993e3ae9f1e7c15961f267cad6 /kernel/l0/paging.c | |
parent | 456fc99e8feac598f7c6f1a3aaa82bf994404e39 (diff) | |
download | macroscope-6a56675851c16a0cefcf5a2d10a1227c37e9d886.tar.gz macroscope-6a56675851c16a0cefcf5a2d10a1227c37e9d886.zip |
Implement kernel memory region allocator.
Diffstat (limited to 'kernel/l0/paging.c')
-rw-r--r-- | kernel/l0/paging.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/kernel/l0/paging.c b/kernel/l0/paging.c index 9e9df6b..f076aa1 100644 --- a/kernel/l0/paging.c +++ b/kernel/l0/paging.c @@ -1,5 +1,7 @@ #include <paging.h> #include <frame.h> +#include <idt.h> +#include <dbglog.h> typedef union page { struct { @@ -38,6 +40,14 @@ static pagedir_t kernel_pd; static pagedir_t *current_pd; +void page_fault_handler(registers_t *regs) { + size_t addr; + asm volatile("movl %%cr2, %0":"=r"(addr)); + dbg_printf("Page fault at 0x%p\n", addr); + PANIC("PAGE FAULT"); + // not handled yet +} + void paging_setup(void* kernel_data_end) { size_t n_kernel_pages = PAGE_ALIGN_UP((size_t)kernel_data_end - K_HIGHHALF_ADDR)/PAGE_SIZE; @@ -76,7 +86,7 @@ void paging_setup(void* kernel_data_end) { cr4 &= ~0x00000010; asm volatile("movl %0, %%cr4":: "r"(cr4)); - // TODO : setup page fault handler + idt_set_ex_handler(EX_PAGE_FAULT, page_fault_handler); } pagedir_t *get_current_pagedir() { |