TianoCore EDK2 master
Loading...
Searching...
No Matches
Ppin.c
Go to the documentation of this file.
1
9#include "CpuCommonFeatures.h"
10
20VOID *
21EFIAPI
23 IN UINTN NumberOfProcessors
24 )
25{
26 VOID *ConfigData;
27
28 ConfigData = AllocateZeroPool (sizeof (MSR_IVY_BRIDGE_PPIN_CTL_REGISTER) * NumberOfProcessors);
29 ASSERT (ConfigData != NULL);
30 return ConfigData;
31}
32
50BOOLEAN
51EFIAPI
53 IN UINTN ProcessorNumber,
55 IN VOID *ConfigData OPTIONAL
56 )
57{
60
61 if ((CpuInfo->DisplayFamily == 0x06) &&
62 ((CpuInfo->DisplayModel == 0x3E) || // Xeon E5 V2
63 (CpuInfo->DisplayModel == 0x56) || // Xeon Processor D Product
64 (CpuInfo->DisplayModel == 0x4F) || // Xeon E5 v4, E7 v4
65 (CpuInfo->DisplayModel == 0x55) || // Xeon Processor Scalable
66 (CpuInfo->DisplayModel == 0x57) || // Xeon Phi processor 3200, 5200, 7200 series.
67 (CpuInfo->DisplayModel == 0x85) // Future Xeon phi processor
68 ))
69 {
70 //
71 // Check whether platform support this feature.
72 //
74 if (PlatformInfo.Bits.PPIN_CAP != 0) {
75 MsrPpinCtrl = (MSR_IVY_BRIDGE_PPIN_CTL_REGISTER *)ConfigData;
76 ASSERT (MsrPpinCtrl != NULL);
77 MsrPpinCtrl[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PPIN_CTL);
78 return TRUE;
79 }
80 }
81
82 return FALSE;
83}
84
107RETURN_STATUS
108EFIAPI
110 IN UINTN ProcessorNumber,
112 IN VOID *ConfigData OPTIONAL,
113 IN BOOLEAN State
114 )
115{
117
118 MsrPpinCtrl = (MSR_IVY_BRIDGE_PPIN_CTL_REGISTER *)ConfigData;
119 ASSERT (MsrPpinCtrl != NULL);
120
121 //
122 // Check whether processor already lock this register.
123 // If already locked, just based on the request state and
124 // the current state to return the status.
125 //
126 if (MsrPpinCtrl[ProcessorNumber].Bits.LockOut != 0) {
127 return MsrPpinCtrl[ProcessorNumber].Bits.Enable_PPIN == State ? RETURN_SUCCESS : RETURN_DEVICE_ERROR;
128 }
129
130 //
131 // Support function already check the processor which support PPIN feature, so this function not need
132 // to check the processor again.
133 //
134 // The scope of the MSR_IVY_BRIDGE_PPIN_CTL is package level, only program MSR_IVY_BRIDGE_PPIN_CTL
135 // once for each package.
136 //
137 if ((CpuInfo->First.Thread == 0) || (CpuInfo->First.Core == 0)) {
138 return RETURN_SUCCESS;
139 }
140
141 if (State) {
142 //
143 // Enable and Unlock.
144 // According to SDM, once Enable_PPIN is set, attempt to write 1 to LockOut will cause #GP.
145 //
146 MsrPpinCtrl[ProcessorNumber].Bits.Enable_PPIN = 1;
147 MsrPpinCtrl[ProcessorNumber].Bits.LockOut = 0;
148 } else {
149 //
150 // Disable and Lock.
151 // According to SDM, writing 1 to LockOut is permitted only if Enable_PPIN is clear.
152 //
153 MsrPpinCtrl[ProcessorNumber].Bits.Enable_PPIN = 0;
154 MsrPpinCtrl[ProcessorNumber].Bits.LockOut = 1;
155 }
156
158 ProcessorNumber,
159 Msr,
161 MsrPpinCtrl[ProcessorNumber].Uint64
162 );
163
164 return RETURN_SUCCESS;
165}
UINT64 UINTN
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
UINT64 EFIAPI AsmReadMsr64(IN UINT32 Index)
Definition: GccInlinePriv.c:60
#define MSR_IVY_BRIDGE_PPIN_CTL
Definition: IvyBridgeMsr.h:508
#define MSR_IVY_BRIDGE_PLATFORM_INFO_1
Definition: IvyBridgeMsr.h:589
#define NULL
Definition: Base.h:319
#define RETURN_DEVICE_ERROR
Definition: Base.h:1104
#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
BOOLEAN EFIAPI PpinSupport(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL)
Definition: Ppin.c:52
VOID *EFIAPI PpinGetConfigData(IN UINTN NumberOfProcessors)
Definition: Ppin.c:22
RETURN_STATUS EFIAPI PpinInitialize(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL, IN BOOLEAN State)
Definition: Ppin.c:109
#define CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value)
struct MSR_IVY_BRIDGE_PLATFORM_INFO_1_REGISTER::@874 Bits
struct MSR_IVY_BRIDGE_PPIN_CTL_REGISTER::@873 Bits