![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only */ 0002 /* 0003 * Copyright (C) 2017 Linaro Ltd. <ard.biesheuvel@linaro.org> 0004 */ 0005 0006 #ifndef __ASM_CPUFEATURE_H 0007 #define __ASM_CPUFEATURE_H 0008 0009 #include <linux/log2.h> 0010 #include <asm/hwcap.h> 0011 0012 /* 0013 * Due to the fact that ELF_HWCAP is a 32-bit type on ARM, and given the number 0014 * of optional CPU features it defines, ARM's CPU hardware capability bits have 0015 * been distributed over separate elf_hwcap and elf_hwcap2 variables, each of 0016 * which covers a subset of the available CPU features. 0017 * 0018 * Currently, only a few of those are suitable for automatic module loading 0019 * (which is the primary use case of this facility) and those happen to be all 0020 * covered by HWCAP2. So let's only cover those via the cpu_feature() 0021 * convenience macro for now (which is used by module_cpu_feature_match()). 0022 * However, all capabilities are exposed via the modalias, and can be matched 0023 * using an explicit MODULE_DEVICE_TABLE() that uses __hwcap_feature() directly. 0024 */ 0025 #define MAX_CPU_FEATURES 64 0026 #define __hwcap_feature(x) ilog2(HWCAP_ ## x) 0027 #define __hwcap2_feature(x) (32 + ilog2(HWCAP2_ ## x)) 0028 #define cpu_feature(x) __hwcap2_feature(x) 0029 0030 static inline bool cpu_have_feature(unsigned int num) 0031 { 0032 return num < 32 ? elf_hwcap & BIT(num) : elf_hwcap2 & BIT(num - 32); 0033 } 0034 0035 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |