TianoCore EDK2 master
Loading...
Searching...
No Matches
StandaloneMmIplPei.c
Go to the documentation of this file.
1
10
11EFI_PEI_MM_COMMUNICATION_PPI mMmCommunicationPpi = { Communicate };
12
13EFI_PEI_PPI_DESCRIPTOR mPpiList = {
14 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
15 &gEfiPeiMmCommunicationPpiGuid,
16 &mMmCommunicationPpi
17};
18
19EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {
20 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
21 &gEfiEndOfPeiSignalPpiGuid,
23};
24
40EFIAPI
43 IN OUT VOID *CommBuffer,
44 IN OUT UINTN *CommSize
45 )
46{
47 EFI_STATUS Status;
48 EFI_PEI_MM_CONTROL_PPI *MmControl;
49 UINT8 SmiCommand;
50 UINTN Size;
51 UINTN TempCommSize;
52 EFI_HOB_GUID_TYPE *GuidHob;
53 MM_COMM_BUFFER *MmCommBuffer;
54 MM_COMM_BUFFER_STATUS *MmCommBufferStatus;
55
56 DEBUG ((DEBUG_INFO, "StandaloneMmIpl Communicate Enter\n"));
57
58 GuidHob = GetFirstGuidHob (&gMmCommBufferHobGuid);
59 if (GuidHob != NULL) {
60 MmCommBuffer = GET_GUID_HOB_DATA (GuidHob);
61 MmCommBufferStatus = (MM_COMM_BUFFER_STATUS *)(UINTN)MmCommBuffer->Status;
62 } else {
63 DEBUG ((DEBUG_ERROR, "MmCommBuffer is not existed !!!\n"));
64 ASSERT (GuidHob != NULL);
65 return EFI_NOT_FOUND;
66 }
67
68 SmiCommand = 0;
69 Size = sizeof (SmiCommand);
70
71 //
72 // Check parameters
73 //
74 if ((CommBuffer == NULL) || (CommSize == NULL)) {
75 return EFI_INVALID_PARAMETER;
76 } else {
77 TempCommSize = *CommSize;
78 //
79 // CommSize must hold HeaderGuid and MessageLength
80 //
81 if (TempCommSize < OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data)) {
82 return EFI_INVALID_PARAMETER;
83 }
84 }
85
86 if (TempCommSize > EFI_PAGES_TO_SIZE (MmCommBuffer->NumberOfPages)) {
87 DEBUG ((DEBUG_ERROR, "Communicate buffer size (%d) is over MAX (%d) size!", TempCommSize, EFI_PAGES_TO_SIZE (MmCommBuffer->NumberOfPages)));
88 return EFI_INVALID_PARAMETER;
89 }
90
91 CopyMem ((VOID *)(UINTN)MmCommBuffer->PhysicalStart, CommBuffer, TempCommSize);
92 MmCommBufferStatus->IsCommBufferValid = TRUE;
93
94 //
95 // Generate Software SMI
96 //
97 Status = PeiServicesLocatePpi (&gEfiPeiMmControlPpiGuid, 0, NULL, (VOID **)&MmControl);
98 ASSERT_EFI_ERROR (Status);
99
100 Status = MmControl->Trigger (
102 MmControl,
103 (INT8 *)&SmiCommand,
104 &Size,
105 FALSE,
106 0
107 );
108 ASSERT_EFI_ERROR (Status);
109
110 //
111 // Return status from software SMI
112 //
113 *CommSize = (UINTN)MmCommBufferStatus->ReturnBufferSize;
114
115 //
116 // Copy the returned data to the non-mmram buffer (CommBuffer)
117 //
118 CopyMem (CommBuffer, (VOID *)(MmCommBuffer->PhysicalStart), *CommSize);
119
120 Status = (EFI_STATUS)MmCommBufferStatus->ReturnStatus;
121 if (Status != EFI_SUCCESS) {
122 DEBUG ((DEBUG_ERROR, "StandaloneMmIpl Communicate failed (%r)\n", Status));
123 } else {
124 MmCommBufferStatus->IsCommBufferValid = FALSE;
125 }
126
127 return Status;
128}
129
144 OUT EFI_PHYSICAL_ADDRESS *MmFvBase,
145 OUT UINTN *MmFvSize,
146 OUT EFI_GUID *MmCoreFileName,
147 OUT VOID **MmCoreImageAddress
148 )
149{
150 EFI_STATUS Status;
151 UINTN FvIndex;
152 EFI_PEI_FV_HANDLE VolumeHandle;
153 EFI_PEI_FILE_HANDLE FileHandle;
154 EFI_PE32_SECTION *SectionData;
155 EFI_FV_INFO VolumeInfo;
156
157 //
158 // Search all FV
159 //
160 VolumeHandle = NULL;
161 for (FvIndex = 0; ; FvIndex++) {
162 Status = PeiServicesFfsFindNextVolume (FvIndex, &VolumeHandle);
163 if (EFI_ERROR (Status)) {
164 break;
165 }
166
167 //
168 // Search MM Core FFS
169 //
170 FileHandle = NULL;
171 Status = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_MM_CORE_STANDALONE, VolumeHandle, &FileHandle);
172 if (EFI_ERROR (Status)) {
173 continue;
174 }
175
176 ASSERT (FileHandle != NULL);
177 if (FileHandle != NULL) {
178 CopyGuid (MmCoreFileName, &((EFI_FFS_FILE_HEADER *)FileHandle)->Name);
179 }
180
181 //
182 // Search Section
183 //
184 Status = PeiServicesFfsFindSectionData (EFI_SECTION_PE32, FileHandle, MmCoreImageAddress);
185 if (EFI_ERROR (Status)) {
186 continue;
187 }
188
189 //
190 // Get MM Core section data.
191 //
192 SectionData = (EFI_PE32_SECTION *)((UINT8 *)*MmCoreImageAddress - sizeof (EFI_PE32_SECTION));
193 ASSERT (SectionData->Type == EFI_SECTION_PE32);
194
195 //
196 // This is the FV that contains MM Core.
197 //
198 Status = PeiServicesFfsGetVolumeInfo (VolumeHandle, &VolumeInfo);
199 if (!EFI_ERROR (Status)) {
200 *MmFvBase = (EFI_PHYSICAL_ADDRESS)(UINTN)VolumeInfo.FvStart;
201 *MmFvSize = VolumeInfo.FvSize;
202 return EFI_SUCCESS;
203 } else {
204 return EFI_NOT_FOUND;
205 }
206 }
207
208 return EFI_NOT_FOUND;
209}
210
228VOID *
230 OUT UINTN *HobSize,
231 IN MM_COMM_BUFFER *MmCommBuffer,
232 IN EFI_PHYSICAL_ADDRESS MmFvBase,
233 IN UINT64 MmFvSize,
234 IN EFI_GUID *MmCoreFileName,
235 IN PHYSICAL_ADDRESS MmCoreImageAddress,
236 IN UINT64 MmCoreImageSize,
237 IN PHYSICAL_ADDRESS MmCoreEntryPoint,
239 )
240{
241 EFI_STATUS Status;
242 VOID *HobList;
243 VOID *PlatformHobList;
244 UINTN PlatformHobSize;
245 UINTN BufferSize;
246 UINTN FoundationHobSize;
247 EFI_HOB_MEMORY_ALLOCATION *MmProfileDataHob;
248
249 //
250 // Get platform HOBs
251 //
252 PlatformHobSize = 0;
253 Status = CreateMmPlatformHob (NULL, &PlatformHobSize);
254 if (Status == RETURN_BUFFER_TOO_SMALL) {
255 ASSERT (PlatformHobSize != 0);
256 //
257 // Create platform HOBs for MM foundation to get MMIO HOB data.
258 //
259 PlatformHobList = AllocatePages (EFI_SIZE_TO_PAGES (PlatformHobSize));
260 ASSERT (PlatformHobList != NULL);
261 if (PlatformHobList == NULL) {
262 DEBUG ((DEBUG_ERROR, "%a: Out of resource to create platform MM HOBs\n", __func__));
263 CpuDeadLoop ();
264 }
265
266 BufferSize = PlatformHobSize;
267 Status = CreateMmPlatformHob (PlatformHobList, &PlatformHobSize);
268 ASSERT_EFI_ERROR (Status);
269 ASSERT (BufferSize == PlatformHobSize);
270 }
271
272 ASSERT_EFI_ERROR (Status);
273
274 //
275 // Build memory allocation HOB in PEI HOB list for MM profile data.
276 //
277 MmProfileDataHob = NULL;
278 if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
279 MmProfileDataHob = BuildMmProfileDataHobInPeiHobList ();
280 }
281
282 //
283 // Get size of foundation HOBs
284 //
285 FoundationHobSize = 0;
287 NULL,
288 &FoundationHobSize,
289 PlatformHobList,
290 PlatformHobSize,
291 MmFvBase,
292 MmFvSize,
293 MmCoreFileName,
294 MmCoreImageAddress,
295 MmCoreImageSize,
296 MmCoreEntryPoint,
297 MmProfileDataHob,
298 Block
299 );
300 FreePages (PlatformHobList, EFI_SIZE_TO_PAGES (PlatformHobSize));
301 ASSERT (Status == RETURN_BUFFER_TOO_SMALL);
302 ASSERT (FoundationHobSize != 0);
303
304 //
305 // Final result includes platform HOBs, foundation HOBs and a END node.
306 //
307 *HobSize = PlatformHobSize + FoundationHobSize + sizeof (EFI_HOB_GENERIC_HEADER);
308 HobList = AllocatePages (EFI_SIZE_TO_PAGES (*HobSize));
309 ASSERT (HobList != NULL);
310 if (HobList == NULL) {
311 DEBUG ((DEBUG_ERROR, "Out of resource to create MM HOBs\n"));
312 CpuDeadLoop ();
313 }
314
315 //
316 // Get platform HOBs
317 //
318 Status = CreateMmPlatformHob (HobList, &PlatformHobSize);
319 ASSERT_EFI_ERROR (Status);
320
321 //
322 // Get foundation HOBs
323 //
325 (UINT8 *)HobList + PlatformHobSize,
326 &FoundationHobSize,
327 HobList,
328 PlatformHobSize,
329 MmFvBase,
330 MmFvSize,
331 MmCoreFileName,
332 MmCoreImageAddress,
333 MmCoreImageSize,
334 MmCoreEntryPoint,
335 MmProfileDataHob,
336 Block
337 );
338 ASSERT_EFI_ERROR (Status);
339
340 //
341 // Create MM HOB list end.
342 //
343 MmIplCreateHob ((UINT8 *)HobList + PlatformHobSize + FoundationHobSize, EFI_HOB_TYPE_END_OF_HOB_LIST, sizeof (EFI_HOB_GENERIC_HEADER));
344
345 return HobList;
346}
347
355VOID
357 IN OUT UINTN *LagestMmramRangeIndex,
359 )
360{
361 UINTN Index;
362 UINT64 MaxSize;
363 BOOLEAN Found;
364 EFI_MMRAM_DESCRIPTOR *MmramRanges;
365
366 MmramRanges = CurrentBlock->Descriptor;
367
368 //
369 // Find largest Mmram range.
370 //
371 Found = FALSE;
372 for (Index = 0, MaxSize = SIZE_256KB - EFI_PAGE_SIZE; Index < CurrentBlock->NumberOfMmReservedRegions; Index++) {
373 //
374 // Skip any MMRAM region that is already allocated, needs testing, or needs ECC initialization
375 //
376 if ((MmramRanges[Index].RegionState & (EFI_ALLOCATED | EFI_NEEDS_TESTING | EFI_NEEDS_ECC_INITIALIZATION)) != 0) {
377 continue;
378 }
379
380 if (MmramRanges[Index].CpuStart >= BASE_1MB) {
381 if ((MmramRanges[Index].CpuStart + MmramRanges[Index].PhysicalSize) <= BASE_4GB) {
382 if (MmramRanges[Index].PhysicalSize >= MaxSize) {
383 Found = TRUE;
384 *LagestMmramRangeIndex = Index;
385 MaxSize = MmramRanges[Index].PhysicalSize;
386 }
387 }
388 }
389 }
390
391 if (Found == FALSE) {
392 DEBUG ((DEBUG_ERROR, "Not found largest unlocated MMRAM\n"));
393 ASSERT (FALSE);
394 CpuDeadLoop ();
395 }
396
397 return;
398}
399
410 IN UINTN Pages,
412 )
413{
414 UINTN LagestMmramRangeIndex;
415 UINT32 FullMmramRangeCount;
416 EFI_HOB_GUID_TYPE *MmramInfoHob;
417 EFI_MMRAM_DESCRIPTOR *Largest;
418 EFI_MMRAM_DESCRIPTOR *Allocated;
419 EFI_MMRAM_DESCRIPTOR *FullMmramRanges;
420 EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *CurrentBlock;
421 EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *NewDescriptorBlock;
422
423 MmramInfoHob = GetFirstGuidHob (&gEfiSmmSmramMemoryGuid);
424 ASSERT (MmramInfoHob != NULL);
425 if (MmramInfoHob == NULL) {
426 DEBUG ((DEBUG_WARN, "SmramMemoryReserve HOB not found\n"));
427 return 0;
428 }
429
430 CurrentBlock = (EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *)(GET_GUID_HOB_DATA (MmramInfoHob));
431
432 //
433 // 1. Find largest unallocated MMRAM region
434 //
435 FindLargestMmramRange (&LagestMmramRangeIndex, CurrentBlock);
436 ASSERT (LagestMmramRangeIndex < CurrentBlock->NumberOfMmReservedRegions);
437
438 //
439 // 2. Split the largest region and mark the allocated region as ALLOCATED
440 //
441 FullMmramRangeCount = CurrentBlock->NumberOfMmReservedRegions + 1;
442 NewDescriptorBlock = (EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *)BuildGuidHob (
443 &gEfiSmmSmramMemoryGuid,
444 sizeof (EFI_MMRAM_HOB_DESCRIPTOR_BLOCK) + ((FullMmramRangeCount - 1) * sizeof (EFI_MMRAM_DESCRIPTOR))
445 );
446 ASSERT (NewDescriptorBlock != NULL);
447
448 NewDescriptorBlock->NumberOfMmReservedRegions = FullMmramRangeCount;
449 FullMmramRanges = NewDescriptorBlock->Descriptor;
450
451 //
452 // Get current MMRAM descriptors and fill to the full MMRAM ranges
453 //
454 CopyMem (NewDescriptorBlock->Descriptor, CurrentBlock->Descriptor, CurrentBlock->NumberOfMmReservedRegions * sizeof (EFI_MMRAM_DESCRIPTOR));
455
456 Largest = &FullMmramRanges[LagestMmramRangeIndex];
457 ASSERT ((Largest->PhysicalSize & EFI_PAGE_MASK) == 0);
458 ASSERT (Largest->PhysicalSize > EFI_PAGES_TO_SIZE (Pages));
459
460 Allocated = &NewDescriptorBlock->Descriptor[NewDescriptorBlock->NumberOfMmReservedRegions - 1];
461
462 //
463 // Allocate MMRAM
464 //
465 Largest->PhysicalSize -= EFI_PAGES_TO_SIZE (Pages);
466 Allocated->CpuStart = Largest->CpuStart + Largest->PhysicalSize;
467 Allocated->PhysicalStart = Largest->PhysicalStart + Largest->PhysicalSize;
468 Allocated->RegionState = Largest->RegionState | EFI_ALLOCATED;
469 Allocated->PhysicalSize = EFI_PAGES_TO_SIZE (Pages);
470
471 //
472 // Scrub old one
473 //
474 ZeroMem (&MmramInfoHob->Name, sizeof (MmramInfoHob->Name));
475
476 //
477 // New MMRAM descriptor block
478 //
479 *NewBlock = NewDescriptorBlock;
480
481 return Allocated->CpuStart;
482}
483
494 IN MM_COMM_BUFFER *MmCommBuffer
495 )
496{
497 EFI_STATUS Status;
498 UINTN PageCount;
499 VOID *MmHobList;
500 UINTN MmHobSize;
501 EFI_GUID MmCoreFileName;
502 UINTN MmFvSize;
503 EFI_PHYSICAL_ADDRESS MmFvBase;
504 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
505 STANDALONE_MM_FOUNDATION_ENTRY_POINT Entry;
507
508 MmFvBase = 0;
509 MmFvSize = 0;
510 //
511 // Search all Firmware Volumes for a PE/COFF image in a file of type MM_CORE_STANDALONE.
512 //
513 Status = LocateMmCoreFv (&MmFvBase, &MmFvSize, &MmCoreFileName, &ImageContext.Handle);
514 ASSERT_EFI_ERROR (Status);
515
516 //
517 // Initialize ImageContext
518 //
520
521 //
522 // Get information about the image being loaded
523 //
524 Status = PeCoffLoaderGetImageInfo (&ImageContext);
525 if (EFI_ERROR (Status)) {
526 return Status;
527 }
528
529 PageCount = (UINTN)EFI_SIZE_TO_PAGES ((UINTN)ImageContext.ImageSize + ImageContext.SectionAlignment);
530
531 //
532 // Allocate memory for the image being loaded from unallocated mmram range
533 //
534 ImageContext.ImageAddress = MmIplAllocateMmramPage (PageCount, &Block);
535 if (ImageContext.ImageAddress == 0) {
536 return EFI_NOT_FOUND;
537 }
538
539 //
540 // Align buffer on section boundary
541 //
542 ImageContext.ImageAddress += ImageContext.SectionAlignment - 1;
543 ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)ImageContext.SectionAlignment - 1);
544
545 //
546 // Print debug message showing MM Core load address.
547 //
548 DEBUG ((DEBUG_INFO, "StandaloneMM IPL loading MM Core at MMRAM address %p\n", (VOID *)(UINTN)ImageContext.ImageAddress));
549
550 //
551 // Load the image to our new buffer
552 //
553 Status = PeCoffLoaderLoadImage (&ImageContext);
554 if (!EFI_ERROR (Status)) {
555 //
556 // Relocate the image in our new buffer
557 //
558 Status = PeCoffLoaderRelocateImage (&ImageContext);
559 if (!EFI_ERROR (Status)) {
560 DEBUG ((DEBUG_INFO, "MmCoreImageBase - 0x%016lx\n", ImageContext.ImageAddress));
561 DEBUG ((DEBUG_INFO, "MmCoreImageSize - 0x%016lx\n", ImageContext.ImageSize));
562
563 //
564 // Flush the instruction cache so the image data are written before we execute it
565 //
566 InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);
567
568 //
569 // Get HOB list for Standalone MM Core.
570 //
571 MmHobSize = 0;
572 MmHobList = CreatMmHobList (
573 &MmHobSize,
574 MmCommBuffer,
575 MmFvBase,
576 MmFvSize,
577 &MmCoreFileName,
578 ImageContext.ImageAddress,
579 ImageContext.ImageSize,
580 ImageContext.EntryPoint,
581 Block
582 );
583
584 //
585 // Print debug message showing Standalone MM Core entry point address.
586 //
587 DEBUG ((DEBUG_INFO, "StandaloneMM IPL calling Standalone MM Core at MMRAM address - 0x%016lx\n", ImageContext.EntryPoint));
588
589 //
590 // Execute image
591 //
592 Entry = (STANDALONE_MM_FOUNDATION_ENTRY_POINT)(UINTN)ImageContext.EntryPoint;
593 Status = Entry (MmHobList);
594 ASSERT_EFI_ERROR (Status);
595 FreePages (MmHobList, EFI_SIZE_TO_PAGES (MmHobSize));
596 }
597 }
598
599 return Status;
600}
601
615EFIAPI
617 IN EFI_PEI_SERVICES **PeiServices,
618 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
619 IN VOID *Ppi
620 )
621{
622 EFI_MM_COMMUNICATE_HEADER CommunicateHeader;
623 UINTN Size;
624 EFI_STATUS Status;
625
626 //
627 // Use Guid to initialize EFI_MM_COMMUNICATE_HEADER structure
628 //
629 CopyGuid (&CommunicateHeader.HeaderGuid, &gEfiMmEndOfPeiProtocol);
630 CommunicateHeader.MessageLength = 1;
631 CommunicateHeader.Data[0] = 0;
632
633 //
634 // Generate the Software SMI and return the result
635 //
636 Size = sizeof (CommunicateHeader);
637 Status = Communicate (NULL, &CommunicateHeader, &Size);
638 ASSERT_EFI_ERROR (Status);
639
640 return Status;
641}
642
656 VOID
657 )
658{
659 EFI_STATUS Status;
660 UINTN Size;
661 EFI_MM_COMMUNICATE_HEADER CommunicateHeader;
662
663 //
664 // Use Guid to initialize EFI_MM_COMMUNICATE_HEADER structure
665 //
666 CopyGuid (&CommunicateHeader.HeaderGuid, &gEventMmDispatchGuid);
667 CommunicateHeader.MessageLength = 1;
668 CommunicateHeader.Data[0] = 0;
669
670 //
671 // Generate the Software SMI and return the result
672 //
673 Size = sizeof (CommunicateHeader);
674 Status = Communicate (NULL, &CommunicateHeader, &Size);
675 ASSERT_EFI_ERROR (Status);
676
677 return Status;
678}
679
688 VOID
689 )
690{
691 EFI_STATUS Status;
692 MM_COMM_BUFFER *MmCommBuffer;
693 UINT64 MmCommBufferPages;
694
695 MmCommBufferPages = PcdGet32 (PcdMmCommBufferPages);
696
697 MmCommBuffer = BuildGuidHob (&gMmCommBufferHobGuid, sizeof (MM_COMM_BUFFER));
698 ASSERT (MmCommBuffer != NULL);
699
700 //
701 // Set MM communicate buffer size
702 //
703 MmCommBuffer->NumberOfPages = MmCommBufferPages;
704
705 //
706 // Allocate runtime memory for MM communicate buffer
707 //
708 MmCommBuffer->PhysicalStart = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateRuntimePages (MmCommBufferPages);
709 if (MmCommBuffer->PhysicalStart == 0) {
710 DEBUG ((DEBUG_ERROR, "Fail to allocate MM communication buffer\n"));
711 ASSERT (MmCommBuffer->PhysicalStart != 0);
712 }
713
714 //
715 // Build MM unblock memory region HOB for MM communication buffer
716 //
717 Status = MmUnblockMemoryRequest (MmCommBuffer->PhysicalStart, MmCommBufferPages);
718 ASSERT_EFI_ERROR (Status);
719
720 //
721 // Allocate runtime memory for MM communication status parameters :
722 // ReturnStatus, ReturnBufferSize, IsCommBufferValid
723 //
725 if (MmCommBuffer->Status == 0) {
726 DEBUG ((DEBUG_ERROR, "Fail to allocate memory for MM communication status\n"));
727 ASSERT (MmCommBuffer->Status != 0);
728 }
729
730 //
731 // Build MM unblock memory region HOB for MM communication status
732 //
733 Status = MmUnblockMemoryRequest (MmCommBuffer->Status, EFI_SIZE_TO_PAGES (sizeof (MM_COMM_BUFFER_STATUS)));
734 ASSERT_EFI_ERROR (Status);
735
736 return MmCommBuffer;
737}
738
752EFIAPI
754 IN EFI_PEI_FILE_HANDLE FileHandle,
755 IN CONST EFI_PEI_SERVICES **PeiServices
756 )
757{
758 EFI_STATUS Status;
759 MM_COMM_BUFFER *MmCommBuffer;
760
761 //
762 // Build communication buffer HOB.
763 //
764 MmCommBuffer = MmIplBuildCommBufferHob ();
765 ASSERT (MmCommBuffer != NULL);
766
767 //
768 // Locate and execute Mm Core to dispatch MM drivers.
769 //
770 Status = ExecuteMmCoreFromMmram (MmCommBuffer);
771 ASSERT_EFI_ERROR (Status);
772
773 //
774 // Install MmCommunicationPpi
775 //
776 Status = PeiServicesInstallPpi (&mPpiList);
777 ASSERT_EFI_ERROR (Status);
778
779 //
780 // Create end of pei callback to call MmEndOfPeiHandler
781 //
782 Status = PeiServicesNotifyPpi (&mNotifyList);
783 ASSERT_EFI_ERROR (Status);
784
785 //
786 // Dispatch StandaloneMm drivers in MM
787 //
788 Status = MmIplDispatchMmDrivers ();
789 ASSERT_EFI_ERROR (Status);
790
791 return EFI_SUCCESS;
792}
UINT64 UINTN
VOID *EFIAPI InvalidateInstructionCacheRange(IN VOID *Address, IN UINTN Length)
CONST EFI_PEI_SERVICES **EFIAPI GetPeiServicesTablePointer(VOID)
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
Definition: HobLib.c:215
VOID *EFIAPI BuildGuidHob(IN CONST EFI_GUID *Guid, IN UINTN DataLength)
Definition: HobLib.c:336
VOID EFIAPI CpuDeadLoop(VOID)
Definition: CpuDeadLoop.c:25
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
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 NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define RETURN_BUFFER_TOO_SMALL
Definition: Base.h:1093
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OFFSET_OF(TYPE, Field)
Definition: Base.h:758
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
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)
EFI_STATUS EFIAPI CreateMmPlatformHob(IN VOID *Buffer, IN OUT UINTN *BufferSize)
RETURN_STATUS EFIAPI MmUnblockMemoryRequest(IN PHYSICAL_ADDRESS UnblockAddress, IN UINT64 NumberOfPages)
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
#define FeaturePcdGet(TokenName)
Definition: PcdLib.h:50
RETURN_STATUS EFIAPI PeCoffLoaderLoadImage(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
Definition: BasePeCoff.c:1244
RETURN_STATUS EFIAPI PeCoffLoaderRelocateImage(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
Definition: BasePeCoff.c:956
RETURN_STATUS EFIAPI PeCoffLoaderGetImageInfo(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
Definition: BasePeCoff.c:577
RETURN_STATUS EFIAPI PeCoffLoaderImageReadFromMemory(IN VOID *FileHandle, IN UINTN FileOffset, IN OUT UINTN *ReadSize, OUT VOID *Buffer)
Definition: BasePeCoff.c:1992
EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION
#define EFI_SECTION_PE32
VOID * EFI_PEI_FILE_HANDLE
Definition: PiPeiCis.h:26
VOID * EFI_PEI_FV_HANDLE
Definition: PiPeiCis.h:21
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
Definition: UefiBaseType.h:50
#define EFI_PAGES_TO_SIZE(Pages)
Definition: UefiBaseType.h:213
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SIZE_TO_PAGES(Size)
Definition: UefiBaseType.h:200
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
UINT64 FvSize
Definition: PiPeiCis.h:789
VOID * FvStart
Definition: PiPeiCis.h:785
EFI_GUID Name
Definition: PiHob.h:347
EFI_PHYSICAL_ADDRESS CpuStart
Definition: PiMultiPhase.h:127
EFI_PHYSICAL_ADDRESS PhysicalStart
Definition: PiMultiPhase.h:122
EFI_MMRAM_DESCRIPTOR Descriptor[1]
Definition: Base.h:213
EFI_PHYSICAL_ADDRESS PhysicalStart
Definition: MmCommBuffer.h:31
EFI_PHYSICAL_ADDRESS Status
Definition: MmCommBuffer.h:41
UINT64 NumberOfPages
Definition: MmCommBuffer.h:36
PE_COFF_LOADER_READ_FILE ImageRead
Definition: PeCoffLib.h:100
PHYSICAL_ADDRESS EntryPoint
Definition: PeCoffLib.h:95
PHYSICAL_ADDRESS ImageAddress
Definition: PeCoffLib.h:79