]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously.
[mirror_edk2.git] / UefiCpuPkg / Library / RegisterCpuFeaturesLib / RegisterCpuFeatures.h
1 /** @file
2 CPU Register Table Library definitions.
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_H_
10 #define _REGISTER_CPU_FEATURES_H_
11 #include <PiPei.h>
12 #include <PiDxe.h>
13 #include <Ppi/MpServices.h>
14 #include <Protocol/MpService.h>
15
16 #include <Library/BaseLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/PcdLib.h>
19 #include <Library/RegisterCpuFeaturesLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/MemoryAllocationLib.h>
22 #include <Library/SynchronizationLib.h>
23 #include <Library/IoLib.h>
24 #include <Library/LocalApicLib.h>
25
26 #include <AcpiCpuData.h>
27
28 #define CPU_FEATURE_ENTRY_SIGNATURE SIGNATURE_32 ('C', 'F', 'E', 'S')
29
30 #define CPU_FEATURE_NAME_SIZE 128
31
32 typedef struct {
33 REGISTER_CPU_FEATURE_INFORMATION CpuInfo;
34 UINT8 *FeaturesSupportedMask;
35 LIST_ENTRY OrderList;
36 } CPU_FEATURES_INIT_ORDER;
37
38 typedef struct {
39 UINT32 Signature;
40 LIST_ENTRY Link;
41 UINT8 *FeatureMask;
42 CHAR8 *FeatureName;
43 CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc;
44 CPU_FEATURE_SUPPORT SupportFunc;
45 CPU_FEATURE_INITIALIZE InitializeFunc;
46 UINT8 *BeforeFeatureBitMask;
47 UINT8 *AfterFeatureBitMask;
48 UINT8 *CoreBeforeFeatureBitMask;
49 UINT8 *CoreAfterFeatureBitMask;
50 UINT8 *PackageBeforeFeatureBitMask;
51 UINT8 *PackageAfterFeatureBitMask;
52 VOID *ConfigData;
53 BOOLEAN BeforeAll;
54 BOOLEAN AfterAll;
55 } CPU_FEATURES_ENTRY;
56
57 //
58 // Flags used when program the register.
59 //
60 typedef struct {
61 volatile UINTN ConsoleLogLock; // Spinlock used to control console.
62 volatile UINTN MemoryMappedLock; // Spinlock used to program mmio
63 volatile UINT32 *CoreSemaphoreCount; // Semaphore containers used to program Core semaphore.
64 volatile UINT32 *PackageSemaphoreCount; // Semaphore containers used to program Package semaphore.
65 } PROGRAM_CPU_REGISTER_FLAGS;
66
67 typedef union {
68 EFI_MP_SERVICES_PROTOCOL *Protocol;
69 EFI_PEI_MP_SERVICES_PPI *Ppi;
70 } MP_SERVICES;
71
72 typedef struct {
73 UINTN FeaturesCount;
74 UINT32 BitMaskSize;
75 LIST_ENTRY FeatureList;
76
77 CPU_FEATURES_INIT_ORDER *InitOrder;
78 UINT8 *CapabilityPcd;
79 UINT8 *SettingPcd;
80
81 UINT32 NumberOfCpus;
82 ACPI_CPU_DATA *AcpiCpuData;
83
84 CPU_REGISTER_TABLE *RegisterTable;
85 CPU_REGISTER_TABLE *PreSmmRegisterTable;
86 UINTN BspNumber;
87
88 PROGRAM_CPU_REGISTER_FLAGS CpuFlags;
89
90 MP_SERVICES MpService;
91 } CPU_FEATURES_DATA;
92
93 #define CPU_FEATURE_ENTRY_FROM_LINK(a) \
94 CR ( \
95 (a), \
96 CPU_FEATURES_ENTRY, \
97 Link, \
98 CPU_FEATURE_ENTRY_SIGNATURE \
99 )
100
101 /**
102 Worker function to get CPU_FEATURES_DATA pointer.
103
104 @return Pointer to CPU_FEATURES_DATA.
105 **/
106 CPU_FEATURES_DATA *
107 GetCpuFeaturesData (
108 VOID
109 );
110
111 /**
112 Worker function to return processor index.
113
114 @param CpuFeaturesData Cpu Feature Data structure.
115
116 @return The processor index.
117 **/
118 UINTN
119 GetProcessorIndex (
120 IN CPU_FEATURES_DATA *CpuFeaturesData
121 );
122
123 /**
124 Gets detailed MP-related information on the requested processor at the
125 instant this call is made.
126
127 @param[in] ProcessorNumber The handle number of processor.
128 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
129 the requested processor is deposited.
130
131 @return Status of MpServices->GetProcessorInfo().
132 **/
133 EFI_STATUS
134 GetProcessorInformation (
135 IN UINTN ProcessorNumber,
136 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
137 );
138
139 /**
140 Worker function to execute a caller provided function on all enabled APs.
141
142 @param[in] Procedure A pointer to the function to be run on
143 enabled APs of the system.
144 @param[in] MpEvent A pointer to the event to be used later
145 to check whether procedure has done.
146 **/
147 VOID
148 StartupAllAPsWorker (
149 IN EFI_AP_PROCEDURE Procedure,
150 IN EFI_EVENT MpEvent
151 );
152
153 /**
154 Worker function to retrieve the number of logical processor in the platform.
155
156 @param[out] NumberOfCpus Pointer to the total number of logical
157 processors in the system, including the BSP
158 and disabled APs.
159 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
160 processors that exist in system, including
161 the BSP.
162 **/
163 VOID
164 GetNumberOfProcessor (
165 OUT UINTN *NumberOfCpus,
166 OUT UINTN *NumberOfEnabledProcessors
167 );
168
169 /**
170 Worker function to switch the requested AP to be the BSP from that point onward.
171
172 @param[in] ProcessorNumber The handle number of AP that is to become the new BSP.
173 **/
174 VOID
175 SwitchNewBsp (
176 IN UINTN ProcessorNumber
177 );
178
179 /**
180 Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask.
181
182 @param[in] FeatureMask A pointer to the CPU feature bit mask.
183 @param[in] BitMaskSize CPU feature bits mask buffer size.
184
185 **/
186 VOID
187 DumpCpuFeatureMask (
188 IN UINT8 *FeatureMask,
189 IN UINT32 BitMaskSize
190 );
191
192 /**
193 Dump CPU feature name or CPU feature bit mask.
194
195 @param[in] CpuFeature Pointer to CPU_FEATURES_ENTRY
196 @param[in] BitMaskSize CPU feature bits mask buffer size.
197
198 **/
199 VOID
200 DumpCpuFeature (
201 IN CPU_FEATURES_ENTRY *CpuFeature,
202 IN UINT32 BitMaskSize
203 );
204
205 /**
206 Return feature dependence result.
207
208 @param[in] CpuFeature Pointer to CPU feature.
209 @param[in] Before Check before dependence or after.
210 @param[in] NextCpuFeatureMask Pointer to next CPU feature Mask.
211
212 @retval return the dependence result.
213 **/
214 CPU_FEATURE_DEPENDENCE_TYPE
215 DetectFeatureScope (
216 IN CPU_FEATURES_ENTRY *CpuFeature,
217 IN BOOLEAN Before,
218 IN UINT8 *NextCpuFeatureMask
219 );
220
221 /**
222 Return feature dependence result.
223
224 @param[in] CpuFeature Pointer to CPU feature.
225 @param[in] Before Check before dependence or after.
226 @param[in] FeatureList Pointer to CPU feature list.
227
228 @retval return the dependence result.
229 **/
230 CPU_FEATURE_DEPENDENCE_TYPE
231 DetectNoneNeighborhoodFeatureScope (
232 IN CPU_FEATURES_ENTRY *CpuFeature,
233 IN BOOLEAN Before,
234 IN LIST_ENTRY *FeatureList
235 );
236
237 /**
238 Programs registers for the calling processor.
239
240 @param[in,out] Buffer The pointer to private data buffer.
241
242 **/
243 VOID
244 EFIAPI
245 SetProcessorRegister (
246 IN OUT VOID *Buffer
247 );
248
249 /**
250 Return ACPI_CPU_DATA data.
251
252 @return Pointer to ACPI_CPU_DATA data.
253 **/
254 ACPI_CPU_DATA *
255 GetAcpiCpuData (
256 VOID
257 );
258
259 /**
260 Worker function to get MP service pointer.
261
262 @return MP_SERVICES variable.
263 **/
264 MP_SERVICES
265 GetMpService (
266 VOID
267 );
268
269 #endif