]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c
MdeModulePkg/Mtftp4Dxe: Separate the timer ticking to calculate the packet live time.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Driver.c
index a23d405baa2fbb48e43c4ad0e031d853a9d5c5bf..713cc66dd17325a1a7b208280bcd6cab9a2e9cb9 100644 (file)
@@ -1,7 +1,7 @@
 /** @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
@@ -162,11 +162,12 @@ Mtftp4CreateService (
   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
@@ -178,8 +179,20 @@ Mtftp4CreateService (
                   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
@@ -196,6 +209,7 @@ Mtftp4CreateService (
                   &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
@@ -211,6 +225,7 @@ Mtftp4CreateService (
 \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
@@ -234,6 +249,7 @@ Mtftp4CleanService (
 {\r
   UdpIoFreeIo (MtftpSb->ConnectUdp);\r
   gBS->CloseEvent (MtftpSb->TimerToGetMap);\r
+  gBS->CloseEvent (MtftpSb->TimerNotifyLevel);\r
   gBS->CloseEvent (MtftpSb->Timer);\r
 }\r
 \r
@@ -294,6 +310,12 @@ Mtftp4DriverBindingStart (
     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