14 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
15 &gEfiPeiMmCommunicationPpiGuid,
20 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
21 &gEfiEndOfPeiSignalPpiGuid,
43 IN OUT VOID *CommBuffer,
56 DEBUG ((DEBUG_INFO,
"StandaloneMmIpl Communicate Enter\n"));
59 if (GuidHob !=
NULL) {
60 MmCommBuffer = GET_GUID_HOB_DATA (GuidHob);
63 DEBUG ((DEBUG_ERROR,
"MmCommBuffer is not existed !!!\n"));
64 ASSERT (GuidHob !=
NULL);
69 Size =
sizeof (SmiCommand);
74 if ((CommBuffer ==
NULL) || (CommSize ==
NULL)) {
75 return EFI_INVALID_PARAMETER;
77 TempCommSize = *CommSize;
82 return EFI_INVALID_PARAMETER;
88 return EFI_INVALID_PARAMETER;
100 Status = MmControl->Trigger (
122 DEBUG ((DEBUG_ERROR,
"StandaloneMmIpl Communicate failed (%r)\n", Status));
147 OUT VOID **MmCoreImageAddress
161 for (FvIndex = 0; ; FvIndex++) {
163 if (EFI_ERROR (Status)) {
172 if (EFI_ERROR (Status)) {
176 ASSERT (FileHandle !=
NULL);
177 if (FileHandle !=
NULL) {
185 if (EFI_ERROR (Status)) {
199 if (!EFI_ERROR (Status)) {
201 *MmFvSize = VolumeInfo.
FvSize;
204 return EFI_NOT_FOUND;
208 return EFI_NOT_FOUND;
235 IN PHYSICAL_ADDRESS MmCoreImageAddress,
236 IN UINT64 MmCoreImageSize,
237 IN PHYSICAL_ADDRESS MmCoreEntryPoint,
243 VOID *PlatformHobList;
244 UINTN PlatformHobSize;
246 UINTN FoundationHobSize;
255 ASSERT (PlatformHobSize != 0);
260 ASSERT (PlatformHobList !=
NULL);
261 if (PlatformHobList ==
NULL) {
262 DEBUG ((DEBUG_ERROR,
"%a: Out of resource to create platform MM HOBs\n", __func__));
266 BufferSize = PlatformHobSize;
269 ASSERT (BufferSize == PlatformHobSize);
277 MmProfileDataHob =
NULL;
285 FoundationHobSize = 0;
302 ASSERT (FoundationHobSize != 0);
309 ASSERT (HobList !=
NULL);
310 if (HobList ==
NULL) {
311 DEBUG ((DEBUG_ERROR,
"Out of resource to create MM HOBs\n"));
325 (UINT8 *)HobList + PlatformHobSize,
366 MmramRanges = CurrentBlock->Descriptor;
372 for (Index = 0, MaxSize = SIZE_256KB - EFI_PAGE_SIZE; Index < CurrentBlock->NumberOfMmReservedRegions; Index++) {
376 if ((MmramRanges[Index].RegionState & (EFI_ALLOCATED | EFI_NEEDS_TESTING | EFI_NEEDS_ECC_INITIALIZATION)) != 0) {
380 if (MmramRanges[Index].CpuStart >= BASE_1MB) {
381 if ((MmramRanges[Index].CpuStart + MmramRanges[Index].PhysicalSize) <= BASE_4GB) {
382 if (MmramRanges[Index].PhysicalSize >= MaxSize) {
384 *LagestMmramRangeIndex = Index;
391 if (Found ==
FALSE) {
392 DEBUG ((DEBUG_ERROR,
"Not found largest unlocated MMRAM\n"));
414 UINTN LagestMmramRangeIndex;
415 UINT32 FullMmramRangeCount;
424 ASSERT (MmramInfoHob !=
NULL);
425 if (MmramInfoHob ==
NULL) {
426 DEBUG ((DEBUG_WARN,
"SmramMemoryReserve HOB not found\n"));
436 ASSERT (LagestMmramRangeIndex < CurrentBlock->NumberOfMmReservedRegions);
443 &gEfiSmmSmramMemoryGuid,
446 ASSERT (NewDescriptorBlock !=
NULL);
449 FullMmramRanges = NewDescriptorBlock->
Descriptor;
456 Largest = &FullMmramRanges[LagestMmramRangeIndex];
479 *NewBlock = NewDescriptorBlock;
505 STANDALONE_MM_FOUNDATION_ENTRY_POINT Entry;
525 if (EFI_ERROR (Status)) {
536 return EFI_NOT_FOUND;
548 DEBUG ((DEBUG_INFO,
"StandaloneMM IPL loading MM Core at MMRAM address %p\n", (VOID *)(
UINTN)ImageContext.
ImageAddress));
554 if (!EFI_ERROR (Status)) {
559 if (!EFI_ERROR (Status)) {
561 DEBUG ((DEBUG_INFO,
"MmCoreImageSize - 0x%016lx\n", ImageContext.
ImageSize));
587 DEBUG ((DEBUG_INFO,
"StandaloneMM IPL calling Standalone MM Core at MMRAM address - 0x%016lx\n", ImageContext.
EntryPoint));
592 Entry = (STANDALONE_MM_FOUNDATION_ENTRY_POINT)(
UINTN)ImageContext.
EntryPoint;
593 Status = Entry (MmHobList);
631 CommunicateHeader.
Data[0] = 0;
636 Size =
sizeof (CommunicateHeader);
668 CommunicateHeader.
Data[0] = 0;
673 Size =
sizeof (CommunicateHeader);
693 UINT64 MmCommBufferPages;
695 MmCommBufferPages =
PcdGet32 (PcdMmCommBufferPages);
698 ASSERT (MmCommBuffer !=
NULL);
710 DEBUG ((DEBUG_ERROR,
"Fail to allocate MM communication buffer\n"));
725 if (MmCommBuffer->
Status == 0) {
726 DEBUG ((DEBUG_ERROR,
"Fail to allocate memory for MM communication status\n"));
727 ASSERT (MmCommBuffer->
Status != 0);
765 ASSERT (MmCommBuffer !=
NULL);
VOID *EFIAPI InvalidateInstructionCacheRange(IN VOID *Address, IN UINTN Length)
CONST EFI_PEI_SERVICES **EFIAPI GetPeiServicesTablePointer(VOID)
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
VOID *EFIAPI BuildGuidHob(IN CONST EFI_GUID *Guid, IN UINTN DataLength)
VOID EFIAPI CpuDeadLoop(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID EFIAPI FreePages(IN VOID *Buffer, IN UINTN Pages)
EFI_STATUS EFIAPI PeiServicesFfsFindSectionData(IN EFI_SECTION_TYPE SectionType, IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **SectionData)
EFI_STATUS EFIAPI PeiServicesFfsFindNextVolume(IN UINTN Instance, IN OUT EFI_PEI_FV_HANDLE *VolumeHandle)
EFI_STATUS EFIAPI PeiServicesFfsFindNextFile(IN EFI_FV_FILETYPE SearchType, IN EFI_PEI_FV_HANDLE VolumeHandle, IN OUT EFI_PEI_FILE_HANDLE *FileHandle)
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
EFI_STATUS EFIAPI PeiServicesNotifyPpi(IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
EFI_STATUS EFIAPI PeiServicesFfsGetVolumeInfo(IN EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_FV_INFO *VolumeInfo)
#define RETURN_BUFFER_TOO_SMALL
#define OFFSET_OF(TYPE, Field)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
VOID * MmIplCreateHob(IN VOID *Hob, IN UINT16 HobType, IN UINT16 HobLength)
RETURN_STATUS CreateMmFoundationHobList(IN UINT8 *FoundationHobList, IN OUT UINTN *FoundationHobSize, IN UINT8 *PlatformHobList, IN UINTN PlatformHobSize, IN EFI_PHYSICAL_ADDRESS MmFvBase, IN UINT64 MmFvSize, IN EFI_GUID *MmCoreFileName, IN EFI_PHYSICAL_ADDRESS MmCoreImageAddress, IN UINT64 MmCoreImageSize, IN EFI_PHYSICAL_ADDRESS MmCoreEntryPoint, IN EFI_HOB_MEMORY_ALLOCATION *MmProfileDataHob, IN EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *Block)
EFI_HOB_MEMORY_ALLOCATION * BuildMmProfileDataHobInPeiHobList(VOID)
RETURN_STATUS EFIAPI MmUnblockMemoryRequest(IN PHYSICAL_ADDRESS UnblockAddress, IN UINT64 NumberOfPages)
#define PcdGet32(TokenName)
#define FeaturePcdGet(TokenName)
RETURN_STATUS EFIAPI PeCoffLoaderLoadImage(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
RETURN_STATUS EFIAPI PeCoffLoaderRelocateImage(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
RETURN_STATUS EFIAPI PeCoffLoaderGetImageInfo(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
RETURN_STATUS EFIAPI PeCoffLoaderImageReadFromMemory(IN VOID *FileHandle, IN UINTN FileOffset, IN OUT UINTN *ReadSize, OUT VOID *Buffer)
EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION
VOID * EFI_PEI_FILE_HANDLE
VOID *EFIAPI AllocatePages(IN UINTN Pages)
VOID *EFIAPI AllocateRuntimePages(IN UINTN Pages)
EFI_STATUS EFIAPI Communicate(IN CONST EFI_PEI_MM_COMMUNICATION_PPI *This, IN OUT VOID *CommBuffer, IN OUT UINTN *CommSize)
VOID FindLargestMmramRange(IN OUT UINTN *LagestMmramRangeIndex, IN EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *CurrentBlock)
EFI_STATUS ExecuteMmCoreFromMmram(IN MM_COMM_BUFFER *MmCommBuffer)
MM_COMM_BUFFER * MmIplBuildCommBufferHob(VOID)
EFI_STATUS LocateMmCoreFv(OUT EFI_PHYSICAL_ADDRESS *MmFvBase, OUT UINTN *MmFvSize, OUT EFI_GUID *MmCoreFileName, OUT VOID **MmCoreImageAddress)
EFI_STATUS EFIAPI EndOfPeiCallback(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
VOID * CreatMmHobList(OUT UINTN *HobSize, IN MM_COMM_BUFFER *MmCommBuffer, IN EFI_PHYSICAL_ADDRESS MmFvBase, IN UINT64 MmFvSize, IN EFI_GUID *MmCoreFileName, IN PHYSICAL_ADDRESS MmCoreImageAddress, IN UINT64 MmCoreImageSize, IN PHYSICAL_ADDRESS MmCoreEntryPoint, IN EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *Block)
EFI_STATUS MmIplDispatchMmDrivers(VOID)
EFI_STATUS EFIAPI StandaloneMmIplPeiEntry(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
EFI_PHYSICAL_ADDRESS MmIplAllocateMmramPage(IN UINTN Pages, OUT EFI_MMRAM_HOB_DESCRIPTOR_BLOCK **NewBlock)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_SIZE_TO_PAGES(Size)
EFI_PHYSICAL_ADDRESS CpuStart
EFI_PHYSICAL_ADDRESS PhysicalStart
UINT32 NumberOfMmReservedRegions
EFI_MMRAM_DESCRIPTOR Descriptor[1]
BOOLEAN IsCommBufferValid
EFI_PHYSICAL_ADDRESS PhysicalStart
EFI_PHYSICAL_ADDRESS Status
PE_COFF_LOADER_READ_FILE ImageRead
PHYSICAL_ADDRESS EntryPoint
PHYSICAL_ADDRESS ImageAddress