public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Sughosh Ganu <sughosh.ganu@arm.com>
To: edk2-devel@lists.01.org
Cc: Achin Gupta <achin.gupta@arm.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Supreeth Venkatesh <supreeth.venkatesh@arm.com>,
	Sughosh Ganu <sughosh.ganu@arm.com>
Subject: [PATCH v2 05/10] StandaloneMmPkg/HobLib: Add HOB Library for management mode.
Date: Fri, 13 Jul 2018 20:35:25 +0530	[thread overview]
Message-ID: <1531494330-1280-6-git-send-email-sughosh.ganu@arm.com> (raw)
In-Reply-To: <1531494330-1280-1-git-send-email-sughosh.ganu@arm.com>

From: Supreeth Venkatesh <supreeth.venkatesh@arm.com>

The Standalone MM environment is initialized during the SEC phase on ARM
Standard Platforms. The MM Core driver implements an entry point module
which is architecture specific and runs prior to the generic core driver
code. The former creates a Hob list that the latter consumes. This
happens in the same phase.

This patch implements a Hob library that can be used by the entry point
module to produce a Hob list and by the core driver code to consume it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Signed-off-by: Sughosh Ganu <sughosh.ganu@arm.com>
---
 .../AArch64/StandaloneMmCoreHobLibInternal.c       |  64 +++
 .../StandaloneMmCoreHobLib.c                       | 433 +++++++++++----------
 .../StandaloneMmCoreHobLib.inf                     |  47 +++
 3 files changed, 330 insertions(+), 214 deletions(-)
 create mode 100644 StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/StandaloneMmCoreHobLibInternal.c
 copy MdePkg/Library/DxeCoreHobLib/HobLib.c => StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.c (67%)
 create mode 100644 StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf

diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/StandaloneMmCoreHobLibInternal.c b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/StandaloneMmCoreHobLibInternal.c
new file mode 100644
index 000000000000..90e1cd479cb2
--- /dev/null
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/StandaloneMmCoreHobLibInternal.c
@@ -0,0 +1,64 @@
+/** @file
+  HOB Library implementation for Standalone MM Core.
+
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.<BR>
+
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution.  The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiMm.h>
+
+#include <Library/HobLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+
+#include <Guid/MemoryAllocationHob.h>
+
+//
+// Cache copy of HobList pointer.
+//
+extern VOID *gHobList;
+
+EFI_HOB_HANDOFF_INFO_TABLE*
+HobConstructor (
+  IN VOID   *EfiMemoryBegin,
+  IN UINTN  EfiMemoryLength,
+  IN VOID   *EfiFreeMemoryBottom,
+  IN VOID   *EfiFreeMemoryTop
+  )
+{
+  EFI_HOB_HANDOFF_INFO_TABLE  *Hob;
+  EFI_HOB_GENERIC_HEADER      *HobEnd;
+
+  Hob    = EfiFreeMemoryBottom;
+  HobEnd = (EFI_HOB_GENERIC_HEADER *)(Hob+1);
+
+  Hob->Header.HobType     = EFI_HOB_TYPE_HANDOFF;
+  Hob->Header.HobLength   = sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
+  Hob->Header.Reserved    = 0;
+
+  HobEnd->HobType     = EFI_HOB_TYPE_END_OF_HOB_LIST;
+  HobEnd->HobLength   = sizeof (EFI_HOB_GENERIC_HEADER);
+  HobEnd->Reserved    = 0;
+
+  Hob->Version             = EFI_HOB_HANDOFF_TABLE_VERSION;
+  Hob->BootMode            = BOOT_WITH_FULL_CONFIGURATION;
+
+  Hob->EfiMemoryTop        = (UINTN)EfiMemoryBegin + EfiMemoryLength;
+  Hob->EfiMemoryBottom     = (UINTN)EfiMemoryBegin;
+  Hob->EfiFreeMemoryTop    = (UINTN)EfiFreeMemoryTop;
+  Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)(HobEnd+1);
+  Hob->EfiEndOfHobList     = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
+
+  gHobList = Hob;
+
+  return Hob;
+}
diff --git a/MdePkg/Library/DxeCoreHobLib/HobLib.c b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.c
similarity index 67%
copy from MdePkg/Library/DxeCoreHobLib/HobLib.c
copy to StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.c
index 6aac20dd4d8d..e2fcda813d1b 100644
--- a/MdePkg/Library/DxeCoreHobLib/HobLib.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.c
@@ -1,7 +1,9 @@
 /** @file
-  HOB Library implementation for DxeCore driver.
+  HOB Library implementation for Standalone MM Core.
+
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.<BR>
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -12,24 +14,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 
-#include <PiDxe.h>
+#include <PiMm.h>
 
 #include <Library/HobLib.h>
 #include <Library/DebugLib.h>
 #include <Library/BaseMemoryLib.h>
-#include <Library/DxeCoreEntryPoint.h>
+
+#include <Guid/MemoryAllocationHob.h>
+
+//
+// Cache copy of HobList pointer.
+//
+VOID *gHobList = NULL;
 
 /**
   Returns the pointer to the HOB list.
 
   This function returns the pointer to first HOB in the list.
-  For PEI phase, the PEI service GetHobList() can be used to retrieve the pointer
-  to the HOB list.  For the DXE phase, the HOB list pointer can be retrieved through
-  the EFI System Table by looking up theHOB list GUID in the System Configuration Table.
-  Since the System Configuration Table does not exist that the time the DXE Core is
-  launched, the DXE Core uses a global variable from the DXE Core Entry Point Library
-  to manage the pointer to the HOB list.
-
   If the pointer to the HOB list is NULL, then ASSERT().
 
   @return The pointer to the HOB list.
@@ -205,16 +206,51 @@ GetBootModeHob (
 
   HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList ();
 
-  return  HandOffHob->BootMode;
+  return HandOffHob->BootMode;
+}
+
+VOID *
+CreateHob (
+  IN  UINT16    HobType,
+  IN  UINT16    HobLength
+  )
+{
+  EFI_HOB_HANDOFF_INFO_TABLE  *HandOffHob;
+  EFI_HOB_GENERIC_HEADER      *HobEnd;
+  EFI_PHYSICAL_ADDRESS        FreeMemory;
+  VOID                        *Hob;
+
+  HandOffHob = GetHobList ();
+
+  HobLength = (UINT16)((HobLength + 0x7) & (~0x7));
+
+  FreeMemory = HandOffHob->EfiFreeMemoryTop - HandOffHob->EfiFreeMemoryBottom;
+
+  if (FreeMemory < HobLength) {
+    return NULL;
+  }
+
+  Hob = (VOID*) (UINTN) HandOffHob->EfiEndOfHobList;
+  ((EFI_HOB_GENERIC_HEADER*) Hob)->HobType = HobType;
+  ((EFI_HOB_GENERIC_HEADER*) Hob)->HobLength = HobLength;
+  ((EFI_HOB_GENERIC_HEADER*) Hob)->Reserved = 0;
+
+  HobEnd = (EFI_HOB_GENERIC_HEADER*) ((UINTN)Hob + HobLength);
+  HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
+
+  HobEnd->HobType   = EFI_HOB_TYPE_END_OF_HOB_LIST;
+  HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);
+  HobEnd->Reserved  = 0;
+  HobEnd++;
+  HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
+
+  return Hob;
 }
 
 /**
   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;
-  for DXE phase, it will ASSERT() because PEI HOB is read-only for DXE phase.
-
   If ModuleName is NULL, then ASSERT().
   If there is no additional space for HOB creation, then ASSERT().
 
@@ -233,51 +269,31 @@ BuildModuleHob (
   IN EFI_PHYSICAL_ADDRESS   EntryPoint
   )
 {
-  //
-  // PEI HOB is read only for DXE phase
-  //
-  ASSERT (FALSE);
-}
+  EFI_HOB_MEMORY_ALLOCATION_MODULE  *Hob;
 
-/**
-  Builds a HOB that describes a chunk of system memory with Owner GUID.
+  ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
+          ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));
 
-  This function builds a HOB that describes a chunk of system memory.
-  It can only be invoked during PEI phase;
-  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+  Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
 
-  If there is no additional space for HOB creation, then ASSERT().
+  CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);
+  Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;
+  Hob->MemoryAllocationHeader.MemoryLength      = ModuleLength;
+  Hob->MemoryAllocationHeader.MemoryType        = EfiBootServicesCode;
 
-  @param  ResourceType        The type of resource described by this HOB.
-  @param  ResourceAttribute   The resource attributes of the memory described by this HOB.
-  @param  PhysicalStart       The 64 bit physical address of memory described by this HOB.
-  @param  NumberOfBytes       The length of the memory described by this HOB in bytes.
-  @param  OwnerGUID           GUID for the owner of this resource.
-
-**/
-VOID
-EFIAPI
-BuildResourceDescriptorWithOwnerHob (
-  IN EFI_RESOURCE_TYPE            ResourceType,
-  IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,
-  IN EFI_PHYSICAL_ADDRESS         PhysicalStart,
-  IN UINT64                       NumberOfBytes,
-  IN EFI_GUID                     *OwnerGUID
-  )
-{
   //
-  // PEI HOB is read only for DXE phase
+  // Zero the reserved space to match HOB spec
   //
-  ASSERT (FALSE);
+  ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved));
+
+  CopyGuid (&Hob->ModuleName, ModuleName);
+  Hob->EntryPoint = EntryPoint;
 }
 
 /**
   Builds a HOB that describes a chunk of system memory.
 
   This function builds a HOB that describes a chunk of system memory.
-  It can only be invoked during PEI phase;
-  for DXE phase, it will ASSERT() because PEI HOB is read-only for DXE phase.
-
   If there is no additional space for HOB creation, then ASSERT().
 
   @param  ResourceType        The type of resource described by this HOB.
@@ -295,32 +311,31 @@ BuildResourceDescriptorHob (
   IN UINT64                       NumberOfBytes
   )
 {
-  //
-  // PEI HOB is read only for DXE phase
-  //
-  ASSERT (FALSE);
+  EFI_HOB_RESOURCE_DESCRIPTOR  *Hob;
+
+  Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));
+  ASSERT (Hob != NULL);
+
+  Hob->ResourceType      = ResourceType;
+  Hob->ResourceAttribute = ResourceAttribute;
+  Hob->PhysicalStart     = PhysicalStart;
+  Hob->ResourceLength    = NumberOfBytes;
 }
 
 /**
-  Builds a customized HOB tagged with a GUID for identification and returns
-  the start address of GUID HOB data.
+  Builds a GUID HOB with a certain data length.
 
   This function builds a customized HOB tagged with a GUID for identification
   and returns the start address of GUID HOB data so that caller can fill the customized data.
   The HOB Header and Name field is already stripped.
-  It can only be invoked during PEI phase.
-  For DXE phase, it will ASSERT() because PEI HOB is read-only for DXE phase.
-
   If Guid is NULL, then ASSERT().
   If there is no additional space for HOB creation, then ASSERT().
-  If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
-  HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
+  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
 
   @param  Guid          The GUID to tag the customized HOB.
   @param  DataLength    The size of the data payload for the GUID HOB.
 
-  @retval  NULL         The GUID HOB could not be allocated.
-  @retval  others       The start address of GUID HOB data.
+  @return The start address of GUID HOB data.
 
 **/
 VOID *
@@ -330,36 +345,35 @@ BuildGuidHob (
   IN UINTN                       DataLength
   )
 {
+  EFI_HOB_GUID_TYPE *Hob;
+
   //
-  // PEI HOB is read only for DXE phase
+  // Make sure that data length is not too long.
   //
-  ASSERT (FALSE);
-  return NULL;
+  ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
+
+  Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));
+  CopyGuid (&Hob->Name, Guid);
+  return Hob + 1;
 }
 
+
 /**
-  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.
+  Copies a data buffer to a newly-built HOB.
 
-  This function builds a customized HOB tagged with a GUID for identification and copies the input
-  data to the HOB data field and returns the start address of the GUID HOB data.  It can only be
-  invoked during PEI phase; for DXE phase, it will ASSERT() because PEI HOB is read-only for DXE phase.
+  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.
   The HOB Header and Name field is already stripped.
-  It can only be invoked during PEI phase.
-  For DXE phase, it will ASSERT() because PEI HOB is read-only for DXE phase.
-
   If Guid is NULL, then ASSERT().
   If Data is NULL and DataLength > 0, then ASSERT().
   If there is no additional space for HOB creation, then ASSERT().
-  If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
-  HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
+  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
 
   @param  Guid          The GUID to tag the customized HOB.
   @param  Data          The data to be copied into the data field of the GUID HOB.
   @param  DataLength    The size of the data payload for the GUID HOB.
 
-  @retval  NULL         The GUID HOB could not be allocated.
-  @retval  others       The start address of GUID HOB data.
+  @return The start address of GUID HOB data.
 
 **/
 VOID *
@@ -370,22 +384,20 @@ BuildGuidDataHob (
   IN UINTN                       DataLength
   )
 {
-  //
-  // PEI HOB is read only for DXE phase
-  //
-  ASSERT (FALSE);
-  return NULL;
+  VOID  *HobData;
+
+  ASSERT (Data != NULL || DataLength == 0);
+
+  HobData = BuildGuidHob (Guid, DataLength);
+
+  return CopyMem (HobData, Data, DataLength);
 }
 
 /**
   Builds a Firmware Volume HOB.
 
   This function builds a Firmware Volume HOB.
-  It can only be invoked during PEI phase;
-  for DXE phase, it will ASSERT() because PEI HOB is read-only for DXE phase.
-
   If there is no additional space for HOB creation, then ASSERT().
-  If the FvImage buffer is not at its required alignment, then ASSERT().
 
   @param  BaseAddress   The base address of the Firmware Volume.
   @param  Length        The size of the Firmware Volume in bytes.
@@ -398,25 +410,24 @@ BuildFvHob (
   IN UINT64                      Length
   )
 {
-  //
-  // PEI HOB is read only for DXE phase
-  //
-  ASSERT (FALSE);
+  EFI_HOB_FIRMWARE_VOLUME  *Hob;
+
+  Hob = CreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));
+
+  Hob->BaseAddress = BaseAddress;
+  Hob->Length      = Length;
 }
 
+
 /**
   Builds a EFI_HOB_TYPE_FV2 HOB.
 
   This function builds a EFI_HOB_TYPE_FV2 HOB.
-  It can only be invoked during PEI phase;
-  for DXE phase, it will ASSERT() because PEI HOB is read-only for DXE phase.
-
   If there is no additional space for HOB creation, then ASSERT().
-  If the FvImage buffer is not at its required alignment, then ASSERT().
 
   @param  BaseAddress   The base address of the Firmware Volume.
   @param  Length        The size of the Firmware Volume in bytes.
-  @param  FvName        The name of the Firmware Volume.
+  @param  FvName       The name of the Firmware Volume.
   @param  FileName      The name of the file.
 
 **/
@@ -429,78 +440,21 @@ BuildFv2Hob (
   IN CONST    EFI_GUID                    *FileName
   )
 {
-  ASSERT (FALSE);
-}
-
-/**
-  Builds a EFI_HOB_TYPE_FV3 HOB.
-
-  This function builds a EFI_HOB_TYPE_FV3 HOB.
-  It can only be invoked during PEI phase;
-  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+  EFI_HOB_FIRMWARE_VOLUME2  *Hob;
 
-  If there is no additional space for HOB creation, then ASSERT().
-  If the FvImage buffer is not at its required alignment, then ASSERT().
+  Hob = CreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2));
 
-  @param BaseAddress            The base address of the Firmware Volume.
-  @param Length                 The size of the Firmware Volume in bytes.
-  @param AuthenticationStatus   The authentication status.
-  @param ExtractedFv            TRUE if the FV was extracted as a file within
-                                another firmware volume. FALSE otherwise.
-  @param FvName                 The name of the Firmware Volume.
-                                Valid only if IsExtractedFv is TRUE.
-  @param FileName               The name of the file.
-                                Valid only if IsExtractedFv is TRUE.
-
-**/
-VOID
-EFIAPI
-BuildFv3Hob (
-  IN          EFI_PHYSICAL_ADDRESS        BaseAddress,
-  IN          UINT64                      Length,
-  IN          UINT32                      AuthenticationStatus,
-  IN          BOOLEAN                     ExtractedFv,
-  IN CONST    EFI_GUID                    *FvName, OPTIONAL
-  IN CONST    EFI_GUID                    *FileName OPTIONAL
-  )
-{
-  ASSERT (FALSE);
+  Hob->BaseAddress = BaseAddress;
+  Hob->Length      = Length;
+  CopyGuid (&Hob->FvName, FvName);
+  CopyGuid (&Hob->FileName, FileName);
 }
 
-/**
-  Builds a Capsule Volume HOB.
-
-  This function builds a Capsule Volume HOB.
-  It can only be invoked during PEI phase;
-  for DXE phase, it will ASSERT() because PEI HOB is read-only for DXE phase.
-
-  If the platform does not support Capsule Volume HOBs, then ASSERT().
-  If there is no additional space for HOB creation, then ASSERT().
-
-  @param  BaseAddress   The base address of the Capsule Volume.
-  @param  Length        The size of the Capsule Volume in bytes.
-
-**/
-VOID
-EFIAPI
-BuildCvHob (
-  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
-  IN UINT64                      Length
-  )
-{
-  //
-  // PEI HOB is read only for DXE phase
-  //
-  ASSERT (FALSE);
-}
 
 /**
   Builds a HOB for the CPU.
 
   This function builds a HOB for the CPU.
-  It can only be invoked during PEI phase;
-  for DXE phase, it will ASSERT() because PEI HOB is read-only for DXE phase.
-
   If there is no additional space for HOB creation, then ASSERT().
 
   @param  SizeOfMemorySpace   The maximum physical memory addressability of the processor.
@@ -514,73 +468,23 @@ BuildCpuHob (
   IN UINT8                       SizeOfIoSpace
   )
 {
-  //
-  // PEI HOB is read only for DXE phase
-  //
-  ASSERT (FALSE);
-}
-
-/**
-  Builds a HOB for the Stack.
-
-  This function builds a HOB for the stack.
-  It can only be invoked during PEI phase;
-  for DXE phase, it will ASSERT() because PEI HOB is read-only for DXE phase.
-
-  If there is no additional space for HOB creation, then ASSERT().
-
-  @param  BaseAddress   The 64 bit physical address of the Stack.
-  @param  Length        The length of the stack in bytes.
-
-**/
-VOID
-EFIAPI
-BuildStackHob (
-  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
-  IN UINT64                      Length
-  )
-{
-  //
-  // PEI HOB is read only for DXE phase
-  //
-  ASSERT (FALSE);
-}
-
-/**
-  Builds a HOB for the BSP store.
-
-  This function builds a HOB for BSP store.
-  It can only be invoked during PEI phase;
-  for DXE phase, it will ASSERT() because PEI HOB is read-only for DXE phase.
+  EFI_HOB_CPU  *Hob;
 
-  If there is no additional space for HOB creation, then ASSERT().
+  Hob = CreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));
 
-  @param  BaseAddress   The 64 bit physical address of the BSP.
-  @param  Length        The length of the BSP store in bytes.
-  @param  MemoryType    Type of memory allocated by this HOB.
+  Hob->SizeOfMemorySpace = SizeOfMemorySpace;
+  Hob->SizeOfIoSpace     = SizeOfIoSpace;
 
-**/
-VOID
-EFIAPI
-BuildBspStoreHob (
-  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
-  IN UINT64                      Length,
-  IN EFI_MEMORY_TYPE             MemoryType
-  )
-{
   //
-  // PEI HOB is read only for DXE phase
+  // Zero the reserved space to match HOB spec
   //
-  ASSERT (FALSE);
+  ZeroMem (Hob->Reserved, sizeof (Hob->Reserved));
 }
 
 /**
   Builds a HOB for the memory allocation.
 
   This function builds a HOB for the memory allocation.
-  It can only be invoked during PEI phase;
-  for DXE phase, it will ASSERT() because PEI HOB is read-only for DXE phase.
-
   If there is no additional space for HOB creation, then ASSERT().
 
   @param  BaseAddress   The 64 bit physical address of the memory.
@@ -596,8 +500,109 @@ BuildMemoryAllocationHob (
   IN EFI_MEMORY_TYPE             MemoryType
   )
 {
+  EFI_HOB_MEMORY_ALLOCATION  *Hob;
+
+  ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
+          ((Length & (EFI_PAGE_SIZE - 1)) == 0));
+
+  Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
+
+  ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));
+  Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
+  Hob->AllocDescriptor.MemoryLength      = Length;
+  Hob->AllocDescriptor.MemoryType        = MemoryType;
   //
-  // PEI HOB is read only for DXE phase
+  // Zero the reserved space to match HOB spec
   //
+  ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));
+}
+
+/**
+  Builds a HOB that describes a chunk of system memory with Owner GUID.
+
+  This function builds a HOB that describes a chunk of system memory.
+  If there is no additional space for HOB creation, then ASSERT().
+
+  @param  ResourceType        The type of resource described by this HOB.
+  @param  ResourceAttribute   The resource attributes of the memory described by this HOB.
+  @param  PhysicalStart       The 64 bit physical address of memory described by this HOB.
+  @param  NumberOfBytes       The length of the memory described by this HOB in bytes.
+  @param  OwnerGUID           GUID for the owner of this resource.
+
+**/
+VOID
+EFIAPI
+BuildResourceDescriptorWithOwnerHob (
+  IN EFI_RESOURCE_TYPE            ResourceType,
+  IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,
+  IN EFI_PHYSICAL_ADDRESS         PhysicalStart,
+  IN UINT64                       NumberOfBytes,
+  IN EFI_GUID                     *OwnerGUID
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Builds a Capsule Volume HOB.
+
+  This function builds a Capsule Volume HOB.
+  If the platform does not support Capsule Volume HOBs, then ASSERT().
+  If there is no additional space for HOB creation, then ASSERT().
+
+  @param  BaseAddress   The base address of the Capsule Volume.
+  @param  Length        The size of the Capsule Volume in bytes.
+
+**/
+VOID
+EFIAPI
+BuildCvHob (
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
+  IN UINT64                      Length
+  )
+{
+  ASSERT (FALSE);
+}
+
+
+/**
+  Builds a HOB for the BSP store.
+
+  This function builds a HOB for BSP store.
+  If there is no additional space for HOB creation, then ASSERT().
+
+  @param  BaseAddress   The 64 bit physical address of the BSP.
+  @param  Length        The length of the BSP store in bytes.
+  @param  MemoryType    Type of memory allocated by this HOB.
+
+**/
+VOID
+EFIAPI
+BuildBspStoreHob (
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
+  IN UINT64                      Length,
+  IN EFI_MEMORY_TYPE             MemoryType
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Builds a HOB for the Stack.
+
+  This function builds a HOB for the stack.
+  If there is no additional space for HOB creation, then ASSERT().
+
+  @param  BaseAddress   The 64 bit physical address of the Stack.
+  @param  Length        The length of the stack in bytes.
+
+**/
+VOID
+EFIAPI
+BuildStackHob (
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
+  IN UINT64                      Length
+  )
+{
   ASSERT (FALSE);
 }
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf
new file mode 100644
index 000000000000..db19d3c926e8
--- /dev/null
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf
@@ -0,0 +1,47 @@
+## @file
+# Instance of HOB Library for Standalone MM Core.
+#
+# HOB Library implementation for the Standalone MM Core. Does not have a constructor.
+#  Uses gHobList defined in the Standalone MM Core Entry Point Library.
+#
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution. The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php.
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001A
+  BASE_NAME                      = HobLib
+  FILE_GUID                      = CF56EF2C-68D8-4BD5-9A8B-8A7BFCFF751C
+  MODULE_TYPE                    = MM_CORE_STANDALONE
+  VERSION_STRING                 = 1.0
+  PI_SPECIFICATION_VERSION       = 0x00010032
+  LIBRARY_CLASS                  = HobLib|MM_CORE_STANDALONE MM_STANDALONE
+
+#
+#  VALID_ARCHITECTURES           = AARCH64
+#
+[Sources.Common]
+  StandaloneMmCoreHobLib.c
+
+[Sources.AARCH64]
+  AArch64/StandaloneMmCoreHobLibInternal.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+
+[LibraryClasses]
+  BaseMemoryLib
+  DebugLib
+
+[Guids]
+  gEfiHobListGuid                               ## CONSUMES  ## SystemTable
-- 
2.7.4



  parent reply	other threads:[~2018-07-13 15:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 15:05 [PATCH v2 00/10] Standalone Management Mode Core Interface for AARCH64 Platforms Sughosh Ganu
2018-07-13 15:05 ` [PATCH v2 01/10] StandaloneMmPkg: Delete StandaloneMmPkg file Sughosh Ganu
2018-07-13 15:05 ` [PATCH v2 02/10] StandaloneMmPkg/FvLib: Add a common FV Library for management mode Sughosh Ganu
2018-07-13 15:05 ` [PATCH v2 03/10] StandaloneMmPkg/MemLib: Add Standalone MM instance of memory check library Sughosh Ganu
2018-07-13 15:05 ` [PATCH v2 04/10] StandaloneMmPkg/MemoryAllocationLib: Add MM memory allocation library Sughosh Ganu
2018-07-13 15:05 ` Sughosh Ganu [this message]
2018-07-13 15:05 ` [PATCH v2 06/10] StandaloneMmPkg: MM driver entry point library Sughosh Ganu
2018-07-13 15:05 ` [PATCH v2 07/10] StandaloneMmPkg/Core: Implementation of Standalone MM Core Module Sughosh Ganu
2018-07-13 15:05 ` [PATCH v2 08/10] StandaloneMmPkg: Add an AArch64 specific entry point library Sughosh Ganu
2018-07-19 19:03   ` Achin Gupta
2018-07-13 15:05 ` [PATCH v2 09/10] StandaloneMmPkg: Add CPU driver suitable for ARM Platforms Sughosh Ganu
2018-07-19 19:05   ` Achin Gupta
2018-07-23 19:27     ` Supreeth Venkatesh
2018-07-13 15:05 ` [PATCH v2 10/10] StandaloneMmPkg: Describe the declaration and definition files Sughosh Ganu
2018-07-20  3:07 ` [PATCH v2 00/10] Standalone Management Mode Core Interface for AARCH64 Platforms Yao, Jiewen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1531494330-1280-6-git-send-email-sughosh.ganu@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox