]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/AndroidFastboot: drop dependency on the LinuxLoader
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 21 Nov 2016 12:13:18 +0000 (12:13 +0000)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 25 Nov 2016 12:56:10 +0000 (12:56 +0000)
When booting the kernel via Fastboot, invoke the kernel image directly
rather than passing it to the LinuxLoader app. This requires the kernel
image to be built with UEFI stub support.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Ryan Harkin <ryan.harkin@linaro.org>
Reviewed-by: Ryan Harkin <ryan.harkin@linaro.org>
EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c

index acedd3e0e3cdd674a4794ca91f4c6a86abf7bbce..46a7ceb3a41c2ebd54a159f1d0ccf7988b1dfe60 100644 (file)
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiLib.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
@@ -68,11 +63,7 @@ BootAndroidBootImg (
   VOID                               *Ramdisk;\r
   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
+  CHAR16                              *LoadOptions, *NewLoadOptions;\r
 \r
   Status = ParseAndroidBootImg (\r
             Buffer,\r
@@ -93,55 +84,38 @@ BootAndroidBootImg (
   KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel;\r
   KernelDevicePath.Node1.EndingAddress   = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel + KernelSize;\r
 \r
-  RamdiskDevicePath = NULL;\r
-  if (RamdiskSize != 0) {\r
-    RamdiskDevicePath = (MEMORY_DEVICE_PATH*)DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL*) &MemoryDevicePathTemplate);\r
-\r
-    RamdiskDevicePath->Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Ramdisk;\r
-    RamdiskDevicePath->Node1.EndingAddress   = ((EFI_PHYSICAL_ADDRESS)(UINTN) Ramdisk) + RamdiskSize;\r
-  }\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
+  // Initialize Linux command line\r
+  LoadOptions = CatSPrint (NULL, L"%a", KernelArgs);\r
+  if (LoadOptions == 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
+  if (RamdiskSize != 0) {\r
+    NewLoadOptions = CatSPrint (LoadOptions, L" initrd=0x%x,0x%x",\r
+                       (UINTN)Ramdisk, RamdiskSize);\r
+    FreePool (LoadOptions);\r
+    if (NewLoadOptions == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    LoadOptions = NewLoadOptions;\r
   }\r
 \r
-  Status = BdsStartEfiApplication (gImageHandle, LinuxLoaderDevicePath, StrSize (LoadOptions), LoadOptions);\r
+  Status = BdsStartEfiApplication (gImageHandle,\r
+             (EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath,\r
+             StrSize (LoadOptions),\r
+             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
+    Status = EFI_DEVICE_ERROR;\r
+    goto FreeLoadOptions;\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
   return EFI_SUCCESS;\r
+\r
+FreeLoadOptions:\r
+  FreePool (LoadOptions);\r
+  return Status;\r
 }\r