TianoCore EDK2 master
Loading...
Searching...
No Matches
PiSmmIpl.c
Go to the documentation of this file.
1
9#include <PiDxe.h>
10
11#include <Protocol/SmmBase2.h>
14#include <Protocol/SmmAccess2.h>
18#include <Protocol/Cpu.h>
19
20#include <Guid/EventGroup.h>
23
24#include <Library/BaseLib.h>
26#include <Library/PeCoffLib.h>
29#include <Library/DebugLib.h>
33#include <Library/UefiLib.h>
35#include <Library/PcdLib.h>
38#include <Library/SafeIntLib.h>
39
40#define SMRAM_CAPABILITIES (EFI_MEMORY_WB | EFI_MEMORY_UC)
41
42//
43// Function prototypes from produced protocols
44//
45
58EFIAPI
61 OUT BOOLEAN *InSmram
62 );
63
76EFIAPI
80 );
81
109EFIAPI
112 IN OUT VOID *CommBuffer,
113 IN OUT UINTN *CommSize OPTIONAL
114 );
115
141EFIAPI
144 IN OUT VOID *CommBufferPhysical,
145 IN OUT VOID *CommBufferVirtual,
146 IN OUT UINTN *CommSize OPTIONAL
147 );
148
156VOID
157EFIAPI
159 IN EFI_EVENT Event,
160 IN VOID *Context
161 );
162
171VOID
172EFIAPI
174 IN EFI_EVENT Event,
175 IN VOID *Context
176 );
177
185VOID
186EFIAPI
188 IN EFI_EVENT Event,
189 IN VOID *Context
190 );
191
199VOID
200EFIAPI
202 IN EFI_EVENT Event,
203 IN VOID *Context
204 );
205
213VOID
214EFIAPI
216 IN EFI_EVENT Event,
217 IN VOID *Context
218 );
219
230VOID
231EFIAPI
233 IN EFI_EVENT Event,
234 IN VOID *Context
235 );
236
237//
238// Data structure used to declare a table of protocol notifications and event
239// notifications required by the SMM IPL
240//
241typedef struct {
242 BOOLEAN Protocol;
243 BOOLEAN CloseOnLock;
244 EFI_GUID *Guid;
246 VOID *NotifyContext;
247 EFI_TPL NotifyTpl;
248 EFI_EVENT Event;
250
251//
252// Handle to install the SMM Base2 Protocol and the SMM Communication Protocol
253//
254EFI_HANDLE mSmmIplHandle = NULL;
255
256//
257// SMM Base 2 Protocol instance
258//
259EFI_SMM_BASE2_PROTOCOL mSmmBase2 = {
262};
263
264//
265// SMM Communication Protocol instance
266//
267EFI_SMM_COMMUNICATION_PROTOCOL mSmmCommunication = {
269};
270
271//
272// PI 1.7 MM Communication Protocol 2 instance
273//
274EFI_MM_COMMUNICATION2_PROTOCOL mMmCommunication2 = {
276};
277
278//
279// SMM Core Private Data structure that contains the data shared between
280// the SMM IPL and the SMM Core.
281//
282SMM_CORE_PRIVATE_DATA mSmmCorePrivateData = {
284 NULL, // SmmIplImageHandle
285 0, // SmramRangeCount
286 NULL, // SmramRanges
287 NULL, // SmmEntryPoint
288 FALSE, // SmmEntryPointRegistered
289 FALSE, // InSmm
290 NULL, // Smst
291 NULL, // CommunicationBuffer
292 0, // BufferSize
293 EFI_SUCCESS // ReturnStatus
294};
295
296//
297// Global pointer used to access mSmmCorePrivateData from outside and inside SMM
298//
299SMM_CORE_PRIVATE_DATA *gSmmCorePrivate = &mSmmCorePrivateData;
300
301//
302// SMM IPL global variables
303//
304EFI_SMM_CONTROL2_PROTOCOL *mSmmControl2;
305EFI_SMM_ACCESS2_PROTOCOL *mSmmAccess;
306EFI_SMRAM_DESCRIPTOR *mCurrentSmramRange;
307BOOLEAN mSmmLocked = FALSE;
308BOOLEAN mEndOfDxe = FALSE;
309EFI_PHYSICAL_ADDRESS mSmramCacheBase;
310UINT64 mSmramCacheSize;
311
312EFI_SMM_COMMUNICATE_HEADER mCommunicateHeader;
313EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE *mLMFAConfigurationTable = NULL;
314
315//
316// Table of Protocol notification and GUIDed Event notifications that the SMM IPL requires
317//
318SMM_IPL_EVENT_NOTIFICATION mSmmIplEvents[] = {
319 //
320 // Declare protocol notification on the SMM Configuration protocol. When this notification is established,
321 // the associated event is immediately signalled, so the notification function will be executed and the
322 // SMM Configuration Protocol will be found if it is already in the handle database.
323 //
324 { TRUE, FALSE, &gEfiSmmConfigurationProtocolGuid, SmmIplSmmConfigurationEventNotify, &gEfiSmmConfigurationProtocolGuid, TPL_NOTIFY, NULL },
325 //
326 // Declare protocol notification on DxeSmmReadyToLock protocols. When this notification is established,
327 // the associated event is immediately signalled, so the notification function will be executed and the
328 // DXE SMM Ready To Lock Protocol will be found if it is already in the handle database.
329 //
330 { TRUE, TRUE, &gEfiDxeSmmReadyToLockProtocolGuid, SmmIplReadyToLockEventNotify, &gEfiDxeSmmReadyToLockProtocolGuid, TPL_CALLBACK, NULL },
331 //
332 // Declare event notification on EndOfDxe event. When this notification is established,
333 // the associated event is immediately signalled, so the notification function will be executed and the
334 // SMM End Of Dxe Protocol will be found if it is already in the handle database.
335 //
336 { FALSE, TRUE, &gEfiEndOfDxeEventGroupGuid, SmmIplGuidedEventNotify, &gEfiEndOfDxeEventGroupGuid, TPL_CALLBACK, NULL },
337 //
338 // Declare event notification on EndOfDxe event. This is used to set EndOfDxe event signaled flag.
339 //
340 { FALSE, TRUE, &gEfiEndOfDxeEventGroupGuid, SmmIplEndOfDxeEventNotify, &gEfiEndOfDxeEventGroupGuid, TPL_CALLBACK, NULL },
341 //
342 // Declare event notification on the DXE Dispatch Event Group. This event is signaled by the DXE Core
343 // each time the DXE Core dispatcher has completed its work. When this event is signalled, the SMM Core
344 // if notified, so the SMM Core can dispatch SMM drivers.
345 //
346 { FALSE, TRUE, &gEfiEventDxeDispatchGuid, SmmIplDxeDispatchEventNotify, &gEfiEventDxeDispatchGuid, TPL_CALLBACK, NULL },
347 //
348 // Declare event notification on Ready To Boot Event Group. This is an extra event notification that is
349 // used to make sure SMRAM is locked before any boot options are processed.
350 //
351 { FALSE, TRUE, &gEfiEventReadyToBootGuid, SmmIplReadyToLockEventNotify, &gEfiEventReadyToBootGuid, TPL_CALLBACK, NULL },
352 //
353 // Declare event notification on Legacy Boot Event Group. This is used to inform the SMM Core that the platform
354 // is performing a legacy boot operation, and that the UEFI environment is no longer available and the SMM Core
355 // must guarantee that it does not access any UEFI related structures outside of SMRAM.
356 // It is also to inform the SMM Core to notify SMM driver that system enter legacy boot.
357 //
358 { FALSE, FALSE, &gEfiEventLegacyBootGuid, SmmIplGuidedEventNotify, &gEfiEventLegacyBootGuid, TPL_CALLBACK, NULL },
359 //
360 // Declare event notification on Exit Boot Services Event Group. This is used to inform the SMM Core
361 // to notify SMM driver that system enter exit boot services.
362 //
363 { FALSE, FALSE, &gEfiEventExitBootServicesGuid, SmmIplGuidedEventNotify, &gEfiEventExitBootServicesGuid, TPL_CALLBACK, NULL },
364 //
365 // Declare event notification on Ready To Boot Event Group. This is used to inform the SMM Core
366 // to notify SMM driver that system enter ready to boot.
367 //
368 { FALSE, FALSE, &gEfiEventReadyToBootGuid, SmmIplGuidedEventNotify, &gEfiEventReadyToBootGuid, TPL_CALLBACK, NULL },
369 //
370 // Declare event notification on SetVirtualAddressMap() Event Group. This is used to convert gSmmCorePrivate
371 // and mSmmControl2 from physical addresses to virtual addresses.
372 //
373 { FALSE, FALSE, &gEfiEventVirtualAddressChangeGuid, SmmIplSetVirtualAddressNotify, NULL, TPL_CALLBACK, NULL },
374 //
375 // Terminate the table of event notifications
376 //
377 { FALSE, FALSE, NULL, NULL, NULL, TPL_CALLBACK, NULL }
378};
379
390VOID
392 IN EFI_SMRAM_DESCRIPTOR *SmramRange,
393 OUT EFI_PHYSICAL_ADDRESS *SmramCacheBase,
394 OUT UINT64 *SmramCacheSize
395 )
396{
397 UINTN Index;
398 EFI_PHYSICAL_ADDRESS RangeCpuStart;
399 UINT64 RangePhysicalSize;
400 BOOLEAN FoundAjacentRange;
401
402 *SmramCacheBase = SmramRange->CpuStart;
403 *SmramCacheSize = SmramRange->PhysicalSize;
404
405 do {
406 FoundAjacentRange = FALSE;
407 for (Index = 0; Index < gSmmCorePrivate->SmramRangeCount; Index++) {
408 RangeCpuStart = gSmmCorePrivate->SmramRanges[Index].CpuStart;
409 RangePhysicalSize = gSmmCorePrivate->SmramRanges[Index].PhysicalSize;
410 if ((RangeCpuStart < *SmramCacheBase) && (*SmramCacheBase == (RangeCpuStart + RangePhysicalSize))) {
411 *SmramCacheBase = RangeCpuStart;
412 *SmramCacheSize += RangePhysicalSize;
413 FoundAjacentRange = TRUE;
414 } else if (((*SmramCacheBase + *SmramCacheSize) == RangeCpuStart) && (RangePhysicalSize > 0)) {
415 *SmramCacheSize += RangePhysicalSize;
416 FoundAjacentRange = TRUE;
417 }
418 }
419 } while (FoundAjacentRange);
420}
421
434EFIAPI
437 OUT BOOLEAN *InSmram
438 )
439{
440 if (InSmram == NULL) {
441 return EFI_INVALID_PARAMETER;
442 }
443
444 *InSmram = gSmmCorePrivate->InSmm;
445
446 return EFI_SUCCESS;
447}
448
461EFIAPI
465 )
466{
467 if ((This == NULL) || (Smst == NULL)) {
468 return EFI_INVALID_PARAMETER;
469 }
470
471 if (!gSmmCorePrivate->InSmm) {
472 return EFI_UNSUPPORTED;
473 }
474
475 *Smst = gSmmCorePrivate->Smst;
476
477 return EFI_SUCCESS;
478}
479
507EFIAPI
510 IN OUT VOID *CommBuffer,
511 IN OUT UINTN *CommSize OPTIONAL
512 )
513{
514 EFI_STATUS Status;
515 EFI_SMM_COMMUNICATE_HEADER *CommunicateHeader;
516 BOOLEAN OldInSmm;
517 UINTN TempCommSize;
518
519 //
520 // Check parameters
521 //
522 if (CommBuffer == NULL) {
523 return EFI_INVALID_PARAMETER;
524 }
525
526 CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *)CommBuffer;
527
528 if (CommSize == NULL) {
529 TempCommSize = OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + CommunicateHeader->MessageLength;
530 } else {
531 TempCommSize = *CommSize;
532 //
533 // CommSize must hold HeaderGuid and MessageLength
534 //
535 if (TempCommSize < OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)) {
536 return EFI_INVALID_PARAMETER;
537 }
538 }
539
540 //
541 // If not already in SMM, then generate a Software SMI
542 //
543 if (!gSmmCorePrivate->InSmm && gSmmCorePrivate->SmmEntryPointRegistered) {
544 //
545 // Put arguments for Software SMI in gSmmCorePrivate
546 //
547 gSmmCorePrivate->CommunicationBuffer = CommBuffer;
548 gSmmCorePrivate->BufferSize = TempCommSize;
549
550 //
551 // Generate Software SMI
552 //
553 Status = mSmmControl2->Trigger (mSmmControl2, NULL, NULL, FALSE, 0);
554 if (EFI_ERROR (Status)) {
555 return EFI_UNSUPPORTED;
556 }
557
558 //
559 // Return status from software SMI
560 //
561 if (CommSize != NULL) {
562 *CommSize = gSmmCorePrivate->BufferSize;
563 }
564
565 return gSmmCorePrivate->ReturnStatus;
566 }
567
568 //
569 // If we are in SMM, then the execution mode must be physical, which means that
570 // OS established virtual addresses can not be used. If SetVirtualAddressMap()
571 // has been called, then a direct invocation of the Software SMI is not allowed,
572 // so return EFI_INVALID_PARAMETER.
573 //
574 if (EfiGoneVirtual ()) {
575 return EFI_INVALID_PARAMETER;
576 }
577
578 //
579 // If we are not in SMM, don't allow call SmiManage() directly when SMRAM is closed or locked.
580 //
581 if ((!gSmmCorePrivate->InSmm) && (!mSmmAccess->OpenState || mSmmAccess->LockState)) {
582 return EFI_INVALID_PARAMETER;
583 }
584
585 //
586 // Save current InSmm state and set InSmm state to TRUE
587 //
588 OldInSmm = gSmmCorePrivate->InSmm;
589 gSmmCorePrivate->InSmm = TRUE;
590
591 //
592 // Before SetVirtualAddressMap(), we are in SMM or SMRAM is open and unlocked, call SmiManage() directly.
593 //
594 TempCommSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
595 Status = gSmmCorePrivate->Smst->SmiManage (
596 &CommunicateHeader->HeaderGuid,
597 NULL,
598 CommunicateHeader->Data,
599 &TempCommSize
600 );
601 TempCommSize += OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
602 if (CommSize != NULL) {
603 *CommSize = TempCommSize;
604 }
605
606 //
607 // Restore original InSmm state
608 //
609 gSmmCorePrivate->InSmm = OldInSmm;
610
611 return (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;
612}
613
639EFIAPI
642 IN OUT VOID *CommBufferPhysical,
643 IN OUT VOID *CommBufferVirtual,
644 IN OUT UINTN *CommSize OPTIONAL
645 )
646{
648 &mSmmCommunication,
649 CommBufferPhysical,
650 CommSize
651 );
652}
653
661VOID
662EFIAPI
664 IN EFI_EVENT Event,
665 IN VOID *Context
666 )
667{
668 UINTN Size;
669
670 //
671 // Use Guid to initialize EFI_SMM_COMMUNICATE_HEADER structure
672 //
673 CopyGuid (&mCommunicateHeader.HeaderGuid, (EFI_GUID *)Context);
674 mCommunicateHeader.MessageLength = 1;
675 mCommunicateHeader.Data[0] = 0;
676
677 //
678 // Generate the Software SMI and return the result
679 //
680 Size = sizeof (mCommunicateHeader);
681 SmmCommunicationCommunicate (&mSmmCommunication, &mCommunicateHeader, &Size);
682}
683
691VOID
692EFIAPI
694 IN EFI_EVENT Event,
695 IN VOID *Context
696 )
697{
698 mEndOfDxe = TRUE;
699}
700
708VOID
709EFIAPI
711 IN EFI_EVENT Event,
712 IN VOID *Context
713 )
714{
715 UINTN Size;
716 EFI_STATUS Status;
717
718 //
719 // Keep calling the SMM Core Dispatcher until there is no request to restart it.
720 //
721 while (TRUE) {
722 //
723 // Use Guid to initialize EFI_SMM_COMMUNICATE_HEADER structure
724 // Clear the buffer passed into the Software SMI. This buffer will return
725 // the status of the SMM Core Dispatcher.
726 //
727 CopyGuid (&mCommunicateHeader.HeaderGuid, (EFI_GUID *)Context);
728 mCommunicateHeader.MessageLength = 1;
729 mCommunicateHeader.Data[0] = 0;
730
731 //
732 // Generate the Software SMI and return the result
733 //
734 Size = sizeof (mCommunicateHeader);
735 SmmCommunicationCommunicate (&mSmmCommunication, &mCommunicateHeader, &Size);
736
737 //
738 // Return if there is no request to restart the SMM Core Dispatcher
739 //
740 if (mCommunicateHeader.Data[0] != COMM_BUFFER_SMM_DISPATCH_RESTART) {
741 return;
742 }
743
744 //
745 // Close all SMRAM ranges to protect SMRAM
746 // NOTE: SMRR is enabled by CPU SMM driver by calling SmmCpuFeaturesInitializeProcessor() from SmmCpuFeaturesLib
747 // so no need to reset the SMRAM to UC in MTRR.
748 //
749 Status = mSmmAccess->Close (mSmmAccess);
750 ASSERT_EFI_ERROR (Status);
751
752 //
753 // Print debug message that the SMRAM window is now closed.
754 //
755 DEBUG ((DEBUG_INFO, "SMM IPL closed SMRAM window\n"));
756 }
757}
758
766VOID
767EFIAPI
769 IN EFI_EVENT Event,
770 IN VOID *Context
771 )
772{
773 EFI_STATUS Status;
774 EFI_SMM_CONFIGURATION_PROTOCOL *SmmConfiguration;
775
776 //
777 // Make sure this notification is for this handler
778 //
779 Status = gBS->LocateProtocol (Context, NULL, (VOID **)&SmmConfiguration);
780 if (EFI_ERROR (Status)) {
781 return;
782 }
783
784 //
785 // Register the SMM Entry Point provided by the SMM Core with the SMM Configuration protocol
786 //
787 Status = SmmConfiguration->RegisterSmmEntry (SmmConfiguration, gSmmCorePrivate->SmmEntryPoint);
788 ASSERT_EFI_ERROR (Status);
789
790 //
791 // Set flag to indicate that the SMM Entry Point has been registered which
792 // means that SMIs are now fully operational.
793 //
794 gSmmCorePrivate->SmmEntryPointRegistered = TRUE;
795
796 //
797 // Print debug message showing SMM Core entry point address.
798 //
799 DEBUG ((DEBUG_INFO, "SMM IPL registered SMM Entry Point address %p\n", (VOID *)(UINTN)gSmmCorePrivate->SmmEntryPoint));
800}
801
810VOID
811EFIAPI
813 IN EFI_EVENT Event,
814 IN VOID *Context
815 )
816{
817 EFI_STATUS Status;
818 VOID *Interface;
819 UINTN Index;
820
821 //
822 // See if we are already locked
823 //
824 if (mSmmLocked) {
825 return;
826 }
827
828 //
829 // Make sure this notification is for this handler
830 //
831 if (CompareGuid ((EFI_GUID *)Context, &gEfiDxeSmmReadyToLockProtocolGuid)) {
832 Status = gBS->LocateProtocol (&gEfiDxeSmmReadyToLockProtocolGuid, NULL, &Interface);
833 if (EFI_ERROR (Status)) {
834 return;
835 }
836 } else {
837 //
838 // If SMM is not locked yet and we got here from gEfiEventReadyToBootGuid being
839 // signaled, then gEfiDxeSmmReadyToLockProtocolGuid was not installed as expected.
840 // Print a warning on debug builds.
841 //
842 DEBUG ((DEBUG_WARN, "SMM IPL! DXE SMM Ready To Lock Protocol not installed before Ready To Boot signal\n"));
843 }
844
845 if (!mEndOfDxe) {
846 DEBUG ((DEBUG_ERROR, "EndOfDxe Event must be signaled before DxeSmmReadyToLock Protocol installation!\n"));
848 EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED,
849 (EFI_SOFTWARE_SMM_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)
850 );
851 ASSERT (FALSE);
852 }
853
854 //
855 // Lock the SMRAM (Note: Locking SMRAM may not be supported on all platforms)
856 //
857 mSmmAccess->Lock (mSmmAccess);
858
859 //
860 // Close protocol and event notification events that do not apply after the
861 // DXE SMM Ready To Lock Protocol has been installed or the Ready To Boot
862 // event has been signalled.
863 //
864 for (Index = 0; mSmmIplEvents[Index].NotifyFunction != NULL; Index++) {
865 if (mSmmIplEvents[Index].CloseOnLock) {
866 gBS->CloseEvent (mSmmIplEvents[Index].Event);
867 }
868 }
869
870 //
871 // Inform SMM Core that the DxeSmmReadyToLock protocol was installed
872 //
873 SmmIplGuidedEventNotify (Event, (VOID *)&gEfiDxeSmmReadyToLockProtocolGuid);
874
875 //
876 // Print debug message that the SMRAM window is now locked.
877 //
878 DEBUG ((DEBUG_INFO, "SMM IPL locked SMRAM window\n"));
879
880 //
881 // Set flag so this operation will not be performed again
882 //
883 mSmmLocked = TRUE;
884}
885
896VOID
897EFIAPI
899 IN EFI_EVENT Event,
900 IN VOID *Context
901 )
902{
903 EfiConvertPointer (0x0, (VOID **)&mSmmControl2);
904}
905
918 )
919{
920 UINTN SectionHeaderOffset;
921 EFI_STATUS Status;
922 EFI_IMAGE_SECTION_HEADER SectionHeader;
924 EFI_PHYSICAL_ADDRESS FixLoadingAddress;
925 UINT16 Index;
926 UINTN Size;
927 UINT16 NumberOfSections;
928 EFI_PHYSICAL_ADDRESS SmramBase;
929 UINT64 SmmCodeSize;
930 UINT64 ValueInSectionHeader;
931
932 //
933 // Build tool will calculate the smm code size and then patch the PcdLoadFixAddressSmmCodePageNumber
934 //
935 SmmCodeSize = EFI_PAGES_TO_SIZE (PcdGet32 (PcdLoadFixAddressSmmCodePageNumber));
936
937 FixLoadingAddress = 0;
938 Status = EFI_NOT_FOUND;
939 SmramBase = mLMFAConfigurationTable->SmramBase;
940 //
941 // Get PeHeader pointer
942 //
943 ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8 *)ImageContext->Handle + ImageContext->PeCoffHeaderOffset);
944 SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +
945 sizeof (UINT32) +
946 sizeof (EFI_IMAGE_FILE_HEADER) +
947 ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;
948 NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;
949
950 //
951 // Get base address from the first section header that doesn't point to code section.
952 //
953 for (Index = 0; Index < NumberOfSections; Index++) {
954 //
955 // Read section header from file
956 //
957 Size = sizeof (EFI_IMAGE_SECTION_HEADER);
958 Status = ImageContext->ImageRead (
959 ImageContext->Handle,
960 SectionHeaderOffset,
961 &Size,
962 &SectionHeader
963 );
964 if (EFI_ERROR (Status)) {
965 return Status;
966 }
967
968 Status = EFI_NOT_FOUND;
969
970 if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_CNT_CODE) == 0) {
971 //
972 // Build tool saves the offset to SMRAM base as image base in PointerToRelocations & PointerToLineNumbers fields in the
973 // first section header that doesn't point to code section in image header. And there is an assumption that when the
974 // feature is enabled, if a module is assigned a loading address by tools, PointerToRelocations & PointerToLineNumbers
975 // fields should NOT be Zero, or else, these 2 fields should be set to Zero
976 //
977 ValueInSectionHeader = ReadUnaligned64 ((UINT64 *)&SectionHeader.PointerToRelocations);
978 if (ValueInSectionHeader != 0) {
979 //
980 // Found first section header that doesn't point to code section in which build tool saves the
981 // offset to SMRAM base as image base in PointerToRelocations & PointerToLineNumbers fields
982 //
983 FixLoadingAddress = (EFI_PHYSICAL_ADDRESS)(SmramBase + (INT64)ValueInSectionHeader);
984
985 if ((SmramBase + SmmCodeSize > FixLoadingAddress) && (SmramBase <= FixLoadingAddress)) {
986 //
987 // The assigned address is valid. Return the specified loading address
988 //
989 ImageContext->ImageAddress = FixLoadingAddress;
990 Status = EFI_SUCCESS;
991 }
992 }
993
994 break;
995 }
996
997 SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
998 }
999
1000 DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r \n", FixLoadingAddress, Status));
1001 return Status;
1002}
1003
1019 IN OUT EFI_SMRAM_DESCRIPTOR *SmramRange,
1020 IN OUT EFI_SMRAM_DESCRIPTOR *SmramRangeSmmCore,
1021 IN VOID *Context
1022 )
1023{
1024 EFI_STATUS Status;
1025 VOID *SourceBuffer;
1026 UINTN SourceSize;
1027 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
1028 UINTN PageCount;
1029 EFI_IMAGE_ENTRY_POINT EntryPoint;
1030
1031 //
1032 // Search all Firmware Volumes for a PE/COFF image in a file of type SMM_CORE
1033 //
1035 EFI_FV_FILETYPE_SMM_CORE,
1036 0,
1038 0,
1039 &SourceBuffer,
1040 &SourceSize
1041 );
1042 if (EFI_ERROR (Status)) {
1043 return Status;
1044 }
1045
1046 //
1047 // Initialize ImageContext
1048 //
1049 ImageContext.Handle = SourceBuffer;
1051
1052 //
1053 // Get information about the image being loaded
1054 //
1055 Status = PeCoffLoaderGetImageInfo (&ImageContext);
1056 if (EFI_ERROR (Status)) {
1057 return Status;
1058 }
1059
1060 //
1061 // if Loading module at Fixed Address feature is enabled, the SMM core driver will be loaded to
1062 // the address assigned by build tool.
1063 //
1064 if (PcdGet64 (PcdLoadModuleAtFixAddressEnable) != 0) {
1065 //
1066 // Get the fixed loading address assigned by Build tool
1067 //
1068 Status = GetPeCoffImageFixLoadingAssignedAddress (&ImageContext);
1069 if (!EFI_ERROR (Status)) {
1070 //
1071 // Since the memory range to load SMM CORE will be cut out in SMM core, so no need to allocate and free this range
1072 //
1073 PageCount = 0;
1074 //
1075 // Reserved Smram Region for SmmCore is not used, and remove it from SmramRangeCount.
1076 //
1077 gSmmCorePrivate->SmramRangeCount--;
1078 } else {
1079 DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED ERROR: Loading module at fixed address at address failed\n"));
1080 //
1081 // Allocate memory for the image being loaded from the EFI_SRAM_DESCRIPTOR
1082 // specified by SmramRange
1083 //
1084 PageCount = (UINTN)EFI_SIZE_TO_PAGES ((UINTN)ImageContext.ImageSize + ImageContext.SectionAlignment);
1085
1086 ASSERT ((SmramRange->PhysicalSize & EFI_PAGE_MASK) == 0);
1087 ASSERT (SmramRange->PhysicalSize > EFI_PAGES_TO_SIZE (PageCount));
1088
1089 SmramRange->PhysicalSize -= EFI_PAGES_TO_SIZE (PageCount);
1090 SmramRangeSmmCore->CpuStart = SmramRange->CpuStart + SmramRange->PhysicalSize;
1091 SmramRangeSmmCore->PhysicalStart = SmramRange->PhysicalStart + SmramRange->PhysicalSize;
1092 SmramRangeSmmCore->RegionState = SmramRange->RegionState | EFI_ALLOCATED;
1093 SmramRangeSmmCore->PhysicalSize = EFI_PAGES_TO_SIZE (PageCount);
1094
1095 //
1096 // Align buffer on section boundary
1097 //
1098 ImageContext.ImageAddress = SmramRangeSmmCore->CpuStart;
1099 }
1100 } else {
1101 //
1102 // Allocate memory for the image being loaded from the EFI_SRAM_DESCRIPTOR
1103 // specified by SmramRange
1104 //
1105 PageCount = (UINTN)EFI_SIZE_TO_PAGES ((UINTN)ImageContext.ImageSize + ImageContext.SectionAlignment);
1106
1107 ASSERT ((SmramRange->PhysicalSize & EFI_PAGE_MASK) == 0);
1108 ASSERT (SmramRange->PhysicalSize > EFI_PAGES_TO_SIZE (PageCount));
1109
1110 SmramRange->PhysicalSize -= EFI_PAGES_TO_SIZE (PageCount);
1111 SmramRangeSmmCore->CpuStart = SmramRange->CpuStart + SmramRange->PhysicalSize;
1112 SmramRangeSmmCore->PhysicalStart = SmramRange->PhysicalStart + SmramRange->PhysicalSize;
1113 SmramRangeSmmCore->RegionState = SmramRange->RegionState | EFI_ALLOCATED;
1114 SmramRangeSmmCore->PhysicalSize = EFI_PAGES_TO_SIZE (PageCount);
1115
1116 //
1117 // Align buffer on section boundary
1118 //
1119 ImageContext.ImageAddress = SmramRangeSmmCore->CpuStart;
1120 }
1121
1122 ImageContext.ImageAddress += ImageContext.SectionAlignment - 1;
1123 ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)ImageContext.SectionAlignment - 1);
1124
1125 //
1126 // Print debug message showing SMM Core load address.
1127 //
1128 DEBUG ((DEBUG_INFO, "SMM IPL loading SMM Core at SMRAM address %p\n", (VOID *)(UINTN)ImageContext.ImageAddress));
1129
1130 //
1131 // Load the image to our new buffer
1132 //
1133 Status = PeCoffLoaderLoadImage (&ImageContext);
1134 if (!EFI_ERROR (Status)) {
1135 //
1136 // Relocate the image in our new buffer
1137 //
1138 Status = PeCoffLoaderRelocateImage (&ImageContext);
1139 if (!EFI_ERROR (Status)) {
1140 //
1141 // Flush the instruction cache so the image data are written before we execute it
1142 //
1143 InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);
1144
1145 //
1146 // Print debug message showing SMM Core entry point address.
1147 //
1148 DEBUG ((DEBUG_INFO, "SMM IPL calling SMM Core at SMRAM address %p\n", (VOID *)(UINTN)ImageContext.EntryPoint));
1149
1150 gSmmCorePrivate->PiSmmCoreImageBase = ImageContext.ImageAddress;
1151 gSmmCorePrivate->PiSmmCoreImageSize = ImageContext.ImageSize;
1152 DEBUG ((DEBUG_INFO, "PiSmmCoreImageBase - 0x%016lx\n", gSmmCorePrivate->PiSmmCoreImageBase));
1153 DEBUG ((DEBUG_INFO, "PiSmmCoreImageSize - 0x%016lx\n", gSmmCorePrivate->PiSmmCoreImageSize));
1154
1155 gSmmCorePrivate->PiSmmCoreEntryPoint = ImageContext.EntryPoint;
1156
1157 //
1158 // Execute image
1159 //
1160 EntryPoint = (EFI_IMAGE_ENTRY_POINT)(UINTN)ImageContext.EntryPoint;
1161 Status = EntryPoint ((EFI_HANDLE)Context, gST);
1162 }
1163 }
1164
1165 //
1166 // Always free memory allocated by GetFileBufferByFilePath ()
1167 //
1168 FreePool (SourceBuffer);
1169
1170 return Status;
1171}
1172
1187VOID
1189 IN OUT EFI_SMRAM_DESCRIPTOR *RangeToCompare,
1190 IN OUT EFI_SMM_RESERVED_SMRAM_REGION *ReservedRangeToCompare,
1191 OUT EFI_SMRAM_DESCRIPTOR *Ranges,
1192 IN OUT UINTN *RangeCount,
1193 OUT EFI_SMM_RESERVED_SMRAM_REGION *ReservedRanges,
1194 IN OUT UINTN *ReservedRangeCount,
1195 OUT EFI_SMRAM_DESCRIPTOR *FinalRanges,
1196 IN OUT UINTN *FinalRangeCount
1197 )
1198{
1199 UINT64 RangeToCompareEnd;
1200 UINT64 ReservedRangeToCompareEnd;
1201
1202 RangeToCompareEnd = RangeToCompare->CpuStart + RangeToCompare->PhysicalSize;
1203 ReservedRangeToCompareEnd = ReservedRangeToCompare->SmramReservedStart + ReservedRangeToCompare->SmramReservedSize;
1204
1205 if ((RangeToCompare->CpuStart >= ReservedRangeToCompare->SmramReservedStart) &&
1206 (RangeToCompare->CpuStart < ReservedRangeToCompareEnd))
1207 {
1208 if (RangeToCompareEnd < ReservedRangeToCompareEnd) {
1209 //
1210 // RangeToCompare ReservedRangeToCompare
1211 // ---- ---- --------------------------------------
1212 // | | | | -> 1. ReservedRangeToCompare
1213 // ---- | | |--| --------------------------------------
1214 // | | | | | |
1215 // | | | | | | -> 2. FinalRanges[*FinalRangeCount] and increment *FinalRangeCount
1216 // | | | | | | RangeToCompare->PhysicalSize = 0
1217 // ---- | | |--| --------------------------------------
1218 // | | | | -> 3. ReservedRanges[*ReservedRangeCount] and increment *ReservedRangeCount
1219 // ---- ---- --------------------------------------
1220 //
1221
1222 //
1223 // 1. Update ReservedRangeToCompare.
1224 //
1225 ReservedRangeToCompare->SmramReservedSize = RangeToCompare->CpuStart - ReservedRangeToCompare->SmramReservedStart;
1226 //
1227 // 2. Update FinalRanges[FinalRangeCount] and increment *FinalRangeCount.
1228 // Zero RangeToCompare->PhysicalSize.
1229 //
1230 FinalRanges[*FinalRangeCount].CpuStart = RangeToCompare->CpuStart;
1231 FinalRanges[*FinalRangeCount].PhysicalStart = RangeToCompare->PhysicalStart;
1232 FinalRanges[*FinalRangeCount].RegionState = RangeToCompare->RegionState | EFI_ALLOCATED;
1233 FinalRanges[*FinalRangeCount].PhysicalSize = RangeToCompare->PhysicalSize;
1234 *FinalRangeCount += 1;
1235 RangeToCompare->PhysicalSize = 0;
1236 //
1237 // 3. Update ReservedRanges[*ReservedRangeCount] and increment *ReservedRangeCount.
1238 //
1239 ReservedRanges[*ReservedRangeCount].SmramReservedStart = FinalRanges[*FinalRangeCount - 1].CpuStart + FinalRanges[*FinalRangeCount - 1].PhysicalSize;
1240 ReservedRanges[*ReservedRangeCount].SmramReservedSize = ReservedRangeToCompareEnd - RangeToCompareEnd;
1241 *ReservedRangeCount += 1;
1242 } else {
1243 //
1244 // RangeToCompare ReservedRangeToCompare
1245 // ---- ---- --------------------------------------
1246 // | | | | -> 1. ReservedRangeToCompare
1247 // ---- | | |--| --------------------------------------
1248 // | | | | | |
1249 // | | | | | | -> 2. FinalRanges[*FinalRangeCount] and increment *FinalRangeCount
1250 // | | | | | |
1251 // | | ---- |--| --------------------------------------
1252 // | | | | -> 3. RangeToCompare
1253 // ---- ---- --------------------------------------
1254 //
1255
1256 //
1257 // 1. Update ReservedRangeToCompare.
1258 //
1259 ReservedRangeToCompare->SmramReservedSize = RangeToCompare->CpuStart - ReservedRangeToCompare->SmramReservedStart;
1260 //
1261 // 2. Update FinalRanges[FinalRangeCount] and increment *FinalRangeCount.
1262 //
1263 FinalRanges[*FinalRangeCount].CpuStart = RangeToCompare->CpuStart;
1264 FinalRanges[*FinalRangeCount].PhysicalStart = RangeToCompare->PhysicalStart;
1265 FinalRanges[*FinalRangeCount].RegionState = RangeToCompare->RegionState | EFI_ALLOCATED;
1266 FinalRanges[*FinalRangeCount].PhysicalSize = ReservedRangeToCompareEnd - RangeToCompare->CpuStart;
1267 *FinalRangeCount += 1;
1268 //
1269 // 3. Update RangeToCompare.
1270 //
1271 RangeToCompare->CpuStart += FinalRanges[*FinalRangeCount - 1].PhysicalSize;
1272 RangeToCompare->PhysicalStart += FinalRanges[*FinalRangeCount - 1].PhysicalSize;
1273 RangeToCompare->PhysicalSize -= FinalRanges[*FinalRangeCount - 1].PhysicalSize;
1274 }
1275 } else if ((ReservedRangeToCompare->SmramReservedStart >= RangeToCompare->CpuStart) &&
1276 (ReservedRangeToCompare->SmramReservedStart < RangeToCompareEnd))
1277 {
1278 if (ReservedRangeToCompareEnd < RangeToCompareEnd) {
1279 //
1280 // RangeToCompare ReservedRangeToCompare
1281 // ---- ---- --------------------------------------
1282 // | | | | -> 1. RangeToCompare
1283 // | | ---- |--| --------------------------------------
1284 // | | | | | |
1285 // | | | | | | -> 2. FinalRanges[*FinalRangeCount] and increment *FinalRangeCount
1286 // | | | | | | ReservedRangeToCompare->SmramReservedSize = 0
1287 // | | ---- |--| --------------------------------------
1288 // | | | | -> 3. Ranges[*RangeCount] and increment *RangeCount
1289 // ---- ---- --------------------------------------
1290 //
1291
1292 //
1293 // 1. Update RangeToCompare.
1294 //
1295 RangeToCompare->PhysicalSize = ReservedRangeToCompare->SmramReservedStart - RangeToCompare->CpuStart;
1296 //
1297 // 2. Update FinalRanges[FinalRangeCount] and increment *FinalRangeCount.
1298 // ReservedRangeToCompare->SmramReservedSize = 0
1299 //
1300 FinalRanges[*FinalRangeCount].CpuStart = ReservedRangeToCompare->SmramReservedStart;
1301 FinalRanges[*FinalRangeCount].PhysicalStart = RangeToCompare->PhysicalStart + RangeToCompare->PhysicalSize;
1302 FinalRanges[*FinalRangeCount].RegionState = RangeToCompare->RegionState | EFI_ALLOCATED;
1303 FinalRanges[*FinalRangeCount].PhysicalSize = ReservedRangeToCompare->SmramReservedSize;
1304 *FinalRangeCount += 1;
1305 ReservedRangeToCompare->SmramReservedSize = 0;
1306 //
1307 // 3. Update Ranges[*RangeCount] and increment *RangeCount.
1308 //
1309 Ranges[*RangeCount].CpuStart = FinalRanges[*FinalRangeCount - 1].CpuStart + FinalRanges[*FinalRangeCount - 1].PhysicalSize;
1310 Ranges[*RangeCount].PhysicalStart = FinalRanges[*FinalRangeCount - 1].PhysicalStart + FinalRanges[*FinalRangeCount - 1].PhysicalSize;
1311 Ranges[*RangeCount].RegionState = RangeToCompare->RegionState;
1312 Ranges[*RangeCount].PhysicalSize = RangeToCompareEnd - ReservedRangeToCompareEnd;
1313 *RangeCount += 1;
1314 } else {
1315 //
1316 // RangeToCompare ReservedRangeToCompare
1317 // ---- ---- --------------------------------------
1318 // | | | | -> 1. RangeToCompare
1319 // | | ---- |--| --------------------------------------
1320 // | | | | | |
1321 // | | | | | | -> 2. FinalRanges[*FinalRangeCount] and increment *FinalRangeCount
1322 // | | | | | |
1323 // ---- | | |--| --------------------------------------
1324 // | | | | -> 3. ReservedRangeToCompare
1325 // ---- ---- --------------------------------------
1326 //
1327
1328 //
1329 // 1. Update RangeToCompare.
1330 //
1331 RangeToCompare->PhysicalSize = ReservedRangeToCompare->SmramReservedStart - RangeToCompare->CpuStart;
1332 //
1333 // 2. Update FinalRanges[FinalRangeCount] and increment *FinalRangeCount.
1334 // ReservedRangeToCompare->SmramReservedSize = 0
1335 //
1336 FinalRanges[*FinalRangeCount].CpuStart = ReservedRangeToCompare->SmramReservedStart;
1337 FinalRanges[*FinalRangeCount].PhysicalStart = RangeToCompare->PhysicalStart + RangeToCompare->PhysicalSize;
1338 FinalRanges[*FinalRangeCount].RegionState = RangeToCompare->RegionState | EFI_ALLOCATED;
1339 FinalRanges[*FinalRangeCount].PhysicalSize = RangeToCompareEnd - ReservedRangeToCompare->SmramReservedStart;
1340 *FinalRangeCount += 1;
1341 //
1342 // 3. Update ReservedRangeToCompare.
1343 //
1344 ReservedRangeToCompare->SmramReservedStart += FinalRanges[*FinalRangeCount - 1].PhysicalSize;
1345 ReservedRangeToCompare->SmramReservedSize -= FinalRanges[*FinalRangeCount - 1].PhysicalSize;
1346 }
1347 }
1348}
1349
1361BOOLEAN
1363 IN EFI_SMRAM_DESCRIPTOR *RangeToCompare,
1364 IN EFI_SMM_RESERVED_SMRAM_REGION *ReservedRangeToCompare
1365 )
1366{
1367 UINT64 RangeToCompareEnd;
1368 UINT64 ReservedRangeToCompareEnd;
1369 BOOLEAN IsOverUnderflow1;
1370 BOOLEAN IsOverUnderflow2;
1371
1372 // Check for over or underflow.
1373 IsOverUnderflow1 = EFI_ERROR (
1375 (UINT64)RangeToCompare->CpuStart,
1376 RangeToCompare->PhysicalSize,
1377 &RangeToCompareEnd
1378 )
1379 );
1380 IsOverUnderflow2 = EFI_ERROR (
1382 (UINT64)ReservedRangeToCompare->SmramReservedStart,
1383 ReservedRangeToCompare->SmramReservedSize,
1384 &ReservedRangeToCompareEnd
1385 )
1386 );
1387 if (IsOverUnderflow1 || IsOverUnderflow2) {
1388 return TRUE;
1389 }
1390
1391 if ((RangeToCompare->CpuStart >= ReservedRangeToCompare->SmramReservedStart) &&
1392 (RangeToCompare->CpuStart < ReservedRangeToCompareEnd))
1393 {
1394 return TRUE;
1395 } else if ((ReservedRangeToCompare->SmramReservedStart >= RangeToCompare->CpuStart) &&
1396 (ReservedRangeToCompare->SmramReservedStart < RangeToCompareEnd))
1397 {
1398 return TRUE;
1399 }
1400
1401 return FALSE;
1402}
1403
1418 OUT UINTN *FullSmramRangeCount
1419 )
1420{
1421 EFI_STATUS Status;
1422 EFI_SMM_CONFIGURATION_PROTOCOL *SmmConfiguration;
1423 UINTN Size;
1424 UINTN Index;
1425 UINTN Index2;
1426 EFI_SMRAM_DESCRIPTOR *FullSmramRanges;
1427 UINTN TempSmramRangeCount;
1428 UINTN AdditionSmramRangeCount;
1429 EFI_SMRAM_DESCRIPTOR *TempSmramRanges;
1430 UINTN SmramRangeCount;
1431 EFI_SMRAM_DESCRIPTOR *SmramRanges;
1432 UINTN SmramReservedCount;
1433 EFI_SMM_RESERVED_SMRAM_REGION *SmramReservedRanges;
1434 UINTN MaxCount;
1435 BOOLEAN Rescan;
1436
1437 //
1438 // Get SMM Configuration Protocol if it is present.
1439 //
1440 SmmConfiguration = NULL;
1441 Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, (VOID **)&SmmConfiguration);
1442
1443 //
1444 // Get SMRAM information.
1445 //
1446 Size = 0;
1447 Status = mSmmAccess->GetCapabilities (mSmmAccess, &Size, NULL);
1448 ASSERT (Status == EFI_BUFFER_TOO_SMALL);
1449
1450 SmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);
1451
1452 //
1453 // Get SMRAM reserved region count.
1454 //
1455 SmramReservedCount = 0;
1456 if (SmmConfiguration != NULL) {
1457 while (SmmConfiguration->SmramReservedRegions[SmramReservedCount].SmramReservedSize != 0) {
1458 SmramReservedCount++;
1459 }
1460 }
1461
1462 //
1463 // Reserve one entry for SMM Core in the full SMRAM ranges.
1464 //
1465 AdditionSmramRangeCount = 1;
1466 if (PcdGet64 (PcdLoadModuleAtFixAddressEnable) != 0) {
1467 //
1468 // Reserve two entries for all SMM drivers and SMM Core in the full SMRAM ranges.
1469 //
1470 AdditionSmramRangeCount = 2;
1471 }
1472
1473 if (SmramReservedCount == 0) {
1474 //
1475 // No reserved SMRAM entry from SMM Configuration Protocol.
1476 //
1477 *FullSmramRangeCount = SmramRangeCount + AdditionSmramRangeCount;
1478 Size = (*FullSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR);
1479 FullSmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocateZeroPool (Size);
1480 ASSERT (FullSmramRanges != NULL);
1481
1482 Status = mSmmAccess->GetCapabilities (mSmmAccess, &Size, FullSmramRanges);
1483 ASSERT_EFI_ERROR (Status);
1484
1485 return FullSmramRanges;
1486 }
1487
1488 //
1489 // Why MaxCount = X + 2 * Y?
1490 // Take Y = 1 as example below, Y > 1 case is just the iteration of Y = 1.
1491 //
1492 // X = 1 Y = 1 MaxCount = 3 = 1 + 2 * 1
1493 // ---- ----
1494 // | | ---- |--|
1495 // | | | | -> | |
1496 // | | ---- |--|
1497 // ---- ----
1498 //
1499 // X = 2 Y = 1 MaxCount = 4 = 2 + 2 * 1
1500 // ---- ----
1501 // | | | |
1502 // | | ---- |--|
1503 // | | | | | |
1504 // |--| | | -> |--|
1505 // | | | | | |
1506 // | | ---- |--|
1507 // | | | |
1508 // ---- ----
1509 //
1510 // X = 3 Y = 1 MaxCount = 5 = 3 + 2 * 1
1511 // ---- ----
1512 // | | | |
1513 // | | ---- |--|
1514 // |--| | | |--|
1515 // | | | | -> | |
1516 // |--| | | |--|
1517 // | | ---- |--|
1518 // | | | |
1519 // ---- ----
1520 //
1521 // ......
1522 //
1523 MaxCount = SmramRangeCount + 2 * SmramReservedCount;
1524
1525 Size = MaxCount * sizeof (EFI_SMM_RESERVED_SMRAM_REGION);
1526 SmramReservedRanges = (EFI_SMM_RESERVED_SMRAM_REGION *)AllocatePool (Size);
1527 ASSERT (SmramReservedRanges != NULL);
1528 for (Index = 0; Index < SmramReservedCount; Index++) {
1529 CopyMem (&SmramReservedRanges[Index], &SmmConfiguration->SmramReservedRegions[Index], sizeof (EFI_SMM_RESERVED_SMRAM_REGION));
1530 }
1531
1532 Size = MaxCount * sizeof (EFI_SMRAM_DESCRIPTOR);
1533 TempSmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocatePool (Size);
1534 ASSERT (TempSmramRanges != NULL);
1535 TempSmramRangeCount = 0;
1536
1537 SmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocatePool (Size);
1538 ASSERT (SmramRanges != NULL);
1539 Status = mSmmAccess->GetCapabilities (mSmmAccess, &Size, SmramRanges);
1540 ASSERT_EFI_ERROR (Status);
1541
1542 do {
1543 Rescan = FALSE;
1544 for (Index = 0; (Index < SmramRangeCount) && !Rescan; Index++) {
1545 //
1546 // Skip zero size entry.
1547 //
1548 if (SmramRanges[Index].PhysicalSize != 0) {
1549 for (Index2 = 0; (Index2 < SmramReservedCount) && !Rescan; Index2++) {
1550 //
1551 // Skip zero size entry.
1552 //
1553 if (SmramReservedRanges[Index2].SmramReservedSize != 0) {
1554 if (SmmIsSmramOverlap (
1555 &SmramRanges[Index],
1556 &SmramReservedRanges[Index2]
1557 ))
1558 {
1559 //
1560 // There is overlap, need to split entry and then rescan.
1561 //
1563 &SmramRanges[Index],
1564 &SmramReservedRanges[Index2],
1565 SmramRanges,
1566 &SmramRangeCount,
1567 SmramReservedRanges,
1568 &SmramReservedCount,
1569 TempSmramRanges,
1570 &TempSmramRangeCount
1571 );
1572 Rescan = TRUE;
1573 }
1574 }
1575 }
1576
1577 if (!Rescan) {
1578 //
1579 // No any overlap, copy the entry to the temp SMRAM ranges.
1580 // Zero SmramRanges[Index].PhysicalSize = 0;
1581 //
1582 CopyMem (&TempSmramRanges[TempSmramRangeCount++], &SmramRanges[Index], sizeof (EFI_SMRAM_DESCRIPTOR));
1583 SmramRanges[Index].PhysicalSize = 0;
1584 }
1585 }
1586 }
1587 } while (Rescan);
1588
1589 ASSERT (TempSmramRangeCount <= MaxCount);
1590
1591 //
1592 // Sort the entries
1593 //
1594 FullSmramRanges = AllocateZeroPool ((TempSmramRangeCount + AdditionSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR));
1595 ASSERT (FullSmramRanges != NULL);
1596 *FullSmramRangeCount = 0;
1597 do {
1598 for (Index = 0; Index < TempSmramRangeCount; Index++) {
1599 if (TempSmramRanges[Index].PhysicalSize != 0) {
1600 break;
1601 }
1602 }
1603
1604 ASSERT (Index < TempSmramRangeCount);
1605 for (Index2 = 0; Index2 < TempSmramRangeCount; Index2++) {
1606 if ((Index2 != Index) && (TempSmramRanges[Index2].PhysicalSize != 0) && (TempSmramRanges[Index2].CpuStart < TempSmramRanges[Index].CpuStart)) {
1607 Index = Index2;
1608 }
1609 }
1610
1611 CopyMem (&FullSmramRanges[*FullSmramRangeCount], &TempSmramRanges[Index], sizeof (EFI_SMRAM_DESCRIPTOR));
1612 *FullSmramRangeCount += 1;
1613 TempSmramRanges[Index].PhysicalSize = 0;
1614 } while (*FullSmramRangeCount < TempSmramRangeCount);
1615
1616 ASSERT (*FullSmramRangeCount == TempSmramRangeCount);
1617 *FullSmramRangeCount += AdditionSmramRangeCount;
1618
1619 FreePool (SmramRanges);
1620 FreePool (SmramReservedRanges);
1621 FreePool (TempSmramRanges);
1622
1623 return FullSmramRanges;
1624}
1625
1641EFIAPI
1643 IN EFI_HANDLE ImageHandle,
1644 IN EFI_SYSTEM_TABLE *SystemTable
1645 )
1646{
1647 EFI_STATUS Status;
1648 UINTN Index;
1649 UINT64 MaxSize;
1650 VOID *Registration;
1651 UINT64 SmmCodeSize;
1652 EFI_CPU_ARCH_PROTOCOL *CpuArch;
1653 EFI_STATUS SetAttrStatus;
1654 EFI_SMRAM_DESCRIPTOR *SmramRangeSmmDriver;
1656
1657 //
1658 // Fill in the image handle of the SMM IPL so the SMM Core can use this as the
1659 // ParentImageHandle field of the Load Image Protocol for all SMM Drivers loaded
1660 // by the SMM Core
1661 //
1662 mSmmCorePrivateData.SmmIplImageHandle = ImageHandle;
1663
1664 //
1665 // Get SMM Access Protocol
1666 //
1667 Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&mSmmAccess);
1668 ASSERT_EFI_ERROR (Status);
1669
1670 //
1671 // Get SMM Control2 Protocol
1672 //
1673 Status = gBS->LocateProtocol (&gEfiSmmControl2ProtocolGuid, NULL, (VOID **)&mSmmControl2);
1674 ASSERT_EFI_ERROR (Status);
1675
1676 gSmmCorePrivate->SmramRanges = GetFullSmramRanges (&gSmmCorePrivate->SmramRangeCount);
1677
1678 //
1679 // Open all SMRAM ranges
1680 //
1681 Status = mSmmAccess->Open (mSmmAccess);
1682 ASSERT_EFI_ERROR (Status);
1683
1684 //
1685 // Print debug message that the SMRAM window is now open.
1686 //
1687 DEBUG ((DEBUG_INFO, "SMM IPL opened SMRAM window\n"));
1688
1689 //
1690 // Find the largest SMRAM range between 1MB and 4GB that is at least 256KB - 4K in size
1691 //
1692 mCurrentSmramRange = NULL;
1693 for (Index = 0, MaxSize = SIZE_256KB - EFI_PAGE_SIZE; Index < gSmmCorePrivate->SmramRangeCount; Index++) {
1694 //
1695 // Skip any SMRAM region that is already allocated, needs testing, or needs ECC initialization
1696 //
1697 if ((gSmmCorePrivate->SmramRanges[Index].RegionState & (EFI_ALLOCATED | EFI_NEEDS_TESTING | EFI_NEEDS_ECC_INITIALIZATION)) != 0) {
1698 continue;
1699 }
1700
1701 if (gSmmCorePrivate->SmramRanges[Index].CpuStart >= BASE_1MB) {
1702 if ((gSmmCorePrivate->SmramRanges[Index].CpuStart + gSmmCorePrivate->SmramRanges[Index].PhysicalSize - 1) <= MAX_ADDRESS) {
1703 if (gSmmCorePrivate->SmramRanges[Index].PhysicalSize >= MaxSize) {
1704 MaxSize = gSmmCorePrivate->SmramRanges[Index].PhysicalSize;
1705 mCurrentSmramRange = &gSmmCorePrivate->SmramRanges[Index];
1706 }
1707 }
1708 }
1709 }
1710
1711 if (mCurrentSmramRange != NULL) {
1712 //
1713 // Print debug message showing SMRAM window that will be used by SMM IPL and SMM Core
1714 //
1715 DEBUG ((
1716 DEBUG_INFO,
1717 "SMM IPL found SMRAM window %p - %p\n",
1718 (VOID *)(UINTN)mCurrentSmramRange->CpuStart,
1719 (VOID *)(UINTN)(mCurrentSmramRange->CpuStart + mCurrentSmramRange->PhysicalSize - 1)
1720 ));
1721
1722 GetSmramCacheRange (mCurrentSmramRange, &mSmramCacheBase, &mSmramCacheSize);
1723 //
1724 // Make sure we can change the desired memory attributes.
1725 //
1726 Status = gDS->GetMemorySpaceDescriptor (
1727 mSmramCacheBase,
1728 &MemDesc
1729 );
1730 ASSERT_EFI_ERROR (Status);
1731 if ((MemDesc.Capabilities & SMRAM_CAPABILITIES) != SMRAM_CAPABILITIES) {
1732 gDS->SetMemorySpaceCapabilities (
1733 mSmramCacheBase,
1734 mSmramCacheSize,
1735 MemDesc.Capabilities | SMRAM_CAPABILITIES
1736 );
1737 }
1738
1739 //
1740 // If CPU AP is present, attempt to set SMRAM cacheability to WB and clear
1741 // all paging attributes.
1742 // Note that it is expected that cacheability of SMRAM has been set to WB if CPU AP
1743 // is not available here.
1744 //
1745 CpuArch = NULL;
1746 Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&CpuArch);
1747 if (!EFI_ERROR (Status)) {
1748 MemDesc.Attributes &= ~(EFI_CACHE_ATTRIBUTE_MASK | EFI_MEMORY_ATTRIBUTE_MASK);
1749 MemDesc.Attributes |= EFI_MEMORY_WB;
1750 Status = gDS->SetMemorySpaceAttributes (
1751 mSmramCacheBase,
1752 mSmramCacheSize,
1753 MemDesc.Attributes
1754 );
1755 if (EFI_ERROR (Status)) {
1756 DEBUG ((DEBUG_WARN, "SMM IPL failed to set SMRAM window to EFI_MEMORY_WB\n"));
1757 }
1758
1759 DEBUG_CODE (
1760 gDS->GetMemorySpaceDescriptor (
1761 mSmramCacheBase,
1762 &MemDesc
1763 );
1764 DEBUG ((DEBUG_INFO, "SMRAM attributes: %016lx\n", MemDesc.Attributes));
1765 ASSERT ((MemDesc.Attributes & EFI_MEMORY_ATTRIBUTE_MASK) == 0);
1766 );
1767 }
1768
1769 //
1770 // if Loading module at Fixed Address feature is enabled, save the SMRAM base to Load
1771 // Modules At Fixed Address Configuration Table.
1772 //
1773 if (PcdGet64 (PcdLoadModuleAtFixAddressEnable) != 0) {
1774 //
1775 // Build tool will calculate the smm code size and then patch the PcdLoadFixAddressSmmCodePageNumber
1776 //
1777 SmmCodeSize = LShiftU64 (PcdGet32 (PcdLoadFixAddressSmmCodePageNumber), EFI_PAGE_SHIFT);
1778 //
1779 // The SMRAM available memory is assumed to be larger than SmmCodeSize
1780 //
1781 ASSERT (mCurrentSmramRange->PhysicalSize > SmmCodeSize);
1782 //
1783 // Retrieve Load modules At fixed address configuration table and save the SMRAM base.
1784 //
1786 &gLoadFixedAddressConfigurationTableGuid,
1787 (VOID **)&mLMFAConfigurationTable
1788 );
1789 if (!EFI_ERROR (Status) && (mLMFAConfigurationTable != NULL)) {
1790 mLMFAConfigurationTable->SmramBase = mCurrentSmramRange->CpuStart;
1791 //
1792 // Print the SMRAM base
1793 //
1794 DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED INFO: TSEG BASE is %x. \n", mLMFAConfigurationTable->SmramBase));
1795 }
1796
1797 //
1798 // Fill the Smram range for all SMM code
1799 //
1800 SmramRangeSmmDriver = &gSmmCorePrivate->SmramRanges[gSmmCorePrivate->SmramRangeCount - 2];
1801 SmramRangeSmmDriver->CpuStart = mCurrentSmramRange->CpuStart;
1802 SmramRangeSmmDriver->PhysicalStart = mCurrentSmramRange->PhysicalStart;
1803 SmramRangeSmmDriver->RegionState = mCurrentSmramRange->RegionState | EFI_ALLOCATED;
1804 SmramRangeSmmDriver->PhysicalSize = SmmCodeSize;
1805
1806 mCurrentSmramRange->PhysicalSize -= SmmCodeSize;
1807 mCurrentSmramRange->CpuStart = mCurrentSmramRange->CpuStart + SmmCodeSize;
1808 mCurrentSmramRange->PhysicalStart = mCurrentSmramRange->PhysicalStart + SmmCodeSize;
1809 }
1810
1811 //
1812 // Load SMM Core into SMRAM and execute it from SMRAM
1813 //
1814 Status = ExecuteSmmCoreFromSmram (
1815 mCurrentSmramRange,
1816 &gSmmCorePrivate->SmramRanges[gSmmCorePrivate->SmramRangeCount - 1],
1817 gSmmCorePrivate
1818 );
1819 if (EFI_ERROR (Status)) {
1820 //
1821 // Print error message that the SMM Core failed to be loaded and executed.
1822 //
1823 DEBUG ((DEBUG_ERROR, "SMM IPL could not load and execute SMM Core from SMRAM\n"));
1824
1825 //
1826 // Attempt to reset SMRAM cacheability to UC
1827 //
1828 if (CpuArch != NULL) {
1829 SetAttrStatus = gDS->SetMemorySpaceAttributes (
1830 mSmramCacheBase,
1831 mSmramCacheSize,
1832 EFI_MEMORY_UC
1833 );
1834 if (EFI_ERROR (SetAttrStatus)) {
1835 DEBUG ((DEBUG_WARN, "SMM IPL failed to reset SMRAM window to EFI_MEMORY_UC\n"));
1836 }
1837 }
1838 }
1839 } else {
1840 //
1841 // Print error message that there are not enough SMRAM resources to load the SMM Core.
1842 //
1843 DEBUG ((DEBUG_ERROR, "SMM IPL could not find a large enough SMRAM region to load SMM Core\n"));
1844 }
1845
1846 //
1847 // If the SMM Core could not be loaded then close SMRAM window, free allocated
1848 // resources, and return an error so SMM IPL will be unloaded.
1849 //
1850 if ((mCurrentSmramRange == NULL) || EFI_ERROR (Status)) {
1851 //
1852 // Close all SMRAM ranges
1853 //
1854 Status = mSmmAccess->Close (mSmmAccess);
1855 ASSERT_EFI_ERROR (Status);
1856
1857 //
1858 // Print debug message that the SMRAM window is now closed.
1859 //
1860 DEBUG ((DEBUG_INFO, "SMM IPL closed SMRAM window\n"));
1861
1862 //
1863 // Free all allocated resources
1864 //
1865 FreePool (gSmmCorePrivate->SmramRanges);
1866
1867 return EFI_UNSUPPORTED;
1868 }
1869
1870 //
1871 // Install SMM Base2 Protocol and SMM Communication Protocol
1872 //
1873 Status = gBS->InstallMultipleProtocolInterfaces (
1874 &mSmmIplHandle,
1875 &gEfiSmmBase2ProtocolGuid,
1876 &mSmmBase2,
1877 &gEfiSmmCommunicationProtocolGuid,
1878 &mSmmCommunication,
1879 &gEfiMmCommunication2ProtocolGuid,
1880 &mMmCommunication2,
1881 NULL
1882 );
1883 ASSERT_EFI_ERROR (Status);
1884
1885 //
1886 // Create the set of protocol and event notifications that the SMM IPL requires
1887 //
1888 for (Index = 0; mSmmIplEvents[Index].NotifyFunction != NULL; Index++) {
1889 if (mSmmIplEvents[Index].Protocol) {
1890 mSmmIplEvents[Index].Event = EfiCreateProtocolNotifyEvent (
1891 mSmmIplEvents[Index].Guid,
1892 mSmmIplEvents[Index].NotifyTpl,
1893 mSmmIplEvents[Index].NotifyFunction,
1894 mSmmIplEvents[Index].NotifyContext,
1895 &Registration
1896 );
1897 } else {
1898 Status = gBS->CreateEventEx (
1899 EVT_NOTIFY_SIGNAL,
1900 mSmmIplEvents[Index].NotifyTpl,
1901 mSmmIplEvents[Index].NotifyFunction,
1902 mSmmIplEvents[Index].NotifyContext,
1903 mSmmIplEvents[Index].Guid,
1904 &mSmmIplEvents[Index].Event
1905 );
1906 ASSERT_EFI_ERROR (Status);
1907 }
1908 }
1909
1910 return EFI_SUCCESS;
1911}
UINT64 UINTN
#define MAX_ADDRESS
VOID *EFIAPI InvalidateInstructionCacheRange(IN VOID *Address, IN UINTN Length)
UINT64 EFIAPI ReadUnaligned64(IN CONST UINT64 *Buffer)
Definition: Unaligned.c:204
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
Definition: LShiftU64.c:28
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
EFI_STATUS EFIAPI GetSectionFromAnyFvByFileType(IN EFI_FV_FILETYPE FileType, IN UINTN FileInstance, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT VOID **Buffer, OUT UINTN *Size)
EFI_DXE_SERVICES * gDS
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#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
#define DEBUG_CODE(Expression)
Definition: DebugLib.h:590
#define REPORT_STATUS_CODE(Type, Value)
#define PcdGet64(TokenName)
Definition: PcdLib.h:375
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
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
#define EFI_IMAGE_SCN_CNT_CODE
0x00000020
Definition: PeImage.h:320
#define EFI_SECTION_PE32
#define SMM_CORE_PRIVATE_DATA_SIGNATURE
VOID EFIAPI SmmIplSmmConfigurationEventNotify(IN EFI_EVENT Event, IN VOID *Context)
Definition: PiSmmIpl.c:768
EFI_STATUS ExecuteSmmCoreFromSmram(IN OUT EFI_SMRAM_DESCRIPTOR *SmramRange, IN OUT EFI_SMRAM_DESCRIPTOR *SmramRangeSmmCore, IN VOID *Context)
Definition: PiSmmIpl.c:1018
EFI_STATUS EFIAPI SmmBase2GetSmstLocation(IN CONST EFI_SMM_BASE2_PROTOCOL *This, OUT EFI_SMM_SYSTEM_TABLE2 **Smst)
Definition: PiSmmIpl.c:462
VOID EFIAPI SmmIplEndOfDxeEventNotify(IN EFI_EVENT Event, IN VOID *Context)
Definition: PiSmmIpl.c:693
EFI_STATUS EFIAPI SmmBase2InSmram(IN CONST EFI_SMM_BASE2_PROTOCOL *This, OUT BOOLEAN *InSmram)
Definition: PiSmmIpl.c:435
EFI_STATUS EFIAPI SmmCommunicationCommunicate(IN CONST EFI_SMM_COMMUNICATION_PROTOCOL *This, IN OUT VOID *CommBuffer, IN OUT UINTN *CommSize OPTIONAL)
Definition: PiSmmIpl.c:508
VOID EFIAPI SmmIplDxeDispatchEventNotify(IN EFI_EVENT Event, IN VOID *Context)
Definition: PiSmmIpl.c:710
VOID EFIAPI SmmIplReadyToLockEventNotify(IN EFI_EVENT Event, IN VOID *Context)
Definition: PiSmmIpl.c:812
EFI_STATUS GetPeCoffImageFixLoadingAssignedAddress(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
Definition: PiSmmIpl.c:916
EFI_STATUS EFIAPI SmmIplEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: PiSmmIpl.c:1642
VOID GetSmramCacheRange(IN EFI_SMRAM_DESCRIPTOR *SmramRange, OUT EFI_PHYSICAL_ADDRESS *SmramCacheBase, OUT UINT64 *SmramCacheSize)
Definition: PiSmmIpl.c:391
BOOLEAN SmmIsSmramOverlap(IN EFI_SMRAM_DESCRIPTOR *RangeToCompare, IN EFI_SMM_RESERVED_SMRAM_REGION *ReservedRangeToCompare)
Definition: PiSmmIpl.c:1362
EFI_STATUS EFIAPI SmmCommunicationMmCommunicate2(IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This, IN OUT VOID *CommBufferPhysical, IN OUT VOID *CommBufferVirtual, IN OUT UINTN *CommSize OPTIONAL)
Definition: PiSmmIpl.c:640
VOID SmmSplitSmramEntry(IN OUT EFI_SMRAM_DESCRIPTOR *RangeToCompare, IN OUT EFI_SMM_RESERVED_SMRAM_REGION *ReservedRangeToCompare, OUT EFI_SMRAM_DESCRIPTOR *Ranges, IN OUT UINTN *RangeCount, OUT EFI_SMM_RESERVED_SMRAM_REGION *ReservedRanges, IN OUT UINTN *ReservedRangeCount, OUT EFI_SMRAM_DESCRIPTOR *FinalRanges, IN OUT UINTN *FinalRangeCount)
Definition: PiSmmIpl.c:1188
VOID EFIAPI SmmIplGuidedEventNotify(IN EFI_EVENT Event, IN VOID *Context)
Definition: PiSmmIpl.c:663
VOID EFIAPI SmmIplSetVirtualAddressNotify(IN EFI_EVENT Event, IN VOID *Context)
Definition: PiSmmIpl.c:898
EFI_SMRAM_DESCRIPTOR * GetFullSmramRanges(OUT UINTN *FullSmramRangeCount)
Definition: PiSmmIpl.c:1417
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
RETURN_STATUS EFIAPI SafeUint64Add(IN UINT64 Augend, IN UINT64 Addend, OUT UINT64 *Result)
Definition: SafeIntLib.c:2973
VOID EFIAPI NotifyFunction(IN EFI_EVENT Event, IN VOID *Context)
Definition: ScsiBus.c:1492
struct _EFI_SMM_RESERVED_SMRAM_REGION EFI_SMM_RESERVED_SMRAM_REGION
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
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
UINTN EFI_TPL
Definition: UefiBaseType.h:41
#define EFI_SIZE_TO_PAGES(Size)
Definition: UefiBaseType.h:200
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_SYSTEM_TABLE * gST
EFI_BOOT_SERVICES * gBS
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
Definition: UefiLib.c:82
EFI_EVENT EFIAPI EfiCreateProtocolNotifyEvent(IN EFI_GUID *ProtocolGuid, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext OPTIONAL, OUT VOID **Registration)
Definition: UefiLib.c:134
EFI_STATUS EFIAPI EfiConvertPointer(IN UINTN DebugDisposition, IN OUT VOID **Address)
Definition: RuntimeLib.c:561
BOOLEAN EFIAPI EfiGoneVirtual(VOID)
Definition: RuntimeLib.c:188
VOID(EFIAPI * EFI_EVENT_NOTIFY)(IN EFI_EVENT Event, IN VOID *Context)
Definition: UefiSpec.h:463
EFI_STATUS(EFIAPI * EFI_IMAGE_ENTRY_POINT)(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: UefiSpec.h:2108
EFI_SMM_RESERVED_SMRAM_REGION * SmramReservedRegions
EFI_SMM_INTERRUPT_MANAGE SmiManage
Definition: PiSmmCis.h:195
EFI_PHYSICAL_ADDRESS SmramBase
SMRAM base address. The build tool assigns an offset relative to the SMRAM base for a SMM driver.
EFI_PHYSICAL_ADDRESS CpuStart
Definition: PiMultiPhase.h:127
EFI_PHYSICAL_ADDRESS PhysicalStart
Definition: PiMultiPhase.h:122
Definition: Base.h:213
PE_COFF_LOADER_READ_FILE ImageRead
Definition: PeCoffLib.h:100
PHYSICAL_ADDRESS EntryPoint
Definition: PeCoffLib.h:95
PHYSICAL_ADDRESS ImageAddress
Definition: PeCoffLib.h:79
EFI_SMM_SYSTEM_TABLE2 * Smst
EFI_SMM_ENTRY_POINT SmmEntryPoint
EFI_SMRAM_DESCRIPTOR * SmramRanges