From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 13C0881C8A for ; Tue, 8 Nov 2016 22:32:04 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 08 Nov 2016 22:32:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,465,1473145200"; d="scan'208";a="899370700" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga003.jf.intel.com with ESMTP; 08 Nov 2016 22:31:59 -0800 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 8 Nov 2016 22:31:58 -0800 Received: from bgsmsx152.gar.corp.intel.com (10.224.48.50) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 8 Nov 2016 22:31:58 -0800 Received: from bgsmsx102.gar.corp.intel.com ([169.254.2.95]) by BGSMSX152.gar.corp.intel.com ([169.254.6.212]) with mapi id 14.03.0248.002; Wed, 9 Nov 2016 12:01:55 +0530 From: "Thomaiyar, Richard Marian" To: "Mudusuru, Giri P" , "edk2-devel@lists.01.org" CC: "Ma, Maurice" , "Yao, Jiewen" Thread-Topic: [PATCH] IntelFsp2Pkg: Support to return error status from FSP API done Thread-Index: AQHSOaTwJKra8Iusg0SlNIynL1L1kaDPUl0AgADeffA= Date: Wed, 9 Nov 2016 06:31:54 +0000 Message-ID: <4D8FDCBD0A020645AD4A2EB6A09DD3DA62CD27CE@BGSMSX102.gar.corp.intel.com> References: <20161108094525.35036-1-richard.marian.thomaiyar@intel.com> <4666AEFED60F8E4198B42BB01DCEABDF76F3CAB9@ORSMSX113.amr.corp.intel.com> In-Reply-To: <4666AEFED60F8E4198B42BB01DCEABDF76F3CAB9@ORSMSX113.amr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.223.10.10] MIME-Version: 1.0 Subject: Re: [PATCH] IntelFsp2Pkg: Support to return error status from FSP API done X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Nov 2016 06:32:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable The debug message will be displayed only when FSP API returned error status= , and when Boot Loader called the subsequent FSP API again. The idea here i= s to return the control back to Boot Loader if there is any error in the pr= evious API Call, without proceeding further and not having a hang inside th= e FSP.=20 Note: Regular FSP API call status will be displayed in debug message, befor= e returning the control back to the Boot Loader.=20 > + DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspSiliconInitApi() - [Status:=20 > + 0x%08X] - > End\n", Status)); Regards,=20 Richard -----Original Message----- From: Mudusuru, Giri P=20 Sent: Wednesday, November 9, 2016 4:09 AM To: Thomaiyar, Richard Marian ; edk2-de= vel@lists.01.org Cc: Ma, Maurice ; Yao, Jiewen Subject: RE: [PATCH] IntelFsp2Pkg: Support to return error status from FSP = API done Hi Richard, In the below snippet the debug message is based on the API status and will = not be display if the switch stack already happened right? Also since it is= in a do while loop "cannot proceed further" is not necessarily accurate. > - SetFspApiReturnStatus (EFI_SUCCESS); > - > - Pei2LoaderSwitchStack(); > - > + do { > + SetFspApiReturnStatus (Status); > + Pei2LoaderSwitchStack (); > + if (Status !=3D EFI_SUCCESS) { > + DEBUG ((DEBUG_ERROR, "!!!ERROR: FspSiliconInitApi() - [Status:=20 > + 0x%08X] - > Error encountered during previous API and cannot proceed further\n",=20 > Status)); > + } > + } while (Status !=3D EFI_SUCCESS); Thanks, -Giri > -----Original Message----- > From: Thomaiyar, Richard Marian > Sent: Tuesday, November 8, 2016 1:45 AM > To: edk2-devel@lists.01.org > Cc: Ma, Maurice ; Yao, Jiewen=20 > ; Mudusuru, Giri P ;=20 > Thomaiyar, Richard Marian > Subject: [PATCH] IntelFsp2Pkg: Support to return error status from FSP=20 > API done >=20 > Added FspMemoryInitDone2, FspTempRamExitDone2, FspSiliconInitDone2 to=20 > return error status to Boot Loader for FSP API calls. > To maintain backward compatibility existing functions=20 > (FspMemoryInitDone, FspTempRamExitDone, FspSiliconInitDone)=20 > declaration left untouched. >=20 > Cc: Maurice Ma > Cc: Jiewen Yao > Cc: Giri P Mudusuru > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Richard Thomaiyar > --- > IntelFsp2Pkg/Include/Library/FspPlatformLib.h | 35 +++++ > .../Library/BaseFspPlatformLib/FspPlatformNotify.c | 151=20 > +++++++++++++++++- > --- > 2 files changed, 163 insertions(+), 23 deletions(-) >=20 > diff --git a/IntelFsp2Pkg/Include/Library/FspPlatformLib.h > b/IntelFsp2Pkg/Include/Library/FspPlatformLib.h > index 61e77bd..1f39601 100644 > --- a/IntelFsp2Pkg/Include/Library/FspPlatformLib.h > +++ b/IntelFsp2Pkg/Include/Library/FspPlatformLib.h > @@ -93,4 +93,39 @@ FspWaitForNotify ( > VOID > ); >=20 > +/** > + This function transfer control back to BootLoader after FspSiliconInit= . > + > + @param[in] Status return status for the FspSiliconInit. > +**/ > +VOID > +EFIAPI > +FspSiliconInitDone2 ( > + IN EFI_STATUS Status > + ); > + > +/** > + This function returns control to BootLoader after MemoryInitApi. > + > + @param[in] Status return status for the MemoryInitApi. > + @param[in,out] HobListPtr The address of HobList pointer. > +**/ > +VOID > +EFIAPI > +FspMemoryInitDone2 ( > + IN EFI_STATUS Status, > + IN OUT VOID **HobListPtr > + ); > + > +/** > + This function returns control to BootLoader after TempRamExitApi. > + > + @param[in] Status return status for the TempRamExitApi. > +**/ > +VOID > +EFIAPI > +FspTempRamExitDone2 ( > + IN EFI_STATUS Status > + ); > + > #endif > diff --git=20 > a/IntelFsp2Pkg/Library/BaseFspPlatformLib/FspPlatformNotify.c > b/IntelFsp2Pkg/Library/BaseFspPlatformLib/FspPlatformNotify.c > index 755e84f..ac1fc1a 100644 > --- a/IntelFsp2Pkg/Library/BaseFspPlatformLib/FspPlatformNotify.c > +++ b/IntelFsp2Pkg/Library/BaseFspPlatformLib/FspPlatformNotify.c > @@ -108,35 +108,56 @@ FspNotificationHandler ( > /** > This function transfer control back to BootLoader after FspSiliconInit= . >=20 > + @param[in] Status return status for the FspSiliconInit. > + > **/ > VOID > EFIAPI > -FspSiliconInitDone ( > - VOID > +FspSiliconInitDone2 ( > + IN EFI_STATUS Status > ) > { > // > + // Convert to FSP EAS defined API return codes // switch (Status)=20 > + { > + case EFI_SUCCESS: > + case EFI_INVALID_PARAMETER: > + case EFI_UNSUPPORTED: > + case EFI_DEVICE_ERROR: > + break; > + default: > + DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspSiliconInitApi() Invalid=20 > + Error - > [Status: 0x%08X]\n", Status)); > + Status =3D EFI_DEVICE_ERROR; // Force to known error. > + break; > + } > + // > // This is the end of the FspSiliconInit API > // Give control back to the boot loader > // > SetFspMeasurePoint (FSP_PERF_ID_API_FSP_SILICON_INIT_EXIT); > - DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspSiliconInitApi() - End\n")); > + DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspSiliconInitApi() - [Status:=20 > + 0x%08X] - > End\n", Status)); > PERF_END_EX (&gFspPerformanceDataGuid, "EventRec", NULL, 0,=20 > FSP_STATUS_CODE_SILICON_INIT | FSP_STATUS_CODE_COMMON_CODE |=20 > FSP_STATUS_CODE_API_EXIT); > REPORT_STATUS_CODE (EFI_PROGRESS_CODE, FSP_STATUS_CODE_COMMON_CODE=20 > | FSP_STATUS_CODE_API_EXIT); > - SetFspApiReturnStatus (EFI_SUCCESS); > - > - Pei2LoaderSwitchStack(); > - > + do { > + SetFspApiReturnStatus (Status); > + Pei2LoaderSwitchStack (); > + if (Status !=3D EFI_SUCCESS) { > + DEBUG ((DEBUG_ERROR, "!!!ERROR: FspSiliconInitApi() - [Status:=20 > + 0x%08X] - > Error encountered during previous API and cannot proceed further\n",=20 > Status)); > + } > + } while (Status !=3D EFI_SUCCESS); > } >=20 > /** > This function returns control to BootLoader after MemoryInitApi. >=20 > - @param[in,out] HobListPtr The address of HobList pointer. > + @param[in] Status return status for the MemoryInitApi. > + @param[in,out] HobListPtr The address of HobList pointer, if NULL,=20 > + will get > value from GetFspApiParameter2 () > **/ > VOID > EFIAPI > -FspMemoryInitDone ( > +FspMemoryInitDone2 ( > + IN EFI_STATUS Status, > IN OUT VOID **HobListPtr > ) > { > @@ -145,15 +166,32 @@ FspMemoryInitDone ( > // Calling use FspMemoryInit API > // Update HOB and return the control directly > // > + if (HobListPtr =3D=3D NULL) { > + HobListPtr =3D (VOID **)GetFspApiParameter2 (); } > if (HobListPtr !=3D NULL) { > *HobListPtr =3D (VOID *) GetHobList (); > } > - > + // > + // Convert to FSP EAS defined API return codes // switch (Status)=20 > + { > + case EFI_SUCCESS: > + case EFI_INVALID_PARAMETER: > + case EFI_UNSUPPORTED: > + case EFI_DEVICE_ERROR: > + case EFI_OUT_OF_RESOURCES: > + break; > + default: > + DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspMemoryInitApi() Invalid=20 > + Error > [Status: 0x%08X]\n", Status)); > + Status =3D EFI_DEVICE_ERROR; // Force to known error. > + break; > + } > // > // This is the end of the FspMemoryInit API > // Give control back to the boot loader > // > - DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspMemoryInitApi() - End\n")); > + DEBUG ((DEBUG_INFO | DEBUG_INIT, "FspMemoryInitApi() - [Status:=20 > + 0x%08X] > - End\n", Status)); > SetFspMeasurePoint (FSP_PERF_ID_API_FSP_MEMORY_INIT_EXIT); > FspData =3D GetFspGlobalDataPointer (); > PERF_START_EX(&gFspPerformanceDataGuid, "EventRec", NULL, (FspData- > >PerfData[0] & FSP_PERFORMANCE_DATA_TIMER_MASK), > FSP_STATUS_CODE_TEMP_RAM_INIT | FSP_STATUS_CODE_COMMON_CODE|=20 > FSP_STATUS_CODE_API_ENTRY); @@ -161,8 +199,13 @@ FspMemoryInitDone ( > PERF_START_EX(&gFspPerformanceDataGuid, "EventRec", NULL, (FspData- > >PerfData[2] & FSP_PERFORMANCE_DATA_TIMER_MASK), > FSP_STATUS_CODE_MEMORY_INIT | FSP_STATUS_CODE_COMMON_CODE |=20 > FSP_STATUS_CODE_API_ENTRY); > PERF_END_EX(&gFspPerformanceDataGuid, "EventRec", NULL, 0,=20 > FSP_STATUS_CODE_MEMORY_INIT | FSP_STATUS_CODE_COMMON_CODE |=20 > FSP_STATUS_CODE_API_EXIT); > REPORT_STATUS_CODE (EFI_PROGRESS_CODE, FSP_STATUS_CODE_MEMORY_INIT=20 > | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT); > - SetFspApiReturnStatus (EFI_SUCCESS); > - Pei2LoaderSwitchStack (); > + do { > + SetFspApiReturnStatus (Status); > + Pei2LoaderSwitchStack (); > + if (Status !=3D EFI_SUCCESS) { > + DEBUG ((DEBUG_ERROR, "!!!ERROR: FspMemoryInitApi() - [Status:=20 > + 0x%08X] > - Error encountered during previous API and cannot proceed further\n",=20 > Status)); > + } > + } while (Status !=3D EFI_SUCCESS); >=20 > // > // The TempRamExitApi is called > @@ -185,25 +228,44 @@ FspMemoryInitDone ( > /** > This function returns control to BootLoader after TempRamExitApi. >=20 > + @param[in] Status return status for the TempRamExitApi. > + > **/ > VOID > EFIAPI > -FspTempRamExitDone ( > - VOID > +FspTempRamExitDone2 ( > + IN EFI_STATUS Status > ) > { > - > + // > + // Convert to FSP EAS defined API return codes // switch (Status)=20 > + { > + case EFI_SUCCESS: > + case EFI_INVALID_PARAMETER: > + case EFI_UNSUPPORTED: > + case EFI_DEVICE_ERROR: > + break; > + default: > + DEBUG ((DEBUG_INFO | DEBUG_INIT, "TempRamExitApi() Invalid=20 > + Error - > [Status: 0x%08X]\n", Status)); > + Status =3D EFI_DEVICE_ERROR; // Force to known error. > + break; > + } > // > // This is the end of the TempRamExit API > // Give control back to the boot loader > // > - DEBUG ((DEBUG_INFO | DEBUG_INIT, "TempRamExitApi() - End\n")); > + DEBUG ((DEBUG_INFO | DEBUG_INIT, "TempRamExitApi() - [Status:=20 > + 0x%08X] > - End\n", Status)); > SetFspMeasurePoint (FSP_PERF_ID_API_TEMP_RAM_EXIT_EXIT); > PERF_END_EX(&gFspPerformanceDataGuid, "EventRec", NULL, 0,=20 > FSP_STATUS_CODE_TEMP_RAM_EXIT | FSP_STATUS_CODE_COMMON_CODE |=20 > FSP_STATUS_CODE_API_EXIT); > REPORT_STATUS_CODE (EFI_PROGRESS_CODE,=20 > FSP_STATUS_CODE_TEMP_RAM_EXIT | FSP_STATUS_CODE_COMMON_CODE |=20 > FSP_STATUS_CODE_API_EXIT); > - SetFspApiReturnStatus (EFI_SUCCESS); > - Pei2LoaderSwitchStack (); > - > + do { > + SetFspApiReturnStatus (Status); > + Pei2LoaderSwitchStack (); > + if (Status !=3D EFI_SUCCESS) { > + DEBUG ((DEBUG_ERROR, "!!!ERROR: TempRamExitApi() - [Status:=20 > + 0x%08X] - > Error encountered during previous API and cannot proceed further\n",=20 > Status)); > + } > + } while (Status !=3D EFI_SUCCESS); > SetPhaseStatusCode (FSP_STATUS_CODE_SILICON_INIT); > SetFspMeasurePoint (FSP_PERF_ID_API_FSP_SILICON_INIT_ENTRY); > PERF_START_EX(&gFspPerformanceDataGuid, "EventRec", NULL, 0,=20 > FSP_STATUS_CODE_SILICON_INIT | FSP_STATUS_CODE_COMMON_CODE |=20 > FSP_STATUS_CODE_API_ENTRY); @@ -266,9 +328,7 @@ FspWaitForNotify ( > } > } >=20 > - SetFspApiReturnStatus(Status); > DEBUG ((DEBUG_INFO | DEBUG_INIT, "NotifyPhaseApi() - End [Status: > 0x%08X]\n", Status)); > - > SetFspMeasurePoint (FSP_PERF_ID_API_NOTIFY_POST_PCI_EXIT +=20 > Count); >=20 > if ((NotificationCount - 1) =3D=3D 0) { @@ -281,7 +341,13 @@=20 > FspWaitForNotify ( > PERF_END_EX(&gFspPerformanceDataGuid, "EventRec", NULL, 0,=20 > FSP_STATUS_CODE_END_OF_FIRMWARE_NOTIFICATION |=20 > FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT); > REPORT_STATUS_CODE (EFI_PROGRESS_CODE,=20 > FSP_STATUS_CODE_END_OF_FIRMWARE_NOTIFICATION |=20 > FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT); > } > - Pei2LoaderSwitchStack(); > + do { > + SetFspApiReturnStatus(Status); > + Pei2LoaderSwitchStack(); > + if (Status !=3D EFI_SUCCESS) { > + DEBUG ((DEBUG_ERROR, "!!!ERROR: NotifyPhaseApi() [Phase:=20 > + %08X] - > Failed - [Status: 0x%08X]\n", NotificationValue, Status)); > + } > + } while (Status !=3D EFI_SUCCESS); > } >=20 > // > @@ -290,3 +356,42 @@ FspWaitForNotify ( > // > } >=20 > +/** > + This function transfer control back to BootLoader after FspSiliconInit= . > + > +**/ > +VOID > +EFIAPI > +FspSiliconInitDone ( > + VOID > + ) > +{ > + FspSiliconInitDone2 (EFI_SUCCESS); > +} > + > +/** > + This function returns control to BootLoader after MemoryInitApi. > + > + @param[in,out] HobListPtr The address of HobList pointer. > +**/ > +VOID > +EFIAPI > +FspMemoryInitDone ( > + IN OUT VOID **HobListPtr > + ) > +{ > + FspMemoryInitDone2 (EFI_SUCCESS, HobListPtr); } > + > +/** > + This function returns control to BootLoader after TempRamExitApi. > + > +**/ > +VOID > +EFIAPI > +FspTempRamExitDone ( > + VOID > + ) > +{ > + FspTempRamExitDone2 (EFI_SUCCESS); > +} > -- > 2.9.0.windows.1