Commit b23761f959166cb2320086bf1ea875ddb2fc4f09

Authored by edgar_igl
1 parent 7d5099d5

CRIS: Avoid a few unecessary steps in the mmu.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5146 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 8 additions and 12 deletions
target-cris/mmu.c
@@ -127,7 +127,7 @@ static int cris_mmu_translate_page(struct cris_mmu_result_t *res, @@ -127,7 +127,7 @@ static int cris_mmu_translate_page(struct cris_mmu_result_t *res,
127 { 127 {
128 unsigned int vpage; 128 unsigned int vpage;
129 unsigned int idx; 129 unsigned int idx;
130 - uint32_t lo, hi; 130 + uint32_t pid, lo, hi;
131 uint32_t tlb_vpn, tlb_pfn = 0; 131 uint32_t tlb_vpn, tlb_pfn = 0;
132 int tlb_pid, tlb_g, tlb_v, tlb_k, tlb_w, tlb_x; 132 int tlb_pid, tlb_g, tlb_v, tlb_k, tlb_w, tlb_x;
133 int cfg_v, cfg_k, cfg_w, cfg_x; 133 int cfg_v, cfg_k, cfg_w, cfg_x;
@@ -140,6 +140,7 @@ static int cris_mmu_translate_page(struct cris_mmu_result_t *res, @@ -140,6 +140,7 @@ static int cris_mmu_translate_page(struct cris_mmu_result_t *res,
140 140
141 r_cause = env->sregs[SFR_R_MM_CAUSE]; 141 r_cause = env->sregs[SFR_R_MM_CAUSE];
142 r_cfg = env->sregs[SFR_RW_MM_CFG]; 142 r_cfg = env->sregs[SFR_RW_MM_CFG];
  143 + pid = env->pregs[PR_PID];
143 144
144 switch (rw) { 145 switch (rw) {
145 case 2: rwcause = CRIS_MMU_ERR_EXEC; mmu = 0; break; 146 case 2: rwcause = CRIS_MMU_ERR_EXEC; mmu = 0; break;
@@ -175,15 +176,14 @@ static int cris_mmu_translate_page(struct cris_mmu_result_t *res, @@ -175,15 +176,14 @@ static int cris_mmu_translate_page(struct cris_mmu_result_t *res,
175 lo = env->tlbsets[mmu][set][idx].lo; 176 lo = env->tlbsets[mmu][set][idx].lo;
176 hi = env->tlbsets[mmu][set][idx].hi; 177 hi = env->tlbsets[mmu][set][idx].hi;
177 178
178 - tlb_vpn = EXTRACT_FIELD(hi, 13, 31); 179 + tlb_vpn = hi >> 13;
179 tlb_pid = EXTRACT_FIELD(hi, 0, 7); 180 tlb_pid = EXTRACT_FIELD(hi, 0, 7);
180 - tlb_pfn = EXTRACT_FIELD(lo, 13, 31);  
181 tlb_g = EXTRACT_FIELD(lo, 4, 4); 181 tlb_g = EXTRACT_FIELD(lo, 4, 4);
182 182
183 D(fprintf(logfile, 183 D(fprintf(logfile,
184 - "TLB[%d][%d][%d] v=%x vpage=%x->pfn=%x lo=%x hi=%x\n",  
185 - mmu, set, idx, tlb_vpn, vpage, tlb_pfn, lo, hi));  
186 - if ((tlb_g || (tlb_pid == (env->pregs[PR_PID] & 0xff))) 184 + "TLB[%d][%d][%d] v=%x vpage=%x lo=%x hi=%x\n",
  185 + mmu, set, idx, tlb_vpn, vpage, lo, hi));
  186 + if ((tlb_g || (tlb_pid == pid))
187 && tlb_vpn == vpage) { 187 && tlb_vpn == vpage) {
188 match = 1; 188 match = 1;
189 break; 189 break;
@@ -245,9 +245,6 @@ static int cris_mmu_translate_page(struct cris_mmu_result_t *res, @@ -245,9 +245,6 @@ static int cris_mmu_translate_page(struct cris_mmu_result_t *res,
245 } 245 }
246 else 246 else
247 D(dump_tlb(env, mmu)); 247 D(dump_tlb(env, mmu));
248 -  
249 - env->sregs[SFR_RW_MM_TLB_HI] = hi;  
250 - env->sregs[SFR_RW_MM_TLB_LO] = lo;  
251 } else { 248 } else {
252 /* If refill, provide a randomized set. */ 249 /* If refill, provide a randomized set. */
253 set = env->mmu_rand_lfsr & 3; 250 set = env->mmu_rand_lfsr & 3;
@@ -278,7 +275,6 @@ static int cris_mmu_translate_page(struct cris_mmu_result_t *res, @@ -278,7 +275,6 @@ static int cris_mmu_translate_page(struct cris_mmu_result_t *res,
278 D(printf("refill vaddr=%x pc=%x\n", vaddr, env->pc)); 275 D(printf("refill vaddr=%x pc=%x\n", vaddr, env->pc));
279 } 276 }
280 277
281 -  
282 D(printf ("%s rw=%d mtch=%d pc=%x va=%x vpn=%x tlbvpn=%x pfn=%x pid=%x" 278 D(printf ("%s rw=%d mtch=%d pc=%x va=%x vpn=%x tlbvpn=%x pfn=%x pid=%x"
283 " %x cause=%x sel=%x sp=%x %x %x\n", 279 " %x cause=%x sel=%x sp=%x %x %x\n",
284 __func__, rw, match, env->pc, 280 __func__, rw, match, env->pc,
@@ -348,7 +344,7 @@ int cris_mmu_translate(struct cris_mmu_result_t *res, @@ -348,7 +344,7 @@ int cris_mmu_translate(struct cris_mmu_result_t *res,
348 344
349 if (!cris_mmu_enabled(env->sregs[SFR_RW_GC_CFG])) { 345 if (!cris_mmu_enabled(env->sregs[SFR_RW_GC_CFG])) {
350 res->phy = vaddr; 346 res->phy = vaddr;
351 - res->prot = PAGE_BITS; 347 + res->prot = PAGE_BITS;
352 goto done; 348 goto done;
353 } 349 }
354 350
@@ -361,7 +357,7 @@ int cris_mmu_translate(struct cris_mmu_result_t *res, @@ -361,7 +357,7 @@ int cris_mmu_translate(struct cris_mmu_result_t *res,
361 base = cris_mmu_translate_seg(env, seg); 357 base = cris_mmu_translate_seg(env, seg);
362 phy = base | (0x0fffffff & vaddr); 358 phy = base | (0x0fffffff & vaddr);
363 res->phy = phy; 359 res->phy = phy;
364 - res->prot = PAGE_BITS; 360 + res->prot = PAGE_BITS;
365 } 361 }
366 else 362 else
367 { 363 {