summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei.xu <xuwei5@huawei.com>2014-05-28 16:41:11 +0800
committerwei.xu <xuwei5@huawei.com>2014-05-28 16:41:11 +0800
commit31f2d7fb499483f360c0494dee8fdf9fb7e29a3f (patch)
tree4c13687c84f45377ed2e936c7d1a9d0a2663560e
parent7464c31baabb3a6bc57037c2d412a4ea224ea22b (diff)
merge Linaro UEFI Bds part
-rw-r--r--HisiPkg/D01BoardPkg/Bds/Bds.c192
-rw-r--r--HisiPkg/D01BoardPkg/Bds/Bds.inf13
-rw-r--r--HisiPkg/D01BoardPkg/Bds/BdsHelper.c126
-rw-r--r--HisiPkg/D01BoardPkg/Bds/BdsInternal.h168
-rw-r--r--HisiPkg/D01BoardPkg/Bds/BootMenu.c802
-rw-r--r--HisiPkg/D01BoardPkg/Bds/BootOption.c311
-rw-r--r--HisiPkg/D01BoardPkg/Bds/BootOptionSupport.c538
7 files changed, 1127 insertions, 1023 deletions
diff --git a/HisiPkg/D01BoardPkg/Bds/Bds.c b/HisiPkg/D01BoardPkg/Bds/Bds.c
index 8005b0924..b994f11c2 100644
--- a/HisiPkg/D01BoardPkg/Bds/Bds.c
+++ b/HisiPkg/D01BoardPkg/Bds/Bds.c
@@ -296,19 +296,22 @@ DefineDefaultBootEntries (
{
BDS_LOAD_OPTION* BdsLoadOption;
UINTN Size;
- EFI_STATUS Status;
- EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol;
- EFI_DEVICE_PATH* BootDevicePath;
- ARM_BDS_LOADER_ARGUMENTS* BootArguments;
- ARM_BDS_LOADER_TYPE BootType;
- EFI_DEVICE_PATH* InitrdPath;
- EFI_DEVICE_PATH* FdtLocalPath;
- UINTN CmdLineSize;
- UINTN InitrdSize;
- UINTN FdtLocalSize;
-
- //
- // If Boot Order does not exist then create a default entry
+ 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;
+ CHAR8* AsciiDefaultBootArgument;
+
+ //
+ // If Boot Order does not exist then create a default entry
//
Size = 0;
Status = gRT->GetVariable (L"BootOrder", &gEfiGlobalVariableGuid, NULL, &Size, NULL);
@@ -333,69 +336,91 @@ DefineDefaultBootEntries (
Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
ASSERT_EFI_ERROR(Status);
DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (BootDevicePath, TRUE, TRUE);
-
- ASSERT (StrCmp ((CHAR16*)PcdGetPtr(PcdDefaultBootDevicePath), DevicePathTxt) == 0);
-
- if (DevicePathTxt != NULL){
- FreePool (DevicePathTxt);
- }
- DEBUG_CODE_END();
-
- // Create the entry is the Default values are correct
- if (BootDevicePath != NULL) {
- BootType = (ARM_BDS_LOADER_TYPE)PcdGet32 (PcdDefaultBootType);
-
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
- CmdLineSize = AsciiStrSize ((CHAR8*)PcdGetPtr(PcdDefaultBootArgument));
- InitrdPath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootInitrdPath));
- if (InitrdPath != NULL) {
- InitrdSize = GetDevicePathSize (InitrdPath);
- } else {
- InitrdSize = 0;
- }
- if (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT) {
- FdtLocalPath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultFdtLocalDevicePath));
- FdtLocalSize = GetDevicePathSize (FdtLocalPath);
- } else {
- FdtLocalPath = NULL;
- FdtLocalSize = 0;
- }
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize + FdtLocalSize);
- if ( BootArguments != NULL ) {
- BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
- BootArguments->LinuxArguments.InitrdSize = InitrdSize;
- BootArguments->LinuxArguments.FdtLocalSize = FdtLocalSize;
+ ASSERT (StrCmp ((CHAR16*)PcdGetPtr(PcdDefaultBootDevicePath), DevicePathTxt) == 0);
- CopyMem ((VOID*)(BootArguments + 1), (CHAR8*)PcdGetPtr(PcdDefaultBootArgument), CmdLineSize);
- CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
- CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineSize + InitrdSize), FdtLocalPath, FdtLocalSize);
- }
- if (FdtLocalPath != NULL ) {
- FreePool (FdtLocalPath);
- }
- if (InitrdPath != NULL ) {
- FreePool (InitrdPath);
- }
- } else {
- BootArguments = NULL;
- }
-
- BootOptionCreate (LOAD_OPTION_ACTIVE | LOAD_OPTION_CATEGORY_BOOT,
- (CHAR16*)PcdGetPtr(PcdDefaultBootDescription),
- BootDevicePath,
- BootType,
- BootArguments,
- &BdsLoadOption
- );
- if (BdsLoadOption != NULL){
- FreePool (BdsLoadOption);
- }
- if (BootDevicePath != NULL){
- FreePool (BootDevicePath);
- }
- } else {
- Status = EFI_UNSUPPORTED;
+ FreePool (DevicePathTxt);
+ DEBUG_CODE_END();
+
+ // 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);
+
+ //
+ // Logic to handle ASCII or Unicode default parameters
+ //
+ if (*(CHAR8*)PcdGetPtr (PcdDefaultBootArgument) == '\0') {
+ CmdLineSize = 0;
+ CmdLineAsciiSize = 0;
+ DefaultBootArgument = NULL;
+ AsciiDefaultBootArgument = NULL;
+ } else if (IsUnicodeString ((CHAR16*)PcdGetPtr (PcdDefaultBootArgument))) {
+ // The command line is a Unicode string
+ DefaultBootArgument = (CHAR16*)PcdGetPtr (PcdDefaultBootArgument);
+ CmdLineSize = StrSize (DefaultBootArgument);
+
+ // Initialize ASCII variables
+ CmdLineAsciiSize = CmdLineSize / 2;
+ AsciiDefaultBootArgument = AllocatePool (CmdLineAsciiSize);
+ if (AsciiDefaultBootArgument == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ UnicodeStrToAsciiStr ((CHAR16*)PcdGetPtr (PcdDefaultBootArgument), AsciiDefaultBootArgument);
+ } else {
+ // The command line is a ASCII string
+ AsciiDefaultBootArgument = (CHAR8*)PcdGetPtr (PcdDefaultBootArgument);
+ CmdLineAsciiSize = AsciiStrSize (AsciiDefaultBootArgument);
+
+ // Initialize ASCII variables
+ CmdLineSize = CmdLineAsciiSize * 2;
+ DefaultBootArgument = AllocatePool (CmdLineSize);
+ if (DefaultBootArgument == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ 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),
+ BootDevicePath,
+ BootType,
+ OptionalData,
+ OptionalDataSize,
+ &BdsLoadOption
+ );
+ FreePool (BdsLoadOption);
+
+ if (DefaultBootArgument == (CHAR16*)PcdGetPtr (PcdDefaultBootArgument)) {
+ FreePool (AsciiDefaultBootArgument);
+ } else if (DefaultBootArgument != NULL) {
+ FreePool (DefaultBootArgument);
+ }
+ } else {
+ Status = EFI_UNSUPPORTED;
}
}
@@ -418,14 +443,17 @@ StartDefaultBootOnTimeout (
CHAR16 BootVariableName[9];
EFI_STATUS Status;
EFI_INPUT_KEY Key;
-
- Size = sizeof(UINT16);
- Timeout = (UINT16)PcdGet16 (PcdPlatformBootTimeOut);
- TimeoutPtr = &Timeout;
- GetGlobalEnvironmentVariable (L"Timeout", &Timeout, &Size, (VOID**)&TimeoutPtr);
-
- if (Timeout != 0xFFFF) {
- if (Timeout > 0) {
+
+ Size = sizeof(UINT16);
+ Timeout = (UINT16)PcdGet16 (PcdPlatformBootTimeOut);
+ Status = GetGlobalEnvironmentVariable (L"Timeout", &Timeout, &Size, (VOID**)&TimeoutPtr);
+ if (!EFI_ERROR (Status)) {
+ Timeout = *TimeoutPtr;
+ FreePool (TimeoutPtr);
+ }
+
+ if (Timeout != 0xFFFF) {
+ if (Timeout > 0) {
// Create the waiting events (keystroke and 1sec timer)
gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &WaitList[0]);
gBS->SetTimer (WaitList[0], TimerPeriodic, EFI_SET_TIMER_TO_SECOND);
diff --git a/HisiPkg/D01BoardPkg/Bds/Bds.inf b/HisiPkg/D01BoardPkg/Bds/Bds.inf
index 195d0dcd6..98bba7536 100644
--- a/HisiPkg/D01BoardPkg/Bds/Bds.inf
+++ b/HisiPkg/D01BoardPkg/Bds/Bds.inf
@@ -72,13 +72,12 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath
gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType
- gArmPlatformTokenSpaceGuid.PcdFdtDevicePath
- gArmPlatformTokenSpaceGuid.PcdDefaultFdtLocalDevicePath
- gArmPlatformTokenSpaceGuid.PcdPlatformBootTimeOut
- gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths
- gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootType
+ gArmPlatformTokenSpaceGuid.PcdFdtDevicePath
+ gArmPlatformTokenSpaceGuid.PcdPlatformBootTimeOut
+ gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths
+ gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths
gHwTokenSpaceGuid.PcdNorFlashBase
[Depex]
diff --git a/HisiPkg/D01BoardPkg/Bds/BdsHelper.c b/HisiPkg/D01BoardPkg/Bds/BdsHelper.c
index 733864ad0..db912d8de 100644
--- a/HisiPkg/D01BoardPkg/Bds/BdsHelper.c
+++ b/HisiPkg/D01BoardPkg/Bds/BdsHelper.c
@@ -1,10 +1,9 @@
-/** @file
-*
-* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-* Copyright (c) Huawei Technologies Co., Ltd. 2013. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
+/** @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
*
@@ -185,15 +184,13 @@ GetHIInputBoolean (
{
CHAR16 CmdBoolean[2];
EFI_STATUS Status;
-
- while(1) {
- Print (L"[y/n] ");
- // Set MaxCmdLine to 3 to give space for carriage return (when the user
- // hits enter) and terminal '\0'.
- Status = GetHIInputStr (CmdBoolean, 3);
- if (EFI_ERROR(Status)) {
- return Status;
- } else if ((CmdBoolean[0] == L'y') || (CmdBoolean[0] == L'Y')) {
+
+ while(1) {
+ Print (L"[y/n] ");
+ Status = GetHIInputStr (CmdBoolean, 2);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ } else if ((CmdBoolean[0] == L'y') || (CmdBoolean[0] == L'Y')) {
if (Value) *Value = TRUE;
return EFI_SUCCESS;
} else if ((CmdBoolean[0] == L'n') || (CmdBoolean[0] == L'N')) {
@@ -323,6 +320,97 @@ GetAlignedDevicePath (
return DuplicateDevicePath (DevicePath);
} else {
return DevicePath;
- }
-}
-
+ }
+}
+
+BOOLEAN
+IsUnicodeString (
+ IN VOID* String
+ )
+{
+ // We do not support NULL pointer
+ ASSERT (String != NULL);
+
+ if (*(CHAR16*)String < 0x100) {
+ //Note: We could get issue if the string is an empty Ascii string...
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+/*
+ * Try to detect if the given string is an ASCII or Unicode string
+ *
+ * There are actually few limitation to this function but it is mainly to give
+ * a user friendly output.
+ *
+ * Some limitations:
+ * - it only supports unicode string that use ASCII character (< 0x100)
+ * - single character ASCII strings are interpreted as Unicode string
+ * - string cannot be longer than 2 x BOOT_DEVICE_OPTION_MAX (600 bytes)
+ *
+ * @param String Buffer that might contain a Unicode or Ascii string
+ * @param IsUnicode If not NULL this boolean value returns if the string is an
+ * ASCII or Unicode string.
+ */
+BOOLEAN
+IsPrintableString (
+ IN VOID* String,
+ OUT BOOLEAN *IsUnicode
+ )
+{
+ BOOLEAN UnicodeDetected;
+ BOOLEAN IsPrintable;
+ UINTN Index;
+ CHAR16 Character;
+
+ // We do not support NULL pointer
+ ASSERT (String != NULL);
+
+ // Test empty string
+ if (*(CHAR16*)String == L'\0') {
+ if (IsUnicode) {
+ *IsUnicode = TRUE;
+ }
+ return TRUE;
+ } else if (*(CHAR16*)String == '\0') {
+ if (IsUnicode) {
+ *IsUnicode = FALSE;
+ }
+ return TRUE;
+ }
+
+ // Limitation: if the string is an ASCII single character string. This comparison
+ // will assume it is a Unicode string.
+ if (*(CHAR16*)String < 0x100) {
+ UnicodeDetected = TRUE;
+ } else {
+ UnicodeDetected = FALSE;
+ }
+
+ IsPrintable = FALSE;
+ for (Index = 0; Index < BOOT_DEVICE_OPTION_MAX * 2; Index++) {
+ if (UnicodeDetected) {
+ Character = ((CHAR16*)String)[Index];
+ } else {
+ Character = ((CHAR8*)String)[Index];
+ }
+
+ if (Character == '\0') {
+ // End of the string
+ IsPrintable = TRUE;
+ break;
+ } else if ((Character < 0x20) || (Character > 0x7f)) {
+ // We only support the range of printable ASCII character
+ IsPrintable = FALSE;
+ break;
+ }
+ }
+
+ if (IsPrintable && IsUnicode) {
+ *IsUnicode = UnicodeDetected;
+ }
+
+ return IsPrintable;
+}
diff --git a/HisiPkg/D01BoardPkg/Bds/BdsInternal.h b/HisiPkg/D01BoardPkg/Bds/BdsInternal.h
index 050aa32cf..e8f6d1b0e 100644
--- a/HisiPkg/D01BoardPkg/Bds/BdsInternal.h
+++ b/HisiPkg/D01BoardPkg/Bds/BdsInternal.h
@@ -1,10 +1,9 @@
-/** @file
-*
-* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-* Copyright (c) Huawei Technologies Co., Ltd. 2013. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
+/** @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
*
@@ -35,41 +34,35 @@
#define BOOT_DEVICE_DESCRIPTION_MAX 100
#define BOOT_DEVICE_FILEPATH_MAX 100
-#define BOOT_DEVICE_OPTION_MAX 300
-#define BOOT_DEVICE_ADDRESS_MAX (sizeof(L"0x0000000000000000"))
-
-// Length of the buffer used to hold the user input for the main menu
-// This includes the NULL terminator
-// 1 chars + newline + NULL gives room for up to 9 boot device configs
-#define BOOT_OPTION_LEN 3
+#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) (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: "
-
-typedef enum {
- BDS_LOADER_EFI_APPLICATION = 0,
- BDS_LOADER_KERNEL_LINUX_ATAG,
- BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT,
- BDS_LOADER_KERNEL_LINUX_LOCAL_FDT,
-} ARM_BDS_LOADER_TYPE;
-
-typedef struct {
- UINT16 CmdLineSize;
- UINT16 InitrdSize;
-
- UINT16 FdtLocalSize;
+#define ARM_BDS_OPTIONAL_DATA_SIGNATURE SIGNATURE_32('a', 'b', 'o', 'd')
- // These following fields have variable length and are packed:
- //CHAR8 *CmdLine;
- //EFI_DEVICE_PATH_PROTOCOL *InitrdPathList;
- //EFI_DEVICE_PATH_PROTOCOL *FdtLocalPathList;
-} ARM_BDS_LINUX_ARGUMENTS;
-
-typedef union {
+#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: "
+
+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;
@@ -106,14 +99,14 @@ typedef struct {
#define SUPPORTED_BOOT_DEVICE_FROM_LINK(a) BASE_CR(a, BDS_SUPPORTED_DEVICE, Link)
typedef struct _BDS_LOAD_OPTION_SUPPORT {
- BDS_SUPPORTED_DEVICE_TYPE Type;
- EFI_STATUS (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList);
- BOOLEAN (*IsSupported)(IN EFI_DEVICE_PATH *DevicePath);
- EFI_STATUS (*CreateDevicePathNode)(IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);
- EFI_STATUS (*UpdateDevicePathNode)(IN EFI_DEVICE_PATH *OldDevicePath, IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);
-} BDS_LOAD_OPTION_SUPPORT;
-
-#define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)
+ BDS_SUPPORTED_DEVICE_TYPE Type;
+ EFI_STATUS (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList);
+ BOOLEAN (*IsSupported)(IN EFI_DEVICE_PATH *DevicePath);
+ EFI_STATUS (*CreateDevicePathNode)(IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes, OUT BOOLEAN *RequestBootType);
+ EFI_STATUS (*UpdateDevicePathNode)(IN EFI_DEVICE_PATH *OldDevicePath, IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT BOOLEAN *RequestBootType);
+} 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
EFI_STATUS
@@ -223,31 +216,66 @@ BootOptionStart (
EFI_STATUS
BootOptionCreate (
IN UINT32 Attributes,
- IN CHAR16* BootDescription,
- IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
- IN ARM_BDS_LOADER_ARGUMENTS* BootArguments,
- OUT BDS_LOAD_OPTION** BdsLoadOption
- );
-
+ 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
+ );
+
EFI_STATUS
BootOptionUpdate (
IN BDS_LOAD_OPTION* BdsLoadOption,
IN UINT32 Attributes,
- IN CHAR16* BootDescription,
- IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
- IN ARM_BDS_LOADER_ARGUMENTS* BootArguments
- );
-
-EFI_STATUS
+ IN CHAR16* BootDescription,
+ IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
+ IN ARM_BDS_LOADER_TYPE BootType,
+ IN UINT8* OptionalData,
+ IN UINTN OptionalDataSize
+ );
+
+EFI_STATUS
BootOptionDelete (
IN BDS_LOAD_OPTION *BootOption
- );
-
-EFI_STATUS
-BootMenuMain (
- VOID
- );
-
-#endif /* _BDSINTERNAL_H_ */
+ );
+
+EFI_STATUS
+BootDeviceGetType (
+ IN EFI_DEVICE_PATH* DevicePath,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
+ );
+
+EFI_STATUS
+BootMenuMain (
+ VOID
+ );
+
+BOOLEAN
+IsUnicodeString (
+ IN VOID* String
+ );
+
+/*
+ * Try to detect if the given string is an ASCII or Unicode string
+ *
+ * There are actually few limitation to this function but it is mainly to give
+ * a user friendly output.
+ *
+ * Some limitations:
+ * - it only supports unicode string that use ASCII character (< 0x100)
+ * - single character ASCII strings are interpreted as Unicode string
+ * - string cannot be longer than 2 x BOOT_DEVICE_OPTION_MAX (600 bytes)
+ *
+ * @param String Buffer that might contain a Unicode or Ascii string
+ * @param IsUnicode If not NULL this boolean value returns if the string is an
+ * ASCII or Unicode string.
+ */
+BOOLEAN
+IsPrintableString (
+ IN VOID* String,
+ OUT BOOLEAN *IsUnicode
+ );
+
+#endif /* _BDSINTERNAL_H_ */
diff --git a/HisiPkg/D01BoardPkg/Bds/BootMenu.c b/HisiPkg/D01BoardPkg/Bds/BootMenu.c
index e265c130f..8880bd5c6 100644
--- a/HisiPkg/D01BoardPkg/Bds/BootMenu.c
+++ b/HisiPkg/D01BoardPkg/Bds/BootMenu.c
@@ -124,136 +124,133 @@ BootMenuAddBootOption (
)
{
EFI_STATUS Status;
- BDS_SUPPORTED_DEVICE* SupportedBootDevice;
- ARM_BDS_LOADER_ARGUMENTS* BootArguments;
- CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];
- CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];
- UINT32 Attributes;
- ARM_BDS_LOADER_TYPE BootType;
- BDS_LOAD_OPTION_ENTRY *BdsLoadOptionEntry;
+ 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;
- EFI_DEVICE_PATH_PROTOCOL *FdtLocalPathNode;
- EFI_DEVICE_PATH_PROTOCOL *FdtLocalPath;
- UINTN CmdLineSize;
- BOOLEAN InitrdSupport;
- UINTN InitrdSize;
- UINTN FdtLocalSize;
-
- Attributes = 0;
- SupportedBootDevice = NULL;
+ 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;
+ BOOLEAN RequestBootType;
+
+ Attributes = 0;
+ SupportedBootDevice = NULL;
// List the Boot Devices supported
Status = SelectBootDevice (&SupportedBootDevice);
if (EFI_ERROR(Status)) {
Status = EFI_ABORTED;
goto EXIT;
- }
-
- // Create the specific device path node
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes, &BootType, &Attributes);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
+ }
+
+ // Create the specific device path node
+ RequestBootType = TRUE;
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes, &RequestBootType);
+ if (EFI_ERROR(Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
}
// Append the Device Path to the selected device path
DevicePath = AppendDevicePath (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)DevicePathNodes);
if (DevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES;
- goto EXIT;
- }
-
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
- Print(L"Add an initrd: ");
- Status = GetHIInputBoolean (&InitrdSupport);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto FREE_DEVICE_PATH;
- }
-
- if (InitrdSupport) {
- // Create the specific device path node
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes, NULL, NULL);
- 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 FREE_DEVICE_PATH;
- }
-
- if (InitrdPathNodes != NULL) {
- // Append the Device Path to the selected device path
- InitrdPath = AppendDevicePath (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);
- if (InitrdPath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto FREE_DEVICE_PATH;
- }
- } else {
- InitrdPath = NULL;
- }
- } else {
- InitrdPath = NULL;
- }
-
- Print(L"Arguments to pass to the binary: ");
- Status = GetHIInputAscii (CmdLine,BOOT_DEVICE_OPTION_MAX);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto FREE_DEVICE_PATH;
- }
-
- if (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT) {
+ goto EXIT;
+ }
+
+ if (RequestBootType) {
+ Status = BootDeviceGetType (DevicePath, &BootType, &Attributes);
+ if (EFI_ERROR(Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+ } else {
+ BootType = BDS_LOADER_EFI_APPLICATION;
+ }
+
+ 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"local FDT", &FdtLocalPathNode, NULL, NULL);
- if (EFI_ERROR(Status) || (FdtLocalPathNode == NULL)) {
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes, NULL);
+ 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 FREE_DEVICE_PATH;
+ goto EXIT;
}
-
- if (FdtLocalPathNode != NULL) {
- // Append the Device Path node to the select device path
- FdtLocalPath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)FdtLocalPathNode);
+
+ if (InitrdPathNodes != NULL) {
+ // Append the Device Path to the selected device path
+ InitrdPath = AppendDevicePath (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);
+ if (InitrdPath == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto EXIT;
+ }
} else {
- FdtLocalPath = NULL;
- }
- } else {
- FdtLocalPath = NULL;
+ InitrdPath = NULL;
+ }
+ } else {
+ InitrdPath = NULL;
}
-
- CmdLineSize = AsciiStrSize (CmdLine);
+
+ 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);
- FdtLocalSize = GetDevicePathSize (FdtLocalPath);
-
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize + FdtLocalSize);
- if ( BootArguments != NULL ) {
- BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
- BootArguments->LinuxArguments.InitrdSize = InitrdSize;
- BootArguments->LinuxArguments.FdtLocalSize = FdtLocalSize;
- CopyMem ((VOID*)(&BootArguments->LinuxArguments + 1), CmdLine, CmdLineSize);
- CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
- CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize + InitrdSize), FdtLocalPath, FdtLocalSize);
- }
- } else {
- BootArguments = NULL;
- }
-
- Print(L"Description for this new Entry: ");
+
+ 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), CmdLine, 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);
+ }
+
+ Print(L"Description for this new Entry: ");
Status = GetHIInputStr (BootDescription, BOOT_DEVICE_DESCRIPTION_MAX);
if (EFI_ERROR(Status)) {
Status = EFI_ABORTED;
goto FREE_DEVICE_PATH;
}
-
- // Create new entry
- BdsLoadOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool (sizeof(BDS_LOAD_OPTION_ENTRY));
- if ( BdsLoadOptionEntry == NULL ) {
- Status = EFI_ABORTED;
- goto FREE_DEVICE_PATH;
- }
- Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, BootArguments, &BdsLoadOptionEntry->BdsLoadOption);
- if (!EFI_ERROR(Status)) {
- InsertTailList (BootOptionsList, &BdsLoadOptionEntry->Link);
- }
+
+ // Create new entry
+ BdsLoadOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool (sizeof(BDS_LOAD_OPTION_ENTRY));
+ Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize, &BdsLoadOptionEntry->BdsLoadOption);
+ if (!EFI_ERROR(Status)) {
+ InsertTailList (BootOptionsList, &BdsLoadOptionEntry->Link);
+ }
FREE_DEVICE_PATH:
FreePool (DevicePath);
@@ -268,36 +265,32 @@ EXIT:
STATIC
EFI_STATUS
-BootMenuSelectBootOption (
- IN LIST_ENTRY* BootOptionsList,
- IN CONST CHAR16* InputStatement,
- IN BOOLEAN OnlyArmBdsBootEntry,
- OUT BDS_LOAD_OPTION_ENTRY** BdsLoadOptionEntry
- )
-{
+BootMenuSelectBootOption (
+ IN LIST_ENTRY* BootOptionsList,
+ IN CONST CHAR16* InputStatement,
+ OUT BDS_LOAD_OPTION_ENTRY** BdsLoadOptionEntry
+ )
+{
EFI_STATUS Status;
LIST_ENTRY* Entry;
BDS_LOAD_OPTION* BdsLoadOption;
- UINTN BootOptionSelected;
- UINTN BootOptionCount;
- UINTN Index;
-
- // Display the list of supported boot devices
- BootOptionCount = 0;
+ UINTN BootOptionSelected;
+ UINTN BootOptionCount;
+ UINTN Index;
+ BOOLEAN IsUnicode;
+
+ // Display the list of supported boot devices
+ BootOptionCount = 0;
for (Entry = GetFirstNode (BootOptionsList);
!IsNull (BootOptionsList,Entry);
Entry = GetNextNode (BootOptionsList, Entry)
)
- {
- BdsLoadOption = LOAD_OPTION_FROM_LINK(Entry);
-
- if (OnlyArmBdsBootEntry && !IS_ARM_BDS_BOOTENTRY (BdsLoadOption)) {
- continue;
- }
-
- Print (L"[%d] %s\n", (BootOptionCount + 1), BdsLoadOption->Description);
-
- DEBUG_CODE_BEGIN();
+ {
+ BdsLoadOption = LOAD_OPTION_FROM_LINK(Entry);
+
+ Print (L"[%d] %s\n", (BootOptionCount + 1), BdsLoadOption->Description);
+
+ DEBUG_CODE_BEGIN();
CHAR16* DevicePathTxt;
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
ARM_BDS_LOADER_TYPE LoaderType;
@@ -306,15 +299,25 @@ BootMenuSelectBootOption (
Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
ASSERT_EFI_ERROR(Status);
DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BdsLoadOption->FilePathList,TRUE,TRUE);
-
- Print(L"\t- %s\n",DevicePathTxt);
- OptionalData = BdsLoadOption->OptionalData;
- LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
- if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (LoaderType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
- Print (L"\t- Arguments: %a\n",&OptionalData->Arguments.LinuxArguments + 1);
- }
-
- FreePool(DevicePathTxt);
+
+ 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);
+ }
+ }
+ }
+
+ FreePool(DevicePathTxt);
DEBUG_CODE_END();
BootOptionCount++;
@@ -368,13 +371,13 @@ BootMenuRemoveBootOption (
IN LIST_ENTRY *BootOptionsList
)
{
- EFI_STATUS Status;
- BDS_LOAD_OPTION_ENTRY* BootOptionEntry;
-
- Status = BootMenuSelectBootOption (BootOptionsList, DELETE_BOOT_ENTRY, FALSE, &BootOptionEntry);
- if (EFI_ERROR(Status)) {
- return Status;
- }
+ EFI_STATUS Status;
+ BDS_LOAD_OPTION_ENTRY* BootOptionEntry;
+
+ Status = BootMenuSelectBootOption (BootOptionsList, DELETE_BOOT_ENTRY, &BootOptionEntry);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
// If the Boot Option was attached to a list remove it
if (!IsListEmpty (&BootOptionEntry->Link)) {
@@ -397,109 +400,70 @@ 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];
- EFI_DEVICE_PATH *DevicePath;
- EFI_DEVICE_PATH *TempInitrdPath;
- EFI_DEVICE_PATH *TempFdtLocalPath;
- ARM_BDS_LOADER_TYPE BootType;
- ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
- ARM_BDS_LINUX_ARGUMENTS* LinuxArguments;
- EFI_DEVICE_PATH *InitrdPathNodes;
- EFI_DEVICE_PATH *InitrdPath;
- UINTN InitrdSize;
- EFI_DEVICE_PATH *FdtLocalPathNode;
- EFI_DEVICE_PATH *FdtLocalPath;
- UINTN FdtLocalSize;
- UINTN CmdLineSize;
- BOOLEAN InitrdSupport;
- BOOLEAN FdtLocalSupport;
-
- Status = BootMenuSelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, TRUE, &BootOptionEntry);
- if (EFI_ERROR(Status)) {
- return Status;
- }
+ 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 RequestBootType;
+ BOOLEAN IsPrintable;
+ BOOLEAN IsUnicode;
+
+ Status = BootMenuSelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, &BootOptionEntry);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
BootOption = BootOptionEntry->BdsLoadOption;
// Get the device support for this Boot Option
Status = BootDeviceGetDeviceSupport (BootOption->FilePathList, &DeviceSupport);
if (EFI_ERROR(Status)) {
Print(L"Not possible to retrieve the supported device for the update\n");
- return EFI_UNSUPPORTED;
- }
-
- Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath, NULL, NULL);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
-
- OptionalData = BootOption->OptionalData;
- BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&OptionalData->Header.LoaderType));
-
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
- LinuxArguments = &OptionalData->Arguments.LinuxArguments;
-
- CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
-
- InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);
- FdtLocalSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->FdtLocalSize);
-
- if (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT) {
- if (FdtLocalSize > 0) {
- Print(L"Keep the local FDT: ");
- } else {
- Print(L"Add a local FDT: ");
- }
- Status = GetHIInputBoolean (&FdtLocalSupport);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
- if (FdtLocalSupport && BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT) {
- if (FdtLocalSize > 0) {
- // Case we update the FDT local device path
- Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize + InitrdSize), L"local FDT", &FdtLocalPath, NULL, NULL);
- if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {// EFI_NOT_FOUND is returned on empty input string
- Status = EFI_ABORTED;
- goto EXIT;
- }
- FdtLocalSize = GetDevicePathSize (FdtLocalPath);
- } else {
- // Case we create the FdtLocal device path
-
- Status = DeviceSupport->CreateDevicePathNode (L"local FDT", &FdtLocalPathNode, NULL, NULL);
- if (EFI_ERROR(Status) || (FdtLocalPathNode == NULL)) {
- Status = EFI_ABORTED;
- goto EXIT;
- }
-
- if (FdtLocalPathNode != NULL) {
- // Duplicate Linux kernel Device Path
- TempFdtLocalPath = DuplicateDevicePath (BootOption->FilePathList);
- if ( TempFdtLocalPath != NULL ) {
- // Replace Linux kernel Node by EndNode
- SetDevicePathEndNode (GetLastDevicePathNode (TempFdtLocalPath));
- // Append the Device Path node to the select device path
- FdtLocalPath = AppendDevicePathNode (TempFdtLocalPath, (CONST EFI_DEVICE_PATH_PROTOCOL *)FdtLocalPathNode);
- FreePool (TempFdtLocalPath);
- FdtLocalSize = GetDevicePathSize (FdtLocalPath);
- }
- } else {
- FdtLocalPath = NULL;
- }
- }
- } else {
- FdtLocalSize = 0;
- }
- } else {
- FdtLocalSupport = FALSE;
- }
-
- if (InitrdSize > 0) {
- Print(L"Keep the initrd: ");
- } else {
+ return EFI_UNSUPPORTED;
+ }
+
+ RequestBootType = TRUE;
+ Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath, &RequestBootType);
+ if (EFI_ERROR(Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ if (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);
@@ -508,22 +472,22 @@ BootMenuUpdateBootOption (
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, NULL, NULL);
- 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 (InitrdSupport) {
+ if (InitrdSize > 0) {
+ // Case we update the initrd device path
+ Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize), L"initrd", &InitrdPath, NULL);
+ 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, NULL, NULL);
- 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;
+ } else {
+ // Case we create the initrd device path
+
+ Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNodes, NULL);
+ 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) {
@@ -558,35 +522,76 @@ BootMenuUpdateBootOption (
Status = EFI_ABORTED;
goto FREE_DEVICE_PATH;
}
-
- CmdLineSize = AsciiStrSize (CmdLine);
-
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool(sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize + FdtLocalSize);
- if ( BootArguments != NULL ) {
- BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
- BootArguments->LinuxArguments.InitrdSize = InitrdSize;
- BootArguments->LinuxArguments.FdtLocalSize = FdtLocalSize;
- CopyMem (&BootArguments->LinuxArguments + 1, CmdLine, CmdLineSize);
- CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
- CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize + InitrdSize), FdtLocalPath, FdtLocalSize);
- }
- } else {
- BootArguments = NULL;
- }
-
- Print(L"Description for this new Entry: ");
+
+ 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) {
+ if (IsUnicode) {
+ StrnCpy (UnicodeCmdLine, BootOption->OptionalData, BootOption->OptionalDataSize / 2);
+ } else {
+ AsciiStrnCpy (CmdLine, BootOption->OptionalData, 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: ");
StrnCpy (BootDescription, BootOption->Description, BOOT_DEVICE_DESCRIPTION_MAX);
Status = EditHIInputStr (BootDescription, BOOT_DEVICE_DESCRIPTION_MAX);
if (EFI_ERROR(Status)) {
Status = EFI_ABORTED;
goto FREE_DEVICE_PATH;
- }
-
- // Update the entry
- Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, BootType, BootArguments);
-
-FREE_DEVICE_PATH:
- FreePool (DevicePath);
+ }
+
+ // Update the entry
+ Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize);
+
+FREE_DEVICE_PATH:
+ FreePool (DevicePath);
EXIT:
if (Status == EFI_ABORTED) {
@@ -610,13 +615,13 @@ UpdateFdtPath (
if (EFI_ERROR(Status)) {
Status = EFI_ABORTED;
goto EXIT;
- }
-
- // Create the specific device path node
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"FDT blob", &FdtDevicePathNodes, NULL, NULL);
- if (EFI_ERROR(Status)) {
- Status = EFI_ABORTED;
- goto EXIT;
+ }
+
+ // Create the specific device path node
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"FDT blob", &FdtDevicePathNodes, NULL);
+ if (EFI_ERROR(Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
}
if (FdtDevicePathNodes != NULL) {
@@ -708,9 +713,9 @@ BootEBL (
} else if (EFI_ERROR(Status)) {
Print ((CHAR16 *)L"Error: Status Code: 0x%X\n",(UINT32)Status);
}
-
- return Status;
-}
+
+ return Status;
+}
EFI_STATUS
BootShell (
@@ -809,41 +814,36 @@ BootGo (
struct BOOT_MAIN_ENTRY {
CONST CHAR16* Description;
EFI_STATUS (*Callback) (IN LIST_ENTRY *BootOptionsList);
-} BootMainEntries[] = {
- { L"Boot Manager", BootMenuManager },
+} BootMainEntries[] = {
+ { L"Boot Manager", BootMenuManager },
{ L"EBL", BootEBL },
{ L"Shell", BootShell },
{ L"Reboot", Reboot },
{ L"Shutdown", Shutdown },
{ L"GO", BootGo },
-};
-
+};
+
EFI_STATUS
BootMenuMain (
- VOID
- )
-{
- LIST_ENTRY BootOptionsList;
- UINTN OptionCount;
- UINTN BootOptionCount;
- EFI_STATUS Status;
- LIST_ENTRY* Entry;
- BDS_LOAD_OPTION* BootOption;
- UINTN BootOptionSelected;
- UINTN Index;
- UINTN BootMainEntryCount;
- CHAR8 BootOptionSelectedStr[BOOT_OPTION_LEN];
- EFI_DEVICE_PATH_PROTOCOL* DefaultFdtDevicePath;
- UINTN FdtDevicePathSize;
- EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
- CHAR16* DevicePathTxt;
-
-
- BootOption = NULL;
- BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY);
-
- while (TRUE) {
+ VOID
+ )
+{
+ LIST_ENTRY BootOptionsList;
+ UINTN OptionCount;
+ UINTN BootOptionCount;
+ EFI_STATUS Status;
+ LIST_ENTRY* Entry;
+ BDS_LOAD_OPTION* BootOption;
+ UINTN BootOptionSelected;
+ UINTN Index;
+ UINTN BootMainEntryCount;
+ BOOLEAN IsUnicode;
+
+ BootOption = NULL;
+ BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY);
+
+ while (TRUE) {
// Get Boot#### list
BootOptionList (&BootOptionsList);
@@ -856,16 +856,17 @@ BootMenuMain (
)
{
BootOption = LOAD_OPTION_FROM_LINK(Entry);
-
- Print(L"[%d] %s\n", OptionCount, BootOption->Description);
-
- //DEBUG_CODE_BEGIN();
- ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
- UINTN CmdLineSize;
- UINTN InitrdSize;
- ARM_BDS_LOADER_TYPE LoaderType;
-
- Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
+
+ Print(L"[%d] %s\n", OptionCount, BootOption->Description);
+
+ 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)) {
// You must provide an implementation of DevicePathToTextProtocol in your firmware (eg: DevicePathDxe)
DEBUG((EFI_D_ERROR,"Error: Bds requires DevicePathToTextProtocol\n"));
@@ -876,109 +877,70 @@ 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_GLOBAL_FDT) || (LoaderType == BDS_LOADER_KERNEL_LINUX_LOCAL_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);
- }
- Print(L"\t- Arguments: %a\n", (&OptionalData->Arguments.LinuxArguments + 1));
- }
-
- switch (LoaderType) {
+ 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_GLOBAL_FDT:
- Print(L"\t- LoaderType: Linux kernel with global FDT support\n");
+ Print(L"\t- LoaderType: Linux kernel with ATAG support\n");
break;
- case BDS_LOADER_KERNEL_LINUX_LOCAL_FDT:
- if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.FdtLocalSize) > 0) {
- CmdLineSize = ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize);
- InitrdSize = ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.InitrdSize);
- DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (
- GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(&OptionalData->Arguments.LinuxArguments + 1) + CmdLineSize + InitrdSize)), TRUE, TRUE);
- Print(L"\t- FDT: %s\n", DevicePathTxt);
- } else {
- Print(L"\t- FDT: error, local FDT not specified, using global FDT\n");
- }
- Print(L"\t- LoaderType: Linux kernel with Local FDT\n");
- break;
- default:
- Print(L"\t- LoaderType: Not recognized (%d)\n", LoaderType);
+
+ case BDS_LOADER_KERNEL_LINUX_FDT:
+ Print(L"\t- LoaderType: Linux kernel with FDT support\n");
break;
- }
- }
- FreePool(DevicePathTxt);
- //DEBUG_CODE_END();
-
- OptionCount++;
- }
- BootOptionCount = OptionCount-1;
-
- // Display the global FDT config
- Print(L"-----------------------\n");
- {
- EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol;
- EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath;
-
- // Get the default FDT device path
- Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);
- ASSERT_EFI_ERROR(Status);
- DefaultFdtDevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdFdtDevicePath));
-
- // Get the FDT device path
- FdtDevicePathSize = GetDevicePathSize (DefaultFdtDevicePath);
- Status = GetEnvironmentVariable ((CHAR16 *)L"Fdt", &gArmGlobalVariableGuid, DefaultFdtDevicePath, &FdtDevicePathSize, (VOID **)&FdtDevicePath);
-
- // Convert FdtDevicePath to text
- if (EFI_ERROR(Status)) {
- DevicePathTxt = L"not configured";
- } else {
- Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
- DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText ( FdtDevicePath, TRUE, TRUE );
- }
- Print(L"Global FDT Config\n\t- %s\n", DevicePathTxt);
- FreePool(DevicePathTxt);
- FreePool(DefaultFdtDevicePath);
+
+ default:
+ Print(L"\t- LoaderType: Not recognized (%d)\n", LoaderType);
+ }
+ } else if (BootOption->OptionalData != NULL) {
+ if (IsPrintableString (BootOption->OptionalData, &IsUnicode)) {
+ if (IsUnicode) {
+ Print (L"\t- Arguments: %s\n", BootOption->OptionalData);
+ } else {
+ AsciiPrint ("\t- Arguments: %a\n", BootOption->OptionalData);
+ }
+ }
+ }
+ FreePool(DevicePathTxt);
+ DEBUG_CODE_END();
+
+ OptionCount++;
+ }
+ BootOptionCount = OptionCount-1;
+
+ // Display the hardcoded Boot entries
+ for (Index = 0; Index < BootMainEntryCount; Index++) {
+ Print(L"[%d] %s\n",OptionCount,BootMainEntries[Index]);
+ OptionCount++;
}
- // Display the hardcoded Boot entries
- Print(L"-----------------------\n");
- for (Index = 0; Index < BootMainEntryCount; Index++) {
- Print(L"[%c] %s\n", ('a' + Index), BootMainEntries[Index]);
- OptionCount++;
- }
-
// Request the boot entry from the user
- BootOptionSelected = 0;
- while (BootOptionSelected == 0) {
- Print(L"Start: ");
- Status = GetHIInputAscii (BootOptionSelectedStr, BOOT_OPTION_LEN);
-
- if (!EFI_ERROR(Status)) {
- if ((BootOptionSelectedStr[0] - '0') < OptionCount) {
- BootOptionSelected = BootOptionSelectedStr[0] - '0';
- } else if ((BootOptionSelectedStr[0] - 'a') < BootMainEntryCount) {
- BootOptionSelected = BootOptionCount + 1 + BootOptionSelectedStr[0] - 'a';
- }
-
- if ((BootOptionSelected == 0) || (BootOptionSelected > OptionCount)) {
- Print(L"Invalid input, please choose a menu option from the list above\n");
- BootOptionSelected = 0;
- }
+ BootOptionSelected = 0;
+ while (BootOptionSelected == 0) {
+ Print(L"Start: ");
+ Status = GetHIInputInteger (&BootOptionSelected);
+ if (EFI_ERROR(Status) || (BootOptionSelected == 0) || (BootOptionSelected > OptionCount)) {
+ Print(L"Invalid input (max %d)\n",(OptionCount-1));
+ BootOptionSelected = 0;
}
- }
-
+ }
+
// Start the selected entry
if (BootOptionSelected > BootOptionCount) {
// Start the hardcoded entry
diff --git a/HisiPkg/D01BoardPkg/Bds/BootOption.c b/HisiPkg/D01BoardPkg/Bds/BootOption.c
index d677687f7..e94aa3fe5 100644
--- a/HisiPkg/D01BoardPkg/Bds/BootOption.c
+++ b/HisiPkg/D01BoardPkg/Bds/BootOption.c
@@ -1,10 +1,9 @@
-/** @file
-*
-* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
-* Copyright (c) Huawei Technologies Co., Ltd. 2013. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
+/** @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
*
@@ -31,23 +30,24 @@ BootOptionStart (
EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath;
EFI_DEVICE_PATH_PROTOCOL* DefaultFdtDevicePath;
UINTN FdtDevicePathSize;
- UINTN CmdLineSize;
- UINTN InitrdSize;
- EFI_DEVICE_PATH* Initrd;
- UINTN FdtLocalSize;
- UINT16 LoadOptionIndexSize;
-
- if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
+ UINTN CmdLineSize;
+ UINTN InitrdSize;
+ EFI_DEVICE_PATH* Initrd;
+ 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) {
- // Need to connect every drivers to ensure no dependencies are missing for the application
- BdsConnectAllDrivers();
-
- Status = BdsStartEfiApplication (mImageHandle, BootOption->FilePathList, 0, NULL);
- } else if (LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) {
+ LoaderType = ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
+
+ if (LoaderType == BDS_LOADER_EFI_APPLICATION) {
+ if ((BootOption->Attributes & LOAD_OPTION_CATEGORY_BOOT) == 0) {
+ // Need to connect every drivers to ensure no dependencies are missing for the application
+ BdsConnectAllDrivers ();
+ }
+
+ Status = BdsStartEfiApplication (mImageHandle, 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);
@@ -58,52 +58,48 @@ BootOptionStart (
Initrd = NULL;
}
- Status = BdsBootLinuxAtag (BootOption->FilePathList,
- Initrd, // Initrd
- (CHAR8*)(LinuxArguments + 1)); // CmdLine
- } else if ((LoaderType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (LoaderType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
- LinuxArguments = &(OptionalData->Arguments.LinuxArguments);
- CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
- InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);
+ Status = BdsBootLinuxAtag (BootOption->FilePathList,
+ Initrd, // Initrd
+ (CHAR8*)(LinuxArguments + 1)); // CmdLine
+ } 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;
- }
-
- if (LoaderType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT) {
- FdtLocalSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->FdtLocalSize);
+ Initrd = NULL;
+ }
- if (FdtLocalSize > 0) {
- FdtDevicePath = GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize + InitrdSize));
- } else {
- FdtDevicePath = NULL;
- }
- } else {
- // Get the default FDT device path
- Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);
- ASSERT_EFI_ERROR(Status);
- DefaultFdtDevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdFdtDevicePath));
+ // Get the default FDT device path
+ Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);
+ ASSERT_EFI_ERROR(Status);
+ DefaultFdtDevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdFdtDevicePath));
- // Get the FDT device path
- FdtDevicePathSize = GetDevicePathSize (DefaultFdtDevicePath);
- Status = GetEnvironmentVariable ((CHAR16 *)L"Fdt", &gArmGlobalVariableGuid,
- DefaultFdtDevicePath, &FdtDevicePathSize, (VOID **)&FdtDevicePath);
- ASSERT_EFI_ERROR(Status);
- FreePool (DefaultFdtDevicePath);
- }
- Status = BdsBootLinuxFdt (BootOption->FilePathList,
- Initrd, // Initrd
- (CHAR8*)(LinuxArguments + 1),
- FdtDevicePath);
-
- FreePool (FdtDevicePath);
- }
- } else {
- // Set BootCurrent variable
- LoadOptionIndexSize = sizeof(UINT16);
- gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
+ // Get the FDT device path
+ FdtDevicePathSize = GetDevicePathSize (DefaultFdtDevicePath);
+ Status = GetEnvironmentVariable ((CHAR16 *)L"Fdt", &gArmGlobalVariableGuid,
+ DefaultFdtDevicePath, &FdtDevicePathSize, (VOID **)&FdtDevicePath);
+ ASSERT_EFI_ERROR(Status);
+
+ Status = BdsBootLinuxFdt (BootOption->FilePathList,
+ Initrd, // Initrd
+ (CHAR8*)(LinuxArguments + 1),
+ FdtDevicePath);
+
+ FreePool (DefaultFdtDevicePath);
+ FreePool (FdtDevicePath);
+ }
+ } else {
+ // Connect all the drivers if the EFI Application is not a EFI OS Loader
+ if ((BootOption->Attributes & LOAD_OPTION_CATEGORY_BOOT) == 0) {
+ BdsConnectAllDrivers ();
+ }
+
+ // Set BootCurrent variable
+ LoadOptionIndexSize = sizeof(UINT16);
+ gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
LoadOptionIndexSize, &(BootOption->LoadOptionIndex));
@@ -158,43 +154,43 @@ EFI_STATUS
BootOptionSetFields (
IN BDS_LOAD_OPTION* BootOption,
IN UINT32 Attributes,
- IN CHAR16* BootDescription,
- IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
- IN ARM_BDS_LOADER_ARGUMENTS* BootArguments
- )
-{
- EFI_LOAD_OPTION EfiLoadOption;
- UINTN EfiLoadOptionSize;
- UINTN BootDescriptionSize;
- UINTN BootOptionalDataSize;
- UINT16 FilePathListLength;
- UINT8* EfiLoadOptionPtr;
- UINT8* InitrdPathListPtr;
- UINT8* FdtLocalPathListPtr;
- UINTN OptionalDataSize;
- ARM_BDS_LINUX_ARGUMENTS* DestLinuxArguments;
- ARM_BDS_LINUX_ARGUMENTS* SrcLinuxArguments;
-
- // If we are overwriting an existent Boot Option then we have to free previously allocated memory
- if (BootOption->LoadOption) {
- FreePool(BootOption->LoadOption);
- }
-
- BootDescriptionSize = StrSize (BootDescription);
- BootOptionalDataSize = sizeof(ARM_BDS_LOADER_OPTIONAL_DATA_HEADER);
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
- BootOptionalDataSize += sizeof(ARM_BDS_LINUX_ARGUMENTS) + BootArguments->LinuxArguments.CmdLineSize + BootArguments->LinuxArguments.InitrdSize + BootArguments->LinuxArguments.FdtLocalSize;
- }
-
- // Compute the size of the FilePath list
- FilePathListLength = GetUnalignedDevicePathSize (DevicePath);
-
- // Allocate the memory for the EFI Load Option
- EfiLoadOptionSize = sizeof(UINT32) + sizeof(UINT16) + BootDescriptionSize + FilePathListLength + BootOptionalDataSize;
- EfiLoadOption = (EFI_LOAD_OPTION)AllocatePool(EfiLoadOptionSize);
- EfiLoadOptionPtr = EfiLoadOption;
-
+ IN CHAR16* BootDescription,
+ IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
+ IN ARM_BDS_LOADER_TYPE BootType,
+ IN UINT8* OptionalData,
+ IN UINTN OptionalDataSize
+ )
+{
+ EFI_LOAD_OPTION EfiLoadOption;
+ UINTN EfiLoadOptionSize;
+ 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) {
+ FreePool (BootOption->LoadOption);
+ }
+
+ 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);
+
+ // Allocate the memory for the EFI Load Option
+ EfiLoadOptionSize = sizeof(UINT32) + sizeof(UINT16) + BootDescriptionSize + FilePathListLength + OptionalDataSize;
+ EfiLoadOption = (EFI_LOAD_OPTION)AllocatePool(EfiLoadOptionSize);
+ EfiLoadOptionPtr = EfiLoadOption;
+
//
// Populate the EFI Load Option and BDS Boot Option structures
//
@@ -218,40 +214,35 @@ BootOptionSetFields (
BootOption->FilePathList = (EFI_DEVICE_PATH_PROTOCOL*)EfiLoadOptionPtr;
CopyMem (EfiLoadOptionPtr, DevicePath, FilePathListLength);
EfiLoadOptionPtr += FilePathListLength;
-
- // Optional Data fields, Do unaligned writes
- BootOption->OptionalData = EfiLoadOptionPtr;
- WriteUnaligned32 ((UINT32 *)EfiLoadOptionPtr, ARM_BDS_OPTIONAL_DATA_SIGNATURE);
- WriteUnaligned32 ((UINT32 *)(EfiLoadOptionPtr + 4), BootType);
-
- OptionalDataSize = sizeof(ARM_BDS_LOADER_OPTIONAL_DATA_HEADER);
-
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
- SrcLinuxArguments = &(BootArguments->LinuxArguments);
- DestLinuxArguments = &((ARM_BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments.LinuxArguments;
-
- WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->CmdLineSize), SrcLinuxArguments->CmdLineSize);
- WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->InitrdSize), SrcLinuxArguments->InitrdSize);
- WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->FdtLocalSize), SrcLinuxArguments->FdtLocalSize);
- OptionalDataSize += sizeof (ARM_BDS_LINUX_ARGUMENTS);
-
- if (SrcLinuxArguments->CmdLineSize > 0) {
- CopyMem ((VOID*)(DestLinuxArguments + 1), (VOID*)(SrcLinuxArguments + 1), SrcLinuxArguments->CmdLineSize);
- OptionalDataSize += SrcLinuxArguments->CmdLineSize;
- }
-
- if (SrcLinuxArguments->InitrdSize > 0) {
- InitrdPathListPtr = (UINT8*)((UINTN)(DestLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize);
- CopyMem (InitrdPathListPtr, (VOID*)((UINTN)(SrcLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize), SrcLinuxArguments->InitrdSize);
- }
- if (SrcLinuxArguments->FdtLocalSize > 0) {
- FdtLocalPathListPtr = (UINT8*)((UINTN)(DestLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize + SrcLinuxArguments->InitrdSize);
- CopyMem (FdtLocalPathListPtr, (VOID*)((UINTN)(SrcLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize + SrcLinuxArguments->InitrdSize), SrcLinuxArguments->FdtLocalSize);
+ // 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);
+
+ 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);
}
- }
- BootOption->OptionalDataSize = OptionalDataSize;
-
+
+ if (SrcLinuxArguments->InitrdSize > 0) {
+ InitrdPathListPtr = (UINT8*)((UINTN)(DestLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize);
+ CopyMem (InitrdPathListPtr, (VOID*)((UINTN)(SrcLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize), SrcLinuxArguments->InitrdSize);
+ }
+ } else {
+ 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
// BootOption->LoadOptionSize must be zero then we get a new BootIndex for this entry
if (BootOption->LoadOptionSize == 0) {
@@ -268,13 +259,14 @@ BootOptionSetFields (
EFI_STATUS
BootOptionCreate (
IN UINT32 Attributes,
- IN CHAR16* BootDescription,
- IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
- IN ARM_BDS_LOADER_ARGUMENTS* BootArguments,
- OUT BDS_LOAD_OPTION** BdsLoadOption
- )
-{
+ 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
+ )
+{
EFI_STATUS Status;
BDS_LOAD_OPTION_ENTRY* BootOptionEntry;
BDS_LOAD_OPTION* BootOption;
@@ -287,13 +279,13 @@ BootOptionCreate (
//
BootOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool (sizeof (BDS_LOAD_OPTION_ENTRY));
InitializeListHead (&BootOptionEntry->Link);
- BootOptionEntry->BdsLoadOption = (BDS_LOAD_OPTION*)AllocateZeroPool (sizeof(BDS_LOAD_OPTION));
-
- BootOption = BootOptionEntry->BdsLoadOption;
- BootOptionSetFields (BootOption, Attributes, BootDescription, DevicePath, BootType, BootArguments);
-
- //
- // Set the related environment variables
+ BootOptionEntry->BdsLoadOption = (BDS_LOAD_OPTION*)AllocateZeroPool (sizeof(BDS_LOAD_OPTION));
+
+ BootOption = BootOptionEntry->BdsLoadOption;
+ BootOptionSetFields (BootOption, Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize);
+
+ //
+ // Set the related environment variables
//
// Create Boot#### environment variable
@@ -341,20 +333,21 @@ EFI_STATUS
BootOptionUpdate (
IN BDS_LOAD_OPTION* BdsLoadOption,
IN UINT32 Attributes,
- IN CHAR16* BootDescription,
- IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
- IN ARM_BDS_LOADER_TYPE BootType,
- IN ARM_BDS_LOADER_ARGUMENTS* BootArguments
- )
-{
- EFI_STATUS Status;
- CHAR16 BootVariableName[9];
-
- // Update the BDS Load Option structure
- BootOptionSetFields (BdsLoadOption, Attributes, BootDescription, DevicePath, BootType, BootArguments);
-
- // Update the related environment variables
- UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BdsLoadOption->LoadOptionIndex);
+ IN CHAR16* BootDescription,
+ IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
+ IN ARM_BDS_LOADER_TYPE BootType,
+ IN UINT8* OptionalData,
+ IN UINTN OptionalDataSize
+ )
+{
+ EFI_STATUS Status;
+ CHAR16 BootVariableName[9];
+
+ // Update the BDS Load Option structure
+ BootOptionSetFields (BdsLoadOption, Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize);
+
+ // Update the related environment variables
+ UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BdsLoadOption->LoadOptionIndex);
Status = gRT->SetVariable (
BootVariableName,
diff --git a/HisiPkg/D01BoardPkg/Bds/BootOptionSupport.c b/HisiPkg/D01BoardPkg/Bds/BootOptionSupport.c
index 7c1ca13b1..6f718357f 100644
--- a/HisiPkg/D01BoardPkg/Bds/BootOptionSupport.c
+++ b/HisiPkg/D01BoardPkg/Bds/BootOptionSupport.c
@@ -1,10 +1,9 @@
-/** @file
-*
-* Copyright (c) 2011, ARM Limited. All rights reserved.
-* Copyright (c) Huawei Technologies Co., Ltd. 2013. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
+/** @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
*
@@ -23,34 +22,31 @@
#include <Protocol/SimpleFileSystem.h>
#include <Protocol/SimpleNetwork.h>
-#include <Guid/FileSystemInfo.h>
-
-#define IS_DEVICE_PATH_NODE(node,type,subtype) (((node)->Type == (type)) && ((node)->SubType == (subtype)))
-#define LOCAL_FDT_RESPONSE_LEN 2 // 1 character, plus carriage return
-
-EFI_STATUS
-BdsLoadOptionFileSystemList (
+#include <Guid/FileSystemInfo.h>
+
+#define IS_DEVICE_PATH_NODE(node,type,subtype) (((node)->Type == (type)) && ((node)->SubType == (subtype)))
+
+EFI_STATUS
+BdsLoadOptionFileSystemList (
IN OUT LIST_ENTRY* BdsLoadOptionList
);
EFI_STATUS
-BdsLoadOptionFileSystemCreateDevicePath (
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- );
-
-EFI_STATUS
+BdsLoadOptionFileSystemCreateDevicePath (
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
+ OUT BOOLEAN *RequestBootType
+ );
+
+EFI_STATUS
BdsLoadOptionFileSystemUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- );
-
-BOOLEAN
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT BOOLEAN *RequestBootType
+ );
+
+BOOLEAN
BdsLoadOptionFileSystemIsSupported (
IN EFI_DEVICE_PATH *DevicePath
);
@@ -61,23 +57,21 @@ BdsLoadOptionMemMapList (
);
EFI_STATUS
-BdsLoadOptionMemMapCreateDevicePath (
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- );
-
-EFI_STATUS
+BdsLoadOptionMemMapCreateDevicePath (
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
+ OUT BOOLEAN *RequestBootType
+ );
+
+EFI_STATUS
BdsLoadOptionMemMapUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- );
-
-BOOLEAN
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT BOOLEAN *RequestBootType
+ );
+
+BOOLEAN
BdsLoadOptionMemMapIsSupported (
IN EFI_DEVICE_PATH *DevicePath
);
@@ -88,23 +82,21 @@ BdsLoadOptionPxeList (
);
EFI_STATUS
-BdsLoadOptionPxeCreateDevicePath (
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- );
-
-EFI_STATUS
+BdsLoadOptionPxeCreateDevicePath (
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
+ OUT BOOLEAN *RequestBootType
+ );
+
+EFI_STATUS
BdsLoadOptionPxeUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- );
-
-BOOLEAN
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT BOOLEAN *RequestBootType
+ );
+
+BOOLEAN
BdsLoadOptionPxeIsSupported (
IN EFI_DEVICE_PATH *DevicePath
);
@@ -115,23 +107,21 @@ BdsLoadOptionTftpList (
);
EFI_STATUS
-BdsLoadOptionTftpCreateDevicePath (
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- );
-
-EFI_STATUS
+BdsLoadOptionTftpCreateDevicePath (
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
+ OUT BOOLEAN *RequestBootType
+ );
+
+EFI_STATUS
BdsLoadOptionTftpUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- );
-
-BOOLEAN
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT BOOLEAN *RequestBootType
+ );
+
+BOOLEAN
BdsLoadOptionTftpIsSupported (
IN EFI_DEVICE_PATH *DevicePath
);
@@ -221,35 +211,95 @@ BootDeviceGetDeviceSupport (
}
}
- return EFI_UNSUPPORTED;
-}
-
-STATIC
-EFI_STATUS
-BootDeviceGetType (
- IN CHAR16* FileName,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- )
-{
- EFI_STATUS Status;
- BOOLEAN IsEfiApp;
- BOOLEAN IsBootLoader;
- CHAR16 FDTType[ LOCAL_FDT_RESPONSE_LEN ];
-
- if (FileName == NULL) {
- Print(L"Is an EFI Application? ");
+ 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 {
- IsEfiApp = FALSE;
- }
-
- if (IsEfiApp) {
+ } 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 is an OS loader? ");
Status = GetHIInputBoolean (&IsBootLoader);
if (EFI_ERROR(Status)) {
@@ -257,25 +307,21 @@ BootDeviceGetType (
}
if (!IsBootLoader) {
*Attributes |= LOAD_OPTION_CATEGORY_APP;
- }
- *BootType = BDS_LOADER_EFI_APPLICATION;
- } else {
- Print(L"Boot Type: [a] ATAGS, [g] Global FDT or [l] Local FDT? [a/g/l] ");
- Status = GetHIInputStr (FDTType, LOCAL_FDT_RESPONSE_LEN );
- if (EFI_ERROR(Status)) {
- return EFI_ABORTED;
- }
- if (StrCmp(FDTType, L"g") == 0) {
- *BootType = BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT;
- } else if (StrCmp(FDTType, L"l") == 0) {
- *BootType = BDS_LOADER_KERNEL_LINUX_LOCAL_FDT;
- } else if (StrCmp(FDTType, L"a") == 0) {
- *BootType = BDS_LOADER_KERNEL_LINUX_ATAG;
- } else {
+ }
+ *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;
}
@@ -336,14 +382,13 @@ BdsLoadOptionFileSystemList (
}
EFI_STATUS
-BdsLoadOptionFileSystemCreateDevicePath (
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- )
-{
- EFI_STATUS Status;
+BdsLoadOptionFileSystemCreateDevicePath (
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
+ OUT BOOLEAN *RequestBootType
+ )
+{
+ EFI_STATUS Status;
FILEPATH_DEVICE_PATH* FilePathDevicePath;
CHAR16 BootFilePath[BOOT_DEVICE_FILEPATH_MAX];
UINTN BootFilePathSize;
@@ -364,33 +409,23 @@ BdsLoadOptionFileSystemCreateDevicePath (
FilePathDevicePath = (FILEPATH_DEVICE_PATH*)AllocatePool(SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize + END_DEVICE_PATH_LENGTH);
FilePathDevicePath->Header.Type = MEDIA_DEVICE_PATH;
FilePathDevicePath->Header.SubType = MEDIA_FILEPATH_DP;
- SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);
- CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);
- SetDevicePathEndNode ((VOID*)((UINTN)FilePathDevicePath + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize));
-
- if (BootType != NULL || Attributes != NULL) {
- Status = BootDeviceGetType (FilePathDevicePath->PathName, BootType, Attributes);
- }
-
- if (EFI_ERROR(Status)) {
- FreePool (FilePathDevicePath);
- } else {
- *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)FilePathDevicePath;
- }
-
- return Status;
-}
+ SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);
+ CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);
+ SetDevicePathEndNode ((VOID*)((UINTN)FilePathDevicePath + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize));
+ *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)FilePathDevicePath;
+
+ return Status;
+}
EFI_STATUS
BdsLoadOptionFileSystemUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- )
-{
- EFI_STATUS Status;
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT BOOLEAN *RequestBootType
+ )
+{
+ EFI_STATUS Status;
CHAR16 BootFilePath[BOOT_DEVICE_FILEPATH_MAX];
UINTN BootFilePathSize;
FILEPATH_DEVICE_PATH* EndingDevicePath;
@@ -423,16 +458,12 @@ BdsLoadOptionFileSystemUpdateDevicePath (
// Generate the new Device Path by replacing the last node by the updated node
SetDevicePathEndNode (EndingDevicePath);
- *NewDevicePath = AppendDevicePathNode (DevicePath, (CONST EFI_DEVICE_PATH_PROTOCOL *)FilePathDevicePath);
- FreePool(DevicePath);
-
- if (BootType != NULL || Attributes != NULL) {
- return BootDeviceGetType (FilePathDevicePath->PathName, BootType, Attributes);
- }
-
- return EFI_SUCCESS;
-}
-
+ *NewDevicePath = AppendDevicePathNode (DevicePath, (CONST EFI_DEVICE_PATH_PROTOCOL *)FilePathDevicePath);
+ FreePool(DevicePath);
+
+ return EFI_SUCCESS;
+}
+
BOOLEAN
BdsLoadOptionFileSystemIsSupported (
IN EFI_DEVICE_PATH *DevicePath
@@ -538,14 +569,13 @@ BdsLoadOptionMemMapList (
}
EFI_STATUS
-BdsLoadOptionMemMapCreateDevicePath (
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- )
-{
- EFI_STATUS Status;
+BdsLoadOptionMemMapCreateDevicePath (
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
+ OUT BOOLEAN *RequestBootType
+ )
+{
+ EFI_STATUS Status;
MEMMAP_DEVICE_PATH *MemMapDevicePath;
CHAR16 StrStartingAddress[BOOT_DEVICE_ADDRESS_MAX];
CHAR16 StrEndingAddress[BOOT_DEVICE_ADDRESS_MAX];
@@ -570,33 +600,23 @@ BdsLoadOptionMemMapCreateDevicePath (
MemMapDevicePath->MemoryType = EfiBootServicesData;
MemMapDevicePath->StartingAddress = StrHexToUint64 (StrStartingAddress);
MemMapDevicePath->EndingAddress = StrHexToUint64 (StrEndingAddress);
-
- // Set a Device Path End Node after the Memory Map Device Path Node
- SetDevicePathEndNode (MemMapDevicePath + 1);
-
- if (BootType != NULL || Attributes != NULL) {
- Status = BootDeviceGetType (NULL, BootType, Attributes);
- }
-
- if (EFI_ERROR(Status)) {
- FreePool (MemMapDevicePath);
- } else {
- *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)MemMapDevicePath;
- }
-
- return Status;
-}
+
+ // Set a Device Path End Node after the Memory Map Device Path Node
+ SetDevicePathEndNode (MemMapDevicePath + 1);
+ *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)MemMapDevicePath;
+
+ return Status;
+}
EFI_STATUS
BdsLoadOptionMemMapUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- )
-{
- EFI_STATUS Status;
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT BOOLEAN *RequestBootType
+ )
+{
+ EFI_STATUS Status;
CHAR16 StrStartingAddress[BOOT_DEVICE_ADDRESS_MAX];
CHAR16 StrEndingAddress[BOOT_DEVICE_ADDRESS_MAX];
MEMMAP_DEVICE_PATH* EndingDevicePath;
@@ -619,16 +639,12 @@ BdsLoadOptionMemMapUpdateDevicePath (
return EFI_ABORTED;
}
- EndingDevicePath->StartingAddress = StrHexToUint64 (StrStartingAddress);
- EndingDevicePath->EndingAddress = StrHexToUint64 (StrEndingAddress);
-
- if (BootType != NULL || Attributes != NULL) {
- Status = BootDeviceGetType (NULL, BootType, Attributes);
- }
-
- if (EFI_ERROR(Status)) {
- FreePool(DevicePath);
- } else {
+ EndingDevicePath->StartingAddress = StrHexToUint64 (StrStartingAddress);
+ EndingDevicePath->EndingAddress = StrHexToUint64 (StrEndingAddress);
+
+ if (EFI_ERROR(Status)) {
+ FreePool(DevicePath);
+ } else {
*NewDevicePath = DevicePath;
}
@@ -696,33 +712,34 @@ BdsLoadOptionPxeList (
}
EFI_STATUS
-BdsLoadOptionPxeCreateDevicePath (
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- )
-{
- *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
- SetDevicePathEndNode (*DevicePathNodes);
- *BootType = BDS_LOADER_EFI_APPLICATION;
- return EFI_SUCCESS;
-}
-
+BdsLoadOptionPxeCreateDevicePath (
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
+ OUT BOOLEAN *RequestBootType
+ )
+{
+ *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
+ SetDevicePathEndNode (*DevicePathNodes);
+
+ if (RequestBootType) {
+ *RequestBootType = FALSE;
+ }
+ return EFI_SUCCESS;
+}
+
EFI_STATUS
BdsLoadOptionPxeUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- )
-{
- ASSERT (0);
- return EFI_SUCCESS;
-}
-
-BOOLEAN
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT BOOLEAN *RequestBootType
+ )
+{
+ ASSERT (0);
+ return EFI_UNSUPPORTED;
+}
+
+BOOLEAN
BdsLoadOptionPxeIsSupported (
IN EFI_DEVICE_PATH *DevicePath
)
@@ -798,14 +815,13 @@ BdsLoadOptionTftpList (
}
EFI_STATUS
-BdsLoadOptionTftpCreateDevicePath (
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- )
-{
- EFI_STATUS Status;
+BdsLoadOptionTftpCreateDevicePath (
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
+ OUT BOOLEAN *RequestBootType
+ )
+{
+ EFI_STATUS Status;
BOOLEAN IsDHCP;
EFI_IP_ADDRESS LocalIp;
EFI_IP_ADDRESS RemoteIp;
@@ -865,37 +881,27 @@ BdsLoadOptionTftpCreateDevicePath (
FilePathDevicePath->Header.SubType = MEDIA_FILEPATH_DP;
SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);
CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);
-
- // Set the End Device Path Node
- SetDevicePathEndNode ((VOID*)((UINTN)FilePathDevicePath + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize));
-
- if (BootType != NULL || Attributes != NULL) {
- Status = BootDeviceGetType (NULL, BootType, Attributes);
- }
-
- if (EFI_ERROR(Status)) {
- FreePool (IPv4DevicePathNode);
- } else {
- *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)IPv4DevicePathNode;
- }
-
- return Status;
-}
+
+ // Set the End Device Path Node
+ SetDevicePathEndNode ((VOID*)((UINTN)FilePathDevicePath + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize));
+ *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)IPv4DevicePathNode;
+
+ return Status;
+}
EFI_STATUS
BdsLoadOptionTftpUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
- )
-{
- ASSERT (0);
- return EFI_SUCCESS;
-}
-
-BOOLEAN
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT BOOLEAN *RequestBootType
+ )
+{
+ ASSERT (0);
+ return EFI_UNSUPPORTED;
+}
+
+BOOLEAN
BdsLoadOptionTftpIsSupported (
IN EFI_DEVICE_PATH *DevicePath
)