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>
};
}
-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)
{
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);
}