]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c
NetworkPkg: Move Network library and drivers from MdeModulePkg to NetworkPkg
[mirror_edk2.git] / MdeModulePkg / Universal / Network / ArpDxe / ArpDriver.c
diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c b/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c
deleted file mode 100644 (file)
index 632d691..0000000
+++ /dev/null
@@ -1,811 +0,0 @@
-/** @file\r
-  ARP driver functions.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "ArpDriver.h"\r
-#include "ArpImpl.h"\r
-\r
-EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding = {\r
-  ArpDriverBindingSupported,\r
-  ArpDriverBindingStart,\r
-  ArpDriverBindingStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-\r
-/**\r
-  Create and initialize the arp service context data.\r
-\r
-  @param[in]       ImageHandle       The image handle representing the loaded driver\r
-                                     image.\r
-  @param[in]       ControllerHandle  The controller handle the driver binds to.\r
-  @param[in, out]  ArpService        Pointer to the buffer containing the arp service\r
-                                     context data.\r
-\r
-  @retval EFI_SUCCESS                The arp service context is initialized.\r
-\r
-  @retval EFI_UNSUPPORTED            The underlayer Snp mode type is not ethernet.\r
-                                     Failed to initialize the service context.\r
-  @retval other                      Failed to initialize the arp service context.\r
-\r
-**/\r
-EFI_STATUS\r
-ArpCreateService (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_HANDLE        ControllerHandle,\r
-  IN OUT ARP_SERVICE_DATA  *ArpService\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  ASSERT (ArpService != NULL);\r
-\r
-  ArpService->Signature = ARP_SERVICE_DATA_SIGNATURE;\r
-\r
-  //\r
-  // Init the lists.\r
-  //\r
-  InitializeListHead (&ArpService->ChildrenList);\r
-  InitializeListHead (&ArpService->PendingRequestTable);\r
-  InitializeListHead (&ArpService->DeniedCacheTable);\r
-  InitializeListHead (&ArpService->ResolvedCacheTable);\r
-\r
-  //\r
-  // Init the servicebinding protocol members.\r
-  //\r
-  ArpService->ServiceBinding.CreateChild  = ArpServiceBindingCreateChild;\r
-  ArpService->ServiceBinding.DestroyChild = ArpServiceBindingDestroyChild;\r
-\r
-  //\r
-  // Save the handles.\r
-  //\r
-  ArpService->ImageHandle      = ImageHandle;\r
-  ArpService->ControllerHandle = ControllerHandle;\r
-\r
-  //\r
-  // Create a MNP child instance.\r
-  //\r
-  Status = NetLibCreateServiceChild (\r
-             ControllerHandle,\r
-             ImageHandle,\r
-             &gEfiManagedNetworkServiceBindingProtocolGuid,\r
-             &ArpService->MnpChildHandle\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Open the MNP protocol.\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ArpService->MnpChildHandle,\r
-                  &gEfiManagedNetworkProtocolGuid,\r
-                  (VOID **)&ArpService->Mnp,\r
-                  ImageHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ERROR_EXIT;\r
-  }\r
-\r
-  //\r
-  // Get the underlayer Snp mode data.\r
-  //\r
-  Status = ArpService->Mnp->GetModeData (ArpService->Mnp, NULL, &ArpService->SnpMode);\r
-  if ((Status != EFI_NOT_STARTED) && EFI_ERROR (Status)) {\r
-    goto ERROR_EXIT;\r
-  }\r
-\r
-  if (ArpService->SnpMode.IfType != NET_IFTYPE_ETHERNET) {\r
-    //\r
-    // Only support the ethernet.\r
-    //\r
-    Status = EFI_UNSUPPORTED;\r
-    goto ERROR_EXIT;\r
-  }\r
-\r
-  //\r
-  // Set the Mnp config parameters.\r
-  //\r
-  ArpService->MnpConfigData.ReceivedQueueTimeoutValue = 0;\r
-  ArpService->MnpConfigData.TransmitQueueTimeoutValue = 0;\r
-  ArpService->MnpConfigData.ProtocolTypeFilter        = ARP_ETHER_PROTO_TYPE;\r
-  ArpService->MnpConfigData.EnableUnicastReceive      = TRUE;\r
-  ArpService->MnpConfigData.EnableMulticastReceive    = FALSE;\r
-  ArpService->MnpConfigData.EnableBroadcastReceive    = TRUE;\r
-  ArpService->MnpConfigData.EnablePromiscuousReceive  = FALSE;\r
-  ArpService->MnpConfigData.FlushQueuesOnReset        = TRUE;\r
-  ArpService->MnpConfigData.EnableReceiveTimestamps   = FALSE;\r
-  ArpService->MnpConfigData.DisableBackgroundPolling  = FALSE;\r
-\r
-  //\r
-  // Configure the Mnp child.\r
-  //\r
-  Status = ArpService->Mnp->Configure (ArpService->Mnp, &ArpService->MnpConfigData);\r
-  if (EFI_ERROR (Status)) {\r
-    goto ERROR_EXIT;\r
-  }\r
-\r
-  //\r
-  // Create the event used in the RxToken.\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  ArpOnFrameRcvd,\r
-                  ArpService,\r
-                  &ArpService->RxToken.Event\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ERROR_EXIT;\r
-  }\r
-\r
-  //\r
-  // Create the Arp heartbeat timer.\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_SIGNAL | EVT_TIMER,\r
-                  TPL_CALLBACK,\r
-                  ArpTimerHandler,\r
-                  ArpService,\r
-                  &ArpService->PeriodicTimer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ERROR_EXIT;\r
-  }\r
-\r
-  //\r
-  // Start the heartbeat timer.\r
-  //\r
-  Status = gBS->SetTimer (\r
-                  ArpService->PeriodicTimer,\r
-                  TimerPeriodic,\r
-                  ARP_PERIODIC_TIMER_INTERVAL\r
-                  );\r
-\r
-ERROR_EXIT:\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Clean the arp service context data.\r
-\r
-  @param[in, out]  ArpService        Pointer to the buffer containing the arp service\r
-                                     context data.\r
-\r
-  @return None.\r
-\r
-**/\r
-VOID\r
-ArpCleanService (\r
-  IN OUT ARP_SERVICE_DATA  *ArpService\r
-  )\r
-{\r
-  NET_CHECK_SIGNATURE (ArpService, ARP_SERVICE_DATA_SIGNATURE);\r
-\r
-  if (ArpService->PeriodicTimer != NULL) {\r
-    //\r
-    // Cancle and close the PeriodicTimer.\r
-    //\r
-    gBS->SetTimer (ArpService->PeriodicTimer, TimerCancel, 0);\r
-    gBS->CloseEvent (ArpService->PeriodicTimer);\r
-  }\r
-\r
-  if (ArpService->RxToken.Event != NULL) {\r
-    //\r
-    // Cancle the RxToken and close the event in the RxToken.\r
-    //\r
-    ArpService->Mnp->Cancel (ArpService->Mnp, NULL);\r
-    gBS->CloseEvent (ArpService->RxToken.Event);\r
-  }\r
-\r
-  if (ArpService->Mnp != NULL) {\r
-    //\r
-    // Reset the Mnp child and close the Mnp protocol.\r
-    //\r
-    ArpService->Mnp->Configure (ArpService->Mnp, NULL);\r
-    gBS->CloseProtocol (\r
-           ArpService->MnpChildHandle,\r
-           &gEfiManagedNetworkProtocolGuid,\r
-           ArpService->ImageHandle,\r
-           ArpService->ControllerHandle\r
-           );\r
-  }\r
-\r
-  if (ArpService->MnpChildHandle != NULL) {\r
-    //\r
-    // Destroy the mnp child.\r
-    //\r
-    NetLibDestroyServiceChild(\r
-      ArpService->ControllerHandle,\r
-      ArpService->ImageHandle,\r
-      &gEfiManagedNetworkServiceBindingProtocolGuid,\r
-      ArpService->MnpChildHandle\r
-      );\r
-  }\r
-}\r
-\r
-/**\r
-  Callback function which provided by user to remove one node in NetDestroyLinkList process.\r
-\r
-  @param[in]    Entry           The entry to be removed.\r
-  @param[in]    Context         Pointer to the callback context corresponds to the Context in NetDestroyLinkList.\r
-\r
-  @retval EFI_SUCCESS           The entry has been removed successfully.\r
-  @retval Others                Fail to remove the entry.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ArpDestroyChildEntryInHandleBuffer (\r
-  IN LIST_ENTRY         *Entry,\r
-  IN VOID               *Context\r
-  )\r
-{\r
-  ARP_INSTANCE_DATA             *Instance;\r
-  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;\r
-\r
-  if (Entry == NULL || Context == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Instance = NET_LIST_USER_STRUCT_S (Entry, ARP_INSTANCE_DATA, List, ARP_INSTANCE_DATA_SIGNATURE);\r
-  ServiceBinding    = (EFI_SERVICE_BINDING_PROTOCOL *) Context;\r
-\r
-  return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);\r
-}\r
-\r
-/**\r
-  Tests to see if this driver supports a given controller.\r
-\r
-  If a child device is provided, it further tests to see if this driver supports\r
-  creating a handle for the specified child device.\r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to test. This handle\r
-                                   must support a protocol interface that supplies\r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-                                   This parameter is ignored by device drivers,\r
-                                   and is optional for bus drivers.\r
-\r
-  @retval EFI_SUCCESS              The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is supported by the driver\r
-                                   specified by This.\r
-  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is already being managed\r
-                                   by the driver specified by This.\r
-  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is already being managed by\r
-                                   a different driver or an application that\r
-                                   requires exclusive acces. Currently not implemented.\r
-  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is not supported by the\r
-                                   driver specified by This.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ArpDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   ControllerHandle,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Test to see if Arp SB is already installed.\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiArpServiceBindingProtocolGuid,\r
-                  NULL,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
-                  );\r
-  if (Status == EFI_SUCCESS) {\r
-    return EFI_ALREADY_STARTED;\r
-  }\r
-\r
-  //\r
-  // Test to see if MNP SB is installed.\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiManagedNetworkServiceBindingProtocolGuid,\r
-                  NULL,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
-                  );\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Start this driver on ControllerHandle.\r
-\r
-  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
-  As a result, much of the error checking on the parameters to Start() has been\r
-  moved into this common boot service. It is legal to call Start() from other locations,\r
-  but the following calling restrictions must be followed or the system behavior\r
-  will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE.\r
-  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally\r
-     aligned EFI_DEVICE_PATH_PROTOCOL.\r
-  3. Prior to calling Start(), the Supported() function for the driver specified\r
-     by This must have been called with the same calling parameters, and Supported()\r
-     must have returned EFI_SUCCESS.\r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to start. This handle\r
-                                   must support a protocol interface that supplies\r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
-                                   This parameter is ignored by device drivers,\r
-                                   and is optional for bus drivers.\r
-\r
-  @retval EFI_SUCCESS              The device was started.\r
-  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.\r
-                                   Currently not implemented.\r
-  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of\r
-                                   resources.\r
-  @retval Others                   The driver failded to start the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ArpDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   ControllerHandle,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-  ARP_SERVICE_DATA  *ArpService;\r
-\r
-  //\r
-  // Allocate a zero pool for ArpService.\r
-  //\r
-  ArpService = AllocateZeroPool (sizeof(ARP_SERVICE_DATA));\r
-  if (ArpService == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // Initialize the arp service context data.\r
-  //\r
-  Status = ArpCreateService (This->DriverBindingHandle, ControllerHandle, ArpService);\r
-  if (EFI_ERROR (Status)) {\r
-    goto ERROR;\r
-  }\r
-\r
-  //\r
-  // Install the ARP service binding protocol.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &ControllerHandle,\r
-                  &gEfiArpServiceBindingProtocolGuid,\r
-                  &ArpService->ServiceBinding,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ERROR;\r
-  }\r
-\r
-  //\r
-  // OK, start to receive arp packets from Mnp.\r
-  //\r
-  Status = ArpService->Mnp->Receive (ArpService->Mnp, &ArpService->RxToken);\r
-  if (EFI_ERROR (Status)) {\r
-    goto ERROR;\r
-  }\r
-\r
-  return Status;\r
-\r
-ERROR:\r
-\r
-  //\r
-  // On error, clean the arp service context data, and free the memory allocated.\r
-  //\r
-  ArpCleanService (ArpService);\r
-  FreePool (ArpService);\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Stop this driver on ControllerHandle.\r
-\r
-  Release the control of this controller and remove the IScsi functions. The Stop()\r
-  function is designed to be invoked from the EFI boot service DisconnectController().\r
-  As a result, much of the error checking on the parameters to Stop() has been moved\r
-  into this common boot service. It is legal to call Stop() from other locations,\r
-  but the following calling restrictions must be followed or the system behavior\r
-  will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
-     same driver's Start() function.\r
-  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
-     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
-     Start() function, and the Start() function must have called OpenProtocol() on\r
-     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
-\r
-  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must\r
-                                support a bus specific I/O protocol for the driver\r
-                                to use to stop the device.\r
-  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-                                Not used.\r
-  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL\r
-                                if NumberOfChildren is 0.Not used.\r
-\r
-  @retval EFI_SUCCESS           The device was stopped.\r
-  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ArpDriverBindingStop (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   ControllerHandle,\r
-  IN UINTN                        NumberOfChildren,\r
-  IN EFI_HANDLE                   *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_HANDLE                    NicHandle;\r
-  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;\r
-  ARP_SERVICE_DATA              *ArpService;\r
-  LIST_ENTRY                    *List;\r
-\r
-  //\r
-  // Get the NicHandle which the arp servicebinding is installed on.\r
-  //\r
-  NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);\r
-  if (NicHandle == NULL) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Try to get the arp servicebinding protocol on the NicHandle.\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  NicHandle,\r
-                  &gEfiArpServiceBindingProtocolGuid,\r
-                  (VOID **)&ServiceBinding,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "ArpDriverBindingStop: Open ArpSb failed, %r.\n", Status));\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  ArpService = ARP_SERVICE_DATA_FROM_THIS (ServiceBinding);\r
-\r
-  if (NumberOfChildren != 0) {\r
-    //\r
-    // NumberOfChildren is not zero, destroy all the ARP children instances.\r
-    //\r
-    List = &ArpService->ChildrenList;\r
-    Status = NetDestroyLinkList (\r
-               List,\r
-               ArpDestroyChildEntryInHandleBuffer,\r
-               ServiceBinding,\r
-               NULL\r
-               );\r
-    ASSERT (IsListEmpty (&ArpService->PendingRequestTable));\r
-    ASSERT (IsListEmpty (&ArpService->DeniedCacheTable));\r
-    ASSERT (IsListEmpty (&ArpService->ResolvedCacheTable));\r
-  } else if (IsListEmpty (&ArpService->ChildrenList)) {\r
-    //\r
-    // Uninstall the ARP ServiceBinding protocol.\r
-    //\r
-    gBS->UninstallMultipleProtocolInterfaces (\r
-           NicHandle,\r
-           &gEfiArpServiceBindingProtocolGuid,\r
-           &ArpService->ServiceBinding,\r
-           NULL\r
-           );\r
-\r
-    //\r
-    // Clean the arp servicebinding context data and free the memory allocated.\r
-    //\r
-    ArpCleanService (ArpService);\r
-\r
-    FreePool (ArpService);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Creates a child handle and installs a protocol.\r
-\r
-  The CreateChild() function installs a protocol on ChildHandle.\r
-  If ChildHandle is a pointer to NULL, then a new handle is created and returned\r
-  in ChildHandle. If ChildHandle is not a pointer to NULL, then the protocol\r
-  installs on the existing ChildHandle.\r
-\r
-  @param  This        Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
-  @param  ChildHandle Pointer to the handle of the child to create. If it is NULL,\r
-                      then a new handle is created. If it is a pointer to an existing\r
-                      UEFI handle, then the protocol is added to the existing UEFI handle.\r
-\r
-  @retval EFI_SUCCES            The protocol was added to ChildHandle.\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
-  @retval EFI_OUT_OF_RESOURCES  There are not enough resources available to create\r
-                                the child\r
-  @retval other                 The child handle was not created\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ArpServiceBindingCreateChild (\r
-  IN EFI_SERVICE_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                    *ChildHandle\r
-  )\r
-{\r
-  EFI_STATUS         Status;\r
-  ARP_SERVICE_DATA   *ArpService;\r
-  ARP_INSTANCE_DATA  *Instance;\r
-  VOID               *Mnp;\r
-  EFI_TPL            OldTpl;\r
-\r
-  if ((This == NULL) || (ChildHandle == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  ArpService = ARP_SERVICE_DATA_FROM_THIS (This);\r
-\r
-  //\r
-  // Allocate memory for the instance context data.\r
-  //\r
-  Instance = AllocateZeroPool (sizeof(ARP_INSTANCE_DATA));\r
-  if (Instance == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "ArpSBCreateChild: Failed to allocate memory for Instance.\n"));\r
-\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // Init the instance context data.\r
-  //\r
-  ArpInitInstance (ArpService, Instance);\r
-\r
-  //\r
-  // Install the ARP protocol onto the ChildHandle.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  ChildHandle,\r
-                  &gEfiArpProtocolGuid,\r
-                  (VOID *)&Instance->ArpProto,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "ArpSBCreateChild: faild to install ARP protocol, %r.\n", Status));\r
-\r
-    FreePool (Instance);\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Save the ChildHandle.\r
-  //\r
-  Instance->Handle = *ChildHandle;\r
-\r
-  //\r
-  // Open the Managed Network protocol BY_CHILD.\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ArpService->MnpChildHandle,\r
-                  &gEfiManagedNetworkProtocolGuid,\r
-                  (VOID **) &Mnp,\r
-                  gArpDriverBinding.DriverBindingHandle,\r
-                  Instance->Handle,\r
-                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ERROR;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  //\r
-  // Insert the instance into children list managed by the arp service context data.\r
-  //\r
-  InsertTailList (&ArpService->ChildrenList, &Instance->List);\r
-  ArpService->ChildrenNumber++;\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-ERROR:\r
-\r
-  if (EFI_ERROR (Status)) {\r
-\r
-    gBS->CloseProtocol (\r
-           ArpService->MnpChildHandle,\r
-           &gEfiManagedNetworkProtocolGuid,\r
-           gArpDriverBinding.DriverBindingHandle,\r
-           Instance->Handle\r
-           );\r
-\r
-    gBS->UninstallMultipleProtocolInterfaces (\r
-           Instance->Handle,\r
-           &gEfiArpProtocolGuid,\r
-           &Instance->ArpProto,\r
-           NULL\r
-           );\r
-\r
-    //\r
-    // Free the allocated memory.\r
-    //\r
-    FreePool (Instance);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Destroys a child handle with a protocol installed on it.\r
-\r
-  The DestroyChild() function does the opposite of CreateChild(). It removes a protocol\r
-  that was installed by CreateChild() from ChildHandle. If the removed protocol is the\r
-  last protocol on ChildHandle, then ChildHandle is destroyed.\r
-\r
-  @param  This        Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
-  @param  ChildHandle Handle of the child to destroy\r
-\r
-  @retval EFI_SUCCES            The protocol was removed from ChildHandle.\r
-  @retval EFI_UNSUPPORTED       ChildHandle does not support the protocol that is\r
-                                being removed.\r
-  @retval EFI_INVALID_PARAMETER Child handle is NULL.\r
-  @retval EFI_ACCESS_DENIED     The protocol could not be removed from the ChildHandle\r
-                                because its services are being used.\r
-  @retval other                 The child handle was not destroyed\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ArpServiceBindingDestroyChild (\r
-  IN EFI_SERVICE_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                    ChildHandle\r
-  )\r
-{\r
-  EFI_STATUS         Status;\r
-  ARP_SERVICE_DATA   *ArpService;\r
-  ARP_INSTANCE_DATA  *Instance;\r
-  EFI_ARP_PROTOCOL   *Arp;\r
-  EFI_TPL            OldTpl;\r
-\r
-  if ((This == NULL) || (ChildHandle == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  ArpService = ARP_SERVICE_DATA_FROM_THIS (This);\r
-\r
-  //\r
-  // Get the arp protocol.\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ChildHandle,\r
-                  &gEfiArpProtocolGuid,\r
-                  (VOID **)&Arp,\r
-                  ArpService->ImageHandle,\r
-                  ChildHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Instance = ARP_INSTANCE_DATA_FROM_THIS (Arp);\r
-\r
-  if (Instance->InDestroy) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Use the InDestroy as a flag to avoid re-entrance.\r
-  //\r
-  Instance->InDestroy = TRUE;\r
-\r
-  //\r
-  // Close the Managed Network protocol.\r
-  //\r
-  gBS->CloseProtocol (\r
-         ArpService->MnpChildHandle,\r
-         &gEfiManagedNetworkProtocolGuid,\r
-         gArpDriverBinding.DriverBindingHandle,\r
-         ChildHandle\r
-         );\r
-\r
-  //\r
-  // Uninstall the ARP protocol.\r
-  //\r
-  Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                  ChildHandle,\r
-                  &gEfiArpProtocolGuid,\r
-                  &Instance->ArpProto,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n",\r
-      Status));\r
-\r
-    Instance->InDestroy = FALSE;\r
-    return Status;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  if (Instance->Configured) {\r
-    //\r
-    // Delete the related cache entry.\r
-    //\r
-    ArpDeleteCacheEntry (Instance, FALSE, NULL, TRUE);\r
-\r
-    //\r
-    // Reset the instance configuration.\r
-    //\r
-    ArpConfigureInstance (Instance, NULL);\r
-  }\r
-\r
-  //\r
-  // Remove this instance from the ChildrenList.\r
-  //\r
-  RemoveEntryList (&Instance->List);\r
-  ArpService->ChildrenNumber--;\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  FreePool (Instance);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  The entry point for Arp driver which installs the driver binding and component name\r
-  protocol on its ImageHandle.\r
-\r
-  @param[in]  ImageHandle        The image handle of the driver.\r
-  @param[in]  SystemTable        The system table.\r
-\r
-  @retval EFI_SUCCESS            if the driver binding and component name protocols\r
-                                 are successfully\r
-  @retval Others                 Failed to install the protocols.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ArpDriverEntryPoint (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  return EfiLibInstallDriverBindingComponentName2 (\r
-           ImageHandle,\r
-           SystemTable,\r
-           &gArpDriverBinding,\r
-           ImageHandle,\r
-           &gArpComponentName,\r
-           &gArpComponentName2\r
-           );\r
-}\r
-\r