Files
Linux_Drivers/opensbi/lib/sbi/sbi_math.c
sam.xiang 93f81bd490 [opensbi] create opensbi from T-Head official:
repo: https://github.com/T-head-Semi/opensbi
	commit: 89182b257c8798e15e4c685c1af0c2862d528d2a

Change-Id: I7b39d66729e0108661a6f4c9e28acbdb303684ea
2023-03-10 20:30:16 +08:00

24 lines
397 B
C

/*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2020 Western Digital Corporation or its affiliates.
*
* Common helper functions used across OpenSBI project.
*
* Authors:
* Atish Patra <atish.patra@wdc.com>
*/
unsigned long log2roundup(unsigned long x)
{
unsigned long ret = 0;
while (ret < __riscv_xlen) {
if (x <= (1UL << ret))
break;
ret++;
}
return ret;
}