/** @file\r
Implementation of Mtftp drivers.\r
\r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
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
MtftpSb->ChildrenNum = 0;\r
InitializeListHead (&MtftpSb->Children);\r
\r
- MtftpSb->Timer = NULL;\r
- MtftpSb->TimerToGetMap = NULL;\r
- MtftpSb->Controller = Controller;\r
- MtftpSb->Image = Image;\r
- MtftpSb->ConnectUdp = NULL;\r
+ MtftpSb->Timer = NULL;\r
+ MtftpSb->TimerNotifyLevel = NULL;\r
+ MtftpSb->TimerToGetMap = NULL;\r
+ MtftpSb->Controller = Controller;\r
+ MtftpSb->Image = Image;\r
+ MtftpSb->ConnectUdp = NULL;\r
\r
//\r
// Create the timer and a udp to be notified when UDP is uninstalled\r
MtftpSb,\r
&MtftpSb->Timer\r
);\r
+ if (EFI_ERROR (Status)) {\r
+ FreePool (MtftpSb);\r
+ return Status;\r
+ }\r
\r
+ Status = gBS->CreateEvent (\r
+ EVT_NOTIFY_SIGNAL | EVT_TIMER,\r
+ TPL_NOTIFY,\r
+ Mtftp4OnTimerTickNotifyLevel,\r
+ MtftpSb,\r
+ &MtftpSb->TimerNotifyLevel\r
+ );\r
if (EFI_ERROR (Status)) {\r
+ gBS->CloseEvent (MtftpSb->Timer);\r
FreePool (MtftpSb);\r
return Status;\r
}\r
&MtftpSb->TimerToGetMap\r
);\r
if (EFI_ERROR (Status)) {\r
+ gBS->CloseEvent (MtftpSb->TimerNotifyLevel);\r
gBS->CloseEvent (MtftpSb->Timer);\r
FreePool (MtftpSb);\r
return Status;\r
\r
if (MtftpSb->ConnectUdp == NULL) {\r
gBS->CloseEvent (MtftpSb->TimerToGetMap);\r
+ gBS->CloseEvent (MtftpSb->TimerNotifyLevel);\r
gBS->CloseEvent (MtftpSb->Timer);\r
FreePool (MtftpSb);\r
return EFI_DEVICE_ERROR;\r
{\r
UdpIoFreeIo (MtftpSb->ConnectUdp);\r
gBS->CloseEvent (MtftpSb->TimerToGetMap);\r
+ gBS->CloseEvent (MtftpSb->TimerNotifyLevel);\r
gBS->CloseEvent (MtftpSb->Timer);\r
}\r
\r
goto ON_ERROR;\r
}\r
\r
+ Status = gBS->SetTimer (MtftpSb->TimerNotifyLevel, TimerPeriodic, TICKS_PER_SECOND);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ goto ON_ERROR;\r
+ }\r
+ \r
//\r
// Install the Mtftp4ServiceBinding Protocol onto Controller\r
//\r
{\r
MTFTP4_PROTOCOL *Instance;\r
EFI_UDP4_PROTOCOL *Udp;\r
+ EFI_STATUS Status;\r
\r
if (This == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
Udp = Instance->UnicastPort->Protocol.Udp4;\r
- return Udp->Poll (Udp);\r
+ Status = Udp->Poll (Udp);\r
+ Mtftp4OnTimerTick (NULL, Instance->Service);\r
+ return Status;\r
}\r
\r
EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate = {\r
RFC2348 - TFTP Blocksize Option\r
RFC2349 - TFTP Timeout Interval and Transfer Size Options\r
\r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
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
UINT16 ChildrenNum;\r
LIST_ENTRY Children;\r
\r
- EFI_EVENT Timer; ///< Ticking timer for all the MTFTP clients\r
+ EFI_EVENT Timer; ///< Ticking timer for all the MTFTP clients to handle the packet timeout case.\r
+ EFI_EVENT TimerNotifyLevel; ///< Ticking timer for all the MTFTP clients to calculate the packet live time.\r
EFI_EVENT TimerToGetMap;\r
\r
EFI_HANDLE Controller;\r
//\r
NET_BUF *LastPacket;\r
UINT32 PacketToLive;\r
+ BOOLEAN HasTimeout;\r
UINT32 CurRetry;\r
UINT32 MaxRetry;\r
UINT32 Timeout;\r
/** @file\r
Support routines for Mtftp.\r
\r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
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
}\r
\r
\r
+/**\r
+ The timer ticking function in TPL_NOTIFY level for the Mtftp service instance.\r
+\r
+ @param Event The ticking event\r
+ @param Context The Mtftp service instance\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+Mtftp4OnTimerTickNotifyLevel (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ MTFTP4_SERVICE *MtftpSb;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
+ MTFTP4_PROTOCOL *Instance;\r
+\r
+ MtftpSb = (MTFTP4_SERVICE *) Context;\r
+\r
+ //\r
+ // Iterate through all the children of the Mtftp service instance. Time\r
+ // out the current packet transmit.\r
+ //\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &MtftpSb->Children) {\r
+ Instance = NET_LIST_USER_STRUCT (Entry, MTFTP4_PROTOCOL, Link);\r
+ if ((Instance->PacketToLive == 0) || (--Instance->PacketToLive > 0)) {\r
+ Instance->HasTimeout = FALSE;\r
+ } else {\r
+ Instance->HasTimeout = TRUE;\r
+ }\r
+ }\r
+}\r
+\r
+\r
/**\r
The timer ticking function for the Mtftp service instance.\r
\r
MtftpSb = (MTFTP4_SERVICE *) Context;\r
\r
//\r
- // Iterate through all the children of the Mtftp service instance. Time\r
- // out the packet. If maximum retries reached, clean the session up.\r
+ // Iterate through all the children of the Mtftp service instance.\r
//\r
NET_LIST_FOR_EACH_SAFE (Entry, Next, &MtftpSb->Children) {\r
Instance = NET_LIST_USER_STRUCT (Entry, MTFTP4_PROTOCOL, Link);\r
-\r
- if ((Instance->PacketToLive == 0) || (--Instance->PacketToLive > 0)) {\r
+ if (!Instance->HasTimeout) {\r
continue;\r
}\r
+ \r
+ Instance->HasTimeout = FALSE;\r
\r
//\r
// Call the user's time out handler\r
//\r
Token = Instance->Token;\r
\r
- if ((Token->TimeoutCallback != NULL) &&\r
+ if (Token != NULL && Token->TimeoutCallback != NULL &&\r
EFI_ERROR (Token->TimeoutCallback (&Instance->Mtftp4, Token))) {\r
-\r
Mtftp4SendError (\r
- Instance,\r
- EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,\r
- (UINT8 *) "User aborted the transfer in time out"\r
- );\r
+ Instance,\r
+ EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,\r
+ (UINT8 *) "User aborted the transfer in time out"\r
+ );\r
\r
Mtftp4CleanOperation (Instance, EFI_ABORTED);\r
continue;\r
/** @file\r
Support routines for MTFTP.\r
\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
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
IN MTFTP4_PROTOCOL *Instance\r
);\r
\r
+/**\r
+ The timer ticking function in TPL_NOTIFY level for the Mtftp service instance.\r
+\r
+ @param Event The ticking event\r
+ @param Context The Mtftp service instance\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+Mtftp4OnTimerTickNotifyLevel (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ );\r
+\r
/**\r
The timer ticking function for the Mtftp service instance.\r
\r