]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/AndroidFastboot: Use Linux Loader instead of BdsLib
authorOlivier Martin <Olivier.Martin@arm.com>
Tue, 14 Jul 2015 14:31:05 +0000 (14:31 +0000)
committeroliviermartin <oliviermartin@Edk2>
Tue, 14 Jul 2015 14:31:05 +0000 (14:31 +0000)
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 <Olivier.Martin@arm.com>
Reviewed-by: Ronald Cron <Ronald.Cron@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17967 6f19259b-4bc3-4df7-8a09-765794883524

EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c

index ab9354c39aa205fe37861a3f0050663003eb487a..ca17af8466277c8a38f6b9ac46d7d4fbd4d65f0d 100644 (file)
@@ -1,6 +1,6 @@
 #/** @file\r
 #\r
-#  Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>\r
+#  Copyright (c) 2013-2015, ARM Ltd. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -39,6 +39,7 @@
   PrintLib\r
   UefiApplicationEntryPoint\r
   UefiBootServicesTableLib\r
+  UefiLib\r
   UefiRuntimeServicesTableLib\r
 \r
 [Protocols]\r
index 7e9ad880baf037f5ee95453f4d632452091a4a00..3053cf06873eddec83506560cd7a0b7e00d73ba1 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-  Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>\r
+  Copyright (c) 2013-2015, ARM Ltd. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 \r
 #include <Library/BdsLib.h>\r
 #include <Library/DevicePathLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
 \r
 #include <Guid/ArmGlobalVariableHob.h>\r
 \r
+#define LINUX_LOADER_COMMAND_LINE       L"%s -f %s -c %s"\r
+\r
+// This GUID is defined in the INGF file of ArmPkg/Application/LinuxLoader\r
+CONST EFI_GUID mLinuxLoaderAppGuid = { 0x701f54f2, 0x0d70, 0x4b89, { 0xbc, 0x0a, 0xd9, 0xca, 0x25, 0x37, 0x90, 0x59 }};\r
+\r
 // Device Path representing an image in memory\r
 #pragma pack(1)\r
 typedef struct {\r
@@ -64,6 +71,10 @@ BootAndroidBootImg (
   UINTN                               RamdiskSize;\r
   MEMORY_DEVICE_PATH                  KernelDevicePath;\r
   MEMORY_DEVICE_PATH*                 RamdiskDevicePath;\r
+  CHAR16*                             KernelDevicePathTxt;\r
+  CHAR16*                             RamdiskDevicePathTxt;\r
+  EFI_DEVICE_PATH*                    LinuxLoaderDevicePath;\r
+  CHAR16*                             LoadOptions;\r
 \r
   Status = ParseAndroidBootImg (\r
             Buffer,\r
@@ -92,20 +103,45 @@ BootAndroidBootImg (
     RamdiskDevicePath->Node1.EndingAddress   = ((EFI_PHYSICAL_ADDRESS)(UINTN) Ramdisk) + RamdiskSize;\r
   }\r
 \r
-  Status = BdsBootLinuxFdt (\r
-              (EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath,\r
-              (EFI_DEVICE_PATH_PROTOCOL *) RamdiskDevicePath,\r
-              KernelArgs\r
-              );\r
+  //\r
+  // Boot Linux using the Legacy Linux Loader\r
+  //\r
+\r
+  Status = LocateEfiApplicationInFvByGuid (&mLinuxLoaderAppGuid, &LinuxLoaderDevicePath);\r
+  if (EFI_ERROR (Status)) {\r
+    Print (L"Couldn't Boot Linux: %d\n", Status);\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  KernelDevicePathTxt = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath, FALSE, FALSE);\r
+  if (KernelDevicePathTxt == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  RamdiskDevicePathTxt = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL *) RamdiskDevicePath, FALSE, FALSE);\r
+  if (RamdiskDevicePathTxt == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  // Initialize Legacy Linux loader command line\r
+  LoadOptions = CatSPrint (NULL, LINUX_LOADER_COMMAND_LINE, KernelDevicePathTxt, RamdiskDevicePathTxt, KernelArgs);\r
+  if (LoadOptions == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Status = BdsStartEfiApplication (gImageHandle, LinuxLoaderDevicePath, StrSize (LoadOptions), LoadOptions);\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((EFI_D_ERROR, "Couldn't Boot Linux: %d\n", Status));\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
   if (RamdiskDevicePath) {\r
+    FreePool (RamdiskDevicePathTxt);\r
     FreePool (RamdiskDevicePath);\r
   }\r
 \r
+  FreePool (KernelDevicePathTxt);\r
+\r
   // If we got here we do a confused face because BootLinuxFdt returned,\r
   // reporting success.\r
   DEBUG ((EFI_D_ERROR, "WARNING: BdsBootLinuxFdt returned EFI_SUCCESS.\n"));\r