]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
c9055a2d82a5630fea447e3b0f8ff0f8e72ab03b
[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 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _REGISTER_CPU_FEATURES_H_
16 #define _REGISTER_CPU_FEATURES_H_
17 #include <PiPei.h>
18 #include <PiDxe.h>
19 #include <Ppi/MpServices.h>
20 #include <Protocol/MpService.h>
21
22 #include <Library/BaseLib.h>
23 #include <Library/DebugLib.h>
24 #include <Library/PcdLib.h>
25 #include <Library/RegisterCpuFeaturesLib.h>
26 #include <Library/BaseMemoryLib.h>
27 #include <Library/MemoryAllocationLib.h>
28 #include <Library/SynchronizationLib.h>
29 #include <Library/IoLib.h>
30 #include <Library/LocalApicLib.h>
31
32 #include <AcpiCpuData.h>
33
34 #define CPU_FEATURE_ENTRY_SIGNATURE SIGNATURE_32 ('C', 'F', 'E', 'S')
35
36 #define CPU_FEATURE_NAME_SIZE 128
37
38 typedef struct {
39 REGISTER_CPU_FEATURE_INFORMATION CpuInfo;
40 UINT8 *FeaturesSupportedMask;
41 LIST_ENTRY OrderList;
42 } CPU_FEATURES_INIT_ORDER;
43
44 typedef struct {
45 UINT32 Signature;
46 LIST_ENTRY Link;
47 UINT8 *FeatureMask;
48 CHAR8 *FeatureName;
49 CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc;
50 CPU_FEATURE_SUPPORT SupportFunc;
51 CPU_FEATURE_INITIALIZE InitializeFunc;
52 UINT8 *BeforeFeatureBitMask;
53 UINT8 *AfterFeatureBitMask;
54 UINT8 *CoreBeforeFeatureBitMask;
55 UINT8 *CoreAfterFeatureBitMask;
56 UINT8 *PackageBeforeFeatureBitMask;
57 UINT8 *PackageAfterFeatureBitMask;
58 VOID *ConfigData;
59 BOOLEAN BeforeAll;
60 BOOLEAN AfterAll;
61 } CPU_FEATURES_ENTRY;
62
63 //
64 // Flags used when program the register.
65 //
66 typedef struct {
67 volatile UINTN ConsoleLogLock; // Spinlock used to control console.
68 volatile UINTN MemoryMappedLock; // Spinlock used to program mmio
69 volatile UINT32 *CoreSemaphoreCount; // Semaphore containers used to program Core semaphore.
70 volatile UINT32 *PackageSemaphoreCount; // Semaphore containers used to program Package semaphore.
71 } PROGRAM_CPU_REGISTER_FLAGS;
72
73 typedef union {
74 EFI_MP_SERVICES_PROTOCOL *Protocol;
75 EFI_PEI_MP_SERVICES_PPI *Ppi;
76 } MP_SERVICES;
77
78 typedef struct {
79 UINTN FeaturesCount;
80 UINT32 BitMaskSize;
81 LIST_ENTRY FeatureList;
82
83 CPU_FEATURES_INIT_ORDER *InitOrder;
84 UINT8 *CapabilityPcd;
85 UINT8 *SettingPcd;
86
87 UINT32 NumberOfCpus;
88 ACPI_CPU_DATA *AcpiCpuData;
89
90 CPU_REGISTER_TABLE *RegisterTable;
91 CPU_REGISTER_TABLE *PreSmmRegisterTable;
92 UINTN BspNumber;
93
94 PROGRAM_CPU_REGISTER_FLAGS CpuFlags;
95
96 MP_SERVICES MpService;
97 } CPU_FEATURES_DATA;
98
99 #define CPU_FEATURE_ENTRY_FROM_LINK(a) \
100 CR ( \
101 (a), \
102 CPU_FEATURES_ENTRY, \
103 Link, \
104 CPU_FEATURE_ENTRY_SIGNATURE \
105 )
106
107 /**
108 Worker function to get CPU_FEATURES_DATA pointer.
109
110 @return Pointer to CPU_FEATURES_DATA.
111 **/
112 CPU_FEATURES_DATA *
113 GetCpuFeaturesData (
114 VOID
115 );
116
117 /**
118 Worker function to return processor index.
119
120 @param CpuFeaturesData Cpu Feature Data structure.
121
122 @return The processor index.
123 **/
124 UINTN
125 GetProcessorIndex (
126 IN CPU_FEATURES_DATA *CpuFeaturesData
127 );
128
129 /**
130 Gets detailed MP-related information on the requested processor at the
131 instant this call is made.
132
133 @param[in] ProcessorNumber The handle number of processor.
134 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
135 the requested processor is deposited.
136
137 @return Status of MpServices->GetProcessorInfo().
138 **/
139 EFI_STATUS
140 GetProcessorInformation (
141 IN UINTN ProcessorNumber,
142 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
143 );
144
145 /**
146 Worker function to execute a caller provided function on all enabled APs.
147
148 @param[in] Procedure A pointer to the function to be run on
149 enabled APs of the system.
150 @param[in] MpEvent A pointer to the event to be used later
151 to check whether procedure has done.
152 **/
153 VOID
154 StartupAPsWorker (
155 IN EFI_AP_PROCEDURE Procedure,
156 IN EFI_EVENT MpEvent
157 );
158
159 /**
160 Worker function to retrieve the number of logical processor in the platform.
161
162 @param[out] NumberOfCpus Pointer to the total number of logical
163 processors in the system, including the BSP
164 and disabled APs.
165 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
166 processors that exist in system, including
167 the BSP.
168 **/
169 VOID
170 GetNumberOfProcessor (
171 OUT UINTN *NumberOfCpus,
172 OUT UINTN *NumberOfEnabledProcessors
173 );
174
175 /**
176 Worker function to switch the requested AP to be the BSP from that point onward.
177
178 @param[in] ProcessorNumber The handle number of AP that is to become the new BSP.
179 **/
180 VOID
181 SwitchNewBsp (
182 IN UINTN ProcessorNumber
183 );
184
185 /**
186 Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask.
187
188 @param[in] FeatureMask A pointer to the CPU feature bit mask.
189 **/
190 VOID
191 DumpCpuFeatureMask (
192 IN UINT8 *FeatureMask
193 );
194
195 /**
196 Dump CPU feature name or CPU feature bit mask.
197
198 @param[in] CpuFeature Pointer to CPU_FEATURES_ENTRY
199 **/
200 VOID
201 DumpCpuFeature (
202 IN CPU_FEATURES_ENTRY *CpuFeature
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