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