Software APIs
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"
9 
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:");
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:");
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(
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 }