]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Driver.c
index 8da47fc8df02b39e24c0102cd0f10046a4172eda..ae9e65544a868308f4ef3a97bec82706b67536dc 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   Implementation of Mtftp drivers.\r
 \r
-Copyright (c) 2006 - 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 of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php<BR>\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
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -162,11 +156,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 +173,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 +203,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 +219,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 +243,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 +304,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
@@ -319,7 +335,7 @@ ON_ERROR:
 \r
 /**\r
   Callback function which provided by user to remove one node in NetDestroyLinkList process.\r
-  \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
@@ -328,10 +344,11 @@ ON_ERROR:
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 Mtftp4DestroyChildEntryInHandleBuffer (\r
   IN LIST_ENTRY         *Entry,\r
   IN VOID               *Context\r
-)\r
+  )\r
 {\r
   MTFTP4_PROTOCOL               *Instance;\r
   EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;\r
@@ -690,7 +707,7 @@ Mtftp4ServiceBindingDestroyChild (
            &gEfiUdp4ProtocolGuid,\r
            gMtftp4DriverBinding.DriverBindingHandle,\r
            ChildHandle\r
-           );  \r
+           );\r
   }\r
 \r
   //\r