OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_61/] [or1ksim/] [mmu/] [immu.c] - Diff between revs 1382 and 1416

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 1382 Rev 1416
Line 34... Line 34...
#include "sprs.h"
#include "sprs.h"
#include "except.h"
#include "except.h"
#include "sim-config.h"
#include "sim-config.h"
#include "debug.h"
#include "debug.h"
 
 
 
DEFAULT_DEBUG_CHANNEL(immu);
 
 
extern int cont_run;
extern int cont_run;
 
 
/* Insn MMU */
/* Insn MMU */
 
 
static inline oraddr_t immu_simulate_tlb(oraddr_t virtaddr)
static inline oraddr_t immu_simulate_tlb(oraddr_t virtaddr)
Line 50... Line 52...
  if (!(mfspr(SPR_SR) & SPR_SR_IME) || !(testsprbits(SPR_UPR, SPR_UPR_IMP))) {
  if (!(mfspr(SPR_SR) & SPR_SR_IME) || !(testsprbits(SPR_UPR, SPR_UPR_IMP))) {
    insn_ci = (virtaddr >= 0x80000000);
    insn_ci = (virtaddr >= 0x80000000);
    return virtaddr;
    return virtaddr;
  }
  }
 
 
 
  TRACE("IMMU enabled, checking mmu ways\n");
 
 
  /* Which set to check out? */
  /* Which set to check out? */
  set = (virtaddr / config.immu.pagesize) % config.immu.nsets;
  set = (virtaddr / config.immu.pagesize) % config.immu.nsets;
  tagaddr = (virtaddr / config.immu.pagesize) / config.immu.nsets;
  tagaddr = (virtaddr / config.immu.pagesize) / config.immu.nsets;
  vpn = virtaddr / (config.immu.pagesize * config.immu.nsets);
  vpn = virtaddr / (config.immu.pagesize * config.immu.nsets);
 
 
Line 64... Line 68...
      way = i;
      way = i;
 
 
  /* Did we find our tlb entry? */
  /* Did we find our tlb entry? */
  if (way >= 0) { /* Yes, we did. */
  if (way >= 0) { /* Yes, we did. */
    immu_stats.fetch_tlbhit++;
    immu_stats.fetch_tlbhit++;
    debug(5, "ITLB hit (virtaddr=%"PRIxADDR").\n", virtaddr);
    TRACE("ITLB hit (virtaddr=%"PRIxADDR").\n", virtaddr);
 
 
    /* Test for page fault */
    /* Test for page fault */
    if (mfspr (SPR_SR) & SPR_SR_SM) {
    if (mfspr (SPR_SR) & SPR_SR_SM) {
      if (!(mfspr (SPR_ITLBTR_BASE(way) + set) & SPR_ITLBTR_SXE))
      if (!(mfspr (SPR_ITLBTR_BASE(way) + set) & SPR_ITLBTR_SXE))
        except_handle(EXCEPT_IPF, virtaddr);
        except_handle(EXCEPT_IPF, virtaddr);
Line 166... Line 170...
  }
  }
  else {
  else {
    return(0);
    return(0);
  }
  }
 
 
  PRINTF("ERR, should never have happened\n");
  ERR("should never have happened\n");
  return(0);
  return(0);
}
}
 
 
 
 
oraddr_t immu_translate(oraddr_t virtaddr)
oraddr_t immu_translate(oraddr_t virtaddr)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.