]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
MdeModulePkg/Core: correct one coding style
[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
63 volatile UINTN ConsoleLogLock; // Spinlock used to control console.\r
64 volatile UINTN MemoryMappedLock; // Spinlock used to program mmio\r
65 volatile UINT32 *SemaphoreCount; // Semaphore used to program semaphore.\r
66} PROGRAM_CPU_REGISTER_FLAGS;\r
67\r
80c4b236
JF
68typedef struct {\r
69 UINTN FeaturesCount;\r
70 UINT32 BitMaskSize;\r
80c4b236
JF
71 LIST_ENTRY FeatureList;\r
72\r
73 CPU_FEATURES_INIT_ORDER *InitOrder;\r
7d3a7c22
SB
74 UINT8 *SupportPcd;\r
75 UINT8 *CapabilityPcd;\r
76 UINT8 *ConfigurationPcd;\r
77 UINT8 *SettingPcd;\r
80c4b236 78\r
b3c71b47
ED
79 UINT32 NumberOfCpus;\r
80 ACPI_CPU_DATA *AcpiCpuData;\r
81\r
80c4b236
JF
82 CPU_REGISTER_TABLE *RegisterTable;\r
83 CPU_REGISTER_TABLE *PreSmmRegisterTable;\r
84 UINTN BspNumber;\r
b3c71b47
ED
85\r
86 PROGRAM_CPU_REGISTER_FLAGS CpuFlags;\r
80c4b236
JF
87} CPU_FEATURES_DATA;\r
88\r
89#define CPU_FEATURE_ENTRY_FROM_LINK(a) \\r
90 CR ( \\r
91 (a), \\r
92 CPU_FEATURES_ENTRY, \\r
93 Link, \\r
94 CPU_FEATURE_ENTRY_SIGNATURE \\r
95 )\r
96\r
97/**\r
98 Worker function to get CPU_FEATURES_DATA pointer.\r
99\r
100 @return Pointer to CPU_FEATURES_DATA.\r
101**/\r
102CPU_FEATURES_DATA *\r
103GetCpuFeaturesData (\r
104 VOID\r
105 );\r
106\r
80c4b236
JF
107/**\r
108 Worker function to return processor index.\r
109\r
110 @return The processor index.\r
111**/\r
112UINTN\r
113GetProcessorIndex (\r
114 VOID\r
115 );\r
116\r
117/**\r
118 Gets detailed MP-related information on the requested processor at the\r
119 instant this call is made.\r
120\r
121 @param[in] ProcessorNumber The handle number of processor.\r
122 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for\r
123 the requested processor is deposited.\r
124\r
125 @return Status of MpServices->GetProcessorInfo().\r
126**/\r
127EFI_STATUS\r
128GetProcessorInformation (\r
129 IN UINTN ProcessorNumber,\r
130 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer\r
131 );\r
132\r
133/**\r
134 Worker function to execute a caller provided function on all enabled APs.\r
135\r
136 @param[in] Procedure A pointer to the function to be run on\r
137 enabled APs of the system.\r
b3c71b47
ED
138 @param[in] MpEvent A pointer to the event to be used later\r
139 to check whether procedure has done.\r
80c4b236
JF
140**/\r
141VOID\r
142StartupAPsWorker (\r
b3c71b47
ED
143 IN EFI_AP_PROCEDURE Procedure,\r
144 IN EFI_EVENT MpEvent\r
80c4b236
JF
145 );\r
146\r
147/**\r
148 Worker function to retrieve the number of logical processor in the platform.\r
149\r
150 @param[out] NumberOfCpus Pointer to the total number of logical\r
151 processors in the system, including the BSP\r
152 and disabled APs.\r
153 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical\r
154 processors that exist in system, including\r
155 the BSP.\r
156**/\r
157VOID\r
158GetNumberOfProcessor (\r
159 OUT UINTN *NumberOfCpus,\r
160 OUT UINTN *NumberOfEnabledProcessors\r
161 );\r
162\r
163/**\r
164 Worker function to switch the requested AP to be the BSP from that point onward.\r
165\r
166 @param[in] ProcessorNumber The handle number of AP that is to become the new BSP.\r
167**/\r
168VOID\r
169SwitchNewBsp (\r
170 IN UINTN ProcessorNumber\r
171 );\r
172\r
173/**\r
174 Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask.\r
175\r
176 @param[in] FeatureMask A pointer to the CPU feature bit mask.\r
177**/\r
178VOID\r
179DumpCpuFeatureMask (\r
180 IN UINT8 *FeatureMask\r
181 );\r
182\r
183/**\r
184 Dump CPU feature name or CPU feature bit mask.\r
185\r
186 @param[in] CpuFeature Pointer to CPU_FEATURES_ENTRY\r
187**/\r
188VOID\r
189DumpCpuFeature (\r
190 IN CPU_FEATURES_ENTRY *CpuFeature\r
191 );\r
192\r
b3c71b47
ED
193/**\r
194 Return feature dependence result.\r
195\r
1475b83f
ED
196 @param[in] CpuFeature Pointer to CPU feature.\r
197 @param[in] Before Check before dependence or after.\r
198 @param[in] NextCpuFeatureMask Pointer to next CPU feature Mask.\r
b3c71b47
ED
199\r
200 @retval return the dependence result.\r
201**/\r
202CPU_FEATURE_DEPENDENCE_TYPE\r
203DetectFeatureScope (\r
204 IN CPU_FEATURES_ENTRY *CpuFeature,\r
1475b83f
ED
205 IN BOOLEAN Before,\r
206 IN CHAR8 *NextCpuFeatureMask\r
b3c71b47
ED
207 );\r
208\r
209/**\r
210 Programs registers for the calling processor.\r
211\r
212 @param[in,out] Buffer The pointer to private data buffer.\r
213\r
214**/\r
215VOID\r
216EFIAPI\r
217SetProcessorRegister (\r
218 IN OUT VOID *Buffer\r
219 );\r
220\r
221/**\r
222 Return ACPI_CPU_DATA data.\r
223\r
224 @return Pointer to ACPI_CPU_DATA data.\r
225**/\r
226ACPI_CPU_DATA *\r
227GetAcpiCpuData (\r
228 VOID\r
229 );\r
230\r
80c4b236 231#endif\r