18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2012 ARM Ltd. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci#ifndef __ASM_HWCAP_H 68c2ecf20Sopenharmony_ci#define __ASM_HWCAP_H 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <uapi/asm/hwcap.h> 98c2ecf20Sopenharmony_ci#include <asm/cpufeature.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_SWP (1 << 0) 128c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_HALF (1 << 1) 138c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_THUMB (1 << 2) 148c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_26BIT (1 << 3) 158c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_FAST_MULT (1 << 4) 168c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_FPA (1 << 5) 178c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_VFP (1 << 6) 188c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_EDSP (1 << 7) 198c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_JAVA (1 << 8) 208c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_IWMMXT (1 << 9) 218c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_CRUNCH (1 << 10) 228c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_THUMBEE (1 << 11) 238c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_NEON (1 << 12) 248c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_VFPv3 (1 << 13) 258c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_VFPV3D16 (1 << 14) 268c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_TLS (1 << 15) 278c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_VFPv4 (1 << 16) 288c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_IDIVA (1 << 17) 298c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_IDIVT (1 << 18) 308c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_IDIV (COMPAT_HWCAP_IDIVA|COMPAT_HWCAP_IDIVT) 318c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_VFPD32 (1 << 19) 328c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_LPAE (1 << 20) 338c2ecf20Sopenharmony_ci#define COMPAT_HWCAP_EVTSTRM (1 << 21) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define COMPAT_HWCAP2_AES (1 << 0) 368c2ecf20Sopenharmony_ci#define COMPAT_HWCAP2_PMULL (1 << 1) 378c2ecf20Sopenharmony_ci#define COMPAT_HWCAP2_SHA1 (1 << 2) 388c2ecf20Sopenharmony_ci#define COMPAT_HWCAP2_SHA2 (1 << 3) 398c2ecf20Sopenharmony_ci#define COMPAT_HWCAP2_CRC32 (1 << 4) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 428c2ecf20Sopenharmony_ci#include <linux/log2.h> 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* 458c2ecf20Sopenharmony_ci * For userspace we represent hwcaps as a collection of HWCAP{,2}_x bitfields 468c2ecf20Sopenharmony_ci * as described in uapi/asm/hwcap.h. For the kernel we represent hwcaps as 478c2ecf20Sopenharmony_ci * natural numbers (in a single range of size MAX_CPU_FEATURES) defined here 488c2ecf20Sopenharmony_ci * with prefix KERNEL_HWCAP_ mapped to their HWCAP{,2}_x counterpart. 498c2ecf20Sopenharmony_ci * 508c2ecf20Sopenharmony_ci * Hwcaps should be set and tested within the kernel via the 518c2ecf20Sopenharmony_ci * cpu_{set,have}_named_feature(feature) where feature is the unique suffix 528c2ecf20Sopenharmony_ci * of KERNEL_HWCAP_{feature}. 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_ci#define __khwcap_feature(x) const_ilog2(HWCAP_ ## x) 558c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_FP __khwcap_feature(FP) 568c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_ASIMD __khwcap_feature(ASIMD) 578c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_EVTSTRM __khwcap_feature(EVTSTRM) 588c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_AES __khwcap_feature(AES) 598c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_PMULL __khwcap_feature(PMULL) 608c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SHA1 __khwcap_feature(SHA1) 618c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SHA2 __khwcap_feature(SHA2) 628c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_CRC32 __khwcap_feature(CRC32) 638c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_ATOMICS __khwcap_feature(ATOMICS) 648c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_FPHP __khwcap_feature(FPHP) 658c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_ASIMDHP __khwcap_feature(ASIMDHP) 668c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_CPUID __khwcap_feature(CPUID) 678c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_ASIMDRDM __khwcap_feature(ASIMDRDM) 688c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_JSCVT __khwcap_feature(JSCVT) 698c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_FCMA __khwcap_feature(FCMA) 708c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_LRCPC __khwcap_feature(LRCPC) 718c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_DCPOP __khwcap_feature(DCPOP) 728c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SHA3 __khwcap_feature(SHA3) 738c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SM3 __khwcap_feature(SM3) 748c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SM4 __khwcap_feature(SM4) 758c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_ASIMDDP __khwcap_feature(ASIMDDP) 768c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SHA512 __khwcap_feature(SHA512) 778c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SVE __khwcap_feature(SVE) 788c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_ASIMDFHM __khwcap_feature(ASIMDFHM) 798c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_DIT __khwcap_feature(DIT) 808c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_USCAT __khwcap_feature(USCAT) 818c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_ILRCPC __khwcap_feature(ILRCPC) 828c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_FLAGM __khwcap_feature(FLAGM) 838c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SSBS __khwcap_feature(SSBS) 848c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SB __khwcap_feature(SB) 858c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_PACA __khwcap_feature(PACA) 868c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_PACG __khwcap_feature(PACG) 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define __khwcap2_feature(x) (const_ilog2(HWCAP2_ ## x) + 32) 898c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_DCPODP __khwcap2_feature(DCPODP) 908c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SVE2 __khwcap2_feature(SVE2) 918c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SVEAES __khwcap2_feature(SVEAES) 928c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SVEPMULL __khwcap2_feature(SVEPMULL) 938c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SVEBITPERM __khwcap2_feature(SVEBITPERM) 948c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SVESHA3 __khwcap2_feature(SVESHA3) 958c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SVESM4 __khwcap2_feature(SVESM4) 968c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_FLAGM2 __khwcap2_feature(FLAGM2) 978c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_FRINT __khwcap2_feature(FRINT) 988c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SVEI8MM __khwcap2_feature(SVEI8MM) 998c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SVEF32MM __khwcap2_feature(SVEF32MM) 1008c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SVEF64MM __khwcap2_feature(SVEF64MM) 1018c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_SVEBF16 __khwcap2_feature(SVEBF16) 1028c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_I8MM __khwcap2_feature(I8MM) 1038c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_BF16 __khwcap2_feature(BF16) 1048c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_DGH __khwcap2_feature(DGH) 1058c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_RNG __khwcap2_feature(RNG) 1068c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_BTI __khwcap2_feature(BTI) 1078c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_MTE __khwcap2_feature(MTE) 1088c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_ECV __khwcap2_feature(ECV) 1098c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_AFP __khwcap2_feature(AFP) 1108c2ecf20Sopenharmony_ci#define KERNEL_HWCAP_RPRES __khwcap2_feature(RPRES) 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/* 1138c2ecf20Sopenharmony_ci * This yields a mask that user programs can use to figure out what 1148c2ecf20Sopenharmony_ci * instruction set this cpu supports. 1158c2ecf20Sopenharmony_ci */ 1168c2ecf20Sopenharmony_ci#define ELF_HWCAP cpu_get_elf_hwcap() 1178c2ecf20Sopenharmony_ci#define ELF_HWCAP2 cpu_get_elf_hwcap2() 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#ifdef CONFIG_COMPAT 1208c2ecf20Sopenharmony_ci#define COMPAT_ELF_HWCAP (compat_elf_hwcap) 1218c2ecf20Sopenharmony_ci#define COMPAT_ELF_HWCAP2 (compat_elf_hwcap2) 1228c2ecf20Sopenharmony_ciextern unsigned int compat_elf_hwcap, compat_elf_hwcap2; 1238c2ecf20Sopenharmony_ci#endif 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_cienum { 1268c2ecf20Sopenharmony_ci CAP_HWCAP = 1, 1278c2ecf20Sopenharmony_ci#ifdef CONFIG_COMPAT 1288c2ecf20Sopenharmony_ci CAP_COMPAT_HWCAP, 1298c2ecf20Sopenharmony_ci CAP_COMPAT_HWCAP2, 1308c2ecf20Sopenharmony_ci#endif 1318c2ecf20Sopenharmony_ci}; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci#endif 1348c2ecf20Sopenharmony_ci#endif 135