cpu/x86: Move fls() and fms() to mtrr.h
Move the funtion to find most significant bit set(fms) and function to find least significant bit set(fls) to a common place. And remove the duplicates. Change-Id: Ia821038b622d93e7f719c18e5ee3e8112de66a53 Signed-off-by: Rizwan Qureshi <rizwan.qureshi@intel.com> Reviewed-on: https://review.coreboot.org/16525 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
committed by
Martin Roth
parent
b1b44d34e3
commit
8453c4f2fb
@@ -92,30 +92,6 @@ static void enable_var_mtrr(unsigned char deftype)
|
||||
wrmsr(MTRR_DEF_TYPE_MSR, msr);
|
||||
}
|
||||
|
||||
/* fms: find most significant bit set, stolen from Linux Kernel Source. */
|
||||
static inline unsigned int fms(unsigned int x)
|
||||
{
|
||||
int r;
|
||||
|
||||
__asm__("bsrl %1,%0\n\t"
|
||||
"jnz 1f\n\t"
|
||||
"movl $0,%0\n"
|
||||
"1:" : "=r" (r) : "g" (x));
|
||||
return r;
|
||||
}
|
||||
|
||||
/* fls: find least significant bit set */
|
||||
static inline unsigned int fls(unsigned int x)
|
||||
{
|
||||
int r;
|
||||
|
||||
__asm__("bsfl %1,%0\n\t"
|
||||
"jnz 1f\n\t"
|
||||
"movl $32,%0\n"
|
||||
"1:" : "=r" (r) : "g" (x));
|
||||
return r;
|
||||
}
|
||||
|
||||
#define MTRR_VERBOSE_LEVEL BIOS_NEVER
|
||||
|
||||
/* MTRRs are at a 4KiB granularity. Therefore all address calculations can
|
||||
|
Reference in New Issue
Block a user