No more discrimination related with core0/core1. using get_core_num() returns the core number.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2022-12-24 01:38:09 +01:00
parent c0a540ae2b
commit a8fe504d14
5 changed files with 9 additions and 27 deletions

View File

@@ -168,19 +168,11 @@ uint32_t neug_get() {
return v;
}
void neug_wait_full(void) { //should be called only on core1
void neug_wait_full() {
struct rng_rb *rb = &the_ring_buffer;
uint core = get_core_num();
while (!rb->full) {
sleep_ms(1);
}
}
void neug_wait_full_ext(bool blocking) {
struct rng_rb *rb = &the_ring_buffer;
while (!rb->full) {
if (blocking == true)
if (core == 1)
sleep_ms(1);
else
neug_task();

View File

@@ -26,8 +26,7 @@
void neug_init(uint32_t *buf, uint8_t size);
uint32_t neug_get();
void neug_flush(void);
void neug_wait_full(void);
void neug_wait_full_ext(bool);
void neug_wait_full();
void neug_fini(void);
#endif

View File

@@ -79,13 +79,13 @@ void random_get_salt(uint8_t *p) {
/*
* Random byte iterator
*/
int random_gen_ext(void *arg, unsigned char *out, size_t out_len, bool blocking) {
int random_gen(void *arg, unsigned char *out, size_t out_len) {
uint8_t *index_p = (uint8_t *)arg;
uint8_t index = index_p ? *index_p : 0;
size_t n;
while (out_len) {
neug_wait_full_ext(blocking);
neug_wait_full();
n = RANDOM_BYTES_LENGTH - index;
if (n > out_len)
@@ -107,11 +107,3 @@ int random_gen_ext(void *arg, unsigned char *out, size_t out_len, bool blocking)
return 0;
}
int random_gen(void *arg, unsigned char *out, size_t out_len) {
return random_gen_ext(arg, out, out_len, true);
}
int random_gen_core0(void *arg, unsigned char *out, size_t out_len) {
return random_gen_ext(arg, out, out_len, false);
}

View File

@@ -33,7 +33,6 @@ void random_bytes_free (const uint8_t *p);
void random_get_salt (uint8_t *p);
/* iterator returning a byta at a time */
extern int random_gen (void *arg, unsigned char *output, size_t output_len);
extern int random_gen_core0(void *arg, unsigned char *out, size_t out_len);
extern int random_gen(void *arg, unsigned char *output, size_t output_len);
#endif