diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c index 68f63f3c64..1dc610d697 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c @@ -6,3 +6,42 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include "PiSmmCpuCommon.h" + +/** + Get SmmProfileData. + + @param[in, out] Size Return Size of SmmProfileData. + + @return Address of SmmProfileData + +**/ +EFI_PHYSICAL_ADDRESS +GetSmmProfileData ( + IN OUT UINT64 *Size + ) +{ + EFI_PEI_HOB_POINTERS SmmProfileDataHob; + + ASSERT (Size != NULL); + + // + // Get Smm Profile Base from Memory Allocation HOB + // + SmmProfileDataHob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION); + while (SmmProfileDataHob.Raw != NULL) { + // + // Find gMmProfileDataHobGuid + // + if (CompareGuid (&SmmProfileDataHob.MemoryAllocation->AllocDescriptor.Name, &gMmProfileDataHobGuid)) { + break; + } + + SmmProfileDataHob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (SmmProfileDataHob)); + } + + ASSERT (SmmProfileDataHob.Raw != NULL); + + *Size = SmmProfileDataHob.MemoryAllocation->AllocDescriptor.MemoryLength; + + return SmmProfileDataHob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress; +} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h index 4b0d5fb08b..7f11429e50 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h @@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include