From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x22e.google.com (mail-io0-x22e.google.com [IPv6:2607:f8b0:4001:c06::22e]) (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 9D9E921A18AAB for ; Tue, 18 Apr 2017 11:08:58 -0700 (PDT) Received: by mail-io0-x22e.google.com with SMTP id o22so6746615iod.3 for ; Tue, 18 Apr 2017 11:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=cBmxu3zh8bcAMp01wszPEqEsZOmUrErhtoHCB2VQx3I=; b=B4BVvJvuyBuji2vN3ZfQ56SowY4uCwQuI/PIhlAKQ6iJTcRDdRyf8+dvKEDkRT7FOB oj1GH5ERU+127Yzn8QdRkaVZ476VxxSGOrtX9V0CFhVrIRO85/vTrxzTmGcZiNCiQyvn jXEwRaYYTvIRGB+f8qax0ePXKyBt8IaVrvtf4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=cBmxu3zh8bcAMp01wszPEqEsZOmUrErhtoHCB2VQx3I=; b=YnWdzBLN83rBHLfA5JYYh5K4R9v3tWC5Lgv3qcd5CBfIOoHtmzT0M0cBbrhRSU+As9 MwQARQ964u4Gs6YW9S7GL6maiXTf+1QStQ+2UVL8twMWYPXqYgjEMmaj9VqKXeLmmdMX +yKi8P4BjDROQV7RUVOn6psUPE2cD8sXHLtsgFa5LFriMvOx38bklklBHgnheyiN1q46 Vns8dWvBlOxEKSFNojyVpXwVujUaayJVlJZFQAlLunBdwkuBxmpMrnp7p6gW0k4AFt2S /su2Dughrn6zvFyEL/nDmu3ywvrmyXjRGlGva/Ufs4v/Pc5RUlZiJeWbiiQUfe+KgSWg Xidg== X-Gm-Message-State: AN3rC/4T6FgJ5sTxv8RgGwiC4TYKrZod72wC+O0FNStWMJiJF3EptGyD JNDTiKF+FDNhj0xE/pk7IUwEf1iNh9zpoUQ= X-Received: by 10.36.2.205 with SMTP id 196mr14798815itu.63.1492538937430; Tue, 18 Apr 2017 11:08:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.201.76 with HTTP; Tue, 18 Apr 2017 11:08:57 -0700 (PDT) In-Reply-To: <20170410165534.22292-1-ard.biesheuvel@linaro.org> References: <20170410165534.22292-1-ard.biesheuvel@linaro.org> From: Ard Biesheuvel Date: Tue, 18 Apr 2017 19:08:57 +0100 Message-ID: To: "edk2-devel@lists.01.org" , Leif Lindholm Cc: Ryan Harkin , Haojian Zhuang , Ard Biesheuvel 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 18:08:58 -0000 Content-Type: text/plain; charset=UTF-8 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? > --- > 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 >