mirror of https://github.com/acidanthera/audk.git
ArmPlatformPkg/Bds: Remove Linux specific boot path
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 <Olivier.Martin@arm.com> Reviewed-by: Ronald Cron <Ronald.Cron@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17970 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
c75d3eb6be
commit
8b129b7b39
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
);
|
||||
|
@ -252,13 +214,6 @@ BootOptionDelete (
|
|||
IN BDS_LOAD_OPTION *BootOption
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
BootDeviceGetType (
|
||||
IN EFI_DEVICE_PATH* DevicePath,
|
||||
OUT ARM_BDS_LOADER_TYPE *BootType,
|
||||
OUT UINT32 *Attributes
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
BootMenuMain (
|
||||
VOID
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
Print (L"Arguments to pass to the EFI Application: ");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
} 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: ");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// We do not request arguments for OptionalData that cannot be printed
|
||||
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) {
|
||||
Status = EditHIInputStr (UnicodeCmdLine, BOOT_DEVICE_OPTION_MAX);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_ABORTED;
|
||||
goto FREE_DEVICE_PATH;
|
||||
}
|
||||
|
||||
OptionalData = (UINT8*)UnicodeCmdLine;
|
||||
OptionalDataSize = StrSize (UnicodeCmdLine);
|
||||
CopyMem (
|
||||
UnicodeCmdLine, BootOption->OptionalData,
|
||||
MIN (sizeof (UnicodeCmdLine),
|
||||
BootOption->OptionalDataSize)
|
||||
);
|
||||
} 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);
|
||||
CopyMem (
|
||||
CmdLine, BootOption->OptionalData,
|
||||
MIN (sizeof (CmdLine),
|
||||
BootOption->OptionalDataSize)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// We keep the former OptionalData
|
||||
OptionalData = BootOption->OptionalData;
|
||||
OptionalDataSize = BootOption->OptionalDataSize;
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
} 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);
|
||||
|
|
|
@ -20,49 +20,28 @@ BootOptionStart (
|
|||
IN BDS_LOAD_OPTION *BootOption
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 LoaderType;
|
||||
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
|
||||
UINT16 LoadOptionIndexSize;
|
||||
EFI_STATUS Status;
|
||||
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 ();
|
||||
}
|
||||
|
||||
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 ();
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// Clear BootCurrent variable
|
||||
LoadOptionIndexSize = sizeof(UINT16);
|
||||
gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
0, NULL);
|
||||
// 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));
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
|
|
@ -213,117 +213,6 @@ BootDeviceGetDeviceSupport (
|
|||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue