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
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, UPDATE_BOOT_ENTRY, TRUE, &BootOptionEntry);\r
if (EFI_ERROR(Status)) {\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"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
\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
+ 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
- InitrdSize = GetDevicePathSize (InitrdPathList);\r
+ } else {\r
+ InitrdSize = 0;\r
}\r
\r
Print(L"Arguments to pass to the binary: "); \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