]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update CapsuleDriver to use capsule library.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 5 Dec 2007 09:58:33 +0000 (09:58 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 5 Dec 2007 09:58:33 +0000 (09:58 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4365 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/MdeModulePkg.dsc
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.h

index 514f16f50b3459050216450f1dce5332df91f350..bda1f8bfa0f8ca9c0ee8c1ab4ff7feb17ac3f949 100644 (file)
@@ -70,6 +70,7 @@
   UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf\r
   DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf\r
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
 \r
 [LibraryClasses.IA32]\r
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
index a13b461fce99744d868cb34da339abee8271f26c..0a9662bf7af1f19deafc2ce9199ef17501a9ac1c 100644 (file)
 \r
 [LibraryClasses]\r
   UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
   PcdLib\r
   DebugLib\r
   UefiRuntimeLib\r
-  DxeServicesTableLib\r
   UefiDriverEntryPoint\r
+  CapsuleLib\r
 \r
 [Guids]\r
   gEfiCapsuleVendorGuid                         # SOMETIMES_CONSUMED\r
index e74a59151aea97c23f2d7905fc182dce1585fb32..2814c9d774bdcff6339fc887761e9112fd72bbb8 100644 (file)
@@ -47,22 +47,18 @@ Returns:
                                  not set, the capsule has been successfully processed by the firmware.\r
                                  If it set, the ScattlerGatherList is successfully to be set.\r
   EFI_INVALID_PARAMETER          CapsuleCount is less than 1,CapsuleGuid is not supported.\r
-  EFI_DEVICE_ERROR               Failed to SetVariable or AllocatePool or ProcessFirmwareVolume.\r
+  EFI_DEVICE_ERROR               Failed to SetVariable or ProcessFirmwareVolume.\r
 \r
 --*/\r
 {\r
-  UINTN                     CapsuleSize;\r
   UINTN                     ArrayNumber;\r
-  VOID                      *BufferPtr;\r
   EFI_STATUS                Status;\r
-  EFI_HANDLE                FvHandle;\r
   EFI_CAPSULE_HEADER        *CapsuleHeader;\r
 \r
   if (CapsuleCount < 1) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  BufferPtr       = NULL;\r
   CapsuleHeader   = NULL;\r
 \r
   for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {\r
@@ -75,25 +71,22 @@ Returns:
       return EFI_INVALID_PARAMETER;\r
     }\r
     //\r
-    // To remove this check. Capsule update supports non reset image.\r
-    // \r
-    //    if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {\r
-    //      return EFI_UNSUPPORTED;\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
+        (SupportCapsuleImage (CapsuleHeader) != EFI_SUCCESS)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
   }\r
 \r
   //\r
-  // Check capsule guid is suppored by this platform. To do\r
-  //\r
-\r
-  //\r
-  //Assume that capsules have the same flags on reseting or not.\r
+  // Assume that capsules have the same flags on reseting or not.\r
   //\r
   CapsuleHeader = CapsuleHeaderArray[0];\r
 \r
   if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {\r
     //\r
-    //Check if the platform supports update capsule across a system reset\r
+    // Check if the platform supports update capsule across a system reset\r
     //\r
     if (!FeaturePcdGet(PcdSupportUpdateCapsuleRest)) {\r
       return EFI_UNSUPPORTED;\r
@@ -120,13 +113,16 @@ Returns:
       if (Status != EFI_SUCCESS) {\r
         return Status;\r
       }\r
+      //\r
+      // Successfully set the capsule image address into variable.\r
+      //\r
+      return EFI_SUCCESS;\r
     }\r
-    return EFI_SUCCESS;\r
   }\r
 \r
   //\r
   // The rest occurs in the condition of non-reset mode\r
-  // Current Runtime mode doesn't support the non-reset capsule image.\r
+  // Now Runtime mode doesn't support the non-reset capsule image.\r
   //\r
   if (EfiAtRuntime ()) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -134,29 +130,13 @@ Returns:
 \r
   //\r
   // Here should be in the boot-time for non-reset capsule image\r
-  // Default process to Update Capsule image into Flash for any guid image.\r
+  // Default process to Update Capsule image into Flash.\r
   //\r
   for (ArrayNumber = 0; ArrayNumber < CapsuleCount ; ArrayNumber++) {\r
-    CapsuleHeader = CapsuleHeaderArray[ArrayNumber];\r
-    CapsuleSize = CapsuleHeader->CapsuleImageSize - CapsuleHeader->HeaderSize;\r
-\r
-    BufferPtr = AllocatePool (CapsuleSize);\r
-    if (BufferPtr == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    CopyMem (BufferPtr, (UINT8*)CapsuleHeader+ CapsuleHeader->HeaderSize, CapsuleSize);\r
-\r
-    //\r
-    //Call DXE service ProcessFirmwareVolume to process immediatelly\r
-    //\r
-    Status = gDS->ProcessFirmwareVolume (BufferPtr, CapsuleSize, &FvHandle);\r
-    if (Status != EFI_SUCCESS) {\r
-      FreePool (BufferPtr);\r
+    Status = ProcessCapsuleImage (CapsuleHeaderArray[ArrayNumber]);\r
+    if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
-    gDS->Dispatch ();\r
-    FreePool (BufferPtr);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -218,11 +198,12 @@ Returns:
       return EFI_INVALID_PARAMETER;\r
     }\r
     //\r
-    // To remove this check. Capsule update supports non reset image.\r
-    // \r
-    //    if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {\r
-    //      return EFI_UNSUPPORTED;\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
+        (SupportCapsuleImage (CapsuleHeader) != EFI_SUCCESS)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
   }\r
 \r
   //\r
index 5d73810f3db3d26151693c37e6405171350f2a21..91fdbb307072c6e3a3bedc3e4a23f51873eaf811 100644 (file)
@@ -29,15 +29,11 @@ Abstract:
 #include <Guid/CapsuleVendor.h>\r
 \r
 #include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/DxeServicesTableLib.h>\r
 #include <Library/UefiRuntimeLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/PcdLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
-\r
-extern EFI_GUID gEfiCapsuleGuid;\r
+#include <Library/CapsuleLib.h>\r
 \r
 EFI_STATUS\r
 EFIAPI\r