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
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
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
\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