]>
Commit | Line | Data |
---|---|---|
caab277b | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
f668cd16 CM |
2 | /* |
3 | * Copyright (C) 2012 ARM Ltd. | |
f668cd16 CM |
4 | */ |
5 | #ifndef __ASM_HWCAP_H | |
6 | #define __ASM_HWCAP_H | |
7 | ||
4262a727 | 8 | #include <uapi/asm/hwcap.h> |
aec0bff7 | 9 | #include <asm/cpufeature.h> |
f668cd16 CM |
10 | |
11 | #define COMPAT_HWCAP_HALF (1 << 1) | |
12 | #define COMPAT_HWCAP_THUMB (1 << 2) | |
13 | #define COMPAT_HWCAP_FAST_MULT (1 << 4) | |
14 | #define COMPAT_HWCAP_VFP (1 << 6) | |
15 | #define COMPAT_HWCAP_EDSP (1 << 7) | |
16 | #define COMPAT_HWCAP_NEON (1 << 12) | |
17 | #define COMPAT_HWCAP_VFPv3 (1 << 13) | |
18 | #define COMPAT_HWCAP_TLS (1 << 15) | |
19 | #define COMPAT_HWCAP_VFPv4 (1 << 16) | |
20 | #define COMPAT_HWCAP_IDIVA (1 << 17) | |
21 | #define COMPAT_HWCAP_IDIVT (1 << 18) | |
22 | #define COMPAT_HWCAP_IDIV (COMPAT_HWCAP_IDIVA|COMPAT_HWCAP_IDIVT) | |
7d57511d | 23 | #define COMPAT_HWCAP_LPAE (1 << 20) |
46efe547 | 24 | #define COMPAT_HWCAP_EVTSTRM (1 << 21) |
f668cd16 | 25 | |
4cf761cd AB |
26 | #define COMPAT_HWCAP2_AES (1 << 0) |
27 | #define COMPAT_HWCAP2_PMULL (1 << 1) | |
28 | #define COMPAT_HWCAP2_SHA1 (1 << 2) | |
29 | #define COMPAT_HWCAP2_SHA2 (1 << 3) | |
30 | #define COMPAT_HWCAP2_CRC32 (1 << 4) | |
31 | ||
1c1e4362 | 32 | #ifndef __ASSEMBLY__ |
aaba098f AM |
33 | #include <linux/log2.h> |
34 | ||
35 | /* | |
36 | * For userspace we represent hwcaps as a collection of HWCAP{,2}_x bitfields | |
37 | * as described in uapi/asm/hwcap.h. For the kernel we represent hwcaps as | |
38 | * natural numbers (in a single range of size MAX_CPU_FEATURES) defined here | |
39 | * with prefix KERNEL_HWCAP_ mapped to their HWCAP{,2}_x counterpart. | |
40 | * | |
41 | * Hwcaps should be set and tested within the kernel via the | |
42 | * cpu_{set,have}_named_feature(feature) where feature is the unique suffix | |
43 | * of KERNEL_HWCAP_{feature}. | |
44 | */ | |
45 | #define __khwcap_feature(x) const_ilog2(HWCAP_ ## x) | |
46 | #define KERNEL_HWCAP_FP __khwcap_feature(FP) | |
47 | #define KERNEL_HWCAP_ASIMD __khwcap_feature(ASIMD) | |
48 | #define KERNEL_HWCAP_EVTSTRM __khwcap_feature(EVTSTRM) | |
49 | #define KERNEL_HWCAP_AES __khwcap_feature(AES) | |
50 | #define KERNEL_HWCAP_PMULL __khwcap_feature(PMULL) | |
51 | #define KERNEL_HWCAP_SHA1 __khwcap_feature(SHA1) | |
52 | #define KERNEL_HWCAP_SHA2 __khwcap_feature(SHA2) | |
53 | #define KERNEL_HWCAP_CRC32 __khwcap_feature(CRC32) | |
54 | #define KERNEL_HWCAP_ATOMICS __khwcap_feature(ATOMICS) | |
55 | #define KERNEL_HWCAP_FPHP __khwcap_feature(FPHP) | |
56 | #define KERNEL_HWCAP_ASIMDHP __khwcap_feature(ASIMDHP) | |
57 | #define KERNEL_HWCAP_CPUID __khwcap_feature(CPUID) | |
58 | #define KERNEL_HWCAP_ASIMDRDM __khwcap_feature(ASIMDRDM) | |
59 | #define KERNEL_HWCAP_JSCVT __khwcap_feature(JSCVT) | |
60 | #define KERNEL_HWCAP_FCMA __khwcap_feature(FCMA) | |
61 | #define KERNEL_HWCAP_LRCPC __khwcap_feature(LRCPC) | |
62 | #define KERNEL_HWCAP_DCPOP __khwcap_feature(DCPOP) | |
63 | #define KERNEL_HWCAP_SHA3 __khwcap_feature(SHA3) | |
64 | #define KERNEL_HWCAP_SM3 __khwcap_feature(SM3) | |
65 | #define KERNEL_HWCAP_SM4 __khwcap_feature(SM4) | |
66 | #define KERNEL_HWCAP_ASIMDDP __khwcap_feature(ASIMDDP) | |
67 | #define KERNEL_HWCAP_SHA512 __khwcap_feature(SHA512) | |
68 | #define KERNEL_HWCAP_SVE __khwcap_feature(SVE) | |
69 | #define KERNEL_HWCAP_ASIMDFHM __khwcap_feature(ASIMDFHM) | |
70 | #define KERNEL_HWCAP_DIT __khwcap_feature(DIT) | |
71 | #define KERNEL_HWCAP_USCAT __khwcap_feature(USCAT) | |
72 | #define KERNEL_HWCAP_ILRCPC __khwcap_feature(ILRCPC) | |
73 | #define KERNEL_HWCAP_FLAGM __khwcap_feature(FLAGM) | |
74 | #define KERNEL_HWCAP_SSBS __khwcap_feature(SSBS) | |
75 | #define KERNEL_HWCAP_SB __khwcap_feature(SB) | |
76 | #define KERNEL_HWCAP_PACA __khwcap_feature(PACA) | |
77 | #define KERNEL_HWCAP_PACG __khwcap_feature(PACG) | |
78 | ||
79 | #define __khwcap2_feature(x) (const_ilog2(HWCAP2_ ## x) + 32) | |
671db581 | 80 | #define KERNEL_HWCAP_DCPODP __khwcap2_feature(DCPODP) |
06a916fe DM |
81 | #define KERNEL_HWCAP_SVE2 __khwcap2_feature(SVE2) |
82 | #define KERNEL_HWCAP_SVEAES __khwcap2_feature(SVEAES) | |
83 | #define KERNEL_HWCAP_SVEPMULL __khwcap2_feature(SVEPMULL) | |
84 | #define KERNEL_HWCAP_SVEBITPERM __khwcap2_feature(SVEBITPERM) | |
85 | #define KERNEL_HWCAP_SVESHA3 __khwcap2_feature(SVESHA3) | |
86 | #define KERNEL_HWCAP_SVESM4 __khwcap2_feature(SVESM4) | |
aaba098f | 87 | |
f668cd16 CM |
88 | /* |
89 | * This yields a mask that user programs can use to figure out what | |
90 | * instruction set this cpu supports. | |
91 | */ | |
aec0bff7 AM |
92 | #define ELF_HWCAP cpu_get_elf_hwcap() |
93 | #define ELF_HWCAP2 cpu_get_elf_hwcap2() | |
46efe547 SH |
94 | |
95 | #ifdef CONFIG_COMPAT | |
96 | #define COMPAT_ELF_HWCAP (compat_elf_hwcap) | |
28964d32 AB |
97 | #define COMPAT_ELF_HWCAP2 (compat_elf_hwcap2) |
98 | extern unsigned int compat_elf_hwcap, compat_elf_hwcap2; | |
46efe547 | 99 | #endif |
f668cd16 | 100 | |
37b01d53 SP |
101 | enum { |
102 | CAP_HWCAP = 1, | |
103 | #ifdef CONFIG_COMPAT | |
104 | CAP_COMPAT_HWCAP, | |
105 | CAP_COMPAT_HWCAP2, | |
106 | #endif | |
107 | }; | |
108 | ||
f668cd16 | 109 | #endif |
1c1e4362 | 110 | #endif |