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

Subversion Repositories or1k

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

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

Rev 1344 Rev 1350
Line 17... Line 17...
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
/* IMMU model (not functional yet, currently just copy of data cache). */
/* IMMU model (not functional yet, currently just copy of data cache). */
 
 
 
#include "config.h"
 
 
 
#ifdef HAVE_INTTYPES_H
 
#include <inttypes.h>
 
#endif
 
 
 
#include "port.h"
 
#include "arch.h"
#include "immu.h"
#include "immu.h"
#include "abstract.h"
#include "abstract.h"
#include "opcode/or32.h"
#include "opcode/or32.h"
#include "stats.h"
#include "stats.h"
#include "sprs.h"
#include "sprs.h"
Line 30... Line 38...
 
 
extern int cont_run;
extern int cont_run;
 
 
/* Insn MMU */
/* Insn MMU */
 
 
static inline unsigned long immu_simulate_tlb(unsigned long virtaddr)
static inline oraddr_t immu_simulate_tlb(oraddr_t virtaddr)
{
{
  int set, way = -1;
  int set, way = -1;
  int i;
  int i;
  unsigned long tagaddr;
  oraddr_t tagaddr;
  unsigned long vpn, ppn;
  oraddr_t vpn, ppn;
 
 
  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;
  }
  }
Line 56... Line 64...
      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=%x).\n", virtaddr);
    debug(5, "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 113... Line 121...
 *
 *
 * RTRN: 0         - no IMMU, IMMU disabled or ITLB miss
 * RTRN: 0         - no IMMU, IMMU disabled or ITLB miss
 *       else      - appropriate PA (note it IMMU is not present
 *       else      - appropriate PA (note it IMMU is not present
 *                   PA === EA)
 *                   PA === EA)
 */
 */
unsigned long peek_into_itlb(unsigned long virtaddr)
oraddr_t peek_into_itlb(oraddr_t virtaddr)
{
{
  int set, way = -1;
  int set, way = -1;
  int i;
  int i;
  unsigned long tagaddr;
  oraddr_t tagaddr;
  unsigned long vpn, ppn;
  oraddr_t vpn, ppn;
 
 
  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))) {
     return(virtaddr);
     return(virtaddr);
  }
  }
 
 
Line 163... Line 171...
  PRINTF("ERR, should never have happened\n");
  PRINTF("ERR, should never have happened\n");
  return(0);
  return(0);
}
}
 
 
 
 
unsigned long immu_translate(unsigned long virtaddr)
oraddr_t immu_translate(oraddr_t virtaddr)
{
{
  unsigned long phyaddr = immu_simulate_tlb(virtaddr);
  oraddr_t phyaddr = immu_simulate_tlb(virtaddr);
 
 
/*  PRINTF("IMMU translate(%x) = %x\n", virtaddr, phyaddr);*/
/*  PRINTF("IMMU translate(%x) = %x\n", virtaddr, phyaddr);*/
  return phyaddr;
  return phyaddr;
}
}
 
 

powered by: WebSVN 2.1.0

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