From bd9a5182a59696870690b54aaa63632c80694000 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Tue, 14 Jul 2015 14:31:05 +0000 Subject: [PATCH] EmbeddedPkg/AndroidFastboot: Use Linux Loader instead of BdsLib Android FastBoot EFI application was using the Linux Loader from BdsLib. This change makes use of the EFI Linux Loader application. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin Reviewed-by: Ronald Cron git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17967 6f19259b-4bc3-4df7-8a09-765794883524 --- .../AndroidFastboot/AndroidFastbootApp.inf | 3 +- .../AndroidFastboot/Arm/BootAndroidBootImg.c | 48 ++++++++++++++++--- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf index ab9354c39a..ca17af8466 100644 --- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf +++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf @@ -1,6 +1,6 @@ #/** @file # -# Copyright (c) 2013-2014, ARM Ltd. All rights reserved.
+# Copyright (c) 2013-2015, ARM Ltd. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -39,6 +39,7 @@ PrintLib UefiApplicationEntryPoint UefiBootServicesTableLib + UefiLib UefiRuntimeServicesTableLib [Protocols] diff --git a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c index 7e9ad880ba..3053cf0687 100644 --- a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c +++ b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2013-2014, ARM Ltd. All rights reserved.
+ Copyright (c) 2013-2015, ARM Ltd. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -18,9 +18,16 @@ #include #include +#include +#include #include +#define LINUX_LOADER_COMMAND_LINE L"%s -f %s -c %s" + +// This GUID is defined in the INGF file of ArmPkg/Application/LinuxLoader +CONST EFI_GUID mLinuxLoaderAppGuid = { 0x701f54f2, 0x0d70, 0x4b89, { 0xbc, 0x0a, 0xd9, 0xca, 0x25, 0x37, 0x90, 0x59 }}; + // Device Path representing an image in memory #pragma pack(1) typedef struct { @@ -64,6 +71,10 @@ BootAndroidBootImg ( UINTN RamdiskSize; MEMORY_DEVICE_PATH KernelDevicePath; MEMORY_DEVICE_PATH* RamdiskDevicePath; + CHAR16* KernelDevicePathTxt; + CHAR16* RamdiskDevicePathTxt; + EFI_DEVICE_PATH* LinuxLoaderDevicePath; + CHAR16* LoadOptions; Status = ParseAndroidBootImg ( Buffer, @@ -92,20 +103,45 @@ BootAndroidBootImg ( RamdiskDevicePath->Node1.EndingAddress = ((EFI_PHYSICAL_ADDRESS)(UINTN) Ramdisk) + RamdiskSize; } - Status = BdsBootLinuxFdt ( - (EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath, - (EFI_DEVICE_PATH_PROTOCOL *) RamdiskDevicePath, - KernelArgs - ); + // + // Boot Linux using the Legacy Linux Loader + // + + Status = LocateEfiApplicationInFvByGuid (&mLinuxLoaderAppGuid, &LinuxLoaderDevicePath); + if (EFI_ERROR (Status)) { + Print (L"Couldn't Boot Linux: %d\n", Status); + return EFI_DEVICE_ERROR; + } + + KernelDevicePathTxt = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath, FALSE, FALSE); + if (KernelDevicePathTxt == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + RamdiskDevicePathTxt = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL *) RamdiskDevicePath, FALSE, FALSE); + if (RamdiskDevicePathTxt == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // Initialize Legacy Linux loader command line + LoadOptions = CatSPrint (NULL, LINUX_LOADER_COMMAND_LINE, KernelDevicePathTxt, RamdiskDevicePathTxt, KernelArgs); + if (LoadOptions == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status = BdsStartEfiApplication (gImageHandle, LinuxLoaderDevicePath, StrSize (LoadOptions), LoadOptions); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "Couldn't Boot Linux: %d\n", Status)); return EFI_DEVICE_ERROR; } if (RamdiskDevicePath) { + FreePool (RamdiskDevicePathTxt); FreePool (RamdiskDevicePath); } + FreePool (KernelDevicePathTxt); + // If we got here we do a confused face because BootLinuxFdt returned, // reporting success. DEBUG ((EFI_D_ERROR, "WARNING: BdsBootLinuxFdt returned EFI_SUCCESS.\n")); -- 2.39.2