[rstmgr] refactored testutil to omit uneccesary args
this should make it comptabile with the driver in silicon_creator/lib
Signed-off-by: Drew Macrae <drewmacrae@google.com>
diff --git a/sw/device/lib/testing/rstmgr_testutils.c b/sw/device/lib/testing/rstmgr_testutils.c
index 8305197..a34e545 100644
--- a/sw/device/lib/testing/rstmgr_testutils.c
+++ b/sw/device/lib/testing/rstmgr_testutils.c
@@ -15,14 +15,14 @@
bool rstmgr_testutils_is_reset_info(const dif_rstmgr_t *rstmgr,
dif_rstmgr_reset_info_bitfield_t info) {
dif_rstmgr_reset_info_bitfield_t actual_info;
- rstmgr_testutils_reset_reason(rstmgr, &actual_info);
+ actual_info = rstmgr_testutils_reason_get();
return actual_info == info;
}
bool rstmgr_testutils_reset_info_any(const dif_rstmgr_t *rstmgr,
dif_rstmgr_reset_info_bitfield_t info) {
dif_rstmgr_reset_info_bitfield_t actual_info;
- rstmgr_testutils_reset_reason(rstmgr, &actual_info);
+ actual_info = rstmgr_testutils_reason_get();
return (actual_info & info) != 0;
}
@@ -53,7 +53,7 @@
void rstmgr_testutils_pre_reset(const dif_rstmgr_t *rstmgr) {
// Clear reset_info.
- rstmgr_testutils_reset_reason_clear(rstmgr);
+ rstmgr_testutils_reason_clear();
// Enable alert and cpu dump capture, even if the test doesn't read it.
CHECK_DIF_OK(dif_rstmgr_alert_info_set_enabled(rstmgr, kDifToggleEnabled));
@@ -69,7 +69,7 @@
size_t cpu_dump_size) {
// Read and compare reset_info.
dif_rstmgr_reset_info_bitfield_t actual_reset_info;
- rstmgr_testutils_reset_reason(rstmgr, &actual_reset_info);
+ actual_reset_info = rstmgr_testutils_reason_get();
CHECK(expected_reset_info == actual_reset_info,
"Unexpected reset_info CSR mismatch, expected 0x%x, got 0x%x",
expected_reset_info, actual_reset_info);
@@ -83,11 +83,10 @@
}
}
-void rstmgr_testutils_reset_reason(const dif_rstmgr_t *rstmgr,
- dif_rstmgr_reset_info_bitfield_t *reason) {
- *reason = retention_sram_get()->reset_reasons;
+dif_rstmgr_reset_info_bitfield_t rstmgr_testutils_reason_get() {
+ return retention_sram_get()->reset_reasons;
}
-void rstmgr_testutils_reset_reason_clear(const dif_rstmgr_t *rstmgr) {
+void rstmgr_testutils_reason_clear() {
retention_sram_get()->reset_reasons = 0;
}
diff --git a/sw/device/lib/testing/rstmgr_testutils.h b/sw/device/lib/testing/rstmgr_testutils.h
index 6c0e5d9..7975a9c 100644
--- a/sw/device/lib/testing/rstmgr_testutils.h
+++ b/sw/device/lib/testing/rstmgr_testutils.h
@@ -96,17 +96,13 @@
/**
* Gets the reason for a reset in retention SRAM.
*
- * @param rstmgr A reset manager handle
- * @param reason pointer to write the reset_reason
+ * @returns reset reason
*/
-void rstmgr_testutils_reset_reason(const dif_rstmgr_t *handle,
- dif_rstmgr_reset_info_bitfield_t *reason);
+dif_rstmgr_reset_info_bitfield_t rstmgr_testutils_reason_get(void);
/**
* Clears the reset information in Retention SRAM
- *
- * @param handle A Reset Manager handle.
*/
-void rstmgr_testutils_reset_reason_clear(const dif_rstmgr_t *handle);
+void rstmgr_testutils_reason_clear(void);
#endif // OPENTITAN_SW_DEVICE_LIB_TESTING_RSTMGR_TESTUTILS_H_
diff --git a/sw/device/silicon_creator/lib/drivers/keymgr_functest.c b/sw/device/silicon_creator/lib/drivers/keymgr_functest.c
index c653593..791babb 100644
--- a/sw/device/silicon_creator/lib/drivers/keymgr_functest.c
+++ b/sw/device/silicon_creator/lib/drivers/keymgr_functest.c
@@ -227,7 +227,7 @@
CHECK_DIF_OK(dif_rstmgr_init(
mmio_region_from_addr(TOP_EARLGREY_RSTMGR_AON_BASE_ADDR), &rstmgr));
- rstmgr_testutils_reset_reason(&rstmgr, &info);
+ info = rstmgr_testutils_reason_get();
dif_otp_ctrl_t otp;
CHECK_DIF_OK(dif_otp_ctrl_init(
@@ -242,7 +242,7 @@
check_lock_otp_partition(&otp);
// Issue and wait for reset.
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rstmgr_testutils_reason_clear();
CHECK_DIF_OK(dif_rstmgr_software_device_reset(&rstmgr));
wait_for_interrupt();
} else if (info == kDifRstmgrResetInfoSw) {
diff --git a/sw/device/silicon_creator/lib/drivers/rstmgr_functest.c b/sw/device/silicon_creator/lib/drivers/rstmgr_functest.c
index 0007cf2..0d15366 100644
--- a/sw/device/silicon_creator/lib/drivers/rstmgr_functest.c
+++ b/sw/device/silicon_creator/lib/drivers/rstmgr_functest.c
@@ -6,6 +6,7 @@
#include <stdint.h>
#include "sw/device/lib/runtime/log.h"
+#include "sw/device/lib/testing/rstmgr_testutils.h"
#include "sw/device/lib/testing/test_framework/check.h"
#include "sw/device/silicon_creator/lib/drivers/retention_sram.h"
#include "sw/device/silicon_creator/lib/drivers/rstmgr.h"
@@ -25,8 +26,8 @@
bool test_main(void) {
// Read and clear reset reason.
- uint32_t reason = rstmgr_reason_get();
- rstmgr_reason_clear(reason);
+ uint32_t reason = rstmgr_testutils_reason_get();
+ rstmgr_testutils_reason_clear();
LOG_INFO("Reset reason: 0x%08x", reason);
// This test assumes that reset reason is unique.
CHECK(bitfield_popcount32(reason) == 1, "Expected exactly 1 reset reason.");
diff --git a/sw/device/tests/aes_sideload_test.c b/sw/device/tests/aes_sideload_test.c
index 9417873..cda0442 100644
--- a/sw/device/tests/aes_sideload_test.c
+++ b/sw/device/tests/aes_sideload_test.c
@@ -254,7 +254,7 @@
CHECK_DIF_OK(dif_rstmgr_init(
mmio_region_from_addr(TOP_EARLGREY_RSTMGR_AON_BASE_ADDR), &rstmgr));
- rstmgr_testutils_reset_reason(&rstmgr, &info);
+ info = rstmgr_testutils_reason_get();
init_flash();
@@ -269,7 +269,7 @@
otp_ctrl_testutils_lock_partition(&otp, kDifOtpCtrlPartitionSecret2, 0);
// Reboot device.
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rstmgr_testutils_reason_clear();
CHECK_DIF_OK(dif_rstmgr_software_device_reset(&rstmgr));
// Wait here until device reset.
diff --git a/sw/device/tests/aon_timer_wdog_bite_reset_test.c b/sw/device/tests/aon_timer_wdog_bite_reset_test.c
index c643951..609b722 100644
--- a/sw/device/tests/aon_timer_wdog_bite_reset_test.c
+++ b/sw/device/tests/aon_timer_wdog_bite_reset_test.c
@@ -110,8 +110,8 @@
// Check if there was a HW reset caused by the wdog bite.
dif_rstmgr_reset_info_bitfield_t rst_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rst_info);
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rst_info = rstmgr_testutils_reason_get();
+ rstmgr_testutils_reason_clear();
CHECK(rst_info == kDifRstmgrResetInfoPor ||
rst_info == kDifRstmgrResetInfoWatchdog ||
diff --git a/sw/device/tests/aon_timer_wdog_lc_escalate_test.c b/sw/device/tests/aon_timer_wdog_lc_escalate_test.c
index 2094b1b..a8e4eed 100644
--- a/sw/device/tests/aon_timer_wdog_lc_escalate_test.c
+++ b/sw/device/tests/aon_timer_wdog_lc_escalate_test.c
@@ -235,8 +235,8 @@
// Check if there was a HW reset caused by the escalation.
dif_rstmgr_reset_info_bitfield_t rst_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rst_info);
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rst_info = rstmgr_testutils_reason_get();
+ rstmgr_testutils_reason_clear();
CHECK(rst_info == kDifRstmgrResetInfoPor ||
rst_info == kDifRstmgrResetInfoEscalation,
diff --git a/sw/device/tests/clkmgr_off_peri_test.c b/sw/device/tests/clkmgr_off_peri_test.c
index 2e21ed4..b5fc1f0 100644
--- a/sw/device/tests/clkmgr_off_peri_test.c
+++ b/sw/device/tests/clkmgr_off_peri_test.c
@@ -100,7 +100,7 @@
return true;
} else {
dif_rstmgr_reset_info_bitfield_t reset_info;
- rstmgr_testutils_reset_reason(&rstmgr, &reset_info);
+ reset_info = rstmgr_testutils_reason_get();
LOG_ERROR("Unexpected reset_info 0x%x", reset_info);
}
return false;
diff --git a/sw/device/tests/clkmgr_off_trans_impl.c b/sw/device/tests/clkmgr_off_trans_impl.c
index 0429a41..b0af71b 100644
--- a/sw/device/tests/clkmgr_off_trans_impl.c
+++ b/sw/device/tests/clkmgr_off_trans_impl.c
@@ -188,7 +188,7 @@
return true;
} else {
dif_rstmgr_reset_info_bitfield_t reset_info;
- rstmgr_testutils_reset_reason(&rstmgr, &reset_info);
+ reset_info = rstmgr_testutils_reason_get();
LOG_ERROR("Unexpected reset_info 0x%x", reset_info);
}
return false;
diff --git a/sw/device/tests/flash_ctrl_idle_low_power_test.c b/sw/device/tests/flash_ctrl_idle_low_power_test.c
index 871522f..3b79d4d 100644
--- a/sw/device/tests/flash_ctrl_idle_low_power_test.c
+++ b/sw/device/tests/flash_ctrl_idle_low_power_test.c
@@ -96,7 +96,7 @@
kDifToggleEnabled));
dif_rstmgr_reset_info_bitfield_t rstmgr_reset_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rstmgr_reset_info);
+ rstmgr_reset_info = rstmgr_testutils_reason_get();
uint32_t address = flash_ctrl_testutils_data_region_setup(
&flash, kRegionBasePageIndex, kFlashDataRegion, kRegionSize);
@@ -144,7 +144,7 @@
// Check the erase operation completed successfully.
CHECK_DIF_OK(dif_aon_timer_watchdog_stop(&aon));
- rstmgr_testutils_reset_reason(&rstmgr, &rstmgr_reset_info);
+ rstmgr_reset_info = rstmgr_testutils_reason_get();
CHECK(rstmgr_reset_info == kDifRstmgrResetInfoPor);
CHECK(peripheral_serviced == kTopEarlgreyPlicPeripheralAonTimerAon);
CHECK(irq_serviced == kDifAonTimerIrqWdogTimerBark);
@@ -158,7 +158,7 @@
memset(expected_data, 0xff, sizeof(expected_data));
CHECK_ARRAYS_EQ(readback_data, expected_data, kNumWords);
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rstmgr_testutils_reason_clear();
} else {
LOG_ERROR("Unexepected reset type detected. Reset info = %0x",
rstmgr_reset_info);
diff --git a/sw/device/tests/pwrmgr_wdog_reset_reqs_test.c b/sw/device/tests/pwrmgr_wdog_reset_reqs_test.c
index 2edc7f2..8f024e4 100644
--- a/sw/device/tests/pwrmgr_wdog_reset_reqs_test.c
+++ b/sw/device/tests/pwrmgr_wdog_reset_reqs_test.c
@@ -92,8 +92,8 @@
// Check if there was a HW reset caused by the wdog bite.
dif_rstmgr_reset_info_bitfield_t rst_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rst_info);
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rst_info = rstmgr_testutils_reason_get();
+ rstmgr_testutils_reason_clear();
CHECK(rst_info == kDifRstmgrResetInfoPor ||
rst_info == kDifRstmgrResetInfoWatchdog,
diff --git a/sw/device/tests/rstmgr_alert_info_test.c b/sw/device/tests/rstmgr_alert_info_test.c
index 09d5917..8c27ee8 100644
--- a/sw/device/tests/rstmgr_alert_info_test.c
+++ b/sw/device/tests/rstmgr_alert_info_test.c
@@ -670,8 +670,8 @@
// Check if there was a HW reset caused by the escalation.
dif_rstmgr_reset_info_bitfield_t rst_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rst_info);
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rst_info = rstmgr_testutils_reason_get();
+ rstmgr_testutils_reason_clear();
LOG_INFO("reset info = 0x%02X", rst_info);
global_alert_called = 0;
diff --git a/sw/device/tests/rstmgr_cpu_info_test.c b/sw/device/tests/rstmgr_cpu_info_test.c
index 48f3977..befc8ff 100644
--- a/sw/device/tests/rstmgr_cpu_info_test.c
+++ b/sw/device/tests/rstmgr_cpu_info_test.c
@@ -158,7 +158,7 @@
/*he_en*/ false);
dif_rstmgr_reset_info_bitfield_t rst_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rst_info);
+ rst_info = rstmgr_testutils_reason_get();
if (rst_info == kDifRstmgrResetInfoPor) {
LOG_INFO("Booting for the first time, setting wdog");
diff --git a/sw/device/tests/rstmgr_sw_req_test.c b/sw/device/tests/rstmgr_sw_req_test.c
index 1bc10ce..c274d8e 100644
--- a/sw/device/tests/rstmgr_sw_req_test.c
+++ b/sw/device/tests/rstmgr_sw_req_test.c
@@ -20,19 +20,19 @@
mmio_region_from_addr(TOP_EARLGREY_RSTMGR_AON_BASE_ADDR), &rstmgr));
dif_rstmgr_reset_info_bitfield_t reason;
- rstmgr_testutils_reset_reason(&rstmgr, &reason);
+ reason = rstmgr_testutils_reason_get();
// If POR, clear reason and request software reset
if (reason & kDifRstmgrResetInfoPor) {
LOG_INFO("POR encountered!");
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rstmgr_testutils_reason_clear();
CHECK_DIF_OK(dif_rstmgr_software_device_reset(&rstmgr));
// wait here until device reset
wait_for_interrupt();
} else if (reason == kDifRstmgrResetInfoSw) {
LOG_INFO("Software reset encountered!");
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rstmgr_testutils_reason_clear();
} else {
LOG_FATAL("Reset reason unexpected!");
test_status_set(kTestStatusFailed);
diff --git a/sw/device/tests/sim_dv/keymgr_key_derivation_test.c b/sw/device/tests/sim_dv/keymgr_key_derivation_test.c
index f8af126..9918d96 100644
--- a/sw/device/tests/sim_dv/keymgr_key_derivation_test.c
+++ b/sw/device/tests/sim_dv/keymgr_key_derivation_test.c
@@ -154,7 +154,7 @@
// Initialize pwrmgr
CHECK_DIF_OK(dif_rstmgr_init(
mmio_region_from_addr(TOP_EARLGREY_RSTMGR_AON_BASE_ADDR), &rstmgr));
- rstmgr_testutils_reset_reason(&rstmgr, &info);
+ info = rstmgr_testutils_reason_get();
// POR reset
if (info == kDifRstmgrResetInfoPor) {
@@ -170,7 +170,7 @@
otp_ctrl_testutils_lock_partition(&otp, kDifOtpCtrlPartitionSecret2, 0);
// reboot device
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rstmgr_testutils_reason_clear();
CHECK_DIF_OK(dif_rstmgr_software_device_reset(&rstmgr));
// wait here until device reset
diff --git a/sw/device/tests/sim_dv/pwrmgr_b2b_sleep_reset_test.c b/sw/device/tests/sim_dv/pwrmgr_b2b_sleep_reset_test.c
index 870315c..6a15975 100644
--- a/sw/device/tests/sim_dv/pwrmgr_b2b_sleep_reset_test.c
+++ b/sw/device/tests/sim_dv/pwrmgr_b2b_sleep_reset_test.c
@@ -159,8 +159,8 @@
// Read reset info before check
dif_rstmgr_reset_info_bitfield_t rst_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rst_info);
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rst_info = rstmgr_testutils_reason_get();
+ rstmgr_testutils_reason_clear();
LOG_INFO("reset info = 0x%02X", rst_info);
if (rst_info != kDifRstmgrResetInfoPor &&
diff --git a/sw/device/tests/sim_dv/pwrmgr_deep_sleep_all_reset_reqs_test.c b/sw/device/tests/sim_dv/pwrmgr_deep_sleep_all_reset_reqs_test.c
index 22dbae4..55d943d 100644
--- a/sw/device/tests/sim_dv/pwrmgr_deep_sleep_all_reset_reqs_test.c
+++ b/sw/device/tests/sim_dv/pwrmgr_deep_sleep_all_reset_reqs_test.c
@@ -462,8 +462,8 @@
// Check if there was a HW reset caused by expected cases.
dif_rstmgr_reset_info_bitfield_t rst_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rst_info);
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rst_info = rstmgr_testutils_reason_get();
+ rstmgr_testutils_reason_clear();
CHECK(rst_info == kDifRstmgrResetInfoPor ||
rst_info == kDifRstmgrResetInfoSysRstCtrl ||
diff --git a/sw/device/tests/sim_dv/pwrmgr_normal_sleep_all_reset_reqs_test.c b/sw/device/tests/sim_dv/pwrmgr_normal_sleep_all_reset_reqs_test.c
index 79a4b7b..ccbc692 100644
--- a/sw/device/tests/sim_dv/pwrmgr_normal_sleep_all_reset_reqs_test.c
+++ b/sw/device/tests/sim_dv/pwrmgr_normal_sleep_all_reset_reqs_test.c
@@ -519,8 +519,8 @@
// Check if there was a HW reset caused by expected cases
dif_rstmgr_reset_info_bitfield_t rst_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rst_info);
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rst_info = rstmgr_testutils_reason_get();
+ rstmgr_testutils_reason_clear();
CHECK(rst_info == kDifRstmgrResetInfoPor ||
rst_info == kDifRstmgrResetInfoSysRstCtrl ||
diff --git a/sw/device/tests/sim_dv/pwrmgr_random_sleep_all_reset_reqs_test.c b/sw/device/tests/sim_dv/pwrmgr_random_sleep_all_reset_reqs_test.c
index e23cfe4..a575689 100644
--- a/sw/device/tests/sim_dv/pwrmgr_random_sleep_all_reset_reqs_test.c
+++ b/sw/device/tests/sim_dv/pwrmgr_random_sleep_all_reset_reqs_test.c
@@ -520,8 +520,8 @@
// Check if there was a HW reset caused by expected cases
dif_rstmgr_reset_info_bitfield_t rst_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rst_info);
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rst_info = rstmgr_testutils_reason_get();
+ rstmgr_testutils_reason_clear();
CHECK(rst_info == kDifRstmgrResetInfoPor ||
rst_info == kDifRstmgrResetInfoSysRstCtrl ||
diff --git a/sw/device/tests/sim_dv/pwrmgr_sysrst_ctrl_test.c b/sw/device/tests/sim_dv/pwrmgr_sysrst_ctrl_test.c
index 5e8be16..adca35c 100644
--- a/sw/device/tests/sim_dv/pwrmgr_sysrst_ctrl_test.c
+++ b/sw/device/tests/sim_dv/pwrmgr_sysrst_ctrl_test.c
@@ -210,8 +210,8 @@
// Check if there was a HW reset caused by the wdog bite.
dif_rstmgr_reset_info_bitfield_t rst_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rst_info);
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rst_info = rstmgr_testutils_reason_get();
+ rstmgr_testutils_reason_clear();
CHECK(rst_info == kDifRstmgrResetInfoPor ||
rst_info == kDifRstmgrResetInfoWatchdog ||
diff --git a/sw/device/tests/sim_dv/rv_dm_ndm_reset_req.c b/sw/device/tests/sim_dv/rv_dm_ndm_reset_req.c
index cccf817..324f1c8 100644
--- a/sw/device/tests/sim_dv/rv_dm_ndm_reset_req.c
+++ b/sw/device/tests/sim_dv/rv_dm_ndm_reset_req.c
@@ -191,7 +191,7 @@
mmio_region_from_addr(TOP_EARLGREY_KEYMGR_BASE_ADDR), &keymgr));
if (rstmgr_testutils_is_reset_info(&rstmgr, kDifRstmgrResetInfoPor)) {
- rstmgr_testutils_reset_reason_clear(&rstmgr);
+ rstmgr_testutils_reason_clear();
// Write arbitrary value to each test register.
write_test_reg();
diff --git a/sw/device/tests/sim_dv/sysrst_ctrl_reset_test.c b/sw/device/tests/sim_dv/sysrst_ctrl_reset_test.c
index 5a7462b..be3f959 100644
--- a/sw/device/tests/sim_dv/sysrst_ctrl_reset_test.c
+++ b/sw/device/tests/sim_dv/sysrst_ctrl_reset_test.c
@@ -133,7 +133,7 @@
&sysrst_ctrl));
dif_rstmgr_reset_info_bitfield_t rstmgr_reset_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rstmgr_reset_info);
+ rstmgr_reset_info = rstmgr_testutils_reason_get();
dif_pinmux_t pinmux;
CHECK_DIF_OK(dif_pinmux_init(
diff --git a/sw/device/tests/sram_ctrl_sleep_sram_ret_contents_test.c b/sw/device/tests/sram_ctrl_sleep_sram_ret_contents_test.c
index 1bbbc88..eda098b 100644
--- a/sw/device/tests/sram_ctrl_sleep_sram_ret_contents_test.c
+++ b/sw/device/tests/sram_ctrl_sleep_sram_ret_contents_test.c
@@ -53,7 +53,7 @@
mmio_region_from_addr(TOP_EARLGREY_AON_TIMER_AON_BASE_ADDR), &aon_timer));
dif_rstmgr_reset_info_bitfield_t rstmgr_reset_info;
- rstmgr_testutils_reset_reason(&rstmgr, &rstmgr_reset_info);
+ rstmgr_reset_info = rstmgr_testutils_reason_get();
LOG_INFO("Reset info = %0x", rstmgr_reset_info);