From b6efdb868033efd9d0c90e9684f4c1c863741aa7 Mon Sep 17 00:00:00 2001 From: Jeff Fan Date: Mon, 23 Feb 2009 02:12:01 +0000 Subject: [PATCH] Clean up gEfiHotPlugDeviceGuid in ConPlatformDxe. --- .../Universal/Console/ConPlatformDxe/ConPlatform.c | 148 +++++++++++---------- .../Universal/Console/ConPlatformDxe/ConPlatform.h | 11 +- .../Console/ConPlatformDxe/ConPlatformDxe.inf | 1 - 3 files changed, 86 insertions(+), 74 deletions(-) diff --git a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c index f3aa4a4fb..0cb07a297 100644 --- a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c +++ b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c @@ -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, @@ -482,31 +482,35 @@ ConPlatformTextInDriverBindingStop ( 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 // @@ -557,36 +561,40 @@ ConPlatformTextOutDriverBindingStop ( 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. + + This function could be updated to check more types of Hot Plug devices. + Currently, it checks USB and PCCard device. - @param DriverBindingHandle Protocol instance pointer. - @param ControllerHandle Handle of device to check. + @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; } diff --git a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h index f7883dce6..d0fa03af5 100644 --- a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h +++ b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h @@ -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 ); // diff --git a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf index a96a6330a..892d051a1 100644 --- a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf +++ b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf @@ -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) \ No newline at end of file -- 2.11.4.GIT