]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events
authorHao Wu <hao.a.wu@intel.com>
Fri, 10 Mar 2017 02:13:32 +0000 (10:13 +0800)
committerHao Wu <hao.a.wu@intel.com>
Mon, 13 Mar 2017 01:15:47 +0000 (09:15 +0800)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf

index 7f500a96ebe38f945166e6faafe4f4050bd001c3..6344214ea099f06ec12f95c5cf422604be50f6b4 100644 (file)
@@ -47,9 +47,8 @@
 #include <Protocol/FirmwareManagement.h>\r
 #include <Protocol/DevicePath.h>\r
 \r
-EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable              = NULL;\r
-BOOLEAN                   mIsVirtualAddrConverted  = FALSE;\r
-BOOLEAN                   mDxeCapsuleLibEndOfDxe   = FALSE;\r
+BOOLEAN                   mDxeCapsuleLibEndOfDxe       = FALSE;\r
+EFI_EVENT                 mDxeCapsuleLibEndOfDxeEvent  = NULL;\r
 \r
 /**\r
   Initialize capsule related variables.\r
@@ -1654,7 +1653,6 @@ DxeCapsuleLibConstructor (
   IN EFI_SYSTEM_TABLE   *SystemTable\r
   )\r
 {\r
-  EFI_EVENT     EndOfDxeEvent;\r
   EFI_STATUS    Status;\r
 \r
   Status = gBS->CreateEventEx (\r
@@ -1663,7 +1661,7 @@ DxeCapsuleLibConstructor (
                   DxeCapsuleLibEndOfDxe,\r
                   NULL,\r
                   &gEfiEndOfDxeEventGroupGuid,\r
-                  &EndOfDxeEvent\r
+                  &mDxeCapsuleLibEndOfDxeEvent\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
@@ -1671,3 +1669,29 @@ DxeCapsuleLibConstructor (
 \r
   return EFI_SUCCESS;\r
 }\r
+\r
+/**\r
+  The destructor function closes the End of DXE event.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The destructor completed successfully.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeCapsuleLibDestructor (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+\r
+  //\r
+  // Close the End of DXE event.\r
+  //\r
+  Status = gBS->CloseEvent (mDxeCapsuleLibEndOfDxeEvent);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
index 5e437dc418ab978f2e30936b7f0f99f9ebb5ac79..a6cf54cb6b4ad35088e1c2b9df6c33b3a1ecc415 100644 (file)
@@ -3,7 +3,7 @@
 #\r
 #  Capsule library instance for DXE_DRIVER module types.\r
 #\r
-#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #  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
@@ -23,6 +23,7 @@
   VERSION_STRING                 = 1.0\r
   LIBRARY_CLASS                  = CapsuleLib|DXE_DRIVER UEFI_APPLICATION\r
   CONSTRUCTOR                    = DxeCapsuleLibConstructor\r
+  DESTRUCTOR                     = DxeCapsuleLibDestructor\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
index 880143905aa1f358b478d841e30dcd98a1fb1ee4..4725d531462cef7f5df9c8246d17e8e568055afb 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Capsule library runtime support.\r
 \r
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
   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
@@ -26,8 +26,9 @@
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 \r
-extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;\r
-extern BOOLEAN                   mIsVirtualAddrConverted;\r
+EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable                                     = NULL;\r
+BOOLEAN                   mIsVirtualAddrConverted                         = FALSE;\r
+EFI_EVENT                 mDxeRuntimeCapsuleLibVirtualAddressChangeEvent  = NULL;\r
 \r
 /**\r
   Convert EsrtTable physical address to virtual address.\r
@@ -92,21 +93,45 @@ DxeRuntimeCapsuleLibConstructor (
   )\r
 {\r
   EFI_STATUS     Status;\r
-  EFI_EVENT      Event;\r
 \r
   //\r
   // Make sure we can handle virtual address changes.\r
   //\r
-  Event = NULL;\r
   Status = gBS->CreateEventEx (\r
                   EVT_NOTIFY_SIGNAL,\r
                   TPL_NOTIFY,\r
                   DxeCapsuleLibVirtualAddressChangeEvent,\r
                   NULL,\r
                   &gEfiEventVirtualAddressChangeGuid,\r
-                  &Event\r
+                  &mDxeRuntimeCapsuleLibVirtualAddressChangeEvent\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   return EFI_SUCCESS;\r
 }\r
+\r
+/**\r
+  The destructor function closes the VirtualAddressChange event.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The destructor completed successfully.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeRuntimeCapsuleLibDestructor (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+\r
+  //\r
+  // Close the VirtualAddressChange event.\r
+  //\r
+  Status = gBS->CloseEvent (mDxeRuntimeCapsuleLibVirtualAddressChangeEvent);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
index 47c67ccac546dacd9e077caf98ef8d8961273c10..25b7d51f57fa98ffa5fd821371fdf9a87cf2372d 100644 (file)
@@ -3,7 +3,7 @@
 #\r
 #  Capsule library instance for DXE_RUNTIME_DRIVER module types.\r
 #\r
-#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #  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
@@ -24,6 +24,8 @@
   LIBRARY_CLASS                  = CapsuleLib|DXE_RUNTIME_DRIVER\r
   CONSTRUCTOR                    = DxeCapsuleLibConstructor\r
   CONSTRUCTOR                    = DxeRuntimeCapsuleLibConstructor\r
+  DESTRUCTOR                     = DxeCapsuleLibDestructor\r
+  DESTRUCTOR                     = DxeRuntimeCapsuleLibDestructor\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r