]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
MdeModulePkg/CapsuleApp: Add Fmp->GetImage() support.
[mirror_edk2.git] / MdeModulePkg / Application / CapsuleApp / CapsuleApp.c
index 23672ae47ba7ba909241d9c4a83bd6f9b35152e0..51372593de4ed125ddf674bb8ea7ae4d846559d4 100644 (file)
@@ -85,6 +85,22 @@ DumpFmpData (
   VOID\r
   );\r
 \r
+/**\r
+  Dump FMP image data.\r
+\r
+  @param[in]  ImageTypeId   The ImageTypeId of the FMP image.\r
+                            It is used to identify the FMP protocol.\r
+  @param[in]  ImageIndex    The ImageIndex of the FMP image.\r
+                            It is the input parameter for FMP->GetImage().\r
+  @param[in]  ImageName     The file name to hold the output FMP image.\r
+**/\r
+VOID\r
+DumpFmpImage (\r
+  IN EFI_GUID  *ImageTypeId,\r
+  IN UINTN     ImageIndex,\r
+  IN CHAR16    *ImageName\r
+  );\r
+\r
 /**\r
   Dump ESRT info.\r
 **/\r
@@ -126,6 +142,24 @@ WriteFileFromBuffer (
   IN  VOID                                 *Buffer\r
   );\r
 \r
+/**\r
+  Converts a string to GUID value.\r
+  Guid Format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\r
+\r
+  @param[in]  Str              The registry format GUID string that contains the GUID value.\r
+  @param[out] Guid             A pointer to the converted GUID value.\r
+\r
+  @retval EFI_SUCCESS     The GUID string was successfully converted to the GUID value.\r
+  @retval EFI_UNSUPPORTED The input string is not in registry format.\r
+  @return others          Some error occurred when converting part of GUID value.\r
+\r
+**/\r
+EFI_STATUS\r
+StrToGuid (\r
+  IN  CHAR16   *Str,\r
+  OUT EFI_GUID *Guid\r
+  );\r
+\r
 /**\r
 \r
   This function parse application ARG.\r
@@ -662,6 +696,7 @@ PrintUsage (
   Print(L"  CapsuleApp -G <BMP> -O <Capsule>\n");\r
   Print(L"  CapsuleApp -N <Capsule> -O <NestedCapsule>\n");\r
   Print(L"  CapsuleApp -D <Capsule>\n");\r
+  Print(L"  CapsuleApp -P GET <ImageTypeId> <Index> -O <FileName>\n");\r
   Print(L"Parameter:\n");\r
   Print(L"  -S:  Dump capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");\r
   Print(L"       which is defined in UEFI specification.\n");\r
@@ -737,7 +772,27 @@ UefiMain (
     return Status;\r
   }\r
   if (StrCmp(Argv[1], L"-P") == 0) {\r
-    DumpFmpData();\r
+    if (Argc == 2) {\r
+      DumpFmpData();\r
+    }\r
+    if (Argc >= 3) {\r
+      if (StrCmp(Argv[2], L"GET") == 0) {\r
+        EFI_GUID  ImageTypeId;\r
+        UINTN     ImageIndex;\r
+        //\r
+        // FMP->GetImage()\r
+        //\r
+        Status = StrToGuid(Argv[3], &ImageTypeId);\r
+        if (EFI_ERROR(Status)) {\r
+          Print (L"Invalid ImageTypeId - %s\n", Argv[3]);\r
+          return Status;\r
+        }\r
+        ImageIndex = StrDecimalToUintn(Argv[4]);\r
+        if (StrCmp(Argv[5], L"-O") == 0) {\r
+          DumpFmpImage(&ImageTypeId, ImageIndex, Argv[6]);\r
+        }\r
+      }\r
+    }\r
     return EFI_SUCCESS;\r
   }\r
   if (StrCmp(Argv[1], L"-E") == 0) {\r