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.
// The policy is, make hot plug device plug in and play immediately.
//
if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {
if (IsHotPlugDevice (DevicePath)) {
gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle,
&gEfiConsoleInDeviceGuid,
@ -378,7 +378,7 @@ ConPlatformTextOutDriverBindingStart (
// and install gEfiConsoleOutDeviceGuid to the device handle directly.
// The policy is, make hot plug device plug in and play immediately.
//
if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {
if (IsHotPlugDevice (DevicePath)) {
gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle,
&gEfiConsoleOutDeviceGuid,
@ -481,32 +481,36 @@ ConPlatformTextInDriverBindingStop (
EFI_STATUS Status;
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 (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {
if (!IsHotPlugDevice (DevicePath)) {
//
// Remove DevicePath from ConInDev
//
// Get the Device Path Protocol so the environment variables can be updated
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
(VOID **) &DevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
//
// Remove DevicePath from ConInDev
//
ConPlatformUpdateDeviceVariable (
L"ConInDev",
DevicePath,
DELETE
);
}
ConPlatformUpdateDeviceVariable (
L"ConInDev",
DevicePath,
DELETE
);
}
//
// Uninstall the Console Device GUIDs from Controller Handle
//
@ -556,37 +560,41 @@ ConPlatformTextOutDriverBindingStop (
EFI_STATUS Status;
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 (!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 (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
(VOID **) &DevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
//
// Remove DevicePath from ConOutDev, and ErrOutDev
//
ConPlatformUpdateDeviceVariable (
L"ConOutDev",
DevicePath,
DELETE
);
ConPlatformUpdateDeviceVariable (
L"ErrOutDev",
DevicePath,
DELETE
);
}
ConPlatformUpdateDeviceVariable (
L"ConOutDev",
DevicePath,
DELETE
);
ConPlatformUpdateDeviceVariable (
L"ErrOutDev",
DevicePath,
DELETE
);
}
//
// 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.
@param ControllerHandle Handle of device to check.
This function could be updated to check more types of Hot Plug devices.
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 FALSE The devcie is not a hot-plug device.
@ -940,26 +950,28 @@ ConPlatformUpdateDeviceVariable (
**/
BOOLEAN
IsHotPlugDevice (
EFI_HANDLE DriverBindingHandle,
EFI_HANDLE ControllerHandle
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
EFI_STATUS Status;
//
// HotPlugDeviceGuid indicates ControllerHandle stands for a hot plug device.
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiHotPlugDeviceGuid,
NULL,
DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
);
if (EFI_ERROR (Status)) {
return FALSE;
// Check device whether is hot plug device or not throught Device Path
//
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (DevicePath) == MSG_USB_DP ||
DevicePathSubType (DevicePath) == MSG_USB_CLASS_DP ||
DevicePathSubType (DevicePath) == MSG_USB_WWID_DP)) {
//
// If Device is USB device
//
return TRUE;
}
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.
@param ControllerHandle Handle of device to check.
This function could be updated to check more types of Hot Plug devices.
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 FALSE The devcie is not a hot-plug device.
@ -304,8 +306,7 @@ ConPlatformUpdateDeviceVariable (
**/
BOOLEAN
IsHotPlugDevice (
EFI_HANDLE DriverBindingHandle,
EFI_HANDLE ControllerHandle
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
//

View File

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