diff options
author | Chih-Min Chao <chihmin.chao@sifive.com> | 2020-11-05 20:02:10 -0800 |
---|---|---|
committer | Chih-Min Chao <chihmin.chao@sifive.com> | 2020-11-11 18:41:24 -0800 |
commit | 0481b56f3496a77ad1251c887445957a3f3dc300 (patch) | |
tree | 4df957f35bffaa16b989dc871f39e290c14b8845 /riscv/dts.cc | |
parent | bed716c601f5140afd595ea60f20d9eddab02032 (diff) | |
download | spike-0481b56f3496a77ad1251c887445957a3f3dc300.zip spike-0481b56f3496a77ad1251c887445957a3f3dc300.tar.gz spike-0481b56f3496a77ad1251c887445957a3f3dc300.tar.bz2 |
dts: extend dts api to get info of each cpu
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Diffstat (limited to 'riscv/dts.cc')
-rw-r--r-- | riscv/dts.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/riscv/dts.cc b/riscv/dts.cc index 56b76e6..9469e3f 100644 --- a/riscv/dts.cc +++ b/riscv/dts.cc @@ -225,6 +225,21 @@ static int fdt_get_node_addr_size(void *fdt, int node, reg_t *addr, return 0; } +int fdt_get_offset(void *fdt, const char *field) +{ + return fdt_path_offset(fdt, field); +} + +int fdt_get_first_subnode(void *fdt, int node) +{ + return fdt_first_subnode(fdt, node); +} + +int fdt_get_next_subnode(void *fdt, int node) +{ + return fdt_next_subnode(fdt, node); +} + int fdt_parse_clint(void *fdt, reg_t *clint_addr, const char *compatible) { @@ -273,3 +288,26 @@ int fdt_parse_pmp_alignment(void *fdt, reg_t *pmp_align, return 0; } + +int fdt_parse_mmu_type(void *fdt, int cpu_offset, char *mmu_type) +{ + int len; + const void *prop; + + if (!fdt || cpu_offset < 0) + return -EINVAL; + + prop = fdt_getprop(fdt, cpu_offset, "device_type", &len); + if (!prop || !len) + return -EINVAL; + if (strncmp ((char *)prop, "cpu", strlen ("cpu"))) + return -EINVAL; + + prop = fdt_getprop(fdt, cpu_offset, "mmu-type", &len); + if (!prop || !len) + return -EINVAL; + + strcpy(mmu_type, (char *)prop); + + return 0; +} |