]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PeiHobLib/HobLib.c
1. Add the fix for the following Bugs:
[mirror_edk2.git] / MdePkg / Library / PeiHobLib / HobLib.c
index 380a735b99f11c5f84217edaf3983ba9dd5150ec..3765d47cdb3d7b4cfe59c516e7c69282934a9c13 100644 (file)
@@ -33,7 +33,7 @@ GetHobList (
   EFI_STATUS            Status;\r
   VOID                  *HobList;\r
 \r
-  Status = PeiCoreGetHobList (&HobList);\r
+  Status = PeiServicesGetHobList (&HobList);\r
   ASSERT_EFI_ERROR (Status);\r
   ASSERT (HobList != NULL);\r
 \r
@@ -187,7 +187,7 @@ InternalPeiCreateHob (
   EFI_STATUS        Status;\r
   VOID              *Hob;\r
 \r
-  Status = PeiCoreCreateHob (Type, Length, &Hob);\r
+  Status = PeiServicesCreateHob (Type, Length, &Hob);\r
   //\r
   // Assume the process of HOB building is always successful.\r
   //\r
@@ -207,7 +207,7 @@ InternalPeiCreateHob (
   @param  ModuleName              The GUID File Name of the module.\r
   @param  MemoryAllocationModule  The 64 bit physical address of the module.\r
   @param  ModuleLength            The length of the module in bytes.\r
-  @param  EntryPoint              The 64 bit physical address of the module\92s entry point.\r
+  @param  EntryPoint              The 64 bit physical address of the module's entry point.\r
 \r
 **/\r
 VOID\r
@@ -228,6 +228,11 @@ BuildModuleHob (
   Hob->MemoryAllocationHeader.MemoryLength      = ModuleLength;\r
   Hob->MemoryAllocationHeader.MemoryType        = EfiBootServicesCode;\r
 \r
+  //\r
+  // Zero the reserved space to match HOB spec\r
+  //\r
+  ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved));\r
+  \r
   CopyGuid (&Hob->ModuleName, ModuleName);\r
   Hob->EntryPoint = EntryPoint;\r
 }\r
@@ -275,7 +280,7 @@ BuildResourceDescriptorHob (
   for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
   If Guid is NULL, then ASSERT().\r
   If there is no additional space for HOB creation, then ASSERT().\r
-  If DataLength > (0x10000 - sizeof (EFI_HOB_TYPE_GUID)), then ASSERT().\r
+  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
 \r
   @param  Guid          The GUID to tag the customized HOB.\r
   @param  DataLength    The size of the data payload for the GUID HOB.\r
@@ -313,7 +318,7 @@ BuildGuidHob (
   If Guid is NULL, then ASSERT().\r
   If Data is NULL and DataLength > 0, then ASSERT().\r
   If there is no additional space for HOB creation, then ASSERT().\r
-  If DataLength > (0x10000 - sizeof (EFI_HOB_TYPE_GUID)), then ASSERT().\r
+  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
 \r
   @param  Guid          The GUID to tag the customized HOB.\r
   @param  Data          The data to be copied into the data field of the GUID HOB.\r
@@ -332,6 +337,8 @@ BuildGuidDataHob (
 {\r
   VOID  *HobData;\r
 \r
+  ASSERT (Data != NULL || DataLength == 0);\r
+\r
   HobData = BuildGuidHob (Guid, DataLength);\r
 \r
   return CopyMem (HobData, Data, DataLength);\r
@@ -416,6 +423,11 @@ BuildCpuHob (
 \r
   Hob->SizeOfMemorySpace = SizeOfMemorySpace;\r
   Hob->SizeOfIoSpace     = SizeOfIoSpace;\r
+\r
+  //\r
+  // Zero the reserved space to match HOB spec\r
+  //\r
+  ZeroMem (Hob->Reserved, sizeof (Hob->Reserved)); \r
 }\r
 \r
 /**\r
@@ -445,6 +457,11 @@ BuildStackHob (
   Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
   Hob->AllocDescriptor.MemoryLength      = Length;\r
   Hob->AllocDescriptor.MemoryType        = EfiConventionalMemory;\r
+\r
+  //\r
+  // Zero the reserved space to match HOB spec\r
+  //\r
+  ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
 }\r
 \r
 /**\r
@@ -476,6 +493,11 @@ BuildBspStoreHob (
   Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
   Hob->AllocDescriptor.MemoryLength      = Length;\r
   Hob->AllocDescriptor.MemoryType        = MemoryType;\r
+\r
+  //\r
+  // Zero the reserved space to match HOB spec\r
+  //\r
+  ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
 }\r
 \r
 /**\r
@@ -507,4 +529,8 @@ BuildMemoryAllocationHob (
   Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
   Hob->AllocDescriptor.MemoryLength      = Length;\r
   Hob->AllocDescriptor.MemoryType        = MemoryType;\r
+  //\r
+  // Zero the reserved space to match HOB spec\r
+  //\r
+  ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
 }\r