diff options
author | Andrew Waterman <andrew@sifive.com> | 2023-01-19 17:21:06 -0800 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2023-01-19 17:24:00 -0800 |
commit | 42ddc543ed4a64b7f8ebf8035e6ee4b1ab569f1b (patch) | |
tree | 291253e91c56611a9dec13594730886f635b4ef2 | |
parent | a875da544dac211099ca9768368cda2a3976a674 (diff) | |
download | spike-42ddc543ed4a64b7f8ebf8035e6ee4b1ab569f1b.zip spike-42ddc543ed4a64b7f8ebf8035e6ee4b1ab569f1b.tar.gz spike-42ddc543ed4a64b7f8ebf8035e6ee4b1ab569f1b.tar.bz2 |
Perform pmpregions input validation in only one place
No reason to check it both in sim_t::sim_t and in processor_t::set_pmp_num.
-rw-r--r-- | riscv/sim.cc | 18 |
1 files changed, 4 insertions, 14 deletions
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); |