]> git.proxmox.com Git - mirror_edk2.git/commitdiff
fixed DMA not be stopped issue when gBS->ExitBootServices called.
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 10 Apr 2009 08:31:45 +0000 (08:31 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 10 Apr 2009 08:31:45 +0000 (08:31 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8058 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
MdeModulePkg/Bus/Pci/UhciDxe/Uhci.h
MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
MdeModulePkg/Universal/Network/SnpDxe/Snp.c
MdeModulePkg/Universal/Network/SnpDxe/Snp.h
MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf

index c8de7052bb9f1b90778e188004e1bb3dd5b0cbfa..d45bdf630cbbf34b4f0ca951a4e3a975ce57b456 100644 (file)
@@ -1449,6 +1449,33 @@ EhcCreateUsb2Hc (
   return Ehc;\r
 }\r
 \r
   return Ehc;\r
 }\r
 \r
+/**\r
+  One notified function to stop the Host Controller when gBS->ExitBootServices() called.\r
+\r
+  @param  Event                   Pointer to this event\r
+  @param  Context                 Event hanlder private data\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EhcExitBootService (\r
+  EFI_EVENT                      Event,\r
+  VOID                           *Context\r
+  )\r
+\r
+{\r
+  USB2_HC_DEV   *Ehc;\r
+\r
+  Ehc = (USB2_HC_DEV *) Context;\r
+\r
+  //\r
+  // Stop the Host Controller\r
+  //\r
+  EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);\r
+\r
+  return;\r
+}\r
+\r
 \r
 /**\r
   Starting the Usb EHCI Driver.\r
 \r
 /**\r
   Starting the Usb EHCI Driver.\r
@@ -1584,6 +1611,21 @@ EhcDriverBindingStart (
     goto UNINSTALL_USBHC;\r
   }\r
 \r
     goto UNINSTALL_USBHC;\r
   }\r
 \r
+  //\r
+  // Create event to stop the HC when exit boot service.\r
+  //\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
+                  EhcExitBootService,\r
+                  Ehc,\r
+                  &gEfiEventExitBootServicesGuid,\r
+                  &Ehc->ExitBootServiceEvent\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto UNINSTALL_USBHC;\r
+  }\r
+\r
   //\r
   // Install the component name protocol, don't fail the start\r
   // because of something for display.\r
   //\r
   // Install the component name protocol, don't fail the start\r
   // because of something for display.\r
@@ -1712,6 +1754,10 @@ EhcDriverBindingStop (
     gBS->CloseEvent (Ehc->PollTimer);\r
   }\r
 \r
     gBS->CloseEvent (Ehc->PollTimer);\r
   }\r
 \r
+  if (Ehc->ExitBootServiceEvent != NULL) {\r
+    gBS->CloseEvent (Ehc->ExitBootServiceEvent);\r
+  }\r
+\r
   EhcFreeSched (Ehc);\r
 \r
   if (Ehc->ControllerNameTable != NULL) {\r
   EhcFreeSched (Ehc);\r
 \r
   if (Ehc->ControllerNameTable != NULL) {\r
index 85772fb30d25e6545031ff9c05daeb1cc3447bac..2137d1cfba48bd2d4085d2936d3bdf47b6c3408b 100644 (file)
@@ -22,6 +22,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/Usb2HostController.h>\r
 #include <Protocol/PciIo.h>\r
 \r
 #include <Protocol/Usb2HostController.h>\r
 #include <Protocol/PciIo.h>\r
 \r
+#include <Guid/EventGroup.h>\r
+\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
@@ -120,6 +122,12 @@ struct _USB2_HC_DEV {
   EHC_QTD                  *ShortReadStop;\r
   EFI_EVENT                 PollTimer;\r
 \r
   EHC_QTD                  *ShortReadStop;\r
   EFI_EVENT                 PollTimer;\r
 \r
+  //\r
+  // ExitBootServicesEvent is used to stop the EHC DMA operation \r
+  // after exit boot service.\r
+  //\r
+  EFI_EVENT                 ExitBootServiceEvent;\r
+\r
   //\r
   // Asynchronous(bulk and control) transfer schedule data:\r
   // ReclaimHead is used as the head of the asynchronous transfer\r
   //\r
   // Asynchronous(bulk and control) transfer schedule data:\r
   // ReclaimHead is used as the head of the asynchronous transfer\r
index deb540524f13ae007a23d4602c317c474486d7dc..fd98e4200f007e4f6179d74f4b6624b1e85e3859 100644 (file)
@@ -71,6 +71,9 @@
   DebugLib\r
   PcdLib\r
 \r
   DebugLib\r
   PcdLib\r
 \r
+[Guids]\r
+  gEfiEventExitBootServicesGuid                 ## PRODUCES ## Event\r
+\r
 [Protocols]\r
   gEfiPciIoProtocolGuid                         ## TO_START\r
   gEfiUsb2HcProtocolGuid                        ## BY_START\r
 [Protocols]\r
   gEfiPciIoProtocolGuid                         ## TO_START\r
   gEfiUsb2HcProtocolGuid                        ## BY_START\r
index a4110b75a2a0323ded4afd68c1f871844d045a2c..abc5c27817df99d48149425eb1da70e8ea464d8a 100644 (file)
@@ -2,7 +2,7 @@
 \r
   The UHCI driver model and HC protocol routines.\r
 \r
 \r
   The UHCI driver model and HC protocol routines.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation\r
+Copyright (c) 2004 - 2009, Intel Corporation\r
 All rights reserved. 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
 All rights reserved. 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
@@ -1517,6 +1517,10 @@ UhciFreeDev (
     gBS->CloseEvent (Uhc->AsyncIntMonitor);\r
   }\r
 \r
     gBS->CloseEvent (Uhc->AsyncIntMonitor);\r
   }\r
 \r
+  if (Uhc->ExitBootServiceEvent != NULL) {\r
+    gBS->CloseEvent (Uhc->ExitBootServiceEvent);\r
+  }\r
+  \r
   if (Uhc->MemPool != NULL) {\r
     UsbHcFreeMemPool (Uhc->MemPool);\r
   }\r
   if (Uhc->MemPool != NULL) {\r
     UsbHcFreeMemPool (Uhc->MemPool);\r
   }\r
@@ -1572,6 +1576,31 @@ UhciCleanDevUp (
   UhciFreeDev (Uhc);\r
 }\r
 \r
   UhciFreeDev (Uhc);\r
 }\r
 \r
+/**\r
+  One notified function to stop the Host Controller when gBS->ExitBootServices() called.\r
+\r
+  @param  Event                   Pointer to this event\r
+  @param  Context                 Event hanlder private data\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+UhcExitBootService (\r
+  EFI_EVENT                      Event,\r
+  VOID                           *Context\r
+  )\r
+{\r
+  USB_HC_DEV   *Uhc;\r
+\r
+  Uhc = (USB_HC_DEV *) Context;\r
+\r
+  //\r
+  // Stop the Host Controller\r
+  //\r
+  UhciStopHc (Uhc, UHC_GENERIC_TIMEOUT);\r
+\r
+  return;\r
+}\r
 \r
 /**\r
   Starting the Usb UHCI Driver.\r
 \r
 /**\r
   Starting the Usb UHCI Driver.\r
@@ -1703,6 +1732,21 @@ UhciDriverBindingStart (
     goto FREE_UHC;\r
   }\r
 \r
     goto FREE_UHC;\r
   }\r
 \r
+  //\r
+  // Create event to stop the HC when exit boot service.\r
+  //\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
+                  UhcExitBootService,\r
+                  Uhc,\r
+                  &gEfiEventExitBootServicesGuid,\r
+                  &Uhc->ExitBootServiceEvent\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto UNINSTALL_USBHC;\r
+  }\r
+\r
   //\r
   // Install the component name protocol\r
   //\r
   //\r
   // Install the component name protocol\r
   //\r
@@ -1730,6 +1774,14 @@ UhciDriverBindingStart (
   UhciWriteReg (Uhc->PciIo, USBCMD_OFFSET, USBCMD_RS | USBCMD_MAXP);\r
 \r
   return EFI_SUCCESS;\r
   UhciWriteReg (Uhc->PciIo, USBCMD_OFFSET, USBCMD_RS | USBCMD_MAXP);\r
 \r
   return EFI_SUCCESS;\r
+  \r
+UNINSTALL_USBHC:\r
+  gBS->UninstallMultipleProtocolInterfaces (\r
+         Controller,\r
+         &gEfiUsb2HcProtocolGuid,\r
+         &Uhc->Usb2Hc,\r
+         NULL\r
+         );\r
 \r
 FREE_UHC:\r
   UhciFreeDev (Uhc);\r
 \r
 FREE_UHC:\r
   UhciFreeDev (Uhc);\r
index 3f6d42f370ce3a40322ee1e58e08dbdaa4f71fcc..58be29e444a32ab6fc9b76311e6b191d923a6f18 100644 (file)
@@ -2,7 +2,7 @@
 \r
   The definition for UHCI driver model and HC protocol routines.\r
 \r
 \r
   The definition for UHCI driver model and HC protocol routines.\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation\r
+Copyright (c) 2004 - 2009, Intel Corporation\r
 All rights reserved. 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
 All rights reserved. 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
@@ -23,6 +23,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/UsbHostController.h>\r
 #include <Protocol/PciIo.h>\r
 \r
 #include <Protocol/UsbHostController.h>\r
 #include <Protocol/PciIo.h>\r
 \r
+#include <Guid/EventGroup.h>\r
+\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
@@ -137,6 +139,12 @@ struct _USB_HC_DEV {
   USBHC_MEM_POOL            *MemPool;\r
   EFI_UNICODE_STRING_TABLE  *CtrlNameTable;\r
   VOID                      *FrameMapping;\r
   USBHC_MEM_POOL            *MemPool;\r
   EFI_UNICODE_STRING_TABLE  *CtrlNameTable;\r
   VOID                      *FrameMapping;\r
+\r
+  //\r
+  // ExitBootServicesEvent is used to stop the EHC DMA operation \r
+  // after exit boot service.\r
+  //\r
+  EFI_EVENT                 ExitBootServiceEvent;\r
 };\r
 \r
 extern EFI_DRIVER_BINDING_PROTOCOL   gUhciDriverBinding;\r
 };\r
 \r
 extern EFI_DRIVER_BINDING_PROTOCOL   gUhciDriverBinding;\r
index cf91655244697ef1bbf6f344bb7e1a20b362fd1d..2b7953cd3534fd98225db299e6711ddb4078096c 100644 (file)
@@ -72,6 +72,8 @@
   DebugLib\r
   PcdLib\r
 \r
   DebugLib\r
   PcdLib\r
 \r
+[Guids]\r
+  gEfiEventExitBootServicesGuid                 ## PRODUCES ## Event\r
 \r
 [Protocols]\r
   gEfiPciIoProtocolGuid                         ## TO_START\r
 \r
 [Protocols]\r
   gEfiPciIoProtocolGuid                         ## TO_START\r
index 6ca7eb515b379bba23898d86a6f9aa4ca40ae7ec..6e535b5d93d1255700363737dd82446dd1acd3f6 100644 (file)
@@ -631,14 +631,14 @@ CoreExitBootServices (
   }\r
 \r
   //\r
   }\r
 \r
   //\r
-  // Notify other drivers that we are exiting boot services.\r
+  // Disable Timer\r
   //\r
   //\r
-  CoreNotifySignalList (&gEfiEventExitBootServicesGuid);\r
+  gTimer->SetTimerPeriod (gTimer, 0);\r
 \r
   //\r
 \r
   //\r
-  // Disable Timer\r
+  // Notify other drivers that we are exiting boot services.\r
   //\r
   //\r
-  gTimer->SetTimerPeriod (gTimer, 0);\r
+  CoreNotifySignalList (&gEfiEventExitBootServicesGuid);\r
 \r
   //\r
   // Disable CPU Interrupts\r
 \r
   //\r
   // Disable CPU Interrupts\r
index 0006c447a6c7d922c2386a7121ab37c409883701..dde0d6021fa297c457dc703e22586b47c0669d3c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
     Implementation of driver entry point and driver binding protocol.\r
  \r
 /** @file\r
     Implementation of driver entry point and driver binding protocol.\r
  \r
-Copyright (c) 2004 - 2008, Intel Corporation. <BR> \r
+Copyright (c) 2004 - 2009, Intel Corporation. <BR> \r
 All rights reserved. This program and the accompanying materials are licensed \r
 and made available under the terms and conditions of the BSD License which \r
 accompanies this distribution. The full text of the license may be found at \r
 All rights reserved. This program and the accompanying materials are licensed \r
 and made available under the terms and conditions of the BSD License which \r
 accompanies this distribution. The full text of the license may be found at \r
@@ -22,6 +22,30 @@ V2P                         *mV2p = NULL; // undi3.0 map_list head
 // End Global variables\r
 //\r
 \r
 // End Global variables\r
 //\r
 \r
+/**\r
+  One notified function to stop UNDI device when gBS->ExitBootServices() called.\r
+\r
+  @param  Event                   Pointer to this event\r
+  @param  Context                 Event hanlder private data\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SnpNotifyExitBootServices (\r
+  EFI_EVENT Event,\r
+  VOID      *Context\r
+  )\r
+{\r
+  SNP_DRIVER             *Snp;\r
+\r
+  Snp  = (SNP_DRIVER *)Context;\r
+\r
+  //\r
+  // Shutdown and stop UNDI driver\r
+  //\r
+  PxeShutdown (Snp);\r
+  PxeStop (Snp);\r
+}\r
 \r
 /**\r
   Send command to UNDI. It does nothing currently.\r
 \r
 /**\r
   Send command to UNDI. It does nothing currently.\r
@@ -634,6 +658,21 @@ SimpleNetworkDriverStart (
   PxeShutdown (Snp);\r
   PxeStop (Snp);\r
 \r
   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
+  }\r
+\r
   //\r
   //  add SNP to the undi handle\r
   //\r
   //\r
   //  add SNP to the undi handle\r
   //\r
@@ -738,6 +777,11 @@ SimpleNetworkDriverStop (
     return Status;\r
   }\r
 \r
     return Status;\r
   }\r
 \r
+  //\r
+  // Close EXIT_BOOT_SERIVES Event\r
+  //\r
+  gBS->CloseEvent (Snp->ExitBootServicesEvent);\r
+\r
   Status = gBS->CloseProtocol (\r
                   Controller,\r
                   &gEfiNetworkInterfaceIdentifierProtocolGuid_31,\r
   Status = gBS->CloseProtocol (\r
                   Controller,\r
                   &gEfiNetworkInterfaceIdentifierProtocolGuid_31,\r
index ff7ad7b444fef415958bf9c096122e3932cecb44..389cbee91d15ed1cc6bad66611fa5a68756546aa 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
     Declaration of strctures and functions for SnpDxe driver.\r
 \r
 /** @file\r
     Declaration of strctures and functions for SnpDxe driver.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. <BR> \r
+Copyright (c) 2004 - 2009, Intel Corporation. <BR> \r
 All rights reserved. This program and the accompanying materials are licensed \r
 and made available under the terms and conditions of the BSD License which \r
 accompanies this distribution. The full text of the license may be found at \r
 All rights reserved. This program and the accompanying materials are licensed \r
 and made available under the terms and conditions of the BSD License which \r
 accompanies this distribution. The full text of the license may be found at \r
@@ -22,6 +22,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/NetworkInterfaceIdentifier.h>\r
 #include <Protocol/DevicePath.h>\r
 \r
 #include <Protocol/NetworkInterfaceIdentifier.h>\r
 #include <Protocol/DevicePath.h>\r
 \r
+#include <Guid/EventGroup.h>\r
+\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
@@ -118,6 +120,8 @@ typedef struct {
     EFI_PHYSICAL_ADDRESS  VirtualAddress;\r
     VOID                  *MapCookie;\r
   } MapList[MAX_MAP_LENGTH];\r
     EFI_PHYSICAL_ADDRESS  VirtualAddress;\r
     VOID                  *MapCookie;\r
   } MapList[MAX_MAP_LENGTH];\r
+\r
+  EFI_EVENT              ExitBootServicesEvent;\r
 } SNP_DRIVER;\r
 \r
 #define EFI_SIMPLE_NETWORK_DEV_FROM_THIS(a) CR (a, SNP_DRIVER, Snp, SNP_DRIVER_SIGNATURE)\r
 } SNP_DRIVER;\r
 \r
 #define EFI_SIMPLE_NETWORK_DEV_FROM_THIS(a) CR (a, SNP_DRIVER, Snp, SNP_DRIVER_SIGNATURE)\r
index c876605f19d3b10994eac344c99bdcb919e0ccb8..0d53e33a655e9d7b1db22abb5956d39f5938f606 100644 (file)
@@ -1,7 +1,7 @@
 #/** @file\r
 #    Component description file for SNP module.\r
 #\r
 #/** @file\r
 #    Component description file for SNP module.\r
 #\r
-# Copyright (c) 2006, Intel Corporation. <BR> \r
+# Copyright (c) 2006 - 2009, Intel Corporation. <BR> \r
 # All rights reserved. This program and the accompanying materials are licensed \r
 # and made available under the terms and conditions of the BSD License which \r
 # accompanies this distribution. The full text of the license may be found at \r
 # All rights reserved. This program and the accompanying materials are licensed \r
 # and made available under the terms and conditions of the BSD License which \r
 # accompanies this distribution. The full text of the license may be found at \r
   DebugLib\r
 \r
 \r
   DebugLib\r
 \r
 \r
+[Guids]\r
+  gEfiEventExitBootServicesGuid                 ## CONSUMES\r
+\r
+\r
 [Protocols]\r
   gEfiPciIoProtocolGuid                         # PROTOCOL ALWAYS_CONSUMED\r
   gEfiSimpleNetworkProtocolGuid                 # PROTOCOL ALWAYS_CONSUMED\r
 [Protocols]\r
   gEfiPciIoProtocolGuid                         # PROTOCOL ALWAYS_CONSUMED\r
   gEfiSimpleNetworkProtocolGuid                 # PROTOCOL ALWAYS_CONSUMED\r