-/**\r
- Get available system memory below 1MB by specified size.\r
-\r
- @param[in] PeiCpuMpData Pointer to PEI CPU MP Data\r
-**/\r
-VOID\r
-BackupAndPrepareWakeupBuffer(\r
- IN CPU_MP_DATA *CpuMpData\r
- )\r
-{\r
- CopyMem (\r
- (VOID *) CpuMpData->BackupBuffer,\r
- (VOID *) CpuMpData->WakeupBuffer,\r
- CpuMpData->BackupBufferSize\r
- );\r
- CopyMem (\r
- (VOID *) CpuMpData->WakeupBuffer,\r
- (VOID *) CpuMpData->AddressMap.RendezvousFunnelAddress,\r
- CpuMpData->AddressMap.RendezvousFunnelSize\r
- );\r
-}\r
-\r
-/**\r
- Restore wakeup buffer data.\r
-\r
- @param[in] PeiCpuMpData Pointer to PEI CPU MP Data\r
-**/\r
-VOID\r
-RestoreWakeupBuffer(\r
- IN CPU_MP_DATA *CpuMpData\r
- )\r
-{\r
- CopyMem (\r
- (VOID *) CpuMpData->WakeupBuffer,\r
- (VOID *) CpuMpData->BackupBuffer,\r
- CpuMpData->BackupBufferSize\r
- );\r
-}\r
-\r
-/**\r
- Notify function on End Of PEI PPI.\r
-\r
- On S3 boot, this function will restore wakeup buffer data.\r
- On normal boot, this function will flag wakeup buffer to be un-used type.\r
-\r
- @param[in] PeiServices The pointer to the PEI Services Table.\r
- @param[in] NotifyDescriptor Address of the notification descriptor data structure.\r
- @param[in] Ppi Address of the PPI that was installed.\r
-\r
- @retval EFI_SUCCESS When everything is OK.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMpEndOfPeiCallback (\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_BOOT_MODE BootMode;\r
- CPU_MP_DATA *CpuMpData;\r
- EFI_PEI_HOB_POINTERS Hob;\r
- EFI_HOB_MEMORY_ALLOCATION *MemoryHob;\r
-\r
- DEBUG ((DEBUG_INFO, "PeiMpInitLib: CpuMpEndOfPeiCallback () invoked\n"));\r
-\r
- Status = PeiServicesGetBootMode (&BootMode);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- CpuMpData = GetCpuMpData ();\r
- if (BootMode != BOOT_ON_S3_RESUME) {\r
- //\r
- // Get the HOB list for processing\r
- //\r
- Hob.Raw = GetHobList ();\r
- //\r
- // Collect memory ranges\r
- //\r
- while (!END_OF_HOB_LIST (Hob)) {\r
- if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r
- MemoryHob = Hob.MemoryAllocation;\r
- if (MemoryHob->AllocDescriptor.MemoryBaseAddress == CpuMpData->WakeupBuffer) {\r
- //\r
- // Flag this HOB type to un-used\r
- //\r
- GET_HOB_TYPE (Hob) = EFI_HOB_TYPE_UNUSED;\r
- break;\r
- }\r
- }\r
- Hob.Raw = GET_NEXT_HOB (Hob);\r
- }\r
- } else {\r
- CpuMpData->EndOfPeiFlag = TRUE;\r
- RestoreWakeupBuffer (CpuMpData);\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r