blob: eabf4eac384663d50454ee01b5f63bb65eda04f1 [file] [log] [blame]
David Benjamin8cd61f72018-08-31 15:37:56 -05001/* Copyright (c) 2018, 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#ifndef OPENSSL_HEADER_CRYPTO_CPU_ARM_LINUX_H
16#define OPENSSL_HEADER_CRYPTO_CPU_ARM_LINUX_H
17
18#include <openssl/base.h>
19
20#if defined(__cplusplus)
21extern "C" {
22#endif
23
24
25// The following symbols are defined on all platforms and exported for testing
26// and fuzzing purposes. They are not exported from the shared library so the
27// static linker will drop them outside of tests.
28
29#define HWCAP_NEON (1 << 12)
30
31// See /usr/include/asm/hwcap.h on an ARM installation for the source of
32// these values.
33#define HWCAP2_AES (1 << 0)
34#define HWCAP2_PMULL (1 << 1)
35#define HWCAP2_SHA1 (1 << 2)
36#define HWCAP2_SHA2 (1 << 3)
37
38typedef struct {
39 const char *data;
40 size_t len;
41} STRING_PIECE;
42
43// crypto_get_arm_hwcap_from_cpuinfo returns an equivalent ARM |AT_HWCAP| value
44// from |cpuinfo|.
45unsigned long crypto_get_arm_hwcap_from_cpuinfo(const STRING_PIECE *cpuinfo);
46
47// crypto_get_arm_hwcap2_from_cpuinfo returns an equivalent ARM |AT_HWCAP2|
48// value from |cpuinfo|.
49unsigned long crypto_get_arm_hwcap2_from_cpuinfo(const STRING_PIECE *cpuinfo);
50
51// crypto_cpuinfo_has_broken_neon returns one if |cpuinfo| matches a CPU known
52// to have broken NEON unit and zero otherwise. See https://crbug.com/341598.
53int crypto_cpuinfo_has_broken_neon(const STRING_PIECE *cpuinfo);
54
55#if defined(__cplusplus)
56} // extern C
57#endif
58
59#endif // OPENSSL_HEADER_CRYPTO_CPU_ARM_LINUX_H