Software APIs
rv_dm_lc_disabled.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/testing/lc_ctrl_testutils.h"
7 #include "sw/device/lib/testing/test_framework/check.h"
9 
11 
12 // This is an ad-hoc definition rather than DIF because we normally do not
13 // communicate with RV-DM from Ibex core, but use JTAG instead.
14 #define RV_DM_DATAADDR_0_REG_OFFSET 0x380
15 
16 enum {
17  kTestData = 0xdeadbeef,
18 };
19 
20 OTTF_DEFINE_TEST_CONFIG();
21 
22 static volatile bool access_exception_seen;
23 
24 void ottf_load_store_fault_handler(uint32_t *exc_info) {
25  access_exception_seen = true;
26 }
27 
28 status_t execute_test(bool debug_func) {
29  mmio_region_t region =
31 
32  // Attempt to write to RV-DM register and read.
33  access_exception_seen = false;
34  mmio_region_write32(region, RV_DM_DATAADDR_0_REG_OFFSET, kTestData);
35  CHECK(debug_func != access_exception_seen);
36 
37  access_exception_seen = false;
38  (void)mmio_region_read32(region, RV_DM_DATAADDR_0_REG_OFFSET);
39  CHECK(debug_func != access_exception_seen);
40 
41  return OK_STATUS();
42 }
43 
44 bool test_main(void) {
45  dif_lc_ctrl_t lc;
46  CHECK_DIF_OK(dif_lc_ctrl_init(
48 
49  bool debug_func = false;
50  CHECK_STATUS_OK(lc_ctrl_testutils_debug_func_enabled(&lc, &debug_func));
51 
52  return status_ok(execute_test(debug_func));
53 }