]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c
ArmPlatformPkg/Bds: Remove any use of the "Fdt" UEFI variable
[mirror_edk2.git] / ArmPkg / Library / BdsLib / AArch64 / BdsLinuxLoader.c
index e094413a53b83db914032619abf67d34b734dbf6..76515978fc9948ffb9068245be64a5f72a3c94fd 100644 (file)
@@ -14,6 +14,8 @@
 #include <Library/ArmGicLib.h>\r
 #include <Ppi/ArmMpCoreInfo.h>\r
 #include <Library/IoLib.h>\r
+#include <Guid/Fdt.h>\r
+#include <libfdt.h>\r
 \r
 #include "BdsInternal.h"\r
 #include "BdsLinuxLoader.h"\r
@@ -171,9 +173,9 @@ BdsBootLinuxAtag (
 /**\r
   Start a Linux kernel from a Device Path\r
 \r
-  @param  LinuxKernel           Device Path to the Linux Kernel\r
-  @param  Parameters            Linux kernel agruments\r
-  @param  Fdt                   Device Path to the Flat Device Tree\r
+  @param[in]  LinuxKernelDevicePath  Device Path to the Linux Kernel\r
+  @param[in]  InitrdDevicePath       Device Path to the Initrd\r
+  @param[in]  Arguments              Linux kernel arguments\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
@@ -184,26 +186,26 @@ EFI_STATUS
 BdsBootLinuxFdt (\r
   IN  EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,\r
   IN  EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,\r
-  IN  CONST CHAR8*              Arguments,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath\r
+  IN  CONST CHAR8*              Arguments\r
   )\r
 {\r
-  EFI_STATUS            Status;\r
-  EFI_STATUS            PenBaseStatus;\r
-  UINTN                 LinuxImageSize;\r
-  UINTN                 InitrdImageSize;\r
-  UINTN                 InitrdImageBaseSize;\r
-  UINTN                 FdtBlobSize;\r
-  EFI_PHYSICAL_ADDRESS  FdtBlobBase;\r
-  EFI_PHYSICAL_ADDRESS  LinuxImage;\r
-  EFI_PHYSICAL_ADDRESS  InitrdImage;\r
-  EFI_PHYSICAL_ADDRESS  InitrdImageBase;\r
-  ARM_PROCESSOR_TABLE   *ArmProcessorTable;\r
-  ARM_CORE_INFO         *ArmCoreInfoTable;\r
-  UINTN                 Index;\r
-  EFI_PHYSICAL_ADDRESS  PenBase;\r
-  UINTN                 PenSize;\r
-  UINTN                 MailBoxBase;\r
+  EFI_STATUS               Status;\r
+  EFI_STATUS               PenBaseStatus;\r
+  UINTN                    LinuxImageSize;\r
+  UINTN                    InitrdImageSize;\r
+  UINTN                    InitrdImageBaseSize;\r
+  VOID                     *InstalledFdtBase;\r
+  UINTN                    FdtBlobSize;\r
+  EFI_PHYSICAL_ADDRESS     FdtBlobBase;\r
+  EFI_PHYSICAL_ADDRESS     LinuxImage;\r
+  EFI_PHYSICAL_ADDRESS     InitrdImage;\r
+  EFI_PHYSICAL_ADDRESS     InitrdImageBase;\r
+  ARM_PROCESSOR_TABLE      *ArmProcessorTable;\r
+  ARM_CORE_INFO            *ArmCoreInfoTable;\r
+  UINTN                    Index;\r
+  EFI_PHYSICAL_ADDRESS     PenBase;\r
+  UINTN                    PenSize;\r
+  UINTN                    MailBoxBase;\r
 \r
   PenBaseStatus = EFI_UNSUPPORTED;\r
   PenSize = 0;\r
@@ -259,14 +261,18 @@ BdsBootLinuxFdt (
     }\r
   }\r
 \r
-  // Load the FDT binary from a device path.\r
-  // The FDT will be reloaded later to a more appropriate location for the Linux kernel.\r
-  FdtBlobBase = LINUX_KERNEL_MAX_OFFSET;\r
-  Status = BdsLoadImage (FdtDevicePath, AllocateMaxAddress, &FdtBlobBase, &FdtBlobSize);\r
-  if (EFI_ERROR(Status)) {\r
-    Print (L"ERROR: Did not find Device Tree blob (%r).\n", Status);\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)InstalledFdtBase;\r
+  FdtBlobSize = fdt_totalsize (InstalledFdtBase);\r
 \r
   //\r
   // Install secondary core pens if the Power State Coordination Interface is not supported\r