blob: 6cc8aee5240051a9f393613a2f56d2f1c31a0e19 [file] [log] [blame]
Steven Valdezbb1ceac2016-10-07 10:34:51 -04001/* Copyright (c) 2016, Google Inc.
2 *
3 * Permission to use, copy, modify, and/or distribute this software for any
4 * purpose with or without fee is hereby granted, provided that the above
5 * copyright notice and this permission notice appear in all copies.
6 *
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14
15#include <openssl/cpu.h>
16
17#if defined(OPENSSL_PPC64LE)
18
19#include <sys/auxv.h>
20
21#include "internal.h"
22
23
24#if !defined(PPC_FEATURE2_HAS_VCRYPTO)
Robert Sloan8f860b12017-08-28 07:37:06 -070025// PPC_FEATURE2_HAS_VCRYPTO was taken from section 4.1.2.3 of the “OpenPOWER
26// ABI for Linux Supplement”.
Steven Valdezbb1ceac2016-10-07 10:34:51 -040027#define PPC_FEATURE2_HAS_VCRYPTO 0x02000000
28#endif
29
Steven Valdezbb1ceac2016-10-07 10:34:51 -040030void OPENSSL_cpuid_setup(void) {
Robert Sloan572a4e22017-04-17 10:52:19 -070031 OPENSSL_ppc64le_hwcap2 = getauxval(AT_HWCAP2);
Steven Valdezbb1ceac2016-10-07 10:34:51 -040032}
33
34int CRYPTO_is_PPC64LE_vcrypto_capable(void) {
Robert Sloan572a4e22017-04-17 10:52:19 -070035 return (OPENSSL_ppc64le_hwcap2 & PPC_FEATURE2_HAS_VCRYPTO) != 0;
Steven Valdezbb1ceac2016-10-07 10:34:51 -040036}
37
Robert Sloan8f860b12017-08-28 07:37:06 -070038#endif // OPENSSL_PPC64LE