Discussion:
[edk2] [PATCH 1/8] ArmPkg/BdsLib: Replaced BdsLoadApplication() by LocateEfiApplicationInFv(Name|Guid)()
Olivier Martin
2015-07-13 16:36:41 UTC
Permalink
Replaced the function BdsLoadApplication() by two explicit
functions that load the EFI application either by its GUID
or its Name.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <***@arm.com>
Reviewed-by: Ronald Cron <***@arm.com>
---
ArmPkg/Include/Library/BdsLib.h | 52 ++++---
ArmPkg/Library/BdsLib/BdsAppLoader.c | 283 ++++++++++++++++++++++++-----------
ArmPlatformPkg/Bds/Bds.inf | 3 +
ArmPlatformPkg/Bds/BootMenu.c | 24 ++-
4 files changed, 250 insertions(+), 112 deletions(-)

diff --git a/ArmPkg/Include/Library/BdsLib.h b/ArmPkg/Include/Library/BdsLib.h
index c6416db..3d9e195 100644
--- a/ArmPkg/Include/Library/BdsLib.h
+++ b/ArmPkg/Include/Library/BdsLib.h
@@ -193,24 +193,6 @@ BdsStartEfiApplication (
IN VOID* LoadOptions
);

-/**
- Start an EFI Application from any Firmware Volume
-
- @param EfiApp EFI Application Name
-
- @retval EFI_SUCCESS All drivers have been connected
- @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsLoadApplication (
- IN EFI_HANDLE ParentImageHandle,
- IN CHAR16* EfiApp,
- IN UINTN LoadOptionsSize,
- IN VOID* LoadOptions
- );
-
EFI_STATUS
BdsLoadImage (
IN EFI_DEVICE_PATH *DevicePath,
@@ -227,4 +209,38 @@ ShutdownUefiBootServices (
VOID
);

+/**
+ Locate an EFI application in a the Firmware Volumes by its name
+
+ @param EfiAppGuid Guid of the EFI Application into the Firmware Volume
+ @param DevicePath EFI Device Path of the EFI application
+
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The protocol could not be located.
+ @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
+
+**/
+EFI_STATUS
+LocateEfiApplicationInFvByName (
+ IN CONST CHAR16* EfiAppName,
+ OUT EFI_DEVICE_PATH **DevicePath
+ );
+
+/**
+ Locate an EFI application in a the Firmware Volumes by its GUID
+
+ @param EfiAppGuid Guid of the EFI Application into the Firmware Volume
+ @param DevicePath EFI Device Path of the EFI application
+
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The protocol could not be located.
+ @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
+
+**/
+EFI_STATUS
+LocateEfiApplicationInFvByGuid (
+ IN CONST EFI_GUID *EfiAppGuid,
+ OUT EFI_DEVICE_PATH **DevicePath
+ );
+
#endif
diff --git a/ArmPkg/Library/BdsLib/BdsAppLoader.c b/ArmPkg/Library/BdsLib/BdsAppLoader.c
index 2b88bf1..1f208f8 100644
--- a/ArmPkg/Library/BdsLib/BdsAppLoader.c
+++ b/ArmPkg/Library/BdsLib/BdsAppLoader.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -14,18 +14,23 @@

#include "BdsInternal.h"

-//#include <Library/DxeServicesLib.h>
+/**
+ Locate an EFI application in a the Firmware Volumes by its Name
+
+ @param EfiAppGuid Guid of the EFI Application into the Firmware Volume
+ @param DevicePath EFI Device Path of the EFI application
+
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The protocol could not be located.
+ @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.

-STATIC
+**/
EFI_STATUS
-BdsLoadFileFromFirmwareVolume (
- IN EFI_HANDLE FvHandle,
- IN CHAR16 *FilePath,
- IN EFI_FV_FILETYPE FileTypeFilter,
- OUT EFI_DEVICE_PATH **EfiAppDevicePath
+LocateEfiApplicationInFvByName (
+ IN CONST CHAR16* EfiAppName,
+ OUT EFI_DEVICE_PATH **DevicePath
)
{
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
VOID *Key;
EFI_STATUS Status, FileStatus;
EFI_GUID NameGuid;
@@ -37,108 +42,212 @@ BdsLoadFileFromFirmwareVolume (
UINT32 Authentication;
EFI_DEVICE_PATH *FvDevicePath;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileDevicePath;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ UINTN Index;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance;

- Status = gBS->HandleProtocol (FvHandle,&gEfiFirmwareVolume2ProtocolGuid, (VOID **)&FvProtocol);
- if (EFI_ERROR(Status)) {
- return Status;
- }
+ ASSERT (DevicePath != NULL);

// Length of FilePath
- UiStringLen = StrLen (FilePath);
-
- // Allocate Key
- Key = AllocatePool (FvProtocol->KeySize);
- ASSERT (Key != NULL);
- ZeroMem (Key, FvProtocol->KeySize);
+ UiStringLen = StrLen (EfiAppName);
+
+ // Locate all the Firmware Volume protocols.
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ NULL,
+ &NumberOfHandles,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }

- do {
- // Search in all files
- FileType = FileTypeFilter;
+ *DevicePath = NULL;
+
+ // Looking for FV with ACPI storage file
+ for (Index = 0; Index < NumberOfHandles; Index++) {
+ //
+ // Get the protocol on this handle
+ // This should not fail because of LocateHandleBuffer
+ //
+ Status = gBS->HandleProtocol (
+ HandleBuffer[Index],
+ &gEfiFirmwareVolume2ProtocolGuid,
+ (VOID**) &FvInstance
+ );
+ if (EFI_ERROR (Status)) {
+ goto FREE_HANDLE_BUFFER;
+ }

- Status = FvProtocol->GetNextFile (FvProtocol, Key, &FileType, &NameGuid, &Attributes, &Size);
- if (!EFI_ERROR (Status)) {
- UiSection = NULL;
- FileStatus = FvProtocol->ReadSection (
- FvProtocol,
- &NameGuid,
- EFI_SECTION_USER_INTERFACE,
- 0,
- (VOID **)&UiSection,
- &Size,
- &Authentication
- );
- if (!EFI_ERROR (FileStatus)) {
- if (StrnCmp (FilePath, UiSection, UiStringLen) == 0) {
- //
- // We found a UiString match.
- //
- Status = gBS->HandleProtocol (FvHandle, &gEfiDevicePathProtocolGuid, (VOID **)&FvDevicePath);
-
- // Generate the Device Path for the file
- //DevicePath = DuplicateDevicePath(FvDevicePath);
- EfiInitializeFwVolDevicepathNode (&FileDevicePath, &NameGuid);
- *EfiAppDevicePath = AppendDevicePathNode (FvDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&FileDevicePath);
-
- FreePool (Key);
+ // Allocate Key
+ Key = AllocatePool (FvInstance->KeySize);
+ ASSERT (Key != NULL);
+ ZeroMem (Key, FvInstance->KeySize);
+
+ do {
+ // Search in all files
+ FileType = EFI_FV_FILETYPE_ALL;
+
+ Status = FvInstance->GetNextFile (FvInstance, Key, &FileType, &NameGuid, &Attributes, &Size);
+ if (!EFI_ERROR (Status)) {
+ UiSection = NULL;
+ FileStatus = FvInstance->ReadSection (
+ FvInstance,
+ &NameGuid,
+ EFI_SECTION_USER_INTERFACE,
+ 0,
+ (VOID **)&UiSection,
+ &Size,
+ &Authentication
+ );
+ if (!EFI_ERROR (FileStatus)) {
+ if (StrnCmp (EfiAppName, UiSection, UiStringLen) == 0) {
+ //
+ // We found a UiString match.
+ //
+ Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **)&FvDevicePath);
+
+ // Generate the Device Path for the file
+ EfiInitializeFwVolDevicepathNode (&FileDevicePath, &NameGuid);
+ *DevicePath = AppendDevicePathNode (FvDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&FileDevicePath);
+ ASSERT (*DevicePath != NULL);
+
+ FreePool (Key);
+ FreePool (UiSection);
+ FreePool (HandleBuffer);
+ return FileStatus;
+ }
FreePool (UiSection);
- return FileStatus;
}
- FreePool (UiSection);
}
- }
- } while (!EFI_ERROR (Status));
+ } while (!EFI_ERROR (Status));

- FreePool(Key);
- return Status;
+ FreePool (Key);
+ }
+
+FREE_HANDLE_BUFFER:
+ FreePool (HandleBuffer);
+ return EFI_NOT_FOUND;
}

/**
- Start an EFI Application from any Firmware Volume
+ Locate an EFI application in a the Firmware Volumes by its GUID

- @param EfiApp EFI Application Name
+ @param EfiAppGuid Guid of the EFI Application into the Firmware Volume
+ @param DevicePath EFI Device Path of the EFI application

- @retval EFI_SUCCESS All drivers have been connected
- @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The protocol could not be located.
+ @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.

**/
EFI_STATUS
-BdsLoadApplication (
- IN EFI_HANDLE ParentImageHandle,
- IN CHAR16* EfiApp,
- IN UINTN LoadOptionsSize,
- IN VOID* LoadOptions
+LocateEfiApplicationInFvByGuid (
+ IN CONST EFI_GUID *EfiAppGuid,
+ OUT EFI_DEVICE_PATH **DevicePath
)
{
- EFI_STATUS Status;
- UINTN NoHandles, HandleIndex;
- EFI_HANDLE *Handles;
- EFI_DEVICE_PATH *EfiAppDevicePath;
-
- // Need to connect every drivers to ensure no dependencies are missing for the application
- Status = BdsConnectAllDrivers();
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "FAIL to connect all drivers\n"));
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH *FvDevicePath;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ UINTN Index;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance;
+ EFI_FV_FILE_ATTRIBUTES Attributes;
+ UINT32 AuthenticationStatus;
+ EFI_FV_FILETYPE Type;
+ UINTN Size;
+ CHAR16 *UiSection;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FvFileDevicePath;
+
+ ASSERT (DevicePath != NULL);
+
+ // Locate all the Firmware Volume protocols.
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ NULL,
+ &NumberOfHandles,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
return Status;
}

- // Search the application in any Firmware Volume
- Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiFirmwareVolume2ProtocolGuid, NULL, &NoHandles, &Handles);
- if (EFI_ERROR (Status) || (NoHandles == 0)) {
- DEBUG ((EFI_D_ERROR, "FAIL to find Firmware Volume\n"));
- return Status;
- }
+ *DevicePath = NULL;
+
+ // Looking for FV with ACPI storage file
+ for (Index = 0; Index < NumberOfHandles; Index++) {
+ //
+ // Get the protocol on this handle
+ // This should not fail because of LocateHandleBuffer
+ //
+ Status = gBS->HandleProtocol (
+ HandleBuffer[Index],
+ &gEfiFirmwareVolume2ProtocolGuid,
+ (VOID**) &FvInstance
+ );
+ if (EFI_ERROR (Status)) {
+ goto FREE_HANDLE_BUFFER;
+ }

- // Search in all Firmware Volume for the EFI Application
- for (HandleIndex = 0; HandleIndex < NoHandles; HandleIndex++) {
- EfiAppDevicePath = NULL;
- Status = BdsLoadFileFromFirmwareVolume (Handles[HandleIndex], EfiApp, EFI_FV_FILETYPE_APPLICATION, &EfiAppDevicePath);
- if (!EFI_ERROR (Status)) {
- // Start the application
- Status = BdsStartEfiApplication (ParentImageHandle, EfiAppDevicePath, LoadOptionsSize, LoadOptions);
- return Status;
+ Status = FvInstance->ReadFile (
+ FvInstance,
+ EfiAppGuid,
+ NULL,
+ &Size,
+ &Type,
+ &Attributes,
+ &AuthenticationStatus
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // Skip if no EFI application file in the FV
+ //
+ continue;
+ } else {
+ UiSection = NULL;
+ Status = FvInstance->ReadSection (
+ FvInstance,
+ EfiAppGuid,
+ EFI_SECTION_USER_INTERFACE,
+ 0,
+ (VOID **)&UiSection,
+ &Size,
+ &AuthenticationStatus
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Create the EFI Device Path for the application using the Filename of the application
+ //
+ *DevicePath = FileDevicePath (HandleBuffer[Index], UiSection);
+ } else {
+ Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID**)&FvDevicePath);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Create the EFI Device Path for the application using the EFI GUID of the application
+ //
+ EfiInitializeFwVolDevicepathNode (&FvFileDevicePath, EfiAppGuid);
+
+ *DevicePath = AppendDevicePathNode (FvDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&FvFileDevicePath);
+ ASSERT (*DevicePath != NULL);
+ }
+ break;
}
}

- return Status;
+FREE_HANDLE_BUFFER:
+ //
+ // Free any allocated buffers
+ //
+ FreePool (HandleBuffer);
+
+ if (*DevicePath == NULL) {
+ return EFI_NOT_FOUND;
+ } else {
+ return EFI_SUCCESS;
+ }
}
diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index f4c0f1c..76a45e0 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -37,6 +37,7 @@
ArmPkg/ArmPkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
EmbeddedPkg/EmbeddedPkg.dec
+ IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec

[LibraryClasses]
BdsLib
@@ -79,5 +80,7 @@
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths

+ gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile
+
[Depex]
TRUE
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c
index d2dccbc..a304cc4 100644
--- a/ArmPlatformPkg/Bds/BootMenu.c
+++ b/ArmPlatformPkg/Bds/BootMenu.c
@@ -1069,17 +1069,27 @@ BootShell (
IN LIST_ENTRY *BootOptionsList
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH* EfiShellDevicePath;

- // Start EFI Shell
- Status = BdsLoadApplication (gImageHandle, L"Shell", 0, NULL);
+ // Find the EFI Shell
+ Status = LocateEfiApplicationInFvByName (L"Shell", &EfiShellDevicePath);
if (Status == EFI_NOT_FOUND) {
Print (L"Error: EFI Application not found.\n");
- } else if (EFI_ERROR(Status)) {
- Print (L"Error: Status Code: 0x%X\n",(UINT32)Status);
- }
+ return Status;
+ } else if (EFI_ERROR (Status)) {
+ Print (L"Error: Status Code: 0x%X\n", (UINT32)Status);
+ return Status;
+ } else {
+ // Need to connect every drivers to ensure no dependencies are missing for the application
+ Status = BdsConnectAllDrivers ();
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "FAIL to connect all drivers\n"));
+ return Status;
+ }

- return Status;
+ return BdsStartEfiApplication (gImageHandle, EfiShellDevicePath, 0, NULL);
+ }
}

struct BOOT_MAIN_ENTRY {
--
2.1.1
Olivier Martin
2015-07-13 16:36:43 UTC
Permalink
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 <***@arm.com>
Reviewed-by: Ronald Cron <***@arm.com>
---
.../AndroidFastboot/AndroidFastbootApp.inf | 3 +-
.../AndroidFastboot/Arm/BootAndroidBootImg.c | 48 +++++++++++++++++++---
2 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
index ab9354c..ca17af8 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
+++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
@@ -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]
diff --git a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
index 7e9ad88..3053cf0 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
+++ b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
@@ -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 @@ BootAndroidBootImg (
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 @@ BootAndroidBootImg (
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"));
--
2.1.1
Olivier Martin
2015-07-13 16:36:52 UTC
Permalink
When PcdBdsLinuxSupport is enabled, users can create boot
entries for the legacy EFI Linux loader.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <***@arm.com>
Reviewed-by: Ronald Cron <***@arm.com>
---
ArmPlatformPkg/ArmPlatformPkg.dec | 3 +
ArmPlatformPkg/Bds/Bds.inf | 4 +
ArmPlatformPkg/Bds/BdsHelper.c | 9 ---
ArmPlatformPkg/Bds/BdsInternal.h | 26 ++++--
ArmPlatformPkg/Bds/BootLinux.c | 124 +++++++++++++++++++++++++++++
ArmPlatformPkg/Bds/BootMenu.c | 161 +++++++++++++++++++++++++++++---------
6 files changed, 274 insertions(+), 53 deletions(-)
create mode 100644 ArmPlatformPkg/Bds/BootLinux.c

diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index be0919b..45aeaee 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -61,6 +61,9 @@
# we assume the OS will handle the FrameBuffer from the UEFI GOP information.
gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices|FALSE|BOOLEAN|0x0000003D

+ # Enable Legacy Linux support in the BDS
+ gArmPlatformTokenSpaceGuid.PcdBdsLinuxSupport|TRUE|BOOLEAN|0x0000002E
+
[PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdCoreCount|1|UINT32|0x00000039
gArmPlatformTokenSpaceGuid.PcdClusterCount|1|UINT32|0x00000038
diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index 3b6ffc3..06e8d91 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -27,6 +27,7 @@
[Sources]
Bds.c
BdsHelper.c
+ BootLinux.c
BootMenu.c
BootOption.c
BootOptionSupport.c
@@ -72,6 +73,9 @@
gEfiDhcp4ServiceBindingProtocolGuid
gEfiMtftp4ServiceBindingProtocolGuid

+[FeaturePcd]
+ gArmPlatformTokenSpaceGuid.PcdBdsLinuxSupport
+
[Pcd]
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription
diff --git a/ArmPlatformPkg/Bds/BdsHelper.c b/ArmPlatformPkg/Bds/BdsHelper.c
index b3003e9..732292c 100644
--- a/ArmPlatformPkg/Bds/BdsHelper.c
+++ b/ArmPlatformPkg/Bds/BdsHelper.c
@@ -256,15 +256,6 @@ GetHIInputBoolean (
}
}

-BOOLEAN
-HasFilePathEfiExtension (
- IN CHAR16* FilePath
- )
-{
- return (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".EFI") == 0) ||
- (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".efi") == 0);
-}
-
// Return the last non end-type Device Path Node from a Device Path
EFI_DEVICE_PATH*
GetLastDevicePathNode (
diff --git a/ArmPlatformPkg/Bds/BdsInternal.h b/ArmPlatformPkg/Bds/BdsInternal.h
index fe4fd79..ddf5308 100644
--- a/ArmPlatformPkg/Bds/BdsInternal.h
+++ b/ArmPlatformPkg/Bds/BdsInternal.h
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -79,6 +79,12 @@ typedef struct _BDS_LOAD_OPTION_SUPPORT {
#define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)
#define LOAD_OPTION_FROM_LINK(a) ((BDS_LOAD_OPTION_ENTRY*)BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link))->BdsLoadOption

+// GUID of the EFI Linux Loader
+extern CONST EFI_GUID mLinuxLoaderAppGuid;
+
+// Device path of the EFI Linux Loader in the Firmware Volume
+extern EFI_DEVICE_PATH* mLinuxLoaderDevicePath;
+
EFI_STATUS
BootDeviceListSupportedInit (
IN OUT LIST_ENTRY *SupportedDeviceList
@@ -141,11 +147,6 @@ GetHIInputBoolean (
OUT BOOLEAN *Value
);

-BOOLEAN
-HasFilePathEfiExtension (
- IN CHAR16* FilePath
- );
-
EFI_DEVICE_PATH*
GetLastDevicePathNode (
IN EFI_DEVICE_PATH* DevicePath
@@ -260,4 +261,17 @@ EmptyCallbackFunction (
IN VOID *Context
);

+/**
+ * This function check if the DevicePath defines an EFI binary
+ *
+ * This function is used when the BDS support Linux loader to
+ * detect if the binary is an EFI application or potentially a
+ * Linux kernel.
+ */
+EFI_STATUS
+IsEfiBinary (
+ IN EFI_DEVICE_PATH* DevicePath,
+ OUT BOOLEAN *EfiBinary
+ );
+
#endif /* _BDSINTERNAL_H_ */
diff --git a/ArmPlatformPkg/Bds/BootLinux.c b/ArmPlatformPkg/Bds/BootLinux.c
new file mode 100644
index 0000000..0445e89
--- /dev/null
+++ b/ArmPlatformPkg/Bds/BootLinux.c
@@ -0,0 +1,124 @@
+/** @file
+*
+* Copyright (c) 2011 - 2015, ARM Limited. All rights reserved.
+*
+* This program and the accompanying materials
+* are licensed and made available under the terms and conditions of the BSD License
+* which accompanies this distribution. The full text of the license may be found at
+* http://opensource.org/licenses/bsd-license.php
+*
+* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+
+#include "BdsInternal.h"
+
+// 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 of the EFI Linux Loader in the Firmware Volume
+EFI_DEVICE_PATH* mLinuxLoaderDevicePath = NULL;
+
+STATIC
+BOOLEAN
+HasFilePathEfiExtension (
+ IN CHAR16* FilePath
+ )
+{
+ return (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".EFI") == 0) ||
+ (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".efi") == 0);
+}
+
+/**
+ * This function check if the DevicePath defines an EFI binary
+ *
+ * This function is used when the BDS support Linux loader to
+ * detect if the binary is an EFI application or potentially a
+ * Linux kernel.
+ */
+EFI_STATUS
+IsEfiBinary (
+ IN EFI_DEVICE_PATH* DevicePath,
+ OUT BOOLEAN *EfiBinary
+ )
+{
+ EFI_STATUS Status;
+ CHAR16* FileName;
+ EFI_DEVICE_PATH* PrevDevicePathNode;
+ EFI_DEVICE_PATH* DevicePathNode;
+ EFI_PHYSICAL_ADDRESS Image;
+ UINTN FileSize;
+ EFI_IMAGE_DOS_HEADER* DosHeader;
+ UINTN PeCoffHeaderOffset;
+ EFI_IMAGE_NT_HEADERS32* NtHeader;
+
+ ASSERT (EfiBinary != NULL);
+
+ //
+ // Check if the last node of the device path is a FilePath node
+ //
+ PrevDevicePathNode = NULL;
+ DevicePathNode = DevicePath;
+ while ((DevicePathNode != NULL) && !IsDevicePathEnd (DevicePathNode)) {
+ PrevDevicePathNode = DevicePathNode;
+ DevicePathNode = NextDevicePathNode (DevicePathNode);
+ }
+
+ if ((PrevDevicePathNode != NULL) &&
+ (PrevDevicePathNode->Type == MEDIA_DEVICE_PATH) &&
+ (PrevDevicePathNode->SubType == MEDIA_FILEPATH_DP))
+ {
+ FileName = ((FILEPATH_DEVICE_PATH*)PrevDevicePathNode)->PathName;
+ } else {
+ FileName = NULL;
+ }
+
+ if (FileName == NULL) {
+ Print (L"Is an EFI Application? ");
+ Status = GetHIInputBoolean (EfiBinary);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ } else if (HasFilePathEfiExtension (FileName)) {
+ *EfiBinary = TRUE;
+ } else {
+ // Check if the file exist
+ Status = BdsLoadImage (DevicePath, AllocateAnyPages, &Image, &FileSize);
+ if (!EFI_ERROR (Status)) {
+
+ DosHeader = (EFI_IMAGE_DOS_HEADER *)(UINTN) Image;
+ if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present,
+ // so read the PE header after the DOS image header.
+ //
+ PeCoffHeaderOffset = DosHeader->e_lfanew;
+ } else {
+ PeCoffHeaderOffset = 0;
+ }
+
+ //
+ // Check PE/COFF image.
+ //
+ NtHeader = (EFI_IMAGE_NT_HEADERS32 *)(UINTN) (Image + PeCoffHeaderOffset);
+ if (NtHeader->Signature != EFI_IMAGE_NT_SIGNATURE) {
+ *EfiBinary = FALSE;
+ } else {
+ *EfiBinary = TRUE;
+ }
+
+ // Free memory
+ gBS->FreePages (Image, EFI_SIZE_TO_PAGES (FileSize));
+ } else {
+ // If we did not manage to open it then ask for the type
+ Print (L"Is an EFI Application? ");
+ Status = GetHIInputBoolean (EfiBinary);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c
index af7f1f1..8caa3ce 100644
--- a/ArmPlatformPkg/Bds/BootMenu.c
+++ b/ArmPlatformPkg/Bds/BootMenu.c
@@ -269,6 +269,8 @@ BootMenuAddBootOption (
EFI_DEVICE_PATH_PROTOCOL *DevicePathNodes;
UINT8* OptionalData;
UINTN OptionalDataSize;
+ BOOLEAN EfiBinary;
+ CHAR16 *LinuxDevicePath;

Attributes = 0;
SupportedBootDevice = NULL;
@@ -281,8 +283,12 @@ BootMenuAddBootOption (
}

// Create the specific device path node
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes);
- if (EFI_ERROR(Status)) {
+ if (FeaturePcdGet (PcdBdsLinuxSupport) && mLinuxLoaderDevicePath) {
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes);
+ } else {
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application", &DevicePathNodes);
+ }
+ if (EFI_ERROR (Status)) {
Status = EFI_ABORTED;
goto EXIT;
}
@@ -293,8 +299,39 @@ BootMenuAddBootOption (
goto EXIT;
}

+ // Is it an EFI application?
+ if (FeaturePcdGet (PcdBdsLinuxSupport) && mLinuxLoaderDevicePath) {
+ Status = IsEfiBinary (DevicePath, &EfiBinary);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ if (EfiBinary == FALSE) {
+ Print (L"It is assumed the binary is a Linux kernel and the embedded Linux Loader is going to be used.\n");
+ Print (L"Supported command line formats by the embedded Linux Loader:\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\"\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\" -f <EFI Device Path of the Linux initrd>\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\" -a <Machine Type for ATAG Linux kernel>\n");
+
+ // Copy the Linux path into the command line
+ LinuxDevicePath = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
+ CopyMem (CmdLine, LinuxDevicePath, MAX (sizeof (CmdLine), StrSize (LinuxDevicePath)));
+ FreePool (LinuxDevicePath);
+
+ // Free the generated Device Path
+ FreePool (DevicePath);
+ // and use the embedded Linux Loader as the EFI application
+ DevicePath = mLinuxLoaderDevicePath;
+ } else {
+ CmdLine[0] = L'\0';
+ }
+ } else {
+ CmdLine[0] = L'\0';
+ }
+
Print (L"Arguments to pass to the EFI Application: ");
- Status = GetHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);
+ Status = EditHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);
if (EFI_ERROR (Status)) {
Status = EFI_ABORTED;
goto EXIT;
@@ -366,11 +403,13 @@ BootMenuUpdateBootOption (
CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];
CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];
CHAR16 UnicodeCmdLine[BOOT_DEVICE_OPTION_MAX];
+ CHAR16 *LinuxDevicePath;
EFI_DEVICE_PATH *DevicePath;
UINT8* OptionalData;
UINTN OptionalDataSize;
BOOLEAN IsPrintable;
BOOLEAN IsUnicode;
+ BOOLEAN EfiBinary;

DisplayBootOptions (BootOptionsList);
Status = SelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, &BootOptionEntry);
@@ -386,46 +425,87 @@ BootMenuUpdateBootOption (
return EFI_UNSUPPORTED;
}

- Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
+ EfiBinary = TRUE;
+ if (FeaturePcdGet (PcdBdsLinuxSupport) && mLinuxLoaderDevicePath) {
+ Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ // Is it an EFI application?
+ Status = IsEfiBinary (DevicePath, &EfiBinary);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ if (EfiBinary == FALSE) {
+ Print (L"It is assumed the binary is a Linux kernel and the embedded Linux Loader is going to be used.\n");
+ Print (L"Supported command line formats by the embedded Linux Loader:\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\"\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\" -f <EFI Device Path of the Linux initrd>\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\" -a <Machine Type for ATAG Linux kernel>\n");
+
+ // Copy the Linux path into the command line
+ LinuxDevicePath = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
+ CopyMem (UnicodeCmdLine, LinuxDevicePath, MAX (sizeof (UnicodeCmdLine), StrSize (LinuxDevicePath)));
+ FreePool (LinuxDevicePath);
+
+ // Free the generated Device Path
+ FreePool (DevicePath);
+ // and use the embedded Linux Loader as the EFI application
+ DevicePath = mLinuxLoaderDevicePath;
+
+ // The command line is a unicode printable string
+ IsPrintable = TRUE;
+ IsUnicode = TRUE;
+ }
+ } else {
+ Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application", &DevicePath);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
}

Print (L"Arguments to pass to the EFI Application: ");

- if (BootOption->OptionalDataSize > 0) {
- IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);
- if (IsPrintable) {
- //
- // The size in bytes of the string, final zero included, should
- // be equal to or at least lower than "BootOption->OptionalDataSize"
- // and the "IsPrintableString()" has already tested that the length
- // in number of characters is smaller than BOOT_DEVICE_OPTION_MAX,
- // final '\0' included. We can thus copy the string for editing
- // using "CopyMem()". Furthermore, note that in the case of an Unicode
- // string "StrnCpy()" and "StrCpy()" can not be used to copy the
- // string because the data pointed to by "BootOption->OptionalData"
- // is not necessarily 2-byte aligned.
- //
- if (IsUnicode) {
- CopyMem (
- UnicodeCmdLine, BootOption->OptionalData,
- MIN (sizeof (UnicodeCmdLine),
- BootOption->OptionalDataSize)
- );
- } else {
- CopyMem (
- CmdLine, BootOption->OptionalData,
- MIN (sizeof (CmdLine),
- BootOption->OptionalDataSize)
- );
+ // When the command line has not been initialized by the embedded Linux loader earlier
+ if (EfiBinary) {
+ if (BootOption->OptionalDataSize > 0) {
+ IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);
+ if (IsPrintable) {
+ //
+ // The size in bytes of the string, final zero included, should
+ // be equal to or at least lower than "BootOption->OptionalDataSize"
+ // and the "IsPrintableString()" has already tested that the length
+ // in number of characters is smaller than BOOT_DEVICE_OPTION_MAX,
+ // final '\0' included. We can thus copy the string for editing
+ // using "CopyMem()". Furthermore, note that in the case of an Unicode
+ // string "StrnCpy()" and "StrCpy()" can not be used to copy the
+ // string because the data pointed to by "BootOption->OptionalData"
+ // is not necessarily 2-byte aligned.
+ //
+ if (IsUnicode) {
+ CopyMem (
+ UnicodeCmdLine, BootOption->OptionalData,
+ MIN (sizeof (UnicodeCmdLine),
+ BootOption->OptionalDataSize)
+ );
+ } else {
+ CopyMem (
+ CmdLine, BootOption->OptionalData,
+ MIN (sizeof (CmdLine),
+ BootOption->OptionalDataSize)
+ );
+ }
}
+ } else {
+ UnicodeCmdLine[0] = L'\0';
+ IsPrintable = TRUE;
+ IsUnicode = TRUE;
}
- } else {
- UnicodeCmdLine[0] = L'\0';
- IsPrintable = TRUE;
- IsUnicode = TRUE;
}

// We do not request arguments for OptionalData that cannot be printed
@@ -909,7 +989,6 @@ struct BOOT_MAIN_ENTRY {
{ L"Boot Manager", BootMenuManager },
};

-
EFI_STATUS
BootMenuMain (
VOID
@@ -929,6 +1008,12 @@ BootMenuMain (
BootOption = NULL;
BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY);

+ if (FeaturePcdGet (PcdBdsLinuxSupport)) {
+ // Check Linux Loader is present
+ Status = LocateEfiApplicationInFvByGuid (&mLinuxLoaderAppGuid, &mLinuxLoaderDevicePath);
+ ASSERT_EFI_ERROR (Status);
+ }
+
while (TRUE) {
// Get Boot#### list
BootOptionList (&BootOptionsList);
--
2.1.1
Olivier Martin
2015-07-13 16:36:46 UTC
Permalink
From: Ronald Cron <***@arm.com>

Add the legacy Linux Loader EFI application to the ARM
development platforms.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <***@arm.com>
Reviewed-by: Olivier Martin <***@arm.com>
---
ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf | 1 +
ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc | 12 ++++++++++++
ArmPlatformPkg/ArmPlatformPkg-2ndstage.fdf | 4 +++-
ArmPlatformPkg/ArmPlatformPkg.dsc | 13 +++++++++++++
ArmPlatformPkg/ArmPlatformPkg.fdf | 4 +++-
.../ArmRealViewEbPkg/ArmRealViewEb-RTSM-MPCore.fdf | 4 +++-
.../ArmRealViewEbPkg/ArmRealViewEb-RTSM-UniCore.fdf | 5 ++++-
ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc | 17 +++++++++++++++--
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc | 2 +-
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf | 3 +++
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc | 2 +-
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf | 3 +++
.../ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf | 3 +++
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc | 2 +-
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf | 3 +++
.../ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc | 2 +-
.../ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf | 3 +++
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc | 3 ++-
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf | 3 +++
.../ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf | 3 +++
.../ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf | 3 +++
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc | 5 ++++-
BeagleBoardPkg/BeagleBoardPkg.dsc | 14 +++++++++++++-
BeagleBoardPkg/BeagleBoardPkg.fdf | 3 +++
24 files changed, 104 insertions(+), 13 deletions(-)

diff --git a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf
index 2dbf0e6..db70609 100644
--- a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf
+++ b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf
@@ -191,6 +191,7 @@ FvNameGuid = B73FE497-B92E-416e-8326-45AD0D270092
# UEFI applications
#
INF ShellBinPkg/UefiShell/UefiShell.inf
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf

#
# Juno platform driver
diff --git a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
index 4cfb913..76415fe 100644
--- a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
@@ -89,6 +89,11 @@
# Networking Requirements for ArmPlatformPkg/Bds
NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf

+ # These libraries are used by the dynamic EFI Shell commands
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+
# EBL Related Libraries
EblCmdLib|ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf
EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf
@@ -298,6 +303,11 @@
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|20
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0

+ # We want to use the Shell Libraries but don't want it to initialise
+ # automatically. We initialise the libraries when the command is called by the
+ # Shell.
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+
#
# ARM Pcds
#
@@ -369,3 +379,5 @@
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ ArmPkg/Application/LinuxLoader/LinuxLoader.inf
diff --git a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.fdf b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.fdf
index 86a94c1..9c35ebb 100644
--- a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.fdf
+++ b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.fdf
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -129,6 +129,8 @@ FvNameGuid = 5eda4200-2c5f-43cb-9da3-0baf74b1b30c
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf

[FV.FVMAIN_COMPACT]
FvAlignment = 8
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc b/ArmPlatformPkg/ArmPlatformPkg.dsc
index f9f217c..0147146 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
@@ -88,6 +88,11 @@
# Networking Requirements for ArmPlatformPkg/Bds
NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf

+ # These libraries are used by the dynamic EFI Shell commands
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+
# EBL Related Libraries
EblCmdLib|ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf
EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf
@@ -331,6 +336,11 @@
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|20
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0

+ # We want to use the Shell Libraries but don't want it to initialise
+ # automatically. We initialise the libraries when the command is called by the
+ # Shell.
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+
#
# ARM Pcds
#
@@ -434,3 +444,6 @@
#
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
ArmPlatformPkg/Bds/Bds.inf
+
+ # Legacy Linux Loader
+ ArmPkg/Application/LinuxLoader/LinuxLoader.inf
diff --git a/ArmPlatformPkg/ArmPlatformPkg.fdf b/ArmPlatformPkg/ArmPlatformPkg.fdf
index 36ca8b0..0dd9849 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.fdf
+++ b/ArmPlatformPkg/ArmPlatformPkg.fdf
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -178,6 +178,8 @@ FvNameGuid = 8fa66cd0-f773-4f26-8f9f-5e54d0804c68
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf

[FV.FVMAIN_COMPACT]
FvAlignment = 8
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-MPCore.fdf b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-MPCore.fdf
index bedcf77..85c74df 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-MPCore.fdf
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-MPCore.fdf
@@ -1,6 +1,6 @@
# FLASH layout file for ARM RealView EB.
#
-# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -177,6 +177,8 @@ FvNameGuid = 14801114-da6a-4113-985b-dc876337a15e
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf

[FV.FVMAIN_COMPACT]
FvAlignment = 8
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-UniCore.fdf b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-UniCore.fdf
index c6acf9e..55257c2 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-UniCore.fdf
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-UniCore.fdf
@@ -1,7 +1,7 @@
# FLASH layout file for ARM RealView EB.
#
# Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
-# Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.
+# Copyright (c) 2011 - 2015, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -178,6 +178,9 @@ FvNameGuid = 14801114-da6a-4113-985b-dc876337a15e
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+

[FV.FVMAIN_COMPACT]
FvAlignment = 8
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
index d0889f5..6232791 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
@@ -105,6 +105,11 @@

GdbSerialLib|ArmPlatformPkg/ArmRealViewEbPkg/Library/GdbSerialLib/GdbSerialLib.inf

+ # These libraries are used by the dynamic EFI Shell commands
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+
# BDS Libraries
BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf
FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
@@ -303,13 +308,18 @@
gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x10000048
gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x10005000

+ # We want to use the Shell Libraries but don't want it to initialise
+ # automatically. We initialise the libraries when the command is called by the
+ # Shell.
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+
#
# ARM OS Loader
#
gArmTokenSpaceGuid.PcdArmMachineType|827
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage-RTSM"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(14801114-DA6A-4113-985B-DC876337A15E)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage-RTSM -a 827 -c \"console=ttyAMA0,38400n8\""

# Use the Serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
@@ -325,3 +335,6 @@

# FV Filesystem
MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf
+
+ # Legacy Linux Loader
+ ArmPkg/Application/LinuxLoader/LinuxLoader.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
index 318c2cf..3b693c2 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
@@ -184,7 +184,7 @@
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NorFlash"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/MemoryMapped(0x0,0xE000000,0xE800000)"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400 earlyprintk debug verbose"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf
index 3cb634a..3b4b1fc 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf
@@ -172,6 +172,9 @@ FvNameGuid = 73dcb643-3862-4904-9076-a94af1890243
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
# FV Filesystem
INF MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf

diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
index ad4e7bf..baa5478 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
@@ -183,7 +183,7 @@
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"NorFlash"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/MemoryMapped(0x0,0x46000000,0x46400000)"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf
index c8f425f..7a26f3c 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf
@@ -241,6 +241,9 @@ FvNameGuid = 1a9b3625-5286-4fa6-af5f-8eabc481f3cc
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
# FV Filesystem
INF MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf

diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf
index 95d5b1d..53e2ca8 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf
@@ -203,6 +203,9 @@ FvNameGuid = 87940482-fc81-41c3-87e6-399cf85ac8a0
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
# FV Filesystem
INF MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf

diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
index bee8f95..fb42f34 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
@@ -160,7 +160,7 @@
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf
index 0f20a04..b71eb5c 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf
@@ -219,6 +219,9 @@ FvNameGuid = 9ca4f58c-341e-4f42-b37d-6042fcddb5bf
# SECTION RAW = ArmPlatformPkg/ArmVExpressPkg/Fdts/rtsm_ve-ca15x1.dtb
#}

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
[FV.FVMAIN_COMPACT]
FvAlignment = 8
ERASE_POLARITY = 1
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
index 5f85b28..09dc1db 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
@@ -162,7 +162,7 @@
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf
index 507afac..1758a5f 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf
@@ -219,6 +219,9 @@ FvNameGuid = 12c68be9-0996-49d3-8c5b-4957379027ee
# SECTION RAW = ArmPlatformPkg/ArmVExpressPkg/Fdts/rtsm_ve-ca15x4.dtb
#}

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
[FV.FVMAIN_COMPACT]
FvAlignment = 8
ERASE_POLARITY = 1
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
index 14d0cf5..2fe9e58 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
@@ -163,7 +163,8 @@
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(272E583C-B951-433F-AF42-A9C6862AF002)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage -c \"console=ttyAMA0,38400n8\""
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf
index d671489..029b608 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf
@@ -205,6 +205,9 @@ FvNameGuid = 272e583c-b951-433f-af42-a9c6862af002
# SECTION RAW = ArmPlatformPkg/ArmVExpressPkg/Fdts/rtsm_ve-ca9x4.dtb
#}

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
[FV.FVMAIN_COMPACT]
FvAlignment = 8
ERASE_POLARITY = 1
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf
index 5015266..402ee96 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf
@@ -187,6 +187,9 @@ FvNameGuid = 6685e0b5-d6bb-4c12-97ef-58bd87112dee
# FV Filesystem
INF MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
[FV.FVMAIN_COMPACT]
FvAlignment = 16
ERASE_POLARITY = 1
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf
index ee862d4..6cd125b 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf
@@ -197,6 +197,9 @@ FvNameGuid = a2fc72eb-4157-40a3-8110-14c010e810b4
# after the device drivers (eg: Ethernet) to ensure we have support for them.
INF EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
[FV.FVMAIN_COMPACT]
FvAlignment = 16
ERASE_POLARITY = 1
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
index c6b2598..3d6537a 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -383,7 +383,7 @@
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NorFlash"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/MemoryMapped(0x0,0xED000000,0xED400000)"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
@@ -436,3 +436,6 @@
# FDT installation
#
EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf
+
+ # Legacy Linux Loader
+ ArmPkg/Application/LinuxLoader/LinuxLoader.inf
diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc b/BeagleBoardPkg/BeagleBoardPkg.dsc
index 9eb364e..7aa6ce2 100644
--- a/BeagleBoardPkg/BeagleBoardPkg.dsc
+++ b/BeagleBoardPkg/BeagleBoardPkg.dsc
@@ -63,6 +63,10 @@

EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf

+ # These libraries are used by the dynamic EFI Shell commands
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf

PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf

@@ -345,13 +349,18 @@
gEmbeddedTokenSpaceGuid.PcdEmbeddedPerformanceCounterPeriodInNanoseconds|77
gEmbeddedTokenSpaceGuid.PcdEmbeddedPerformanceCounterFrequencyInHz|13000000

+ # We want to use the Shell Libraries but don't want it to initialise
+ # automatically. We initialise the libraries when the command is called by the
+ # Shell.
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+
#
# ARM Pcds
#
gArmTokenSpaceGuid.PcdArmUncachedMemoryMask|0x0000000040000000

gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SD"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(B615F1F5-5088-43CD-809C-A16E52487D00)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/zImage"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(B615F1F5-5088-43CD-809C-A16E52487D00)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=tty0 console=ttyS2,115200n8 root=UUID=a4af765b-c2b5-48f4-9564-7a4e9104c4f6 rootwait ro earlyprintk"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|10
@@ -473,6 +482,9 @@
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
#
# Example Application
#
diff --git a/BeagleBoardPkg/BeagleBoardPkg.fdf b/BeagleBoardPkg/BeagleBoardPkg.fdf
index 9bc5b13..a639244 100644
--- a/BeagleBoardPkg/BeagleBoardPkg.fdf
+++ b/BeagleBoardPkg/BeagleBoardPkg.fdf
@@ -174,6 +174,9 @@ FvNameGuid = d0dd3e90-343d-4cb3-8f69-772214989282
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+

[FV.FVMAIN_COMPACT]
FvAlignment = 8
--
2.1.1
Olivier Martin
2015-07-13 16:36:54 UTC
Permalink
There are still ARM/AArch64 Linux kernels that do not
support EFI Stub.
By using the EFI Linux loader as the default option
we can boot any Linux kernel from UEFI as Linux
kernel with EFI stub can also be booted with the
legacy way.

Change-Id: I23aa84ae46c3fbad72380c4bab92ec86fbca0c24
---
ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc | 5 ++---
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc | 4 ++--
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc | 5 +++--
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc | 5 ++---
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc | 3 ++-
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc | 5 +++--
6 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
index 9860cf0..09ec5b3 100644
--- a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
+++ b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
@@ -146,10 +146,9 @@
#
# ARM OS Loader
#
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NOR Flash"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/Image"
-
# Support the Linux EFI stub by default
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"EFI Linux from NOR Flash"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"console=ttyAMA0,115200 earlycon=pl011,0x7ff80000 root=/dev/sda1 rootwait verbose debug"

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
index 50bb556..c1e3513 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
@@ -182,8 +182,8 @@
# ARM OS Loader
#
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NorFlash"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400 earlyprintk debug verbose"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(73DCB643-3862-4904-9076-A94AF1890243)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/kernel -c \"console=ttyAMA0,38400 earlyprintk debug verbose\""

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
# PL111 - CLCD
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
index 18cc978..b7a43fc 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
@@ -180,8 +180,9 @@
#
# ARM OS Loader
#
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"NorFlash"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/Image"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NorFlash"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(1A9B3625-5286-4FA6-AF5F-8EABC481F3CC)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/kernel -c \"console=ttyAMA0,38400 earlyprintk debug verbose\""

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
index 1b6134f..119ba3a 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
@@ -174,9 +174,8 @@
# ARM OS Loader
#
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/filesystem.cpio.gz"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 loglevel=9"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(87940482-FC81-41C3-87E6-399CF85AC8A0)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image -f VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/filesystem.cpio.gz -c \"console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 loglevel=9\""

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
index 3896166..b34d9d1 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
@@ -158,7 +158,8 @@
# ARM OS Loader
#
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(9CA4F58C-341E-4F42-B37D-6042FCDDB5BF)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image -c \"console=ttyAMA0,38400 earlyprintk debug verbose\""

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
index acfe164..37f3648 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
@@ -159,8 +159,9 @@
#
# ARM OS Loader
#
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SemiHosting"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(12C68BE9-0996-49D3-8C5B-4957379027EE)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image -c \"console=ttyAMA0,38400 earlyprintk debug verbose\""

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
--
2.1.1
Olivier Martin
2015-07-13 16:36:44 UTC
Permalink
Change-Id: I8b8596c9457e079227cc00d3f7eff8cc0319cedd
---
.../AndroidFastboot/AndroidFastbootApp.inf | 3 +-
.../AndroidFastboot/Arm/BootAndroidBootImg.c | 48 +++++++++++++++++++---
2 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
index ab9354c..ca17af8 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
+++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
@@ -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]
diff --git a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
index 7e9ad88..3053cf0 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
+++ b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
@@ -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 @@ BootAndroidBootImg (
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 @@ BootAndroidBootImg (
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"));
--
2.1.1
Olivier Martin
2015-07-13 16:36:56 UTC
Permalink
PcdDefaultBootType has been removed when the embedded
Linux Loader has been removed from BdsLib.
The boot arguments (defined by PcdDefaultBootArgument) are
now always targetting EFI applications.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <***@arm.com>
Reviewed-by: Ronald Cron <***@arm.com>
---
ArmVirtPkg/ArmVirtQemu.dsc | 1 -
1 file changed, 1 deletion(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index fbc2b12..0d4f4b0 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -133,7 +133,6 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux (EFI stub) on virtio31:hd0:part0"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(837DCA9E-E874-4D82-B29A-23FE0E23D1E2,003E000A00000000)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"root=/dev/vda2 console=ttyAMA0 earlycon uefi_debug"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|0

#
# Settings for ARM BDS -- use the serial console (ConIn & ConOut).
--
2.1.1
Laszlo Ersek
2015-07-13 17:30:04 UTC
Permalink
Post by Olivier Martin
PcdDefaultBootType has been removed when the embedded
Linux Loader has been removed from BdsLib.
The boot arguments (defined by PcdDefaultBootArgument) are
now always targetting EFI applications.
Contributed-under: TianoCore Contribution Agreement 1.0
---
ArmVirtPkg/ArmVirtQemu.dsc | 1 -
1 file changed, 1 deletion(-)
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index fbc2b12..0d4f4b0 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -133,7 +133,6 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux (EFI stub) on virtio31:hd0:part0"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(837DCA9E-E874-4D82-B29A-23FE0E23D1E2,003E000A00000000)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"root=/dev/vda2 console=ttyAMA0 earlycon uefi_debug"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|0
#
# Settings for ARM BDS -- use the serial console (ConIn & ConOut).
The declaration of "gArmPlatformTokenSpaceGuid.PcdDefaultBootType" is
removed from "ArmPlatformPkg/ArmPlatformPkg.dec" in patch #5. Therefore,
if someone were to build the ArmVirtQemu.dsc platform right at patch #5,
it would break.

I'd like to request the following:
- First, please remove the code (driver, library, etc) that consumes
PcdDefaultBootType. At this point the PCD becomes unused, code-wise,
but the tree should build.
- Second, please remove the PCD assignments from the DSC files across
the tree.
- Third, please drop the PCD declaration as last step.

Thank you
Laszlo
Olivier Martin
2015-07-13 16:36:55 UTC
Permalink
PcdDefaultBootType has been removed when the embedded
Linux Loader has been removed from BdsLib.
The boot arguments (defined by PcdDefaultBootArgument) are
now always targetting EFI applications.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <***@arm.com>
Reviewed-by: Ronald Cron <***@arm.com>
Cc: Laszlo Ersek <***@redhat.com>
Cc: Ard Biesheuvel <***@linaro.org>
---
ArmVirtPkg/ArmVirtQemu.dsc | 1 -
1 file changed, 1 deletion(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index fbc2b12..0d4f4b0 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -133,7 +133,6 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux (EFI stub) on virtio31:hd0:part0"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(837DCA9E-E874-4D82-B29A-23FE0E23D1E2,003E000A00000000)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"root=/dev/vda2 console=ttyAMA0 earlycon uefi_debug"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|0

#
# Settings for ARM BDS -- use the serial console (ConIn & ConOut).
--
2.1.1
Olivier Martin
2015-07-13 16:36:42 UTC
Permalink
Change-Id: I34777219b14393759f57dc660bd386da0542376a
---
ArmPkg/Include/Library/BdsLib.h | 52 ++++---
ArmPkg/Library/BdsLib/BdsAppLoader.c | 283 ++++++++++++++++++++++++-----------
ArmPlatformPkg/Bds/Bds.inf | 3 +
ArmPlatformPkg/Bds/BootMenu.c | 24 ++-
4 files changed, 250 insertions(+), 112 deletions(-)

diff --git a/ArmPkg/Include/Library/BdsLib.h b/ArmPkg/Include/Library/BdsLib.h
index c6416db..3d9e195 100644
--- a/ArmPkg/Include/Library/BdsLib.h
+++ b/ArmPkg/Include/Library/BdsLib.h
@@ -193,24 +193,6 @@ BdsStartEfiApplication (
IN VOID* LoadOptions
);

-/**
- Start an EFI Application from any Firmware Volume
-
- @param EfiApp EFI Application Name
-
- @retval EFI_SUCCESS All drivers have been connected
- @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsLoadApplication (
- IN EFI_HANDLE ParentImageHandle,
- IN CHAR16* EfiApp,
- IN UINTN LoadOptionsSize,
- IN VOID* LoadOptions
- );
-
EFI_STATUS
BdsLoadImage (
IN EFI_DEVICE_PATH *DevicePath,
@@ -227,4 +209,38 @@ ShutdownUefiBootServices (
VOID
);

+/**
+ Locate an EFI application in a the Firmware Volumes by its name
+
+ @param EfiAppGuid Guid of the EFI Application into the Firmware Volume
+ @param DevicePath EFI Device Path of the EFI application
+
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The protocol could not be located.
+ @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
+
+**/
+EFI_STATUS
+LocateEfiApplicationInFvByName (
+ IN CONST CHAR16* EfiAppName,
+ OUT EFI_DEVICE_PATH **DevicePath
+ );
+
+/**
+ Locate an EFI application in a the Firmware Volumes by its GUID
+
+ @param EfiAppGuid Guid of the EFI Application into the Firmware Volume
+ @param DevicePath EFI Device Path of the EFI application
+
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The protocol could not be located.
+ @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
+
+**/
+EFI_STATUS
+LocateEfiApplicationInFvByGuid (
+ IN CONST EFI_GUID *EfiAppGuid,
+ OUT EFI_DEVICE_PATH **DevicePath
+ );
+
#endif
diff --git a/ArmPkg/Library/BdsLib/BdsAppLoader.c b/ArmPkg/Library/BdsLib/BdsAppLoader.c
index 2b88bf1..1f208f8 100644
--- a/ArmPkg/Library/BdsLib/BdsAppLoader.c
+++ b/ArmPkg/Library/BdsLib/BdsAppLoader.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -14,18 +14,23 @@

#include "BdsInternal.h"

-//#include <Library/DxeServicesLib.h>
+/**
+ Locate an EFI application in a the Firmware Volumes by its Name
+
+ @param EfiAppGuid Guid of the EFI Application into the Firmware Volume
+ @param DevicePath EFI Device Path of the EFI application
+
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The protocol could not be located.
+ @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.

-STATIC
+**/
EFI_STATUS
-BdsLoadFileFromFirmwareVolume (
- IN EFI_HANDLE FvHandle,
- IN CHAR16 *FilePath,
- IN EFI_FV_FILETYPE FileTypeFilter,
- OUT EFI_DEVICE_PATH **EfiAppDevicePath
+LocateEfiApplicationInFvByName (
+ IN CONST CHAR16* EfiAppName,
+ OUT EFI_DEVICE_PATH **DevicePath
)
{
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
VOID *Key;
EFI_STATUS Status, FileStatus;
EFI_GUID NameGuid;
@@ -37,108 +42,212 @@ BdsLoadFileFromFirmwareVolume (
UINT32 Authentication;
EFI_DEVICE_PATH *FvDevicePath;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileDevicePath;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ UINTN Index;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance;

- Status = gBS->HandleProtocol (FvHandle,&gEfiFirmwareVolume2ProtocolGuid, (VOID **)&FvProtocol);
- if (EFI_ERROR(Status)) {
- return Status;
- }
+ ASSERT (DevicePath != NULL);

// Length of FilePath
- UiStringLen = StrLen (FilePath);
-
- // Allocate Key
- Key = AllocatePool (FvProtocol->KeySize);
- ASSERT (Key != NULL);
- ZeroMem (Key, FvProtocol->KeySize);
+ UiStringLen = StrLen (EfiAppName);
+
+ // Locate all the Firmware Volume protocols.
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ NULL,
+ &NumberOfHandles,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }

- do {
- // Search in all files
- FileType = FileTypeFilter;
+ *DevicePath = NULL;
+
+ // Looking for FV with ACPI storage file
+ for (Index = 0; Index < NumberOfHandles; Index++) {
+ //
+ // Get the protocol on this handle
+ // This should not fail because of LocateHandleBuffer
+ //
+ Status = gBS->HandleProtocol (
+ HandleBuffer[Index],
+ &gEfiFirmwareVolume2ProtocolGuid,
+ (VOID**) &FvInstance
+ );
+ if (EFI_ERROR (Status)) {
+ goto FREE_HANDLE_BUFFER;
+ }

- Status = FvProtocol->GetNextFile (FvProtocol, Key, &FileType, &NameGuid, &Attributes, &Size);
- if (!EFI_ERROR (Status)) {
- UiSection = NULL;
- FileStatus = FvProtocol->ReadSection (
- FvProtocol,
- &NameGuid,
- EFI_SECTION_USER_INTERFACE,
- 0,
- (VOID **)&UiSection,
- &Size,
- &Authentication
- );
- if (!EFI_ERROR (FileStatus)) {
- if (StrnCmp (FilePath, UiSection, UiStringLen) == 0) {
- //
- // We found a UiString match.
- //
- Status = gBS->HandleProtocol (FvHandle, &gEfiDevicePathProtocolGuid, (VOID **)&FvDevicePath);
-
- // Generate the Device Path for the file
- //DevicePath = DuplicateDevicePath(FvDevicePath);
- EfiInitializeFwVolDevicepathNode (&FileDevicePath, &NameGuid);
- *EfiAppDevicePath = AppendDevicePathNode (FvDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&FileDevicePath);
-
- FreePool (Key);
+ // Allocate Key
+ Key = AllocatePool (FvInstance->KeySize);
+ ASSERT (Key != NULL);
+ ZeroMem (Key, FvInstance->KeySize);
+
+ do {
+ // Search in all files
+ FileType = EFI_FV_FILETYPE_ALL;
+
+ Status = FvInstance->GetNextFile (FvInstance, Key, &FileType, &NameGuid, &Attributes, &Size);
+ if (!EFI_ERROR (Status)) {
+ UiSection = NULL;
+ FileStatus = FvInstance->ReadSection (
+ FvInstance,
+ &NameGuid,
+ EFI_SECTION_USER_INTERFACE,
+ 0,
+ (VOID **)&UiSection,
+ &Size,
+ &Authentication
+ );
+ if (!EFI_ERROR (FileStatus)) {
+ if (StrnCmp (EfiAppName, UiSection, UiStringLen) == 0) {
+ //
+ // We found a UiString match.
+ //
+ Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **)&FvDevicePath);
+
+ // Generate the Device Path for the file
+ EfiInitializeFwVolDevicepathNode (&FileDevicePath, &NameGuid);
+ *DevicePath = AppendDevicePathNode (FvDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&FileDevicePath);
+ ASSERT (*DevicePath != NULL);
+
+ FreePool (Key);
+ FreePool (UiSection);
+ FreePool (HandleBuffer);
+ return FileStatus;
+ }
FreePool (UiSection);
- return FileStatus;
}
- FreePool (UiSection);
}
- }
- } while (!EFI_ERROR (Status));
+ } while (!EFI_ERROR (Status));

- FreePool(Key);
- return Status;
+ FreePool (Key);
+ }
+
+FREE_HANDLE_BUFFER:
+ FreePool (HandleBuffer);
+ return EFI_NOT_FOUND;
}

/**
- Start an EFI Application from any Firmware Volume
+ Locate an EFI application in a the Firmware Volumes by its GUID

- @param EfiApp EFI Application Name
+ @param EfiAppGuid Guid of the EFI Application into the Firmware Volume
+ @param DevicePath EFI Device Path of the EFI application

- @retval EFI_SUCCESS All drivers have been connected
- @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The protocol could not be located.
+ @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.

**/
EFI_STATUS
-BdsLoadApplication (
- IN EFI_HANDLE ParentImageHandle,
- IN CHAR16* EfiApp,
- IN UINTN LoadOptionsSize,
- IN VOID* LoadOptions
+LocateEfiApplicationInFvByGuid (
+ IN CONST EFI_GUID *EfiAppGuid,
+ OUT EFI_DEVICE_PATH **DevicePath
)
{
- EFI_STATUS Status;
- UINTN NoHandles, HandleIndex;
- EFI_HANDLE *Handles;
- EFI_DEVICE_PATH *EfiAppDevicePath;
-
- // Need to connect every drivers to ensure no dependencies are missing for the application
- Status = BdsConnectAllDrivers();
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "FAIL to connect all drivers\n"));
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH *FvDevicePath;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ UINTN Index;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance;
+ EFI_FV_FILE_ATTRIBUTES Attributes;
+ UINT32 AuthenticationStatus;
+ EFI_FV_FILETYPE Type;
+ UINTN Size;
+ CHAR16 *UiSection;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FvFileDevicePath;
+
+ ASSERT (DevicePath != NULL);
+
+ // Locate all the Firmware Volume protocols.
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ NULL,
+ &NumberOfHandles,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
return Status;
}

- // Search the application in any Firmware Volume
- Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiFirmwareVolume2ProtocolGuid, NULL, &NoHandles, &Handles);
- if (EFI_ERROR (Status) || (NoHandles == 0)) {
- DEBUG ((EFI_D_ERROR, "FAIL to find Firmware Volume\n"));
- return Status;
- }
+ *DevicePath = NULL;
+
+ // Looking for FV with ACPI storage file
+ for (Index = 0; Index < NumberOfHandles; Index++) {
+ //
+ // Get the protocol on this handle
+ // This should not fail because of LocateHandleBuffer
+ //
+ Status = gBS->HandleProtocol (
+ HandleBuffer[Index],
+ &gEfiFirmwareVolume2ProtocolGuid,
+ (VOID**) &FvInstance
+ );
+ if (EFI_ERROR (Status)) {
+ goto FREE_HANDLE_BUFFER;
+ }

- // Search in all Firmware Volume for the EFI Application
- for (HandleIndex = 0; HandleIndex < NoHandles; HandleIndex++) {
- EfiAppDevicePath = NULL;
- Status = BdsLoadFileFromFirmwareVolume (Handles[HandleIndex], EfiApp, EFI_FV_FILETYPE_APPLICATION, &EfiAppDevicePath);
- if (!EFI_ERROR (Status)) {
- // Start the application
- Status = BdsStartEfiApplication (ParentImageHandle, EfiAppDevicePath, LoadOptionsSize, LoadOptions);
- return Status;
+ Status = FvInstance->ReadFile (
+ FvInstance,
+ EfiAppGuid,
+ NULL,
+ &Size,
+ &Type,
+ &Attributes,
+ &AuthenticationStatus
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // Skip if no EFI application file in the FV
+ //
+ continue;
+ } else {
+ UiSection = NULL;
+ Status = FvInstance->ReadSection (
+ FvInstance,
+ EfiAppGuid,
+ EFI_SECTION_USER_INTERFACE,
+ 0,
+ (VOID **)&UiSection,
+ &Size,
+ &AuthenticationStatus
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Create the EFI Device Path for the application using the Filename of the application
+ //
+ *DevicePath = FileDevicePath (HandleBuffer[Index], UiSection);
+ } else {
+ Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID**)&FvDevicePath);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Create the EFI Device Path for the application using the EFI GUID of the application
+ //
+ EfiInitializeFwVolDevicepathNode (&FvFileDevicePath, EfiAppGuid);
+
+ *DevicePath = AppendDevicePathNode (FvDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&FvFileDevicePath);
+ ASSERT (*DevicePath != NULL);
+ }
+ break;
}
}

- return Status;
+FREE_HANDLE_BUFFER:
+ //
+ // Free any allocated buffers
+ //
+ FreePool (HandleBuffer);
+
+ if (*DevicePath == NULL) {
+ return EFI_NOT_FOUND;
+ } else {
+ return EFI_SUCCESS;
+ }
}
diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index f4c0f1c..76a45e0 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -37,6 +37,7 @@
ArmPkg/ArmPkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
EmbeddedPkg/EmbeddedPkg.dec
+ IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec

[LibraryClasses]
BdsLib
@@ -79,5 +80,7 @@
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths

+ gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile
+
[Depex]
TRUE
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c
index d2dccbc..a304cc4 100644
--- a/ArmPlatformPkg/Bds/BootMenu.c
+++ b/ArmPlatformPkg/Bds/BootMenu.c
@@ -1069,17 +1069,27 @@ BootShell (
IN LIST_ENTRY *BootOptionsList
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH* EfiShellDevicePath;

- // Start EFI Shell
- Status = BdsLoadApplication (gImageHandle, L"Shell", 0, NULL);
+ // Find the EFI Shell
+ Status = LocateEfiApplicationInFvByName (L"Shell", &EfiShellDevicePath);
if (Status == EFI_NOT_FOUND) {
Print (L"Error: EFI Application not found.\n");
- } else if (EFI_ERROR(Status)) {
- Print (L"Error: Status Code: 0x%X\n",(UINT32)Status);
- }
+ return Status;
+ } else if (EFI_ERROR (Status)) {
+ Print (L"Error: Status Code: 0x%X\n", (UINT32)Status);
+ return Status;
+ } else {
+ // Need to connect every drivers to ensure no dependencies are missing for the application
+ Status = BdsConnectAllDrivers ();
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "FAIL to connect all drivers\n"));
+ return Status;
+ }

- return Status;
+ return BdsStartEfiApplication (gImageHandle, EfiShellDevicePath, 0, NULL);
+ }
}

struct BOOT_MAIN_ENTRY {
--
2.1.1
Olivier Martin
2015-07-13 16:36:45 UTC
Permalink
From: Ronald Cron <***@arm.com>

Add the legacy Linux Loader EFI application to the ARM
development platform firmware.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <***@arm.com>
Reviewed-by: Olivier Martin <***@arm.com>
---
ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf | 1 +
ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc | 12 ++++++++++++
ArmPlatformPkg/ArmPlatformPkg-2ndstage.fdf | 4 +++-
ArmPlatformPkg/ArmPlatformPkg.dsc | 13 +++++++++++++
ArmPlatformPkg/ArmPlatformPkg.fdf | 4 +++-
.../ArmRealViewEbPkg/ArmRealViewEb-RTSM-MPCore.fdf | 4 +++-
.../ArmRealViewEbPkg/ArmRealViewEb-RTSM-UniCore.fdf | 5 ++++-
ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc | 17 +++++++++++++++--
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc | 2 +-
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf | 3 +++
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc | 2 +-
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf | 3 +++
.../ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf | 3 +++
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc | 2 +-
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf | 3 +++
.../ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc | 2 +-
.../ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf | 3 +++
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc | 3 ++-
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf | 3 +++
.../ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf | 3 +++
.../ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf | 3 +++
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc | 5 ++++-
BeagleBoardPkg/BeagleBoardPkg.dsc | 14 +++++++++++++-
BeagleBoardPkg/BeagleBoardPkg.fdf | 3 +++
24 files changed, 104 insertions(+), 13 deletions(-)

diff --git a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf
index 2dbf0e6..db70609 100644
--- a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf
+++ b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf
@@ -191,6 +191,7 @@ FvNameGuid = B73FE497-B92E-416e-8326-45AD0D270092
# UEFI applications
#
INF ShellBinPkg/UefiShell/UefiShell.inf
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf

#
# Juno platform driver
diff --git a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
index 4cfb913..76415fe 100644
--- a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
@@ -89,6 +89,11 @@
# Networking Requirements for ArmPlatformPkg/Bds
NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf

+ # These libraries are used by the dynamic EFI Shell commands
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+
# EBL Related Libraries
EblCmdLib|ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf
EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf
@@ -298,6 +303,11 @@
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|20
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0

+ # We want to use the Shell Libraries but don't want it to initialise
+ # automatically. We initialise the libraries when the command is called by the
+ # Shell.
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+
#
# ARM Pcds
#
@@ -369,3 +379,5 @@
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ ArmPkg/Application/LinuxLoader/LinuxLoader.inf
diff --git a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.fdf b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.fdf
index 86a94c1..9c35ebb 100644
--- a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.fdf
+++ b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.fdf
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -129,6 +129,8 @@ FvNameGuid = 5eda4200-2c5f-43cb-9da3-0baf74b1b30c
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf

[FV.FVMAIN_COMPACT]
FvAlignment = 8
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc b/ArmPlatformPkg/ArmPlatformPkg.dsc
index f9f217c..0147146 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
@@ -88,6 +88,11 @@
# Networking Requirements for ArmPlatformPkg/Bds
NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf

+ # These libraries are used by the dynamic EFI Shell commands
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+
# EBL Related Libraries
EblCmdLib|ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf
EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf
@@ -331,6 +336,11 @@
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|20
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0

+ # We want to use the Shell Libraries but don't want it to initialise
+ # automatically. We initialise the libraries when the command is called by the
+ # Shell.
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+
#
# ARM Pcds
#
@@ -434,3 +444,6 @@
#
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
ArmPlatformPkg/Bds/Bds.inf
+
+ # Legacy Linux Loader
+ ArmPkg/Application/LinuxLoader/LinuxLoader.inf
diff --git a/ArmPlatformPkg/ArmPlatformPkg.fdf b/ArmPlatformPkg/ArmPlatformPkg.fdf
index 36ca8b0..0dd9849 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.fdf
+++ b/ArmPlatformPkg/ArmPlatformPkg.fdf
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -178,6 +178,8 @@ FvNameGuid = 8fa66cd0-f773-4f26-8f9f-5e54d0804c68
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf

[FV.FVMAIN_COMPACT]
FvAlignment = 8
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-MPCore.fdf b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-MPCore.fdf
index bedcf77..85c74df 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-MPCore.fdf
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-MPCore.fdf
@@ -1,6 +1,6 @@
# FLASH layout file for ARM RealView EB.
#
-# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -177,6 +177,8 @@ FvNameGuid = 14801114-da6a-4113-985b-dc876337a15e
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf

[FV.FVMAIN_COMPACT]
FvAlignment = 8
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-UniCore.fdf b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-UniCore.fdf
index c6acf9e..55257c2 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-UniCore.fdf
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-UniCore.fdf
@@ -1,7 +1,7 @@
# FLASH layout file for ARM RealView EB.
#
# Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
-# Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.
+# Copyright (c) 2011 - 2015, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -178,6 +178,9 @@ FvNameGuid = 14801114-da6a-4113-985b-dc876337a15e
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+

[FV.FVMAIN_COMPACT]
FvAlignment = 8
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
index d0889f5..6232791 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
@@ -105,6 +105,11 @@

GdbSerialLib|ArmPlatformPkg/ArmRealViewEbPkg/Library/GdbSerialLib/GdbSerialLib.inf

+ # These libraries are used by the dynamic EFI Shell commands
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+
# BDS Libraries
BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf
FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
@@ -303,13 +308,18 @@
gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x10000048
gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x10005000

+ # We want to use the Shell Libraries but don't want it to initialise
+ # automatically. We initialise the libraries when the command is called by the
+ # Shell.
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+
#
# ARM OS Loader
#
gArmTokenSpaceGuid.PcdArmMachineType|827
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage-RTSM"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(14801114-DA6A-4113-985B-DC876337A15E)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage-RTSM -a 827 -c \"console=ttyAMA0,38400n8\""

# Use the Serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
@@ -325,3 +335,6 @@

# FV Filesystem
MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf
+
+ # Legacy Linux Loader
+ ArmPkg/Application/LinuxLoader/LinuxLoader.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
index 318c2cf..3b693c2 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
@@ -184,7 +184,7 @@
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NorFlash"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/MemoryMapped(0x0,0xE000000,0xE800000)"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400 earlyprintk debug verbose"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf
index 3cb634a..3b4b1fc 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf
@@ -172,6 +172,9 @@ FvNameGuid = 73dcb643-3862-4904-9076-a94af1890243
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
# FV Filesystem
INF MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf

diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
index ad4e7bf..baa5478 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
@@ -183,7 +183,7 @@
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"NorFlash"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/MemoryMapped(0x0,0x46000000,0x46400000)"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf
index c8f425f..7a26f3c 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf
@@ -241,6 +241,9 @@ FvNameGuid = 1a9b3625-5286-4fa6-af5f-8eabc481f3cc
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
# FV Filesystem
INF MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf

diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf
index 95d5b1d..53e2ca8 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf
@@ -203,6 +203,9 @@ FvNameGuid = 87940482-fc81-41c3-87e6-399cf85ac8a0
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
# FV Filesystem
INF MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf

diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
index bee8f95..fb42f34 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
@@ -160,7 +160,7 @@
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf
index 0f20a04..b71eb5c 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf
@@ -219,6 +219,9 @@ FvNameGuid = 9ca4f58c-341e-4f42-b37d-6042fcddb5bf
# SECTION RAW = ArmPlatformPkg/ArmVExpressPkg/Fdts/rtsm_ve-ca15x1.dtb
#}

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
[FV.FVMAIN_COMPACT]
FvAlignment = 8
ERASE_POLARITY = 1
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
index 5f85b28..09dc1db 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
@@ -162,7 +162,7 @@
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf
index 507afac..1758a5f 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf
@@ -219,6 +219,9 @@ FvNameGuid = 12c68be9-0996-49d3-8c5b-4957379027ee
# SECTION RAW = ArmPlatformPkg/ArmVExpressPkg/Fdts/rtsm_ve-ca15x4.dtb
#}

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
[FV.FVMAIN_COMPACT]
FvAlignment = 8
ERASE_POLARITY = 1
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
index 14d0cf5..2fe9e58 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
@@ -163,7 +163,8 @@
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(272E583C-B951-433F-AF42-A9C6862AF002)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage -c \"console=ttyAMA0,38400n8\""
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf
index d671489..029b608 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf
@@ -205,6 +205,9 @@ FvNameGuid = 272e583c-b951-433f-af42-a9c6862af002
# SECTION RAW = ArmPlatformPkg/ArmVExpressPkg/Fdts/rtsm_ve-ca9x4.dtb
#}

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
[FV.FVMAIN_COMPACT]
FvAlignment = 8
ERASE_POLARITY = 1
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf
index 5015266..402ee96 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf
@@ -187,6 +187,9 @@ FvNameGuid = 6685e0b5-d6bb-4c12-97ef-58bd87112dee
# FV Filesystem
INF MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
[FV.FVMAIN_COMPACT]
FvAlignment = 16
ERASE_POLARITY = 1
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf
index ee862d4..6cd125b 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf
@@ -197,6 +197,9 @@ FvNameGuid = a2fc72eb-4157-40a3-8110-14c010e810b4
# after the device drivers (eg: Ethernet) to ensure we have support for them.
INF EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
[FV.FVMAIN_COMPACT]
FvAlignment = 16
ERASE_POLARITY = 1
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
index c6b2598..3d6537a 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -383,7 +383,7 @@
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NorFlash"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/MemoryMapped(0x0,0xED000000,0xED400000)"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
@@ -436,3 +436,6 @@
# FDT installation
#
EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf
+
+ # Legacy Linux Loader
+ ArmPkg/Application/LinuxLoader/LinuxLoader.inf
diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc b/BeagleBoardPkg/BeagleBoardPkg.dsc
index 9eb364e..7aa6ce2 100644
--- a/BeagleBoardPkg/BeagleBoardPkg.dsc
+++ b/BeagleBoardPkg/BeagleBoardPkg.dsc
@@ -63,6 +63,10 @@

EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf

+ # These libraries are used by the dynamic EFI Shell commands
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf

PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf

@@ -345,13 +349,18 @@
gEmbeddedTokenSpaceGuid.PcdEmbeddedPerformanceCounterPeriodInNanoseconds|77
gEmbeddedTokenSpaceGuid.PcdEmbeddedPerformanceCounterFrequencyInHz|13000000

+ # We want to use the Shell Libraries but don't want it to initialise
+ # automatically. We initialise the libraries when the command is called by the
+ # Shell.
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+
#
# ARM Pcds
#
gArmTokenSpaceGuid.PcdArmUncachedMemoryMask|0x0000000040000000

gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SD"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(B615F1F5-5088-43CD-809C-A16E52487D00)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/zImage"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(B615F1F5-5088-43CD-809C-A16E52487D00)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=tty0 console=ttyS2,115200n8 root=UUID=a4af765b-c2b5-48f4-9564-7a4e9104c4f6 rootwait ro earlyprintk"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|10
@@ -473,6 +482,9 @@
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+
#
# Example Application
#
diff --git a/BeagleBoardPkg/BeagleBoardPkg.fdf b/BeagleBoardPkg/BeagleBoardPkg.fdf
index 9bc5b13..a639244 100644
--- a/BeagleBoardPkg/BeagleBoardPkg.fdf
+++ b/BeagleBoardPkg/BeagleBoardPkg.fdf
@@ -174,6 +174,9 @@ FvNameGuid = d0dd3e90-343d-4cb3-8f69-772214989282
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf

+ # Legacy Linux Loader
+ INF ArmPkg/Application/LinuxLoader/LinuxLoader.inf
+

[FV.FVMAIN_COMPACT]
FvAlignment = 8
--
2.1.1
Olivier Martin
2015-07-13 16:36:53 UTC
Permalink
There are still ARM/AArch64 Linux kernels that do not
support EFI Stub.
By using the EFI Linux loader as the default option
we can boot any Linux kernel from UEFI as Linux
kernel with EFI stub can also be booted with the
legacy way.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <***@arm.com>
Reviewed-by: Ronald Cron <***@arm.com>
---
ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc | 5 ++---
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc | 4 ++--
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc | 5 +++--
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc | 5 ++---
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc | 3 ++-
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc | 5 +++--
6 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
index 9860cf0..09ec5b3 100644
--- a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
+++ b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
@@ -146,10 +146,9 @@
#
# ARM OS Loader
#
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NOR Flash"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/Image"
-
# Support the Linux EFI stub by default
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"EFI Linux from NOR Flash"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"console=ttyAMA0,115200 earlycon=pl011,0x7ff80000 root=/dev/sda1 rootwait verbose debug"

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
index 50bb556..c1e3513 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
@@ -182,8 +182,8 @@
# ARM OS Loader
#
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NorFlash"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400 earlyprintk debug verbose"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(73DCB643-3862-4904-9076-A94AF1890243)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/kernel -c \"console=ttyAMA0,38400 earlyprintk debug verbose\""

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
# PL111 - CLCD
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
index 18cc978..b7a43fc 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
@@ -180,8 +180,9 @@
#
# ARM OS Loader
#
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"NorFlash"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/Image"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NorFlash"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(1A9B3625-5286-4FA6-AF5F-8EABC481F3CC)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/kernel -c \"console=ttyAMA0,38400 earlyprintk debug verbose\""

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
index 1b6134f..119ba3a 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
@@ -174,9 +174,8 @@
# ARM OS Loader
#
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/filesystem.cpio.gz"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 loglevel=9"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(87940482-FC81-41C3-87E6-399CF85AC8A0)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image -f VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/filesystem.cpio.gz -c \"console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 loglevel=9\""

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
index 3896166..b34d9d1 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
@@ -158,7 +158,8 @@
# ARM OS Loader
#
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(9CA4F58C-341E-4F42-B37D-6042FCDDB5BF)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image -c \"console=ttyAMA0,38400 earlyprintk debug verbose\""

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
index acfe164..37f3648 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
@@ -159,8 +159,9 @@
#
# ARM OS Loader
#
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SemiHosting"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(12C68BE9-0996-49D3-8C5B-4957379027EE)/LinuxLoader.efi"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image -c \"console=ttyAMA0,38400 earlyprintk debug verbose\""

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
--
2.1.1
Olivier Martin
2015-07-13 16:36:51 UTC
Permalink
When PcdBdsLinuxSupport is enabled, users can create boot
entries for the legacy EFI Linux loader if it exists into
the firmware.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <***@arm.com>
Reviewed-by: Ronald Cron <***@arm.com>
---
ArmPlatformPkg/ArmPlatformPkg.dec | 3 +
ArmPlatformPkg/Bds/Bds.inf | 4 +
ArmPlatformPkg/Bds/BdsHelper.c | 9 ---
ArmPlatformPkg/Bds/BdsInternal.h | 26 ++++--
ArmPlatformPkg/Bds/BootLinux.c | 124 +++++++++++++++++++++++++++++
ArmPlatformPkg/Bds/BootMenu.c | 161 +++++++++++++++++++++++++++++---------
6 files changed, 274 insertions(+), 53 deletions(-)
create mode 100644 ArmPlatformPkg/Bds/BootLinux.c

diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index be0919b..45aeaee 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -61,6 +61,9 @@
# we assume the OS will handle the FrameBuffer from the UEFI GOP information.
gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices|FALSE|BOOLEAN|0x0000003D

+ # Enable Legacy Linux support in the BDS
+ gArmPlatformTokenSpaceGuid.PcdBdsLinuxSupport|TRUE|BOOLEAN|0x0000002E
+
[PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdCoreCount|1|UINT32|0x00000039
gArmPlatformTokenSpaceGuid.PcdClusterCount|1|UINT32|0x00000038
diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index 3b6ffc3..06e8d91 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -27,6 +27,7 @@
[Sources]
Bds.c
BdsHelper.c
+ BootLinux.c
BootMenu.c
BootOption.c
BootOptionSupport.c
@@ -72,6 +73,9 @@
gEfiDhcp4ServiceBindingProtocolGuid
gEfiMtftp4ServiceBindingProtocolGuid

+[FeaturePcd]
+ gArmPlatformTokenSpaceGuid.PcdBdsLinuxSupport
+
[Pcd]
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription
diff --git a/ArmPlatformPkg/Bds/BdsHelper.c b/ArmPlatformPkg/Bds/BdsHelper.c
index b3003e9..732292c 100644
--- a/ArmPlatformPkg/Bds/BdsHelper.c
+++ b/ArmPlatformPkg/Bds/BdsHelper.c
@@ -256,15 +256,6 @@ GetHIInputBoolean (
}
}

-BOOLEAN
-HasFilePathEfiExtension (
- IN CHAR16* FilePath
- )
-{
- return (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".EFI") == 0) ||
- (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".efi") == 0);
-}
-
// Return the last non end-type Device Path Node from a Device Path
EFI_DEVICE_PATH*
GetLastDevicePathNode (
diff --git a/ArmPlatformPkg/Bds/BdsInternal.h b/ArmPlatformPkg/Bds/BdsInternal.h
index fe4fd79..ddf5308 100644
--- a/ArmPlatformPkg/Bds/BdsInternal.h
+++ b/ArmPlatformPkg/Bds/BdsInternal.h
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -79,6 +79,12 @@ typedef struct _BDS_LOAD_OPTION_SUPPORT {
#define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)
#define LOAD_OPTION_FROM_LINK(a) ((BDS_LOAD_OPTION_ENTRY*)BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link))->BdsLoadOption

+// GUID of the EFI Linux Loader
+extern CONST EFI_GUID mLinuxLoaderAppGuid;
+
+// Device path of the EFI Linux Loader in the Firmware Volume
+extern EFI_DEVICE_PATH* mLinuxLoaderDevicePath;
+
EFI_STATUS
BootDeviceListSupportedInit (
IN OUT LIST_ENTRY *SupportedDeviceList
@@ -141,11 +147,6 @@ GetHIInputBoolean (
OUT BOOLEAN *Value
);

-BOOLEAN
-HasFilePathEfiExtension (
- IN CHAR16* FilePath
- );
-
EFI_DEVICE_PATH*
GetLastDevicePathNode (
IN EFI_DEVICE_PATH* DevicePath
@@ -260,4 +261,17 @@ EmptyCallbackFunction (
IN VOID *Context
);

+/**
+ * This function check if the DevicePath defines an EFI binary
+ *
+ * This function is used when the BDS support Linux loader to
+ * detect if the binary is an EFI application or potentially a
+ * Linux kernel.
+ */
+EFI_STATUS
+IsEfiBinary (
+ IN EFI_DEVICE_PATH* DevicePath,
+ OUT BOOLEAN *EfiBinary
+ );
+
#endif /* _BDSINTERNAL_H_ */
diff --git a/ArmPlatformPkg/Bds/BootLinux.c b/ArmPlatformPkg/Bds/BootLinux.c
new file mode 100644
index 0000000..0445e89
--- /dev/null
+++ b/ArmPlatformPkg/Bds/BootLinux.c
@@ -0,0 +1,124 @@
+/** @file
+*
+* Copyright (c) 2011 - 2015, ARM Limited. All rights reserved.
+*
+* This program and the accompanying materials
+* are licensed and made available under the terms and conditions of the BSD License
+* which accompanies this distribution. The full text of the license may be found at
+* http://opensource.org/licenses/bsd-license.php
+*
+* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+
+#include "BdsInternal.h"
+
+// 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 of the EFI Linux Loader in the Firmware Volume
+EFI_DEVICE_PATH* mLinuxLoaderDevicePath = NULL;
+
+STATIC
+BOOLEAN
+HasFilePathEfiExtension (
+ IN CHAR16* FilePath
+ )
+{
+ return (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".EFI") == 0) ||
+ (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".efi") == 0);
+}
+
+/**
+ * This function check if the DevicePath defines an EFI binary
+ *
+ * This function is used when the BDS support Linux loader to
+ * detect if the binary is an EFI application or potentially a
+ * Linux kernel.
+ */
+EFI_STATUS
+IsEfiBinary (
+ IN EFI_DEVICE_PATH* DevicePath,
+ OUT BOOLEAN *EfiBinary
+ )
+{
+ EFI_STATUS Status;
+ CHAR16* FileName;
+ EFI_DEVICE_PATH* PrevDevicePathNode;
+ EFI_DEVICE_PATH* DevicePathNode;
+ EFI_PHYSICAL_ADDRESS Image;
+ UINTN FileSize;
+ EFI_IMAGE_DOS_HEADER* DosHeader;
+ UINTN PeCoffHeaderOffset;
+ EFI_IMAGE_NT_HEADERS32* NtHeader;
+
+ ASSERT (EfiBinary != NULL);
+
+ //
+ // Check if the last node of the device path is a FilePath node
+ //
+ PrevDevicePathNode = NULL;
+ DevicePathNode = DevicePath;
+ while ((DevicePathNode != NULL) && !IsDevicePathEnd (DevicePathNode)) {
+ PrevDevicePathNode = DevicePathNode;
+ DevicePathNode = NextDevicePathNode (DevicePathNode);
+ }
+
+ if ((PrevDevicePathNode != NULL) &&
+ (PrevDevicePathNode->Type == MEDIA_DEVICE_PATH) &&
+ (PrevDevicePathNode->SubType == MEDIA_FILEPATH_DP))
+ {
+ FileName = ((FILEPATH_DEVICE_PATH*)PrevDevicePathNode)->PathName;
+ } else {
+ FileName = NULL;
+ }
+
+ if (FileName == NULL) {
+ Print (L"Is an EFI Application? ");
+ Status = GetHIInputBoolean (EfiBinary);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ } else if (HasFilePathEfiExtension (FileName)) {
+ *EfiBinary = TRUE;
+ } else {
+ // Check if the file exist
+ Status = BdsLoadImage (DevicePath, AllocateAnyPages, &Image, &FileSize);
+ if (!EFI_ERROR (Status)) {
+
+ DosHeader = (EFI_IMAGE_DOS_HEADER *)(UINTN) Image;
+ if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present,
+ // so read the PE header after the DOS image header.
+ //
+ PeCoffHeaderOffset = DosHeader->e_lfanew;
+ } else {
+ PeCoffHeaderOffset = 0;
+ }
+
+ //
+ // Check PE/COFF image.
+ //
+ NtHeader = (EFI_IMAGE_NT_HEADERS32 *)(UINTN) (Image + PeCoffHeaderOffset);
+ if (NtHeader->Signature != EFI_IMAGE_NT_SIGNATURE) {
+ *EfiBinary = FALSE;
+ } else {
+ *EfiBinary = TRUE;
+ }
+
+ // Free memory
+ gBS->FreePages (Image, EFI_SIZE_TO_PAGES (FileSize));
+ } else {
+ // If we did not manage to open it then ask for the type
+ Print (L"Is an EFI Application? ");
+ Status = GetHIInputBoolean (EfiBinary);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c
index af7f1f1..8caa3ce 100644
--- a/ArmPlatformPkg/Bds/BootMenu.c
+++ b/ArmPlatformPkg/Bds/BootMenu.c
@@ -269,6 +269,8 @@ BootMenuAddBootOption (
EFI_DEVICE_PATH_PROTOCOL *DevicePathNodes;
UINT8* OptionalData;
UINTN OptionalDataSize;
+ BOOLEAN EfiBinary;
+ CHAR16 *LinuxDevicePath;

Attributes = 0;
SupportedBootDevice = NULL;
@@ -281,8 +283,12 @@ BootMenuAddBootOption (
}

// Create the specific device path node
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes);
- if (EFI_ERROR(Status)) {
+ if (FeaturePcdGet (PcdBdsLinuxSupport) && mLinuxLoaderDevicePath) {
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes);
+ } else {
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application", &DevicePathNodes);
+ }
+ if (EFI_ERROR (Status)) {
Status = EFI_ABORTED;
goto EXIT;
}
@@ -293,8 +299,39 @@ BootMenuAddBootOption (
goto EXIT;
}

+ // Is it an EFI application?
+ if (FeaturePcdGet (PcdBdsLinuxSupport) && mLinuxLoaderDevicePath) {
+ Status = IsEfiBinary (DevicePath, &EfiBinary);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ if (EfiBinary == FALSE) {
+ Print (L"It is assumed the binary is a Linux kernel and the embedded Linux Loader is going to be used.\n");
+ Print (L"Supported command line formats by the embedded Linux Loader:\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\"\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\" -f <EFI Device Path of the Linux initrd>\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\" -a <Machine Type for ATAG Linux kernel>\n");
+
+ // Copy the Linux path into the command line
+ LinuxDevicePath = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
+ CopyMem (CmdLine, LinuxDevicePath, MAX (sizeof (CmdLine), StrSize (LinuxDevicePath)));
+ FreePool (LinuxDevicePath);
+
+ // Free the generated Device Path
+ FreePool (DevicePath);
+ // and use the embedded Linux Loader as the EFI application
+ DevicePath = mLinuxLoaderDevicePath;
+ } else {
+ CmdLine[0] = L'\0';
+ }
+ } else {
+ CmdLine[0] = L'\0';
+ }
+
Print (L"Arguments to pass to the EFI Application: ");
- Status = GetHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);
+ Status = EditHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);
if (EFI_ERROR (Status)) {
Status = EFI_ABORTED;
goto EXIT;
@@ -366,11 +403,13 @@ BootMenuUpdateBootOption (
CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];
CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];
CHAR16 UnicodeCmdLine[BOOT_DEVICE_OPTION_MAX];
+ CHAR16 *LinuxDevicePath;
EFI_DEVICE_PATH *DevicePath;
UINT8* OptionalData;
UINTN OptionalDataSize;
BOOLEAN IsPrintable;
BOOLEAN IsUnicode;
+ BOOLEAN EfiBinary;

DisplayBootOptions (BootOptionsList);
Status = SelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, &BootOptionEntry);
@@ -386,46 +425,87 @@ BootMenuUpdateBootOption (
return EFI_UNSUPPORTED;
}

- Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
+ EfiBinary = TRUE;
+ if (FeaturePcdGet (PcdBdsLinuxSupport) && mLinuxLoaderDevicePath) {
+ Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ // Is it an EFI application?
+ Status = IsEfiBinary (DevicePath, &EfiBinary);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ if (EfiBinary == FALSE) {
+ Print (L"It is assumed the binary is a Linux kernel and the embedded Linux Loader is going to be used.\n");
+ Print (L"Supported command line formats by the embedded Linux Loader:\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\"\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\" -f <EFI Device Path of the Linux initrd>\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\" -a <Machine Type for ATAG Linux kernel>\n");
+
+ // Copy the Linux path into the command line
+ LinuxDevicePath = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
+ CopyMem (UnicodeCmdLine, LinuxDevicePath, MAX (sizeof (UnicodeCmdLine), StrSize (LinuxDevicePath)));
+ FreePool (LinuxDevicePath);
+
+ // Free the generated Device Path
+ FreePool (DevicePath);
+ // and use the embedded Linux Loader as the EFI application
+ DevicePath = mLinuxLoaderDevicePath;
+
+ // The command line is a unicode printable string
+ IsPrintable = TRUE;
+ IsUnicode = TRUE;
+ }
+ } else {
+ Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application", &DevicePath);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
}

Print (L"Arguments to pass to the EFI Application: ");

- if (BootOption->OptionalDataSize > 0) {
- IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);
- if (IsPrintable) {
- //
- // The size in bytes of the string, final zero included, should
- // be equal to or at least lower than "BootOption->OptionalDataSize"
- // and the "IsPrintableString()" has already tested that the length
- // in number of characters is smaller than BOOT_DEVICE_OPTION_MAX,
- // final '\0' included. We can thus copy the string for editing
- // using "CopyMem()". Furthermore, note that in the case of an Unicode
- // string "StrnCpy()" and "StrCpy()" can not be used to copy the
- // string because the data pointed to by "BootOption->OptionalData"
- // is not necessarily 2-byte aligned.
- //
- if (IsUnicode) {
- CopyMem (
- UnicodeCmdLine, BootOption->OptionalData,
- MIN (sizeof (UnicodeCmdLine),
- BootOption->OptionalDataSize)
- );
- } else {
- CopyMem (
- CmdLine, BootOption->OptionalData,
- MIN (sizeof (CmdLine),
- BootOption->OptionalDataSize)
- );
+ // When the command line has not been initialized by the embedded Linux loader earlier
+ if (EfiBinary) {
+ if (BootOption->OptionalDataSize > 0) {
+ IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);
+ if (IsPrintable) {
+ //
+ // The size in bytes of the string, final zero included, should
+ // be equal to or at least lower than "BootOption->OptionalDataSize"
+ // and the "IsPrintableString()" has already tested that the length
+ // in number of characters is smaller than BOOT_DEVICE_OPTION_MAX,
+ // final '\0' included. We can thus copy the string for editing
+ // using "CopyMem()". Furthermore, note that in the case of an Unicode
+ // string "StrnCpy()" and "StrCpy()" can not be used to copy the
+ // string because the data pointed to by "BootOption->OptionalData"
+ // is not necessarily 2-byte aligned.
+ //
+ if (IsUnicode) {
+ CopyMem (
+ UnicodeCmdLine, BootOption->OptionalData,
+ MIN (sizeof (UnicodeCmdLine),
+ BootOption->OptionalDataSize)
+ );
+ } else {
+ CopyMem (
+ CmdLine, BootOption->OptionalData,
+ MIN (sizeof (CmdLine),
+ BootOption->OptionalDataSize)
+ );
+ }
}
+ } else {
+ UnicodeCmdLine[0] = L'\0';
+ IsPrintable = TRUE;
+ IsUnicode = TRUE;
}
- } else {
- UnicodeCmdLine[0] = L'\0';
- IsPrintable = TRUE;
- IsUnicode = TRUE;
}

// We do not request arguments for OptionalData that cannot be printed
@@ -909,7 +989,6 @@ struct BOOT_MAIN_ENTRY {
{ L"Boot Manager", BootMenuManager },
};

-
EFI_STATUS
BootMenuMain (
VOID
@@ -929,6 +1008,12 @@ BootMenuMain (
BootOption = NULL;
BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY);

+ if (FeaturePcdGet (PcdBdsLinuxSupport)) {
+ // Check Linux Loader is present
+ Status = LocateEfiApplicationInFvByGuid (&mLinuxLoaderAppGuid, &mLinuxLoaderDevicePath);
+ ASSERT_EFI_ERROR (Status);
+ }
+
while (TRUE) {
// Get Boot#### list
BootOptionList (&BootOptionsList);
--
2.1.1
Ryan Harkin
2015-07-13 17:17:06 UTC
Permalink
Post by Olivier Martin
When PcdBdsLinuxSupport is enabled, users can create boot
entries for the legacy EFI Linux loader if it exists into
the firmware.
Surely this is only true if the kernel doesn't have an EFI header? If it
has an EFI header, it will be forced to use the EFI loader.
Post by Olivier Martin
Contributed-under: TianoCore Contribution Agreement 1.0
---
ArmPlatformPkg/ArmPlatformPkg.dec | 3 +
ArmPlatformPkg/Bds/Bds.inf | 4 +
ArmPlatformPkg/Bds/BdsHelper.c | 9 ---
ArmPlatformPkg/Bds/BdsInternal.h | 26 ++++--
ArmPlatformPkg/Bds/BootLinux.c | 124 +++++++++++++++++++++++++++++
ArmPlatformPkg/Bds/BootMenu.c | 161
+++++++++++++++++++++++++++++---------
6 files changed, 274 insertions(+), 53 deletions(-)
create mode 100644 ArmPlatformPkg/Bds/BootLinux.c
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec
b/ArmPlatformPkg/ArmPlatformPkg.dec
index be0919b..45aeaee 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -61,6 +61,9 @@
# we assume the OS will handle the FrameBuffer from the UEFI GOP information.
gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices|FALSE|BOOLEAN|0x0000003D
+ # Enable Legacy Linux support in the BDS
+ gArmPlatformTokenSpaceGuid.PcdBdsLinuxSupport|TRUE|BOOLEAN|0x0000002E
+
[PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdCoreCount|1|UINT32|0x00000039
gArmPlatformTokenSpaceGuid.PcdClusterCount|1|UINT32|0x00000038
diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index 3b6ffc3..06e8d91 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -27,6 +27,7 @@
[Sources]
Bds.c
BdsHelper.c
+ BootLinux.c
BootMenu.c
BootOption.c
BootOptionSupport.c
@@ -72,6 +73,9 @@
gEfiDhcp4ServiceBindingProtocolGuid
gEfiMtftp4ServiceBindingProtocolGuid
+[FeaturePcd]
+ gArmPlatformTokenSpaceGuid.PcdBdsLinuxSupport
+
[Pcd]
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription
diff --git a/ArmPlatformPkg/Bds/BdsHelper.c
b/ArmPlatformPkg/Bds/BdsHelper.c
index b3003e9..732292c 100644
--- a/ArmPlatformPkg/Bds/BdsHelper.c
+++ b/ArmPlatformPkg/Bds/BdsHelper.c
@@ -256,15 +256,6 @@ GetHIInputBoolean (
}
}
-BOOLEAN
-HasFilePathEfiExtension (
- IN CHAR16* FilePath
- )
-{
- return (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".EFI") == 0) ||
- (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".efi") == 0);
-}
-
// Return the last non end-type Device Path Node from a Device Path
EFI_DEVICE_PATH*
GetLastDevicePathNode (
diff --git a/ArmPlatformPkg/Bds/BdsInternal.h
b/ArmPlatformPkg/Bds/BdsInternal.h
index fe4fd79..ddf5308 100644
--- a/ArmPlatformPkg/Bds/BdsInternal.h
+++ b/ArmPlatformPkg/Bds/BdsInternal.h
@@ -1,6 +1,6 @@
*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -79,6 +79,12 @@ typedef struct _BDS_LOAD_OPTION_SUPPORT {
#define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)
#define LOAD_OPTION_FROM_LINK(a)
((BDS_LOAD_OPTION_ENTRY*)BASE_CR(a, BDS_LOAD_OPTION_ENTRY,
Link))->BdsLoadOption
+// GUID of the EFI Linux Loader
+extern CONST EFI_GUID mLinuxLoaderAppGuid;
+
+// Device path of the EFI Linux Loader in the Firmware Volume
+extern EFI_DEVICE_PATH* mLinuxLoaderDevicePath;
+
EFI_STATUS
BootDeviceListSupportedInit (
IN OUT LIST_ENTRY *SupportedDeviceList
@@ -141,11 +147,6 @@ GetHIInputBoolean (
OUT BOOLEAN *Value
);
-BOOLEAN
-HasFilePathEfiExtension (
- IN CHAR16* FilePath
- );
-
EFI_DEVICE_PATH*
GetLastDevicePathNode (
IN EFI_DEVICE_PATH* DevicePath
@@ -260,4 +261,17 @@ EmptyCallbackFunction (
IN VOID *Context
);
+/**
+ * This function check if the DevicePath defines an EFI binary
+ *
+ * This function is used when the BDS support Linux loader to
+ * detect if the binary is an EFI application or potentially a
+ * Linux kernel.
+ */
+EFI_STATUS
+IsEfiBinary (
+ IN EFI_DEVICE_PATH* DevicePath,
+ OUT BOOLEAN *EfiBinary
+ );
+
#endif /* _BDSINTERNAL_H_ */
diff --git a/ArmPlatformPkg/Bds/BootLinux.c
b/ArmPlatformPkg/Bds/BootLinux.c
new file mode 100644
index 0000000..0445e89
--- /dev/null
+++ b/ArmPlatformPkg/Bds/BootLinux.c
@@ -0,0 +1,124 @@
+*
+* Copyright (c) 2011 - 2015, ARM Limited. All rights reserved.
+*
+* This program and the accompanying materials
+* are licensed and made available under the terms and conditions of the BSD License
+* which accompanies this distribution. The full text of the license may be found at
+* http://opensource.org/licenses/bsd-license.php
+*
+* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+
+#include "BdsInternal.h"
+
+// 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 of the EFI Linux Loader in the Firmware Volume
+EFI_DEVICE_PATH* mLinuxLoaderDevicePath = NULL;
+
+STATIC
+BOOLEAN
+HasFilePathEfiExtension (
+ IN CHAR16* FilePath
+ )
+{
+ return (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".EFI") == 0) ||
+ (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".efi") == 0);
+}
+
+/**
+ * This function check if the DevicePath defines an EFI binary
+ *
+ * This function is used when the BDS support Linux loader to
+ * detect if the binary is an EFI application or potentially a
+ * Linux kernel.
+ */
+EFI_STATUS
+IsEfiBinary (
+ IN EFI_DEVICE_PATH* DevicePath,
+ OUT BOOLEAN *EfiBinary
+ )
+{
+ EFI_STATUS Status;
+ CHAR16* FileName;
+ EFI_DEVICE_PATH* PrevDevicePathNode;
+ EFI_DEVICE_PATH* DevicePathNode;
+ EFI_PHYSICAL_ADDRESS Image;
+ UINTN FileSize;
+ EFI_IMAGE_DOS_HEADER* DosHeader;
+ UINTN PeCoffHeaderOffset;
+ EFI_IMAGE_NT_HEADERS32* NtHeader;
+
+ ASSERT (EfiBinary != NULL);
+
+ //
+ // Check if the last node of the device path is a FilePath node
+ //
+ PrevDevicePathNode = NULL;
+ DevicePathNode = DevicePath;
+ while ((DevicePathNode != NULL) && !IsDevicePathEnd (DevicePathNode)) {
+ PrevDevicePathNode = DevicePathNode;
+ DevicePathNode = NextDevicePathNode (DevicePathNode);
+ }
+
+ if ((PrevDevicePathNode != NULL) &&
+ (PrevDevicePathNode->Type == MEDIA_DEVICE_PATH) &&
+ (PrevDevicePathNode->SubType == MEDIA_FILEPATH_DP))
+ {
+ FileName = ((FILEPATH_DEVICE_PATH*)PrevDevicePathNode)->PathName;
+ } else {
+ FileName = NULL;
+ }
+
+ if (FileName == NULL) {
+ Print (L"Is an EFI Application? ");
+ Status = GetHIInputBoolean (EfiBinary);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ } else if (HasFilePathEfiExtension (FileName)) {
+ *EfiBinary = TRUE;
+ } else {
+ // Check if the file exist
+ Status = BdsLoadImage (DevicePath, AllocateAnyPages, &Image, &FileSize);
+ if (!EFI_ERROR (Status)) {
+
+ DosHeader = (EFI_IMAGE_DOS_HEADER *)(UINTN) Image;
+ if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present,
+ // so read the PE header after the DOS image header.
+ //
+ PeCoffHeaderOffset = DosHeader->e_lfanew;
+ } else {
+ PeCoffHeaderOffset = 0;
+ }
+
+ //
+ // Check PE/COFF image.
+ //
+ NtHeader = (EFI_IMAGE_NT_HEADERS32 *)(UINTN) (Image +
PeCoffHeaderOffset);
+ if (NtHeader->Signature != EFI_IMAGE_NT_SIGNATURE) {
+ *EfiBinary = FALSE;
+ } else {
+ *EfiBinary = TRUE;
+ }
+
+ // Free memory
+ gBS->FreePages (Image, EFI_SIZE_TO_PAGES (FileSize));
+ } else {
+ // If we did not manage to open it then ask for the type
+ Print (L"Is an EFI Application? ");
+ Status = GetHIInputBoolean (EfiBinary);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c
index af7f1f1..8caa3ce 100644
--- a/ArmPlatformPkg/Bds/BootMenu.c
+++ b/ArmPlatformPkg/Bds/BootMenu.c
@@ -269,6 +269,8 @@ BootMenuAddBootOption (
EFI_DEVICE_PATH_PROTOCOL *DevicePathNodes;
UINT8* OptionalData;
UINTN OptionalDataSize;
+ BOOLEAN EfiBinary;
+ CHAR16 *LinuxDevicePath;
Attributes = 0;
SupportedBootDevice = NULL;
@@ -281,8 +283,12 @@ BootMenuAddBootOption (
}
// Create the specific device path node
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI
Application or the kernel", &DevicePathNodes);
- if (EFI_ERROR(Status)) {
+ if (FeaturePcdGet (PcdBdsLinuxSupport) && mLinuxLoaderDevicePath) {
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI
Application or the kernel", &DevicePathNodes);
+ } else {
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI
Application", &DevicePathNodes);
+ }
+ if (EFI_ERROR (Status)) {
Status = EFI_ABORTED;
goto EXIT;
}
@@ -293,8 +299,39 @@ BootMenuAddBootOption (
goto EXIT;
}
+ // Is it an EFI application?
+ if (FeaturePcdGet (PcdBdsLinuxSupport) && mLinuxLoaderDevicePath) {
+ Status = IsEfiBinary (DevicePath, &EfiBinary);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ if (EfiBinary == FALSE) {
+ Print (L"It is assumed the binary is a Linux kernel and the
embedded Linux Loader is going to be used.\n");
+ Print (L"Supported command line formats by the embedded Linux Loader:\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel
command line>\"\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel
command line>\" -f <EFI Device Path of the Linux initrd>\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel
command line>\" -a <Machine Type for ATAG Linux kernel>\n");
+
+ // Copy the Linux path into the command line
+ LinuxDevicePath = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
+ CopyMem (CmdLine, LinuxDevicePath, MAX (sizeof (CmdLine), StrSize
(LinuxDevicePath)));
+ FreePool (LinuxDevicePath);
+
+ // Free the generated Device Path
+ FreePool (DevicePath);
+ // and use the embedded Linux Loader as the EFI application
+ DevicePath = mLinuxLoaderDevicePath;
+ } else {
+ CmdLine[0] = L'\0';
+ }
+ } else {
+ CmdLine[0] = L'\0';
+ }
+
Print (L"Arguments to pass to the EFI Application: ");
- Status = GetHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);
+ Status = EditHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);
if (EFI_ERROR (Status)) {
Status = EFI_ABORTED;
goto EXIT;
@@ -366,11 +403,13 @@ BootMenuUpdateBootOption (
CHAR16
BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];
CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];
CHAR16 UnicodeCmdLine[BOOT_DEVICE_OPTION_MAX];
+ CHAR16 *LinuxDevicePath;
EFI_DEVICE_PATH *DevicePath;
UINT8* OptionalData;
UINTN OptionalDataSize;
BOOLEAN IsPrintable;
BOOLEAN IsUnicode;
+ BOOLEAN EfiBinary;
DisplayBootOptions (BootOptionsList);
Status = SelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, &BootOptionEntry);
@@ -386,46 +425,87 @@ BootMenuUpdateBootOption (
return EFI_UNSUPPORTED;
}
- Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList,
L"EFI Application or the kernel", &DevicePath);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
+ EfiBinary = TRUE;
+ if (FeaturePcdGet (PcdBdsLinuxSupport) && mLinuxLoaderDevicePath) {
+ Status = DeviceSupport->UpdateDevicePathNode
(BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ // Is it an EFI application?
+ Status = IsEfiBinary (DevicePath, &EfiBinary);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ if (EfiBinary == FALSE) {
+ Print (L"It is assumed the binary is a Linux kernel and the
embedded Linux Loader is going to be used.\n");
+ Print (L"Supported command line formats by the embedded Linux Loader:\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel
command line>\"\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel
command line>\" -f <EFI Device Path of the Linux initrd>\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel
command line>\" -a <Machine Type for ATAG Linux kernel>\n");
+
+ // Copy the Linux path into the command line
+ LinuxDevicePath = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
+ CopyMem (UnicodeCmdLine, LinuxDevicePath, MAX (sizeof
(UnicodeCmdLine), StrSize (LinuxDevicePath)));
+ FreePool (LinuxDevicePath);
+
+ // Free the generated Device Path
+ FreePool (DevicePath);
+ // and use the embedded Linux Loader as the EFI application
+ DevicePath = mLinuxLoaderDevicePath;
+
+ // The command line is a unicode printable string
+ IsPrintable = TRUE;
+ IsUnicode = TRUE;
+ }
+ } else {
+ Status = DeviceSupport->UpdateDevicePathNode
(BootOption->FilePathList, L"EFI Application", &DevicePath);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
}
Print (L"Arguments to pass to the EFI Application: ");
- if (BootOption->OptionalDataSize > 0) {
- IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);
- if (IsPrintable) {
- //
- // The size in bytes of the string, final zero included, should
- // be equal to or at least lower than
"BootOption->OptionalDataSize"
- // and the "IsPrintableString()" has already tested that the length
- // in number of characters is smaller than BOOT_DEVICE_OPTION_MAX,
- // final '\0' included. We can thus copy the string for editing
- // using "CopyMem()". Furthermore, note that in the case of an Unicode
- // string "StrnCpy()" and "StrCpy()" can not be used to copy the
- // string because the data pointed to by
"BootOption->OptionalData"
- // is not necessarily 2-byte aligned.
- //
- if (IsUnicode) {
- CopyMem (
- UnicodeCmdLine, BootOption->OptionalData,
- MIN (sizeof (UnicodeCmdLine),
- BootOption->OptionalDataSize)
- );
- } else {
- CopyMem (
- CmdLine, BootOption->OptionalData,
- MIN (sizeof (CmdLine),
- BootOption->OptionalDataSize)
- );
+ // When the command line has not been initialized by the embedded Linux loader earlier
+ if (EfiBinary) {
+ if (BootOption->OptionalDataSize > 0) {
+ IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);
+ if (IsPrintable) {
+ //
+ // The size in bytes of the string, final zero included, should
+ // be equal to or at least lower than
"BootOption->OptionalDataSize"
+ // and the "IsPrintableString()" has already tested that the length
+ // in number of characters is smaller than
BOOT_DEVICE_OPTION_MAX,
+ // final '\0' included. We can thus copy the string for editing
+ // using "CopyMem()". Furthermore, note that in the case of an Unicode
+ // string "StrnCpy()" and "StrCpy()" can not be used to copy the
+ // string because the data pointed to by
"BootOption->OptionalData"
+ // is not necessarily 2-byte aligned.
+ //
+ if (IsUnicode) {
+ CopyMem (
+ UnicodeCmdLine, BootOption->OptionalData,
+ MIN (sizeof (UnicodeCmdLine),
+ BootOption->OptionalDataSize)
+ );
+ } else {
+ CopyMem (
+ CmdLine, BootOption->OptionalData,
+ MIN (sizeof (CmdLine),
+ BootOption->OptionalDataSize)
+ );
+ }
}
+ } else {
+ UnicodeCmdLine[0] = L'\0';
+ IsPrintable = TRUE;
+ IsUnicode = TRUE;
}
- } else {
- UnicodeCmdLine[0] = L'\0';
- IsPrintable = TRUE;
- IsUnicode = TRUE;
}
// We do not request arguments for OptionalData that cannot be printed
@@ -909,7 +989,6 @@ struct BOOT_MAIN_ENTRY {
{ L"Boot Manager", BootMenuManager },
};
-
EFI_STATUS
BootMenuMain (
VOID
@@ -929,6 +1008,12 @@ BootMenuMain (
BootOption = NULL;
BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY);
+ if (FeaturePcdGet (PcdBdsLinuxSupport)) {
+ // Check Linux Loader is present
+ Status = LocateEfiApplicationInFvByGuid (&mLinuxLoaderAppGuid,
&mLinuxLoaderDevicePath);
+ ASSERT_EFI_ERROR (Status);
+ }
+
while (TRUE) {
// Get Boot#### list
BootOptionList (&BootOptionsList);
--
2.1.1
------------------------------------------------------------------------------
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-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Olivier Martin
2015-07-14 09:33:12 UTC
Permalink
Yes, that’s correct that was the patch is doing. I will update the comment and send a V2 as per Laszlo’s comments.

From: Ryan Harkin [mailto:***@linaro.org]
Sent: 13 July 2015 18:17
To: Olivier Martin
Cc: edk2-***@lists.sourceforge.net
Subject: Re: [edk2] [PATCH 6/8] ArmPlatformPkg/Bds: Added support for booting legacy kernel from BDS



On 13 July 2015 at 17:36, Olivier Martin <***@arm.com<mailto:***@arm.com>> wrote:
When PcdBdsLinuxSupport is enabled, users can create boot
entries for the legacy EFI Linux loader if it exists into
the firmware.

Surely this is only true if the kernel doesn't have an EFI header? If it has an EFI header, it will be forced to use the EFI loader.


Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <***@arm.com<mailto:***@arm.com>>
Reviewed-by: Ronald Cron <***@arm.com<mailto:***@arm.com>>
---
ArmPlatformPkg/ArmPlatformPkg.dec | 3 +
ArmPlatformPkg/Bds/Bds.inf | 4 +
ArmPlatformPkg/Bds/BdsHelper.c | 9 ---
ArmPlatformPkg/Bds/BdsInternal.h | 26 ++++--
ArmPlatformPkg/Bds/BootLinux.c | 124 +++++++++++++++++++++++++++++
ArmPlatformPkg/Bds/BootMenu.c | 161 +++++++++++++++++++++++++++++---------
6 files changed, 274 insertions(+), 53 deletions(-)
create mode 100644 ArmPlatformPkg/Bds/BootLinux.c

diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index be0919b..45aeaee 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -61,6 +61,9 @@
# we assume the OS will handle the FrameBuffer from the UEFI GOP information.
gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices|FALSE|BOOLEAN|0x0000003D

+ # Enable Legacy Linux support in the BDS
+ gArmPlatformTokenSpaceGuid.PcdBdsLinuxSupport|TRUE|BOOLEAN|0x0000002E
+
[PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdCoreCount|1|UINT32|0x00000039
gArmPlatformTokenSpaceGuid.PcdClusterCount|1|UINT32|0x00000038
diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index 3b6ffc3..06e8d91 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -27,6 +27,7 @@
[Sources]
Bds.c
BdsHelper.c
+ BootLinux.c
BootMenu.c
BootOption.c
BootOptionSupport.c
@@ -72,6 +73,9 @@
gEfiDhcp4ServiceBindingProtocolGuid
gEfiMtftp4ServiceBindingProtocolGuid

+[FeaturePcd]
+ gArmPlatformTokenSpaceGuid.PcdBdsLinuxSupport
+
[Pcd]
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription
diff --git a/ArmPlatformPkg/Bds/BdsHelper.c b/ArmPlatformPkg/Bds/BdsHelper.c
index b3003e9..732292c 100644
--- a/ArmPlatformPkg/Bds/BdsHelper.c
+++ b/ArmPlatformPkg/Bds/BdsHelper.c
@@ -256,15 +256,6 @@ GetHIInputBoolean (
}
}

-BOOLEAN
-HasFilePathEfiExtension (
- IN CHAR16* FilePath
- )
-{
- return (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".EFI") == 0) ||
- (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".efi") == 0);
-}
-
// Return the last non end-type Device Path Node from a Device Path
EFI_DEVICE_PATH*
GetLastDevicePathNode (
diff --git a/ArmPlatformPkg/Bds/BdsInternal.h b/ArmPlatformPkg/Bds/BdsInternal.h
index fe4fd79..ddf5308 100644
--- a/ArmPlatformPkg/Bds/BdsInternal.h
+++ b/ArmPlatformPkg/Bds/BdsInternal.h
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -79,6 +79,12 @@ typedef struct _BDS_LOAD_OPTION_SUPPORT {
#define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)
#define LOAD_OPTION_FROM_LINK(a) ((BDS_LOAD_OPTION_ENTRY*)BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link))->BdsLoadOption

+// GUID of the EFI Linux Loader
+extern CONST EFI_GUID mLinuxLoaderAppGuid;
+
+// Device path of the EFI Linux Loader in the Firmware Volume
+extern EFI_DEVICE_PATH* mLinuxLoaderDevicePath;
+
EFI_STATUS
BootDeviceListSupportedInit (
IN OUT LIST_ENTRY *SupportedDeviceList
@@ -141,11 +147,6 @@ GetHIInputBoolean (
OUT BOOLEAN *Value
);

-BOOLEAN
-HasFilePathEfiExtension (
- IN CHAR16* FilePath
- );
-
EFI_DEVICE_PATH*
GetLastDevicePathNode (
IN EFI_DEVICE_PATH* DevicePath
@@ -260,4 +261,17 @@ EmptyCallbackFunction (
IN VOID *Context
);

+/**
+ * This function check if the DevicePath defines an EFI binary
+ *
+ * This function is used when the BDS support Linux loader to
+ * detect if the binary is an EFI application or potentially a
+ * Linux kernel.
+ */
+EFI_STATUS
+IsEfiBinary (
+ IN EFI_DEVICE_PATH* DevicePath,
+ OUT BOOLEAN *EfiBinary
+ );
+
#endif /* _BDSINTERNAL_H_ */
diff --git a/ArmPlatformPkg/Bds/BootLinux.c b/ArmPlatformPkg/Bds/BootLinux.c
new file mode 100644
index 0000000..0445e89
--- /dev/null
+++ b/ArmPlatformPkg/Bds/BootLinux.c
@@ -0,0 +1,124 @@
+/** @file
+*
+* Copyright (c) 2011 - 2015, ARM Limited. All rights reserved.
+*
+* This program and the accompanying materials
+* are licensed and made available under the terms and conditions of the BSD License
+* which accompanies this distribution. The full text of the license may be found at
+* http://opensource.org/licenses/bsd-license.php
+*
+* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+
+#include "BdsInternal.h"
+
+// 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 of the EFI Linux Loader in the Firmware Volume
+EFI_DEVICE_PATH* mLinuxLoaderDevicePath = NULL;
+
+STATIC
+BOOLEAN
+HasFilePathEfiExtension (
+ IN CHAR16* FilePath
+ )
+{
+ return (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".EFI") == 0) ||
+ (StrCmp (FilePath + (StrSize (FilePath) / sizeof (CHAR16)) - 5, L".efi") == 0);
+}
+
+/**
+ * This function check if the DevicePath defines an EFI binary
+ *
+ * This function is used when the BDS support Linux loader to
+ * detect if the binary is an EFI application or potentially a
+ * Linux kernel.
+ */
+EFI_STATUS
+IsEfiBinary (
+ IN EFI_DEVICE_PATH* DevicePath,
+ OUT BOOLEAN *EfiBinary
+ )
+{
+ EFI_STATUS Status;
+ CHAR16* FileName;
+ EFI_DEVICE_PATH* PrevDevicePathNode;
+ EFI_DEVICE_PATH* DevicePathNode;
+ EFI_PHYSICAL_ADDRESS Image;
+ UINTN FileSize;
+ EFI_IMAGE_DOS_HEADER* DosHeader;
+ UINTN PeCoffHeaderOffset;
+ EFI_IMAGE_NT_HEADERS32* NtHeader;
+
+ ASSERT (EfiBinary != NULL);
+
+ //
+ // Check if the last node of the device path is a FilePath node
+ //
+ PrevDevicePathNode = NULL;
+ DevicePathNode = DevicePath;
+ while ((DevicePathNode != NULL) && !IsDevicePathEnd (DevicePathNode)) {
+ PrevDevicePathNode = DevicePathNode;
+ DevicePathNode = NextDevicePathNode (DevicePathNode);
+ }
+
+ if ((PrevDevicePathNode != NULL) &&
+ (PrevDevicePathNode->Type == MEDIA_DEVICE_PATH) &&
+ (PrevDevicePathNode->SubType == MEDIA_FILEPATH_DP))
+ {
+ FileName = ((FILEPATH_DEVICE_PATH*)PrevDevicePathNode)->PathName;
+ } else {
+ FileName = NULL;
+ }
+
+ if (FileName == NULL) {
+ Print (L"Is an EFI Application? ");
+ Status = GetHIInputBoolean (EfiBinary);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ } else if (HasFilePathEfiExtension (FileName)) {
+ *EfiBinary = TRUE;
+ } else {
+ // Check if the file exist
+ Status = BdsLoadImage (DevicePath, AllocateAnyPages, &Image, &FileSize);
+ if (!EFI_ERROR (Status)) {
+
+ DosHeader = (EFI_IMAGE_DOS_HEADER *)(UINTN) Image;
+ if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present,
+ // so read the PE header after the DOS image header.
+ //
+ PeCoffHeaderOffset = DosHeader->e_lfanew;
+ } else {
+ PeCoffHeaderOffset = 0;
+ }
+
+ //
+ // Check PE/COFF image.
+ //
+ NtHeader = (EFI_IMAGE_NT_HEADERS32 *)(UINTN) (Image + PeCoffHeaderOffset);
+ if (NtHeader->Signature != EFI_IMAGE_NT_SIGNATURE) {
+ *EfiBinary = FALSE;
+ } else {
+ *EfiBinary = TRUE;
+ }
+
+ // Free memory
+ gBS->FreePages (Image, EFI_SIZE_TO_PAGES (FileSize));
+ } else {
+ // If we did not manage to open it then ask for the type
+ Print (L"Is an EFI Application? ");
+ Status = GetHIInputBoolean (EfiBinary);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c
index af7f1f1..8caa3ce 100644
--- a/ArmPlatformPkg/Bds/BootMenu.c
+++ b/ArmPlatformPkg/Bds/BootMenu.c
@@ -269,6 +269,8 @@ BootMenuAddBootOption (
EFI_DEVICE_PATH_PROTOCOL *DevicePathNodes;
UINT8* OptionalData;
UINTN OptionalDataSize;
+ BOOLEAN EfiBinary;
+ CHAR16 *LinuxDevicePath;

Attributes = 0;
SupportedBootDevice = NULL;
@@ -281,8 +283,12 @@ BootMenuAddBootOption (
}

// Create the specific device path node
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes);
- if (EFI_ERROR(Status)) {
+ if (FeaturePcdGet (PcdBdsLinuxSupport) && mLinuxLoaderDevicePath) {
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes);
+ } else {
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application", &DevicePathNodes);
+ }
+ if (EFI_ERROR (Status)) {
Status = EFI_ABORTED;
goto EXIT;
}
@@ -293,8 +299,39 @@ BootMenuAddBootOption (
goto EXIT;
}

+ // Is it an EFI application?
+ if (FeaturePcdGet (PcdBdsLinuxSupport) && mLinuxLoaderDevicePath) {
+ Status = IsEfiBinary (DevicePath, &EfiBinary);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ if (EfiBinary == FALSE) {
+ Print (L"It is assumed the binary is a Linux kernel and the embedded Linux Loader is going to be used.\n");
+ Print (L"Supported command line formats by the embedded Linux Loader:\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\"\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\" -f <EFI Device Path of the Linux initrd>\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\" -a <Machine Type for ATAG Linux kernel>\n");
+
+ // Copy the Linux path into the command line
+ LinuxDevicePath = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
+ CopyMem (CmdLine, LinuxDevicePath, MAX (sizeof (CmdLine), StrSize (LinuxDevicePath)));
+ FreePool (LinuxDevicePath);
+
+ // Free the generated Device Path
+ FreePool (DevicePath);
+ // and use the embedded Linux Loader as the EFI application
+ DevicePath = mLinuxLoaderDevicePath;
+ } else {
+ CmdLine[0] = L'\0';
+ }
+ } else {
+ CmdLine[0] = L'\0';
+ }
+
Print (L"Arguments to pass to the EFI Application: ");
- Status = GetHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);
+ Status = EditHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);
if (EFI_ERROR (Status)) {
Status = EFI_ABORTED;
goto EXIT;
@@ -366,11 +403,13 @@ BootMenuUpdateBootOption (
CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];
CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];
CHAR16 UnicodeCmdLine[BOOT_DEVICE_OPTION_MAX];
+ CHAR16 *LinuxDevicePath;
EFI_DEVICE_PATH *DevicePath;
UINT8* OptionalData;
UINTN OptionalDataSize;
BOOLEAN IsPrintable;
BOOLEAN IsUnicode;
+ BOOLEAN EfiBinary;

DisplayBootOptions (BootOptionsList);
Status = SelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, &BootOptionEntry);
@@ -386,46 +425,87 @@ BootMenuUpdateBootOption (
return EFI_UNSUPPORTED;
}

- Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
+ EfiBinary = TRUE;
+ if (FeaturePcdGet (PcdBdsLinuxSupport) && mLinuxLoaderDevicePath) {
+ Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ // Is it an EFI application?
+ Status = IsEfiBinary (DevicePath, &EfiBinary);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ if (EfiBinary == FALSE) {
+ Print (L"It is assumed the binary is a Linux kernel and the embedded Linux Loader is going to be used.\n");
+ Print (L"Supported command line formats by the embedded Linux Loader:\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\"\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\" -f <EFI Device Path of the Linux initrd>\n");
+ Print (L"- <EFI device path of the Linux kernel> -c \"<Linux kernel command line>\" -a <Machine Type for ATAG Linux kernel>\n");
+
+ // Copy the Linux path into the command line
+ LinuxDevicePath = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
+ CopyMem (UnicodeCmdLine, LinuxDevicePath, MAX (sizeof (UnicodeCmdLine), StrSize (LinuxDevicePath)));
+ FreePool (LinuxDevicePath);
+
+ // Free the generated Device Path
+ FreePool (DevicePath);
+ // and use the embedded Linux Loader as the EFI application
+ DevicePath = mLinuxLoaderDevicePath;
+
+ // The command line is a unicode printable string
+ IsPrintable = TRUE;
+ IsUnicode = TRUE;
+ }
+ } else {
+ Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application", &DevicePath);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
}

Print (L"Arguments to pass to the EFI Application: ");

- if (BootOption->OptionalDataSize > 0) {
- IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);
- if (IsPrintable) {
- //
- // The size in bytes of the string, final zero included, should
- // be equal to or at least lower than "BootOption->OptionalDataSize"
- // and the "IsPrintableString()" has already tested that the length
- // in number of characters is smaller than BOOT_DEVICE_OPTION_MAX,
- // final '\0' included. We can thus copy the string for editing
- // using "CopyMem()". Furthermore, note that in the case of an Unicode
- // string "StrnCpy()" and "StrCpy()" can not be used to copy the
- // string because the data pointed to by "BootOption->OptionalData"
- // is not necessarily 2-byte aligned.
- //
- if (IsUnicode) {
- CopyMem (
- UnicodeCmdLine, BootOption->OptionalData,
- MIN (sizeof (UnicodeCmdLine),
- BootOption->OptionalDataSize)
- );
- } else {
- CopyMem (
- CmdLine, BootOption->OptionalData,
- MIN (sizeof (CmdLine),
- BootOption->OptionalDataSize)
- );
+ // When the command line has not been initialized by the embedded Linux loader earlier
+ if (EfiBinary) {
+ if (BootOption->OptionalDataSize > 0) {
+ IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);
+ if (IsPrintable) {
+ //
+ // The size in bytes of the string, final zero included, should
+ // be equal to or at least lower than "BootOption->OptionalDataSize"
+ // and the "IsPrintableString()" has already tested that the length
+ // in number of characters is smaller than BOOT_DEVICE_OPTION_MAX,
+ // final '\0' included. We can thus copy the string for editing
+ // using "CopyMem()". Furthermore, note that in the case of an Unicode
+ // string "StrnCpy()" and "StrCpy()" can not be used to copy the
+ // string because the data pointed to by "BootOption->OptionalData"
+ // is not necessarily 2-byte aligned.
+ //
+ if (IsUnicode) {
+ CopyMem (
+ UnicodeCmdLine, BootOption->OptionalData,
+ MIN (sizeof (UnicodeCmdLine),
+ BootOption->OptionalDataSize)
+ );
+ } else {
+ CopyMem (
+ CmdLine, BootOption->OptionalData,
+ MIN (sizeof (CmdLine),
+ BootOption->OptionalDataSize)
+ );
+ }
}
+ } else {
+ UnicodeCmdLine[0] = L'\0';
+ IsPrintable = TRUE;
+ IsUnicode = TRUE;
}
- } else {
- UnicodeCmdLine[0] = L'\0';
- IsPrintable = TRUE;
- IsUnicode = TRUE;
}

// We do not request arguments for OptionalData that cannot be printed
@@ -909,7 +989,6 @@ struct BOOT_MAIN_ENTRY {
{ L"Boot Manager", BootMenuManager },
};

-
EFI_STATUS
BootMenuMain (
VOID
@@ -929,6 +1008,12 @@ BootMenuMain (
BootOption = NULL;
BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY);

+ if (FeaturePcdGet (PcdBdsLinuxSupport)) {
+ // Check Linux Loader is present
+ Status = LocateEfiApplicationInFvByGuid (&mLinuxLoaderAppGuid, &mLinuxLoaderDevicePath);
+ ASSERT_EFI_ERROR (Status);
+ }
+
while (TRUE) {
// Get Boot#### list
BootOptionList (&BootOptionsList);
--
2.1.1


------------------------------------------------------------------------------
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-devel mailing list
edk2-***@lists.sourceforge.net<mailto:edk2-***@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/edk2-devel


-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2548782
Olivier Martin
2015-07-13 16:36:50 UTC
Permalink
Change-Id: Id055d77ee78729dcfd692d956e9b5ebc7b930611
---
ArmPkg/ArmPkg.dec | 1 -
ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc | 1 -
ArmPlatformPkg/ArmPlatformPkg.dec | 6 -
.../ArmRealViewEbPkg/ArmRealViewEb.dsc.inc | 1 -
.../ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc | 3 -
.../ArmVExpressPkg/ArmVExpress-CTA9x4.dsc | 3 -
.../ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc | 2 -
.../ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc | 3 -
.../ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc | 3 -
.../ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc | 3 -
.../ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc | 1 -
.../ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc | 1 -
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc | 3 -
ArmPlatformPkg/Bds/Bds.c | 36 +--
ArmPlatformPkg/Bds/Bds.inf | 7 +-
ArmPlatformPkg/Bds/BdsInternal.h | 45 ---
ArmPlatformPkg/Bds/BootMenu.c | 358 ++++-----------------
ArmPlatformPkg/Bds/BootOption.c | 100 ++----
ArmPlatformPkg/Bds/BootOptionSupport.c | 111 -------
BeagleBoardPkg/BeagleBoardPkg.dsc | 7 -
20 files changed, 93 insertions(+), 602 deletions(-)

diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index b30de91..da0c8a9 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -115,7 +115,6 @@
#
# BdsLib
#
- gArmTokenSpaceGuid.PcdArmMachineType|0|UINT32|0x0000001E
# The compressed Linux kernel is expected to be under 128MB from the beginning of the System Memory
gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset|0x08000000|UINT32|0x0000001F
# Maximum file size for TFTP servers that do not support 'tsize' extension
diff --git a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
index b5b959a..9860cf0 100644
--- a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
+++ b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
@@ -151,7 +151,6 @@

# Support the Linux EFI stub by default
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"console=ttyAMA0,115200 earlycon=pl011,0x7ff80000 root=/dev/sda1 rootwait verbose debug"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|0

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N,1)/VenPcAnsi();VenHw(CE660500-824D-11E0-AC72-0002A5D5C51B)"
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index cd67aee..be0919b 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -129,13 +129,7 @@
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"ARM Platform"|VOID*|0x00000019
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Default Boot Device"|VOID*|0x0000000C
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L""|VOID*|0x0000000D
- gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L""|VOID*|0x0000000E
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L""|VOID*|0x000000F
- # PcdDefaultBootType define the type of the binary pointed by PcdDefaultBootDevicePath:
- # - 0 = an EFI application
- # - 1 = a Linux kernel with ATAG support
- # - 2 = a Linux kernel with FDT support
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|0|UINT32|0x00000010

gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L""|VOID*|0x0000001B
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L""|VOID*|0x0000001C
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
index 6232791..9445ce2 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
@@ -316,7 +316,6 @@
#
# ARM OS Loader
#
- gArmTokenSpaceGuid.PcdArmMachineType|827
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(14801114-DA6A-4113-985B-DC876337A15E)/LinuxLoader.efi"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage-RTSM -a 827 -c \"console=ttyAMA0,38400n8\""
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
index 3b693c2..50bb556 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
@@ -181,12 +181,9 @@
#
# ARM OS Loader
#
- # Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NorFlash"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400 earlyprintk debug verbose"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
# PL111 - CLCD
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
index baa5478..18cc978 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
@@ -180,11 +180,8 @@
#
# ARM OS Loader
#
- # Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"NorFlash"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
index bfdc96b..1b6134f 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
@@ -177,8 +177,6 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/filesystem.cpio.gz"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 loglevel=9"
- # Use EFI Stub
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|0

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
index fb42f34..3896166 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
@@ -157,11 +157,8 @@
#
# ARM OS Loader
#
- # Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
index 09dc1db..acfe164 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
@@ -159,11 +159,8 @@
#
# ARM OS Loader
#
- # Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
index 2fe9e58..4bcdc8c 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
@@ -160,12 +160,9 @@
#
# ARM OS Loader
#
- # Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(272E583C-B951-433F-AF42-A9C6862AF002)/LinuxLoader.efi"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage -c \"console=ttyAMA0,38400n8\""
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
index 9129288..c956897 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
@@ -126,7 +126,6 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SemiHosting"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"root=/dev/vda2 rw console=ttyAMA0 earlyprintk=pl011,0x1c090000 maxcpus=4 debug user_debug=31 loglevel=9"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc
index 280fb72..4880591 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc
@@ -155,7 +155,6 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SemiHosting"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"root=/dev/mmcblk0p2 console=ttyAMA0 earlyprintk=pl011,0x1c090000 debug user_debug=31 loglevel=9"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
index 3d6537a..ad804ab 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -380,11 +380,8 @@
#
# ARM OS Loader
#
- # Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NorFlash"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(CE660500-824D-11E0-AC72-0002A5D5C51B)"
diff --git a/ArmPlatformPkg/Bds/Bds.c b/ArmPlatformPkg/Bds/Bds.c
index 1fab439..3ee866c 100644
--- a/ArmPlatformPkg/Bds/Bds.c
+++ b/ArmPlatformPkg/Bds/Bds.c
@@ -220,12 +220,6 @@ DefineDefaultBootEntries (
EFI_STATUS Status;
EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol;
EFI_DEVICE_PATH* BootDevicePath;
- UINT8* OptionalData;
- UINTN OptionalDataSize;
- ARM_BDS_LOADER_ARGUMENTS* BootArguments;
- ARM_BDS_LOADER_TYPE BootType;
- EFI_DEVICE_PATH* InitrdPath;
- UINTN InitrdSize;
UINTN CmdLineSize;
UINTN CmdLineAsciiSize;
CHAR16* DefaultBootArgument;
@@ -269,8 +263,6 @@ DefineDefaultBootEntries (

// Create the entry is the Default values are correct
if (BootDevicePath != NULL) {
- BootType = (ARM_BDS_LOADER_TYPE)PcdGet32 (PcdDefaultBootType);
-
// We do not support NULL pointer
ASSERT (PcdGetPtr (PcdDefaultBootArgument) != NULL);

@@ -308,33 +300,11 @@ DefineDefaultBootEntries (
AsciiStrToUnicodeStr (AsciiDefaultBootArgument, DefaultBootArgument);
}

- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- InitrdPath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootInitrdPath));
- InitrdSize = GetDevicePathSize (InitrdPath);
-
- OptionalDataSize = sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineAsciiSize + InitrdSize;
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (OptionalDataSize);
- if (BootArguments == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- BootArguments->LinuxArguments.CmdLineSize = CmdLineAsciiSize;
- BootArguments->LinuxArguments.InitrdSize = InitrdSize;
-
- CopyMem ((VOID*)(BootArguments + 1), AsciiDefaultBootArgument, CmdLineAsciiSize);
- CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineAsciiSize), InitrdPath, InitrdSize);
-
- OptionalData = (UINT8*)BootArguments;
- } else {
- OptionalData = (UINT8*)DefaultBootArgument;
- OptionalDataSize = CmdLineSize;
- }
-
BootOptionCreate (LOAD_OPTION_ACTIVE | LOAD_OPTION_CATEGORY_BOOT,
- (CHAR16*)PcdGetPtr(PcdDefaultBootDescription),
+ (CHAR16*)PcdGetPtr (PcdDefaultBootDescription),
BootDevicePath,
- BootType,
- OptionalData,
- OptionalDataSize,
+ (UINT8 *)DefaultBootArgument, // OptionalData
+ CmdLineSize, // OptionalDataSize
&BdsLoadOption
);
FreePool (BdsLoadOption);
diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index 9639f14..3b6ffc3 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -24,7 +24,7 @@

ENTRY_POINT = BdsInitialize

-[Sources.common]
+[Sources]
Bds.c
BdsHelper.c
BootMenu.c
@@ -44,12 +44,11 @@

[LibraryClasses]
BdsLib
- TimerLib
- PerformanceLib
UefiBootServicesTableLib
DxeServicesTableLib
UefiDriverEntryPoint
DebugLib
+ PerformanceLib
PrintLib
BaseLib
FdtLib
@@ -77,9 +76,7 @@
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath
- gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths
diff --git a/ArmPlatformPkg/Bds/BdsInternal.h b/ArmPlatformPkg/Bds/BdsInternal.h
index 1cb154e..fe4fd79 100644
--- a/ArmPlatformPkg/Bds/BdsInternal.h
+++ b/ArmPlatformPkg/Bds/BdsInternal.h
@@ -38,46 +38,10 @@
#define BOOT_DEVICE_OPTION_MAX 300
#define BOOT_DEVICE_ADDRESS_MAX (sizeof(L"0x0000000000000000"))

-#define ARM_BDS_OPTIONAL_DATA_SIGNATURE SIGNATURE_32('a', 'b', 'o', 'd')
-
-#define IS_ARM_BDS_BOOTENTRY(ptr) \
- (((ptr)->OptionalData != NULL) && \
- (ReadUnaligned32 ((CONST UINT32*)&((ARM_BDS_LOADER_OPTIONAL_DATA*)((ptr)->OptionalData))->Header.Signature) \
- == ARM_BDS_OPTIONAL_DATA_SIGNATURE))
-
#define UPDATE_BOOT_ENTRY L"Update entry: "
#define DELETE_BOOT_ENTRY L"Delete entry: "
#define MOVE_BOOT_ENTRY L"Move entry: "

-typedef enum {
- BDS_LOADER_EFI_APPLICATION = 0,
- BDS_LOADER_KERNEL_LINUX_ATAG,
- BDS_LOADER_KERNEL_LINUX_FDT,
-} ARM_BDS_LOADER_TYPE;
-
-typedef struct {
- UINT16 CmdLineSize;
- UINT16 InitrdSize;
-
- // These following fields have variable length and are packed:
- //CHAR8 *CmdLine;
- //EFI_DEVICE_PATH_PROTOCOL *InitrdPathList;
-} ARM_BDS_LINUX_ARGUMENTS;
-
-typedef union {
- ARM_BDS_LINUX_ARGUMENTS LinuxArguments;
-} ARM_BDS_LOADER_ARGUMENTS;
-
-typedef struct {
- UINT32 Signature;
- ARM_BDS_LOADER_TYPE LoaderType;
-} ARM_BDS_LOADER_OPTIONAL_DATA_HEADER;
-
-typedef struct {
- ARM_BDS_LOADER_OPTIONAL_DATA_HEADER Header;
- ARM_BDS_LOADER_ARGUMENTS Arguments;
-} ARM_BDS_LOADER_OPTIONAL_DATA;
-
typedef struct {
LIST_ENTRY Link;
BDS_LOAD_OPTION* BdsLoadOption;
@@ -230,7 +194,6 @@ BootOptionCreate (
IN UINT32 Attributes,
IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
IN UINT8* OptionalData,
IN UINTN OptionalDataSize,
OUT BDS_LOAD_OPTION** BdsLoadOption
@@ -242,7 +205,6 @@ BootOptionUpdate (
IN UINT32 Attributes,
IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
IN UINT8* OptionalData,
IN UINTN OptionalDataSize
);
@@ -253,13 +215,6 @@ BootOptionDelete (
);

EFI_STATUS
-BootDeviceGetType (
- IN EFI_DEVICE_PATH* DevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- );
-
-EFI_STATUS
BootMenuMain (
VOID
);
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c
index a304cc4..af7f1f1 100644
--- a/ArmPlatformPkg/Bds/BootMenu.c
+++ b/ArmPlatformPkg/Bds/BootMenu.c
@@ -54,8 +54,6 @@ DisplayBootOptions (
DEBUG_CODE_BEGIN ();
CHAR16* DevicePathTxt;
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
- ARM_BDS_LOADER_TYPE LoaderType;
- ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;

Status = gBS->LocateProtocol (
&gEfiDevicePathToTextProtocolGuid,
@@ -70,20 +68,11 @@ DisplayBootOptions (
);
Print (L"\t- %s\n", DevicePathTxt);

- OptionalData = BdsLoadOption->OptionalData;
- if (IS_ARM_BDS_BOOTENTRY (BdsLoadOption)) {
- LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
- if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) ||
- (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT ) ) {
- Print (L"\t- Arguments: %a\n", &OptionalData->Arguments.LinuxArguments + 1);
- }
- } else if (OptionalData != NULL) {
- if (IsPrintableString (OptionalData, &IsUnicode)) {
- if (IsUnicode) {
- Print (L"\t- Arguments: %s\n", OptionalData);
- } else {
- AsciiPrint ("\t- Arguments: %a\n", OptionalData);
- }
+ if (IsPrintableString (BdsLoadOption->OptionalData, &IsUnicode)) {
+ if (IsUnicode) {
+ Print (L"\t- Arguments: %s\n", BdsLoadOption->OptionalData);
+ } else {
+ AsciiPrint ("\t- Arguments: %a\n", BdsLoadOption->OptionalData);
}
}

@@ -272,20 +261,12 @@ BootMenuAddBootOption (
{
EFI_STATUS Status;
BDS_SUPPORTED_DEVICE* SupportedBootDevice;
- ARM_BDS_LOADER_ARGUMENTS* BootArguments;
CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];
- CHAR8 AsciiCmdLine[BOOT_DEVICE_OPTION_MAX];
CHAR16 CmdLine[BOOT_DEVICE_OPTION_MAX];
UINT32 Attributes;
- ARM_BDS_LOADER_TYPE BootType;
BDS_LOAD_OPTION_ENTRY *BdsLoadOptionEntry;
EFI_DEVICE_PATH *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePathNodes;
- EFI_DEVICE_PATH_PROTOCOL *InitrdPathNodes;
- EFI_DEVICE_PATH_PROTOCOL *InitrdPath;
- UINTN CmdLineSize;
- BOOLEAN InitrdSupport;
- UINTN InitrdSize;
UINT8* OptionalData;
UINTN OptionalDataSize;

@@ -312,79 +293,15 @@ BootMenuAddBootOption (
goto EXIT;
}

- if (SupportedBootDevice->Support->RequestBootType) {
- Status = BootDeviceGetType (DevicePath, &BootType, &Attributes);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
- } else {
- BootType = BDS_LOADER_EFI_APPLICATION;
+ Print (L"Arguments to pass to the EFI Application: ");
+ Status = GetHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
}

- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- Print(L"Add an initrd: ");
- Status = GetHIInputBoolean (&InitrdSupport);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
-
- if (InitrdSupport) {
- // Create the specific device path node
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes);
- if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd
- Status = EFI_ABORTED;
- goto EXIT;
- }
-
- if (InitrdPathNodes != NULL) {
- // Append the Device Path to the selected device path
- InitrdPath = AppendDevicePath (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);
- // Free the InitrdPathNodes created by Support->CreateDevicePathNode()
- FreePool (InitrdPathNodes);
-
- if (InitrdPath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto EXIT;
- }
- } else {
- InitrdPath = NULL;
- }
- } else {
- InitrdPath = NULL;
- }
-
- Print(L"Arguments to pass to the binary: ");
- Status = GetHIInputAscii (AsciiCmdLine, BOOT_DEVICE_OPTION_MAX);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto FREE_DEVICE_PATH;
- }
-
- CmdLineSize = AsciiStrSize (AsciiCmdLine);
- InitrdSize = GetDevicePathSize (InitrdPath);
-
- OptionalDataSize = sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize;
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (OptionalDataSize);
-
- BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
- BootArguments->LinuxArguments.InitrdSize = InitrdSize;
- CopyMem ((VOID*)(&BootArguments->LinuxArguments + 1), AsciiCmdLine, CmdLineSize);
- CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
-
- OptionalData = (UINT8*)BootArguments;
- } else {
- Print (L"Arguments to pass to the EFI Application: ");
- Status = GetHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);
- if (EFI_ERROR (Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
-
- OptionalData = (UINT8*)CmdLine;
- OptionalDataSize = StrSize (CmdLine);
- }
+ OptionalData = (UINT8*)CmdLine;
+ OptionalDataSize = StrSize (CmdLine);

Print(L"Description for this new Entry: ");
Status = GetHIInputStr (BootDescription, BOOT_DEVICE_DESCRIPTION_MAX);
@@ -395,7 +312,7 @@ BootMenuAddBootOption (

// Create new entry
BdsLoadOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool (sizeof(BDS_LOAD_OPTION_ENTRY));
- Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize, &BdsLoadOptionEntry->BdsLoadOption);
+ Status = BootOptionCreate (Attributes, BootDescription, DevicePath, OptionalData, OptionalDataSize, &BdsLoadOptionEntry->BdsLoadOption);
if (!EFI_ERROR(Status)) {
InsertTailList (BootOptionsList, &BdsLoadOptionEntry->Link);
}
@@ -446,20 +363,10 @@ BootMenuUpdateBootOption (
BDS_LOAD_OPTION_ENTRY *BootOptionEntry;
BDS_LOAD_OPTION *BootOption;
BDS_LOAD_OPTION_SUPPORT* DeviceSupport;
- ARM_BDS_LOADER_ARGUMENTS* BootArguments;
CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];
CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];
CHAR16 UnicodeCmdLine[BOOT_DEVICE_OPTION_MAX];
EFI_DEVICE_PATH *DevicePath;
- EFI_DEVICE_PATH *TempInitrdPath;
- ARM_BDS_LOADER_TYPE BootType;
- ARM_BDS_LOADER_OPTIONAL_DATA* LoaderOptionalData;
- ARM_BDS_LINUX_ARGUMENTS* LinuxArguments;
- EFI_DEVICE_PATH *InitrdPathNodes;
- EFI_DEVICE_PATH *InitrdPath;
- UINTN InitrdSize;
- UINTN CmdLineSize;
- BOOLEAN InitrdSupport;
UINT8* OptionalData;
UINTN OptionalDataSize;
BOOLEAN IsPrintable;
@@ -485,165 +392,67 @@ BootMenuUpdateBootOption (
goto EXIT;
}

- if (DeviceSupport->RequestBootType) {
- Status = BootDeviceGetType (DevicePath, &BootType, &BootOption->Attributes);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
- }
-
- LoaderOptionalData = BootOption->OptionalData;
- if (LoaderOptionalData != NULL) {
- BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&LoaderOptionalData->Header.LoaderType));
- } else {
- BootType = BDS_LOADER_EFI_APPLICATION;
- }
-
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- LinuxArguments = &LoaderOptionalData->Arguments.LinuxArguments;
-
- CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
-
- InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);
- if (InitrdSize > 0) {
- Print(L"Keep the initrd: ");
- } else {
- Print(L"Add an initrd: ");
- }
- Status = GetHIInputBoolean (&InitrdSupport);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
+ Print (L"Arguments to pass to the EFI Application: ");

- if (InitrdSupport) {
- if (InitrdSize > 0) {
- // Case we update the initrd device path
- Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize), L"initrd", &InitrdPath);
- if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {// EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd
- Status = EFI_ABORTED;
- goto EXIT;
- }
- InitrdSize = GetDevicePathSize (InitrdPath);
+ if (BootOption->OptionalDataSize > 0) {
+ IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);
+ if (IsPrintable) {
+ //
+ // The size in bytes of the string, final zero included, should
+ // be equal to or at least lower than "BootOption->OptionalDataSize"
+ // and the "IsPrintableString()" has already tested that the length
+ // in number of characters is smaller than BOOT_DEVICE_OPTION_MAX,
+ // final '\0' included. We can thus copy the string for editing
+ // using "CopyMem()". Furthermore, note that in the case of an Unicode
+ // string "StrnCpy()" and "StrCpy()" can not be used to copy the
+ // string because the data pointed to by "BootOption->OptionalData"
+ // is not necessarily 2-byte aligned.
+ //
+ if (IsUnicode) {
+ CopyMem (
+ UnicodeCmdLine, BootOption->OptionalData,
+ MIN (sizeof (UnicodeCmdLine),
+ BootOption->OptionalDataSize)
+ );
} else {
- // Case we create the initrd device path
-
- Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNodes);
- if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd
- Status = EFI_ABORTED;
- goto EXIT;
- }
-
- if (InitrdPathNodes != NULL) {
- // Duplicate Linux kernel Device Path
- TempInitrdPath = DuplicateDevicePath (BootOption->FilePathList);
- // Replace Linux kernel Node by EndNode
- SetDevicePathEndNode (GetLastDevicePathNode (TempInitrdPath));
- // Append the Device Path to the selected device path
- InitrdPath = AppendDevicePath (TempInitrdPath, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);
- FreePool (TempInitrdPath);
- // Free the InitrdPathNodes created by Support->CreateDevicePathNode()
- FreePool (InitrdPathNodes);
- if (InitrdPath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto EXIT;
- }
- InitrdSize = GetDevicePathSize (InitrdPath);
- } else {
- InitrdPath = NULL;
- }
+ CopyMem (
+ CmdLine, BootOption->OptionalData,
+ MIN (sizeof (CmdLine),
+ BootOption->OptionalDataSize)
+ );
}
- } else {
- InitrdSize = 0;
- }
-
- Print(L"Arguments to pass to the binary: ");
- if (CmdLineSize > 0) {
- AsciiStrnCpy (CmdLine, (CONST CHAR8*)(LinuxArguments + 1), sizeof (CmdLine));
- CmdLine[sizeof (CmdLine) - 1] = '\0';
- } else {
- CmdLine[0] = '\0';
}
- Status = EditHIInputAscii (CmdLine, BOOT_DEVICE_OPTION_MAX);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto FREE_DEVICE_PATH;
- }
-
- CmdLineSize = AsciiStrSize (CmdLine);
-
- OptionalDataSize = sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize;
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (OptionalDataSize);
- BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
- BootArguments->LinuxArguments.InitrdSize = InitrdSize;
- CopyMem (&BootArguments->LinuxArguments + 1, CmdLine, CmdLineSize);
- CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
-
- OptionalData = (UINT8*)BootArguments;
} else {
- Print (L"Arguments to pass to the EFI Application: ");
+ UnicodeCmdLine[0] = L'\0';
+ IsPrintable = TRUE;
+ IsUnicode = TRUE;
+ }

- if (BootOption->OptionalDataSize > 0) {
- IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);
- if (IsPrintable) {
- //
- // The size in bytes of the string, final zero included, should
- // be equal to or at least lower than "BootOption->OptionalDataSize"
- // and the "IsPrintableString()" has already tested that the length
- // in number of characters is smaller than BOOT_DEVICE_OPTION_MAX,
- // final '\0' included. We can thus copy the string for editing
- // using "CopyMem()". Furthermore, note that in the case of an Unicode
- // string "StrnCpy()" and "StrCpy()" can not be used to copy the
- // string because the data pointed to by "BootOption->OptionalData"
- // is not necessarily 2-byte aligned.
- //
- if (IsUnicode) {
- CopyMem (
- UnicodeCmdLine, BootOption->OptionalData,
- MIN (sizeof (UnicodeCmdLine),
- BootOption->OptionalDataSize)
- );
- } else {
- CopyMem (
- CmdLine, BootOption->OptionalData,
- MIN (sizeof (CmdLine),
- BootOption->OptionalDataSize)
- );
- }
+ // We do not request arguments for OptionalData that cannot be printed
+ if (IsPrintable) {
+ if (IsUnicode) {
+ Status = EditHIInputStr (UnicodeCmdLine, BOOT_DEVICE_OPTION_MAX);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto FREE_DEVICE_PATH;
}
- } else {
- UnicodeCmdLine[0] = L'\0';
- IsPrintable = TRUE;
- IsUnicode = TRUE;
- }
-
- // We do not request arguments for OptionalData that cannot be printed
- if (IsPrintable) {
- if (IsUnicode) {
- Status = EditHIInputStr (UnicodeCmdLine, BOOT_DEVICE_OPTION_MAX);
- if (EFI_ERROR (Status)) {
- Status = EFI_ABORTED;
- goto FREE_DEVICE_PATH;
- }
-
- OptionalData = (UINT8*)UnicodeCmdLine;
- OptionalDataSize = StrSize (UnicodeCmdLine);
- } else {
- Status = EditHIInputAscii (CmdLine, BOOT_DEVICE_OPTION_MAX);
- if (EFI_ERROR (Status)) {
- Status = EFI_ABORTED;
- goto FREE_DEVICE_PATH;
- }

- OptionalData = (UINT8*)CmdLine;
- OptionalDataSize = AsciiStrSize (CmdLine);
- }
+ OptionalData = (UINT8*)UnicodeCmdLine;
+ OptionalDataSize = StrSize (UnicodeCmdLine);
} else {
- // We keep the former OptionalData
- OptionalData = BootOption->OptionalData;
- OptionalDataSize = BootOption->OptionalDataSize;
+ Status = EditHIInputAscii (CmdLine, BOOT_DEVICE_OPTION_MAX);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto FREE_DEVICE_PATH;
+ }
+
+ OptionalData = (UINT8*)CmdLine;
+ OptionalDataSize = AsciiStrSize (CmdLine);
}
+ } else {
+ // We keep the former OptionalData
+ OptionalData = BootOption->OptionalData;
+ OptionalDataSize = BootOption->OptionalDataSize;
}

Print(L"Description for this new Entry: ");
@@ -655,7 +464,7 @@ BootMenuUpdateBootOption (
}

// Update the entry
- Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize);
+ Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, OptionalData, OptionalDataSize);

FREE_DEVICE_PATH:
FreePool (DevicePath);
@@ -1139,9 +948,6 @@ BootMenuMain (
DEBUG_CODE_BEGIN();
CHAR16* DevicePathTxt;
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
- ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
- UINTN CmdLineSize;
- ARM_BDS_LOADER_TYPE LoaderType;

Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
if (EFI_ERROR(Status)) {
@@ -1153,39 +959,7 @@ BootMenuMain (

Print(L"\t- %s\n",DevicePathTxt);

- // If it is a supported BootEntry then print its details
- if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
- OptionalData = BootOption->OptionalData;
- LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
- if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.InitrdSize) > 0) {
- CmdLineSize = ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize);
- DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (
- GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(&OptionalData->Arguments.LinuxArguments + 1) + CmdLineSize)), TRUE, TRUE);
- Print(L"\t- Initrd: %s\n", DevicePathTxt);
- }
- if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize) > 0) {
- Print(L"\t- Arguments: %a\n", (&OptionalData->Arguments.LinuxArguments + 1));
- }
- }
-
- switch (LoaderType) {
- case BDS_LOADER_EFI_APPLICATION:
- Print(L"\t- LoaderType: EFI Application\n");
- break;
-
- case BDS_LOADER_KERNEL_LINUX_ATAG:
- Print(L"\t- LoaderType: Linux kernel with ATAG support\n");
- break;
-
- case BDS_LOADER_KERNEL_LINUX_FDT:
- Print(L"\t- LoaderType: Linux kernel with FDT support\n");
- break;
-
- default:
- Print(L"\t- LoaderType: Not recognized (%d)\n", LoaderType);
- }
- } else if (BootOption->OptionalData != NULL) {
+ if (BootOption->OptionalData != NULL) {
if (IsPrintableString (BootOption->OptionalData, &IsUnicode)) {
if (IsUnicode) {
Print (L"\t- Arguments: %s\n", BootOption->OptionalData);
diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c
index 342d441..bdd02b4 100644
--- a/ArmPlatformPkg/Bds/BootOption.c
+++ b/ArmPlatformPkg/Bds/BootOption.c
@@ -20,48 +20,27 @@ BootOptionStart (
IN BDS_LOAD_OPTION *BootOption
)
{
- EFI_STATUS Status;
- UINT32 LoaderType;
- ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
- UINT16 LoadOptionIndexSize;
-
- if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
- Status = EFI_UNSUPPORTED;
- OptionalData = BootOption->OptionalData;
- LoaderType = ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
-
- if (LoaderType == BDS_LOADER_EFI_APPLICATION) {
- if ((BootOption->Attributes & LOAD_OPTION_CATEGORY) == LOAD_OPTION_CATEGORY_APP) {
- // Need to connect every drivers to ensure no dependencies are missing for the application
- BdsConnectAllDrivers ();
- }
+ EFI_STATUS Status;
+ UINT16 LoadOptionIndexSize;

- Status = BdsStartEfiApplication (gImageHandle, BootOption->FilePathList, 0, NULL);
- } else if (LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) {
- ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
- } else if (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT) {
- ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
- }
- } else {
- // Connect all the drivers if the EFI Application is not a EFI OS Loader
- if ((BootOption->Attributes & LOAD_OPTION_CATEGORY) == LOAD_OPTION_CATEGORY_APP) {
- BdsConnectAllDrivers ();
- }
+ // Connect all the drivers if the EFI Application is not a EFI OS Loader
+ if ((BootOption->Attributes & LOAD_OPTION_CATEGORY) == LOAD_OPTION_CATEGORY_APP) {
+ BdsConnectAllDrivers ();
+ }

- // Set BootCurrent variable
- LoadOptionIndexSize = sizeof(UINT16);
- gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- LoadOptionIndexSize, &(BootOption->LoadOptionIndex));
+ // Set BootCurrent variable
+ LoadOptionIndexSize = sizeof (UINT16);
+ gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ LoadOptionIndexSize, &(BootOption->LoadOptionIndex));

- Status = BdsStartEfiApplication (gImageHandle, BootOption->FilePathList, BootOption->OptionalDataSize, BootOption->OptionalData);
+ Status = BdsStartEfiApplication (gImageHandle, BootOption->FilePathList, BootOption->OptionalDataSize, BootOption->OptionalData);

- // Clear BootCurrent variable
- LoadOptionIndexSize = sizeof(UINT16);
- gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- 0, NULL);
- }
+ // Clear BootCurrent variable
+ LoadOptionIndexSize = sizeof (UINT16);
+ gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ 0, NULL);

return Status;
}
@@ -107,7 +86,6 @@ BootOptionSetFields (
IN UINT32 Attributes,
IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
IN UINT8* OptionalData,
IN UINTN OptionalDataSize
)
@@ -117,10 +95,6 @@ BootOptionSetFields (
UINTN BootDescriptionSize;
UINT16 FilePathListLength;
UINT8* EfiLoadOptionPtr;
- UINT8* InitrdPathListPtr;
- ARM_BDS_LINUX_ARGUMENTS* DestLinuxArguments;
- ARM_BDS_LINUX_ARGUMENTS* SrcLinuxArguments;
- ARM_BDS_LOADER_ARGUMENTS* BootArguments;

// If we are overwriting an existent Boot Option then we have to free previously allocated memory
if (BootOption->LoadOption) {
@@ -129,11 +103,6 @@ BootOptionSetFields (

BootDescriptionSize = StrSize (BootDescription);

- // Fixup the size in case of entry specific to ArmPlatformPkg/Bds
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- OptionalDataSize += sizeof(ARM_BDS_LOADER_OPTIONAL_DATA_HEADER);
- }
-
// Compute the size of the FilePath list
FilePathListLength = GetUnalignedDevicePathSize (DevicePath);

@@ -169,33 +138,10 @@ BootOptionSetFields (
// Optional Data fields, Do unaligned writes
BootOption->OptionalData = EfiLoadOptionPtr;

- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- // Write the header
- WriteUnaligned32 ((UINT32 *)EfiLoadOptionPtr, ARM_BDS_OPTIONAL_DATA_SIGNATURE);
- WriteUnaligned32 ((UINT32 *)(EfiLoadOptionPtr + 4), BootType);
-
- // OptionalData should have been initialized by the caller of this function
- ASSERT (OptionalData != NULL);
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)OptionalData;
- SrcLinuxArguments = &(BootArguments->LinuxArguments);
- DestLinuxArguments = &((ARM_BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments.LinuxArguments;
-
- WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->CmdLineSize), SrcLinuxArguments->CmdLineSize);
- WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->InitrdSize), SrcLinuxArguments->InitrdSize);
-
- if (SrcLinuxArguments->CmdLineSize > 0) {
- CopyMem ((VOID*)(DestLinuxArguments + 1), (VOID*)(SrcLinuxArguments + 1), SrcLinuxArguments->CmdLineSize);
- }
-
- if (SrcLinuxArguments->InitrdSize > 0) {
- InitrdPathListPtr = (UINT8*)((UINTN)(DestLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize);
- CopyMem (InitrdPathListPtr, (VOID*)((UINTN)(SrcLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize), SrcLinuxArguments->InitrdSize);
- }
- } else {
- if (OptionalData != NULL) {
- CopyMem (BootOption->OptionalData, OptionalData, OptionalDataSize);
- }
+ if (OptionalData != NULL) {
+ CopyMem (BootOption->OptionalData, OptionalData, OptionalDataSize);
}
+
BootOption->OptionalDataSize = OptionalDataSize;

// If this function is called at the creation of the Boot Device entry (not at the update) the
@@ -216,7 +162,6 @@ BootOptionCreate (
IN UINT32 Attributes,
IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
IN UINT8* OptionalData,
IN UINTN OptionalDataSize,
OUT BDS_LOAD_OPTION** BdsLoadOption
@@ -237,7 +182,7 @@ BootOptionCreate (
BootOptionEntry->BdsLoadOption = (BDS_LOAD_OPTION*)AllocateZeroPool (sizeof(BDS_LOAD_OPTION));

BootOption = BootOptionEntry->BdsLoadOption;
- BootOptionSetFields (BootOption, Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize);
+ BootOptionSetFields (BootOption, Attributes, BootDescription, DevicePath, OptionalData, OptionalDataSize);

//
// Set the related environment variables
@@ -290,7 +235,6 @@ BootOptionUpdate (
IN UINT32 Attributes,
IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
IN UINT8* OptionalData,
IN UINTN OptionalDataSize
)
@@ -299,7 +243,7 @@ BootOptionUpdate (
CHAR16 BootVariableName[9];

// Update the BDS Load Option structure
- BootOptionSetFields (BdsLoadOption, Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize);
+ BootOptionSetFields (BdsLoadOption, Attributes, BootDescription, DevicePath, OptionalData, OptionalDataSize);

// Update the related environment variables
UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BdsLoadOption->LoadOptionIndex);
diff --git a/ArmPlatformPkg/Bds/BootOptionSupport.c b/ArmPlatformPkg/Bds/BootOptionSupport.c
index 974f220..f50f13f 100644
--- a/ArmPlatformPkg/Bds/BootOptionSupport.c
+++ b/ArmPlatformPkg/Bds/BootOptionSupport.c
@@ -214,117 +214,6 @@ BootDeviceGetDeviceSupport (
}

EFI_STATUS
-BootDeviceGetType (
- IN EFI_DEVICE_PATH* DevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- )
-{
- EFI_STATUS Status;
- BOOLEAN IsEfiApp;
- BOOLEAN IsBootLoader;
- BOOLEAN HasFDTSupport;
- CHAR16* FileName;
- EFI_DEVICE_PATH* PrevDevicePathNode;
- EFI_DEVICE_PATH* DevicePathNode;
- EFI_PHYSICAL_ADDRESS Image;
- UINTN FileSize;
- EFI_IMAGE_DOS_HEADER* DosHeader;
- UINTN PeCoffHeaderOffset;
- EFI_IMAGE_NT_HEADERS32* NtHeader;
-
- //
- // Check if the last node of the device path is a FilePath node
- //
- PrevDevicePathNode = NULL;
- DevicePathNode = DevicePath;
- while ((DevicePathNode != NULL) && !IsDevicePathEnd (DevicePathNode)) {
- PrevDevicePathNode = DevicePathNode;
- DevicePathNode = NextDevicePathNode (DevicePathNode);
- }
-
- if ((PrevDevicePathNode != NULL) &&
- (PrevDevicePathNode->Type == MEDIA_DEVICE_PATH) &&
- (PrevDevicePathNode->SubType == MEDIA_FILEPATH_DP))
- {
- FileName = ((FILEPATH_DEVICE_PATH*)PrevDevicePathNode)->PathName;
- } else {
- FileName = NULL;
- }
-
- if (FileName == NULL) {
- Print(L"Is an EFI Application? ");
- Status = GetHIInputBoolean (&IsEfiApp);
- if (EFI_ERROR(Status)) {
- return EFI_ABORTED;
- }
- } else if (HasFilePathEfiExtension(FileName)) {
- IsEfiApp = TRUE;
- } else {
- // Check if the file exist
- Status = BdsLoadImage (DevicePath, AllocateAnyPages, &Image, &FileSize);
- if (!EFI_ERROR (Status)) {
-
- DosHeader = (EFI_IMAGE_DOS_HEADER *)(UINTN) Image;
- if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
- //
- // DOS image header is present,
- // so read the PE header after the DOS image header.
- //
- PeCoffHeaderOffset = DosHeader->e_lfanew;
- } else {
- PeCoffHeaderOffset = 0;
- }
-
- //
- // Check PE/COFF image.
- //
- NtHeader = (EFI_IMAGE_NT_HEADERS32 *)(UINTN) (Image + PeCoffHeaderOffset);
- if (NtHeader->Signature != EFI_IMAGE_NT_SIGNATURE) {
- IsEfiApp = FALSE;
- } else {
- IsEfiApp = TRUE;
- }
-
- // Free memory
- gBS->FreePages (Image, EFI_SIZE_TO_PAGES(FileSize));
- } else {
- // If we did not manage to open it then ask for the type
- Print(L"Is an EFI Application? ");
- Status = GetHIInputBoolean (&IsEfiApp);
- if (EFI_ERROR(Status)) {
- return EFI_ABORTED;
- }
- }
- }
-
- if (IsEfiApp) {
- Print(L"Is your application an OS loader? ");
- Status = GetHIInputBoolean (&IsBootLoader);
- if (EFI_ERROR(Status)) {
- return EFI_ABORTED;
- }
- if (!IsBootLoader) {
- *Attributes |= LOAD_OPTION_CATEGORY_APP;
- }
- *BootType = BDS_LOADER_EFI_APPLICATION;
- } else {
- Print(L"Has FDT support? ");
- Status = GetHIInputBoolean (&HasFDTSupport);
- if (EFI_ERROR(Status)) {
- return EFI_ABORTED;
- }
- if (HasFDTSupport) {
- *BootType = BDS_LOADER_KERNEL_LINUX_FDT;
- } else {
- *BootType = BDS_LOADER_KERNEL_LINUX_ATAG;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
BdsLoadOptionFileSystemList (
IN OUT LIST_ENTRY* BdsLoadOptionList
)
diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc b/BeagleBoardPkg/BeagleBoardPkg.dsc
index 7aa6ce2..5338492 100644
--- a/BeagleBoardPkg/BeagleBoardPkg.dsc
+++ b/BeagleBoardPkg/BeagleBoardPkg.dsc
@@ -362,18 +362,11 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SD"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(B615F1F5-5088-43CD-809C-A16E52487D00)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=tty0 console=ttyS2,115200n8 root=UUID=a4af765b-c2b5-48f4-9564-7a4e9104c4f6 rootwait ro earlyprintk"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|10

gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N,1)/VenPcAnsi();VenHw(E68088EF-D1A4-4336-C1DB-4D3A204730A6)"
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N,1)/VenPcAnsi()"

- #
- # ARM OS Loader
- #
- # BeagleBoard machine type (OMAP3_BEAGLE = 1546) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|1546
-
################################################################################
#
# Components Section - list of all EDK II Modules needed by this Platform
--
2.1.1
Olivier Martin
2015-07-13 16:36:48 UTC
Permalink
Change-Id: Ieb50d812dccdf0f105b7a0848349a5010b67097c
---
ArmPkg/Include/Library/BdsLib.h | 37 --
ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c | 355 -------------
.../Library/BdsLib/AArch64/BdsLinuxLoaderHelper.S | 58 ---
ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c | 173 -------
ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c | 323 ------------
ArmPkg/Library/BdsLib/BdsHelper.c | 178 +------
ArmPkg/Library/BdsLib/BdsInternal.h | 13 -
ArmPkg/Library/BdsLib/BdsLib.inf | 38 --
ArmPkg/Library/BdsLib/BdsLinuxFdt.c | 572 ---------------------
ArmPkg/Library/BdsLib/BdsLinuxLoader.h | 156 ------
ArmPlatformPkg/Bds/Bds.inf | 4 +
ArmPlatformPkg/Bds/BootOption.c | 35 +-
12 files changed, 8 insertions(+), 1934 deletions(-)
delete mode 100644 ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c
delete mode 100644 ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoaderHelper.S
delete mode 100644 ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c
delete mode 100644 ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
delete mode 100644 ArmPkg/Library/BdsLib/BdsLinuxFdt.c
delete mode 100644 ArmPkg/Library/BdsLib/BdsLinuxLoader.h

diff --git a/ArmPkg/Include/Library/BdsLib.h b/ArmPkg/Include/Library/BdsLib.h
index 3d9e195..c58f47e 100644
--- a/ArmPkg/Include/Library/BdsLib.h
+++ b/ArmPkg/Include/Library/BdsLib.h
@@ -138,43 +138,6 @@ BootOptionAllocateBootIndex (
);

/**
- Start a Linux kernel from a Device Path
-
- @param LinuxKernel Device Path to the Linux Kernel
- @param Parameters Linux kernel arguments
-
- @retval EFI_SUCCESS All drivers have been connected
- @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsBootLinuxAtag (
- IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* Arguments
- );
-
-/**
- Start a Linux kernel from a Device Path
-
- @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
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsBootLinuxFdt (
- IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* Arguments
- );
-
-/**
Start an EFI Application from a Device Path

@param ParentImageHandle Handle of the calling image
diff --git a/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c b/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c
deleted file mode 100644
index 7651597..0000000
--- a/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-#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"
-
-/*
- Linux kernel booting: Look at the doc in the Kernel source :
- Documentation/arm64/booting.txt
- The kernel image must be placed at the start of the memory to be used by the
- kernel (2MB aligned) + 0x80000.
-
- The Device tree blob is expected to be under 2MB and be within the first 512MB
- of kernel memory and be 2MB aligned.
-
- A Flattened Device Tree (FDT) used to boot linux needs to be updated before
- the kernel is started. It needs to indicate how secondary cores are brought up
- and where they are waiting before loading Linux. The FDT also needs to hold
- the correct kernel command line and filesystem RAM-disk information.
- At the moment we do not fully support generating this FDT information at
- runtime. A prepared FDT should be provided at boot. FDT is the only supported
- method for booting the AArch64 Linux kernel.
-
- Linux does not use any runtime services at this time, so we can let it
- overwrite UEFI.
-*/
-
-
-#define LINUX_ALIGN_VAL (0x080000) // 2MB + 0x80000 mask
-#define LINUX_ALIGN_MASK (0x1FFFFF) // Bottom 21bits
-#define ALIGN_2MB(addr) ALIGN_POINTER(addr , (2*1024*1024))
-
-/* ARM32 and AArch64 kernel handover differ.
- * x0 is set to FDT base.
- * x1-x3 are reserved for future use and should be set to zero.
- */
-typedef VOID (*LINUX_KERNEL64)(UINTN ParametersBase, UINTN Reserved0,
- UINTN Reserved1, UINTN Reserved2);
-
-/* These externs are used to relocate some ASM code into Linux memory. */
-extern VOID *SecondariesPenStart;
-extern VOID *SecondariesPenEnd;
-extern UINTN *AsmMailboxbase;
-
-
-STATIC
-EFI_STATUS
-PreparePlatformHardware (
- VOID
- )
-{
- //Note: Interrupts will be disabled by the GIC driver when ExitBootServices() will be called.
-
- // Clean before Disable else the Stack gets corrupted with old data.
- ArmCleanDataCache ();
- ArmDisableDataCache ();
- // Invalidate all the entries that might have snuck in.
- ArmInvalidateDataCache ();
-
- // Disable and invalidate the instruction cache
- ArmDisableInstructionCache ();
- ArmInvalidateInstructionCache ();
-
- // Turn off MMU
- ArmDisableMmu();
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-StartLinux (
- IN EFI_PHYSICAL_ADDRESS LinuxImage,
- IN UINTN LinuxImageSize,
- IN EFI_PHYSICAL_ADDRESS FdtBlobBase,
- IN UINTN FdtBlobSize
- )
-{
- EFI_STATUS Status;
- LINUX_KERNEL64 LinuxKernel = (LINUX_KERNEL64)LinuxImage;
-
- // Send msg to secondary cores to go to the kernel pen.
- ArmGicSendSgiTo (PcdGet32(PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));
-
- // Shut down UEFI boot services. ExitBootServices() will notify every driver that created an event on
- // ExitBootServices event. Example the Interrupt DXE driver will disable the interrupts on this event.
- Status = ShutdownUefiBootServices ();
- if(EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR,"ERROR: Can not shutdown UEFI boot services. Status=0x%X\n", Status));
- goto Exit;
- }
-
- // Check if the Linux Image is a uImage
- if (*(UINTN*)LinuxKernel == LINUX_UIMAGE_SIGNATURE) {
- // Assume the Image Entry Point is just after the uImage header (64-byte size)
- LinuxKernel = (LINUX_KERNEL64)((UINTN)LinuxKernel + 64);
- LinuxImageSize -= 64;
- }
-
- //
- // Switch off interrupts, caches, mmu, etc
- //
- Status = PreparePlatformHardware ();
- ASSERT_EFI_ERROR(Status);
-
- // Register and print out performance information
- PERF_END (NULL, "BDS", NULL, 0);
- if (PerformanceMeasurementEnabled ()) {
- PrintPerformance ();
- }
-
- //
- // Start the Linux Kernel
- //
-
- // x1-x3 are reserved (set to zero) for future use.
- LinuxKernel ((UINTN)FdtBlobBase, 0, 0, 0);
-
- // Kernel should never exit
- // After Life services are not provided
- ASSERT(FALSE);
-
-Exit:
- // Only be here if we fail to start Linux
- Print (L"ERROR : Can not start the kernel. Status=0x%X\n", Status);
-
- // Free Runtimee Memory (kernel and FDT)
- return Status;
-}
-
-
-/**
- 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
-
- @retval EFI_SUCCESS All drivers have been connected
- @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsBootLinuxAtag (
- IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* Arguments
- )
-{
- // NOTE : AArch64 Linux kernel does not support ATAG, FDT only.
- ASSERT(0);
-
- return RETURN_UNSUPPORTED;
-}
-
-/**
- Start a Linux kernel from a Device Path
-
- @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
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsBootLinuxFdt (
- IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* Arguments
- )
-{
- 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;
- InitrdImage = 0;
- InitrdImageSize = 0;
- InitrdImageBase = 0;
- InitrdImageBaseSize = 0;
-
- PERF_START (NULL, "BDS", NULL, 0);
-
- //
- // Load the Linux kernel from a device path
- //
-
- // Try to put the kernel at the start of RAM so as to give it access to all memory.
- // If that fails fall back to try loading it within LINUX_KERNEL_MAX_OFFSET of memory start.
- LinuxImage = PcdGet64 (PcdSystemMemoryBase) + 0x80000;
- Status = BdsLoadImage (LinuxKernelDevicePath, AllocateAddress, &LinuxImage, &LinuxImageSize);
- if (EFI_ERROR(Status)) {
- // Try again but give the loader more freedom of where to put the image.
- LinuxImage = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (LinuxKernelDevicePath, AllocateMaxAddress, &LinuxImage, &LinuxImageSize);
- if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find Linux kernel (%r).\n", Status);
- return Status;
- }
- }
- // Adjust the kernel location slightly if required. The kernel needs to be placed at start
- // of memory (2MB aligned) + 0x80000.
- if ((LinuxImage & LINUX_ALIGN_MASK) != LINUX_ALIGN_VAL) {
- LinuxImage = (EFI_PHYSICAL_ADDRESS)CopyMem (ALIGN_2MB(LinuxImage) + 0x80000, (VOID*)(UINTN)LinuxImage, LinuxImageSize);
- }
-
- if (InitrdDevicePath) {
- InitrdImageBase = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (InitrdDevicePath, AllocateMaxAddress, &InitrdImageBase, &InitrdImageBaseSize);
- if (Status == EFI_OUT_OF_RESOURCES) {
- Status = BdsLoadImage (InitrdDevicePath, AllocateAnyPages, &InitrdImageBase, &InitrdImageBaseSize);
- }
- if (EFI_ERROR (Status)) {
- Print (L"ERROR: Did not find initrd image (%r).\n", Status);
- goto EXIT_FREE_LINUX;
- }
-
- // Check if the initrd is a uInitrd
- if (*(UINTN*)((UINTN)InitrdImageBase) == LINUX_UIMAGE_SIGNATURE) {
- // Skip the 64-byte image header
- InitrdImage = (EFI_PHYSICAL_ADDRESS)((UINTN)InitrdImageBase + 64);
- InitrdImageSize = InitrdImageBaseSize - 64;
- } else {
- InitrdImage = InitrdImageBase;
- InitrdImageSize = InitrdImageBaseSize;
- }
- }
-
- //
- // 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
- //
- if (FeaturePcdGet (PcdArmLinuxSpinTable)) {
- // Place Pen at the start of Linux memory. We can then tell Linux to not use this bit of memory
- PenBase = LinuxImage - 0x80000;
- PenSize = (UINTN)&SecondariesPenEnd - (UINTN)&SecondariesPenStart;
-
- // Reserve the memory as RuntimeServices
- PenBaseStatus = gBS->AllocatePages (AllocateAddress, EfiRuntimeServicesCode, EFI_SIZE_TO_PAGES (PenSize), &PenBase);
- if (EFI_ERROR (PenBaseStatus)) {
- Print (L"Warning: Failed to reserve the memory required for the secondary cores at 0x%lX, Status = %r\n", PenBase, PenBaseStatus);
- // Even if there is a risk of memory corruption we carry on
- }
-
- // Put mailboxes below the pen code so we know where they are relative to code.
- MailBoxBase = (UINTN)PenBase + ((UINTN)&SecondariesPenEnd - (UINTN)&SecondariesPenStart);
- // Make sure this is 8 byte aligned.
- if (MailBoxBase % sizeof(MailBoxBase) != 0) {
- MailBoxBase += sizeof(MailBoxBase) - MailBoxBase % sizeof(MailBoxBase);
- }
-
- CopyMem ( (VOID*)(PenBase), (VOID*)&SecondariesPenStart, PenSize);
-
- // Update the MailboxBase variable used in the pen code
- *(UINTN*)(PenBase + ((UINTN)&AsmMailboxbase - (UINTN)&SecondariesPenStart)) = MailBoxBase;
-
- for (Index=0; Index < gST->NumberOfTableEntries; Index++) {
- // Check for correct GUID type
- if (CompareGuid (&gArmMpCoreInfoGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {
- UINTN i;
-
- // Get them under our control. Move from depending on 32bit reg(sys_flags) and SWI
- // to 64 bit addr and WFE
- ArmProcessorTable = (ARM_PROCESSOR_TABLE *)gST->ConfigurationTable[Index].VendorTable;
- ArmCoreInfoTable = ArmProcessorTable->ArmCpus;
-
- for (i = 0; i < ArmProcessorTable->NumberOfEntries; i++ ) {
- // This goes into the SYSFLAGS register for the VE platform. We only have one 32bit reg to use
- MmioWrite32(ArmCoreInfoTable[i].MailboxSetAddress, (UINTN)PenBase);
-
- // So FDT can set the mailboxes correctly with the parser. These are 64bit Memory locations.
- ArmCoreInfoTable[i].MailboxSetAddress = (UINTN)MailBoxBase + i*sizeof(MailBoxBase);
-
- // Clear the mailboxes for the respective cores
- *((UINTN*)(ArmCoreInfoTable[i].MailboxSetAddress)) = 0x0;
- }
- }
- }
- // Flush caches to make sure our pen gets to mem before we free the cores.
- ArmCleanDataCache();
- }
-
- // By setting address=0 we leave the memory allocation to the function
- Status = PrepareFdt (Arguments, InitrdImage, InitrdImageSize, &FdtBlobBase, &FdtBlobSize);
- if (EFI_ERROR(Status)) {
- Print(L"ERROR: Can not load Linux kernel with Device Tree. Status=0x%X\n", Status);
- goto EXIT_FREE_FDT;
- }
-
- return StartLinux (LinuxImage, LinuxImageSize, FdtBlobBase, FdtBlobSize);
-
-EXIT_FREE_FDT:
- if (!EFI_ERROR (PenBaseStatus)) {
- gBS->FreePages (PenBase, EFI_SIZE_TO_PAGES (PenSize));
- }
-
- gBS->FreePages (FdtBlobBase, EFI_SIZE_TO_PAGES (FdtBlobSize));
-
-EXIT_FREE_INITRD:
- if (InitrdDevicePath) {
- gBS->FreePages (InitrdImageBase, EFI_SIZE_TO_PAGES (InitrdImageBaseSize));
- }
-
-EXIT_FREE_LINUX:
- gBS->FreePages (LinuxImage, EFI_SIZE_TO_PAGES (LinuxImageSize));
-
- return Status;
-}
diff --git a/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoaderHelper.S b/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoaderHelper.S
deleted file mode 100644
index 525c128..0000000
--- a/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoaderHelper.S
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-//
-//
-
-
-/* Secondary core pens for AArch64 Linux booting.
-
- This code it placed in Linux kernel memory and marked reserved. UEFI ensures
- that the secondary cores get to this pen and the kernel can then start the
- cores from here.
- NOTE: This code must be self-contained.
-*/
-
-#include <Library/ArmLib.h>
-
-.text
-.align 3
-
-GCC_ASM_EXPORT(SecondariesPenStart)
-ASM_GLOBAL SecondariesPenEnd
-
-ASM_PFX(SecondariesPenStart):
- // Registers x0-x3 are reserved for future use and should be set to zero.
- mov x0, xzr
- mov x1, xzr
- mov x2, xzr
- mov x3, xzr
-
- // Get core position. Taken from ArmPlatformGetCorePosition().
- // Assumes max 4 cores per cluster.
- mrs x4, mpidr_el1 // Get MPCore register.
- and x5, x4, #ARM_CORE_MASK // Get core number.
- and x4, x4, #ARM_CLUSTER_MASK // Get cluster number.
- add x4, x5, x4, LSR #6 // Add scaled cluster number to core number.
- lsl x4, x4, 3 // Get mailbox offset for this core.
- ldr x5, AsmMailboxbase // Get mailbox addr relative to pc (36 bytes ahead).
- add x4, x4, x5 // Add core mailbox offset to base of mailbox.
-1: ldr x5, [x4] // Load value from mailbox.
- cmp xzr, x5 // Has the mailbox been set?
- b.ne 2f // If so break out of loop.
- wfe // If not, wait a bit.
- b 1b // Wait over, check if mailbox set again.
-2: br x5 // Jump to mailbox value.
-
-.align 3 // Make sure the variable below is 8 byte aligned.
- .global AsmMailboxbase
-AsmMailboxbase: .xword 0xdeaddeadbeefbeef
-
-SecondariesPenEnd:
diff --git a/ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c b/ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c
deleted file mode 100644
index 33c2798..0000000
--- a/ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include "BdsInternal.h"
-#include "BdsLinuxLoader.h"
-
-// Point to the current ATAG
-STATIC LINUX_ATAG *mLinuxKernelCurrentAtag;
-
-STATIC
-VOID
-SetupCoreTag (
- IN UINT32 PageSize
- )
-{
- mLinuxKernelCurrentAtag->header.size = tag_size(LINUX_ATAG_CORE);
- mLinuxKernelCurrentAtag->header.type = ATAG_CORE;
-
- mLinuxKernelCurrentAtag->body.core_tag.flags = 1; /* ensure read-only */
- mLinuxKernelCurrentAtag->body.core_tag.pagesize = PageSize; /* systems PageSize (4k) */
- mLinuxKernelCurrentAtag->body.core_tag.rootdev = 0; /* zero root device (typically overridden from kernel command line )*/
-
- // move pointer to next tag
- mLinuxKernelCurrentAtag = next_tag_address(mLinuxKernelCurrentAtag);
-}
-
-STATIC
-VOID
-SetupMemTag (
- IN UINTN StartAddress,
- IN UINT32 Size
- )
-{
- mLinuxKernelCurrentAtag->header.size = tag_size(LINUX_ATAG_MEM);
- mLinuxKernelCurrentAtag->header.type = ATAG_MEM;
-
- mLinuxKernelCurrentAtag->body.mem_tag.start = StartAddress; /* Start of memory chunk for AtagMem */
- mLinuxKernelCurrentAtag->body.mem_tag.size = Size; /* Size of memory chunk for AtagMem */
-
- // move pointer to next tag
- mLinuxKernelCurrentAtag = next_tag_address(mLinuxKernelCurrentAtag);
-}
-
-STATIC
-VOID
-SetupCmdlineTag (
- IN CONST CHAR8 *CmdLine
- )
-{
- UINT32 LineLength;
-
- // Increment the line length by 1 to account for the null string terminator character
- LineLength = AsciiStrLen(CmdLine) + 1;
-
- /* Check for NULL strings.
- * Do not insert a tag for an empty CommandLine, don't even modify the tag address pointer.
- * Remember, you have at least one null string terminator character.
- */
- if(LineLength > 1) {
- mLinuxKernelCurrentAtag->header.size = ((UINT32)sizeof(LINUX_ATAG_HEADER) + LineLength + (UINT32)3) >> 2;
- mLinuxKernelCurrentAtag->header.type = ATAG_CMDLINE;
-
- /* place CommandLine into tag */
- AsciiStrCpy(mLinuxKernelCurrentAtag->body.cmdline_tag.cmdline, CmdLine);
-
- // move pointer to next tag
- mLinuxKernelCurrentAtag = next_tag_address(mLinuxKernelCurrentAtag);
- }
-}
-
-STATIC
-VOID
-SetupInitrdTag (
- IN UINT32 InitrdImage,
- IN UINT32 InitrdImageSize
- )
-{
- mLinuxKernelCurrentAtag->header.size = tag_size(LINUX_ATAG_INITRD2);
- mLinuxKernelCurrentAtag->header.type = ATAG_INITRD2;
-
- mLinuxKernelCurrentAtag->body.initrd2_tag.start = InitrdImage;
- mLinuxKernelCurrentAtag->body.initrd2_tag.size = InitrdImageSize;
-
- // Move pointer to next tag
- mLinuxKernelCurrentAtag = next_tag_address(mLinuxKernelCurrentAtag);
-}
-STATIC
-VOID
-SetupEndTag (
- VOID
- )
-{
- // Empty tag ends list; this has zero length and no body
- mLinuxKernelCurrentAtag->header.type = ATAG_NONE;
- mLinuxKernelCurrentAtag->header.size = 0;
-
- /* We can not calculate the next address by using the standard macro:
- * Params = next_tag_address(Params);
- * because it relies on the header.size, which here it is 0 (zero).
- * The easiest way is to add the sizeof(mLinuxKernelCurrentAtag->header).
- */
- mLinuxKernelCurrentAtag = (LINUX_ATAG*)((UINT32)mLinuxKernelCurrentAtag + sizeof(mLinuxKernelCurrentAtag->header));
-}
-
-EFI_STATUS
-PrepareAtagList (
- IN CONST CHAR8* CommandLineString,
- IN EFI_PHYSICAL_ADDRESS InitrdImage,
- IN UINTN InitrdImageSize,
- OUT EFI_PHYSICAL_ADDRESS *AtagBase,
- OUT UINT32 *AtagSize
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *ResourceLink;
- LIST_ENTRY ResourceList;
- EFI_PHYSICAL_ADDRESS AtagStartAddress;
- BDS_SYSTEM_MEMORY_RESOURCE *Resource;
-
- AtagStartAddress = LINUX_ATAG_MAX_OFFSET;
- Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData, EFI_SIZE_TO_PAGES(ATAG_MAX_SIZE), &AtagStartAddress);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_WARN, "Warning: Failed to allocate Atag at 0x%lX (%r). The Atag will be allocated somewhere else in System Memory.\n", AtagStartAddress, Status));
- Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData, EFI_SIZE_TO_PAGES(ATAG_MAX_SIZE), &AtagStartAddress);
- ASSERT_EFI_ERROR(Status);
- }
-
- // Ready to setup the atag list
- mLinuxKernelCurrentAtag = (LINUX_ATAG*)(UINTN)AtagStartAddress;
-
- // Standard core tag 4k PageSize
- SetupCoreTag( (UINT32)SIZE_4KB );
-
- // Physical memory setup
- GetSystemMemoryResources (&ResourceList);
- ResourceLink = ResourceList.ForwardLink;
- while (ResourceLink != NULL && ResourceLink != &ResourceList) {
- Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)ResourceLink;
- DEBUG((EFI_D_INFO,"- [0x%08X,0x%08X]\n",(UINT32)Resource->PhysicalStart,(UINT32)Resource->PhysicalStart+(UINT32)Resource->ResourceLength));
- SetupMemTag( (UINT32)Resource->PhysicalStart, (UINT32)Resource->ResourceLength );
- ResourceLink = ResourceLink->ForwardLink;
- }
-
- // CommandLine setting root device
- if (CommandLineString) {
- SetupCmdlineTag (CommandLineString);
- }
-
- if (InitrdImageSize > 0 && InitrdImage != 0) {
- SetupInitrdTag ((UINT32)InitrdImage, (UINT32)InitrdImageSize);
- }
-
- // End of tags
- SetupEndTag();
-
- // Calculate atag list size
- *AtagBase = AtagStartAddress;
- *AtagSize = (UINT32)mLinuxKernelCurrentAtag - (UINT32)AtagStartAddress + 1;
-
- return EFI_SUCCESS;
-}
-
diff --git a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c b/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
deleted file mode 100644
index e5fda08..0000000
--- a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <Guid/Fdt.h>
-#include <libfdt.h>
-
-#include "BdsInternal.h"
-#include "BdsLinuxLoader.h"
-
-#define ALIGN32_BELOW(addr) ALIGN_POINTER(addr - 32,32)
-
-#define IS_ADDRESS_IN_REGION(RegionStart, RegionSize, Address) \
- (((UINTN)(RegionStart) <= (UINTN)(Address)) && ((UINTN)(Address) <= ((UINTN)(RegionStart) + (UINTN)(RegionSize))))
-
-STATIC
-EFI_STATUS
-PreparePlatformHardware (
- VOID
- )
-{
- //Note: Interrupts will be disabled by the GIC driver when ExitBootServices() will be called.
-
- // Clean before Disable else the Stack gets corrupted with old data.
- ArmCleanDataCache ();
- ArmDisableDataCache ();
- // Invalidate all the entries that might have snuck in.
- ArmInvalidateDataCache ();
-
- // Invalidate and disable the Instruction cache
- ArmDisableInstructionCache ();
- ArmInvalidateInstructionCache ();
-
- // Turn off MMU
- ArmDisableMmu();
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-StartLinux (
- IN EFI_PHYSICAL_ADDRESS LinuxImage,
- IN UINTN LinuxImageSize,
- IN EFI_PHYSICAL_ADDRESS KernelParamsAddress,
- IN UINTN KernelParamsSize,
- IN UINT32 MachineType
- )
-{
- EFI_STATUS Status;
- LINUX_KERNEL LinuxKernel;
-
- // Shut down UEFI boot services. ExitBootServices() will notify every driver that created an event on
- // ExitBootServices event. Example the Interrupt DXE driver will disable the interrupts on this event.
- Status = ShutdownUefiBootServices ();
- if(EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR,"ERROR: Can not shutdown UEFI boot services. Status=0x%X\n", Status));
- goto Exit;
- }
-
- // Move the kernel parameters to any address inside the first 1MB.
- // This is necessary because the ARM Linux kernel requires
- // the FTD / ATAG List to reside entirely inside the first 1MB of
- // physical memory.
- //Note: There is no requirement on the alignment
- if (MachineType != ARM_FDT_MACHINE_TYPE) {
- if (((UINTN)KernelParamsAddress > LINUX_ATAG_MAX_OFFSET) && (KernelParamsSize < PcdGet32(PcdArmLinuxAtagMaxOffset))) {
- KernelParamsAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CopyMem (ALIGN32_BELOW(LINUX_ATAG_MAX_OFFSET - KernelParamsSize), (VOID*)(UINTN)KernelParamsAddress, KernelParamsSize);
- }
- } else {
- if (((UINTN)KernelParamsAddress > LINUX_FDT_MAX_OFFSET) && (KernelParamsSize < PcdGet32(PcdArmLinuxFdtMaxOffset))) {
- KernelParamsAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CopyMem (ALIGN32_BELOW(LINUX_FDT_MAX_OFFSET - KernelParamsSize), (VOID*)(UINTN)KernelParamsAddress, KernelParamsSize);
- }
- }
-
- if ((UINTN)LinuxImage > LINUX_KERNEL_MAX_OFFSET) {
- //Note: There is no requirement on the alignment
- LinuxKernel = (LINUX_KERNEL)CopyMem (ALIGN32_BELOW(LINUX_KERNEL_MAX_OFFSET - LinuxImageSize), (VOID*)(UINTN)LinuxImage, LinuxImageSize);
- } else {
- LinuxKernel = (LINUX_KERNEL)(UINTN)LinuxImage;
- }
-
- // Check if the Linux Image is a uImage
- if (*(UINT32*)LinuxKernel == LINUX_UIMAGE_SIGNATURE) {
- // Assume the Image Entry Point is just after the uImage header (64-byte size)
- LinuxKernel = (LINUX_KERNEL)((UINTN)LinuxKernel + 64);
- LinuxImageSize -= 64;
- }
-
- // Check there is no overlapping between kernel and its parameters
- // We can only assert because it is too late to fallback to UEFI (ExitBootServices has been called).
- ASSERT (!IS_ADDRESS_IN_REGION(LinuxKernel, LinuxImageSize, KernelParamsAddress) &&
- !IS_ADDRESS_IN_REGION(LinuxKernel, LinuxImageSize, KernelParamsAddress + KernelParamsSize));
-
- //
- // Switch off interrupts, caches, mmu, etc
- //
- Status = PreparePlatformHardware ();
- ASSERT_EFI_ERROR(Status);
-
- // Register and print out performance information
- PERF_END (NULL, "BDS", NULL, 0);
- if (PerformanceMeasurementEnabled ()) {
- PrintPerformance ();
- }
-
- //
- // Start the Linux Kernel
- //
-
- // Outside BootServices, so can't use Print();
- DEBUG((EFI_D_ERROR, "\nStarting the kernel:\n\n"));
-
- // Jump to kernel with register set
- LinuxKernel ((UINTN)0, MachineType, (UINTN)KernelParamsAddress);
-
- // Kernel should never exit
- // After Life services are not provided
- ASSERT(FALSE);
-
-Exit:
- // Only be here if we fail to start Linux
- Print (L"ERROR : Can not start the kernel. Status=0x%X\n", Status);
-
- // Free Runtimee Memory (kernel and FDT)
- return Status;
-}
-
-/**
- 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
-
- @retval EFI_SUCCESS All drivers have been connected
- @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsBootLinuxAtag (
- IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* CommandLineArguments
- )
-{
- EFI_STATUS Status;
- UINT32 LinuxImageSize;
- UINT32 InitrdImageBaseSize = 0;
- UINT32 InitrdImageSize = 0;
- UINT32 AtagSize;
- EFI_PHYSICAL_ADDRESS AtagBase;
- EFI_PHYSICAL_ADDRESS LinuxImage;
- EFI_PHYSICAL_ADDRESS InitrdImageBase = 0;
- EFI_PHYSICAL_ADDRESS InitrdImage = 0;
-
- PERF_START (NULL, "BDS", NULL, 0);
-
- // Load the Linux kernel from a device path
- LinuxImage = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (LinuxKernelDevicePath, AllocateMaxAddress, &LinuxImage, &LinuxImageSize);
- if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find Linux kernel.\n");
- return Status;
- }
-
- if (InitrdDevicePath) {
- // Load the initrd near to the Linux kernel
- InitrdImageBase = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (InitrdDevicePath, AllocateMaxAddress, &InitrdImageBase, &InitrdImageBaseSize);
- if (Status == EFI_OUT_OF_RESOURCES) {
- Status = BdsLoadImage (InitrdDevicePath, AllocateAnyPages, &InitrdImageBase, &InitrdImageBaseSize);
- }
- if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find initrd image.\n");
- goto EXIT_FREE_LINUX;
- }
-
- // Check if the initrd is a uInitrd
- if (*(UINT32*)((UINTN)InitrdImageBase) == LINUX_UIMAGE_SIGNATURE) {
- // Skip the 64-byte image header
- InitrdImage = (EFI_PHYSICAL_ADDRESS)((UINTN)InitrdImageBase + 64);
- InitrdImageSize = InitrdImageBaseSize - 64;
- } else {
- InitrdImage = InitrdImageBase;
- InitrdImageSize = InitrdImageBaseSize;
- }
- }
-
- //
- // Setup the Linux Kernel Parameters
- //
-
- // By setting address=0 we leave the memory allocation to the function
- Status = PrepareAtagList (CommandLineArguments, InitrdImage, InitrdImageSize, &AtagBase, &AtagSize);
- if (EFI_ERROR(Status)) {
- Print(L"ERROR: Can not prepare ATAG list. Status=0x%X\n", Status);
- goto EXIT_FREE_INITRD;
- }
-
- return StartLinux (LinuxImage, LinuxImageSize, AtagBase, AtagSize, PcdGet32(PcdArmMachineType));
-
-EXIT_FREE_INITRD:
- if (InitrdDevicePath) {
- gBS->FreePages (InitrdImageBase, EFI_SIZE_TO_PAGES (InitrdImageBaseSize));
- }
-
-EXIT_FREE_LINUX:
- gBS->FreePages (LinuxImage, EFI_SIZE_TO_PAGES (LinuxImageSize));
-
- return Status;
-}
-
-/**
- Start a Linux kernel from a Device Path
-
- @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
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsBootLinuxFdt (
- IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* CommandLineArguments
- )
-{
- 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);
-
- // Load the Linux kernel from a device path
- LinuxImage = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (LinuxKernelDevicePath, AllocateMaxAddress, &LinuxImage, &LinuxImageSize);
- if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find Linux kernel.\n");
- return Status;
- }
-
- if (InitrdDevicePath) {
- InitrdImageBase = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (InitrdDevicePath, AllocateMaxAddress, &InitrdImageBase, &InitrdImageBaseSize);
- if (Status == EFI_OUT_OF_RESOURCES) {
- Status = BdsLoadImage (InitrdDevicePath, AllocateAnyPages, &InitrdImageBase, &InitrdImageBaseSize);
- }
- if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find initrd image.\n");
- goto EXIT_FREE_LINUX;
- }
-
- // Check if the initrd is a uInitrd
- if (*(UINT32*)((UINTN)InitrdImageBase) == LINUX_UIMAGE_SIGNATURE) {
- // Skip the 64-byte image header
- InitrdImage = (EFI_PHYSICAL_ADDRESS)((UINTN)InitrdImageBase + 64);
- InitrdImageSize = InitrdImageBaseSize - 64;
- } else {
- InitrdImage = InitrdImageBase;
- InitrdImageSize = InitrdImageBaseSize;
- }
- }
-
- //
- // 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
- Status = PrepareFdt (CommandLineArguments, InitrdImage, InitrdImageSize, &FdtBlobBase, &FdtBlobSize);
- if (EFI_ERROR(Status)) {
- Print(L"ERROR: Can not load kernel with FDT. Status=%r\n", Status);
- goto EXIT_FREE_FDT;
- }
-
- return StartLinux (LinuxImage, LinuxImageSize, FdtBlobBase, FdtBlobSize, ARM_FDT_MACHINE_TYPE);
-
-EXIT_FREE_FDT:
- gBS->FreePages (FdtBlobBase, EFI_SIZE_TO_PAGES (FdtBlobSize));
-
-EXIT_FREE_INITRD:
- if (InitrdDevicePath) {
- gBS->FreePages (InitrdImageBase, EFI_SIZE_TO_PAGES (InitrdImageBaseSize));
- }
-
-EXIT_FREE_LINUX:
- gBS->FreePages (LinuxImage, EFI_SIZE_TO_PAGES (LinuxImageSize));
-
- return Status;
-}
-
diff --git a/ArmPkg/Library/BdsLib/BdsHelper.c b/ArmPkg/Library/BdsLib/BdsHelper.c
index 7f83c2b..b10fe20 100644
--- a/ArmPkg/Library/BdsLib/BdsHelper.c
+++ b/ArmPkg/Library/BdsLib/BdsHelper.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -14,19 +14,6 @@

#include "BdsInternal.h"

-#include <Library/HobLib.h>
-#include <Library/TimerLib.h>
-#include <Library/PrintLib.h>
-#include <Library/SerialPortLib.h>
-
-STATIC CHAR8 *mTokenList[] = {
- /*"SEC",*/
- "PEI",
- "DXE",
- "BDS",
- NULL
-};
-
EFI_STATUS
ShutdownUefiBootServices (
VOID
@@ -129,169 +116,6 @@ BdsConnectAllDrivers (
return EFI_SUCCESS;
}

-STATIC
-EFI_STATUS
-InsertSystemMemoryResources (
- LIST_ENTRY *ResourceList,
- EFI_HOB_RESOURCE_DESCRIPTOR *ResHob
- )
-{
- BDS_SYSTEM_MEMORY_RESOURCE *NewResource;
- LIST_ENTRY *Link;
- LIST_ENTRY *NextLink;
- LIST_ENTRY AttachedResources;
- BDS_SYSTEM_MEMORY_RESOURCE *Resource;
- EFI_PHYSICAL_ADDRESS NewResourceEnd;
-
- if (IsListEmpty (ResourceList)) {
- NewResource = AllocateZeroPool (sizeof(BDS_SYSTEM_MEMORY_RESOURCE));
- NewResource->PhysicalStart = ResHob->PhysicalStart;
- NewResource->ResourceLength = ResHob->ResourceLength;
- InsertTailList (ResourceList, &NewResource->Link);
- return EFI_SUCCESS;
- }
-
- InitializeListHead (&AttachedResources);
-
- Link = ResourceList->ForwardLink;
- ASSERT (Link != NULL);
- while (Link != ResourceList) {
- Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)Link;
-
- // Sanity Check. The resources should not overlapped.
- ASSERT(!((ResHob->PhysicalStart >= Resource->PhysicalStart) && (ResHob->PhysicalStart < (Resource->PhysicalStart + Resource->ResourceLength))));
- ASSERT(!((ResHob->PhysicalStart + ResHob->ResourceLength - 1 >= Resource->PhysicalStart) &&
- ((ResHob->PhysicalStart + ResHob->ResourceLength - 1) < (Resource->PhysicalStart + Resource->ResourceLength))));
-
- // The new resource is attached after this resource descriptor
- if (ResHob->PhysicalStart == Resource->PhysicalStart + Resource->ResourceLength) {
- Resource->ResourceLength = Resource->ResourceLength + ResHob->ResourceLength;
-
- NextLink = RemoveEntryList (&Resource->Link);
- InsertTailList (&AttachedResources, &Resource->Link);
- Link = NextLink;
- }
- // The new resource is attached before this resource descriptor
- else if (ResHob->PhysicalStart + ResHob->ResourceLength == Resource->PhysicalStart) {
- Resource->PhysicalStart = ResHob->PhysicalStart;
- Resource->ResourceLength = Resource->ResourceLength + ResHob->ResourceLength;
-
- NextLink = RemoveEntryList (&Resource->Link);
- InsertTailList (&AttachedResources, &Resource->Link);
- Link = NextLink;
- } else {
- Link = Link->ForwardLink;
- }
- }
-
- if (!IsListEmpty (&AttachedResources)) {
- // See if we can merge the attached resource with other resources
-
- NewResource = (BDS_SYSTEM_MEMORY_RESOURCE*)GetFirstNode (&AttachedResources);
- Link = RemoveEntryList (&NewResource->Link);
- while (!IsListEmpty (&AttachedResources)) {
- // Merge resources
- Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)Link;
-
- // Ensure they overlap each other
- ASSERT(
- ((NewResource->PhysicalStart >= Resource->PhysicalStart) && (NewResource->PhysicalStart < (Resource->PhysicalStart + Resource->ResourceLength))) ||
- (((NewResource->PhysicalStart + NewResource->ResourceLength) >= Resource->PhysicalStart) && ((NewResource->PhysicalStart + NewResource->ResourceLength) < (Resource->PhysicalStart + Resource->ResourceLength)))
- );
-
- NewResourceEnd = MAX (NewResource->PhysicalStart + NewResource->ResourceLength, Resource->PhysicalStart + Resource->ResourceLength);
- NewResource->PhysicalStart = MIN (NewResource->PhysicalStart, Resource->PhysicalStart);
- NewResource->ResourceLength = NewResourceEnd - NewResource->PhysicalStart;
-
- Link = RemoveEntryList (Link);
- }
- } else {
- // None of the Resource of the list is attached to this ResHob. Create a new entry for it
- NewResource = AllocateZeroPool (sizeof(BDS_SYSTEM_MEMORY_RESOURCE));
- NewResource->PhysicalStart = ResHob->PhysicalStart;
- NewResource->ResourceLength = ResHob->ResourceLength;
- }
- InsertTailList (ResourceList, &NewResource->Link);
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-GetSystemMemoryResources (
- IN LIST_ENTRY *ResourceList
- )
-{
- EFI_HOB_RESOURCE_DESCRIPTOR *ResHob;
-
- InitializeListHead (ResourceList);
-
- // Find the first System Memory Resource Descriptor
- ResHob = (EFI_HOB_RESOURCE_DESCRIPTOR *)GetFirstHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR);
- while ((ResHob != NULL) && (ResHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY)) {
- ResHob = (EFI_HOB_RESOURCE_DESCRIPTOR *)GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,(VOID *)((UINTN)ResHob + ResHob->Header.HobLength));
- }
-
- // Did not find any
- if (ResHob == NULL) {
- return EFI_NOT_FOUND;
- } else {
- InsertSystemMemoryResources (ResourceList, ResHob);
- }
-
- ResHob = (EFI_HOB_RESOURCE_DESCRIPTOR *)GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,(VOID *)((UINTN)ResHob + ResHob->Header.HobLength));
- while (ResHob != NULL) {
- if (ResHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {
- InsertSystemMemoryResources (ResourceList, ResHob);
- }
- ResHob = (EFI_HOB_RESOURCE_DESCRIPTOR *)GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,(VOID *)((UINTN)ResHob + ResHob->Header.HobLength));
- }
-
- return EFI_SUCCESS;
-}
-
-VOID
-PrintPerformance (
- VOID
- )
-{
- UINTN Key;
- CONST VOID *Handle;
- CONST CHAR8 *Token, *Module;
- UINT64 Start, Stop, TimeStamp;
- UINT64 Delta, TicksPerSecond, Milliseconds;
- UINTN Index;
- CHAR8 Buffer[100];
- UINTN CharCount;
- BOOLEAN CountUp;
-
- TicksPerSecond = GetPerformanceCounterProperties (&Start, &Stop);
- if (Start < Stop) {
- CountUp = TRUE;
- } else {
- CountUp = FALSE;
- }
-
- TimeStamp = 0;
- Key = 0;
- do {
- Key = GetPerformanceMeasurement (Key, (CONST VOID **)&Handle, &Token, &Module, &Start, &Stop);
- if (Key != 0) {
- for (Index = 0; mTokenList[Index] != NULL; Index++) {
- if (AsciiStriCmp (mTokenList[Index], Token) == 0) {
- Delta = CountUp?(Stop - Start):(Start - Stop);
- TimeStamp += Delta;
- Milliseconds = DivU64x64Remainder (MultU64x32 (Delta, 1000), TicksPerSecond, NULL);
- CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"%6a %6ld ms\n", Token, Milliseconds);
- SerialPortWrite ((UINT8 *) Buffer, CharCount);
- break;
- }
- }
- }
- } while (Key != 0);
-
- CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Total Time = %ld ms\n\n", DivU64x64Remainder (MultU64x32 (TimeStamp, 1000), TicksPerSecond, NULL));
- SerialPortWrite ((UINT8 *) Buffer, CharCount);
-}
-
EFI_STATUS
GetGlobalEnvironmentVariable (
IN CONST CHAR16* VariableName,
diff --git a/ArmPkg/Library/BdsLib/BdsInternal.h b/ArmPkg/Library/BdsLib/BdsInternal.h
index 1fab2ae..f70aae6 100644
--- a/ArmPkg/Library/BdsLib/BdsInternal.h
+++ b/ArmPkg/Library/BdsLib/BdsInternal.h
@@ -28,11 +28,9 @@
#include <Library/DebugLib.h>
#include <Library/BdsLib.h>
#include <Library/PcdLib.h>
-#include <Library/PerformanceLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>

-#include <Guid/ArmMpCoreInfo.h>
#include <Guid/GlobalVariable.h>
#include <Guid/FileInfo.h>

@@ -102,17 +100,6 @@ typedef struct {
UINT64 LastReportedNbOfBytes;
} BDS_TFTP_CONTEXT;

-// BdsHelper.c
-EFI_STATUS
-GetSystemMemoryResources (
- LIST_ENTRY *ResourceList
- );
-
-VOID
-PrintPerformance (
- VOID
- );
-
EFI_STATUS
BdsLoadImage (
IN EFI_DEVICE_PATH *DevicePath,
diff --git a/ArmPkg/Library/BdsLib/BdsLib.inf b/ArmPkg/Library/BdsLib/BdsLib.inf
index ecf6de5..eb4543e 100644
--- a/ArmPkg/Library/BdsLib/BdsLib.inf
+++ b/ArmPkg/Library/BdsLib/BdsLib.inf
@@ -25,15 +25,6 @@
BdsAppLoader.c
BdsHelper.c
BdsLoadOption.c
- BdsLinuxFdt.c
-
-[Sources.ARM]
- Arm/BdsLinuxLoader.c
- Arm/BdsLinuxAtag.c
-
-[Sources.AARCH64]
- AArch64/BdsLinuxLoader.c
- AArch64/BdsLinuxLoaderHelper.S

[Packages]
EmbeddedPkg/EmbeddedPkg.dec
@@ -44,26 +35,16 @@

[LibraryClasses]
ArmLib
- ArmSmcLib
BaseLib
DebugLib
DevicePathLib
HobLib
PcdLib
- PerformanceLib
- SerialPortLib
- FdtLib
- TimerLib
NetLib

-[LibraryClasses.AARCH64]
- ArmGicLib
-
[Guids]
gEfiFileInfoGuid
- gArmMpCoreInfoGuid
gArmGlobalVariableGuid
- gFdtTableGuid

[Protocols]
gEfiBdsArchProtocolGuid
@@ -82,27 +63,8 @@
gEfiMtftp4ServiceBindingProtocolGuid
gEfiMtftp4ProtocolGuid

-[FeaturePcd]
- gArmTokenSpaceGuid.PcdArmLinuxSpinTable
-
-[Pcd]
- gArmTokenSpaceGuid.PcdSystemMemoryBase
- gArmTokenSpaceGuid.PcdSystemMemorySize
-
[FixedPcd]
- gArmTokenSpaceGuid.PcdArmMachineType
- gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset
- gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment
- gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset
-
gArmTokenSpaceGuid.PcdMaxTftpFileSize

-[FixedPcd.ARM]
- gArmTokenSpaceGuid.PcdArmLinuxAtagMaxOffset
-
-[Pcd.AARCH64]
- gArmTokenSpaceGuid.PcdGicDistributorBase
- gArmTokenSpaceGuid.PcdGicSgiIntId
-
[Depex]
TRUE
diff --git a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
deleted file mode 100644
index e379552..0000000
--- a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
+++ /dev/null
@@ -1,572 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <Library/ArmSmcLib.h>
-#include <Library/PcdLib.h>
-#include <libfdt.h>
-
-#include "BdsInternal.h"
-#include "BdsLinuxLoader.h"
-
-#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
-#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a))))
-#define GET_CELL(p) (p += 4, *((const UINT32 *)(p-4)))
-
-STATIC
-UINTN
-cpu_to_fdtn (UINTN x) {
- if (sizeof (UINTN) == sizeof (UINT32)) {
- return cpu_to_fdt32 (x);
- } else {
- return cpu_to_fdt64 (x);
- }
-}
-
-typedef struct {
- UINTN Base;
- UINTN Size;
-} FdtRegion;
-
-
-STATIC
-UINTN
-IsPrintableString (
- IN CONST VOID* data,
- IN UINTN len
- )
-{
- CONST CHAR8 *s = data;
- CONST CHAR8 *ss;
-
- // Zero length is not
- if (len == 0) {
- return 0;
- }
-
- // Must terminate with zero
- if (s[len - 1] != '\0') {
- return 0;
- }
-
- ss = s;
- while (*s/* && isprint(*s)*/) {
- s++;
- }
-
- // Not zero, or not done yet
- if (*s != '\0' || (s + 1 - ss) < len) {
- return 0;
- }
-
- return 1;
-}
-
-STATIC
-VOID
-PrintData (
- IN CONST CHAR8* data,
- IN UINTN len
- )
-{
- UINTN i;
- CONST CHAR8 *p = data;
-
- // No data, don't print
- if (len == 0)
- return;
-
- if (IsPrintableString (data, len)) {
- Print(L" = \"%a\"", (const char *)data);
- } else if ((len % 4) == 0) {
- Print(L" = <");
- for (i = 0; i < len; i += 4) {
- Print(L"0x%08x%a", fdt32_to_cpu(GET_CELL(p)),i < (len - 4) ? " " : "");
- }
- Print(L">");
- } else {
- Print(L" = [");
- for (i = 0; i < len; i++)
- Print(L"%02x%a", *p++, i < len - 1 ? " " : "");
- Print(L"]");
- }
-}
-
-VOID
-DebugDumpFdt (
- IN VOID* FdtBlob
- )
-{
- struct fdt_header *bph;
- UINT32 off_dt;
- UINT32 off_str;
- CONST CHAR8* p_struct;
- CONST CHAR8* p_strings;
- CONST CHAR8* p;
- CONST CHAR8* s;
- CONST CHAR8* t;
- UINT32 tag;
- UINTN sz;
- UINTN depth;
- UINTN shift;
- UINT32 version;
-
- {
- // Can 'memreserve' be printed by below code?
- INTN num = fdt_num_mem_rsv(FdtBlob);
- INTN i, err;
- UINT64 addr = 0,size = 0;
-
- for (i = 0; i < num; i++) {
- err = fdt_get_mem_rsv(FdtBlob, i, &addr, &size);
- if (err) {
- DEBUG((EFI_D_ERROR, "Error (%d) : Cannot get memreserve section (%d)\n", err, i));
- }
- else {
- Print(L"/memreserve/ \t0x%lx \t0x%lx;\n",addr,size);
- }
- }
- }
-
- depth = 0;
- shift = 4;
-
- bph = FdtBlob;
- off_dt = fdt32_to_cpu(bph->off_dt_struct);
- off_str = fdt32_to_cpu(bph->off_dt_strings);
- p_struct = (CONST CHAR8*)FdtBlob + off_dt;
- p_strings = (CONST CHAR8*)FdtBlob + off_str;
- version = fdt32_to_cpu(bph->version);
-
- p = p_struct;
- while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) {
- if (tag == FDT_BEGIN_NODE) {
- s = p;
- p = PALIGN(p + AsciiStrLen (s) + 1, 4);
-
- if (*s == '\0')
- s = "/";
-
- Print(L"%*s%a {\n", depth * shift, L" ", s);
-
- depth++;
- continue;
- }
-
- if (tag == FDT_END_NODE) {
- depth--;
-
- Print(L"%*s};\n", depth * shift, L" ");
- continue;
- }
-
- if (tag == FDT_NOP) {
- Print(L"%*s// [NOP]\n", depth * shift, L" ");
- continue;
- }
-
- if (tag != FDT_PROP) {
- Print(L"%*s ** Unknown tag 0x%08x\n", depth * shift, L" ", tag);
- break;
- }
- sz = fdt32_to_cpu(GET_CELL(p));
- s = p_strings + fdt32_to_cpu(GET_CELL(p));
- if (version < 16 && sz >= 8)
- p = PALIGN(p, 8);
- t = p;
-
- p = PALIGN(p + sz, 4);
-
- Print(L"%*s%a", depth * shift, L" ", s);
- PrintData(t, sz);
- Print(L";\n");
- }
-}
-
-STATIC
-BOOLEAN
-IsLinuxReservedRegion (
- IN EFI_MEMORY_TYPE MemoryType
- )
-{
- switch(MemoryType) {
- case EfiRuntimeServicesCode:
- case EfiRuntimeServicesData:
- case EfiUnusableMemory:
- case EfiACPIReclaimMemory:
- case EfiACPIMemoryNVS:
- case EfiReservedMemoryType:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-/**
-** Relocate the FDT blob to a more appropriate location for the Linux kernel.
-** This function will allocate memory for the relocated FDT blob.
-**
-** @retval EFI_SUCCESS on success.
-** @retval EFI_OUT_OF_RESOURCES or EFI_INVALID_PARAMETER on failure.
-*/
-STATIC
-EFI_STATUS
-RelocateFdt (
- EFI_PHYSICAL_ADDRESS OriginalFdt,
- UINTN OriginalFdtSize,
- EFI_PHYSICAL_ADDRESS *RelocatedFdt,
- UINTN *RelocatedFdtSize,
- EFI_PHYSICAL_ADDRESS *RelocatedFdtAlloc
- )
-{
- EFI_STATUS Status;
- INTN Error;
- UINT64 FdtAlignment;
-
- *RelocatedFdtSize = OriginalFdtSize + FDT_ADDITIONAL_ENTRIES_SIZE;
-
- // If FDT load address needs to be aligned, allocate more space.
- FdtAlignment = PcdGet32 (PcdArmLinuxFdtAlignment);
- if (FdtAlignment != 0) {
- *RelocatedFdtSize += FdtAlignment;
- }
-
- // Try below a watermark address.
- Status = EFI_NOT_FOUND;
- if (PcdGet32 (PcdArmLinuxFdtMaxOffset) != 0) {
- *RelocatedFdt = LINUX_FDT_MAX_OFFSET;
- Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData,
- EFI_SIZE_TO_PAGES (*RelocatedFdtSize), RelocatedFdt);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_WARN, "Warning: Failed to load FDT below address 0x%lX (%r). Will try again at a random address anywhere.\n", *RelocatedFdt, Status));
- }
- }
-
- // Try anywhere there is available space.
- if (EFI_ERROR (Status)) {
- Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData,
- EFI_SIZE_TO_PAGES (*RelocatedFdtSize), RelocatedFdt);
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- return EFI_OUT_OF_RESOURCES;
- } else {
- DEBUG ((EFI_D_WARN, "WARNING: Loaded FDT at random address 0x%lX.\nWARNING: There is a risk of accidental overwriting by other code/data.\n", *RelocatedFdt));
- }
- }
-
- *RelocatedFdtAlloc = *RelocatedFdt;
- if (FdtAlignment != 0) {
- *RelocatedFdt = ALIGN (*RelocatedFdt, FdtAlignment);
- }
-
- // Load the Original FDT tree into the new region
- Error = fdt_open_into ((VOID*)(UINTN) OriginalFdt,
- (VOID*)(UINTN)(*RelocatedFdt), *RelocatedFdtSize);
- if (Error) {
- DEBUG ((EFI_D_ERROR, "fdt_open_into(): %a\n", fdt_strerror (Error)));
- gBS->FreePages (*RelocatedFdtAlloc, EFI_SIZE_TO_PAGES (*RelocatedFdtSize));
- return EFI_INVALID_PARAMETER;
- }
-
- DEBUG_CODE_BEGIN();
- //DebugDumpFdt (fdt);
- DEBUG_CODE_END();
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-PrepareFdt (
- IN CONST CHAR8* CommandLineArguments,
- IN EFI_PHYSICAL_ADDRESS InitrdImage,
- IN UINTN InitrdImageSize,
- IN OUT EFI_PHYSICAL_ADDRESS *FdtBlobBase,
- IN OUT UINTN *FdtBlobSize
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS NewFdtBlobBase;
- EFI_PHYSICAL_ADDRESS NewFdtBlobAllocation;
- UINTN NewFdtBlobSize;
- VOID* fdt;
- INTN err;
- INTN node;
- INTN cpu_node;
- INT32 lenp;
- CONST VOID* BootArg;
- CONST VOID* Method;
- EFI_PHYSICAL_ADDRESS InitrdImageStart;
- EFI_PHYSICAL_ADDRESS InitrdImageEnd;
- FdtRegion Region;
- UINTN Index;
- CHAR8 Name[10];
- LIST_ENTRY ResourceList;
- BDS_SYSTEM_MEMORY_RESOURCE *Resource;
- ARM_PROCESSOR_TABLE *ArmProcessorTable;
- ARM_CORE_INFO *ArmCoreInfoTable;
- UINT32 MpId;
- UINT32 ClusterId;
- UINT32 CoreId;
- UINT64 CpuReleaseAddr;
- UINTN MemoryMapSize;
- EFI_MEMORY_DESCRIPTOR *MemoryMap;
- EFI_MEMORY_DESCRIPTOR *MemoryMapPtr;
- UINTN MapKey;
- UINTN DescriptorSize;
- UINT32 DescriptorVersion;
- UINTN Pages;
- UINTN OriginalFdtSize;
- BOOLEAN CpusNodeExist;
- UINTN CoreMpId;
-
- NewFdtBlobAllocation = 0;
-
- //
- // Sanity checks on the original FDT blob.
- //
- err = fdt_check_header ((VOID*)(UINTN)(*FdtBlobBase));
- if (err != 0) {
- Print (L"ERROR: Device Tree header not valid (err:%d)\n", err);
- return EFI_INVALID_PARAMETER;
- }
-
- // The original FDT blob might have been loaded partially.
- // Check that it is not the case.
- OriginalFdtSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(*FdtBlobBase));
- if (OriginalFdtSize > *FdtBlobSize) {
- Print (L"ERROR: Incomplete FDT. Only %d/%d bytes have been loaded.\n",
- *FdtBlobSize, OriginalFdtSize);
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Relocate the FDT to its final location.
- //
- Status = RelocateFdt (*FdtBlobBase, OriginalFdtSize,
- &NewFdtBlobBase, &NewFdtBlobSize, &NewFdtBlobAllocation);
- if (EFI_ERROR (Status)) {
- goto FAIL_RELOCATE_FDT;
- }
-
- fdt = (VOID*)(UINTN)NewFdtBlobBase;
-
- node = fdt_subnode_offset (fdt, 0, "chosen");
- if (node < 0) {
- // The 'chosen' node does not exist, create it
- node = fdt_add_subnode(fdt, 0, "chosen");
- if (node < 0) {
- DEBUG((EFI_D_ERROR,"Error on finding 'chosen' node\n"));
- Status = EFI_INVALID_PARAMETER;
- goto FAIL_COMPLETE_FDT;
- }
- }
-
- DEBUG_CODE_BEGIN();
- BootArg = fdt_getprop(fdt, node, "bootargs", &lenp);
- if (BootArg != NULL) {
- DEBUG((EFI_D_ERROR,"BootArg: %a\n",BootArg));
- }
- DEBUG_CODE_END();
-
- //
- // Set Linux CmdLine
- //
- if ((CommandLineArguments != NULL) && (AsciiStrLen (CommandLineArguments) > 0)) {
- err = fdt_setprop(fdt, node, "bootargs", CommandLineArguments, AsciiStrSize(CommandLineArguments));
- if (err) {
- DEBUG((EFI_D_ERROR,"Fail to set new 'bootarg' (err:%d)\n",err));
- }
- }
-
- //
- // Set Linux Initrd
- //
- if (InitrdImageSize != 0) {
- InitrdImageStart = cpu_to_fdt64 (InitrdImage);
- err = fdt_setprop(fdt, node, "linux,initrd-start", &InitrdImageStart, sizeof(EFI_PHYSICAL_ADDRESS));
- if (err) {
- DEBUG((EFI_D_ERROR,"Fail to set new 'linux,initrd-start' (err:%d)\n",err));
- }
- InitrdImageEnd = cpu_to_fdt64 (InitrdImage + InitrdImageSize);
- err = fdt_setprop(fdt, node, "linux,initrd-end", &InitrdImageEnd, sizeof(EFI_PHYSICAL_ADDRESS));
- if (err) {
- DEBUG((EFI_D_ERROR,"Fail to set new 'linux,initrd-start' (err:%d)\n",err));
- }
- }
-
- //
- // Set Physical memory setup if does not exist
- //
- node = fdt_subnode_offset(fdt, 0, "memory");
- if (node < 0) {
- // The 'memory' node does not exist, create it
- node = fdt_add_subnode(fdt, 0, "memory");
- if (node >= 0) {
- fdt_setprop_string(fdt, node, "name", "memory");
- fdt_setprop_string(fdt, node, "device_type", "memory");
-
- GetSystemMemoryResources (&ResourceList);
- Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)ResourceList.ForwardLink;
-
- Region.Base = cpu_to_fdtn ((UINTN)Resource->PhysicalStart);
- Region.Size = cpu_to_fdtn ((UINTN)Resource->ResourceLength);
-
- err = fdt_setprop(fdt, node, "reg", &Region, sizeof(Region));
- if (err) {
- DEBUG((EFI_D_ERROR,"Fail to set new 'memory region' (err:%d)\n",err));
- }
- }
- }
-
- //
- // Add the memory regions reserved by the UEFI Firmware
- //
-
- // Retrieve the UEFI Memory Map
- MemoryMap = NULL;
- MemoryMapSize = 0;
- Status = gBS->GetMemoryMap (&MemoryMapSize, MemoryMap, &MapKey, &DescriptorSize, &DescriptorVersion);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- // The UEFI specification advises to allocate more memory for the MemoryMap buffer between successive
- // calls to GetMemoryMap(), since allocation of the new buffer may potentially increase memory map size.
- Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1;
- MemoryMap = AllocatePages (Pages);
- if (MemoryMap == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto FAIL_COMPLETE_FDT;
- }
- Status = gBS->GetMemoryMap (&MemoryMapSize, MemoryMap, &MapKey, &DescriptorSize, &DescriptorVersion);
- }
-
- // Go through the list and add the reserved region to the Device Tree
- if (!EFI_ERROR(Status)) {
- MemoryMapPtr = MemoryMap;
- for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) {
- if (IsLinuxReservedRegion ((EFI_MEMORY_TYPE)MemoryMapPtr->Type)) {
- DEBUG((DEBUG_VERBOSE, "Reserved region of type %d [0x%lX, 0x%lX]\n",
- MemoryMapPtr->Type,
- (UINTN)MemoryMapPtr->PhysicalStart,
- (UINTN)(MemoryMapPtr->PhysicalStart + MemoryMapPtr->NumberOfPages * EFI_PAGE_SIZE)));
- err = fdt_add_mem_rsv(fdt, MemoryMapPtr->PhysicalStart, MemoryMapPtr->NumberOfPages * EFI_PAGE_SIZE);
- if (err != 0) {
- Print(L"Warning: Fail to add 'memreserve' (err:%d)\n", err);
- }
- }
- MemoryMapPtr = (EFI_MEMORY_DESCRIPTOR*)((UINTN)MemoryMapPtr + DescriptorSize);
- }
- }
-
- //
- // Setup Arm Mpcore Info if it is a multi-core or multi-cluster platforms.
- //
- // For 'cpus' and 'cpu' device tree nodes bindings, refer to this file
- // in the kernel documentation:
- // Documentation/devicetree/bindings/arm/cpus.txt
- //
- for (Index=0; Index < gST->NumberOfTableEntries; Index++) {
- // Check for correct GUID type
- if (CompareGuid (&gArmMpCoreInfoGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {
- MpId = ArmReadMpidr ();
- ClusterId = GET_CLUSTER_ID(MpId);
- CoreId = GET_CORE_ID(MpId);
-
- node = fdt_subnode_offset(fdt, 0, "cpus");
- if (node < 0) {
- // Create the /cpus node
- node = fdt_add_subnode(fdt, 0, "cpus");
- fdt_setprop_string(fdt, node, "name", "cpus");
- fdt_setprop_cell (fdt, node, "#address-cells", sizeof (UINTN) / 4);
- fdt_setprop_cell(fdt, node, "#size-cells", 0);
- CpusNodeExist = FALSE;
- } else {
- CpusNodeExist = TRUE;
- }
-
- // Get pointer to ARM processor table
- ArmProcessorTable = (ARM_PROCESSOR_TABLE *)gST->ConfigurationTable[Index].VendorTable;
- ArmCoreInfoTable = ArmProcessorTable->ArmCpus;
-
- for (Index = 0; Index < ArmProcessorTable->NumberOfEntries; Index++) {
- CoreMpId = (UINTN) GET_MPID (ArmCoreInfoTable[Index].ClusterId,
- ArmCoreInfoTable[Index].CoreId);
- AsciiSPrint (Name, 10, "cpu@%x", CoreMpId);
-
- // If the 'cpus' node did not exist then create all the 'cpu' nodes.
- // In case 'cpus' node is provided in the original FDT then we do not add
- // any 'cpu' node.
- if (!CpusNodeExist) {
- cpu_node = fdt_add_subnode (fdt, node, Name);
- if (cpu_node < 0) {
- DEBUG ((EFI_D_ERROR, "Error on creating '%s' node\n", Name));
- Status = EFI_INVALID_PARAMETER;
- goto FAIL_COMPLETE_FDT;
- }
-
- fdt_setprop_string (fdt, cpu_node, "device_type", "cpu");
-
- CoreMpId = cpu_to_fdtn (CoreMpId);
- fdt_setprop (fdt, cpu_node, "reg", &CoreMpId, sizeof (CoreMpId));
- } else {
- cpu_node = fdt_subnode_offset(fdt, node, Name);
- }
-
- if (cpu_node >= 0) {
- Method = fdt_getprop (fdt, cpu_node, "enable-method", &lenp);
- // We only care when 'enable-method' == 'spin-table'. If the enable-method is not defined
- // or defined as 'psci' then we ignore its properties.
- if ((Method != NULL) && (AsciiStrCmp ((CHAR8 *)Method, "spin-table") == 0)) {
- // There are two cases;
- // - UEFI firmware parked the secondary cores and/or UEFI firmware is aware of the CPU
- // release addresses (PcdArmLinuxSpinTable == TRUE)
- // - the parking of the secondary cores has been managed before starting UEFI and/or UEFI
- // does not anything about the CPU release addresses - in this case we do nothing
- if (FeaturePcdGet (PcdArmLinuxSpinTable)) {
- CpuReleaseAddr = cpu_to_fdt64 (ArmCoreInfoTable[Index].MailboxSetAddress);
- fdt_setprop (fdt, cpu_node, "cpu-release-addr", &CpuReleaseAddr, sizeof(CpuReleaseAddr));
-
- // If it is not the primary core than the cpu should be disabled
- if (((ArmCoreInfoTable[Index].ClusterId != ClusterId) || (ArmCoreInfoTable[Index].CoreId != CoreId))) {
- fdt_setprop_string(fdt, cpu_node, "status", "disabled");
- }
- }
- }
- }
- }
- break;
- }
- }
-
- DEBUG_CODE_BEGIN();
- //DebugDumpFdt (fdt);
- DEBUG_CODE_END();
-
- // If we succeeded to generate the new Device Tree then free the old Device Tree
- gBS->FreePages (*FdtBlobBase, EFI_SIZE_TO_PAGES (*FdtBlobSize));
-
- // Update the real size of the Device Tree
- fdt_pack ((VOID*)(UINTN)(NewFdtBlobBase));
-
- *FdtBlobBase = NewFdtBlobBase;
- *FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(NewFdtBlobBase));
- return EFI_SUCCESS;
-
-FAIL_COMPLETE_FDT:
- gBS->FreePages (NewFdtBlobAllocation, EFI_SIZE_TO_PAGES (NewFdtBlobSize));
-
-FAIL_RELOCATE_FDT:
- *FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(*FdtBlobBase));
- // Return success even if we failed to update the FDT blob.
- // The original one is still valid.
- return EFI_SUCCESS;
-}
diff --git a/ArmPkg/Library/BdsLib/BdsLinuxLoader.h b/ArmPkg/Library/BdsLib/BdsLinuxLoader.h
deleted file mode 100644
index b78f606..0000000
--- a/ArmPkg/Library/BdsLib/BdsLinuxLoader.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#ifndef __BDSLINUXLOADER_H
-#define __BDSLINUXLOADER_H
-
-#define LINUX_UIMAGE_SIGNATURE 0x56190527
-#define LINUX_KERNEL_MAX_OFFSET (PcdGet64 (PcdSystemMemoryBase) + PcdGet32(PcdArmLinuxKernelMaxOffset))
-#define LINUX_ATAG_MAX_OFFSET (PcdGet64 (PcdSystemMemoryBase) + PcdGet32(PcdArmLinuxAtagMaxOffset))
-#define LINUX_FDT_MAX_OFFSET (PcdGet64 (PcdSystemMemoryBase) + PcdGet32(PcdArmLinuxFdtMaxOffset))
-
-// Additional size that could be used for FDT entries added by the UEFI OS Loader
-// Estimation based on: EDID (300bytes) + bootargs (200bytes) + initrd region (20bytes)
-// + system memory region (20bytes) + mp_core entries (200 bytes)
-#define FDT_ADDITIONAL_ENTRIES_SIZE 0x300
-
-#define ARM_FDT_MACHINE_TYPE 0xFFFFFFFF
-
-typedef VOID (*LINUX_KERNEL)(UINT32 Zero, UINT32 Arch, UINTN ParametersBase);
-
-//
-// ATAG Definitions
-//
-
-#define ATAG_MAX_SIZE 0x3000
-
-/* ATAG : list of possible tags */
-#define ATAG_NONE 0x00000000
-#define ATAG_CORE 0x54410001
-#define ATAG_MEM 0x54410002
-#define ATAG_VIDEOTEXT 0x54410003
-#define ATAG_RAMDISK 0x54410004
-#define ATAG_INITRD2 0x54420005
-#define ATAG_SERIAL 0x54410006
-#define ATAG_REVISION 0x54410007
-#define ATAG_VIDEOLFB 0x54410008
-#define ATAG_CMDLINE 0x54410009
-#define ATAG_ARM_MP_CORE 0x5441000A
-
-#define next_tag_address(t) ((LINUX_ATAG*)((UINT32)(t) + (((t)->header.size) << 2) ))
-#define tag_size(type) ((UINT32)((sizeof(LINUX_ATAG_HEADER) + sizeof(type)) >> 2))
-
-typedef struct {
- UINT32 size; /* length of tag in words including this header */
- UINT32 type; /* tag type */
-} LINUX_ATAG_HEADER;
-
-typedef struct {
- UINT32 flags;
- UINT32 pagesize;
- UINT32 rootdev;
-} LINUX_ATAG_CORE;
-
-typedef struct {
- UINT32 size;
- UINTN start;
-} LINUX_ATAG_MEM;
-
-typedef struct {
- UINT8 x;
- UINT8 y;
- UINT16 video_page;
- UINT8 video_mode;
- UINT8 video_cols;
- UINT16 video_ega_bx;
- UINT8 video_lines;
- UINT8 video_isvga;
- UINT16 video_points;
-} LINUX_ATAG_VIDEOTEXT;
-
-typedef struct {
- UINT32 flags;
- UINT32 size;
- UINTN start;
-} LINUX_ATAG_RAMDISK;
-
-typedef struct {
- UINT32 start;
- UINT32 size;
-} LINUX_ATAG_INITRD2;
-
-typedef struct {
- UINT32 low;
- UINT32 high;
-} LINUX_ATAG_SERIALNR;
-
-typedef struct {
- UINT32 rev;
-} LINUX_ATAG_REVISION;
-
-typedef struct {
- UINT16 lfb_width;
- UINT16 lfb_height;
- UINT16 lfb_depth;
- UINT16 lfb_linelength;
- UINT32 lfb_base;
- UINT32 lfb_size;
- UINT8 red_size;
- UINT8 red_pos;
- UINT8 green_size;
- UINT8 green_pos;
- UINT8 blue_size;
- UINT8 blue_pos;
- UINT8 rsvd_size;
- UINT8 rsvd_pos;
-} LINUX_ATAG_VIDEOLFB;
-
-typedef struct {
- CHAR8 cmdline[1];
-} LINUX_ATAG_CMDLINE;
-
-typedef struct {
- LINUX_ATAG_HEADER header;
- union {
- LINUX_ATAG_CORE core_tag;
- LINUX_ATAG_MEM mem_tag;
- LINUX_ATAG_VIDEOTEXT videotext_tag;
- LINUX_ATAG_RAMDISK ramdisk_tag;
- LINUX_ATAG_INITRD2 initrd2_tag;
- LINUX_ATAG_SERIALNR serialnr_tag;
- LINUX_ATAG_REVISION revision_tag;
- LINUX_ATAG_VIDEOLFB videolfb_tag;
- LINUX_ATAG_CMDLINE cmdline_tag;
- } body;
-} LINUX_ATAG;
-
-EFI_STATUS
-PrepareAtagList (
- IN CONST CHAR8* CommandLineString,
- IN EFI_PHYSICAL_ADDRESS InitrdImage,
- IN UINTN InitrdImageSize,
- OUT EFI_PHYSICAL_ADDRESS *AtagBase,
- OUT UINT32 *AtagSize
- );
-
-EFI_STATUS
-PrepareFdt (
- IN CONST CHAR8* CommandLineArguments,
- IN EFI_PHYSICAL_ADDRESS InitrdImage,
- IN UINTN InitrdImageSize,
- IN OUT EFI_PHYSICAL_ADDRESS *FdtBlobBase,
- IN OUT UINTN *FdtBlobSize
- );
-
-#endif
diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index 76a45e0..9639f14 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -39,6 +39,9 @@
EmbeddedPkg/EmbeddedPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec

+[Guids]
+ gFdtTableGuid
+
[LibraryClasses]
BdsLib
TimerLib
@@ -49,6 +52,7 @@
DebugLib
PrintLib
BaseLib
+ FdtLib
NetLib

[Guids]
diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c
index bb218f8..342d441 100644
--- a/ArmPlatformPkg/Bds/BootOption.c
+++ b/ArmPlatformPkg/Bds/BootOption.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -23,10 +23,6 @@ BootOptionStart (
EFI_STATUS Status;
UINT32 LoaderType;
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
- ARM_BDS_LINUX_ARGUMENTS* LinuxArguments;
- UINTN CmdLineSize;
- UINTN InitrdSize;
- EFI_DEVICE_PATH* Initrd;
UINT16 LoadOptionIndexSize;

if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
@@ -42,34 +38,9 @@ BootOptionStart (

Status = BdsStartEfiApplication (gImageHandle, BootOption->FilePathList, 0, NULL);
} else if (LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) {
- LinuxArguments = &(OptionalData->Arguments.LinuxArguments);
- CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
- InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);
-
- if (InitrdSize > 0) {
- Initrd = GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize));
- } else {
- Initrd = NULL;
- }
-
- Status = BdsBootLinuxAtag (BootOption->FilePathList,
- Initrd, // Initrd
- (CHAR8*)(LinuxArguments + 1)); // CmdLine
+ ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
} else if (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT) {
- LinuxArguments = &(OptionalData->Arguments.LinuxArguments);
- CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
- InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);
-
- if (InitrdSize > 0) {
- Initrd = GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize));
- } else {
- Initrd = NULL;
- }
- Status = BdsBootLinuxFdt (
- BootOption->FilePathList,
- Initrd,
- (CHAR8*)(LinuxArguments + 1)
- );
+ ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
}
} else {
// Connect all the drivers if the EFI Application is not a EFI OS Loader
--
2.1.1
Olivier Martin
2015-07-13 16:36:47 UTC
Permalink
This change removes the embedded Linux Loder from BdsLib.
BdsLib becomes OS agnostic.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <***@arm.com>
Reviewed-by: Ronald Cron <***@arm.com>
---
ArmPkg/Include/Library/BdsLib.h | 37 --
ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c | 355 -------------
.../Library/BdsLib/AArch64/BdsLinuxLoaderHelper.S | 58 ---
ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c | 173 -------
ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c | 323 ------------
ArmPkg/Library/BdsLib/BdsHelper.c | 178 +------
ArmPkg/Library/BdsLib/BdsInternal.h | 13 -
ArmPkg/Library/BdsLib/BdsLib.inf | 38 --
ArmPkg/Library/BdsLib/BdsLinuxFdt.c | 572 ---------------------
ArmPkg/Library/BdsLib/BdsLinuxLoader.h | 156 ------
ArmPlatformPkg/Bds/Bds.inf | 4 +
ArmPlatformPkg/Bds/BootOption.c | 35 +-
12 files changed, 8 insertions(+), 1934 deletions(-)
delete mode 100644 ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c
delete mode 100644 ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoaderHelper.S
delete mode 100644 ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c
delete mode 100644 ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
delete mode 100644 ArmPkg/Library/BdsLib/BdsLinuxFdt.c
delete mode 100644 ArmPkg/Library/BdsLib/BdsLinuxLoader.h

diff --git a/ArmPkg/Include/Library/BdsLib.h b/ArmPkg/Include/Library/BdsLib.h
index 3d9e195..c58f47e 100644
--- a/ArmPkg/Include/Library/BdsLib.h
+++ b/ArmPkg/Include/Library/BdsLib.h
@@ -138,43 +138,6 @@ BootOptionAllocateBootIndex (
);

/**
- Start a Linux kernel from a Device Path
-
- @param LinuxKernel Device Path to the Linux Kernel
- @param Parameters Linux kernel arguments
-
- @retval EFI_SUCCESS All drivers have been connected
- @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsBootLinuxAtag (
- IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* Arguments
- );
-
-/**
- Start a Linux kernel from a Device Path
-
- @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
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsBootLinuxFdt (
- IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* Arguments
- );
-
-/**
Start an EFI Application from a Device Path

@param ParentImageHandle Handle of the calling image
diff --git a/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c b/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c
deleted file mode 100644
index 7651597..0000000
--- a/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoader.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-#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"
-
-/*
- Linux kernel booting: Look at the doc in the Kernel source :
- Documentation/arm64/booting.txt
- The kernel image must be placed at the start of the memory to be used by the
- kernel (2MB aligned) + 0x80000.
-
- The Device tree blob is expected to be under 2MB and be within the first 512MB
- of kernel memory and be 2MB aligned.
-
- A Flattened Device Tree (FDT) used to boot linux needs to be updated before
- the kernel is started. It needs to indicate how secondary cores are brought up
- and where they are waiting before loading Linux. The FDT also needs to hold
- the correct kernel command line and filesystem RAM-disk information.
- At the moment we do not fully support generating this FDT information at
- runtime. A prepared FDT should be provided at boot. FDT is the only supported
- method for booting the AArch64 Linux kernel.
-
- Linux does not use any runtime services at this time, so we can let it
- overwrite UEFI.
-*/
-
-
-#define LINUX_ALIGN_VAL (0x080000) // 2MB + 0x80000 mask
-#define LINUX_ALIGN_MASK (0x1FFFFF) // Bottom 21bits
-#define ALIGN_2MB(addr) ALIGN_POINTER(addr , (2*1024*1024))
-
-/* ARM32 and AArch64 kernel handover differ.
- * x0 is set to FDT base.
- * x1-x3 are reserved for future use and should be set to zero.
- */
-typedef VOID (*LINUX_KERNEL64)(UINTN ParametersBase, UINTN Reserved0,
- UINTN Reserved1, UINTN Reserved2);
-
-/* These externs are used to relocate some ASM code into Linux memory. */
-extern VOID *SecondariesPenStart;
-extern VOID *SecondariesPenEnd;
-extern UINTN *AsmMailboxbase;
-
-
-STATIC
-EFI_STATUS
-PreparePlatformHardware (
- VOID
- )
-{
- //Note: Interrupts will be disabled by the GIC driver when ExitBootServices() will be called.
-
- // Clean before Disable else the Stack gets corrupted with old data.
- ArmCleanDataCache ();
- ArmDisableDataCache ();
- // Invalidate all the entries that might have snuck in.
- ArmInvalidateDataCache ();
-
- // Disable and invalidate the instruction cache
- ArmDisableInstructionCache ();
- ArmInvalidateInstructionCache ();
-
- // Turn off MMU
- ArmDisableMmu();
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-StartLinux (
- IN EFI_PHYSICAL_ADDRESS LinuxImage,
- IN UINTN LinuxImageSize,
- IN EFI_PHYSICAL_ADDRESS FdtBlobBase,
- IN UINTN FdtBlobSize
- )
-{
- EFI_STATUS Status;
- LINUX_KERNEL64 LinuxKernel = (LINUX_KERNEL64)LinuxImage;
-
- // Send msg to secondary cores to go to the kernel pen.
- ArmGicSendSgiTo (PcdGet32(PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));
-
- // Shut down UEFI boot services. ExitBootServices() will notify every driver that created an event on
- // ExitBootServices event. Example the Interrupt DXE driver will disable the interrupts on this event.
- Status = ShutdownUefiBootServices ();
- if(EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR,"ERROR: Can not shutdown UEFI boot services. Status=0x%X\n", Status));
- goto Exit;
- }
-
- // Check if the Linux Image is a uImage
- if (*(UINTN*)LinuxKernel == LINUX_UIMAGE_SIGNATURE) {
- // Assume the Image Entry Point is just after the uImage header (64-byte size)
- LinuxKernel = (LINUX_KERNEL64)((UINTN)LinuxKernel + 64);
- LinuxImageSize -= 64;
- }
-
- //
- // Switch off interrupts, caches, mmu, etc
- //
- Status = PreparePlatformHardware ();
- ASSERT_EFI_ERROR(Status);
-
- // Register and print out performance information
- PERF_END (NULL, "BDS", NULL, 0);
- if (PerformanceMeasurementEnabled ()) {
- PrintPerformance ();
- }
-
- //
- // Start the Linux Kernel
- //
-
- // x1-x3 are reserved (set to zero) for future use.
- LinuxKernel ((UINTN)FdtBlobBase, 0, 0, 0);
-
- // Kernel should never exit
- // After Life services are not provided
- ASSERT(FALSE);
-
-Exit:
- // Only be here if we fail to start Linux
- Print (L"ERROR : Can not start the kernel. Status=0x%X\n", Status);
-
- // Free Runtimee Memory (kernel and FDT)
- return Status;
-}
-
-
-/**
- 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
-
- @retval EFI_SUCCESS All drivers have been connected
- @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsBootLinuxAtag (
- IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* Arguments
- )
-{
- // NOTE : AArch64 Linux kernel does not support ATAG, FDT only.
- ASSERT(0);
-
- return RETURN_UNSUPPORTED;
-}
-
-/**
- Start a Linux kernel from a Device Path
-
- @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
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsBootLinuxFdt (
- IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* Arguments
- )
-{
- 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;
- InitrdImage = 0;
- InitrdImageSize = 0;
- InitrdImageBase = 0;
- InitrdImageBaseSize = 0;
-
- PERF_START (NULL, "BDS", NULL, 0);
-
- //
- // Load the Linux kernel from a device path
- //
-
- // Try to put the kernel at the start of RAM so as to give it access to all memory.
- // If that fails fall back to try loading it within LINUX_KERNEL_MAX_OFFSET of memory start.
- LinuxImage = PcdGet64 (PcdSystemMemoryBase) + 0x80000;
- Status = BdsLoadImage (LinuxKernelDevicePath, AllocateAddress, &LinuxImage, &LinuxImageSize);
- if (EFI_ERROR(Status)) {
- // Try again but give the loader more freedom of where to put the image.
- LinuxImage = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (LinuxKernelDevicePath, AllocateMaxAddress, &LinuxImage, &LinuxImageSize);
- if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find Linux kernel (%r).\n", Status);
- return Status;
- }
- }
- // Adjust the kernel location slightly if required. The kernel needs to be placed at start
- // of memory (2MB aligned) + 0x80000.
- if ((LinuxImage & LINUX_ALIGN_MASK) != LINUX_ALIGN_VAL) {
- LinuxImage = (EFI_PHYSICAL_ADDRESS)CopyMem (ALIGN_2MB(LinuxImage) + 0x80000, (VOID*)(UINTN)LinuxImage, LinuxImageSize);
- }
-
- if (InitrdDevicePath) {
- InitrdImageBase = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (InitrdDevicePath, AllocateMaxAddress, &InitrdImageBase, &InitrdImageBaseSize);
- if (Status == EFI_OUT_OF_RESOURCES) {
- Status = BdsLoadImage (InitrdDevicePath, AllocateAnyPages, &InitrdImageBase, &InitrdImageBaseSize);
- }
- if (EFI_ERROR (Status)) {
- Print (L"ERROR: Did not find initrd image (%r).\n", Status);
- goto EXIT_FREE_LINUX;
- }
-
- // Check if the initrd is a uInitrd
- if (*(UINTN*)((UINTN)InitrdImageBase) == LINUX_UIMAGE_SIGNATURE) {
- // Skip the 64-byte image header
- InitrdImage = (EFI_PHYSICAL_ADDRESS)((UINTN)InitrdImageBase + 64);
- InitrdImageSize = InitrdImageBaseSize - 64;
- } else {
- InitrdImage = InitrdImageBase;
- InitrdImageSize = InitrdImageBaseSize;
- }
- }
-
- //
- // 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
- //
- if (FeaturePcdGet (PcdArmLinuxSpinTable)) {
- // Place Pen at the start of Linux memory. We can then tell Linux to not use this bit of memory
- PenBase = LinuxImage - 0x80000;
- PenSize = (UINTN)&SecondariesPenEnd - (UINTN)&SecondariesPenStart;
-
- // Reserve the memory as RuntimeServices
- PenBaseStatus = gBS->AllocatePages (AllocateAddress, EfiRuntimeServicesCode, EFI_SIZE_TO_PAGES (PenSize), &PenBase);
- if (EFI_ERROR (PenBaseStatus)) {
- Print (L"Warning: Failed to reserve the memory required for the secondary cores at 0x%lX, Status = %r\n", PenBase, PenBaseStatus);
- // Even if there is a risk of memory corruption we carry on
- }
-
- // Put mailboxes below the pen code so we know where they are relative to code.
- MailBoxBase = (UINTN)PenBase + ((UINTN)&SecondariesPenEnd - (UINTN)&SecondariesPenStart);
- // Make sure this is 8 byte aligned.
- if (MailBoxBase % sizeof(MailBoxBase) != 0) {
- MailBoxBase += sizeof(MailBoxBase) - MailBoxBase % sizeof(MailBoxBase);
- }
-
- CopyMem ( (VOID*)(PenBase), (VOID*)&SecondariesPenStart, PenSize);
-
- // Update the MailboxBase variable used in the pen code
- *(UINTN*)(PenBase + ((UINTN)&AsmMailboxbase - (UINTN)&SecondariesPenStart)) = MailBoxBase;
-
- for (Index=0; Index < gST->NumberOfTableEntries; Index++) {
- // Check for correct GUID type
- if (CompareGuid (&gArmMpCoreInfoGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {
- UINTN i;
-
- // Get them under our control. Move from depending on 32bit reg(sys_flags) and SWI
- // to 64 bit addr and WFE
- ArmProcessorTable = (ARM_PROCESSOR_TABLE *)gST->ConfigurationTable[Index].VendorTable;
- ArmCoreInfoTable = ArmProcessorTable->ArmCpus;
-
- for (i = 0; i < ArmProcessorTable->NumberOfEntries; i++ ) {
- // This goes into the SYSFLAGS register for the VE platform. We only have one 32bit reg to use
- MmioWrite32(ArmCoreInfoTable[i].MailboxSetAddress, (UINTN)PenBase);
-
- // So FDT can set the mailboxes correctly with the parser. These are 64bit Memory locations.
- ArmCoreInfoTable[i].MailboxSetAddress = (UINTN)MailBoxBase + i*sizeof(MailBoxBase);
-
- // Clear the mailboxes for the respective cores
- *((UINTN*)(ArmCoreInfoTable[i].MailboxSetAddress)) = 0x0;
- }
- }
- }
- // Flush caches to make sure our pen gets to mem before we free the cores.
- ArmCleanDataCache();
- }
-
- // By setting address=0 we leave the memory allocation to the function
- Status = PrepareFdt (Arguments, InitrdImage, InitrdImageSize, &FdtBlobBase, &FdtBlobSize);
- if (EFI_ERROR(Status)) {
- Print(L"ERROR: Can not load Linux kernel with Device Tree. Status=0x%X\n", Status);
- goto EXIT_FREE_FDT;
- }
-
- return StartLinux (LinuxImage, LinuxImageSize, FdtBlobBase, FdtBlobSize);
-
-EXIT_FREE_FDT:
- if (!EFI_ERROR (PenBaseStatus)) {
- gBS->FreePages (PenBase, EFI_SIZE_TO_PAGES (PenSize));
- }
-
- gBS->FreePages (FdtBlobBase, EFI_SIZE_TO_PAGES (FdtBlobSize));
-
-EXIT_FREE_INITRD:
- if (InitrdDevicePath) {
- gBS->FreePages (InitrdImageBase, EFI_SIZE_TO_PAGES (InitrdImageBaseSize));
- }
-
-EXIT_FREE_LINUX:
- gBS->FreePages (LinuxImage, EFI_SIZE_TO_PAGES (LinuxImageSize));
-
- return Status;
-}
diff --git a/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoaderHelper.S b/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoaderHelper.S
deleted file mode 100644
index 525c128..0000000
--- a/ArmPkg/Library/BdsLib/AArch64/BdsLinuxLoaderHelper.S
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-//
-//
-
-
-/* Secondary core pens for AArch64 Linux booting.
-
- This code it placed in Linux kernel memory and marked reserved. UEFI ensures
- that the secondary cores get to this pen and the kernel can then start the
- cores from here.
- NOTE: This code must be self-contained.
-*/
-
-#include <Library/ArmLib.h>
-
-.text
-.align 3
-
-GCC_ASM_EXPORT(SecondariesPenStart)
-ASM_GLOBAL SecondariesPenEnd
-
-ASM_PFX(SecondariesPenStart):
- // Registers x0-x3 are reserved for future use and should be set to zero.
- mov x0, xzr
- mov x1, xzr
- mov x2, xzr
- mov x3, xzr
-
- // Get core position. Taken from ArmPlatformGetCorePosition().
- // Assumes max 4 cores per cluster.
- mrs x4, mpidr_el1 // Get MPCore register.
- and x5, x4, #ARM_CORE_MASK // Get core number.
- and x4, x4, #ARM_CLUSTER_MASK // Get cluster number.
- add x4, x5, x4, LSR #6 // Add scaled cluster number to core number.
- lsl x4, x4, 3 // Get mailbox offset for this core.
- ldr x5, AsmMailboxbase // Get mailbox addr relative to pc (36 bytes ahead).
- add x4, x4, x5 // Add core mailbox offset to base of mailbox.
-1: ldr x5, [x4] // Load value from mailbox.
- cmp xzr, x5 // Has the mailbox been set?
- b.ne 2f // If so break out of loop.
- wfe // If not, wait a bit.
- b 1b // Wait over, check if mailbox set again.
-2: br x5 // Jump to mailbox value.
-
-.align 3 // Make sure the variable below is 8 byte aligned.
- .global AsmMailboxbase
-AsmMailboxbase: .xword 0xdeaddeadbeefbeef
-
-SecondariesPenEnd:
diff --git a/ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c b/ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c
deleted file mode 100644
index 33c2798..0000000
--- a/ArmPkg/Library/BdsLib/Arm/BdsLinuxAtag.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include "BdsInternal.h"
-#include "BdsLinuxLoader.h"
-
-// Point to the current ATAG
-STATIC LINUX_ATAG *mLinuxKernelCurrentAtag;
-
-STATIC
-VOID
-SetupCoreTag (
- IN UINT32 PageSize
- )
-{
- mLinuxKernelCurrentAtag->header.size = tag_size(LINUX_ATAG_CORE);
- mLinuxKernelCurrentAtag->header.type = ATAG_CORE;
-
- mLinuxKernelCurrentAtag->body.core_tag.flags = 1; /* ensure read-only */
- mLinuxKernelCurrentAtag->body.core_tag.pagesize = PageSize; /* systems PageSize (4k) */
- mLinuxKernelCurrentAtag->body.core_tag.rootdev = 0; /* zero root device (typically overridden from kernel command line )*/
-
- // move pointer to next tag
- mLinuxKernelCurrentAtag = next_tag_address(mLinuxKernelCurrentAtag);
-}
-
-STATIC
-VOID
-SetupMemTag (
- IN UINTN StartAddress,
- IN UINT32 Size
- )
-{
- mLinuxKernelCurrentAtag->header.size = tag_size(LINUX_ATAG_MEM);
- mLinuxKernelCurrentAtag->header.type = ATAG_MEM;
-
- mLinuxKernelCurrentAtag->body.mem_tag.start = StartAddress; /* Start of memory chunk for AtagMem */
- mLinuxKernelCurrentAtag->body.mem_tag.size = Size; /* Size of memory chunk for AtagMem */
-
- // move pointer to next tag
- mLinuxKernelCurrentAtag = next_tag_address(mLinuxKernelCurrentAtag);
-}
-
-STATIC
-VOID
-SetupCmdlineTag (
- IN CONST CHAR8 *CmdLine
- )
-{
- UINT32 LineLength;
-
- // Increment the line length by 1 to account for the null string terminator character
- LineLength = AsciiStrLen(CmdLine) + 1;
-
- /* Check for NULL strings.
- * Do not insert a tag for an empty CommandLine, don't even modify the tag address pointer.
- * Remember, you have at least one null string terminator character.
- */
- if(LineLength > 1) {
- mLinuxKernelCurrentAtag->header.size = ((UINT32)sizeof(LINUX_ATAG_HEADER) + LineLength + (UINT32)3) >> 2;
- mLinuxKernelCurrentAtag->header.type = ATAG_CMDLINE;
-
- /* place CommandLine into tag */
- AsciiStrCpy(mLinuxKernelCurrentAtag->body.cmdline_tag.cmdline, CmdLine);
-
- // move pointer to next tag
- mLinuxKernelCurrentAtag = next_tag_address(mLinuxKernelCurrentAtag);
- }
-}
-
-STATIC
-VOID
-SetupInitrdTag (
- IN UINT32 InitrdImage,
- IN UINT32 InitrdImageSize
- )
-{
- mLinuxKernelCurrentAtag->header.size = tag_size(LINUX_ATAG_INITRD2);
- mLinuxKernelCurrentAtag->header.type = ATAG_INITRD2;
-
- mLinuxKernelCurrentAtag->body.initrd2_tag.start = InitrdImage;
- mLinuxKernelCurrentAtag->body.initrd2_tag.size = InitrdImageSize;
-
- // Move pointer to next tag
- mLinuxKernelCurrentAtag = next_tag_address(mLinuxKernelCurrentAtag);
-}
-STATIC
-VOID
-SetupEndTag (
- VOID
- )
-{
- // Empty tag ends list; this has zero length and no body
- mLinuxKernelCurrentAtag->header.type = ATAG_NONE;
- mLinuxKernelCurrentAtag->header.size = 0;
-
- /* We can not calculate the next address by using the standard macro:
- * Params = next_tag_address(Params);
- * because it relies on the header.size, which here it is 0 (zero).
- * The easiest way is to add the sizeof(mLinuxKernelCurrentAtag->header).
- */
- mLinuxKernelCurrentAtag = (LINUX_ATAG*)((UINT32)mLinuxKernelCurrentAtag + sizeof(mLinuxKernelCurrentAtag->header));
-}
-
-EFI_STATUS
-PrepareAtagList (
- IN CONST CHAR8* CommandLineString,
- IN EFI_PHYSICAL_ADDRESS InitrdImage,
- IN UINTN InitrdImageSize,
- OUT EFI_PHYSICAL_ADDRESS *AtagBase,
- OUT UINT32 *AtagSize
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *ResourceLink;
- LIST_ENTRY ResourceList;
- EFI_PHYSICAL_ADDRESS AtagStartAddress;
- BDS_SYSTEM_MEMORY_RESOURCE *Resource;
-
- AtagStartAddress = LINUX_ATAG_MAX_OFFSET;
- Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData, EFI_SIZE_TO_PAGES(ATAG_MAX_SIZE), &AtagStartAddress);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_WARN, "Warning: Failed to allocate Atag at 0x%lX (%r). The Atag will be allocated somewhere else in System Memory.\n", AtagStartAddress, Status));
- Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData, EFI_SIZE_TO_PAGES(ATAG_MAX_SIZE), &AtagStartAddress);
- ASSERT_EFI_ERROR(Status);
- }
-
- // Ready to setup the atag list
- mLinuxKernelCurrentAtag = (LINUX_ATAG*)(UINTN)AtagStartAddress;
-
- // Standard core tag 4k PageSize
- SetupCoreTag( (UINT32)SIZE_4KB );
-
- // Physical memory setup
- GetSystemMemoryResources (&ResourceList);
- ResourceLink = ResourceList.ForwardLink;
- while (ResourceLink != NULL && ResourceLink != &ResourceList) {
- Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)ResourceLink;
- DEBUG((EFI_D_INFO,"- [0x%08X,0x%08X]\n",(UINT32)Resource->PhysicalStart,(UINT32)Resource->PhysicalStart+(UINT32)Resource->ResourceLength));
- SetupMemTag( (UINT32)Resource->PhysicalStart, (UINT32)Resource->ResourceLength );
- ResourceLink = ResourceLink->ForwardLink;
- }
-
- // CommandLine setting root device
- if (CommandLineString) {
- SetupCmdlineTag (CommandLineString);
- }
-
- if (InitrdImageSize > 0 && InitrdImage != 0) {
- SetupInitrdTag ((UINT32)InitrdImage, (UINT32)InitrdImageSize);
- }
-
- // End of tags
- SetupEndTag();
-
- // Calculate atag list size
- *AtagBase = AtagStartAddress;
- *AtagSize = (UINT32)mLinuxKernelCurrentAtag - (UINT32)AtagStartAddress + 1;
-
- return EFI_SUCCESS;
-}
-
diff --git a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c b/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
deleted file mode 100644
index e5fda08..0000000
--- a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <Guid/Fdt.h>
-#include <libfdt.h>
-
-#include "BdsInternal.h"
-#include "BdsLinuxLoader.h"
-
-#define ALIGN32_BELOW(addr) ALIGN_POINTER(addr - 32,32)
-
-#define IS_ADDRESS_IN_REGION(RegionStart, RegionSize, Address) \
- (((UINTN)(RegionStart) <= (UINTN)(Address)) && ((UINTN)(Address) <= ((UINTN)(RegionStart) + (UINTN)(RegionSize))))
-
-STATIC
-EFI_STATUS
-PreparePlatformHardware (
- VOID
- )
-{
- //Note: Interrupts will be disabled by the GIC driver when ExitBootServices() will be called.
-
- // Clean before Disable else the Stack gets corrupted with old data.
- ArmCleanDataCache ();
- ArmDisableDataCache ();
- // Invalidate all the entries that might have snuck in.
- ArmInvalidateDataCache ();
-
- // Invalidate and disable the Instruction cache
- ArmDisableInstructionCache ();
- ArmInvalidateInstructionCache ();
-
- // Turn off MMU
- ArmDisableMmu();
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-StartLinux (
- IN EFI_PHYSICAL_ADDRESS LinuxImage,
- IN UINTN LinuxImageSize,
- IN EFI_PHYSICAL_ADDRESS KernelParamsAddress,
- IN UINTN KernelParamsSize,
- IN UINT32 MachineType
- )
-{
- EFI_STATUS Status;
- LINUX_KERNEL LinuxKernel;
-
- // Shut down UEFI boot services. ExitBootServices() will notify every driver that created an event on
- // ExitBootServices event. Example the Interrupt DXE driver will disable the interrupts on this event.
- Status = ShutdownUefiBootServices ();
- if(EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR,"ERROR: Can not shutdown UEFI boot services. Status=0x%X\n", Status));
- goto Exit;
- }
-
- // Move the kernel parameters to any address inside the first 1MB.
- // This is necessary because the ARM Linux kernel requires
- // the FTD / ATAG List to reside entirely inside the first 1MB of
- // physical memory.
- //Note: There is no requirement on the alignment
- if (MachineType != ARM_FDT_MACHINE_TYPE) {
- if (((UINTN)KernelParamsAddress > LINUX_ATAG_MAX_OFFSET) && (KernelParamsSize < PcdGet32(PcdArmLinuxAtagMaxOffset))) {
- KernelParamsAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CopyMem (ALIGN32_BELOW(LINUX_ATAG_MAX_OFFSET - KernelParamsSize), (VOID*)(UINTN)KernelParamsAddress, KernelParamsSize);
- }
- } else {
- if (((UINTN)KernelParamsAddress > LINUX_FDT_MAX_OFFSET) && (KernelParamsSize < PcdGet32(PcdArmLinuxFdtMaxOffset))) {
- KernelParamsAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CopyMem (ALIGN32_BELOW(LINUX_FDT_MAX_OFFSET - KernelParamsSize), (VOID*)(UINTN)KernelParamsAddress, KernelParamsSize);
- }
- }
-
- if ((UINTN)LinuxImage > LINUX_KERNEL_MAX_OFFSET) {
- //Note: There is no requirement on the alignment
- LinuxKernel = (LINUX_KERNEL)CopyMem (ALIGN32_BELOW(LINUX_KERNEL_MAX_OFFSET - LinuxImageSize), (VOID*)(UINTN)LinuxImage, LinuxImageSize);
- } else {
- LinuxKernel = (LINUX_KERNEL)(UINTN)LinuxImage;
- }
-
- // Check if the Linux Image is a uImage
- if (*(UINT32*)LinuxKernel == LINUX_UIMAGE_SIGNATURE) {
- // Assume the Image Entry Point is just after the uImage header (64-byte size)
- LinuxKernel = (LINUX_KERNEL)((UINTN)LinuxKernel + 64);
- LinuxImageSize -= 64;
- }
-
- // Check there is no overlapping between kernel and its parameters
- // We can only assert because it is too late to fallback to UEFI (ExitBootServices has been called).
- ASSERT (!IS_ADDRESS_IN_REGION(LinuxKernel, LinuxImageSize, KernelParamsAddress) &&
- !IS_ADDRESS_IN_REGION(LinuxKernel, LinuxImageSize, KernelParamsAddress + KernelParamsSize));
-
- //
- // Switch off interrupts, caches, mmu, etc
- //
- Status = PreparePlatformHardware ();
- ASSERT_EFI_ERROR(Status);
-
- // Register and print out performance information
- PERF_END (NULL, "BDS", NULL, 0);
- if (PerformanceMeasurementEnabled ()) {
- PrintPerformance ();
- }
-
- //
- // Start the Linux Kernel
- //
-
- // Outside BootServices, so can't use Print();
- DEBUG((EFI_D_ERROR, "\nStarting the kernel:\n\n"));
-
- // Jump to kernel with register set
- LinuxKernel ((UINTN)0, MachineType, (UINTN)KernelParamsAddress);
-
- // Kernel should never exit
- // After Life services are not provided
- ASSERT(FALSE);
-
-Exit:
- // Only be here if we fail to start Linux
- Print (L"ERROR : Can not start the kernel. Status=0x%X\n", Status);
-
- // Free Runtimee Memory (kernel and FDT)
- return Status;
-}
-
-/**
- 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
-
- @retval EFI_SUCCESS All drivers have been connected
- @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsBootLinuxAtag (
- IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* CommandLineArguments
- )
-{
- EFI_STATUS Status;
- UINT32 LinuxImageSize;
- UINT32 InitrdImageBaseSize = 0;
- UINT32 InitrdImageSize = 0;
- UINT32 AtagSize;
- EFI_PHYSICAL_ADDRESS AtagBase;
- EFI_PHYSICAL_ADDRESS LinuxImage;
- EFI_PHYSICAL_ADDRESS InitrdImageBase = 0;
- EFI_PHYSICAL_ADDRESS InitrdImage = 0;
-
- PERF_START (NULL, "BDS", NULL, 0);
-
- // Load the Linux kernel from a device path
- LinuxImage = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (LinuxKernelDevicePath, AllocateMaxAddress, &LinuxImage, &LinuxImageSize);
- if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find Linux kernel.\n");
- return Status;
- }
-
- if (InitrdDevicePath) {
- // Load the initrd near to the Linux kernel
- InitrdImageBase = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (InitrdDevicePath, AllocateMaxAddress, &InitrdImageBase, &InitrdImageBaseSize);
- if (Status == EFI_OUT_OF_RESOURCES) {
- Status = BdsLoadImage (InitrdDevicePath, AllocateAnyPages, &InitrdImageBase, &InitrdImageBaseSize);
- }
- if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find initrd image.\n");
- goto EXIT_FREE_LINUX;
- }
-
- // Check if the initrd is a uInitrd
- if (*(UINT32*)((UINTN)InitrdImageBase) == LINUX_UIMAGE_SIGNATURE) {
- // Skip the 64-byte image header
- InitrdImage = (EFI_PHYSICAL_ADDRESS)((UINTN)InitrdImageBase + 64);
- InitrdImageSize = InitrdImageBaseSize - 64;
- } else {
- InitrdImage = InitrdImageBase;
- InitrdImageSize = InitrdImageBaseSize;
- }
- }
-
- //
- // Setup the Linux Kernel Parameters
- //
-
- // By setting address=0 we leave the memory allocation to the function
- Status = PrepareAtagList (CommandLineArguments, InitrdImage, InitrdImageSize, &AtagBase, &AtagSize);
- if (EFI_ERROR(Status)) {
- Print(L"ERROR: Can not prepare ATAG list. Status=0x%X\n", Status);
- goto EXIT_FREE_INITRD;
- }
-
- return StartLinux (LinuxImage, LinuxImageSize, AtagBase, AtagSize, PcdGet32(PcdArmMachineType));
-
-EXIT_FREE_INITRD:
- if (InitrdDevicePath) {
- gBS->FreePages (InitrdImageBase, EFI_SIZE_TO_PAGES (InitrdImageBaseSize));
- }
-
-EXIT_FREE_LINUX:
- gBS->FreePages (LinuxImage, EFI_SIZE_TO_PAGES (LinuxImageSize));
-
- return Status;
-}
-
-/**
- Start a Linux kernel from a Device Path
-
- @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
- @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
-
-**/
-EFI_STATUS
-BdsBootLinuxFdt (
- IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,
- IN CONST CHAR8* CommandLineArguments
- )
-{
- 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);
-
- // Load the Linux kernel from a device path
- LinuxImage = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (LinuxKernelDevicePath, AllocateMaxAddress, &LinuxImage, &LinuxImageSize);
- if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find Linux kernel.\n");
- return Status;
- }
-
- if (InitrdDevicePath) {
- InitrdImageBase = LINUX_KERNEL_MAX_OFFSET;
- Status = BdsLoadImage (InitrdDevicePath, AllocateMaxAddress, &InitrdImageBase, &InitrdImageBaseSize);
- if (Status == EFI_OUT_OF_RESOURCES) {
- Status = BdsLoadImage (InitrdDevicePath, AllocateAnyPages, &InitrdImageBase, &InitrdImageBaseSize);
- }
- if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find initrd image.\n");
- goto EXIT_FREE_LINUX;
- }
-
- // Check if the initrd is a uInitrd
- if (*(UINT32*)((UINTN)InitrdImageBase) == LINUX_UIMAGE_SIGNATURE) {
- // Skip the 64-byte image header
- InitrdImage = (EFI_PHYSICAL_ADDRESS)((UINTN)InitrdImageBase + 64);
- InitrdImageSize = InitrdImageBaseSize - 64;
- } else {
- InitrdImage = InitrdImageBase;
- InitrdImageSize = InitrdImageBaseSize;
- }
- }
-
- //
- // 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
- Status = PrepareFdt (CommandLineArguments, InitrdImage, InitrdImageSize, &FdtBlobBase, &FdtBlobSize);
- if (EFI_ERROR(Status)) {
- Print(L"ERROR: Can not load kernel with FDT. Status=%r\n", Status);
- goto EXIT_FREE_FDT;
- }
-
- return StartLinux (LinuxImage, LinuxImageSize, FdtBlobBase, FdtBlobSize, ARM_FDT_MACHINE_TYPE);
-
-EXIT_FREE_FDT:
- gBS->FreePages (FdtBlobBase, EFI_SIZE_TO_PAGES (FdtBlobSize));
-
-EXIT_FREE_INITRD:
- if (InitrdDevicePath) {
- gBS->FreePages (InitrdImageBase, EFI_SIZE_TO_PAGES (InitrdImageBaseSize));
- }
-
-EXIT_FREE_LINUX:
- gBS->FreePages (LinuxImage, EFI_SIZE_TO_PAGES (LinuxImageSize));
-
- return Status;
-}
-
diff --git a/ArmPkg/Library/BdsLib/BdsHelper.c b/ArmPkg/Library/BdsLib/BdsHelper.c
index 7f83c2b..b10fe20 100644
--- a/ArmPkg/Library/BdsLib/BdsHelper.c
+++ b/ArmPkg/Library/BdsLib/BdsHelper.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -14,19 +14,6 @@

#include "BdsInternal.h"

-#include <Library/HobLib.h>
-#include <Library/TimerLib.h>
-#include <Library/PrintLib.h>
-#include <Library/SerialPortLib.h>
-
-STATIC CHAR8 *mTokenList[] = {
- /*"SEC",*/
- "PEI",
- "DXE",
- "BDS",
- NULL
-};
-
EFI_STATUS
ShutdownUefiBootServices (
VOID
@@ -129,169 +116,6 @@ BdsConnectAllDrivers (
return EFI_SUCCESS;
}

-STATIC
-EFI_STATUS
-InsertSystemMemoryResources (
- LIST_ENTRY *ResourceList,
- EFI_HOB_RESOURCE_DESCRIPTOR *ResHob
- )
-{
- BDS_SYSTEM_MEMORY_RESOURCE *NewResource;
- LIST_ENTRY *Link;
- LIST_ENTRY *NextLink;
- LIST_ENTRY AttachedResources;
- BDS_SYSTEM_MEMORY_RESOURCE *Resource;
- EFI_PHYSICAL_ADDRESS NewResourceEnd;
-
- if (IsListEmpty (ResourceList)) {
- NewResource = AllocateZeroPool (sizeof(BDS_SYSTEM_MEMORY_RESOURCE));
- NewResource->PhysicalStart = ResHob->PhysicalStart;
- NewResource->ResourceLength = ResHob->ResourceLength;
- InsertTailList (ResourceList, &NewResource->Link);
- return EFI_SUCCESS;
- }
-
- InitializeListHead (&AttachedResources);
-
- Link = ResourceList->ForwardLink;
- ASSERT (Link != NULL);
- while (Link != ResourceList) {
- Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)Link;
-
- // Sanity Check. The resources should not overlapped.
- ASSERT(!((ResHob->PhysicalStart >= Resource->PhysicalStart) && (ResHob->PhysicalStart < (Resource->PhysicalStart + Resource->ResourceLength))));
- ASSERT(!((ResHob->PhysicalStart + ResHob->ResourceLength - 1 >= Resource->PhysicalStart) &&
- ((ResHob->PhysicalStart + ResHob->ResourceLength - 1) < (Resource->PhysicalStart + Resource->ResourceLength))));
-
- // The new resource is attached after this resource descriptor
- if (ResHob->PhysicalStart == Resource->PhysicalStart + Resource->ResourceLength) {
- Resource->ResourceLength = Resource->ResourceLength + ResHob->ResourceLength;
-
- NextLink = RemoveEntryList (&Resource->Link);
- InsertTailList (&AttachedResources, &Resource->Link);
- Link = NextLink;
- }
- // The new resource is attached before this resource descriptor
- else if (ResHob->PhysicalStart + ResHob->ResourceLength == Resource->PhysicalStart) {
- Resource->PhysicalStart = ResHob->PhysicalStart;
- Resource->ResourceLength = Resource->ResourceLength + ResHob->ResourceLength;
-
- NextLink = RemoveEntryList (&Resource->Link);
- InsertTailList (&AttachedResources, &Resource->Link);
- Link = NextLink;
- } else {
- Link = Link->ForwardLink;
- }
- }
-
- if (!IsListEmpty (&AttachedResources)) {
- // See if we can merge the attached resource with other resources
-
- NewResource = (BDS_SYSTEM_MEMORY_RESOURCE*)GetFirstNode (&AttachedResources);
- Link = RemoveEntryList (&NewResource->Link);
- while (!IsListEmpty (&AttachedResources)) {
- // Merge resources
- Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)Link;
-
- // Ensure they overlap each other
- ASSERT(
- ((NewResource->PhysicalStart >= Resource->PhysicalStart) && (NewResource->PhysicalStart < (Resource->PhysicalStart + Resource->ResourceLength))) ||
- (((NewResource->PhysicalStart + NewResource->ResourceLength) >= Resource->PhysicalStart) && ((NewResource->PhysicalStart + NewResource->ResourceLength) < (Resource->PhysicalStart + Resource->ResourceLength)))
- );
-
- NewResourceEnd = MAX (NewResource->PhysicalStart + NewResource->ResourceLength, Resource->PhysicalStart + Resource->ResourceLength);
- NewResource->PhysicalStart = MIN (NewResource->PhysicalStart, Resource->PhysicalStart);
- NewResource->ResourceLength = NewResourceEnd - NewResource->PhysicalStart;
-
- Link = RemoveEntryList (Link);
- }
- } else {
- // None of the Resource of the list is attached to this ResHob. Create a new entry for it
- NewResource = AllocateZeroPool (sizeof(BDS_SYSTEM_MEMORY_RESOURCE));
- NewResource->PhysicalStart = ResHob->PhysicalStart;
- NewResource->ResourceLength = ResHob->ResourceLength;
- }
- InsertTailList (ResourceList, &NewResource->Link);
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-GetSystemMemoryResources (
- IN LIST_ENTRY *ResourceList
- )
-{
- EFI_HOB_RESOURCE_DESCRIPTOR *ResHob;
-
- InitializeListHead (ResourceList);
-
- // Find the first System Memory Resource Descriptor
- ResHob = (EFI_HOB_RESOURCE_DESCRIPTOR *)GetFirstHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR);
- while ((ResHob != NULL) && (ResHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY)) {
- ResHob = (EFI_HOB_RESOURCE_DESCRIPTOR *)GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,(VOID *)((UINTN)ResHob + ResHob->Header.HobLength));
- }
-
- // Did not find any
- if (ResHob == NULL) {
- return EFI_NOT_FOUND;
- } else {
- InsertSystemMemoryResources (ResourceList, ResHob);
- }
-
- ResHob = (EFI_HOB_RESOURCE_DESCRIPTOR *)GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,(VOID *)((UINTN)ResHob + ResHob->Header.HobLength));
- while (ResHob != NULL) {
- if (ResHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {
- InsertSystemMemoryResources (ResourceList, ResHob);
- }
- ResHob = (EFI_HOB_RESOURCE_DESCRIPTOR *)GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,(VOID *)((UINTN)ResHob + ResHob->Header.HobLength));
- }
-
- return EFI_SUCCESS;
-}
-
-VOID
-PrintPerformance (
- VOID
- )
-{
- UINTN Key;
- CONST VOID *Handle;
- CONST CHAR8 *Token, *Module;
- UINT64 Start, Stop, TimeStamp;
- UINT64 Delta, TicksPerSecond, Milliseconds;
- UINTN Index;
- CHAR8 Buffer[100];
- UINTN CharCount;
- BOOLEAN CountUp;
-
- TicksPerSecond = GetPerformanceCounterProperties (&Start, &Stop);
- if (Start < Stop) {
- CountUp = TRUE;
- } else {
- CountUp = FALSE;
- }
-
- TimeStamp = 0;
- Key = 0;
- do {
- Key = GetPerformanceMeasurement (Key, (CONST VOID **)&Handle, &Token, &Module, &Start, &Stop);
- if (Key != 0) {
- for (Index = 0; mTokenList[Index] != NULL; Index++) {
- if (AsciiStriCmp (mTokenList[Index], Token) == 0) {
- Delta = CountUp?(Stop - Start):(Start - Stop);
- TimeStamp += Delta;
- Milliseconds = DivU64x64Remainder (MultU64x32 (Delta, 1000), TicksPerSecond, NULL);
- CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"%6a %6ld ms\n", Token, Milliseconds);
- SerialPortWrite ((UINT8 *) Buffer, CharCount);
- break;
- }
- }
- }
- } while (Key != 0);
-
- CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Total Time = %ld ms\n\n", DivU64x64Remainder (MultU64x32 (TimeStamp, 1000), TicksPerSecond, NULL));
- SerialPortWrite ((UINT8 *) Buffer, CharCount);
-}
-
EFI_STATUS
GetGlobalEnvironmentVariable (
IN CONST CHAR16* VariableName,
diff --git a/ArmPkg/Library/BdsLib/BdsInternal.h b/ArmPkg/Library/BdsLib/BdsInternal.h
index 1fab2ae..f70aae6 100644
--- a/ArmPkg/Library/BdsLib/BdsInternal.h
+++ b/ArmPkg/Library/BdsLib/BdsInternal.h
@@ -28,11 +28,9 @@
#include <Library/DebugLib.h>
#include <Library/BdsLib.h>
#include <Library/PcdLib.h>
-#include <Library/PerformanceLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>

-#include <Guid/ArmMpCoreInfo.h>
#include <Guid/GlobalVariable.h>
#include <Guid/FileInfo.h>

@@ -102,17 +100,6 @@ typedef struct {
UINT64 LastReportedNbOfBytes;
} BDS_TFTP_CONTEXT;

-// BdsHelper.c
-EFI_STATUS
-GetSystemMemoryResources (
- LIST_ENTRY *ResourceList
- );
-
-VOID
-PrintPerformance (
- VOID
- );
-
EFI_STATUS
BdsLoadImage (
IN EFI_DEVICE_PATH *DevicePath,
diff --git a/ArmPkg/Library/BdsLib/BdsLib.inf b/ArmPkg/Library/BdsLib/BdsLib.inf
index ecf6de5..eb4543e 100644
--- a/ArmPkg/Library/BdsLib/BdsLib.inf
+++ b/ArmPkg/Library/BdsLib/BdsLib.inf
@@ -25,15 +25,6 @@
BdsAppLoader.c
BdsHelper.c
BdsLoadOption.c
- BdsLinuxFdt.c
-
-[Sources.ARM]
- Arm/BdsLinuxLoader.c
- Arm/BdsLinuxAtag.c
-
-[Sources.AARCH64]
- AArch64/BdsLinuxLoader.c
- AArch64/BdsLinuxLoaderHelper.S

[Packages]
EmbeddedPkg/EmbeddedPkg.dec
@@ -44,26 +35,16 @@

[LibraryClasses]
ArmLib
- ArmSmcLib
BaseLib
DebugLib
DevicePathLib
HobLib
PcdLib
- PerformanceLib
- SerialPortLib
- FdtLib
- TimerLib
NetLib

-[LibraryClasses.AARCH64]
- ArmGicLib
-
[Guids]
gEfiFileInfoGuid
- gArmMpCoreInfoGuid
gArmGlobalVariableGuid
- gFdtTableGuid

[Protocols]
gEfiBdsArchProtocolGuid
@@ -82,27 +63,8 @@
gEfiMtftp4ServiceBindingProtocolGuid
gEfiMtftp4ProtocolGuid

-[FeaturePcd]
- gArmTokenSpaceGuid.PcdArmLinuxSpinTable
-
-[Pcd]
- gArmTokenSpaceGuid.PcdSystemMemoryBase
- gArmTokenSpaceGuid.PcdSystemMemorySize
-
[FixedPcd]
- gArmTokenSpaceGuid.PcdArmMachineType
- gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset
- gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment
- gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset
-
gArmTokenSpaceGuid.PcdMaxTftpFileSize

-[FixedPcd.ARM]
- gArmTokenSpaceGuid.PcdArmLinuxAtagMaxOffset
-
-[Pcd.AARCH64]
- gArmTokenSpaceGuid.PcdGicDistributorBase
- gArmTokenSpaceGuid.PcdGicSgiIntId
-
[Depex]
TRUE
diff --git a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
deleted file mode 100644
index e379552..0000000
--- a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
+++ /dev/null
@@ -1,572 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <Library/ArmSmcLib.h>
-#include <Library/PcdLib.h>
-#include <libfdt.h>
-
-#include "BdsInternal.h"
-#include "BdsLinuxLoader.h"
-
-#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
-#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a))))
-#define GET_CELL(p) (p += 4, *((const UINT32 *)(p-4)))
-
-STATIC
-UINTN
-cpu_to_fdtn (UINTN x) {
- if (sizeof (UINTN) == sizeof (UINT32)) {
- return cpu_to_fdt32 (x);
- } else {
- return cpu_to_fdt64 (x);
- }
-}
-
-typedef struct {
- UINTN Base;
- UINTN Size;
-} FdtRegion;
-
-
-STATIC
-UINTN
-IsPrintableString (
- IN CONST VOID* data,
- IN UINTN len
- )
-{
- CONST CHAR8 *s = data;
- CONST CHAR8 *ss;
-
- // Zero length is not
- if (len == 0) {
- return 0;
- }
-
- // Must terminate with zero
- if (s[len - 1] != '\0') {
- return 0;
- }
-
- ss = s;
- while (*s/* && isprint(*s)*/) {
- s++;
- }
-
- // Not zero, or not done yet
- if (*s != '\0' || (s + 1 - ss) < len) {
- return 0;
- }
-
- return 1;
-}
-
-STATIC
-VOID
-PrintData (
- IN CONST CHAR8* data,
- IN UINTN len
- )
-{
- UINTN i;
- CONST CHAR8 *p = data;
-
- // No data, don't print
- if (len == 0)
- return;
-
- if (IsPrintableString (data, len)) {
- Print(L" = \"%a\"", (const char *)data);
- } else if ((len % 4) == 0) {
- Print(L" = <");
- for (i = 0; i < len; i += 4) {
- Print(L"0x%08x%a", fdt32_to_cpu(GET_CELL(p)),i < (len - 4) ? " " : "");
- }
- Print(L">");
- } else {
- Print(L" = [");
- for (i = 0; i < len; i++)
- Print(L"%02x%a", *p++, i < len - 1 ? " " : "");
- Print(L"]");
- }
-}
-
-VOID
-DebugDumpFdt (
- IN VOID* FdtBlob
- )
-{
- struct fdt_header *bph;
- UINT32 off_dt;
- UINT32 off_str;
- CONST CHAR8* p_struct;
- CONST CHAR8* p_strings;
- CONST CHAR8* p;
- CONST CHAR8* s;
- CONST CHAR8* t;
- UINT32 tag;
- UINTN sz;
- UINTN depth;
- UINTN shift;
- UINT32 version;
-
- {
- // Can 'memreserve' be printed by below code?
- INTN num = fdt_num_mem_rsv(FdtBlob);
- INTN i, err;
- UINT64 addr = 0,size = 0;
-
- for (i = 0; i < num; i++) {
- err = fdt_get_mem_rsv(FdtBlob, i, &addr, &size);
- if (err) {
- DEBUG((EFI_D_ERROR, "Error (%d) : Cannot get memreserve section (%d)\n", err, i));
- }
- else {
- Print(L"/memreserve/ \t0x%lx \t0x%lx;\n",addr,size);
- }
- }
- }
-
- depth = 0;
- shift = 4;
-
- bph = FdtBlob;
- off_dt = fdt32_to_cpu(bph->off_dt_struct);
- off_str = fdt32_to_cpu(bph->off_dt_strings);
- p_struct = (CONST CHAR8*)FdtBlob + off_dt;
- p_strings = (CONST CHAR8*)FdtBlob + off_str;
- version = fdt32_to_cpu(bph->version);
-
- p = p_struct;
- while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) {
- if (tag == FDT_BEGIN_NODE) {
- s = p;
- p = PALIGN(p + AsciiStrLen (s) + 1, 4);
-
- if (*s == '\0')
- s = "/";
-
- Print(L"%*s%a {\n", depth * shift, L" ", s);
-
- depth++;
- continue;
- }
-
- if (tag == FDT_END_NODE) {
- depth--;
-
- Print(L"%*s};\n", depth * shift, L" ");
- continue;
- }
-
- if (tag == FDT_NOP) {
- Print(L"%*s// [NOP]\n", depth * shift, L" ");
- continue;
- }
-
- if (tag != FDT_PROP) {
- Print(L"%*s ** Unknown tag 0x%08x\n", depth * shift, L" ", tag);
- break;
- }
- sz = fdt32_to_cpu(GET_CELL(p));
- s = p_strings + fdt32_to_cpu(GET_CELL(p));
- if (version < 16 && sz >= 8)
- p = PALIGN(p, 8);
- t = p;
-
- p = PALIGN(p + sz, 4);
-
- Print(L"%*s%a", depth * shift, L" ", s);
- PrintData(t, sz);
- Print(L";\n");
- }
-}
-
-STATIC
-BOOLEAN
-IsLinuxReservedRegion (
- IN EFI_MEMORY_TYPE MemoryType
- )
-{
- switch(MemoryType) {
- case EfiRuntimeServicesCode:
- case EfiRuntimeServicesData:
- case EfiUnusableMemory:
- case EfiACPIReclaimMemory:
- case EfiACPIMemoryNVS:
- case EfiReservedMemoryType:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-/**
-** Relocate the FDT blob to a more appropriate location for the Linux kernel.
-** This function will allocate memory for the relocated FDT blob.
-**
-** @retval EFI_SUCCESS on success.
-** @retval EFI_OUT_OF_RESOURCES or EFI_INVALID_PARAMETER on failure.
-*/
-STATIC
-EFI_STATUS
-RelocateFdt (
- EFI_PHYSICAL_ADDRESS OriginalFdt,
- UINTN OriginalFdtSize,
- EFI_PHYSICAL_ADDRESS *RelocatedFdt,
- UINTN *RelocatedFdtSize,
- EFI_PHYSICAL_ADDRESS *RelocatedFdtAlloc
- )
-{
- EFI_STATUS Status;
- INTN Error;
- UINT64 FdtAlignment;
-
- *RelocatedFdtSize = OriginalFdtSize + FDT_ADDITIONAL_ENTRIES_SIZE;
-
- // If FDT load address needs to be aligned, allocate more space.
- FdtAlignment = PcdGet32 (PcdArmLinuxFdtAlignment);
- if (FdtAlignment != 0) {
- *RelocatedFdtSize += FdtAlignment;
- }
-
- // Try below a watermark address.
- Status = EFI_NOT_FOUND;
- if (PcdGet32 (PcdArmLinuxFdtMaxOffset) != 0) {
- *RelocatedFdt = LINUX_FDT_MAX_OFFSET;
- Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData,
- EFI_SIZE_TO_PAGES (*RelocatedFdtSize), RelocatedFdt);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_WARN, "Warning: Failed to load FDT below address 0x%lX (%r). Will try again at a random address anywhere.\n", *RelocatedFdt, Status));
- }
- }
-
- // Try anywhere there is available space.
- if (EFI_ERROR (Status)) {
- Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData,
- EFI_SIZE_TO_PAGES (*RelocatedFdtSize), RelocatedFdt);
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- return EFI_OUT_OF_RESOURCES;
- } else {
- DEBUG ((EFI_D_WARN, "WARNING: Loaded FDT at random address 0x%lX.\nWARNING: There is a risk of accidental overwriting by other code/data.\n", *RelocatedFdt));
- }
- }
-
- *RelocatedFdtAlloc = *RelocatedFdt;
- if (FdtAlignment != 0) {
- *RelocatedFdt = ALIGN (*RelocatedFdt, FdtAlignment);
- }
-
- // Load the Original FDT tree into the new region
- Error = fdt_open_into ((VOID*)(UINTN) OriginalFdt,
- (VOID*)(UINTN)(*RelocatedFdt), *RelocatedFdtSize);
- if (Error) {
- DEBUG ((EFI_D_ERROR, "fdt_open_into(): %a\n", fdt_strerror (Error)));
- gBS->FreePages (*RelocatedFdtAlloc, EFI_SIZE_TO_PAGES (*RelocatedFdtSize));
- return EFI_INVALID_PARAMETER;
- }
-
- DEBUG_CODE_BEGIN();
- //DebugDumpFdt (fdt);
- DEBUG_CODE_END();
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-PrepareFdt (
- IN CONST CHAR8* CommandLineArguments,
- IN EFI_PHYSICAL_ADDRESS InitrdImage,
- IN UINTN InitrdImageSize,
- IN OUT EFI_PHYSICAL_ADDRESS *FdtBlobBase,
- IN OUT UINTN *FdtBlobSize
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS NewFdtBlobBase;
- EFI_PHYSICAL_ADDRESS NewFdtBlobAllocation;
- UINTN NewFdtBlobSize;
- VOID* fdt;
- INTN err;
- INTN node;
- INTN cpu_node;
- INT32 lenp;
- CONST VOID* BootArg;
- CONST VOID* Method;
- EFI_PHYSICAL_ADDRESS InitrdImageStart;
- EFI_PHYSICAL_ADDRESS InitrdImageEnd;
- FdtRegion Region;
- UINTN Index;
- CHAR8 Name[10];
- LIST_ENTRY ResourceList;
- BDS_SYSTEM_MEMORY_RESOURCE *Resource;
- ARM_PROCESSOR_TABLE *ArmProcessorTable;
- ARM_CORE_INFO *ArmCoreInfoTable;
- UINT32 MpId;
- UINT32 ClusterId;
- UINT32 CoreId;
- UINT64 CpuReleaseAddr;
- UINTN MemoryMapSize;
- EFI_MEMORY_DESCRIPTOR *MemoryMap;
- EFI_MEMORY_DESCRIPTOR *MemoryMapPtr;
- UINTN MapKey;
- UINTN DescriptorSize;
- UINT32 DescriptorVersion;
- UINTN Pages;
- UINTN OriginalFdtSize;
- BOOLEAN CpusNodeExist;
- UINTN CoreMpId;
-
- NewFdtBlobAllocation = 0;
-
- //
- // Sanity checks on the original FDT blob.
- //
- err = fdt_check_header ((VOID*)(UINTN)(*FdtBlobBase));
- if (err != 0) {
- Print (L"ERROR: Device Tree header not valid (err:%d)\n", err);
- return EFI_INVALID_PARAMETER;
- }
-
- // The original FDT blob might have been loaded partially.
- // Check that it is not the case.
- OriginalFdtSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(*FdtBlobBase));
- if (OriginalFdtSize > *FdtBlobSize) {
- Print (L"ERROR: Incomplete FDT. Only %d/%d bytes have been loaded.\n",
- *FdtBlobSize, OriginalFdtSize);
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Relocate the FDT to its final location.
- //
- Status = RelocateFdt (*FdtBlobBase, OriginalFdtSize,
- &NewFdtBlobBase, &NewFdtBlobSize, &NewFdtBlobAllocation);
- if (EFI_ERROR (Status)) {
- goto FAIL_RELOCATE_FDT;
- }
-
- fdt = (VOID*)(UINTN)NewFdtBlobBase;
-
- node = fdt_subnode_offset (fdt, 0, "chosen");
- if (node < 0) {
- // The 'chosen' node does not exist, create it
- node = fdt_add_subnode(fdt, 0, "chosen");
- if (node < 0) {
- DEBUG((EFI_D_ERROR,"Error on finding 'chosen' node\n"));
- Status = EFI_INVALID_PARAMETER;
- goto FAIL_COMPLETE_FDT;
- }
- }
-
- DEBUG_CODE_BEGIN();
- BootArg = fdt_getprop(fdt, node, "bootargs", &lenp);
- if (BootArg != NULL) {
- DEBUG((EFI_D_ERROR,"BootArg: %a\n",BootArg));
- }
- DEBUG_CODE_END();
-
- //
- // Set Linux CmdLine
- //
- if ((CommandLineArguments != NULL) && (AsciiStrLen (CommandLineArguments) > 0)) {
- err = fdt_setprop(fdt, node, "bootargs", CommandLineArguments, AsciiStrSize(CommandLineArguments));
- if (err) {
- DEBUG((EFI_D_ERROR,"Fail to set new 'bootarg' (err:%d)\n",err));
- }
- }
-
- //
- // Set Linux Initrd
- //
- if (InitrdImageSize != 0) {
- InitrdImageStart = cpu_to_fdt64 (InitrdImage);
- err = fdt_setprop(fdt, node, "linux,initrd-start", &InitrdImageStart, sizeof(EFI_PHYSICAL_ADDRESS));
- if (err) {
- DEBUG((EFI_D_ERROR,"Fail to set new 'linux,initrd-start' (err:%d)\n",err));
- }
- InitrdImageEnd = cpu_to_fdt64 (InitrdImage + InitrdImageSize);
- err = fdt_setprop(fdt, node, "linux,initrd-end", &InitrdImageEnd, sizeof(EFI_PHYSICAL_ADDRESS));
- if (err) {
- DEBUG((EFI_D_ERROR,"Fail to set new 'linux,initrd-start' (err:%d)\n",err));
- }
- }
-
- //
- // Set Physical memory setup if does not exist
- //
- node = fdt_subnode_offset(fdt, 0, "memory");
- if (node < 0) {
- // The 'memory' node does not exist, create it
- node = fdt_add_subnode(fdt, 0, "memory");
- if (node >= 0) {
- fdt_setprop_string(fdt, node, "name", "memory");
- fdt_setprop_string(fdt, node, "device_type", "memory");
-
- GetSystemMemoryResources (&ResourceList);
- Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)ResourceList.ForwardLink;
-
- Region.Base = cpu_to_fdtn ((UINTN)Resource->PhysicalStart);
- Region.Size = cpu_to_fdtn ((UINTN)Resource->ResourceLength);
-
- err = fdt_setprop(fdt, node, "reg", &Region, sizeof(Region));
- if (err) {
- DEBUG((EFI_D_ERROR,"Fail to set new 'memory region' (err:%d)\n",err));
- }
- }
- }
-
- //
- // Add the memory regions reserved by the UEFI Firmware
- //
-
- // Retrieve the UEFI Memory Map
- MemoryMap = NULL;
- MemoryMapSize = 0;
- Status = gBS->GetMemoryMap (&MemoryMapSize, MemoryMap, &MapKey, &DescriptorSize, &DescriptorVersion);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- // The UEFI specification advises to allocate more memory for the MemoryMap buffer between successive
- // calls to GetMemoryMap(), since allocation of the new buffer may potentially increase memory map size.
- Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1;
- MemoryMap = AllocatePages (Pages);
- if (MemoryMap == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto FAIL_COMPLETE_FDT;
- }
- Status = gBS->GetMemoryMap (&MemoryMapSize, MemoryMap, &MapKey, &DescriptorSize, &DescriptorVersion);
- }
-
- // Go through the list and add the reserved region to the Device Tree
- if (!EFI_ERROR(Status)) {
- MemoryMapPtr = MemoryMap;
- for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) {
- if (IsLinuxReservedRegion ((EFI_MEMORY_TYPE)MemoryMapPtr->Type)) {
- DEBUG((DEBUG_VERBOSE, "Reserved region of type %d [0x%lX, 0x%lX]\n",
- MemoryMapPtr->Type,
- (UINTN)MemoryMapPtr->PhysicalStart,
- (UINTN)(MemoryMapPtr->PhysicalStart + MemoryMapPtr->NumberOfPages * EFI_PAGE_SIZE)));
- err = fdt_add_mem_rsv(fdt, MemoryMapPtr->PhysicalStart, MemoryMapPtr->NumberOfPages * EFI_PAGE_SIZE);
- if (err != 0) {
- Print(L"Warning: Fail to add 'memreserve' (err:%d)\n", err);
- }
- }
- MemoryMapPtr = (EFI_MEMORY_DESCRIPTOR*)((UINTN)MemoryMapPtr + DescriptorSize);
- }
- }
-
- //
- // Setup Arm Mpcore Info if it is a multi-core or multi-cluster platforms.
- //
- // For 'cpus' and 'cpu' device tree nodes bindings, refer to this file
- // in the kernel documentation:
- // Documentation/devicetree/bindings/arm/cpus.txt
- //
- for (Index=0; Index < gST->NumberOfTableEntries; Index++) {
- // Check for correct GUID type
- if (CompareGuid (&gArmMpCoreInfoGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {
- MpId = ArmReadMpidr ();
- ClusterId = GET_CLUSTER_ID(MpId);
- CoreId = GET_CORE_ID(MpId);
-
- node = fdt_subnode_offset(fdt, 0, "cpus");
- if (node < 0) {
- // Create the /cpus node
- node = fdt_add_subnode(fdt, 0, "cpus");
- fdt_setprop_string(fdt, node, "name", "cpus");
- fdt_setprop_cell (fdt, node, "#address-cells", sizeof (UINTN) / 4);
- fdt_setprop_cell(fdt, node, "#size-cells", 0);
- CpusNodeExist = FALSE;
- } else {
- CpusNodeExist = TRUE;
- }
-
- // Get pointer to ARM processor table
- ArmProcessorTable = (ARM_PROCESSOR_TABLE *)gST->ConfigurationTable[Index].VendorTable;
- ArmCoreInfoTable = ArmProcessorTable->ArmCpus;
-
- for (Index = 0; Index < ArmProcessorTable->NumberOfEntries; Index++) {
- CoreMpId = (UINTN) GET_MPID (ArmCoreInfoTable[Index].ClusterId,
- ArmCoreInfoTable[Index].CoreId);
- AsciiSPrint (Name, 10, "cpu@%x", CoreMpId);
-
- // If the 'cpus' node did not exist then create all the 'cpu' nodes.
- // In case 'cpus' node is provided in the original FDT then we do not add
- // any 'cpu' node.
- if (!CpusNodeExist) {
- cpu_node = fdt_add_subnode (fdt, node, Name);
- if (cpu_node < 0) {
- DEBUG ((EFI_D_ERROR, "Error on creating '%s' node\n", Name));
- Status = EFI_INVALID_PARAMETER;
- goto FAIL_COMPLETE_FDT;
- }
-
- fdt_setprop_string (fdt, cpu_node, "device_type", "cpu");
-
- CoreMpId = cpu_to_fdtn (CoreMpId);
- fdt_setprop (fdt, cpu_node, "reg", &CoreMpId, sizeof (CoreMpId));
- } else {
- cpu_node = fdt_subnode_offset(fdt, node, Name);
- }
-
- if (cpu_node >= 0) {
- Method = fdt_getprop (fdt, cpu_node, "enable-method", &lenp);
- // We only care when 'enable-method' == 'spin-table'. If the enable-method is not defined
- // or defined as 'psci' then we ignore its properties.
- if ((Method != NULL) && (AsciiStrCmp ((CHAR8 *)Method, "spin-table") == 0)) {
- // There are two cases;
- // - UEFI firmware parked the secondary cores and/or UEFI firmware is aware of the CPU
- // release addresses (PcdArmLinuxSpinTable == TRUE)
- // - the parking of the secondary cores has been managed before starting UEFI and/or UEFI
- // does not anything about the CPU release addresses - in this case we do nothing
- if (FeaturePcdGet (PcdArmLinuxSpinTable)) {
- CpuReleaseAddr = cpu_to_fdt64 (ArmCoreInfoTable[Index].MailboxSetAddress);
- fdt_setprop (fdt, cpu_node, "cpu-release-addr", &CpuReleaseAddr, sizeof(CpuReleaseAddr));
-
- // If it is not the primary core than the cpu should be disabled
- if (((ArmCoreInfoTable[Index].ClusterId != ClusterId) || (ArmCoreInfoTable[Index].CoreId != CoreId))) {
- fdt_setprop_string(fdt, cpu_node, "status", "disabled");
- }
- }
- }
- }
- }
- break;
- }
- }
-
- DEBUG_CODE_BEGIN();
- //DebugDumpFdt (fdt);
- DEBUG_CODE_END();
-
- // If we succeeded to generate the new Device Tree then free the old Device Tree
- gBS->FreePages (*FdtBlobBase, EFI_SIZE_TO_PAGES (*FdtBlobSize));
-
- // Update the real size of the Device Tree
- fdt_pack ((VOID*)(UINTN)(NewFdtBlobBase));
-
- *FdtBlobBase = NewFdtBlobBase;
- *FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(NewFdtBlobBase));
- return EFI_SUCCESS;
-
-FAIL_COMPLETE_FDT:
- gBS->FreePages (NewFdtBlobAllocation, EFI_SIZE_TO_PAGES (NewFdtBlobSize));
-
-FAIL_RELOCATE_FDT:
- *FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(*FdtBlobBase));
- // Return success even if we failed to update the FDT blob.
- // The original one is still valid.
- return EFI_SUCCESS;
-}
diff --git a/ArmPkg/Library/BdsLib/BdsLinuxLoader.h b/ArmPkg/Library/BdsLib/BdsLinuxLoader.h
deleted file mode 100644
index b78f606..0000000
--- a/ArmPkg/Library/BdsLib/BdsLinuxLoader.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#ifndef __BDSLINUXLOADER_H
-#define __BDSLINUXLOADER_H
-
-#define LINUX_UIMAGE_SIGNATURE 0x56190527
-#define LINUX_KERNEL_MAX_OFFSET (PcdGet64 (PcdSystemMemoryBase) + PcdGet32(PcdArmLinuxKernelMaxOffset))
-#define LINUX_ATAG_MAX_OFFSET (PcdGet64 (PcdSystemMemoryBase) + PcdGet32(PcdArmLinuxAtagMaxOffset))
-#define LINUX_FDT_MAX_OFFSET (PcdGet64 (PcdSystemMemoryBase) + PcdGet32(PcdArmLinuxFdtMaxOffset))
-
-// Additional size that could be used for FDT entries added by the UEFI OS Loader
-// Estimation based on: EDID (300bytes) + bootargs (200bytes) + initrd region (20bytes)
-// + system memory region (20bytes) + mp_core entries (200 bytes)
-#define FDT_ADDITIONAL_ENTRIES_SIZE 0x300
-
-#define ARM_FDT_MACHINE_TYPE 0xFFFFFFFF
-
-typedef VOID (*LINUX_KERNEL)(UINT32 Zero, UINT32 Arch, UINTN ParametersBase);
-
-//
-// ATAG Definitions
-//
-
-#define ATAG_MAX_SIZE 0x3000
-
-/* ATAG : list of possible tags */
-#define ATAG_NONE 0x00000000
-#define ATAG_CORE 0x54410001
-#define ATAG_MEM 0x54410002
-#define ATAG_VIDEOTEXT 0x54410003
-#define ATAG_RAMDISK 0x54410004
-#define ATAG_INITRD2 0x54420005
-#define ATAG_SERIAL 0x54410006
-#define ATAG_REVISION 0x54410007
-#define ATAG_VIDEOLFB 0x54410008
-#define ATAG_CMDLINE 0x54410009
-#define ATAG_ARM_MP_CORE 0x5441000A
-
-#define next_tag_address(t) ((LINUX_ATAG*)((UINT32)(t) + (((t)->header.size) << 2) ))
-#define tag_size(type) ((UINT32)((sizeof(LINUX_ATAG_HEADER) + sizeof(type)) >> 2))
-
-typedef struct {
- UINT32 size; /* length of tag in words including this header */
- UINT32 type; /* tag type */
-} LINUX_ATAG_HEADER;
-
-typedef struct {
- UINT32 flags;
- UINT32 pagesize;
- UINT32 rootdev;
-} LINUX_ATAG_CORE;
-
-typedef struct {
- UINT32 size;
- UINTN start;
-} LINUX_ATAG_MEM;
-
-typedef struct {
- UINT8 x;
- UINT8 y;
- UINT16 video_page;
- UINT8 video_mode;
- UINT8 video_cols;
- UINT16 video_ega_bx;
- UINT8 video_lines;
- UINT8 video_isvga;
- UINT16 video_points;
-} LINUX_ATAG_VIDEOTEXT;
-
-typedef struct {
- UINT32 flags;
- UINT32 size;
- UINTN start;
-} LINUX_ATAG_RAMDISK;
-
-typedef struct {
- UINT32 start;
- UINT32 size;
-} LINUX_ATAG_INITRD2;
-
-typedef struct {
- UINT32 low;
- UINT32 high;
-} LINUX_ATAG_SERIALNR;
-
-typedef struct {
- UINT32 rev;
-} LINUX_ATAG_REVISION;
-
-typedef struct {
- UINT16 lfb_width;
- UINT16 lfb_height;
- UINT16 lfb_depth;
- UINT16 lfb_linelength;
- UINT32 lfb_base;
- UINT32 lfb_size;
- UINT8 red_size;
- UINT8 red_pos;
- UINT8 green_size;
- UINT8 green_pos;
- UINT8 blue_size;
- UINT8 blue_pos;
- UINT8 rsvd_size;
- UINT8 rsvd_pos;
-} LINUX_ATAG_VIDEOLFB;
-
-typedef struct {
- CHAR8 cmdline[1];
-} LINUX_ATAG_CMDLINE;
-
-typedef struct {
- LINUX_ATAG_HEADER header;
- union {
- LINUX_ATAG_CORE core_tag;
- LINUX_ATAG_MEM mem_tag;
- LINUX_ATAG_VIDEOTEXT videotext_tag;
- LINUX_ATAG_RAMDISK ramdisk_tag;
- LINUX_ATAG_INITRD2 initrd2_tag;
- LINUX_ATAG_SERIALNR serialnr_tag;
- LINUX_ATAG_REVISION revision_tag;
- LINUX_ATAG_VIDEOLFB videolfb_tag;
- LINUX_ATAG_CMDLINE cmdline_tag;
- } body;
-} LINUX_ATAG;
-
-EFI_STATUS
-PrepareAtagList (
- IN CONST CHAR8* CommandLineString,
- IN EFI_PHYSICAL_ADDRESS InitrdImage,
- IN UINTN InitrdImageSize,
- OUT EFI_PHYSICAL_ADDRESS *AtagBase,
- OUT UINT32 *AtagSize
- );
-
-EFI_STATUS
-PrepareFdt (
- IN CONST CHAR8* CommandLineArguments,
- IN EFI_PHYSICAL_ADDRESS InitrdImage,
- IN UINTN InitrdImageSize,
- IN OUT EFI_PHYSICAL_ADDRESS *FdtBlobBase,
- IN OUT UINTN *FdtBlobSize
- );
-
-#endif
diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index 76a45e0..9639f14 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -39,6 +39,9 @@
EmbeddedPkg/EmbeddedPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec

+[Guids]
+ gFdtTableGuid
+
[LibraryClasses]
BdsLib
TimerLib
@@ -49,6 +52,7 @@
DebugLib
PrintLib
BaseLib
+ FdtLib
NetLib

[Guids]
diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c
index bb218f8..342d441 100644
--- a/ArmPlatformPkg/Bds/BootOption.c
+++ b/ArmPlatformPkg/Bds/BootOption.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -23,10 +23,6 @@ BootOptionStart (
EFI_STATUS Status;
UINT32 LoaderType;
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
- ARM_BDS_LINUX_ARGUMENTS* LinuxArguments;
- UINTN CmdLineSize;
- UINTN InitrdSize;
- EFI_DEVICE_PATH* Initrd;
UINT16 LoadOptionIndexSize;

if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
@@ -42,34 +38,9 @@ BootOptionStart (

Status = BdsStartEfiApplication (gImageHandle, BootOption->FilePathList, 0, NULL);
} else if (LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) {
- LinuxArguments = &(OptionalData->Arguments.LinuxArguments);
- CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
- InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);
-
- if (InitrdSize > 0) {
- Initrd = GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize));
- } else {
- Initrd = NULL;
- }
-
- Status = BdsBootLinuxAtag (BootOption->FilePathList,
- Initrd, // Initrd
- (CHAR8*)(LinuxArguments + 1)); // CmdLine
+ ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
} else if (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT) {
- LinuxArguments = &(OptionalData->Arguments.LinuxArguments);
- CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
- InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);
-
- if (InitrdSize > 0) {
- Initrd = GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize));
- } else {
- Initrd = NULL;
- }
- Status = BdsBootLinuxFdt (
- BootOption->FilePathList,
- Initrd,
- (CHAR8*)(LinuxArguments + 1)
- );
+ ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
}
} else {
// Connect all the drivers if the EFI Application is not a EFI OS Loader
--
2.1.1
Olivier Martin
2015-07-13 16:36:49 UTC
Permalink
Since the embedded Linux Loader has been removed from BdsLib
there is no more Linux specific boot option.
All the boot options are now expected to be arguments for
EFI applications.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <***@arm.com>
Reviewed-by: Ronald Cron <***@arm.com>
---
ArmPkg/ArmPkg.dec | 1 -
ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc | 1 -
ArmPlatformPkg/ArmPlatformPkg.dec | 6 -
.../ArmRealViewEbPkg/ArmRealViewEb.dsc.inc | 1 -
.../ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc | 3 -
.../ArmVExpressPkg/ArmVExpress-CTA9x4.dsc | 3 -
.../ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc | 2 -
.../ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc | 3 -
.../ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc | 3 -
.../ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc | 3 -
.../ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc | 1 -
.../ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc | 1 -
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc | 3 -
ArmPlatformPkg/Bds/Bds.c | 36 +--
ArmPlatformPkg/Bds/Bds.inf | 7 +-
ArmPlatformPkg/Bds/BdsInternal.h | 45 ---
ArmPlatformPkg/Bds/BootMenu.c | 358 ++++-----------------
ArmPlatformPkg/Bds/BootOption.c | 100 ++----
ArmPlatformPkg/Bds/BootOptionSupport.c | 111 -------
BeagleBoardPkg/BeagleBoardPkg.dsc | 7 -
20 files changed, 93 insertions(+), 602 deletions(-)

diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index b30de91..da0c8a9 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -115,7 +115,6 @@
#
# BdsLib
#
- gArmTokenSpaceGuid.PcdArmMachineType|0|UINT32|0x0000001E
# The compressed Linux kernel is expected to be under 128MB from the beginning of the System Memory
gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset|0x08000000|UINT32|0x0000001F
# Maximum file size for TFTP servers that do not support 'tsize' extension
diff --git a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
index b5b959a..9860cf0 100644
--- a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
+++ b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
@@ -151,7 +151,6 @@

# Support the Linux EFI stub by default
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"console=ttyAMA0,115200 earlycon=pl011,0x7ff80000 root=/dev/sda1 rootwait verbose debug"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|0

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N,1)/VenPcAnsi();VenHw(CE660500-824D-11E0-AC72-0002A5D5C51B)"
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index cd67aee..be0919b 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -129,13 +129,7 @@
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"ARM Platform"|VOID*|0x00000019
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Default Boot Device"|VOID*|0x0000000C
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L""|VOID*|0x0000000D
- gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L""|VOID*|0x0000000E
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L""|VOID*|0x000000F
- # PcdDefaultBootType define the type of the binary pointed by PcdDefaultBootDevicePath:
- # - 0 = an EFI application
- # - 1 = a Linux kernel with ATAG support
- # - 2 = a Linux kernel with FDT support
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|0|UINT32|0x00000010

gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L""|VOID*|0x0000001B
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L""|VOID*|0x0000001C
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
index 6232791..9445ce2 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
@@ -316,7 +316,6 @@
#
# ARM OS Loader
#
- gArmTokenSpaceGuid.PcdArmMachineType|827
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(14801114-DA6A-4113-985B-DC876337A15E)/LinuxLoader.efi"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage-RTSM -a 827 -c \"console=ttyAMA0,38400n8\""
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
index 3b693c2..50bb556 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
@@ -181,12 +181,9 @@
#
# ARM OS Loader
#
- # Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NorFlash"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400 earlyprintk debug verbose"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
# PL111 - CLCD
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
index baa5478..18cc978 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
@@ -180,11 +180,8 @@
#
# ARM OS Loader
#
- # Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"NorFlash"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(1F15DA3C-37FF-4070-B471-BB4AF12A724A)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
index bfdc96b..1b6134f 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
@@ -177,8 +177,6 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/filesystem.cpio.gz"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 loglevel=9"
- # Use EFI Stub
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|0

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
index fb42f34..3896166 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
@@ -157,11 +157,8 @@
#
# ARM OS Loader
#
- # Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
index 09dc1db..acfe164 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
@@ -159,11 +159,8 @@
#
# ARM OS Loader
#
- # Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
index 2fe9e58..4bcdc8c 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
@@ -160,12 +160,9 @@
#
# ARM OS Loader
#
- # Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"Fv(272E583C-B951-433F-AF42-A9C6862AF002)/LinuxLoader.efi"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage -c \"console=ttyAMA0,38400n8\""
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
index 9129288..c956897 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
@@ -126,7 +126,6 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SemiHosting"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"root=/dev/vda2 rw console=ttyAMA0 earlyprintk=pl011,0x1c090000 maxcpus=4 debug user_debug=31 loglevel=9"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc
index 280fb72..4880591 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc
@@ -155,7 +155,6 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SemiHosting"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"root=/dev/mmcblk0p2 console=ttyAMA0 earlyprintk=pl011,0x1c090000 debug user_debug=31 loglevel=9"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
index 3d6537a..ad804ab 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -380,11 +380,8 @@
#
# ARM OS Loader
#
- # Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2272
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from NorFlash"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/Image"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1

# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(CE660500-824D-11E0-AC72-0002A5D5C51B)"
diff --git a/ArmPlatformPkg/Bds/Bds.c b/ArmPlatformPkg/Bds/Bds.c
index 1fab439..3ee866c 100644
--- a/ArmPlatformPkg/Bds/Bds.c
+++ b/ArmPlatformPkg/Bds/Bds.c
@@ -220,12 +220,6 @@ DefineDefaultBootEntries (
EFI_STATUS Status;
EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol;
EFI_DEVICE_PATH* BootDevicePath;
- UINT8* OptionalData;
- UINTN OptionalDataSize;
- ARM_BDS_LOADER_ARGUMENTS* BootArguments;
- ARM_BDS_LOADER_TYPE BootType;
- EFI_DEVICE_PATH* InitrdPath;
- UINTN InitrdSize;
UINTN CmdLineSize;
UINTN CmdLineAsciiSize;
CHAR16* DefaultBootArgument;
@@ -269,8 +263,6 @@ DefineDefaultBootEntries (

// Create the entry is the Default values are correct
if (BootDevicePath != NULL) {
- BootType = (ARM_BDS_LOADER_TYPE)PcdGet32 (PcdDefaultBootType);
-
// We do not support NULL pointer
ASSERT (PcdGetPtr (PcdDefaultBootArgument) != NULL);

@@ -308,33 +300,11 @@ DefineDefaultBootEntries (
AsciiStrToUnicodeStr (AsciiDefaultBootArgument, DefaultBootArgument);
}

- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- InitrdPath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootInitrdPath));
- InitrdSize = GetDevicePathSize (InitrdPath);
-
- OptionalDataSize = sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineAsciiSize + InitrdSize;
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (OptionalDataSize);
- if (BootArguments == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- BootArguments->LinuxArguments.CmdLineSize = CmdLineAsciiSize;
- BootArguments->LinuxArguments.InitrdSize = InitrdSize;
-
- CopyMem ((VOID*)(BootArguments + 1), AsciiDefaultBootArgument, CmdLineAsciiSize);
- CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineAsciiSize), InitrdPath, InitrdSize);
-
- OptionalData = (UINT8*)BootArguments;
- } else {
- OptionalData = (UINT8*)DefaultBootArgument;
- OptionalDataSize = CmdLineSize;
- }
-
BootOptionCreate (LOAD_OPTION_ACTIVE | LOAD_OPTION_CATEGORY_BOOT,
- (CHAR16*)PcdGetPtr(PcdDefaultBootDescription),
+ (CHAR16*)PcdGetPtr (PcdDefaultBootDescription),
BootDevicePath,
- BootType,
- OptionalData,
- OptionalDataSize,
+ (UINT8 *)DefaultBootArgument, // OptionalData
+ CmdLineSize, // OptionalDataSize
&BdsLoadOption
);
FreePool (BdsLoadOption);
diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index 9639f14..3b6ffc3 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -24,7 +24,7 @@

ENTRY_POINT = BdsInitialize

-[Sources.common]
+[Sources]
Bds.c
BdsHelper.c
BootMenu.c
@@ -44,12 +44,11 @@

[LibraryClasses]
BdsLib
- TimerLib
- PerformanceLib
UefiBootServicesTableLib
DxeServicesTableLib
UefiDriverEntryPoint
DebugLib
+ PerformanceLib
PrintLib
BaseLib
FdtLib
@@ -77,9 +76,7 @@
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath
- gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths
diff --git a/ArmPlatformPkg/Bds/BdsInternal.h b/ArmPlatformPkg/Bds/BdsInternal.h
index 1cb154e..fe4fd79 100644
--- a/ArmPlatformPkg/Bds/BdsInternal.h
+++ b/ArmPlatformPkg/Bds/BdsInternal.h
@@ -38,46 +38,10 @@
#define BOOT_DEVICE_OPTION_MAX 300
#define BOOT_DEVICE_ADDRESS_MAX (sizeof(L"0x0000000000000000"))

-#define ARM_BDS_OPTIONAL_DATA_SIGNATURE SIGNATURE_32('a', 'b', 'o', 'd')
-
-#define IS_ARM_BDS_BOOTENTRY(ptr) \
- (((ptr)->OptionalData != NULL) && \
- (ReadUnaligned32 ((CONST UINT32*)&((ARM_BDS_LOADER_OPTIONAL_DATA*)((ptr)->OptionalData))->Header.Signature) \
- == ARM_BDS_OPTIONAL_DATA_SIGNATURE))
-
#define UPDATE_BOOT_ENTRY L"Update entry: "
#define DELETE_BOOT_ENTRY L"Delete entry: "
#define MOVE_BOOT_ENTRY L"Move entry: "

-typedef enum {
- BDS_LOADER_EFI_APPLICATION = 0,
- BDS_LOADER_KERNEL_LINUX_ATAG,
- BDS_LOADER_KERNEL_LINUX_FDT,
-} ARM_BDS_LOADER_TYPE;
-
-typedef struct {
- UINT16 CmdLineSize;
- UINT16 InitrdSize;
-
- // These following fields have variable length and are packed:
- //CHAR8 *CmdLine;
- //EFI_DEVICE_PATH_PROTOCOL *InitrdPathList;
-} ARM_BDS_LINUX_ARGUMENTS;
-
-typedef union {
- ARM_BDS_LINUX_ARGUMENTS LinuxArguments;
-} ARM_BDS_LOADER_ARGUMENTS;
-
-typedef struct {
- UINT32 Signature;
- ARM_BDS_LOADER_TYPE LoaderType;
-} ARM_BDS_LOADER_OPTIONAL_DATA_HEADER;
-
-typedef struct {
- ARM_BDS_LOADER_OPTIONAL_DATA_HEADER Header;
- ARM_BDS_LOADER_ARGUMENTS Arguments;
-} ARM_BDS_LOADER_OPTIONAL_DATA;
-
typedef struct {
LIST_ENTRY Link;
BDS_LOAD_OPTION* BdsLoadOption;
@@ -230,7 +194,6 @@ BootOptionCreate (
IN UINT32 Attributes,
IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
IN UINT8* OptionalData,
IN UINTN OptionalDataSize,
OUT BDS_LOAD_OPTION** BdsLoadOption
@@ -242,7 +205,6 @@ BootOptionUpdate (
IN UINT32 Attributes,
IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
IN UINT8* OptionalData,
IN UINTN OptionalDataSize
);
@@ -253,13 +215,6 @@ BootOptionDelete (
);

EFI_STATUS
-BootDeviceGetType (
- IN EFI_DEVICE_PATH* DevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- );
-
-EFI_STATUS
BootMenuMain (
VOID
);
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c
index a304cc4..af7f1f1 100644
--- a/ArmPlatformPkg/Bds/BootMenu.c
+++ b/ArmPlatformPkg/Bds/BootMenu.c
@@ -54,8 +54,6 @@ DisplayBootOptions (
DEBUG_CODE_BEGIN ();
CHAR16* DevicePathTxt;
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
- ARM_BDS_LOADER_TYPE LoaderType;
- ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;

Status = gBS->LocateProtocol (
&gEfiDevicePathToTextProtocolGuid,
@@ -70,20 +68,11 @@ DisplayBootOptions (
);
Print (L"\t- %s\n", DevicePathTxt);

- OptionalData = BdsLoadOption->OptionalData;
- if (IS_ARM_BDS_BOOTENTRY (BdsLoadOption)) {
- LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
- if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) ||
- (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT ) ) {
- Print (L"\t- Arguments: %a\n", &OptionalData->Arguments.LinuxArguments + 1);
- }
- } else if (OptionalData != NULL) {
- if (IsPrintableString (OptionalData, &IsUnicode)) {
- if (IsUnicode) {
- Print (L"\t- Arguments: %s\n", OptionalData);
- } else {
- AsciiPrint ("\t- Arguments: %a\n", OptionalData);
- }
+ if (IsPrintableString (BdsLoadOption->OptionalData, &IsUnicode)) {
+ if (IsUnicode) {
+ Print (L"\t- Arguments: %s\n", BdsLoadOption->OptionalData);
+ } else {
+ AsciiPrint ("\t- Arguments: %a\n", BdsLoadOption->OptionalData);
}
}

@@ -272,20 +261,12 @@ BootMenuAddBootOption (
{
EFI_STATUS Status;
BDS_SUPPORTED_DEVICE* SupportedBootDevice;
- ARM_BDS_LOADER_ARGUMENTS* BootArguments;
CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];
- CHAR8 AsciiCmdLine[BOOT_DEVICE_OPTION_MAX];
CHAR16 CmdLine[BOOT_DEVICE_OPTION_MAX];
UINT32 Attributes;
- ARM_BDS_LOADER_TYPE BootType;
BDS_LOAD_OPTION_ENTRY *BdsLoadOptionEntry;
EFI_DEVICE_PATH *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePathNodes;
- EFI_DEVICE_PATH_PROTOCOL *InitrdPathNodes;
- EFI_DEVICE_PATH_PROTOCOL *InitrdPath;
- UINTN CmdLineSize;
- BOOLEAN InitrdSupport;
- UINTN InitrdSize;
UINT8* OptionalData;
UINTN OptionalDataSize;

@@ -312,79 +293,15 @@ BootMenuAddBootOption (
goto EXIT;
}

- if (SupportedBootDevice->Support->RequestBootType) {
- Status = BootDeviceGetType (DevicePath, &BootType, &Attributes);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
- } else {
- BootType = BDS_LOADER_EFI_APPLICATION;
+ Print (L"Arguments to pass to the EFI Application: ");
+ Status = GetHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
}

- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- Print(L"Add an initrd: ");
- Status = GetHIInputBoolean (&InitrdSupport);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
-
- if (InitrdSupport) {
- // Create the specific device path node
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes);
- if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd
- Status = EFI_ABORTED;
- goto EXIT;
- }
-
- if (InitrdPathNodes != NULL) {
- // Append the Device Path to the selected device path
- InitrdPath = AppendDevicePath (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);
- // Free the InitrdPathNodes created by Support->CreateDevicePathNode()
- FreePool (InitrdPathNodes);
-
- if (InitrdPath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto EXIT;
- }
- } else {
- InitrdPath = NULL;
- }
- } else {
- InitrdPath = NULL;
- }
-
- Print(L"Arguments to pass to the binary: ");
- Status = GetHIInputAscii (AsciiCmdLine, BOOT_DEVICE_OPTION_MAX);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto FREE_DEVICE_PATH;
- }
-
- CmdLineSize = AsciiStrSize (AsciiCmdLine);
- InitrdSize = GetDevicePathSize (InitrdPath);
-
- OptionalDataSize = sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize;
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (OptionalDataSize);
-
- BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
- BootArguments->LinuxArguments.InitrdSize = InitrdSize;
- CopyMem ((VOID*)(&BootArguments->LinuxArguments + 1), AsciiCmdLine, CmdLineSize);
- CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
-
- OptionalData = (UINT8*)BootArguments;
- } else {
- Print (L"Arguments to pass to the EFI Application: ");
- Status = GetHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);
- if (EFI_ERROR (Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
-
- OptionalData = (UINT8*)CmdLine;
- OptionalDataSize = StrSize (CmdLine);
- }
+ OptionalData = (UINT8*)CmdLine;
+ OptionalDataSize = StrSize (CmdLine);

Print(L"Description for this new Entry: ");
Status = GetHIInputStr (BootDescription, BOOT_DEVICE_DESCRIPTION_MAX);
@@ -395,7 +312,7 @@ BootMenuAddBootOption (

// Create new entry
BdsLoadOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool (sizeof(BDS_LOAD_OPTION_ENTRY));
- Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize, &BdsLoadOptionEntry->BdsLoadOption);
+ Status = BootOptionCreate (Attributes, BootDescription, DevicePath, OptionalData, OptionalDataSize, &BdsLoadOptionEntry->BdsLoadOption);
if (!EFI_ERROR(Status)) {
InsertTailList (BootOptionsList, &BdsLoadOptionEntry->Link);
}
@@ -446,20 +363,10 @@ BootMenuUpdateBootOption (
BDS_LOAD_OPTION_ENTRY *BootOptionEntry;
BDS_LOAD_OPTION *BootOption;
BDS_LOAD_OPTION_SUPPORT* DeviceSupport;
- ARM_BDS_LOADER_ARGUMENTS* BootArguments;
CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];
CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];
CHAR16 UnicodeCmdLine[BOOT_DEVICE_OPTION_MAX];
EFI_DEVICE_PATH *DevicePath;
- EFI_DEVICE_PATH *TempInitrdPath;
- ARM_BDS_LOADER_TYPE BootType;
- ARM_BDS_LOADER_OPTIONAL_DATA* LoaderOptionalData;
- ARM_BDS_LINUX_ARGUMENTS* LinuxArguments;
- EFI_DEVICE_PATH *InitrdPathNodes;
- EFI_DEVICE_PATH *InitrdPath;
- UINTN InitrdSize;
- UINTN CmdLineSize;
- BOOLEAN InitrdSupport;
UINT8* OptionalData;
UINTN OptionalDataSize;
BOOLEAN IsPrintable;
@@ -485,165 +392,67 @@ BootMenuUpdateBootOption (
goto EXIT;
}

- if (DeviceSupport->RequestBootType) {
- Status = BootDeviceGetType (DevicePath, &BootType, &BootOption->Attributes);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
- }
-
- LoaderOptionalData = BootOption->OptionalData;
- if (LoaderOptionalData != NULL) {
- BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&LoaderOptionalData->Header.LoaderType));
- } else {
- BootType = BDS_LOADER_EFI_APPLICATION;
- }
-
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- LinuxArguments = &LoaderOptionalData->Arguments.LinuxArguments;
-
- CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
-
- InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);
- if (InitrdSize > 0) {
- Print(L"Keep the initrd: ");
- } else {
- Print(L"Add an initrd: ");
- }
- Status = GetHIInputBoolean (&InitrdSupport);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
+ Print (L"Arguments to pass to the EFI Application: ");

- if (InitrdSupport) {
- if (InitrdSize > 0) {
- // Case we update the initrd device path
- Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize), L"initrd", &InitrdPath);
- if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {// EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd
- Status = EFI_ABORTED;
- goto EXIT;
- }
- InitrdSize = GetDevicePathSize (InitrdPath);
+ if (BootOption->OptionalDataSize > 0) {
+ IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);
+ if (IsPrintable) {
+ //
+ // The size in bytes of the string, final zero included, should
+ // be equal to or at least lower than "BootOption->OptionalDataSize"
+ // and the "IsPrintableString()" has already tested that the length
+ // in number of characters is smaller than BOOT_DEVICE_OPTION_MAX,
+ // final '\0' included. We can thus copy the string for editing
+ // using "CopyMem()". Furthermore, note that in the case of an Unicode
+ // string "StrnCpy()" and "StrCpy()" can not be used to copy the
+ // string because the data pointed to by "BootOption->OptionalData"
+ // is not necessarily 2-byte aligned.
+ //
+ if (IsUnicode) {
+ CopyMem (
+ UnicodeCmdLine, BootOption->OptionalData,
+ MIN (sizeof (UnicodeCmdLine),
+ BootOption->OptionalDataSize)
+ );
} else {
- // Case we create the initrd device path
-
- Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNodes);
- if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd
- Status = EFI_ABORTED;
- goto EXIT;
- }
-
- if (InitrdPathNodes != NULL) {
- // Duplicate Linux kernel Device Path
- TempInitrdPath = DuplicateDevicePath (BootOption->FilePathList);
- // Replace Linux kernel Node by EndNode
- SetDevicePathEndNode (GetLastDevicePathNode (TempInitrdPath));
- // Append the Device Path to the selected device path
- InitrdPath = AppendDevicePath (TempInitrdPath, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);
- FreePool (TempInitrdPath);
- // Free the InitrdPathNodes created by Support->CreateDevicePathNode()
- FreePool (InitrdPathNodes);
- if (InitrdPath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto EXIT;
- }
- InitrdSize = GetDevicePathSize (InitrdPath);
- } else {
- InitrdPath = NULL;
- }
+ CopyMem (
+ CmdLine, BootOption->OptionalData,
+ MIN (sizeof (CmdLine),
+ BootOption->OptionalDataSize)
+ );
}
- } else {
- InitrdSize = 0;
- }
-
- Print(L"Arguments to pass to the binary: ");
- if (CmdLineSize > 0) {
- AsciiStrnCpy (CmdLine, (CONST CHAR8*)(LinuxArguments + 1), sizeof (CmdLine));
- CmdLine[sizeof (CmdLine) - 1] = '\0';
- } else {
- CmdLine[0] = '\0';
}
- Status = EditHIInputAscii (CmdLine, BOOT_DEVICE_OPTION_MAX);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto FREE_DEVICE_PATH;
- }
-
- CmdLineSize = AsciiStrSize (CmdLine);
-
- OptionalDataSize = sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize;
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (OptionalDataSize);
- BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
- BootArguments->LinuxArguments.InitrdSize = InitrdSize;
- CopyMem (&BootArguments->LinuxArguments + 1, CmdLine, CmdLineSize);
- CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
-
- OptionalData = (UINT8*)BootArguments;
} else {
- Print (L"Arguments to pass to the EFI Application: ");
+ UnicodeCmdLine[0] = L'\0';
+ IsPrintable = TRUE;
+ IsUnicode = TRUE;
+ }

- if (BootOption->OptionalDataSize > 0) {
- IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);
- if (IsPrintable) {
- //
- // The size in bytes of the string, final zero included, should
- // be equal to or at least lower than "BootOption->OptionalDataSize"
- // and the "IsPrintableString()" has already tested that the length
- // in number of characters is smaller than BOOT_DEVICE_OPTION_MAX,
- // final '\0' included. We can thus copy the string for editing
- // using "CopyMem()". Furthermore, note that in the case of an Unicode
- // string "StrnCpy()" and "StrCpy()" can not be used to copy the
- // string because the data pointed to by "BootOption->OptionalData"
- // is not necessarily 2-byte aligned.
- //
- if (IsUnicode) {
- CopyMem (
- UnicodeCmdLine, BootOption->OptionalData,
- MIN (sizeof (UnicodeCmdLine),
- BootOption->OptionalDataSize)
- );
- } else {
- CopyMem (
- CmdLine, BootOption->OptionalData,
- MIN (sizeof (CmdLine),
- BootOption->OptionalDataSize)
- );
- }
+ // We do not request arguments for OptionalData that cannot be printed
+ if (IsPrintable) {
+ if (IsUnicode) {
+ Status = EditHIInputStr (UnicodeCmdLine, BOOT_DEVICE_OPTION_MAX);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto FREE_DEVICE_PATH;
}
- } else {
- UnicodeCmdLine[0] = L'\0';
- IsPrintable = TRUE;
- IsUnicode = TRUE;
- }
-
- // We do not request arguments for OptionalData that cannot be printed
- if (IsPrintable) {
- if (IsUnicode) {
- Status = EditHIInputStr (UnicodeCmdLine, BOOT_DEVICE_OPTION_MAX);
- if (EFI_ERROR (Status)) {
- Status = EFI_ABORTED;
- goto FREE_DEVICE_PATH;
- }
-
- OptionalData = (UINT8*)UnicodeCmdLine;
- OptionalDataSize = StrSize (UnicodeCmdLine);
- } else {
- Status = EditHIInputAscii (CmdLine, BOOT_DEVICE_OPTION_MAX);
- if (EFI_ERROR (Status)) {
- Status = EFI_ABORTED;
- goto FREE_DEVICE_PATH;
- }

- OptionalData = (UINT8*)CmdLine;
- OptionalDataSize = AsciiStrSize (CmdLine);
- }
+ OptionalData = (UINT8*)UnicodeCmdLine;
+ OptionalDataSize = StrSize (UnicodeCmdLine);
} else {
- // We keep the former OptionalData
- OptionalData = BootOption->OptionalData;
- OptionalDataSize = BootOption->OptionalDataSize;
+ Status = EditHIInputAscii (CmdLine, BOOT_DEVICE_OPTION_MAX);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
+ goto FREE_DEVICE_PATH;
+ }
+
+ OptionalData = (UINT8*)CmdLine;
+ OptionalDataSize = AsciiStrSize (CmdLine);
}
+ } else {
+ // We keep the former OptionalData
+ OptionalData = BootOption->OptionalData;
+ OptionalDataSize = BootOption->OptionalDataSize;
}

Print(L"Description for this new Entry: ");
@@ -655,7 +464,7 @@ BootMenuUpdateBootOption (
}

// Update the entry
- Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize);
+ Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, OptionalData, OptionalDataSize);

FREE_DEVICE_PATH:
FreePool (DevicePath);
@@ -1139,9 +948,6 @@ BootMenuMain (
DEBUG_CODE_BEGIN();
CHAR16* DevicePathTxt;
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
- ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
- UINTN CmdLineSize;
- ARM_BDS_LOADER_TYPE LoaderType;

Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
if (EFI_ERROR(Status)) {
@@ -1153,39 +959,7 @@ BootMenuMain (

Print(L"\t- %s\n",DevicePathTxt);

- // If it is a supported BootEntry then print its details
- if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
- OptionalData = BootOption->OptionalData;
- LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
- if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.InitrdSize) > 0) {
- CmdLineSize = ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize);
- DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (
- GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(&OptionalData->Arguments.LinuxArguments + 1) + CmdLineSize)), TRUE, TRUE);
- Print(L"\t- Initrd: %s\n", DevicePathTxt);
- }
- if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize) > 0) {
- Print(L"\t- Arguments: %a\n", (&OptionalData->Arguments.LinuxArguments + 1));
- }
- }
-
- switch (LoaderType) {
- case BDS_LOADER_EFI_APPLICATION:
- Print(L"\t- LoaderType: EFI Application\n");
- break;
-
- case BDS_LOADER_KERNEL_LINUX_ATAG:
- Print(L"\t- LoaderType: Linux kernel with ATAG support\n");
- break;
-
- case BDS_LOADER_KERNEL_LINUX_FDT:
- Print(L"\t- LoaderType: Linux kernel with FDT support\n");
- break;
-
- default:
- Print(L"\t- LoaderType: Not recognized (%d)\n", LoaderType);
- }
- } else if (BootOption->OptionalData != NULL) {
+ if (BootOption->OptionalData != NULL) {
if (IsPrintableString (BootOption->OptionalData, &IsUnicode)) {
if (IsUnicode) {
Print (L"\t- Arguments: %s\n", BootOption->OptionalData);
diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c
index 342d441..bdd02b4 100644
--- a/ArmPlatformPkg/Bds/BootOption.c
+++ b/ArmPlatformPkg/Bds/BootOption.c
@@ -20,48 +20,27 @@ BootOptionStart (
IN BDS_LOAD_OPTION *BootOption
)
{
- EFI_STATUS Status;
- UINT32 LoaderType;
- ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
- UINT16 LoadOptionIndexSize;
-
- if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
- Status = EFI_UNSUPPORTED;
- OptionalData = BootOption->OptionalData;
- LoaderType = ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
-
- if (LoaderType == BDS_LOADER_EFI_APPLICATION) {
- if ((BootOption->Attributes & LOAD_OPTION_CATEGORY) == LOAD_OPTION_CATEGORY_APP) {
- // Need to connect every drivers to ensure no dependencies are missing for the application
- BdsConnectAllDrivers ();
- }
+ EFI_STATUS Status;
+ UINT16 LoadOptionIndexSize;

- Status = BdsStartEfiApplication (gImageHandle, BootOption->FilePathList, 0, NULL);
- } else if (LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) {
- ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
- } else if (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT) {
- ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
- }
- } else {
- // Connect all the drivers if the EFI Application is not a EFI OS Loader
- if ((BootOption->Attributes & LOAD_OPTION_CATEGORY) == LOAD_OPTION_CATEGORY_APP) {
- BdsConnectAllDrivers ();
- }
+ // Connect all the drivers if the EFI Application is not a EFI OS Loader
+ if ((BootOption->Attributes & LOAD_OPTION_CATEGORY) == LOAD_OPTION_CATEGORY_APP) {
+ BdsConnectAllDrivers ();
+ }

- // Set BootCurrent variable
- LoadOptionIndexSize = sizeof(UINT16);
- gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- LoadOptionIndexSize, &(BootOption->LoadOptionIndex));
+ // Set BootCurrent variable
+ LoadOptionIndexSize = sizeof (UINT16);
+ gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ LoadOptionIndexSize, &(BootOption->LoadOptionIndex));

- Status = BdsStartEfiApplication (gImageHandle, BootOption->FilePathList, BootOption->OptionalDataSize, BootOption->OptionalData);
+ Status = BdsStartEfiApplication (gImageHandle, BootOption->FilePathList, BootOption->OptionalDataSize, BootOption->OptionalData);

- // Clear BootCurrent variable
- LoadOptionIndexSize = sizeof(UINT16);
- gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- 0, NULL);
- }
+ // Clear BootCurrent variable
+ LoadOptionIndexSize = sizeof (UINT16);
+ gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ 0, NULL);

return Status;
}
@@ -107,7 +86,6 @@ BootOptionSetFields (
IN UINT32 Attributes,
IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
IN UINT8* OptionalData,
IN UINTN OptionalDataSize
)
@@ -117,10 +95,6 @@ BootOptionSetFields (
UINTN BootDescriptionSize;
UINT16 FilePathListLength;
UINT8* EfiLoadOptionPtr;
- UINT8* InitrdPathListPtr;
- ARM_BDS_LINUX_ARGUMENTS* DestLinuxArguments;
- ARM_BDS_LINUX_ARGUMENTS* SrcLinuxArguments;
- ARM_BDS_LOADER_ARGUMENTS* BootArguments;

// If we are overwriting an existent Boot Option then we have to free previously allocated memory
if (BootOption->LoadOption) {
@@ -129,11 +103,6 @@ BootOptionSetFields (

BootDescriptionSize = StrSize (BootDescription);

- // Fixup the size in case of entry specific to ArmPlatformPkg/Bds
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- OptionalDataSize += sizeof(ARM_BDS_LOADER_OPTIONAL_DATA_HEADER);
- }
-
// Compute the size of the FilePath list
FilePathListLength = GetUnalignedDevicePathSize (DevicePath);

@@ -169,33 +138,10 @@ BootOptionSetFields (
// Optional Data fields, Do unaligned writes
BootOption->OptionalData = EfiLoadOptionPtr;

- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- // Write the header
- WriteUnaligned32 ((UINT32 *)EfiLoadOptionPtr, ARM_BDS_OPTIONAL_DATA_SIGNATURE);
- WriteUnaligned32 ((UINT32 *)(EfiLoadOptionPtr + 4), BootType);
-
- // OptionalData should have been initialized by the caller of this function
- ASSERT (OptionalData != NULL);
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)OptionalData;
- SrcLinuxArguments = &(BootArguments->LinuxArguments);
- DestLinuxArguments = &((ARM_BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments.LinuxArguments;
-
- WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->CmdLineSize), SrcLinuxArguments->CmdLineSize);
- WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->InitrdSize), SrcLinuxArguments->InitrdSize);
-
- if (SrcLinuxArguments->CmdLineSize > 0) {
- CopyMem ((VOID*)(DestLinuxArguments + 1), (VOID*)(SrcLinuxArguments + 1), SrcLinuxArguments->CmdLineSize);
- }
-
- if (SrcLinuxArguments->InitrdSize > 0) {
- InitrdPathListPtr = (UINT8*)((UINTN)(DestLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize);
- CopyMem (InitrdPathListPtr, (VOID*)((UINTN)(SrcLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize), SrcLinuxArguments->InitrdSize);
- }
- } else {
- if (OptionalData != NULL) {
- CopyMem (BootOption->OptionalData, OptionalData, OptionalDataSize);
- }
+ if (OptionalData != NULL) {
+ CopyMem (BootOption->OptionalData, OptionalData, OptionalDataSize);
}
+
BootOption->OptionalDataSize = OptionalDataSize;

// If this function is called at the creation of the Boot Device entry (not at the update) the
@@ -216,7 +162,6 @@ BootOptionCreate (
IN UINT32 Attributes,
IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
IN UINT8* OptionalData,
IN UINTN OptionalDataSize,
OUT BDS_LOAD_OPTION** BdsLoadOption
@@ -237,7 +182,7 @@ BootOptionCreate (
BootOptionEntry->BdsLoadOption = (BDS_LOAD_OPTION*)AllocateZeroPool (sizeof(BDS_LOAD_OPTION));

BootOption = BootOptionEntry->BdsLoadOption;
- BootOptionSetFields (BootOption, Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize);
+ BootOptionSetFields (BootOption, Attributes, BootDescription, DevicePath, OptionalData, OptionalDataSize);

//
// Set the related environment variables
@@ -290,7 +235,6 @@ BootOptionUpdate (
IN UINT32 Attributes,
IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
IN UINT8* OptionalData,
IN UINTN OptionalDataSize
)
@@ -299,7 +243,7 @@ BootOptionUpdate (
CHAR16 BootVariableName[9];

// Update the BDS Load Option structure
- BootOptionSetFields (BdsLoadOption, Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize);
+ BootOptionSetFields (BdsLoadOption, Attributes, BootDescription, DevicePath, OptionalData, OptionalDataSize);

// Update the related environment variables
UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BdsLoadOption->LoadOptionIndex);
diff --git a/ArmPlatformPkg/Bds/BootOptionSupport.c b/ArmPlatformPkg/Bds/BootOptionSupport.c
index 974f220..f50f13f 100644
--- a/ArmPlatformPkg/Bds/BootOptionSupport.c
+++ b/ArmPlatformPkg/Bds/BootOptionSupport.c
@@ -214,117 +214,6 @@ BootDeviceGetDeviceSupport (
}

EFI_STATUS
-BootDeviceGetType (
- IN EFI_DEVICE_PATH* DevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- )
-{
- EFI_STATUS Status;
- BOOLEAN IsEfiApp;
- BOOLEAN IsBootLoader;
- BOOLEAN HasFDTSupport;
- CHAR16* FileName;
- EFI_DEVICE_PATH* PrevDevicePathNode;
- EFI_DEVICE_PATH* DevicePathNode;
- EFI_PHYSICAL_ADDRESS Image;
- UINTN FileSize;
- EFI_IMAGE_DOS_HEADER* DosHeader;
- UINTN PeCoffHeaderOffset;
- EFI_IMAGE_NT_HEADERS32* NtHeader;
-
- //
- // Check if the last node of the device path is a FilePath node
- //
- PrevDevicePathNode = NULL;
- DevicePathNode = DevicePath;
- while ((DevicePathNode != NULL) && !IsDevicePathEnd (DevicePathNode)) {
- PrevDevicePathNode = DevicePathNode;
- DevicePathNode = NextDevicePathNode (DevicePathNode);
- }
-
- if ((PrevDevicePathNode != NULL) &&
- (PrevDevicePathNode->Type == MEDIA_DEVICE_PATH) &&
- (PrevDevicePathNode->SubType == MEDIA_FILEPATH_DP))
- {
- FileName = ((FILEPATH_DEVICE_PATH*)PrevDevicePathNode)->PathName;
- } else {
- FileName = NULL;
- }
-
- if (FileName == NULL) {
- Print(L"Is an EFI Application? ");
- Status = GetHIInputBoolean (&IsEfiApp);
- if (EFI_ERROR(Status)) {
- return EFI_ABORTED;
- }
- } else if (HasFilePathEfiExtension(FileName)) {
- IsEfiApp = TRUE;
- } else {
- // Check if the file exist
- Status = BdsLoadImage (DevicePath, AllocateAnyPages, &Image, &FileSize);
- if (!EFI_ERROR (Status)) {
-
- DosHeader = (EFI_IMAGE_DOS_HEADER *)(UINTN) Image;
- if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
- //
- // DOS image header is present,
- // so read the PE header after the DOS image header.
- //
- PeCoffHeaderOffset = DosHeader->e_lfanew;
- } else {
- PeCoffHeaderOffset = 0;
- }
-
- //
- // Check PE/COFF image.
- //
- NtHeader = (EFI_IMAGE_NT_HEADERS32 *)(UINTN) (Image + PeCoffHeaderOffset);
- if (NtHeader->Signature != EFI_IMAGE_NT_SIGNATURE) {
- IsEfiApp = FALSE;
- } else {
- IsEfiApp = TRUE;
- }
-
- // Free memory
- gBS->FreePages (Image, EFI_SIZE_TO_PAGES(FileSize));
- } else {
- // If we did not manage to open it then ask for the type
- Print(L"Is an EFI Application? ");
- Status = GetHIInputBoolean (&IsEfiApp);
- if (EFI_ERROR(Status)) {
- return EFI_ABORTED;
- }
- }
- }
-
- if (IsEfiApp) {
- Print(L"Is your application an OS loader? ");
- Status = GetHIInputBoolean (&IsBootLoader);
- if (EFI_ERROR(Status)) {
- return EFI_ABORTED;
- }
- if (!IsBootLoader) {
- *Attributes |= LOAD_OPTION_CATEGORY_APP;
- }
- *BootType = BDS_LOADER_EFI_APPLICATION;
- } else {
- Print(L"Has FDT support? ");
- Status = GetHIInputBoolean (&HasFDTSupport);
- if (EFI_ERROR(Status)) {
- return EFI_ABORTED;
- }
- if (HasFDTSupport) {
- *BootType = BDS_LOADER_KERNEL_LINUX_FDT;
- } else {
- *BootType = BDS_LOADER_KERNEL_LINUX_ATAG;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
BdsLoadOptionFileSystemList (
IN OUT LIST_ENTRY* BdsLoadOptionList
)
diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc b/BeagleBoardPkg/BeagleBoardPkg.dsc
index 7aa6ce2..5338492 100644
--- a/BeagleBoardPkg/BeagleBoardPkg.dsc
+++ b/BeagleBoardPkg/BeagleBoardPkg.dsc
@@ -362,18 +362,11 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SD"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(B615F1F5-5088-43CD-809C-A16E52487D00)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=tty0 console=ttyS2,115200n8 root=UUID=a4af765b-c2b5-48f4-9564-7a4e9104c4f6 rootwait ro earlyprintk"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|10

gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N,1)/VenPcAnsi();VenHw(E68088EF-D1A4-4336-C1DB-4D3A204730A6)"
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N,1)/VenPcAnsi()"

- #
- # ARM OS Loader
- #
- # BeagleBoard machine type (OMAP3_BEAGLE = 1546) required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|1546
-
################################################################################
#
# Components Section - list of all EDK II Modules needed by this Platform
--
2.1.1
Loading...