//\r
Status = S3BootScriptExecute ();\r
\r
- //\r
- // Need report status back to S3ResumePeim. \r
- // If boot script execution is failed, S3ResumePeim wil report the error status code.\r
- //\r
- PeiS3ResumeState->ReturnStatus = (UINT64)(UINTN)Status;\r
-\r
AsmWbinvd ();\r
\r
//\r
// We need turn back to S3Resume - install boot script done ppi and report status code on S3resume.\r
//\r
if (PeiS3ResumeState != 0) {\r
+ //\r
+ // Need report status back to S3ResumePeim. \r
+ // If boot script execution is failed, S3ResumePeim wil report the error status code.\r
+ //\r
+ PeiS3ResumeState->ReturnStatus = (UINT64)(UINTN)Status;\r
if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {\r
//\r
// X64 S3 Resume\r
// This is the first-time loaded by DXE core. reload itself to NVS mem\r
//\r
//\r
- // A workarouond: Here we install a dummy handle\r
+ // A workaround: Here we install a dummy handle\r
//\r
NewImageHandle = NULL;\r
Status = gBS->InstallProtocolInterface (\r
EFI_NATIVE_INTERFACE,\r
NULL\r
);\r
+ ASSERT_EFI_ERROR (Status);\r
\r
Status = GetSectionFromAnyFv (\r
&gEfiCallerIdGuid,\r
(VOID **) &Buffer,\r
&BufferSize\r
);\r
+ ASSERT_EFI_ERROR (Status);\r
ImageContext.Handle = Buffer;\r
ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;\r
//\r
// Get information about the image being loaded\r
//\r
Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
+ ASSERT_EFI_ERROR (Status);\r
Pages = EFI_SIZE_TO_PAGES(BufferSize + ImageContext.SectionAlignment);\r
FfsBuffer = 0xFFFFFFFF;\r
Status = gBS->AllocatePages (\r
Pages,\r
&FfsBuffer\r
);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
+ ASSERT_EFI_ERROR (Status);\r
ImageContext.ImageAddress = (PHYSICAL_ADDRESS)(UINTN)FfsBuffer;\r
//\r
// Align buffer on section boundry\r
// Load the image to our new buffer\r
//\r
Status = PeCoffLoaderLoadImage (&ImageContext);\r
- if (EFI_ERROR (Status)) {\r
- gBS->FreePages (FfsBuffer, Pages);\r
- return Status;\r
- }\r
+ ASSERT_EFI_ERROR (Status);\r
\r
//\r
// Relocate the image in our new buffer\r
//\r
Status = PeCoffLoaderRelocateImage (&ImageContext);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Free the buffer allocated by ReadSection since the image has been relocated in the new buffer\r
+ //\r
+ gBS->FreePool (Buffer);\r
\r
- if (EFI_ERROR (Status)) {\r
- PeCoffLoaderUnloadImage (&ImageContext);\r
- gBS->FreePages (FfsBuffer, Pages);\r
- return Status;\r
- }\r
//\r
// Flush the instruction cache so the image data is written before we execute it\r
//\r
InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);\r
Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)(ImageContext.EntryPoint)) (NewImageHandle, SystemTable);\r
- if (EFI_ERROR (Status)) {\r
- gBS->FreePages (FfsBuffer, Pages);\r
- return Status;\r
- }\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
//\r
// Additional step for BootScript integrity\r
// Save BootScriptExecutor image\r
Pages,\r
&BootScriptExecutorBuffer\r
);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
+ ASSERT_EFI_ERROR (Status);\r
\r
EfiBootScriptExecutorVariable = (BOOT_SCRIPT_EXECUTOR_VARIABLE *)(UINTN)BootScriptExecutorBuffer;\r
EfiBootScriptExecutorVariable->BootScriptExecutorEntrypoint = (UINTN) S3BootScriptExecutorEntryFunction ;\r