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