X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FConsole%2FConPlatformDxe%2FConPlatform.c;h=e40e2cc804ea6bcea4e6e34679a9b7ed427c0e10;hp=f2f7d4caecf96064ee1732938b770a0930530d3a;hb=1ccdbf2a3e61fe9494fcd39432107ba0eb74f584;hpb=c5ed97f62898afc846af1751ac10ae874f93e24c diff --git a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c index f2f7d4caec..e40e2cc804 100644 --- a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c +++ b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c @@ -1,8 +1,8 @@ /** @file - Console Platfrom DXE Driver, install Console Device Guids and update Console + Console Platform DXE Driver, install Console Device Guids and update Console Environment Variables. -Copyright (c) 2006 - 2008, Intel Corporation.
+Copyright (c) 2006 - 2010, 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 @@ -226,6 +226,7 @@ ConPlatformTextInDriverBindingStart ( EFI_STATUS Status; EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn; + BOOLEAN IsInConInVariable; // // Get the Device Path Protocol so the environment variables can be updated @@ -256,18 +257,41 @@ ConPlatformTextInDriverBindingStart ( return Status; } // - // Check the device handle, if it is a hot plug device, + // Check if the device path is in ConIn Variable + // + IsInConInVariable = FALSE; + Status = ConPlatformUpdateDeviceVariable ( + L"ConIn", + DevicePath, + Check + ); + if (!EFI_ERROR (Status)) { + IsInConInVariable = TRUE; + } + + // + // 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. // - if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) { + if (IsHotPlugDevice (DevicePath)) { gBS->InstallMultipleProtocolInterfaces ( &ControllerHandle, &gEfiConsoleInDeviceGuid, NULL, NULL ); + // + // Append the device path to ConInDev only if it is in ConIn variable. + // + if (IsInConInVariable) { + ConPlatformUpdateDeviceVariable ( + L"ConInDev", + DevicePath, + Append + ); + } } else { // // If it is not a hot-plug device, append the device path to the @@ -276,20 +300,14 @@ ConPlatformTextInDriverBindingStart ( ConPlatformUpdateDeviceVariable ( L"ConInDev", DevicePath, - APPEND + Append ); // - // If the device path is successfully added to the ConIn environment variable, + // If the device path is an instance in the ConIn environment variable, // then install EfiConsoleInDeviceGuid onto ControllerHandle // - Status = ConPlatformUpdateDeviceVariable ( - L"ConIn", - DevicePath, - CHECK - ); - - if (!EFI_ERROR (Status)) { + if (IsInConInVariable) { gBS->InstallMultipleProtocolInterfaces ( &ControllerHandle, &gEfiConsoleInDeviceGuid, @@ -317,7 +335,7 @@ ConPlatformTextInDriverBindingStart ( Device GUID on ControllerHandle. If this devcie is not one hot-plug devce, append its device path into the - console environment variables ConOutDev, StdErrDev. + console environment variables ConOutDev, ErrOutDev. @param This Protocol instance pointer. @param ControllerHandle Handle of device to bind driver to @@ -341,6 +359,8 @@ ConPlatformTextOutDriverBindingStart ( EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut; BOOLEAN NeedClose; + BOOLEAN IsInConOutVariable; + BOOLEAN IsInErrOutVariable; NeedClose = TRUE; @@ -373,18 +393,61 @@ ConPlatformTextOutDriverBindingStart ( return Status; } // - // Check the device handle, if it is a hot plug device, - // do not put the device path into ConOutDev and StdErrDev, + // Check if the device path is in ConOut & ErrOut Variable + // + IsInConOutVariable = FALSE; + Status = ConPlatformUpdateDeviceVariable ( + L"ConOut", + DevicePath, + Check + ); + if (!EFI_ERROR (Status)) { + IsInConOutVariable = TRUE; + } + + IsInErrOutVariable = FALSE; + Status = ConPlatformUpdateDeviceVariable ( + L"ErrOut", + DevicePath, + Check + ); + if (!EFI_ERROR (Status)) { + IsInErrOutVariable = TRUE; + } + + // + // 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. // - if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) { + if (IsHotPlugDevice (DevicePath)) { gBS->InstallMultipleProtocolInterfaces ( &ControllerHandle, &gEfiConsoleOutDeviceGuid, NULL, NULL ); + // + // Append the device path to ConOutDev only if it is in ConOut variable. + // + if (IsInConOutVariable) { + ConPlatformUpdateDeviceVariable ( + L"ConOutDev", + DevicePath, + Append + ); + } + // + // Append the device path to ErrOutDev only if it is in ErrOut variable. + // + if (IsInErrOutVariable) { + ConPlatformUpdateDeviceVariable ( + L"ErrOutDev", + DevicePath, + Append + ); + } } else { // // If it is not a hot-plug device, first append the device path to the @@ -393,28 +456,22 @@ ConPlatformTextOutDriverBindingStart ( ConPlatformUpdateDeviceVariable ( L"ConOutDev", DevicePath, - APPEND + Append ); // - // Then append the device path to the StdErrDev environment variable + // Then append the device path to the ErrOutDev environment variable // ConPlatformUpdateDeviceVariable ( L"ErrOutDev", DevicePath, - APPEND + Append ); // - // If the device path is successfully added to the ConOut environment variable, + // If the device path is an instance in the ConOut environment variable, // then install EfiConsoleOutDeviceGuid onto ControllerHandle // - Status = ConPlatformUpdateDeviceVariable ( - L"ConOut", - DevicePath, - CHECK - ); - - if (!EFI_ERROR (Status)) { + if (IsInConOutVariable) { NeedClose = FALSE; Status = gBS->InstallMultipleProtocolInterfaces ( &ControllerHandle, @@ -424,15 +481,10 @@ ConPlatformTextOutDriverBindingStart ( ); } // - // If the device path is successfully added to the StdErr environment variable, + // If the device path is an instance in the ErrOut environment variable, // then install EfiStandardErrorDeviceGuid onto ControllerHandle // - Status = ConPlatformUpdateDeviceVariable ( - L"ErrOut", - DevicePath, - CHECK - ); - if (!EFI_ERROR (Status)) { + if (IsInErrOutVariable) { NeedClose = FALSE; gBS->InstallMultipleProtocolInterfaces ( &ControllerHandle, @@ -482,31 +534,30 @@ ConPlatformTextInDriverBindingStop ( 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 + // + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiDevicePathProtocolGuid, + (VOID **) &DevicePath, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + // + // If there is device path on ControllerHandle // - if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) { + if (!EFI_ERROR (Status)) { // - // Get the Device Path Protocol so the environment variables can be updated + // Remove DevicePath from ConInDev if exists. // - 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 // @@ -520,11 +571,11 @@ ConPlatformTextInDriverBindingStop ( // Close the Simple Text Input Protocol // gBS->CloseProtocol ( - ControllerHandle, - &gEfiSimpleTextInProtocolGuid, - This->DriverBindingHandle, - ControllerHandle - ); + ControllerHandle, + &gEfiSimpleTextInProtocolGuid, + This->DriverBindingHandle, + ControllerHandle + ); return EFI_SUCCESS; } @@ -557,36 +608,32 @@ ConPlatformTextOutDriverBindingStop ( EFI_DEVICE_PATH_PROTOCOL *DevicePath; // - // If it is not a hot-plug device, first delete it from the ConOutDev and StdErrDev variable. + // Get the Device Path Protocol firstly // - if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) { + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiDevicePathProtocolGuid, + (VOID **) &DevicePath, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (!EFI_ERROR (Status)) { // - // Get the Device Path Protocol so the environment variables can be updated + // Remove DevicePath from ConOutDev and ErrOutDev if exists. // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiDevicePathProtocolGuid, - (VOID **) &DevicePath, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - // - // Remove DevicePath from ConOutDev, and StdErrDev - // - 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 // @@ -655,7 +702,7 @@ ConPlatformUnInstallProtocol ( } /** - Get the necessary size of buffer and read the variabe. + Get the necessary size of buffer and read the variable. First get the necessary size of buffer. Then read the EFI variable (Name) and return a dynamically allocated @@ -824,7 +871,7 @@ ConPlatformMatchDevicePaths ( Update console environment variables. @param VariableName Console environment variables, ConOutDev, ConInDev - StdErrDev, ConIn or ConOut. + ErrOutDev, ConIn ,ConOut or ErrOut. @param DevicePath Console devcie's device path. @param Operation Variable operations, including APPEND, CHECK and DELETE. @@ -854,7 +901,7 @@ ConPlatformUpdateDeviceVariable ( // VariableDevicePath = ConPlatformGetVariable (VariableName); - if (Operation != DELETE) { + if (Operation != Delete) { // // Match specified DevicePath in Console Variable. // @@ -865,7 +912,7 @@ ConPlatformUpdateDeviceVariable ( FALSE ); - if ((Operation == CHECK) || (!EFI_ERROR (Status))) { + if ((Operation == Check) || (!EFI_ERROR (Status))) { // // Branch here includes 2 cases: // 1. Operation is CHECK, simply return Status. @@ -929,10 +976,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 +989,36 @@ ConPlatformUpdateDeviceVariable ( **/ BOOLEAN IsHotPlugDevice ( - EFI_HANDLE DriverBindingHandle, - EFI_HANDLE ControllerHandle + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { - EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *CheckDevicePath; - // - // 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; + 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 TRUE; + return FALSE; } +