]> git.proxmox.com Git - mirror_edk2.git/commitdiff
temporary roll back changing on gEfiHotPlugDevice.
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 24 Feb 2009 08:03:42 +0000 (08:03 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 24 Feb 2009 08:03:42 +0000 (08:03 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7640 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Include/Protocol/HotPlugDevice.h [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf

diff --git a/MdeModulePkg/Include/Protocol/HotPlugDevice.h b/MdeModulePkg/Include/Protocol/HotPlugDevice.h
new file mode 100644 (file)
index 0000000..ae6ef46
--- /dev/null
@@ -0,0 +1,24 @@
+/** @file\r
+  This guid is used to specify the device is the hot plug device.\r
+  If the device is the hot plug device, this guid as the protocol guid\r
+  will be installed into this device handle.\r
+\r
+Copyright (c) 2006 - 2008, 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
+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 __HOT_PLUG_DEVICE_H__\r
+#define __HOT_PLUG_DEVICE_H__\r
+\r
+#define HOT_PLUG_DEVICE_GUID    \\r
+    { 0x220ac432, 0x1d43, 0x49e5, {0xa7, 0x4f, 0x4c, 0x9d, 0xa6, 0x7a, 0xd2, 0x3b } }\r
+\r
+extern EFI_GUID gEfiHotPlugDeviceGuid;\r
+#endif\r
index 8b5866a5ae0a760bab4cb24381c60d6107c51520..c8fde3abdccb1fbe09c313a09c8f09665a2b2344 100644 (file)
   ## Protocol Guid specify the Simple TextIn Notify handle.\r
   ## Include/Protocol/SimpleTextInExNotify.h\r
   gSimpleTextInExNotifyGuid      = { 0x856f2def, 0x4e93, 0x4d6b, { 0x94, 0xce, 0x1c, 0xfe, 0x47, 0x01, 0x3e, 0xa5 }}  \r
+  ## Protocol Guid specify the device is the hot plug device.\r
+  gEfiHotPlugDeviceGuid          = { 0x220AC432, 0x1D43, 0x49E5, { 0xA7, 0x4F, 0x4C, 0x9D, 0xA6, 0x7A, 0xD2, 0x3B }}\r
 \r
 [PcdsFeatureFlag.common]\r
   ## Indicate whether platform can support update capsule across a system reset\r
index f6483ed1fd0ec07767fc3b95bdf3971cd11d48fc..f3aa4a4fb3041c4b480befca1a036f594f6e98bd 100644 (file)
@@ -256,12 +256,12 @@ ConPlatformTextInDriverBindingStart (
     return Status;\r
   }\r
   //\r
-  // Check the device path, if it is a hot plug device,\r
+  // Check the device handle, if it is a hot plug device,\r
   // do not put the device path into ConInDev, and install\r
   // gEfiConsoleInDeviceGuid to the device handle directly.\r
   // The policy is, make hot plug device plug in and play immediately.\r
   //\r
-  if (IsHotPlugDevice (DevicePath)) {\r
+  if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
     gBS->InstallMultipleProtocolInterfaces (\r
            &ControllerHandle,\r
            &gEfiConsoleInDeviceGuid,\r
@@ -373,12 +373,12 @@ ConPlatformTextOutDriverBindingStart (
     return Status;\r
   }\r
   //\r
-  // Check the device path, if it is a hot plug device,\r
+  // Check the device handle, if it is a hot plug device,\r
   // do not put the device path into ConOutDev and ErrOutDev,\r
   // and install gEfiConsoleOutDeviceGuid to the device handle directly.\r
   // The policy is, make hot plug device plug in and play immediately.\r
   //\r
-  if (IsHotPlugDevice (DevicePath)) {\r
+  if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
     gBS->InstallMultipleProtocolInterfaces (\r
            &ControllerHandle,\r
            &gEfiConsoleOutDeviceGuid,\r
@@ -481,36 +481,32 @@ ConPlatformTextInDriverBindingStop (
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
 \r
-  //\r
-  // Get the Device Path Protocol firstly\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &DevicePath,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
   //\r
   // If it is not a hot-plug device, first delete it from the ConInDev variable.\r
   //\r
-  if (!IsHotPlugDevice (DevicePath)) {\r
-   //\r
-    // Remove DevicePath from ConInDev\r
+  if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
     //\r
-    ConPlatformUpdateDeviceVariable (\r
-      L"ConInDev",\r
-      DevicePath,\r
-      DELETE\r
-      );\r
+    // Get the Device Path Protocol so the environment variables can be updated\r
+    //\r
+    Status = gBS->OpenProtocol (\r
+                    ControllerHandle,\r
+                    &gEfiDevicePathProtocolGuid,\r
+                    (VOID **) &DevicePath,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      //\r
+      // Remove DevicePath from ConInDev\r
+      //\r
+      ConPlatformUpdateDeviceVariable (\r
+        L"ConInDev",\r
+        DevicePath,\r
+        DELETE\r
+        );\r
+    }\r
   }\r
-\r
   //\r
   // Uninstall the Console Device GUIDs from Controller Handle\r
   //\r
@@ -560,41 +556,37 @@ ConPlatformTextOutDriverBindingStop (
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
 \r
-  //\r
-  // Get the Device Path Protocol firstly\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &DevicePath,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
   //\r
   // If it is not a hot-plug device, first delete it from the ConOutDev and ErrOutDev variable.\r
   //\r
-  if (!IsHotPlugDevice (DevicePath)) {\r
+  if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
     //\r
-    // Remove DevicePath from ConOutDev, and ErrOutDev\r
+    // Get the Device Path Protocol so the environment variables can be updated\r
     //\r
-    ConPlatformUpdateDeviceVariable (\r
-      L"ConOutDev",\r
-      DevicePath,\r
-      DELETE\r
-      );\r
-    ConPlatformUpdateDeviceVariable (\r
-      L"ErrOutDev",\r
-      DevicePath,\r
-      DELETE\r
-      );\r
+    Status = gBS->OpenProtocol (\r
+                    ControllerHandle,\r
+                    &gEfiDevicePathProtocolGuid,\r
+                    (VOID **) &DevicePath,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      //\r
+      // Remove DevicePath from ConOutDev, and ErrOutDev\r
+      //\r
+      ConPlatformUpdateDeviceVariable (\r
+        L"ConOutDev",\r
+        DevicePath,\r
+        DELETE\r
+        );\r
+      ConPlatformUpdateDeviceVariable (\r
+        L"ErrOutDev",\r
+        DevicePath,\r
+        DELETE\r
+        );\r
+    }\r
   }\r
\r
   //\r
   // Uninstall the Console Device GUIDs from Controller Handle\r
   //\r
@@ -937,12 +929,10 @@ ConPlatformUpdateDeviceVariable (
 }\r
 \r
 /**\r
-  Check if the device supports hot-plug through its device path.\r
-\r
-  This function could be updated to check more types of Hot Plug devices.\r
-  Currently, it checks USB and PCCard device.\r
+  Check if the device supports hot-plug.\r
 \r
-  @param  DevicePath            Pointer to device's device path.\r
+  @param  DriverBindingHandle   Protocol instance pointer.\r
+  @param  ControllerHandle      Handle of device to check.\r
 \r
   @retval TRUE                  The devcie is a hot-plug device\r
   @retval FALSE                 The devcie is not a hot-plug device.\r
@@ -950,35 +940,26 @@ ConPlatformUpdateDeviceVariable (
 **/\r
 BOOLEAN\r
 IsHotPlugDevice (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL    *DevicePath\r
+  EFI_HANDLE    DriverBindingHandle,\r
+  EFI_HANDLE    ControllerHandle\r
   )\r
 {\r
-  EFI_DEVICE_PATH_PROTOCOL     *CheckDevicePath;\r
+  EFI_STATUS  Status;\r
 \r
-  CheckDevicePath = DevicePath;\r
-  while (!IsDevicePathEnd (CheckDevicePath)) {\r
-    //\r
-    // Check device whether is hot plug device or not throught Device Path\r
-    // \r
-    if ((DevicePathType (CheckDevicePath) == MESSAGING_DEVICE_PATH) &&\r
-        (DevicePathSubType (CheckDevicePath) == MSG_USB_DP ||\r
-         DevicePathSubType (CheckDevicePath) == MSG_USB_CLASS_DP ||\r
-         DevicePathSubType (CheckDevicePath) == MSG_USB_WWID_DP)) {\r
-      //\r
-      // If Device is USB device\r
-      //\r
-      return TRUE;\r
-    }\r
-    if ((DevicePathType (CheckDevicePath) == HARDWARE_DEVICE_PATH) &&\r
-        (DevicePathSubType (CheckDevicePath) == HW_PCCARD_DP)) {\r
-      //\r
-      // If Device is PCCard\r
-      //\r
-      return TRUE;\r
-    }\r
-  \r
-    CheckDevicePath = NextDevicePathNode (CheckDevicePath);\r
+  //\r
+  // HotPlugDeviceGuid indicates ControllerHandle stands for a hot plug device.\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiHotPlugDeviceGuid,\r
+                  NULL,\r
+                  DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
   }\r
 \r
-  return FALSE;\r
+  return TRUE;\r
 }\r
index a47ad1ce303b62204e96cea3e8d423c16fa212cf..f7883dce6cb14f92961010a15ddcc806872360cb 100644 (file)
@@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/SimpleTextOut.h>\r
 #include <Protocol/DevicePath.h>\r
 #include <Protocol/SimpleTextIn.h>\r
+#include <Protocol/HotPlugDevice.h>\r
 \r
 #include <Guid/GlobalVariable.h>\r
 #include <Guid/ConsoleInDevice.h>\r
@@ -292,12 +293,10 @@ ConPlatformUpdateDeviceVariable (
   );\r
 \r
 /**\r
-  Check if the device supports hot-plug through its device path.\r
+  Check if the device supports hot-plug.\r
 \r
-  This function could be updated to check more types of Hot Plug devices.\r
-  Currently, it checks USB and PCCard device.\r
-\r
-  @param  DevicePath            Pointer to device's device path.\r
+  @param  DriverBindingHandle   Protocol instance pointer.\r
+  @param  ControllerHandle      Handle of device to check.\r
 \r
   @retval TRUE                  The devcie is a hot-plug device\r
   @retval FALSE                 The devcie is not a hot-plug device.\r
@@ -305,7 +304,8 @@ ConPlatformUpdateDeviceVariable (
 **/\r
 BOOLEAN\r
 IsHotPlugDevice (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL    *DevicePath\r
+  EFI_HANDLE    DriverBindingHandle,\r
+  EFI_HANDLE    ControllerHandle\r
   );\r
 \r
 //\r
index 892d051a1a1f16255eca860a47f8913eb7731632..a96a6330a0d926a95c1a2331ea538efb42467b4b 100644 (file)
@@ -87,4 +87,5 @@
   gEfiDevicePathProtocolGuid                    ## TO_START\r
   gEfiSimpleTextInProtocolGuid                  ## TO_START\r
   gEfiSimpleTextOutProtocolGuid                 ## TO_START\r
+  gEfiHotPlugDeviceGuid                         ## SOMETIMES_CONSUMES (Used to check if it's a hot-plug device)\r
   
\ No newline at end of file
index 1da6d90677291e53f5b179bb03ce76ae7e228342..92ec98a09fdc0b342729994b265d42ad90bfc0b1 100644 (file)
@@ -300,12 +300,19 @@ TerminalDriverBindingStart (
       if (EFI_ERROR (Status)) {\r
         goto Error;\r
       }\r
-\r
-      if (IsHotPlugDevice (ParentDevicePath)) {\r
-        //\r
-        // if the serial device is a hot plug device, do not update the\r
-        // ConInDev, ConOutDev, and StdErrDev variables.\r
-        //\r
+      //\r
+      // if the serial device is a hot plug device, do not update the\r
+      // ConInDev, ConOutDev, and StdErrDev variables.\r
+      //\r
+      Status = gBS->OpenProtocol (\r
+                      Controller,\r
+                      &gEfiHotPlugDeviceGuid,\r
+                      NULL,\r
+                      This->DriverBindingHandle,\r
+                      Controller,\r
+                      EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+                      );\r
+      if (EFI_ERROR (Status)) {\r
         TerminalUpdateConsoleDevVariable (L"ConInDev", ParentDevicePath);\r
         TerminalUpdateConsoleDevVariable (L"ConOutDev", ParentDevicePath);\r
         TerminalUpdateConsoleDevVariable (L"ErrOutDev", ParentDevicePath);\r
@@ -620,7 +627,26 @@ TerminalDriverBindingStart (
   if (EFI_ERROR (Status)) {\r
     goto Error;\r
   }\r
-\r
+  //\r
+  // if the serial device is a hot plug device, attaches the HotPlugGuid\r
+  // onto the terminal device handle.\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiHotPlugDeviceGuid,\r
+                  NULL,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    Status = gBS->InstallMultipleProtocolInterfaces (\r
+                    &TerminalDevice->Handle,\r
+                    &gEfiHotPlugDeviceGuid,\r
+                    NULL,\r
+                    NULL\r
+                    );\r
+  }\r
   //\r
   // Register the Parent-Child relationship via\r
   // EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
@@ -860,6 +886,25 @@ TerminalDriverBindingStop (
           FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);\r
         }\r
 \r
+        Status = gBS->OpenProtocol (\r
+                        ChildHandleBuffer[Index],\r
+                        &gEfiHotPlugDeviceGuid,\r
+                        NULL,\r
+                        This->DriverBindingHandle,\r
+                        Controller,\r
+                        EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+                        );\r
+        if (!EFI_ERROR (Status)) {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          ChildHandleBuffer[Index],\r
+                          &gEfiHotPlugDeviceGuid,\r
+                          NULL,\r
+                          NULL\r
+                          );\r
+        } else {\r
+          Status = EFI_SUCCESS;\r
+        }\r
+\r
         gBS->CloseEvent (TerminalDevice->TwoSecondTimeOut);\r
         gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);\r
         gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx);\r
@@ -1277,50 +1322,3 @@ InitializeTerminal(
 \r
   return Status;\r
 }\r
-\r
-/**\r
-  Check if the device supports hot-plug through its device path.\r
-\r
-  This function could be updated to check more types of Hot Plug devices.\r
-  Currently, it checks USB and PCCard device.\r
-\r
-  @param  DevicePath            Pointer to device's device path.\r
-\r
-  @retval TRUE                  The devcie is a hot-plug device\r
-  @retval FALSE                 The devcie is not a hot-plug device.\r
-\r
-**/\r
-BOOLEAN\r
-IsHotPlugDevice (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL    *DevicePath\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL     *CheckDevicePath;\r
-\r
-  CheckDevicePath = DevicePath;\r
-  while (!IsDevicePathEnd (CheckDevicePath)) {\r
-    //\r
-    // Check device whether is hot plug device or not throught Device Path\r
-    // \r
-    if ((DevicePathType (CheckDevicePath) == MESSAGING_DEVICE_PATH) &&\r
-        (DevicePathSubType (CheckDevicePath) == MSG_USB_DP ||\r
-         DevicePathSubType (CheckDevicePath) == MSG_USB_CLASS_DP ||\r
-         DevicePathSubType (CheckDevicePath) == MSG_USB_WWID_DP)) {\r
-      //\r
-      // If Device is USB device\r
-      //\r
-      return TRUE;\r
-    }\r
-    if ((DevicePathType (CheckDevicePath) == HARDWARE_DEVICE_PATH) &&\r
-        (DevicePathSubType (CheckDevicePath) == HW_PCCARD_DP)) {\r
-      //\r
-      // If Device is PCCard\r
-      //\r
-      return TRUE;\r
-    }\r
-  \r
-    CheckDevicePath = NextDevicePathNode (CheckDevicePath);\r
-  }\r
-\r
-  return FALSE;\r
-}\r
index 7327da003a8bb2e318627726585c7a58f3217446..af3afecd1538b46d5a0d5699b5848fed5464885c 100644 (file)
@@ -22,6 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/PcAnsi.h>\r
 \r
 #include <Protocol/SimpleTextInExNotify.h>\r
+#include <Protocol/HotPlugDevice.h>\r
 #include <Protocol/SimpleTextOut.h>\r
 #include <Protocol/SerialIo.h>\r
 #include <Protocol/DevicePath.h>\r
@@ -1346,21 +1347,4 @@ TerminalIsValidEfiCntlChar (
   IN  CHAR16  CharC\r
   );\r
 \r
-/**\r
-  Check if the device supports hot-plug through its device path.\r
-\r
-  This function could be updated to check more types of Hot Plug devices.\r
-  Currently, it checks USB and PCCard device.\r
-\r
-  @param  DevicePath            Pointer to device's device path.\r
-\r
-  @retval TRUE                  The devcie is a hot-plug device\r
-  @retval FALSE                 The devcie is not a hot-plug device.\r
-\r
-**/\r
-BOOLEAN\r
-IsHotPlugDevice (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL    *DevicePath\r
-  );\r
-\r
 #endif\r
index 1d849c698bac31aa698f03f71eac6cae9eeac772..204ca6040bebfe284b726e31c1f67c2f9a98a70e 100644 (file)
@@ -73,6 +73,7 @@
   gEfiSimpleTextInputExProtocolGuid             ## BY_START\r
   gEfiSimpleTextOutProtocolGuid                 ## BY_START\r
   gSimpleTextInExNotifyGuid                     ## SOMETIMES_CONSUMES\r
+  gEfiHotPlugDeviceGuid                         ## SOMETIMES_CONSUMES\r
 \r
 [Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueRemoteConsoleError\r