public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdePkg/UefiLib: Simplify protocol un/installation abstraction
@ 2019-02-04 20:16 Ashish Singhal
  2019-02-19 16:19 ` Ashish Singhal
  0 siblings, 1 reply; 4+ messages in thread
From: Ashish Singhal @ 2019-02-04 20:16 UTC (permalink / raw)
  To: edk2-devel; +Cc: michael.d.kinney, liming.gao, Ashish Singhal

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



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

end of thread, other threads:[~2019-02-25 19:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-04 20:16 [PATCH] MdePkg/UefiLib: Simplify protocol un/installation abstraction Ashish Singhal
2019-02-19 16:19 ` Ashish Singhal
2019-02-19 19:56   ` Kinney, Michael D
2019-02-25 19:09     ` Ashish Singhal

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