]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PeiHobLib/HobLib.c
MdePkg/IntelFrameworkPkg HobLib: Add BuildResourceDescriptorWithOwnerHob() API.
[mirror_edk2.git] / MdePkg / Library / PeiHobLib / HobLib.c
index 0586ba86c0b4b9755b8dd4a238fb65854a3eff94..a608325c6555c061a63f064cd9eaccac5d99d6b1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provide Hob Library functions for Pei phase.\r
 \r
-Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -300,6 +300,46 @@ BuildModuleHob (
   Hob->EntryPoint = EntryPoint;\r
 }\r
 \r
+/**
+  Builds a HOB that describes a chunk of system memory with Owner GUID.\r
+
+  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.
+  
+  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.\r
+
+**/
+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
+  )
+{
+  EFI_HOB_RESOURCE_DESCRIPTOR  *Hob;
+  EFI_STATUS                    Status;
+
+  Status = PeiServicesCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR), (void **)&Hob);
+  ASSERT_EFI_ERROR (Status);
+
+  Hob->ResourceType      = ResourceType;
+  Hob->ResourceAttribute = ResourceAttribute;
+  Hob->PhysicalStart     = PhysicalStart;
+  Hob->ResourceLength    = NumberOfBytes;
+
+  CopyGuid (&Hob->Owner, OwnerGUID);
+}\r
+\r
 /**\r
   Builds a HOB that describes a chunk of system memory.\r
 \r
@@ -335,6 +375,7 @@ BuildResourceDescriptorHob (
   Hob->ResourceAttribute = ResourceAttribute;\r
   Hob->PhysicalStart     = PhysicalStart;\r
   Hob->ResourceLength    = NumberOfBytes;\r
+  ZeroMem (&(Hob->Owner), sizeof (EFI_GUID));\r
 }\r
 \r
 /**\r