2 Update and publish processors' BIST information.
4 Copyright (c) 2015, 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
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.
17 EFI_SEC_PLATFORM_INFORMATION2_PPI mSecPlatformInformation2Ppi
= {
18 SecPlatformInformation2
21 EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation2Ppi
= {
22 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
23 &gEfiSecPlatformInformation2PpiGuid
,
24 &mSecPlatformInformation2Ppi
28 Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.
30 @param PeiServices The pointer to the PEI Services Table.
31 @param StructureSize The pointer to the variable describing size of the input buffer.
32 @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.
34 @retval EFI_SUCCESS The data was successfully returned.
35 @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to
36 hold the record is returned in StructureSize.
41 SecPlatformInformation2 (
42 IN CONST EFI_PEI_SERVICES
**PeiServices
,
43 IN OUT UINT64
*StructureSize
,
44 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2
*PlatformInformationRecord2
47 UINTN BistInformationSize
;
49 EFI_SEC_PLATFORM_INFORMATION_CPU
*CpuInstance
;
50 EFI_PROCESSOR_INFORMATION ProcessorInfo
;
51 EFI_HEALTH_FLAGS BistData
;
52 UINTN NumberOfProcessors
;
53 UINTN NumberOfEnabledProcessors
;
55 MpInitLibGetNumberOfProcessors(&NumberOfProcessors
, &NumberOfEnabledProcessors
);
57 BistInformationSize
= sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2
) +
58 sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU
) * NumberOfProcessors
;
60 // return the information size if input buffer size is too small
62 if ((*StructureSize
) < (UINT64
) BistInformationSize
) {
63 *StructureSize
= (UINT64
) BistInformationSize
;
64 return EFI_BUFFER_TOO_SMALL
;
67 PlatformInformationRecord2
->NumberOfCpus
= (UINT32
)NumberOfProcessors
;
68 CpuInstance
= PlatformInformationRecord2
->CpuInstance
;
69 for (CpuIndex
= 0; CpuIndex
< NumberOfProcessors
; CpuIndex
++) {
70 MpInitLibGetProcessorInfo (CpuIndex
, &ProcessorInfo
, &BistData
);
71 CpuInstance
[CpuIndex
].CpuLocation
= (UINT32
) ProcessorInfo
.ProcessorId
;
72 CpuInstance
[CpuIndex
].InfoRecord
.IA32HealthFlags
= BistData
;
79 Worker function to get CPUs' BIST by calling SecPlatformInformationPpi
80 or SecPlatformInformation2Ppi.
82 @param PeiServices Pointer to PEI Services Table
84 @param PpiDescriptor Return a pointer to instance of the
85 EFI_PEI_PPI_DESCRIPTOR
86 @param BistInformationData Pointer to BIST information data
88 @retval EFI_SUCCESS Retrieve of the BIST data successfully
89 @retval EFI_NOT_FOUND No sec platform information(2) ppi export
90 @retval EFI_DEVICE_ERROR Failed to get CPU Information
95 IN CONST EFI_PEI_SERVICES
**PeiServices
,
96 IN CONST EFI_GUID
*Guid
,
97 OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
,
98 OUT VOID
**BistInformationData
102 EFI_SEC_PLATFORM_INFORMATION2_PPI
*SecPlatformInformation2Ppi
;
103 EFI_SEC_PLATFORM_INFORMATION_RECORD2
*SecPlatformInformation2
;
104 UINT64 InformationSize
;
106 Status
= PeiServicesLocatePpi (
109 PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
110 (VOID
**)&SecPlatformInformation2Ppi
// PPI
112 if (Status
== EFI_NOT_FOUND
) {
113 return EFI_NOT_FOUND
;
116 if (Status
== EFI_SUCCESS
) {
118 // Get the size of the sec platform information2(BSP/APs' BIST data)
121 SecPlatformInformation2
= NULL
;
122 Status
= SecPlatformInformation2Ppi
->PlatformInformation2 (
125 SecPlatformInformation2
127 if (Status
== EFI_BUFFER_TOO_SMALL
) {
128 Status
= PeiServicesAllocatePool (
129 (UINTN
) InformationSize
,
130 (VOID
**) &SecPlatformInformation2
132 if (Status
== EFI_SUCCESS
) {
134 // Retrieve BIST data
136 Status
= SecPlatformInformation2Ppi
->PlatformInformation2 (
139 SecPlatformInformation2
141 if (Status
== EFI_SUCCESS
) {
142 *BistInformationData
= SecPlatformInformation2
;
149 return EFI_DEVICE_ERROR
;
153 Collects BIST data from PPI.
155 This function collects BIST data from Sec Platform Information2 PPI
156 or SEC Platform Information PPI.
158 @param PeiServices Pointer to PEI Services Table
162 CollectBistDataFromPpi (
163 IN CONST EFI_PEI_SERVICES
**PeiServices
167 EFI_PEI_PPI_DESCRIPTOR
*SecInformationDescriptor
;
168 EFI_SEC_PLATFORM_INFORMATION_RECORD2
*SecPlatformInformation2
;
169 EFI_SEC_PLATFORM_INFORMATION_RECORD
*SecPlatformInformation
;
171 EFI_SEC_PLATFORM_INFORMATION_CPU
*CpuInstance
;
172 EFI_SEC_PLATFORM_INFORMATION_CPU BspCpuInstance
;
173 UINTN ProcessorNumber
;
175 EFI_PROCESSOR_INFORMATION ProcessorInfo
;
176 EFI_HEALTH_FLAGS BistData
;
177 UINTN NumberOfProcessors
;
178 UINTN NumberOfEnabledProcessors
;
180 MpInitLibGetNumberOfProcessors(&NumberOfProcessors
, &NumberOfEnabledProcessors
);
182 SecPlatformInformation2
= NULL
;
183 SecPlatformInformation
= NULL
;
188 // Get BIST information from Sec Platform Information2 Ppi firstly
190 Status
= GetBistInfoFromPpi (
192 &gEfiSecPlatformInformation2PpiGuid
,
193 &SecInformationDescriptor
,
194 (VOID
*) &SecPlatformInformation2
196 if (Status
== EFI_SUCCESS
) {
198 // Sec Platform Information2 PPI includes BSP/APs' BIST information
200 NumberOfData
= SecPlatformInformation2
->NumberOfCpus
;
201 CpuInstance
= SecPlatformInformation2
->CpuInstance
;
204 // Otherwise, get BIST information from Sec Platform Information Ppi
206 Status
= GetBistInfoFromPpi (
208 &gEfiSecPlatformInformationPpiGuid
,
209 &SecInformationDescriptor
,
210 (VOID
*) &SecPlatformInformation
212 if (Status
== EFI_SUCCESS
) {
215 // SEC Platform Information only includes BSP's BIST information
216 // and does not have BSP's APIC ID
218 BspCpuInstance
.CpuLocation
= GetInitialApicId ();
219 BspCpuInstance
.InfoRecord
.IA32HealthFlags
.Uint32
= SecPlatformInformation
->IA32HealthFlags
.Uint32
;
220 CpuInstance
= &BspCpuInstance
;
222 DEBUG ((EFI_D_INFO
, "Does not find any stored CPU BIST information from PPI!\n"));
225 for (ProcessorNumber
= 0; ProcessorNumber
< NumberOfProcessors
; ProcessorNumber
++) {
226 MpInitLibGetProcessorInfo (ProcessorNumber
, &ProcessorInfo
, &BistData
);
227 for (CpuIndex
= 0; CpuIndex
< NumberOfData
; CpuIndex
++) {
228 ASSERT (CpuInstance
!= NULL
);
229 if (ProcessorInfo
.ProcessorId
== CpuInstance
[CpuIndex
].CpuLocation
) {
231 // Update processor's BIST data if it is already stored before
233 BistData
= CpuInstance
[CpuIndex
].InfoRecord
.IA32HealthFlags
;
236 if (BistData
.Uint32
!= 0) {
238 // Report Status Code that self test is failed
241 EFI_ERROR_CODE
| EFI_ERROR_MAJOR
,
242 (EFI_COMPUTING_UNIT_HOST_PROCESSOR
| EFI_CU_HP_EC_SELF_TEST
)
245 DEBUG ((EFI_D_INFO
, " APICID - 0x%08x, BIST - 0x%08x\n",
246 ProcessorInfo
.ProcessorId
,
251 if (SecPlatformInformation2
!= NULL
&& NumberOfData
< NumberOfProcessors
) {
253 // Reinstall SecPlatformInformation2 PPI to include new BIST information
255 Status
= PeiServicesReInstallPpi (
256 SecInformationDescriptor
,
257 &mPeiSecPlatformInformation2Ppi
259 ASSERT_EFI_ERROR (Status
);
262 // Install SecPlatformInformation2 PPI to include new BIST information
264 Status
= PeiServicesInstallPpi (&mPeiSecPlatformInformation2Ppi
);
265 ASSERT_EFI_ERROR(Status
);