]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
ArmPlatformPkg/Bds: Remove any use of the "Fdt" UEFI variable
[mirror_edk2.git] / ArmPkg / Library / BdsLib / Arm / BdsLinuxLoader.c
index 42f301d9b9cd0f9158634191f265a0be40a929c4..e5fda081f8a93c0176fca9877d9a47fafa0b7fba 100644 (file)
@@ -12,6 +12,9 @@
 *\r
 **/\r
 \r
+#include <Guid/Fdt.h>\r
+#include <libfdt.h>\r
+\r
 #include "BdsInternal.h"\r
 #include "BdsLinuxLoader.h"\r
 \r
@@ -222,9 +225,9 @@ EXIT_FREE_LINUX:
 /**\r
   Start a Linux kernel from a Device Path\r
 \r
-  @param  LinuxKernel           Device Path to the Linux Kernel\r
-  @param  Parameters            Linux kernel arguments\r
-  @param  Fdt                   Device Path to the Flat Device Tree\r
+  @param  LinuxKernelDevicePath  Device Path to the Linux Kernel\r
+  @param  InitrdDevicePath       Device Path to the Initrd\r
+  @param  CommandLineArguments   Linux command line\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
@@ -235,19 +238,19 @@ EFI_STATUS
 BdsBootLinuxFdt (\r
   IN  EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,\r
   IN  EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,\r
-  IN  CONST CHAR8*              CommandLineArguments,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath\r
+  IN  CONST CHAR8*              CommandLineArguments\r
   )\r
 {\r
-  EFI_STATUS            Status;\r
-  UINT32                LinuxImageSize;\r
-  UINT32                InitrdImageBaseSize = 0;\r
-  UINT32                InitrdImageSize = 0;\r
-  UINT32                FdtBlobSize;\r
-  EFI_PHYSICAL_ADDRESS  FdtBlobBase;\r
-  EFI_PHYSICAL_ADDRESS  LinuxImage;\r
-  EFI_PHYSICAL_ADDRESS  InitrdImageBase = 0;\r
-  EFI_PHYSICAL_ADDRESS  InitrdImage = 0;\r
+  EFI_STATUS               Status;\r
+  UINT32                   LinuxImageSize;\r
+  UINT32                   InitrdImageBaseSize = 0;\r
+  UINT32                   InitrdImageSize = 0;\r
+  VOID                     *InstalledFdtBase;\r
+  UINT32                   FdtBlobSize;\r
+  EFI_PHYSICAL_ADDRESS     FdtBlobBase;\r
+  EFI_PHYSICAL_ADDRESS     LinuxImage;\r
+  EFI_PHYSICAL_ADDRESS     InitrdImageBase = 0;\r
+  EFI_PHYSICAL_ADDRESS     InitrdImage = 0;\r
 \r
   PERF_START (NULL, "BDS", NULL, 0);\r
 \r
@@ -281,13 +284,18 @@ BdsBootLinuxFdt (
     }\r
   }\r
 \r
-  // Load the FDT binary from a device path. The FDT will be reloaded later to a more appropriate location for the Linux kernel.\r
-  FdtBlobBase = 0;\r
-  Status = BdsLoadImage (FdtDevicePath, AllocateAnyPages, &FdtBlobBase, &FdtBlobSize);\r
-  if (EFI_ERROR(Status)) {\r
-    Print (L"ERROR: Did not find Device Tree blob.\n");\r
+  //\r
+  // Get the FDT from the Configuration Table.\r
+  // The FDT will be reloaded in PrepareFdt() to a more appropriate\r
+  // location for the Linux Kernel.\r
+  //\r
+  Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &InstalledFdtBase);\r
+  if (EFI_ERROR (Status)) {\r
+    Print (L"ERROR: Did not get the Device Tree blob (%r).\n", Status);\r
     goto EXIT_FREE_INITRD;\r
   }\r
+  FdtBlobBase = (EFI_PHYSICAL_ADDRESS)(UINTN)InstalledFdtBase;\r
+  FdtBlobSize = fdt_totalsize (InstalledFdtBase);\r
 \r
   // Update the Fdt with the Initrd information. The FDT will increase in size.\r
   // By setting address=0 we leave the memory allocation to the function\r