Skip to content

Commit

Permalink
[nv_counter_testutils] Port to DT
Browse files Browse the repository at this point in the history
Signed-off-by: Amaury Pouly <[email protected]>
  • Loading branch information
pamaury committed Nov 22, 2024
1 parent f8cae9a commit 085a520
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sw/device/lib/testing/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ cc_library(
target_compatible_with = [OPENTITAN_CPU],
deps = [
":flash_ctrl_testutils",
"//hw/top:devicetables",
"//hw/top:flash_ctrl_c_regs",
"//hw/top_earlgrey/sw/autogen:top_earlgrey",
"//sw/device/lib/dif:flash_ctrl",
"//sw/device/lib/testing/test_framework:check",
],
Expand Down
20 changes: 10 additions & 10 deletions sw/device/lib/testing/nv_counter_testutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include <stdbool.h>
#include <stdint.h>

#include "devicetables.h"
#include "sw/device/lib/dif/dif_flash_ctrl.h"
#include "sw/device/lib/testing/flash_ctrl_testutils.h"
#include "sw/device/lib/testing/test_framework/check.h"

#include "flash_ctrl_regs.h" // Generated.
#include "hw/top_earlgrey/sw/autogen/top_earlgrey.h"

enum {
kNonVolatileCounterFlashWords = 256,
Expand Down Expand Up @@ -82,11 +82,11 @@ status_t flash_ctrl_testutils_counter_set_at_least(
return OK_STATUS();
}
uint32_t new_val[FLASH_CTRL_PARAM_BYTES_PER_WORD / sizeof(uint32_t)] = {0, 0};
return flash_ctrl_testutils_write(flash_state,
(uint32_t)&kNvCounters[counter][val - 1] -
TOP_EARLGREY_FLASH_CTRL_MEM_BASE_ADDR,
0, new_val, kDifFlashCtrlPartitionTypeData,
ARRAYSIZE(new_val));
uint32_t flash_mem_base =
dt_flash_ctrl_reg_block(&kDtFlashCtrl[0], kDtFlashCtrlRegBlockMem);
return flash_ctrl_testutils_write(
flash_state, (uint32_t)&kNvCounters[counter][val - 1] - flash_mem_base, 0,
new_val, kDifFlashCtrlPartitionTypeData, ARRAYSIZE(new_val));
}

// At the beginning of the simulation (Verilator, VCS,etc.),
Expand All @@ -99,12 +99,12 @@ status_t flash_ctrl_testutils_counter_init_zero(
dif_flash_ctrl_state_t *flash_state, size_t counter) {
uint32_t new_val[FLASH_CTRL_PARAM_BYTES_PER_WORD / sizeof(uint32_t)] = {0xaa,
0xbb};
uint32_t flash_mem_base =
dt_flash_ctrl_reg_block(&kDtFlashCtrl[0], kDtFlashCtrlRegBlockMem);
for (int ii = 0; ii < kNonVolatileCounterFlashWords; ii++) {
TRY(flash_ctrl_testutils_erase_and_write_page(
flash_state,
(uint32_t)&kNvCounters[counter][ii] -
TOP_EARLGREY_FLASH_CTRL_MEM_BASE_ADDR,
0, new_val, kDifFlashCtrlPartitionTypeData, ARRAYSIZE(new_val)));
flash_state, (uint32_t)&kNvCounters[counter][ii] - flash_mem_base, 0,
new_val, kDifFlashCtrlPartitionTypeData, ARRAYSIZE(new_val)));
}
return OK_STATUS();
}

0 comments on commit 085a520

Please sign in to comment.