From nobody Sat Nov 2 10:19:14 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; dkim=fail spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1491843377086972.8201369875003; Mon, 10 Apr 2017 09:56:17 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6AD4E2194235A; Mon, 10 Apr 2017 09:55:45 -0700 (PDT) Received: from mail-wr0-x232.google.com (mail-wr0-x232.google.com [IPv6:2a00:1450:400c:c0c::232]) (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 A18BD21A04817 for ; Mon, 10 Apr 2017 09:55:44 -0700 (PDT) Received: by mail-wr0-x232.google.com with SMTP id o21so124749545wrb.2 for ; Mon, 10 Apr 2017 09:55:44 -0700 (PDT) Received: from localhost.localdomain ([196.85.182.219]) by smtp.gmail.com with ESMTPSA id o15sm18043685wra.61.2017.04.10.09.55.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Apr 2017 09:55:41 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=4dTSXB49HBM0AdWiu5lCl/DhOP6g7mG95BHVCgAumVQ=; b=f752UEtTLz+KcOsELtVlYNGK18sIdUVUelhOroI51hDabQnXUuKumxSZVAhtNKhjtb xVrs5ibx1IEj56XKPWyyg+ZDut5KDsHrA91tzlvV9JyHX67D6f4HZ1D7sGJFggKD+Nbx pxJLgvU0BMsJq4nS58Nsdq4cqpoVsy+KxW2cA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4dTSXB49HBM0AdWiu5lCl/DhOP6g7mG95BHVCgAumVQ=; b=eYZRAiYhGsLTlkL5MUYnNUy9cSyex5V3Kfas196cVkZJNMHerFNuGmsANCz/w8kTMu j3ptlBb6wgb8RzRGvF2t+R9CaCAqcJcLryv0NXS45w/PGN6WGDyEv79ytKUeBRGacbEx Z8ozTIjmpLeS2xoxXWrDZ/6lm13YF9l5WslkHkU/2ce37dt7DHyGhr5SNMmeumMYz6Bs Rf1tZACEaDitkyeA2IjImJdnTSq1RRrqWfWxUpPJ5e1Cc99TAFyj9oye5oo0abcYgtMW lft1q7o9P8DsNO8dU2FDO2NczHNEARF7V0ilXudnCKdkNt+7OHY6KmAhLXHrMhXMyoHt mwNQ== X-Gm-Message-State: AFeK/H08N//rLUbb/RMNoyfEUl1tbMTFQFmSyJ7EJ8kfWQKrK/5VTnARp5OV4GaOm2eare3F X-Received: by 10.223.176.202 with SMTP id j10mr31781956wra.10.1491843342886; Mon, 10 Apr 2017 09:55:42 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Mon, 10 Apr 2017 17:55:34 +0100 Message-Id: <20170410165534.22292-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 Subject: [edk2] [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: , Cc: ryan.harkin@linaro.org, haojian.zhuang@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 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 =20 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" =20 #include +#include =20 #include #include @@ -50,6 +51,60 @@ STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate= =3D } // End }; =20 + +/** + 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 sto= re 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 =3D gBS->LoadImage (TRUE, ParentImageHandle, DevicePath, NULL, 0, + &ImageHandle); + if (EFI_ERROR (Status)) { + return Status; + } + + // Passed LoadOptions to the EFI Application + if (LoadOptionsSize !=3D 0) { + Status =3D gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolG= uid, + (VOID **) &LoadedImage); + if (EFI_ERROR (Status)) { + return Status; + } + + LoadedImage->LoadOptionsSize =3D LoadOptionsSize; + LoadedImage->LoadOptions =3D 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 =3D 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 =3D NewLoadOptions; } =20 - Status =3D BdsStartEfiApplication (gImageHandle, + Status =3D StartEfiApplication (gImageHandle, (EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath, StrSize (LoadOptions), LoadOptions); --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel