]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
UefiCpuPkg/RegisterCpuFeaturesLib: Combine implementation.
[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
27 #include <AcpiCpuData.h>
28
29 #define CPU_FEATURE_ENTRY_SIGNATURE SIGNATURE_32 ('C', 'F', 'E', 'S')
30
31 #define CPU_FEATURE_NAME_SIZE 128
32
33 typedef struct {
34 REGISTER_CPU_FEATURE_INFORMATION CpuInfo;
35 UINT8 *FeaturesSupportedMask;
36 LIST_ENTRY OrderList;
37 } CPU_FEATURES_INIT_ORDER;
38
39 typedef struct {
40 UINT32 Signature;
41 LIST_ENTRY Link;
42 UINT8 *FeatureMask;
43 CHAR8 *FeatureName;
44 CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc;
45 CPU_FEATURE_SUPPORT SupportFunc;
46 CPU_FEATURE_INITIALIZE InitializeFunc;
47 UINT8 *BeforeFeatureBitMask;
48 UINT8 *AfterFeatureBitMask;
49 VOID *ConfigData;
50 BOOLEAN BeforeAll;
51 BOOLEAN AfterAll;
52 } CPU_FEATURES_ENTRY;
53
54 typedef struct {
55 UINTN FeaturesCount;
56 UINT32 BitMaskSize;
57 SPIN_LOCK MsrLock;
58 SPIN_LOCK MemoryMappedLock;
59 LIST_ENTRY FeatureList;
60
61 CPU_FEATURES_INIT_ORDER *InitOrder;
62 UINT8 *SupportPcd;
63 UINT8 *CapabilityPcd;
64 UINT8 *ConfigurationPcd;
65 UINT8 *SettingPcd;
66
67 CPU_REGISTER_TABLE *RegisterTable;
68 CPU_REGISTER_TABLE *PreSmmRegisterTable;
69 UINTN BspNumber;
70 } CPU_FEATURES_DATA;
71
72 #define CPU_FEATURE_ENTRY_FROM_LINK(a) \
73 CR ( \
74 (a), \
75 CPU_FEATURES_ENTRY, \
76 Link, \
77 CPU_FEATURE_ENTRY_SIGNATURE \
78 )
79
80 /**
81 Worker function to get CPU_FEATURES_DATA pointer.
82
83 @return Pointer to CPU_FEATURES_DATA.
84 **/
85 CPU_FEATURES_DATA *
86 GetCpuFeaturesData (
87 VOID
88 );
89
90 /**
91 Worker function to return processor index.
92
93 @return The processor index.
94 **/
95 UINTN
96 GetProcessorIndex (
97 VOID
98 );
99
100 /**
101 Gets detailed MP-related information on the requested processor at the
102 instant this call is made.
103
104 @param[in] ProcessorNumber The handle number of processor.
105 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
106 the requested processor is deposited.
107
108 @return Status of MpServices->GetProcessorInfo().
109 **/
110 EFI_STATUS
111 GetProcessorInformation (
112 IN UINTN ProcessorNumber,
113 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
114 );
115
116 /**
117 Worker function to execute a caller provided function on all enabled APs.
118
119 @param[in] Procedure A pointer to the function to be run on
120 enabled APs of the system.
121 **/
122 VOID
123 StartupAPsWorker (
124 IN EFI_AP_PROCEDURE Procedure
125 );
126
127 /**
128 Worker function to retrieve the number of logical processor in the platform.
129
130 @param[out] NumberOfCpus Pointer to the total number of logical
131 processors in the system, including the BSP
132 and disabled APs.
133 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
134 processors that exist in system, including
135 the BSP.
136 **/
137 VOID
138 GetNumberOfProcessor (
139 OUT UINTN *NumberOfCpus,
140 OUT UINTN *NumberOfEnabledProcessors
141 );
142
143 /**
144 Worker function to switch the requested AP to be the BSP from that point onward.
145
146 @param[in] ProcessorNumber The handle number of AP that is to become the new BSP.
147 **/
148 VOID
149 SwitchNewBsp (
150 IN UINTN ProcessorNumber
151 );
152
153 /**
154 Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask.
155
156 @param[in] FeatureMask A pointer to the CPU feature bit mask.
157 **/
158 VOID
159 DumpCpuFeatureMask (
160 IN UINT8 *FeatureMask
161 );
162
163 /**
164 Dump CPU feature name or CPU feature bit mask.
165
166 @param[in] CpuFeature Pointer to CPU_FEATURES_ENTRY
167 **/
168 VOID
169 DumpCpuFeature (
170 IN CPU_FEATURES_ENTRY *CpuFeature
171 );
172
173 #endif