summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg/Bds/BootOptionSupport.c
diff options
context:
space:
mode:
Diffstat (limited to 'ArmPlatformPkg/Bds/BootOptionSupport.c')
-rw-r--r--ArmPlatformPkg/Bds/BootOptionSupport.c59
1 files changed, 32 insertions, 27 deletions
diff --git a/ArmPlatformPkg/Bds/BootOptionSupport.c b/ArmPlatformPkg/Bds/BootOptionSupport.c
index 897786f5..cf69175d 100644
--- a/ArmPlatformPkg/Bds/BootOptionSupport.c
+++ b/ArmPlatformPkg/Bds/BootOptionSupport.c
@@ -25,6 +25,7 @@
#include <Guid/FileSystemInfo.h>
#define IS_DEVICE_PATH_NODE(node,type,subtype) (((node)->Type == (type)) && ((node)->SubType == (subtype)))
+#define LOCAL_FDT_RESPONSE_LEN 2 // 1 character, plus carriage return
EFI_STATUS
BdsLoadOptionFileSystemList (
@@ -34,7 +35,7 @@ BdsLoadOptionFileSystemList (
EFI_STATUS
BdsLoadOptionFileSystemCreateDevicePath (
IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes
);
@@ -61,7 +62,7 @@ BdsLoadOptionMemMapList (
EFI_STATUS
BdsLoadOptionMemMapCreateDevicePath (
IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes
);
@@ -88,7 +89,7 @@ BdsLoadOptionPxeList (
EFI_STATUS
BdsLoadOptionPxeCreateDevicePath (
IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes
);
@@ -115,7 +116,7 @@ BdsLoadOptionTftpList (
EFI_STATUS
BdsLoadOptionTftpCreateDevicePath (
IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes
);
@@ -233,7 +234,7 @@ BootDeviceGetType (
EFI_STATUS Status;
BOOLEAN IsEfiApp;
BOOLEAN IsBootLoader;
- CHAR16 FDTType[16];
+ CHAR16 FDTType[ LOCAL_FDT_RESPONSE_LEN ];
if (FileName == NULL) {
Print(L"Is an EFI Application? ");
@@ -258,20 +259,20 @@ BootDeviceGetType (
}
*BootType = BDS_LOADER_EFI_APPLICATION;
} else {
- Print(L"Boot Type: [a] ATAGS, [g] Global FDT or [l] Local FDT? [a/g/l] ");
- Status = GetHIInputStr (FDTType, 16);
+ Print(L"Boot Type: [a] ATAGS, [g] Global FDT or [l] Local FDT? [a/g/l] ");
+ Status = GetHIInputStr (FDTType, LOCAL_FDT_RESPONSE_LEN );
if (EFI_ERROR(Status)) {
return EFI_ABORTED;
}
- if (StrCmp(FDTType, L"g") == 0) {
- *BootType = BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT;
- } else if (StrCmp(FDTType, L"l") == 0) {
- *BootType = BDS_LOADER_KERNEL_LINUX_LOCAL_FDT;
- } else if (StrCmp(FDTType, L"a") == 0) {
+ if (StrCmp(FDTType, L"g") == 0) {
+ *BootType = BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT;
+ } else if (StrCmp(FDTType, L"l") == 0) {
+ *BootType = BDS_LOADER_KERNEL_LINUX_LOCAL_FDT;
+ } else if (StrCmp(FDTType, L"a") == 0) {
*BootType = BDS_LOADER_KERNEL_LINUX_ATAG;
- } else {
- return EFI_ABORTED;
- }
+ } else {
+ return EFI_ABORTED;
+ }
}
return EFI_SUCCESS;
@@ -336,7 +337,7 @@ BdsLoadOptionFileSystemList (
EFI_STATUS
BdsLoadOptionFileSystemCreateDevicePath (
IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes
)
@@ -354,16 +355,17 @@ BdsLoadOptionFileSystemCreateDevicePath (
BootFilePathSize = StrSize (BootFilePath);
if (BootFilePathSize == 2) {
- *DevicePathNode = NULL;
+ *DevicePathNodes = NULL;
return EFI_NOT_FOUND;
}
// Create the FilePath Device Path node
- FilePathDevicePath = (FILEPATH_DEVICE_PATH*)AllocatePool(SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);
+ FilePathDevicePath = (FILEPATH_DEVICE_PATH*)AllocatePool(SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize + END_DEVICE_PATH_LENGTH);
FilePathDevicePath->Header.Type = MEDIA_DEVICE_PATH;
FilePathDevicePath->Header.SubType = MEDIA_FILEPATH_DP;
SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);
CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);
+ SetDevicePathEndNode ((VOID*)((UINTN)FilePathDevicePath + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize));
if (BootType != NULL || Attributes != NULL) {
Status = BootDeviceGetType (FilePathDevicePath->PathName, BootType, Attributes);
@@ -372,7 +374,7 @@ BdsLoadOptionFileSystemCreateDevicePath (
if (EFI_ERROR(Status)) {
FreePool (FilePathDevicePath);
} else {
- *DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL*)FilePathDevicePath;
+ *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)FilePathDevicePath;
}
return Status;
@@ -537,7 +539,7 @@ BdsLoadOptionMemMapList (
EFI_STATUS
BdsLoadOptionMemMapCreateDevicePath (
IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes
)
@@ -578,7 +580,7 @@ BdsLoadOptionMemMapCreateDevicePath (
if (EFI_ERROR(Status)) {
FreePool (MemMapDevicePath);
} else {
- *DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL*)MemMapDevicePath;
+ *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)MemMapDevicePath;
}
return Status;
@@ -695,13 +697,13 @@ BdsLoadOptionPxeList (
EFI_STATUS
BdsLoadOptionPxeCreateDevicePath (
IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes
)
{
- *DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
- SetDevicePathEndNode (*DevicePathNode);
+ *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
+ SetDevicePathEndNode (*DevicePathNodes);
*BootType = BDS_LOADER_EFI_APPLICATION;
return EFI_SUCCESS;
}
@@ -797,7 +799,7 @@ BdsLoadOptionTftpList (
EFI_STATUS
BdsLoadOptionTftpCreateDevicePath (
IN CHAR16* FileName,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes,
OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes
)
@@ -843,7 +845,7 @@ BdsLoadOptionTftpCreateDevicePath (
}
// Allocate the memory for the IPv4 + File Path Device Path Nodes
- IPv4DevicePathNode = (IPv4_DEVICE_PATH*)AllocatePool(sizeof(IPv4_DEVICE_PATH) + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);
+ IPv4DevicePathNode = (IPv4_DEVICE_PATH*)AllocatePool(sizeof(IPv4_DEVICE_PATH) + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize + END_DEVICE_PATH_LENGTH);
// Create the IPv4 Device Path
IPv4DevicePathNode->Header.Type = MESSAGING_DEVICE_PATH;
@@ -863,6 +865,9 @@ BdsLoadOptionTftpCreateDevicePath (
SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);
CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);
+ // Set the End Device Path Node
+ SetDevicePathEndNode ((VOID*)((UINTN)FilePathDevicePath + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize));
+
if (BootType != NULL || Attributes != NULL) {
Status = BootDeviceGetType (NULL, BootType, Attributes);
}
@@ -870,7 +875,7 @@ BdsLoadOptionTftpCreateDevicePath (
if (EFI_ERROR(Status)) {
FreePool (IPv4DevicePathNode);
} else {
- *DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL*)IPv4DevicePathNode;
+ *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)IPv4DevicePathNode;
}
return Status;