summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/IScsiDxe/IScsiMisc.c
diff options
context:
space:
mode:
authorFu Siyuan <siyuan.fu@intel.com>2014-01-10 08:24:29 +0000
committersfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>2014-01-10 08:24:29 +0000
commit18b24f924f06f2345c0410d145d14e1a9a500dc8 (patch)
tree3022f6cdbe1070be66bef76bb2e5d05aa316d33e /NetworkPkg/IScsiDxe/IScsiMisc.c
parent9325f68430361597e811f2ae2ad88a4b3440da09 (diff)
downloadedk2-18b24f924f06f2345c0410d145d14e1a9a500dc8.tar.gz
edk2-18b24f924f06f2345c0410d145d14e1a9a500dc8.tar.bz2
edk2-18b24f924f06f2345c0410d145d14e1a9a500dc8.zip
Fix bug in unload function: Check if component name protocol exist, only uninstall it when it really exists.
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Tian, Feng <feng.tian@intel.com> Reviewed-by: Jin, Eric <eric.jin@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15092 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'NetworkPkg/IScsiDxe/IScsiMisc.c')
-rw-r--r--NetworkPkg/IScsiDxe/IScsiMisc.c69
1 files changed, 68 insertions, 1 deletions
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index 6ed4974545..444d6f062e 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1,7 +1,7 @@
/** @file
Miscellaneous routines for iSCSI driver.
-Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1436,3 +1436,70 @@ IScsiOnExitBootService (
IScsiSessionAbort (Private->Session);
}
}
+
+/**
+ Tests whether a controller handle is being managed by IScsi driver.
+
+ This function tests whether the driver specified by DriverBindingHandle is
+ currently managing the controller specified by ControllerHandle. This test
+ is performed by evaluating if the the protocol specified by ProtocolGuid is
+ present on ControllerHandle and is was opened by DriverBindingHandle and Nic
+ Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
+ If ProtocolGuid is NULL, then ASSERT().
+
+ @param ControllerHandle A handle for a controller to test.
+ @param DriverBindingHandle Specifies the driver binding handle for the
+ driver.
+ @param ProtocolGuid Specifies the protocol that the driver specified
+ by DriverBindingHandle opens in its Start()
+ function.
+
+ @retval EFI_SUCCESS ControllerHandle is managed by the driver
+ specified by DriverBindingHandle.
+ @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver
+ specified by DriverBindingHandle.
+
+**/
+EFI_STATUS
+EFIAPI
+IScsiTestManagedDevice (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_GUID *ProtocolGuid
+ )
+{
+ EFI_STATUS Status;
+ VOID *ManagedInterface;
+ EFI_HANDLE NicControllerHandle;
+
+ ASSERT (ProtocolGuid != NULL);
+
+ NicControllerHandle = NetLibGetNicHandle (ControllerHandle, ProtocolGuid);
+ if (NicControllerHandle == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ (EFI_GUID *) ProtocolGuid,
+ &ManagedInterface,
+ DriverBindingHandle,
+ NicControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->CloseProtocol (
+ ControllerHandle,
+ (EFI_GUID *) ProtocolGuid,
+ DriverBindingHandle,
+ NicControllerHandle
+ );
+ return EFI_UNSUPPORTED;
+ }
+
+ if (Status != EFI_ALREADY_STARTED) {
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}