Changeset 5d67baa in mainline for kernel/arch/ppc32
- Timestamp:
- 2008-06-30T20:33:18Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 939e9c1
- Parents:
- ac0e791
- Location:
- kernel/arch/ppc32/src/mm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ppc32/src/mm/page.c
rac0e791 r5d67baa 48 48 uintptr_t hw_map(uintptr_t physaddr, size_t size) 49 49 { 50 if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) 51 panic("Unable to map physical memory %p (%" PRIs " bytes)", physaddr, size) 50 if (last_frame + ALIGN_UP(size, PAGE_SIZE) > 51 KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) 52 panic("Unable to map physical memory %p (%" PRIs " bytes)", 53 physaddr, size) 52 54 53 55 uintptr_t virtaddr = PA2KA(last_frame); 54 56 pfn_t i; 55 57 for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) 56 page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE | PAGE_WRITE); 58 page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), 59 physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE | PAGE_WRITE); 57 60 58 61 last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); -
kernel/arch/ppc32/src/mm/tlb.c
rac0e791 r5d67baa 48 48 * if lock is true. 49 49 * 50 * @param as Address space. 51 * @param lock Lock/unlock the address space. 52 * @param badvaddr Faulting virtual address. 53 * @param access Access mode that caused the fault. 54 * @param istate Pointer to interrupted state. 55 * @param pfrc Pointer to variable where as_page_fault() return code will be stored. 56 * @return PTE on success, NULL otherwise. 57 * 58 */ 59 static pte_t *find_mapping_and_check(as_t *as, bool lock, uintptr_t badvaddr, int access, istate_t *istate, int *pfrc) 50 * @param as Address space. 51 * @param lock Lock/unlock the address space. 52 * @param badvaddr Faulting virtual address. 53 * @param access Access mode that caused the fault. 54 * @param istate Pointer to interrupted state. 55 * @param pfrc Pointer to variable where as_page_fault() return code 56 * will be stored. 57 * @return PTE on success, NULL otherwise. 58 * 59 */ 60 static pte_t * 61 find_mapping_and_check(as_t *as, bool lock, uintptr_t badvaddr, int access, 62 istate_t *istate, int *pfrc) 60 63 { 61 64 /* … … 78 81 page_table_unlock(as, lock); 79 82 switch (rc = as_page_fault(badvaddr, access, istate)) { 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 83 case AS_PF_OK: 84 /* 85 * The higher-level page fault handler succeeded, 86 * The mapping ought to be in place. 87 */ 88 page_table_lock(as, lock); 89 pte = page_mapping_find(as, badvaddr); 90 ASSERT((pte) && (pte->p)); 91 *pfrc = 0; 92 return pte; 93 case AS_PF_DEFER: 94 page_table_lock(as, lock); 95 *pfrc = rc; 96 return NULL; 97 case AS_PF_FAULT: 98 page_table_lock(as, lock); 99 printf("Page fault.\n"); 100 *pfrc = rc; 101 return NULL; 102 default: 103 panic("unexpected rc (%d)\n", rc); 101 104 } 102 105 } … … 115 118 if (s) 116 119 sym2 = s; 117 panic("%p: PHT Refill Exception at %p (%s<-%s)\n", badvaddr, istate->pc, symbol, sym2); 120 panic("%p: PHT Refill Exception at %p (%s<-%s)\n", badvaddr, 121 istate->pc, symbol, sym2); 118 122 } 119 123 … … 148 152 PTE in PTEG */ 149 153 for (i = 0; i < 8; i++) { 150 if ((!phte[base + i].v) || ((phte[base + i].vsid == vsid) && (phte[base + i].api == api))) { 154 if ((!phte[base + i].v) || ((phte[base + i].vsid == vsid) && 155 (phte[base + i].api == api))) { 151 156 found = true; 152 157 break; … … 161 166 PTE in PTEG */ 162 167 for (i = 0; i < 8; i++) { 163 if ((!phte[base2 + i].v) || ((phte[base2 + i].vsid == vsid) && (phte[base2 + i].api == api))) { 168 if ((!phte[base2 + i].v) || 169 ((phte[base2 + i].vsid == vsid) && 170 (phte[base2 + i].api == api))) { 164 171 found = true; 165 172 base = base2; … … 215 222 PTE in PTEG */ 216 223 for (i = 0; i < 8; i++) { 217 if ((!phte_physical[base + i].v) || ((phte_physical[base + i].vsid == vsid) && (phte_physical[base + i].api == api))) { 224 if ((!phte_physical[base + i].v) || 225 ((phte_physical[base + i].vsid == vsid) && 226 (phte_physical[base + i].api == api))) { 218 227 found = true; 219 228 break; … … 228 237 PTE in PTEG */ 229 238 for (i = 0; i < 8; i++) { 230 if ((!phte_physical[base2 + i].v) || ((phte_physical[base2 + i].vsid == vsid) && (phte_physical[base2 + i].api == api))) { 239 if ((!phte_physical[base2 + i].v) || 240 ((phte_physical[base2 + i].vsid == vsid) && 241 (phte_physical[base2 + i].api == api))) { 231 242 found = true; 232 243 base = base2; … … 255 266 /** Process Instruction/Data Storage Interrupt 256 267 * 257 * @param n 258 * @param istate 268 * @param n Interrupt vector number. 269 * @param istate Interrupted register context. 259 270 * 260 271 */ … … 285 296 page_table_lock(as, lock); 286 297 287 pte = find_mapping_and_check(as, lock, badvaddr, PF_ACCESS_READ /* FIXME */, istate, &pfrc); 298 pte = find_mapping_and_check(as, lock, badvaddr, 299 PF_ACCESS_READ /* FIXME */, istate, &pfrc); 288 300 if (!pte) { 289 301 switch (pfrc) { 290 291 292 293 294 295 296 297 298 299 300 301 302 case AS_PF_FAULT: 303 goto fail; 304 break; 305 case AS_PF_DEFER: 306 /* 307 * The page fault came during copy_from_uspace() 308 * or copy_to_uspace(). 309 */ 310 page_table_unlock(as, lock); 311 return; 312 default: 313 panic("Unexpected pfrc (%d)\n", pfrc); 302 314 } 303 315 } … … 317 329 /** Process Instruction/Data Storage Interrupt in Real Mode 318 330 * 319 * @param n 320 * @param istate 331 * @param n Interrupt vector number. 332 * @param istate Interrupted register context. 321 333 * 322 334 */ … … 374 386 uint32_t i; 375 387 for (i = 0; i < 8192; i++) { 376 if ((phte[i].v) && (phte[i].vsid >= (asid << 4)) && (phte[i].vsid < ((asid << 4) + 16))) 388 if ((phte[i].v) && (phte[i].vsid >= (asid << 4)) && 389 (phte[i].vsid < ((asid << 4) + 16))) 377 390 phte[i].v = 0; 378 391 } … … 408 421 } else \ 409 422 length = 0; \ 410 printf(name ": page=%.*p frame=%.*p length=%d KB (mask=%#x)%s%s\n", sizeof(upper) * 2, upper & 0xffff0000, sizeof(lower) * 2, lower & 0xffff0000, length, mask, ((upper >> 1) & 1) ? " supervisor" : "", (upper & 1) ? " user" : ""); 423 printf(name ": page=%.*p frame=%.*p length=%d KB (mask=%#x)%s%s\n", \ 424 sizeof(upper) * 2, upper & 0xffff0000, sizeof(lower) * 2, \ 425 lower & 0xffff0000, length, mask, \ 426 ((upper >> 1) & 1) ? " supervisor" : "", \ 427 (upper & 1) ? " user" : ""); 411 428 412 429 … … 422 439 : "r" (sr << 28) 423 440 ); 424 printf("vsid[%d]: VSID=%.*p (ASID=%d)%s%s\n", sr, sizeof(vsid) * 2, vsid & 0xffffff, (vsid & 0xffffff) >> 4, ((vsid >> 30) & 1) ? " supervisor" : "", ((vsid >> 29) & 1) ? " user" : ""); 441 printf("vsid[%d]: VSID=%.*p (ASID=%d)%s%s\n", sr, 442 sizeof(vsid) * 2, vsid & 0xffffff, (vsid & 0xffffff) >> 4, 443 ((vsid >> 30) & 1) ? " supervisor" : "", 444 ((vsid >> 29) & 1) ? " user" : ""); 425 445 } 426 446
Note:
See TracChangeset
for help on using the changeset viewer.