From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7F6A381E9E for ; Thu, 19 Jan 2017 23:26:27 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 19 Jan 2017 23:26:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,257,1477983600"; d="scan'208";a="1085189480" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga001.jf.intel.com with ESMTP; 19 Jan 2017 23:26:27 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 19 Jan 2017 23:26:26 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 19 Jan 2017 23:26:26 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.177]) with mapi id 14.03.0248.002; Fri, 20 Jan 2017 15:26:24 +0800 From: "Gao, Liming" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , "Chan, Amy" , "Yao, Jiewen" , "Zeng, Star" Thread-Topic: [edk2] [PATCH] MdePkg DxeHobLib: Make GetHobList working before Constructor is called Thread-Index: AQHSb9gCX2AyeeWDjUulwwbS/YWsCaFA/U4w Date: Fri, 20 Jan 2017 07:26:23 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D6D1DEC@shsmsx102.ccr.corp.intel.com> References: <1484557638-172800-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1484557638-172800-1-git-send-email-star.zeng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdePkg DxeHobLib: Make GetHobList working before Constructor is called X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jan 2017 07:26:27 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Sta= r >Zeng >Sent: Monday, January 16, 2017 5:07 PM >To: edk2-devel@lists.01.org >Cc: Kinney, Michael D ; Chan, Amy >; Yao, Jiewen ; Gao, Liming >; Zeng, Star >Subject: [edk2] [PATCH] MdePkg DxeHobLib: Make GetHobList working >before Constructor is called > >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 >Cc: Liming Gao >Cc: Michael Kinney >Cc: Amy Chan >Contributed-under: TianoCore Contribution Agreement 1.0 >Signed-off-by: Star Zeng >--- > MdePkg/Library/DxeHobLib/HobLib.c | 67 ++++++++++++++++++++----------- >-------- > 1 file changed, 34 insertions(+), 33 deletions(-) > >diff --git a/MdePkg/Library/DxeHobLib/HobLib.c >b/MdePkg/Library/DxeHobLib/HobLib.c >index c6c04e6a5924..bb65206b044a 100644 >--- a/MdePkg/Library/DxeHobLib/HobLib.c >+++ b/MdePkg/Library/DxeHobLib/HobLib.c >@@ -1,7 +1,7 @@ > /** @file > HOB Library implemenation for Dxe Phase. > >-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
>+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
> 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 >@@ -24,35 +24,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY >KIND, EITHER EXPRESS OR IMPLIED. > VOID *mHobList =3D NULL; > > /** >- The constructor function caches the pointer to HOB list. >- >- The constructor function gets the start address of HOB list from system >configuration table. >- It will ASSERT() if that operation fails and it will always return EFI_= SUCCESS. >- >- @param ImageHandle The firmware allocated handle for the EFI image. >- @param SystemTable A pointer to the EFI System Table. >- >- @retval EFI_SUCCESS The constructor successfully gets HobList. >- @retval Other value The constructor can't get HobList. >- >-**/ >-EFI_STATUS >-EFIAPI >-HobLibConstructor ( >- IN EFI_HANDLE ImageHandle, >- IN EFI_SYSTEM_TABLE *SystemTable >- ) >-{ >- EFI_STATUS Status; >- >- Status =3D EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList)= ; >- ASSERT_EFI_ERROR (Status); >- ASSERT (mHobList !=3D NULL); >- >- return Status; >-} >- >-/** > Returns the pointer to the HOB list. > > This function returns the pointer to first HOB in the list. >@@ -62,9 +33,11 @@ HobLibConstructor ( > Since the System Configuration Table does not exist that the time the D= XE >Core is > launched, the DXE Core uses a global variable from the DXE Core Entry P= oint >Library > to manage the pointer to the HOB list. >- >+ > If the pointer to the HOB list is NULL, then ASSERT(). >- >+ >+ This function also caches the pointer to the HOB list retrieved. >+ > @return The pointer to the HOB list. > > **/ >@@ -74,11 +47,39 @@ GetHobList ( > VOID > ) > { >- ASSERT (mHobList !=3D NULL); >+ EFI_STATUS Status; >+ >+ if (mHobList =3D=3D NULL) { >+ Status =3D EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobLis= t); >+ ASSERT_EFI_ERROR (Status); >+ ASSERT (mHobList !=3D NULL); >+ } > return mHobList; > } > > /** >+ The constructor function caches the pointer to HOB list by calling >GetHobList() >+ and will always return EFI_SUCCESS. >+ >+ @param ImageHandle The firmware allocated handle for the EFI image. >+ @param SystemTable A pointer to the EFI System Table. >+ >+ @retval EFI_SUCCESS The constructor successfully gets HobList. >+ >+**/ >+EFI_STATUS >+EFIAPI >+HobLibConstructor ( >+ IN EFI_HANDLE ImageHandle, >+ IN EFI_SYSTEM_TABLE *SystemTable >+ ) >+{ >+ GetHobList (); >+ >+ return EFI_SUCCESS; >+} >+ >+/** > Returns the next instance of a HOB type from the starting HOB. > > This function searches the first instance of a HOB type from the starti= ng HOB >pointer. >-- >2.7.0.windows.1 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel