summaryrefslogtreecommitdiff
path: root/lib/sbi/sbi_hart.c
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2020-03-17 17:59:38 +0300
committerAnup Patel <anup@brainfault.org>2020-03-18 06:28:26 +0300
commit5fbcd625bc8f8980164b4c905dc8097269461419 (patch)
treeebc4aef34a53d85b5768a066199f127ff723a409 /lib/sbi/sbi_hart.c
parent327ba362119a9cb36ff03575723546d8abcb5465 (diff)
downloadopensbi-5fbcd625bc8f8980164b4c905dc8097269461419.tar.xz
lib: sbi: Update pmp_get() to return decoded size directly
Currently pmp_get() returns the log2 length of the PMP memory region size. The caller has to calculate the size based on that and the same codes are duplicated. Update this function to return decoded size directly. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_hart.c')
-rw-r--r--lib/sbi/sbi_hart.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index aa32615..e71725c 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -125,20 +125,16 @@ unsigned long log2roundup(unsigned long x)
void sbi_hart_pmp_dump(struct sbi_scratch *scratch)
{
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
- unsigned long prot, addr, size, l2l;
+ unsigned long prot, addr, size;
unsigned int i;
if (!sbi_platform_has_pmp(plat))
return;
for (i = 0; i < PMP_COUNT; i++) {
- pmp_get(i, &prot, &addr, &l2l);
+ pmp_get(i, &prot, &addr, &size);
if (!(prot & PMP_A))
continue;
- if (l2l < __riscv_xlen)
- size = (1UL << l2l);
- else
- size = 0;
#if __riscv_xlen == 32
sbi_printf("PMP%d : 0x%08lx-0x%08lx (A",
#else
@@ -160,20 +156,16 @@ void sbi_hart_pmp_dump(struct sbi_scratch *scratch)
int sbi_hart_pmp_check_addr(struct sbi_scratch *scratch, unsigned long addr,
unsigned long attr)
{
- unsigned long prot, size, l2l, i, tempaddr;
+ unsigned long prot, size, i, tempaddr;
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
if (!sbi_platform_has_pmp(plat))
return SBI_OK;
for (i = 0; i < PMP_COUNT; i++) {
- pmp_get(i, &prot, &tempaddr, &l2l);
+ pmp_get(i, &prot, &tempaddr, &size);
if (!(prot & PMP_A))
continue;
- if (l2l < __riscv_xlen)
- size = (1UL << l2l);
- else
- size = 0;
if (tempaddr <= addr && addr <= tempaddr + size)
if (!(prot & attr))
return SBI_INVALID_ADDR;