+ OptionalData = BootOption->OptionalData;\r
+ BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&OptionalData->Header.LoaderType));\r
+\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
+\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*)((UINTN)(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
+ TempInitrdPath = DuplicateDevicePath (BootOption->FilePathList);\r
+ // Replace Linux kernel Node by EndNode\r
+ SetDevicePathEndNode (GetLastDevicePathNode (TempInitrdPath));\r
+ // Append the Device Path node to the select device path\r
+ InitrdPath = AppendDevicePathNode (TempInitrdPath, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode);\r
+ FreePool (TempInitrdPath);\r
+ InitrdSize = GetDevicePathSize (InitrdPath);\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
+ } else {\r
+ CmdLine[0] = '\0';\r
+ }\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
+ CmdLineSize = AsciiStrSize (CmdLine);\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 ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);\r