Guillaume Chatelet | 439d371 | 2018-02-01 10:03:09 +0100 | [diff] [blame] | 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 | |
Guillaume Chatelet | 8e58ef0 | 2018-02-01 10:38:48 +0100 | [diff] [blame] | 15 | #ifndef CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ |
| 16 | #define CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ |
Guillaume Chatelet | 439d371 | 2018-02-01 10:03:09 +0100 | [diff] [blame] | 17 | |
| 18 | #include "cpu_features_macros.h" |
Artem Alekseev | 653d581 | 2019-07-02 17:52:25 +0300 | [diff] [blame] | 19 | #include "cpu_features_cache_info.h" |
Guillaume Chatelet | 439d371 | 2018-02-01 10:03:09 +0100 | [diff] [blame] | 20 | |
Guillaume Chatelet | e419573 | 2018-02-12 16:15:15 +0100 | [diff] [blame] | 21 | CPU_FEATURES_START_CPP_NAMESPACE |
Guillaume Chatelet | 439d371 | 2018-02-01 10:03:09 +0100 | [diff] [blame] | 22 | |
| 23 | typedef struct { |
| 24 | int fp : 1; // Floating-point. |
| 25 | int asimd : 1; // Advanced SIMD. |
| 26 | int aes : 1; // Hardware-accelerated Advanced Encryption Standard. |
| 27 | int pmull : 1; // Polynomial multiply long. |
| 28 | int sha1 : 1; // Hardware-accelerated SHA1. |
| 29 | int sha2 : 1; // Hardware-accelerated SHA2-256. |
| 30 | int crc32 : 1; // Hardware-accelerated CRC-32. |
| 31 | |
| 32 | // Make sure to update Aarch64FeaturesEnum below if you add a field here. |
| 33 | } Aarch64Features; |
| 34 | |
| 35 | typedef struct { |
| 36 | Aarch64Features features; |
| 37 | int implementer; |
| 38 | int variant; |
| 39 | int part; |
| 40 | int revision; |
| 41 | } Aarch64Info; |
| 42 | |
| 43 | Aarch64Info GetAarch64Info(void); |
| 44 | |
| 45 | //////////////////////////////////////////////////////////////////////////////// |
| 46 | // Introspection functions |
| 47 | |
| 48 | typedef enum { |
| 49 | AARCH64_FP, |
| 50 | AARCH64_ASIMD, |
| 51 | AARCH64_AES, |
| 52 | AARCH64_PMULL, |
| 53 | AARCH64_SHA1, |
| 54 | AARCH64_SHA2, |
| 55 | AARCH64_CRC32, |
| 56 | AARCH64_LAST_, |
| 57 | } Aarch64FeaturesEnum; |
| 58 | |
| 59 | int GetAarch64FeaturesEnumValue(const Aarch64Features* features, |
| 60 | Aarch64FeaturesEnum value); |
| 61 | |
| 62 | const char* GetAarch64FeaturesEnumName(Aarch64FeaturesEnum); |
| 63 | |
Guillaume Chatelet | e419573 | 2018-02-12 16:15:15 +0100 | [diff] [blame] | 64 | CPU_FEATURES_END_CPP_NAMESPACE |
Guillaume Chatelet | 439d371 | 2018-02-01 10:03:09 +0100 | [diff] [blame] | 65 | |
Guillaume Chatelet | 4155ee7 | 2019-01-18 13:38:22 +0100 | [diff] [blame] | 66 | #if !defined(CPU_FEATURES_ARCH_AARCH64) |
| 67 | #error "Including cpuinfo_aarch64.h from a non-aarch64 target." |
| 68 | #endif |
| 69 | |
Guillaume Chatelet | 8e58ef0 | 2018-02-01 10:38:48 +0100 | [diff] [blame] | 70 | #endif // CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ |