61,7 → 61,7 |
* PA2KA(identity) mapping for all frames until last_frame. |
*/ |
for (cur = 0; cur < last_frame; cur += FRAME_SIZE) { |
flags = PAGE_CACHEABLE; |
flags = PAGE_CACHEABLE | PAGE_WRITE; |
if ((PA2KA(cur) >= config.base) && (PA2KA(cur) < config.base + config.kernel_size)) |
flags |= PAGE_GLOBAL; |
page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); |
69,10 → 69,8 |
|
exc_register(14, "page_fault", (iroutine) page_fault); |
write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); |
} |
else { |
} else |
write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); |
} |
|
paging_on(); |
} |
86,7 → 84,7 |
uintptr_t virtaddr = PA2KA(last_frame); |
pfn_t i; |
for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) |
page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE); |
page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE | PAGE_WRITE); |
|
last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); |
|
95,12 → 93,12 |
|
void page_fault(int n, istate_t *istate) |
{ |
uintptr_t page; |
uintptr_t page; |
pf_access_t access; |
|
page = read_cr2(); |
page = read_cr2(); |
|
if (istate->error_word & PFERR_CODE_RSVD) |
if (istate->error_word & PFERR_CODE_RSVD) |
panic("Reserved bit set in page directory.\n"); |
|
if (istate->error_word & PFERR_CODE_RW) |
107,14 → 105,14 |
access = PF_ACCESS_WRITE; |
else |
access = PF_ACCESS_READ; |
|
if (as_page_fault(page, access, istate) == AS_PF_FAULT) { |
|
if (as_page_fault(page, access, istate) == AS_PF_FAULT) { |
fault_if_from_uspace(istate, "Page fault: %#x", page); |
|
decode_istate(istate); |
printf("page fault address: %#x\n", page); |
panic("page fault\n"); |
} |
|
decode_istate(istate); |
printf("page fault address: %#x\n", page); |
panic("page fault\n"); |
} |
} |
|
/** @} |