/** @file\r
Implementation of Managed Network Protocol private services.\r
\r
-Copyright (c) 2005 - 2009, Intel Corporation.<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
are licensed and made available under the terms and conditions\r
of the BSD License which accompanies this distribution. The full\r
text of the license may be found at<BR>\r
FALSE\r
};\r
\r
-\r
/**\r
Add Count of net buffers to MnpDeviceData->FreeNbufQue. The length of the net\r
buffer is specified by MnpDeviceData->BufferLength.\r
goto ERROR;\r
}\r
\r
+ //\r
+ // Create the timer for media detection.\r
+ //\r
+ Status = gBS->CreateEvent (\r
+ EVT_NOTIFY_SIGNAL | EVT_TIMER,\r
+ TPL_CALLBACK,\r
+ MnpCheckMediaStatus,\r
+ MnpDeviceData,\r
+ &MnpDeviceData->MediaDetectTimer\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "MnpInitializeDeviceData: CreateEvent for media detection failed.\n"));\r
+\r
+ goto ERROR;\r
+ }\r
+\r
//\r
// Create the timer for tx timeout check.\r
//\r
gBS->CloseEvent (MnpDeviceData->TimeoutCheckTimer);\r
}\r
\r
+ if (MnpDeviceData->MediaDetectTimer != NULL) {\r
+ gBS->CloseEvent (MnpDeviceData->MediaDetectTimer);\r
+ }\r
+\r
if (MnpDeviceData->PollTimer != NULL) {\r
gBS->CloseEvent (MnpDeviceData->PollTimer);\r
}\r
//\r
// Close the event.\r
//\r
- gBS->CloseEvent (&MnpDeviceData->TxTimeoutEvent);\r
- gBS->CloseEvent (&MnpDeviceData->TimeoutCheckTimer);\r
- gBS->CloseEvent (&MnpDeviceData->PollTimer);\r
+ gBS->CloseEvent (MnpDeviceData->TxTimeoutEvent);\r
+ gBS->CloseEvent (MnpDeviceData->TimeoutCheckTimer);\r
+ gBS->CloseEvent (MnpDeviceData->MediaDetectTimer);\r
+ gBS->CloseEvent (MnpDeviceData->PollTimer);\r
\r
//\r
// Free the tx buffer.\r
return Status;\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
+MnpDestoryChildEntry (\r
+ IN LIST_ENTRY *Entry,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ MNP_INSTANCE_DATA *Instance;\r
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
+\r
+ ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context;\r
+ Instance = CR (Entry, MNP_INSTANCE_DATA, InstEntry, MNP_INSTANCE_DATA_SIGNATURE);\r
+ return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);\r
+}\r
+\r
/**\r
Destroy all child of the MNP service data.\r
\r
IN OUT MNP_SERVICE_DATA *MnpServiceData\r
)\r
{\r
- EFI_STATUS Status;\r
- MNP_INSTANCE_DATA *Instance;\r
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
-\r
- ServiceBinding = &MnpServiceData->ServiceBinding;\r
- while (!IsListEmpty (&MnpServiceData->ChildrenList)) {\r
- //\r
- // Don't use NetListRemoveHead here, the remove opreration will be done\r
- // in ServiceBindingDestroyChild.\r
- //\r
- Instance = NET_LIST_HEAD (\r
- &MnpServiceData->ChildrenList,\r
- MNP_INSTANCE_DATA,\r
- InstEntry\r
- );\r
-\r
- Status = ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
+ LIST_ENTRY *List;\r
+ EFI_STATUS Status;\r
+ UINTN ListLength;\r
+ \r
+ List = &MnpServiceData->ChildrenList;\r
+ \r
+ Status = NetDestroyLinkList (\r
+ List,\r
+ MnpDestoryChildEntry,\r
+ &MnpServiceData->ServiceBinding,\r
+ &ListLength\r
+ );\r
+ if (EFI_ERROR (Status) || ListLength != 0) {\r
+ return EFI_DEVICE_ERROR;\r
}\r
\r
return EFI_SUCCESS;\r
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
MnpTokenExist (\r
IN NET_MAP *Map,\r
IN NET_MAP_ITEM *Item,\r
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
MnpCancelTokens (\r
IN OUT NET_MAP *Map,\r
IN OUT NET_MAP_ITEM *Item,\r
\r
goto ErrorExit;\r
}\r
+\r
+ //\r
+ // Start the media detection timer.\r
+ //\r
+ Status = gBS->SetTimer (\r
+ MnpDeviceData->MediaDetectTimer,\r
+ TimerPeriodic,\r
+ MNP_MEDIA_DETECT_INTERVAL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG (\r
+ (EFI_D_ERROR,\r
+ "MnpStart, gBS->SetTimer for MediaDetectTimer %r.\n",\r
+ Status)\r
+ );\r
+\r
+ goto ErrorExit;\r
+ }\r
}\r
}\r
\r
//\r
Status = gBS->SetTimer (MnpDeviceData->TimeoutCheckTimer, TimerCancel, 0);\r
\r
+ //\r
+ // Cancel the media detect timer.\r
+ //\r
+ Status = gBS->SetTimer (MnpDeviceData->MediaDetectTimer, TimerCancel, 0);\r
+\r
//\r
// Stop the simple network.\r
//\r