cpu/x86/mtrr: Use fls/ffs from lib.h
Definitions of __fls/__ffs from lib.h and fms/fls from cpu/x86/mtrr.h are duplicated. Use definition from lib.h which is more generic. Change-Id: Ic9c6f1027447b04627d7f21d777cbea142588093 Signed-off-by: Shuo Liu <shuo.liu@intel.com> Suggested-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/85104 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
02cbfaa201
commit
97412d1929
4 changed files with 10 additions and 57 deletions
|
|
@ -61,6 +61,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <lib.h>
|
||||
|
||||
/*
|
||||
* The MTRR code has some side effects that the callers should be aware for.
|
||||
|
|
@ -128,29 +129,6 @@ int var_mtrr_set(struct var_mtrr_context *ctx, uintptr_t addr, size_t size, int
|
|||
void commit_mtrr_setup(const struct var_mtrr_context *ctx);
|
||||
void postcar_mtrr_setup(void);
|
||||
|
||||
/* fms: find most significant bit set, stolen from Linux Kernel Source. */
|
||||
static inline unsigned int fms(unsigned int x)
|
||||
{
|
||||
unsigned int r;
|
||||
|
||||
__asm__("bsrl %1,%0\n\t"
|
||||
"jnz 1f\n\t"
|
||||
"movl $0,%0\n"
|
||||
"1:" : "=r" (r) : "mr" (x));
|
||||
return r;
|
||||
}
|
||||
|
||||
/* fls: find least significant bit set */
|
||||
static inline unsigned int fls(unsigned int x)
|
||||
{
|
||||
unsigned int r;
|
||||
|
||||
__asm__("bsfl %1,%0\n\t"
|
||||
"jnz 1f\n\t"
|
||||
"movl $32,%0\n"
|
||||
"1:" : "=r" (r) : "mr" (x));
|
||||
return r;
|
||||
}
|
||||
#endif /* !defined(__ASSEMBLER__) */
|
||||
|
||||
/* Align up/down to next power of 2, suitable for assembler
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue