]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg CapsuleApp: Add -NR (no-reset) option support
authorStar Zeng <star.zeng@intel.com>
Fri, 17 Mar 2017 03:27:37 +0000 (11:27 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 21 Mar 2017 06:48:10 +0000 (14:48 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=388

Add -NR (no-reset) option support, once the option is specified,
no reset will be trigger for the capsule with flag
CAPSULE_FLAGS_PERSIST_ACROSS_RESET and no CAPSULE_FLAGS_INITIATE_RESET.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Xiaofeng Wang <winggundum82@163.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdeModulePkg/Application/CapsuleApp/CapsuleApp.c

index 84ed4d738bc4ba777124643168d93b2d2744ad67..6febe846b1406f1f9098114061b3ccd95877dd09 100644 (file)
@@ -670,7 +670,7 @@ PrintUsage (
   )\r
 {\r
   Print(L"CapsuleApp:  usage\n");\r
-  Print(L"  CapsuleApp <Capsule...>\n");\r
+  Print(L"  CapsuleApp <Capsule...> [-NR]\n");\r
   Print(L"  CapsuleApp -S\n");\r
   Print(L"  CapsuleApp -C\n");\r
   Print(L"  CapsuleApp -P\n");\r
@@ -680,6 +680,8 @@ PrintUsage (
   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"  -NR: No reset will be triggered for the capsule\n");\r
+  Print(L"       with CAPSULE_FLAGS_PERSIST_ACROSS_RESET and without CAPSULE_FLAGS_INITIATE_RESET.\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
   Print(L"  -C:  Clear capsule report variable (EFI_CAPSULE_RPORT_GUID),\n");\r
@@ -721,6 +723,7 @@ UefiMain (
   UINT64                         MaxCapsuleSize;\r
   EFI_RESET_TYPE                 ResetType;\r
   BOOLEAN                        NeedReset;\r
+  BOOLEAN                        NoReset;\r
   CHAR16                         *CapsuleName;\r
   UINTN                          CapsuleNum;\r
   UINTN                          Index;\r
@@ -783,7 +786,13 @@ UefiMain (
     return EFI_SUCCESS;\r
   }\r
   CapsuleFirstIndex = 1;\r
-  CapsuleLastIndex = Argc - 1;\r
+  NoReset = FALSE;\r
+  if ((Argc > 1) && (StrCmp(Argv[Argc - 1], L"-NR") == 0)) {\r
+    NoReset = TRUE;\r
+    CapsuleLastIndex = Argc - 2;\r
+  } else {\r
+    CapsuleLastIndex = Argc - 1;\r
+  }\r
   CapsuleNum = CapsuleLastIndex - CapsuleFirstIndex + 1;\r
 \r
   if (CapsuleFirstIndex > CapsuleLastIndex) {\r
@@ -855,10 +864,19 @@ UefiMain (
       goto Done;\r
     }\r
     //\r
-    // For capsule who has reset flag, after calling UpdateCapsule service,triger a\r
-    // system reset to process capsule persist across a system reset.\r
+    // For capsule with CAPSULE_FLAGS_PERSIST_ACROSS_RESET + CAPSULE_FLAGS_INITIATE_RESET,\r
+    // a system reset should have been triggered by gRT->UpdateCapsule() calling above.\r
+    //\r
+    // For capsule with CAPSULE_FLAGS_PERSIST_ACROSS_RESET and without CAPSULE_FLAGS_INITIATE_RESET,\r
+    // check if -NR (no-reset) has been specified or not.\r
     //\r
-    gRT->ResetSystem (ResetType, EFI_SUCCESS, 0, NULL);\r
+    if (!NoReset) {\r
+      //\r
+      // For capsule who has reset flag and no -NR (no-reset) has been specified, after calling UpdateCapsule service,\r
+      // trigger a system reset to process capsule persist across a system reset.\r
+      //\r
+      gRT->ResetSystem (ResetType, EFI_SUCCESS, 0, NULL);\r
+    }\r
   } else {\r
     //\r
     // For capsule who has no reset flag, only call UpdateCapsule Service without a\r