Skip to content

Commit

Permalink
ipl3: add support for iQue hardware RNG
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Dec 17, 2023
1 parent 64a380d commit 51e46ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions boot/ipl3.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ void stage1(void)
// in-use by save state emulation, so we shouldn't access it anyway.
if (memsize == 0x800000)
memsize = 0x7C0000;

// iQue has a hardware RNG. Use that to fetch 32 bits of entropy
uint32_t rng = 0;
for (int i=0;i<32;i++)
rng = (rng << 1) | (*MI_IQUE_RNG & 1);
entropy_add(rng);
} else {
// On warm boots,
int chip_id = 0;
Expand Down
1 change: 1 addition & 0 deletions boot/minidragon.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ typedef uint64_t u_uint64_t __attribute__((aligned(1)));
#define MI_WMODE_CLEAR_UPPER_MODE 0x1000
#define MI_VERSION ((volatile uint32_t*)0xA4300004)
#define MI_INTERRUPT ((volatile uint32_t*)0xA4300008)
#define MI_IQUE_RNG ((volatile uint32_t*)0xA430002C)
#define MI_WINTERRUPT_CLR_SP 0x0001
#define MI_WINTERRUPT_SET_SP 0x0002
#define MI_WINTERRUPT_CLR_SI 0x0004
Expand Down

0 comments on commit 51e46ae

Please sign in to comment.