]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg/SnpDxe: Add PCD to remove ExitBootServices event from SNP driver.
authorRabeda, Maciej <maciej.rabeda@intel.com>
Mon, 14 Oct 2019 12:37:28 +0000 (20:37 +0800)
committerSiyuan Fu <siyuan.fu@intel.com>
Mon, 21 Oct 2019 06:50:51 +0000 (14:50 +0800)
Patch addresses Bugzilla #1974.

During ExitBootServices stage, drivers should not call any
functions known to use Memory Allocation Services. One of such
functions (as per UEFI spec) is UNDI->Shutdown().

Since UNDI drivers during ExitBootServices phase are expected
to put the adapter to such a state that it will not perform any DMA
operations, there is no need to interface UNDI by SNP driver during
that phase.

Finally, since ExitBootServices event notification function in SNP
only calls UNDI->Shutdown() and Stop() functions, there is no need
to create this event at all. Adding PCD to control creation of event
reacting to ExitBootServices() call so that systems with UNDIs relying
on SNP to call their Shutdown() and Stop() can still work.

Change-Id: Idd76f26d2e8ff7cf88b2d75e2d524c74211f2e89
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Maciej Rabeda <maciej.rabeda@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
NetworkPkg/NetworkPkg.dec
NetworkPkg/SnpDxe/Snp.c
NetworkPkg/SnpDxe/Snp.h
NetworkPkg/SnpDxe/SnpDxe.inf

index 944b1d1501c0470c80ab6d0f2542e2bb49f8eea1..66e500cbeaf7b01266843db09c7a87c84f91a51e 100644 (file)
   # @Prompt TFTP block size.\r
   gEfiNetworkPkgTokenSpaceGuid.PcdTftpBlockSize|0x0|UINT64|0x1000000B\r
 \r
+  ## Indicates whether SnpDxe driver will create an event that will be notified\r
+  # upon gBS->ExitBootServices() call.\r
+  # TRUE - Event being triggered upon ExitBootServices call will be created\r
+  # FALSE - Event being triggered upon ExitBootServices call will NOT be created\r
+  # @Prompt Indicates whether SnpDxe creates event for ExitBootServices() call.\r
+  gEfiNetworkPkgTokenSpaceGuid.PcdSnpCreateExitBootServicesEvent|TRUE|BOOLEAN|0x1000000C\r
+\r
 [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]\r
   ## IPv6 DHCP Unique Identifier (DUID) Type configuration (From RFCs 3315 and 6355).\r
   # 01 = DUID Based on Link-layer Address Plus Time [DUID-LLT]\r
index a23af05078bc8939c7ea42dc83f2d26ad9489888..9fb007f7aecac00a89a07d3441b42035b9bd9cd9 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of driver entry point and driver binding protocol.\r
 \r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -647,19 +647,21 @@ SimpleNetworkDriverStart (
   PxeShutdown (Snp);\r
   PxeStop (Snp);\r
 \r
-  //\r
-  // Create EXIT_BOOT_SERIVES Event\r
-  //\r
-  Status = gBS->CreateEventEx (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  SnpNotifyExitBootServices,\r
-                  Snp,\r
-                  &gEfiEventExitBootServicesGuid,\r
-                  &Snp->ExitBootServicesEvent\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Error_DeleteSNP;\r
+  if (FixedPcdGetBool (PcdSnpCreateExitBootServicesEvent)) {\r
+    //\r
+    // Create EXIT_BOOT_SERIVES Event\r
+    //\r
+    Status = gBS->CreateEventEx (\r
+                    EVT_NOTIFY_SIGNAL,\r
+                    TPL_NOTIFY,\r
+                    SnpNotifyExitBootServices,\r
+                    Snp,\r
+                    &gEfiEventExitBootServicesGuid,\r
+                    &Snp->ExitBootServicesEvent\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      goto Error_DeleteSNP;\r
+    }\r
   }\r
 \r
   //\r
@@ -778,10 +780,12 @@ SimpleNetworkDriverStop (
     return Status;\r
   }\r
 \r
-  //\r
-  // Close EXIT_BOOT_SERIVES Event\r
-  //\r
-  gBS->CloseEvent (Snp->ExitBootServicesEvent);\r
+  if (FixedPcdGetBool (PcdSnpCreateExitBootServicesEvent)) {\r
+    //\r
+    // Close EXIT_BOOT_SERIVES Event\r
+    //\r
+    gBS->CloseEvent (Snp->ExitBootServicesEvent);\r
+  }\r
 \r
   Status = gBS->CloseProtocol (\r
                   Controller,\r
index e6b62930397d6aec9e2fb617c09f3d4d840ceb4c..9e4b7d6f86a074fbbdea62bcb1110ee4df46172b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
     Declaration of strctures and functions for SnpDxe driver.\r
 \r
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -26,6 +26,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/UefiLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/PrintLib.h>\r
+#include <Library/PcdLib.h>\r
 \r
 #include <IndustryStandard/Pci.h>\r
 #include <IndustryStandard/Acpi.h>\r
index afeb1526cc102c9f6c15ed174cd7e6e6ef3f3390..d16f1888b30f4ff21fc0df4b6574dd0df586bab0 100644 (file)
@@ -4,7 +4,7 @@
 #  This module produces Simple Network Protocol upon EFI Network Interface\r
 #  Identifier Protocol, to provide a packet level interface to a network adapter.\r
 #\r
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
@@ -73,5 +73,8 @@
   gEfiNetworkInterfaceIdentifierProtocolGuid_31 ## TO_START\r
   gEfiPciIoProtocolGuid                         ## TO_START\r
 \r
+[Pcd]\r
+  gEfiNetworkPkgTokenSpaceGuid.PcdSnpCreateExitBootServicesEvent   ## CONSUMES\r
+\r
 [UserExtensions.TianoCore."ExtraFiles"]\r
   SnpDxeExtra.uni\r