@@ -35,8 +35,10 @@ int __attribute__((noinline)) target() {
35
35
volatile uint64_t * const eccctrl = (uint64_t * )(ICACHECTRL_ECCCTRL_ADDR );
36
36
volatile uint64_t * const ecciaddr = (uint64_t * )(ICACHECTRL_ECCIADDR_ADDR );
37
37
38
- int test (uint64_t ctrl , istatus_t expected_istatus , ierror_t expected_ierror , const char * desp ) {
38
+ int test (uint64_t ctrl , int (* target )(), istatus_t expected_istatus , ierror_t expected_ierror , const char * desp ) {
39
+ #if TEST_LOG_LEVEL <= TEST_LOG_LEVEL_INFO
39
40
static int test_id = 0 ;
41
+ #endif
40
42
41
43
asm volatile ("fence.i" :::"memory" );
42
44
@@ -49,6 +51,7 @@ int test(uint64_t ctrl, istatus_t expected_istatus, ierror_t expected_ierror, co
49
51
50
52
// set the control register and wait for the operation to finish
51
53
DEBUG ("ECC inject start! eccctrl=0x%x\n" , ctrl );
54
+ * ecciaddr = (uint64_t ) target ;
52
55
* eccctrl = ctrl ;
53
56
istatus_t istatus ;
54
57
int wait = 0 ;
@@ -90,20 +93,13 @@ int test(uint64_t ctrl, istatus_t expected_istatus, ierror_t expected_ierror, co
90
93
}
91
94
92
95
int main () {
93
- INFO ("Setup\n" );
94
- target (); // call target() first to make sure it is in the icache
95
- * ecciaddr = (uint64_t ) target ;
96
-
97
- INFO ("Test\n" );
98
96
int failed = 0 ;
99
97
100
- failed += test (ITARGET_SET (ITARGET_META ) | INJECT | ENABLE , ISTATUS_INJECTED , 0 , "Inject metaArray" );
101
- failed += test (ITARGET_SET (ITARGET_DATA ) | INJECT | ENABLE , ISTATUS_INJECTED , 0 , "Inject dataArray" );
102
- failed += test (ITARGET_SET (ITARGET_RSVD1 ) | INJECT | ENABLE , ISTATUS_ERROR , IERROR_TARGET_INVALID , "Inject to invalid target" );
103
- failed += test (ITARGET_SET (ITARGET_META ) | INJECT , ISTATUS_ERROR , IERROR_NOT_ENABLED , "Inject when ecc not enabled" );
104
-
105
- * ecciaddr = 0 ; // set to where definitely cannot be in the icache
106
- failed += test (ITARGET_SET (ITARGET_META ) | INJECT | ENABLE , ISTATUS_ERROR , IERROR_NOT_FOUND , "Inject to invalid address" );
98
+ failed += test (ITARGET_SET (ITARGET_META ) | INJECT | ENABLE , target , ISTATUS_INJECTED , 0 , "Inject metaArray" );
99
+ failed += test (ITARGET_SET (ITARGET_DATA ) | INJECT | ENABLE , target , ISTATUS_INJECTED , 0 , "Inject dataArray" );
100
+ failed += test (ITARGET_SET (ITARGET_RSVD1 ) | INJECT | ENABLE , target , ISTATUS_ERROR , IERROR_TARGET_INVALID , "Inject to invalid target" );
101
+ failed += test (ITARGET_SET (ITARGET_META ) | INJECT , target , ISTATUS_ERROR , IERROR_NOT_ENABLED , "Inject when ecc not enabled" );
102
+ failed += test (ITARGET_SET (ITARGET_META ) | INJECT | ENABLE , 0 , ISTATUS_ERROR , IERROR_NOT_FOUND , "Inject to invalid address" );
107
103
108
104
return failed ;
109
105
}
0 commit comments