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