Reviewed-by: Liming Gao <[email protected]>
-----Original Message-----
From: Dong, Eric 
Sent: Thursday, January 07, 2016 1:49 PM
To: [email protected]
Cc: Gao, Liming
Subject: [Patch] Refine construct function error handle, avoid assert when load 
this module twice.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <[email protected]>
Cc: Liming Gao <[email protected]>
---
 .../Library/FileExplorerLib/FileExplorer.c         | 33 +++++++++++++---------
 .../Library/FileExplorerLib/FileExplorerLib.inf    |  7 +++--
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c 
b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
index bcf3ec9..9714dbc 100644
--- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
+++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
@@ -1,9 +1,9 @@
 /** @file
 File explorer related functions.
 
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2016, 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 that accompanies this 
distribution.
 The full text of the license may be found at  
http://opensource.org/licenses/bsd-license.php.
 
@@ -1440,11 +1440,16 @@ FileExplorerLibConstructor (
                   gHiiVendorDevicePath,
                   &gEfiHiiConfigAccessProtocolGuid,
                   &gFileExplorerPrivate.FeConfigAccess,
                   NULL
                   );
-  ASSERT_EFI_ERROR (Status);
+  if (Status == EFI_ALREADY_STARTED) {
+    return EFI_SUCCESS;
+  }
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
 
   //
   // Post our File Explorer VFR binary to the HII database.
   //
   gFileExplorerPrivate.FeHiiHandle = HiiAddPackages ( @@ -1484,21 +1489,23 @@ 
FileExplorerLibDestructor (  {
   EFI_STATUS    Status;
 
   ASSERT (gHiiVendorDevicePath != NULL);
 
-  Status = gBS->UninstallMultipleProtocolInterfaces (
-                  gFileExplorerPrivate.FeDriverHandle,
-                  &gEfiDevicePathProtocolGuid,
-                  gHiiVendorDevicePath,
-                  &gEfiHiiConfigAccessProtocolGuid,
-                  &gFileExplorerPrivate.FeConfigAccess,
-                  NULL
-                  );
-  ASSERT_EFI_ERROR (Status);
-
-  HiiRemovePackages (gFileExplorerPrivate.FeHiiHandle);
+  if (gFileExplorerPrivate.FeDriverHandle != NULL) {
+    Status = gBS->UninstallMultipleProtocolInterfaces (
+                    gFileExplorerPrivate.FeDriverHandle,
+                    &gEfiDevicePathProtocolGuid,
+                    gHiiVendorDevicePath,
+                    &gEfiHiiConfigAccessProtocolGuid,
+                    &gFileExplorerPrivate.FeConfigAccess,
+                    NULL
+                    );
+    ASSERT_EFI_ERROR (Status);
+    
+    HiiRemovePackages (gFileExplorerPrivate.FeHiiHandle);
+  }
 
   FreePool (gHiiVendorDevicePath);
 
   return EFI_SUCCESS;
 }
diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf 
b/MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
index 2770ca9..a97fd4a 100644
--- a/MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
+++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
@@ -1,9 +1,9 @@
 ## @file
 #  library defines a set of interfaces for how to do file explorer.
 #
-#  Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2011 - 2016, 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 that accompanies this 
distribution.
 #  The full text of the license may be found at  #  
http://opensource.org/licenses/bsd-license.php.
 #
@@ -55,6 +55,9 @@
 [Protocols]
   gEfiSimpleFileSystemProtocolGuid              ## CONSUMES
   gEfiLoadFileProtocolGuid                      ## CONSUMES
   gEfiHiiConfigAccessProtocolGuid               ## CONSUMES
   gEfiFormBrowser2ProtocolGuid                  ## CONSUMES
-  gEfiDevicePathToTextProtocolGuid              ## CONSUMES
\ No newline at end of file
+  gEfiDevicePathToTextProtocolGuid              ## CONSUMES
+
+[Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, 
Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER]
+  gEfiFormBrowser2ProtocolGuid AND gEfiHiiDatabaseProtocolGuid
\ No newline at end of file
-- 
2.6.4.windows.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to