\r
#include "DxeIpl.h"\r
\r
-//\r
-// This global variable indicates whether this module has been shadowed\r
-// to memory.\r
-//\r
-BOOLEAN gInMemory = FALSE;\r
\r
//\r
-// Module Globals used in the DXE to PEI handoff\r
+// Module Globals used in the DXE to PEI hand off\r
// These must be module globals, so the stack can be switched\r
//\r
CONST EFI_DXE_IPL_PPI mDxeIplPpi = {\r
Decompress\r
};\r
\r
-CONST EFI_PEI_PPI_DESCRIPTOR mPpiList[] = {\r
+CONST EFI_PEI_PPI_DESCRIPTOR mPpiList[] = {\r
{\r
EFI_PEI_PPI_DESCRIPTOR_PPI,\r
&gEfiDxeIplPpiGuid,\r
}\r
};\r
\r
-CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = {\r
+CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = {\r
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
&gEfiEndOfPeiSignalPpiGuid,\r
NULL\r
};\r
\r
/**\r
- Initializes the Dxe Ipl PPI\r
+ Entry point of DXE IPL PEIM.\r
+ \r
+ This function installs DXE IPL PPI and Decompress PPI. It also reloads\r
+ itself to memory on non-S3 resume boot path.\r
\r
@param FileHandle Handle of the file being invoked.\r
@param PeiServices Describes the list of possible PEI Services.\r
\r
- @return EFI_SUCESS\r
+ @retval EFI_SUCESS The entry point of DXE IPL PEIM executes successfully.\r
+ @retval Others Some error occurs during the execution of this function. \r
+\r
**/\r
EFI_STATUS\r
EFIAPI\r
Status = PeiServicesRegisterForShadow (FileHandle);\r
if (Status == EFI_SUCCESS) {\r
//\r
- // EFI_SUCESS means the first time call register for shadow \r
+ // EFI_SUCESS means it is the first time to call register for shadow. \r
// \r
return Status;\r
- } else if (Status == EFI_ALREADY_STARTED) {\r
+ }\r
+ \r
+ //\r
+ // Ensure that DXE IPL is shadowed to permanent memory.\r
+ //\r
+ ASSERT (Status == EFI_ALREADY_STARTED);\r
\r
- //\r
- // Get custom extract guided section method guid list \r
- //\r
- ExtractHandlerNumber = ExtractGuidedSectionGetGuidList (&ExtractHandlerGuidTable);\r
- \r
- //\r
- // Install custom extraction guid ppi\r
- //\r
- if (ExtractHandlerNumber > 0) {\r
- GuidPpi = (EFI_PEI_PPI_DESCRIPTOR *) AllocatePool (ExtractHandlerNumber * sizeof (EFI_PEI_PPI_DESCRIPTOR));\r
- ASSERT (GuidPpi != NULL);\r
- while (ExtractHandlerNumber-- > 0) {\r
- GuidPpi->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r
- GuidPpi->Ppi = (VOID *) &mCustomGuidedSectionExtractionPpi;\r
- GuidPpi->Guid = &(ExtractHandlerGuidTable [ExtractHandlerNumber]);\r
- Status = PeiServicesInstallPpi (GuidPpi++);\r
- ASSERT_EFI_ERROR(Status);\r
- }\r
+ //\r
+ // Get custom extract guided section method guid list \r
+ //\r
+ ExtractHandlerNumber = ExtractGuidedSectionGetGuidList (&ExtractHandlerGuidTable);\r
+ \r
+ //\r
+ // Install custom extraction guid PPI\r
+ //\r
+ if (ExtractHandlerNumber > 0) {\r
+ GuidPpi = (EFI_PEI_PPI_DESCRIPTOR *) AllocatePool (ExtractHandlerNumber * sizeof (EFI_PEI_PPI_DESCRIPTOR));\r
+ ASSERT (GuidPpi != NULL);\r
+ while (ExtractHandlerNumber-- > 0) {\r
+ GuidPpi->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r
+ GuidPpi->Ppi = (VOID *) &mCustomGuidedSectionExtractionPpi;\r
+ GuidPpi->Guid = &ExtractHandlerGuidTable[ExtractHandlerNumber];\r
+ Status = PeiServicesInstallPpi (GuidPpi++);\r
+ ASSERT_EFI_ERROR(Status);\r
}\r
- } else {\r
- ASSERT (FALSE);\r
}\r
+ \r
}\r
\r
//\r
\r
/**\r
Main entry point to last PEIM. \r
+\r
+ This function finds DXE Core in the firmware volume and transfer the control to\r
+ DXE core.\r
\r
@param This Entry point for DXE IPL PPI.\r
@param PeiServices General purpose services available to every PEIM.\r
}\r
\r
//\r
- // Now should have a HOB with the DXE core w/ the old HOB destroyed\r
+ // Now should have a HOB with the DXE core\r
//\r
}\r
\r
FileHandle = DxeIplFindDxeCore ();\r
\r
//\r
- // Load the DXE Core from a Firmware Volume, may use LoadFile ppi to do this for save code size.\r
+ // Load the DXE Core from a Firmware Volume, may use LoadFile PPI to do this to save code size.\r
//\r
Status = PeiLoadFile (\r
FileHandle,\r
BuildModuleHob (\r
&DxeCoreFileInfo.FileName,\r
DxeCoreAddress,\r
- EFI_SIZE_TO_PAGES ((UINTN) DxeCoreSize) * EFI_PAGE_SIZE,\r
+ ALIGN_VALUE (DxeCoreSize, EFI_PAGE_SIZE),\r
DxeCoreEntryPoint\r
);\r
\r
//\r
// Report Status Code EFI_SW_PEI_PC_HANDOFF_TO_NEXT\r
//\r
- REPORT_STATUS_CODE (\r
- EFI_PROGRESS_CODE,\r
- PcdGet32(PcdStatusCodeValuePeiHandoffToDxe)\r
- );\r
+ REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdStatusCodeValuePeiHandoffToDxe));\r
\r
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading DXE CORE at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN)DxeCoreAddress, FUNCTION_ENTRY_POINT (DxeCoreEntryPoint)));\r
\r
//\r
// Transfer control to the DXE Core\r
- // The handoff state is simply a pointer to the HOB list\r
+ // The hand off state is simply a pointer to the HOB list\r
//\r
HandOffToDxeCore (DxeCoreEntryPoint, HobList);\r
//\r
// If we get here, then the DXE Core returned. This is an error\r
- // Dxe Core should not return.\r
+ // DxeCore should not return.\r
//\r
ASSERT (FALSE);\r
CpuDeadLoop ();\r
\r
ZeroMem (&ImageContext, sizeof (ImageContext));\r
ImageContext.Handle = Pe32Data;\r
- Status = GetImageReadFunction (&ImageContext);\r
+ ImageContext.ImageRead = PeiImageRead;\r
\r
- ASSERT_EFI_ERROR (Status);\r
\r
Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
if (EFI_ERROR (Status)) {\r
}\r
\r
//\r
- // Flush the instruction cache so the image data is written before we execute it\r
+ // Flush the instruction cache so the image data are written before we execute it\r
//\r
- InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);\r
+ InvalidateInstructionCacheRange ((VOID *)(UINTN) ImageContext.ImageAddress, (UINTN) ImageContext.ImageSize);\r
\r
*ImageAddress = ImageContext.ImageAddress;\r
*ImageSize = ImageContext.ImageSize;\r
if (*OutputBuffer == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- DEBUG ((DEBUG_INFO, "Customed Guided section Memory Size required is 0x%x and address is 0x%p\n", OutputBufferSize, *OutputBuffer));\r
+ DEBUG ((DEBUG_INFO, "Customized Guided section Memory Size required is 0x%x and address is 0x%p\n", OutputBufferSize, *OutputBuffer));\r
//\r
// *OutputBuffer still is one section. Adjust *OutputBuffer offset, \r
// skip EFI section header to make section data at page alignment.\r
OutputBuffer,\r
ScratchBuffer,\r
AuthenticationStatus\r
- );\r
+ );\r
if (EFI_ERROR (Status)) {\r
//\r
// Decode failed\r
/**\r
Decompresses a section to the output buffer.\r
\r
- This function lookes up the compression type field in the input section and\r
+ This function looks up the compression type field in the input section and\r
applies the appropriate compression algorithm to compress the section to a\r
callee allocated buffer.\r
\r
case EFI_STANDARD_COMPRESSION:\r
//\r
// Load EFI standard compression.\r
- // For compressed data, decompress them to dstbuffer.\r
+ // For compressed data, decompress them to destination buffer.\r
//\r
Status = UefiDecompressGetInfo (\r
(UINT8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),\r
}\r
\r
\r
-\r
-\r
/**\r
Updates the Stack HOB passed to DXE phase.\r
\r