TianoCore EDK2 master
RegisterCpuFeaturesLib.h
Go to the documentation of this file.
1
9#ifndef __REGISTER_CPU_FEATURES_LIB_H__
10#define __REGISTER_CPU_FEATURES_LIB_H__
11
12#include <AcpiCpuData.h>
14#include <Protocol/MpService.h>
15
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_RESERVED_5 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#define CPU_FEATURE_THREAD_BEFORE BIT25
73#define CPU_FEATURE_THREAD_AFTER BIT26
74#define CPU_FEATURE_CORE_BEFORE BIT27
75#define CPU_FEATURE_CORE_AFTER BIT28
76#define CPU_FEATURE_PACKAGE_BEFORE BIT29
77#define CPU_FEATURE_PACKAGE_AFTER BIT30
78#define CPU_FEATURE_END MAX_UINT32
80
84typedef struct {
85 //
86 // Set to 1 when current processor is the first thread in the core it resides in.
87 //
88 UINT32 Thread : 1;
89 //
90 // Set to 1 when current processor is a thread of the first core in the module it resides in.
91 //
92 UINT32 Core : 1;
93 //
94 // Set to 1 when current processor is a thread of the first module in the tile it resides in.
95 //
96 UINT32 Module : 1;
97 //
98 // Set to 1 when current processor is a thread of the first tile in the die it resides in.
99 //
100 UINT32 Tile : 1;
101 //
102 // Set to 1 when current processor is a thread of the first die in the package it resides in.
103 //
104 UINT32 Die : 1;
105 //
106 // Set to 1 when current processor is a thread of the first package in the system.
107 //
108 UINT32 Package : 1;
109 UINT32 Reserved : 26;
111
117typedef struct {
122
152
167BOOLEAN
168EFIAPI
170 IN UINT32 Feature
171 );
172
184BOOLEAN
185EFIAPI
187 IN UINT32 Feature
188 );
189
199typedef
200VOID *
202 IN UINTN NumberOfProcessors
203 );
204
221typedef
222BOOLEAN
223(EFIAPI *CPU_FEATURE_SUPPORT)(
224 IN UINTN ProcessorNumber,
226 IN VOID *ConfigData OPTIONAL
227 );
228
250typedef
251RETURN_STATUS
252(EFIAPI *CPU_FEATURE_INITIALIZE)(
253 IN UINTN ProcessorNumber,
255 IN VOID *ConfigData OPTIONAL,
256 IN BOOLEAN State
257 );
258
303RETURN_STATUS
304EFIAPI
306 IN CHAR8 *FeatureName OPTIONAL,
307 IN CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc OPTIONAL,
308 IN CPU_FEATURE_SUPPORT SupportFunc OPTIONAL,
309 IN CPU_FEATURE_INITIALIZE InitializeFunc OPTIONAL,
310 ...
311 );
312
321VOID
322EFIAPI
324 VOID
325 );
326
335VOID
336EFIAPI
338 VOID
339 );
340
348VOID
349EFIAPI
351 IN UINTN ProcessorNumber
352 );
353
368VOID
369EFIAPI
371 IN UINTN ProcessorNumber,
372 IN REGISTER_TYPE RegisterType,
373 IN UINT64 Index,
374 IN UINT64 ValueMask,
375 IN UINT64 Value
376 );
377
394VOID
395EFIAPI
397 IN UINTN ProcessorNumber,
398 IN REGISTER_TYPE RegisterType,
399 IN UINT64 Index,
400 IN UINT64 ValueMask,
401 IN UINT64 Value
402 );
403
418VOID
419EFIAPI
421 IN UINTN ProcessorNumber,
422 IN REGISTER_TYPE RegisterType,
423 IN UINT64 Index,
424 IN UINT64 ValueMask,
425 IN UINT64 Value
426 );
427
441#define CPU_REGISTER_TABLE_WRITE32(ProcessorNumber, RegisterType, Index, Value) \
442 do { \
443 CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value); \
444 } while(FALSE);
445
461#define CPU_REGISTER_TABLE_TEST_THEN_WRITE32(ProcessorNumber, RegisterType, Index, Value) \
462 do { \
463 CpuRegisterTableTestThenWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value); \
464 } while(FALSE);
465
479#define CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value) \
480 do { \
481 CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value); \
482 } while(FALSE);
483
499#define CPU_REGISTER_TABLE_TEST_THEN_WRITE64(ProcessorNumber, RegisterType, Index, Value) \
500 do { \
501 CpuRegisterTableTestThenWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value); \
502 } while(FALSE);
503
519#define CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \
520 do { \
521 UINT64 ValueMask; \
522 ValueMask = MAX_UINT64; \
523 ((Type *)(&ValueMask))->Field = 0; \
524 CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value); \
525 } while(FALSE);
526
544#define CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \
545 do { \
546 UINT64 ValueMask; \
547 ValueMask = MAX_UINT64; \
548 ((Type *)(&ValueMask))->Field = 0; \
549 CpuRegisterTableTestThenWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value); \
550 } while(FALSE);
551
565#define PRE_SMM_CPU_REGISTER_TABLE_WRITE32(ProcessorNumber, RegisterType, Index, Value) \
566 do { \
567 PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value); \
568 } while(FALSE);
569
583#define PRE_SMM_CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value) \
584 do { \
585 PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value); \
586 } while(FALSE);
587
603#define PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \
604 do { \
605 UINT64 ValueMask; \
606 ValueMask = MAX_UINT64; \
607 ((Type *)(&ValueMask))->Field = 0; \
608 PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value); \
609 } while(FALSE);
610
611#endif
UINT64 UINTN
#define OPTIONAL
Definition: Base.h:290
#define IN
Definition: Base.h:279
VOID EFIAPI SwitchBspAfterFeaturesInitialize(IN UINTN ProcessorNumber)
RETURN_STATUS(EFIAPI * CPU_FEATURE_INITIALIZE)(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL, IN BOOLEAN State)
BOOLEAN(EFIAPI * CPU_FEATURE_SUPPORT)(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL)
VOID EFIAPI CpuRegisterTableWrite(IN UINTN ProcessorNumber, IN REGISTER_TYPE RegisterType, IN UINT64 Index, IN UINT64 ValueMask, IN UINT64 Value)
VOID EFIAPI CpuFeaturesDetect(VOID)
BOOLEAN EFIAPI IsCpuFeatureInSetting(IN UINT32 Feature)
BOOLEAN EFIAPI IsCpuFeatureSupported(IN UINT32 Feature)
VOID EFIAPI PreSmmCpuRegisterTableWrite(IN UINTN ProcessorNumber, IN REGISTER_TYPE RegisterType, IN UINT64 Index, IN UINT64 ValueMask, IN UINT64 Value)
VOID *(EFIAPI * CPU_FEATURE_GET_CONFIG_DATA)(IN UINTN NumberOfProcessors)
VOID EFIAPI CpuRegisterTableTestThenWrite(IN UINTN ProcessorNumber, IN REGISTER_TYPE RegisterType, IN UINT64 Index, IN UINT64 ValueMask, IN UINT64 Value)
VOID EFIAPI CpuFeaturesInitialize(VOID)
RETURN_STATUS EFIAPI RegisterCpuFeature(IN CHAR8 *FeatureName OPTIONAL, IN CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc OPTIONAL, IN CPU_FEATURE_SUPPORT SupportFunc OPTIONAL, IN CPU_FEATURE_INITIALIZE InitializeFunc OPTIONAL,...)
EFI_PROCESSOR_INFORMATION ProcessorInfo
REGISTER_CPU_FEATURE_FIRST_PROCESSOR First
CPUID_VERSION_INFO_ECX CpuIdVersionInfoEcx
CPUID_VERSION_INFO_EDX CpuIdVersionInfoEdx