Changes in kernel/genarch/src/mm/page_pt.c [de73242:f18d01b6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/mm/page_pt.c
rde73242 rf18d01b6 82 82 83 83 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) { 84 pte_t *newpt = (pte_t *) frame_alloc(PTL1_SIZE,85 FRAME_LOWMEM | FRAME_KA);86 memsetb(newpt, FRAME_SIZE <<PTL1_SIZE, 0);84 pte_t *newpt = (pte_t *) 85 PA2KA(frame_alloc(PTL1_FRAMES, FRAME_LOWMEM, PTL1_SIZE - 1)); 86 memsetb(newpt, PTL1_SIZE, 0); 87 87 SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt)); 88 88 SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), … … 101 101 102 102 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) { 103 pte_t *newpt = (pte_t *) frame_alloc(PTL2_SIZE,104 FRAME_LOWMEM | FRAME_KA);105 memsetb(newpt, FRAME_SIZE <<PTL2_SIZE, 0);103 pte_t *newpt = (pte_t *) 104 PA2KA(frame_alloc(PTL2_FRAMES, FRAME_LOWMEM, PTL2_SIZE - 1)); 105 memsetb(newpt, PTL2_SIZE, 0); 106 106 SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt)); 107 107 SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), … … 112 112 */ 113 113 write_barrier(); 114 SET_PTL2_PRESENT(ptl1, PTL1_INDEX(page)); 114 SET_PTL2_PRESENT(ptl1, PTL1_INDEX(page)); 115 115 } 116 116 … … 118 118 119 119 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) { 120 pte_t *newpt = (pte_t *) frame_alloc(PTL3_SIZE,121 FRAME_LOWMEM | FRAME_KA);122 memsetb(newpt, FRAME_SIZE << PTL3_SIZE, 0);120 pte_t *newpt = (pte_t *) 121 PA2KA(frame_alloc(PTL3_FRAMES, FRAME_LOWMEM, PTL2_SIZE - 1)); 122 memsetb(newpt, PTL2_SIZE, 0); 123 123 SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt)); 124 124 SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), … … 180 180 * Destroy the mapping. 181 181 * Setting to PAGE_NOT_PRESENT is not sufficient. 182 */ 182 * But we need SET_FRAME for possible PT coherence maintenance. 183 * At least on ARM. 184 */ 185 //TODO: Fix this inconsistency 186 SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), PAGE_NOT_PRESENT); 183 187 memsetb(&ptl3[PTL3_INDEX(page)], sizeof(pte_t), 0); 184 188 … … 215 219 memsetb(&ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); 216 220 #endif 217 frame_free(KA2PA((uintptr_t) ptl3) );221 frame_free(KA2PA((uintptr_t) ptl3), PTL3_FRAMES); 218 222 } else { 219 223 /* … … 249 253 memsetb(&ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); 250 254 #endif 251 frame_free(KA2PA((uintptr_t) ptl2) );255 frame_free(KA2PA((uintptr_t) ptl2), PTL2_FRAMES); 252 256 } else { 253 257 /* … … 280 284 281 285 memsetb(&ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); 282 frame_free(KA2PA((uintptr_t) ptl1) );286 frame_free(KA2PA((uintptr_t) ptl1), PTL1_FRAMES); 283 287 } 284 288 #endif /* PTL1_ENTRIES != 0 */ … … 359 363 * @param size Size in bytes defining the range of PTL0 entries that will be 360 364 * altered by this function. 365 * 361 366 */ 362 367 void pt_mapping_make_global(uintptr_t base, size_t size) 363 368 { 369 ASSERT(size > 0); 370 364 371 uintptr_t ptl0 = PA2KA((uintptr_t) AS_KERNEL->genarch.page_table); 365 372 uintptr_t ptl0_step = ptl0_step_get(); 366 size_t order; 367 uintptr_t addr; 368 373 size_t frames; 374 369 375 #if (PTL1_ENTRIES != 0) 370 order = PTL1_SIZE;376 frames = PTL1_FRAMES; 371 377 #elif (PTL2_ENTRIES != 0) 372 order = PTL2_SIZE;378 frames = PTL2_FRAMES; 373 379 #else 374 order = PTL3_SIZE; 375 #endif 376 377 ASSERT(size > 0); 378 379 for (addr = ALIGN_DOWN(base, ptl0_step); addr - 1 < base + size - 1; 380 frames = PTL3_FRAMES; 381 #endif 382 383 for (uintptr_t addr = ALIGN_DOWN(base, ptl0_step); 384 addr - 1 < base + size - 1; 380 385 addr += ptl0_step) { 381 uintptr_t l1; 382 383 l1 = (uintptr_t) frame_alloc(order, FRAME_KA | FRAME_LOWMEM); 384 memsetb((void *) l1, FRAME_SIZE << order, 0); 386 uintptr_t l1 = PA2KA(frame_alloc(frames, FRAME_LOWMEM, 0)); 387 memsetb((void *) l1, FRAMES2SIZE(frames), 0); 385 388 SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(addr), KA2PA(l1)); 386 389 SET_PTL1_FLAGS(ptl0, PTL0_INDEX(addr),
Note:
See TracChangeset
for help on using the changeset viewer.