Software APIs
sw
device
silicon_creator
rom_ext
e2e
lockdown
otp_creator_lockdown.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/base/status.h"
6
#include "
sw/device/lib/dif/dif_otp_ctrl.h
"
7
#include "
sw/device/lib/runtime/log.h
"
8
#include "
sw/device/lib/testing/test_framework/ottf_main.h
"
9
10
#include "
hw/top_earlgrey/sw/autogen/top_earlgrey.h
"
11
12
OTTF_DEFINE_TEST_CONFIG();
13
14
dif_otp_ctrl_t otp;
15
16
status_t
test_otp_creator_lockdown(
void
) {
17
uint32_t value;
18
LOG_INFO
(
"OTP OwnerSwCfg:"
);
19
TRY(
dif_otp_ctrl_read_blocking
(&otp,
kDifOtpCtrlPartitionOwnerSwCfg
, 0,
20
&value,
sizeof
(value)));
21
LOG_INFO
(
"OTP OwnerSwCfg word 0 = %x"
, value);
22
23
// If the creator partition has been locked down, this read should cause a
24
// fault.
25
LOG_INFO
(
"OTP CreatorSwCfg:"
);
26
TRY(
dif_otp_ctrl_read_blocking
(&otp,
kDifOtpCtrlPartitionCreatorSwCfg
, 0,
27
&value,
sizeof
(value)));
28
LOG_INFO
(
"OTP CreatorSwCfg word 0 = %x"
, value);
29
30
return
OK_STATUS();
31
}
32
33
bool
test_main
(
void
) {
34
CHECK_DIF_OK(dif_otp_ctrl_init(
35
mmio_region_from_addr
(
TOP_EARLGREY_OTP_CTRL_CORE_BASE_ADDR
), &otp));
36
37
// Since the ePMP locks down the OTP register space, we cannot call
38
// dif_otp_ctrl_configure here.
39
40
status_t
sts = test_otp_creator_lockdown();
41
if
(status_err(sts)) {
42
LOG_ERROR
(
"otp_creator_lockdown: %r"
, sts);
43
}
44
return
status_ok(sts);
45
}
Return to
OpenTitan Documentation