]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Add "CAPSULE_FLAGS_INITIATE_RESET" flag support.
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 16 Sep 2009 01:29:14 +0000 (01:29 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 16 Sep 2009 01:29:14 +0000 (01:29 +0000)
2. Minor update CapuseUpdate() implementation to align with recent UEFI spec update.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9265 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c

index 2a45bf37fe92d18778402989fd6c7ce611dccf69..c47335bece81606b5ca4e0df4f8c805b49077b34 100644 (file)
@@ -4,7 +4,7 @@
   It installs the Capsule Architectural Protocol defined in PI1.0a to signify \r
   the capsule runtime services are ready.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -28,6 +28,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/UefiRuntimeLib.h>\r
 \r
+//\r
+// Handle for the installation of Capsule Architecture Protocol.\r
+//\r
+EFI_HANDLE  mNewHandle = NULL;\r
+\r
 /**\r
   Passes capsules to the firmware with both virtual and physical mapping. Depending on the intended\r
   consumption, the firmware may process the capsule immediately. If the payload should persist\r
@@ -47,8 +52,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
                                 CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set, the\r
                                 capsule has been successfully processed by the firmware.\r
   @retval EFI_DEVICE_ERROR      The capsule update was started, but failed due to a device error.\r
-  @retval EFI_INVALID_PARAMETER CapsuleCount is Zero, or CapsuleImage is not valid.\r
-                                For across reset capsule image, ScatterGatherList is NULL.\r
+  @retval EFI_INVALID_PARAMETER CapsuleSize is NULL, or an incompatible set of flags were\r
+                                set in the capsule header.\r
+  @retval EFI_INVALID_PARAMETER CapsuleCount is Zero.\r
+  @retval EFI_INVALID_PARAMETER For across reset capsule image, ScatterGatherList is NULL.\r
   @retval EFI_UNSUPPORTED       CapsuleImage is not recognized by the firmware.\r
 \r
 **/\r
@@ -64,6 +71,7 @@ UpdateCapsule (
   EFI_STATUS                Status;\r
   EFI_CAPSULE_HEADER        *CapsuleHeader;\r
   BOOLEAN                   NeedReset;\r
+  BOOLEAN                   InitiateReset;\r
   \r
   //\r
   // Capsule Count can't be less than one.\r
@@ -71,7 +79,9 @@ UpdateCapsule (
   if (CapsuleCount < 1) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
+\r
   NeedReset     = FALSE;\r
+  InitiateReset = FALSE;\r
   CapsuleHeader = NULL;\r
 \r
   for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {\r
@@ -84,6 +94,13 @@ UpdateCapsule (
       return EFI_INVALID_PARAMETER;\r
     }\r
     //\r
+    // A capsule which has the CAPSULE_FLAGS_INITIATE_RESET flag must have\r
+    // CAPSULE_FLAGS_PERSIST_ACROSS_RESET set in its header as well.\r
+    //\r
+    if ((CapsuleHeader->Flags & (CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_INITIATE_RESET)) == CAPSULE_FLAGS_INITIATE_RESET) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+    //\r
     // Check Capsule image without populate flag by firmware support capsule function  \r
     //\r
     if (((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) && \r
@@ -93,8 +110,8 @@ UpdateCapsule (
   }\r
 \r
   //\r
-  // Walk through all capsules, record whether there is a capsule \r
-  // needs reset. And then process capsules which has no reset flag directly.\r
+  // Walk through all capsules, record whether there is a capsule needs reset\r
+  // or initiate reset. And then process capsules which has no reset flag directly.\r
   //\r
   for (ArrayNumber = 0; ArrayNumber < CapsuleCount ; ArrayNumber++) {\r
     CapsuleHeader = CapsuleHeaderArray[ArrayNumber];\r
@@ -113,6 +130,9 @@ UpdateCapsule (
       }\r
     } else {\r
       NeedReset = TRUE;\r
+      if ((CapsuleHeader->Flags & CAPSULE_FLAGS_INITIATE_RESET) != 0) {\r
+        InitiateReset = TRUE;\r
+      }\r
     }\r
   }\r
   \r
@@ -151,7 +171,14 @@ UpdateCapsule (
                  sizeof (UINTN),\r
                  (VOID *) &ScatterGatherList\r
                  );\r
-\r
+  if (!EFI_ERROR (Status) && InitiateReset) {\r
+    //\r
+    // Firmware that encounters a capsule which has the CAPSULE_FLAGS_INITIATE_RESET Flag set in its header\r
+    // will initiate a reset of the platform which is compatible with the passed-in capsule request and will \r
+    // not return back to the caller.\r
+    //\r
+    gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
+  }\r
   return Status;\r
 }\r
 \r
@@ -194,7 +221,7 @@ QueryCapsuleCapabilities (
   }\r
   \r
   //\r
-  // Check whether input paramter is valid\r
+  // Check whether input parameter is valid\r
   //\r
   if ((MaxiumCapsuleSize == NULL) ||(ResetType == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -212,6 +239,13 @@ QueryCapsuleCapabilities (
       return EFI_INVALID_PARAMETER;\r
     }\r
     //\r
+    // A capsule which has the CAPSULE_FLAGS_INITIATE_RESET flag must have\r
+    // CAPSULE_FLAGS_PERSIST_ACROSS_RESET set in its header as well.\r
+    //\r
+    if ((CapsuleHeader->Flags & (CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_INITIATE_RESET)) == CAPSULE_FLAGS_INITIATE_RESET) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+    //\r
     // Check Capsule image without populate flag is supported by firmware\r
     //\r
     if (((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) && \r
@@ -270,7 +304,6 @@ CapsuleServiceInitialize (
   )\r
 {\r
   EFI_STATUS  Status;\r
-  EFI_HANDLE  NewHandle;\r
   \r
   //\r
   // Install capsule runtime services into UEFI runtime service tables.\r
@@ -282,15 +315,13 @@ CapsuleServiceInitialize (
   // Install the Capsule Architectural Protocol on a new handle\r
   // to signify the capsule runtime services are ready.\r
   //\r
-  NewHandle = NULL;\r
-\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &NewHandle,\r
+                  &mNewHandle,\r
                   &gEfiCapsuleArchProtocolGuid,\r
                   NULL,\r
                   NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  return EFI_SUCCESS;\r
+  return Status;\r
 }\r