From a070e6802bc94ec21bc7c12275cf4c091a0fafe4 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Fri, 23 Apr 2021 22:41:53 -0700 Subject: [PATCH] make the linker information work... add an inline to ignore warning.. symbols defined by the linker script are all treated as addresses, so we need to get the address, and cast it to an integer for the length case.. The return value must be used, but as we init early on, we don't need to check it, so just hide the error w/ an inline function.. --- strobe_rng_init.c | 12 +++++++++--- strobe_rng_init.h | 10 ++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/strobe_rng_init.c b/strobe_rng_init.c index 4176fd7..0b8926e 100644 --- a/strobe_rng_init.c +++ b/strobe_rng_init.c @@ -2,9 +2,15 @@ #include -extern uint8_t rng_save; +/* + * Note: rng_save is really REAL_RNG_SAVE_LEN, BUT, we want to use the + * uninitalized SRAM after it as entropy. + */ +extern uint8_t rng_save[2*1048]; extern int rng_save_len; +#define REAL_RNG_SAVE_LEN ((int)&rng_save_len) + void strobe_rng_init(void) { @@ -15,11 +21,11 @@ strobe_rng_init(void) * On first boot, SRAM is uninitialized and randomness from * it is used. On reset, the previously saved state is used. */ - strobe_seed_prng(&rng_save, 2*1024); + strobe_seed_prng(rng_save, 2*1024); /* * Save entropy for next reset. */ - r = strobe_randomize(&rng_save, rng_save_len); + r = strobe_randomize(rng_save, REAL_RNG_SAVE_LEN); (void)r; } diff --git a/strobe_rng_init.h b/strobe_rng_init.h index 9c02972..7f9e489 100644 --- a/strobe_rng_init.h +++ b/strobe_rng_init.h @@ -1,2 +1,12 @@ +#include void strobe_rng_init(void); + +static inline void +bare_strobe_randomize(uint8_t *ptr, ssize_t len) +{ + int r; + + r = strobe_randomize(ptr, len); + (void)r; +}