]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg DxeHobLib: Make GetHobList working before Constructor is called
authorStar Zeng <star.zeng@intel.com>
Mon, 16 Jan 2017 08:07:53 +0000 (16:07 +0800)
committerStar Zeng <star.zeng@intel.com>
Fri, 20 Jan 2017 07:39:23 +0000 (15:39 +0800)
The latest PiSmmCore driver added several debug messages in the
function SmmAddMemoryRegion in Page.c. The function SmmAddMemoryRegion
is called by the library constructor
PiSmmCoreMemoryAllocationLibConstructor.

When PiSmmCoreMemoryAllocationLibConstructor is executed, the
constructor of DxeHobLib (HobLibConstructor in HobLib.c) is not
executed yet. But platform instance of DebugLib may need get hob
before printing any message. As a result, an ASSERT happens in the
function GetHobList.

The patch is to update GetHobList to get HOB list from system
configuration table when the HOB list is not retrieved and not cached
yet, and HobLibConstructor is also to be updated to just call
GetHobList.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Amy Chan <amy.chan@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdePkg/Library/DxeHobLib/HobLib.c

index c6c04e6a5924063d144919f2446a089cf9f9256c..bb65206b044addf0cddfbb0287092b6538aa8842 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   HOB Library implemenation for Dxe Phase.\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\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
@@ -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