Line 8... |
Line 8... |
Bottom half will be used for this program, the rest
|
Bottom half will be used for this program, the rest
|
will be used for testing */
|
will be used for testing */
|
#define FLASH_START 0x04000000
|
#define FLASH_START 0x04000000
|
#define FLASH_SIZE 0x00200000
|
#define FLASH_SIZE 0x00200000
|
#define RAM_START 0x00000000
|
#define RAM_START 0x00000000
|
#define RAM_SIZE 0x00200000
|
#define RAM_SIZE 0x00400000
|
|
|
/* 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) */
|
Line 35... |
Line 35... |
#define TLB_TEXT_SET_NB 6
|
#define TLB_TEXT_SET_NB 6
|
#define TLB_DATA_SET_NB 6
|
#define TLB_DATA_SET_NB 6
|
|
|
#define TLB_CODE_MASK 0xffffc000
|
#define TLB_CODE_MASK 0xffffc000
|
#define TLB_PR_MASK 0x00003fff
|
#define TLB_PR_MASK 0x00003fff
|
#define DTLB_PR_NOLIMIT ( SPR_DTLBTR_CI | \
|
|
SPR_DTLBTR_URE | \
|
#define DTLB_PR_NOLIMIT (SPR_DTLBTR_URE | \
|
SPR_DTLBTR_UWE | \
|
SPR_DTLBTR_UWE | \
|
SPR_DTLBTR_SRE | \
|
SPR_DTLBTR_SRE | \
|
SPR_DTLBTR_SWE )
|
SPR_DTLBTR_SWE )
|
|
|
#define ITLB_PR_NOLIMIT ( SPR_ITLBTR_CI | \
|
#define ITLB_PR_NOLIMIT (SPR_ITLBTR_SXE | \
|
SPR_ITLBTR_SXE | \
|
|
SPR_ITLBTR_UXE )
|
SPR_ITLBTR_UXE )
|
|
|
/* fails if x is false */
|
/* fails if x is false */
|
#define ASSERT(x) ((x)?1: fail (__FUNCTION__, __LINE__))
|
#define ASSERT(x) ((x)?1: fail (__FUNCTION__, __LINE__))
|
|
|
Line 88... |
Line 87... |
extern int store_acc_16 (unsigned long add);
|
extern int store_acc_16 (unsigned long add);
|
extern int load_b_acc_32 (unsigned long add);
|
extern int load_b_acc_32 (unsigned long add);
|
extern int int_trigger (void);
|
extern int int_trigger (void);
|
extern int int_loop (void);
|
extern int int_loop (void);
|
extern int jump_back (void);
|
extern int jump_back (void);
|
|
extern int ic_invalidate (void);
|
|
|
/* Local functions prototypes */
|
/* Local functions prototypes */
|
void dmmu_disable (void);
|
void dmmu_disable (void);
|
void immu_disable (void);
|
void immu_disable (void);
|
|
|
Line 407... |
Line 407... |
mtspr (SPR_ITLBMR_BASE(0) + i, ea & SPR_ITLBMR_VPN | SPR_ITLBMR_V);
|
mtspr (SPR_ITLBMR_BASE(0) + i, ea & SPR_ITLBMR_VPN | SPR_ITLBMR_V);
|
mtspr (SPR_ITLBTR_BASE(0) + i, ta & SPR_ITLBTR_PPN| ITLB_PR_NOLIMIT);
|
mtspr (SPR_ITLBTR_BASE(0) + i, ta & SPR_ITLBTR_PPN| ITLB_PR_NOLIMIT);
|
}
|
}
|
|
|
/* Set dtlb no permisions */
|
/* Set dtlb no permisions */
|
itlb_val = SPR_ITLBTR_CI;
|
itlb_val = 0;
|
|
|
/* Reset except counter */
|
/* Reset except counter */
|
except_count = 0;
|
except_count = 0;
|
except_mask = 0;
|
except_mask = 0;
|
except_pc = 0;
|
except_pc = 0;
|
Line 430... |
Line 430... |
ASSERT(except_mask == (1 << V_ITLB_MISS));
|
ASSERT(except_mask == (1 << V_ITLB_MISS));
|
ASSERT(except_pc == ea);
|
ASSERT(except_pc == ea);
|
ASSERT(ret == 0);
|
ASSERT(ret == 0);
|
|
|
/* Set dtlb no permisions */
|
/* Set dtlb no permisions */
|
itlb_val = SPR_ITLBTR_CI | SPR_ITLBTR_SXE;
|
itlb_val = SPR_ITLBTR_SXE;
|
|
|
/* Reset except counter */
|
/* Reset except counter */
|
except_count = 0;
|
except_count = 0;
|
except_mask = 0;
|
except_mask = 0;
|
except_pc = 0;
|
except_pc = 0;
|
Line 446... |
Line 446... |
ASSERT(except_mask == (1 << V_IPF));
|
ASSERT(except_mask == (1 << V_IPF));
|
ASSERT(except_pc == ea);
|
ASSERT(except_pc == ea);
|
ASSERT(ret == 0);
|
ASSERT(ret == 0);
|
|
|
/* Set dtlb no permisions */
|
/* Set dtlb no permisions */
|
itlb_val = SPR_ITLBTR_CI;
|
itlb_val = 0;
|
|
|
/* Reset except counter */
|
/* Reset except counter */
|
except_count = 0;
|
except_count = 0;
|
except_mask = 0;
|
except_mask = 0;
|
except_pc = 0;
|
except_pc = 0;
|
Line 462... |
Line 462... |
ASSERT(except_mask == (1 << V_ITLB_MISS));
|
ASSERT(except_mask == (1 << V_ITLB_MISS));
|
ASSERT(except_pc == ea + 4);
|
ASSERT(except_pc == ea + 4);
|
ASSERT(ret == 0);
|
ASSERT(ret == 0);
|
|
|
/* Set dtlb no permisions */
|
/* Set dtlb no permisions */
|
itlb_val = SPR_ITLBTR_CI | SPR_ITLBTR_SXE;
|
itlb_val = SPR_ITLBTR_SXE;
|
|
|
/* Reset except counter */
|
/* Reset except counter */
|
except_count = 0;
|
except_count = 0;
|
except_mask = 0;
|
except_mask = 0;
|
except_pc = 0;
|
except_pc = 0;
|
Line 516... |
Line 516... |
mtspr (SPR_DTLBMR_BASE(0) + i, ea & SPR_DTLBMR_VPN | SPR_ITLBMR_V);
|
mtspr (SPR_DTLBMR_BASE(0) + i, ea & SPR_DTLBMR_VPN | SPR_ITLBMR_V);
|
mtspr (SPR_DTLBTR_BASE(0) + i, ta & SPR_DTLBTR_PPN | DTLB_PR_NOLIMIT);
|
mtspr (SPR_DTLBTR_BASE(0) + i, ta & SPR_DTLBTR_PPN | DTLB_PR_NOLIMIT);
|
}
|
}
|
|
|
/* Set dtlb no permisions */
|
/* Set dtlb no permisions */
|
dtlb_val = SPR_DTLBTR_CI;
|
dtlb_val = 0;
|
|
|
/* Reset except counter */
|
/* Reset except counter */
|
except_count = 0;
|
except_count = 0;
|
except_mask = 0;
|
except_mask = 0;
|
except_pc = 0;
|
except_pc = 0;
|
Line 540... |
Line 540... |
ASSERT(except_pc == (unsigned long)load_b_acc_32 + 8);
|
ASSERT(except_pc == (unsigned long)load_b_acc_32 + 8);
|
ASSERT(except_ea == ea);
|
ASSERT(except_ea == ea);
|
ASSERT(ret == 0x12345678);
|
ASSERT(ret == 0x12345678);
|
|
|
/* Set dtlb no permisions */
|
/* Set dtlb no permisions */
|
dtlb_val = SPR_DTLBTR_CI | SPR_DTLBTR_SRE;
|
dtlb_val = SPR_DTLBTR_SRE;
|
|
|
/* Reset except counter */
|
/* Reset except counter */
|
except_count = 0;
|
except_count = 0;
|
except_mask = 0;
|
except_mask = 0;
|
except_pc = 0;
|
except_pc = 0;
|
Line 618... |
Line 618... |
except_pc = 0;
|
except_pc = 0;
|
except_ea = 0;
|
except_ea = 0;
|
|
|
/* Set IMMU translation */
|
/* Set IMMU translation */
|
ea = RAM_START + (RAM_SIZE) + ((TLB_TEXT_SET_NB)*PAGE_SIZE);
|
ea = RAM_START + (RAM_SIZE) + ((TLB_TEXT_SET_NB)*PAGE_SIZE);
|
itlb_val = SPR_ITLBTR_CI | SPR_ITLBTR_SXE;
|
itlb_val = SPR_ITLBTR_SXE;
|
mtspr (SPR_ITLBMR_BASE(0) + TLB_TEXT_SET_NB, (ea & SPR_ITLBMR_VPN) | SPR_ITLBMR_V);
|
mtspr (SPR_ITLBMR_BASE(0) + TLB_TEXT_SET_NB, (ea & SPR_ITLBMR_VPN) | SPR_ITLBMR_V);
|
mtspr (SPR_ITLBTR_BASE(0) + TLB_TEXT_SET_NB, ((ea + PAGE_SIZE) & SPR_ITLBTR_PPN) | itlb_val);
|
mtspr (SPR_ITLBTR_BASE(0) + TLB_TEXT_SET_NB, ((ea + PAGE_SIZE) & SPR_ITLBTR_PPN) | itlb_val);
|
|
|
/* Enable IMMU */
|
/* Enable IMMU */
|
immu_enable ();
|
immu_enable ();
|
Line 645... |
Line 645... |
|
|
/* Copy jump instruction to last location of RAM */
|
/* Copy jump instruction to last location of RAM */
|
ea = RAM_START + RAM_SIZE - 8;
|
ea = RAM_START + RAM_SIZE - 8;
|
memcpy((void *)ea, (void *)&jump_back, 8);
|
memcpy((void *)ea, (void *)&jump_back, 8);
|
|
|
|
// ic_invalidate ();
|
|
|
/* Check if there was bus error exception */
|
/* Check if there was bus error exception */
|
ret = call (ea, 0);
|
ret = call (ea, 0);
|
ASSERT(except_count == 1);
|
ASSERT(except_count == 1);
|
ASSERT(except_mask == (1 << V_BERR));
|
ASSERT(except_mask == (1 << V_BERR));
|
ASSERT(except_pc == ea + 4);
|
ASSERT(except_pc == ea + 4);
|
Line 660... |
Line 662... |
except_pc = 0;
|
except_pc = 0;
|
except_ea = 0;
|
except_ea = 0;
|
|
|
/* Set DMMU translation */
|
/* Set DMMU translation */
|
ea = RAM_START + (RAM_SIZE) + ((TLB_DATA_SET_NB)*PAGE_SIZE);
|
ea = RAM_START + (RAM_SIZE) + ((TLB_DATA_SET_NB)*PAGE_SIZE);
|
dtlb_val = SPR_DTLBTR_CI | SPR_DTLBTR_SRE;
|
dtlb_val = SPR_DTLBTR_SRE;
|
mtspr (SPR_DTLBMR_BASE(0) + TLB_DATA_SET_NB, (ea & SPR_DTLBMR_VPN) | SPR_DTLBMR_V);
|
mtspr (SPR_DTLBMR_BASE(0) + TLB_DATA_SET_NB, (ea & SPR_DTLBMR_VPN) | SPR_DTLBMR_V);
|
mtspr (SPR_DTLBTR_BASE(0) + TLB_DATA_SET_NB, ((ea + PAGE_SIZE) & SPR_DTLBTR_PPN) | dtlb_val);
|
mtspr (SPR_DTLBTR_BASE(0) + TLB_DATA_SET_NB, ((ea + PAGE_SIZE) & SPR_DTLBTR_PPN) | dtlb_val);
|
|
|
/* Enable DMMU */
|
/* Enable DMMU */
|
dmmu_enable ();
|
dmmu_enable ();
|
Line 882... |
Line 884... |
mtspr (SPR_ITLBMR_BASE(0) + i, ea | SPR_ITLBMR_V);
|
mtspr (SPR_ITLBMR_BASE(0) + i, ea | SPR_ITLBMR_V);
|
mtspr (SPR_ITLBTR_BASE(0) + i, ta | ITLB_PR_NOLIMIT);
|
mtspr (SPR_ITLBTR_BASE(0) + i, ta | ITLB_PR_NOLIMIT);
|
}
|
}
|
|
|
/* Set dtlb no permisions */
|
/* Set dtlb no permisions */
|
itlb_val = SPR_ITLBTR_CI;
|
itlb_val = 0;
|
|
|
/* Invalidate all entries in DTLB */
|
/* Invalidate all entries in DTLB */
|
for (i = 0; i < DTLB_WAYS; i++) {
|
for (i = 0; i < DTLB_WAYS; i++) {
|
for (j = 0; j < DTLB_SETS; j++) {
|
for (j = 0; j < DTLB_SETS; j++) {
|
mtspr (SPR_DTLBMR_BASE(i) + j, 0);
|
mtspr (SPR_DTLBMR_BASE(i) + j, 0);
|
Line 904... |
Line 906... |
|
|
/* Init tick timer */
|
/* Init tick timer */
|
tick_init (1, 1);
|
tick_init (1, 1);
|
|
|
/* Set dtlb no permisions */
|
/* Set dtlb no permisions */
|
dtlb_val = SPR_DTLBTR_CI;
|
dtlb_val = 0;
|
|
|
/* Reset except counter */
|
/* Reset except counter */
|
except_count = 0;
|
except_count = 0;
|
except_mask = 0;
|
except_mask = 0;
|
except_pc = 0;
|
except_pc = 0;
|
Line 1125... |
Line 1127... |
|
|
/* ITLB exception test */
|
/* ITLB exception test */
|
itlb_test (); // OK
|
itlb_test (); // OK
|
|
|
/* DTLB exception test */
|
/* DTLB exception test */
|
// dtlb_test (); // OK [with enabled IC/DC it fails on or1ksim]
|
dtlb_test (); // OK [with enabled IC/DC it fails on or1ksim]
|
|
|
/* Bus error exception test */
|
/* Bus error exception test */
|
// buserr_test (); // Doesn't work on or1ksim
|
buserr_test (); // Doesn't work on or1ksim
|
|
|
/* Illegal insn test */
|
/* Illegal insn test */
|
illegal_insn_test (); // OK
|
illegal_insn_test (); // OK
|
|
|
/* Alignment test */
|
/* Alignment test */
|
Line 1143... |
Line 1145... |
|
|
/* Range test */
|
/* Range test */
|
// range_test (); // Doesn't work on or1ksim
|
// range_test (); // Doesn't work on or1ksim
|
|
|
/* Exception priority test */
|
/* Exception priority test */
|
// except_priority_test (); // Doesn't work on or1ksim
|
except_priority_test (); // Doesn't work on or1ksim
|
|
|
report (0xdeaddead);
|
report (0xdeaddead);
|
exit (0);
|
exit (0);
|
|
|
return 0;
|
return 0;
|