+ This function installs the PPIs that require permanent memory.\r
+\r
+ @param PeiServices Indirect reference to the PEI Services Table.\r
+ @param NotifyDescriptor Address of the notification descriptor data structure.\r
+ @param Ppi Address of the PPI that was installed.\r
+\r
+ @return EFI_SUCCESS The PPIs were installed successfully.\r
+ @return Others Some error occurs during the execution of this function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InstallIplPermanentMemoryPpis (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
+ IN VOID *Ppi\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_GUID *ExtractHandlerGuidTable;\r
+ UINTN ExtractHandlerNumber;\r
+ EFI_PEI_PPI_DESCRIPTOR *GuidPpi;\r
+\r
+ //\r
+ // Get custom extract guided section method guid list\r
+ //\r
+ ExtractHandlerNumber = ExtractGuidedSectionGetGuidList (&ExtractHandlerGuidTable);\r
+\r
+ //\r
+ // Install custom guided section extraction 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
+\r
+ //\r
+ // Install Decompress PPI.\r
+ //\r
+ Status = PeiServicesInstallPpi (&mDecompressPpiList);\r
+ ASSERT_EFI_ERROR(Status);\r
+\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Validate variable data for the MemoryTypeInformation.\r
+\r
+ @param MemoryData Variable data.\r
+ @param MemoryDataSize Variable data length.\r
+\r
+ @return TRUE The variable data is valid.\r
+ @return FALSE The variable data is invalid.\r
+\r
+**/\r
+BOOLEAN\r
+ValidateMemoryTypeInfoVariable (\r
+ IN EFI_MEMORY_TYPE_INFORMATION *MemoryData,\r
+ IN UINTN MemoryDataSize\r
+ )\r
+{\r
+ UINTN Count;\r
+ UINTN Index;\r
+\r
+ // Check the input parameter.\r
+ if (MemoryData == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
+ // Get Count\r
+ Count = MemoryDataSize / sizeof (*MemoryData);\r
+\r
+ // Check Size\r
+ if (Count * sizeof(*MemoryData) != MemoryDataSize) {\r
+ return FALSE;\r
+ }\r
+\r
+ // Check last entry type filed.\r
+ if (MemoryData[Count - 1].Type != EfiMaxMemoryType) {\r
+ return FALSE;\r
+ }\r
+\r
+ // Check the type filed.\r
+ for (Index = 0; Index < Count - 1; Index++) {\r
+ if (MemoryData[Index].Type >= EfiMaxMemoryType) {\r
+ return FALSE;\r
+ }\r
+ }\r
+\r
+ return TRUE;\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