X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFsp2WrapperPkg%2FFspsWrapperPeim%2FFspsWrapperPeim.c;h=70dac7a4142dc62c1ba8b549599fe17b097d8eea;hp=9bc720fe2d406afa8ce4aab7a2c197b0e673ea64;hb=e69dcef54e03a193964e1ca39769d8a394ccde9d;hpb=cf1d454983fb4fd3b580a92bd242310467a5eaef diff --git a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c index 9bc720fe2d..70dac7a414 100644 --- a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c +++ b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c @@ -3,7 +3,7 @@ register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi notify to call FspSiliconInit API. - Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2017, 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 @@ -36,22 +36,22 @@ #include #include #include -#include #include #include +#include extern EFI_PEI_NOTIFY_DESCRIPTOR mS3EndOfPeiNotifyDesc; extern EFI_GUID gFspHobGuid; /** -This function handles S3 resume task at the end of PEI + This function handles S3 resume task at the end of PEI -@param[in] PeiServices Pointer to PEI Services Table. -@param[in] NotifyDesc Pointer to the descriptor for the Notification event that -caused this function to execute. -@param[in] Ppi Pointer to the PPI data associated with this function. + @param[in] PeiServices Pointer to PEI Services Table. + @param[in] NotifyDesc Pointer to the descriptor for the Notification event that + caused this function to execute. + @param[in] Ppi Pointer to the PPI data associated with this function. -@retval EFI_STATUS Always return EFI_SUCCESS + @retval EFI_STATUS Always return EFI_SUCCESS **/ EFI_STATUS EFIAPI @@ -68,14 +68,14 @@ EFI_PEI_NOTIFY_DESCRIPTOR mS3EndOfPeiNotifyDesc = { }; /** -This function handles S3 resume task at the end of PEI + This function handles S3 resume task at the end of PEI -@param[in] PeiServices Pointer to PEI Services Table. -@param[in] NotifyDesc Pointer to the descriptor for the Notification event that -caused this function to execute. -@param[in] Ppi Pointer to the PPI data associated with this function. + @param[in] PeiServices Pointer to PEI Services Table. + @param[in] NotifyDesc Pointer to the descriptor for the Notification event that + caused this function to execute. + @param[in] Ppi Pointer to the PPI data associated with this function. -@retval EFI_STATUS Always return EFI_SUCCESS + @retval EFI_STATUS Always return EFI_SUCCESS **/ EFI_STATUS EFIAPI @@ -94,25 +94,49 @@ S3EndOfPeiNotify( Status = CallFspNotifyPhase (&NotifyPhaseParams); DEBUG((DEBUG_INFO, "FSP S3NotifyPhase AfterPciEnumeration status: 0x%x\n", Status)); + // + // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status + // + if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) { + DEBUG((DEBUG_INFO, "FSP S3NotifyPhase AfterPciEnumeration requested reset 0x%x\n", Status)); + CallFspWrapperResetSystem ((UINT32)Status); + } + NotifyPhaseParams.Phase = EnumInitPhaseReadyToBoot; Status = CallFspNotifyPhase (&NotifyPhaseParams); DEBUG((DEBUG_INFO, "FSP S3NotifyPhase ReadyToBoot status: 0x%x\n", Status)); + // + // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status + // + if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) { + DEBUG((DEBUG_INFO, "FSP S3NotifyPhase ReadyToBoot requested reset 0x%x\n", Status)); + CallFspWrapperResetSystem ((UINT32)Status); + } + NotifyPhaseParams.Phase = EnumInitPhaseEndOfFirmware; Status = CallFspNotifyPhase (&NotifyPhaseParams); DEBUG((DEBUG_INFO, "FSP S3NotifyPhase EndOfFirmware status: 0x%x\n", Status)); + // + // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status + // + if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) { + DEBUG((DEBUG_INFO, "FSP S3NotifyPhase EndOfFirmware requested reset 0x%x\n", Status)); + CallFspWrapperResetSystem ((UINT32)Status); + } + return EFI_SUCCESS; } /** -Return Hob list produced by FSP. + Return Hob list produced by FSP. -@param[in] PeiServices The pointer to the PEI Services Table. -@param[in] This The pointer to this instance of this PPI. -@param[out] FspHobList The pointer to Hob list produced by FSP. + @param[in] PeiServices The pointer to the PEI Services Table. + @param[in] This The pointer to this instance of this PPI. + @param[out] FspHobList The pointer to Hob list produced by FSP. -@return EFI_SUCCESS FReturn Hob list produced by FSP successfully. + @return EFI_SUCCESS FReturn Hob list produced by FSP successfully. **/ EFI_STATUS EFIAPI @@ -133,13 +157,13 @@ EFI_PEI_PPI_DESCRIPTOR mPeiFspSiliconInitDonePpi = { }; /** -Return Hob list produced by FSP. + Return Hob list produced by FSP. -@param[in] PeiServices The pointer to the PEI Services Table. -@param[in] This The pointer to this instance of this PPI. -@param[out] FspHobList The pointer to Hob list produced by FSP. + @param[in] PeiServices The pointer to the PEI Services Table. + @param[in] This The pointer to this instance of this PPI. + @param[out] FspHobList The pointer to Hob list produced by FSP. -@return EFI_SUCCESS FReturn Hob list produced by FSP successfully. + @return EFI_SUCCESS FReturn Hob list produced by FSP successfully. **/ EFI_STATUS EFIAPI @@ -185,14 +209,14 @@ EFI_PEI_NOTIFY_DESCRIPTOR mPeiMemoryDiscoveredNotifyDesc = { }; /** -This function is called after PEI core discover memory and finish migration. + This function is called after PEI core discover memory and finish migration. -@param[in] PeiServices Pointer to PEI Services Table. -@param[in] NotifyDesc Pointer to the descriptor for the Notification event that -caused this function to execute. -@param[in] Ppi Pointer to the PPI data associated with this function. + @param[in] PeiServices Pointer to PEI Services Table. + @param[in] NotifyDesc Pointer to the descriptor for the Notification event that + caused this function to execute. + @param[in] Ppi Pointer to the PPI data associated with this function. -@retval EFI_STATUS Always return EFI_SUCCESS + @retval EFI_STATUS Always return EFI_SUCCESS **/ EFI_STATUS EFIAPI @@ -210,25 +234,44 @@ PeiMemoryDiscoveredNotify ( FSPS_UPD_COMMON *FspsUpdDataPtr; UINTN *SourceData; - DEBUG ((DEBUG_INFO, "PeiMemoryDiscoveredNotify enter\n")); - - // - // Copy default FSP-S UPD data from Flash - // + FspsUpdDataPtr = NULL; + FspsHeaderPtr = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspsBaseAddress)); - FspsUpdDataPtr = (FSPS_UPD_COMMON *)AllocateZeroPool ((UINTN)FspsHeaderPtr->CfgRegionSize); - ASSERT (FspsUpdDataPtr != NULL); - SourceData = (UINTN *)((UINTN)FspsHeaderPtr->ImageBase + (UINTN)FspsHeaderPtr->CfgRegionOffset); - CopyMem (FspsUpdDataPtr, SourceData, (UINTN)FspsHeaderPtr->CfgRegionSize); + DEBUG ((DEBUG_INFO, "FspsHeaderPtr - 0x%x\n", FspsHeaderPtr)); + if (FspsHeaderPtr == NULL) { + return EFI_DEVICE_ERROR; + } + + if (PcdGet32 (PcdFspsUpdDataAddress) == 0 && (FspsHeaderPtr->CfgRegionSize != 0) && (FspsHeaderPtr->CfgRegionOffset != 0)) { + // + // Copy default FSP-S UPD data from Flash + // + FspsUpdDataPtr = (FSPS_UPD_COMMON *)AllocateZeroPool ((UINTN)FspsHeaderPtr->CfgRegionSize); + ASSERT (FspsUpdDataPtr != NULL); + SourceData = (UINTN *)((UINTN)FspsHeaderPtr->ImageBase + (UINTN)FspsHeaderPtr->CfgRegionOffset); + CopyMem (FspsUpdDataPtr, SourceData, (UINTN)FspsHeaderPtr->CfgRegionSize); + } else { + FspsUpdDataPtr = (FSPS_UPD_COMMON *)PcdGet32 (PcdFspsUpdDataAddress); + ASSERT (FspsUpdDataPtr != NULL); + } UpdateFspsUpdData ((VOID *)FspsUpdDataPtr); TimeStampCounterStart = AsmReadTsc (); - PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x9000); + PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_SILICON_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_ENTRY); Status = CallFspSiliconInit ((VOID *)FspsUpdDataPtr); - PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x907F); + PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_SILICON_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT); DEBUG ((DEBUG_INFO, "Total time spent executing FspSiliconInitApi: %d millisecond\n", DivU64x32 (GetTimeInNanoSecond (AsmReadTsc () - TimeStampCounterStart), 1000000))); + + // + // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status + // + if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) { + DEBUG((DEBUG_INFO, "FspSiliconInitApi requested reset 0x%x\n", Status)); + CallFspWrapperResetSystem ((UINT32)Status); + } + if (EFI_ERROR(Status)) { DEBUG ((DEBUG_ERROR, "ERROR - Failed to execute FspSiliconInitApi(), Status = %r\n", Status)); } @@ -276,7 +319,7 @@ FspsWrapperInit ( // Status = PeiServicesNotifyPpi (&mPeiMemoryDiscoveredNotifyDesc); ASSERT_EFI_ERROR (Status); - + // // Register EndOfPei Notify for S3 to run FSP NotifyPhase // @@ -304,7 +347,6 @@ FspsWrapperPeimEntryPoint ( IN CONST EFI_PEI_SERVICES **PeiServices ) { - DEBUG ((DEBUG_INFO, "FspsWrapperPeimEntryPoint\n")); FspsWrapperInit ();