/** @file\r
*\r
-* Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
+* Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.\r
*\r
* This program and the accompanying materials\r
* are licensed and made available under the terms and conditions of the BSD License\r
BDS_SUPPORTED_DEVICE* SupportedBootDevice;\r
ARM_BDS_LOADER_ARGUMENTS* BootArguments;\r
CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];\r
- CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];\r
+ CHAR8 AsciiCmdLine[BOOT_DEVICE_OPTION_MAX];\r
+ CHAR16 CmdLine[BOOT_DEVICE_OPTION_MAX];\r
UINT32 Attributes;\r
ARM_BDS_LOADER_TYPE BootType;\r
BDS_LOAD_OPTION_ENTRY *BdsLoadOptionEntry;\r
}\r
\r
// Create the specific device path node\r
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes, &BootType, &Attributes);\r
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes);\r
if (EFI_ERROR(Status)) {\r
Status = EFI_ABORTED;\r
goto EXIT;\r
goto EXIT;\r
}\r
\r
+ if (SupportedBootDevice->Support->RequestBootType) {\r
+ Status = BootDeviceGetType (DevicePath, &BootType, &Attributes);\r
+ if (EFI_ERROR(Status)) {\r
+ Status = EFI_ABORTED;\r
+ goto EXIT;\r
+ }\r
+ } else {\r
+ BootType = BDS_LOADER_EFI_APPLICATION;\r
+ }\r
+\r
if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {\r
Print(L"Add an initrd: ");\r
Status = GetHIInputBoolean (&InitrdSupport);\r
\r
if (InitrdSupport) {\r
// Create the specific device path node\r
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes, NULL, NULL);\r
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes);\r
if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd\r
Status = EFI_ABORTED;\r
goto EXIT;\r
}\r
\r
Print(L"Arguments to pass to the binary: ");\r
- Status = GetHIInputAscii (CmdLine,BOOT_DEVICE_OPTION_MAX);\r
+ Status = GetHIInputAscii (AsciiCmdLine, BOOT_DEVICE_OPTION_MAX);\r
if (EFI_ERROR(Status)) {\r
Status = EFI_ABORTED;\r
goto FREE_DEVICE_PATH;\r
}\r
\r
- CmdLineSize = AsciiStrSize (CmdLine);\r
+ CmdLineSize = AsciiStrSize (AsciiCmdLine);\r
InitrdSize = GetDevicePathSize (InitrdPath);\r
\r
OptionalDataSize = sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize;\r
\r
BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;\r
BootArguments->LinuxArguments.InitrdSize = InitrdSize;\r
- CopyMem ((VOID*)(&BootArguments->LinuxArguments + 1), CmdLine, CmdLineSize);\r
+ CopyMem ((VOID*)(&BootArguments->LinuxArguments + 1), AsciiCmdLine, CmdLineSize);\r
CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);\r
\r
OptionalData = (UINT8*)BootArguments;\r
} else {\r
- OptionalData = NULL;\r
- OptionalDataSize = 0;\r
+ Print (L"Arguments to pass to the EFI Application: ");\r
+ Status = GetHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);\r
+ if (EFI_ERROR (Status)) {\r
+ Status = EFI_ABORTED;\r
+ goto EXIT;\r
+ }\r
+\r
+ OptionalData = (UINT8*)CmdLine;\r
+ OptionalDataSize = StrSize (CmdLine);\r
}\r
\r
Print(L"Description for this new Entry: ");\r
BootMenuSelectBootOption (\r
IN LIST_ENTRY* BootOptionsList,\r
IN CONST CHAR16* InputStatement,\r
- IN BOOLEAN OnlyArmBdsBootEntry,\r
OUT BDS_LOAD_OPTION_ENTRY** BdsLoadOptionEntry\r
)\r
{\r
UINTN BootOptionSelected;\r
UINTN BootOptionCount;\r
UINTN Index;\r
+ BOOLEAN IsUnicode;\r
\r
// Display the list of supported boot devices\r
BootOptionCount = 0;\r
{\r
BdsLoadOption = LOAD_OPTION_FROM_LINK(Entry);\r
\r
- if (OnlyArmBdsBootEntry && !IS_ARM_BDS_BOOTENTRY (BdsLoadOption)) {\r
- continue;\r
- }\r
-\r
Print (L"[%d] %s\n", (BootOptionCount + 1), BdsLoadOption->Description);\r
\r
DEBUG_CODE_BEGIN();\r
\r
Print(L"\t- %s\n",DevicePathTxt);\r
OptionalData = BdsLoadOption->OptionalData;\r
- LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);\r
- if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT)) {\r
- Print (L"\t- Arguments: %a\n",&OptionalData->Arguments.LinuxArguments + 1);\r
+ if (IS_ARM_BDS_BOOTENTRY (BdsLoadOption)) {\r
+ LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);\r
+ if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT)) {\r
+ Print (L"\t- Arguments: %a\n",&OptionalData->Arguments.LinuxArguments + 1);\r
+ }\r
+ } else if (OptionalData != NULL) {\r
+ if (IsPrintableString (OptionalData, &IsUnicode)) {\r
+ if (IsUnicode) {\r
+ Print (L"\t- Arguments: %s\n", OptionalData);\r
+ } else {\r
+ AsciiPrint ("\t- Arguments: %a\n", OptionalData);\r
+ }\r
+ }\r
}\r
\r
FreePool(DevicePathTxt);\r
EFI_STATUS Status;\r
BDS_LOAD_OPTION_ENTRY* BootOptionEntry;\r
\r
- Status = BootMenuSelectBootOption (BootOptionsList, DELETE_BOOT_ENTRY, FALSE, &BootOptionEntry);\r
+ Status = BootMenuSelectBootOption (BootOptionsList, DELETE_BOOT_ENTRY, &BootOptionEntry);\r
if (EFI_ERROR(Status)) {\r
return Status;\r
}\r
ARM_BDS_LOADER_ARGUMENTS* BootArguments;\r
CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];\r
CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];\r
+ CHAR16 UnicodeCmdLine[BOOT_DEVICE_OPTION_MAX];\r
EFI_DEVICE_PATH *DevicePath;\r
EFI_DEVICE_PATH *TempInitrdPath;\r
ARM_BDS_LOADER_TYPE BootType;\r
BOOLEAN InitrdSupport;\r
UINT8* OptionalData;\r
UINTN OptionalDataSize;\r
+ BOOLEAN IsPrintable;\r
+ BOOLEAN IsUnicode;\r
\r
- Status = BootMenuSelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, TRUE, &BootOptionEntry);\r
+ Status = BootMenuSelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, &BootOptionEntry);\r
if (EFI_ERROR(Status)) {\r
return Status;\r
}\r
return EFI_UNSUPPORTED;\r
}\r
\r
- Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath, NULL, NULL);\r
+ Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath);\r
if (EFI_ERROR(Status)) {\r
Status = EFI_ABORTED;\r
goto EXIT;\r
}\r
\r
+ if (DeviceSupport->RequestBootType) {\r
+ Status = BootDeviceGetType (DevicePath, &BootType, &BootOption->Attributes);\r
+ if (EFI_ERROR(Status)) {\r
+ Status = EFI_ABORTED;\r
+ goto EXIT;\r
+ }\r
+ }\r
+\r
LoaderOptionalData = BootOption->OptionalData;\r
- BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&LoaderOptionalData->Header.LoaderType));\r
+ if (LoaderOptionalData != NULL) {\r
+ BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&LoaderOptionalData->Header.LoaderType));\r
+ } else {\r
+ BootType = BDS_LOADER_EFI_APPLICATION;\r
+ }\r
\r
if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {\r
LinuxArguments = &LoaderOptionalData->Arguments.LinuxArguments;\r
if (InitrdSupport) {\r
if (InitrdSize > 0) {\r
// Case we update the initrd device path\r
- Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize), L"initrd", &InitrdPath, NULL, NULL);\r
+ Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize), L"initrd", &InitrdPath);\r
if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {// EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd\r
Status = EFI_ABORTED;\r
goto EXIT;\r
} else {\r
// Case we create the initrd device path\r
\r
- Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNodes, NULL, NULL);\r
+ Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNodes);\r
if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd\r
Status = EFI_ABORTED;\r
goto EXIT;\r
\r
OptionalData = (UINT8*)BootArguments;\r
} else {\r
- OptionalData = NULL;\r
- OptionalDataSize = 0;\r
+ Print (L"Arguments to pass to the EFI Application: ");\r
+\r
+ if (BootOption->OptionalDataSize > 0) {\r
+ IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);\r
+ if (IsPrintable) {\r
+ if (IsUnicode) {\r
+ StrnCpy (UnicodeCmdLine, BootOption->OptionalData, BootOption->OptionalDataSize / 2);\r
+ } else {\r
+ AsciiStrnCpy (CmdLine, BootOption->OptionalData, BootOption->OptionalDataSize);\r
+ }\r
+ }\r
+ } else {\r
+ UnicodeCmdLine[0] = L'\0';\r
+ IsPrintable = TRUE;\r
+ IsUnicode = TRUE;\r
+ }\r
+\r
+ // We do not request arguments for OptionalData that cannot be printed\r
+ if (IsPrintable) {\r
+ if (IsUnicode) {\r
+ Status = EditHIInputStr (UnicodeCmdLine, BOOT_DEVICE_OPTION_MAX);\r
+ if (EFI_ERROR (Status)) {\r
+ Status = EFI_ABORTED;\r
+ goto FREE_DEVICE_PATH;\r
+ }\r
+\r
+ OptionalData = (UINT8*)UnicodeCmdLine;\r
+ OptionalDataSize = StrSize (UnicodeCmdLine);\r
+ } else {\r
+ Status = EditHIInputAscii (CmdLine, BOOT_DEVICE_OPTION_MAX);\r
+ if (EFI_ERROR (Status)) {\r
+ Status = EFI_ABORTED;\r
+ goto FREE_DEVICE_PATH;\r
+ }\r
+\r
+ OptionalData = (UINT8*)CmdLine;\r
+ OptionalDataSize = AsciiStrSize (CmdLine);\r
+ }\r
+ } else {\r
+ // We keep the former OptionalData\r
+ OptionalData = BootOption->OptionalData;\r
+ OptionalDataSize = BootOption->OptionalDataSize;\r
+ }\r
}\r
\r
Print(L"Description for this new Entry: ");\r
}\r
\r
// Create the specific device path node\r
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"FDT blob", &FdtDevicePathNodes, NULL, NULL);\r
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"FDT blob", &FdtDevicePathNodes);\r
if (EFI_ERROR(Status)) {\r
Status = EFI_ABORTED;\r
goto EXIT;\r
return Status;\r
}\r
\r
+/**\r
+ Set boot timeout\r
+\r
+ Ask for the boot timeout in seconds and if the input succeeds assign the\r
+ input value to the UEFI global variable "Timeout". This function is called\r
+ when the user selects the "Set Boot Timeout" of the boot manager menu.\r
+\r
+ @param[in] BootOptionsList List of the boot devices, not used here\r
+\r
+ @retval EFI_SUCCESS Boot timeout in second retrieved from the standard\r
+ input and assigned to the UEFI "Timeout" global\r
+ variable\r
+ @retval !EFI_SUCCESS Either the input or the setting of the UEFI global\r
+ variable "Timeout" has failed.\r
+**/\r
+EFI_STATUS\r
+STATIC\r
+BootMenuSetBootTimeout (\r
+ IN LIST_ENTRY *BootOptionsList\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN Input;\r
+ UINT16 Timeout;\r
+\r
+ Print (L"Timeout duration (in seconds): ");\r
+ Status = GetHIInputInteger (&Input);\r
+ if (EFI_ERROR (Status)) {\r
+ Print (L"\n");\r
+ goto ErrorExit;\r
+ }\r
+\r
+ Timeout = Input;\r
+ Status = gRT->SetVariable (\r
+ (CHAR16*)L"Timeout",\r
+ &gEfiGlobalVariableGuid,\r
+ EFI_VARIABLE_NON_VOLATILE |\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |\r
+ EFI_VARIABLE_RUNTIME_ACCESS,\r
+ sizeof (UINT16),\r
+ &Timeout\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ErrorExit:\r
+ return Status;\r
+}\r
+\r
struct BOOT_MANAGER_ENTRY {\r
CONST CHAR16* Description;\r
EFI_STATUS (*Callback) (IN LIST_ENTRY *BootOptionsList);\r
{ L"Update Boot Device Entry", BootMenuUpdateBootOption },\r
{ L"Remove Boot Device Entry", BootMenuRemoveBootOption },\r
{ L"Update FDT path", UpdateFdtPath },\r
+ { L"Set Boot Timeout", BootMenuSetBootTimeout },\r
};\r
\r
EFI_STATUS\r
UINTN BootOptionSelected;\r
UINTN Index;\r
UINTN BootMainEntryCount;\r
+ BOOLEAN IsUnicode;\r
\r
- BootOption = NULL;\r
+ BootOption = NULL;\r
BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY);\r
\r
while (TRUE) {\r
GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(&OptionalData->Arguments.LinuxArguments + 1) + CmdLineSize)), TRUE, TRUE);\r
Print(L"\t- Initrd: %s\n", DevicePathTxt);\r
}\r
- Print(L"\t- Arguments: %a\n", (&OptionalData->Arguments.LinuxArguments + 1));\r
+ if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize) > 0) {\r
+ Print(L"\t- Arguments: %a\n", (&OptionalData->Arguments.LinuxArguments + 1));\r
+ }\r
}\r
\r
switch (LoaderType) {\r
default:\r
Print(L"\t- LoaderType: Not recognized (%d)\n", LoaderType);\r
}\r
+ } else if (BootOption->OptionalData != NULL) {\r
+ if (IsPrintableString (BootOption->OptionalData, &IsUnicode)) {\r
+ if (IsUnicode) {\r
+ Print (L"\t- Arguments: %s\n", BootOption->OptionalData);\r
+ } else {\r
+ AsciiPrint ("\t- Arguments: %a\n", BootOption->OptionalData);\r
+ }\r
+ }\r
}\r
FreePool(DevicePathTxt);\r
DEBUG_CODE_END();\r