Changeset 91befde0 in mainline
- Timestamp:
- 2008-09-08T20:30:20Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c867756e
- Parents:
- bd83ccea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/mips32/src/mm/tlb.c
rbd83ccea r91befde0 48 48 #include <interrupt.h> 49 49 50 static void tlb_refill_fail(istate_t *istate); 51 static void tlb_invalid_fail(istate_t *istate); 52 static void tlb_modified_fail(istate_t *istate); 53 54 static pte_t *find_mapping_and_check(uintptr_t badvaddr, int access, istate_t *istate, int *pfrc); 55 56 /** Initialize TLB 57 * 58 * Initialize TLB. 50 static void tlb_refill_fail(istate_t *); 51 static void tlb_invalid_fail(istate_t *); 52 static void tlb_modified_fail(istate_t *); 53 54 static pte_t *find_mapping_and_check(uintptr_t, int, istate_t *, int *); 55 56 /** Initialize TLB. 57 * 59 58 * Invalidate all entries and mark wired entries. 60 59 */ … … 82 81 } 83 82 84 /** Process TLB Refill Exception 85 * 86 * Process TLB Refill Exception. 87 * 88 * @param istate Interrupted register context. 83 /** Process TLB Refill Exception. 84 * 85 * @param istate Interrupted register context. 89 86 */ 90 87 void tlb_refill(istate_t *istate) … … 129 126 130 127 tlb_prepare_entry_hi(&hi, asid, badvaddr); 131 tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, pte->pfn); 128 tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, 129 pte->pfn); 132 130 133 131 /* … … 135 133 */ 136 134 cp0_entry_hi_write(hi.value); 137 if ((badvaddr /PAGE_SIZE) % 2 == 0) {135 if ((badvaddr / PAGE_SIZE) % 2 == 0) { 138 136 cp0_entry_lo0_write(lo.value); 139 137 cp0_entry_lo1_write(0); … … 154 152 } 155 153 156 /** Process TLB Invalid Exception 157 * 158 * Process TLB Invalid Exception. 159 * 160 * @param istate Interrupted register context. 154 /** Process TLB Invalid Exception. 155 * 156 * @param istate Interrupted register context. 161 157 */ 162 158 void tlb_invalid(istate_t *istate) … … 218 214 pte->a = 1; 219 215 220 tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, pte->pfn); 216 tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, 217 pte->pfn); 221 218 222 219 /* 223 220 * The entry is to be updated in TLB. 224 221 */ 225 if ((badvaddr /PAGE_SIZE) % 2 == 0)222 if ((badvaddr / PAGE_SIZE) % 2 == 0) 226 223 cp0_entry_lo0_write(lo.value); 227 224 else … … 238 235 } 239 236 240 /** Process TLB Modified Exception 241 * 242 * Process TLB Modified Exception. 243 * 244 * @param istate Interrupted register context. 237 /** Process TLB Modified Exception. 238 * 239 * @param istate Interrupted register context. 245 240 */ 246 241 void tlb_modified(istate_t *istate) … … 309 304 pte->d = 1; 310 305 311 tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->w, pte->cacheable, pte->pfn); 306 tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->w, pte->cacheable, 307 pte->pfn); 312 308 313 309 /* 314 310 * The entry is to be updated in TLB. 315 311 */ 316 if ((badvaddr /PAGE_SIZE) % 2 == 0)312 if ((badvaddr / PAGE_SIZE) % 2 == 0) 317 313 cp0_entry_lo0_write(lo.value); 318 314 else … … 341 337 sym2 = s; 342 338 343 fault_if_from_uspace(istate, "TLB Refill Exception on %p", cp0_badvaddr_read()); 344 panic("%x: TLB Refill Exception at %x(%s<-%s)\n", cp0_badvaddr_read(), istate->epc, symbol, sym2); 339 fault_if_from_uspace(istate, "TLB Refill Exception on %p", 340 cp0_badvaddr_read()); 341 panic("%x: TLB Refill Exception at %x(%s<-%s)\n", cp0_badvaddr_read(), 342 istate->epc, symbol, sym2); 345 343 } 346 344 … … 353 351 if (s) 354 352 symbol = s; 355 fault_if_from_uspace(istate, "TLB Invalid Exception on %p", cp0_badvaddr_read()); 356 panic("%x: TLB Invalid Exception at %x(%s)\n", cp0_badvaddr_read(), istate->epc, symbol); 353 fault_if_from_uspace(istate, "TLB Invalid Exception on %p", 354 cp0_badvaddr_read()); 355 panic("%x: TLB Invalid Exception at %x(%s)\n", cp0_badvaddr_read(), 356 istate->epc, symbol); 357 357 } 358 358 … … 364 364 if (s) 365 365 symbol = s; 366 fault_if_from_uspace(istate, "TLB Modified Exception on %p", cp0_badvaddr_read()); 367 panic("%x: TLB Modified Exception at %x(%s)\n", cp0_badvaddr_read(), istate->epc, symbol); 368 } 369 370 /** Try to find PTE for faulting address 371 * 372 * Try to find PTE for faulting address. 366 fault_if_from_uspace(istate, "TLB Modified Exception on %p", 367 cp0_badvaddr_read()); 368 panic("%x: TLB Modified Exception at %x(%s)\n", cp0_badvaddr_read(), 369 istate->epc, symbol); 370 } 371 372 /** Try to find PTE for faulting address. 373 * 373 374 * The AS->lock must be held on entry to this function. 374 375 * 375 * @param badvaddr Faulting virtual address. 376 * @param access Access mode that caused the fault. 377 * @param istate Pointer to interrupted state. 378 * @param pfrc Pointer to variable where as_page_fault() return code will be stored. 379 * 380 * @return PTE on success, NULL otherwise. 381 */ 382 pte_t *find_mapping_and_check(uintptr_t badvaddr, int access, istate_t *istate, int *pfrc) 376 * @param badvaddr Faulting virtual address. 377 * @param access Access mode that caused the fault. 378 * @param istate Pointer to interrupted state. 379 * @param pfrc Pointer to variable where as_page_fault() return code 380 * will be stored. 381 * 382 * @return PTE on success, NULL otherwise. 383 */ 384 pte_t * 385 find_mapping_and_check(uintptr_t badvaddr, int access, istate_t *istate, 386 int *pfrc) 383 387 { 384 388 entry_hi_t hi; … … 442 446 } 443 447 444 void tlb_prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn) 448 void 449 tlb_prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, 450 uintptr_t pfn) 445 451 { 446 452 lo->value = 0; … … 481 487 482 488 printf("%-2u %-4u %#6x %#4x %1u %1u %1u %1u %#6x\n", 483 484 489 i, hi.asid, hi.vpn2, mask.mask, 490 lo0.g, lo0.v, lo0.d, lo0.c, lo0.pfn); 485 491 printf(" %1u %1u %1u %1u %#6x\n", 486 492 lo1.g, lo1.v, lo1.d, lo1.c, lo1.pfn); 487 493 } 488 494 … … 561 567 } 562 568 563 /** Invalidate TLB entries for specified page range belonging to specified address space. 564 * 565 * @param asid Address space identifier. 566 * @param page First page whose TLB entry is to be invalidated. 567 * @param cnt Number of entries to invalidate. 569 /** Invalidate TLB entries for specified page range belonging to specified 570 * address space. 571 * 572 * @param asid Address space identifier. 573 * @param page First page whose TLB entry is to be invalidated. 574 * @param cnt Number of entries to invalidate. 568 575 */ 569 576 void tlb_invalidate_pages(asid_t asid, uintptr_t page, count_t cnt) … … 589 596 590 597 if (!index.p) { 591 /* Entry was found, index register contains valid index. */ 598 /* 599 * Entry was found, index register contains valid 600 * index. 601 */ 592 602 tlbr(); 593 603
Note:
See TracChangeset
for help on using the changeset viewer.