]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the issue that consplitter should not touch ConIn variable & do ConIn connection
authorczhang46 <czhang46@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 17 Aug 2012 07:43:09 +0000 (07:43 +0000)
committerczhang46 <czhang46@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 17 Aug 2012 07:43:09 +0000 (07:43 +0000)
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by  : Hot Tian <hot.tian@intel.com>
Reviewed-by  : Ni, Ruiyu <ruiyu.ni@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13645 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Include/Guid/ConnectConInEvent.h [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

diff --git a/MdeModulePkg/Include/Guid/ConnectConInEvent.h b/MdeModulePkg/Include/Guid/ConnectConInEvent.h
new file mode 100644 (file)
index 0000000..fb9d52b
--- /dev/null
@@ -0,0 +1,24 @@
+/** @file\r
+  GUID is the name of events used with CreateEventEx in order to be notified\r
+  when the requires ConIn connection.\r
+\r
+  Copyright (c) 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\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
+\r
+**/\r
+\r
+#ifndef __CONNECT_CONIN_EVENT_GUID_H__\r
+#define __CONNECT_CONIN_EVENT_GUID_H__\r
+\r
+#define CONNECT_CONIN_EVENT_GUID \\r
+    { 0xdb4e8151, 0x57ed, 0x4bed, { 0x88, 0x33, 0x67, 0x51, 0xb5, 0xd1, 0xa8, 0xd7 }}\r
+\r
+extern EFI_GUID gConnectConInEventGuid;\r
+\r
+#endif\r
index bb58f794f1acb699e27db6472ffe0a0484ecdfb1..d3d1a299b4cd479d479a9c0f432b1c3a26955bbf 100644 (file)
   ## Include/Guid/ExitBootServiceFailed.h\r
   gEventExitBootServicesFailedGuid   = { 0x4f6c5507, 0x232f, 0x4787, { 0xb9, 0x5e, 0x72, 0xf8, 0x62, 0x49, 0xc, 0xb1 } }\r
 \r
+  ## Include/Guid/ConnectConInEvent.h\r
+  gConnectConInEventGuid             = { 0xdb4e8151, 0x57ed, 0x4bed, { 0x88, 0x33, 0x67, 0x51, 0xb5, 0xd1, 0xa8, 0xd7 }}\r
+\r
 [Ppis]\r
   ## Include/Ppi/AtaController.h\r
   gPeiAtaControllerPpiGuid       = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}\r
index dc23e321c814ddb8ddc965658592824c6277937c..d34e7ce5aa96adcc6461fa83d23c53c2b23ac079 100644 (file)
@@ -620,6 +620,18 @@ ConSplitterTextInConstructor (
                   ConInPrivate,\r
                   &ConInPrivate->SimplePointer.WaitForInput\r
                   );\r
+  ASSERT_EFI_ERROR (Status);\r
+  //\r
+  // Create Event to signal ConIn connection request\r
+  //\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  ConSplitterEmptyCallbackFunction,\r
+                  NULL,\r
+                  &gConnectConInEventGuid,\r
+                  &ConInPrivate->ConnectConIn\r
+                  );\r
 \r
   return Status;\r
 }\r
@@ -3310,245 +3322,6 @@ ConSplitterTextInPrivateReadKeyStroke (
   return EFI_NOT_READY;\r
 }\r
 \r
-/**\r
-  Connect the specific Usb device which match the short form device path,\r
-  and whose bus is determined by Host Controller.\r
-\r
-  @param  DevicePath             A short-form device path that starts with the first\r
-                                 element being a USB WWID or a USB Class device\r
-                                 path\r
-\r
-  @return EFI_INVALID_PARAMETER  DevicePath is NULL pointer.\r
-                                 DevicePath is not a USB device path.\r
-\r
-  @return EFI_SUCCESS            Success to connect USB device\r
-  @return EFI_NOT_FOUND          Fail to find handle for USB controller to connect.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ConSplitterConnectUsbShortFormDevicePath (\r
-  IN EFI_DEVICE_PATH_PROTOCOL   *DevicePath\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_HANDLE                            *Handles;\r
-  UINTN                                 HandleCount;\r
-  UINTN                                 Index;\r
-  EFI_PCI_IO_PROTOCOL                   *PciIo;\r
-  UINT8                                 Class[3];\r
-  BOOLEAN                               AtLeastOneConnected;\r
-\r
-  //\r
-  // Check the passed in parameters\r
-  //\r
-  if (DevicePath == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH) ||\r
-      ((DevicePathSubType (DevicePath) != MSG_USB_CLASS_DP) && (DevicePathSubType (DevicePath) != MSG_USB_WWID_DP))\r
-     ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Find the usb host controller firstly, then connect with the remaining device path\r
-  //\r
-  AtLeastOneConnected = FALSE;\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &Handles\r
-                  );\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = gBS->HandleProtocol (\r
-                    Handles[Index],\r
-                    &gEfiPciIoProtocolGuid,\r
-                    (VOID **) &PciIo\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Check whether the Pci device is the wanted usb host controller\r
-      //\r
-      Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);\r
-      if (!EFI_ERROR (Status) &&\r
-          ((PCI_CLASS_SERIAL == Class[2]) && (PCI_CLASS_SERIAL_USB == Class[1]))\r
-         ) {\r
-        Status = gBS->ConnectController (\r
-                        Handles[Index],\r
-                        NULL,\r
-                        DevicePath,\r
-                        FALSE\r
-                        );\r
-        if (!EFI_ERROR(Status)) {\r
-          AtLeastOneConnected = TRUE;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  return AtLeastOneConnected ? EFI_SUCCESS : EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
-  This function will create all handles associate with every device\r
-  path node. If the handle associate with one device path node can not\r
-  be created successfully, then still give one chance to do the dispatch,\r
-  which load the missing drivers if possible.\r
-\r
-  @param  DevicePathToConnect   The device path which will be connected, it CANNOT be\r
-                                a multi-instance device path\r
-  @param  MatchingHandle        Return the controller handle closest to the DevicePathToConnect\r
-\r
-  @retval EFI_INVALID_PARAMETER DevicePathToConnect is NULL.\r
-  @retval EFI_NOT_FOUND         Failed to create all handles associate with every device path node.\r
-  @retval EFI_SUCCESS           Successful to create all handles associate with every device path node.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ConSplitterConnectDevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect,\r
-  OUT EFI_HANDLE                *MatchingHandle          OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *RemainingDevicePath;\r
-  EFI_HANDLE                Handle;\r
-  EFI_HANDLE                PreviousHandle;\r
-\r
-  if (DevicePathToConnect == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Start the real work of connect with RemainingDevicePath\r
-  //\r
-  PreviousHandle = NULL;\r
-  do {\r
-    //\r
-    // Find the handle that best matches the Device Path. If it is only a\r
-    // partial match the remaining part of the device path is returned in\r
-    // RemainingDevicePath.\r
-    //\r
-    RemainingDevicePath = DevicePathToConnect;\r
-    Status              = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);\r
-    if (!EFI_ERROR (Status)) {\r
-      if (Handle == PreviousHandle) {\r
-        //\r
-        // If no forward progress is made try invoking the Dispatcher.\r
-        // A new FV may have been added to the system an new drivers\r
-        // may now be found.\r
-        // Status == EFI_SUCCESS means a driver was dispatched\r
-        // Status == EFI_NOT_FOUND means no new drivers were dispatched\r
-        //\r
-        Status = gDS->Dispatch ();\r
-      }\r
-\r
-      if (!EFI_ERROR (Status)) {\r
-        PreviousHandle = Handle;\r
-        //\r
-        // Connect all drivers that apply to Handle and RemainingDevicePath,\r
-        // the Recursive flag is FALSE so only one level will be expanded.\r
-        //\r
-        // Do not check the connect status here, if the connect controller fail,\r
-        // then still give the chance to do dispatch, because partial\r
-        // RemainingDevicepath may be in the new FV\r
-        //\r
-        // 1. If the connect fail, RemainingDevicepath and handle will not\r
-        //    change, so next time will do the dispatch, then dispatch's status\r
-        //    will take effect\r
-        // 2. If the connect success, the RemainingDevicepath and handle will\r
-        //    change, then avoid the dispatch, we have chance to continue the\r
-        //    next connection\r
-        //\r
-        gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);\r
-        if (MatchingHandle != NULL) {\r
-          *MatchingHandle = Handle;\r
-        }\r
-      }\r
-    }\r
-    //\r
-    // Loop until RemainingDevicePath is an empty device path\r
-    //\r
-  } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));\r
-\r
-  ASSERT (EFI_ERROR (Status) || IsDevicePathEnd (RemainingDevicePath));\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Connect to all ConIn device which is in the ConIn variable.\r
-\r
-  @param  DevicePath             A short-form device path that starts with the first\r
-                                 element being a USB WWID or a USB Class device\r
-                                 path\r
-\r
-  @return EFI_INVALID_PARAMETER  DevicePath is NULL pointer.\r
-                                 DevicePath is not a USB device path.\r
-\r
-  @return EFI_SUCCESS            Success to connect USB device\r
-  @return EFI_NOT_FOUND          Fail to find handle for USB controller to connect.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ConSplitterConnectConInDevicePath (\r
-  \r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL              *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL              *DevicePathInst;\r
-  EFI_DEVICE_PATH_PROTOCOL              *CopyDevicePath;\r
-  UINTN                                 Size;\r
-  EFI_DEVICE_PATH_PROTOCOL              *Next;\r
-\r
-  DevicePath = GetEfiGlobalVariable (L"ConIn");\r
-\r
-  //\r
-  // Check the passed in parameters\r
-  //\r
-  if (DevicePath == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  CopyDevicePath = DevicePath;\r
-\r
-  DevicePathInst  = GetNextDevicePathInstance (&DevicePath, &Size);\r
-  while (DevicePathInst != NULL) {\r
-\r
-    Next      = DevicePathInst;\r
-    while (!IsDevicePathEndType (Next)) {\r
-      Next = NextDevicePathNode (Next);\r
-    }\r
-\r
-    SetDevicePathEndNode (Next);\r
-    \r
-    //\r
-    // Connect the USB console\r
-    // USB console device path is a short-form device path that \r
-    //  starts with the first element being a USB WWID\r
-    //  or a USB Class device path\r
-    //\r
-    if ((DevicePathType (DevicePathInst) == MESSAGING_DEVICE_PATH) &&\r
-       ((DevicePathSubType (DevicePathInst) == MSG_USB_CLASS_DP)\r
-       || (DevicePathSubType (DevicePathInst) == MSG_USB_WWID_DP)\r
-       )) {\r
-      ConSplitterConnectUsbShortFormDevicePath (DevicePathInst);\r
-    } else {\r
-      ConSplitterConnectDevicePath (DevicePathInst, NULL);\r
-    }    \r
-    DevicePathInst  = GetNextDevicePathInstance (&DevicePath, &Size);\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
 \r
 \r
 /**\r
@@ -3578,11 +3351,11 @@ ConSplitterTextInReadKeyStroke (
   Private->KeyEventSignalState = FALSE;\r
 \r
   //\r
-  // Connect ConIn when first call in Lazy ConIn mode\r
+  // Signal ConnectConIn event on first call in Lazy ConIn mode\r
   //\r
   if (!mConInIsConnect && PcdGetBool (PcdConInConnectOnDemand)) {\r
     DEBUG ((EFI_D_INFO, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));    \r
-    ConSplitterConnectConInDevicePath ();\r
+    gBS->SignalEvent (Private->ConnectConIn);\r
     mConInIsConnect = TRUE;\r
   }\r
 \r
@@ -3758,15 +3531,6 @@ ConSplitterTextInReadKeyStrokeEx (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  //\r
-  // Connect ConIn when first call in Lazy ConIn mode\r
-  //\r
-  if (!mConInIsConnect && PcdGetBool (PcdConInConnectOnDemand)) {\r
-    DEBUG ((EFI_D_INFO, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));    \r
-    ConSplitterConnectConInDevicePath ();\r
-    mConInIsConnect = TRUE;\r
-  }\r
-\r
   Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
 \r
   Private->KeyEventSignalState = FALSE;\r
@@ -3774,6 +3538,15 @@ ConSplitterTextInReadKeyStrokeEx (
   KeyData->Key.UnicodeChar  = 0;\r
   KeyData->Key.ScanCode     = SCAN_NULL;\r
 \r
+  //\r
+  // Signal ConnectConIn event on first call in Lazy ConIn mode\r
+  //\r
+  if (!mConInIsConnect && PcdGetBool (PcdConInConnectOnDemand)) {\r
+    DEBUG ((EFI_D_INFO, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));    \r
+    gBS->SignalEvent (Private->ConnectConIn);\r
+    mConInIsConnect = TRUE;\r
+  }\r
+\r
   //\r
   // if no physical console input device exists, return EFI_NOT_READY;\r
   // if any physical console input device has key input,\r
@@ -4938,3 +4711,21 @@ ConSplitterTextOutEnableCursor (
   return ReturnStatus;\r
 }\r
 \r
+\r
+/**\r
+  An empty function to pass error checking of CreateEventEx ().\r
+\r
+  @param  Event                 Event whose notification function is being invoked.\r
+  @param  Context               Pointer to the notification function's context,\r
+                                which is implementation-dependent.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ConSplitterEmptyCallbackFunction (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  )\r
+{\r
+  return;\r
+}\r
index 680e02f8120da7521b9530bee5745ad783ef2ccc..b5b1435d9281f18b9f64322c84bed346ec942a9f 100644 (file)
@@ -18,8 +18,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Uefi.h>\r
 #include <PiDxe.h>\r
 \r
-#include <IndustryStandard/Pci.h>\r
-\r
 #include <Protocol/DevicePath.h>\r
 #include <Protocol/ComponentName.h>\r
 #include <Protocol/DriverBinding.h>\r
@@ -30,11 +28,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/SimpleTextInEx.h>\r
 #include <Protocol/GraphicsOutput.h>\r
 #include <Protocol/UgaDraw.h>\r
-#include <Protocol/PciIo.h>\r
 \r
 #include <Guid/ConsoleInDevice.h>\r
 #include <Guid/StandardErrorDevice.h>\r
 #include <Guid/ConsoleOutDevice.h>\r
+#include <Guid/ConnectConInEvent.h>\r
 \r
 #include <Library/PcdLib.h>\r
 #include <Library/DebugLib.h>\r
@@ -45,9 +43,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-\r
 \r
 //\r
 // Driver Binding Externs\r
@@ -150,6 +145,7 @@ typedef struct {
 \r
   BOOLEAN                            KeyEventSignalState;\r
   BOOLEAN                            InputEventSignalState;\r
+  EFI_EVENT                          ConnectConIn;\r
 } TEXT_IN_SPLITTER_PRIVATE_DATA;\r
 \r
 #define TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS(a)  \\r
@@ -1989,5 +1985,20 @@ TextOutSetMode (
   IN  UINTN                           ModeNumber\r
   );\r
 \r
+/**\r
+  An empty function to pass error checking of CreateEventEx ().\r
+\r
+  @param  Event                 Event whose notification function is being invoked.\r
+  @param  Context               Pointer to the notification function's context,\r
+                                which is implementation-dependent.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ConSplitterEmptyCallbackFunction (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  );\r
+\r
 \r
 #endif\r
index 3d2b5bc3186cccd0491ed6f7752ae26c37c5cf8d..4885dc7fe92134edb611044b0cc07bb868bf7370 100644 (file)
   UefiDriverEntryPoint\r
   DebugLib\r
   PcdLib\r
-  DevicePathLib\r
-  DxeServicesLib\r
-  DxeServicesTableLib\r
 \r
 [Guids]\r
   gEfiConsoleInDeviceGuid                       ## SOMETIMES_CONSUMES\r
   gEfiStandardErrorDeviceGuid                   ## SOMETIMES_CONSUMES\r
   gEfiConsoleOutDeviceGuid                      ## SOMETIMES_CONSUMES\r
-\r
+  gConnectConInEventGuid                        ## ALWAYS_CONSUMES\r
 \r
 [Protocols]\r
   gEfiSimplePointerProtocolGuid                 ## BY_START\r
@@ -86,7 +83,6 @@
   gEfiSimpleTextOutProtocolGuid                 ## BY_START\r
   gEfiGraphicsOutputProtocolGuid                ## BY_START\r
   gEfiUgaDrawProtocolGuid                       ## BY_START\r
-  gEfiPciIoProtocolGuid                         ## PROTOCOL CONSUMES\r
 \r
 \r
 [FeaturePcd]\r