]>
Commit | Line | Data |
---|---|---|
80c4b236 JF |
1 | /** @file\r |
2 | Register CPU Features Library to register and manage CPU features.\r | |
3 | \r | |
79be3d27 | 4 | Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>\r |
0acd8697 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
80c4b236 JF |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #ifndef __REGISTER_CPU_FEATURES_LIB_H__\r | |
10 | #define __REGISTER_CPU_FEATURES_LIB_H__\r | |
11 | \r | |
12 | #include <AcpiCpuData.h>\r | |
01acb06c | 13 | #include <Register/Intel/Cpuid.h>\r |
80c4b236 JF |
14 | #include <Protocol/MpService.h>\r |
15 | \r | |
16 | ///\r | |
17 | /// Defines used to identify a CPU feature. The lower 16-bits are used to\r | |
18 | /// identify a unique CPU feature and the value represents a bit number in\r | |
19 | /// a bit mask. The upper 16-bits are bit mask values that are used as\r | |
20 | /// modifiers of a CPU feature. When used in a list, the define value\r | |
21 | /// CPU_FEATURE_END is used to terminate a list of CPU feature values.\r | |
22 | /// @{\r | |
23 | #define CPU_FEATURE_AESNI 0\r | |
24 | #define CPU_FEATURE_TURBO_MODE 1\r | |
25 | #define CPU_FEATURE_MWAIT 2\r | |
26 | #define CPU_FEATURE_ACPI 3\r | |
27 | #define CPU_FEATURE_EIST 4\r | |
c801f33d | 28 | #define CPU_FEATURE_RESERVED_5 5\r |
80c4b236 JF |
29 | #define CPU_FEATURE_FASTSTRINGS 6\r |
30 | #define CPU_FEATURE_VMX 7\r | |
31 | #define CPU_FEATURE_SMX 8\r | |
ac36ef87 | 32 | #define CPU_FEATURE_LMCE 9\r |
80c4b236 JF |
33 | #define CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER 10\r |
34 | #define CPU_FEATURE_LIMIT_CPUID_MAX_VAL 11\r | |
35 | #define CPU_FEATURE_MCE 12\r | |
36 | #define CPU_FEATURE_MCA 13\r | |
37 | #define CPU_FEATURE_MCG_CTL 14\r | |
38 | #define CPU_FEATURE_PENDING_BREAK 15\r | |
39 | #define CPU_FEATURE_C1E 16\r | |
40 | #define CPU_FEATURE_C1_AUTO_DEMOTION 17\r | |
41 | #define CPU_FEATURE_C3_AUTO_DEMOTION 18\r | |
bea7af27 JF |
42 | #define CPU_FEATURE_C1_UNDEMOTION 19\r |
43 | #define CPU_FEATURE_C3_UNDEMOTION 20\r | |
80c4b236 JF |
44 | #define CPU_FEATURE_C_STATE 21\r |
45 | #define CPU_FEATURE_TM 22\r | |
46 | #define CPU_FEATURE_TM2 23\r | |
47 | #define CPU_FEATURE_X2APIC 24\r | |
48 | #define CPU_FEATURE_RESERVED_25 25\r | |
49 | #define CPU_FEATURE_RESERVED_26 26\r | |
50 | #define CPU_FEATURE_RESERVED_27 27\r | |
51 | #define CPU_FEATURE_RESERVED_28 28\r | |
52 | #define CPU_FEATURE_RESERVED_29 29\r | |
53 | #define CPU_FEATURE_RESERVED_30 30\r | |
54 | #define CPU_FEATURE_RESERVED_31 31\r | |
55 | \r | |
56 | #define CPU_FEATURE_L2_PREFETCHER (32+0)\r | |
57 | #define CPU_FEATURE_L1_DATA_PREFETCHER (32+1)\r | |
58 | #define CPU_FEATURE_HARDWARE_PREFETCHER (32+2)\r | |
59 | #define CPU_FEATURE_ADJACENT_CACHE_LINE_PREFETCH (32+3)\r | |
60 | #define CPU_FEATURE_DCU_PREFETCHER (32+4)\r | |
61 | #define CPU_FEATURE_IP_PREFETCHER (32+5)\r | |
62 | #define CPU_FEATURE_MLC_STREAMER_PREFETCHER (32+6)\r | |
63 | #define CPU_FEATURE_MLC_SPATIAL_PREFETCHER (32+7)\r | |
e85cfa2f | 64 | #define CPU_FEATURE_THREE_STRIKE_COUNTER (32+8)\r |
80c4b236 JF |
65 | #define CPU_FEATURE_APIC_TPR_UPDATE_MESSAGE (32+9)\r |
66 | #define CPU_FEATURE_ENERGY_PERFORMANCE_BIAS (32+10)\r | |
f1a68ab2 | 67 | #define CPU_FEATURE_PPIN (32+11)\r |
a7e2a253 | 68 | #define CPU_FEATURE_PROC_TRACE (32+12)\r |
80c4b236 | 69 | \r |
87e93951 ED |
70 | #define CPU_FEATURE_BEFORE_ALL BIT23\r |
71 | #define CPU_FEATURE_AFTER_ALL BIT24\r | |
72 | //\r | |
73 | // CPU_FEATURE_BEFORE and CPU_FEATURE_AFTER only mean Thread scope\r | |
74 | // before and Thread scope after.\r | |
75 | // It will be replace with CPU_FEATURE_THREAD_BEFORE and\r | |
76 | // CPU_FEATURE_THREAD_AFTER, and should not be used anymore.\r | |
77 | //\r | |
78 | #define CPU_FEATURE_BEFORE BIT25\r | |
79 | #define CPU_FEATURE_AFTER BIT26\r | |
80 | \r | |
81 | #define CPU_FEATURE_THREAD_BEFORE CPU_FEATURE_BEFORE\r | |
82 | #define CPU_FEATURE_THREAD_AFTER CPU_FEATURE_AFTER\r | |
83 | #define CPU_FEATURE_CORE_BEFORE BIT27\r | |
84 | #define CPU_FEATURE_CORE_AFTER BIT28\r | |
85 | #define CPU_FEATURE_PACKAGE_BEFORE BIT29\r | |
86 | #define CPU_FEATURE_PACKAGE_AFTER BIT30\r | |
80c4b236 JF |
87 | #define CPU_FEATURE_END MAX_UINT32\r |
88 | /// @}\r | |
89 | \r | |
90 | ///\r | |
91 | /// CPU Information passed into the SupportFunc and InitializeFunc of the\r | |
92 | /// RegisterCpuFeature() library function. This structure contains information\r | |
93 | /// that is commonly used during CPU feature detection and initialization.\r | |
94 | ///\r | |
95 | typedef struct {\r | |
96 | ///\r | |
97 | /// The package that the CPU resides\r | |
98 | ///\r | |
99 | EFI_PROCESSOR_INFORMATION ProcessorInfo;\r | |
100 | ///\r | |
101 | /// The Display Family of the CPU computed from CPUID leaf CPUID_VERSION_INFO\r | |
102 | ///\r | |
103 | UINT32 DisplayFamily;\r | |
104 | ///\r | |
105 | /// The Display Model of the CPU computed from CPUID leaf CPUID_VERSION_INFO\r | |
106 | ///\r | |
107 | UINT32 DisplayModel;\r | |
108 | ///\r | |
109 | /// The Stepping ID of the CPU computed from CPUID leaf CPUID_VERSION_INFO\r | |
110 | ///\r | |
111 | UINT32 SteppingId;\r | |
112 | ///\r | |
113 | /// The Processor Type of the CPU computed from CPUID leaf CPUID_VERSION_INFO\r | |
114 | ///\r | |
115 | UINT32 ProcessorType;\r | |
116 | ///\r | |
117 | /// Bit field structured returned in ECX from CPUID leaf CPUID_VERSION_INFO\r | |
118 | ///\r | |
119 | CPUID_VERSION_INFO_ECX CpuIdVersionInfoEcx;\r | |
120 | ///\r | |
121 | /// Bit field structured returned in EDX from CPUID leaf CPUID_VERSION_INFO\r | |
122 | ///\r | |
123 | CPUID_VERSION_INFO_EDX CpuIdVersionInfoEdx;\r | |
124 | } REGISTER_CPU_FEATURE_INFORMATION;\r | |
125 | \r | |
126 | /**\r | |
127 | Determines if a CPU feature is enabled in PcdCpuFeaturesSupport bit mask.\r | |
128 | If a CPU feature is disabled in PcdCpuFeaturesSupport then all the code/data\r | |
129 | associated with that feature should be optimized away if compiler\r | |
130 | optimizations are enabled.\r | |
131 | \r | |
132 | @param[in] Feature The bit number of the CPU feature to check in the PCD\r | |
133 | PcdCpuFeaturesSupport.\r | |
134 | \r | |
135 | @retval TRUE The CPU feature is set in PcdCpuFeaturesSupport.\r | |
136 | @retval FALSE The CPU feature is not set in PcdCpuFeaturesSupport.\r | |
137 | \r | |
138 | @note This service could be called by BSP only.\r | |
139 | **/\r | |
140 | BOOLEAN\r | |
141 | EFIAPI\r | |
142 | IsCpuFeatureSupported (\r | |
143 | IN UINT32 Feature\r | |
144 | );\r | |
145 | \r | |
146 | /**\r | |
147 | Determines if a CPU feature is set in PcdCpuFeaturesSetting bit mask.\r | |
148 | \r | |
149 | @param[in] Feature The bit number of the CPU feature to check in the PCD\r | |
150 | PcdCpuFeaturesSetting.\r | |
151 | \r | |
152 | @retval TRUE The CPU feature is set in PcdCpuFeaturesSetting.\r | |
153 | @retval FALSE The CPU feature is not set in PcdCpuFeaturesSetting.\r | |
154 | \r | |
155 | @note This service could be called by BSP only.\r | |
156 | **/\r | |
157 | BOOLEAN\r | |
158 | EFIAPI\r | |
159 | IsCpuFeatureInSetting (\r | |
160 | IN UINT32 Feature\r | |
161 | );\r | |
162 | \r | |
80c4b236 JF |
163 | /**\r |
164 | Prepares for the data used by CPU feature detection and initialization.\r | |
165 | \r | |
166 | @param[in] NumberOfProcessors The number of CPUs in the platform.\r | |
167 | \r | |
168 | @return Pointer to a buffer of CPU related configuration data.\r | |
169 | \r | |
170 | @note This service could be called by BSP only.\r | |
171 | **/\r | |
172 | typedef\r | |
173 | VOID *\r | |
174 | (EFIAPI *CPU_FEATURE_GET_CONFIG_DATA)(\r | |
175 | IN UINTN NumberOfProcessors\r | |
176 | );\r | |
177 | \r | |
178 | /**\r | |
179 | Detects if CPU feature supported on current processor.\r | |
180 | \r | |
181 | @param[in] ProcessorNumber The index of the CPU executing this function.\r | |
182 | @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r | |
183 | structure for the CPU executing this function.\r | |
184 | @param[in] ConfigData A pointer to the configuration buffer returned\r | |
185 | by CPU_FEATURE_GET_CONFIG_DATA. NULL if\r | |
186 | CPU_FEATURE_GET_CONFIG_DATA was not provided in\r | |
187 | RegisterCpuFeature().\r | |
188 | \r | |
189 | @retval TRUE CPU feature is supported.\r | |
190 | @retval FALSE CPU feature is not supported.\r | |
191 | \r | |
192 | @note This service could be called by BSP/APs.\r | |
193 | **/\r | |
194 | typedef\r | |
195 | BOOLEAN\r | |
196 | (EFIAPI *CPU_FEATURE_SUPPORT)(\r | |
197 | IN UINTN ProcessorNumber,\r | |
198 | IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,\r | |
199 | IN VOID *ConfigData OPTIONAL\r | |
200 | );\r | |
201 | \r | |
202 | /**\r | |
203 | Initializes CPU feature to specific state.\r | |
204 | \r | |
205 | This service does not initialize hardware and only produces entries in the\r | |
206 | Register Table for specified processor. Hardware initialization on BSP/APs\r | |
207 | will be done in CpuFeaturesInitialize().\r | |
208 | \r | |
209 | @param[in] ProcessorNumber The index of the CPU executing this function.\r | |
210 | @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r | |
211 | structure for the CPU executing this function.\r | |
212 | @param[in] ConfigData A pointer to the configuration buffer returned\r | |
213 | by CPU_FEATURE_GET_CONFIG_DATA. NULL if\r | |
214 | CPU_FEATURE_GET_CONFIG_DATA was not provided in\r | |
215 | RegisterCpuFeature().\r | |
216 | @param[in] State If TRUE, then the CPU feature must be enabled.\r | |
217 | If FALSE, then the CPU feature must be disabled.\r | |
218 | \r | |
219 | @retval RETURN_SUCCESS CPU feature is initialized.\r | |
220 | \r | |
221 | @note This service could be called by BSP only.\r | |
222 | **/\r | |
223 | typedef\r | |
224 | RETURN_STATUS\r | |
225 | (EFIAPI *CPU_FEATURE_INITIALIZE)(\r | |
226 | IN UINTN ProcessorNumber,\r | |
227 | IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,\r | |
228 | IN VOID *ConfigData, OPTIONAL\r | |
229 | IN BOOLEAN State\r | |
230 | );\r | |
231 | \r | |
232 | /**\r | |
233 | Registers a CPU Feature.\r | |
234 | \r | |
235 | @param[in] FeatureName A Null-terminated Ascii string indicates CPU feature\r | |
236 | name.\r | |
237 | @param[in] GetConfigDataFunc CPU feature get configuration data function. This\r | |
238 | is an optional parameter that may be NULL. If NULL,\r | |
239 | then the most recently registered function for the\r | |
240 | CPU feature is used. If no functions are registered\r | |
241 | for a CPU feature, then the CPU configuration data\r | |
242 | for the registered feature is NULL.\r | |
243 | @param[in] SupportFunc CPU feature support function. This is an optional\r | |
244 | parameter that may be NULL. If NULL, then the most\r | |
245 | recently registered function for the CPU feature is\r | |
246 | used. If no functions are registered for a CPU\r | |
247 | feature, then the CPU feature is assumed to be\r | |
248 | supported by all CPUs.\r | |
249 | @param[in] InitializeFunc CPU feature initialize function. This is an optional\r | |
250 | parameter that may be NULL. If NULL, then the most\r | |
251 | recently registered function for the CPU feature is\r | |
252 | used. If no functions are registered for a CPU\r | |
253 | feature, then the CPU feature initialization is\r | |
254 | skipped.\r | |
255 | @param[in] ... Variable argument list of UINT32 CPU feature value.\r | |
256 | Values with no modifiers are the features provided\r | |
257 | by the registered functions.\r | |
258 | Values with CPU_FEATURE_BEFORE modifier are features\r | |
259 | that must be initialized after the features provided\r | |
260 | by the registered functions are used.\r | |
261 | Values with CPU_FEATURE_AFTER modifier are features\r | |
262 | that must be initialized before the features provided\r | |
263 | by the registered functions are used.\r | |
264 | The last argument in this variable argument list must\r | |
265 | always be CPU_FEATURE_END.\r | |
266 | \r | |
267 | @retval RETURN_SUCCESS The CPU feature was successfully registered.\r | |
268 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources to register\r | |
269 | the CPU feature.\r | |
270 | @retval RETURN_UNSUPPORTED Registration of the CPU feature is not\r | |
271 | supported due to a circular dependency between\r | |
272 | BEFORE and AFTER features.\r | |
273 | \r | |
274 | @note This service could be called by BSP only.\r | |
275 | **/\r | |
276 | RETURN_STATUS\r | |
277 | EFIAPI\r | |
278 | RegisterCpuFeature (\r | |
279 | IN CHAR8 *FeatureName, OPTIONAL\r | |
280 | IN CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc, OPTIONAL\r | |
281 | IN CPU_FEATURE_SUPPORT SupportFunc, OPTIONAL\r | |
282 | IN CPU_FEATURE_INITIALIZE InitializeFunc, OPTIONAL\r | |
283 | ...\r | |
284 | );\r | |
285 | \r | |
286 | /**\r | |
287 | Performs CPU features detection.\r | |
288 | \r | |
289 | This service will invoke MP service to check CPU features'\r | |
290 | capabilities on BSP/APs.\r | |
291 | \r | |
292 | @note This service could be called by BSP only.\r | |
293 | **/\r | |
294 | VOID\r | |
295 | EFIAPI\r | |
296 | CpuFeaturesDetect (\r | |
297 | VOID\r | |
298 | );\r | |
299 | \r | |
300 | /**\r | |
301 | Performs CPU features Initialization.\r | |
302 | \r | |
303 | This service will invoke MP service to perform CPU features\r | |
304 | initialization on BSP/APs per user configuration.\r | |
305 | \r | |
306 | @note This service could be called by BSP only.\r | |
307 | **/\r | |
308 | VOID\r | |
309 | EFIAPI\r | |
310 | CpuFeaturesInitialize (\r | |
311 | VOID\r | |
312 | );\r | |
313 | \r | |
314 | /**\r | |
315 | Switches to assigned BSP after CPU features initialization.\r | |
316 | \r | |
317 | @param[in] ProcessorNumber The index of the CPU executing this function.\r | |
318 | \r | |
319 | @note This service could be called by BSP only.\r | |
320 | **/\r | |
321 | VOID\r | |
322 | EFIAPI\r | |
323 | SwitchBspAfterFeaturesInitialize (\r | |
324 | IN UINTN ProcessorNumber\r | |
325 | );\r | |
326 | \r | |
327 | /**\r | |
328 | Adds an entry in specified register table.\r | |
329 | \r | |
330 | This function adds an entry in specified register table, with given register type,\r | |
331 | register index, bit section and value.\r | |
332 | \r | |
333 | @param[in] ProcessorNumber The index of the CPU to add a register table entry.\r | |
334 | @param[in] RegisterType Type of the register to program\r | |
335 | @param[in] Index Index of the register to program\r | |
336 | @param[in] ValueMask Mask of bits in register to write\r | |
337 | @param[in] Value Value to write\r | |
338 | \r | |
339 | @note This service could be called by BSP only.\r | |
340 | **/\r | |
341 | VOID\r | |
342 | EFIAPI\r | |
343 | CpuRegisterTableWrite (\r | |
344 | IN UINTN ProcessorNumber,\r | |
345 | IN REGISTER_TYPE RegisterType,\r | |
346 | IN UINT64 Index,\r | |
347 | IN UINT64 ValueMask,\r | |
348 | IN UINT64 Value\r | |
349 | );\r | |
350 | \r | |
35c2809b ED |
351 | /**\r |
352 | Adds an entry in specified register table.\r | |
353 | \r | |
354 | This function adds an entry in specified register table, with given register type,\r | |
355 | register index, bit section and value.\r | |
356 | \r | |
357 | Driver will test the current value before setting new value.\r | |
358 | \r | |
359 | @param[in] ProcessorNumber The index of the CPU to add a register table entry\r | |
360 | @param[in] RegisterType Type of the register to program\r | |
361 | @param[in] Index Index of the register to program\r | |
362 | @param[in] ValueMask Mask of bits in register to write\r | |
363 | @param[in] Value Value to write\r | |
364 | \r | |
365 | @note This service could be called by BSP only.\r | |
366 | **/\r | |
367 | VOID\r | |
368 | EFIAPI\r | |
369 | CpuRegisterTableTestThenWrite (\r | |
370 | IN UINTN ProcessorNumber,\r | |
371 | IN REGISTER_TYPE RegisterType,\r | |
372 | IN UINT64 Index,\r | |
373 | IN UINT64 ValueMask,\r | |
374 | IN UINT64 Value\r | |
375 | );\r | |
376 | \r | |
80c4b236 JF |
377 | /**\r |
378 | Adds an entry in specified Pre-SMM register table.\r | |
379 | \r | |
380 | This function adds an entry in specified register table, with given register type,\r | |
381 | register index, bit section and value.\r | |
382 | \r | |
383 | @param[in] ProcessorNumber The index of the CPU to add a register table entry.\r | |
384 | @param[in] RegisterType Type of the register to program\r | |
385 | @param[in] Index Index of the register to program\r | |
386 | @param[in] ValueMask Mask of bits in register to write\r | |
387 | @param[in] Value Value to write\r | |
388 | \r | |
389 | @note This service could be called by BSP only.\r | |
390 | **/\r | |
391 | VOID\r | |
392 | EFIAPI\r | |
393 | PreSmmCpuRegisterTableWrite (\r | |
394 | IN UINTN ProcessorNumber,\r | |
395 | IN REGISTER_TYPE RegisterType,\r | |
396 | IN UINT64 Index,\r | |
397 | IN UINT64 ValueMask,\r | |
398 | IN UINT64 Value\r | |
399 | );\r | |
400 | \r | |
401 | /**\r | |
402 | Adds a 32-bit register write entry in specified register table.\r | |
403 | \r | |
404 | This macro adds an entry in specified register table, with given register type,\r | |
405 | register index, and value.\r | |
406 | \r | |
407 | @param[in] ProcessorNumber The index of the CPU to add a register table entry.\r | |
408 | @param[in] RegisterType Type of the register to program\r | |
409 | @param[in] Index Index of the register to program\r | |
410 | @param[in] Value Value to write\r | |
411 | \r | |
412 | @note This service could be called by BSP only.\r | |
413 | **/\r | |
414 | #define CPU_REGISTER_TABLE_WRITE32(ProcessorNumber, RegisterType, Index, Value) \\r | |
415 | do { \\r | |
416 | CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value); \\r | |
417 | } while(FALSE);\r | |
418 | \r | |
35c2809b ED |
419 | /**\r |
420 | Adds a 32-bit register write entry in specified register table.\r | |
421 | \r | |
422 | This macro adds an entry in specified register table, with given register type,\r | |
423 | register index, and value.\r | |
424 | \r | |
425 | Driver will test the current value before setting new value.\r | |
426 | \r | |
427 | @param[in] ProcessorNumber The index of the CPU to add a register table entry.\r | |
428 | @param[in] RegisterType Type of the register to program\r | |
429 | @param[in] Index Index of the register to program\r | |
430 | @param[in] Value Value to write\r | |
431 | \r | |
432 | @note This service could be called by BSP only.\r | |
433 | **/\r | |
434 | #define CPU_REGISTER_TABLE_TEST_THEN_WRITE32(ProcessorNumber, RegisterType, Index, Value) \\r | |
435 | do { \\r | |
436 | CpuRegisterTableTestThenWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value); \\r | |
437 | } while(FALSE);\r | |
438 | \r | |
80c4b236 JF |
439 | /**\r |
440 | Adds a 64-bit register write entry in specified register table.\r | |
441 | \r | |
442 | This macro adds an entry in specified register table, with given register type,\r | |
443 | register index, and value.\r | |
444 | \r | |
445 | @param[in] ProcessorNumber The index of the CPU to add a register table entry.\r | |
446 | @param[in] RegisterType Type of the register to program\r | |
447 | @param[in] Index Index of the register to program\r | |
448 | @param[in] Value Value to write\r | |
449 | \r | |
450 | @note This service could be called by BSP only.\r | |
451 | **/\r | |
452 | #define CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value) \\r | |
453 | do { \\r | |
454 | CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value); \\r | |
455 | } while(FALSE);\r | |
456 | \r | |
35c2809b ED |
457 | /**\r |
458 | Adds a 64-bit register write entry in specified register table.\r | |
459 | \r | |
460 | This macro adds an entry in specified register table, with given register type,\r | |
461 | register index, and value.\r | |
462 | \r | |
463 | Driver will test the current value before setting new value.\r | |
464 | \r | |
465 | @param[in] ProcessorNumber The index of the CPU to add a register table entry.\r | |
466 | @param[in] RegisterType Type of the register to program\r | |
467 | @param[in] Index Index of the register to program\r | |
468 | @param[in] Value Value to write\r | |
469 | \r | |
470 | @note This service could be called by BSP only.\r | |
471 | **/\r | |
472 | #define CPU_REGISTER_TABLE_TEST_THEN_WRITE64(ProcessorNumber, RegisterType, Index, Value) \\r | |
473 | do { \\r | |
474 | CpuRegisterTableTestThenWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value); \\r | |
475 | } while(FALSE);\r | |
476 | \r | |
80c4b236 JF |
477 | /**\r |
478 | Adds a bit field write entry in specified register table.\r | |
479 | \r | |
480 | This macro adds an entry in specified register table, with given register type,\r | |
481 | register index, bit field section, and value.\r | |
482 | \r | |
483 | @param[in] ProcessorNumber The index of the CPU to add a register table entry.\r | |
484 | @param[in] RegisterType Type of the register to program.\r | |
485 | @param[in] Index Index of the register to program.\r | |
486 | @param[in] Type The data type name of a register structure.\r | |
487 | @param[in] Field The bit fiel name in register structure to write.\r | |
488 | @param[in] Value Value to write to the bit field.\r | |
489 | \r | |
490 | @note This service could be called by BSP only.\r | |
491 | **/\r | |
492 | #define CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \\r | |
493 | do { \\r | |
494 | UINT64 ValueMask; \\r | |
495 | ValueMask = MAX_UINT64; \\r | |
496 | ((Type *)(&ValueMask))->Field = 0; \\r | |
497 | CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value); \\r | |
498 | } while(FALSE);\r | |
499 | \r | |
35c2809b ED |
500 | /**\r |
501 | Adds a bit field write entry in specified register table.\r | |
502 | \r | |
503 | This macro adds an entry in specified register table, with given register type,\r | |
504 | register index, bit field section, and value.\r | |
505 | \r | |
506 | Driver will test the current value before setting new value.\r | |
507 | \r | |
508 | @param[in] ProcessorNumber The index of the CPU to add a register table entry.\r | |
509 | @param[in] RegisterType Type of the register to program.\r | |
510 | @param[in] Index Index of the register to program.\r | |
511 | @param[in] Type The data type name of a register structure.\r | |
512 | @param[in] Field The bit fiel name in register structure to write.\r | |
513 | @param[in] Value Value to write to the bit field.\r | |
514 | \r | |
515 | @note This service could be called by BSP only.\r | |
516 | **/\r | |
517 | #define CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \\r | |
518 | do { \\r | |
519 | UINT64 ValueMask; \\r | |
520 | ValueMask = MAX_UINT64; \\r | |
521 | ((Type *)(&ValueMask))->Field = 0; \\r | |
522 | CpuRegisterTableTestThenWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value); \\r | |
523 | } while(FALSE);\r | |
524 | \r | |
80c4b236 JF |
525 | /**\r |
526 | Adds a 32-bit register write entry in specified register table.\r | |
527 | \r | |
528 | This macro adds an entry in specified register table, with given register type,\r | |
529 | register index, and value.\r | |
530 | \r | |
531 | @param[in] ProcessorNumber The index of the CPU to add a register table entry.\r | |
532 | @param[in] RegisterType Type of the register to program\r | |
533 | @param[in] Index Index of the register to program\r | |
534 | @param[in] Value Value to write\r | |
535 | \r | |
536 | @note This service could be called by BSP only.\r | |
537 | **/\r | |
538 | #define PRE_SMM_CPU_REGISTER_TABLE_WRITE32(ProcessorNumber, RegisterType, Index, Value) \\r | |
539 | do { \\r | |
540 | PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value); \\r | |
541 | } while(FALSE);\r | |
542 | \r | |
543 | /**\r | |
544 | Adds a 64-bit register write entry in specified register table.\r | |
545 | \r | |
546 | This macro adds an entry in specified register table, with given register type,\r | |
547 | register index, and value.\r | |
548 | \r | |
549 | @param[in] ProcessorNumber The index of the CPU to add a register table entry.\r | |
550 | @param[in] RegisterType Type of the register to program\r | |
551 | @param[in] Index Index of the register to program\r | |
552 | @param[in] Value Value to write\r | |
553 | \r | |
554 | @note This service could be called by BSP only.\r | |
555 | **/\r | |
556 | #define PRE_SMM_CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value) \\r | |
557 | do { \\r | |
558 | PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value); \\r | |
559 | } while(FALSE);\r | |
560 | \r | |
561 | /**\r | |
562 | Adds a bit field write entry in specified register table.\r | |
563 | \r | |
564 | This macro adds an entry in specified register table, with given register type,\r | |
565 | register index, bit field section, and value.\r | |
566 | \r | |
567 | @param[in] ProcessorNumber The index of the CPU to add a register table entry.\r | |
568 | @param[in] RegisterType Type of the register to program.\r | |
569 | @param[in] Index Index of the register to program.\r | |
570 | @param[in] Type The data type name of a register structure.\r | |
571 | @param[in] Field The bit fiel name in register structure to write.\r | |
572 | @param[in] Value Value to write to the bit field.\r | |
573 | \r | |
574 | @note This service could be called by BSP only.\r | |
575 | **/\r | |
576 | #define PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \\r | |
577 | do { \\r | |
578 | UINT64 ValueMask; \\r | |
579 | ValueMask = MAX_UINT64; \\r | |
580 | ((Type *)(&ValueMask))->Field = 0; \\r | |
581 | PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value); \\r | |
582 | } while(FALSE);\r | |
583 | \r | |
584 | #endif\r |