From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-x233.google.com (mail-wr0-x233.google.com [IPv6:2a00:1450:400c:c0c::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C4ADD21A04823 for ; Tue, 18 Apr 2017 12:21:28 -0700 (PDT) Received: by mail-wr0-x233.google.com with SMTP id z109so1594281wrb.1 for ; Tue, 18 Apr 2017 12:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=o69s/rp2F+5XQRcWwnleiwr80isAfhB9R+Omm15PquA=; b=TxcPHXY5GrVrwlyfWs5ID2Pn+fw+WyV0PU7hte6+kV8pVB75ilp8AdW4i38pPlI69I xoNWuPdj2MQdoTXNZH4wJ10Einyg5DDdTsTj1gE8/aaIYyx4jG4EylAhwLJg/JsoX8nB JeKrcoPsshAZELf1QkQGKtur3EiWTc5V2OEwI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=o69s/rp2F+5XQRcWwnleiwr80isAfhB9R+Omm15PquA=; b=NOWI0nIA1HomJ+84o7nmY93X3Rn0KnE0AUVU7AWWdx8px+sfYA9Oy30uK8xaO1rE5w Za3m7i8CJcQZFhuyCcy/t5GQXhuyPakRIoDRwF819pnFFXrLd8WgHyPtKuPoT0Bz14Wh CKKMeT0CI1fhr1ax4pkSOq1PLgrDedQ+8Vj2YnoVpMNnoRDsjAunPjZOnSsOI0niYalI V9v/wDentE5Mz4VZwDOtn/cJRHAQssjScvOVtJ05yJ7LohczwAA7xlErzU3eCzHMzbwZ es9w5uYvmnW0RD6Wlj6LuIVCaDaLRRuV2sZrLm8ymFPKzwojFlI2CA2uCL0+aKqTHPzF CGpg== X-Gm-Message-State: AN3rC/7Jsg8TYm5L5luVWjjziAfg31yiAr81SY8mkXxcqk+HBa9/v06w FkX03Npd/cvsKHXj X-Received: by 10.223.136.125 with SMTP id e58mr23199564wre.73.1492543287137; Tue, 18 Apr 2017 12:21:27 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id 3sm95898wrv.33.2017.04.18.12.21.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Apr 2017 12:21:26 -0700 (PDT) Date: Tue, 18 Apr 2017 20:21:24 +0100 From: Leif Lindholm To: Ard Biesheuvel Cc: "edk2-devel@lists.01.org" , Ryan Harkin , Haojian Zhuang Message-ID: <20170418192124.GR1657@bivouac.eciton.net> References: <20170410165534.22292-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [RFT PATCH] EmbeddedPkg/AndroidFastbootApp: remove dependency on deprecated BdsLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Apr 2017 19:21:29 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Apr 18, 2017 at 07:08:57PM +0100, Ard Biesheuvel wrote: > On 10 April 2017 at 17:55, Ard Biesheuvel wrote: > > One of the last remaining modules with a dependency on the deprecated > > BdsLib implementation from ArmPkg is the Android fastboot application. > > > > Its only dependency on BdsLib is BdsStartEfiApplication(), which is > > used in the most peculiar way: the fastboot app loads the kernel image > > into memory, and creates a MemoryMapped() device path for it. It then > > proceeds and calls BdsStartEfiApplication(), which explicitly loads the > > contents of the devicepath into memory, creating a second in-memory copy > > of the kernel image, after which it invokes gBS->LoadImage() with a > > buffer address and size (while it is perfectly capable of loading from > > a devicepath directly) > > > > Since we know the device path is fully qualified and connected, and does > > not require any of the additional processing that BdsStartEfiApplication() > > does when dereferencing a device path, we should be able to pass this > > devicepath into LoadImage() directly. > > > > So create a simplified local clone of BdsStartEfiApplication(), and drop > > the dependency on BdsLib. > > > > Signed-off-by: Ard Biesheuvel > > Should we just merge this and see what happens? With no other comments so far - sure: Reviewed-by: Leif Lindholm > > --- > > EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf | 2 +- > > EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c | 57 +++++++++++++++++++- > > 2 files changed, 57 insertions(+), 2 deletions(-) > > > > diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf > > index 3e115171ce01..8d2b23c6f8b8 100644 > > --- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf > > +++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf > > @@ -30,7 +30,6 @@ [Sources.ARM, Sources.AARCH64] > > [LibraryClasses] > > BaseLib > > BaseMemoryLib > > - BdsLib > > DebugLib > > DevicePathLib > > DxeServicesTableLib > > @@ -45,6 +44,7 @@ [LibraryClasses] > > [Protocols] > > gAndroidFastbootTransportProtocolGuid > > gAndroidFastbootPlatformProtocolGuid > > + gEfiLoadedImageProtocolGuid > > gEfiSimpleTextOutProtocolGuid > > gEfiSimpleTextInProtocolGuid > > > > diff --git a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c > > index 46a7ceb3a41c..f446cce2855a 100644 > > --- a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c > > +++ b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c > > @@ -15,6 +15,7 @@ > > #include "AndroidFastbootApp.h" > > > > #include > > +#include > > > > #include > > #include > > @@ -50,6 +51,60 @@ STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate = > > } // End > > }; > > > > + > > +/** > > + Start an EFI Application from a Device Path > > + > > + @param ParentImageHandle Handle of the calling image > > + @param DevicePath Location of the EFI Application > > + > > + @retval EFI_SUCCESS All drivers have been connected > > + @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found > > + @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results. > > + > > +**/ > > +STATIC > > +EFI_STATUS > > +StartEfiApplication ( > > + IN EFI_HANDLE ParentImageHandle, > > + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, > > + IN UINTN LoadOptionsSize, > > + IN VOID* LoadOptions > > + ) > > +{ > > + EFI_STATUS Status; > > + EFI_HANDLE ImageHandle; > > + EFI_LOADED_IMAGE_PROTOCOL* LoadedImage; > > + > > + // Load the image from the device path with Boot Services function > > + Status = gBS->LoadImage (TRUE, ParentImageHandle, DevicePath, NULL, 0, > > + &ImageHandle); > > + if (EFI_ERROR (Status)) { > > + return Status; > > + } > > + > > + // Passed LoadOptions to the EFI Application > > + if (LoadOptionsSize != 0) { > > + Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, > > + (VOID **) &LoadedImage); > > + if (EFI_ERROR (Status)) { > > + return Status; > > + } > > + > > + LoadedImage->LoadOptionsSize = LoadOptionsSize; > > + LoadedImage->LoadOptions = LoadOptions; > > + } > > + > > + // Before calling the image, enable the Watchdog Timer for the 5 Minute period > > + gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL); > > + // Start the image > > + Status = gBS->StartImage (ImageHandle, NULL, NULL); > > + // Clear the Watchdog Timer after the image returns > > + gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL); > > + > > + return Status; > > +} > > + > > EFI_STATUS > > BootAndroidBootImg ( > > IN UINTN BufferSize, > > @@ -100,7 +155,7 @@ BootAndroidBootImg ( > > LoadOptions = NewLoadOptions; > > } > > > > - Status = BdsStartEfiApplication (gImageHandle, > > + Status = StartEfiApplication (gImageHandle, > > (EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath, > > StrSize (LoadOptions), > > LoadOptions); > > -- > > 2.9.3 > >