]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/DxeHobLib/HobLib.c
MdePkg/Library/BaseStackCheckLib: Add Null handler for VS2017/ARM
[mirror_edk2.git] / MdePkg / Library / DxeHobLib / HobLib.c
index 9de92ef3bec8664da24e5a37fe1420cda6c15797..ed6262c4b2626e6f58a1d6622c03acc40217f6ca 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   HOB Library implemenation for Dxe Phase.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2017, 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
 http://opensource.org/licenses/bsd-license.php\r
@@ -23,35 +23,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 VOID  *mHobList = NULL;\r
 \r
-/**\r
-  The constructor function caches the pointer to HOB list.\r
-  \r
-  The constructor function gets the start address of HOB list from system configuration table.\r
-  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
-\r
-  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
-  @param  SystemTable   A pointer to the EFI System Table.\r
-  \r
-  @retval EFI_SUCCESS   The constructor successfully gets HobList.\r
-  @retval Other value   The constructor can't get HobList.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HobLibConstructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList);\r
-  ASSERT_EFI_ERROR (Status);\r
-  ASSERT (mHobList != NULL);\r
-\r
-  return Status;\r
-}\r
-\r
 /**\r
   Returns the pointer to the HOB list.\r
 \r
@@ -62,9 +33,11 @@ HobLibConstructor (
   Since the System Configuration Table does not exist that the time the DXE Core is \r
   launched, the DXE Core uses a global variable from the DXE Core Entry Point Library \r
   to manage the pointer to the HOB list.\r
-  \r
+\r
   If the pointer to the HOB list is NULL, then ASSERT().\r
-  \r
+\r
+  This function also caches the pointer to the HOB list retrieved.\r
+\r
   @return The pointer to the HOB list.\r
 \r
 **/\r
@@ -74,10 +47,38 @@ GetHobList (
   VOID\r
   )\r
 {\r
-  ASSERT (mHobList != NULL);\r
+  EFI_STATUS  Status;\r
+\r
+  if (mHobList == NULL) {\r
+    Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList);\r
+    ASSERT_EFI_ERROR (Status);\r
+    ASSERT (mHobList != NULL);\r
+  }\r
   return mHobList;\r
 }\r
 \r
+/**\r
+  The constructor function caches the pointer to HOB list by calling GetHobList()\r
+  and will always return EFI_SUCCESS. \r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The constructor successfully gets HobList.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HobLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  GetHobList ();\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   Returns the next instance of a HOB type from the starting HOB.\r
 \r
@@ -152,7 +153,7 @@ GetFirstHob (
   its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. \r
   If there does not exist such HOB from the starting HOB pointer, it will return NULL. \r
   Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
-  to extract the data section and its size info respectively.\r
+  to extract the data section and its size information, respectively.\r
   In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
   unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
   caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
@@ -193,7 +194,7 @@ GetNextGuidHob (
   its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r
   If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r
   Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
-  to extract the data section and its size info respectively.\r
+  to extract the data section and its size information, respectively.\r
   \r
   If the pointer to the HOB list is NULL, then ASSERT().\r
   If Guid is NULL, then ASSERT().\r
@@ -272,6 +273,38 @@ BuildModuleHob (
   ASSERT (FALSE);\r
 }\r
 \r
+/**\r
+  Builds a HOB that describes a chunk of system memory with Owner GUID.\r
+\r
+  This function builds a HOB that describes a chunk of system memory.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  \r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  ResourceType        The type of resource described by this HOB.\r
+  @param  ResourceAttribute   The resource attributes of the memory described by this HOB.\r
+  @param  PhysicalStart       The 64 bit physical address of memory described by this HOB.\r
+  @param  NumberOfBytes       The length of the memory described by this HOB in bytes.\r
+  @param  OwnerGUID           GUID for the owner of this resource.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildResourceDescriptorWithOwnerHob (\r
+  IN EFI_RESOURCE_TYPE            ResourceType,\r
+  IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,\r
+  IN EFI_PHYSICAL_ADDRESS         PhysicalStart,\r
+  IN UINT64                       NumberOfBytes,\r
+  IN EFI_GUID                     *OwnerGUID\r
+  )\r
+{\r
+  //\r
+  // PEI HOB is read only for DXE phase\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
+\r
 /**\r
   Builds a HOB that describes a chunk of system memory.\r
 \r
@@ -314,12 +347,14 @@ BuildResourceDescriptorHob (
   \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_GUID_TYPE)), then ASSERT().\r
+  If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
+  HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.\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
 \r
-  @return The start address of GUID HOB data.\r
+  @retval  NULL         The GUID HOB could not be allocated.\r
+  @retval  others       The start address of GUID HOB data.\r
 \r
 **/\r
 VOID *\r
@@ -350,13 +385,15 @@ 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_GUID_TYPE)), then ASSERT().\r
+  If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
+  HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.\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
   @param  DataLength    The size of the data payload for the GUID HOB.\r
 \r
-  @return The start address of GUID HOB data.\r
+  @retval  NULL         The GUID HOB could not be allocated.\r
+  @retval  others       The start address of GUID HOB data.\r
 \r
 **/\r
 VOID *\r
@@ -382,6 +419,7 @@ BuildGuidDataHob (
   for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
   \r
   If there is no additional space for HOB creation, then ASSERT().\r
+  If the FvImage buffer is not at its required alignment, then ASSERT().\r
 \r
   @param  BaseAddress   The base address of the Firmware Volume.\r
   @param  Length        The size of the Firmware Volume in bytes.\r
@@ -408,6 +446,7 @@ BuildFvHob (
   for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
   \r
   If there is no additional space for HOB creation, then ASSERT().\r
+  If the FvImage buffer is not at its required alignment, then ASSERT().\r
 \r
   @param  BaseAddress   The base address of the Firmware Volume.\r
   @param  Length        The size of the Firmware Volume in bytes.\r
@@ -427,6 +466,40 @@ BuildFv2Hob (
   ASSERT (FALSE);\r
 }\r
 \r
+/**\r
+  Builds a EFI_HOB_TYPE_FV3 HOB.\r
+\r
+  This function builds a EFI_HOB_TYPE_FV3 HOB.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+  If the FvImage buffer is not at its required alignment, then ASSERT().\r
+\r
+  @param BaseAddress            The base address of the Firmware Volume.\r
+  @param Length                 The size of the Firmware Volume in bytes.\r
+  @param AuthenticationStatus   The authentication status.\r
+  @param ExtractedFv            TRUE if the FV was extracted as a file within\r
+                                another firmware volume. FALSE otherwise.\r
+  @param FvName                 The name of the Firmware Volume.\r
+                                Valid only if IsExtractedFv is TRUE.\r
+  @param FileName               The name of the file.\r
+                                Valid only if IsExtractedFv is TRUE.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildFv3Hob (\r
+  IN          EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN          UINT64                      Length,\r
+  IN          UINT32                      AuthenticationStatus,\r
+  IN          BOOLEAN                     ExtractedFv,\r
+  IN CONST    EFI_GUID                    *FvName, OPTIONAL\r
+  IN CONST    EFI_GUID                    *FileName OPTIONAL\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
 \r
 /**\r
   Builds a Capsule Volume HOB.\r
@@ -562,28 +635,3 @@ BuildMemoryAllocationHob (
   //\r
   ASSERT (FALSE);\r
 }\r
-\r
-/**\r
-  Builds an UEFI Capsule HOB.\r
-\r
-  This function builds an UEFI Capsule HOB.\r
-  It can only be invoked during PEI phase;\r
-  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
-  If there is no additional space for HOB creation, then ASSERT().\r
-\r
-  @param  BaseAddress   The physical memory-mapped base address of an UEFI capsule.\r
-  @param  Length        The length of the contiguous memory in bytes.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BuildCapsuleHob (\r
-  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
-  IN UINT64                      Length\r
-  )\r
-{\r
-  //\r
-  // PEI HOB is read only for DXE phase\r
-  //\r
-  ASSERT (FALSE);\r
-}\r