Skip to content

Commit

Permalink
StandaloneMmPkg/MmIpl : Add EFI_HOB_HANDOFF_INFO_TABLE to MM HOB list
Browse files Browse the repository at this point in the history
GetBootModeHob function need to add EFI_HOB_HANDOFF_INFO_TABLE
in MM hob data base.

Signed-off-by: Hongbin1 Zhang <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Star Zeng <[email protected]>
Cc: Jiaxin Wu <[email protected]>
Cc: Wei6 Xu <[email protected]>
Cc: Sami Mujawar <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Supreeth Venkatesh <[email protected]>
  • Loading branch information
hongbin123 committed Jan 3, 2025
1 parent dca265a commit 07aadd6
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 8 deletions.
41 changes: 41 additions & 0 deletions StandaloneMmPkg/Drivers/StandaloneMmIplPei/MmFoundationHob.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,3 +1032,44 @@ CreateMmFoundationHobList (
*FoundationHobSize = UsedSize;
return Status;
}

/**
Builds a Handoff Information Table HOB and HOB end
@param MemoryBegin - Start Memory Address.
@param MemoryLength - Length of Memory.
@return EFI_SUCCESS Always success to initialize HOB.
**/
EFI_STATUS
CreateMmHobHandoffInfoTableAndMmHobEnd (
IN EFI_PHYSICAL_ADDRESS MemoryBegin,
IN UINT64 MemoryLength
)
{
EFI_HOB_HANDOFF_INFO_TABLE *Hob;
EFI_HOB_GENERIC_HEADER *HobEnd;

Hob = (VOID *)(UINTN)MemoryBegin;
HobEnd = (EFI_HOB_GENERIC_HEADER *)(UINTN)(MemoryBegin + MemoryLength - sizeof (EFI_HOB_GENERIC_HEADER));
Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
Hob->Header.HobLength = (UINT16)sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
Hob->Header.Reserved = 0;

HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
HobEnd->HobLength = (UINT16)sizeof (EFI_HOB_GENERIC_HEADER);
HobEnd->Reserved = 0;

Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
Hob->BootMode = GetBootModeHob ();

Hob->EfiMemoryTop = 0;
Hob->EfiMemoryBottom = 0;
Hob->EfiFreeMemoryTop = 0;
Hob->EfiFreeMemoryBottom = 0;
Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;

return EFI_SUCCESS;
}
19 changes: 11 additions & 8 deletions StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ CreatMmHobList (
UINTN BufferSize;
UINTN FoundationHobSize;
EFI_HOB_MEMORY_ALLOCATION *MmProfileDataHob;
UINTN HandOfTableSize;

//
// Get platform HOBs
Expand Down Expand Up @@ -336,28 +337,35 @@ CreatMmHobList (
ASSERT (Status == RETURN_BUFFER_TOO_SMALL);
ASSERT (FoundationHobSize != 0);

HandOfTableSize = sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
//
// Final result includes platform HOBs, foundation HOBs and a END node.
//
*HobSize = PlatformHobSize + FoundationHobSize + sizeof (EFI_HOB_GENERIC_HEADER);
*HobSize = HandOfTableSize + PlatformHobSize + FoundationHobSize + sizeof (EFI_HOB_GENERIC_HEADER);
HobList = AllocatePages (EFI_SIZE_TO_PAGES (*HobSize));
ASSERT (HobList != NULL);
if (HobList == NULL) {
DEBUG ((DEBUG_ERROR, "Out of resource to create MM HOBs\n"));
CpuDeadLoop ();
}

//
// Create MmHobHandoffInfoTable
//
Status = CreateMmHobHandoffInfoTable ((UINTN)HobList, *HobSize);
ASSERT_EFI_ERROR (Status);

//
// Get platform HOBs
//
Status = CreateMmPlatformHob (HobList, &PlatformHobSize);
Status = CreateMmPlatformHob ((UINT8 *)HobList + HandOfTableSize, &PlatformHobSize);
ASSERT_EFI_ERROR (Status);

//
// Get foundation HOBs
//
Status = CreateMmFoundationHobList (
(UINT8 *)HobList + PlatformHobSize,
(UINT8 *)HobList + HandOfTableSize + PlatformHobSize,
&FoundationHobSize,
HobList,
PlatformHobSize,
Expand All @@ -372,11 +380,6 @@ CreatMmHobList (
);
ASSERT_EFI_ERROR (Status);

//
// Create MM HOB list end.
//
MmIplCreateHob ((UINT8 *)HobList + PlatformHobSize + FoundationHobSize, EFI_HOB_TYPE_END_OF_HOB_LIST, sizeof (EFI_HOB_GENERIC_HEADER));

return HobList;
}

Expand Down
16 changes: 16 additions & 0 deletions StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,20 @@ BuildMmProfileDataHobInPeiHobList (
VOID
);

/**
Builds a Handoff Information Table HOB and HOB end
@param MemoryBegin - Start Memory Address.
@param MemoryLength - Length of Memory.
@return EFI_SUCCESS Always success to initialize HOB.
**/
EFI_STATUS
CreateMmHobHandoffInfoTableAndMmHobEnd (
IN EFI_PHYSICAL_ADDRESS MemoryBegin,
IN UINT64 MemoryLength
);

#endif

0 comments on commit 07aadd6

Please sign in to comment.