X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FMnpDxe%2FMnpDriver.c;h=2ddcec8962bf8399ffa0e67a376426656c18f102;hp=e3abd48cf393072fff81e4d2388f7e4fdd2bb68f;hb=bdebd2cecf015a5feb11e99269731cac606167e8;hpb=779ae3579848a36319d67a6ba012b4b9aa88aa6b diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c b/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c index e3abd48cf3..2ddcec8962 100644 --- a/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c +++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c @@ -1,8 +1,8 @@ /** @file Implementation of driver entry point and driver binding protocol. -Copyright (c) 2005 - 2009, Intel Corporation.
-All rights reserved. This program and the accompanying materials +Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.
+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
@@ -26,6 +26,52 @@ EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding = { NULL }; +/** + Callback function which provided by user to remove one node in NetDestroyLinkList process. + + @param[in] Entry The entry to be removed. + @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. + + @retval EFI_SUCCESS The entry has been removed successfully. + @retval Others Fail to remove the entry. + +**/ +EFI_STATUS +EFIAPI +MnpDestroyServiceDataEntry ( + IN LIST_ENTRY *Entry, + IN VOID *Context + ) +{ + MNP_SERVICE_DATA *MnpServiceData; + + MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry); + return MnpDestroyServiceData (MnpServiceData); +} + +/** + Callback function which provided by user to remove one node in NetDestroyLinkList process. + + @param[in] Entry The entry to be removed. + @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. + + @retval EFI_SUCCESS The entry has been removed successfully. + @retval Others Fail to remove the entry. + +**/ +EFI_STATUS +EFIAPI +MnpDestroyServiceChildEntry ( + IN LIST_ENTRY *Entry, + IN VOID *Context + ) +{ + MNP_SERVICE_DATA *MnpServiceData; + + MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry); + return MnpDestroyServiceChild (MnpServiceData); +} + /** Test to see if this driver supports ControllerHandle. This service is called by the EFI boot service ConnectController(). In @@ -276,8 +322,8 @@ MnpDriverBindingStop ( EFI_VLAN_CONFIG_PROTOCOL *VlanConfig; MNP_DEVICE_DATA *MnpDeviceData; MNP_SERVICE_DATA *MnpServiceData; - BOOLEAN AllChildrenStopped; - LIST_ENTRY *Entry; + LIST_ENTRY *List; + UINTN ListLength; // // Try to retrieve MNP service binding protocol from the ControllerHandle @@ -317,10 +363,15 @@ MnpDriverBindingStop ( // // Destroy all MNP service data // - while (!IsListEmpty (&MnpDeviceData->ServiceList)) { - Entry = GetFirstNode (&MnpDeviceData->ServiceList); - MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry); - MnpDestroyServiceData (MnpServiceData); + List = &MnpDeviceData->ServiceList; + Status = NetDestroyLinkList ( + List, + MnpDestroyServiceDataEntry, + NULL, + &ListLength + ); + if (EFI_ERROR (Status) || ListLength !=0) { + return EFI_DEVICE_ERROR; } // @@ -336,28 +387,29 @@ MnpDriverBindingStop ( } // - // Destroy the Mnp device data + // Destroy Mnp Device Data // MnpDestroyDeviceData (MnpDeviceData, This->DriverBindingHandle); FreePool (MnpDeviceData); + if (gMnpControllerNameTable != NULL) { + FreeUnicodeStringTable (gMnpControllerNameTable); + gMnpControllerNameTable = NULL; + } return EFI_SUCCESS; } // // Stop all MNP child // - AllChildrenStopped = TRUE; - NET_LIST_FOR_EACH (Entry, &MnpDeviceData->ServiceList) { - MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry); - - Status = MnpDestroyServiceChild (MnpServiceData); - if (EFI_ERROR (Status)) { - AllChildrenStopped = FALSE; - } - } - - if (!AllChildrenStopped) { + List = &MnpDeviceData->ServiceList; + Status = NetDestroyLinkList ( + List, + MnpDestroyServiceChildEntry, + NULL, + &ListLength + ); + if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } @@ -465,6 +517,7 @@ ErrorExit: if (Instance->Handle != NULL) { gBS->UninstallMultipleProtocolInterfaces ( + Instance->Handle, &gEfiManagedNetworkProtocolGuid, &Instance->ManagedNetwork, NULL @@ -492,7 +545,7 @@ ErrorExit: @retval EFI_SUCCES The protocol was removed from ChildHandle. @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed. - @retval EFI_INVALID_PARAMETER ChildHandle is not a valid UEFI handle. + @retval EFI_INVALID_PARAMETER ChildHandle is NULL. @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle because its services are being used.