]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/Bds: Fixed adding support for new boot entry when the generated Device...
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 12 Mar 2013 01:03:23 +0000 (01:03 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 12 Mar 2013 01:03:23 +0000 (01:03 +0000)
The initial support was only considering the added Device Path will be a single node.
TFTP for instance requires two new nodes on the top of the ethernet Device Path; a first
one for the IP address of the server and a second one for the file to download.

This change replace the return argument from a DevicePath node by a DevicePath.
It means the End Device Path node is now required.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14194 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/Bds/BdsInternal.h
ArmPlatformPkg/Bds/BootMenu.c
ArmPlatformPkg/Bds/BootOptionSupport.c

index 426d61e3cf28e8cfd96e7460f40687fb34a8ee48..a8d836d8697a4f3b61fe5d197e41d820d2a54eb5 100644 (file)
@@ -100,7 +100,7 @@ typedef struct _BDS_LOAD_OPTION_SUPPORT {
   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
index 03f695b1709ab7496ce6316fc5896c5b17a4845f..1b101d45c1f7972038b55649cb1b85270363b76a 100644 (file)
@@ -125,8 +125,8 @@ BootMenuAddBootOption (
   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
@@ -143,13 +143,17 @@ BootMenuAddBootOption (
   }\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
@@ -161,15 +165,19 @@ BootMenuAddBootOption (
 \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
@@ -214,7 +222,6 @@ BootMenuAddBootOption (
 FREE_DEVICE_PATH:\r
   FreePool (DevicePath);\r
 \r
-\r
 EXIT:\r
   if (Status == EFI_ABORTED) {\r
     Print(L"\n");\r
@@ -281,7 +288,7 @@ BootMenuSelectBootOption (
   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
@@ -362,7 +369,7 @@ BootMenuUpdateBootOption (
   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
@@ -419,20 +426,24 @@ BootMenuUpdateBootOption (
       } 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
@@ -494,7 +505,7 @@ UpdateFdtPath (
   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
@@ -504,15 +515,15 @@ UpdateFdtPath (
   }\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
index fbdd5947d33dd1afad4d70293956cb7397966271..190169a304b84240b2cd73f88d52ce0f077f0900 100644 (file)
@@ -34,7 +34,7 @@ BdsLoadOptionFileSystemList (
 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
@@ -61,7 +61,7 @@ BdsLoadOptionMemMapList (
 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
@@ -88,7 +88,7 @@ BdsLoadOptionPxeList (
 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
@@ -115,7 +115,7 @@ BdsLoadOptionTftpList (
 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
@@ -332,7 +332,7 @@ BdsLoadOptionFileSystemList (
 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
@@ -350,16 +350,17 @@ BdsLoadOptionFileSystemCreateDevicePath (
 \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
@@ -368,7 +369,7 @@ BdsLoadOptionFileSystemCreateDevicePath (
   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
@@ -533,7 +534,7 @@ BdsLoadOptionMemMapList (
 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
@@ -574,7 +575,7 @@ BdsLoadOptionMemMapCreateDevicePath (
   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
@@ -691,13 +692,13 @@ BdsLoadOptionPxeList (
 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
@@ -793,7 +794,7 @@ BdsLoadOptionTftpList (
 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
@@ -839,7 +840,7 @@ BdsLoadOptionTftpCreateDevicePath (
   }\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
@@ -859,6 +860,9 @@ BdsLoadOptionTftpCreateDevicePath (
   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
@@ -866,7 +870,7 @@ BdsLoadOptionTftpCreateDevicePath (
   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