]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
Correct minor comments in meta data file.
[mirror_edk2.git] / MdeModulePkg / Universal / CapsuleRuntimeDxe / CapsuleService.c
index dbb9563188b237edc5b06ae0bfb5e73bad7dc2ee..f0e82ae602872a5b43d43795621e4ae64448fa68 100644 (file)
@@ -1,6 +1,8 @@
 /** @file\r
-  Capsule Runtime Drivers produces two UEFI capsule runtime services.\r
+  Capsule Runtime Driver produces two UEFI capsule runtime services.\r
   (UpdateCapsule, QueryCapsuleCapabilities)\r
+  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
 All rights reserved. This program and the accompanying materials\r
@@ -13,7 +15,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include "CapsuleService.h"\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/Capsule.h>\r
+#include <Guid/CapsuleVendor.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/CapsuleLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/UefiRuntimeLib.h>\r
 \r
 /**\r
   Passes capsules to the firmware with both virtual and physical mapping. Depending on the intended\r
@@ -90,7 +103,7 @@ UpdateCapsule (
     //\r
     // Check if the platform supports update capsule across a system reset\r
     //\r
-    if (!FeaturePcdGet(PcdSupportUpdateCapsuleRest)) {\r
+    if (!FeaturePcdGet(PcdSupportUpdateCapsuleReset)) {\r
       return EFI_UNSUPPORTED;\r
     }\r
     //\r
@@ -105,13 +118,13 @@ UpdateCapsule (
       // system reset. Set its value into NV storage to let pre-boot driver to pick it up \r
       // after coming through a system reset.\r
       //\r
-      Status = EfiSetVariable (\r
-                 EFI_CAPSULE_VARIABLE_NAME,\r
-                 &gEfiCapsuleVendorGuid,\r
-                 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-                 sizeof (UINTN),\r
-                 (VOID *) &ScatterGatherList\r
-                 );\r
+      Status = gRT->SetVariable (\r
+                     EFI_CAPSULE_VARIABLE_NAME,\r
+                     &gEfiCapsuleVendorGuid,\r
+                     EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
+                     sizeof (UINTN),\r
+                     (VOID *) &ScatterGatherList\r
+                     );\r
       if (Status != EFI_SUCCESS) {\r
         return Status;\r
       }\r
@@ -219,25 +232,33 @@ QueryCapsuleCapabilities (
     //\r
     //Check if the platform supports update capsule across a system reset\r
     //\r
-    if (!FeaturePcdGet(PcdSupportUpdateCapsuleRest)) {\r
+    if (!FeaturePcdGet(PcdSupportUpdateCapsuleReset)) {\r
       return EFI_UNSUPPORTED;\r
     }\r
-    *ResetType = EfiResetWarm;\r
-    *MaxiumCapsuleSize = FixedPcdGet32(PcdMaxSizePopulateCapsule);\r
+    *ResetType = EfiResetWarm;   \r
   } else {\r
     //\r
     // For non-reset capsule image.\r
     //\r
     *ResetType = EfiResetCold;\r
+  }\r
+  \r
+  //\r
+  // The support max capsule image size\r
+  //\r
+  if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) != 0) {\r
+    *MaxiumCapsuleSize = FixedPcdGet32(PcdMaxSizePopulateCapsule);\r
+  } else {\r
     *MaxiumCapsuleSize = FixedPcdGet32(PcdMaxSizeNonPopulateCapsule);\r
   }\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
 \r
 /**\r
 \r
-  This code is to install UEFI capsule runtime service.\r
+  This code installs UEFI capsule runtime service.\r
 \r
   @param  ImageHandle    The firmware allocated handle for the EFI image.  \r
   @param  SystemTable    A pointer to the EFI System Table.\r
@@ -258,8 +279,8 @@ CapsuleServiceInitialize (
   //\r
   // Install capsule runtime services into UEFI runtime service tables.\r
   //\r
-  SystemTable->RuntimeServices->UpdateCapsule                    = UpdateCapsule;\r
-  SystemTable->RuntimeServices->QueryCapsuleCapabilities         = QueryCapsuleCapabilities;\r
+  gRT->UpdateCapsule                    = UpdateCapsule;\r
+  gRT->QueryCapsuleCapabilities         = QueryCapsuleCapabilities;\r
 \r
   //\r
   // Install the Capsule Architectural Protocol on a new handle\r