kernel: stop gathering timestamps once the bin is full per interrupt
random: once seeded, retrieve new entropy at a lower rate
Change-Id: I4ce6081d39274728d82c6889686d1650cfd5fc2e
static struct k_randomness_bin krandom_bin;
u32_t hi, lo;
rand_t r;
+ int nextperiod = random_isseeded() ? KRANDOM_PERIOD*500 : KRANDOM_PERIOD;
bin = (bin+1) % RANDOM_SOURCES;
random_update(RND_TIMING, &r, 1);
/* Schedule new alarm for next m_random call. */
- if (OK != (s=sys_setalarm(KRANDOM_PERIOD, 0)))
+ if (OK != (s=sys_setalarm(nextperiod, 0)))
printf("RANDOM: sys_setalarm failed: %d\n", s);
}
unsigned long tsc_high, tsc_low;
source %= RANDOM_SOURCES;
+ if (rand->bin[source].r_size >= RANDOM_ELEMENTS) return;
r_next= rand->bin[source].r_next;
read_tsc((u32_t *) &tsc_high, (u32_t *) &tsc_low);
rand->bin[source].r_buf[r_next] = tsc_low;