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
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
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
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
}\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
**/\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