Add UefiDriverModel.c for Installation of driver model protocols .
authoryshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 22 Jun 2007 16:34:13 +0000 (16:34 +0000)
committeryshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 22 Jun 2007 16:34:13 +0000 (16:34 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2725 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/UefiLib/UefiDriverModel.c [new file with mode: 0644]

diff --git a/MdePkg/Library/UefiLib/UefiDriverModel.c b/MdePkg/Library/UefiLib/UefiDriverModel.c
new file mode 100644 (file)
index 0000000..582ad6a
--- /dev/null
@@ -0,0 +1,581 @@
+/** @file\r
+  Library functions that abstract driver model protocols\r
+  installation.\r
+\r
+  Copyright (c) 2006 - 2007, Intel Corporation<BR> All rights\r
+  reserved. This program and the accompanying materials are\r
+  licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+  \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/ \r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+/**\r
+  Intialize a driver by installing the Driver Binding Protocol onto the\r
+  driver's DriverBindingHandle.  This is typically the same as the driver's\r
+  ImageHandle, but it can be different if the driver produces multiple\r
+  DriverBinding Protocols.  This function also initializes the EFI Driver\r
+  Library that initializes the global variables gST, gBS, gRT.\r
+\r
+  @param  ImageHandle          The image handle of the driver\r
+  @param  SystemTable          The EFI System Table that was passed to the driver's entry point\r
+  @param  DriverBinding        A Driver Binding Protocol instance that this driver is producing\r
+  @param  DriverBindingHandle  The handle that DriverBinding is to be installe onto.  If this\r
+                               parameter is NULL, then a new handle is created.\r
+\r
+  @retval EFI_SUCCESS          DriverBinding is installed onto DriverBindingHandle\r
+  @retval Other                Status from gBS->InstallProtocolInterface()\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiLibInstallDriverBinding (\r
+  IN const EFI_HANDLE             ImageHandle,\r
+  IN const EFI_SYSTEM_TABLE       *SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding,\r
+  IN EFI_HANDLE                   DriverBindingHandle\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  ASSERT (NULL != DriverBinding);\r
+\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &DriverBindingHandle,\r
+                  &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                  NULL\r
+                  );\r
+  //\r
+  // ASSERT if the call to InstallMultipleProtocolInterfaces() failed\r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol\r
+  //\r
+  DriverBinding->ImageHandle         = ImageHandle;\r
+  DriverBinding->DriverBindingHandle = DriverBindingHandle;\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Intialize a driver by installing the Driver Binding Protocol onto the\r
+  driver's DriverBindingHandle.  This is typically the same as the driver's\r
+  ImageHandle, but it can be different if the driver produces multiple\r
+  DriverBinding Protocols.  This function also initializes the EFI Driver\r
+  Library that initializes the global variables gST, gBS, gRT.\r
+\r
+  @ImageHandle                 The image handle of the driver\r
+  @SystemTable                 The EFI System Table that was passed to the driver's entry point\r
+  @DriverBinding               A Driver Binding Protocol instance that this driver is producing\r
+  @DriverBindingHandle         The handle that DriverBinding is to be installe onto.  If this\r
+                               parameter is NULL, then a new handle is created.\r
+  @ComponentName               A Component Name Protocol instance that this driver is producing\r
+  @DriverConfiguration         A Driver Configuration Protocol instance that this driver is producing\r
+  @DriverDiagnostics           A Driver Diagnostics Protocol instance that this driver is producing\r
+\r
+  @retval EFI_SUCCESS          DriverBinding is installed onto DriverBindingHandle\r
+  @retval Other                Status from gBS->InstallProtocolInterface()\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiLibInstallAllDriverProtocols (\r
+  IN const EFI_HANDLE                         ImageHandle,\r
+  IN const EFI_SYSTEM_TABLE                   *SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL              *DriverBinding,\r
+  IN EFI_HANDLE                               DriverBindingHandle,\r
+  IN const EFI_COMPONENT_NAME_PROTOCOL        *ComponentName,       OPTIONAL\r
+  IN const EFI_DRIVER_CONFIGURATION_PROTOCOL  *DriverConfiguration, OPTIONAL\r
+  IN const EFI_DRIVER_DIAGNOSTICS_PROTOCOL    *DriverDiagnostics    OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  ASSERT (NULL != DriverBinding);\r
+\r
+  if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {\r
+    if (DriverConfiguration == NULL) {\r
+      if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {\r
+        Status = gBS->InstallMultipleProtocolInterfaces (\r
+                        &DriverBindingHandle,\r
+                        &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                        NULL\r
+                        );\r
+      } else {\r
+        Status = gBS->InstallMultipleProtocolInterfaces (\r
+                        &DriverBindingHandle,\r
+                        &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                        &gEfiComponentNameProtocolGuid, ComponentName,\r
+                        NULL\r
+                        );\r
+      }\r
+    } else {\r
+      if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {\r
+        Status = gBS->InstallMultipleProtocolInterfaces (\r
+                        &DriverBindingHandle,\r
+                        &gEfiDriverBindingProtocolGuid,       DriverBinding,\r
+                        &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                        NULL\r
+                        );\r
+      } else {\r
+        Status = gBS->InstallMultipleProtocolInterfaces (\r
+                        &DriverBindingHandle,\r
+                        &gEfiDriverBindingProtocolGuid,       DriverBinding,\r
+                        &gEfiComponentNameProtocolGuid,       ComponentName,\r
+                        &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                        NULL\r
+                        );\r
+      }\r
+    }\r
+  } else {\r
+    if (DriverConfiguration == NULL) {\r
+      if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {\r
+        Status = gBS->InstallMultipleProtocolInterfaces (\r
+                        &DriverBindingHandle,\r
+                        &gEfiDriverBindingProtocolGuid,     DriverBinding,\r
+                        &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                        NULL\r
+                        );\r
+      } else {\r
+        Status = gBS->InstallMultipleProtocolInterfaces (\r
+                        &DriverBindingHandle,\r
+                        &gEfiDriverBindingProtocolGuid,     DriverBinding,\r
+                        &gEfiComponentNameProtocolGuid,     ComponentName,\r
+                        &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                        NULL\r
+                        );\r
+      }\r
+    } else {\r
+      if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {\r
+       Status = gBS->InstallMultipleProtocolInterfaces (\r
+                        &DriverBindingHandle,\r
+                        &gEfiDriverBindingProtocolGuid,       DriverBinding,\r
+                        &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                        &gEfiDriverDiagnosticsProtocolGuid,   DriverDiagnostics,\r
+                        NULL\r
+                        );\r
+      } else {\r
+        Status = gBS->InstallMultipleProtocolInterfaces (\r
+                        &DriverBindingHandle,\r
+                        &gEfiDriverBindingProtocolGuid,       DriverBinding,\r
+                        &gEfiComponentNameProtocolGuid,       ComponentName,\r
+                        &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                        &gEfiDriverDiagnosticsProtocolGuid,   DriverDiagnostics,\r
+                        NULL\r
+                        );\r
+      }\r
+    }\r
+  }\r
+\r
+  //\r
+  // ASSERT if the call to InstallMultipleProtocolInterfaces() failed\r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol\r
+  //\r
+  DriverBinding->ImageHandle         = ImageHandle;\r
+  DriverBinding->DriverBindingHandle = DriverBindingHandle;\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Intialize a driver by installing the Driver Binding Protocol onto the\r
+  driver's DriverBindingHandle.  This is typically the same as the driver's\r
+  ImageHandle, but it can be different if the driver produces multiple\r
+  DriverBinding Protocols.  This function also initializes the EFI Driver\r
+  Library that initializes the global variables gST, gBS, gRT.\r
+\r
+  @ImageHandle                 The image handle of the driver\r
+  @SystemTable                 The EFI System Table that was passed to the driver's entry point\r
+  @DriverBinding               A Driver Binding Protocol instance that this driver is producing\r
+  @DriverBindingHandle         The handle that DriverBinding is to be installe onto.  If this\r
+                               parameter is NULL, then a new handle is created.\r
+  @ComponentName               A Component Name Protocol instance that this driver is producing\r
+  @DriverConfiguration         A Driver Configuration Protocol instance that this driver is producing\r
+  @DriverDiagnostics           A Driver Diagnostics Protocol instance that this driver is producing\r
+\r
+  @retval EFI_SUCCESS          DriverBinding is installed onto DriverBindingHandle\r
+  @retval Other                Status from gBS->InstallProtocolInterface()\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiLibInstallAllDriverProtocols2 (\r
+  IN const EFI_HANDLE                         ImageHandle,\r
+  IN const EFI_SYSTEM_TABLE                   *SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL              *DriverBinding,\r
+  IN EFI_HANDLE                               DriverBindingHandle,\r
+  IN const EFI_COMPONENT_NAME_PROTOCOL        *ComponentName,       OPTIONAL\r
+  IN const EFI_COMPONENT_NAME2_PROTOCOL       *ComponentName2,      OPTIONAL\r
+  IN const EFI_DRIVER_CONFIGURATION_PROTOCOL  *DriverConfiguration, OPTIONAL\r
+  IN const EFI_DRIVER_DIAGNOSTICS_PROTOCOL    *DriverDiagnostics,   OPTIONAL\r
+  IN const EFI_DRIVER_DIAGNOSTICS2_PROTOCOL   *DriverDiagnostics2   OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  ASSERT (NULL != DriverBinding);\r
+\r
+  if (DriverConfiguration == NULL) {\r
+    if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {\r
+      if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {\r
+        if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            NULL\r
+                            );\r
+          }\r
+        } else {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            NULL\r
+                            );\r
+          }\r
+        }\r
+      } else {\r
+        if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          }\r
+        } else {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          }\r
+        }\r
+      }\r
+    } else {\r
+      if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {\r
+        if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            NULL\r
+                            );\r
+          }\r
+        } else {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            NULL\r
+                            );\r
+          }\r
+        }\r
+      } else {\r
+        if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          }\r
+        } else {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          }\r
+        }\r
+      }\r
+    }\r
+  } else {\r
+    if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) {\r
+      if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {\r
+        if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            NULL\r
+                            );\r
+          }\r
+        } else {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            NULL\r
+                            );\r
+          }\r
+        }\r
+      } else {\r
+        if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          }\r
+        } else {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          }\r
+        }\r
+      }\r
+    } else {\r
+      if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) {\r
+        if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            NULL\r
+                            );\r
+          }\r
+        } else {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            NULL\r
+                            );\r
+          }\r
+        }\r
+      } else {\r
+        if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          }\r
+        } else {\r
+          if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          } else {\r
+            Status = gBS->InstallMultipleProtocolInterfaces (\r
+                            &DriverBindingHandle,\r
+                            &gEfiDriverBindingProtocolGuid, DriverBinding,\r
+                            &gEfiComponentNameProtocolGuid, ComponentName,\r
+                            &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+                            &gEfiDriverConfigurationProtocolGuid, DriverConfiguration,\r
+                            &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics,\r
+                            &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2,\r
+                            NULL\r
+                            );\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  //\r
+  // ASSERT if the call to InstallMultipleProtocolInterfaces() failed\r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol\r
+  //\r
+  DriverBinding->ImageHandle         = ImageHandle;\r
+  DriverBinding->DriverBindingHandle = DriverBindingHandle;\r
+\r
+  return Status;\r
+}\r
+\r
+\r