]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
ShellPkg/Bcfg: Add support for 'addp' command.
[mirror_edk2.git] / ShellPkg / Library / UefiShellBcfgCommandLib / UefiShellBcfgCommandLib.c
index d109ca29a781b1ac06eaf888ff633b87f805f520..bf35a35b985d00e32af4e4aa5d1cb285c7e9a014 100644 (file)
@@ -310,6 +310,7 @@ BcfgAdd(
 {\r
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
   EFI_DEVICE_PATH_PROTOCOL  *FilePath;\r
   CHAR16                    *Str;\r
   UINT8                     *TempByteBuffer;\r
@@ -462,9 +463,9 @@ BcfgAdd(
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE_DP), gShellBcfgHiiHandle, L"bcfg", Arg->FullName);  \r
           ShellStatus = SHELL_UNSUPPORTED;\r
         } else {\r
-/*\r
           if (UsePath) {\r
-            DevPath = DevicePath;\r
+            DevPath     = DevicePath;\r
+            ShellStatus = SHELL_INVALID_PARAMETER;\r
             while (!IsDevicePathEnd(DevPath)) {\r
               if ((DevicePathType(DevPath) == MEDIA_DEVICE_PATH) &&\r
                 (DevicePathSubType(DevPath) == MEDIA_HARDDRIVE_DP)) {\r
@@ -472,24 +473,15 @@ BcfgAdd(
                 //\r
                 // If we find it use it instead\r
                 //\r
-                DevicePath = DevPath;\r
+                ShellStatus = SHELL_SUCCESS;\r
+                FilePath    = DuplicateDevicePath (DevPath);\r
                 break;\r
               }\r
               DevPath = NextDevicePathNode(DevPath);\r
             }\r
-            //\r
-            // append the file\r
-            //\r
-            for(StringWalker=Arg->FullName; *StringWalker != CHAR_NULL && *StringWalker != ':'; StringWalker++);\r
-            FileNode = FileDevicePath(NULL, StringWalker+1);\r
-            FilePath = AppendDevicePath(DevicePath, FileNode);\r
-            FreePool(FileNode);\r
           } else {\r
-*/\r
             FilePath = DuplicateDevicePath(DevicePath);\r
-/*\r
           }\r
-*/\r
           FreePool(DevicePath);\r
         }\r
       }\r
@@ -1048,13 +1040,13 @@ BcfgDisplayDump(
   UINTN           BufferSize;\r
   CHAR16          VariableName[12];\r
   UINTN           LoopVar;\r
-  UINTN           LoopVar2;\r
   CHAR16          *DevPathString;\r
   VOID            *FilePathList;\r
   UINTN           Errors;\r
   EFI_LOAD_OPTION *LoadOption;\r
   CHAR16          *Description;\r
   UINTN           DescriptionSize;\r
+  UINTN           OptionalDataOffset;\r
 \r
   if (OrderCount == 0) {\r
     ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_BCFG_NONE), gShellBcfgHiiHandle, L"bcfg");  \r
@@ -1111,13 +1103,17 @@ BcfgDisplayDump(
     }\r
 \r
     LoadOption      = (EFI_LOAD_OPTION *)Buffer;\r
-    Description     = (CHAR16 *)(&LoadOption->FilePathListLength + 1);\r
+    Description     = (CHAR16*)(Buffer + sizeof (EFI_LOAD_OPTION));\r
     DescriptionSize = StrSize (Description);\r
 \r
     if (LoadOption->FilePathListLength != 0) {\r
       FilePathList = (UINT8 *)Description + DescriptionSize;\r
       DevPathString = ConvertDevicePathToText(FilePathList, TRUE, FALSE);\r
     }\r
+\r
+    OptionalDataOffset = sizeof *LoadOption + DescriptionSize +\r
+                         LoadOption->FilePathListLength;\r
+\r
     ShellPrintHiiEx(\r
       -1,\r
       -1,\r
@@ -1128,21 +1124,15 @@ BcfgDisplayDump(
       VariableName,\r
       Description,\r
       DevPathString,\r
-      (DescriptionSize + LoadOption->FilePathListLength + 6) <= BufferSize?L'N':L'Y');\r
-    if (VerboseOutput) {\r
-      for (LoopVar2 = (DescriptionSize + LoadOption->FilePathListLength + 6);LoopVar2<BufferSize;LoopVar2++){\r
-        ShellPrintEx(\r
-          -1,\r
-          -1,\r
-          NULL,\r
-          L"%02x",\r
-          Buffer[LoopVar2]);\r
-      }\r
-      ShellPrintEx(\r
-        -1,\r
-        -1,\r
-        NULL,\r
-        L"\r\n");\r
+      OptionalDataOffset >= BufferSize ? L'N' : L'Y'\r
+      );\r
+    if (VerboseOutput && (OptionalDataOffset < BufferSize)) {\r
+      DumpHex (\r
+        2,                               // Indent\r
+        0,                               // Offset (displayed)\r
+        BufferSize - OptionalDataOffset, // DataSize\r
+        Buffer + OptionalDataOffset      // UserData\r
+        );\r
     }\r
 \r
 Cleanup:\r