Change-Id: I8b8596c9457e079227cc00d3f7eff8cc0319cedd --- .../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 ab9354c..ca17af8 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.<BR> +# Copyright (c) 2013-2015, ARM Ltd. All rights reserved.<BR> # # 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 7e9ad88..3053cf0 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.<BR> + Copyright (c) 2013-2015, ARM Ltd. All rights reserved.<BR> 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 <Library/BdsLib.h> #include <Library/DevicePathLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/UefiLib.h> #include <Guid/ArmGlobalVariableHob.h> +#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.1.1 ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel