TianoCore EDK2 master
Loading...
Searching...
No Matches
AArch64Cap.c
Go to the documentation of this file.
1
9#include <openssl/types.h>
10#include "crypto/arm_arch.h"
11
12#include <Library/BaseLib.h>
13
24#define GET_BITFIELD(value, shift, mask) \
25 ((value >> shift) & mask)
26
27UINT32 OPENSSL_armcap_P = 0;
28
29void
31 void
32 )
33{
34 UINT64 Isar0;
35
36 OPENSSL_armcap_P = 0;
37 Isar0 = ArmReadIdAA64Isar0Reg ();
38
39 /* Access to EL0 registers is possible from higher ELx. */
40 OPENSSL_armcap_P |= ARMV8_CPUID;
41 /* Access to Physical timer is possible. */
42 OPENSSL_armcap_P |= ARMV7_TICK;
43
44 /* Neon support is not guaranteed, but it is assumed to be present.
45 Arm ARM for Armv8, sA1.5 Advanced SIMD and floating-point support
46 */
47 OPENSSL_armcap_P |= ARMV7_NEON;
48
49 if (GET_BITFIELD (
50 Isar0,
51 ARM_ID_AA64ISAR0_EL1_AES_SHIFT,
52 ARM_ID_AA64ISAR0_EL1_AES_MASK
53 ) != 0)
54 {
55 OPENSSL_armcap_P |= ARMV8_AES;
56 }
57
58 if (GET_BITFIELD (
59 Isar0,
60 ARM_ID_AA64ISAR0_EL1_SHA1_SHIFT,
61 ARM_ID_AA64ISAR0_EL1_SHA1_MASK
62 ) != 0)
63 {
64 OPENSSL_armcap_P |= ARMV8_SHA1;
65 }
66
67 if (GET_BITFIELD (
68 Isar0,
69 ARM_ID_AA64ISAR0_EL1_SHA2_SHIFT,
70 ARM_ID_AA64ISAR0_EL1_SHA2_MASK
71 ) != 0)
72 {
73 OPENSSL_armcap_P |= ARMV8_SHA256;
74 }
75
76 if (GET_BITFIELD (
77 Isar0,
78 ARM_ID_AA64ISAR0_EL1_AES_SHIFT,
79 ARM_ID_AA64ISAR0_EL1_AES_MASK
80 ) >= ARM_ID_AA64ISAR0_EL1_AES_FEAT_PMULL_MASK)
81 {
82 OPENSSL_armcap_P |= ARMV8_PMULL;
83 }
84
85 if (GET_BITFIELD (
86 Isar0,
87 ARM_ID_AA64ISAR0_EL1_SHA2_SHIFT,
88 ARM_ID_AA64ISAR0_EL1_SHA2_MASK
89 ) >= ARM_ID_AA64ISAR0_EL1_SHA2_FEAT_SHA512_MASK)
90 {
91 OPENSSL_armcap_P |= ARMV8_SHA512;
92 }
93}
94
101uint32_t
103 void
104 )
105{
106 return (UINT32)ArmReadCntPctReg ();
107}
#define GET_BITFIELD(value, shift, mask)
Definition: AArch64Cap.c:24
uint32_t OPENSSL_rdtsc(void)
Definition: AArch64Cap.c:102
VOID OPENSSL_cpuid_setup(VOID)