Browse Source

use sbrk(0) instead of end to get the uninitalized memory...

This is better, as if anyone allocated memory before, we will not use
that memory, and still use uninitalized memory..
irr_shared
John-Mark Gurney 3 years ago
parent
commit
9bbf03c6db
1 changed files with 5 additions and 7 deletions
  1. +5
    -7
      strobe_rng_init.c

+ 5
- 7
strobe_rng_init.c View File

@@ -33,18 +33,14 @@

#include <utilities.h>

#include <unistd.h>

#define nitems(x) (sizeof(x) / sizeof *(x))
#define DEFINE_RNG_SAVE 1
#if DEFINE_RNG_SAVE
const rng_word_t rng_save[roundup(32, sizeof(rng_word_t)) / sizeof(rng_word_t)] __attribute__ ((section (".eeprom")));
#endif

/*
* Note: This is the end of allocated SRAM, aka, the begining of
* uninitalized SRAM.
*/
extern uint8_t end;

void
strobe_rng_init(void)
{
@@ -58,8 +54,10 @@ strobe_rng_init(void)
/*
* On first boot, SRAM is uninitialized and randomness from
* it is used.
*
* Note: This depends upon sbrk pointing to uinitalized SRAM.
*/
strobe_seed_prng(&end, 2*1024);
strobe_seed_prng(sbrk(0), 2*1024);

}



Loading…
Cancel
Save