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,
@ -481,32 +481,36 @@ ConPlatformTextInDriverBindingStop (
EFI_STATUS Status; EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_DEVICE_PATH_PROTOCOL *DevicePath;
//
// Get the Device Path Protocol firstly
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
(VOID **) &DevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return Status;
}
// //
// If it is not a hot-plug device, first delete it from the ConInDev variable. // If it is not a hot-plug device, first delete it from the ConInDev variable.
// //
if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) { if (!IsHotPlugDevice (DevicePath)) {
//
// Remove DevicePath from ConInDev
// //
// Get the Device Path Protocol so the environment variables can be updated ConPlatformUpdateDeviceVariable (
// L"ConInDev",
Status = gBS->OpenProtocol ( DevicePath,
ControllerHandle, DELETE
&gEfiDevicePathProtocolGuid, );
(VOID **) &DevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
//
// Remove DevicePath from ConInDev
//
ConPlatformUpdateDeviceVariable (
L"ConInDev",
DevicePath,
DELETE
);
}
} }
// //
// Uninstall the Console Device GUIDs from Controller Handle // Uninstall the Console Device GUIDs from Controller Handle
// //
@ -556,37 +560,41 @@ ConPlatformTextOutDriverBindingStop (
EFI_STATUS Status; EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_DEVICE_PATH_PROTOCOL *DevicePath;
//
// Get the Device Path Protocol firstly
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
(VOID **) &DevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return Status;
}
// //
// If it is not a hot-plug device, first delete it from the ConOutDev and ErrOutDev variable. // If it is not a hot-plug device, first delete it from the ConOutDev and ErrOutDev variable.
// //
if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) { if (!IsHotPlugDevice (DevicePath)) {
// //
// Get the Device Path Protocol so the environment variables can be updated // Remove DevicePath from ConOutDev, and ErrOutDev
// //
Status = gBS->OpenProtocol ( ConPlatformUpdateDeviceVariable (
ControllerHandle, L"ConOutDev",
&gEfiDevicePathProtocolGuid, DevicePath,
(VOID **) &DevicePath, DELETE
This->DriverBindingHandle, );
ControllerHandle, ConPlatformUpdateDeviceVariable (
EFI_OPEN_PROTOCOL_GET_PROTOCOL L"ErrOutDev",
); DevicePath,
if (!EFI_ERROR (Status)) { DELETE
// );
// Remove DevicePath from ConOutDev, and ErrOutDev
//
ConPlatformUpdateDeviceVariable (
L"ConOutDev",
DevicePath,
DELETE
);
ConPlatformUpdateDeviceVariable (
L"ErrOutDev",
DevicePath,
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)