From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 4794381D5B for ; Tue, 8 Nov 2016 06:08:10 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 08 Nov 2016 06:08:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,462,1473145200"; d="scan'208";a="1056850018" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 08 Nov 2016 06:08:12 -0800 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 8 Nov 2016 06:08:12 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 8 Nov 2016 06:08:12 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.206]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.96]) with mapi id 14.03.0248.002; Tue, 8 Nov 2016 22:08:08 +0800 From: "Zhang, Chao B" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS Thread-Index: AQHSObvPK8MOZGYNWk+i/CO2RVnPY6DPH27A Date: Tue, 8 Nov 2016 14:08:08 +0000 Message-ID: References: <20161108122928.53984-1-ruiyu.ni@intel.com> <20161108122928.53984-4-ruiyu.ni@intel.com> In-Reply-To: <20161108122928.53984-4-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzA4ZDBkOTAtNzFhYS00Y2I5LTkyODAtYjNlNDVjNTcwOTQwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlBPdmlNWHZIV0ZBdmZuMDE2MEZpczNGamZrVnYxSWNmU1dVTlQwZ1JhcjQ9In0= x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS 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: Tue, 08 Nov 2016 14:08:10 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by : Chao Zhang Thanks & Best regards Chao Zhang -----Original Message----- From: Ni, Ruiyu=20 Sent: Tuesday, November 08, 2016 8:29 PM To: edk2-devel@lists.01.org Cc: Gao, Liming; Zhang, Chao B Subject: [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before b= ooting to OS The patch adds check of deferred images before booting to OS. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Liming Gao Cc: Chao B Zhang --- MdeModulePkg/Universal/BdsDxe/Bds.h | 4 +- MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 2 + MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 90 ++++++++++++++++++++++++++++= ++++ 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/BdsDxe/Bds.h b/MdeModulePkg/Universal/B= dsDxe/Bds.h index d243932..1f8a192 100644 --- a/MdeModulePkg/Universal/BdsDxe/Bds.h +++ b/MdeModulePkg/Universal/BdsDxe/Bds.h @@ -1,7 +1,7 @@ /** @file Head file for BDS Architectural Protocol implementation =20 -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, 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 @@ -20,10 +20,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include #include #include +#include =20 #include #include #include +#include =20 #include #include diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf b/MdeModulePkg/Univer= sal/BdsDxe/BdsDxe.inf index e03cfde..a00b442 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf +++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf @@ -79,11 +79,13 @@ [Guids] gConnectConInEventGuid ## SOMETIMES_CONSUMES ## E= vent gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## G= UID gPerformanceProtocolGuid ## SOMETIMES_PRODUCES ## V= ariable:L"PerfDataMemAddr" (The ACPI address of performance data) + gEfiEventReadyToBootGuid ## CONSUMES ## E= vent =20 [Protocols] gEfiBdsArchProtocolGuid ## PRODUCES gEfiSimpleTextInputExProtocolGuid ## CONSUMES gEdkiiVariableLockProtocolGuid ## CONSUMES + gEfiDeferredImageLoadProtocolGuid ## CONSUMES =20 [FeaturePcd] gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate ## CONSU= MES diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Univer= sal/BdsDxe/BdsEntry.c index aacc4a6..72adc51 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -86,6 +86,81 @@ BdsDxeOnConnectConInCallBack ( DEBUG ((EFI_D_WARN, "[Bds] Connect ConIn failed - %r!!!\n", Status)); } } +/** + Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is u= sed to + check whether there is remaining deferred load images. + + @param[in] Event The Event that is being processed. + @param[in] Context The Event Context. + +**/ +VOID +EFIAPI +CheckDeferredLoadImageOnReadyToBoot ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage; + UINTN HandleCount; + EFI_HANDLE *Handles; + UINTN Index; + UINTN ImageIndex; + EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath; + VOID *Image; + UINTN ImageSize; + BOOLEAN BootOption; + CHAR16 *DevicePathStr; + + // + // Find all the deferred image load protocols. + // + HandleCount =3D 0; + Handles =3D NULL; + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiDeferredImageLoadProtocolGuid, + NULL, + &HandleCount, + &Handles + ); + if (EFI_ERROR (Status)) { + return; + } + + for (Index =3D 0; Index < HandleCount; Index++) { + Status =3D gBS->HandleProtocol (Handles[Index], &gEfiDeferredImageLoad= ProtocolGuid, (VOID **) &DeferredImage); + if (EFI_ERROR (Status)) { + continue; + } + + for (ImageIndex =3D 0; ; ImageIndex++) { + // + // Load all the deferred images in this protocol instance. + // + Status =3D DeferredImage->GetImageInfo ( + DeferredImage, + ImageIndex, + &ImageDevicePath, + (VOID **) &Image, + &ImageSize, + &BootOption + ); + if (EFI_ERROR (Status)) { + break; + } + DevicePathStr =3D ConvertDevicePathToText (ImageDevicePath, FALSE, F= ALSE); + DEBUG ((DEBUG_LOAD, "[Bds] Image was deferred but not loaded: %s.\n"= , DevicePathStr)); + if (DevicePathStr !=3D NULL) { + FreePool (DevicePathStr); + } + } + } + if (Handles !=3D NULL) { + FreePool (Handles); + } +} =20 /** =20 @@ -119,6 +194,21 @@ BdsInitialize ( ); ASSERT_EFI_ERROR (Status); =20 + DEBUG_CODE ( + EFI_EVENT Event; + // + // Register notify function to check deferred images on ReadyToBoot Ev= ent. + // + Status =3D gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + CheckDeferredLoadImageOnReadyToBoot, + NULL, + &gEfiEventReadyToBootGuid, + &Event + ); + ASSERT_EFI_ERROR (Status); + ); return Status; } =20 --=20 2.9.0.windows.1