]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/UefiDebugLibDebugPortProtocol: Add destructor to CloseEvent
authorXu, Wei6 <wei6.xu@intel.com>
Fri, 26 Jul 2019 03:10:54 +0000 (11:10 +0800)
committerLiming Gao <liming.gao@intel.com>
Mon, 29 Jul 2019 03:01:40 +0000 (11:01 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2012

When driver is unloaded, the ExitBootSerivesEvent must be closed at
the same time. Otherwise exception will occur when ExitBootServices.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLibConstructor.c
MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf

index de60d339a86fb06ade405b92dd564fa49439c0dc..6ea0912f2b3a1b143483dd5861cadee77f303da7 100644 (file)
@@ -75,3 +75,26 @@ DxeDebugLibConstructor(
 \r
   return EFI_SUCCESS;\r
 }\r
+\r
+/**\r
+  The destructor closes Exit Boot Services 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 always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeDebugLibDestructor(\r
+  IN EFI_HANDLE                 ImageHandle,\r
+  IN EFI_SYSTEM_TABLE           *SystemTable\r
+  )\r
+{\r
+  if (mExitBootServicesEvent != NULL) {\r
+    SystemTable->BootServices->CloseEvent (mExitBootServicesEvent);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
index 10a8f2a8576b1df7d8f62b7b161277bb02195bcc..ff09a12ce40ddbce80dd3d8c7e7e562a4a190f12 100644 (file)
@@ -22,6 +22,7 @@
   LIBRARY_CLASS                  = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
 \r
   CONSTRUCTOR                    = DxeDebugLibConstructor\r
+  DESTRUCTOR                     = DxeDebugLibDestructor\r
 \r
 #\r
 #  VALID_ARCHITECTURES           = IA32 X64 EBC\r