]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Bds/BootMenu.c
ArmPlatformPkg/Bds: Fixed adding support for new boot entry when the generated Device...
[mirror_edk2.git] / ArmPlatformPkg / Bds / BootMenu.c
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