X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFsp2WrapperPkg%2FFspWrapperNotifyDxe%2FFspWrapperNotifyDxe.c;h=a2fe18c2da106fd01d3930da5a91644dcbaf2f40;hp=30c06b88bf16cf841f5538bbdc39159d0cb9267b;hb=5866d49923967b86e2921672cd83b3f506b45e3d;hpb=cf1d454983fb4fd3b580a92bd242310467a5eaef diff --git a/IntelFsp2WrapperPkg/FspWrapperNotifyDxe/FspWrapperNotifyDxe.c b/IntelFsp2WrapperPkg/FspWrapperNotifyDxe/FspWrapperNotifyDxe.c index 30c06b88bf..a2fe18c2da 100644 --- a/IntelFsp2WrapperPkg/FspWrapperNotifyDxe/FspWrapperNotifyDxe.c +++ b/IntelFsp2WrapperPkg/FspWrapperNotifyDxe/FspWrapperNotifyDxe.c @@ -22,8 +22,12 @@ #include #include #include +#include #include #include +#include + +#define FSP_API_NOTIFY_PHASE_AFTER_PCI_ENUMERATION BIT16 typedef EFI_STATUS @@ -90,9 +94,18 @@ OnPciEnumerationComplete ( } NotifyPhaseParams.Phase = EnumInitPhaseAfterPciEnumeration; - PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x6000); + PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_POST_PCIE_ENUM_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_ENTRY); Status = CallFspNotifyPhase (&NotifyPhaseParams); - PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x607F); + PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_POST_PCIE_ENUM_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT); + + // + // 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 NotifyPhase AfterPciEnumeration requested reset 0x%x\n", Status)); + CallFspWrapperResetSystem ((UINT32)Status); + } + if (Status != EFI_SUCCESS) { DEBUG((DEBUG_ERROR, "FSP NotifyPhase AfterPciEnumeration failed, status: 0x%x\n", Status)); } else { @@ -120,38 +133,27 @@ OnReadyToBoot ( { NOTIFY_PHASE_PARAMS NotifyPhaseParams; EFI_STATUS Status; - ADD_PERFORMANCE_RECORD_PROTOCOL *AddPerfRecordInterface; - EFI_PEI_HOB_POINTERS Hob; - VOID **FspHobListPtr; gBS->CloseEvent (Event); NotifyPhaseParams.Phase = EnumInitPhaseReadyToBoot; - PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x4000); + PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_READY_TO_BOOT_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_ENTRY); Status = CallFspNotifyPhase (&NotifyPhaseParams); - PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x407F); + PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_READY_TO_BOOT_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT); + + // + // 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 NotifyPhase ReadyToBoot requested reset 0x%x\n", Status)); + CallFspWrapperResetSystem ((UINT32)Status); + } + if (Status != EFI_SUCCESS) { DEBUG((DEBUG_ERROR, "FSP NotifyPhase ReadyToBoot failed, status: 0x%x\n", Status)); } else { DEBUG((DEBUG_INFO, "FSP NotifyPhase ReadyToBoot Success.\n")); } - - Status = gBS->LocateProtocol ( - &gAddPerfRecordProtocolGuid, - NULL, - (VOID**) &AddPerfRecordInterface - ); - if (EFI_ERROR (Status)) { - DEBUG((DEBUG_INFO, "gAddPerfRecordProtocolGuid - Locate protocol failed\n")); - return; - } else { - Hob.Raw = GetHobList (); - if (Hob.Raw != NULL) { - Hob.Raw = GetNextGuidHob (&gFspHobGuid, Hob.Raw); - FspHobListPtr = GET_GUID_HOB_DATA(Hob.Raw); - AddPerfRecordInterface->AddPerformanceRecords((VOID *)(UINTN)(((UINT32)(UINTN)*FspHobListPtr) & 0xFFFFFFFF)); - } - } } /** @@ -170,20 +172,47 @@ OnEndOfFirmware ( IN VOID *Context ) { - NOTIFY_PHASE_PARAMS NotifyPhaseParams; - EFI_STATUS Status; + NOTIFY_PHASE_PARAMS NotifyPhaseParams; + EFI_STATUS Status; + ADD_PERFORMANCE_RECORD_PROTOCOL *AddPerfRecordInterface; + EFI_PEI_HOB_POINTERS Hob; + VOID **FspHobListPtr; gBS->CloseEvent (Event); NotifyPhaseParams.Phase = EnumInitPhaseEndOfFirmware; - PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x2000); + PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_END_OF_FIRMWARE_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_ENTRY); Status = CallFspNotifyPhase (&NotifyPhaseParams); - PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x207F); + PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_END_OF_FIRMWARE_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT); + + // + // 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 NotifyPhase EndOfFirmware requested reset 0x%x\n", Status)); + CallFspWrapperResetSystem ((UINT32)Status); + } + if (Status != EFI_SUCCESS) { DEBUG((DEBUG_ERROR, "FSP NotifyPhase EndOfFirmware failed, status: 0x%x\n", Status)); } else { DEBUG((DEBUG_INFO, "FSP NotifyPhase EndOfFirmware Success.\n")); } + Status = gBS->LocateProtocol ( + &gAddPerfRecordProtocolGuid, + NULL, + (VOID**) &AddPerfRecordInterface + ); + if (EFI_ERROR (Status)) { + DEBUG((DEBUG_INFO, "gAddPerfRecordProtocolGuid - Locate protocol failed\n")); + return; + } else { + Hob.Raw = GetFirstGuidHob (&gFspHobGuid); + if (Hob.Raw != NULL) { + FspHobListPtr = GET_GUID_HOB_DATA (Hob.Raw); + AddPerfRecordInterface->AddPerformanceRecords ((VOID *)(UINTN)(((UINT32)(UINTN)*FspHobListPtr) & 0xFFFFFFFF)); + } + } } /** @@ -209,6 +238,7 @@ FspWrapperNotifyDxeEntryPoint ( EFI_EVENT ReadyToBootEvent; VOID *Registration; EFI_EVENT ProtocolNotifyEvent; + UINT32 FspApiMask; // // Load this driver's image to memory @@ -218,14 +248,17 @@ FspWrapperNotifyDxeEntryPoint ( return EFI_SUCCESS; } - ProtocolNotifyEvent = EfiCreateProtocolNotifyEvent ( - &gEfiPciEnumerationCompleteProtocolGuid, - TPL_CALLBACK, - OnPciEnumerationComplete, - NULL, - &Registration - ); - ASSERT (ProtocolNotifyEvent != NULL); + FspApiMask = PcdGet32 (PcdSkipFspApi); + if ((FspApiMask & FSP_API_NOTIFY_PHASE_AFTER_PCI_ENUMERATION) == 0) { + ProtocolNotifyEvent = EfiCreateProtocolNotifyEvent ( + &gEfiPciEnumerationCompleteProtocolGuid, + TPL_CALLBACK, + OnPciEnumerationComplete, + NULL, + &Registration + ); + ASSERT (ProtocolNotifyEvent != NULL); + } Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK,