diff options
author | Andrew Waterman <andrew@sifive.com> | 2017-03-30 00:30:14 -0700 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2017-03-30 00:30:14 -0700 |
commit | f84441c926756579f2108f6e3ab17e54c24954ed (patch) | |
tree | 35a785047088e2878463197ecf368f4a705a0658 /benchmarks/pmp | |
parent | d5f7bd296f72c1a75a910aff6dd9c43f4365a188 (diff) | |
download | riscv-tests-f84441c926756579f2108f6e3ab17e54c24954ed.zip riscv-tests-f84441c926756579f2108f6e3ab17e54c24954ed.tar.gz riscv-tests-f84441c926756579f2108f6e3ab17e54c24954ed.tar.bz2 |
New PMP encoding
Diffstat (limited to 'benchmarks/pmp')
-rw-r--r-- | benchmarks/pmp/pmp.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/benchmarks/pmp/pmp.c b/benchmarks/pmp/pmp.c index 055ec79..9d07ed8 100644 --- a/benchmarks/pmp/pmp.c +++ b/benchmarks/pmp/pmp.c @@ -44,7 +44,7 @@ static void init_pt() #endif write_csr(sptbr, ((uintptr_t)l1pt >> RISCV_PGSHIFT) | (vm_choice * (SPTBR_MODE & ~(SPTBR_MODE<<1)))); - write_csr(pmpcfg0, (PMP_EN | PMP_NAPOT | PMP_R) << 16); + write_csr(pmpcfg0, (PMP_NAPOT | PMP_R) << 16); write_csr(pmpaddr2, -1); } @@ -65,10 +65,13 @@ typedef struct { INLINE int pmp_ok(pmpcfg_t p, uintptr_t addr, uintptr_t size) { - if (!(p.cfg & PMP_TOR)) { + if ((p.cfg & PMP_A) == 0) + return 1; + + if ((p.cfg & PMP_A) != PMP_TOR) { uintptr_t range = 1; - if (p.cfg & PMP_NAPOT) { + if ((p.cfg & PMP_A) == PMP_NAPOT) { range <<= 1; for (uintptr_t i = 1; i; i <<= 1) { if ((p.a1 & i) == 0) @@ -141,7 +144,7 @@ INLINE pmpcfg_t set_pmp(pmpcfg_t p) INLINE pmpcfg_t set_pmp_range(uintptr_t base, uintptr_t range) { pmpcfg_t p; - p.cfg = PMP_EN | PMP_TOR | PMP_M | PMP_R; + p.cfg = PMP_TOR | PMP_R; p.a0 = base >> PMP_SHIFT; p.a1 = (base + range) >> PMP_SHIFT; return set_pmp(p); @@ -150,7 +153,7 @@ INLINE pmpcfg_t set_pmp_range(uintptr_t base, uintptr_t range) INLINE pmpcfg_t set_pmp_napot(uintptr_t base, uintptr_t range) { pmpcfg_t p; - p.cfg = PMP_EN | PMP_M | PMP_R | (range > GRANULE ? PMP_NAPOT : 0); + p.cfg = PMP_R | (range > GRANULE ? PMP_NAPOT : PMP_NA4); p.a0 = 0; p.a1 = (base + (range/2 - 1)) >> PMP_SHIFT; return set_pmp(p); |