Skip to content

Commit 3f1256a

Browse files
committed
refactor(icache-ecc-test): allow pass in *target
1 parent ee3c91c commit 3f1256a

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

apps/icache-ecc-test/main.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ int __attribute__((noinline)) target() {
3535
volatile uint64_t* const eccctrl = (uint64_t *)(ICACHECTRL_ECCCTRL_ADDR);
3636
volatile uint64_t* const ecciaddr = (uint64_t *)(ICACHECTRL_ECCIADDR_ADDR);
3737

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
3940
static int test_id = 0;
41+
#endif
4042

4143
asm volatile("fence.i":::"memory");
4244

@@ -49,6 +51,7 @@ int test(uint64_t ctrl, istatus_t expected_istatus, ierror_t expected_ierror, co
4951

5052
// set the control register and wait for the operation to finish
5153
DEBUG("ECC inject start! eccctrl=0x%x\n", ctrl);
54+
*ecciaddr = (uint64_t) target;
5255
*eccctrl = ctrl;
5356
istatus_t istatus;
5457
int wait = 0;
@@ -90,20 +93,13 @@ int test(uint64_t ctrl, istatus_t expected_istatus, ierror_t expected_ierror, co
9093
}
9194

9295
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");
9896
int failed = 0;
9997

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");
107103

108104
return failed;
109105
}

0 commit comments

Comments
 (0)