blob: bd92ac80fcd80daa5ff6f896a01bb7158171f7f8 [file] [log] [blame]
Guillaume Chatelet439d3712018-02-01 10:03:09 +01001// 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
Guillaume Chatelet8e58ef02018-02-01 10:38:48 +010015#ifndef CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_
16#define CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_
Guillaume Chatelet439d3712018-02-01 10:03:09 +010017
Guillaume Chatelet918553a2019-01-17 15:28:04 +010018#include <stdint.h> // uint32_t
Guillaume Chatelet439d3712018-02-01 10:03:09 +010019#include "cpu_features_macros.h"
20
Guillaume Chatelete4195732018-02-12 16:15:15 +010021CPU_FEATURES_START_CPP_NAMESPACE
Guillaume Chatelet439d3712018-02-01 10:03:09 +010022
23typedef struct {
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020024 int swp : 1; // SWP instruction (atomic read-modify-write)
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020025 int half : 1; // Half-word loads and stores
26 int thumb : 1; // Thumb (16-bit instruction set)
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020027 int _26bit : 1; // "26 Bit" Model (Processor status register folded into program counter)
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020028 int fastmult : 1; // 32x32->64-bit multiplication
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020029 int fpa : 1; // Floating point accelerator
Guillaume Chatelet439d3712018-02-01 10:03:09 +010030 int vfp : 1; // Vector Floating Point.
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020031 int edsp : 1; // DSP extensions (the 'e' variant of the ARM9 CPUs, and all others above)
32 int java : 1; // Jazelle (Java bytecode accelerator)
Guillaume Chatelet439d3712018-02-01 10:03:09 +010033 int iwmmxt : 1; // Intel Wireless MMX Technology.
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020034 int crunch : 1; // MaverickCrunch coprocessor
35 int thumbee : 1; // ThumbEE
Guillaume Chatelet439d3712018-02-01 10:03:09 +010036 int neon : 1; // Advanced SIMD.
37 int vfpv3 : 1; // VFP version 3
38 int vfpv3d16 : 1; // VFP version 3 with 16 D-registers
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020039 int tls : 1; // TLS register
Guillaume Chatelet439d3712018-02-01 10:03:09 +010040 int vfpv4 : 1; // VFP version 4 with fast context switching
41 int idiva : 1; // SDIV and UDIV hardware division in ARM mode.
42 int idivt : 1; // SDIV and UDIV hardware division in Thumb mode.
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020043 int vfpd32 : 1; // VFP with 32 D-registers
44 int lpae : 1; // Large Physical Address Extension (>4GB physical memory on 32-bit architecture)
45 int evtstrm : 1; // kernel event stream using generic architected timer
Guillaume Chatelet439d3712018-02-01 10:03:09 +010046 int aes : 1; // Hardware-accelerated Advanced Encryption Standard.
47 int pmull : 1; // Polynomial multiply long.
48 int sha1 : 1; // Hardware-accelerated SHA1.
49 int sha2 : 1; // Hardware-accelerated SHA2-256.
50 int crc32 : 1; // Hardware-accelerated CRC-32.
51
52 // Make sure to update ArmFeaturesEnum below if you add a field here.
53} ArmFeatures;
54
55typedef struct {
56 ArmFeatures features;
57 int implementer;
58 int architecture;
59 int variant;
60 int part;
61 int revision;
62} ArmInfo;
63
64// TODO(user): Add macros to know which features are present at compile
65// time.
66
67ArmInfo GetArmInfo(void);
68
Guillaume Chatelet918553a2019-01-17 15:28:04 +010069// Compute CpuId from ArmInfo.
70uint32_t GetArmCpuId(const ArmInfo* const info);
71
Guillaume Chatelet439d3712018-02-01 10:03:09 +010072////////////////////////////////////////////////////////////////////////////////
73// Introspection functions
74
75typedef enum {
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020076 ARM_SWP,
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020077 ARM_HALF,
78 ARM_THUMB,
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020079 ARM_26BIT,
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020080 ARM_FASTMULT,
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020081 ARM_FPA,
Guillaume Chatelet439d3712018-02-01 10:03:09 +010082 ARM_VFP,
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020083 ARM_EDSP,
84 ARM_JAVA,
Guillaume Chatelet439d3712018-02-01 10:03:09 +010085 ARM_IWMMXT,
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020086 ARM_CRUNCH,
87 ARM_THUMBEE,
Guillaume Chatelet439d3712018-02-01 10:03:09 +010088 ARM_NEON,
89 ARM_VFPV3,
90 ARM_VFPV3D16,
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020091 ARM_TLS,
Guillaume Chatelet439d3712018-02-01 10:03:09 +010092 ARM_VFPV4,
93 ARM_IDIVA,
94 ARM_IDIVT,
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020095 ARM_VFPD32,
96 ARM_LPAE,
97 ARM_EVTSTRM,
Guillaume Chatelet439d3712018-02-01 10:03:09 +010098 ARM_AES,
99 ARM_PMULL,
100 ARM_SHA1,
101 ARM_SHA2,
102 ARM_CRC32,
103 ARM_LAST_,
104} ArmFeaturesEnum;
105
106int GetArmFeaturesEnumValue(const ArmFeatures* features, ArmFeaturesEnum value);
107
108const char* GetArmFeaturesEnumName(ArmFeaturesEnum);
109
Guillaume Chatelete4195732018-02-12 16:15:15 +0100110CPU_FEATURES_END_CPP_NAMESPACE
Guillaume Chatelet439d3712018-02-01 10:03:09 +0100111
Guillaume Chatelet4155ee72019-01-18 13:38:22 +0100112#if !defined(CPU_FEATURES_ARCH_ARM)
113#error "Including cpuinfo_arm.h from a non-arm target."
114#endif
115
Guillaume Chatelet8e58ef02018-02-01 10:38:48 +0100116#endif // CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_