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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_61/] [or1ksim/] [mmu/] [dmmu.c] - Diff between revs 997 and 1240

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

Rev 997 Rev 1240
Line 106... Line 106...
    runtime.sim.mem_cycles += config.dmmu.missdelay;
    runtime.sim.mem_cycles += config.dmmu.missdelay;
    return 0;
    return 0;
  }
  }
}
}
 
 
 
/* DESC: try to find EA -> PA transaltion without changing
 
 *       any of precessor states. if this is not passible gives up
 
 *       (without triggering exceptions)
 
 *
 
 * PRMS: virtaddr     - EA for which to find translation
 
 *
 
 *       write_access - 0 ignore testing for write access
 
 *                      1 test for write access, if fails
 
 *                        do not return translation
 
 *
 
 *       through_dc   - 1 go through data cache
 
 *                      0 ignore data cache
 
 *
 
 * RTRN: 0            - no DMMU, DMMU disabled or ITLB miss
 
 *       else         - appropriate PA (note it DMMU is not present
 
 *                      PA === EA)
 
 */
 
unsigned long peek_into_dtlb(unsigned long virtaddr, int write_access,
 
                            int through_dc)
 
{
 
  int set, way = -1;
 
  int i;
 
  unsigned long tagaddr;
 
  unsigned long vpn, ppn;
 
 
 
  if (!(mfspr(SPR_SR) & SPR_SR_DME) || !testsprbits(SPR_UPR, SPR_UPR_DMP)) {
 
    if (through_dc)
 
      data_ci = (virtaddr >= 0x80000000);
 
    return virtaddr;
 
  }
 
 
 
  /* Which set to check out? */
 
  set = (virtaddr / config.dmmu.pagesize) % config.dmmu.nsets;
 
  tagaddr = (virtaddr / config.dmmu.pagesize) / config.dmmu.nsets;
 
  vpn = virtaddr / (config.dmmu.pagesize * config.dmmu.nsets);
 
 
 
  /* Scan all ways and try to find a matching way. */
 
  for (i = 0; i < config.dmmu.nways; i++)
 
    if (((mfspr(SPR_DTLBMR_BASE(i) + set) / (config.dmmu.pagesize * config.dmmu.nsets)) == vpn) &&
 
        testsprbits(SPR_DTLBMR_BASE(i) + set, SPR_DTLBMR_V))
 
      way = i;
 
 
 
   /* Did we find our tlb entry? */
 
  if (way >= 0) { /* Yes, we did. */
 
    dmmu_stats.loads_tlbhit++;
 
    debug(5, "DTLB hit (virtaddr=%x).\n", virtaddr);
 
 
 
    /* Test for page fault */
 
    if (mfspr (SPR_SR) & SPR_SR_SM) {
 
      if ( write_access && !(mfspr (SPR_DTLBTR_BASE(way) + set) & SPR_DTLBTR_SWE)
 
       || !write_access && !(mfspr (SPR_DTLBTR_BASE(way) + set) & SPR_DTLBTR_SRE))
 
 
 
        /* otherwise exception DPF would be raised */
 
        return(0);
 
    } else {
 
      if ( write_access && !(mfspr (SPR_DTLBTR_BASE(way) + set) & SPR_DTLBTR_UWE)
 
       || !write_access && !(mfspr (SPR_DTLBTR_BASE(way) + set) & SPR_DTLBTR_URE))
 
 
 
        /* otherwise exception DPF would be raised */
 
        return(0);
 
    }
 
 
 
    if (through_dc) {
 
      /* Check if page is cache inhibited */
 
      data_ci = (mfspr(SPR_DTLBTR_BASE(way) + set) & SPR_DTLBTR_CI) == SPR_DTLBTR_CI;
 
    }
 
 
 
    ppn = mfspr(SPR_DTLBTR_BASE(way) + set) / config.dmmu.pagesize;
 
    return (ppn * config.dmmu.pagesize) + (virtaddr % config.dmmu.pagesize);
 
  }
 
  else {  /* No, we didn't. */
 
    return(0);
 
  }
 
 
 
  PRINTF("ERR, should never have happened\n");
 
  return(0);
 
}
 
 
 
 
unsigned long dmmu_translate(unsigned long virtaddr, int write_access)
unsigned long dmmu_translate(unsigned long virtaddr, int write_access)
{
{
  unsigned long phyaddr = dmmu_simulate_tlb(virtaddr, write_access);
  unsigned long phyaddr = dmmu_simulate_tlb(virtaddr, write_access);
 
 
/*  PRINTF("DMMU translate(%x) = %x\n", virtaddr, phyaddr);*/
/*  PRINTF("DMMU translate(%x) = %x\n", virtaddr, phyaddr);*/

powered by: WebSVN 2.1.0

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