From 97412d1929e88a929f73a229e40ca85a38168d7e Mon Sep 17 00:00:00 2001 From: Shuo Liu Date: Tue, 12 Nov 2024 18:30:15 +0800 Subject: 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 Suggested-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/85104 Reviewed-by: Angel Pons Tested-by: build bot (Jenkins) --- src/include/cpu/x86/mtrr.h | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'src/include/cpu/x86/mtrr.h') diff --git a/src/include/cpu/x86/mtrr.h b/src/include/cpu/x86/mtrr.h index 5741afbb2d..2d7a8416c1 100644 --- a/src/include/cpu/x86/mtrr.h +++ b/src/include/cpu/x86/mtrr.h @@ -61,6 +61,7 @@ #include #include +#include /* * 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 -- cgit v1.2.3