Pete Bentley | 1748611 | 2021-01-20 11:51:47 +0000 | [diff] [blame^] | 1 | /* Copyright (c) 2018, Google Inc. |
| 2 | * Copyright (c) 2020, Arm Ltd. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ |
| 15 | |
| 16 | #include <openssl/cpu.h> |
| 17 | |
| 18 | #if defined(OPENSSL_AARCH64) && defined(OPENSSL_WINDOWS) && \ |
| 19 | !defined(OPENSSL_STATIC_ARMCAP) |
| 20 | |
| 21 | #include <windows.h> |
| 22 | |
| 23 | #include <openssl/arm_arch.h> |
| 24 | |
| 25 | #include "internal.h" |
| 26 | |
| 27 | extern uint32_t OPENSSL_armcap_P; |
| 28 | void OPENSSL_cpuid_setup(void) { |
| 29 | // We do not need to check for the presence of NEON, as Armv8-A always has it |
| 30 | OPENSSL_armcap_P |= ARMV7_NEON; |
| 31 | |
| 32 | if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE)) { |
| 33 | // These are all covered by one call in Windows |
| 34 | OPENSSL_armcap_P |= ARMV8_AES; |
| 35 | OPENSSL_armcap_P |= ARMV8_PMULL; |
| 36 | OPENSSL_armcap_P |= ARMV8_SHA1; |
| 37 | OPENSSL_armcap_P |= ARMV8_SHA256; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | #endif |