UefiCpuPkg: Add NULL CPU Common Features Library instance
[mirror_edk2.git] / UefiCpuPkg / Library / CpuCommonFeaturesLib / CpuCommonFeaturesLib.c
1 /** @file
2 This library registers CPU features defined in Intel(R) 64 and IA-32
3 Architectures Software Developer's Manual.
4
5 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include "CpuCommonFeatures.h"
17
18 /**
19 Register CPU features.
20
21 @retval RETURN_SUCCESS Register successfully
22 **/
23 RETURN_STATUS
24 EFIAPI
25 CpuCommonFeaturesLibConstructor (
26 VOID
27 )
28 {
29 RETURN_STATUS Status;
30
31 if (IsCpuFeatureSupported (CPU_FEATURE_AESNI)) {
32 Status = RegisterCpuFeature (
33 "AESNI",
34 AesniGetConfigData,
35 AesniSupport,
36 AesniInitialize,
37 CPU_FEATURE_AESNI,
38 CPU_FEATURE_END
39 );
40 ASSERT_EFI_ERROR (Status);
41 }
42 if (IsCpuFeatureSupported (CPU_FEATURE_MWAIT)) {
43 Status = RegisterCpuFeature (
44 "MWAIT",
45 NULL,
46 MonitorMwaitSupport,
47 MonitorMwaitInitialize,
48 CPU_FEATURE_MWAIT,
49 CPU_FEATURE_END
50 );
51 ASSERT_EFI_ERROR (Status);
52 }
53 if (IsCpuFeatureSupported (CPU_FEATURE_ACPI)) {
54 Status = RegisterCpuFeature (
55 "ACPI",
56 NULL,
57 ClockModulationSupport,
58 ClockModulationInitialize,
59 CPU_FEATURE_ACPI,
60 CPU_FEATURE_END
61 );
62 ASSERT_EFI_ERROR (Status);
63 }
64 if (IsCpuFeatureSupported (CPU_FEATURE_EIST)) {
65 Status = RegisterCpuFeature (
66 "EIST",
67 NULL,
68 EistSupport,
69 EistInitialize,
70 CPU_FEATURE_EIST,
71 CPU_FEATURE_END
72 );
73 ASSERT_EFI_ERROR (Status);
74 }
75 if (IsCpuFeatureSupported (CPU_FEATURE_XD)) {
76 Status = RegisterCpuFeature (
77 "Execute Disable",
78 NULL,
79 ExecuteDisableSupport,
80 ExecuteDisableInitialize,
81 CPU_FEATURE_XD,
82 CPU_FEATURE_END
83 );
84 ASSERT_EFI_ERROR (Status);
85 }
86 if (IsCpuFeatureSupported (CPU_FEATURE_FASTSTRINGS)) {
87 Status = RegisterCpuFeature (
88 "FastStrings",
89 NULL,
90 NULL,
91 FastStringsInitialize,
92 CPU_FEATURE_FASTSTRINGS,
93 CPU_FEATURE_END
94 );
95 ASSERT_EFI_ERROR (Status);
96 }
97 if (IsCpuFeatureSupported (CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER)) {
98 Status = RegisterCpuFeature (
99 "Lock Feature Control Register",
100 FeatureControlGetConfigData,
101 LockFeatureControlRegisterSupport,
102 LockFeatureControlRegisterInitialize,
103 CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER,
104 CPU_FEATURE_END
105 );
106 ASSERT_EFI_ERROR (Status);
107 }
108 if (IsCpuFeatureSupported (CPU_FEATURE_SENTER)) {
109 Status = RegisterCpuFeature (
110 "SENTER",
111 FeatureControlGetConfigData,
112 VmxSupport,
113 SenterInitialize,
114 CPU_FEATURE_SENTER,
115 CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE,
116 CPU_FEATURE_SMX | CPU_FEATURE_AFTER,
117 CPU_FEATURE_END
118 );
119 ASSERT_EFI_ERROR (Status);
120 }
121 if (IsCpuFeatureSupported (CPU_FEATURE_SMX)) {
122 Status = RegisterCpuFeature (
123 "SMX",
124 FeatureControlGetConfigData,
125 SmxSupport,
126 VmxInsideSmxInitialize,
127 CPU_FEATURE_SMX,
128 CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE,
129 CPU_FEATURE_END
130 );
131 ASSERT_EFI_ERROR (Status);
132 }
133 if (IsCpuFeatureSupported (CPU_FEATURE_VMX)) {
134 Status = RegisterCpuFeature (
135 "VMX",
136 FeatureControlGetConfigData,
137 SmxSupport,
138 VmxOutsideSmxInitialize,
139 CPU_FEATURE_VMX,
140 CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE,
141 CPU_FEATURE_END
142 );
143 ASSERT_EFI_ERROR (Status);
144 }
145 if (IsCpuFeatureSupported (CPU_FEATURE_LIMIT_CPUID_MAX_VAL)) {
146 Status = RegisterCpuFeature (
147 "Limit CpuId Maximum Value",
148 NULL,
149 LimitCpuidMaxvalSupport,
150 LimitCpuidMaxvalInitialize,
151 CPU_FEATURE_LIMIT_CPUID_MAX_VAL,
152 CPU_FEATURE_END
153 );
154 ASSERT_EFI_ERROR (Status);
155 }
156 if (IsCpuFeatureSupported (CPU_FEATURE_MCE)) {
157 Status = RegisterCpuFeature (
158 "Machine Check Enable",
159 NULL,
160 MceSupport,
161 MceInitialize,
162 CPU_FEATURE_MCE,
163 CPU_FEATURE_END
164 );
165 ASSERT_EFI_ERROR (Status);
166 }
167 if (IsCpuFeatureSupported (CPU_FEATURE_MCA)) {
168 Status = RegisterCpuFeature (
169 "Machine Check Architect",
170 NULL,
171 McaSupport,
172 McaInitialize,
173 CPU_FEATURE_MCA,
174 CPU_FEATURE_END
175 );
176 ASSERT_EFI_ERROR (Status);
177 }
178 if (IsCpuFeatureSupported (CPU_FEATURE_MCG_CTL)) {
179 Status = RegisterCpuFeature (
180 "MCG_CTL",
181 NULL,
182 McgCtlSupport,
183 McgCtlInitialize,
184 CPU_FEATURE_MCG_CTL,
185 CPU_FEATURE_END
186 );
187 ASSERT_EFI_ERROR (Status);
188 }
189 if (IsCpuFeatureSupported (CPU_FEATURE_PENDING_BREAK)) {
190 Status = RegisterCpuFeature (
191 "Pending Break",
192 NULL,
193 PendingBreakSupport,
194 PendingBreakInitialize,
195 CPU_FEATURE_PENDING_BREAK,
196 CPU_FEATURE_END
197 );
198 ASSERT_EFI_ERROR (Status);
199 }
200 if (IsCpuFeatureSupported (CPU_FEATURE_C1E)) {
201 Status = RegisterCpuFeature (
202 "C1E",
203 NULL,
204 C1eSupport,
205 C1eInitialize,
206 CPU_FEATURE_C1E,
207 CPU_FEATURE_END
208 );
209 ASSERT_EFI_ERROR (Status);
210 }
211 if (IsCpuFeatureSupported (CPU_FEATURE_X2APIC)) {
212 Status = RegisterCpuFeature (
213 "X2Apic",
214 NULL,
215 X2ApicSupport,
216 X2ApicInitialize,
217 CPU_FEATURE_X2APIC,
218 CPU_FEATURE_END
219 );
220 ASSERT_EFI_ERROR (Status);
221 }
222
223 return RETURN_SUCCESS;
224 }
225
226
227