Revision: 17967
          http://sourceforge.net/p/edk2/code/17967
Author:   oliviermartin
Date:     2015-07-14 14:31:05 +0000 (Tue, 14 Jul 2015)
Log Message:
-----------
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 <[email protected]>
Reviewed-by: Ronald Cron <[email protected]>

Modified Paths:
--------------
    trunk/edk2/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
    trunk/edk2/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c

Modified: 
trunk/edk2/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
===================================================================
--- trunk/edk2/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf   
2015-07-14 14:30:08 UTC (rev 17966)
+++ trunk/edk2/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf   
2015-07-14 14:31:05 UTC (rev 17967)
@@ -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]

Modified: 
trunk/edk2/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
===================================================================
--- trunk/edk2/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c 
2015-07-14 14:30:08 UTC (rev 17966)
+++ trunk/edk2/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c 
2015-07-14 14:31:05 UTC (rev 17967)
@@ -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 @@
   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 @@
     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"));


------------------------------------------------------------------------------
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-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to