/** @file\r
-\r
-Copyright (c) 2006, Intel Corporation\r
+ Abstract:\r
+ \r
+Copyright (c) 2006 - 2008, Intel Corporation.<BR>\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
+which accompanies this distribution. The full text of the license may be found at<BR>\r
http://opensource.org/licenses/bsd-license.php\r
\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
-Module Name:\r
-\r
- ArpDriver.c\r
-\r
-Abstract:\r
-\r
-\r
**/\r
\r
-\r
#include "ArpDriver.h"\r
#include "ArpImpl.h"\r
\r
/**\r
Create and initialize the arp service context data.\r
\r
- @param ImageHandle The image handle representing the loaded driver\r
- image.\r
- @param ControllerHandle The controller handle the driver binds to.\r
- @param ArpService Pointer to the buffer containing the arp service\r
- context data.\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] ArpService Pointer to the buffer containing the arp service\r
+ context data.\r
\r
- @retval EFI_SUCCESS The arp service context is initialized.\r
- @retval other Failed to initialize the arp service context.\r
+ @retval EFI_SUCCESS The arp service context is initialized.\r
+ @retval other Failed to initialize the arp service context.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
ArpCreateService (\r
IN EFI_HANDLE ImageHandle,\r
//\r
Status = gBS->CreateEvent (\r
EVT_NOTIFY_SIGNAL,\r
- NET_TPL_EVENT,\r
+ TPL_NOTIFY,\r
ArpOnFrameRcvd,\r
ArpService,\r
&ArpService->RxToken.Event\r
//\r
Status = gBS->CreateEvent (\r
EVT_NOTIFY_SIGNAL | EVT_TIMER,\r
- NET_TPL_TIMER,\r
+ TPL_CALLBACK,\r
ArpTimerHandler,\r
ArpService,\r
&ArpService->PeriodicTimer\r
goto ERROR_EXIT;\r
}\r
\r
- //\r
- // Init the lock.\r
- //\r
- NET_LOCK_INIT (&ArpService->Lock);\r
-\r
//\r
// Init the lists.\r
//\r
- NetListInit (&ArpService->ChildrenList);\r
- NetListInit (&ArpService->PendingRequestTable);\r
- NetListInit (&ArpService->DeniedCacheTable);\r
- NetListInit (&ArpService->ResolvedCacheTable);\r
+ InitializeListHead (&ArpService->ChildrenList);\r
+ InitializeListHead (&ArpService->PendingRequestTable);\r
+ InitializeListHead (&ArpService->DeniedCacheTable);\r
+ InitializeListHead (&ArpService->ResolvedCacheTable);\r
\r
ERROR_EXIT:\r
\r
/**\r
Clean the arp service context data.\r
\r
- @param ArpService Pointer to the buffer containing the arp service\r
- context data.\r
+ @param[in] ArpService Pointer to the buffer containing the arp service\r
+ context data.\r
\r
@return None.\r
\r
**/\r
-STATIC\r
VOID\r
ArpCleanService (\r
IN ARP_SERVICE_DATA *ArpService\r
}\r
}\r
\r
-\r
/**\r
Test to see if this driver supports ControllerHandle.\r
-\r
- @param This Protocol instance pointer.\r
- @param ControllerHandle Handle of device to test.\r
- @param RemainingDevicePath Optional parameter use to pick a specific child\r
- device to start.\r
-\r
- @retval EFI_SUCCES This driver supports this device\r
- @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
- @retval other This driver does not support this device.\r
+ \r
+ This service is called by the EFI boot service ConnectController(). In\r
+ order to make drivers as small as possible, there are a few calling\r
+ restrictions for this service. ConnectController() must\r
+ follow these calling restrictions. If any other agent wishes to call\r
+ Supported() it must also follow these calling restrictions.\r
+ \r
+ @param[in] This Protocol instance pointer.\r
+ @param[in] ControllerHandle Handle of device to test.\r
+ @param[in] RemainingDevicePath Optional parameter use to pick a specific child\r
+ device to start.\r
+\r
+ @retval EFI_SUCCES This driver supports this device\r
+ @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
+ @retval other This driver does not support this device.\r
\r
**/\r
EFI_STATUS\r
\r
/**\r
Start this driver on ControllerHandle.\r
-\r
- @param This Protocol instance pointer.\r
- @param ControllerHandle Handle of device to bind driver to\r
- @param RemainingDevicePath Optional parameter use to pick a specific child\r
- device to start.\r
-\r
- @retval EFI_SUCCES This driver is added to ControllerHandle\r
- @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
- @retval other This driver does not support this device\r
+ \r
+ This service is called by the EFI boot service ConnectController(). In order to make\r
+ drivers as small as possible, there are a few calling restrictions for\r
+ this service. ConnectController() must follow these\r
+ calling restrictions. If any other agent wishes to call Start() it\r
+ must also follow these calling restrictions.\r
+\r
+ @param[in] This Protocol instance pointer.\r
+ @param[in] ControllerHandle Handle of device to bind driver to.\r
+ @param[in] RemainingDevicePath Optional parameter use to pick a specific child\r
+ device to start.\r
+\r
+ @retval EFI_SUCCES This driver is added to ControllerHandle.\r
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r
+ @retval other This driver does not support this device.\r
\r
**/\r
EFI_STATUS\r
//\r
// Allocate a zero pool for ArpService.\r
//\r
- ArpService = NetAllocateZeroPool (sizeof(ARP_SERVICE_DATA));\r
+ ArpService = AllocateZeroPool (sizeof(ARP_SERVICE_DATA));\r
if (ArpService == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
// On error, clean the arp service context data, and free the memory allocated.\r
//\r
ArpCleanService (ArpService);\r
- NetFreePool (ArpService);\r
+ gBS->FreePool (ArpService);\r
\r
return Status;\r
}\r
\r
/**\r
Stop this driver on ControllerHandle.\r
-\r
- @param This Protocol instance pointer.\r
- @param ControllerHandle Handle of device to stop driver on\r
- @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number\r
- of children is zero stop the entire bus driver.\r
- @param ChildHandleBuffer List of Child Handles to Stop.\r
-\r
- @retval EFI_SUCCES This driver is removed ControllerHandle\r
- @retval other This driver was not removed from this device\r
+ \r
+ This service is called by the EFI boot service DisconnectController(). In order to\r
+ make drivers as small as possible, there are a few calling\r
+ restrictions for this service. DisconnectController()\r
+ must follow these calling restrictions. If any other agent wishes\r
+ to call Stop() it must also follow these calling restrictions.\r
+ \r
+ @param[in] This Protocol instance pointer.\r
+ @param[in] ControllerHandle Handle of device to stop driver on\r
+ @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number\r
+ of children is zero stop the entire bus driver.\r
+ @param[in] ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+ @retval EFI_SUCCES This driver is removed ControllerHandle\r
+ @retval other This driver was not removed from this device\r
\r
**/\r
EFI_STATUS\r
//\r
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);\r
if (NicHandle == NULL) {\r
- return EFI_SUCCESS;\r
+ return EFI_DEVICE_ERROR;\r
}\r
\r
//\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
);\r
if (EFI_ERROR (Status)) {\r
- ARP_DEBUG_ERROR (("ArpDriverBindingStop: Open ArpSb failed, %r.\n", Status));\r
- return 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
- while (!NetListIsEmpty (&ArpService->ChildrenList)) {\r
+ if (NumberOfChildren == 0) {\r
//\r
- // Iterate all the instances.\r
+ // Uninstall the ARP ServiceBinding protocol.\r
//\r
- Instance = NET_LIST_HEAD (&ArpService->ChildrenList, ARP_INSTANCE_DATA, List);\r
+ gBS->UninstallMultipleProtocolInterfaces (\r
+ NicHandle,\r
+ &gEfiArpServiceBindingProtocolGuid,\r
+ &ArpService->ServiceBinding,\r
+ NULL\r
+ );\r
\r
//\r
- // Destroy this arp child.\r
+ // Clean the arp servicebinding context data and free the memory allocated.\r
//\r
- ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);\r
- }\r
+ ArpCleanService (ArpService);\r
\r
- ASSERT (NetListIsEmpty (&ArpService->PendingRequestTable));\r
- ASSERT (NetListIsEmpty (&ArpService->DeniedCacheTable));\r
- ASSERT (NetListIsEmpty (&ArpService->ResolvedCacheTable));\r
+ gBS->FreePool (ArpService);\r
+ } else {\r
\r
- //\r
- // Uninstall the ARP ServiceBinding protocol.\r
- //\r
- Status = gBS->UninstallMultipleProtocolInterfaces (\r
- NicHandle,\r
- &gEfiArpServiceBindingProtocolGuid,\r
- &ArpService->ServiceBinding,\r
- NULL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- ARP_DEBUG_ERROR (("ArpDriverBindingStop: Failed to uninstall ArpSb, %r.\n", Status));\r
- return Status;\r
- }\r
+ while (!IsListEmpty (&ArpService->ChildrenList)) {\r
+ Instance = NET_LIST_HEAD (&ArpService->ChildrenList, ARP_INSTANCE_DATA, List);\r
\r
- //\r
- // Clean the arp servicebinding context data and free the memory allocated.\r
- //\r
- ArpCleanService (ArpService);\r
- NetFreePool (ArpService);\r
+ ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);\r
+ }\r
\r
- return Status;\r
-}\r
+ ASSERT (IsListEmpty (&ArpService->PendingRequestTable));\r
+ ASSERT (IsListEmpty (&ArpService->DeniedCacheTable));\r
+ ASSERT (IsListEmpty (&ArpService->ResolvedCacheTable));\r
+ }\r
\r
+ return EFI_SUCCESS;\r
+}\r
\r
/**\r
Creates a child handle with a set of I/O services.\r
\r
- @param This Protocol instance pointer.\r
- @param ChildHandle Pointer to the handle of the child to create. If\r
- it is NULL, then a new handle is created. If it is\r
- not NULL, then the I/O services are added to the\r
- existing child handle.\r
+ @param[in] This Protocol instance pointer.\r
+ @param[in] ChildHandle Pointer to the handle of the child to create. If\r
+ it is NULL, then a new handle is created. If it is\r
+ not NULL, then the I/O services are added to the\r
+ existing child handle.\r
\r
- @retval EFI_SUCCES The child handle was created with the I/O\r
- services.\r
- @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r
- the child.\r
- @retval other The child handle was not created.\r
+ @retval EFI_SUCCES The child handle was created with the I/O\r
+ services.\r
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r
+ the child.\r
+ @retval other The child handle was not created.\r
\r
**/\r
EFI_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
// Allocate memory for the instance context data.\r
//\r
- Instance = NetAllocateZeroPool (sizeof(ARP_INSTANCE_DATA));\r
+ Instance = AllocateZeroPool (sizeof(ARP_INSTANCE_DATA));\r
if (Instance == NULL) {\r
- ARP_DEBUG_ERROR (("ArpSBCreateChild: Failed to allocate memory for Instance.\n"));\r
+ DEBUG ((EFI_D_ERROR, "ArpSBCreateChild: Failed to allocate memory for Instance.\n"));\r
\r
return EFI_OUT_OF_RESOURCES;\r
}\r
NULL\r
);\r
if (EFI_ERROR (Status)) {\r
- ARP_DEBUG_ERROR (("ArpSBCreateChild: faild to install ARP protocol, %r.\n", Status));\r
+ DEBUG ((EFI_D_ERROR, "ArpSBCreateChild: faild to install ARP protocol, %r.\n", Status));\r
\r
- NetFreePool (Instance);\r
+ gBS->FreePool (Instance);\r
return Status;\r
}\r
\r
goto ERROR;\r
}\r
\r
- if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {\r
-\r
- Status = EFI_ACCESS_DENIED;\r
- goto ERROR;\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
- NetListInsertTail (&ArpService->ChildrenList, &Instance->List);\r
+ InsertTailList (&ArpService->ChildrenList, &Instance->List);\r
ArpService->ChildrenNumber++;\r
\r
- NET_UNLOCK (&ArpService->Lock);\r
+ gBS->RestoreTPL (OldTpl);\r
\r
ERROR:\r
\r
//\r
// Free the allocated memory.\r
//\r
- NetFreePool (Instance);\r
+ gBS->FreePool (Instance);\r
}\r
\r
return Status;\r
/**\r
Destroys a child handle with a set of I/O services.\r
\r
- @param This Protocol instance pointer.\r
- @param ChildHandle Handle of the child to destroy.\r
+ @param[in] This Protocol instance pointer.\r
+ @param[in] ChildHandle Handle of the child to destroy.\r
\r
- @retval EFI_SUCCES The I/O services were removed from the child\r
- handle.\r
- @retval EFI_UNSUPPORTED The child handle does not support the I/O services\r
- that are being removed.\r
- @retval EFI_INVALID_PARAMETER Child handle is not a valid EFI Handle.\r
- @retval EFI_ACCESS_DENIED The child handle could not be destroyed because\r
- its I/O services are being used.\r
- @retval other The child handle was not destroyed.\r
+ @retval EFI_SUCCES The I/O services were removed from the child\r
+ handle.\r
+ @retval EFI_UNSUPPORTED The child handle does not support the I/O services\r
+ that are being removed.\r
+ @retval EFI_INVALID_PARAMETER Child handle is not a valid EFI Handle.\r
+ @retval EFI_ACCESS_DENIED The child handle could not be destroyed because\r
+ its I/O services are being used.\r
+ @retval other The child handle was not destroyed.\r
\r
**/\r
EFI_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
NULL\r
);\r
if (EFI_ERROR (Status)) {\r
- ARP_DEBUG_ERROR (("ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n",\r
+ DEBUG ((EFI_D_ERROR, "ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n",\r
Status));\r
\r
Instance->Destroyed = FALSE;\r
return Status;\r
}\r
\r
- if (EFI_ERROR (NET_TRYLOCK (&ArpService->Lock))) {\r
- Instance->Destroyed = FALSE;\r
- return EFI_ACCESS_DENIED;\r
- }\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
if (Instance->Configured) {\r
//\r
//\r
// Remove this instance from the ChildrenList.\r
//\r
- NetListRemoveEntry (&Instance->List);\r
+ RemoveEntryList (&Instance->List);\r
ArpService->ChildrenNumber--;\r
\r
- NET_UNLOCK (&ArpService->Lock);\r
+ gBS->RestoreTPL (OldTpl);\r
\r
- NetFreePool (Instance);\r
+ gBS->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_SUCCES if the driver binding and component name protocols 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
-\r
-Routine Description:\r
-\r
- The entry point for Arp driver which installs the driver binding and component name\r
- protocol on its ImageHandle.\r
-\r
-Arguments:\r
-\r
- ImageHandle - The image handle of the driver.\r
- SystemTable - The system table.\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - if the driver binding and component name protocols are successfully\r
- installed, otherwise if failed.\r
-\r
---*/\r
{\r
- return EfiLibInstallAllDriverProtocols (\r
+ return EfiLibInstallDriverBindingComponentName2 (\r
ImageHandle,\r
SystemTable,\r
&gArpDriverBinding,\r
ImageHandle,\r
&gArpComponentName,\r
- NULL,\r
- NULL\r
+ &gArpComponentName2\r
);\r
}\r
\r