- //\r
- // IP4 driver opens the MNP child, ARP children or the IP4_CONFIG protocol\r
- // by driver. So the ControllerHandle may be the MNP child handle, ARP child\r
- // handle, or the NIC (UNDI) handle because IP4_CONFIG protocol is installed\r
- // in the NIC handle.\r
- //\r
- //\r
- // First, check whether it is the IP4_CONFIG protocol being uninstalled.\r
- // IP4_CONFIG protocol is installed on the NIC handle. It isn't necessary\r
- // to clean up the default configuration if IP4_CONFIG is being stopped.\r
- //\r
- Status = gBS->OpenProtocol (\r
- ControllerHandle,\r
- &gEfiIp4ConfigProtocolGuid,\r
- NULL,\r
- This->DriverBindingHandle,\r
- ControllerHandle,\r
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
- );\r
- if (Status == EFI_SUCCESS) {\r
- //\r
- // Retrieve the IP4 service binding protocol. If failed, it is\r
- // likely that Ip4 ServiceBinding is uninstalled already. In this\r
- // case, return immediately.\r
- //\r
- Status = gBS->OpenProtocol (\r
- ControllerHandle,\r
- &gEfiIp4ServiceBindingProtocolGuid,\r
- (VOID **) &ServiceBinding,\r
- This->DriverBindingHandle,\r
- ControllerHandle,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- IpSb = IP4_SERVICE_FROM_PROTOCOL (ServiceBinding);\r
- if (IpSb->Ip4Config != NULL && (IpSb->State != IP4_SERVICE_DESTROY)) {\r
-\r
- IpSb->Ip4Config->Stop (IpSb->Ip4Config);\r
-\r
- Status = gBS->CloseProtocol (\r
- ControllerHandle,\r
- &gEfiIp4ConfigProtocolGuid,\r
- IpSb->Image,\r
- ControllerHandle\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // If the auto configure hasn't complete, mark it as not started.\r
- //\r
- if (IpSb->State == IP4_SERVICE_STARTED) {\r
- IpSb->State = IP4_SERVICE_UNSTARTED;\r
- }\r
-\r
- IpSb->Ip4Config = NULL;\r
- gBS->CloseEvent (IpSb->DoneEvent);\r
- gBS->CloseEvent (IpSb->ReconfigEvent);\r
- }\r
-\r
- return EFI_SUCCESS;\r
- }\r