CHAR16* DevicePathTxt;\r
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;\r
\r
- Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);\r
+ Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);\r
ASSERT_EFI_ERROR(Status);\r
- DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText((*SupportedBootDevice)->DevicePathProtocol,TRUE,TRUE);\r
+ DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText ((*SupportedBootDevice)->DevicePathProtocol,TRUE,TRUE);\r
\r
Print(L"\t- %s\n",DevicePathTxt);\r
\r
Status = EFI_ABORTED;\r
goto EXIT;\r
} else if ((SupportedDeviceSelected == 0) || (SupportedDeviceSelected > SupportedDeviceCount)) {\r
- Print(L"Invalid input (max %d)\n",SupportedDeviceSelected);\r
+ Print(L"Invalid input (max %d)\n",SupportedDeviceCount);\r
SupportedDeviceSelected = 0;\r
}\r
}\r
CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];\r
UINT32 Attributes;\r
ARM_BDS_LOADER_TYPE BootType;\r
- BDS_LOAD_OPTION *BdsLoadOption;\r
+ BDS_LOAD_OPTION_ENTRY *BdsLoadOptionEntry;\r
EFI_DEVICE_PATH *DevicePath;\r
EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;\r
EFI_DEVICE_PATH_PROTOCOL *InitrdPathNode;\r
}\r
\r
// Create new entry\r
- Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, &BootArguments, &BdsLoadOption);\r
+ BdsLoadOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool (sizeof(BDS_LOAD_OPTION_ENTRY));\r
+ Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, BootArguments, &BdsLoadOptionEntry->BdsLoadOption);\r
if (!EFI_ERROR(Status)) {\r
- InsertTailList (BootOptionsList,&BdsLoadOption->Link);\r
+ InsertTailList (BootOptionsList, &BdsLoadOptionEntry->Link);\r
}\r
\r
FREE_DEVICE_PATH:\r
STATIC\r
EFI_STATUS\r
BootMenuSelectBootOption (\r
- IN LIST_ENTRY *BootOptionsList,\r
- IN CONST CHAR16* InputStatement,\r
- OUT BDS_LOAD_OPTION **BdsLoadOption\r
+ IN LIST_ENTRY* BootOptionsList,\r
+ IN CONST CHAR16* InputStatement,\r
+ IN BOOLEAN OnlyArmBdsBootEntry,\r
+ OUT BDS_LOAD_OPTION_ENTRY** BdsLoadOptionEntry\r
)\r
{\r
- EFI_STATUS Status;\r
- LIST_ENTRY* Entry;\r
- BDS_LOAD_OPTION *BootOption;\r
- UINTN BootOptionSelected;\r
- UINTN BootOptionCount;\r
- UINTN Index;\r
+ EFI_STATUS Status;\r
+ LIST_ENTRY* Entry;\r
+ BDS_LOAD_OPTION* BdsLoadOption;\r
+ UINTN BootOptionSelected;\r
+ UINTN BootOptionCount;\r
+ UINTN Index;\r
\r
// Display the list of supported boot devices\r
- BootOptionCount = 1;\r
+ BootOptionCount = 0;\r
for (Entry = GetFirstNode (BootOptionsList);\r
!IsNull (BootOptionsList,Entry);\r
- Entry = GetNextNode (BootOptionsList,Entry)\r
+ Entry = GetNextNode (BootOptionsList, Entry)\r
)\r
{\r
- BootOption = LOAD_OPTION_FROM_LINK(Entry);\r
- Print(L"[%d] %s\n",BootOptionCount,BootOption->Description);\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
CHAR16* DevicePathTxt;\r
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;\r
ARM_BDS_LOADER_TYPE LoaderType;\r
+ ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;\r
\r
Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);\r
ASSERT_EFI_ERROR(Status);\r
- DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BootOption->FilePathList,TRUE,TRUE);\r
+ DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BdsLoadOption->FilePathList,TRUE,TRUE);\r
\r
Print(L"\t- %s\n",DevicePathTxt);\r
OptionalData = BdsLoadOption->OptionalData;\r
BootOptionCount++;\r
}\r
\r
+ // Check if a valid boot option(s) is found\r
+ if (BootOptionCount == 0) {\r
+ if (StrCmp (InputStatement, DELETE_BOOT_ENTRY) == 0) {\r
+ Print (L"Nothing to remove!\n");\r
+ }else if (StrCmp (InputStatement, UPDATE_BOOT_ENTRY) == 0) {\r
+ Print (L"Couldn't find valid boot entries\n");\r
+ } else{\r
+ Print (L"No supported Boot Entry.\n");\r
+ }\r
+\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
// Get the index of the boot device to delete\r
BootOptionSelected = 0;\r
while (BootOptionSelected == 0) {\r
Status = GetHIInputInteger (&BootOptionSelected);\r
if (EFI_ERROR(Status)) {\r
return Status;\r
- } else if ((BootOptionSelected == 0) || (BootOptionSelected >= BootOptionCount)) {\r
- Print(L"Invalid input (max %d)\n",BootOptionCount-1);\r
+ } else if ((BootOptionSelected == 0) || (BootOptionSelected > BootOptionCount)) {\r
+ Print(L"Invalid input (max %d)\n",BootOptionCount);\r
BootOptionSelected = 0;\r
}\r
}\r
// Get the structure of the Boot device to delete\r
Index = 1;\r
for (Entry = GetFirstNode (BootOptionsList);\r
- !IsNull (BootOptionsList,Entry);\r
+ !IsNull (BootOptionsList, Entry);\r
Entry = GetNextNode (BootOptionsList,Entry)\r
)\r
{\r
if (Index == BootOptionSelected) {\r
- *BdsLoadOption = LOAD_OPTION_FROM_LINK(Entry);\r
+ *BdsLoadOptionEntry = LOAD_OPTION_ENTRY_FROM_LINK(Entry);\r
break;\r
}\r
Index++;\r
IN LIST_ENTRY *BootOptionsList\r
)\r
{\r
- EFI_STATUS Status;\r
- BDS_LOAD_OPTION *BootOption;\r
+ EFI_STATUS Status;\r
+ BDS_LOAD_OPTION_ENTRY* BootOptionEntry;\r
\r
- Status = BootMenuSelectBootOption (BootOptionsList,L"Delete entry: ",&BootOption);\r
+ Status = BootMenuSelectBootOption (BootOptionsList, DELETE_BOOT_ENTRY, FALSE, &BootOptionEntry);\r
if (EFI_ERROR(Status)) {\r
return Status;\r
}\r
\r
+ // If the Boot Option was attached to a list remove it\r
+ if (!IsListEmpty (&BootOptionEntry->Link)) {\r
+ // Remove the entry from the list\r
+ RemoveEntryList (&BootOptionEntry->Link);\r
+ }\r
+\r
// Delete the BDS Load option structures\r
- BootOptionDelete (BootOption);\r
+ BootOptionDelete (BootOptionEntry->BdsLoadOption);\r
\r
return EFI_SUCCESS;\r
}\r
)\r
{\r
EFI_STATUS Status;\r
+ BDS_LOAD_OPTION_ENTRY *BootOptionEntry;\r
BDS_LOAD_OPTION *BootOption;\r
BDS_LOAD_OPTION_SUPPORT* DeviceSupport;\r
ARM_BDS_LOADER_ARGUMENTS* BootArguments;\r
UINTN InitrdSize;\r
UINTN CmdLineSize;\r
\r
- Status = BootMenuSelectBootOption (BootOptionsList,L"Update entry: ",&BootOption);\r
+ Status = BootMenuSelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, TRUE, &BootOptionEntry);\r
if (EFI_ERROR(Status)) {\r
return Status;\r
}\r
+ BootOption = BootOptionEntry->BdsLoadOption;\r
\r
// Get the device support for this Boot Option\r
- Status = BootDeviceGetDeviceSupport (BootOption,&DeviceSupport);\r
+ Status = BootDeviceGetDeviceSupport (BootOption, &DeviceSupport);\r
if (EFI_ERROR(Status)) {\r
- Print(L"Impossible to retrieve the supported device for the update\n");\r
+ Print(L"Not possible to retrieve the supported device for the update\n");\r
return EFI_UNSUPPORTED;\r
}\r
\r
LinuxArguments = &OptionalData->Arguments.LinuxArguments;\r
\r
CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);\r
- InitrdSize = GetUnalignedDevicePathSize ((EFI_DEVICE_PATH*)((LinuxArguments + 1) + CmdLineSize));\r
\r
- Print(L"File path of the initrd: ");\r
- Status = DeviceSupport->UpdateDevicePathNode (\r
- (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)(LinuxArguments + 1) + CmdLineSize), &InitrdPathList, NULL, NULL);\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
+ InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);\r
+ if (InitrdSize > 0) {\r
+ Print(L"File path of the initrd: ");\r
+ Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((LinuxArguments + 1) + CmdLineSize), &InitrdPathList, NULL, NULL);\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
+ InitrdSize = GetDevicePathSize (InitrdPathList);\r
}\r
\r
Print(L"Arguments to pass to the binary: "); \r
}\r
\r
CmdLineSize = AsciiStrSize (CmdLine);\r
- InitrdSize = GetDevicePathSize (InitrdPathList);\r
\r
BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool(sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize);\r
BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;\r
}\r
\r
Print(L"Description for this new Entry: ");\r
+ StrnCpy (BootDescription, BootOption->Description, BOOT_DEVICE_DESCRIPTION_MAX);\r
Status = EditHIInputStr (BootDescription, BOOT_DEVICE_DESCRIPTION_MAX);\r
if (EFI_ERROR(Status)) {\r
Status = EFI_ABORTED;\r
}\r
return EFI_SUCCESS;\r
} else if ((OptionSelected > 0) && (OptionSelected <= BootManagerEntryCount)) {\r
- Status = BootManagerEntries[OptionSelected-1].Callback (BootOptionsList);\r
+ BootManagerEntries[OptionSelected-1].Callback (BootOptionsList);\r
}\r
}\r
-\r
- return EFI_SUCCESS;\r
+ // Should never go here\r
}\r
\r
EFI_STATUS\r
EFI_STATUS Status;\r
\r
// Start EFI Shell\r
- Status = BdsLoadApplication(mImageHandle, L"Ebl");\r
+ Status = BdsLoadApplication (mImageHandle, L"Ebl", 0, NULL);\r
if (Status == EFI_NOT_FOUND) {\r
Print (L"Error: EFI Application not found.\n");\r
} else if (EFI_ERROR(Status)) {\r
BootOption = NULL;\r
BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY);\r
\r
- // Get Boot#### list\r
- BootOptionList (&BootOptionsList);\r
-\r
while (TRUE) {\r
+ // Get Boot#### list\r
+ BootOptionList (&BootOptionsList);\r
+\r
OptionCount = 1;\r
\r
// Display the Boot options\r
{\r
BootOption = LOAD_OPTION_FROM_LINK(Entry);\r
\r
- Print(L"[%d] %s\n",OptionCount,BootOption->Description);\r
+ Print(L"[%d] %s\n", OptionCount, BootOption->Description);\r
\r
DEBUG_CODE_BEGIN();\r
CHAR16* DevicePathTxt;\r
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;\r
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;\r
UINTN CmdLineSize;\r
- ARM_BDS_LOADER_TYPE LoaderType;\r
+ ARM_BDS_LOADER_TYPE LoaderType;\r
\r
- Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);\r
+ Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);\r
if (EFI_ERROR(Status)) {\r
// You must provide an implementation of DevicePathToTextProtocol in your firmware (eg: DevicePathDxe)\r
DEBUG((EFI_D_ERROR,"Error: Bds requires DevicePathToTextProtocol\n"));\r
return Status;\r
}\r
- DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BootOption->FilePathList,TRUE,TRUE);\r
+ DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (BootOption->FilePathList, TRUE, TRUE);\r
\r
Print(L"\t- %s\n",DevicePathTxt);\r
\r
Status = BootOptionStart (BootOption);\r
}\r
}\r
-\r
- return Status;\r
+ // Should never go here\r
}\r