45 ASSERT (HobLength < MAX_UINT16 - 0x7);
76 IN UINT64 NumberOfBytes,
83 Hob->ResourceType = EFI_RESOURCE_SYSTEM_MEMORY;
84 Hob->ResourceAttribute = ResourceAttribute;
85 Hob->PhysicalStart = PhysicalStart;
86 Hob->ResourceLength = NumberOfBytes;
121 if (*HobBufferSize >= HobLength) {
122 ASSERT (Hob !=
NULL);
130 *HobBufferSize = HobLength;
156 if (*HobBufferSize >= HobLength) {
157 ASSERT (Hob !=
NULL);
167 *HobBufferSize = HobLength;
195 if (*HobBufferSize >= HobLength) {
196 ASSERT (Hob !=
NULL);
202 MmSyncModeInfoHob->
RelaxedApMode = (BOOLEAN)(
PcdGet8 (PcdCpuSmmSyncMode) == MmCpuSyncModeRelaxedAp);
207 *HobBufferSize = HobLength;
228 IN BOOLEAN MultiInstances
236 ASSERT (GuidHob !=
NULL);
238 while (GuidHob !=
NULL) {
239 if (*HobBufferSize >= UsedSize + GuidHob->
HobLength) {
240 ASSERT (HobBuffer !=
NULL);
246 if (!MultiInstances) {
253 *HobBufferSize = UsedSize;
288 ASSERT (EntryPoint >= Base && EntryPoint < Base + Length);
291 if (*HobBufferSize >= HobLength) {
292 ASSERT (Hob !=
NULL);
306 *HobBufferSize = HobLength;
327 TotalSize =
PcdGet32 (PcdCpuSmmProfileSize);
335 Hob.Raw =
GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
336 while (Hob.Raw !=
NULL) {
342 return Hob.MemoryAllocation;
345 Hob.Raw =
GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (Hob));
371 Hob.MemoryAllocation =
NULL;
374 if (*HobBufferSize >= HobLength) {
375 Hob.Raw =
GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
376 while (Hob.Raw !=
NULL) {
381 Hob.Raw =
GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (Hob));
384 ASSERT (Hob.MemoryAllocation !=
NULL);
390 ASSERT (HobBuffer !=
NULL);
398 EFI_RESOURCE_SYSTEM_MEMORY,
402 &gMmProfileDataHobGuid
406 *HobBufferSize = HobLength;
432 while (GuidHob !=
NULL) {
434 UnblockRegion = GET_GUID_HOB_DATA (GuidHob);
437 EFI_RESOURCE_SYSTEM_MEMORY,
446 GuidHob =
GetNextGuidHob (&gMmUnblockRegionHobGuid, GET_NEXT_HOB (GuidHob));
449 *HobBufferSize = UsedSize;
468 ASSERT (MemoryRegionCount !=
NULL);
469 ASSERT (*MemoryRegionCount == 0 || MemoryRegion !=
NULL);
476 while (GuidHob !=
NULL) {
477 if (Index < *MemoryRegionCount) {
478 UnblockRegion = GET_GUID_HOB_DATA (GuidHob);
484 GuidHob =
GetNextGuidHob (&gMmUnblockRegionHobGuid, GET_NEXT_HOB (GuidHob));
487 *MemoryRegionCount = Index;
500 IN UINT8 *PlatformHobList,
509 ASSERT (MemoryRegionCount !=
NULL);
510 ASSERT (*MemoryRegionCount == 0 || MemoryRegion !=
NULL);
516 Hob.Raw = PlatformHobList;
521 while (Hob.Raw < PlatformHobList + PlatformHobSize) {
522 if (Hob.Header->
HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
523 if ( (Hob.ResourceDescriptor->
ResourceType == EFI_RESOURCE_MEMORY_MAPPED_IO)
524 || (Hob.ResourceDescriptor->
ResourceType == EFI_RESOURCE_SYSTEM_MEMORY)
525 || (Hob.ResourceDescriptor->
ResourceType == EFI_RESOURCE_FIRMWARE_DEVICE)
526 || (Hob.ResourceDescriptor->
ResourceType == EFI_RESOURCE_MEMORY_RESERVED))
528 if (Index < *MemoryRegionCount) {
529 MemoryRegion[Index].Base = Hob.ResourceDescriptor->
PhysicalStart;
530 MemoryRegion[Index].Length = Hob.ResourceDescriptor->
ResourceLength;
537 Hob.Raw = GET_NEXT_HOB (Hob);
540 *MemoryRegionCount = Index;
585 UINT32 MaxExtendedFunctionId;
588 if (MaxExtendedFunctionId >= CPUID_VIR_PHY_ADDRESS_SIZE) {
623 UINT8 PhysicalAddressBits;
631 PhysicalAddressBits = ((
EFI_HOB_CPU *)Hob)->SizeOfMemorySpace;
634 if (RegEax >= CPUID_VIR_PHY_ADDRESS_SIZE) {
636 PhysicalAddressBits = (UINT8)RegEax;
638 PhysicalAddressBits = 36;
649 ASSERT (PhysicalAddressBits <= 52);
651 PhysicalAddressBits = 47;
654 return PhysicalAddressBits;
673 IN VOID *PlatformHobList,
681 UINTN PlatformRegionCount;
683 UINT64 PreviousAddress;
687 UINTN UnblockRegionCount;
694 PlatformRegionCount = 0;
695 if ((PlatformHobList !=
NULL) && (PlatformHobSize != 0)) {
702 UnblockRegionCount = 0;
709 Count = PlatformRegionCount + UnblockRegionCount + Block->NumberOfMmReservedRegions + ((MmProfileDataHob !=
NULL) ? 1 : 0) + 1;
711 ASSERT (MemoryRegions !=
NULL);
712 if (MemoryRegions ==
NULL) {
713 DEBUG ((DEBUG_ERROR,
"%a:%d - No enough memory\n", __func__, __LINE__));
721 MemoryRegions[Count - 1].Base = MaxAddress;
722 MemoryRegions[Count - 1].Length = 0;
727 if (PlatformRegionCount != 0) {
734 if (UnblockRegionCount != 0) {
741 for (Index = 0; Index < Block->NumberOfMmReservedRegions; Index++) {
742 MemoryRegions[PlatformRegionCount + UnblockRegionCount + Index].Base = Block->Descriptor[Index].CpuStart;
743 MemoryRegions[PlatformRegionCount + UnblockRegionCount + Index].Length = Block->Descriptor[Index].PhysicalSize;
749 if (MmProfileDataHob !=
NULL) {
750 MemoryRegions[PlatformRegionCount + UnblockRegionCount + Block->NumberOfMmReservedRegions].Base = MmProfileDataHob->AllocDescriptor.MemoryBaseAddress;
751 MemoryRegions[PlatformRegionCount + UnblockRegionCount + Block->NumberOfMmReservedRegions].Length = MmProfileDataHob->AllocDescriptor.MemoryLength;
760 for (Index = 0; Index < Count; Index++) {
761 ASSERT (MaxAddress >= MemoryRegions[Index].Base + MemoryRegions[Index].Length);
763 if (MemoryRegions[Index].Base > PreviousAddress) {
767 EFI_RESOURCE_SYSTEM_MEMORY,
770 MemoryRegions[Index].Base - PreviousAddress,
778 PreviousAddress = MemoryRegions[Index].Base + MemoryRegions[Index].Length;
781 *HobBufferSize = UsedSize;
799 if (TotalHobSize > UsedSize) {
800 return TotalHobSize - UsedSize;
835 IN UINT8 *FoundationHobList,
837 IN UINT8 *PlatformHobList,
843 IN UINT64 MmCoreImageSize,
850 RETURN_STATUS Status;
853 ASSERT (FoundationHobSize !=
NULL);
856 ((*FoundationHobSize != 0) && (FoundationHobList !=
NULL)) ||
857 ((*FoundationHobSize == 0) && (FoundationHobList ==
NULL))
867 ASSERT (!
PcdGetBool (PcdCpuSmmRestrictedMemoryAccess));
875 HobLength = *FoundationHobSize;
877 UsedSize += HobLength;
884 FoundationHobList + UsedSize,
892 UsedSize += HobLength;
898 MmIplBuildFvHob (FoundationHobList + UsedSize, &HobLength, MmFvBase, MmFvSize);
899 UsedSize += HobLength;
906 UsedSize += HobLength;
913 UsedSize += HobLength;
920 UsedSize += HobLength;
927 UsedSize += HobLength;
934 UsedSize += HobLength;
941 UsedSize += HobLength;
949 UsedSize += HobLength;
957 UsedSize += HobLength;
959 if (!
PcdGetBool (PcdCpuSmmRestrictedMemoryAccess)) {
968 FoundationHobList + UsedSize,
975 UsedSize += HobLength;
978 if (*FoundationHobSize < UsedSize) {
984 *FoundationHobSize = UsedSize;
VOID *EFIAPI GetFirstHob(IN UINT16 Type)
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
VOID *EFIAPI GetNextHob(IN UINT16 Type, IN CONST VOID *HobStart)
VOID *EFIAPI GetNextGuidHob(IN CONST EFI_GUID *Guid, IN CONST VOID *HobStart)
VOID EFIAPI CpuDeadLoop(VOID)
VOID EFIAPI QuickSort(IN OUT VOID *BufferToSort, IN CONST UINTN Count, IN CONST UINTN ElementSize, IN BASE_SORT_COMPARE CompareFunction, OUT VOID *BufferOneElement)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
UINT32 EFIAPI AsmCpuidEx(IN UINT32 Index, IN UINT32 SubIndex, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
VOID EFIAPI FreePages(IN VOID *Buffer, IN UINTN Pages)
VOID *EFIAPI AllocateReservedPages(IN UINTN Pages)
#define RETURN_BUFFER_TOO_SMALL
#define ADDRESS_IS_ALIGNED(Address, Alignment)
#define IS_ALIGNED(Value, Alignment)
#define ALIGN_VALUE(Value, Alignment)
#define DEBUG(Expression)
#define CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS
#define CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO
UINT32 EFIAPI AsmCpuid(IN UINT32 Index, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
VOID * MmIplCreateHob(IN VOID *Hob, IN UINT16 HobType, IN UINT16 HobLength)
VOID MmIplBuildMmCoreModuleHob(IN UINT8 *Hob, IN OUT UINTN *HobBufferSize, IN CONST EFI_GUID *ModuleName, IN EFI_PHYSICAL_ADDRESS Base, IN UINT64 Length, IN EFI_PHYSICAL_ADDRESS EntryPoint)
VOID MmIplCopyGuidHob(IN UINT8 *HobBuffer, IN OUT UINTN *HobBufferSize, IN EFI_GUID *Guid, IN BOOLEAN MultiInstances)
VOID MmIplBuildMmProfileHobs(IN UINT8 *HobBuffer, IN OUT UINTN *HobBufferSize)
INTN EFIAPI MemoryRegionBaseAddressCompare(IN CONST VOID *Buffer1, IN CONST VOID *Buffer2)
VOID CollectPlatformMemoryRegions(IN UINT8 *PlatformHobList, IN UINTN PlatformHobSize, IN OUT MM_IPL_MEMORY_REGION *MemoryRegion, IN OUT UINTN *MemoryRegionCount)
VOID MmIplBuildResourceHobForUnblockedRegion(IN UINT8 *HobBuffer, IN OUT UINTN *HobBufferSize)
VOID MmIplBuildResourceHobForAllSystemMemory(IN UINT8 *HobBuffer, IN OUT UINTN *HobBufferSize, IN VOID *PlatformHobList, IN UINTN PlatformHobSize, IN EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *Block, IN EFI_HOB_MEMORY_ALLOCATION *MmProfileDataHob)
BOOLEAN MmIplIs5LevelPagingNeeded(VOID)
VOID MmIplBuildMmCpuSyncConfigHob(IN UINT8 *Hob, IN OUT UINTN *HobBufferSize)
VOID MmIplBuildMmAcpiS3EnableHob(IN UINT8 *Hob, IN OUT UINTN *HobBufferSize)
UINTN GetRemainingHobSize(IN UINTN TotalHobSize, IN UINTN UsedSize)
VOID MmIplBuildFvHob(IN UINT8 *Hob, IN OUT UINTN *HobBufferSize, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
VOID MmIplBuildMemoryResourceHob(IN EFI_HOB_RESOURCE_DESCRIPTOR *Hob, IN EFI_RESOURCE_TYPE ResourceType, IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, IN EFI_PHYSICAL_ADDRESS PhysicalStart, IN UINT64 NumberOfBytes, IN EFI_GUID *Owner)
UINT8 MmIplCalculateMaximumSupportAddress(VOID)
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)
VOID CollectUnblockMemoryRegions(IN OUT MM_IPL_MEMORY_REGION *MemoryRegion, IN OUT UINTN *MemoryRegionCount)
#define MM_RESOURCE_ATTRIBUTE_LOGGING
#define PcdGet64(TokenName)
#define PcdGet8(TokenName)
#define PcdGet32(TokenName)
#define PcdGetBool(TokenName)
#define FeaturePcdGet(TokenName)
UINT32 EFI_RESOURCE_ATTRIBUTE_TYPE
VOID *EFIAPI AllocatePages(IN UINTN Pages)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_SIZE_TO_PAGES(Size)
EFI_PHYSICAL_ADDRESS BaseAddress
EFI_PHYSICAL_ADDRESS MemoryBaseAddress
EFI_MEMORY_TYPE MemoryType
EFI_PHYSICAL_ADDRESS EntryPoint
EFI_HOB_MEMORY_ALLOCATION_HEADER MemoryAllocationHeader
EFI_HOB_GENERIC_HEADER Header
EFI_HOB_MEMORY_ALLOCATION_HEADER AllocDescriptor
EFI_PHYSICAL_ADDRESS PhysicalStart
EFI_RESOURCE_TYPE ResourceType
MM_CPU_SYNC_MODE RelaxedApMode
EFI_PHYSICAL_ADDRESS PhysicalStart
struct CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_ECX::@709 Bits
struct CPUID_VIR_PHY_ADDRESS_SIZE_EAX::@753 Bits
UINT32 PhysicalAddressBits