Subversion Repositories HelenOS

Rev

Rev 2222 | Rev 3908 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2222 Rev 2441
Line 81... Line 81...
81
    if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
81
    if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
82
        panic("Unable to map physical memory %p (%d bytes)", physaddr, size)
82
        panic("Unable to map physical memory %p (%d bytes)", physaddr, size)
83
   
83
   
84
    uintptr_t virtaddr = PA2KA(last_frame);
84
    uintptr_t virtaddr = PA2KA(last_frame);
85
    pfn_t i;
85
    pfn_t i;
86
    for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++)
86
    for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) {
-
 
87
        uintptr_t addr = PFN2ADDR(i);
87
        page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE | PAGE_WRITE);
88
        page_mapping_insert(AS_KERNEL, virtaddr + addr, physaddr + addr, PAGE_NOT_CACHEABLE | PAGE_WRITE);
-
 
89
    }
88
   
90
   
89
    last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
91
    last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
90
   
92
   
91
    return virtaddr;
93
    return virtaddr;
92
}
94
}
93
 
95
 
94
void page_fault(int n, istate_t *istate)
96
void page_fault(int n __attribute__((unused)), istate_t *istate)
95
{
97
{
96
    uintptr_t page;
98
    uintptr_t page;
97
    pf_access_t access;
99
    pf_access_t access;
98
   
100
   
99
    page = read_cr2();
101
    page = read_cr2();
Line 108... Line 110...
108
   
110
   
109
    if (as_page_fault(page, access, istate) == AS_PF_FAULT) {
111
    if (as_page_fault(page, access, istate) == AS_PF_FAULT) {
110
        fault_if_from_uspace(istate, "Page fault: %#x", page);
112
        fault_if_from_uspace(istate, "Page fault: %#x", page);
111
       
113
       
112
        decode_istate(istate);
114
        decode_istate(istate);
113
        printf("page fault address: %#x\n", page);
115
        printf("page fault address: %#lx\n", page);
114
        panic("page fault\n");
116
        panic("page fault\n");
115
    }
117
    }
116
}
118
}
117
 
119
 
118
/** @}
120
/** @}