BDS_SUPPORTED_DEVICE_TYPE Type;\r
EFI_STATUS (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList);\r
BOOLEAN (*IsSupported)(IN EFI_DEVICE_PATH *DevicePath);\r
- EFI_STATUS (*CreateDevicePathNode)(IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);\r
+ EFI_STATUS (*CreateDevicePathNode)(IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);\r
EFI_STATUS (*UpdateDevicePathNode)(IN EFI_DEVICE_PATH *OldDevicePath, IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);\r
} BDS_LOAD_OPTION_SUPPORT;\r
\r
ARM_BDS_LOADER_TYPE BootType;\r
BDS_LOAD_OPTION_ENTRY *BdsLoadOptionEntry;\r
EFI_DEVICE_PATH *DevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;\r
- EFI_DEVICE_PATH_PROTOCOL *InitrdPathNode;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathNodes;\r
+ EFI_DEVICE_PATH_PROTOCOL *InitrdPathNodes;\r
EFI_DEVICE_PATH_PROTOCOL *InitrdPath;\r
UINTN CmdLineSize;\r
BOOLEAN InitrdSupport;\r
}\r
\r
// Create the specific device path node\r
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNode, &BootType, &Attributes);\r
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes, &BootType, &Attributes);\r
if (EFI_ERROR(Status)) {\r
Status = EFI_ABORTED;\r
goto EXIT;\r
}\r
- // Append the Device Path node to the select device path\r
- DevicePath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode);\r
+ // Append the Device Path to the selected device path\r
+ DevicePath = AppendDevicePath (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)DevicePathNodes);\r
+ if (DevicePath == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto EXIT;\r
+ }\r
\r
if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {\r
Print(L"Add an initrd: ");\r
\r
if (InitrdSupport) {\r
// Create the specific device path node\r
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNode, NULL, NULL);\r
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes, 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
+ if (InitrdPathNodes != NULL) {\r
+ // Append the Device Path to the selected device path\r
+ InitrdPath = AppendDevicePath (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);\r
+ if (InitrdPath == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto EXIT;\r
+ }\r
} else {\r
InitrdPath = NULL;\r
}\r
FREE_DEVICE_PATH:\r
FreePool (DevicePath);\r
\r
-\r
EXIT:\r
if (Status == EFI_ABORTED) {\r
Print(L"\n");\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
+ } 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
ARM_BDS_LOADER_TYPE BootType;\r
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;\r
ARM_BDS_LINUX_ARGUMENTS* LinuxArguments;\r
- EFI_DEVICE_PATH *InitrdPathNode;\r
+ EFI_DEVICE_PATH *InitrdPathNodes;\r
EFI_DEVICE_PATH *InitrdPath;\r
UINTN InitrdSize;\r
UINTN CmdLineSize;\r
} else {\r
// Case we create the initrd device path\r
\r
- Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNode, NULL, NULL);\r
+ Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNodes, 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
+ if (InitrdPathNodes != 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
+ // Append the Device Path to the selected device path\r
+ InitrdPath = AppendDevicePath (TempInitrdPath, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);\r
FreePool (TempInitrdPath);\r
+ if (InitrdPath == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto EXIT;\r
+ }\r
InitrdSize = GetDevicePathSize (InitrdPath);\r
} else {\r
InitrdPath = NULL;\r
EFI_STATUS Status;\r
UINTN FdtDevicePathSize;\r
BDS_SUPPORTED_DEVICE *SupportedBootDevice;\r
- EFI_DEVICE_PATH_PROTOCOL *FdtDevicePathNode;\r
+ EFI_DEVICE_PATH_PROTOCOL *FdtDevicePathNodes;\r
EFI_DEVICE_PATH_PROTOCOL *FdtDevicePath;\r
\r
Status = SelectBootDevice (&SupportedBootDevice);\r
}\r
\r
// Create the specific device path node\r
- Status = SupportedBootDevice->Support->CreateDevicePathNode (L"FDT blob", &FdtDevicePathNode, NULL, NULL);\r
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"FDT blob", &FdtDevicePathNodes, NULL, NULL);\r
if (EFI_ERROR(Status)) {\r
Status = EFI_ABORTED;\r
goto EXIT;\r
}\r
\r
- if (FdtDevicePathNode != NULL) {\r
+ if (FdtDevicePathNodes != NULL) {\r
// Append the Device Path node to the select device path\r
- FdtDevicePath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, FdtDevicePathNode);\r
+ FdtDevicePath = AppendDevicePath (SupportedBootDevice->DevicePathProtocol, FdtDevicePathNodes);\r
FdtDevicePathSize = GetDevicePathSize (FdtDevicePath);\r
Status = gRT->SetVariable (\r
(CHAR16*)L"Fdt",\r
EFI_STATUS\r
BdsLoadOptionFileSystemCreateDevicePath (\r
IN CHAR16* FileName,\r
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,\r
OUT ARM_BDS_LOADER_TYPE *BootType,\r
OUT UINT32 *Attributes\r
);\r
EFI_STATUS\r
BdsLoadOptionMemMapCreateDevicePath (\r
IN CHAR16* FileName,\r
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,\r
OUT ARM_BDS_LOADER_TYPE *BootType,\r
OUT UINT32 *Attributes\r
);\r
EFI_STATUS\r
BdsLoadOptionPxeCreateDevicePath (\r
IN CHAR16* FileName,\r
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,\r
OUT ARM_BDS_LOADER_TYPE *BootType,\r
OUT UINT32 *Attributes\r
);\r
EFI_STATUS\r
BdsLoadOptionTftpCreateDevicePath (\r
IN CHAR16* FileName,\r
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,\r
OUT ARM_BDS_LOADER_TYPE *BootType,\r
OUT UINT32 *Attributes\r
);\r
EFI_STATUS\r
BdsLoadOptionFileSystemCreateDevicePath (\r
IN CHAR16* FileName,\r
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,\r
OUT ARM_BDS_LOADER_TYPE *BootType,\r
OUT UINT32 *Attributes\r
)\r
\r
BootFilePathSize = StrSize (BootFilePath);\r
if (BootFilePathSize == 2) {\r
- *DevicePathNode = NULL;\r
+ *DevicePathNodes = NULL;\r
return EFI_NOT_FOUND;\r
}\r
\r
// Create the FilePath Device Path node\r
- FilePathDevicePath = (FILEPATH_DEVICE_PATH*)AllocatePool(SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\r
+ FilePathDevicePath = (FILEPATH_DEVICE_PATH*)AllocatePool(SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize + END_DEVICE_PATH_LENGTH);\r
FilePathDevicePath->Header.Type = MEDIA_DEVICE_PATH;\r
FilePathDevicePath->Header.SubType = MEDIA_FILEPATH_DP;\r
SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\r
CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);\r
+ SetDevicePathEndNode ((VOID*)((UINTN)FilePathDevicePath + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize));\r
\r
if (BootType != NULL || Attributes != NULL) {\r
Status = BootDeviceGetType (FilePathDevicePath->PathName, BootType, Attributes);\r
if (EFI_ERROR(Status)) {\r
FreePool (FilePathDevicePath);\r
} else {\r
- *DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL*)FilePathDevicePath;\r
+ *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)FilePathDevicePath;\r
}\r
\r
return Status;\r
EFI_STATUS\r
BdsLoadOptionMemMapCreateDevicePath (\r
IN CHAR16* FileName,\r
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,\r
OUT ARM_BDS_LOADER_TYPE *BootType,\r
OUT UINT32 *Attributes\r
)\r
if (EFI_ERROR(Status)) {\r
FreePool (MemMapDevicePath);\r
} else {\r
- *DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL*)MemMapDevicePath;\r
+ *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)MemMapDevicePath;\r
}\r
\r
return Status;\r
EFI_STATUS\r
BdsLoadOptionPxeCreateDevicePath (\r
IN CHAR16* FileName,\r
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,\r
OUT ARM_BDS_LOADER_TYPE *BootType,\r
OUT UINT32 *Attributes\r
)\r
{\r
- *DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
- SetDevicePathEndNode (*DevicePathNode);\r
+ *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
+ SetDevicePathEndNode (*DevicePathNodes);\r
*BootType = BDS_LOADER_EFI_APPLICATION;\r
return EFI_SUCCESS;\r
}\r
EFI_STATUS\r
BdsLoadOptionTftpCreateDevicePath (\r
IN CHAR16* FileName,\r
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,\r
OUT ARM_BDS_LOADER_TYPE *BootType,\r
OUT UINT32 *Attributes\r
)\r
}\r
\r
// Allocate the memory for the IPv4 + File Path Device Path Nodes\r
- IPv4DevicePathNode = (IPv4_DEVICE_PATH*)AllocatePool(sizeof(IPv4_DEVICE_PATH) + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\r
+ IPv4DevicePathNode = (IPv4_DEVICE_PATH*)AllocatePool(sizeof(IPv4_DEVICE_PATH) + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize + END_DEVICE_PATH_LENGTH);\r
\r
// Create the IPv4 Device Path\r
IPv4DevicePathNode->Header.Type = MESSAGING_DEVICE_PATH;\r
SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\r
CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);\r
\r
+ // Set the End Device Path Node\r
+ SetDevicePathEndNode ((VOID*)((UINTN)FilePathDevicePath + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize));\r
+\r
if (BootType != NULL || Attributes != NULL) {\r
Status = BootDeviceGetType (NULL, BootType, Attributes);\r
}\r
if (EFI_ERROR(Status)) {\r
FreePool (IPv4DevicePathNode);\r
} else {\r
- *DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL*)IPv4DevicePathNode;\r
+ *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)IPv4DevicePathNode;\r
}\r
\r
return Status;\r