/* * This file contains the page fault handler. * There is an early handler which just gives out memory when requested. This * is used by the kernel before it has initialised multi-tasking and the virtual * file system. */ #include #include #include #include /* Early (pre-VFS/tasking) page fault handler */ void early_page_fault_handler(struct InterruptFrame *frame, uint32_t err) { uintptr_t addr; asm volatile("mov %%cr2, %0" : "=r" (addr)); if (!PAGE_ADDR(addr)) panic("Null dereference @ %#.8x", frame->eip); /* Allocate a page */ set_page(addr, alloc_frame() | PTE_PRESENT | PTE_WRITE | PTE_GLOBAL); }