Software APIs
sw
device
tests
sim_dv
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
5
#include "
sw/device/lib/arch/device.h
"
6
#include "
sw/device/lib/base/abs_mmio.h
"
7
#include "
sw/device/lib/base/mmio.h
"
8
#include "
sw/device/lib/dif/dif_base.h
"
9
#include "
sw/device/lib/dif/dif_lc_ctrl.h
"
10
#include "
sw/device/lib/runtime/log.h
"
11
#include "sw/device/lib/testing/test_framework/check.h"
12
#include "
sw/device/lib/testing/test_framework/ottf_main.h
"
13
#include "sw/device/lib/testing/test_framework/status.h"
14
15
#include "
hw/top_earlgrey/sw/autogen/top_earlgrey.h
"
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(
23
mmio_region_from_addr
(
TOP_EARLGREY_LC_CTRL_REGS_BASE_ADDR
), &lc_ctrl));
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
}
Return to
OpenTitan Documentation