diff options
Diffstat (limited to 'eim/sw')
-rw-r--r-- | eim/sw/trng_tester_eim.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/eim/sw/trng_tester_eim.c b/eim/sw/trng_tester_eim.c index f60aeec..0cb9312 100644 --- a/eim/sw/trng_tester_eim.c +++ b/eim/sw/trng_tester_eim.c @@ -55,6 +55,7 @@ int debug = 0; int quiet = 0; int repeat = 0; +int dump_data = 1; int num_words = 10; /* ---------------- sanity test case ---------------- */ @@ -230,32 +231,50 @@ int TC6(void) /* TC7: Read random data from trng_csprng. */ int TC7(void) { - int i, n; - unsigned long random; + int i; +#ifdef WAIT_STATS + int n; +#endif + uint32_t random; if (!quiet) printf("TC7: Read random data from trng_csprng.\n"); for (i = 0; i < num_words; ++i) { /* check status */ - n = 0; - if (tc_wait(CSPRNG_ADDR_STATUS, CSPRNG_STATUS_VALID, &n) != 0) +#ifdef WAIT_STATS + if ((n = tc_wait(CSPRNG_ADDR_STATUS, CSPRNG_STATUS_VALID)) < 0) +#else + if (tc_wait(CSPRNG_ADDR_STATUS, CSPRNG_STATUS_VALID) != 0) +#endif return 1; /* read random data */ if (tc_read(CSPRNG_ADDR_RANDOM, (uint8_t *)&random, 4) != 0) return 1; /* display random data */ - if (!debug) + if (!debug) { + if (dump_data) { + // Raw data output to std out. + printf("%c%c%c%c", (int8_t)(random >> 24 & 0xff), + (int8_t)(random >> 16 & 0xff), + (int8_t)(random >> 8 & 0xff), + (int8_t)(random & 0xff)); + } + else + { #ifdef WAIT_STATS - printf("%08lx %d\n", random, n); + printf("0x%08x %d\n", random, n); #else - printf("%08lx\n", random); + printf("0x%08x\n", random); #endif + } + } } return 0; } + /* ---------------- main ---------------- */ /* signal handler for ctrl-c to end repeat testing */ |