X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FArpDxe%2FArpDriver.c;h=37042d11cd1ebfa6dcc2253307011ab344e30e9a;hp=aa99ff5b51f001ddf78503a149c01498b7eddaf3;hb=284ee2e829ab2453293b7dc4539727ad6c047163;hpb=c4a62a12c2890297cfcb9828b51b058fb347c01a diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c b/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c index aa99ff5b51..37042d11cd 100644 --- a/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c +++ b/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c @@ -1,24 +1,17 @@ /** @file - -Copyright (c) 2006 - 2007, Intel Corporation -All rights reserved. This program and the accompanying materials + ARP driver functions. + +Copyright (c) 2006 - 2011, 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 +which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -Module Name: - - ArpDriver.c - -Abstract: - - **/ - #include "ArpDriver.h" #include "ArpImpl.h" @@ -35,22 +28,24 @@ EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding = { /** Create and initialize the arp service context data. - @param ImageHandle The image handle representing the loaded driver - image. - @param ControllerHandle The controller handle the driver binds to. - @param ArpService Pointer to the buffer containing the arp service - context data. + @param[in] ImageHandle The image handle representing the loaded driver + image. + @param[in] ControllerHandle The controller handle the driver binds to. + @param[in, out] ArpService Pointer to the buffer containing the arp service + context data. - @retval EFI_SUCCESS The arp service context is initialized. - @retval other Failed to initialize the arp service context. + @retval EFI_SUCCESS The arp service context is initialized. + + @retval EFI_UNSUPPORTED The underlayer Snp mode type is not ethernet. + Failed to initialize the service context. + @retval other Failed to initialize the arp service context. **/ -STATIC EFI_STATUS ArpCreateService ( IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ControllerHandle, - IN ARP_SERVICE_DATA *ArpService + IN OUT ARP_SERVICE_DATA *ArpService ) { EFI_STATUS Status; @@ -59,6 +54,14 @@ ArpCreateService ( ArpService->Signature = ARP_SERVICE_DATA_SIGNATURE; + // + // Init the lists. + // + InitializeListHead (&ArpService->ChildrenList); + InitializeListHead (&ArpService->PendingRequestTable); + InitializeListHead (&ArpService->DeniedCacheTable); + InitializeListHead (&ArpService->ResolvedCacheTable); + // // Init the servicebinding protocol members. // @@ -142,7 +145,7 @@ ArpCreateService ( // Status = gBS->CreateEvent ( EVT_NOTIFY_SIGNAL, - NET_TPL_EVENT, + TPL_NOTIFY, ArpOnFrameRcvd, ArpService, &ArpService->RxToken.Event @@ -156,7 +159,7 @@ ArpCreateService ( // Status = gBS->CreateEvent ( EVT_NOTIFY_SIGNAL | EVT_TIMER, - NET_TPL_TIMER, + TPL_CALLBACK, ArpTimerHandler, ArpService, &ArpService->PeriodicTimer @@ -173,17 +176,6 @@ ArpCreateService ( TimerPeriodic, ARP_PERIODIC_TIMER_INTERVAL ); - if (EFI_ERROR (Status)) { - goto ERROR_EXIT; - } - - // - // Init the lists. - // - NetListInit (&ArpService->ChildrenList); - NetListInit (&ArpService->PendingRequestTable); - NetListInit (&ArpService->DeniedCacheTable); - NetListInit (&ArpService->ResolvedCacheTable); ERROR_EXIT: @@ -194,16 +186,15 @@ ERROR_EXIT: /** Clean the arp service context data. - @param ArpService Pointer to the buffer containing the arp service - context data. + @param[in, out] ArpService Pointer to the buffer containing the arp service + context data. @return None. **/ -STATIC VOID ArpCleanService ( - IN ARP_SERVICE_DATA *ArpService + IN OUT ARP_SERVICE_DATA *ArpService ) { NET_CHECK_SIGNATURE (ArpService, ARP_SERVICE_DATA_SIGNATURE); @@ -250,18 +241,33 @@ ArpCleanService ( } } - /** - Test to see if this driver supports ControllerHandle. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to test. - @param RemainingDevicePath Optional parameter use to pick a specific child - device to start. - - @retval EFI_SUCCES This driver supports this device - @retval EFI_ALREADY_STARTED This driver is already running on this device. - @retval other This driver does not support this device. + Tests to see if this driver supports a given controller. + + If a child device is provided, it further tests to see if this driver supports + creating a handle for the specified child device. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle The handle of the controller to test. This handle + must support a protocol interface that supplies + an I/O abstraction to the driver. + @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. + This parameter is ignored by device drivers, + and is optional for bus drivers. + + @retval EFI_SUCCESS The device specified by ControllerHandle and + RemainingDevicePath is supported by the driver + specified by This. + @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and + RemainingDevicePath is already being managed + by the driver specified by This. + @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and + RemainingDevicePath is already being managed by + a different driver or an application that + requires exclusive acces. Currently not implemented. + @retval EFI_UNSUPPORTED The device specified by ControllerHandle and + RemainingDevicePath is not supported by the + driver specified by This. **/ EFI_STATUS @@ -306,16 +312,34 @@ ArpDriverBindingSupported ( /** - Start this driver on ControllerHandle. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to bind driver to - @param RemainingDevicePath Optional parameter use to pick a specific child - device to start. - - @retval EFI_SUCCES This driver is added to ControllerHandle - @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle - @retval other This driver does not support this device + Start this driver on ControllerHandle. + + The Start() function is designed to be invoked from the EFI boot service ConnectController(). + As a result, much of the error checking on the parameters to Start() has been + moved into this common boot service. It is legal to call Start() from other locations, + but the following calling restrictions must be followed or the system behavior + will not be deterministic. + 1. ControllerHandle must be a valid EFI_HANDLE. + 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally + aligned EFI_DEVICE_PATH_PROTOCOL. + 3. Prior to calling Start(), the Supported() function for the driver specified + by This must have been called with the same calling parameters, and Supported() + must have returned EFI_SUCCESS. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle The handle of the controller to start. This handle + must support a protocol interface that supplies + an I/O abstraction to the driver. + @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. + This parameter is ignored by device drivers, + and is optional for bus drivers. + + @retval EFI_SUCCESS The device was started. + @retval EFI_DEVICE_ERROR The device could not be started due to a device error. + Currently not implemented. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of + resources. + @retval Others The driver failded to start the device. **/ EFI_STATUS @@ -332,7 +356,7 @@ ArpDriverBindingStart ( // // Allocate a zero pool for ArpService. // - ArpService = NetAllocateZeroPool (sizeof(ARP_SERVICE_DATA)); + ArpService = AllocateZeroPool (sizeof(ARP_SERVICE_DATA)); if (ArpService == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -374,23 +398,39 @@ ERROR: // On error, clean the arp service context data, and free the memory allocated. // ArpCleanService (ArpService); - NetFreePool (ArpService); + FreePool (ArpService); return Status; } /** - Stop this driver on ControllerHandle. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to stop driver on - @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number - of children is zero stop the entire bus driver. - @param ChildHandleBuffer List of Child Handles to Stop. - - @retval EFI_SUCCES This driver is removed ControllerHandle - @retval other This driver was not removed from this device + Stop this driver on ControllerHandle. + + Release the control of this controller and remove the IScsi functions. The Stop() + function is designed to be invoked from the EFI boot service DisconnectController(). + As a result, much of the error checking on the parameters to Stop() has been moved + into this common boot service. It is legal to call Stop() from other locations, + but the following calling restrictions must be followed or the system behavior + will not be deterministic. + 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this + same driver's Start() function. + 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid + EFI_HANDLE. In addition, all of these handles must have been created in this driver's + Start() function, and the Start() function must have called OpenProtocol() on + ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle A handle to the device being stopped. The handle must + support a bus specific I/O protocol for the driver + to use to stop the device. + @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. + Not used. + @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL + if NumberOfChildren is 0.Not used. + + @retval EFI_SUCCESS The device was stopped. + @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. **/ EFI_STATUS @@ -428,7 +468,7 @@ ArpDriverBindingStop ( EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { - ARP_DEBUG_ERROR (("ArpDriverBindingStop: Open ArpSb failed, %r.\n", Status)); + DEBUG ((EFI_D_ERROR, "ArpDriverBindingStop: Open ArpSb failed, %r.\n", Status)); return EFI_DEVICE_ERROR; } @@ -450,37 +490,41 @@ ArpDriverBindingStop ( // ArpCleanService (ArpService); - NetFreePool (ArpService); + FreePool (ArpService); } else { - while (!NetListIsEmpty (&ArpService->ChildrenList)) { + while (!IsListEmpty (&ArpService->ChildrenList)) { Instance = NET_LIST_HEAD (&ArpService->ChildrenList, ARP_INSTANCE_DATA, List); ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); } - ASSERT (NetListIsEmpty (&ArpService->PendingRequestTable)); - ASSERT (NetListIsEmpty (&ArpService->DeniedCacheTable)); - ASSERT (NetListIsEmpty (&ArpService->ResolvedCacheTable)); + ASSERT (IsListEmpty (&ArpService->PendingRequestTable)); + ASSERT (IsListEmpty (&ArpService->DeniedCacheTable)); + ASSERT (IsListEmpty (&ArpService->ResolvedCacheTable)); } return EFI_SUCCESS; } /** - Creates a child handle with a set of I/O services. - - @param This Protocol instance pointer. - @param ChildHandle Pointer to the handle of the child to create. If - it is NULL, then a new handle is created. If it is - not NULL, then the I/O services are added to the - existing child handle. - - @retval EFI_SUCCES The child handle was created with the I/O - services. - @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create - the child. - @retval other The child handle was not created. + Creates a child handle and installs a protocol. + + The CreateChild() function installs a protocol on ChildHandle. + If ChildHandle is a pointer to NULL, then a new handle is created and returned + in ChildHandle. If ChildHandle is not a pointer to NULL, then the protocol + installs on the existing ChildHandle. + + @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance. + @param ChildHandle Pointer to the handle of the child to create. If it is NULL, + then a new handle is created. If it is a pointer to an existing + UEFI handle, then the protocol is added to the existing UEFI handle. + + @retval EFI_SUCCES The protocol was added to ChildHandle. + @retval EFI_INVALID_PARAMETER ChildHandle is NULL. + @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create + the child + @retval other The child handle was not created **/ EFI_STATUS @@ -505,9 +549,9 @@ ArpServiceBindingCreateChild ( // // Allocate memory for the instance context data. // - Instance = NetAllocateZeroPool (sizeof(ARP_INSTANCE_DATA)); + Instance = AllocateZeroPool (sizeof(ARP_INSTANCE_DATA)); if (Instance == NULL) { - ARP_DEBUG_ERROR (("ArpSBCreateChild: Failed to allocate memory for Instance.\n")); + DEBUG ((EFI_D_ERROR, "ArpSBCreateChild: Failed to allocate memory for Instance.\n")); return EFI_OUT_OF_RESOURCES; } @@ -527,9 +571,9 @@ ArpServiceBindingCreateChild ( NULL ); if (EFI_ERROR (Status)) { - ARP_DEBUG_ERROR (("ArpSBCreateChild: faild to install ARP protocol, %r.\n", Status)); + DEBUG ((EFI_D_ERROR, "ArpSBCreateChild: faild to install ARP protocol, %r.\n", Status)); - NetFreePool (Instance); + FreePool (Instance); return Status; } @@ -553,15 +597,15 @@ ArpServiceBindingCreateChild ( goto ERROR; } - OldTpl = NET_RAISE_TPL (NET_TPL_LOCK); + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); // // Insert the instance into children list managed by the arp service context data. // - NetListInsertTail (&ArpService->ChildrenList, &Instance->List); + InsertTailList (&ArpService->ChildrenList, &Instance->List); ArpService->ChildrenNumber++; - NET_RESTORE_TPL (OldTpl); + gBS->RestoreTPL (OldTpl); ERROR: @@ -584,7 +628,7 @@ ERROR: // // Free the allocated memory. // - NetFreePool (Instance); + FreePool (Instance); } return Status; @@ -592,19 +636,22 @@ ERROR: /** - Destroys a child handle with a set of I/O services. - - @param This Protocol instance pointer. - @param ChildHandle Handle of the child to destroy. - - @retval EFI_SUCCES The I/O services were removed from the child - handle. - @retval EFI_UNSUPPORTED The child handle does not support the I/O services - that are being removed. - @retval EFI_INVALID_PARAMETER Child handle is not a valid EFI Handle. - @retval EFI_ACCESS_DENIED The child handle could not be destroyed because - its I/O services are being used. - @retval other The child handle was not destroyed. + Destroys a child handle with a protocol installed on it. + + The DestroyChild() function does the opposite of CreateChild(). It removes a protocol + that was installed by CreateChild() from ChildHandle. If the removed protocol is the + last protocol on ChildHandle, then ChildHandle is destroyed. + + @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance. + @param ChildHandle Handle of the child to destroy + + @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 Child handle is NULL. + @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle + because its services are being used. + @retval other The child handle was not destroyed **/ EFI_STATUS @@ -672,14 +719,14 @@ ArpServiceBindingDestroyChild ( NULL ); if (EFI_ERROR (Status)) { - ARP_DEBUG_ERROR (("ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n", + DEBUG ((EFI_D_ERROR, "ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n", Status)); Instance->Destroyed = FALSE; return Status; } - OldTpl = NET_RAISE_TPL (NET_TPL_LOCK); + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); if (Instance->Configured) { // @@ -696,41 +743,34 @@ ArpServiceBindingDestroyChild ( // // Remove this instance from the ChildrenList. // - NetListRemoveEntry (&Instance->List); + RemoveEntryList (&Instance->List); ArpService->ChildrenNumber--; - NET_RESTORE_TPL (OldTpl); + gBS->RestoreTPL (OldTpl); - NetFreePool (Instance); + FreePool (Instance); return Status; } +/** + The entry point for Arp driver which installs the driver binding and component name + protocol on its ImageHandle. + + @param[in] ImageHandle The image handle of the driver. + @param[in] SystemTable The system table. + + @retval EFI_SUCCESS if the driver binding and component name protocols + are successfully + @retval Others Failed to install the protocols. +**/ EFI_STATUS EFIAPI ArpDriverEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) -/*++ - -Routine Description: - - The entry point for Arp driver which installs the driver binding and component name - protocol on its ImageHandle. - -Arguments: - - ImageHandle - The image handle of the driver. - SystemTable - The system table. - -Returns: - - EFI_SUCCESS - if the driver binding and component name protocols are successfully - installed, otherwise if failed. - ---*/ { return EfiLibInstallDriverBindingComponentName2 ( ImageHandle,