]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
EmbeddedPkg/AndroidFastbootApp: remove dependency on deprecated BdsLib
[mirror_edk2.git] / EmbeddedPkg / Application / AndroidFastboot / Arm / BootAndroidBootImg.c
index 46a7ceb3a41c2ebd54a159f1d0ccf7988b1dfe60..f446cce2855aa7aec91f02a00a1f0881291fb625 100644 (file)
@@ -15,6 +15,7 @@
 #include "AndroidFastbootApp.h"\r
 \r
 #include <Protocol/DevicePath.h>\r
 #include "AndroidFastbootApp.h"\r
 \r
 #include <Protocol/DevicePath.h>\r
+#include <Protocol/LoadedImage.h>\r
 \r
 #include <Library/BdsLib.h>\r
 #include <Library/DevicePathLib.h>\r
 \r
 #include <Library/BdsLib.h>\r
 #include <Library/DevicePathLib.h>\r
@@ -50,6 +51,60 @@ STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =
   } // End\r
 };\r
 \r
   } // End\r
 };\r
 \r
+\r
+/**\r
+  Start an EFI Application from a Device Path\r
+\r
+  @param  ParentImageHandle     Handle of the calling image\r
+  @param  DevicePath            Location of the EFI Application\r
+\r
+  @retval EFI_SUCCESS           All drivers have been connected\r
+  @retval EFI_NOT_FOUND         The Linux kernel Device Path has not been found\r
+  @retval EFI_OUT_OF_RESOURCES  There is not enough resource memory to store the matching results.\r
+\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+StartEfiApplication (\r
+  IN EFI_HANDLE                  ParentImageHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *DevicePath,\r
+  IN UINTN                       LoadOptionsSize,\r
+  IN VOID*                       LoadOptions\r
+  )\r
+{\r
+  EFI_STATUS                   Status;\r
+  EFI_HANDLE                   ImageHandle;\r
+  EFI_LOADED_IMAGE_PROTOCOL*   LoadedImage;\r
+\r
+  // Load the image from the device path with Boot Services function\r
+  Status = gBS->LoadImage (TRUE, ParentImageHandle, DevicePath, NULL, 0,\r
+                  &ImageHandle);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  // Passed LoadOptions to the EFI Application\r
+  if (LoadOptionsSize != 0) {\r
+    Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid,\r
+                    (VOID **) &LoadedImage);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    LoadedImage->LoadOptionsSize  = LoadOptionsSize;\r
+    LoadedImage->LoadOptions      = LoadOptions;\r
+  }\r
+\r
+  // Before calling the image, enable the Watchdog Timer for  the 5 Minute period\r
+  gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);\r
+  // Start the image\r
+  Status = gBS->StartImage (ImageHandle, NULL, NULL);\r
+  // Clear the Watchdog Timer after the image returns\r
+  gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
+\r
+  return Status;\r
+}\r
+\r
 EFI_STATUS\r
 BootAndroidBootImg (\r
   IN UINTN    BufferSize,\r
 EFI_STATUS\r
 BootAndroidBootImg (\r
   IN UINTN    BufferSize,\r
@@ -100,7 +155,7 @@ BootAndroidBootImg (
     LoadOptions = NewLoadOptions;\r
   }\r
 \r
     LoadOptions = NewLoadOptions;\r
   }\r
 \r
-  Status = BdsStartEfiApplication (gImageHandle,\r
+  Status = StartEfiApplication (gImageHandle,\r
              (EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath,\r
              StrSize (LoadOptions),\r
              LoadOptions);\r
              (EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath,\r
              StrSize (LoadOptions),\r
              LoadOptions);\r