14 #include "csrng_regs.h"
36 alert_idx = CSRNG_ALERT_TEST_RECOV_ALERT_BIT;
39 alert_idx = CSRNG_ALERT_TEST_FATAL_ALERT_BIT;
46 mmio_region_write32(csrng->
base_addr, (ptrdiff_t)CSRNG_ALERT_TEST_REG_OFFSET,
59 *index_out = CSRNG_INTR_COMMON_CS_CMD_REQ_DONE_BIT;
62 *index_out = CSRNG_INTR_COMMON_CS_ENTROPY_REQ_BIT;
65 *index_out = CSRNG_INTR_COMMON_CS_HW_INST_EXC_BIT;
68 *index_out = CSRNG_INTR_COMMON_CS_FATAL_ERR_BIT;
87 if (csrng == NULL || type == NULL || irq < 0 ||
92 *type = irq_types[irq];
100 if (csrng == NULL || snapshot == NULL) {
104 *snapshot = mmio_region_read32(csrng->
base_addr,
105 (ptrdiff_t)CSRNG_INTR_STATE_REG_OFFSET);
117 mmio_region_write32(csrng->
base_addr, (ptrdiff_t)CSRNG_INTR_STATE_REG_OFFSET,
126 if (csrng == NULL || is_pending == NULL) {
131 if (!csrng_get_irq_bit_index(irq, &index)) {
135 uint32_t intr_state_reg = mmio_region_read32(
136 csrng->
base_addr, (ptrdiff_t)CSRNG_INTR_STATE_REG_OFFSET);
150 mmio_region_write32(csrng->
base_addr, (ptrdiff_t)CSRNG_INTR_STATE_REG_OFFSET,
164 if (!csrng_get_irq_bit_index(irq, &index)) {
170 mmio_region_write32(csrng->
base_addr, (ptrdiff_t)CSRNG_INTR_STATE_REG_OFFSET,
184 if (!csrng_get_irq_bit_index(irq, &index)) {
189 mmio_region_write32(csrng->
base_addr, (ptrdiff_t)CSRNG_INTR_TEST_REG_OFFSET,
199 if (csrng == NULL || state == NULL) {
204 if (!csrng_get_irq_bit_index(irq, &index)) {
208 uint32_t intr_enable_reg = mmio_region_read32(
209 csrng->
base_addr, (ptrdiff_t)CSRNG_INTR_ENABLE_REG_OFFSET);
226 if (!csrng_get_irq_bit_index(irq, &index)) {
230 uint32_t intr_enable_reg = mmio_region_read32(
231 csrng->
base_addr, (ptrdiff_t)CSRNG_INTR_ENABLE_REG_OFFSET);
235 mmio_region_write32(csrng->
base_addr, (ptrdiff_t)CSRNG_INTR_ENABLE_REG_OFFSET,
249 if (snapshot != NULL) {
250 *snapshot = mmio_region_read32(csrng->
base_addr,
251 (ptrdiff_t)CSRNG_INTR_ENABLE_REG_OFFSET);
255 mmio_region_write32(csrng->
base_addr, (ptrdiff_t)CSRNG_INTR_ENABLE_REG_OFFSET,
264 if (csrng == NULL || snapshot == NULL) {
268 mmio_region_write32(csrng->
base_addr, (ptrdiff_t)CSRNG_INTR_ENABLE_REG_OFFSET,