From aa8f4f55ff80d0c1b1efcdae6d45db76849fc265 Mon Sep 17 00:00:00 2001 From: vanjeff Date: Mon, 23 Feb 2009 02:51:45 +0000 Subject: [PATCH] 1. Retired HotPlugDevice protocol. 2. Check devicepath node to get hot plug information. Currently, USB and PCCard device are checked. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7562 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c | 13 +-- MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h | 1 - MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf | 1 - MdeModulePkg/Include/Protocol/HotPlugDevice.h | 24 ---- MdeModulePkg/MdeModulePkg.dec | 4 - .../Console/ConPlatformDxe/ConPlatform.c | 45 ++++---- .../Console/ConPlatformDxe/ConPlatform.h | 1 - .../Universal/Console/TerminalDxe/Terminal.c | 106 +++++++++--------- .../Universal/Console/TerminalDxe/Terminal.h | 18 ++- .../Console/TerminalDxe/TerminalDxe.inf | 1 - 10 files changed, 99 insertions(+), 115 deletions(-) delete mode 100644 MdeModulePkg/Include/Protocol/HotPlugDevice.h diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c index 74f19c3278..07fec7c315 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c @@ -293,9 +293,8 @@ USBKeyboardDriverBindingStart ( // Install Simple Text Input Protocol and Simple Text Input Ex Protocol // for the USB keyboard device. // USB keyboard is a hot plug device, and expected to work immediately - // when plugging into system, so a HotPlugDeviceGuid is installed onto - // the usb keyboard device handle, to distinguish it from other conventional - // console devices. + // when plugging into system, other conventional console devices could + // distinguish it by its device path. // Status = gBS->InstallMultipleProtocolInterfaces ( &Controller, @@ -303,8 +302,6 @@ USBKeyboardDriverBindingStart ( &UsbKeyboardDevice->SimpleInput, &gEfiSimpleTextInputExProtocolGuid, &UsbKeyboardDevice->SimpleInputEx, - &gEfiHotPlugDeviceGuid, - NULL, NULL ); if (EFI_ERROR (Status)) { @@ -325,8 +322,6 @@ USBKeyboardDriverBindingStart ( &UsbKeyboardDevice->SimpleInput, &gEfiSimpleTextInputExProtocolGuid, &UsbKeyboardDevice->SimpleInputEx, - &gEfiHotPlugDeviceGuid, - NULL, NULL ); goto ErrorExit; @@ -356,8 +351,6 @@ USBKeyboardDriverBindingStart ( &UsbKeyboardDevice->SimpleInput, &gEfiSimpleTextInputExProtocolGuid, &UsbKeyboardDevice->SimpleInputEx, - &gEfiHotPlugDeviceGuid, - NULL, NULL ); goto ErrorExit; @@ -495,8 +488,6 @@ USBKeyboardDriverBindingStop ( &UsbKeyboardDevice->SimpleInput, &gEfiSimpleTextInputExProtocolGuid, &UsbKeyboardDevice->SimpleInputEx, - &gEfiHotPlugDeviceGuid, - NULL, NULL ); // diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h index 608d45a188..73191e6a27 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h @@ -23,7 +23,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #include diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf b/MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf index a724e8955a..b2953fb9cf 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf @@ -79,7 +79,6 @@ gEfiDevicePathProtocolGuid ## TO_START gEfiSimpleTextInProtocolGuid ## BY_START gEfiSimpleTextInputExProtocolGuid ## BY_START - gEfiHotPlugDeviceGuid ## BY_START ## # If HII Database Protocol exists, then keyboard layout from HII database is used. # Otherwise, USB keyboard module tries to use its carried default layout. diff --git a/MdeModulePkg/Include/Protocol/HotPlugDevice.h b/MdeModulePkg/Include/Protocol/HotPlugDevice.h deleted file mode 100644 index e36c826b38..0000000000 --- a/MdeModulePkg/Include/Protocol/HotPlugDevice.h +++ /dev/null @@ -1,24 +0,0 @@ -/** @file - This protocol guid is used to specify the device is the hot plug device. - If the device is the hot plug device, this protocol guid - will be installed into this device handle. - -Copyright (c) 2006 - 2008, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __HOT_PLUG_DEVICE_H__ -#define __HOT_PLUG_DEVICE_H__ - -#define HOT_PLUG_DEVICE_GUID \ - { 0x220ac432, 0x1d43, 0x49e5, {0xa7, 0x4f, 0x4c, 0x9d, 0xa6, 0x7a, 0xd2, 0x3b } } - -extern EFI_GUID gEfiHotPlugDeviceGuid; -#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index b3ad2dc2c3..386b0a0f70 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -269,10 +269,6 @@ ## Include/Protocol/SimpleTextInExNotify.h gSimpleTextInExNotifyGuid = { 0x856f2def, 0x4e93, 0x4d6b, { 0x94, 0xce, 0x1c, 0xfe, 0x47, 0x01, 0x3e, 0xa5 }} - ## Protocol Guid specify the device is the hot plug device. - ## Include/Protocol/HotPlugDevice.h - gEfiHotPlugDeviceGuid = { 0x220AC432, 0x1D43, 0x49E5, { 0xA7, 0x4F, 0x4C, 0x9D, 0xA6, 0x7A, 0xD2, 0x3B }} - [PcdsFeatureFlag.common] ## Indicate whether platform can support update capsule across a system reset gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset|FALSE|BOOLEAN|0x0001001d diff --git a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c index 0cb07a2971..f6483ed1fd 100644 --- a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c +++ b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c @@ -256,7 +256,7 @@ ConPlatformTextInDriverBindingStart ( return Status; } // - // Check the device handle, if it is a hot plug device, + // Check the device path, if it is a hot plug device, // do not put the device path into ConInDev, and install // gEfiConsoleInDeviceGuid to the device handle directly. // The policy is, make hot plug device plug in and play immediately. @@ -373,7 +373,7 @@ ConPlatformTextOutDriverBindingStart ( return Status; } // - // Check the device handle, if it is a hot plug device, + // Check the device path, if it is a hot plug device, // do not put the device path into ConOutDev and ErrOutDev, // and install gEfiConsoleOutDeviceGuid to the device handle directly. // The policy is, make hot plug device plug in and play immediately. @@ -953,24 +953,31 @@ IsHotPlugDevice ( IN EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { - // - // 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 + EFI_DEVICE_PATH_PROTOCOL *CheckDevicePath; + + CheckDevicePath = DevicePath; + while (!IsDevicePathEnd (CheckDevicePath)) { // - return TRUE; + // Check device whether is hot plug device or not throught Device Path + // + if ((DevicePathType (CheckDevicePath) == MESSAGING_DEVICE_PATH) && + (DevicePathSubType (CheckDevicePath) == MSG_USB_DP || + DevicePathSubType (CheckDevicePath) == MSG_USB_CLASS_DP || + DevicePathSubType (CheckDevicePath) == MSG_USB_WWID_DP)) { + // + // If Device is USB device + // + return TRUE; + } + if ((DevicePathType (CheckDevicePath) == HARDWARE_DEVICE_PATH) && + (DevicePathSubType (CheckDevicePath) == HW_PCCARD_DP)) { + // + // If Device is PCCard + // + return TRUE; + } + + CheckDevicePath = NextDevicePathNode (CheckDevicePath); } return FALSE; diff --git a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h index d0fa03af5b..a47ad1ce30 100644 --- a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h +++ b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h @@ -20,7 +20,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #include #include diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c index 92ec98a09f..1da6d90677 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c @@ -300,19 +300,12 @@ TerminalDriverBindingStart ( if (EFI_ERROR (Status)) { goto Error; } - // - // if the serial device is a hot plug device, do not update the - // ConInDev, ConOutDev, and StdErrDev variables. - // - Status = gBS->OpenProtocol ( - Controller, - &gEfiHotPlugDeviceGuid, - NULL, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - if (EFI_ERROR (Status)) { + + if (IsHotPlugDevice (ParentDevicePath)) { + // + // if the serial device is a hot plug device, do not update the + // ConInDev, ConOutDev, and StdErrDev variables. + // TerminalUpdateConsoleDevVariable (L"ConInDev", ParentDevicePath); TerminalUpdateConsoleDevVariable (L"ConOutDev", ParentDevicePath); TerminalUpdateConsoleDevVariable (L"ErrOutDev", ParentDevicePath); @@ -627,26 +620,7 @@ TerminalDriverBindingStart ( if (EFI_ERROR (Status)) { goto Error; } - // - // if the serial device is a hot plug device, attaches the HotPlugGuid - // onto the terminal device handle. - // - Status = gBS->OpenProtocol ( - Controller, - &gEfiHotPlugDeviceGuid, - NULL, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &TerminalDevice->Handle, - &gEfiHotPlugDeviceGuid, - NULL, - NULL - ); - } + // // Register the Parent-Child relationship via // EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. @@ -886,25 +860,6 @@ TerminalDriverBindingStop ( FreeUnicodeStringTable (TerminalDevice->ControllerNameTable); } - Status = gBS->OpenProtocol ( - ChildHandleBuffer[Index], - &gEfiHotPlugDeviceGuid, - NULL, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - Status = gBS->UninstallMultipleProtocolInterfaces ( - ChildHandleBuffer[Index], - &gEfiHotPlugDeviceGuid, - NULL, - NULL - ); - } else { - Status = EFI_SUCCESS; - } - gBS->CloseEvent (TerminalDevice->TwoSecondTimeOut); gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey); gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx); @@ -1322,3 +1277,50 @@ InitializeTerminal( return Status; } + +/** + 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 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. + +**/ +BOOLEAN +IsHotPlugDevice ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + EFI_DEVICE_PATH_PROTOCOL *CheckDevicePath; + + CheckDevicePath = DevicePath; + while (!IsDevicePathEnd (CheckDevicePath)) { + // + // Check device whether is hot plug device or not throught Device Path + // + if ((DevicePathType (CheckDevicePath) == MESSAGING_DEVICE_PATH) && + (DevicePathSubType (CheckDevicePath) == MSG_USB_DP || + DevicePathSubType (CheckDevicePath) == MSG_USB_CLASS_DP || + DevicePathSubType (CheckDevicePath) == MSG_USB_WWID_DP)) { + // + // If Device is USB device + // + return TRUE; + } + if ((DevicePathType (CheckDevicePath) == HARDWARE_DEVICE_PATH) && + (DevicePathSubType (CheckDevicePath) == HW_PCCARD_DP)) { + // + // If Device is PCCard + // + return TRUE; + } + + CheckDevicePath = NextDevicePathNode (CheckDevicePath); + } + + return FALSE; +} diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h index af3afecd15..7327da003a 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h @@ -22,7 +22,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include -#include #include #include #include @@ -1347,4 +1346,21 @@ TerminalIsValidEfiCntlChar ( IN CHAR16 CharC ); +/** + 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 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. + +**/ +BOOLEAN +IsHotPlugDevice ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + #endif diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf index 204ca6040b..1d849c698b 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf @@ -73,7 +73,6 @@ gEfiSimpleTextInputExProtocolGuid ## BY_START gEfiSimpleTextOutProtocolGuid ## BY_START gSimpleTextInExNotifyGuid ## SOMETIMES_CONSUMES - gEfiHotPlugDeviceGuid ## SOMETIMES_CONSUMES [Pcd] gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueRemoteConsoleError -- 2.39.2