13 #include "sw/device/lib/testing/test_framework/check.h"
14 #include "sw/device/lib/testing/test_framework/ottf_isrs.h"
15 #include "sw/device/lib/testing/test_framework/ottf_macros.h"
17 #include "sw/device/silicon_creator/lib/epmp_state.h"
21 OTTF_DEFINE_TEST_CONFIG();
23 static dif_sram_ctrl_t sram_ctrl;
34 static
void sram_function_test(
void) {
36 asm(
"auipc %[pc], 0;" : [pc]
"=r"(pc));
37 LOG_INFO(
"PC: %p, SRAM: [%p, %p)", pc, kSramStart, kSramEnd);
38 CHECK(pc >= kSramStart && pc < kSramEnd,
"PC is outside the main SRAM");
43 extern const char kSramRetNegTestReturn[];
45 void ottf_exception_handler(uint32_t *exc_info) {
54 case kIbexExcInstrAccessFault:
55 LOG_INFO(
"Detected instruction access fault");
56 *mepc_stack_addr = (uintptr_t)kSramRetNegTestReturn;
59 LOG_FATAL(
"Unexpected exception id = 0x%x", exception);
64 static void sram_ret_neg_test(
void) {
65 memset((
void *)kSramRetStart, 0,
sizeof(uint32_t));
66 ((void (*)(void))kSramRetStart)();
67 CHECK(
false,
"Should not be here");
72 CHECK_DIF_OK(dif_sram_ctrl_init(
82 CHECK((pmpcfg1 & 0xff000000) == 0,
83 "expected PMPCFG1 to be unconfigured before changing it");
86 (kEpmpModeNapot | kEpmpPermLockedReadWriteExecute) << 24);
102 CHECK_DIF_OK(exec_enabled);
103 sram_function_test();