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
EFI_DEVICE_PATH_PROTOCOL *InitrdPathNode;\r
EFI_DEVICE_PATH_PROTOCOL *InitrdPath;\r
UINTN CmdLineSize;\r
+ BOOLEAN InitrdSupport;\r
UINTN InitrdSize;\r
\r
Attributes = 0;\r
}\r
\r
// Create the specific device path node\r
- Print(L"File path of the EFI Application or the kernel: ");\r
- Status = SupportedBootDevice->Support->CreateDevicePathNode (SupportedBootDevice, &DevicePathNode, &BootType, &Attributes);\r
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNode, &BootType, &Attributes);\r
if (EFI_ERROR(Status)) {\r
Status = EFI_ABORTED;\r
goto EXIT;\r
DevicePath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode);\r
\r
if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {\r
- // Create the specific device path node\r
- Print(L"File path of the initrd: ");\r
- Status = SupportedBootDevice->Support->CreateDevicePathNode (SupportedBootDevice, &InitrdPathNode, 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
+ Print(L"Add an initrd: ");\r
+ Status = GetHIInputBoolean (&InitrdSupport);\r
+ if (EFI_ERROR(Status)) {\r
Status = EFI_ABORTED;\r
goto EXIT;\r
}\r
\r
- if (InitrdPathNode != NULL) {\r
- // Append the Device Path node to the select device path\r
- InitrdPath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode);\r
+ if (InitrdSupport) {\r
+ // Create the specific device path node\r
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNode, 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
+\r
+ if (InitrdPathNode != NULL) {\r
+ // Append the Device Path node to the select device path\r
+ InitrdPath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode);\r
+ } else {\r
+ InitrdPath = NULL;\r
+ }\r
} else {\r
InitrdPath = NULL;\r
}\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
continue;\r
}\r
\r
- Print (L"[%d] %s\n", BootOptionCount, BdsLoadOption->Description);\r
+ Print (L"[%d] %s\n", (BootOptionCount + 1), BdsLoadOption->Description);\r
\r
DEBUG_CODE_BEGIN();\r
CHAR16* DevicePathTxt;\r
BootOptionCount++;\r
}\r
\r
+ // Check if a valid boot option(s) is found\r
if (BootOptionCount == 0) {\r
- Print (L"No supported Boot Entry.\n");\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
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
EFI_STATUS Status;\r
BDS_LOAD_OPTION_ENTRY* BootOptionEntry;\r
\r
- Status = BootMenuSelectBootOption (BootOptionsList, L"Delete entry: ", FALSE, &BootOptionEntry);\r
+ Status = BootMenuSelectBootOption (BootOptionsList, DELETE_BOOT_ENTRY, FALSE, &BootOptionEntry);\r
if (EFI_ERROR(Status)) {\r
return Status;\r
}\r
ARM_BDS_LOADER_TYPE BootType;\r
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;\r
ARM_BDS_LINUX_ARGUMENTS* LinuxArguments;\r
- EFI_DEVICE_PATH* InitrdPathList;\r
+ EFI_DEVICE_PATH *InitrdPathNode;\r
+ EFI_DEVICE_PATH *InitrdPath;\r
UINTN InitrdSize;\r
UINTN CmdLineSize;\r
+ BOOLEAN InitrdSupport;\r
\r
- Status = BootMenuSelectBootOption (BootOptionsList, L"Update entry: ", TRUE, &BootOptionEntry);\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->FilePathList, &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
- Print(L"File path of the EFI Application or the kernel: ");\r
- Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, &DevicePath, NULL, NULL);\r
+ Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath, NULL, NULL);\r
if (EFI_ERROR(Status)) {\r
Status = EFI_ABORTED;\r
goto EXIT;\r
OptionalData = BootOption->OptionalData;\r
BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&OptionalData->Header.LoaderType));\r
\r
- // TODO: Allow adding an initrd to a boot entry without one\r
if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {\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
+ InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);\r
+ if (InitrdSize > 0) {\r
+ Print(L"Keep the initrd: ");\r
+ } else {\r
+ Print(L"Add an initrd: ");\r
+ }\r
+ Status = GetHIInputBoolean (&InitrdSupport);\r
+ if (EFI_ERROR(Status)) {\r
Status = EFI_ABORTED;\r
goto EXIT;\r
}\r
\r
+ if (InitrdSupport) {\r
+ if (InitrdSize > 0) {\r
+ // Case we update the initrd device path\r
+ Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((LinuxArguments + 1) + CmdLineSize), L"initrd", &InitrdPath, 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 (InitrdPath);\r
+ } else {\r
+ // Case we create the initrd device path\r
+\r
+ Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNode, 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
+\r
+ if (InitrdPathNode != NULL) {\r
+ // Duplicate Linux kernel Device Path\r
+ DevicePath = DuplicateDevicePath (BootOption->FilePathList);\r
+ // Replace Linux kernel Node by EndNode\r
+ SetDevicePathEndNode (GetLastDevicePathNode (DevicePath));\r
+ // Append the Device Path node to the select device path\r
+ InitrdPath = AppendDevicePathNode (DevicePath, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode);\r
+ } else {\r
+ InitrdPath = NULL;\r
+ }\r
+ }\r
+ } else {\r
+ InitrdSize = 0;\r
+ }\r
+\r
Print(L"Arguments to pass to the binary: "); \r
if (CmdLineSize > 0) {\r
AsciiStrnCpy(CmdLine, (CONST CHAR8*)(LinuxArguments + 1), CmdLineSize);\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
BootArguments->LinuxArguments.InitrdSize = InitrdSize;\r
CopyMem (&BootArguments->LinuxArguments + 1, CmdLine, CmdLineSize);\r
- CopyMem ((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLine, InitrdPathList, InitrdSize);\r
+ CopyMem ((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLine, InitrdPath, InitrdSize);\r
} else {\r
BootArguments = NULL;\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
return Status;\r
}\r
\r
+EFI_STATUS\r
+UpdateFdtPath (\r
+ IN LIST_ENTRY *BootOptionsList\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ BDS_SUPPORTED_DEVICE *SupportedBootDevice;\r
+ EFI_DEVICE_PATH_PROTOCOL *FdtDevicePathNode;\r
+ EFI_DEVICE_PATH_PROTOCOL *FdtDevicePath;\r
+\r
+ Status = SelectBootDevice (&SupportedBootDevice);\r
+ if (EFI_ERROR(Status)) {\r
+ Status = EFI_ABORTED;\r
+ goto EXIT;\r
+ }\r
+\r
+ // Create the specific device path node\r
+ Print(L"File path of the FDT blob: ");\r
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (SupportedBootDevice, &FdtDevicePathNode, NULL, NULL);\r
+ if (EFI_ERROR(Status)) {\r
+ Status = EFI_ABORTED;\r
+ goto EXIT;\r
+ }\r
+\r
+ if (FdtDevicePathNode != NULL) {\r
+ // Append the Device Path node to the select device path\r
+ FdtDevicePath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, FdtDevicePathNode);\r
+ Status = gRT->SetVariable ((CHAR16*)L"FDT", &gEfiGlobalVariableGuid, (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS ), 4, &FdtDevicePath);\r
+ ASSERT_EFI_ERROR(Status);\r
+ } else {\r
+ gRT->SetVariable ((CHAR16*)L"FDT", &gEfiGlobalVariableGuid, (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS ), 0, NULL);\r
+ ASSERT_EFI_ERROR(Status);\r
+ }\r
+\r
+EXIT:\r
+ if (Status == EFI_ABORTED) {\r
+ Print(L"\n");\r
+ }\r
+ FreePool(SupportedBootDevice);\r
+ return Status;\r
+}\r
+\r
struct BOOT_MANAGER_ENTRY {\r
CONST CHAR16* Description;\r
EFI_STATUS (*Callback) (IN LIST_ENTRY *BootOptionsList);\r
{ L"Add Boot Device Entry", BootMenuAddBootOption },\r
{ L"Update Boot Device Entry", BootMenuUpdateBootOption },\r
{ L"Remove Boot Device Entry", BootMenuRemoveBootOption },\r
+ { L"Update FDT path", UpdateFdtPath },\r
};\r
\r
EFI_STATUS\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
{\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