cpu-feature: Support Via Padlock security features
[strongswan.git] / src / libstrongswan / utils / cpu_feature.h
1 /*
2 * Copyright (C) 2015 Martin Willi
3 * Copyright (C) 2015 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup cpu_feature cpu_feature
18 * @{ @ingroup utils
19 */
20
21 #ifndef CPU_FEATURE_H_
22 #define CPU_FEATURE_H_
23
24 #include <library.h>
25
26 typedef enum {
27 /** x86/x64 extensions */
28 CPU_FEATURE_MMX = (1 << 0),
29 CPU_FEATURE_SSE = (1 << 1),
30 CPU_FEATURE_SSE2 = (1 << 2),
31 CPU_FEATURE_SSE3 = (1 << 3),
32 CPU_FEATURE_SSSE3 = (1 << 4),
33 CPU_FEATURE_SSE41 = (1 << 5),
34 CPU_FEATURE_SSE42 = (1 << 6),
35 CPU_FEATURE_AVX = (1 << 7),
36 CPU_FEATURE_RDRAND = (1 << 8),
37 CPU_FEATURE_AESNI = (1 << 9),
38 CPU_FEATURE_PCLMULQDQ = (1 << 10),
39 /** Via Padlock Security features */
40 CPU_FEATURE_PADLOCK_RNG_AVAILABLE = (1 << 22),
41 CPU_FEATURE_PADLOCK_RNG_ENABLED = (1 << 23),
42 CPU_FEATURE_PADLOCK_ACE_AVAILABLE = (1 << 24),
43 CPU_FEATURE_PADLOCK_ACE_ENABLED = (1 << 25),
44 CPU_FEATURE_PADLOCK_ACE2_AVAILABLE = (1 << 26),
45 CPU_FEATURE_PADLOCK_ACE2_ENABLED = (1 << 27),
46 CPU_FEATURE_PADLOCK_PHE_AVAILABLE = (1 << 28),
47 CPU_FEATURE_PADLOCK_PHE_ENABLED = (1 << 29),
48 CPU_FEATURE_PADLOCK_PMM_AVAILABLE = (1 << 30),
49 CPU_FEATURE_PADLOCK_PMM_ENABLED = (1 << 31),
50 } cpu_feature_t;
51
52 /**
53 * Get a bitmask for all supported CPU features
54 */
55 cpu_feature_t cpu_feature_get_all();
56
57 /**
58 * Check if a given set of CPU features is available.
59 */
60 bool cpu_feature_available(cpu_feature_t feature);
61
62 #endif /** CPU_FEATURE_H_ @}*/