aboutsummaryrefslogtreecommitdiff
path: root/lib/sbi/riscv_asm.c
diff options
context:
space:
mode:
authorLi Jinpei <leekingp1994@163.com>2020-02-11 15:37:24 +0530
committerAnup Patel <anup@brainfault.org>2020-02-13 09:10:57 +0530
commit897b8fbdd92fcfad194417d348b8dad16ab0e17a (patch)
treecab2199681b64d28c865937d121cee8bef9efe99 /lib/sbi/riscv_asm.c
parent179eddeb9ca5fc1869d40696e0d4cd9899b9d92d (diff)
lib: Use __builtin_ctzl() in pmp_get()
We should should __builtin_ctzl() in pmp_get() instead of custom ctz() function. Signed-off-by: Li Jinpei <leekingp1994@163.com> Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/sbi/riscv_asm.c')
-rw-r--r--lib/sbi/riscv_asm.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/lib/sbi/riscv_asm.c b/lib/sbi/riscv_asm.c
index 7b612d4..68f5f17 100644
--- a/lib/sbi/riscv_asm.c
+++ b/lib/sbi/riscv_asm.c
@@ -184,18 +184,6 @@ void csr_write_num(int csr_num, unsigned long val)
};
}
-static unsigned long ctz(unsigned long x)
-{
- unsigned long ret = 0;
-
- while (!(x & 1UL)) {
- ret++;
- x = x >> 1;
- }
-
- return ret;
-}
-
int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
unsigned long log2len)
{
@@ -287,7 +275,7 @@ int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
addr = 0;
log2len = __riscv_xlen;
} else {
- t1 = ctz(~addr);
+ t1 = __builtin_ctzl(~addr);
addr = (addr & ~((1UL << t1) - 1)) << PMP_SHIFT;
log2len = (t1 + PMP_SHIFT + 1);
}