+\r
+/**\r
+ Intialize a driver by installing the Driver Binding Protocol together with the optional Component Name,\r
+ Component Name 2 onto the driver's DriverBindingHandle. This is typically the same as the driver's\r
+ ImageHandle, but it can be different if the driver produces multiple DriverBinding Protocols. \r
+ If the Drvier Binding Protocol interface is NULL, then ASSERT (). \r
+ If the installation fails, then ASSERT ().\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
+ @param ComponentName A Component Name Protocol instance that this driver is producing.\r
+ @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.\r
+\r
+ @retval EFI_SUCCESS The protocol installation is completed successfully.\r
+ @retval Others Status from gBS->InstallMultipleProtocolInterfaces().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiLibInstallDriverBindingComponentName2 (\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
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (NULL != DriverBinding);\r
+\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
+ //\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