cpuid.h
1 /* cpuid.h
2  *
3  * Copyright (C) 2006-2020 wolfSSL Inc.
4  *
5  * This file is part of wolfSSL.
6  *
7  * wolfSSL is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * wolfSSL is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20  */
21 
22 
23 
24 #ifndef WOLF_CRYPT_CPUID_H
25 #define WOLF_CRYPT_CPUID_H
26 
27 
29 
30 
31 #ifdef __cplusplus
32  extern "C" {
33 #endif
34 
35 #if defined(WOLFSSL_X86_64_BUILD) || defined(USE_INTEL_SPEEDUP) || \
36  defined(WOLFSSL_AESNI)
37  #define CPUID_AVX1 0x0001
38  #define CPUID_AVX2 0x0002
39  #define CPUID_RDRAND 0x0004
40  #define CPUID_RDSEED 0x0008
41  #define CPUID_BMI2 0x0010 /* MULX, RORX */
42  #define CPUID_AESNI 0x0020
43  #define CPUID_ADX 0x0040 /* ADCX, ADOX */
44 
45  #define IS_INTEL_AVX1(f) ((f) & CPUID_AVX1)
46  #define IS_INTEL_AVX2(f) ((f) & CPUID_AVX2)
47  #define IS_INTEL_RDRAND(f) ((f) & CPUID_RDRAND)
48  #define IS_INTEL_RDSEED(f) ((f) & CPUID_RDSEED)
49  #define IS_INTEL_BMI2(f) ((f) & CPUID_BMI2)
50  #define IS_INTEL_AESNI(f) ((f) & CPUID_AESNI)
51  #define IS_INTEL_ADX(f) ((f) & CPUID_ADX)
52 
53  void cpuid_set_flags(void);
54  word32 cpuid_get_flags(void);
55 #endif
56 
57 #ifdef __cplusplus
58  } /* extern "C" */
59 #endif
60 
61 
62 #endif /* WOLF_CRYPT_CPUID_H */