/*++\r
\r
-Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials are licensed and made available\r
under the terms and conditions of the BSD License which accompanies this\r
distribution. The full text of the license may be found at\r
EFI_HANDLE *DeviceHandleBuffer;\r
UINTN DeviceHandleCount;\r
UINTN Index;\r
+ VOID *ComponentName;\r
+ VOID *ComponentName2;\r
\r
Status = gBS->LocateHandleBuffer (\r
AllHandles,\r
&DeviceHandleCount,\r
&DeviceHandleBuffer\r
);\r
- if (!EFI_ERROR (Status)) {\r
- for (Index = 0; Index < DeviceHandleCount; Index++) {\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ for (Index = 0; Index < DeviceHandleCount; Index++) {\r
+ Status = EfiTestManagedDevice (DeviceHandleBuffer[Index], ImageHandle, &gEfiDiskIoProtocolGuid);\r
+ if (!EFI_ERROR (Status)) {\r
Status = gBS->DisconnectController (\r
DeviceHandleBuffer[Index],\r
ImageHandle,\r
NULL\r
);\r
+ if (EFI_ERROR (Status)) {\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (Index == DeviceHandleCount) {\r
+ //\r
+ // Driver is stopped successfully.\r
+ //\r
+ Status = gBS->HandleProtocol (ImageHandle, &gEfiComponentNameProtocolGuid, &ComponentName);\r
+ if (EFI_ERROR (Status)) {\r
+ ComponentName = NULL;\r
}\r
\r
- if (DeviceHandleBuffer != NULL) {\r
- FreePool (DeviceHandleBuffer);\r
+ Status = gBS->HandleProtocol (ImageHandle, &gEfiComponentName2ProtocolGuid, &ComponentName2);\r
+ if (EFI_ERROR (Status)) {\r
+ ComponentName2 = NULL;\r
}\r
+\r
+ if (ComponentName == NULL) {\r
+ if (ComponentName2 == NULL) {\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ ImageHandle,\r
+ &gEfiDriverBindingProtocolGuid, &gFatDriverBinding,\r
+ NULL\r
+ );\r
+ } else {\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ ImageHandle,\r
+ &gEfiDriverBindingProtocolGuid, &gFatDriverBinding,\r
+ &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+ NULL\r
+ );\r
+ }\r
+ } else {\r
+ if (ComponentName2 == NULL) {\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ ImageHandle,\r
+ &gEfiDriverBindingProtocolGuid, &gFatDriverBinding,\r
+ &gEfiComponentNameProtocolGuid, ComponentName,\r
+ NULL\r
+ );\r
+ } else {\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ ImageHandle,\r
+ &gEfiDriverBindingProtocolGuid, &gFatDriverBinding,\r
+ &gEfiComponentNameProtocolGuid, ComponentName,\r
+ &gEfiComponentName2ProtocolGuid, ComponentName2,\r
+ NULL\r
+ );\r
+ }\r
+ }\r
+ }\r
+\r
+ if (DeviceHandleBuffer != NULL) {\r
+ FreePool (DeviceHandleBuffer);\r
}\r
\r
return Status;\r