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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_43/] [or1ksim/] [testbench/] [mmu.c] - Diff between revs 600 and 639

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

Rev 600 Rev 639
Line 16... Line 16...
 
 
/* What is the last address in ram that is used by this program */
/* What is the last address in ram that is used by this program */
#define TEXT_END_ADD (FLASH_START + (FLASH_SIZE / 2))
#define TEXT_END_ADD (FLASH_START + (FLASH_SIZE / 2))
#define DATA_END_ADD (RAM_START + (RAM_SIZE / 2))
#define DATA_END_ADD (RAM_START + (RAM_SIZE / 2))
 
 
#define TLB_TEXT_SET_NB 6
#define TLB_TEXT_SET_NB 8
#define TLB_DATA_SET_NB 2
#define TLB_DATA_SET_NB 4
 
 
/* MMU page size */
/* MMU page size */
#define PAGE_SIZE 8192
#define PAGE_SIZE 8192
 
 
/* Number of DTLB sets used (power of 2, max is 256) */
/* Number of DTLB sets used (power of 2, max is 256) */
#define DTLB_SETS 32
#define DTLB_SETS 64
 
 
/* Number of DTLB ways (1, 2, 3 etc., max is 4). */
/* Number of DTLB ways (1, 2, 3 etc., max is 4). */
#define DTLB_WAYS 1
#define DTLB_WAYS 1
 
 
/* Number of ITLB sets used (power of 2, max is 256) */
/* Number of ITLB sets used (power of 2, max is 256) */
#define ITLB_SETS 32
#define ITLB_SETS 64
 
 
/* Number of ITLB ways (1, 2, 3 etc., max is 4). */
/* Number of ITLB ways (1, 2, 3 etc., max is 4). */
#define ITLB_WAYS 1
#define ITLB_WAYS 1
 
 
/* TLB mode codes */
/* TLB mode codes */
Line 66... Line 66...
#define TEST_JUMP(x) copy_jump (((x) & (RAM_SIZE/2 - 1)) + DATA_END_ADD); call (x)
#define TEST_JUMP(x) copy_jump (((x) & (RAM_SIZE/2 - 1)) + DATA_END_ADD); call (x)
 
 
/* Extern functions */
/* Extern functions */
extern void lo_dmmu_en (void);
extern void lo_dmmu_en (void);
extern void lo_immu_en (void);
extern void lo_immu_en (void);
 
extern int  lo_dtlb_ci_test (unsigned long, unsigned long);
 
extern int  lo_itlb_ci_test(unsigned long, unsigned long);
extern void testjump(unsigned long phy_addr, unsigned long virt_addr);
extern void testjump(unsigned long phy_addr, unsigned long virt_addr);
extern void (*jr)(void);
extern void (*jr)(void);
 
 
/* Local functions prototypes */
/* Local functions prototypes */
void dmmu_disable (void);
void dmmu_disable (void);
Line 787... Line 789...
  dmmu_disable();
  dmmu_disable();
 
 
  return 0;
  return 0;
}
}
 
 
 
/* Data cache inhibit bit test
 
   Set and clear CI bit and check the pattern. */
 
int dtlb_ci_test (void)
 
{
 
  int i, j;
 
  unsigned long ea, ta, ret;
 
 
 
  /* Disable DMMU */
 
  dmmu_disable();
 
 
 
  /* Invalidate all entries in DTLB */
 
  for (i = 0; i < DTLB_WAYS; i++) {
 
    for (j = 0; j < DTLB_SETS; j++) {
 
      mtspr (SPR_DTLBMR_BASE(i) + j, 0);
 
      mtspr (SPR_DTLBTR_BASE(i) + j, 0);
 
    }
 
  }
 
 
 
  /* Set one to one translation for the use of this program */
 
  for (i = 0; i < TLB_DATA_SET_NB; i++) {
 
    ea = RAM_START + (i*PAGE_SIZE);
 
    ta = RAM_START + (i*PAGE_SIZE);
 
    mtspr (SPR_DTLBMR_BASE(0) + i, ea | SPR_DTLBMR_V);
 
    mtspr (SPR_DTLBTR_BASE(0) + i, ta | DTLB_PR_NOLIMIT  | SPR_DTLBTR_CI);
 
  }
 
 
 
  /* Testing page */
 
  ea = RAM_START + (RAM_SIZE/2) + (TLB_DATA_SET_NB*PAGE_SIZE);
 
  ta = RAM_START + (RAM_SIZE/2) + (TLB_DATA_SET_NB*PAGE_SIZE);
 
 
 
  /* Write test pattern */
 
  REG32(ea) = 0x01234567;
 
  REG32(ea + PAGE_SIZE - 4) = 0x9abcdef;
 
 
 
  /* Set one to one translation with CI bit for testing area */
 
  mtspr (SPR_DTLBMR_BASE(0) + TLB_DATA_SET_NB, ea | SPR_DTLBMR_V);
 
  mtspr (SPR_DTLBTR_BASE(0) + TLB_DATA_SET_NB, ta | DTLB_PR_NOLIMIT | SPR_DTLBTR_CI);
 
 
 
  ret = lo_dtlb_ci_test(ea, TLB_DATA_SET_NB);
 
  ASSERT(ret == 0);
 
 
 
  return 0;
 
}
 
 
/* Translation address register test
/* Translation address register test
   Set various translation and check the pattern */
   Set various translation and check the pattern */
int itlb_translation_test (void)
int itlb_translation_test (void)
{
{
  int i, j;
  int i, j;
Line 1120... Line 1166...
  immu_disable ();
  immu_disable ();
 
 
  return 0;
  return 0;
}
}
 
 
 
/* Instruction cache inhibit bit test
 
   Set and clear CI bit and check the pattern. */
 
int itlb_ci_test(void)
 
{
 
  int i, j;
 
  unsigned long ea, ta, ret;
 
 
 
  /* Disable IMMU */
 
  immu_disable();
 
 
 
  /* Invalidate all entries in DTLB */
 
  for (i = 0; i < ITLB_WAYS; i++) {
 
    for (j = 0; j < ITLB_SETS; j++) {
 
      mtspr (SPR_ITLBMR_BASE(i) + j, 0);
 
      mtspr (SPR_ITLBTR_BASE(i) + j, 0);
 
    }
 
  }
 
 
 
  /* Set one to one translation for the use of this program */
 
  for (i = 0; i < TLB_TEXT_SET_NB; i++) {
 
    ea = FLASH_START + (i*PAGE_SIZE);
 
    ta = FLASH_START + (i*PAGE_SIZE);
 
    mtspr (SPR_ITLBMR_BASE(0) + i, ea | SPR_ITLBMR_V);
 
    mtspr (SPR_ITLBTR_BASE(0) + i, ta | ITLB_PR_NOLIMIT);
 
  }
 
 
 
  /* Testing page */
 
  ea = RAM_START + (RAM_SIZE/2) + (TLB_TEXT_SET_NB*PAGE_SIZE);
 
 
 
  ret = lo_itlb_ci_test (ea, TLB_TEXT_SET_NB);
 
  ASSERT(ret == 0);
 
 
 
  return 0;
 
}
 
 
int main (void)
int main (void)
{
{
  int i, j;
  int i, j;
 
 
  i = j = 0; /* Get rid of warnings */
  i = j = 0; /* Get rid of warnings */
Line 1165... Line 1246...
    dtlb_premission_test (i);
    dtlb_premission_test (i);
#else
#else
  dtlb_premission_test (DTLB_SETS - 2);
  dtlb_premission_test (DTLB_SETS - 2);
#endif
#endif
 
 
 
  dtlb_ci_test();
#endif
#endif
 
 
#if 1
#if 1
  /* Translation test */
  /* Translation test */
  itlb_translation_test ();
  itlb_translation_test ();
Line 1197... Line 1279...
    itlb_premission_test (i);
    itlb_premission_test (i);
#else
#else
  itlb_premission_test (ITLB_SETS - 2);
  itlb_premission_test (ITLB_SETS - 2);
#endif
#endif
 
 
 
  itlb_ci_test();
#endif
#endif
 
 
  report (0xdeaddead);
  report (0xdeaddead);
  exit (0);
  exit (0);
  return 0;
  return 0;

powered by: WebSVN 2.1.0

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