blob: d15471f73037b7dd2610d602dc28bbced35c8a1f [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"
Artem Alekseev653d5812019-07-02 17:52:25 +030020#include "cpu_features_cache_info.h"
Guillaume Chatelet439d3712018-02-01 10:03:09 +010021
Guillaume Chatelete4195732018-02-12 16:15:15 +010022CPU_FEATURES_START_CPP_NAMESPACE
Guillaume Chatelet439d3712018-02-01 10:03:09 +010023
24typedef struct {
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020025 int swp : 1; // SWP instruction (atomic read-modify-write)
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020026 int half : 1; // Half-word loads and stores
27 int thumb : 1; // Thumb (16-bit instruction set)
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020028 int _26bit : 1; // "26 Bit" Model (Processor status register folded into program counter)
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020029 int fastmult : 1; // 32x32->64-bit multiplication
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020030 int fpa : 1; // Floating point accelerator
Guillaume Chatelet439d3712018-02-01 10:03:09 +010031 int vfp : 1; // Vector Floating Point.
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020032 int edsp : 1; // DSP extensions (the 'e' variant of the ARM9 CPUs, and all others above)
33 int java : 1; // Jazelle (Java bytecode accelerator)
Guillaume Chatelet439d3712018-02-01 10:03:09 +010034 int iwmmxt : 1; // Intel Wireless MMX Technology.
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020035 int crunch : 1; // MaverickCrunch coprocessor
36 int thumbee : 1; // ThumbEE
Guillaume Chatelet439d3712018-02-01 10:03:09 +010037 int neon : 1; // Advanced SIMD.
38 int vfpv3 : 1; // VFP version 3
39 int vfpv3d16 : 1; // VFP version 3 with 16 D-registers
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020040 int tls : 1; // TLS register
Guillaume Chatelet439d3712018-02-01 10:03:09 +010041 int vfpv4 : 1; // VFP version 4 with fast context switching
42 int idiva : 1; // SDIV and UDIV hardware division in ARM mode.
43 int idivt : 1; // SDIV and UDIV hardware division in Thumb mode.
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020044 int vfpd32 : 1; // VFP with 32 D-registers
45 int lpae : 1; // Large Physical Address Extension (>4GB physical memory on 32-bit architecture)
46 int evtstrm : 1; // kernel event stream using generic architected timer
Guillaume Chatelet439d3712018-02-01 10:03:09 +010047 int aes : 1; // Hardware-accelerated Advanced Encryption Standard.
48 int pmull : 1; // Polynomial multiply long.
49 int sha1 : 1; // Hardware-accelerated SHA1.
50 int sha2 : 1; // Hardware-accelerated SHA2-256.
51 int crc32 : 1; // Hardware-accelerated CRC-32.
52
53 // Make sure to update ArmFeaturesEnum below if you add a field here.
54} ArmFeatures;
55
56typedef struct {
57 ArmFeatures features;
58 int implementer;
59 int architecture;
60 int variant;
61 int part;
62 int revision;
63} ArmInfo;
64
65// TODO(user): Add macros to know which features are present at compile
66// time.
67
68ArmInfo GetArmInfo(void);
69
Guillaume Chatelet918553a2019-01-17 15:28:04 +010070// Compute CpuId from ArmInfo.
71uint32_t GetArmCpuId(const ArmInfo* const info);
72
Guillaume Chatelet439d3712018-02-01 10:03:09 +010073////////////////////////////////////////////////////////////////////////////////
74// Introspection functions
75
76typedef enum {
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020077 ARM_SWP,
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020078 ARM_HALF,
79 ARM_THUMB,
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020080 ARM_26BIT,
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020081 ARM_FASTMULT,
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020082 ARM_FPA,
Guillaume Chatelet439d3712018-02-01 10:03:09 +010083 ARM_VFP,
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020084 ARM_EDSP,
85 ARM_JAVA,
Guillaume Chatelet439d3712018-02-01 10:03:09 +010086 ARM_IWMMXT,
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020087 ARM_CRUNCH,
88 ARM_THUMBEE,
Guillaume Chatelet439d3712018-02-01 10:03:09 +010089 ARM_NEON,
90 ARM_VFPV3,
91 ARM_VFPV3D16,
Dr.-Ing. Patrick Siegl6482bad2019-06-18 12:53:08 +020092 ARM_TLS,
Guillaume Chatelet439d3712018-02-01 10:03:09 +010093 ARM_VFPV4,
94 ARM_IDIVA,
95 ARM_IDIVT,
Dr.-Ing. Patrick Sieglbfd109b2019-06-26 12:56:52 +020096 ARM_VFPD32,
97 ARM_LPAE,
98 ARM_EVTSTRM,
Guillaume Chatelet439d3712018-02-01 10:03:09 +010099 ARM_AES,
100 ARM_PMULL,
101 ARM_SHA1,
102 ARM_SHA2,
103 ARM_CRC32,
104 ARM_LAST_,
105} ArmFeaturesEnum;
106
107int GetArmFeaturesEnumValue(const ArmFeatures* features, ArmFeaturesEnum value);
108
109const char* GetArmFeaturesEnumName(ArmFeaturesEnum);
110
Guillaume Chatelete4195732018-02-12 16:15:15 +0100111CPU_FEATURES_END_CPP_NAMESPACE
Guillaume Chatelet439d3712018-02-01 10:03:09 +0100112
Guillaume Chatelet4155ee72019-01-18 13:38:22 +0100113#if !defined(CPU_FEATURES_ARCH_ARM)
114#error "Including cpuinfo_arm.h from a non-arm target."
115#endif
116
Guillaume Chatelet8e58ef02018-02-01 10:38:48 +0100117#endif // CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_