diff options
author | Chih-Min Chao <chihmin.chao@sifive.com> | 2020-04-27 21:46:11 -0700 |
---|---|---|
committer | Chih-Min Chao <chihmin.chao@sifive.com> | 2020-04-27 23:18:07 -0700 |
commit | 0f54569856de576eaf8daca98fdb5f620f344055 (patch) | |
tree | bb1fdd6f47e340ab8af2f8ae983dd845d8ee0f16 /riscv/dts.cc | |
parent | 2e567debf479cf5ef86d6266dc27814f7ba8a088 (diff) | |
download | spike-0f54569856de576eaf8daca98fdb5f620f344055.zip spike-0f54569856de576eaf8daca98fdb5f620f344055.tar.gz spike-0f54569856de576eaf8daca98fdb5f620f344055.tar.bz2 |
fdt: add pmp granularity function
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Diffstat (limited to 'riscv/dts.cc')
-rw-r--r-- | riscv/dts.cc | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/riscv/dts.cc b/riscv/dts.cc index 3257976..c12ff06 100644 --- a/riscv/dts.cc +++ b/riscv/dts.cc @@ -45,6 +45,7 @@ std::string make_dts(size_t insns_per_rtc_tick, size_t cpu_hz, " riscv,isa = \"" << procs[i]->get_isa_string() << "\";\n" " mmu-type = \"riscv," << (procs[i]->get_max_xlen() <= 32 ? "sv32" : "sv48") << "\";\n" " riscv,pmpregions = <16>;\n" + " riscv,pmpgranularity = <4>;\n" " clock-frequency = <" << cpu_hz << ">;\n" " CPU" << i << "_intc: interrupt-controller {\n" " #interrupt-cells = <1>;\n" @@ -229,7 +230,7 @@ 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 fdt_parse_pmp_num(void *fdt, unsigned long *pmp_num, const char *compatible) { int nodeoffset, rc; @@ -237,9 +238,27 @@ int fdt_parse_pmp(void *fdt, unsigned long *pmp_num, const char *compatible) if (nodeoffset < 0) return nodeoffset; - rc = fdt_get_node_addr_size(fdt, nodeoffset, pmp_num, NULL, "riscv,pmpregions"); + rc = fdt_get_node_addr_size(fdt, nodeoffset, pmp_num, NULL, + "riscv,pmpregions"); if (rc < 0 || !pmp_num) return -ENODEV; return 0; } + +int fdt_parse_pmp_alignment(void *fdt, unsigned long *pmp_align, + 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_align, NULL, + "riscv,pmpgranularity"); + if (rc < 0 || !pmp_align) + return -ENODEV; + + return 0; +} |