Changes in kernel/arch/mips32/src/mm/tlb.c [59fb782:346b12a2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/mips32/src/mm/tlb.c
r59fb782 r346b12a2 43 43 #include <synch/mutex.h> 44 44 #include <print.h> 45 #include <log.h> 45 46 #include <debug.h> 46 47 #include <align.h> … … 48 49 #include <symtab.h> 49 50 50 #define PFN_SHIFT 12 51 #define VPN_SHIFT 12 52 #define ADDR2VPN(a) ((a) >> VPN_SHIFT) 53 #define ADDR2VPN2(a) (ADDR2VPN((a)) >> 1) 54 #define VPN2ADDR(vpn) ((vpn) << VPN_SHIFT) 55 #define VPN22ADDR(vpn2) (VPN2ADDR(vpn2) << 1) 56 #define PFN2ADDR(pfn) ((pfn) << PFN_SHIFT) 57 58 #define BANK_SELECT_BIT(a) (((a) >> PAGE_WIDTH) & 1) 59 51 #define PFN_SHIFT 12 52 #define VPN_SHIFT 12 53 54 #define ADDR2HI_VPN(a) ((a) >> VPN_SHIFT) 55 #define ADDR2HI_VPN2(a) (ADDR2HI_VPN((a)) >> 1) 56 57 #define HI_VPN2ADDR(vpn) ((vpn) << VPN_SHIFT) 58 #define HI_VPN22ADDR(vpn2) (HI_VPN2ADDR(vpn2) << 1) 59 60 #define LO_PFN2ADDR(pfn) ((pfn) << PFN_SHIFT) 61 62 #define BANK_SELECT_BIT(a) (((a) >> PAGE_WIDTH) & 1) 60 63 61 64 /** Initialize TLB. … … 94 97 entry_lo_t lo; 95 98 uintptr_t badvaddr; 96 pte_t *pte;99 pte_t pte; 97 100 98 101 badvaddr = cp0_badvaddr_read(); 99 102 100 pte = page_mapping_find(AS, badvaddr, true);101 if ( pte && pte->p) {103 bool found = page_mapping_find(AS, badvaddr, true, &pte); 104 if (found && pte.p) { 102 105 /* 103 106 * Record access to PTE. 104 107 */ 105 pte->a = 1; 106 107 tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, 108 pte->cacheable, pte->pfn); 108 pte.a = 1; 109 110 tlb_prepare_entry_lo(&lo, pte.g, pte.p, pte.d, 111 pte.cacheable, pte.pfn); 112 113 page_mapping_update(AS, badvaddr, true, &pte); 109 114 110 115 /* … … 135 140 tlb_index_t index; 136 141 uintptr_t badvaddr; 137 pte_t *pte;142 pte_t pte; 138 143 139 144 /* … … 159 164 badvaddr = cp0_badvaddr_read(); 160 165 161 pte = page_mapping_find(AS, badvaddr, true);162 if ( pte && pte->p) {166 bool found = page_mapping_find(AS, badvaddr, true, &pte); 167 if (found && pte.p) { 163 168 /* 164 169 * Read the faulting TLB entry. … … 169 174 * Record access to PTE. 170 175 */ 171 pte->a = 1; 172 173 tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, 174 pte->cacheable, pte->pfn); 176 pte.a = 1; 177 178 tlb_prepare_entry_lo(&lo, pte.g, pte.p, pte.d, 179 pte.cacheable, pte.pfn); 180 181 page_mapping_update(AS, badvaddr, true, &pte); 175 182 176 183 /* … … 197 204 tlb_index_t index; 198 205 uintptr_t badvaddr; 199 pte_t *pte;206 pte_t pte; 200 207 201 208 badvaddr = cp0_badvaddr_read(); … … 215 222 */ 216 223 if (index.p) { 217 printf("%s: TLBP failed in exception handler (badvaddr=%#"224 log(LF_ARCH, LVL_WARN, "%s: TLBP failed in exception handler (badvaddr=%#" 218 225 PRIxn ", ASID=%d).\n", __func__, badvaddr, 219 226 AS ? AS->asid : -1); … … 221 228 } 222 229 223 pte = page_mapping_find(AS, badvaddr, true);224 if ( pte && pte->p && pte->w) {230 bool found = page_mapping_find(AS, badvaddr, true, &pte); 231 if (found && pte.p && pte.w) { 225 232 /* 226 233 * Read the faulting TLB entry. … … 231 238 * Record access and write to PTE. 232 239 */ 233 pte->a = 1; 234 pte->d = 1; 235 236 tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->w, 237 pte->cacheable, pte->pfn); 240 pte.a = 1; 241 pte.d = 1; 242 243 tlb_prepare_entry_lo(&lo, pte.g, pte.p, pte.w, 244 pte.cacheable, pte.pfn); 245 246 page_mapping_update(AS, badvaddr, true, &pte); 238 247 239 248 /* … … 266 275 { 267 276 hi->value = 0; 268 hi->vpn2 = ADDR2 VPN2(ALIGN_DOWN(addr, PAGE_SIZE));277 hi->vpn2 = ADDR2HI_VPN2(ALIGN_DOWN(addr, PAGE_SIZE)); 269 278 hi->asid = asid; 270 279 } … … 295 304 296 305 printf("%-4u %-6u %0#10x %-#6x %1u%1u%1u%1u %0#10x\n", 297 i, hi.asid, VPN22ADDR(hi.vpn2), mask.mask,298 lo0.g, lo0.v, lo0.d, lo0.c, PFN2ADDR(lo0.pfn));306 i, hi.asid, HI_VPN22ADDR(hi.vpn2), mask.mask, 307 lo0.g, lo0.v, lo0.d, lo0.c, LO_PFN2ADDR(lo0.pfn)); 299 308 printf(" %1u%1u%1u%1u %0#10x\n", 300 lo1.g, lo1.v, lo1.d, lo1.c, PFN2ADDR(lo1.pfn));309 lo1.g, lo1.v, lo1.d, lo1.c, LO_PFN2ADDR(lo1.pfn)); 301 310 } 302 311
Note:
See TracChangeset
for help on using the changeset viewer.