diff options
author | Shuo Liu <shuo.liu@intel.com> | 2024-11-12 18:30:15 +0800 |
---|---|---|
committer | Lean Sheng Tan <sheng.tan@9elements.com> | 2024-11-14 14:29:18 +0000 |
commit | 97412d1929e88a929f73a229e40ca85a38168d7e (patch) | |
tree | 13549d8e57b4ae7b0d73157ef81e1727aeffe843 /src/include/cpu/x86/mtrr.h | |
parent | 02cbfaa201209e4145aae8e475e923ed68052f3c (diff) |
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>
Diffstat (limited to 'src/include/cpu/x86/mtrr.h')
-rw-r--r-- | src/include/cpu/x86/mtrr.h | 24 |
1 files changed, 1 insertions, 23 deletions
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 <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 |