TianoCore EDK2 master
Loading...
Searching...
No Matches
X2Apic.c
Go to the documentation of this file.
1
9#include "CpuCommonFeatures.h"
10
20VOID *
21EFIAPI
23 IN UINTN NumberOfProcessors
24 )
25{
26 BOOLEAN *ConfigData;
27
28 ConfigData = AllocateZeroPool (sizeof (BOOLEAN) * NumberOfProcessors);
29 ASSERT (ConfigData != NULL);
30 return ConfigData;
31}
32
51BOOLEAN
52EFIAPI
54 IN UINTN ProcessorNumber,
56 IN VOID *ConfigData OPTIONAL
57 )
58{
59 BOOLEAN *X2ApicEnabled;
60
61 ASSERT (ConfigData != NULL);
62 X2ApicEnabled = (BOOLEAN *)ConfigData;
63 //
64 // *ConfigData indicates if X2APIC enabled on current processor
65 //
66 X2ApicEnabled[ProcessorNumber] = (GetApicMode () == LOCAL_APIC_MODE_X2APIC) ? TRUE : FALSE;
67
68 return (CpuInfo->CpuIdVersionInfoEcx.Bits.x2APIC == 1);
69}
70
88RETURN_STATUS
89EFIAPI
91 IN UINTN ProcessorNumber,
93 IN VOID *ConfigData OPTIONAL,
94 IN BOOLEAN State
95 )
96{
97 BOOLEAN *X2ApicEnabled;
98
99 //
100 // The scope of the MSR_IA32_APIC_BASE is core for below processor type, only program
101 // MSR_IA32_APIC_BASE for thread 0 in each core.
102 //
103 if (IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {
104 if (CpuInfo->ProcessorInfo.Location.Thread != 0) {
105 return RETURN_SUCCESS;
106 }
107 }
108
109 ASSERT (ConfigData != NULL);
110 X2ApicEnabled = (BOOLEAN *)ConfigData;
111 if (X2ApicEnabled[ProcessorNumber]) {
113 ProcessorNumber,
114 Msr,
117 Bits.EXTD,
118 1
119 );
120 } else {
121 //
122 // Enable X2APIC mode only if X2APIC is not enabled,
123 // Needn't to disabe X2APIC mode again if X2APIC is not enabled
124 //
125 if (State) {
127 ProcessorNumber,
128 Msr,
131 Bits.EXTD,
132 1
133 );
134 }
135 }
136
137 return RETURN_SUCCESS;
138}
UINT64 UINTN
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
#define LOCAL_APIC_MODE_X2APIC
x2APIC mode.
Definition: LocalApicLib.h:16
UINTN EFIAPI GetApicMode(VOID)
Definition: BaseXApicLib.c:242
#define NULL
Definition: Base.h:319
#define RETURN_SUCCESS
Definition: Base.h:1066
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define MSR_IA32_APIC_BASE
#define CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value)
#define PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value)
#define IS_SILVERMONT_PROCESSOR(DisplayFamily, DisplayModel)
Definition: SilvermontMsr.h:32
RETURN_STATUS EFIAPI X2ApicInitialize(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL, IN BOOLEAN State)
Definition: X2Apic.c:90
VOID *EFIAPI X2ApicGetConfigData(IN UINTN NumberOfProcessors)
Definition: X2Apic.c:22
BOOLEAN EFIAPI X2ApicSupport(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL)
Definition: X2Apic.c:53