162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2012 ARM Ltd. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci#ifndef __ASM_HWCAP_H 662306a36Sopenharmony_ci#define __ASM_HWCAP_H 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#include <uapi/asm/hwcap.h> 962306a36Sopenharmony_ci#include <asm/cpufeature.h> 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#define COMPAT_HWCAP_SWP (1 << 0) 1262306a36Sopenharmony_ci#define COMPAT_HWCAP_HALF (1 << 1) 1362306a36Sopenharmony_ci#define COMPAT_HWCAP_THUMB (1 << 2) 1462306a36Sopenharmony_ci#define COMPAT_HWCAP_26BIT (1 << 3) 1562306a36Sopenharmony_ci#define COMPAT_HWCAP_FAST_MULT (1 << 4) 1662306a36Sopenharmony_ci#define COMPAT_HWCAP_FPA (1 << 5) 1762306a36Sopenharmony_ci#define COMPAT_HWCAP_VFP (1 << 6) 1862306a36Sopenharmony_ci#define COMPAT_HWCAP_EDSP (1 << 7) 1962306a36Sopenharmony_ci#define COMPAT_HWCAP_JAVA (1 << 8) 2062306a36Sopenharmony_ci#define COMPAT_HWCAP_IWMMXT (1 << 9) 2162306a36Sopenharmony_ci#define COMPAT_HWCAP_CRUNCH (1 << 10) /* Obsolete */ 2262306a36Sopenharmony_ci#define COMPAT_HWCAP_THUMBEE (1 << 11) 2362306a36Sopenharmony_ci#define COMPAT_HWCAP_NEON (1 << 12) 2462306a36Sopenharmony_ci#define COMPAT_HWCAP_VFPv3 (1 << 13) 2562306a36Sopenharmony_ci#define COMPAT_HWCAP_VFPV3D16 (1 << 14) 2662306a36Sopenharmony_ci#define COMPAT_HWCAP_TLS (1 << 15) 2762306a36Sopenharmony_ci#define COMPAT_HWCAP_VFPv4 (1 << 16) 2862306a36Sopenharmony_ci#define COMPAT_HWCAP_IDIVA (1 << 17) 2962306a36Sopenharmony_ci#define COMPAT_HWCAP_IDIVT (1 << 18) 3062306a36Sopenharmony_ci#define COMPAT_HWCAP_IDIV (COMPAT_HWCAP_IDIVA|COMPAT_HWCAP_IDIVT) 3162306a36Sopenharmony_ci#define COMPAT_HWCAP_VFPD32 (1 << 19) 3262306a36Sopenharmony_ci#define COMPAT_HWCAP_LPAE (1 << 20) 3362306a36Sopenharmony_ci#define COMPAT_HWCAP_EVTSTRM (1 << 21) 3462306a36Sopenharmony_ci#define COMPAT_HWCAP_FPHP (1 << 22) 3562306a36Sopenharmony_ci#define COMPAT_HWCAP_ASIMDHP (1 << 23) 3662306a36Sopenharmony_ci#define COMPAT_HWCAP_ASIMDDP (1 << 24) 3762306a36Sopenharmony_ci#define COMPAT_HWCAP_ASIMDFHM (1 << 25) 3862306a36Sopenharmony_ci#define COMPAT_HWCAP_ASIMDBF16 (1 << 26) 3962306a36Sopenharmony_ci#define COMPAT_HWCAP_I8MM (1 << 27) 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci#define COMPAT_HWCAP2_AES (1 << 0) 4262306a36Sopenharmony_ci#define COMPAT_HWCAP2_PMULL (1 << 1) 4362306a36Sopenharmony_ci#define COMPAT_HWCAP2_SHA1 (1 << 2) 4462306a36Sopenharmony_ci#define COMPAT_HWCAP2_SHA2 (1 << 3) 4562306a36Sopenharmony_ci#define COMPAT_HWCAP2_CRC32 (1 << 4) 4662306a36Sopenharmony_ci#define COMPAT_HWCAP2_SB (1 << 5) 4762306a36Sopenharmony_ci#define COMPAT_HWCAP2_SSBS (1 << 6) 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 5062306a36Sopenharmony_ci#include <linux/log2.h> 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci/* 5362306a36Sopenharmony_ci * For userspace we represent hwcaps as a collection of HWCAP{,2}_x bitfields 5462306a36Sopenharmony_ci * as described in uapi/asm/hwcap.h. For the kernel we represent hwcaps as 5562306a36Sopenharmony_ci * natural numbers (in a single range of size MAX_CPU_FEATURES) defined here 5662306a36Sopenharmony_ci * with prefix KERNEL_HWCAP_ mapped to their HWCAP{,2}_x counterpart. 5762306a36Sopenharmony_ci * 5862306a36Sopenharmony_ci * Hwcaps should be set and tested within the kernel via the 5962306a36Sopenharmony_ci * cpu_{set,have}_named_feature(feature) where feature is the unique suffix 6062306a36Sopenharmony_ci * of KERNEL_HWCAP_{feature}. 6162306a36Sopenharmony_ci */ 6262306a36Sopenharmony_ci#define __khwcap_feature(x) const_ilog2(HWCAP_ ## x) 6362306a36Sopenharmony_ci#define KERNEL_HWCAP_FP __khwcap_feature(FP) 6462306a36Sopenharmony_ci#define KERNEL_HWCAP_ASIMD __khwcap_feature(ASIMD) 6562306a36Sopenharmony_ci#define KERNEL_HWCAP_EVTSTRM __khwcap_feature(EVTSTRM) 6662306a36Sopenharmony_ci#define KERNEL_HWCAP_AES __khwcap_feature(AES) 6762306a36Sopenharmony_ci#define KERNEL_HWCAP_PMULL __khwcap_feature(PMULL) 6862306a36Sopenharmony_ci#define KERNEL_HWCAP_SHA1 __khwcap_feature(SHA1) 6962306a36Sopenharmony_ci#define KERNEL_HWCAP_SHA2 __khwcap_feature(SHA2) 7062306a36Sopenharmony_ci#define KERNEL_HWCAP_CRC32 __khwcap_feature(CRC32) 7162306a36Sopenharmony_ci#define KERNEL_HWCAP_ATOMICS __khwcap_feature(ATOMICS) 7262306a36Sopenharmony_ci#define KERNEL_HWCAP_FPHP __khwcap_feature(FPHP) 7362306a36Sopenharmony_ci#define KERNEL_HWCAP_ASIMDHP __khwcap_feature(ASIMDHP) 7462306a36Sopenharmony_ci#define KERNEL_HWCAP_CPUID __khwcap_feature(CPUID) 7562306a36Sopenharmony_ci#define KERNEL_HWCAP_ASIMDRDM __khwcap_feature(ASIMDRDM) 7662306a36Sopenharmony_ci#define KERNEL_HWCAP_JSCVT __khwcap_feature(JSCVT) 7762306a36Sopenharmony_ci#define KERNEL_HWCAP_FCMA __khwcap_feature(FCMA) 7862306a36Sopenharmony_ci#define KERNEL_HWCAP_LRCPC __khwcap_feature(LRCPC) 7962306a36Sopenharmony_ci#define KERNEL_HWCAP_DCPOP __khwcap_feature(DCPOP) 8062306a36Sopenharmony_ci#define KERNEL_HWCAP_SHA3 __khwcap_feature(SHA3) 8162306a36Sopenharmony_ci#define KERNEL_HWCAP_SM3 __khwcap_feature(SM3) 8262306a36Sopenharmony_ci#define KERNEL_HWCAP_SM4 __khwcap_feature(SM4) 8362306a36Sopenharmony_ci#define KERNEL_HWCAP_ASIMDDP __khwcap_feature(ASIMDDP) 8462306a36Sopenharmony_ci#define KERNEL_HWCAP_SHA512 __khwcap_feature(SHA512) 8562306a36Sopenharmony_ci#define KERNEL_HWCAP_SVE __khwcap_feature(SVE) 8662306a36Sopenharmony_ci#define KERNEL_HWCAP_ASIMDFHM __khwcap_feature(ASIMDFHM) 8762306a36Sopenharmony_ci#define KERNEL_HWCAP_DIT __khwcap_feature(DIT) 8862306a36Sopenharmony_ci#define KERNEL_HWCAP_USCAT __khwcap_feature(USCAT) 8962306a36Sopenharmony_ci#define KERNEL_HWCAP_ILRCPC __khwcap_feature(ILRCPC) 9062306a36Sopenharmony_ci#define KERNEL_HWCAP_FLAGM __khwcap_feature(FLAGM) 9162306a36Sopenharmony_ci#define KERNEL_HWCAP_SSBS __khwcap_feature(SSBS) 9262306a36Sopenharmony_ci#define KERNEL_HWCAP_SB __khwcap_feature(SB) 9362306a36Sopenharmony_ci#define KERNEL_HWCAP_PACA __khwcap_feature(PACA) 9462306a36Sopenharmony_ci#define KERNEL_HWCAP_PACG __khwcap_feature(PACG) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#define __khwcap2_feature(x) (const_ilog2(HWCAP2_ ## x) + 64) 9762306a36Sopenharmony_ci#define KERNEL_HWCAP_DCPODP __khwcap2_feature(DCPODP) 9862306a36Sopenharmony_ci#define KERNEL_HWCAP_SVE2 __khwcap2_feature(SVE2) 9962306a36Sopenharmony_ci#define KERNEL_HWCAP_SVEAES __khwcap2_feature(SVEAES) 10062306a36Sopenharmony_ci#define KERNEL_HWCAP_SVEPMULL __khwcap2_feature(SVEPMULL) 10162306a36Sopenharmony_ci#define KERNEL_HWCAP_SVEBITPERM __khwcap2_feature(SVEBITPERM) 10262306a36Sopenharmony_ci#define KERNEL_HWCAP_SVESHA3 __khwcap2_feature(SVESHA3) 10362306a36Sopenharmony_ci#define KERNEL_HWCAP_SVESM4 __khwcap2_feature(SVESM4) 10462306a36Sopenharmony_ci#define KERNEL_HWCAP_FLAGM2 __khwcap2_feature(FLAGM2) 10562306a36Sopenharmony_ci#define KERNEL_HWCAP_FRINT __khwcap2_feature(FRINT) 10662306a36Sopenharmony_ci#define KERNEL_HWCAP_SVEI8MM __khwcap2_feature(SVEI8MM) 10762306a36Sopenharmony_ci#define KERNEL_HWCAP_SVEF32MM __khwcap2_feature(SVEF32MM) 10862306a36Sopenharmony_ci#define KERNEL_HWCAP_SVEF64MM __khwcap2_feature(SVEF64MM) 10962306a36Sopenharmony_ci#define KERNEL_HWCAP_SVEBF16 __khwcap2_feature(SVEBF16) 11062306a36Sopenharmony_ci#define KERNEL_HWCAP_I8MM __khwcap2_feature(I8MM) 11162306a36Sopenharmony_ci#define KERNEL_HWCAP_BF16 __khwcap2_feature(BF16) 11262306a36Sopenharmony_ci#define KERNEL_HWCAP_DGH __khwcap2_feature(DGH) 11362306a36Sopenharmony_ci#define KERNEL_HWCAP_RNG __khwcap2_feature(RNG) 11462306a36Sopenharmony_ci#define KERNEL_HWCAP_BTI __khwcap2_feature(BTI) 11562306a36Sopenharmony_ci#define KERNEL_HWCAP_MTE __khwcap2_feature(MTE) 11662306a36Sopenharmony_ci#define KERNEL_HWCAP_ECV __khwcap2_feature(ECV) 11762306a36Sopenharmony_ci#define KERNEL_HWCAP_AFP __khwcap2_feature(AFP) 11862306a36Sopenharmony_ci#define KERNEL_HWCAP_RPRES __khwcap2_feature(RPRES) 11962306a36Sopenharmony_ci#define KERNEL_HWCAP_MTE3 __khwcap2_feature(MTE3) 12062306a36Sopenharmony_ci#define KERNEL_HWCAP_SME __khwcap2_feature(SME) 12162306a36Sopenharmony_ci#define KERNEL_HWCAP_SME_I16I64 __khwcap2_feature(SME_I16I64) 12262306a36Sopenharmony_ci#define KERNEL_HWCAP_SME_F64F64 __khwcap2_feature(SME_F64F64) 12362306a36Sopenharmony_ci#define KERNEL_HWCAP_SME_I8I32 __khwcap2_feature(SME_I8I32) 12462306a36Sopenharmony_ci#define KERNEL_HWCAP_SME_F16F32 __khwcap2_feature(SME_F16F32) 12562306a36Sopenharmony_ci#define KERNEL_HWCAP_SME_B16F32 __khwcap2_feature(SME_B16F32) 12662306a36Sopenharmony_ci#define KERNEL_HWCAP_SME_F32F32 __khwcap2_feature(SME_F32F32) 12762306a36Sopenharmony_ci#define KERNEL_HWCAP_SME_FA64 __khwcap2_feature(SME_FA64) 12862306a36Sopenharmony_ci#define KERNEL_HWCAP_WFXT __khwcap2_feature(WFXT) 12962306a36Sopenharmony_ci#define KERNEL_HWCAP_EBF16 __khwcap2_feature(EBF16) 13062306a36Sopenharmony_ci#define KERNEL_HWCAP_SVE_EBF16 __khwcap2_feature(SVE_EBF16) 13162306a36Sopenharmony_ci#define KERNEL_HWCAP_CSSC __khwcap2_feature(CSSC) 13262306a36Sopenharmony_ci#define KERNEL_HWCAP_RPRFM __khwcap2_feature(RPRFM) 13362306a36Sopenharmony_ci#define KERNEL_HWCAP_SVE2P1 __khwcap2_feature(SVE2P1) 13462306a36Sopenharmony_ci#define KERNEL_HWCAP_SME2 __khwcap2_feature(SME2) 13562306a36Sopenharmony_ci#define KERNEL_HWCAP_SME2P1 __khwcap2_feature(SME2P1) 13662306a36Sopenharmony_ci#define KERNEL_HWCAP_SME_I16I32 __khwcap2_feature(SME_I16I32) 13762306a36Sopenharmony_ci#define KERNEL_HWCAP_SME_BI32I32 __khwcap2_feature(SME_BI32I32) 13862306a36Sopenharmony_ci#define KERNEL_HWCAP_SME_B16B16 __khwcap2_feature(SME_B16B16) 13962306a36Sopenharmony_ci#define KERNEL_HWCAP_SME_F16F16 __khwcap2_feature(SME_F16F16) 14062306a36Sopenharmony_ci#define KERNEL_HWCAP_MOPS __khwcap2_feature(MOPS) 14162306a36Sopenharmony_ci#define KERNEL_HWCAP_HBC __khwcap2_feature(HBC) 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_ci/* 14462306a36Sopenharmony_ci * This yields a mask that user programs can use to figure out what 14562306a36Sopenharmony_ci * instruction set this cpu supports. 14662306a36Sopenharmony_ci */ 14762306a36Sopenharmony_ci#define ELF_HWCAP cpu_get_elf_hwcap() 14862306a36Sopenharmony_ci#define ELF_HWCAP2 cpu_get_elf_hwcap2() 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci#ifdef CONFIG_COMPAT 15162306a36Sopenharmony_ci#define COMPAT_ELF_HWCAP (compat_elf_hwcap) 15262306a36Sopenharmony_ci#define COMPAT_ELF_HWCAP2 (compat_elf_hwcap2) 15362306a36Sopenharmony_ciextern unsigned int compat_elf_hwcap, compat_elf_hwcap2; 15462306a36Sopenharmony_ci#endif 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_cienum { 15762306a36Sopenharmony_ci CAP_HWCAP = 1, 15862306a36Sopenharmony_ci#ifdef CONFIG_COMPAT 15962306a36Sopenharmony_ci CAP_COMPAT_HWCAP, 16062306a36Sopenharmony_ci CAP_COMPAT_HWCAP2, 16162306a36Sopenharmony_ci#endif 16262306a36Sopenharmony_ci}; 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_ci#endif 16562306a36Sopenharmony_ci#endif 166