Software APIs
exit_test_unlocked_bootstrap.c
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
11 #include "sw/device/lib/testing/test_framework/check.h"
13 #include "sw/device/lib/testing/test_framework/status.h"
14 
16 #include "otp_ctrl_regs.h"
17 
18 OTTF_DEFINE_TEST_CONFIG();
19 
20 bool test_main(void) {
21  dif_lc_ctrl_t lc_ctrl;
22  CHECK_DIF_OK(dif_lc_ctrl_init(
24 
25  dif_lc_ctrl_state_t state;
26  CHECK_DIF_OK(dif_lc_ctrl_get_state(&lc_ctrl, &state));
27 
28  uint32_t rom_en = abs_mmio_read32(
29  TOP_EARLGREY_OTP_CTRL_CORE_BASE_ADDR + OTP_CTRL_SW_CFG_WINDOW_REG_OFFSET +
30  OTP_CTRL_PARAM_CREATOR_SW_CFG_ROM_EXEC_EN_OFFSET);
31 
32  if (rom_en == 0) {
33  // The test should never reach here
34  CHECK(false,
35  "Unexpected branch - code not expected to execute since ROM "
36  "execution is disabled");
37  } else if (state == kDifLcCtrlStateProd && rom_en > 0) {
38  // The test environment is waiting for this message
39  LOG_INFO("ROM and flash execution successful");
40  return true;
41  }
42 
43  LOG_INFO("Current state is 0x%x, rom_en is 0x%x", state, rom_en);
44  return false;
45 }