aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2023-01-20 15:02:34 -0800
committerGitHub <noreply@github.com>2023-01-20 15:02:34 -0800
commit471d43a6e392d8aad6b6c6e3b5fc2464c32ca8d0 (patch)
tree2211c5f725c8c323bf76cee65c6258a641625f55
parenta3a663c1e4cf42f34c05537a8a4f5f4980fa4ba1 (diff)
parent570eca63d847a423d140e7e29f62236dc944b2d5 (diff)
downloadspike-471d43a6e392d8aad6b6c6e3b5fc2464c32ca8d0.zip
spike-471d43a6e392d8aad6b6c6e3b5fc2464c32ca8d0.tar.gz
spike-471d43a6e392d8aad6b6c6e3b5fc2464c32ca8d0.tar.bz2
Merge pull request #1233 from riscv-software-src/pmp64
Support all 64 PMP regions
-rw-r--r--riscv/processor.cc7
-rw-r--r--riscv/processor.h2
-rw-r--r--riscv/sim.cc18
3 files changed, 9 insertions, 18 deletions
diff --git a/riscv/processor.cc b/riscv/processor.cc
index 39096e9..27ca995 100644
--- a/riscv/processor.cc
+++ b/riscv/processor.cc
@@ -583,7 +583,7 @@ void processor_t::set_pmp_num(reg_t n)
{
// check the number of pmp is in a reasonable range
if (n > state.max_pmp) {
- fprintf(stderr, "error: bad number of pmp regions: '%ld' from the dtb\n", (unsigned long)n);
+ fprintf(stderr, "error: number of PMP regions requested (%" PRIu64 ") exceeds maximum (%d)\n", n, state.max_pmp);
abort();
}
n_pmp = n;
@@ -592,8 +592,9 @@ void processor_t::set_pmp_num(reg_t n)
void processor_t::set_pmp_granularity(reg_t gran)
{
// check the pmp granularity is set from dtb(!=0) and is power of 2
- if (gran < (1 << PMP_SHIFT) || (gran & (gran - 1)) != 0) {
- fprintf(stderr, "error: bad pmp granularity '%ld' from the dtb\n", (unsigned long)gran);
+ unsigned min = 1 << PMP_SHIFT;
+ if (gran < min || (gran & (gran - 1)) != 0) {
+ fprintf(stderr, "error: PMP granularity (%" PRIu64 ") must be a power of two and at least %u\n", gran, min);
abort();
}
diff --git a/riscv/processor.h b/riscv/processor.h
index a8ccac0..7c4c24f 100644
--- a/riscv/processor.h
+++ b/riscv/processor.h
@@ -136,7 +136,7 @@ struct state_t
mseccfg_csr_t_p mseccfg;
- static const int max_pmp = 16;
+ static const int max_pmp = 64;
pmpaddr_csr_t_p pmpaddr[max_pmp];
float_csr_t_p fflags;
diff --git a/riscv/sim.cc b/riscv/sim.cc
index 74b3523..051a483 100644
--- a/riscv/sim.cc
+++ b/riscv/sim.cc
@@ -156,20 +156,10 @@ sim_t::sim_t(const cfg_t *cfg, bool halted,
break;
//handle pmp
- reg_t pmp_num = 0, pmp_granularity = 0;
- if (fdt_parse_pmp_num(fdt, cpu_offset, &pmp_num) == 0) {
- if (pmp_num <= 64) {
- procs[cpu_idx]->set_pmp_num(pmp_num);
- } else {
- std::cerr << "core ("
- << cpu_idx
- << ") doesn't have valid 'riscv,pmpregions'"
- << pmp_num << ").\n";
- exit(1);
- }
- } else {
- procs[cpu_idx]->set_pmp_num(0);
- }
+ reg_t pmp_num, pmp_granularity;
+ if (fdt_parse_pmp_num(fdt, cpu_offset, &pmp_num) != 0)
+ pmp_num = 0;
+ procs[cpu_idx]->set_pmp_num(pmp_num);
if (fdt_parse_pmp_alignment(fdt, cpu_offset, &pmp_granularity) == 0) {
procs[cpu_idx]->set_pmp_granularity(pmp_granularity);