From 250d08b938dee4dbf80da0c35b6aa8720da3fd50 Mon Sep 17 00:00:00 2001 From: Wojciech Sipak Date: Wed, 8 Jan 2025 13:58:43 +0100 Subject: [PATCH] bring back pmp test --- testbench/tests/pmp/main.c | 313 +++++++++++++++---------------------- 1 file changed, 124 insertions(+), 189 deletions(-) diff --git a/testbench/tests/pmp/main.c b/testbench/tests/pmp/main.c index 2a88f2032c7..98269c9eb34 100644 --- a/testbench/tests/pmp/main.c +++ b/testbench/tests/pmp/main.c @@ -21,7 +21,6 @@ #include "veer.h" #include "fault.h" #include "pmp.h" -#include "random_data.h" #ifndef RV_SMEPMP #define RV_SMEPMP 0 @@ -150,47 +149,6 @@ int trap_handler (const struct fault* fault) { #define ADDR2PMP(x) ((((uint32_t)(x)) & 3) ? ((((uint32_t)(x)) >> 2) + 1) : \ (((uint32_t)(x)) >> 2)) -uint32_t legalize_address(uint32_t address, uint32_t cfg) { - uint32_t area_end = ((uint32_t)&_area) + 0x40; - - // if ((cfg & PMP_NA4) == PMP_NA4) { - // if ((address < (uint32_t)&_stack_hi && address > (uint32_t)&_stack_lo) - // |(address < (uint32_t)&_text && address > (uint32_t)&_text_end) - // |(address < (uint32_t)&_data && address > (uint32_t)&_data_end) - // |(address < (uint32_t)&_area && address > area_end) - // ) { - // address >>= 16; - // } - // } else if ((cfg & PMP_NAPOT) == PMP_NAPOT) { - // } - address >>= 8; - address &= ~(1<<3); - address |= 3; - return (address); -} - -uint32_t legalize_config(uint32_t config) { - /* Leave only A, X and R fields as any combination of them is legal and - * does not influence PMPADDR access. Setting L would interfere with the - * test. - */ - // temporarily enforce NA4 - if ((config & PMP_NAPOT) == PMP_NAPOT) { - config &= ~(PMP_NAPOT); - config |= PMP_NA4; - } - while((config & (PMP_NAPOT | PMP_NA4 | PMP_TOR) == 0) && config != 0) { - // if not enabled, shift right until it's a valid enabled region. - // if it's 0, give up. - config >>= 1; - } - config &= ~PMP_LOCK; -#if !(RV_SMEPMP) - -#endif - return config; -} - // Set mstatus MPRV #define set_mprv(x) { \ uint32_t mstatus; \ @@ -256,7 +214,6 @@ int main () { // ....................................................................... struct pmp_entry_s entry; - struct pmp_entry_s random_entry; int tid = 0; int failed = 0; @@ -423,167 +380,145 @@ int main () { // ................................ // Do the tests - // use regions 6..15 for random data - int region_for_rand_data = 6; - for (size_t i=0; i