2 Get SEC platform information(2) PPI and reinstall it.
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 EFI_SEC_PLATFORM_INFORMATION_PPI mSecPlatformInformation
= {
12 SecPlatformInformationBist
15 EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation
= {
16 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
17 &gEfiSecPlatformInformationPpiGuid
,
18 &mSecPlatformInformation
21 EFI_SEC_PLATFORM_INFORMATION2_PPI mSecPlatformInformation2
= {
22 SecPlatformInformation2Bist
25 EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation2
= {
26 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
27 &gEfiSecPlatformInformation2PpiGuid
,
28 &mSecPlatformInformation2
32 Worker function to parse CPU BIST information from Guided HOB.
34 @param[in, out] StructureSize Pointer to the variable describing size of the input buffer.
35 @param[in, out] StructureBuffer Pointer to the buffer save CPU BIST information.
37 @retval EFI_SUCCESS The data was successfully returned.
38 @retval EFI_BUFFER_TOO_SMALL The buffer was too small.
43 IN OUT UINT64
*StructureSize
,
44 IN OUT VOID
*StructureBuffer
47 EFI_HOB_GUID_TYPE
*GuidHob
;
51 GuidHob
= GetFirstGuidHob (&gEfiCallerIdGuid
);
52 if (GuidHob
== NULL
) {
57 DataInHob
= GET_GUID_HOB_DATA (GuidHob
);
58 DataSize
= GET_GUID_HOB_DATA_SIZE (GuidHob
);
61 // return the information from BistHob
63 if ((*StructureSize
) < (UINT64
)DataSize
) {
64 *StructureSize
= (UINT64
)DataSize
;
65 return EFI_BUFFER_TOO_SMALL
;
68 *StructureSize
= (UINT64
)DataSize
;
69 CopyMem (StructureBuffer
, DataInHob
, DataSize
);
74 Implementation of the PlatformInformation service in EFI_SEC_PLATFORM_INFORMATION_PPI.
76 @param[in] PeiServices Pointer to the PEI Services Table.
77 @param[in, out] StructureSize Pointer to the variable describing size of the input buffer.
78 @param[out] PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.
80 @retval EFI_SUCCESS The data was successfully returned.
81 @retval EFI_BUFFER_TOO_SMALL The buffer was too small.
86 SecPlatformInformationBist (
87 IN CONST EFI_PEI_SERVICES
**PeiServices
,
88 IN OUT UINT64
*StructureSize
,
89 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD
*PlatformInformationRecord
92 return GetBistFromHob (StructureSize
, PlatformInformationRecord
);
96 Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.
98 @param[in] PeiServices The pointer to the PEI Services Table.
99 @param[in, out] StructureSize The pointer to the variable describing size of the input buffer.
100 @param[out] PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.
102 @retval EFI_SUCCESS The data was successfully returned.
103 @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to
104 hold the record is returned in StructureSize.
109 SecPlatformInformation2Bist (
110 IN CONST EFI_PEI_SERVICES
**PeiServices
,
111 IN OUT UINT64
*StructureSize
,
112 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2
*PlatformInformationRecord2
115 return GetBistFromHob (StructureSize
, PlatformInformationRecord2
);
119 Worker function to get CPUs' BIST by calling SecPlatformInformationPpi
120 or SecPlatformInformation2Ppi.
122 @param[in] PeiServices Pointer to PEI Services Table
123 @param[in] Guid PPI Guid
124 @param[out] PpiDescriptor Return a pointer to instance of the
125 EFI_PEI_PPI_DESCRIPTOR
126 @param[out] BistInformationData Pointer to BIST information data
127 @param[out] BistInformationSize Return the size in bytes of BIST information
129 @retval EFI_SUCCESS Retrieve of the BIST data successfully
130 @retval EFI_NOT_FOUND No sec platform information(2) ppi export
131 @retval EFI_DEVICE_ERROR Failed to get CPU Information
136 IN CONST EFI_PEI_SERVICES
**PeiServices
,
137 IN CONST EFI_GUID
*Guid
,
138 OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
,
139 OUT VOID
**BistInformationData
,
140 OUT UINT64
*BistInformationSize OPTIONAL
144 EFI_SEC_PLATFORM_INFORMATION2_PPI
*SecPlatformInformation2Ppi
;
145 EFI_SEC_PLATFORM_INFORMATION_RECORD2
*SecPlatformInformation2
;
146 UINT64 InformationSize
;
148 Status
= PeiServicesLocatePpi (
151 PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
152 (VOID
**)&SecPlatformInformation2Ppi
// PPI
154 if (Status
== EFI_NOT_FOUND
) {
155 return EFI_NOT_FOUND
;
158 if (Status
== EFI_SUCCESS
) {
160 // Get the size of the sec platform information2(BSP/APs' BIST data)
163 SecPlatformInformation2
= NULL
;
164 Status
= SecPlatformInformation2Ppi
->PlatformInformation2 (
167 SecPlatformInformation2
169 if (Status
== EFI_BUFFER_TOO_SMALL
) {
170 Status
= PeiServicesAllocatePool (
171 (UINTN
)InformationSize
,
172 (VOID
**)&SecPlatformInformation2
174 if (Status
== EFI_SUCCESS
) {
176 // Retrieve BIST data
178 Status
= SecPlatformInformation2Ppi
->PlatformInformation2 (
181 SecPlatformInformation2
183 if (Status
== EFI_SUCCESS
) {
184 *BistInformationData
= SecPlatformInformation2
;
185 if (BistInformationSize
!= NULL
) {
186 *BistInformationSize
= InformationSize
;
195 return EFI_DEVICE_ERROR
;
199 Get CPUs' BIST by calling SecPlatformInformationPpi/SecPlatformInformation2Ppi.
203 RepublishSecPlatformInformationPpi (
208 CONST EFI_PEI_SERVICES
**PeiServices
;
209 UINT64 BistInformationSize
;
210 VOID
*BistInformationData
;
211 EFI_PEI_PPI_DESCRIPTOR
*SecInformationDescriptor
;
213 PeiServices
= GetPeiServicesTablePointer ();
214 Status
= GetBistInfoFromPpi (
216 &gEfiSecPlatformInformation2PpiGuid
,
217 &SecInformationDescriptor
,
218 &BistInformationData
,
221 if (Status
== EFI_SUCCESS
) {
225 (UINTN
)BistInformationSize
228 // The old SecPlatformInformation2 data is on temporary memory.
229 // After memory discovered, we should never get it from temporary memory,
230 // or the data will be crashed. So, we reinstall SecPlatformInformation2 PPI here.
232 Status
= PeiServicesReInstallPpi (
233 SecInformationDescriptor
,
234 &mPeiSecPlatformInformation2
238 if (Status
== EFI_NOT_FOUND
) {
239 Status
= GetBistInfoFromPpi (
241 &gEfiSecPlatformInformationPpiGuid
,
242 &SecInformationDescriptor
,
243 &BistInformationData
,
246 if (Status
== EFI_SUCCESS
) {
250 (UINTN
)BistInformationSize
253 // The old SecPlatformInformation data is on temporary memory.
254 // After memory discovered, we should never get it from temporary memory,
255 // or the data will be crashed. So, we reinstall SecPlatformInformation PPI here.
257 Status
= PeiServicesReInstallPpi (
258 SecInformationDescriptor
,
259 &mPeiSecPlatformInformation
261 } else if (Status
== EFI_NOT_FOUND
) {
266 ASSERT_EFI_ERROR (Status
);