diff options
Diffstat (limited to 'sw/trng_tester.c')
-rw-r--r-- | sw/trng_tester.c | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/sw/trng_tester.c b/sw/trng_tester.c index f0b80d0..715a20c 100644 --- a/sw/trng_tester.c +++ b/sw/trng_tester.c @@ -61,39 +61,26 @@ int wait_stats = 0; int TC0() { - uint8_t board_name0[4] = "PVT1"; - uint8_t board_name1[4] = " "; - uint8_t board_version[4] = "0.10"; - - uint8_t comm_name0[4] = "eim "; - uint8_t comm_name1[4] = " "; - uint8_t comm_version[4] = "0.10"; - + uint8_t name0[4] = NOVENA_BOARD_NAME0; + uint8_t name1[4] = NOVENA_BOARD_NAME1; + uint8_t version[4] = NOVENA_BOARD_VERSION; uint8_t t[4]; if (!quiet) - printf("TC0-1: Reading board type, version, and dummy reg from global registers.\n"); + printf("TC0: Reading board type, version, and dummy reg from global registers.\n"); /* write current time into dummy register, then try to read it back * to make sure that we can actually write something into EIM */ (void)time((time_t *)t); - if (tc_write(BOARD_ADDR_DUMMY, (void *)&t, 4) != 0) - return 1; - - if (tc_expected(BOARD_ADDR_NAME0, board_name0, 4) || - tc_expected(BOARD_ADDR_NAME1, board_name1, 4) || - tc_expected(BOARD_ADDR_VERSION, board_version, 4) || - tc_expected(BOARD_ADDR_DUMMY, (void *)t, 4)) + if (tc_write(BOARD_ADDR_DUMMY, t, 4) != 0) return 1; - if (!quiet) - printf("TC0-2: Reading name and version words from communications core.\n"); - return - tc_expected(COMM_ADDR_NAME0, comm_name0, 4) || - tc_expected(COMM_ADDR_NAME1, comm_name1, 4) || - tc_expected(COMM_ADDR_VERSION, comm_version, 4); + tc_expected(BOARD_ADDR_NAME0, name0, 4) || + tc_expected(BOARD_ADDR_NAME1, name1, 4) || + tc_expected(BOARD_ADDR_VERSION, version, 4) || + tc_expected(BOARD_ADDR_DUMMY, t, 4); } /* ---------------- trng test cases ---------------- */ @@ -101,9 +88,9 @@ int TC0() /* TC1: Read name and version from trng core. */ int TC1(void) { - uint8_t name0[4] = "trng"; - uint8_t name1[4] = " "; - uint8_t version[4] = "0.01"; + uint8_t name0[4] = TRNG_NAME0; + uint8_t name1[4] = TRNG_NAME1; + uint8_t version[4] = TRNG_VERSION; if (!quiet) printf("TC1: Reading name and version words from trng core.\n"); @@ -122,9 +109,9 @@ int TC1(void) /* TC2: Read name and version from avalanche_entropy core. */ int TC2(void) { - uint8_t name0[4] = "extn"; - uint8_t name1[4] = "oise"; - uint8_t version[4] = "0.10"; + uint8_t name0[4] = AVALANCHE_ENTROPY_NAME0; + uint8_t name1[4] = AVALANCHE_ENTROPY_NAME1; + uint8_t version[4] = AVALANCHE_ENTROPY_VERSION; if (!quiet) printf("TC2: Reading name and version words from avalanche_entropy core.\n"); @@ -171,9 +158,9 @@ int TC3(void) /* TC4: Read name and version from rosc_entropy core. */ int TC4(void) { - uint8_t name0[4] = "rosc"; - uint8_t name1[4] = " ent"; - uint8_t version[4] = "0.10"; + uint8_t name0[4] = ROSC_ENTROPY_NAME0; + uint8_t name1[4] = ROSC_ENTROPY_NAME1; + uint8_t version[4] = ROSC_ENTROPY_VERSION; if (!quiet) printf("TC4: Reading name and version words from rosc_entropy core.\n"); @@ -220,8 +207,17 @@ int TC5(void) /* TC6: Read name and version from trng_csprng core. */ int TC6(void) { - /* XXX csprng core currently doesn't have name/version registers */ - return 0; + uint8_t name0[4] = CSPRNG_NAME0; + uint8_t name1[4] = CSPRNG_NAME1; + uint8_t version[4] = CSPRNG_VERSION; + + if (!quiet) + printf("TC6: Reading name and version words from trng_csprng core.\n"); + + return + tc_expected(CSPRNG_ADDR_NAME0, name0, 4) || + tc_expected(CSPRNG_ADDR_NAME1, name1, 4) || + tc_expected(CSPRNG_ADDR_VERSION, version, 4); } /* XXX clear 'enable' control bit, see if we read the same value */ |