Clean up gEfiHotPlugDeviceGuid in ConPlatformDxe.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7559 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff 2009-02-23 02:12:01 +00:00
parent f735177861
commit ea1ac7a0f7
3 changed files with 86 additions and 74 deletions

View File

@ -261,7 +261,7 @@ ConPlatformTextInDriverBindingStart (
// gEfiConsoleInDeviceGuid to the device handle directly. // gEfiConsoleInDeviceGuid to the device handle directly.
// The policy is, make hot plug device plug in and play immediately. // The policy is, make hot plug device plug in and play immediately.
// //
if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) { if (IsHotPlugDevice (DevicePath)) {
gBS->InstallMultipleProtocolInterfaces ( gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle, &ControllerHandle,
&gEfiConsoleInDeviceGuid, &gEfiConsoleInDeviceGuid,
@ -378,7 +378,7 @@ ConPlatformTextOutDriverBindingStart (
// and install gEfiConsoleOutDeviceGuid to the device handle directly. // and install gEfiConsoleOutDeviceGuid to the device handle directly.
// The policy is, make hot plug device plug in and play immediately. // The policy is, make hot plug device plug in and play immediately.
// //
if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) { if (IsHotPlugDevice (DevicePath)) {
gBS->InstallMultipleProtocolInterfaces ( gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle, &ControllerHandle,
&gEfiConsoleOutDeviceGuid, &gEfiConsoleOutDeviceGuid,
@ -482,11 +482,7 @@ ConPlatformTextInDriverBindingStop (
EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_DEVICE_PATH_PROTOCOL *DevicePath;
// //
// If it is not a hot-plug device, first delete it from the ConInDev variable. // Get the Device Path Protocol firstly
//
if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {
//
// Get the Device Path Protocol so the environment variables can be updated
// //
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
@ -496,7 +492,15 @@ ConPlatformTextInDriverBindingStop (
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
); );
if (!EFI_ERROR (Status)) {
if (EFI_ERROR (Status)) {
return Status;
}
//
// If it is not a hot-plug device, first delete it from the ConInDev variable.
//
if (!IsHotPlugDevice (DevicePath)) {
// //
// Remove DevicePath from ConInDev // Remove DevicePath from ConInDev
// //
@ -506,7 +510,7 @@ ConPlatformTextInDriverBindingStop (
DELETE DELETE
); );
} }
}
// //
// Uninstall the Console Device GUIDs from Controller Handle // Uninstall the Console Device GUIDs from Controller Handle
// //
@ -557,11 +561,7 @@ ConPlatformTextOutDriverBindingStop (
EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_DEVICE_PATH_PROTOCOL *DevicePath;
// //
// If it is not a hot-plug device, first delete it from the ConOutDev and ErrOutDev variable. // Get the Device Path Protocol firstly
//
if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {
//
// Get the Device Path Protocol so the environment variables can be updated
// //
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
@ -571,7 +571,15 @@ ConPlatformTextOutDriverBindingStop (
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
); );
if (!EFI_ERROR (Status)) {
if (EFI_ERROR (Status)) {
return Status;
}
//
// If it is not a hot-plug device, first delete it from the ConOutDev and ErrOutDev variable.
//
if (!IsHotPlugDevice (DevicePath)) {
// //
// Remove DevicePath from ConOutDev, and ErrOutDev // Remove DevicePath from ConOutDev, and ErrOutDev
// //
@ -586,7 +594,7 @@ ConPlatformTextOutDriverBindingStop (
DELETE DELETE
); );
} }
}
// //
// Uninstall the Console Device GUIDs from Controller Handle // Uninstall the Console Device GUIDs from Controller Handle
// //
@ -929,10 +937,12 @@ ConPlatformUpdateDeviceVariable (
} }
/** /**
Check if the device supports hot-plug. Check if the device supports hot-plug through its device path.
@param DriverBindingHandle Protocol instance pointer. This function could be updated to check more types of Hot Plug devices.
@param ControllerHandle Handle of device to check. Currently, it checks USB and PCCard device.
@param DevicePath Pointer to device's device path.
@retval TRUE The devcie is a hot-plug device @retval TRUE The devcie is a hot-plug device
@retval FALSE The devcie is not a hot-plug device. @retval FALSE The devcie is not a hot-plug device.
@ -940,26 +950,28 @@ ConPlatformUpdateDeviceVariable (
**/ **/
BOOLEAN BOOLEAN
IsHotPlugDevice ( IsHotPlugDevice (
EFI_HANDLE DriverBindingHandle, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
EFI_HANDLE ControllerHandle
) )
{ {
EFI_STATUS Status;
// //
// HotPlugDeviceGuid indicates ControllerHandle stands for a hot plug device. // Check device whether is hot plug device or not throught Device Path
// //
Status = gBS->OpenProtocol ( if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
ControllerHandle, (DevicePathSubType (DevicePath) == MSG_USB_DP ||
&gEfiHotPlugDeviceGuid, DevicePathSubType (DevicePath) == MSG_USB_CLASS_DP ||
NULL, DevicePathSubType (DevicePath) == MSG_USB_WWID_DP)) {
DriverBindingHandle, //
ControllerHandle, // If Device is USB device
EFI_OPEN_PROTOCOL_TEST_PROTOCOL //
); return TRUE;
if (EFI_ERROR (Status)) { }
return FALSE; if ((DevicePathType (DevicePath) == HARDWARE_DEVICE_PATH) &&
(DevicePathSubType (DevicePath) == HW_PCCARD_DP)) {
//
// If Device is PCCard
//
return TRUE;
} }
return TRUE; return FALSE;
} }

View File

@ -293,10 +293,12 @@ ConPlatformUpdateDeviceVariable (
); );
/** /**
Check if the device supports hot-plug. Check if the device supports hot-plug through its device path.
@param DriverBindingHandle Protocol instance pointer. This function could be updated to check more types of Hot Plug devices.
@param ControllerHandle Handle of device to check. Currently, it checks USB and PCCard device.
@param DevicePath Pointer to device's device path.
@retval TRUE The devcie is a hot-plug device @retval TRUE The devcie is a hot-plug device
@retval FALSE The devcie is not a hot-plug device. @retval FALSE The devcie is not a hot-plug device.
@ -304,8 +306,7 @@ ConPlatformUpdateDeviceVariable (
**/ **/
BOOLEAN BOOLEAN
IsHotPlugDevice ( IsHotPlugDevice (
EFI_HANDLE DriverBindingHandle, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
EFI_HANDLE ControllerHandle
); );
// //

View File

@ -87,5 +87,4 @@
gEfiDevicePathProtocolGuid ## TO_START gEfiDevicePathProtocolGuid ## TO_START
gEfiSimpleTextInProtocolGuid ## TO_START gEfiSimpleTextInProtocolGuid ## TO_START
gEfiSimpleTextOutProtocolGuid ## TO_START gEfiSimpleTextOutProtocolGuid ## TO_START
gEfiHotPlugDeviceGuid ## SOMETIMES_CONSUMES (Used to check if it's a hot-plug device)