[sw, sram_ctrl_testutils] Fix naming inconsistencies (minor tidy-up)
Signed-off-by: Silvestrs Timofejevs <silvestrst@lowrisc.org>
diff --git a/sw/device/lib/testing/sram_ctrl_testutils.c b/sw/device/lib/testing/sram_ctrl_testutils.c
index 48a0536..037ae12 100644
--- a/sw/device/lib/testing/sram_ctrl_testutils.c
+++ b/sw/device/lib/testing/sram_ctrl_testutils.c
@@ -11,9 +11,9 @@
#include "sw/device/lib/testing/check.h"
void sram_ctrl_testutils_write(uintptr_t address,
- const sram_ctrl_data_t *data) {
+ const sram_ctrl_testutils_data_t *data) {
mmio_region_t region = mmio_region_from_addr(address);
- for (size_t index = 0; index < SRAM_CTRL_DATA_NUM_WORDS; ++index) {
+ for (size_t index = 0; index < SRAM_CTRL_TESTUTILS_DATA_NUM_WORDS; ++index) {
mmio_region_write32(region, index, data->words[index]);
}
}
@@ -25,9 +25,10 @@
* Caller can request to check for equality or inequality through `eq`.
*/
static bool read_from_ram_check(uintptr_t address,
- const sram_ctrl_data_t *expected, bool eq) {
+ const sram_ctrl_testutils_data_t *expected,
+ bool eq) {
mmio_region_t region = mmio_region_from_addr(address);
- for (size_t index = 0; index < SRAM_CTRL_DATA_NUM_WORDS; ++index) {
+ for (size_t index = 0; index < SRAM_CTRL_TESTUTILS_DATA_NUM_WORDS; ++index) {
uint32_t read_word = mmio_region_read32(region, index);
if ((read_word == expected->words[index]) != eq) {
LOG_INFO("READ_WORD[%x], CONTROL_WORD[%x], INDEX = %d", read_word,
@@ -40,8 +41,8 @@
return true;
}
-bool sram_ctrl_testutils_read_check_eq(uintptr_t address,
- const sram_ctrl_data_t *expected) {
+bool sram_ctrl_testutils_read_check_eq(
+ uintptr_t address, const sram_ctrl_testutils_data_t *expected) {
if (!read_from_ram_check(address, expected, true)) {
LOG_INFO("Equality check failure");
return false;
@@ -50,8 +51,8 @@
return true;
}
-bool sram_ctrl_testutils_read_check_neq(uintptr_t address,
- const sram_ctrl_data_t *expected) {
+bool sram_ctrl_testutils_read_check_neq(
+ uintptr_t address, const sram_ctrl_testutils_data_t *expected) {
if (!read_from_ram_check(address, expected, false)) {
LOG_INFO("Inequality check failure");
return false;
diff --git a/sw/device/lib/testing/sram_ctrl_testutils.h b/sw/device/lib/testing/sram_ctrl_testutils.h
index 8461a8e..851770e 100644
--- a/sw/device/lib/testing/sram_ctrl_testutils.h
+++ b/sw/device/lib/testing/sram_ctrl_testutils.h
@@ -11,34 +11,40 @@
#include "sw/device/lib/dif/dif_sram_ctrl.h"
/**
+ * Test buffer size in words and bytes.
+ */
+#define SRAM_CTRL_TESTUTILS_DATA_NUM_WORDS 4
+#define SRAM_CTRL_TESTUTILS_DATA_NUM_BYTES \
+ (SRAM_CTRL_TESTUTILS_DATA_NUM_WORDS * sizeof(uint32_t))
+
+/**
* A typed representation of the test data.
*/
-#define SRAM_CTRL_DATA_NUM_WORDS 4
-#define SRAM_CTRL_DATA_NUM_BYTES 128
-typedef struct sram_ctrl_data {
- uint32_t words[SRAM_CTRL_DATA_NUM_WORDS];
-} sram_ctrl_data_t;
+typedef struct sram_ctrl_testutils_data {
+ uint32_t words[SRAM_CTRL_TESTUTILS_DATA_NUM_WORDS];
+} sram_ctrl_testutils_data_t;
/**
* Writes `data` at the `address` in RAM.
*/
-void sram_ctrl_testutils_write(uintptr_t address, const sram_ctrl_data_t *data);
+void sram_ctrl_testutils_write(uintptr_t address,
+ const sram_ctrl_testutils_data_t *data);
/**
* Reads data from `address` in SRAM and compares against `expected`.
*
* The data is checked for equality.
*/
-bool sram_ctrl_testutils_read_check_eq(uintptr_t address,
- const sram_ctrl_data_t *expected);
+bool sram_ctrl_testutils_read_check_eq(
+ uintptr_t address, const sram_ctrl_testutils_data_t *expected);
/**
* Reads data from `address` in SRAM and compares against `expected`.
*
* The data is checked for inequality.
*/
-bool sram_ctrl_testutils_read_check_neq(uintptr_t address,
- const sram_ctrl_data_t *expected);
+bool sram_ctrl_testutils_read_check_neq(
+ uintptr_t address, const sram_ctrl_testutils_data_t *expected);
/**
* Triggers the SRAM scrambling operation.
diff --git a/sw/device/tests/sram_ctrl_execution_test_ret.c b/sw/device/tests/sram_ctrl_execution_test_ret.c
index c34f876..3e4e436 100644
--- a/sw/device/tests/sram_ctrl_execution_test_ret.c
+++ b/sw/device/tests/sram_ctrl_execution_test_ret.c
@@ -93,7 +93,7 @@
* https://github.com/riscv-non-isa/riscv-asm-manual/blob/master/riscv-asm.md
*/
static void sram_execution_test(void) {
- memset((void *)kRetRamStartAddr, 0, SRAM_CTRL_DATA_NUM_BYTES);
+ memset((void *)kRetRamStartAddr, 0, SRAM_CTRL_TESTUTILS_DATA_NUM_BYTES);
// Map the function pointer onto the instruction buffer.
sram_ctrl_instruction_fault_function_t instruction_access_fault_func =
diff --git a/sw/device/tests/sram_ctrl_scrambled_access_test.c b/sw/device/tests/sram_ctrl_scrambled_access_test.c
index 5517a08..c9030de 100644
--- a/sw/device/tests/sram_ctrl_scrambled_access_test.c
+++ b/sw/device/tests/sram_ctrl_scrambled_access_test.c
@@ -27,7 +27,7 @@
/**
* First test pattern to be written and read from SRAM.
*/
-static const sram_ctrl_data_t kRamTestPattern1 = {
+static const sram_ctrl_testutils_data_t kRamTestPattern1 = {
.words =
{
0xA5A5A5A5,
@@ -40,7 +40,7 @@
/**
* Second test pattern to be written and read from SRAM.
*/
-static const sram_ctrl_data_t kRamTestPattern2 = {
+static const sram_ctrl_testutils_data_t kRamTestPattern2 = {
.words =
{
0x5A5A5A5A,