aboutsummaryrefslogtreecommitdiff
path: root/riscv/dts.cc
diff options
context:
space:
mode:
authorChih-Min Chao <chihmin.chao@sifive.com>2020-04-27 21:16:21 -0700
committerChih-Min Chao <chihmin.chao@sifive.com>2020-04-27 21:16:43 -0700
commit2e567debf479cf5ef86d6266dc27814f7ba8a088 (patch)
treec8aa6fd1d87b97f4d6c9e2c1279b061cfc70d4aa /riscv/dts.cc
parent3b26740205c401498fe77c2c9a16c8907a139cd8 (diff)
downloadspike-2e567debf479cf5ef86d6266dc27814f7ba8a088.zip
spike-2e567debf479cf5ef86d6266dc27814f7ba8a088.tar.gz
spike-2e567debf479cf5ef86d6266dc27814f7ba8a088.tar.bz2
fdt: add pmp parsing helper
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Diffstat (limited to 'riscv/dts.cc')
-rw-r--r--riscv/dts.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/riscv/dts.cc b/riscv/dts.cc
index c9daa96..3257976 100644
--- a/riscv/dts.cc
+++ b/riscv/dts.cc
@@ -44,6 +44,7 @@ std::string make_dts(size_t insns_per_rtc_tick, size_t cpu_hz,
" compatible = \"riscv\";\n"
" riscv,isa = \"" << procs[i]->get_isa_string() << "\";\n"
" mmu-type = \"riscv," << (procs[i]->get_max_xlen() <= 32 ? "sv32" : "sv48") << "\";\n"
+ " riscv,pmpregions = <16>;\n"
" clock-frequency = <" << cpu_hz << ">;\n"
" CPU" << i << "_intc: interrupt-controller {\n"
" #interrupt-cells = <1>;\n"
@@ -227,3 +228,18 @@ int fdt_parse_clint(void *fdt, unsigned long *clint_addr,
return 0;
}
+
+int fdt_parse_pmp(void *fdt, unsigned long *pmp_num, const char *compatible)
+{
+ int nodeoffset, rc;
+
+ nodeoffset = fdt_node_offset_by_compatible(fdt, -1, compatible);
+ if (nodeoffset < 0)
+ return nodeoffset;
+
+ rc = fdt_get_node_addr_size(fdt, nodeoffset, pmp_num, NULL, "riscv,pmpregions");
+ if (rc < 0 || !pmp_num)
+ return -ENODEV;
+
+ return 0;
+}