3 Copyright (c) 2005 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 The driver binding and service binding protocol for IP4 driver.
25 EFI_DRIVER_BINDING_PROTOCOL gIp4DriverBinding
= {
26 Ip4DriverBindingSupported
,
27 Ip4DriverBindingStart
,
35 This is the declaration of an EFI image entry point. This entry point is
36 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
37 both device drivers and bus drivers.
39 The entry point for IP4 driver which install the driver
40 binding and component name protocol on its image.
42 @param ImageHandle The firmware allocated handle for the UEFI image.
43 @param SystemTable A pointer to the EFI System Table.
45 @retval EFI_SUCCESS The operation completed successfully.
46 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
52 IN EFI_HANDLE ImageHandle
,
53 IN EFI_SYSTEM_TABLE
*SystemTable
56 return EfiLibInstallDriverBindingComponentName2 (
67 Test to see if this driver supports ControllerHandle. This service
68 is called by the EFI boot service ConnectController(). In
69 order to make drivers as small as possible, there are a few calling
70 restrictions for this service. ConnectController() must
71 follow these calling restrictions. If any other agent wishes to call
72 Supported() it must also follow these calling restrictions.
74 @param This Protocol instance pointer.
75 @param ControllerHandle Handle of device to test
76 @param RemainingDevicePath Optional parameter use to pick a specific child
79 @retval EFI_SUCCESS This driver supports this device
80 @retval EFI_ALREADY_STARTED This driver is already running on this device
81 @retval other This driver does not support this device
86 Ip4DriverBindingSupported (
87 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
88 IN EFI_HANDLE ControllerHandle
,
89 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
95 // Test for the MNP service binding Protocol
97 Status
= gBS
->OpenProtocol (
99 &gEfiManagedNetworkServiceBindingProtocolGuid
,
101 This
->DriverBindingHandle
,
103 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
106 if (EFI_ERROR (Status
)) {
111 // Test for the Arp service binding Protocol
113 Status
= gBS
->OpenProtocol (
115 &gEfiArpServiceBindingProtocolGuid
,
117 This
->DriverBindingHandle
,
119 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
126 Clean up a IP4 service binding instance. It will release all
127 the resource allocated by the instance. The instance may be
128 partly initialized, or partly destroyed. If a resource is
129 destroyed, it is marked as that in case the destory failed and
130 being called again later.
132 @param IpSb The IP4 serviceing binding instance to clean up
134 @retval EFI_SUCCESS The resource used by the instance are cleaned up
135 @retval other Failed to clean up some of the resources.
145 Create a new IP4 driver service binding private instance.
147 @param Controller The controller that has MNP service binding
149 @param ImageHandle The IP4 driver's image handle
150 @param Service The variable to receive the newly created IP4
153 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resource
154 @retval EFI_SUCCESS A new IP4 service binding private is created.
155 @retval other Other error occurs.
160 IN EFI_HANDLE Controller
,
161 IN EFI_HANDLE ImageHandle
,
162 OUT IP4_SERVICE
**Service
168 ASSERT (Service
!= NULL
);
173 // allocate a service private data then initialize all the filed to
174 // empty resources, so if any thing goes wrong when allocating
175 // resources, Ip4CleanService can be called to clean it up.
177 IpSb
= AllocatePool (sizeof (IP4_SERVICE
));
180 return EFI_OUT_OF_RESOURCES
;
183 IpSb
->Signature
= IP4_SERVICE_SIGNATURE
;
184 IpSb
->ServiceBinding
.CreateChild
= Ip4ServiceBindingCreateChild
;
185 IpSb
->ServiceBinding
.DestroyChild
= Ip4ServiceBindingDestroyChild
;
186 IpSb
->State
= IP4_SERVICE_UNSTARTED
;
187 IpSb
->InDestory
= FALSE
;
189 IpSb
->NumChildren
= 0;
190 InitializeListHead (&IpSb
->Children
);
192 InitializeListHead (&IpSb
->Interfaces
);
193 IpSb
->DefaultInterface
= NULL
;
194 IpSb
->DefaultRouteTable
= NULL
;
196 Ip4InitAssembleTable (&IpSb
->Assemble
);
198 IpSb
->IgmpCtrl
.Igmpv1QuerySeen
= 0;
199 InitializeListHead (&IpSb
->IgmpCtrl
.Groups
);
201 IpSb
->Image
= ImageHandle
;
202 IpSb
->Controller
= Controller
;
204 IpSb
->MnpChildHandle
= NULL
;
207 IpSb
->MnpConfigData
.ReceivedQueueTimeoutValue
= 0;
208 IpSb
->MnpConfigData
.TransmitQueueTimeoutValue
= 0;
209 IpSb
->MnpConfigData
.ProtocolTypeFilter
= IP4_ETHER_PROTO
;
210 IpSb
->MnpConfigData
.EnableUnicastReceive
= TRUE
;
211 IpSb
->MnpConfigData
.EnableMulticastReceive
= TRUE
;
212 IpSb
->MnpConfigData
.EnableBroadcastReceive
= TRUE
;
213 IpSb
->MnpConfigData
.EnablePromiscuousReceive
= FALSE
;
214 IpSb
->MnpConfigData
.FlushQueuesOnReset
= TRUE
;
215 IpSb
->MnpConfigData
.EnableReceiveTimestamps
= FALSE
;
216 IpSb
->MnpConfigData
.DisableBackgroundPolling
= FALSE
;
218 ZeroMem (&IpSb
->SnpMode
, sizeof (EFI_SIMPLE_NETWORK_MODE
));
221 IpSb
->Ip4Config
= NULL
;
222 IpSb
->DoneEvent
= NULL
;
223 IpSb
->ReconfigEvent
= NULL
;
224 IpSb
->ActiveEvent
= NULL
;
227 // Create various resources. First create the route table, timer
228 // event and MNP child. IGMP, interface's initialization depend
231 IpSb
->DefaultRouteTable
= Ip4CreateRouteTable ();
233 if (IpSb
->DefaultRouteTable
== NULL
) {
234 Status
= EFI_OUT_OF_RESOURCES
;
238 Status
= gBS
->CreateEvent (
239 EVT_NOTIFY_SIGNAL
| EVT_TIMER
,
246 if (EFI_ERROR (Status
)) {
250 Status
= NetLibCreateServiceChild (
253 &gEfiManagedNetworkServiceBindingProtocolGuid
,
254 &IpSb
->MnpChildHandle
257 if (EFI_ERROR (Status
)) {
261 Status
= gBS
->OpenProtocol (
262 IpSb
->MnpChildHandle
,
263 &gEfiManagedNetworkProtocolGuid
,
264 (VOID
**) &IpSb
->Mnp
,
267 EFI_OPEN_PROTOCOL_BY_DRIVER
270 if (EFI_ERROR (Status
)) {
274 Status
= Ip4ServiceConfigMnp (IpSb
, TRUE
);
276 if (EFI_ERROR (Status
)) {
280 Status
= IpSb
->Mnp
->GetModeData (IpSb
->Mnp
, NULL
, &IpSb
->SnpMode
);
282 if (EFI_ERROR (Status
)) {
286 Status
= Ip4InitIgmp (IpSb
);
288 if (EFI_ERROR (Status
)) {
292 IpSb
->DefaultInterface
= Ip4CreateInterface (IpSb
->Mnp
, Controller
, ImageHandle
);
294 if (IpSb
->DefaultInterface
== NULL
) {
295 Status
= EFI_OUT_OF_RESOURCES
;
299 InsertHeadList (&IpSb
->Interfaces
, &IpSb
->DefaultInterface
->Link
);
301 IpSb
->MacString
= NULL
;
307 Ip4CleanService (IpSb
);
308 gBS
->FreePool (IpSb
);
315 Clean up a IP4 service binding instance. It will release all
316 the resource allocated by the instance. The instance may be
317 partly initialized, or partly destroyed. If a resource is
318 destroyed, it is marked as that in case the destory failed and
319 being called again later.
321 @param IpSb The IP4 serviceing binding instance to clean up
323 @retval EFI_SUCCESS The resource used by the instance are cleaned up
324 @retval other Failed to clean up some of the resources.
334 if (IpSb
->DefaultInterface
!= NULL
) {
335 Status
= Ip4FreeInterface (IpSb
->DefaultInterface
, NULL
);
337 if (EFI_ERROR (Status
)) {
341 IpSb
->DefaultInterface
= NULL
;
344 if (IpSb
->DefaultRouteTable
!= NULL
) {
345 Ip4FreeRouteTable (IpSb
->DefaultRouteTable
);
346 IpSb
->DefaultRouteTable
= NULL
;
349 Ip4CleanAssembleTable (&IpSb
->Assemble
);
351 if (IpSb
->MnpChildHandle
!= NULL
) {
352 if (IpSb
->Mnp
!= NULL
) {
354 IpSb
->MnpChildHandle
,
355 &gEfiManagedNetworkProtocolGuid
,
363 NetLibDestroyServiceChild (
366 &gEfiManagedNetworkServiceBindingProtocolGuid
,
370 IpSb
->MnpChildHandle
= NULL
;
373 if (IpSb
->Timer
!= NULL
) {
374 gBS
->SetTimer (IpSb
->Timer
, TimerCancel
, 0);
375 gBS
->CloseEvent (IpSb
->Timer
);
380 if (IpSb
->Ip4Config
!= NULL
) {
381 IpSb
->Ip4Config
->Stop (IpSb
->Ip4Config
);
385 &gEfiIp4ConfigProtocolGuid
,
390 gBS
->CloseEvent (IpSb
->DoneEvent
);
391 gBS
->CloseEvent (IpSb
->ReconfigEvent
);
392 IpSb
->ActiveEvent
= NULL
;
393 IpSb
->Ip4Config
= NULL
;
401 Start this driver on ControllerHandle. This service is called by the
402 EFI boot service ConnectController(). In order to make
403 drivers as small as possible, there are a few calling restrictions for
404 this service. ConnectController() must follow these
405 calling restrictions. If any other agent wishes to call Start() it
406 must also follow these calling restrictions.
408 @param This Protocol instance pointer.
409 @param ControllerHandle Handle of device to bind driver to
410 @param RemainingDevicePath Optional parameter use to pick a specific child
413 @retval EFI_SUCCESS This driver is added to ControllerHandle
414 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
415 @retval other This driver does not support this device
420 Ip4DriverBindingStart (
421 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
422 IN EFI_HANDLE ControllerHandle
,
423 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
430 // Test for the Ip4 service binding protocol
432 Status
= gBS
->OpenProtocol (
434 &gEfiIp4ServiceBindingProtocolGuid
,
436 This
->DriverBindingHandle
,
438 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
441 if (Status
== EFI_SUCCESS
) {
442 return EFI_ALREADY_STARTED
;
445 Status
= Ip4CreateService (ControllerHandle
, This
->DriverBindingHandle
, &IpSb
);
447 if (EFI_ERROR (Status
)) {
452 // Install the Ip4ServiceBinding Protocol onto ControlerHandle
454 Status
= gBS
->InstallMultipleProtocolInterfaces (
456 &gEfiIp4ServiceBindingProtocolGuid
,
457 &IpSb
->ServiceBinding
,
461 if (EFI_ERROR (Status
)) {
466 // ready to go: start the receiving and timer
468 Status
= Ip4ReceiveFrame (IpSb
->DefaultInterface
, NULL
, Ip4AccpetFrame
, IpSb
);
470 if (EFI_ERROR (Status
)) {
471 goto UNINSTALL_PROTOCOL
;
474 Status
= gBS
->SetTimer (IpSb
->Timer
, TimerPeriodic
, TICKS_PER_SECOND
);
476 if (EFI_ERROR (Status
)) {
477 goto UNINSTALL_PROTOCOL
;
481 // Initialize the IP4 ID
483 mIp4Id
= (UINT16
)NET_RANDOM (NetRandomInitSeed ());
485 Ip4SetVariableData (IpSb
);
490 gBS
->UninstallProtocolInterface (
492 &gEfiIp4ServiceBindingProtocolGuid
,
493 &IpSb
->ServiceBinding
497 Ip4CleanService (IpSb
);
498 gBS
->FreePool (IpSb
);
505 Stop this driver on ControllerHandle. This service is called by the
506 EFI boot service DisconnectController(). In order to
507 make drivers as small as possible, there are a few calling
508 restrictions for this service. DisconnectController()
509 must follow these calling restrictions. If any other agent wishes
510 to call Stop() it must also follow these calling restrictions.
512 @param This Protocol instance pointer.
513 @param ControllerHandle Handle of device to stop driver on
514 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
515 children is zero stop the entire bus driver.
516 @param ChildHandleBuffer List of Child Handles to Stop.
518 @retval EFI_SUCCESS This driver is removed ControllerHandle
519 @retval other This driver was not removed from this device
524 Ip4DriverBindingStop (
525 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
526 IN EFI_HANDLE ControllerHandle
,
527 IN UINTN NumberOfChildren
,
528 IN EFI_HANDLE
*ChildHandleBuffer
531 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
533 IP4_PROTOCOL
*IpInstance
;
534 EFI_HANDLE NicHandle
;
541 // IP4 driver opens the MNP child, ARP children or the IP4_CONFIG protocol
542 // by driver. So the ControllerHandle may be the MNP child handle, ARP child
543 // handle, or the NIC (UNDI) handle because IP4_CONFIG protocol is installed
544 // in the NIC handle.
547 // First, check whether it is the IP4_CONFIG protocol being uninstalled.
548 // IP4_CONFIG protocol is installed on the NIC handle. It isn't necessary
549 // to clean up the default configuration if IP4_CONFIG is being stopped.
551 Status
= gBS
->OpenProtocol (
553 &gEfiIp4ConfigProtocolGuid
,
555 This
->DriverBindingHandle
,
557 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
560 if (Status
== EFI_SUCCESS
) {
562 // Retrieve the IP4 service binding protocol. If failed, it is
563 // likely that Ip4 ServiceBinding is uninstalled already. In this
564 // case, return immediately.
566 Status
= gBS
->OpenProtocol (
568 &gEfiIp4ServiceBindingProtocolGuid
,
569 (VOID
**) &ServiceBinding
,
570 This
->DriverBindingHandle
,
572 EFI_OPEN_PROTOCOL_GET_PROTOCOL
575 if (EFI_ERROR (Status
)) {
576 return EFI_DEVICE_ERROR
;
579 IpSb
= IP4_SERVICE_FROM_PROTOCOL (ServiceBinding
);
581 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
583 if (IpSb
->Ip4Config
!= NULL
&& (IpSb
->State
!= IP4_SERVICE_DESTORY
)) {
585 IpSb
->Ip4Config
->Stop (IpSb
->Ip4Config
);
587 Status
= gBS
->CloseProtocol (
589 &gEfiIp4ConfigProtocolGuid
,
594 if (EFI_ERROR (Status
)) {
595 gBS
->RestoreTPL (OldTpl
);
600 // If the auto configure hasn't complete, mark it as not started.
602 if (IpSb
->State
== IP4_SERVICE_STARTED
) {
603 IpSb
->State
= IP4_SERVICE_UNSTARTED
;
606 IpSb
->Ip4Config
= NULL
;
607 gBS
->CloseEvent (IpSb
->DoneEvent
);
608 gBS
->CloseEvent (IpSb
->ReconfigEvent
);
611 gBS
->RestoreTPL (OldTpl
);
616 // Either MNP or ARP protocol is being uninstalled. The controller
617 // handle is either the MNP child or ARP child. But, the IP4's
618 // service binding is installed on the NIC handle. So, need to open
619 // the protocol info to find the NIC handle.
622 NicHandle
= NetLibGetNicHandle (ControllerHandle
, &gEfiManagedNetworkProtocolGuid
);
624 if (NicHandle
== NULL
) {
625 NicHandle
= NetLibGetNicHandle (ControllerHandle
, &gEfiArpProtocolGuid
);
629 if (NicHandle
== NULL
) {
630 return EFI_DEVICE_ERROR
;
634 // Retrieve the IP4 service binding protocol
636 Status
= gBS
->OpenProtocol (
638 &gEfiIp4ServiceBindingProtocolGuid
,
639 (VOID
**) &ServiceBinding
,
640 This
->DriverBindingHandle
,
642 EFI_OPEN_PROTOCOL_GET_PROTOCOL
645 if (EFI_ERROR (Status
)) {
646 return EFI_DEVICE_ERROR
;
649 IpSb
= IP4_SERVICE_FROM_PROTOCOL (ServiceBinding
);
651 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
653 if (IpSb
->InDestory
) {
654 gBS
->RestoreTPL (OldTpl
);
659 while (!IsListEmpty (&IpSb
->Children
)) {
660 IpInstance
= NET_LIST_HEAD (&IpSb
->Children
, IP4_PROTOCOL
, Link
);
662 ServiceBinding
->DestroyChild (ServiceBinding
, IpInstance
->Handle
);
665 if (IpSb
->NumChildren
!= 0) {
666 Status
= EFI_DEVICE_ERROR
;
670 IpSb
->InDestory
= TRUE
;
673 IpSb
->State
= IP4_SERVICE_DESTORY
;
676 // Clear the variable data.
678 Ip4ClearVariableData (IpSb
);
681 // OK, clean other resources then uninstall the service binding protocol.
683 Status
= Ip4CleanService (IpSb
);
685 if (EFI_ERROR (Status
)) {
690 gBS
->UninstallProtocolInterface (
692 &gEfiIp4ServiceBindingProtocolGuid
,
696 gBS
->FreePool (IpSb
);
697 } else if (NumberOfChildren
== 0) {
698 IpSb
->InDestory
= TRUE
;
701 IpSb
->State
= IP4_SERVICE_DESTORY
;
704 // Clear the variable data.
706 Ip4ClearVariableData (IpSb
);
709 // OK, clean other resources then uninstall the service binding protocol.
711 Status
= Ip4CleanService (IpSb
);
713 if (EFI_ERROR (Status
)) {
718 gBS
->UninstallProtocolInterface (
720 &gEfiIp4ServiceBindingProtocolGuid
,
724 gBS
->FreePool (IpSb
);
727 while (!IsListEmpty (&IpSb
->Children
)) {
728 IpInstance
= NET_LIST_HEAD (&IpSb
->Children
, IP4_PROTOCOL
, Link
);
730 ServiceBinding
->DestroyChild (ServiceBinding
, IpInstance
->Handle
);
733 if (IpSb
->NumChildren
!= 0) {
734 Status
= EFI_DEVICE_ERROR
;
740 gBS
->RestoreTPL (OldTpl
);
746 Creates a child handle with a set of I/O services.
748 @param This Protocol instance pointer.
749 @param ChildHandle Pointer to the handle of the child to create. If it is NULL,
750 then a new handle is created. If it is not NULL, then the
751 I/O services are added to the existing child handle.
753 @retval EFI_SUCCES The child handle was created with the I/O services
754 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
755 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
757 @retval other The child handle was not created
762 Ip4ServiceBindingCreateChild (
763 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
764 IN OUT EFI_HANDLE
*ChildHandle
768 IP4_PROTOCOL
*IpInstance
;
773 if ((This
== NULL
) || (ChildHandle
== NULL
)) {
774 return EFI_INVALID_PARAMETER
;
777 IpSb
= IP4_SERVICE_FROM_PROTOCOL (This
);
778 IpInstance
= AllocatePool (sizeof (IP4_PROTOCOL
));
780 if (IpInstance
== NULL
) {
781 return EFI_OUT_OF_RESOURCES
;
784 Ip4InitProtocol (IpSb
, IpInstance
);
787 // Install Ip4 onto ChildHandle
789 Status
= gBS
->InstallMultipleProtocolInterfaces (
791 &gEfiIp4ProtocolGuid
,
792 &IpInstance
->Ip4Proto
,
796 if (EFI_ERROR (Status
)) {
800 IpInstance
->Handle
= *ChildHandle
;
803 // Open the Managed Network protocol BY_CHILD.
805 Status
= gBS
->OpenProtocol (
806 IpSb
->MnpChildHandle
,
807 &gEfiManagedNetworkProtocolGuid
,
809 gIp4DriverBinding
.DriverBindingHandle
,
811 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
813 if (EFI_ERROR (Status
)) {
814 gBS
->UninstallMultipleProtocolInterfaces (
816 &gEfiIp4ProtocolGuid
,
817 &IpInstance
->Ip4Proto
,
825 // Insert it into the service binding instance.
827 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
829 InsertTailList (&IpSb
->Children
, &IpInstance
->Link
);
832 gBS
->RestoreTPL (OldTpl
);
836 if (EFI_ERROR (Status
)) {
838 Ip4CleanProtocol (IpInstance
);
840 gBS
->FreePool (IpInstance
);
848 Destroys a child handle with a set of I/O services.
850 @param This Protocol instance pointer.
851 @param ChildHandle Handle of the child to destroy
853 @retval EFI_SUCCES The I/O services were removed from the child handle
854 @retval EFI_UNSUPPORTED The child handle does not support the I/O services
855 that are being removed.
856 @retval EFI_INVALID_PARAMETER Child handle is not a valid EFI Handle.
857 @retval EFI_ACCESS_DENIED The child handle could not be destroyed because its
858 I/O services are being used.
859 @retval other The child handle was not destroyed
864 Ip4ServiceBindingDestroyChild (
865 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
866 IN EFI_HANDLE ChildHandle
871 IP4_PROTOCOL
*IpInstance
;
872 EFI_IP4_PROTOCOL
*Ip4
;
876 if ((This
== NULL
) || (ChildHandle
== NULL
)) {
877 return EFI_INVALID_PARAMETER
;
881 // Retrieve the private context data structures
883 IpSb
= IP4_SERVICE_FROM_PROTOCOL (This
);
885 Status
= gBS
->OpenProtocol (
887 &gEfiIp4ProtocolGuid
,
889 gIp4DriverBinding
.DriverBindingHandle
,
891 EFI_OPEN_PROTOCOL_GET_PROTOCOL
894 if (EFI_ERROR (Status
)) {
895 return EFI_UNSUPPORTED
;
898 IpInstance
= IP4_INSTANCE_FROM_PROTOCOL (Ip4
);
900 if (IpInstance
->Service
!= IpSb
) {
901 return EFI_INVALID_PARAMETER
;
904 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
907 // A child can be destoried more than once. For example,
908 // Ip4DriverBindingStop will destory all of its children.
909 // when UDP driver is being stopped, it will destory all
910 // the IP child it opens.
912 if (IpInstance
->State
== IP4_STATE_DESTORY
) {
913 gBS
->RestoreTPL (OldTpl
);
917 State
= IpInstance
->State
;
918 IpInstance
->State
= IP4_STATE_DESTORY
;
921 // Close the Managed Network protocol.
924 IpSb
->MnpChildHandle
,
925 &gEfiManagedNetworkProtocolGuid
,
926 gIp4DriverBinding
.DriverBindingHandle
,
931 // Uninstall the IP4 protocol first. Many thing happens during
933 // 1. The consumer of the IP4 protocol will be stopped if it
934 // opens the protocol BY_DRIVER. For eaxmple, if MNP driver is
935 // stopped, IP driver's stop function will be called, and uninstall
936 // EFI_IP4_PROTOCOL will trigger the UDP's stop function. This
937 // makes it possible to create the network stack bottom up, and
939 // 2. the upper layer will recycle the received packet. The recycle
940 // event's TPL is higher than this function. The recycle events
941 // will be called back before preceeding. If any packets not recycled,
942 // that means there is a resource leak.
944 Status
= gBS
->UninstallProtocolInterface (
946 &gEfiIp4ProtocolGuid
,
947 &IpInstance
->Ip4Proto
950 if (EFI_ERROR (Status
)) {
954 Status
= Ip4CleanProtocol (IpInstance
);
956 Ip4SetVariableData (IpSb
);
958 if (EFI_ERROR (Status
)) {
959 gBS
->InstallMultipleProtocolInterfaces (
961 &gEfiIp4ProtocolGuid
,
969 RemoveEntryList (&IpInstance
->Link
);
972 gBS
->RestoreTPL (OldTpl
);
974 gBS
->FreePool (IpInstance
);
978 IpInstance
->State
= State
;
979 gBS
->RestoreTPL (OldTpl
);