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>
This commit is contained in:
Bin Meng authored and Anup Patel committed 2020-03-18 08:58:26 +05:30
1 parent 327ba36211
commit 5fbcd625bc
3 files changed
+11 -17

No files matched your search

+6 -4
View File
@@ -249,16 +249,16 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
}
int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
unsigned long *log2len_out)
unsigned long *size)
{
int pmpcfg_csr, pmpcfg_shift, pmpaddr_csr;
unsigned long cfgmask, pmpcfg, prot;
unsigned long t1, addr, log2len;
/* check parameters */
if (n >= PMP_COUNT || !prot_out || !addr_out || !log2len_out)
if (n >= PMP_COUNT || !prot_out || !addr_out || !size)
return SBI_EINVAL;
*prot_out = *addr_out = *log2len_out = 0;
*prot_out = *addr_out = *size = 0;
/* calculate PMP register and offset */
#if __riscv_xlen == 32
@@ -299,7 +299,9 @@ int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
/* return details */
*prot_out = prot;
*addr_out = addr;
*log2len_out = log2len;
if (log2len < __riscv_xlen)
*size = (1UL << log2len);
return 0;
}