Skip to content

Commit

Permalink
[sw,rnd] Fix polling loop for RND_DATA_VALID
Browse files Browse the repository at this point in the history
https://opentitan.org/book/hw/ip/rv_core_ibex/doc/registers.html#rnd_status

According to the register doc, the `RND_DATA_VALID` is only one bit at bit 0.
Testing against full 32-bits might make us exit the waiting loop before the
data actually becomes ready.

Change-Id: I1127684e1b0e93612e76ff3885cfb62d441ee172
Signed-off-by: Yi-Hsuan Deng <[email protected]>
(cherry picked from commit 4b8a39e)
  • Loading branch information
sasdf authored and timothytrippel committed Dec 14, 2024
1 parent 96962e4 commit a7168f5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sw/device/silicon_creator/lib/drivers/rnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
enum {
kBaseEntropySrc = TOP_EARLGREY_ENTROPY_SRC_BASE_ADDR,
kBaseIbex = TOP_EARLGREY_RV_CORE_IBEX_CFG_BASE_ADDR,
kIbexRndStatusReg = kBaseIbex + RV_CORE_IBEX_RND_STATUS_REG_OFFSET,

// This covers the health threshold registers which are contiguous. The alert
// threshold register is not included here.
Expand Down Expand Up @@ -112,7 +113,7 @@ uint32_t rnd_uint32(void) {
kHardenedBoolTrue) {
// When bit-0 is clear an EDN request for new data for RND_DATA is
// pending.
while (!abs_mmio_read32(kBaseIbex + RV_CORE_IBEX_RND_STATUS_REG_OFFSET)) {
while (!(abs_mmio_read32(kIbexRndStatusReg) & 1)) {
}
}
uint32_t mcycle;
Expand Down

0 comments on commit a7168f5

Please sign in to comment.