diff options
Diffstat (limited to 'ArmPkg')
-rw-r--r-- | ArmPkg/Application/LinuxLoader/LinuxFdtLoader.c | 6 | ||||
-rw-r--r-- | ArmPkg/Include/Library/BdsLib.h | 9 | ||||
-rw-r--r-- | ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c | 60 | ||||
-rw-r--r-- | ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c | 46 | ||||
-rw-r--r-- | ArmPkg/Library/BdsLib/BdsLib.inf | 5 |
5 files changed, 69 insertions, 57 deletions
diff --git a/ArmPkg/Application/LinuxLoader/LinuxFdtLoader.c b/ArmPkg/Application/LinuxLoader/LinuxFdtLoader.c index 07d0ea7..8e5d1c6 100644 --- a/ArmPkg/Application/LinuxLoader/LinuxFdtLoader.c +++ b/ArmPkg/Application/LinuxLoader/LinuxFdtLoader.c @@ -39,7 +39,6 @@ UefiMain ( EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
LINUX_LOADER_OPTIONAL_DATA* LinuxOptionalData;
EFI_DEVICE_PATH* DevicePathKernel;
- EFI_DEVICE_PATH* DevicePathFdt;
EFI_DEVICE_PATH* InitrdDevicePath;
CHAR16* OptionalDataInitrd;
CHAR8* OptionalDataArguments;
@@ -57,9 +56,8 @@ UefiMain ( return EFI_UNSUPPORTED;
}
- // Generate the File Path Node for the Linux Kernel & Device Tree blob
+ // Generate the File Path Node for the Linux Kernel
DevicePathKernel = FileDevicePath (LoadedImage->DeviceHandle, LINUX_KERNEL_NAME);
- DevicePathFdt = FileDevicePath (LoadedImage->DeviceHandle, FDT_NAME);
if (LinuxOptionalData->CmdLineLength > 0) {
OptionalDataArguments = (CHAR8*)LinuxOptionalData + sizeof(LINUX_LOADER_OPTIONAL_DATA);
@@ -89,7 +87,7 @@ UefiMain ( }
// Load and Start the Linux Kernel (we should never return)
- Status = BdsBootLinuxFdt (DevicePathKernel, InitrdDevicePath, OptionalDataArguments, DevicePathFdt);
+ Status = BdsBootLinuxFdt (DevicePathKernel, InitrdDevicePath, OptionalDataArguments);
if ((UINTN)OptionalDataInitrd & 0x1) {
FreePool (Initrd);
diff --git a/ArmPkg/Include/Library/BdsLib.h b/ArmPkg/Include/Library/BdsLib.h index 9fa6870..68dbfd5 100644 --- a/ArmPkg/Include/Library/BdsLib.h +++ b/ArmPkg/Include/Library/BdsLib.h @@ -160,9 +160,9 @@ BdsBootLinuxAtag ( /**
Start a Linux kernel from a Device Path
- @param LinuxKernel Device Path to the Linux Kernel
- @param Parameters Linux kernel arguments
- @param Fdt Device Path to the Flat Device Tree
+ @param[in] LinuxKernelDevicePath Device Path to the Linux Kernel
+ @param[in] InitrdDevicePath Device Path to the Initrd
+ @param[in] Arguments Linux kernel arguments
@retval EFI_SUCCESS All drivers have been connected
@retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
@@ -173,8 +173,7 @@ EFI_STATUS BdsBootLinuxFdt (
IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* Arguments,
- IN EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath
+ IN CONST CHAR8* Arguments
);
/**
diff --git a/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c b/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c index e094413..7651597 100644 --- a/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c +++ b/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c @@ -14,6 +14,8 @@ #include <Library/ArmGicLib.h>
#include <Ppi/ArmMpCoreInfo.h>
#include <Library/IoLib.h>
+#include <Guid/Fdt.h>
+#include <libfdt.h>
#include "BdsInternal.h"
#include "BdsLinuxLoader.h"
@@ -171,9 +173,9 @@ BdsBootLinuxAtag ( /**
Start a Linux kernel from a Device Path
- @param LinuxKernel Device Path to the Linux Kernel
- @param Parameters Linux kernel agruments
- @param Fdt Device Path to the Flat Device Tree
+ @param[in] LinuxKernelDevicePath Device Path to the Linux Kernel
+ @param[in] InitrdDevicePath Device Path to the Initrd
+ @param[in] Arguments Linux kernel arguments
@retval EFI_SUCCESS All drivers have been connected
@retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
@@ -184,26 +186,26 @@ EFI_STATUS BdsBootLinuxFdt (
IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* Arguments,
- IN EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath
+ IN CONST CHAR8* Arguments
)
{
- EFI_STATUS Status;
- EFI_STATUS PenBaseStatus;
- UINTN LinuxImageSize;
- UINTN InitrdImageSize;
- UINTN InitrdImageBaseSize;
- UINTN FdtBlobSize;
- EFI_PHYSICAL_ADDRESS FdtBlobBase;
- EFI_PHYSICAL_ADDRESS LinuxImage;
- EFI_PHYSICAL_ADDRESS InitrdImage;
- EFI_PHYSICAL_ADDRESS InitrdImageBase;
- ARM_PROCESSOR_TABLE *ArmProcessorTable;
- ARM_CORE_INFO *ArmCoreInfoTable;
- UINTN Index;
- EFI_PHYSICAL_ADDRESS PenBase;
- UINTN PenSize;
- UINTN MailBoxBase;
+ EFI_STATUS Status;
+ EFI_STATUS PenBaseStatus;
+ UINTN LinuxImageSize;
+ UINTN InitrdImageSize;
+ UINTN InitrdImageBaseSize;
+ VOID *InstalledFdtBase;
+ UINTN FdtBlobSize;
+ EFI_PHYSICAL_ADDRESS FdtBlobBase;
+ EFI_PHYSICAL_ADDRESS LinuxImage;
+ EFI_PHYSICAL_ADDRESS InitrdImage;
+ EFI_PHYSICAL_ADDRESS InitrdImageBase;
+ ARM_PROCESSOR_TABLE *ArmProcessorTable;
+ ARM_CORE_INFO *ArmCoreInfoTable;
+ UINTN Index;
+ EFI_PHYSICAL_ADDRESS PenBase;
+ UINTN PenSize;
+ UINTN MailBoxBase;
PenBaseStatus = EFI_UNSUPPORTED;
PenSize = 0;
@@ -259,14 +261,18 @@ BdsBootLinuxFdt ( }
}
- // Load the FDT binary from a device path.
- // The FDT will be reloaded later to a more appropriate location for the Linux kernel.
- FdtBlobBase = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (FdtDevicePath, AllocateMaxAddress, &FdtBlobBase, &FdtBlobSize);
- if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find Device Tree blob (%r).\n", Status);
+ //
+ // Get the FDT from the Configuration Table.
+ // The FDT will be reloaded in PrepareFdt() to a more appropriate
+ // location for the Linux Kernel.
+ //
+ Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &InstalledFdtBase);
+ if (EFI_ERROR (Status)) {
+ Print (L"ERROR: Did not get the Device Tree blob (%r).\n", Status);
goto EXIT_FREE_INITRD;
}
+ FdtBlobBase = (EFI_PHYSICAL_ADDRESS)InstalledFdtBase;
+ FdtBlobSize = fdt_totalsize (InstalledFdtBase);
//
// Install secondary core pens if the Power State Coordination Interface is not supported
diff --git a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c b/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c index 42f301d..e5fda08 100644 --- a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c +++ b/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c @@ -12,6 +12,9 @@ *
**/
+#include <Guid/Fdt.h>
+#include <libfdt.h>
+
#include "BdsInternal.h"
#include "BdsLinuxLoader.h"
@@ -222,9 +225,9 @@ EXIT_FREE_LINUX: /**
Start a Linux kernel from a Device Path
- @param LinuxKernel Device Path to the Linux Kernel
- @param Parameters Linux kernel arguments
- @param Fdt Device Path to the Flat Device Tree
+ @param LinuxKernelDevicePath Device Path to the Linux Kernel
+ @param InitrdDevicePath Device Path to the Initrd
+ @param CommandLineArguments Linux command line
@retval EFI_SUCCESS All drivers have been connected
@retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
@@ -235,19 +238,19 @@ EFI_STATUS BdsBootLinuxFdt (
IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* CommandLineArguments,
- IN EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath
+ IN CONST CHAR8* CommandLineArguments
)
{
- EFI_STATUS Status;
- UINT32 LinuxImageSize;
- UINT32 InitrdImageBaseSize = 0;
- UINT32 InitrdImageSize = 0;
- UINT32 FdtBlobSize;
- EFI_PHYSICAL_ADDRESS FdtBlobBase;
- EFI_PHYSICAL_ADDRESS LinuxImage;
- EFI_PHYSICAL_ADDRESS InitrdImageBase = 0;
- EFI_PHYSICAL_ADDRESS InitrdImage = 0;
+ EFI_STATUS Status;
+ UINT32 LinuxImageSize;
+ UINT32 InitrdImageBaseSize = 0;
+ UINT32 InitrdImageSize = 0;
+ VOID *InstalledFdtBase;
+ UINT32 FdtBlobSize;
+ EFI_PHYSICAL_ADDRESS FdtBlobBase;
+ EFI_PHYSICAL_ADDRESS LinuxImage;
+ EFI_PHYSICAL_ADDRESS InitrdImageBase = 0;
+ EFI_PHYSICAL_ADDRESS InitrdImage = 0;
PERF_START (NULL, "BDS", NULL, 0);
@@ -281,13 +284,18 @@ BdsBootLinuxFdt ( }
}
- // Load the FDT binary from a device path. The FDT will be reloaded later to a more appropriate location for the Linux kernel.
- FdtBlobBase = 0;
- Status = BdsLoadImage (FdtDevicePath, AllocateAnyPages, &FdtBlobBase, &FdtBlobSize);
- if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find Device Tree blob.\n");
+ //
+ // Get the FDT from the Configuration Table.
+ // The FDT will be reloaded in PrepareFdt() to a more appropriate
+ // location for the Linux Kernel.
+ //
+ Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &InstalledFdtBase);
+ if (EFI_ERROR (Status)) {
+ Print (L"ERROR: Did not get the Device Tree blob (%r).\n", Status);
goto EXIT_FREE_INITRD;
}
+ FdtBlobBase = (EFI_PHYSICAL_ADDRESS)(UINTN)InstalledFdtBase;
+ FdtBlobSize = fdt_totalsize (InstalledFdtBase);
// Update the Fdt with the Initrd information. The FDT will increase in size.
// By setting address=0 we leave the memory allocation to the function
diff --git a/ArmPkg/Library/BdsLib/BdsLib.inf b/ArmPkg/Library/BdsLib/BdsLib.inf index 6d6a2df..ecf6de5 100644 --- a/ArmPkg/Library/BdsLib/BdsLib.inf +++ b/ArmPkg/Library/BdsLib/BdsLib.inf @@ -36,10 +36,10 @@ AArch64/BdsLinuxLoaderHelper.S
[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
ArmPkg/ArmPkg.dec
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
[LibraryClasses]
@@ -63,6 +63,7 @@ gEfiFileInfoGuid
gArmMpCoreInfoGuid
gArmGlobalVariableGuid
+ gFdtTableGuid
[Protocols]
gEfiBdsArchProtocolGuid
|