]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/Bds: Fixed and Improved initrd support in the ArmPlatformPkg Boot...
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 1 Nov 2011 23:43:37 +0000 (23:43 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 1 Nov 2011 23:43:37 +0000 (23:43 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12641 6f19259b-4bc3-4df7-8a09-765794883524

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

index e7a83e6926f7fff60e35f39f096296493c1d56b2..5ef85631f3782a9eee6539ff0cce95a3ea57f44e 100644 (file)
@@ -99,9 +99,9 @@ typedef struct {
 typedef struct _BDS_LOAD_OPTION_SUPPORT {\r
   BDS_SUPPORTED_DEVICE_TYPE   Type;\r
   EFI_STATUS    (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList);\r
-  BOOLEAN       (*IsSupported)(IN BDS_LOAD_OPTION* BdsLoadOption);\r
-  EFI_STATUS    (*CreateDevicePathNode)(IN BDS_SUPPORTED_DEVICE* BdsLoadOption, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);\r
-  EFI_STATUS    (*UpdateDevicePathNode)(IN EFI_DEVICE_PATH *OldDevicePath, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);\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    (*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
 #define LOAD_OPTION_ENTRY_FROM_LINK(a)  BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)\r
@@ -128,8 +128,8 @@ BootDeviceListSupportedFree (
 \r
 EFI_STATUS\r
 BootDeviceGetDeviceSupport (\r
-  IN  BDS_LOAD_OPTION *BootOption,\r
-  OUT BDS_LOAD_OPTION_SUPPORT**  DeviceSupport\r
+  IN  EFI_DEVICE_PATH           *DevicePath,\r
+  OUT BDS_LOAD_OPTION_SUPPORT   **DeviceSupport\r
   );\r
 \r
 EFI_STATUS\r
index 7d1010bac274469ecc3a3c5898cc5bcb72f4b54b..315fc953f5a27a8672904032e962675714529ffc 100644 (file)
@@ -126,6 +126,7 @@ BootMenuAddBootOption (
   EFI_DEVICE_PATH_PROTOCOL  *InitrdPathNode;\r
   EFI_DEVICE_PATH_PROTOCOL  *InitrdPath;\r
   UINTN                     CmdLineSize;\r
+  BOOLEAN                   InitrdSupport;\r
   UINTN                     InitrdSize;\r
 \r
   Attributes                = 0;\r
@@ -139,8 +140,7 @@ BootMenuAddBootOption (
   }\r
 \r
   // Create the specific device path node\r
-  Print(L"File path of the EFI Application or the kernel: ");\r
-  Status = SupportedBootDevice->Support->CreateDevicePathNode (SupportedBootDevice, &DevicePathNode, &BootType, &Attributes);\r
+  Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNode, &BootType, &Attributes);\r
   if (EFI_ERROR(Status)) {\r
     Status = EFI_ABORTED;\r
     goto EXIT;\r
@@ -149,17 +149,27 @@ BootMenuAddBootOption (
   DevicePath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode);\r
 \r
   if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {\r
-    // Create the specific device path node\r
-    Print(L"File path of the initrd: ");\r
-    Status = SupportedBootDevice->Support->CreateDevicePathNode (SupportedBootDevice, &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
+    Print(L"Add an initrd: ");\r
+    Status = GetHIInputBoolean (&InitrdSupport);\r
+    if (EFI_ERROR(Status)) {\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 (InitrdSupport) {\r
+      // Create the specific device path node\r
+      Status = SupportedBootDevice->Support->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
+        // Append the Device Path node to the select device path\r
+        InitrdPath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode);\r
+      } else {\r
+        InitrdPath = NULL;\r
+      }\r
     } else {\r
       InitrdPath = NULL;\r
     }\r
@@ -348,9 +358,11 @@ BootMenuUpdateBootOption (
   ARM_BDS_LOADER_TYPE           BootType;\r
   ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;\r
   ARM_BDS_LINUX_ARGUMENTS*      LinuxArguments;\r
-  EFI_DEVICE_PATH*              InitrdPathList;\r
+  EFI_DEVICE_PATH               *InitrdPathNode;\r
+  EFI_DEVICE_PATH               *InitrdPath;\r
   UINTN                         InitrdSize;\r
   UINTN                         CmdLineSize;\r
+  BOOLEAN                       InitrdSupport;\r
 \r
   Status = BootMenuSelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, TRUE, &BootOptionEntry);\r
   if (EFI_ERROR(Status)) {\r
@@ -359,14 +371,13 @@ BootMenuUpdateBootOption (
   BootOption = BootOptionEntry->BdsLoadOption;\r
 \r
   // Get the device support for this Boot Option\r
-  Status = BootDeviceGetDeviceSupport (BootOption, &DeviceSupport);\r
+  Status = BootDeviceGetDeviceSupport (BootOption->FilePathList, &DeviceSupport);\r
   if (EFI_ERROR(Status)) {\r
     Print(L"Not possible to retrieve the supported device for the update\n");\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
-  Print(L"File path of the EFI Application or the kernel: ");\r
-  Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, &DevicePath, NULL, NULL);\r
+  Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath, NULL, NULL);\r
   if (EFI_ERROR(Status)) {\r
     Status = EFI_ABORTED;\r
     goto EXIT;\r
@@ -375,7 +386,6 @@ BootMenuUpdateBootOption (
   OptionalData = BootOption->OptionalData;\r
   BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&OptionalData->Header.LoaderType));\r
 \r
-  // TODO: Allow adding an initrd to a boot entry without one\r
   if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {\r
     LinuxArguments = &OptionalData->Arguments.LinuxArguments;\r
 \r
@@ -383,13 +393,47 @@ BootMenuUpdateBootOption (
 \r
     InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);\r
     if (InitrdSize > 0) {\r
-      Print(L"File path of the initrd: ");\r
-      Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((LinuxArguments + 1) + CmdLineSize), &InitrdPathList, 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
+      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*)((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
+          DevicePath = DuplicateDevicePath (BootOption->FilePathList);\r
+          // Replace Linux kernel Node by EndNode\r
+          SetDevicePathEndNode (GetLastDevicePathNode (DevicePath));\r
+          // Append the Device Path node to the select device path\r
+          InitrdPath = AppendDevicePathNode (DevicePath, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode);\r
+        } else {\r
+          InitrdPath = NULL;\r
+        }\r
       }\r
-      InitrdSize = GetDevicePathSize (InitrdPathList);\r
+    } else {\r
+      InitrdSize = 0;\r
     }\r
 \r
     Print(L"Arguments to pass to the binary: "); \r
@@ -410,7 +454,7 @@ BootMenuUpdateBootOption (
     BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;\r
     BootArguments->LinuxArguments.InitrdSize = InitrdSize;\r
     CopyMem (&BootArguments->LinuxArguments + 1, CmdLine, CmdLineSize);\r
-    CopyMem ((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLine, InitrdPathList, InitrdSize);\r
+    CopyMem ((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLine, InitrdPath, InitrdSize);\r
   } else {\r
     BootArguments = NULL;\r
   }\r
index fb383b6f2468beb405991784c058fc5b7fbabdf3..f16de7c82dc3df6877edca7db28deca91a8c9397 100644 (file)
@@ -33,23 +33,24 @@ BdsLoadOptionFileSystemList (
 \r
 EFI_STATUS\r
 BdsLoadOptionFileSystemCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 EFI_STATUS\r
 BdsLoadOptionFileSystemUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 BOOLEAN\r
 BdsLoadOptionFileSystemIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   );\r
 \r
 EFI_STATUS\r
@@ -59,23 +60,24 @@ BdsLoadOptionMemMapList (
 \r
 EFI_STATUS\r
 BdsLoadOptionMemMapCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 EFI_STATUS\r
 BdsLoadOptionMemMapUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 BOOLEAN\r
 BdsLoadOptionMemMapIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   );\r
 \r
 EFI_STATUS\r
@@ -85,23 +87,24 @@ BdsLoadOptionPxeList (
 \r
 EFI_STATUS\r
 BdsLoadOptionPxeCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 EFI_STATUS\r
 BdsLoadOptionPxeUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 BOOLEAN\r
 BdsLoadOptionPxeIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   );\r
 \r
 EFI_STATUS\r
@@ -111,23 +114,24 @@ BdsLoadOptionTftpList (
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 BOOLEAN\r
 BdsLoadOptionTftpIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   );\r
 \r
 BDS_LOAD_OPTION_SUPPORT BdsLoadOptionSupportList[] = {\r
@@ -201,15 +205,15 @@ BootDeviceListSupportedFree (
 \r
 EFI_STATUS\r
 BootDeviceGetDeviceSupport (\r
-  IN  BDS_LOAD_OPTION *BootOption,\r
-  OUT BDS_LOAD_OPTION_SUPPORT**  DeviceSupport\r
+  IN  EFI_DEVICE_PATH           *DevicePath,\r
+  OUT BDS_LOAD_OPTION_SUPPORT   **DeviceSupport\r
   )\r
 {\r
   UINTN Index;\r
 \r
   // Find which supported device is the most appropriate\r
   for (Index = 0; Index < BDS_DEVICE_MAX; Index++) {\r
-    if (BdsLoadOptionSupportList[Index].IsSupported (BootOption)) {\r
+    if (BdsLoadOptionSupportList[Index].IsSupported (DevicePath)) {\r
       *DeviceSupport = &BdsLoadOptionSupportList[Index];\r
       return EFI_SUCCESS;\r
     }\r
@@ -327,10 +331,10 @@ BdsLoadOptionFileSystemList (
 \r
 EFI_STATUS\r
 BdsLoadOptionFileSystemCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   EFI_STATUS  Status;\r
@@ -338,6 +342,7 @@ BdsLoadOptionFileSystemCreateDevicePath (
   CHAR16      BootFilePath[BOOT_DEVICE_FILEPATH_MAX];\r
   UINTN       BootFilePathSize;\r
 \r
+  Print(L"File path of the %s: ", FileName);\r
   Status = GetHIInputStr (BootFilePath, BOOT_DEVICE_FILEPATH_MAX);\r
   if (EFI_ERROR(Status)) {\r
     return EFI_ABORTED;\r
@@ -371,10 +376,11 @@ BdsLoadOptionFileSystemCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionFileSystemUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   EFI_STATUS  Status;\r
@@ -388,6 +394,7 @@ BdsLoadOptionFileSystemUpdateDevicePath (
 \r
   EndingDevicePath = (FILEPATH_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);\r
  \r
+  Print(L"File path of the %s: ", FileName);\r
   StrnCpy (BootFilePath, EndingDevicePath->PathName, BOOT_DEVICE_FILEPATH_MAX);\r
   Status = EditHIInputStr (BootFilePath, BOOT_DEVICE_FILEPATH_MAX);\r
   if (EFI_ERROR(Status)) {\r
@@ -421,12 +428,12 @@ BdsLoadOptionFileSystemUpdateDevicePath (
 \r
 BOOLEAN\r
 BdsLoadOptionFileSystemIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   )\r
 {\r
   EFI_DEVICE_PATH*  DevicePathNode;\r
 \r
-  DevicePathNode = GetLastDevicePathNode (BdsLoadOption->FilePathList);\r
+  DevicePathNode = GetLastDevicePathNode (DevicePath);\r
 \r
   return IS_DEVICE_PATH_NODE(DevicePathNode,MEDIA_DEVICE_PATH,MEDIA_FILEPATH_DP);\r
 }\r
@@ -525,38 +532,45 @@ BdsLoadOptionMemMapList (
 \r
 EFI_STATUS\r
 BdsLoadOptionMemMapCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
-  MEMMAP_DEVICE_PATHMemMapDevicePath;\r
-  CHAR16       StrStartingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
-  CHAR16       StrEndingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
+  EFI_STATUS              Status;\r
+  MEMMAP_DEVICE_PATH      *MemMapDevicePath;\r
+  CHAR16                  StrStartingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
+  CHAR16                  StrEndingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
 \r
-  Print(L"Starting Address of the binary: ");\r
-  Status = GetHIInputStr (StrStartingAddress,BOOT_DEVICE_ADDRESS_MAX);\r
+  Print(L"Starting Address of the %s: ", FileName);\r
+  Status = GetHIInputStr (StrStartingAddress, BOOT_DEVICE_ADDRESS_MAX);\r
   if (EFI_ERROR(Status)) {\r
     return EFI_ABORTED;\r
   }\r
 \r
-  Print(L"Ending Address of the binary: ");\r
-  Status = GetHIInputStr (StrEndingAddress,BOOT_DEVICE_ADDRESS_MAX);\r
+  Print(L"Ending Address of the %s: ", FileName);\r
+  Status = GetHIInputStr (StrEndingAddress, BOOT_DEVICE_ADDRESS_MAX);\r
   if (EFI_ERROR(Status)) {\r
     return EFI_ABORTED;\r
   }\r
 \r
   // Create the MemMap Device Path Node\r
-  MemMapDevicePath = (MEMMAP_DEVICE_PATH*)AllocatePool (sizeof(MEMMAP_DEVICE_PATH));\r
+  MemMapDevicePath = (MEMMAP_DEVICE_PATH*)AllocatePool (sizeof(MEMMAP_DEVICE_PATH) + END_DEVICE_PATH_LENGTH);\r
   MemMapDevicePath->Header.Type = HARDWARE_DEVICE_PATH;\r
   MemMapDevicePath->Header.SubType = HW_MEMMAP_DP;\r
+  SetDevicePathNodeLength (MemMapDevicePath, sizeof(MEMMAP_DEVICE_PATH));\r
   MemMapDevicePath->MemoryType = EfiBootServicesData;\r
   MemMapDevicePath->StartingAddress = StrHexToUint64 (StrStartingAddress);\r
   MemMapDevicePath->EndingAddress = StrHexToUint64 (StrEndingAddress);\r
 \r
-  Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  // Set a Device Path End Node after the Memory Map Device Path Node\r
+  SetDevicePathEndNode (MemMapDevicePath + 1);\r
+\r
+  if (BootType != NULL || Attributes != NULL) {\r
+    Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  }\r
+\r
   if (EFI_ERROR(Status)) {\r
     FreePool (MemMapDevicePath);\r
   } else {\r
@@ -568,10 +582,11 @@ BdsLoadOptionMemMapCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionMemMapUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   EFI_STATUS          Status;\r
@@ -583,14 +598,14 @@ BdsLoadOptionMemMapUpdateDevicePath (
   DevicePath = DuplicateDevicePath (OldDevicePath);\r
   EndingDevicePath = (MEMMAP_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);\r
 \r
-  Print(L"Starting Address of the binary: ");\r
+  Print(L"Starting Address of the %s: ", FileName);\r
   UnicodeSPrint (StrStartingAddress, BOOT_DEVICE_ADDRESS_MAX, L"0x%X", (UINTN)EndingDevicePath->StartingAddress);\r
   Status = EditHIInputStr (StrStartingAddress, BOOT_DEVICE_ADDRESS_MAX);\r
   if (EFI_ERROR(Status)) {\r
     return EFI_ABORTED;\r
   }\r
 \r
-  Print(L"Ending Address of the binary: ");\r
+  Print(L"Ending Address of the %s: ", FileName);\r
   UnicodeSPrint (StrEndingAddress, BOOT_DEVICE_ADDRESS_MAX, L"0x%X", (UINTN)EndingDevicePath->EndingAddress);\r
   Status = EditHIInputStr (StrEndingAddress, BOOT_DEVICE_ADDRESS_MAX);\r
   if (EFI_ERROR(Status)) {\r
@@ -600,7 +615,10 @@ BdsLoadOptionMemMapUpdateDevicePath (
   EndingDevicePath->StartingAddress = StrHexToUint64 (StrStartingAddress);\r
   EndingDevicePath->EndingAddress = StrHexToUint64 (StrEndingAddress);\r
 \r
-  Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  if (BootType != NULL || Attributes != NULL) {\r
+    Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  }\r
+\r
   if (EFI_ERROR(Status)) {\r
     FreePool(DevicePath);\r
   } else {\r
@@ -612,12 +630,12 @@ BdsLoadOptionMemMapUpdateDevicePath (
 \r
 BOOLEAN\r
 BdsLoadOptionMemMapIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   )\r
 {\r
   EFI_DEVICE_PATH*  DevicePathNode;\r
 \r
-  DevicePathNode = GetLastDevicePathNode (BdsLoadOption->FilePathList);\r
+  DevicePathNode = GetLastDevicePathNode (DevicePath);\r
 \r
   return IS_DEVICE_PATH_NODE(DevicePathNode,HARDWARE_DEVICE_PATH,HW_MEMMAP_DP);\r
 }\r
@@ -672,10 +690,10 @@ BdsLoadOptionPxeList (
 \r
 EFI_STATUS\r
 BdsLoadOptionPxeCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\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
@@ -686,10 +704,11 @@ BdsLoadOptionPxeCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionPxeUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   ASSERT (0);\r
@@ -698,7 +717,7 @@ BdsLoadOptionPxeUpdateDevicePath (
 \r
 BOOLEAN\r
 BdsLoadOptionPxeIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   )\r
 {\r
   EFI_STATUS  Status;\r
@@ -706,7 +725,7 @@ BdsLoadOptionPxeIsSupported (
   EFI_DEVICE_PATH_PROTOCOL  *RemainingDevicePath;\r
   EFI_PXE_BASE_CODE_PROTOCOL  *PxeBcProtocol;\r
 \r
-  Status = BdsConnectDevicePath (BdsLoadOption->FilePathList, &Handle, &RemainingDevicePath);\r
+  Status = BdsConnectDevicePath (DevicePath, &Handle, &RemainingDevicePath);\r
   if (EFI_ERROR(Status)) {\r
     return FALSE;\r
   }\r
@@ -773,10 +792,10 @@ BdsLoadOptionTftpList (
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   EFI_STATUS    Status;\r
@@ -808,7 +827,7 @@ BdsLoadOptionTftpCreateDevicePath (
     return EFI_ABORTED;\r
   }\r
 \r
-  Print(L"File path of the EFI Application or the kernel : ");\r
+  Print(L"File path of the %s : ", FileName);\r
   Status = GetHIInputStr (BootFilePath, BOOT_DEVICE_FILEPATH_MAX);\r
   if (EFI_ERROR(Status)) {\r
     return EFI_ABORTED;\r
@@ -840,7 +859,10 @@ BdsLoadOptionTftpCreateDevicePath (
   SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\r
   CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);\r
 \r
-  Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  if (BootType != NULL || Attributes != NULL) {\r
+    Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  }\r
+\r
   if (EFI_ERROR(Status)) {\r
     FreePool (IPv4DevicePathNode);\r
   } else {\r
@@ -852,10 +874,11 @@ BdsLoadOptionTftpCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   ASSERT (0);\r
@@ -864,7 +887,7 @@ BdsLoadOptionTftpUpdateDevicePath (
 \r
 BOOLEAN\r
 BdsLoadOptionTftpIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   )\r
 {\r
   EFI_STATUS  Status;\r
@@ -873,7 +896,7 @@ BdsLoadOptionTftpIsSupported (
   EFI_DEVICE_PATH  *NextDevicePath;\r
   EFI_PXE_BASE_CODE_PROTOCOL  *PxeBcProtocol;\r
 \r
-  Status = BdsConnectDevicePath (BdsLoadOption->FilePathList, &Handle, &RemainingDevicePath);\r
+  Status = BdsConnectDevicePath (DevicePath, &Handle, &RemainingDevicePath);\r
   if (EFI_ERROR(Status)) {\r
     return FALSE;\r
   }\r