Software APIs
epmp_rlb_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 
6 #include "sw/device/lib/base/status.h"
8 #include "sw/device/lib/testing/test_framework/check.h"
10 #include "sw/device/silicon_creator/lib/dbg_print.h"
11 
13 
14 OTTF_DEFINE_TEST_CONFIG();
15 
16 bool test_main(void) {
17  // Try to overwrite ePMP entry 0 (ie: the otp lockout) by clearing its config
18  // bits.
19  CSR_CLEAR_BITS(CSR_REG_PMPCFG0, 0xff);
20  CSR_WRITE(CSR_REG_PMPADDR0, 0);
21 
22  // Read back ePMP entry 0 and make sure it hasn't changed to zero.
23  uint32_t pmpcfg0, pmpaddr0;
24  CSR_READ(CSR_REG_PMPCFG0, &pmpcfg0);
25  CSR_READ(CSR_REG_PMPADDR0, &pmpaddr0);
26  CHECK((pmpcfg0 & 0xFF) != 0);
27  CHECK(pmpaddr0 != 0);
28  return true;
29 }