]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
1. Retired HotPlugDevice protocol.
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / Terminal.c
index 92ec98a09fdc0b342729994b265d42ad90bfc0b1..1da6d90677291e53f5b179bb03ce76ae7e228342 100644 (file)
@@ -300,19 +300,12 @@ TerminalDriverBindingStart (
       if (EFI_ERROR (Status)) {\r
         goto Error;\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
+\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
         TerminalUpdateConsoleDevVariable (L"ConInDev", ParentDevicePath);\r
         TerminalUpdateConsoleDevVariable (L"ConOutDev", ParentDevicePath);\r
         TerminalUpdateConsoleDevVariable (L"ErrOutDev", ParentDevicePath);\r
@@ -627,26 +620,7 @@ TerminalDriverBindingStart (
   if (EFI_ERROR (Status)) {\r
     goto Error;\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
   //\r
   // Register the Parent-Child relationship via\r
   // EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
@@ -886,25 +860,6 @@ 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
@@ -1322,3 +1277,50 @@ 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