830cde3167e78dce3a6ed375886408cab8172180
[iec.git] / src / type3_AndroidCloud / anbox-master / external / cpu_features / include / internal / hwcaps.h
1 // Copyright 2017 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Interface to retrieve hardware capabilities. It relies on Linux's getauxval
16 // or `/proc/self/auxval` under the hood.
17 #ifndef CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_
18 #define CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_
19
20 #include <stdint.h>
21 #include "cpu_features_macros.h"
22
23 CPU_FEATURES_START_CPP_NAMESPACE
24
25 // To avoid depending on the linux kernel we reproduce the architecture specific
26 // constants here.
27
28 // http://elixir.free-electrons.com/linux/latest/source/arch/arm64/include/uapi/asm/hwcap.h
29 #define AARCH64_HWCAP_FP (1UL << 0)
30 #define AARCH64_HWCAP_ASIMD (1UL << 1)
31 #define AARCH64_HWCAP_AES (1UL << 3)
32 #define AARCH64_HWCAP_PMULL (1UL << 4)
33 #define AARCH64_HWCAP_SHA1 (1UL << 5)
34 #define AARCH64_HWCAP_SHA2 (1UL << 6)
35 #define AARCH64_HWCAP_CRC32 (1UL << 7)
36
37 // http://elixir.free-electrons.com/linux/latest/source/arch/arm/include/uapi/asm/hwcap.h
38 #define ARM_HWCAP_VFP (1UL << 6)
39 #define ARM_HWCAP_IWMMXT (1UL << 9)
40 #define ARM_HWCAP_NEON (1UL << 12)
41 #define ARM_HWCAP_VFPV3 (1UL << 13)
42 #define ARM_HWCAP_VFPV3D16 (1UL << 14)
43 #define ARM_HWCAP_VFPV4 (1UL << 16)
44 #define ARM_HWCAP_IDIVA (1UL << 17)
45 #define ARM_HWCAP_IDIVT (1UL << 18)
46 #define ARM_HWCAP2_AES (1UL << 0)
47 #define ARM_HWCAP2_PMULL (1UL << 1)
48 #define ARM_HWCAP2_SHA1 (1UL << 2)
49 #define ARM_HWCAP2_SHA2 (1UL << 3)
50 #define ARM_HWCAP2_CRC32 (1UL << 4)
51
52 // http://elixir.free-electrons.com/linux/latest/source/arch/mips/include/uapi/asm/hwcap.h
53 #define MIPS_HWCAP_VZ (1UL << 0)
54 #define MIPS_HWCAP_EVA (1UL << 1)
55 #define MIPS_HWCAP_HTW (1UL << 2)
56 #define MIPS_HWCAP_FPU (1UL << 3)
57 #define MIPS_HWCAP_MIPS32R2 (1UL << 4)
58 #define MIPS_HWCAP_MIPS32R5 (1UL << 5)
59 #define MIPS_HWCAP_MIPS64R6 (1UL << 6)
60 #define MIPS_HWCAP_DSPR1 (1UL << 7)
61 #define MIPS_HWCAP_DSPR2 (1UL << 8)
62 #define MIPS_HWCAP_MSA (1UL << 9)
63
64 // http://elixir.free-electrons.com/linux/latest/source/arch/powerpc/include/uapi/asm/cputable.h
65 #ifndef _UAPI__ASM_POWERPC_CPUTABLE_H
66 /* in AT_HWCAP */
67 #define PPC_FEATURE_32 0x80000000
68 #define PPC_FEATURE_64 0x40000000
69 #define PPC_FEATURE_601_INSTR 0x20000000
70 #define PPC_FEATURE_HAS_ALTIVEC 0x10000000
71 #define PPC_FEATURE_HAS_FPU 0x08000000
72 #define PPC_FEATURE_HAS_MMU 0x04000000
73 #define PPC_FEATURE_HAS_4xxMAC 0x02000000
74 #define PPC_FEATURE_UNIFIED_CACHE 0x01000000
75 #define PPC_FEATURE_HAS_SPE 0x00800000
76 #define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000
77 #define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000
78 #define PPC_FEATURE_NO_TB 0x00100000
79 #define PPC_FEATURE_POWER4 0x00080000
80 #define PPC_FEATURE_POWER5 0x00040000
81 #define PPC_FEATURE_POWER5_PLUS 0x00020000
82 #define PPC_FEATURE_CELL 0x00010000
83 #define PPC_FEATURE_BOOKE 0x00008000
84 #define PPC_FEATURE_SMT 0x00004000
85 #define PPC_FEATURE_ICACHE_SNOOP 0x00002000
86 #define PPC_FEATURE_ARCH_2_05 0x00001000
87 #define PPC_FEATURE_PA6T 0x00000800
88 #define PPC_FEATURE_HAS_DFP 0x00000400
89 #define PPC_FEATURE_POWER6_EXT 0x00000200
90 #define PPC_FEATURE_ARCH_2_06 0x00000100
91 #define PPC_FEATURE_HAS_VSX 0x00000080
92
93 #define PPC_FEATURE_PSERIES_PERFMON_COMPAT 0x00000040
94
95 /* Reserved - do not use                0x00000004 */
96 #define PPC_FEATURE_TRUE_LE 0x00000002
97 #define PPC_FEATURE_PPC_LE 0x00000001
98
99 /* in AT_HWCAP2 */
100 #define PPC_FEATURE2_ARCH_2_07 0x80000000
101 #define PPC_FEATURE2_HTM 0x40000000
102 #define PPC_FEATURE2_DSCR 0x20000000
103 #define PPC_FEATURE2_EBB 0x10000000
104 #define PPC_FEATURE2_ISEL 0x08000000
105 #define PPC_FEATURE2_TAR 0x04000000
106 #define PPC_FEATURE2_VEC_CRYPTO 0x02000000
107 #define PPC_FEATURE2_HTM_NOSC 0x01000000
108 #define PPC_FEATURE2_ARCH_3_00 0x00800000
109 #define PPC_FEATURE2_HAS_IEEE128 0x00400000
110 #define PPC_FEATURE2_DARN 0x00200000
111 #define PPC_FEATURE2_SCV 0x00100000
112 #define PPC_FEATURE2_HTM_NO_SUSPEND 0x00080000
113 #endif
114
115 typedef struct {
116   unsigned long hwcaps;
117   unsigned long hwcaps2;
118 } HardwareCapabilities;
119
120 HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void);
121
122 typedef struct {
123   char platform[64];       // 0 terminated string
124   char base_platform[64];  // 0 terminated string
125 } PlatformType;
126
127 PlatformType CpuFeatures_GetPlatformType(void);
128
129 CPU_FEATURES_END_CPP_NAMESPACE
130
131 #endif  // CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_