]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c
Fix the comments to follow UEFI Spec regarding how to check an EFI_HANDLE is valid...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / ArpDxe / ArpDriver.c
1 /** @file
2 ARP driver functions.
3
4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at<BR>
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "ArpDriver.h"
16 #include "ArpImpl.h"
17
18 EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding = {
19 ArpDriverBindingSupported,
20 ArpDriverBindingStart,
21 ArpDriverBindingStop,
22 0xa,
23 NULL,
24 NULL
25 };
26
27
28 /**
29 Create and initialize the arp service context data.
30
31 @param[in] ImageHandle The image handle representing the loaded driver
32 image.
33 @param[in] ControllerHandle The controller handle the driver binds to.
34 @param[in, out] ArpService Pointer to the buffer containing the arp service
35 context data.
36
37 @retval EFI_SUCCESS The arp service context is initialized.
38
39 @retval EFI_UNSUPPORTED The underlayer Snp mode type is not ethernet.
40 Failed to initialize the service context.
41 @retval other Failed to initialize the arp service context.
42
43 **/
44 EFI_STATUS
45 ArpCreateService (
46 IN EFI_HANDLE ImageHandle,
47 IN EFI_HANDLE ControllerHandle,
48 IN OUT ARP_SERVICE_DATA *ArpService
49 )
50 {
51 EFI_STATUS Status;
52
53 ASSERT (ArpService != NULL);
54
55 ArpService->Signature = ARP_SERVICE_DATA_SIGNATURE;
56
57 //
58 // Init the lists.
59 //
60 InitializeListHead (&ArpService->ChildrenList);
61 InitializeListHead (&ArpService->PendingRequestTable);
62 InitializeListHead (&ArpService->DeniedCacheTable);
63 InitializeListHead (&ArpService->ResolvedCacheTable);
64
65 //
66 // Init the servicebinding protocol members.
67 //
68 ArpService->ServiceBinding.CreateChild = ArpServiceBindingCreateChild;
69 ArpService->ServiceBinding.DestroyChild = ArpServiceBindingDestroyChild;
70
71 //
72 // Save the handles.
73 //
74 ArpService->ImageHandle = ImageHandle;
75 ArpService->ControllerHandle = ControllerHandle;
76
77 //
78 // Create a MNP child instance.
79 //
80 Status = NetLibCreateServiceChild (
81 ControllerHandle,
82 ImageHandle,
83 &gEfiManagedNetworkServiceBindingProtocolGuid,
84 &ArpService->MnpChildHandle
85 );
86 if (EFI_ERROR (Status)) {
87 return Status;
88 }
89
90 //
91 // Open the MNP protocol.
92 //
93 Status = gBS->OpenProtocol (
94 ArpService->MnpChildHandle,
95 &gEfiManagedNetworkProtocolGuid,
96 (VOID **)&ArpService->Mnp,
97 ImageHandle,
98 ControllerHandle,
99 EFI_OPEN_PROTOCOL_BY_DRIVER
100 );
101 if (EFI_ERROR (Status)) {
102 goto ERROR_EXIT;
103 }
104
105 //
106 // Get the underlayer Snp mode data.
107 //
108 Status = ArpService->Mnp->GetModeData (ArpService->Mnp, NULL, &ArpService->SnpMode);
109 if ((Status != EFI_NOT_STARTED) && EFI_ERROR (Status)) {
110 goto ERROR_EXIT;
111 }
112
113 if (ArpService->SnpMode.IfType != NET_IFTYPE_ETHERNET) {
114 //
115 // Only support the ethernet.
116 //
117 Status = EFI_UNSUPPORTED;
118 goto ERROR_EXIT;
119 }
120
121 //
122 // Set the Mnp config parameters.
123 //
124 ArpService->MnpConfigData.ReceivedQueueTimeoutValue = 0;
125 ArpService->MnpConfigData.TransmitQueueTimeoutValue = 0;
126 ArpService->MnpConfigData.ProtocolTypeFilter = ARP_ETHER_PROTO_TYPE;
127 ArpService->MnpConfigData.EnableUnicastReceive = TRUE;
128 ArpService->MnpConfigData.EnableMulticastReceive = FALSE;
129 ArpService->MnpConfigData.EnableBroadcastReceive = TRUE;
130 ArpService->MnpConfigData.EnablePromiscuousReceive = FALSE;
131 ArpService->MnpConfigData.FlushQueuesOnReset = TRUE;
132 ArpService->MnpConfigData.EnableReceiveTimestamps = FALSE;
133 ArpService->MnpConfigData.DisableBackgroundPolling = FALSE;
134
135 //
136 // Configure the Mnp child.
137 //
138 Status = ArpService->Mnp->Configure (ArpService->Mnp, &ArpService->MnpConfigData);
139 if (EFI_ERROR (Status)) {
140 goto ERROR_EXIT;
141 }
142
143 //
144 // Create the event used in the RxToken.
145 //
146 Status = gBS->CreateEvent (
147 EVT_NOTIFY_SIGNAL,
148 TPL_NOTIFY,
149 ArpOnFrameRcvd,
150 ArpService,
151 &ArpService->RxToken.Event
152 );
153 if (EFI_ERROR (Status)) {
154 goto ERROR_EXIT;
155 }
156
157 //
158 // Create the Arp heartbeat timer.
159 //
160 Status = gBS->CreateEvent (
161 EVT_NOTIFY_SIGNAL | EVT_TIMER,
162 TPL_CALLBACK,
163 ArpTimerHandler,
164 ArpService,
165 &ArpService->PeriodicTimer
166 );
167 if (EFI_ERROR (Status)) {
168 goto ERROR_EXIT;
169 }
170
171 //
172 // Start the heartbeat timer.
173 //
174 Status = gBS->SetTimer (
175 ArpService->PeriodicTimer,
176 TimerPeriodic,
177 ARP_PERIODIC_TIMER_INTERVAL
178 );
179
180 ERROR_EXIT:
181
182 return Status;
183 }
184
185
186 /**
187 Clean the arp service context data.
188
189 @param[in, out] ArpService Pointer to the buffer containing the arp service
190 context data.
191
192 @return None.
193
194 **/
195 VOID
196 ArpCleanService (
197 IN OUT ARP_SERVICE_DATA *ArpService
198 )
199 {
200 NET_CHECK_SIGNATURE (ArpService, ARP_SERVICE_DATA_SIGNATURE);
201
202 if (ArpService->PeriodicTimer != NULL) {
203 //
204 // Cancle and close the PeriodicTimer.
205 //
206 gBS->SetTimer (ArpService->PeriodicTimer, TimerCancel, 0);
207 gBS->CloseEvent (ArpService->PeriodicTimer);
208 }
209
210 if (ArpService->RxToken.Event != NULL) {
211 //
212 // Cancle the RxToken and close the event in the RxToken.
213 //
214 ArpService->Mnp->Cancel (ArpService->Mnp, NULL);
215 gBS->CloseEvent (ArpService->RxToken.Event);
216 }
217
218 if (ArpService->Mnp != NULL) {
219 //
220 // Reset the Mnp child and close the Mnp protocol.
221 //
222 ArpService->Mnp->Configure (ArpService->Mnp, NULL);
223 gBS->CloseProtocol (
224 ArpService->MnpChildHandle,
225 &gEfiManagedNetworkProtocolGuid,
226 ArpService->ImageHandle,
227 ArpService->ControllerHandle
228 );
229 }
230
231 if (ArpService->MnpChildHandle != NULL) {
232 //
233 // Destroy the mnp child.
234 //
235 NetLibDestroyServiceChild(
236 ArpService->ControllerHandle,
237 ArpService->ImageHandle,
238 &gEfiManagedNetworkServiceBindingProtocolGuid,
239 ArpService->MnpChildHandle
240 );
241 }
242 }
243
244 /**
245 Tests to see if this driver supports a given controller.
246
247 If a child device is provided, it further tests to see if this driver supports
248 creating a handle for the specified child device.
249
250 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
251 @param[in] ControllerHandle The handle of the controller to test. This handle
252 must support a protocol interface that supplies
253 an I/O abstraction to the driver.
254 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
255 This parameter is ignored by device drivers,
256 and is optional for bus drivers.
257
258 @retval EFI_SUCCESS The device specified by ControllerHandle and
259 RemainingDevicePath is supported by the driver
260 specified by This.
261 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
262 RemainingDevicePath is already being managed
263 by the driver specified by This.
264 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
265 RemainingDevicePath is already being managed by
266 a different driver or an application that
267 requires exclusive acces. Currently not implemented.
268 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
269 RemainingDevicePath is not supported by the
270 driver specified by This.
271
272 **/
273 EFI_STATUS
274 EFIAPI
275 ArpDriverBindingSupported (
276 IN EFI_DRIVER_BINDING_PROTOCOL *This,
277 IN EFI_HANDLE ControllerHandle,
278 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
279 )
280 {
281 EFI_STATUS Status;
282
283 //
284 // Test to see if Arp SB is already installed.
285 //
286 Status = gBS->OpenProtocol (
287 ControllerHandle,
288 &gEfiArpServiceBindingProtocolGuid,
289 NULL,
290 This->DriverBindingHandle,
291 ControllerHandle,
292 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
293 );
294 if (Status == EFI_SUCCESS) {
295 return EFI_ALREADY_STARTED;
296 }
297
298 //
299 // Test to see if MNP SB is installed.
300 //
301 Status = gBS->OpenProtocol (
302 ControllerHandle,
303 &gEfiManagedNetworkServiceBindingProtocolGuid,
304 NULL,
305 This->DriverBindingHandle,
306 ControllerHandle,
307 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
308 );
309
310 return Status;
311 }
312
313
314 /**
315 Start this driver on ControllerHandle.
316
317 The Start() function is designed to be invoked from the EFI boot service ConnectController().
318 As a result, much of the error checking on the parameters to Start() has been
319 moved into this common boot service. It is legal to call Start() from other locations,
320 but the following calling restrictions must be followed or the system behavior
321 will not be deterministic.
322 1. ControllerHandle must be a valid EFI_HANDLE.
323 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally
324 aligned EFI_DEVICE_PATH_PROTOCOL.
325 3. Prior to calling Start(), the Supported() function for the driver specified
326 by This must have been called with the same calling parameters, and Supported()
327 must have returned EFI_SUCCESS.
328
329 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
330 @param[in] ControllerHandle The handle of the controller to start. This handle
331 must support a protocol interface that supplies
332 an I/O abstraction to the driver.
333 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
334 This parameter is ignored by device drivers,
335 and is optional for bus drivers.
336
337 @retval EFI_SUCCESS The device was started.
338 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.
339 Currently not implemented.
340 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of
341 resources.
342 @retval Others The driver failded to start the device.
343
344 **/
345 EFI_STATUS
346 EFIAPI
347 ArpDriverBindingStart (
348 IN EFI_DRIVER_BINDING_PROTOCOL *This,
349 IN EFI_HANDLE ControllerHandle,
350 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
351 )
352 {
353 EFI_STATUS Status;
354 ARP_SERVICE_DATA *ArpService;
355
356 //
357 // Allocate a zero pool for ArpService.
358 //
359 ArpService = AllocateZeroPool (sizeof(ARP_SERVICE_DATA));
360 if (ArpService == NULL) {
361 return EFI_OUT_OF_RESOURCES;
362 }
363
364 //
365 // Initialize the arp service context data.
366 //
367 Status = ArpCreateService (This->DriverBindingHandle, ControllerHandle, ArpService);
368 if (EFI_ERROR (Status)) {
369 goto ERROR;
370 }
371
372 //
373 // Install the ARP service binding protocol.
374 //
375 Status = gBS->InstallMultipleProtocolInterfaces (
376 &ControllerHandle,
377 &gEfiArpServiceBindingProtocolGuid,
378 &ArpService->ServiceBinding,
379 NULL
380 );
381 if (EFI_ERROR (Status)) {
382 goto ERROR;
383 }
384
385 //
386 // OK, start to receive arp packets from Mnp.
387 //
388 Status = ArpService->Mnp->Receive (ArpService->Mnp, &ArpService->RxToken);
389 if (EFI_ERROR (Status)) {
390 goto ERROR;
391 }
392
393 return Status;
394
395 ERROR:
396
397 //
398 // On error, clean the arp service context data, and free the memory allocated.
399 //
400 ArpCleanService (ArpService);
401 FreePool (ArpService);
402
403 return Status;
404 }
405
406
407 /**
408 Stop this driver on ControllerHandle.
409
410 Release the control of this controller and remove the IScsi functions. The Stop()
411 function is designed to be invoked from the EFI boot service DisconnectController().
412 As a result, much of the error checking on the parameters to Stop() has been moved
413 into this common boot service. It is legal to call Stop() from other locations,
414 but the following calling restrictions must be followed or the system behavior
415 will not be deterministic.
416 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
417 same driver's Start() function.
418 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
419 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
420 Start() function, and the Start() function must have called OpenProtocol() on
421 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
422
423 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
424 @param[in] ControllerHandle A handle to the device being stopped. The handle must
425 support a bus specific I/O protocol for the driver
426 to use to stop the device.
427 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
428 Not used.
429 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
430 if NumberOfChildren is 0.Not used.
431
432 @retval EFI_SUCCESS The device was stopped.
433 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
434
435 **/
436 EFI_STATUS
437 EFIAPI
438 ArpDriverBindingStop (
439 IN EFI_DRIVER_BINDING_PROTOCOL *This,
440 IN EFI_HANDLE ControllerHandle,
441 IN UINTN NumberOfChildren,
442 IN EFI_HANDLE *ChildHandleBuffer
443 )
444 {
445 EFI_STATUS Status;
446 EFI_HANDLE NicHandle;
447 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
448 ARP_SERVICE_DATA *ArpService;
449 ARP_INSTANCE_DATA *Instance;
450
451 //
452 // Get the NicHandle which the arp servicebinding is installed on.
453 //
454 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);
455 if (NicHandle == NULL) {
456 return EFI_DEVICE_ERROR;
457 }
458
459 //
460 // Try to get the arp servicebinding protocol on the NicHandle.
461 //
462 Status = gBS->OpenProtocol (
463 NicHandle,
464 &gEfiArpServiceBindingProtocolGuid,
465 (VOID **)&ServiceBinding,
466 This->DriverBindingHandle,
467 ControllerHandle,
468 EFI_OPEN_PROTOCOL_GET_PROTOCOL
469 );
470 if (EFI_ERROR (Status)) {
471 DEBUG ((EFI_D_ERROR, "ArpDriverBindingStop: Open ArpSb failed, %r.\n", Status));
472 return EFI_DEVICE_ERROR;
473 }
474
475 ArpService = ARP_SERVICE_DATA_FROM_THIS (ServiceBinding);
476
477 if (NumberOfChildren == 0) {
478 //
479 // Uninstall the ARP ServiceBinding protocol.
480 //
481 gBS->UninstallMultipleProtocolInterfaces (
482 NicHandle,
483 &gEfiArpServiceBindingProtocolGuid,
484 &ArpService->ServiceBinding,
485 NULL
486 );
487
488 //
489 // Clean the arp servicebinding context data and free the memory allocated.
490 //
491 ArpCleanService (ArpService);
492
493 FreePool (ArpService);
494 } else {
495
496 while (!IsListEmpty (&ArpService->ChildrenList)) {
497 Instance = NET_LIST_HEAD (&ArpService->ChildrenList, ARP_INSTANCE_DATA, List);
498
499 ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
500 }
501
502 ASSERT (IsListEmpty (&ArpService->PendingRequestTable));
503 ASSERT (IsListEmpty (&ArpService->DeniedCacheTable));
504 ASSERT (IsListEmpty (&ArpService->ResolvedCacheTable));
505 }
506
507 return EFI_SUCCESS;
508 }
509
510 /**
511 Creates a child handle and installs a protocol.
512
513 The CreateChild() function installs a protocol on ChildHandle.
514 If ChildHandle is a pointer to NULL, then a new handle is created and returned
515 in ChildHandle. If ChildHandle is not a pointer to NULL, then the protocol
516 installs on the existing ChildHandle.
517
518 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
519 @param ChildHandle Pointer to the handle of the child to create. If it is NULL,
520 then a new handle is created. If it is a pointer to an existing
521 UEFI handle, then the protocol is added to the existing UEFI handle.
522
523 @retval EFI_SUCCES The protocol was added to ChildHandle.
524 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
525 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
526 the child
527 @retval other The child handle was not created
528
529 **/
530 EFI_STATUS
531 EFIAPI
532 ArpServiceBindingCreateChild (
533 IN EFI_SERVICE_BINDING_PROTOCOL *This,
534 IN EFI_HANDLE *ChildHandle
535 )
536 {
537 EFI_STATUS Status;
538 ARP_SERVICE_DATA *ArpService;
539 ARP_INSTANCE_DATA *Instance;
540 VOID *Mnp;
541 EFI_TPL OldTpl;
542
543 if ((This == NULL) || (ChildHandle == NULL)) {
544 return EFI_INVALID_PARAMETER;
545 }
546
547 ArpService = ARP_SERVICE_DATA_FROM_THIS (This);
548
549 //
550 // Allocate memory for the instance context data.
551 //
552 Instance = AllocateZeroPool (sizeof(ARP_INSTANCE_DATA));
553 if (Instance == NULL) {
554 DEBUG ((EFI_D_ERROR, "ArpSBCreateChild: Failed to allocate memory for Instance.\n"));
555
556 return EFI_OUT_OF_RESOURCES;
557 }
558
559 //
560 // Init the instance context data.
561 //
562 ArpInitInstance (ArpService, Instance);
563
564 //
565 // Install the ARP protocol onto the ChildHandle.
566 //
567 Status = gBS->InstallMultipleProtocolInterfaces (
568 ChildHandle,
569 &gEfiArpProtocolGuid,
570 (VOID *)&Instance->ArpProto,
571 NULL
572 );
573 if (EFI_ERROR (Status)) {
574 DEBUG ((EFI_D_ERROR, "ArpSBCreateChild: faild to install ARP protocol, %r.\n", Status));
575
576 FreePool (Instance);
577 return Status;
578 }
579
580 //
581 // Save the ChildHandle.
582 //
583 Instance->Handle = *ChildHandle;
584
585 //
586 // Open the Managed Network protocol BY_CHILD.
587 //
588 Status = gBS->OpenProtocol (
589 ArpService->MnpChildHandle,
590 &gEfiManagedNetworkProtocolGuid,
591 (VOID **) &Mnp,
592 gArpDriverBinding.DriverBindingHandle,
593 Instance->Handle,
594 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
595 );
596 if (EFI_ERROR (Status)) {
597 goto ERROR;
598 }
599
600 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
601
602 //
603 // Insert the instance into children list managed by the arp service context data.
604 //
605 InsertTailList (&ArpService->ChildrenList, &Instance->List);
606 ArpService->ChildrenNumber++;
607
608 gBS->RestoreTPL (OldTpl);
609
610 ERROR:
611
612 if (EFI_ERROR (Status)) {
613
614 gBS->CloseProtocol (
615 ArpService->MnpChildHandle,
616 &gEfiManagedNetworkProtocolGuid,
617 gArpDriverBinding.DriverBindingHandle,
618 Instance->Handle
619 );
620
621 gBS->UninstallMultipleProtocolInterfaces (
622 Instance->Handle,
623 &gEfiArpProtocolGuid,
624 &Instance->ArpProto,
625 NULL
626 );
627
628 //
629 // Free the allocated memory.
630 //
631 FreePool (Instance);
632 }
633
634 return Status;
635 }
636
637
638 /**
639 Destroys a child handle with a protocol installed on it.
640
641 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
642 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
643 last protocol on ChildHandle, then ChildHandle is destroyed.
644
645 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
646 @param ChildHandle Handle of the child to destroy
647
648 @retval EFI_SUCCES The protocol was removed from ChildHandle.
649 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is
650 being removed.
651 @retval EFI_INVALID_PARAMETER Child handle is NULL.
652 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
653 because its services are being used.
654 @retval other The child handle was not destroyed
655
656 **/
657 EFI_STATUS
658 EFIAPI
659 ArpServiceBindingDestroyChild (
660 IN EFI_SERVICE_BINDING_PROTOCOL *This,
661 IN EFI_HANDLE ChildHandle
662 )
663 {
664 EFI_STATUS Status;
665 ARP_SERVICE_DATA *ArpService;
666 ARP_INSTANCE_DATA *Instance;
667 EFI_ARP_PROTOCOL *Arp;
668 EFI_TPL OldTpl;
669
670 if ((This == NULL) || (ChildHandle == NULL)) {
671 return EFI_INVALID_PARAMETER;
672 }
673
674 ArpService = ARP_SERVICE_DATA_FROM_THIS (This);
675
676 //
677 // Get the arp protocol.
678 //
679 Status = gBS->OpenProtocol (
680 ChildHandle,
681 &gEfiArpProtocolGuid,
682 (VOID **)&Arp,
683 ArpService->ImageHandle,
684 ChildHandle,
685 EFI_OPEN_PROTOCOL_GET_PROTOCOL
686 );
687 if (EFI_ERROR (Status)) {
688 return EFI_UNSUPPORTED;
689 }
690
691 Instance = ARP_INSTANCE_DATA_FROM_THIS (Arp);
692
693 if (Instance->Destroyed) {
694 return EFI_SUCCESS;
695 }
696
697 //
698 // Use the Destroyed as a flag to avoid re-entrance.
699 //
700 Instance->Destroyed = TRUE;
701
702 //
703 // Close the Managed Network protocol.
704 //
705 gBS->CloseProtocol (
706 ArpService->MnpChildHandle,
707 &gEfiManagedNetworkProtocolGuid,
708 gArpDriverBinding.DriverBindingHandle,
709 ChildHandle
710 );
711
712 //
713 // Uninstall the ARP protocol.
714 //
715 Status = gBS->UninstallMultipleProtocolInterfaces (
716 ChildHandle,
717 &gEfiArpProtocolGuid,
718 &Instance->ArpProto,
719 NULL
720 );
721 if (EFI_ERROR (Status)) {
722 DEBUG ((EFI_D_ERROR, "ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n",
723 Status));
724
725 Instance->Destroyed = FALSE;
726 return Status;
727 }
728
729 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
730
731 if (Instance->Configured) {
732 //
733 // Delete the related cache entry.
734 //
735 ArpDeleteCacheEntry (Instance, FALSE, NULL, TRUE);
736
737 //
738 // Reset the instance configuration.
739 //
740 ArpConfigureInstance (Instance, NULL);
741 }
742
743 //
744 // Remove this instance from the ChildrenList.
745 //
746 RemoveEntryList (&Instance->List);
747 ArpService->ChildrenNumber--;
748
749 gBS->RestoreTPL (OldTpl);
750
751 FreePool (Instance);
752
753 return Status;
754 }
755
756 /**
757 The entry point for Arp driver which installs the driver binding and component name
758 protocol on its ImageHandle.
759
760 @param[in] ImageHandle The image handle of the driver.
761 @param[in] SystemTable The system table.
762
763 @retval EFI_SUCCESS if the driver binding and component name protocols
764 are successfully
765 @retval Others Failed to install the protocols.
766
767 **/
768 EFI_STATUS
769 EFIAPI
770 ArpDriverEntryPoint (
771 IN EFI_HANDLE ImageHandle,
772 IN EFI_SYSTEM_TABLE *SystemTable
773 )
774 {
775 return EfiLibInstallDriverBindingComponentName2 (
776 ImageHandle,
777 SystemTable,
778 &gArpDriverBinding,
779 ImageHandle,
780 &gArpComponentName,
781 &gArpComponentName2
782 );
783 }
784