Subversion Repositories HelenOS

Rev

Rev 3386 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3386 Rev 4153
Line 77... Line 77...
77
 
77
 
78
 
78
 
79
uintptr_t hw_map(uintptr_t physaddr, size_t size)
79
uintptr_t hw_map(uintptr_t physaddr, size_t size)
80
{
80
{
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
        uintptr_t addr = PFN2ADDR(i);
Line 99... Line 99...
99
    pf_access_t access;
99
    pf_access_t access;
100
   
100
   
101
    page = read_cr2();
101
    page = read_cr2();
102
       
102
       
103
    if (istate->error_word & PFERR_CODE_RSVD)
103
    if (istate->error_word & PFERR_CODE_RSVD)
104
        panic("Reserved bit set in page directory.\n");
104
        panic("Reserved bit set in page directory.");
105
 
105
   
106
    if (istate->error_word & PFERR_CODE_RW)
106
    if (istate->error_word & PFERR_CODE_RW)
107
        access = PF_ACCESS_WRITE;
107
        access = PF_ACCESS_WRITE;
108
    else
108
    else
109
        access = PF_ACCESS_READ;
109
        access = PF_ACCESS_READ;
110
   
110
   
111
    if (as_page_fault(page, access, istate) == AS_PF_FAULT) {
111
    if (as_page_fault(page, access, istate) == AS_PF_FAULT) {
112
        fault_if_from_uspace(istate, "Page fault: %#x", page);
112
        fault_if_from_uspace(istate, "Page fault: %#x.", page);
113
       
113
       
114
        decode_istate(istate);
114
        decode_istate(istate);
115
        printf("page fault address: %#lx\n", page);
115
        printf("page fault address: %#lx\n", page);
116
        panic("page fault\n");
116
        panic("Page fault.");
117
    }
117
    }
118
}
118
}
119
 
119
 
120
/** @}
120
/** @}
121
 */
121
 */