X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=UefiCpuPkg%2FCpuMpPei%2FCpuBist.c;h=20728525e2d9f98ed0d126af4a94831b83fd8604;hb=0a563f3fecfd9baffe8dce51bb4411d6a748a936;hp=641eb10ca5809fba555963c7d9391f1a641b78b5;hpb=a1a4c7a467d12db1c4652fda504ada4f368c1e26;p=mirror_edk2.git diff --git a/UefiCpuPkg/CpuMpPei/CpuBist.c b/UefiCpuPkg/CpuMpPei/CpuBist.c index 641eb10ca5..20728525e2 100644 --- a/UefiCpuPkg/CpuMpPei/CpuBist.c +++ b/UefiCpuPkg/CpuMpPei/CpuBist.c @@ -1,7 +1,7 @@ /** @file Update and publish processors' BIST information. - Copyright (c) 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -44,34 +44,29 @@ SecPlatformInformation2 ( OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2 ) { - UINTN BistInformationSize; - UINTN CpuIndex; - EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstance; - EFI_PROCESSOR_INFORMATION ProcessorInfo; - EFI_HEALTH_FLAGS BistData; - UINTN NumberOfProcessors; - UINTN NumberOfEnabledProcessors; + EFI_HOB_GUID_TYPE *GuidHob; + VOID *DataInHob; + UINTN DataSize; - MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors); + GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid); + if (GuidHob == NULL) { + *StructureSize = 0; + return EFI_SUCCESS; + } + + DataInHob = GET_GUID_HOB_DATA (GuidHob); + DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob); - BistInformationSize = sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) + - sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * NumberOfProcessors; // - // return the information size if input buffer size is too small + // return the information from BistHob // - if ((*StructureSize) < (UINT64) BistInformationSize) { - *StructureSize = (UINT64) BistInformationSize; + if ((*StructureSize) < (UINT64) DataSize) { + *StructureSize = (UINT64) DataSize; return EFI_BUFFER_TOO_SMALL; } - PlatformInformationRecord2->NumberOfCpus = (UINT32)NumberOfProcessors; - CpuInstance = PlatformInformationRecord2->CpuInstance; - for (CpuIndex = 0; CpuIndex < NumberOfProcessors; CpuIndex ++) { - MpInitLibGetProcessorInfo (CpuIndex, &ProcessorInfo, &BistData); - CpuInstance[CpuIndex].CpuLocation = (UINT32) ProcessorInfo.ProcessorId; - CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags = BistData; - } - + *StructureSize = (UINT64) DataSize; + CopyMem (PlatformInformationRecord2, DataInHob, DataSize); return EFI_SUCCESS; } @@ -84,6 +79,7 @@ SecPlatformInformation2 ( @param PpiDescriptor Return a pointer to instance of the EFI_PEI_PPI_DESCRIPTOR @param BistInformationData Pointer to BIST information data + @param BistInformationSize Return the size in bytes of BIST information @retval EFI_SUCCESS Retrieve of the BIST data successfully @retval EFI_NOT_FOUND No sec platform information(2) ppi export @@ -95,7 +91,8 @@ GetBistInfoFromPpi ( IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_GUID *Guid, OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, - OUT VOID **BistInformationData + OUT VOID **BistInformationData, + OUT UINT64 *BistInformationSize OPTIONAL ) { EFI_STATUS Status; @@ -140,6 +137,9 @@ GetBistInfoFromPpi ( ); if (Status == EFI_SUCCESS) { *BistInformationData = SecPlatformInformation2; + if (BistInformationSize != NULL) { + *BistInformationSize = InformationSize; + } return EFI_SUCCESS; } } @@ -176,14 +176,26 @@ CollectBistDataFromPpi ( EFI_HEALTH_FLAGS BistData; UINTN NumberOfProcessors; UINTN NumberOfEnabledProcessors; + UINTN BistInformationSize; + EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2; + EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstanceInHob; + MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors); + BistInformationSize = sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) + + sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * NumberOfProcessors; + Status = PeiServicesAllocatePool ( + (UINTN) BistInformationSize, + (VOID **) &PlatformInformationRecord2 + ); + ASSERT_EFI_ERROR (Status); + PlatformInformationRecord2->NumberOfCpus = (UINT32)NumberOfProcessors; + SecPlatformInformation2 = NULL; SecPlatformInformation = NULL; NumberOfData = 0; CpuInstance = NULL; - // // Get BIST information from Sec Platform Information2 Ppi firstly // @@ -191,7 +203,8 @@ CollectBistDataFromPpi ( PeiServices, &gEfiSecPlatformInformation2PpiGuid, &SecInformationDescriptor, - (VOID *) &SecPlatformInformation2 + (VOID *) &SecPlatformInformation2, + NULL ); if (Status == EFI_SUCCESS) { // @@ -207,7 +220,8 @@ CollectBistDataFromPpi ( PeiServices, &gEfiSecPlatformInformationPpiGuid, &SecInformationDescriptor, - (VOID *) &SecPlatformInformation + (VOID *) &SecPlatformInformation, + NULL ); if (Status == EFI_SUCCESS) { NumberOfData = 1; @@ -243,11 +257,24 @@ CollectBistDataFromPpi ( ); } DEBUG ((EFI_D_INFO, " APICID - 0x%08x, BIST - 0x%08x\n", - ProcessorInfo.ProcessorId, + (UINT32) ProcessorInfo.ProcessorId, BistData )); + CpuInstanceInHob = PlatformInformationRecord2->CpuInstance; + CpuInstanceInHob[ProcessorNumber].CpuLocation = (UINT32) ProcessorInfo.ProcessorId; + CpuInstanceInHob[ProcessorNumber].InfoRecord.IA32HealthFlags = BistData; } + // + // Build SecPlatformInformation2 PPI GUIDed HOB that also could be consumed + // by CPU MP driver to get CPU BIST data + // + BuildGuidDataHob ( + &gEfiSecPlatformInformation2PpiGuid, + PlatformInformationRecord2, + (UINTN) BistInformationSize + ); + if (SecPlatformInformation2 != NULL && NumberOfData < NumberOfProcessors) { // // Reinstall SecPlatformInformation2 PPI to include new BIST information