Rev 2131 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2131 | Rev 2307 | ||
---|---|---|---|
Line 81... | Line 81... | ||
81 | 81 | ||
82 | void page_arch_init(void) |
82 | void page_arch_init(void) |
83 | { |
83 | { |
84 | uintptr_t cur; |
84 | uintptr_t cur; |
85 | int i; |
85 | int i; |
86 | int identity_flags = PAGE_CACHEABLE | PAGE_EXEC | PAGE_GLOBAL; |
86 | int identity_flags = PAGE_CACHEABLE | PAGE_EXEC | PAGE_GLOBAL | PAGE_WRITE; |
87 | 87 | ||
88 | if (config.cpu_active == 1) { |
88 | if (config.cpu_active == 1) { |
89 | page_mapping_operations = &pt_mapping_operations; |
89 | page_mapping_operations = &pt_mapping_operations; |
90 | 90 | ||
91 | /* |
91 | /* |
Line 110... | Line 110... | ||
110 | page_mapping_insert(AS_KERNEL, PA2KA_CODE(KA2PA(cur)), KA2PA(cur), identity_flags); |
110 | page_mapping_insert(AS_KERNEL, PA2KA_CODE(KA2PA(cur)), KA2PA(cur), identity_flags); |
111 | } |
111 | } |
112 | 112 | ||
113 | exc_register(14, "page_fault", (iroutine) page_fault); |
113 | exc_register(14, "page_fault", (iroutine) page_fault); |
114 | write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); |
114 | write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); |
115 | } |
- | |
116 | else { |
115 | } else |
117 | write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); |
116 | write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); |
118 | } |
- | |
119 | } |
117 | } |
120 | 118 | ||
121 | 119 | ||
122 | /** Identity page mapper |
120 | /** Identity page mapper |
123 | * |
121 | * |
Line 206... | Line 204... | ||
206 | panic("Unable to map physical memory %p (%d bytes)", physaddr, size) |
204 | panic("Unable to map physical memory %p (%d bytes)", physaddr, size) |
207 | 205 | ||
208 | uintptr_t virtaddr = PA2KA(last_frame); |
206 | uintptr_t virtaddr = PA2KA(last_frame); |
209 | pfn_t i; |
207 | pfn_t i; |
210 | for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) |
208 | for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) |
211 | page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE); |
209 | page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE | PAGE_WRITE); |
212 | 210 | ||
213 | last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); |
211 | last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); |
214 | 212 | ||
215 | return virtaddr; |
213 | return virtaddr; |
216 | } |
214 | } |