public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ashish Singhal <ashishsingha@nvidia.com>
To: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "michael.d.kinney@intel.com" <michael.d.kinney@intel.com>,
	"liming.gao@intel.com" <liming.gao@intel.com>
Subject: Re: [PATCH] MdePkg/UefiLib: Simplify protocol un/installation abstraction
Date: Tue, 19 Feb 2019 16:19:02 +0000	[thread overview]
Message-ID: <DM6PR12MB3324336080A9FD7FC5408B38BA7C0@DM6PR12MB3324.namprd12.prod.outlook.com> (raw)
In-Reply-To: <9c850690f22cc52a348211f28b6c1c8d0b9c47c2.1549310714.git.ashishsingha@nvidia.com>

Hello Mike/Lao,

Were you able to have a look at this?

Thanks
Ashish

-----Original Message-----
From: Ashish Singhal <ashishsingha@nvidia.com> 
Sent: Monday, February 4, 2019 1:16 PM
To: edk2-devel@lists.01.org
Cc: michael.d.kinney@intel.com; liming.gao@intel.com; Ashish Singhal <ashishsingha@nvidia.com>
Subject: [PATCH] MdePkg/UefiLib: Simplify protocol un/installation abstraction

Add helper functions to operate upon protocol installation and
uninstallation instead of every function doing it by itself.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com>
---
 MdePkg/Library/UefiLib/UefiDriverModel.c | 2040 +++++-------------------------
 1 file changed, 342 insertions(+), 1698 deletions(-)

diff --git a/MdePkg/Library/UefiLib/UefiDriverModel.c b/MdePkg/Library/UefiLib/UefiDriverModel.c
index 262d8bc..268edf7 100644
--- a/MdePkg/Library/UefiLib/UefiDriverModel.c
+++ b/MdePkg/Library/UefiLib/UefiDriverModel.c
@@ -17,6 +17,290 @@
 
 #include "UefiLibInternal.h"
 
+
+#define MAX_SUPPORTED_PROTOCOLS 7
+typedef struct {
+  EFI_GUID *Guid;
+  VOID     *Interface;
+} EFI_PROCESS_PROTOCOL;
+
+
+static
+EFI_STATUS
+EFIAPI
+EfiLibProcessProtocols (
+  IN CONST EFI_HANDLE                         ImageHandle,
+  IN EFI_DRIVER_BINDING_PROTOCOL              *DriverBinding,
+  IN EFI_HANDLE                               DriverBindingHandle,
+  IN BOOLEAN                                  Install,
+  IN CONST EFI_PROCESS_PROTOCOL               *ProtocolArray
+  )
+{
+  ASSERT (DriverBinding != NULL);
+  ASSERT (ProtocolArray != NULL);
+
+  if (Install) {
+    //
+    // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol
+    //
+    DriverBinding->ImageHandle         = ImageHandle;
+    DriverBinding->DriverBindingHandle = DriverBindingHandle;
+
+    return gBS->InstallMultipleProtocolInterfaces (
+                  &DriverBinding->DriverBindingHandle,
+                  ProtocolArray[0].Guid, ProtocolArray[0].Interface,
+                  ProtocolArray[1].Guid, ProtocolArray[1].Interface,
+                  ProtocolArray[2].Guid, ProtocolArray[2].Interface,
+                  ProtocolArray[3].Guid, ProtocolArray[3].Interface,
+                  ProtocolArray[4].Guid, ProtocolArray[4].Interface,
+                  ProtocolArray[5].Guid, ProtocolArray[5].Interface,
+                  ProtocolArray[6].Guid, ProtocolArray[6].Interface,
+                  NULL
+                  );
+  } else {
+    return gBS->UninstallMultipleProtocolInterfaces (
+                  DriverBinding->DriverBindingHandle,
+                  ProtocolArray[0].Guid, ProtocolArray[0].Interface,
+                  ProtocolArray[1].Guid, ProtocolArray[1].Interface,
+                  ProtocolArray[2].Guid, ProtocolArray[2].Interface,
+                  ProtocolArray[3].Guid, ProtocolArray[3].Interface,
+                  ProtocolArray[4].Guid, ProtocolArray[4].Interface,
+                  ProtocolArray[5].Guid, ProtocolArray[5].Interface,
+                  ProtocolArray[6].Guid, ProtocolArray[6].Interface,
+                  NULL
+                  );
+  }
+}
+
+
+
+static
+EFI_STATUS
+EFIAPI
+EfiLibProcessAllDriverProtocols (
+  IN CONST EFI_HANDLE                         ImageHandle,
+  IN EFI_DRIVER_BINDING_PROTOCOL              *DriverBinding,
+  IN EFI_HANDLE                               DriverBindingHandle,
+  IN BOOLEAN                                  Install,
+  IN CONST EFI_COMPONENT_NAME_PROTOCOL        *ComponentName,
+  IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL  *DriverConfiguration,
+  IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL    *DriverDiagnostics
+  )
+{
+  EFI_STATUS           Status;
+  EFI_PROCESS_PROTOCOL ProtocolArray[MAX_SUPPORTED_PROTOCOLS];
+  UINT8                ProtocolCount;
+
+  ASSERT (DriverBinding != NULL);
+
+  //
+  // ZI the ProtocolArray structure. Both InstallMultipleProtocolInterfaces
+  // and UninstallMultipleProtocolInterfaces would stop processing ProtocolArray
+  // elements as soon as they encounter a NULL.
+  //
+  ZeroMem(ProtocolArray, sizeof(ProtocolArray));
+  ProtocolCount = 0;
+
+  //
+  // Populate ProtocolArray with valid protocol interfaces.
+  //
+  ProtocolArray[ProtocolCount].Guid = &gEfiDriverBindingProtocolGuid;
+  ProtocolArray[ProtocolCount].Interface = DriverBinding;
+  ProtocolCount++;
+
+  if (ComponentName != NULL && !FeaturePcdGet(PcdComponentNameDisable)) {
+    ProtocolArray[ProtocolCount].Guid = &gEfiComponentNameProtocolGuid;
+    ProtocolArray[ProtocolCount].Interface = (VOID *)ComponentName;
+    ProtocolCount++;
+  }
+
+  if (DriverConfiguration != NULL) {
+    ProtocolArray[ProtocolCount].Guid = &gEfiDriverConfigurationProtocolGuid;
+    ProtocolArray[ProtocolCount].Interface = (VOID *)DriverConfiguration;
+    ProtocolCount++;
+  }
+
+  if (DriverDiagnostics != NULL && !FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
+    ProtocolArray[ProtocolCount].Guid = &gEfiDriverDiagnosticsProtocolGuid;
+    ProtocolArray[ProtocolCount].Interface = (VOID *)DriverDiagnostics;
+    ProtocolCount++;
+  }
+
+  Status = EfiLibProcessProtocols (
+             ImageHandle,
+             DriverBinding,
+             DriverBindingHandle,
+             Install,
+             ProtocolArray
+             );
+
+  //
+  // ASSERT if the call to InstallMultipleProtocolInterfaces() or
+  // UninstallMultipleProtocolInterfaces() failed
+  //
+  ASSERT_EFI_ERROR (Status);
+
+  return Status;
+}
+
+
+
+static
+EFI_STATUS
+EFIAPI
+EfiLibProcessDriverBindingComponentName2 (
+  IN CONST EFI_HANDLE                         ImageHandle,
+  IN EFI_DRIVER_BINDING_PROTOCOL              *DriverBinding,
+  IN EFI_HANDLE                               DriverBindingHandle,
+  IN BOOLEAN                                  Install,
+  IN CONST EFI_COMPONENT_NAME_PROTOCOL        *ComponentName,
+  IN CONST EFI_COMPONENT_NAME2_PROTOCOL       *ComponentName2
+  )
+{
+  EFI_STATUS           Status;
+  EFI_PROCESS_PROTOCOL ProtocolArray[MAX_SUPPORTED_PROTOCOLS];
+  UINT8                ProtocolCount;
+
+  ASSERT (DriverBinding != NULL);
+
+  //
+  // ZI the ProtocolArray structure. Both InstallMultipleProtocolInterfaces
+  // and UninstallMultipleProtocolInterfaces would stop processing ProtocolArray
+  // elements as soon as they encounter a NULL.
+  //
+  ZeroMem(ProtocolArray, sizeof(ProtocolArray));
+  ProtocolCount = 0;
+
+  //
+  // Populate ProtocolArray with valid protocol interfaces.
+  //
+  ProtocolArray[ProtocolCount].Guid = &gEfiDriverBindingProtocolGuid;
+  ProtocolArray[ProtocolCount].Interface = DriverBinding;
+  ProtocolCount++;
+
+  if (ComponentName != NULL && !FeaturePcdGet(PcdComponentNameDisable)) {
+    ProtocolArray[ProtocolCount].Guid = &gEfiComponentNameProtocolGuid;
+    ProtocolArray[ProtocolCount].Interface = (VOID *)ComponentName;
+    ProtocolCount++;
+  }
+
+  if (ComponentName2 != NULL && !FeaturePcdGet(PcdComponentName2Disable)) {
+    ProtocolArray[ProtocolCount].Guid = &gEfiComponentName2ProtocolGuid;
+    ProtocolArray[ProtocolCount].Interface = (VOID *)ComponentName2;
+    ProtocolCount++;
+  }
+
+  Status = EfiLibProcessProtocols (
+             ImageHandle,
+             DriverBinding,
+             DriverBindingHandle,
+             Install,
+             ProtocolArray
+             );
+
+  //
+  // ASSERT if the call to InstallMultipleProtocolInterfaces() or
+  // UninstallMultipleProtocolInterfaces() failed
+  //
+  ASSERT_EFI_ERROR (Status);
+
+  return Status;
+}
+
+
+
+static
+EFI_STATUS
+EFIAPI
+EfiLibProcessAllDriverProtocols2 (
+  IN CONST EFI_HANDLE                         ImageHandle,
+  IN EFI_DRIVER_BINDING_PROTOCOL              *DriverBinding,
+  IN EFI_HANDLE                               DriverBindingHandle,
+  IN BOOLEAN                                  Install,
+  IN CONST EFI_COMPONENT_NAME_PROTOCOL        *ComponentName,
+  IN CONST EFI_COMPONENT_NAME2_PROTOCOL       *ComponentName2,
+  IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL  *DriverConfiguration,
+  IN CONST EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2,
+  IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL    *DriverDiagnostics,
+  IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL   *DriverDiagnostics2
+  )
+{
+  EFI_STATUS           Status;
+  EFI_PROCESS_PROTOCOL ProtocolArray[MAX_SUPPORTED_PROTOCOLS];
+  UINT8                ProtocolCount;
+
+  ASSERT (DriverBinding != NULL);
+
+  //
+  // ZI the ProtocolArray structure. Both InstallMultipleProtocolInterfaces
+  // and UninstallMultipleProtocolInterfaces would stop processing ProtocolArray
+  // elements as soon as they encounter a NULL.
+  //
+  ZeroMem(ProtocolArray, sizeof(ProtocolArray));
+  ProtocolCount = 0;
+
+  //
+  // Populate ProtocolArray with valid protocol interfaces.
+  //
+  ProtocolArray[ProtocolCount].Guid = &gEfiDriverBindingProtocolGuid;
+  ProtocolArray[ProtocolCount].Interface = DriverBinding;
+  ProtocolCount++;
+
+  if (ComponentName != NULL && !FeaturePcdGet(PcdComponentNameDisable)) {
+    ProtocolArray[ProtocolCount].Guid = &gEfiComponentNameProtocolGuid;
+    ProtocolArray[ProtocolCount].Interface = (VOID *)ComponentName;
+    ProtocolCount++;
+  }
+
+  if (ComponentName2 != NULL && !FeaturePcdGet(PcdComponentName2Disable)) {
+    ProtocolArray[ProtocolCount].Guid = &gEfiComponentName2ProtocolGuid;
+    ProtocolArray[ProtocolCount].Interface = (VOID *)ComponentName2;
+    ProtocolCount++;
+  }
+
+  if (DriverConfiguration != NULL) {
+    ProtocolArray[ProtocolCount].Guid = &gEfiDriverConfigurationProtocolGuid;
+    ProtocolArray[ProtocolCount].Interface = (VOID *)DriverConfiguration;
+    ProtocolCount++;
+  }
+
+  if (DriverConfiguration2 != NULL) {
+    ProtocolArray[ProtocolCount].Guid = &gEfiDriverConfiguration2ProtocolGuid;
+    ProtocolArray[ProtocolCount].Interface = (VOID *)DriverConfiguration2;
+    ProtocolCount++;
+  }
+
+  if (DriverDiagnostics != NULL && !FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
+    ProtocolArray[ProtocolCount].Guid = &gEfiDriverDiagnosticsProtocolGuid;
+    ProtocolArray[ProtocolCount].Interface = (VOID *)DriverDiagnostics;
+    ProtocolCount++;
+  }
+
+  if (DriverDiagnostics2 != NULL && !FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
+    ProtocolArray[ProtocolCount].Guid = &gEfiDriverDiagnostics2ProtocolGuid;
+    ProtocolArray[ProtocolCount].Interface = (VOID *)DriverDiagnostics2;
+    ProtocolCount++;
+  }
+
+  Status = EfiLibProcessProtocols (
+             ImageHandle,
+             DriverBinding,
+             DriverBindingHandle,
+             Install,
+             ProtocolArray
+             );
+
+  //
+  // ASSERT if the call to InstallMultipleProtocolInterfaces() or
+  // UninstallMultipleProtocolInterfaces() failed
+  //
+  ASSERT_EFI_ERROR (Status);
+
+  return Status;
+}
+
+
+
 /**
   Installs and completes the initialization of a Driver Binding Protocol instance.
 
@@ -148,96 +432,15 @@ EfiLibInstallAllDriverProtocols (
   IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL    *DriverDiagnostics    OPTIONAL
   )
 {
-  EFI_STATUS  Status;
-
-  ASSERT (DriverBinding != NULL);
-
-  //
-  // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol
-  //
-  DriverBinding->ImageHandle         = ImageHandle;
-  DriverBinding->DriverBindingHandle = DriverBindingHandle;
-
-  if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
-    if (DriverConfiguration == NULL) {
-      if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-        Status = gBS->InstallMultipleProtocolInterfaces (
-                        &DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid, DriverBinding,
-                        NULL
-                        );
-      } else {
-        Status = gBS->InstallMultipleProtocolInterfaces (
-                        &DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid, DriverBinding,
-                        &gEfiComponentNameProtocolGuid, ComponentName,
-                        NULL
-                        );
-      }
-    } else {
-      if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-        Status = gBS->InstallMultipleProtocolInterfaces (
-                        &DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid,       DriverBinding,
-                        &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                        NULL
-                        );
-      } else {
-        Status = gBS->InstallMultipleProtocolInterfaces (
-                        &DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid,       DriverBinding,
-                        &gEfiComponentNameProtocolGuid,       ComponentName,
-                        &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                        NULL
-                        );
-      }
-    }
-  } else {
-    if (DriverConfiguration == NULL) {
-      if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-        Status = gBS->InstallMultipleProtocolInterfaces (
-                        &DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid,     DriverBinding,
-                        &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                        NULL
-                        );
-      } else {
-        Status = gBS->InstallMultipleProtocolInterfaces (
-                        &DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid,     DriverBinding,
-                        &gEfiComponentNameProtocolGuid,     ComponentName,
-                        &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                        NULL
-                        );
-      }
-    } else {
-      if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-       Status = gBS->InstallMultipleProtocolInterfaces (
-                        &DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid,       DriverBinding,
-                        &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                        &gEfiDriverDiagnosticsProtocolGuid,   DriverDiagnostics,
-                        NULL
-                        );
-      } else {
-        Status = gBS->InstallMultipleProtocolInterfaces (
-                        &DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid,       DriverBinding,
-                        &gEfiComponentNameProtocolGuid,       ComponentName,
-                        &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                        &gEfiDriverDiagnosticsProtocolGuid,   DriverDiagnostics,
-                        NULL
-                        );
-      }
-    }
-  }
-
-  //
-  // ASSERT if the call to InstallMultipleProtocolInterfaces() failed
-  //
-  ASSERT_EFI_ERROR (Status);
-
-  return Status;
+  return EfiLibProcessAllDriverProtocols (
+           ImageHandle,
+           DriverBinding,
+           DriverBindingHandle,
+           TRUE,
+           ComponentName,
+           DriverConfiguration,
+           DriverDiagnostics
+           );
 }
 
 
@@ -267,90 +470,15 @@ EfiLibUninstallAllDriverProtocols (
   IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL    *DriverDiagnostics    OPTIONAL
   )
 {
-  EFI_STATUS  Status;
-
-  ASSERT (DriverBinding != NULL);
-
-  if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
-    if (DriverConfiguration == NULL) {
-      if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-        Status = gBS->UninstallMultipleProtocolInterfaces (
-                        DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid, DriverBinding,
-                        NULL
-                        );
-      } else {
-        Status = gBS->UninstallMultipleProtocolInterfaces (
-                        DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid, DriverBinding,
-                        &gEfiComponentNameProtocolGuid, ComponentName,
-                        NULL
-                        );
-      }
-    } else {
-      if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-        Status = gBS->UninstallMultipleProtocolInterfaces (
-                        DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid,       DriverBinding,
-                        &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                        NULL
-                        );
-      } else {
-        Status = gBS->UninstallMultipleProtocolInterfaces (
-                        DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid,       DriverBinding,
-                        &gEfiComponentNameProtocolGuid,       ComponentName,
-                        &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                        NULL
-                        );
-      }
-    }
-  } else {
-    if (DriverConfiguration == NULL) {
-      if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-        Status = gBS->UninstallMultipleProtocolInterfaces (
-                        DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid,     DriverBinding,
-                        &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                        NULL
-                        );
-      } else {
-        Status = gBS->UninstallMultipleProtocolInterfaces (
-                        DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid,     DriverBinding,
-                        &gEfiComponentNameProtocolGuid,     ComponentName,
-                        &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                        NULL
-                        );
-      }
-    } else {
-      if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-       Status = gBS->UninstallMultipleProtocolInterfaces (
-                        DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid,       DriverBinding,
-                        &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                        &gEfiDriverDiagnosticsProtocolGuid,   DriverDiagnostics,
-                        NULL
-                        );
-      } else {
-        Status = gBS->UninstallMultipleProtocolInterfaces (
-                        DriverBinding->DriverBindingHandle,
-                        &gEfiDriverBindingProtocolGuid,       DriverBinding,
-                        &gEfiComponentNameProtocolGuid,       ComponentName,
-                        &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                        &gEfiDriverDiagnosticsProtocolGuid,   DriverDiagnostics,
-                        NULL
-                        );
-      }
-    }
-  }
-
-  //
-  // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed
-  //
-  ASSERT_EFI_ERROR (Status);
-
-  return Status;
+  return EfiLibProcessAllDriverProtocols (
+           NULL,
+           DriverBinding,
+           NULL,
+           FALSE,
+           ComponentName,
+           DriverConfiguration,
+           DriverDiagnostics
+           );
 }
 
 
@@ -389,56 +517,14 @@ EfiLibInstallDriverBindingComponentName2 (
   IN CONST EFI_COMPONENT_NAME2_PROTOCOL       *ComponentName2       OPTIONAL
   )
 {
-  EFI_STATUS  Status;
-
-  ASSERT (DriverBinding != NULL);
-
-  //
-  // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol
-  //
-  DriverBinding->ImageHandle         = ImageHandle;
-  DriverBinding->DriverBindingHandle = DriverBindingHandle;
-
-  if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-    if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-      Status = gBS->InstallMultipleProtocolInterfaces (
-                      &DriverBinding->DriverBindingHandle,
-                      &gEfiDriverBindingProtocolGuid, DriverBinding,
-                      NULL
-                      );
-      } else {
-      Status = gBS->InstallMultipleProtocolInterfaces (
-                      &DriverBinding->DriverBindingHandle,
-                      &gEfiDriverBindingProtocolGuid, DriverBinding,
-                      &gEfiComponentName2ProtocolGuid, ComponentName2,
-                      NULL
-                      );
-     }
-  } else {
-     if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-       Status = gBS->InstallMultipleProtocolInterfaces (
-                       &DriverBinding->DriverBindingHandle,
-                       &gEfiDriverBindingProtocolGuid, DriverBinding,
-                       &gEfiComponentNameProtocolGuid, ComponentName,
-                       NULL
-                       );
-     } else {
-       Status = gBS->InstallMultipleProtocolInterfaces (
-                       &DriverBinding->DriverBindingHandle,
-                       &gEfiDriverBindingProtocolGuid, DriverBinding,
-                       &gEfiComponentNameProtocolGuid, ComponentName,
-                       &gEfiComponentName2ProtocolGuid, ComponentName2,
-                       NULL
-                       );
-    }
-  }
-
-  //
-  // ASSERT if the call to InstallMultipleProtocolInterfaces() failed
-  //
-  ASSERT_EFI_ERROR (Status);
-
-  return Status;
+  return EfiLibProcessDriverBindingComponentName2 (
+           ImageHandle,
+           DriverBinding,
+           DriverBindingHandle,
+           TRUE,
+           ComponentName,
+           ComponentName2
+           );
 }
 
 
@@ -465,50 +551,14 @@ EfiLibUninstallDriverBindingComponentName2 (
   IN CONST EFI_COMPONENT_NAME2_PROTOCOL       *ComponentName2       OPTIONAL
   )
 {
-  EFI_STATUS  Status;
-
-  ASSERT (DriverBinding != NULL);
-
-  if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-    if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-      Status = gBS->UninstallMultipleProtocolInterfaces (
-                      DriverBinding->DriverBindingHandle,
-                      &gEfiDriverBindingProtocolGuid, DriverBinding,
-                      NULL
-                      );
-      } else {
-      Status = gBS->UninstallMultipleProtocolInterfaces (
-                      DriverBinding->DriverBindingHandle,
-                      &gEfiDriverBindingProtocolGuid, DriverBinding,
-                      &gEfiComponentName2ProtocolGuid, ComponentName2,
-                      NULL
-                      );
-     }
-  } else {
-     if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-       Status = gBS->UninstallMultipleProtocolInterfaces (
-                       DriverBinding->DriverBindingHandle,
-                       &gEfiDriverBindingProtocolGuid, DriverBinding,
-                       &gEfiComponentNameProtocolGuid, ComponentName,
-                       NULL
-                       );
-     } else {
-       Status = gBS->UninstallMultipleProtocolInterfaces (
-                       DriverBinding->DriverBindingHandle,
-                       &gEfiDriverBindingProtocolGuid, DriverBinding,
-                       &gEfiComponentNameProtocolGuid, ComponentName,
-                       &gEfiComponentName2ProtocolGuid, ComponentName2,
-                       NULL
-                       );
-    }
-  }
-
-  //
-  // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed
-  //
-  ASSERT_EFI_ERROR (Status);
-
-  return Status;
+  return EfiLibProcessDriverBindingComponentName2 (
+           NULL,
+           DriverBinding,
+           NULL,
+           FALSE,
+           ComponentName,
+           ComponentName2
+           );
 }
 
 
@@ -557,724 +607,18 @@ EfiLibInstallAllDriverProtocols2 (
   IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL   *DriverDiagnostics2    OPTIONAL
   )
 {
-  EFI_STATUS  Status;
-
-  ASSERT (DriverBinding != NULL);
-
-  //
-  // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol
-  //
-  DriverBinding->ImageHandle         = ImageHandle;
-  DriverBinding->DriverBindingHandle = DriverBindingHandle;
-
-  if (DriverConfiguration2 == NULL) {
-    if (DriverConfiguration == NULL) {
-      if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      } else {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      }
-    } else {
-      if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      } else {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      }
-    }
-  } else {
-    if (DriverConfiguration == NULL) {
-      if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      } else {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      }
-    } else {
-      if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      } else {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->InstallMultipleProtocolInterfaces (
-                              &DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      }
-    }
-  }
-
-  //
-  // ASSERT if the call to InstallMultipleProtocolInterfaces() failed
-  //
-  ASSERT_EFI_ERROR (Status);
-
-  return Status;
+  return EfiLibProcessAllDriverProtocols2 (
+           ImageHandle,
+           DriverBinding,
+           DriverBindingHandle,
+           TRUE,
+           ComponentName,
+           ComponentName2,
+           DriverConfiguration,
+           DriverConfiguration2,
+           DriverDiagnostics,
+           DriverDiagnostics2
+           );
 }
 
 
@@ -1311,716 +655,16 @@ EfiLibUninstallAllDriverProtocols2 (
   IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL   *DriverDiagnostics2    OPTIONAL
   )
 {
-  EFI_STATUS  Status;
-
-  ASSERT (DriverBinding != NULL);
-
-  if (DriverConfiguration2 == NULL) {
-    if (DriverConfiguration == NULL) {
-      if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      } else {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      }
-    } else {
-      if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      } else {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      }
-    }
-  } else {
-    if (DriverConfiguration == NULL) {
-      if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      } else {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      }
-    } else {
-      if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      } else {
-        if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              NULL
-                              );
-            }
-          }
-        } else {
-          if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          } else {
-            if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            } else {
-              Status = gBS->UninstallMultipleProtocolInterfaces (
-                              DriverBinding->DriverBindingHandle,
-                              &gEfiDriverBindingProtocolGuid, DriverBinding,
-                              &gEfiComponentNameProtocolGuid, ComponentName,
-                              &gEfiComponentName2ProtocolGuid, ComponentName2,
-                              &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,
-                              &gEfiDriverConfiguration2ProtocolGuid, DriverConfiguration2,
-                              &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,
-                              &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,
-                              NULL
-                              );
-            }
-          }
-        }
-      }
-    }
-  }
-
-  //
-  // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed
-  //
-  ASSERT_EFI_ERROR (Status);
-
-  return Status;
+  return EfiLibProcessAllDriverProtocols2 (
+           NULL,
+           DriverBinding,
+           NULL,
+           FALSE,
+           ComponentName,
+           ComponentName2,
+           DriverConfiguration,
+           DriverConfiguration2,
+           DriverDiagnostics,
+           DriverDiagnostics2
+           );
 }
-- 
2.7.4

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------


  reply	other threads:[~2019-02-19 16:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04 20:16 [PATCH] MdePkg/UefiLib: Simplify protocol un/installation abstraction Ashish Singhal
2019-02-19 16:19 ` Ashish Singhal [this message]
2019-02-19 19:56   ` Kinney, Michael D
2019-02-25 19:09     ` Ashish Singhal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM6PR12MB3324336080A9FD7FC5408B38BA7C0@DM6PR12MB3324.namprd12.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox