OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /* | 7 /* |
8 * This module provides a simple abstraction for using the CPUID | 8 * This module provides a simple abstraction for using the CPUID |
9 * instruction to determine instruction set extensions supported by | 9 * instruction to determine instruction set extensions supported by |
10 * the current processor. | 10 * the current processor. |
11 */ | 11 */ |
12 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NACL_CPUID_H_ | 12 #ifndef NATIVE_CLIENT_SRC_TRUSTED_CPU_FEATURES_ARCH_X86_CPU_X86_H_ |
13 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NACL_CPUID_H_ | 13 #define NATIVE_CLIENT_SRC_TRUSTED_CPU_FEATURES_ARCH_X86_CPU_X86_H_ |
14 | 14 |
15 #include "native_client/src/include/portability.h" | 15 #include "native_client/src/include/portability.h" |
16 #include "native_client/src/trusted/validator/ncvalidate.h" | 16 #include "native_client/src/trusted/validator/ncvalidate.h" |
17 | 17 |
18 | 18 |
19 EXTERN_C_BEGIN | 19 EXTERN_C_BEGIN |
20 | 20 |
21 /* The list of features we can get from the CPUID instruction. | 21 /* The list of features we can get from the CPUID instruction. |
22 * Do not modify this enum without making similar modifications to | 22 * Do not modify this enum without making similar modifications to |
23 * CPUFeatureDescriptions in nacl_cpuid.c. | 23 * CPUFeatureDescriptions in cpu_x86.c. |
24 */ | 24 */ |
25 typedef enum { | 25 typedef enum { |
26 NaClCPUFeatureX86_CPUIDSupported, | 26 NaClCPUFeatureX86_CPUIDSupported, |
27 NaClCPUFeatureX86_CPUSupported, /* CPU is one we support. */ | 27 NaClCPUFeatureX86_CPUSupported, /* CPU is one we support. */ |
28 NaClCPUFeatureX86_3DNOW, /* AMD-specific */ | 28 NaClCPUFeatureX86_3DNOW, /* AMD-specific */ |
29 NaClCPUFeatureX86_AES, | 29 NaClCPUFeatureX86_AES, |
30 NaClCPUFeatureX86_AVX, | 30 NaClCPUFeatureX86_AVX, |
31 NaClCPUFeatureX86_BMI1, | 31 NaClCPUFeatureX86_BMI1, |
32 NaClCPUFeatureX86_CLFLUSH, | 32 NaClCPUFeatureX86_CLFLUSH, |
33 NaClCPUFeatureX86_CLMUL, | 33 NaClCPUFeatureX86_CLMUL, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } NaClCPUFeatureX86ID; | 65 } NaClCPUFeatureX86ID; |
66 | 66 |
67 /* Features we can get about the x86 hardware. */ | 67 /* Features we can get about the x86 hardware. */ |
68 typedef struct cpu_feature_struct_X86 { | 68 typedef struct cpu_feature_struct_X86 { |
69 char data[NaClCPUFeatureX86_Max]; | 69 char data[NaClCPUFeatureX86_Max]; |
70 } NaClCPUFeaturesX86; | 70 } NaClCPUFeaturesX86; |
71 | 71 |
72 /* Define the maximum length of a CPUID string. | 72 /* Define the maximum length of a CPUID string. |
73 * | 73 * |
74 * Note: If you change this length, fix the static initialization of wlid | 74 * Note: If you change this length, fix the static initialization of wlid |
75 * in nacl_cpuid.c to be initialized with an appropriate string. | 75 * in cpu_x86.c to be initialized with an appropriate string. |
76 */ | 76 */ |
77 #define /* static const int */ kCPUIDStringLength 21 | 77 #define /* static const int */ kCPUIDStringLength 21 |
78 | 78 |
79 /* Defines the maximum number of feature registers used to hold CPUID. | 79 /* Defines the maximum number of feature registers used to hold CPUID. |
80 * Note: This value corresponds to the number of enumerated elements in | 80 * Note: This value corresponds to the number of enumerated elements in |
81 * enum CPUFeatureReg defined in nacl_cpuid.c. | 81 * enum CPUFeatureReg defined in cpu_x86.c. |
82 */ | 82 */ |
83 #define kMaxCPUFeatureReg 12 | 83 #define kMaxCPUFeatureReg 12 |
84 | 84 |
85 /* Defines the maximum number of extended control registers. | 85 /* Defines the maximum number of extended control registers. |
86 */ | 86 */ |
87 #define kMaxCPUXCRReg 1 | 87 #define kMaxCPUXCRReg 1 |
88 | 88 |
89 /* Define a cache for collected CPU runtime information, from which | 89 /* Define a cache for collected CPU runtime information, from which |
90 * queries can answer questions. | 90 * queries can answer questions. |
91 */ | 91 */ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 * TODO(jfb) The ARM and MIPS CPU feature do not offer NaClCopyCPUFeaturesX86 | 144 * TODO(jfb) The ARM and MIPS CPU feature do not offer NaClCopyCPUFeaturesX86 |
145 * and NaClArchSupportedX86, should they be removed? | 145 * and NaClArchSupportedX86, should they be removed? |
146 */ | 146 */ |
147 void NaClClearCPUFeaturesX86(NaClCPUFeaturesX86 *features); | 147 void NaClClearCPUFeaturesX86(NaClCPUFeaturesX86 *features); |
148 void NaClCopyCPUFeaturesX86(NaClCPUFeaturesX86 *target, | 148 void NaClCopyCPUFeaturesX86(NaClCPUFeaturesX86 *target, |
149 const NaClCPUFeaturesX86 *source); | 149 const NaClCPUFeaturesX86 *source); |
150 int NaClArchSupportedX86(const NaClCPUFeaturesX86 *features); | 150 int NaClArchSupportedX86(const NaClCPUFeaturesX86 *features); |
151 | 151 |
152 EXTERN_C_END | 152 EXTERN_C_END |
153 | 153 |
154 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NACL_CPUID_H_ */ | 154 #endif /* NATIVE_CLIENT_SRC_TRUSTED_CPU_FEATURES_ARCH_X86_CPU_X86_H_ */ |
OLD | NEW |