Subversion Repositories HelenOS

Rev

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

Rev 2106 Rev 2222
Line 59... Line 59...
59
   
59
   
60
        /*
60
        /*
61
         * PA2KA(identity) mapping for all frames until last_frame.
61
         * PA2KA(identity) mapping for all frames until last_frame.
62
         */
62
         */
63
        for (cur = 0; cur < last_frame; cur += FRAME_SIZE) {
63
        for (cur = 0; cur < last_frame; cur += FRAME_SIZE) {
64
            flags = PAGE_CACHEABLE;
64
            flags = PAGE_CACHEABLE | PAGE_WRITE;
65
            if ((PA2KA(cur) >= config.base) && (PA2KA(cur) < config.base + config.kernel_size))
65
            if ((PA2KA(cur) >= config.base) && (PA2KA(cur) < config.base + config.kernel_size))
66
                flags |= PAGE_GLOBAL;
66
                flags |= PAGE_GLOBAL;
67
            page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags);
67
            page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags);
68
        }
68
        }
69
 
69
 
70
        exc_register(14, "page_fault", (iroutine) page_fault);
70
        exc_register(14, "page_fault", (iroutine) page_fault);
71
        write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
71
        write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
72
    }
-
 
73
    else {
72
    } else
74
        write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
73
        write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
75
    }
-
 
76
 
74
 
77
    paging_on();
75
    paging_on();
78
}
76
}
79
 
77
 
80
 
78
 
Line 84... Line 82...
84
        panic("Unable to map physical memory %p (%d bytes)", physaddr, size)
82
        panic("Unable to map physical memory %p (%d bytes)", physaddr, size)
85
   
83
   
86
    uintptr_t virtaddr = PA2KA(last_frame);
84
    uintptr_t virtaddr = PA2KA(last_frame);
87
    pfn_t i;
85
    pfn_t i;
88
    for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++)
86
    for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++)
89
        page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE);
87
        page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE | PAGE_WRITE);
90
   
88
   
91
    last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
89
    last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
92
   
90
   
93
    return virtaddr;
91
    return virtaddr;
94
}
92
}