TianoCore EDK2 master
Loading...
Searching...
No Matches
MmFoundationHob.c File Reference

Go to the source code of this file.

Data Structures

struct  MM_IPL_MEMORY_REGION
 

Functions

VOID * MmIplCreateHob (IN VOID *Hob, IN UINT16 HobType, IN UINT16 HobLength)
 
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)
 
VOID MmIplBuildFvHob (IN UINT8 *Hob, IN OUT UINTN *HobBufferSize, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
 
VOID MmIplBuildMmAcpiS3EnableHob (IN UINT8 *Hob, IN OUT UINTN *HobBufferSize)
 
VOID MmIplBuildMmCpuSyncConfigHob (IN UINT8 *Hob, IN OUT UINTN *HobBufferSize)
 
VOID MmIplCopyGuidHob (IN UINT8 *HobBuffer, IN OUT UINTN *HobBufferSize, IN EFI_GUID *Guid, IN BOOLEAN MultiInstances)
 
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)
 
EFI_HOB_MEMORY_ALLOCATIONBuildMmProfileDataHobInPeiHobList (VOID)
 
VOID MmIplBuildMmProfileHobs (IN UINT8 *HobBuffer, IN OUT UINTN *HobBufferSize)
 
VOID MmIplBuildResourceHobForUnblockedRegion (IN UINT8 *HobBuffer, IN OUT UINTN *HobBufferSize)
 
VOID CollectUnblockMemoryRegions (IN OUT MM_IPL_MEMORY_REGION *MemoryRegion, IN OUT UINTN *MemoryRegionCount)
 
VOID CollectPlatformMemoryRegions (IN UINT8 *PlatformHobList, IN UINTN PlatformHobSize, IN OUT MM_IPL_MEMORY_REGION *MemoryRegion, IN OUT UINTN *MemoryRegionCount)
 
INTN EFIAPI MemoryRegionBaseAddressCompare (IN CONST VOID *Buffer1, IN CONST VOID *Buffer2)
 
BOOLEAN MmIplIs5LevelPagingNeeded (VOID)
 
UINT8 MmIplCalculateMaximumSupportAddress (VOID)
 
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)
 
UINTN GetRemainingHobSize (IN UINTN TotalHobSize, IN UINTN UsedSize)
 
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)
 

Detailed Description

Copyright (c) 2024, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file MmFoundationHob.c.

Function Documentation

◆ BuildMmProfileDataHobInPeiHobList()

EFI_HOB_MEMORY_ALLOCATION * BuildMmProfileDataHobInPeiHobList ( VOID  )

Build memory allocation HOB in PEI HOB list for MM profile data.

This function is to allocate memory for MM profile data.

Returns
NULL if MM profile data memory allocation HOB build fail.
Pointer of MM profile data memory allocation HOB if build successfully.

Definition at line 319 of file MmFoundationHob.c.

◆ CollectPlatformMemoryRegions()

VOID CollectPlatformMemoryRegions ( IN UINT8 *  PlatformHobList,
IN UINTN  PlatformHobSize,
IN OUT MM_IPL_MEMORY_REGION MemoryRegion,
IN OUT UINTN MemoryRegionCount 
)

Create MMIO memory map according to platform HOB.

Parameters
[in]PlatformHobListPlatform HOB list.
[in]PlatformHobSizePlatform HOB size.
[in,out]MemoryRegionMemory regions.
[in,out]MemoryRegionCountCount of MMIO regions

Definition at line 499 of file MmFoundationHob.c.

◆ CollectUnblockMemoryRegions()

VOID CollectUnblockMemoryRegions ( IN OUT MM_IPL_MEMORY_REGION MemoryRegion,
IN OUT UINTN MemoryRegionCount 
)

Collect unblock memory regions.

Parameters
[in,out]MemoryRegionPointer to unblock memory regions.
[in,out]MemoryRegionCountCount of unblock memory regions.

Definition at line 459 of file MmFoundationHob.c.

◆ CreateMmFoundationHobList()

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 
)

Create the MM foundation specific HOB list which StandaloneMm Core needed.

This function build the MM foundation specific HOB list needed by StandaloneMm Core based on the PEI HOB list.

Parameters
[in]FoundationHobListThe foundation HOB list to be used for HOB creation.
[in,out]FoundationHobSizeThe foundation HOB size. On return, the expected/used size.
[in]PlatformHobListPlatform HOB list.
[in]PlatformHobSizePlatform HOB size.
[in]MmFvBaseBase of firmare volume which included MM core dirver.
[in]MmFvSizeSize of firmare volume which included MM core dirver.
[in]MmCoreFileNameFile name of MM core dirver.
[in]MmCoreImageAddressImage address of MM core dirver.
[in]MmCoreImageSizeImage size of MM core dirver.
[in]MmCoreEntryPointEntry pinter of MM core dirver.
[in]MmProfileDataHobPointer to Mm profile data HOB.
[in]BlockPointer of MMRAM descriptor block.
Return values
RETURN_BUFFER_TOO_SMALLThe buffer is too small for HOB creation. BufferSize is updated to indicate the expected buffer size. When the input BufferSize is bigger than the expected buffer size, the BufferSize value will be changed the used buffer size.
RETURN_SUCCESSHOB List is created/updated successfully or the input Length is 0.

Definition at line 834 of file MmFoundationHob.c.

◆ GetRemainingHobSize()

UINTN GetRemainingHobSize ( IN UINTN  TotalHobSize,
IN UINTN  UsedSize 
)

Get remaining size for building HOBs.

Parameters
[in]TotalHobSizeTotal size of foundation HOBs.
[in]UsedSizeRequired HOBs' size.
Return values
MAXremaining size for building HOBs

Definition at line 794 of file MmFoundationHob.c.

◆ MemoryRegionBaseAddressCompare()

INTN EFIAPI MemoryRegionBaseAddressCompare ( IN CONST VOID *  Buffer1,
IN CONST VOID *  Buffer2 
)

Function to compare 2 MM_IPL_MEMORY_REGION pointer based on Base.

Parameters
[in]Buffer1pointer to MM_IPL_MEMORY_REGION pointer to compare
[in]Buffer2pointer to second MM_IPL_MEMORY_REGION pointer to compare
Return values
0Buffer1 equal to Buffer2
<0Buffer1 is less than Buffer2
>0Buffer1 is greater than Buffer2

Definition at line 555 of file MmFoundationHob.c.

◆ MmIplBuildFvHob()

VOID MmIplBuildFvHob ( IN UINT8 *  Hob,
IN OUT UINTN HobBufferSize,
IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length 
)

Builds a Firmware Volume HOB.

This function builds a Firmware Volume HOB. It can only be invoked during PEI phase; If new HOB buffer is NULL, then ASSERT().

Parameters
[in]HobThe pointer of new HOB buffer.
[in,out]HobBufferSizeThe available size of the HOB buffer when as input. The used size of when as output.
[in]BaseAddressThe base address of the Firmware Volume.
[in]LengthThe size of the Firmware Volume in bytes.

Definition at line 110 of file MmFoundationHob.c.

◆ MmIplBuildMemoryResourceHob()

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 
)

Builds a HOB that describes a chunk of system memory.

This function builds a HOB that describes a chunk of system memory. If there is no additional space for HOB creation, then ASSERT().

Parameters
[in]HobThe pointer of new HOB buffer.
[in]ResourceTypeThe type of resource described by this HOB.
[in]ResourceAttributeThe resource attributes of the memory described by this HOB.
[in]PhysicalStartThe 64 bit physical address of memory described by this HOB.
[in]NumberOfBytesThe length of the memory described by this HOB in bytes.
[in]OwnerThe pointer of GUID.

Definition at line 71 of file MmFoundationHob.c.

◆ MmIplBuildMmAcpiS3EnableHob()

VOID MmIplBuildMmAcpiS3EnableHob ( IN UINT8 *  Hob,
IN OUT UINTN HobBufferSize 
)

Builds MM ACPI S3 Enable HOB.

This function builds MM ACPI S3 Enable HOB. It can only be invoked during PEI phase; If new HOB buffer is NULL, then ASSERT().

Parameters
[in]HobThe pointer of new HOB buffer.
[in,out]HobBufferSizeThe available size of the HOB buffer when as input. The used size of when as output.

Definition at line 146 of file MmFoundationHob.c.

◆ MmIplBuildMmCoreModuleHob()

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 
)

Builds a HOB for a loaded PE32 module.

This function builds a HOB for a loaded PE32 module. It can only be invoked during PEI phase; If physical address of the Module is not 4K aligned, then ASSERT(). If new HOB buffer is NULL, then ASSERT().

Parameters
[in]HobThe pointer of new HOB buffer.
[in,out]HobBufferSizeThe available size of the HOB buffer when as input. The used size of when as output.
[in]ModuleNameThe GUID File Name of the module.
[in]BaseThe 64 bit physical address of the module.
[in]LengthThe length of the module in bytes.
[in]EntryPointThe 64 bit physical address of the module entry point.

Definition at line 274 of file MmFoundationHob.c.

◆ MmIplBuildMmCpuSyncConfigHob()

VOID MmIplBuildMmCpuSyncConfigHob ( IN UINT8 *  Hob,
IN OUT UINTN HobBufferSize 
)

Builds MM cpu sync configuration HOB.

This function builds smm cpu sync configuration HOB. It can only be invoked during PEI phase; If new HOB buffer is NULL, then ASSERT().

Parameters
[in]HobThe pointer of new HOB buffer.
[in,out]HobBufferSizeThe available size of the HOB buffer when as input. The used size of when as output.

Definition at line 183 of file MmFoundationHob.c.

◆ MmIplBuildMmProfileHobs()

VOID MmIplBuildMmProfileHobs ( IN UINT8 *  HobBuffer,
IN OUT UINTN HobBufferSize 
)

Build memory allocation and resource HOB for MM profile data

This function builds HOBs for MM profile data, one is memory allocation HOB, another is resource HOB.

Parameters
[in]HobBufferThe pointer of new HOB buffer.
[in,out]HobBufferSizeThe total size of the same GUID HOBs when as input. The size will be 0 for output when build HOB fail.

Definition at line 363 of file MmFoundationHob.c.

◆ MmIplBuildResourceHobForAllSystemMemory()

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 
)

Build resource HOB to cover [0, PhysicalAddressBits length] by excluding all Mmram ranges, MM Profile data, Unblock memory ranges and MMIO ranges.

Parameters
[in]HobBufferThe pointer of new HOB buffer.
[in,out]HobBufferSizeThe available size of the HOB buffer when as input. The used size of when as output.
[in]PlatformHobListPlatform HOB list.
[in]PlatformHobSizePlatform HOB size.
[in]BlockPointer of MMRAM descriptor block.
[in]MmProfileDataHobPointer to MM profile data HOB.

Definition at line 670 of file MmFoundationHob.c.

◆ MmIplBuildResourceHobForUnblockedRegion()

VOID MmIplBuildResourceHobForUnblockedRegion ( IN UINT8 *  HobBuffer,
IN OUT UINTN HobBufferSize 
)

Build resource Hobs from unblocked memory regions

This function builds resource HOBs for all unblocked memory regions.

Parameters
[in]HobBufferThe pointer of new HOB buffer.
[in,out]HobBufferSizeThe total size of the same GUID HOBs when as output.

Definition at line 420 of file MmFoundationHob.c.

◆ MmIplCalculateMaximumSupportAddress()

UINT8 MmIplCalculateMaximumSupportAddress ( VOID  )

Calculate the maximum support address.

Returns
the maximum support address.

Definition at line 618 of file MmFoundationHob.c.

◆ MmIplCopyGuidHob()

VOID MmIplCopyGuidHob ( IN UINT8 *  HobBuffer,
IN OUT UINTN HobBufferSize,
IN EFI_GUID Guid,
IN BOOLEAN  MultiInstances 
)

Copies a data buffer to a newly-built HOB for GUID HOB

This function builds a customized HOB tagged with a GUID for identification, copies the input data to the HOB data field and returns the start address of the GUID HOB data. If new HOB buffer is NULL or the GUID HOB could not found, then ASSERT().

Parameters
[in]HobBufferThe pointer of HOB buffer.
[in,out]HobBufferSizeThe available size of the HOB buffer when as input. The used size of when as output.
[in]GuidThe GUID of the GUID type HOB.
[in]MultiInstancesTRUE indicating copying multiple HOBs with the same Guid.

Definition at line 224 of file MmFoundationHob.c.

◆ MmIplCreateHob()

VOID * MmIplCreateHob ( IN VOID *  Hob,
IN UINT16  HobType,
IN UINT16  HobLength 
)

Add a new HOB to the HOB List.

Parameters
[in]HobThe pointer of new HOB buffer.
[in]HobTypeType of the new HOB.
[in]HobLengthLength of the new HOB to allocate.
Returns
NULL if there is no space to create a hob.
The address point to the new created hob.

Definition at line 36 of file MmFoundationHob.c.

◆ MmIplIs5LevelPagingNeeded()

BOOLEAN MmIplIs5LevelPagingNeeded ( VOID  )

The routine returns TRUE when CPU supports it (CPUID[7,0].ECX.BIT[16] is set) and the max physical address bits is bigger than 48. Because 4-level paging can support to address physical address up to 2^48 - 1, there is no need to enable 5-level paging with max physical address bits <= 48.

Return values
TRUE5-level paging enabling is needed.
FALSE5-level paging enabling is not needed.

Definition at line 579 of file MmFoundationHob.c.