diff options
author | Paul Selkirk <paul@psgd.org> | 2015-11-13 17:53:30 -0500 |
---|---|---|
committer | Paul Selkirk <paul@psgd.org> | 2015-11-13 17:53:30 -0500 |
commit | a7037d918cbf60bd829e44ccc6d1522f55d5d8b1 (patch) | |
tree | 708a05da632c4ed5b8bd3601c39e3b0c0cf41ea7 /csprng.c | |
parent | 49ac8847de1120a4ae7b72747ee259bc0f5ffb3c (diff) | |
parent | 6ed2c92afd94c08a07f31a7bec345baef07bdf19 (diff) |
Merge branch 'config_core_selector'
Diffstat (limited to 'csprng.c')
-rw-r--r-- | csprng.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -35,24 +35,28 @@ #include <stdint.h> #include "hal.h" +#include "verilog_constants.h" #ifndef WAIT_FOR_CSPRNG_VALID #define WAIT_FOR_CSPRNG_VALID 0 #endif -hal_error_t hal_get_random(void *buffer, const size_t length) +hal_error_t hal_get_random(const hal_core_t *core, void *buffer, const size_t length) { uint8_t temp[4], *buf = buffer; hal_error_t err; size_t i; + if ((err = hal_core_check_name(&core, CSPRNG_NAME)) != HAL_OK) + return err; + for (i = 0; i < length; i += 4) { const int last = (length - i) < 4; - if (WAIT_FOR_CSPRNG_VALID && (err = hal_io_wait_valid(CSPRNG_ADDR_STATUS)) != HAL_OK) + if (WAIT_FOR_CSPRNG_VALID && (err = hal_io_wait_valid(core)) != HAL_OK) return err; - if ((err = hal_io_read(CSPRNG_ADDR_RANDOM, (last ? temp : &buf[i]), 4)) != HAL_OK) + if ((err = hal_io_read(core, CSPRNG_ADDR_RANDOM, (last ? temp : &buf[i]), 4)) != HAL_OK) return err; if (last) |