From be720b8d6cc01383b4eba6174c390798e4194491 Mon Sep 17 00:00:00 2001 From: Dun Tan Date: Fri, 11 Apr 2025 13:11:56 +0800 Subject: [PATCH] EmbeddedPkg: Add two new APIs in PrePiHobLib This commit is to add two new APIs in EmbeddedPkg PrePiHobLib: 1.The GetNextMemoryAllocationGuidHob () returns the next instance of the Memory Allocation HOB with the matched GUID from a starting HOB pointer. 2.The TagMemoryAllocationHobWithGuid () searchs the HOB list for the Memory Allocation HOB with a matching base address and set the Name GUID. Then the instance of the tagged Memory Allocation HOB with matched base address is returned. Signed-off-by: Dun Tan --- EmbeddedPkg/Library/PrePiHobLib/Hob.c | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/EmbeddedPkg/Library/PrePiHobLib/Hob.c b/EmbeddedPkg/Library/PrePiHobLib/Hob.c index a394ca00b4..89c5d928af 100644 --- a/EmbeddedPkg/Library/PrePiHobLib/Hob.c +++ b/EmbeddedPkg/Library/PrePiHobLib/Hob.c @@ -866,3 +866,58 @@ BuildMemoryTypeInformationHob ( BuildGuidDataHob (&gEfiMemoryTypeInformationGuid, &Info, sizeof (Info)); } + +/** + Returns the next instance of the memory allocation HOB with the matched GUID from + the starting HOB. + + This function searches the first instance of a HOB from the starting HOB pointer. + Such HOB should satisfy two conditions: + Its HOB type is EFI_HOB_TYPE_MEMORY_ALLOCATION and its GUID Name equals to input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + + If Guid is NULL, then ASSERT(). + If HobStart is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + @param HobStart The starting HOB pointer to search from. + + @retval !NULL The next instance of the Memory Allocation HOB with matched GUID from the starting HOB. + @retval NULL NULL is returned if the matching Memory Allocation HOB is not found. + +**/ +VOID * +EFIAPI +GetNextMemoryAllocationGuidHob ( + IN CONST EFI_GUID *Guid, + IN CONST VOID *HobStart + ) +{ + ASSERT (FALSE); + return NULL; +} + +/** + Search the HOB list for the Memory Allocation HOB with a matching base address + and set the Name GUID. If there does not exist such Memory Allocation HOB in the + HOB list, it will return NULL. + + If Guid is NULL, then ASSERT(). + + @param BaseAddress BaseAddress of Memory Allocation HOB to set Name to Guid. + @param Guid Pointer to the GUID to set in the matching Memory Allocation GUID. + + @retval !NULL The instance of the tagged Memory Allocation HOB with matched base address. + @retval NULL NULL is returned if the matching Memory Allocation HOB is not found. + +**/ +VOID * +EFIAPI +TagMemoryAllocationHobWithGuid ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN CONST EFI_GUID *Guid + ) +{ + ASSERT (FALSE); + return NULL; +}