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-05-19 19:56:57 -0700 |
commit | b9f67e66755941b9681a89fa42e9ba80f7fa8351 (patch) | |
tree | 2fe804045d14782053d09a97521605e0d88110ae | |
parent | cf0fc9b5b25566da1689c24e07871bf91aa00a44 (diff) | |
download | spike-b9f67e66755941b9681a89fa42e9ba80f7fa8351.zip spike-b9f67e66755941b9681a89fa42e9ba80f7fa8351.tar.gz spike-b9f67e66755941b9681a89fa42e9ba80f7fa8351.tar.bz2 |
fdt: add pmp granularity function
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
-rw-r--r-- | riscv/dts.cc | 23 | ||||
-rw-r--r-- | riscv/dts.h | 5 |
2 files changed, 25 insertions, 3 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; +} diff --git a/riscv/dts.h b/riscv/dts.h index ec27abc..08d8f9d 100644 --- a/riscv/dts.h +++ b/riscv/dts.h @@ -15,5 +15,8 @@ std::string dts_compile(const std::string& dts); int fdt_parse_clint(void *fdt, unsigned long *clint_addr, const char *compatible); -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 fdt_parse_pmp_alignment(void *fdt, unsigned long *pmp_align, + const char *compatible); #endif |