public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 0/2] MdeModulePkg/CapsuleLib: Code refinements
@ 2017-03-10  7:16 Hao Wu
  2017-03-10  7:16 ` [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events Hao Wu
  2017-03-10  7:16 ` [PATCH v2 2/2] MdeModulePkg/CapsuleLib: Free the buffer returned by GetVariable2 API Hao Wu
  0 siblings, 2 replies; 8+ messages in thread
From: Hao Wu @ 2017-03-10  7:16 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu, Jiewen Yao

V2 changes:
1) Check the return status of the GetVariable2 API before freeing the
returned buffer from this function.

V1 history:
The series makes the following refinements in DxeCapsuleLibFmp:
1) Add library destructors to close the events created in their relative
constructors.

2) Free the buffer returned by the GetVariable2 API.

Cc: Jiewen Yao <jiewen.yao@intel.com>

Hao Wu (2):
  MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events
  MdeModulePkg/CapsuleLib: Free the buffer returned by GetVariable2 API

 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c          | 37 +++++++++++++++++---
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf        |  3 +-
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c    |  4 +++
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c      | 33 ++++++++++++++---
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf |  4 ++-
 5 files changed, 70 insertions(+), 11 deletions(-)

-- 
2.12.0.windows.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events
  2017-03-10  7:16 [PATCH v2 0/2] MdeModulePkg/CapsuleLib: Code refinements Hao Wu
@ 2017-03-10  7:16 ` Hao Wu
  2017-03-10  7:22   ` Yao, Jiewen
  2017-03-10  7:16 ` [PATCH v2 2/2] MdeModulePkg/CapsuleLib: Free the buffer returned by GetVariable2 API Hao Wu
  1 sibling, 1 reply; 8+ messages in thread
From: Hao Wu @ 2017-03-10  7:16 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu

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          | 37 +++++++++++++++++---
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf        |  3 +-
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c      | 33 ++++++++++++++---
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf |  4 ++-
 4 files changed, 66 insertions(+), 11 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
index 7f500a96eb..a892892ccd 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
@@ -47,9 +47,11 @@
 #include <Protocol/FirmwareManagement.h>
 #include <Protocol/DevicePath.h>
 
-EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable              = NULL;
-BOOLEAN                   mIsVirtualAddrConverted  = FALSE;
-BOOLEAN                   mDxeCapsuleLibEndOfDxe   = FALSE;
+EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable                                     = NULL;
+BOOLEAN                   mIsVirtualAddrConverted                         = FALSE;
+BOOLEAN                   mDxeCapsuleLibEndOfDxe                          = FALSE;
+EFI_EVENT                 mDxeCapsuleLibEndOfDxeEvent                     = NULL;
+EFI_EVENT                 mDxeRuntimeCapsuleLibVirtualAddressChangeEvent  = NULL;
 
 /**
   Initialize capsule related variables.
@@ -1654,7 +1656,6 @@ DxeCapsuleLibConstructor (
   IN EFI_SYSTEM_TABLE   *SystemTable
   )
 {
-  EFI_EVENT     EndOfDxeEvent;
   EFI_STATUS    Status;
 
   Status = gBS->CreateEventEx (
@@ -1663,7 +1664,7 @@ DxeCapsuleLibConstructor (
                   DxeCapsuleLibEndOfDxe,
                   NULL,
                   &gEfiEndOfDxeEventGroupGuid,
-                  &EndOfDxeEvent
+                  &mDxeCapsuleLibEndOfDxeEvent
                   );
   ASSERT_EFI_ERROR (Status);
 
@@ -1671,3 +1672,29 @@ DxeCapsuleLibConstructor (
 
   return EFI_SUCCESS;
 }
+
+/**
+  The destructor function closes the End of DXE event.
+
+  @param  ImageHandle   The firmware allocated handle for the EFI image.
+  @param  SystemTable   A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS   The destructor completed successfully.
+**/
+EFI_STATUS
+EFIAPI
+DxeCapsuleLibDestructor (
+  IN EFI_HANDLE         ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS    Status;
+
+  //
+  // Close the End of DXE event.
+  //
+  Status = gBS->CloseEvent (mDxeCapsuleLibEndOfDxeEvent);
+  ASSERT_EFI_ERROR (Status);
+
+  return EFI_SUCCESS;
+}
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
index 5e437dc418..a6cf54cb6b 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
@@ -3,7 +3,7 @@
 #
 #  Capsule library instance for DXE_DRIVER module types.
 #
-#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
@@ -23,6 +23,7 @@
   VERSION_STRING                 = 1.0
   LIBRARY_CLASS                  = CapsuleLib|DXE_DRIVER UEFI_APPLICATION
   CONSTRUCTOR                    = DxeCapsuleLibConstructor
+  DESTRUCTOR                     = DxeCapsuleLibDestructor
 
 #
 # The following information is for reference only and not required by the build tools.
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
index 880143905a..513aa533e1 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
@@ -1,7 +1,7 @@
 /** @file
   Capsule library runtime support.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
@@ -28,6 +28,7 @@
 
 extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;
 extern BOOLEAN                   mIsVirtualAddrConverted;
+extern EFI_EVENT                 mDxeRuntimeCapsuleLibVirtualAddressChangeEvent;
 
 /**
   Convert EsrtTable physical address to virtual address.
@@ -92,21 +93,45 @@ DxeRuntimeCapsuleLibConstructor (
   )
 {
   EFI_STATUS     Status;
-  EFI_EVENT      Event;
 
   //
   // Make sure we can handle virtual address changes.
   //
-  Event = NULL;
   Status = gBS->CreateEventEx (
                   EVT_NOTIFY_SIGNAL,
                   TPL_NOTIFY,
                   DxeCapsuleLibVirtualAddressChangeEvent,
                   NULL,
                   &gEfiEventVirtualAddressChangeGuid,
-                  &Event
+                  &mDxeRuntimeCapsuleLibVirtualAddressChangeEvent
                   );
   ASSERT_EFI_ERROR (Status);
 
   return EFI_SUCCESS;
 }
+
+/**
+  The destructor function closes the VirtualAddressChange event.
+
+  @param  ImageHandle   The firmware allocated handle for the EFI image.
+  @param  SystemTable   A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS   The destructor completed successfully.
+**/
+EFI_STATUS
+EFIAPI
+DxeRuntimeCapsuleLibDestructor (
+  IN EFI_HANDLE         ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS    Status;
+
+  //
+  // Close the VirtualAddressChange event.
+  //
+  Status = gBS->CloseEvent (mDxeRuntimeCapsuleLibVirtualAddressChangeEvent);
+  ASSERT_EFI_ERROR (Status);
+
+  return EFI_SUCCESS;
+}
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
index 47c67ccac5..25b7d51f57 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
@@ -3,7 +3,7 @@
 #
 #  Capsule library instance for DXE_RUNTIME_DRIVER module types.
 #
-#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
@@ -24,6 +24,8 @@
   LIBRARY_CLASS                  = CapsuleLib|DXE_RUNTIME_DRIVER
   CONSTRUCTOR                    = DxeCapsuleLibConstructor
   CONSTRUCTOR                    = DxeRuntimeCapsuleLibConstructor
+  DESTRUCTOR                     = DxeCapsuleLibDestructor
+  DESTRUCTOR                     = DxeRuntimeCapsuleLibDestructor
 
 #
 # The following information is for reference only and not required by the build tools.
-- 
2.12.0.windows.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] MdeModulePkg/CapsuleLib: Free the buffer returned by GetVariable2 API
  2017-03-10  7:16 [PATCH v2 0/2] MdeModulePkg/CapsuleLib: Code refinements Hao Wu
  2017-03-10  7:16 ` [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events Hao Wu
@ 2017-03-10  7:16 ` Hao Wu
  2017-03-10  7:21   ` Yao, Jiewen
  1 sibling, 1 reply; 8+ messages in thread
From: Hao Wu @ 2017-03-10  7:16 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu, Jiewen Yao

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
index fc0f8698a9..3fed8e06e4 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
@@ -342,6 +342,10 @@ InitCapsuleLastVariable (
                         0,
                         NULL
                         );
+      } else {
+        if (CapsuleResult != NULL) {
+          FreePool (CapsuleResult);
+        }
       }
     }
 
-- 
2.12.0.windows.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] MdeModulePkg/CapsuleLib: Free the buffer returned by GetVariable2 API
  2017-03-10  7:16 ` [PATCH v2 2/2] MdeModulePkg/CapsuleLib: Free the buffer returned by GetVariable2 API Hao Wu
@ 2017-03-10  7:21   ` Yao, Jiewen
  0 siblings, 0 replies; 8+ messages in thread
From: Yao, Jiewen @ 2017-03-10  7:21 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org

Reviewed-by: jiewen.yao@intel.com

> -----Original Message-----
> From: Wu, Hao A
> Sent: Friday, March 10, 2017 3:16 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH v2 2/2] MdeModulePkg/CapsuleLib: Free the buffer returned by
> GetVariable2 API
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
>  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
> index fc0f8698a9..3fed8e06e4 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c
> @@ -342,6 +342,10 @@ InitCapsuleLastVariable (
>                          0,
>                          NULL
>                          );
> +      } else {
> +        if (CapsuleResult != NULL) {
> +          FreePool (CapsuleResult);
> +        }
>        }
>      }
> 
> --
> 2.12.0.windows.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events
  2017-03-10  7:16 ` [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events Hao Wu
@ 2017-03-10  7:22   ` Yao, Jiewen
  2017-03-10  7:39     ` Wu, Hao A
  0 siblings, 1 reply; 8+ messages in thread
From: Yao, Jiewen @ 2017-03-10  7:22 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Wu, Hao A

I just find it is unnecessary to put mDxeRuntimeCapsuleLibVirtualAddressChangeEvent and mIsVirtualAddrConverted to DxeCapsuleLib.c.
Can we just move them to DxeCapsuleLibRuntime.c?

I think this is simple update. No need to send V3.
You can do that when check in.

Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>

Thank you
Yao Jiewen


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Hao
> Wu
> Sent: Friday, March 10, 2017 3:16 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A <hao.a.wu@intel.com>
> Subject: [edk2] [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib destructors
> to handle unclosed events
> 
> 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          | 37
> +++++++++++++++++---
>  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf        |  3 +-
>  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c      | 33
> ++++++++++++++---
>  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf |  4
> ++-
>  4 files changed, 66 insertions(+), 11 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> index 7f500a96eb..a892892ccd 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> @@ -47,9 +47,11 @@
>  #include <Protocol/FirmwareManagement.h>
>  #include <Protocol/DevicePath.h>
> 
> -EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable              = NULL;
> -BOOLEAN                   mIsVirtualAddrConverted  = FALSE;
> -BOOLEAN                   mDxeCapsuleLibEndOfDxe   = FALSE;
> +EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable
> = NULL;
> +BOOLEAN                   mIsVirtualAddrConverted
> = FALSE;
> +BOOLEAN                   mDxeCapsuleLibEndOfDxe
> = FALSE;
> +EFI_EVENT                 mDxeCapsuleLibEndOfDxeEvent
> = NULL;
> +EFI_EVENT
> mDxeRuntimeCapsuleLibVirtualAddressChangeEvent  = NULL;
> 
>  /**
>    Initialize capsule related variables.
> @@ -1654,7 +1656,6 @@ DxeCapsuleLibConstructor (
>    IN EFI_SYSTEM_TABLE   *SystemTable
>    )
>  {
> -  EFI_EVENT     EndOfDxeEvent;
>    EFI_STATUS    Status;
> 
>    Status = gBS->CreateEventEx (
> @@ -1663,7 +1664,7 @@ DxeCapsuleLibConstructor (
>                    DxeCapsuleLibEndOfDxe,
>                    NULL,
>                    &gEfiEndOfDxeEventGroupGuid,
> -                  &EndOfDxeEvent
> +                  &mDxeCapsuleLibEndOfDxeEvent
>                    );
>    ASSERT_EFI_ERROR (Status);
> 
> @@ -1671,3 +1672,29 @@ DxeCapsuleLibConstructor (
> 
>    return EFI_SUCCESS;
>  }
> +
> +/**
> +  The destructor function closes the End of DXE event.
> +
> +  @param  ImageHandle   The firmware allocated handle for the EFI image.
> +  @param  SystemTable   A pointer to the EFI System Table.
> +
> +  @retval EFI_SUCCESS   The destructor completed successfully.
> +**/
> +EFI_STATUS
> +EFIAPI
> +DxeCapsuleLibDestructor (
> +  IN EFI_HANDLE         ImageHandle,
> +  IN EFI_SYSTEM_TABLE   *SystemTable
> +  )
> +{
> +  EFI_STATUS    Status;
> +
> +  //
> +  // Close the End of DXE event.
> +  //
> +  Status = gBS->CloseEvent (mDxeCapsuleLibEndOfDxeEvent);
> +  ASSERT_EFI_ERROR (Status);
> +
> +  return EFI_SUCCESS;
> +}
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> index 5e437dc418..a6cf54cb6b 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> @@ -3,7 +3,7 @@
>  #
>  #  Capsule library instance for DXE_DRIVER module types.
>  #
> -#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> +#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the BSD
> License
>  #  which accompanies this distribution.  The full text of the license may be
> found at
> @@ -23,6 +23,7 @@
>    VERSION_STRING                 = 1.0
>    LIBRARY_CLASS                  = CapsuleLib|DXE_DRIVER
> UEFI_APPLICATION
>    CONSTRUCTOR                    = DxeCapsuleLibConstructor
> +  DESTRUCTOR                     = DxeCapsuleLibDestructor
> 
>  #
>  # The following information is for reference only and not required by the build
> tools.
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> index 880143905a..513aa533e1 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> @@ -1,7 +1,7 @@
>  /** @file
>    Capsule library runtime support.
> 
> -  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
>    This program and the accompanying materials
>    are licensed and made available under the terms and conditions of the BSD
> License
>    which accompanies this distribution.  The full text of the license may be
> found at
> @@ -28,6 +28,7 @@
> 
>  extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;
>  extern BOOLEAN                   mIsVirtualAddrConverted;
> +extern EFI_EVENT
> mDxeRuntimeCapsuleLibVirtualAddressChangeEvent;
> 
>  /**
>    Convert EsrtTable physical address to virtual address.
> @@ -92,21 +93,45 @@ DxeRuntimeCapsuleLibConstructor (
>    )
>  {
>    EFI_STATUS     Status;
> -  EFI_EVENT      Event;
> 
>    //
>    // Make sure we can handle virtual address changes.
>    //
> -  Event = NULL;
>    Status = gBS->CreateEventEx (
>                    EVT_NOTIFY_SIGNAL,
>                    TPL_NOTIFY,
>                    DxeCapsuleLibVirtualAddressChangeEvent,
>                    NULL,
>                    &gEfiEventVirtualAddressChangeGuid,
> -                  &Event
> +                  &mDxeRuntimeCapsuleLibVirtualAddressChangeEvent
>                    );
>    ASSERT_EFI_ERROR (Status);
> 
>    return EFI_SUCCESS;
>  }
> +
> +/**
> +  The destructor function closes the VirtualAddressChange event.
> +
> +  @param  ImageHandle   The firmware allocated handle for the EFI image.
> +  @param  SystemTable   A pointer to the EFI System Table.
> +
> +  @retval EFI_SUCCESS   The destructor completed successfully.
> +**/
> +EFI_STATUS
> +EFIAPI
> +DxeRuntimeCapsuleLibDestructor (
> +  IN EFI_HANDLE         ImageHandle,
> +  IN EFI_SYSTEM_TABLE   *SystemTable
> +  )
> +{
> +  EFI_STATUS    Status;
> +
> +  //
> +  // Close the VirtualAddressChange event.
> +  //
> +  Status = gBS->CloseEvent
> (mDxeRuntimeCapsuleLibVirtualAddressChangeEvent);
> +  ASSERT_EFI_ERROR (Status);
> +
> +  return EFI_SUCCESS;
> +}
> diff --git
> a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> index 47c67ccac5..25b7d51f57 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> @@ -3,7 +3,7 @@
>  #
>  #  Capsule library instance for DXE_RUNTIME_DRIVER module types.
>  #
> -#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> +#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the BSD
> License
>  #  which accompanies this distribution.  The full text of the license may be
> found at
> @@ -24,6 +24,8 @@
>    LIBRARY_CLASS                  = CapsuleLib|DXE_RUNTIME_DRIVER
>    CONSTRUCTOR                    = DxeCapsuleLibConstructor
>    CONSTRUCTOR                    = DxeRuntimeCapsuleLibConstructor
> +  DESTRUCTOR                     = DxeCapsuleLibDestructor
> +  DESTRUCTOR                     = DxeRuntimeCapsuleLibDestructor
> 
>  #
>  # The following information is for reference only and not required by the build
> tools.
> --
> 2.12.0.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events
  2017-03-10  7:22   ` Yao, Jiewen
@ 2017-03-10  7:39     ` Wu, Hao A
  2017-03-10  7:45       ` Wu, Hao A
  0 siblings, 1 reply; 8+ messages in thread
From: Wu, Hao A @ 2017-03-10  7:39 UTC (permalink / raw)
  To: Yao, Jiewen, edk2-devel@lists.01.org

> -----Original Message-----
> From: Yao, Jiewen
> Sent: Friday, March 10, 2017 3:23 PM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Wu, Hao A
> Subject: RE: [edk2] [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib
> destructors to handle unclosed events
> 
> I just find it is unnecessary to put
> mDxeRuntimeCapsuleLibVirtualAddressChangeEvent and
> mIsVirtualAddrConverted to DxeCapsuleLib.c.
> Can we just move them to DxeCapsuleLibRuntime.c?
> 
> I think this is simple update. No need to send V3.
> You can do that when check in.
> 
> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>

Got it, I will move them before checking in the code.

Best Regards,
Hao Wu

> 
> Thank you
> Yao Jiewen
> 
> 
> > -----Original Message-----
> > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Hao
> > Wu
> > Sent: Friday, March 10, 2017 3:16 PM
> > To: edk2-devel@lists.01.org
> > Cc: Wu, Hao A <hao.a.wu@intel.com>
> > Subject: [edk2] [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib
> destructors
> > to handle unclosed events
> >
> > 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          | 37
> > +++++++++++++++++---
> >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf        |  3 +-
> >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c      | 33
> > ++++++++++++++---
> >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf |  4
> > ++-
> >  4 files changed, 66 insertions(+), 11 deletions(-)
> >
> > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > index 7f500a96eb..a892892ccd 100644
> > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > @@ -47,9 +47,11 @@
> >  #include <Protocol/FirmwareManagement.h>
> >  #include <Protocol/DevicePath.h>
> >
> > -EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable              = NULL;
> > -BOOLEAN                   mIsVirtualAddrConverted  = FALSE;
> > -BOOLEAN                   mDxeCapsuleLibEndOfDxe   = FALSE;
> > +EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable
> > = NULL;
> > +BOOLEAN                   mIsVirtualAddrConverted
> > = FALSE;
> > +BOOLEAN                   mDxeCapsuleLibEndOfDxe
> > = FALSE;
> > +EFI_EVENT                 mDxeCapsuleLibEndOfDxeEvent
> > = NULL;
> > +EFI_EVENT
> > mDxeRuntimeCapsuleLibVirtualAddressChangeEvent  = NULL;
> >
> >  /**
> >    Initialize capsule related variables.
> > @@ -1654,7 +1656,6 @@ DxeCapsuleLibConstructor (
> >    IN EFI_SYSTEM_TABLE   *SystemTable
> >    )
> >  {
> > -  EFI_EVENT     EndOfDxeEvent;
> >    EFI_STATUS    Status;
> >
> >    Status = gBS->CreateEventEx (
> > @@ -1663,7 +1664,7 @@ DxeCapsuleLibConstructor (
> >                    DxeCapsuleLibEndOfDxe,
> >                    NULL,
> >                    &gEfiEndOfDxeEventGroupGuid,
> > -                  &EndOfDxeEvent
> > +                  &mDxeCapsuleLibEndOfDxeEvent
> >                    );
> >    ASSERT_EFI_ERROR (Status);
> >
> > @@ -1671,3 +1672,29 @@ DxeCapsuleLibConstructor (
> >
> >    return EFI_SUCCESS;
> >  }
> > +
> > +/**
> > +  The destructor function closes the End of DXE event.
> > +
> > +  @param  ImageHandle   The firmware allocated handle for the EFI image.
> > +  @param  SystemTable   A pointer to the EFI System Table.
> > +
> > +  @retval EFI_SUCCESS   The destructor completed successfully.
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +DxeCapsuleLibDestructor (
> > +  IN EFI_HANDLE         ImageHandle,
> > +  IN EFI_SYSTEM_TABLE   *SystemTable
> > +  )
> > +{
> > +  EFI_STATUS    Status;
> > +
> > +  //
> > +  // Close the End of DXE event.
> > +  //
> > +  Status = gBS->CloseEvent (mDxeCapsuleLibEndOfDxeEvent);
> > +  ASSERT_EFI_ERROR (Status);
> > +
> > +  return EFI_SUCCESS;
> > +}
> > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> > index 5e437dc418..a6cf54cb6b 100644
> > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> > @@ -3,7 +3,7 @@
> >  #
> >  #  Capsule library instance for DXE_DRIVER module types.
> >  #
> > -#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> > +#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
> >  #  This program and the accompanying materials
> >  #  are licensed and made available under the terms and conditions of the
> BSD
> > License
> >  #  which accompanies this distribution.  The full text of the license may be
> > found at
> > @@ -23,6 +23,7 @@
> >    VERSION_STRING                 = 1.0
> >    LIBRARY_CLASS                  = CapsuleLib|DXE_DRIVER
> > UEFI_APPLICATION
> >    CONSTRUCTOR                    = DxeCapsuleLibConstructor
> > +  DESTRUCTOR                     = DxeCapsuleLibDestructor
> >
> >  #
> >  # The following information is for reference only and not required by the
> build
> > tools.
> > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > index 880143905a..513aa533e1 100644
> > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > @@ -1,7 +1,7 @@
> >  /** @file
> >    Capsule library runtime support.
> >
> > -  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> > +  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
> >    This program and the accompanying materials
> >    are licensed and made available under the terms and conditions of the BSD
> > License
> >    which accompanies this distribution.  The full text of the license may be
> > found at
> > @@ -28,6 +28,7 @@
> >
> >  extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;
> >  extern BOOLEAN                   mIsVirtualAddrConverted;
> > +extern EFI_EVENT
> > mDxeRuntimeCapsuleLibVirtualAddressChangeEvent;
> >
> >  /**
> >    Convert EsrtTable physical address to virtual address.
> > @@ -92,21 +93,45 @@ DxeRuntimeCapsuleLibConstructor (
> >    )
> >  {
> >    EFI_STATUS     Status;
> > -  EFI_EVENT      Event;
> >
> >    //
> >    // Make sure we can handle virtual address changes.
> >    //
> > -  Event = NULL;
> >    Status = gBS->CreateEventEx (
> >                    EVT_NOTIFY_SIGNAL,
> >                    TPL_NOTIFY,
> >                    DxeCapsuleLibVirtualAddressChangeEvent,
> >                    NULL,
> >                    &gEfiEventVirtualAddressChangeGuid,
> > -                  &Event
> > +                  &mDxeRuntimeCapsuleLibVirtualAddressChangeEvent
> >                    );
> >    ASSERT_EFI_ERROR (Status);
> >
> >    return EFI_SUCCESS;
> >  }
> > +
> > +/**
> > +  The destructor function closes the VirtualAddressChange event.
> > +
> > +  @param  ImageHandle   The firmware allocated handle for the EFI image.
> > +  @param  SystemTable   A pointer to the EFI System Table.
> > +
> > +  @retval EFI_SUCCESS   The destructor completed successfully.
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +DxeRuntimeCapsuleLibDestructor (
> > +  IN EFI_HANDLE         ImageHandle,
> > +  IN EFI_SYSTEM_TABLE   *SystemTable
> > +  )
> > +{
> > +  EFI_STATUS    Status;
> > +
> > +  //
> > +  // Close the VirtualAddressChange event.
> > +  //
> > +  Status = gBS->CloseEvent
> > (mDxeRuntimeCapsuleLibVirtualAddressChangeEvent);
> > +  ASSERT_EFI_ERROR (Status);
> > +
> > +  return EFI_SUCCESS;
> > +}
> > diff --git
> > a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> > index 47c67ccac5..25b7d51f57 100644
> > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> > @@ -3,7 +3,7 @@
> >  #
> >  #  Capsule library instance for DXE_RUNTIME_DRIVER module types.
> >  #
> > -#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> > +#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
> >  #  This program and the accompanying materials
> >  #  are licensed and made available under the terms and conditions of the
> BSD
> > License
> >  #  which accompanies this distribution.  The full text of the license may be
> > found at
> > @@ -24,6 +24,8 @@
> >    LIBRARY_CLASS                  = CapsuleLib|DXE_RUNTIME_DRIVER
> >    CONSTRUCTOR                    = DxeCapsuleLibConstructor
> >    CONSTRUCTOR                    = DxeRuntimeCapsuleLibConstructor
> > +  DESTRUCTOR                     = DxeCapsuleLibDestructor
> > +  DESTRUCTOR                     = DxeRuntimeCapsuleLibDestructor
> >
> >  #
> >  # The following information is for reference only and not required by the
> build
> > tools.
> > --
> > 2.12.0.windows.1
> >
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events
  2017-03-10  7:39     ` Wu, Hao A
@ 2017-03-10  7:45       ` Wu, Hao A
  2017-03-10  7:52         ` Yao, Jiewen
  0 siblings, 1 reply; 8+ messages in thread
From: Wu, Hao A @ 2017-03-10  7:45 UTC (permalink / raw)
  To: Yao, Jiewen, edk2-devel@lists.01.org

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Wu,
> Hao A
> Sent: Friday, March 10, 2017 3:40 PM
> To: Yao, Jiewen; edk2-devel@lists.01.org
> Subject: Re: [edk2] [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib
> destructors to handle unclosed events
> 
> > -----Original Message-----
> > From: Yao, Jiewen
> > Sent: Friday, March 10, 2017 3:23 PM
> > To: Wu, Hao A; edk2-devel@lists.01.org
> > Cc: Wu, Hao A
> > Subject: RE: [edk2] [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib
> > destructors to handle unclosed events
> >
> > I just find it is unnecessary to put
> > mDxeRuntimeCapsuleLibVirtualAddressChangeEvent and
> > mIsVirtualAddrConverted to DxeCapsuleLib.c.
> > Can we just move them to DxeCapsuleLibRuntime.c?
> >
> > I think this is simple update. No need to send V3.
> > You can do that when check in.
> >
> > Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
> 
> Got it, I will move them before checking in the code.

I double checked the code, it seems that 'mEsrtTable' is only used in file
DxeCapsuleRuntime.c as well, I will move it from DxeCapsuleLib.c as well.

> 
> Best Regards,
> Hao Wu
> 
> >
> > Thank you
> > Yao Jiewen
> >
> >
> > > -----Original Message-----
> > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Hao
> > > Wu
> > > Sent: Friday, March 10, 2017 3:16 PM
> > > To: edk2-devel@lists.01.org
> > > Cc: Wu, Hao A <hao.a.wu@intel.com>
> > > Subject: [edk2] [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib
> > destructors
> > > to handle unclosed events
> > >
> > > 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          | 37
> > > +++++++++++++++++---
> > >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf        |  3 +-
> > >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c      | 33
> > > ++++++++++++++---
> > >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf |  4
> > > ++-
> > >  4 files changed, 66 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > index 7f500a96eb..a892892ccd 100644
> > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > @@ -47,9 +47,11 @@
> > >  #include <Protocol/FirmwareManagement.h>
> > >  #include <Protocol/DevicePath.h>
> > >
> > > -EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable              = NULL;
> > > -BOOLEAN                   mIsVirtualAddrConverted  = FALSE;
> > > -BOOLEAN                   mDxeCapsuleLibEndOfDxe   = FALSE;
> > > +EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable
> > > = NULL;
> > > +BOOLEAN                   mIsVirtualAddrConverted
> > > = FALSE;
> > > +BOOLEAN                   mDxeCapsuleLibEndOfDxe
> > > = FALSE;
> > > +EFI_EVENT                 mDxeCapsuleLibEndOfDxeEvent
> > > = NULL;
> > > +EFI_EVENT
> > > mDxeRuntimeCapsuleLibVirtualAddressChangeEvent  = NULL;
> > >
> > >  /**
> > >    Initialize capsule related variables.
> > > @@ -1654,7 +1656,6 @@ DxeCapsuleLibConstructor (
> > >    IN EFI_SYSTEM_TABLE   *SystemTable
> > >    )
> > >  {
> > > -  EFI_EVENT     EndOfDxeEvent;
> > >    EFI_STATUS    Status;
> > >
> > >    Status = gBS->CreateEventEx (
> > > @@ -1663,7 +1664,7 @@ DxeCapsuleLibConstructor (
> > >                    DxeCapsuleLibEndOfDxe,
> > >                    NULL,
> > >                    &gEfiEndOfDxeEventGroupGuid,
> > > -                  &EndOfDxeEvent
> > > +                  &mDxeCapsuleLibEndOfDxeEvent
> > >                    );
> > >    ASSERT_EFI_ERROR (Status);
> > >
> > > @@ -1671,3 +1672,29 @@ DxeCapsuleLibConstructor (
> > >
> > >    return EFI_SUCCESS;
> > >  }
> > > +
> > > +/**
> > > +  The destructor function closes the End of DXE event.
> > > +
> > > +  @param  ImageHandle   The firmware allocated handle for the EFI
> image.
> > > +  @param  SystemTable   A pointer to the EFI System Table.
> > > +
> > > +  @retval EFI_SUCCESS   The destructor completed successfully.
> > > +**/
> > > +EFI_STATUS
> > > +EFIAPI
> > > +DxeCapsuleLibDestructor (
> > > +  IN EFI_HANDLE         ImageHandle,
> > > +  IN EFI_SYSTEM_TABLE   *SystemTable
> > > +  )
> > > +{
> > > +  EFI_STATUS    Status;
> > > +
> > > +  //
> > > +  // Close the End of DXE event.
> > > +  //
> > > +  Status = gBS->CloseEvent (mDxeCapsuleLibEndOfDxeEvent);
> > > +  ASSERT_EFI_ERROR (Status);
> > > +
> > > +  return EFI_SUCCESS;
> > > +}
> > > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> > > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> > > index 5e437dc418..a6cf54cb6b 100644
> > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> > > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> > > @@ -3,7 +3,7 @@
> > >  #
> > >  #  Capsule library instance for DXE_DRIVER module types.
> > >  #
> > > -#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> > > +#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
> > >  #  This program and the accompanying materials
> > >  #  are licensed and made available under the terms and conditions of the
> > BSD
> > > License
> > >  #  which accompanies this distribution.  The full text of the license may be
> > > found at
> > > @@ -23,6 +23,7 @@
> > >    VERSION_STRING                 = 1.0
> > >    LIBRARY_CLASS                  = CapsuleLib|DXE_DRIVER
> > > UEFI_APPLICATION
> > >    CONSTRUCTOR                    = DxeCapsuleLibConstructor
> > > +  DESTRUCTOR                     = DxeCapsuleLibDestructor
> > >
> > >  #
> > >  # The following information is for reference only and not required by the
> > build
> > > tools.
> > > diff --git
> a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > index 880143905a..513aa533e1 100644
> > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > @@ -1,7 +1,7 @@
> > >  /** @file
> > >    Capsule library runtime support.
> > >
> > > -  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> > > +  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
> > >    This program and the accompanying materials
> > >    are licensed and made available under the terms and conditions of the
> BSD
> > > License
> > >    which accompanies this distribution.  The full text of the license may be
> > > found at
> > > @@ -28,6 +28,7 @@
> > >
> > >  extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;
> > >  extern BOOLEAN                   mIsVirtualAddrConverted;
> > > +extern EFI_EVENT
> > > mDxeRuntimeCapsuleLibVirtualAddressChangeEvent;
> > >
> > >  /**
> > >    Convert EsrtTable physical address to virtual address.
> > > @@ -92,21 +93,45 @@ DxeRuntimeCapsuleLibConstructor (
> > >    )
> > >  {
> > >    EFI_STATUS     Status;
> > > -  EFI_EVENT      Event;
> > >
> > >    //
> > >    // Make sure we can handle virtual address changes.
> > >    //
> > > -  Event = NULL;
> > >    Status = gBS->CreateEventEx (
> > >                    EVT_NOTIFY_SIGNAL,
> > >                    TPL_NOTIFY,
> > >                    DxeCapsuleLibVirtualAddressChangeEvent,
> > >                    NULL,
> > >                    &gEfiEventVirtualAddressChangeGuid,
> > > -                  &Event
> > > +                  &mDxeRuntimeCapsuleLibVirtualAddressChangeEvent
> > >                    );
> > >    ASSERT_EFI_ERROR (Status);
> > >
> > >    return EFI_SUCCESS;
> > >  }
> > > +
> > > +/**
> > > +  The destructor function closes the VirtualAddressChange event.
> > > +
> > > +  @param  ImageHandle   The firmware allocated handle for the EFI
> image.
> > > +  @param  SystemTable   A pointer to the EFI System Table.
> > > +
> > > +  @retval EFI_SUCCESS   The destructor completed successfully.
> > > +**/
> > > +EFI_STATUS
> > > +EFIAPI
> > > +DxeRuntimeCapsuleLibDestructor (
> > > +  IN EFI_HANDLE         ImageHandle,
> > > +  IN EFI_SYSTEM_TABLE   *SystemTable
> > > +  )
> > > +{
> > > +  EFI_STATUS    Status;
> > > +
> > > +  //
> > > +  // Close the VirtualAddressChange event.
> > > +  //
> > > +  Status = gBS->CloseEvent
> > > (mDxeRuntimeCapsuleLibVirtualAddressChangeEvent);
> > > +  ASSERT_EFI_ERROR (Status);
> > > +
> > > +  return EFI_SUCCESS;
> > > +}
> > > diff --git
> > > a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> > > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> > > index 47c67ccac5..25b7d51f57 100644
> > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> > > +++
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> > > @@ -3,7 +3,7 @@
> > >  #
> > >  #  Capsule library instance for DXE_RUNTIME_DRIVER module types.
> > >  #
> > > -#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> > > +#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
> > >  #  This program and the accompanying materials
> > >  #  are licensed and made available under the terms and conditions of the
> > BSD
> > > License
> > >  #  which accompanies this distribution.  The full text of the license may be
> > > found at
> > > @@ -24,6 +24,8 @@
> > >    LIBRARY_CLASS                  = CapsuleLib|DXE_RUNTIME_DRIVER
> > >    CONSTRUCTOR                    = DxeCapsuleLibConstructor
> > >    CONSTRUCTOR                    = DxeRuntimeCapsuleLibConstructor
> > > +  DESTRUCTOR                     = DxeCapsuleLibDestructor
> > > +  DESTRUCTOR                     = DxeRuntimeCapsuleLibDestructor
> > >
> > >  #
> > >  # The following information is for reference only and not required by the
> > build
> > > tools.
> > > --
> > > 2.12.0.windows.1
> > >
> > > _______________________________________________
> > > edk2-devel mailing list
> > > edk2-devel@lists.01.org
> > > https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events
  2017-03-10  7:45       ` Wu, Hao A
@ 2017-03-10  7:52         ` Yao, Jiewen
  0 siblings, 0 replies; 8+ messages in thread
From: Yao, Jiewen @ 2017-03-10  7:52 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org

Good. That is better.

From: Wu, Hao A
Sent: Friday, March 10, 2017 3:46 PM
To: Yao, Jiewen <jiewen.yao@intel.com>; edk2-devel@lists.01.org
Subject: RE: [edk2] [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Wu,
> Hao A
> Sent: Friday, March 10, 2017 3:40 PM
> To: Yao, Jiewen; edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> Subject: Re: [edk2] [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib
> destructors to handle unclosed events
>
> > -----Original Message-----
> > From: Yao, Jiewen
> > Sent: Friday, March 10, 2017 3:23 PM
> > To: Wu, Hao A; edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> > Cc: Wu, Hao A
> > Subject: RE: [edk2] [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib
> > destructors to handle unclosed events
> >
> > I just find it is unnecessary to put
> > mDxeRuntimeCapsuleLibVirtualAddressChangeEvent and
> > mIsVirtualAddrConverted to DxeCapsuleLib.c.
> > Can we just move them to DxeCapsuleLibRuntime.c?
> >
> > I think this is simple update. No need to send V3.
> > You can do that when check in.
> >
> > Reviewed-by: Jiewen Yao <jiewen.yao@intel.com<mailto:jiewen.yao@intel.com>>
>
> Got it, I will move them before checking in the code.

I double checked the code, it seems that 'mEsrtTable' is only used in file
DxeCapsuleRuntime.c as well, I will move it from DxeCapsuleLib.c as well.

>
> Best Regards,
> Hao Wu
>
> >
> > Thank you
> > Yao Jiewen
> >
> >
> > > -----Original Message-----
> > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Hao
> > > Wu
> > > Sent: Friday, March 10, 2017 3:16 PM
> > > To: edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> > > Cc: Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>
> > > Subject: [edk2] [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib
> > destructors
> > > to handle unclosed events
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.0
> > > Signed-off-by: Hao Wu <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>
> > > Reviewed-by: Jiewen Yao <jiewen.yao@intel.com<mailto:jiewen.yao@intel.com>>
> > > ---
> > >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c          | 37
> > > +++++++++++++++++---
> > >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf        |  3 +-
> > >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c      | 33
> > > ++++++++++++++---
> > >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf |  4
> > > ++-
> > >  4 files changed, 66 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > index 7f500a96eb..a892892ccd 100644
> > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > @@ -47,9 +47,11 @@
> > >  #include <Protocol/FirmwareManagement.h>
> > >  #include <Protocol/DevicePath.h>
> > >
> > > -EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable              = NULL;
> > > -BOOLEAN                   mIsVirtualAddrConverted  = FALSE;
> > > -BOOLEAN                   mDxeCapsuleLibEndOfDxe   = FALSE;
> > > +EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable
> > > = NULL;
> > > +BOOLEAN                   mIsVirtualAddrConverted
> > > = FALSE;
> > > +BOOLEAN                   mDxeCapsuleLibEndOfDxe
> > > = FALSE;
> > > +EFI_EVENT                 mDxeCapsuleLibEndOfDxeEvent
> > > = NULL;
> > > +EFI_EVENT
> > > mDxeRuntimeCapsuleLibVirtualAddressChangeEvent  = NULL;
> > >
> > >  /**
> > >    Initialize capsule related variables.
> > > @@ -1654,7 +1656,6 @@ DxeCapsuleLibConstructor (
> > >    IN EFI_SYSTEM_TABLE   *SystemTable
> > >    )
> > >  {
> > > -  EFI_EVENT     EndOfDxeEvent;
> > >    EFI_STATUS    Status;
> > >
> > >    Status = gBS->CreateEventEx (
> > > @@ -1663,7 +1664,7 @@ DxeCapsuleLibConstructor (
> > >                    DxeCapsuleLibEndOfDxe,
> > >                    NULL,
> > >                    &gEfiEndOfDxeEventGroupGuid,
> > > -                  &EndOfDxeEvent
> > > +                  &mDxeCapsuleLibEndOfDxeEvent
> > >                    );
> > >    ASSERT_EFI_ERROR (Status);
> > >
> > > @@ -1671,3 +1672,29 @@ DxeCapsuleLibConstructor (
> > >
> > >    return EFI_SUCCESS;
> > >  }
> > > +
> > > +/**
> > > +  The destructor function closes the End of DXE event.
> > > +
> > > +  @param  ImageHandle   The firmware allocated handle for the EFI
> image.
> > > +  @param  SystemTable   A pointer to the EFI System Table.
> > > +
> > > +  @retval EFI_SUCCESS   The destructor completed successfully.
> > > +**/
> > > +EFI_STATUS
> > > +EFIAPI
> > > +DxeCapsuleLibDestructor (
> > > +  IN EFI_HANDLE         ImageHandle,
> > > +  IN EFI_SYSTEM_TABLE   *SystemTable
> > > +  )
> > > +{
> > > +  EFI_STATUS    Status;
> > > +
> > > +  //
> > > +  // Close the End of DXE event.
> > > +  //
> > > +  Status = gBS->CloseEvent (mDxeCapsuleLibEndOfDxeEvent);
> > > +  ASSERT_EFI_ERROR (Status);
> > > +
> > > +  return EFI_SUCCESS;
> > > +}
> > > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> > > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> > > index 5e437dc418..a6cf54cb6b 100644
> > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> > > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> > > @@ -3,7 +3,7 @@
> > >  #
> > >  #  Capsule library instance for DXE_DRIVER module types.
> > >  #
> > > -#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> > > +#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
> > >  #  This program and the accompanying materials
> > >  #  are licensed and made available under the terms and conditions of the
> > BSD
> > > License
> > >  #  which accompanies this distribution.  The full text of the license may be
> > > found at
> > > @@ -23,6 +23,7 @@
> > >    VERSION_STRING                 = 1.0
> > >    LIBRARY_CLASS                  = CapsuleLib|DXE_DRIVER
> > > UEFI_APPLICATION
> > >    CONSTRUCTOR                    = DxeCapsuleLibConstructor
> > > +  DESTRUCTOR                     = DxeCapsuleLibDestructor
> > >
> > >  #
> > >  # The following information is for reference only and not required by the
> > build
> > > tools.
> > > diff --git
> a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > index 880143905a..513aa533e1 100644
> > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > @@ -1,7 +1,7 @@
> > >  /** @file
> > >    Capsule library runtime support.
> > >
> > > -  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> > > +  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
> > >    This program and the accompanying materials
> > >    are licensed and made available under the terms and conditions of the
> BSD
> > > License
> > >    which accompanies this distribution.  The full text of the license may be
> > > found at
> > > @@ -28,6 +28,7 @@
> > >
> > >  extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;
> > >  extern BOOLEAN                   mIsVirtualAddrConverted;
> > > +extern EFI_EVENT
> > > mDxeRuntimeCapsuleLibVirtualAddressChangeEvent;
> > >
> > >  /**
> > >    Convert EsrtTable physical address to virtual address.
> > > @@ -92,21 +93,45 @@ DxeRuntimeCapsuleLibConstructor (
> > >    )
> > >  {
> > >    EFI_STATUS     Status;
> > > -  EFI_EVENT      Event;
> > >
> > >    //
> > >    // Make sure we can handle virtual address changes.
> > >    //
> > > -  Event = NULL;
> > >    Status = gBS->CreateEventEx (
> > >                    EVT_NOTIFY_SIGNAL,
> > >                    TPL_NOTIFY,
> > >                    DxeCapsuleLibVirtualAddressChangeEvent,
> > >                    NULL,
> > >                    &gEfiEventVirtualAddressChangeGuid,
> > > -                  &Event
> > > +                  &mDxeRuntimeCapsuleLibVirtualAddressChangeEvent
> > >                    );
> > >    ASSERT_EFI_ERROR (Status);
> > >
> > >    return EFI_SUCCESS;
> > >  }
> > > +
> > > +/**
> > > +  The destructor function closes the VirtualAddressChange event.
> > > +
> > > +  @param  ImageHandle   The firmware allocated handle for the EFI
> image.
> > > +  @param  SystemTable   A pointer to the EFI System Table.
> > > +
> > > +  @retval EFI_SUCCESS   The destructor completed successfully.
> > > +**/
> > > +EFI_STATUS
> > > +EFIAPI
> > > +DxeRuntimeCapsuleLibDestructor (
> > > +  IN EFI_HANDLE         ImageHandle,
> > > +  IN EFI_SYSTEM_TABLE   *SystemTable
> > > +  )
> > > +{
> > > +  EFI_STATUS    Status;
> > > +
> > > +  //
> > > +  // Close the VirtualAddressChange event.
> > > +  //
> > > +  Status = gBS->CloseEvent
> > > (mDxeRuntimeCapsuleLibVirtualAddressChangeEvent);
> > > +  ASSERT_EFI_ERROR (Status);
> > > +
> > > +  return EFI_SUCCESS;
> > > +}
> > > diff --git
> > > a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> > > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> > > index 47c67ccac5..25b7d51f57 100644
> > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> > > +++
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> > > @@ -3,7 +3,7 @@
> > >  #
> > >  #  Capsule library instance for DXE_RUNTIME_DRIVER module types.
> > >  #
> > > -#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> > > +#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
> > >  #  This program and the accompanying materials
> > >  #  are licensed and made available under the terms and conditions of the
> > BSD
> > > License
> > >  #  which accompanies this distribution.  The full text of the license may be
> > > found at
> > > @@ -24,6 +24,8 @@
> > >    LIBRARY_CLASS                  = CapsuleLib|DXE_RUNTIME_DRIVER
> > >    CONSTRUCTOR                    = DxeCapsuleLibConstructor
> > >    CONSTRUCTOR                    = DxeRuntimeCapsuleLibConstructor
> > > +  DESTRUCTOR                     = DxeCapsuleLibDestructor
> > > +  DESTRUCTOR                     = DxeRuntimeCapsuleLibDestructor
> > >
> > >  #
> > >  # The following information is for reference only and not required by the
> > build
> > > tools.
> > > --
> > > 2.12.0.windows.1
> > >
> > > _______________________________________________
> > > edk2-devel mailing list
> > > edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> > > https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-03-10  7:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-10  7:16 [PATCH v2 0/2] MdeModulePkg/CapsuleLib: Code refinements Hao Wu
2017-03-10  7:16 ` [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events Hao Wu
2017-03-10  7:22   ` Yao, Jiewen
2017-03-10  7:39     ` Wu, Hao A
2017-03-10  7:45       ` Wu, Hao A
2017-03-10  7:52         ` Yao, Jiewen
2017-03-10  7:16 ` [PATCH v2 2/2] MdeModulePkg/CapsuleLib: Free the buffer returned by GetVariable2 API Hao Wu
2017-03-10  7:21   ` Yao, Jiewen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox