X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FConsole%2FConSplitterDxe%2FConSplitter.c;h=6fc0e4796f9c2fa02615e0645af0d69a0a049418;hb=9d510e61fceee7b92955ef9a3c20343752d8ce3f;hp=67052b20b3a58c5cea773727ca7e1b5648f362f7;hpb=9e604fe42d90c05adb08cf86bc1843c436f523dc;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c index 67052b20b3..6fc0e4796f 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c @@ -1,6 +1,7 @@ /** @file - Console Splitter Driver. Any Handle that attatched - EFI_CONSOLE_IDENTIFIER_PROTOCOL can be bound by this driver. + Console Splitter Driver. Any Handle that attatched console I/O protocols + (Console In device, Console Out device, Console Error device, Simple Pointer + protocol, Absolute Pointer protocol) can be bound by this driver. So far it works like any other driver by opening a SimpleTextIn and/or SimpleTextOut protocol with EFI_OPEN_PROTOCOL_BY_DRIVER attributes. The big @@ -8,33 +9,34 @@ handle, or construct a child handle like a standard device or bus driver. This driver produces three virtual handles as children, one for console input splitter, one for console output splitter and one for error output splitter. - EFI_CONSOLE_SPLIT_PROTOCOL will be attatched onto each virtual handle to - identify the splitter type. + These 3 virtual handles would be installed on gST. - Each virtual handle, that supports both the EFI_CONSOLE_SPLIT_PROTOCOL - and Console I/O protocol, will be produced in the driver entry point. - The virtual handle are added on driver entry and never removed. - Such design ensures sytem function well during none console device situation. + Each virtual handle, that supports the Console I/O protocol, will be produced + in the driver entry point. The virtual handle are added on driver entry and + never removed. Such design ensures sytem function well during none console + device situation. -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. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include "ConSplitter.h" // -// Template for Text In Splitter +// Identify if ConIn is connected in PcdConInConnectOnDemand enabled mode. +// default not connect +// +BOOLEAN mConInIsConnect = FALSE; + +// +// Text In Splitter Private Data template // -TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { +GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE, (EFI_HANDLE) NULL, + { ConSplitterTextInReset, ConSplitterTextInReadKeyStroke, @@ -43,6 +45,7 @@ TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { 0, (EFI_SIMPLE_TEXT_INPUT_PROTOCOL **) NULL, 0, + { ConSplitterTextInResetEx, ConSplitterTextInReadKeyStrokeEx, @@ -58,6 +61,10 @@ TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { (LIST_ENTRY *) NULL, (LIST_ENTRY *) NULL }, + (EFI_KEY_DATA *) NULL, + 0, + 0, + FALSE, { ConSplitterSimplePointerReset, @@ -82,64 +89,49 @@ TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { (EFI_EVENT) NULL, (EFI_ABSOLUTE_POINTER_MODE *) NULL }, - { - 0, //AbsoluteMinX - 0, //AbsoluteMinY - 0, //AbsoluteMinZ - 0x10000, //AbsoluteMaxX - 0x10000, //AbsoluteMaxY - 0x10000, //AbsoluteMaxZ - 0 //Attributes + 0, // AbsoluteMinX + 0, // AbsoluteMinY + 0, // AbsoluteMinZ + 0x10000, // AbsoluteMaxX + 0x10000, // AbsoluteMaxY + 0x10000, // AbsoluteMaxZ + 0 // Attributes }, 0, (EFI_ABSOLUTE_POINTER_PROTOCOL **) NULL, 0, FALSE, - FALSE, - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }, - 0, - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }, - (EFI_EVENT) NULL, - FALSE, FALSE }; + // -// Template for Uga Draw Protocol +// Uga Draw Protocol Private Data template // GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate = { - ConSpliterUgaDrawGetMode, - ConSpliterUgaDrawSetMode, - ConSpliterUgaDrawBlt + ConSplitterUgaDrawGetMode, + ConSplitterUgaDrawSetMode, + ConSplitterUgaDrawBlt }; // -// Template for Graphics Output Protocol +// Graphics Output Protocol Private Data template // GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate = { - ConSpliterGraphicsOutputQueryMode, - ConSpliterGraphicsOutputSetMode, - ConSpliterGraphicsOutputBlt, + ConSplitterGraphicsOutputQueryMode, + ConSplitterGraphicsOutputSetMode, + ConSplitterGraphicsOutputBlt, NULL }; + // -// Template for Text Out Splitter +// Text Out Splitter Private Data template // -TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = { +GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = { TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE, (EFI_HANDLE) NULL, { @@ -162,6 +154,7 @@ TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = { 0, FALSE, }, + { NULL, NULL, @@ -171,42 +164,29 @@ TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = { 0, 0, 0, - (EFI_UGA_PIXEL *) NULL, + { NULL, NULL, NULL, NULL }, - (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL, (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) NULL, 0, 0, - TRUE, - { - ConSpliterConsoleControlGetMode, - ConSpliterConsoleControlSetMode, - ConSpliterConsoleControlLockStdIn - }, 0, (TEXT_OUT_AND_GOP_DATA *) NULL, 0, (TEXT_OUT_SPLITTER_QUERY_DATA *) NULL, 0, - (INT32 *) NULL, - - EfiConsoleControlScreenText, - 0, - 0, - (CHAR16 *) NULL, (INT32 *) NULL }; // -// Template for Standard Error Text Out Splitter +// Standard Error Text Out Splitter Data Template // -TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = { +GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = { TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE, (EFI_HANDLE) NULL, { @@ -229,6 +209,7 @@ TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = { 0, FALSE, }, + { NULL, NULL, @@ -238,35 +219,22 @@ TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = { 0, 0, 0, - (EFI_UGA_PIXEL *) NULL, + { NULL, NULL, NULL, NULL }, - (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL, (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) NULL, 0, 0, - TRUE, - { - ConSpliterConsoleControlGetMode, - ConSpliterConsoleControlSetMode, - ConSpliterConsoleControlLockStdIn - }, 0, (TEXT_OUT_AND_GOP_DATA *) NULL, 0, (TEXT_OUT_SPLITTER_QUERY_DATA *) NULL, 0, - (INT32 *) NULL, - - EfiConsoleControlScreenText, - 0, - 0, - (CHAR16 *) NULL, (INT32 *) NULL }; @@ -283,59 +251,175 @@ EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding = { }; // -// Driver binding instance for Simple Pointer protocol +// Driver binding instance for Console Out device // -EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding = { - ConSplitterSimplePointerDriverBindingSupported, - ConSplitterSimplePointerDriverBindingStart, - ConSplitterSimplePointerDriverBindingStop, +EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding = { + ConSplitterConOutDriverBindingSupported, + ConSplitterConOutDriverBindingStart, + ConSplitterConOutDriverBindingStop, 0xa, NULL, NULL }; // -// Driver binding instance for Absolute Pointer protocol +// Driver binding instance for Standard Error device // -EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding = { - ConSplitterAbsolutePointerDriverBindingSupported, - ConSplitterAbsolutePointerDriverBindingStart, - ConSplitterAbsolutePointerDriverBindingStop, +EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding = { + ConSplitterStdErrDriverBindingSupported, + ConSplitterStdErrDriverBindingStart, + ConSplitterStdErrDriverBindingStop, 0xa, NULL, NULL }; // -// Driver binding instance for Console Out device +// Driver binding instance for Simple Pointer protocol // -EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding = { - ConSplitterConOutDriverBindingSupported, - ConSplitterConOutDriverBindingStart, - ConSplitterConOutDriverBindingStop, +EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding = { + ConSplitterSimplePointerDriverBindingSupported, + ConSplitterSimplePointerDriverBindingStart, + ConSplitterSimplePointerDriverBindingStop, 0xa, NULL, NULL }; // -// Driver binding instance for Standard Error device +// Driver binding instance for Absolute Pointer protocol // -EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding = { - ConSplitterStdErrDriverBindingSupported, - ConSplitterStdErrDriverBindingStart, - ConSplitterStdErrDriverBindingStop, +EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding = { + ConSplitterAbsolutePointerDriverBindingSupported, + ConSplitterAbsolutePointerDriverBindingStart, + ConSplitterAbsolutePointerDriverBindingStop, 0xa, NULL, NULL }; /** - The user Entry Point for module ConSplitter. The user code starts with this function. + Key notify for toggle state sync. + + @param KeyData A pointer to a buffer that is filled in with + the keystroke information for the key that was + pressed. + + @retval EFI_SUCCESS Toggle state sync successfully. + +**/ +EFI_STATUS +EFIAPI +ToggleStateSyncKeyNotify ( + IN EFI_KEY_DATA *KeyData + ) +{ + UINTN Index; + + if (((KeyData->KeyState.KeyToggleState & KEY_STATE_VALID_EXPOSED) == KEY_STATE_VALID_EXPOSED) && + (KeyData->KeyState.KeyToggleState != mConIn.PhysicalKeyToggleState)) { + // + // There is toggle state change, sync to other console input devices. + // + for (Index = 0; Index < mConIn.CurrentNumberOfExConsoles; Index++) { + mConIn.TextInExList[Index]->SetState ( + mConIn.TextInExList[Index], + &KeyData->KeyState.KeyToggleState + ); + } + mConIn.PhysicalKeyToggleState = KeyData->KeyState.KeyToggleState; + DEBUG ((EFI_D_INFO, "Current toggle state is 0x%02x\n", mConIn.PhysicalKeyToggleState)); + } + + return EFI_SUCCESS; +} + +/** + Initialization for toggle state sync. + + @param Private Text In Splitter pointer. + +**/ +VOID +ToggleStateSyncInitialization ( + IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private + ) +{ + EFI_KEY_DATA KeyData; + VOID *NotifyHandle; + + // + // Initialize PhysicalKeyToggleState that will be synced to new console + // input device to turn on physical TextInEx partial key report for + // toggle state sync. + // + Private->PhysicalKeyToggleState = KEY_STATE_VALID_EXPOSED; + + // + // Initialize VirtualKeyStateExported to let the virtual TextInEx not report + // the partial key even though the physical TextInEx turns on the partial + // key report. The virtual TextInEx will report the partial key after it is + // required by calling SetState(X | KEY_STATE_VALID_EXPOSED) explicitly. + // + Private->VirtualKeyStateExported = FALSE; + + // + // Register key notify for toggle state sync. + // + KeyData.Key.ScanCode = SCAN_NULL; + KeyData.Key.UnicodeChar = CHAR_NULL; + KeyData.KeyState.KeyShiftState = 0; + KeyData.KeyState.KeyToggleState = 0; + Private->TextInEx.RegisterKeyNotify ( + &Private->TextInEx, + &KeyData, + ToggleStateSyncKeyNotify, + &NotifyHandle + ); +} + +/** + Reinitialization for toggle state sync. + + @param Private Text In Splitter pointer. + +**/ +VOID +ToggleStateSyncReInitialization ( + IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private + ) +{ + UINTN Index; + + // + // Reinitialize PhysicalKeyToggleState that will be synced to new console + // input device to turn on physical TextInEx partial key report for + // toggle state sync. + // + Private->PhysicalKeyToggleState = KEY_STATE_VALID_EXPOSED; + + // + // Reinitialize VirtualKeyStateExported to let the virtual TextInEx not report + // the partial key even though the physical TextInEx turns on the partial + // key report. The virtual TextInEx will report the partial key after it is + // required by calling SetState(X | KEY_STATE_VALID_EXPOSED) explicitly. + // + Private->VirtualKeyStateExported = FALSE; + + for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) { + Private->TextInExList[Index]->SetState ( + Private->TextInExList[Index], + &Private->PhysicalKeyToggleState + ); + } +} + +/** + The Entry Point for module ConSplitter. The user code starts with this function. Installs driver module protocols and. Creates virtual device handles for ConIn, ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol, - Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers. + Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers. Installs Graphics Output protocol and/or UGA Draw protocol if needed. @param[in] ImageHandle The firmware allocated handle for the EFI image. @@ -407,29 +491,18 @@ ConSplitterDriverEntry( ); ASSERT_EFI_ERROR (Status); - + // + // Either Graphics Output protocol or UGA Draw protocol must be supported. + // ASSERT (FeaturePcdGet (PcdConOutGopSupport) || FeaturePcdGet (PcdConOutUgaSupport)); + // - // The driver creates virtual handles for ConIn, ConOut, and StdErr. + // The driver creates virtual handles for ConIn, ConOut, StdErr. // The virtual handles will always exist even if no console exist in the // system. This is need to support hotplug devices like USB. // // - // Create virtual device handle for StdErr Splitter - // - Status = ConSplitterTextOutConstructor (&mStdErr); - if (!EFI_ERROR (Status)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &mStdErr.VirtualHandle, - &gEfiSimpleTextOutProtocolGuid, - &mStdErr.TextOut, - &gEfiPrimaryStandardErrorDeviceGuid, - NULL, - NULL - ); - } - // // Create virtual device handle for ConIn Splitter // Status = ConSplitterTextInConstructor (&mConIn); @@ -444,13 +517,12 @@ ConSplitterDriverEntry( &mConIn.SimplePointer, &gEfiAbsolutePointerProtocolGuid, &mConIn.AbsolutePointer, - &gEfiPrimaryConsoleInDeviceGuid, - NULL, NULL ); if (!EFI_ERROR (Status)) { // // Update the EFI System Table with new virtual console + // and update the pointer to Simple Text Input protocol. // gST->ConsoleInHandle = mConIn.VirtualHandle; gST->ConIn = &mConIn.TextIn; @@ -461,68 +533,44 @@ ConSplitterDriverEntry( // Status = ConSplitterTextOutConstructor (&mConOut); if (!EFI_ERROR (Status)) { - if (!FeaturePcdGet (PcdConOutGopSupport)) { - // - // In EFI mode, UGA Draw protocol is installed - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &mConOut.VirtualHandle, - &gEfiSimpleTextOutProtocolGuid, - &mConOut.TextOut, - &gEfiUgaDrawProtocolGuid, - &mConOut.UgaDraw, - &gEfiConsoleControlProtocolGuid, - &mConOut.ConsoleControl, - &gEfiPrimaryConsoleOutDeviceGuid, - NULL, - NULL - ); - } else if (!FeaturePcdGet (PcdConOutUgaSupport)) { - // - // In UEFI mode, Graphics Output Protocol is installed on virtual handle. - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &mConOut.VirtualHandle, - &gEfiSimpleTextOutProtocolGuid, - &mConOut.TextOut, - &gEfiGraphicsOutputProtocolGuid, - &mConOut.GraphicsOutput, - &gEfiConsoleControlProtocolGuid, - &mConOut.ConsoleControl, - &gEfiPrimaryConsoleOutDeviceGuid, - NULL, - NULL - ); - } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &mConOut.VirtualHandle, + &gEfiSimpleTextOutProtocolGuid, + &mConOut.TextOut, + NULL + ); + if (!EFI_ERROR (Status)) { // - // In EFI and UEFI comptible mode, Graphics Output Protocol and UGA are - // installed on virtual handle. + // Update the EFI System Table with new virtual console + // and Update the pointer to Text Output protocol. // - Status = gBS->InstallMultipleProtocolInterfaces ( - &mConOut.VirtualHandle, - &gEfiSimpleTextOutProtocolGuid, - &mConOut.TextOut, - &gEfiGraphicsOutputProtocolGuid, - &mConOut.GraphicsOutput, - &gEfiUgaDrawProtocolGuid, - &mConOut.UgaDraw, - &gEfiConsoleControlProtocolGuid, - &mConOut.ConsoleControl, - &gEfiPrimaryConsoleOutDeviceGuid, - NULL, - NULL - ); + gST->ConsoleOutHandle = mConOut.VirtualHandle; + gST->ConOut = &mConOut.TextOut; } + } + + // + // Create virtual device handle for StdErr Splitter + // + Status = ConSplitterTextOutConstructor (&mStdErr); + if (!EFI_ERROR (Status)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &mStdErr.VirtualHandle, + &gEfiSimpleTextOutProtocolGuid, + &mStdErr.TextOut, + NULL + ); if (!EFI_ERROR (Status)) { // // Update the EFI System Table with new virtual console + // and update the pointer to Text Output protocol. // - gST->ConsoleOutHandle = mConOut.VirtualHandle; - gST->ConOut = &mConOut.TextOut; + gST->StandardErrorHandle = mStdErr.VirtualHandle; + gST->StdErr = &mStdErr.TextOut; } - } + // // Update the CRC32 in the EFI System Table header // @@ -537,7 +585,6 @@ ConSplitterDriverEntry( } - /** Construct console input devices' private data. @@ -555,9 +602,10 @@ ConSplitterTextInConstructor ( ) { EFI_STATUS Status; + UINTN TextInExListCount; // - // Initilize console input splitter's private data. + // Allocate buffer for Simple Text Input device // Status = ConSplitterGrowBuffer ( sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *), @@ -567,18 +615,10 @@ ConSplitterTextInConstructor ( if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } + // - // Create Event to support locking StdIn Device + // Create Event to wait for a key // - Status = gBS->CreateEvent ( - EVT_TIMER | EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - ConSpliterConsoleControlLockStdInEvent, - NULL, - &ConInPrivate->LockEvent - ); - ASSERT_EFI_ERROR (Status); - Status = gBS->CreateEvent ( EVT_NOTIFY_WAIT, TPL_NOTIFY, @@ -589,7 +629,20 @@ ConSplitterTextInConstructor ( ASSERT_EFI_ERROR (Status); // - // Buffer for Simple Text Input Ex Protocol + // Allocate buffer for KeyQueue + // + TextInExListCount = ConInPrivate->TextInExListCount; + Status = ConSplitterGrowBuffer ( + sizeof (EFI_KEY_DATA), + &TextInExListCount, + (VOID **) &ConInPrivate->KeyQueue + ); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Allocate buffer for Simple Text Input Ex device // Status = ConSplitterGrowBuffer ( sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *), @@ -599,7 +652,9 @@ ConSplitterTextInConstructor ( if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } - + // + // Create Event to wait for a key Ex + // Status = gBS->CreateEvent ( EVT_NOTIFY_WAIT, TPL_NOTIFY, @@ -611,11 +666,12 @@ ConSplitterTextInConstructor ( InitializeListHead (&ConInPrivate->NotifyList); + ToggleStateSyncInitialization (ConInPrivate); + + ConInPrivate->AbsolutePointer.Mode = &ConInPrivate->AbsolutePointerMode; // - // Allocate Buffer and Create Event for Absolute Pointer and Simple Pointer Protocols + // Allocate buffer for Absolute Pointer device // - ConInPrivate->AbsolutePointer.Mode = &ConInPrivate->AbsolutePointerMode; - Status = ConSplitterGrowBuffer ( sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *), &ConInPrivate->AbsolutePointerListCount, @@ -624,7 +680,9 @@ ConSplitterTextInConstructor ( if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } - + // + // Create Event to wait for device input for Absolute pointer device + // Status = gBS->CreateEvent ( EVT_NOTIFY_WAIT, TPL_NOTIFY, @@ -635,7 +693,9 @@ ConSplitterTextInConstructor ( ASSERT_EFI_ERROR (Status); ConInPrivate->SimplePointer.Mode = &ConInPrivate->SimplePointerMode; - + // + // Allocate buffer for Simple Pointer device + // Status = ConSplitterGrowBuffer ( sizeof (EFI_SIMPLE_POINTER_PROTOCOL *), &ConInPrivate->PointerListCount, @@ -644,7 +704,9 @@ ConSplitterTextInConstructor ( if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } - + // + // Create Event to wait for device input for Simple pointer device + // Status = gBS->CreateEvent ( EVT_NOTIFY_WAIT, TPL_NOTIFY, @@ -652,6 +714,18 @@ ConSplitterTextInConstructor ( ConInPrivate, &ConInPrivate->SimplePointer.WaitForInput ); + ASSERT_EFI_ERROR (Status); + // + // Create Event to signal ConIn connection request + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + EfiEventEmptyFunction, + NULL, + &gConnectConInEventGuid, + &ConInPrivate->ConnectConInEvent + ); return Status; } @@ -659,7 +733,7 @@ ConSplitterTextInConstructor ( /** Construct console output devices' private data. - @param ConOutPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA + @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA structure. @retval EFI_OUT_OF_RESOURCES Out of resources. @@ -680,7 +754,6 @@ ConSplitterTextOutConstructor ( if (FeaturePcdGet (PcdConOutUgaSupport)) { CopyMem (&ConOutPrivate->UgaDraw, &mUgaDrawProtocolTemplate, sizeof (EFI_UGA_DRAW_PROTOCOL)); } - if (FeaturePcdGet (PcdConOutGopSupport)) { CopyMem (&ConOutPrivate->GraphicsOutput, &mGraphicsOutputProtocolTemplate, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL)); } @@ -695,7 +768,9 @@ ConSplitterTextOutConstructor ( // so put current mode back to init state. // ConOutPrivate->TextOutMode.Mode = 0xFF; - + // + // Allocate buffer for Console Out device + // Status = ConSplitterGrowBuffer ( sizeof (TEXT_OUT_AND_GOP_DATA), &ConOutPrivate->TextOutListCount, @@ -704,7 +779,9 @@ ConSplitterTextOutConstructor ( if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } - + // + // Allocate buffer for Text Out query data + // Status = ConSplitterGrowBuffer ( sizeof (TEXT_OUT_SPLITTER_QUERY_DATA), &ConOutPrivate->TextOutQueryDataCount, @@ -713,18 +790,20 @@ ConSplitterTextOutConstructor ( if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } + // - // Setup the DevNullTextOut console to 80 x 25 + // Setup the default console to 80 x 25 and mode to 0 // ConOutPrivate->TextOutQueryData[0].Columns = 80; ConOutPrivate->TextOutQueryData[0].Rows = 25; - DevNullTextOutSetMode (ConOutPrivate, 0); + TextOutSetMode (ConOutPrivate, 0); + if (FeaturePcdGet (PcdConOutUgaSupport)) { // - // Setup the DevNullUgaDraw to 800 x 600 x 32 bits per pixel + // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz. // - ConSpliterUgaDrawSetMode (&ConOutPrivate->UgaDraw, 800, 600, 32, 60); + ConSplitterUgaDrawSetMode (&ConOutPrivate->UgaDraw, 800, 600, 32, 60); } if (FeaturePcdGet (PcdConOutGopSupport)) { // @@ -772,14 +851,15 @@ ConSplitterTextOutConstructor ( /** - Test to see if the specified protocol could be supported on the ControllerHandle. + Test to see if the specified protocol could be supported on the specified device. - @param This Protocol instance pointer. + @param This Driver Binding protocol pointer. @param ControllerHandle Handle of device to test. - @param Guid The specified protocol guid. + @param Guid The specified protocol. @retval EFI_SUCCESS The specified protocol is supported on this device. - @retval other The specified protocol is not supported on this device. + @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle. + @retval other Failed to open specified protocol on this device. **/ EFI_STATUS @@ -795,19 +875,15 @@ ConSplitterSupported ( // // Make sure the Console Splitter does not attempt to attach to itself // - if (ControllerHandle == mConIn.VirtualHandle) { - return EFI_UNSUPPORTED; - } - - if (ControllerHandle == mConOut.VirtualHandle) { + if (ControllerHandle == mConIn.VirtualHandle || + ControllerHandle == mConOut.VirtualHandle || + ControllerHandle == mStdErr.VirtualHandle + ) { return EFI_UNSUPPORTED; } - if (ControllerHandle == mStdErr.VirtualHandle) { - return EFI_UNSUPPORTED; - } // - // Check to see whether the handle has the ConsoleInDevice GUID on it + // Check to see whether the specific protocol could be opened BY_DRIVER // Status = gBS->OpenProtocol ( ControllerHandle, @@ -833,9 +909,9 @@ ConSplitterSupported ( } /** - Test to see if Console In Device could be supported on the ControllerHandle. + Test to see if Console In Device could be supported on the Controller. - @param This Protocol instance pointer. + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to test. @param RemainingDevicePath Optional parameter use to pick a specific child device to start. @@ -860,9 +936,9 @@ ConSplitterConInDriverBindingSupported ( } /** - Test to see if Simple Pointer protocol could be supported on the ControllerHandle. + Test to see if Simple Pointer protocol could be supported on the Controller. - @param This Protocol instance pointer. + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to test. @param RemainingDevicePath Optional parameter use to pick a specific child device to start. @@ -886,11 +962,10 @@ ConSplitterSimplePointerDriverBindingSupported ( ); } - /** - Test to see if Absolute Pointer protocol could be supported on the ControllerHandle. + Test to see if Absolute Pointer protocol could be supported on the Controller. - @param This Protocol instance pointer. + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to test. @param RemainingDevicePath Optional parameter use to pick a specific child device to start. @@ -916,9 +991,9 @@ ConSplitterAbsolutePointerDriverBindingSupported ( /** - Test to see if Console Out Device could be supported on the ControllerHandle. + Test to see if Console Out Device could be supported on the Controller. - @param This Protocol instance pointer. + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to test. @param RemainingDevicePath Optional parameter use to pick a specific child device to start. @@ -943,9 +1018,9 @@ ConSplitterConOutDriverBindingSupported ( } /** - Test to see if Standard Error Device could be supported on the ControllerHandle. + Test to see if Standard Error Device could be supported on the Controller. - @param This Protocol instance pointer. + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to test. @param RemainingDevicePath Optional parameter use to pick a specific child device to start. @@ -971,10 +1046,10 @@ ConSplitterStdErrDriverBindingSupported ( /** - Start ConSplitter on devcie handle by opening Console Device Guid on device handle + Start ConSplitter on devcie handle by opening Console Device Guid on device handle and the console virtual handle. And Get the console interface on controller handle. - - @param This Protocol instance pointer. + + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device. @param ConSplitterVirtualHandle Console virtual Handle. @param DeviceGuid The specified Console Device, such as ConInDev, @@ -1001,7 +1076,7 @@ ConSplitterStart ( VOID *Instance; // - // Check to see whether the ControllerHandle has the InterfaceGuid on it. + // Check to see whether the ControllerHandle has the DeviceGuid on it. // Status = gBS->OpenProtocol ( ControllerHandle, @@ -1015,6 +1090,9 @@ ConSplitterStart ( return Status; } + // + // Open the Parent Handle for the child. + // Status = gBS->OpenProtocol ( ControllerHandle, DeviceGuid, @@ -1024,10 +1102,13 @@ ConSplitterStart ( EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); if (EFI_ERROR (Status)) { - return Status; + goto Err; } - return gBS->OpenProtocol ( + // + // Open InterfaceGuid on the virtul handle. + // + Status = gBS->OpenProtocol ( ControllerHandle, InterfaceGuid, Interface, @@ -1035,13 +1116,40 @@ ConSplitterStart ( ConSplitterVirtualHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); + + if (!EFI_ERROR (Status)) { + return EFI_SUCCESS; + } + + // + // close the DeviceGuid on ConSplitter VirtualHandle. + // + gBS->CloseProtocol ( + ControllerHandle, + DeviceGuid, + This->DriverBindingHandle, + ConSplitterVirtualHandle + ); + +Err: + // + // close the DeviceGuid on ControllerHandle. + // + gBS->CloseProtocol ( + ControllerHandle, + DeviceGuid, + This->DriverBindingHandle, + ControllerHandle + ); + + return Status; } /** - Start Console In Consplitter on device handle. - - @param This Protocol instance pointer. + Start Console In Consplitter on device handle. + + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to bind driver to. @param RemainingDevicePath Optional parameter use to pick a specific child device to start. @@ -1107,9 +1215,9 @@ ConSplitterConInDriverBindingStart ( /** - Start Simple Pointer Consplitter on device handle. - - @param This Protocol instance pointer. + Start Simple Pointer Consplitter on device handle. + + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to bind driver to. @param RemainingDevicePath Optional parameter use to pick a specific child device to start. @@ -1153,9 +1261,9 @@ ConSplitterSimplePointerDriverBindingStart ( /** - Start Absolute Pointer Consplitter on device handle. - - @param This Protocol instance pointer. + Start Absolute Pointer Consplitter on device handle. + + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to bind driver to. @param RemainingDevicePath Optional parameter use to pick a specific child device to start. @@ -1200,9 +1308,9 @@ ConSplitterAbsolutePointerDriverBindingStart ( /** - Start Console Out Consplitter on device handle. - - @param This Protocol instance pointer. + Start Console Out Consplitter on device handle. + + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to bind driver to. @param RemainingDevicePath Optional parameter use to pick a specific child device to start. @@ -1219,10 +1327,12 @@ ConSplitterConOutDriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { - EFI_STATUS Status; - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut; - EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; - EFI_UGA_DRAW_PROTOCOL *UgaDraw; + EFI_STATUS Status; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut; + EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; + EFI_UGA_DRAW_PROTOCOL *UgaDraw; + UINTN SizeOfInfo; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; // // Start ConSplitter on ControllerHandle, and create the virtual @@ -1258,14 +1368,14 @@ ConSplitterConOutDriverBindingStart ( // // Open UGA DRAW protocol // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiUgaDrawProtocolGuid, - (VOID **) &UgaDraw, - This->DriverBindingHandle, - mConOut.VirtualHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); + gBS->OpenProtocol ( + ControllerHandle, + &gEfiUgaDrawProtocolGuid, + (VOID **) &UgaDraw, + This->DriverBindingHandle, + mConOut.VirtualHandle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); } // @@ -1281,12 +1391,26 @@ ConSplitterConOutDriverBindingStart ( Status = ConSplitterTextOutAddDevice (&mConOut, TextOut, GraphicsOutput, UgaDraw); ConSplitterTextOutSetAttribute (&mConOut.TextOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); - if (FeaturePcdGet (PcdConOutUgaSupport) && FeaturePcdGet (PcdUgaConsumeSupport)) { + if (FeaturePcdGet (PcdConOutUgaSupport)) { // - // Match the UGA mode data of ConOut with the current mode + // Get the UGA mode data of ConOut from the current mode // - if (UgaDraw != NULL) { - UgaDraw->GetMode ( + if (GraphicsOutput != NULL) { + Status = GraphicsOutput->QueryMode (GraphicsOutput, GraphicsOutput->Mode->Mode, &SizeOfInfo, &Info); + if (EFI_ERROR (Status)) { + return Status; + } + ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); + + mConOut.UgaHorizontalResolution = Info->HorizontalResolution; + mConOut.UgaVerticalResolution = Info->VerticalResolution; + mConOut.UgaColorDepth = 32; + mConOut.UgaRefreshRate = 60; + + FreePool (Info); + + } else if (UgaDraw != NULL) { + Status = UgaDraw->GetMode ( UgaDraw, &mConOut.UgaHorizontalResolution, &mConOut.UgaVerticalResolution, @@ -1295,14 +1419,15 @@ ConSplitterConOutDriverBindingStart ( ); } } + return Status; } /** - Start Standard Error Consplitter on device handle. - - @param This Protocol instance pointer. + Start Standard Error Consplitter on device handle. + + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to bind driver to. @param RemainingDevicePath Optional parameter use to pick a specific child device to start. @@ -1350,32 +1475,15 @@ ConSplitterStdErrDriverBindingStart ( // Status = ConSplitterTextOutAddDevice (&mStdErr, TextOut, NULL, NULL); ConSplitterTextOutSetAttribute (&mStdErr.TextOut, EFI_TEXT_ATTR (EFI_MAGENTA, EFI_BLACK)); - if (EFI_ERROR (Status)) { - return Status; - } - - if (mStdErr.CurrentNumberOfConsoles == 1) { - gST->StandardErrorHandle = mStdErr.VirtualHandle; - gST->StdErr = &mStdErr.TextOut; - // - // Update the CRC32 in the EFI System Table header - // - gST->Hdr.CRC32 = 0; - gBS->CalculateCrc32 ( - (UINT8 *) &gST->Hdr, - gST->Hdr.HeaderSize, - &gST->Hdr.CRC32 - ); - } return Status; } /** - Stop ConSplitter on device handle by closing Console Device Guid on device handle + Stop ConSplitter on device handle by closing Console Device Guid on device handle and the console virtual handle. - + @param This Protocol instance pointer. @param ControllerHandle Handle of device. @param ConSplitterVirtualHandle Console virtual Handle. @@ -1435,7 +1543,7 @@ ConSplitterStop ( /** Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID. - @param This Protocol instance pointer. + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to stop driver on @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of children is zero stop the entire bus driver. @@ -1474,7 +1582,7 @@ ConSplitterConInDriverBindingStop ( // // If Simple Text Input Ex protocol exists, // remove device from Text Input Ex devices list. - // + // Status = ConSplitterTextInExDeleteDevice (&mConIn, TextInEx); if (EFI_ERROR (Status)) { return Status; @@ -1498,7 +1606,7 @@ ConSplitterConInDriverBindingStop ( // // Remove device from Text Input devices list. - // + // return ConSplitterTextInDeleteDevice (&mConIn, TextIn); } @@ -1507,7 +1615,7 @@ ConSplitterConInDriverBindingStop ( Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing Simple Pointer protocol. - @param This Protocol instance pointer. + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to stop driver on @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of children is zero stop the entire bus driver. @@ -1559,7 +1667,7 @@ ConSplitterSimplePointerDriverBindingStop ( Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing Absolute Pointer protocol. - @param This Protocol instance pointer. + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to stop driver on @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of children is zero stop the entire bus driver. @@ -1610,7 +1718,7 @@ ConSplitterAbsolutePointerDriverBindingStop ( /** Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID. - @param This Protocol instance pointer. + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to stop driver on @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of children is zero stop the entire bus driver. @@ -1661,7 +1769,7 @@ ConSplitterConOutDriverBindingStop ( /** Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID. - @param This Protocol instance pointer. + @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to stop driver on @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of children is zero stop the entire bus driver. @@ -1704,53 +1812,32 @@ ConSplitterStdErrDriverBindingStop ( // // Delete this console error out device's data structures. // - Status = ConSplitterTextOutDeleteDevice (&mStdErr, TextOut); - if (EFI_ERROR (Status)) { - return Status; - } - - if (mStdErr.CurrentNumberOfConsoles == 0) { - gST->StandardErrorHandle = NULL; - gST->StdErr = NULL; - // - // Update the CRC32 in the EFI System Table header - // - gST->Hdr.CRC32 = 0; - gBS->CalculateCrc32 ( - (UINT8 *) &gST->Hdr, - gST->Hdr.HeaderSize, - &gST->Hdr.CRC32 - ); - } - - return Status; + return ConSplitterTextOutDeleteDevice (&mStdErr, TextOut); } /** - Take the passed in Buffer of size SizeOfCount and grow the buffer - by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount - bytes. Copy the current data in Buffer to the new version of Buffer - and free the old version of buffer. + Take the passed in Buffer of size ElementSize and grow the buffer + by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes. + Copy the current data in Buffer to the new version of Buffer and + free the old version of buffer. - @param SizeOfCount Size of element in array - @param Count Current number of elements in array + @param ElementSize Size of element in array. + @param Count Current number of elements in array. @param Buffer Bigger version of passed in Buffer with all the - data + data. - @retval EFI_SUCCESS Buffer size has grown + @retval EFI_SUCCESS Buffer size has grown. @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size. **/ EFI_STATUS ConSplitterGrowBuffer ( - IN UINTN SizeOfCount, - IN UINTN *Count, + IN UINTN ElementSize, + IN OUT UINTN *Count, IN OUT VOID **Buffer ) { - UINTN NewSize; - UINTN OldSize; VOID *Ptr; // @@ -1758,23 +1845,16 @@ ConSplitterGrowBuffer ( // copy the old buffer's content to the new-size buffer, // then free the old buffer. // - OldSize = *Count * SizeOfCount; - *Count += CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT; - NewSize = *Count * SizeOfCount; - - Ptr = AllocateZeroPool (NewSize); + Ptr = ReallocatePool ( + ElementSize * (*Count), + ElementSize * ((*Count) + CONSOLE_SPLITTER_ALLOC_UNIT), + *Buffer + ); if (Ptr == NULL) { return EFI_OUT_OF_RESOURCES; } - - CopyMem (Ptr, *Buffer, OldSize); - - if (*Buffer != NULL) { - FreePool (*Buffer); - } - + *Count += CONSOLE_SPLITTER_ALLOC_UNIT; *Buffer = Ptr; - return EFI_SUCCESS; } @@ -1798,7 +1878,7 @@ ConSplitterTextInAddDevice ( EFI_STATUS Status; // - // If the Text In List is full, enlarge it by calling growbuffer(). + // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer(). // if (Private->CurrentNumberOfConsoles >= Private->TextInListCount) { Status = ConSplitterGrowBuffer ( @@ -1817,7 +1897,7 @@ ConSplitterTextInAddDevice ( Private->CurrentNumberOfConsoles++; // - // Extra CheckEvent added to reduce the double CheckEvent() in UI.c + // Extra CheckEvent added to reduce the double CheckEvent(). // gBS->CheckEvent (TextIn->WaitForKey); @@ -1826,7 +1906,7 @@ ConSplitterTextInAddDevice ( /** - Remove Simple Text Device in Consplitter Absolute Pointer list. + Remove Text Input Device from Consplitter Text Input list. @param Private Text In Splitter pointer. @param TextIn Simple Text protocol pointer. @@ -1848,7 +1928,7 @@ ConSplitterTextInDeleteDevice ( // for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) { if (Private->TextInList[Index] == TextIn) { - for (Index = Index; Index < Private->CurrentNumberOfConsoles - 1; Index++) { + for (; Index < Private->CurrentNumberOfConsoles - 1; Index++) { Private->TextInList[Index] = Private->TextInList[Index + 1]; } @@ -1864,7 +1944,7 @@ ConSplitterTextInDeleteDevice ( Add Text Input Ex Device in Consplitter Text Input Ex list. @param Private Text In Splitter pointer. - @param TextInEx Simple Text Ex Input protocol pointer. + @param TextInEx Simple Text Input Ex Input protocol pointer. @retval EFI_SUCCESS Text Input Ex Device added successfully. @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size. @@ -1876,12 +1956,39 @@ ConSplitterTextInExAddDevice ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx ) { - EFI_STATUS Status; + EFI_STATUS Status; + LIST_ENTRY *Link; + TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify; + UINTN TextInExListCount; // - // If the TextInEx List is full, enlarge it by calling growbuffer(). + // Enlarge the NotifyHandleList and the TextInExList // if (Private->CurrentNumberOfExConsoles >= Private->TextInExListCount) { + for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) { + CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link); + TextInExListCount = Private->TextInExListCount; + + Status = ConSplitterGrowBuffer ( + sizeof (EFI_HANDLE), + &TextInExListCount, + (VOID **) &CurrentNotify->NotifyHandleList + ); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + } + + TextInExListCount = Private->TextInExListCount; + Status = ConSplitterGrowBuffer ( + sizeof (EFI_KEY_DATA), + &TextInExListCount, + (VOID **) &Private->KeyQueue + ); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + Status = ConSplitterGrowBuffer ( sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *), &Private->TextInExListCount, @@ -1891,14 +1998,43 @@ ConSplitterTextInExAddDevice ( return EFI_OUT_OF_RESOURCES; } } + // - // Add the new text-in device data structure into the Text In List. + // Register the key notify in the new text-in device + // + for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) { + CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link); + Status = TextInEx->RegisterKeyNotify ( + TextInEx, + &CurrentNotify->KeyData, + CurrentNotify->KeyNotificationFn, + &CurrentNotify->NotifyHandleList[Private->CurrentNumberOfExConsoles] + ); + if (EFI_ERROR (Status)) { + for (Link = Link->BackLink; Link != &Private->NotifyList; Link = Link->BackLink) { + CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link); + TextInEx->UnregisterKeyNotify ( + TextInEx, + CurrentNotify->NotifyHandleList[Private->CurrentNumberOfExConsoles] + ); + } + return Status; + } + } + + // + // Add the new text-in device data structure into the Text Input Ex List. // Private->TextInExList[Private->CurrentNumberOfExConsoles] = TextInEx; Private->CurrentNumberOfExConsoles++; // - // Extra CheckEvent added to reduce the double CheckEvent() in UI.c + // Sync current toggle state to this new console input device. + // + TextInEx->SetState (TextInEx, &Private->PhysicalKeyToggleState); + + // + // Extra CheckEvent added to reduce the double CheckEvent(). // gBS->CheckEvent (TextInEx->WaitForKeyEx); @@ -1906,13 +2042,13 @@ ConSplitterTextInExAddDevice ( } /** - Remove Simple Text Ex Device in Consplitter Absolute Pointer list. + Remove Text Ex Device from Consplitter Text Input Ex list. @param Private Text In Splitter pointer. @param TextInEx Simple Text Ex protocol pointer. - @retval EFI_SUCCESS Simple Text Ex Device removed successfully. - @retval EFI_NOT_FOUND No Simple Text Ex Device found. + @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully. + @retval EFI_NOT_FOUND No Simple Text Input Ex Device found. **/ EFI_STATUS @@ -1923,12 +2059,12 @@ ConSplitterTextInExDeleteDevice ( { UINTN Index; // - // Remove the specified text-in device data structure from the Text In List, + // Remove the specified text-in device data structure from the Text Input Ex List, // and rearrange the remaining data structures in the Text In List. // for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) { if (Private->TextInExList[Index] == TextInEx) { - for (Index = Index; Index < Private->CurrentNumberOfExConsoles - 1; Index++) { + for (; Index < Private->CurrentNumberOfExConsoles - 1; Index++) { Private->TextInExList[Index] = Private->TextInExList[Index + 1]; } @@ -1960,7 +2096,7 @@ ConSplitterSimplePointerAddDevice ( EFI_STATUS Status; // - // If the Text In List is full, enlarge it by calling growbuffer(). + // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer(). // if (Private->CurrentNumberOfPointers >= Private->PointerListCount) { Status = ConSplitterGrowBuffer ( @@ -1973,16 +2109,17 @@ ConSplitterSimplePointerAddDevice ( } } // - // Add the new text-in device data structure into the Text In List. + // Add the new text-in device data structure into the Simple Pointer List. // Private->PointerList[Private->CurrentNumberOfPointers] = SimplePointer; Private->CurrentNumberOfPointers++; + return EFI_SUCCESS; } /** - Remove Simple Pointer Device in Consplitter Absolute Pointer list. + Remove Simple Pointer Device from Consplitter Simple Pointer list. @param Private Text In Splitter pointer. @param SimplePointer Simple Pointer protocol pointer. @@ -1999,12 +2136,12 @@ ConSplitterSimplePointerDeleteDevice ( { UINTN Index; // - // Remove the specified text-in device data structure from the Text In List, + // Remove the specified text-in device data structure from the Simple Pointer List, // and rearrange the remaining data structures in the Text In List. // for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) { if (Private->PointerList[Index] == SimplePointer) { - for (Index = Index; Index < Private->CurrentNumberOfPointers - 1; Index++) { + for (; Index < Private->CurrentNumberOfPointers - 1; Index++) { Private->PointerList[Index] = Private->PointerList[Index + 1]; } @@ -2036,7 +2173,7 @@ ConSplitterAbsolutePointerAddDevice ( EFI_STATUS Status; // - // If the Absolute Pointer List is full, enlarge it by calling growbuffer(). + // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer(). // if (Private->CurrentNumberOfAbsolutePointers >= Private->AbsolutePointerListCount) { Status = ConSplitterGrowBuffer ( @@ -2049,16 +2186,17 @@ ConSplitterAbsolutePointerAddDevice ( } } // - // Add the new text-in device data structure into the Text In List. + // Add the new text-in device data structure into the Absolute Pointer List. // Private->AbsolutePointerList[Private->CurrentNumberOfAbsolutePointers] = AbsolutePointer; Private->CurrentNumberOfAbsolutePointers++; + return EFI_SUCCESS; } /** - Remove Absolute Pointer Device in Consplitter Absolute Pointer list. + Remove Absolute Pointer Device from Consplitter Absolute Pointer list. @param Private Text In Splitter pointer. @param AbsolutePointer Absolute Pointer protocol pointer. @@ -2075,12 +2213,12 @@ ConSplitterAbsolutePointerDeleteDevice ( { UINTN Index; // - // Remove the specified text-in device data structure from the Text In List, - // and rearrange the remaining data structures in the Text In List. + // Remove the specified text-in device data structure from the Absolute Pointer List, + // and rearrange the remaining data structures from the Absolute Pointer List. // for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) { if (Private->AbsolutePointerList[Index] == AbsolutePointer) { - for (Index = Index; Index < Private->CurrentNumberOfAbsolutePointers - 1; Index++) { + for (; Index < Private->CurrentNumberOfAbsolutePointers - 1; Index++) { Private->AbsolutePointerList[Index] = Private->AbsolutePointerList[Index + 1]; } @@ -2095,6 +2233,8 @@ ConSplitterAbsolutePointerDeleteDevice ( /** Reallocate Text Out mode map. + Allocate new buffer and copy original buffer into the new buffer. + @param Private Consplitter Text Out pointer. @retval EFI_SUCCESS Buffer size has grown @@ -2113,12 +2253,17 @@ ConSplitterGrowMapTable ( INT32 *OldTextOutModeMap; INT32 *SrcAddress; INT32 Index; + UINTN OldStepSize; + UINTN NewStepSize; NewSize = Private->TextOutListCount * sizeof (INT32); OldTextOutModeMap = Private->TextOutModeMap; - TotalSize = NewSize * Private->TextOutQueryDataCount; + TotalSize = NewSize * (Private->TextOutQueryDataCount); - TextOutModeMap = AllocateZeroPool (TotalSize); + // + // Allocate new buffer for Text Out List. + // + TextOutModeMap = AllocatePool (TotalSize); if (TextOutModeMap == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -2147,14 +2292,26 @@ ConSplitterGrowMapTable ( Size = Private->CurrentNumberOfConsoles * sizeof (INT32); Index = 0; SrcAddress = OldTextOutModeMap; + NewStepSize = NewSize / sizeof(INT32); + // If Private->CurrentNumberOfConsoles is not zero and OldTextOutModeMap + // is not NULL, it indicates that the original TextOutModeMap is not enough + // for the new console devices and has been enlarged by CONSOLE_SPLITTER_ALLOC_UNIT columns. + // + OldStepSize = NewStepSize - CONSOLE_SPLITTER_ALLOC_UNIT; // // Copy the old data to the new one // while (Index < Private->TextOutMode.MaxMode) { CopyMem (TextOutModeMap, SrcAddress, Size); - TextOutModeMap += NewSize; - SrcAddress += Size; + // + // Go to next row of new TextOutModeMap. + // + TextOutModeMap += NewStepSize; + // + // Go to next row of old TextOutModeMap. + // + SrcAddress += OldStepSize; Index++; } // @@ -2168,11 +2325,11 @@ ConSplitterGrowMapTable ( /** - Add the device's output mode to console splitter's mode list. + Add new device's output mode to console splitter's mode list. @param Private Text Out Splitter pointer @param TextOut Simple Text Output protocol pointer. - + @retval EFI_SUCCESS Device added successfully. @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size. @@ -2252,24 +2409,25 @@ ConSplitterAddOutputMode ( @param TextOutModeMap Current text out mode map, begin with the mode 80x25 @param NewlyAddedMap New text out mode map, begin with the mode 80x25 @param MapStepSize Mode step size for one console device - @param NewMapStepSize Mode step size for one console device - @param MaxMode Current max text mode - @param CurrentMode Current text mode + @param NewMapStepSize New Mode step size for one console device + @param MaxMode IN: Current max text mode, OUT: Updated max text mode. + @param CurrentMode IN: Current text mode, OUT: Updated current text mode. **/ VOID ConSplitterGetIntersection ( - IN INT32 *TextOutModeMap, - IN INT32 *NewlyAddedMap, - IN UINTN MapStepSize, - IN UINTN NewMapStepSize, - OUT INT32 *MaxMode, - OUT INT32 *CurrentMode + IN INT32 *TextOutModeMap, + IN INT32 *NewlyAddedMap, + IN UINTN MapStepSize, + IN UINTN NewMapStepSize, + IN OUT INT32 *MaxMode, + IN OUT INT32 *CurrentMode ) { INT32 Index; INT32 *CurrentMapEntry; INT32 *NextMapEntry; + INT32 *NewMapEntry; INT32 CurrentMaxMode; INT32 Mode; @@ -2280,14 +2438,14 @@ ConSplitterGetIntersection ( // Index = 2; CurrentMapEntry = &TextOutModeMap[MapStepSize * 2]; - NextMapEntry = &TextOutModeMap[MapStepSize * 2]; - NewlyAddedMap = &NewlyAddedMap[NewMapStepSize * 2]; + NextMapEntry = CurrentMapEntry; + NewMapEntry = &NewlyAddedMap[NewMapStepSize * 2]; CurrentMaxMode = *MaxMode; Mode = *CurrentMode; while (Index < CurrentMaxMode) { - if (*NewlyAddedMap == -1) { + if (*NewMapEntry == -1) { // // This mode is not supported any more. Remove it. Special care // must be taken as this remove will also affect current mode; @@ -2307,7 +2465,7 @@ ConSplitterGetIntersection ( } CurrentMapEntry += MapStepSize; - NewlyAddedMap += NewMapStepSize; + NewMapEntry += NewMapStepSize; Index++; } @@ -2316,14 +2474,11 @@ ConSplitterGetIntersection ( return ; } - /** - Add the device's output mode to console splitter's mode list. + Sync the device's output mode to console splitter's mode list. @param Private Text Out Splitter pointer. @param TextOut Simple Text Output protocol pointer. - - @return None **/ VOID @@ -2359,8 +2514,13 @@ ConSplitterSyncOutputMode ( MapTable = TextOutModeMap + Private->CurrentNumberOfConsoles; while (Mode < TextOut->Mode->MaxMode) { Status = TextOut->QueryMode (TextOut, Mode, &Columns, &Rows); + if (EFI_ERROR(Status)) { if (Mode == 1) { + // + // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData + // is clear to 0x0. + // MapTable[StepSize] = Mode; TextOutQueryData[Mode].Columns = 0; TextOutQueryData[Mode].Rows = 0; @@ -2378,10 +2538,8 @@ ConSplitterSyncOutputMode ( MapTable[Index * StepSize] = Mode; break; } - Index++; } - Mode++; } // @@ -2501,7 +2659,7 @@ ConSplitterGetIntersectionBetweenConOutAndStrErr ( // // Find the intersection of the two set of modes. If they actually intersect, the - // correponding entry in the map table is set to 1. + // corresponding entry in the map table is set to 1. // Mode = 0; while (Mode < ConOutMaxMode) { @@ -2539,6 +2697,7 @@ ConSplitterGetIntersectionBetweenConOutAndStrErr ( &(mConOut.TextOutMode.MaxMode), &(mConOut.TextOutMode.Mode) ); + if (mConOut.TextOutMode.Mode < 0) { mConOut.TextOut.SetMode (&(mConOut.TextOut), 0); } @@ -2551,6 +2710,7 @@ ConSplitterGetIntersectionBetweenConOutAndStrErr ( &(mStdErr.TextOutMode.MaxMode), &(mStdErr.TextOutMode.Mode) ); + if (mStdErr.TextOutMode.Mode < 0) { mStdErr.TextOut.SetMode (&(mStdErr.TextOut), 0); } @@ -2563,7 +2723,7 @@ ConSplitterGetIntersectionBetweenConOutAndStrErr ( /** - Add GOP or UGA output mode into Consplitter Text Out list. + Add Grahpics Output modes into Consplitter Text Out list. @param Private Text Out Splitter pointer. @param GraphicsOutput Graphics Output protocol pointer. @@ -2597,14 +2757,13 @@ ConSplitterAddGraphicsOutputMode ( UINT32 UgaColorDepth; UINT32 UgaRefreshRate; - if ((GraphicsOutput == NULL) && (UgaDraw == NULL)) { - return EFI_UNSUPPORTED; - } + ASSERT (GraphicsOutput != NULL || UgaDraw != NULL); CurrentGraphicsOutputMode = Private->GraphicsOutput.Mode; Index = 0; CurrentIndex = 0; + Status = EFI_SUCCESS; if (Private->CurrentNumberOfUgaDraw != 0) { // @@ -2630,7 +2789,7 @@ ConSplitterAddGraphicsOutputMode ( // // Allocate resource for the private mode buffer // - ModeBuffer = AllocatePool (GraphicsOutput->Mode->SizeOfInfo * GraphicsOutput->Mode->MaxMode); + ModeBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) * GraphicsOutput->Mode->MaxMode); if (ModeBuffer == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -2642,10 +2801,14 @@ ConSplitterAddGraphicsOutputMode ( // Mode = ModeBuffer; for (Index = 0; Index < GraphicsOutput->Mode->MaxMode; Index++) { + // + // The Info buffer would be allocated by callee + // Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) Index, &SizeOfInfo, &Info); if (EFI_ERROR (Status)) { return Status; } + ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); CopyMem (Mode, Info, SizeOfInfo); Mode++; FreePool (Info); @@ -2665,12 +2828,19 @@ ConSplitterAddGraphicsOutputMode ( Match = FALSE; for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex++) { + // + // The Info buffer would be allocated by callee + // Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info); if (EFI_ERROR (Status)) { return Status; } if ((Info->HorizontalResolution == Mode->HorizontalResolution) && (Info->VerticalResolution == Mode->VerticalResolution)) { + // + // If GOP device supports one mode in current mode buffer, + // it will be added into matched mode buffer + // Match = TRUE; FreePool (Info); break; @@ -2681,6 +2851,9 @@ ConSplitterAddGraphicsOutputMode ( if (Match) { AlreadyExist = FALSE; + // + // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin. + // for (Info = ModeBuffer; Info < MatchedMode; Info++) { if ((Info->HorizontalResolution == Mode->HorizontalResolution) && (Info->VerticalResolution == Mode->VerticalResolution)) { @@ -2746,8 +2919,7 @@ ConSplitterAddGraphicsOutputMode ( } } } - } - if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) { + } else if (UgaDraw != NULL) { // // Graphics console driver can ensure the same mode for all GOP devices // so we can get the current mode from this video device @@ -2763,11 +2935,11 @@ ConSplitterAddGraphicsOutputMode ( CurrentGraphicsOutputMode->MaxMode = 1; Info = CurrentGraphicsOutputMode->Info; Info->Version = 0; - Info->HorizontalResolution = UgaHorizontalResolution; - Info->VerticalResolution = UgaVerticalResolution; - Info->PixelFormat = PixelBltOnly; - Info->PixelsPerScanLine = UgaHorizontalResolution; - CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); + Info->HorizontalResolution = UgaHorizontalResolution; + Info->VerticalResolution = UgaVerticalResolution; + Info->PixelFormat = PixelBltOnly; + Info->PixelsPerScanLine = UgaHorizontalResolution; + CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL; CurrentGraphicsOutputMode->FrameBufferSize = 0; @@ -2787,101 +2959,119 @@ Done: if (GraphicsOutput != NULL) { Private->CurrentNumberOfGraphicsOutput++; } - if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) { + if (UgaDraw != NULL) { Private->CurrentNumberOfUgaDraw++; } // // Force GraphicsOutput mode to be set, - // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode - // - Private->HardwareNeedsStarting = TRUE; - // - // Current mode number may need update now, so set it to an invalid mode number // - CurrentGraphicsOutputMode->Mode = 0xffff; - // - // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode. - // - Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, (UINT32) CurrentIndex); - // - // If user defined mode is not valid for UGA, set to the default mode 800x600. - // - if (EFI_ERROR(Status)) { - (Private->GraphicsOutputModeBuffer[0]).HorizontalResolution = 800; - (Private->GraphicsOutputModeBuffer[0]).VerticalResolution = 600; - Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, 0); + Mode = &Private->GraphicsOutputModeBuffer[CurrentIndex]; + if ((GraphicsOutput != NULL) && + (Mode->HorizontalResolution == CurrentGraphicsOutputMode->Info->HorizontalResolution) && + (Mode->VerticalResolution == CurrentGraphicsOutputMode->Info->VerticalResolution)) { + CurrentGraphicsOutputMode->Mode = (UINT32) CurrentIndex; + if ((Mode->HorizontalResolution != GraphicsOutput->Mode->Info->HorizontalResolution) || + (Mode->VerticalResolution != GraphicsOutput->Mode->Info->VerticalResolution)) { + // + // If all existing video device has been set to common mode, only set new GOP device to + // the common mode + // + for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) { + Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info); + if (EFI_ERROR (Status)) { + return Status; + } + if ((Info->HorizontalResolution == Mode->HorizontalResolution) && (Info->VerticalResolution == Mode->VerticalResolution)) { + FreePool (Info); + break; + } + FreePool (Info); + } + Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex); + } + } else { + // + // Current mode number may need update now, so set it to an invalid mode number + // + CurrentGraphicsOutputMode->Mode = 0xffff; + // + // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode. + // + Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, (UINT32) CurrentIndex); + if (EFI_ERROR(Status)) { + // + // If user defined mode is not valid for display device, set to the default mode 800x600. + // + (Private->GraphicsOutputModeBuffer[0]).HorizontalResolution = 800; + (Private->GraphicsOutputModeBuffer[0]).VerticalResolution = 600; + Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, 0); + } } return Status; } - /** + Set the current console out mode. + This routine will get the current console mode information (column, row) from ConsoleOutMode variable and set it; if the variable does not exist, set to user defined console mode. @param Private Consplitter Text Out pointer. - @return None - **/ VOID ConsplitterSetConsoleOutMode ( IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private ) { - UINTN Col; - UINTN Row; - UINTN Mode; - UINTN PreferMode; - UINTN BaseMode; - UINTN ModeInfoSize; - UINTN MaxMode; - EFI_STATUS Status; - CONSOLE_OUT_MODE *ModeInfo; + UINTN Col; + UINTN Row; + UINTN Mode; + UINTN PreferMode; + UINTN BaseMode; + UINTN MaxMode; + EFI_STATUS Status; + CONSOLE_OUT_MODE ModeInfo; + CONSOLE_OUT_MODE MaxModeInfo; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut; PreferMode = 0xFF; BaseMode = 0xFF; TextOut = &Private->TextOut; MaxMode = (UINTN) (TextOut->Mode->MaxMode); - ModeInfoSize = sizeof (CONSOLE_OUT_MODE); - - ModeInfo = AllocateZeroPool (sizeof(CONSOLE_OUT_MODE)); - ASSERT(ModeInfo != NULL); - Status = gRT->GetVariable ( - VARCONOUTMODE, - &gEfiGenericPlatformVariableGuid, - NULL, - &ModeInfoSize, - ModeInfo - ); + MaxModeInfo.Column = 0; + MaxModeInfo.Row = 0; + ModeInfo.Column = PcdGet32 (PcdConOutColumn); + ModeInfo.Row = PcdGet32 (PcdConOutRow); // - // Set to the default mode 80 x 25 required by EFI/UEFI spec; - // user can also define other valid default console mode here. + // To find the prefer mode and basic mode from Text Out mode list // - if (EFI_ERROR(Status)) { - ModeInfo->Column = 80; - ModeInfo->Row = 25; - Status = gRT->SetVariable ( - VARCONOUTMODE, - &gEfiGenericPlatformVariableGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, - sizeof (CONSOLE_OUT_MODE), - ModeInfo - ); - } - for (Mode = 0; Mode < MaxMode; Mode++) { Status = TextOut->QueryMode (TextOut, Mode, &Col, &Row); if (!EFI_ERROR(Status)) { - if (Col == ModeInfo->Column && Row == ModeInfo->Row) { - PreferMode = Mode; + if ((ModeInfo.Column != 0) && (ModeInfo.Row != 0)) { + // + // Use user defined column and row + // + if (Col == ModeInfo.Column && Row == ModeInfo.Row) { + PreferMode = Mode; + } + } else { + // + // If user sets PcdConOutColumn or PcdConOutRow to 0, + // find and set the highest text mode. + // + if ((Col >= MaxModeInfo.Column) && (Row >= MaxModeInfo.Row)) { + MaxModeInfo.Column = Col; + MaxModeInfo.Row = Row; + PreferMode = Mode; + } } if (Col == 80 && Row == 25) { BaseMode = Mode; @@ -2889,31 +3079,24 @@ ConsplitterSetConsoleOutMode ( } } - Status = TextOut->SetMode (TextOut, PreferMode); - // - // if current mode setting is failed, default 80x25 mode will be set. + // Set prefer mode to Text Out devices. // + Status = TextOut->SetMode (TextOut, PreferMode); if (EFI_ERROR(Status)) { + // + // if current mode setting is failed, default 80x25 mode will be set. + // Status = TextOut->SetMode (TextOut, BaseMode); ASSERT(!EFI_ERROR(Status)); - ModeInfo->Column = 80; - ModeInfo->Row = 25; - - // - // Update ConOutMode variable - // - Status = gRT->SetVariable ( - VARCONOUTMODE, - &gEfiGenericPlatformVariableGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, - sizeof (CONSOLE_OUT_MODE), - ModeInfo - ); + Status = PcdSet32S (PcdConOutColumn, 80); + ASSERT(!EFI_ERROR(Status)); + Status = PcdSet32S (PcdConOutRow, 25); + ASSERT(!EFI_ERROR(Status)); } - gBS->FreePool (ModeInfo); + return ; } @@ -2937,21 +3120,23 @@ ConSplitterTextOutAddDevice ( IN EFI_UGA_DRAW_PROTOCOL *UgaDraw ) { - EFI_STATUS Status; - UINTN CurrentNumOfConsoles; - INT32 CurrentMode; - INT32 MaxMode; - UINT32 UgaHorizontalResolution; - UINT32 UgaVerticalResolution; - UINT32 UgaColorDepth; - UINT32 UgaRefreshRate; - TEXT_OUT_AND_GOP_DATA *TextAndGop; + EFI_STATUS Status; + UINTN CurrentNumOfConsoles; + INT32 MaxMode; + UINT32 UgaHorizontalResolution; + UINT32 UgaVerticalResolution; + UINT32 UgaColorDepth; + UINT32 UgaRefreshRate; + TEXT_OUT_AND_GOP_DATA *TextAndGop; + UINTN SizeOfInfo; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; + EFI_STATUS DeviceStatus; Status = EFI_SUCCESS; CurrentNumOfConsoles = Private->CurrentNumberOfConsoles; // - // If the Text Out List is full, enlarge it by calling growbuffer(). + // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer(). // while (CurrentNumOfConsoles >= Private->TextOutListCount) { Status = ConSplitterGrowBuffer ( @@ -2973,21 +3158,9 @@ ConSplitterTextOutAddDevice ( TextAndGop = &Private->TextOutList[CurrentNumOfConsoles]; - TextAndGop->TextOut = TextOut; + TextAndGop->TextOut = TextOut; TextAndGop->GraphicsOutput = GraphicsOutput; - TextAndGop->UgaDraw = UgaDraw; - - if ((GraphicsOutput == NULL) && (UgaDraw == NULL)) { - // - // If No GOP/UGA device then use the ConOut device - // - TextAndGop->TextOutEnabled = TRUE; - } else { - // - // If GOP/UGA device use ConOut device only used if screen is in Text mode - // - TextAndGop->TextOutEnabled = (BOOLEAN) (Private->ConsoleOutputMode == EfiConsoleControlScreenText); - } + TextAndGop->UgaDraw = UgaDraw; if (CurrentNumOfConsoles == 0) { // @@ -3007,20 +3180,36 @@ ConSplitterTextOutAddDevice ( // ConSplitterGetIntersectionBetweenConOutAndStrErr (); - CurrentMode = Private->TextOutMode.Mode; MaxMode = Private->TextOutMode.MaxMode; ASSERT (MaxMode >= 1); + DeviceStatus = EFI_DEVICE_ERROR; + Status = EFI_DEVICE_ERROR; + // - // Update DevNull mode according to current video device + // This device display mode will be added into Graphics Ouput modes. // - if (FeaturePcdGet (PcdConOutGopSupport)) { - if ((GraphicsOutput != NULL) || (UgaDraw != NULL)) { - ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput, UgaDraw); - } + if ((GraphicsOutput != NULL) || (UgaDraw != NULL)) { + DeviceStatus = ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput, UgaDraw); } + if (FeaturePcdGet (PcdConOutUgaSupport)) { - if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) { + // + // If UGA is produced by Consplitter + // + if (GraphicsOutput != NULL) { + Status = GraphicsOutput->QueryMode (GraphicsOutput, GraphicsOutput->Mode->Mode, &SizeOfInfo, &Info); + if (EFI_ERROR (Status)) { + return Status; + } + ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); + + UgaHorizontalResolution = Info->HorizontalResolution; + UgaVerticalResolution = Info->VerticalResolution; + + FreePool (Info); + + } else if (UgaDraw != NULL) { Status = UgaDraw->GetMode ( UgaDraw, &UgaHorizontalResolution, @@ -3028,8 +3217,11 @@ ConSplitterTextOutAddDevice ( &UgaColorDepth, &UgaRefreshRate ); - if (!EFI_ERROR (Status)) { - Status = ConSpliterUgaDrawSetMode ( + if (!EFI_ERROR (Status) && EFI_ERROR (DeviceStatus)) { + // + // if GetMode is successfully and UGA device hasn't been set, set it + // + Status = ConSplitterUgaDrawSetMode ( &Private->UgaDraw, UgaHorizontalResolution, UgaVerticalResolution, @@ -3041,7 +3233,7 @@ ConSplitterTextOutAddDevice ( // If GetMode/SetMode is failed, set to 800x600 mode // if(EFI_ERROR (Status)) { - Status = ConSpliterUgaDrawSetMode ( + Status = ConSplitterUgaDrawSetMode ( &Private->UgaDraw, 800, 600, @@ -3052,25 +3244,44 @@ ConSplitterTextOutAddDevice ( } } - if (Private->ConsoleOutputMode == EfiConsoleControlScreenGraphics && GraphicsOutput != NULL) { - // - // We just added a new GOP or UGA device in graphics mode - // - if (FeaturePcdGet (PcdConOutGopSupport)) { - DevNullGopSync (Private, TextAndGop->GraphicsOutput, TextAndGop->UgaDraw); - } else if (FeaturePcdGet (PcdConOutUgaSupport)) { - DevNullUgaSync (Private, TextAndGop->GraphicsOutput, TextAndGop->UgaDraw); + if (((!EFI_ERROR (DeviceStatus)) || (!EFI_ERROR (Status))) && + ((Private->CurrentNumberOfGraphicsOutput + Private->CurrentNumberOfUgaDraw) == 1)) { + if (!FeaturePcdGet (PcdConOutGopSupport)) { + // + // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed + // on the virtual handle. + // + Status = gBS->InstallMultipleProtocolInterfaces ( + &mConOut.VirtualHandle, + &gEfiUgaDrawProtocolGuid, + &mConOut.UgaDraw, + NULL + ); + } else if (!FeaturePcdGet (PcdConOutUgaSupport)) { + // + // If UGA Draw protocol not supported, Graphics Output Protocol is installed + // on virtual handle. + // + Status = gBS->InstallMultipleProtocolInterfaces ( + &mConOut.VirtualHandle, + &gEfiGraphicsOutputProtocolGuid, + &mConOut.GraphicsOutput, + NULL + ); + } else { + // + // Boot Graphics Output protocol and UGA Draw protocol are supported, + // both they will be installed on virtual handle. + // + Status = gBS->InstallMultipleProtocolInterfaces ( + &mConOut.VirtualHandle, + &gEfiGraphicsOutputProtocolGuid, + &mConOut.GraphicsOutput, + &gEfiUgaDrawProtocolGuid, + &mConOut.UgaDraw, + NULL + ); } - } else if ((CurrentMode >= 0) && ((GraphicsOutput != NULL) || (UgaDraw != NULL)) && (CurrentMode < Private->TextOutMode.MaxMode)) { - // - // The new console supports the same mode of the current console so sync up - // - DevNullSyncStdOut (Private); - } else { - // - // If ConOut, then set the mode to Mode #0 which us 80 x 25 - // - Private->TextOut.SetMode (&Private->TextOut, 0); } // @@ -3113,14 +3324,14 @@ ConSplitterTextOutDeleteDevice ( TextOutList = Private->TextOutList; while (Index >= 0) { if (TextOutList->TextOut == TextOut) { - CopyMem (TextOutList, TextOutList + 1, sizeof (TEXT_OUT_AND_GOP_DATA) * Index); - CurrentNumOfConsoles--; - if (TextOutList->UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) { + if (TextOutList->UgaDraw != NULL) { Private->CurrentNumberOfUgaDraw--; } if (TextOutList->GraphicsOutput != NULL) { Private->CurrentNumberOfGraphicsOutput--; } + CopyMem (TextOutList, TextOutList + 1, sizeof (TEXT_OUT_AND_GOP_DATA) * Index); + CurrentNumOfConsoles--; break; } @@ -3134,15 +3345,44 @@ ConSplitterTextOutDeleteDevice ( return EFI_NOT_FOUND; } + if ((Private->CurrentNumberOfGraphicsOutput == 0) && (Private->CurrentNumberOfUgaDraw == 0)) { + // + // If there is not any physical GOP and UGA device in system, + // Consplitter GOP or UGA protocol will be uninstalled + // + if (!FeaturePcdGet (PcdConOutGopSupport)) { + Status = gBS->UninstallProtocolInterface ( + Private->VirtualHandle, + &gEfiUgaDrawProtocolGuid, + &Private->UgaDraw + ); + } else if (!FeaturePcdGet (PcdConOutUgaSupport)) { + Status = gBS->UninstallProtocolInterface ( + Private->VirtualHandle, + &gEfiGraphicsOutputProtocolGuid, + &Private->GraphicsOutput + ); + } else { + Status = gBS->UninstallMultipleProtocolInterfaces ( + Private->VirtualHandle, + &gEfiUgaDrawProtocolGuid, + &Private->UgaDraw, + &gEfiGraphicsOutputProtocolGuid, + &Private->GraphicsOutput, + NULL + ); + } + } + if (CurrentNumOfConsoles == 0) { // - // If the number of consoles is zero clear the Dev NULL device + // If the number of consoles is zero, reset all parameters // Private->CurrentNumberOfConsoles = 0; Private->TextOutMode.MaxMode = 1; Private->TextOutQueryData[0].Columns = 80; Private->TextOutQueryData[0].Rows = 25; - DevNullTextOutSetMode (Private, 0); + TextOutSetMode (Private, 0); return EFI_SUCCESS; } @@ -3224,9 +3464,48 @@ ConSplitterTextInReset ( } } + if (!EFI_ERROR (ReturnStatus)) { + ToggleStateSyncReInitialization (Private); + // + // Empty the key queue. + // + Private->CurrentNumberOfKeys = 0; + } + return ReturnStatus; } +/** + Dequeue the saved key from internal key queue. + + @param Private Protocol instance pointer. + @param KeyData A pointer to a buffer that is filled in with the + keystroke state data for the key that was + pressed. + @retval EFI_NOT_FOUND Queue is empty. + @retval EFI_SUCCESS First key is dequeued and returned. +**/ +EFI_STATUS +ConSplitterTextInExDequeueKey ( + IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, + OUT EFI_KEY_DATA *KeyData + ) +{ + if (Private->CurrentNumberOfKeys == 0) { + return EFI_NOT_FOUND; + } + // + // Return the first saved key. + // + CopyMem (KeyData, &Private->KeyQueue[0], sizeof (EFI_KEY_DATA)); + Private->CurrentNumberOfKeys--; + CopyMem ( + &Private->KeyQueue[0], + &Private->KeyQueue[1], + Private->CurrentNumberOfKeys * sizeof (EFI_KEY_DATA) + ); + return EFI_SUCCESS; +} /** Reads the next keystroke from the input device. The WaitForKey Event can @@ -3250,179 +3529,60 @@ ConSplitterTextInPrivateReadKeyStroke ( { EFI_STATUS Status; UINTN Index; - EFI_INPUT_KEY CurrentKey; - - Key->UnicodeChar = 0; - Key->ScanCode = SCAN_NULL; + EFI_KEY_DATA KeyData; // - // if no physical console input device exists, return EFI_NOT_READY; - // if any physical console input device has key input, - // return the key and EFI_SUCCESS. + // Return the first saved non-NULL key. // - for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) { - Status = Private->TextInList[Index]->ReadKeyStroke ( - Private->TextInList[Index], - &CurrentKey - ); - if (!EFI_ERROR (Status)) { - *Key = CurrentKey; - return Status; + while (TRUE) { + Status = ConSplitterTextInExDequeueKey (Private, &KeyData); + if (EFI_ERROR (Status)) { + break; } - } - - return EFI_NOT_READY; -} - - -/** - Return TRUE if StdIn is locked. The ConIn device on the virtual handle is - the only device locked. - - NONE - - @retval TRUE StdIn locked - @retval FALSE StdIn working normally - -**/ -BOOLEAN -ConSpliterConssoleControlStdInLocked ( - VOID - ) -{ - return mConIn.PasswordEnabled; -} - - -/** - This timer event will fire when StdIn is locked. It will check the key - sequence on StdIn to see if it matches the password. Any error in the - password will cause the check to reset. As long a mConIn.PasswordEnabled is - TRUE the StdIn splitter will not report any input. - - @param Event The Event this notify function registered to. - @param Context Pointer to the context data registerd to the - Event. - - @return None - -**/ -VOID -EFIAPI -ConSpliterConsoleControlLockStdInEvent ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - EFI_INPUT_KEY Key; - CHAR16 BackSpaceString[2]; - CHAR16 SpaceString[2]; - - do { - Status = ConSplitterTextInPrivateReadKeyStroke (&mConIn, &Key); - if (!EFI_ERROR (Status)) { - // - // if it's an ENTER, match password - // - if ((Key.UnicodeChar == CHAR_CARRIAGE_RETURN) && (Key.ScanCode == SCAN_NULL)) { - mConIn.PwdAttempt[mConIn.PwdIndex] = CHAR_NULL; - if (StrCmp (mConIn.Password, mConIn.PwdAttempt)) { - // - // Password not match - // - ConSplitterTextOutOutputString (&mConOut.TextOut, (CHAR16 *) L"\n\rPassword not correct\n\r"); - mConIn.PwdIndex = 0; - } else { - // - // Key matches password sequence - // - gBS->SetTimer (mConIn.LockEvent, TimerPeriodic, 0); - mConIn.PasswordEnabled = FALSE; - Status = EFI_NOT_READY; - } - } else if ((Key.UnicodeChar == CHAR_BACKSPACE) && (Key.ScanCode == SCAN_NULL)) { - // - // BackSpace met - // - if (mConIn.PwdIndex > 0) { - BackSpaceString[0] = CHAR_BACKSPACE; - BackSpaceString[1] = 0; - - SpaceString[0] = L' '; - SpaceString[1] = 0; - - ConSplitterTextOutOutputString (&mConOut.TextOut, BackSpaceString); - ConSplitterTextOutOutputString (&mConOut.TextOut, SpaceString); - ConSplitterTextOutOutputString (&mConOut.TextOut, BackSpaceString); - - mConIn.PwdIndex--; - } - } else if ((Key.ScanCode == SCAN_NULL) && (Key.UnicodeChar >= 32)) { - // - // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input - // - if (mConIn.PwdIndex < (MAX_STD_IN_PASSWORD - 1)) { - if (mConIn.PwdIndex == 0) { - ConSplitterTextOutOutputString (&mConOut.TextOut, (CHAR16 *) L"\n\r"); - } - - ConSplitterTextOutOutputString (&mConOut.TextOut, (CHAR16 *) L"*"); - mConIn.PwdAttempt[mConIn.PwdIndex] = Key.UnicodeChar; - mConIn.PwdIndex++; - } - } + if ((KeyData.Key.ScanCode != CHAR_NULL) || (KeyData.Key.UnicodeChar != SCAN_NULL)) { + CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY)); + return Status; } - } while (!EFI_ERROR (Status)); -} - - -/** - If Password is NULL unlock the password state variable and set the event - timer. If the Password is too big return an error. If the Password is valid - Copy the Password and enable state variable and then arm the periodic timer - - @param This Console Control protocol pointer. - @param Password The password input. - - @retval EFI_SUCCESS Lock the StdIn device - @retval EFI_INVALID_PARAMETER Password is NULL - @retval EFI_OUT_OF_RESOURCES Buffer allocation to store the password fails - -**/ -EFI_STATUS -EFIAPI -ConSpliterConsoleControlLockStdIn ( - IN EFI_CONSOLE_CONTROL_PROTOCOL *This, - IN CHAR16 *Password - ) -{ - if (Password == NULL) { - return EFI_INVALID_PARAMETER; } - if (StrLen (Password) >= MAX_STD_IN_PASSWORD) { - // - // Currently have a max password size - // - return EFI_OUT_OF_RESOURCES; - } + Key->UnicodeChar = 0; + Key->ScanCode = SCAN_NULL; + // - // Save the password, initialize state variables and arm event timer + // if no physical console input device exists, return EFI_NOT_READY; + // if any physical console input device has key input, + // return the key and EFI_SUCCESS. // - StrCpy (mConIn.Password, Password); - mConIn.PasswordEnabled = TRUE; - mConIn.PwdIndex = 0; - gBS->SetTimer (mConIn.LockEvent, TimerPeriodic, (10000 * 25)); + for (Index = 0; Index < Private->CurrentNumberOfConsoles;) { + Status = Private->TextInList[Index]->ReadKeyStroke ( + Private->TextInList[Index], + &KeyData.Key + ); + if (!EFI_ERROR (Status)) { + // + // If it is not partial keystorke, return the key. Otherwise, continue + // to read key from THIS physical console input device. + // + if ((KeyData.Key.ScanCode != CHAR_NULL) || (KeyData.Key.UnicodeChar != SCAN_NULL)) { + CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY)); + return Status; + } + } else { + // + // Continue to read key from NEXT physical console input device. + // + Index++; + } + } - return EFI_SUCCESS; + return EFI_NOT_READY; } + /** Reads the next keystroke from the input device. The WaitForKey Event can be used to test for existance of a keystroke via WaitForEvent () call. - If the ConIn is password locked make it look like no keystroke is availible @param This Protocol instance pointer. @param Key Driver may perform diagnostics on reset. @@ -3443,22 +3603,25 @@ ConSplitterTextInReadKeyStroke ( TEXT_IN_SPLITTER_PRIVATE_DATA *Private; Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This); - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return EFI_NOT_READY; - } Private->KeyEventSignalState = FALSE; + // + // Signal ConnectConIn event on first call in Lazy ConIn mode + // + if (!mConInIsConnect && PcdGetBool (PcdConInConnectOnDemand)) { + DEBUG ((EFI_D_INFO, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n")); + gBS->SignalEvent (Private->ConnectConInEvent); + mConInIsConnect = TRUE; + } + return ConSplitterTextInPrivateReadKeyStroke (Private, Key); } /** - This event agregates all the events of the ConIn devices in the spliter. - If the ConIn is password locked then return. + This event aggregates all the events of the ConIn devices in the spliter. + If any events of physical ConIn devices are signaled, signal the ConIn spliter event. This will cause the calling code to call ConSplitterTextInReadKeyStroke (). @@ -3466,8 +3629,6 @@ ConSplitterTextInReadKeyStroke ( @param Event The Event assoicated with callback. @param Context Context registered when Event was created. - @return None - **/ VOID EFIAPI @@ -3481,22 +3642,17 @@ ConSplitterTextInWaitForKey ( UINTN Index; Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context; - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return ; - } - // - // if KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke() - // if (Private->KeyEventSignalState) { + // + // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke() + // gBS->SignalEvent (Event); return ; } + // - // if any physical console input device has key input, signal the event. + // If any physical console input device has key input, signal the event. // for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) { Status = gBS->CheckEvent (Private->TextInList[Index]->WaitForKey); @@ -3593,6 +3749,14 @@ ConSplitterTextInResetEx ( } } + if (!EFI_ERROR (ReturnStatus)) { + ToggleStateSyncReInitialization (Private); + // + // Empty the key queue. + // + Private->CurrentNumberOfKeys = 0; + } + return ReturnStatus; } @@ -3624,6 +3788,7 @@ ConSplitterTextInReadKeyStrokeEx ( TEXT_IN_SPLITTER_PRIVATE_DATA *Private; EFI_STATUS Status; UINTN Index; + EFI_KEY_STATE KeyState; EFI_KEY_DATA CurrentKeyData; @@ -3632,34 +3797,94 @@ ConSplitterTextInReadKeyStrokeEx ( } Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This); - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return EFI_NOT_READY; - } Private->KeyEventSignalState = FALSE; - KeyData->Key.UnicodeChar = 0; - KeyData->Key.ScanCode = SCAN_NULL; + // + // Signal ConnectConIn event on first call in Lazy ConIn mode + // + if (!mConInIsConnect && PcdGetBool (PcdConInConnectOnDemand)) { + DEBUG ((EFI_D_INFO, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n")); + gBS->SignalEvent (Private->ConnectConInEvent); + mConInIsConnect = TRUE; + } // - // if no physical console input device exists, return EFI_NOT_READY; - // if any physical console input device has key input, - // return the key and EFI_SUCCESS. + // Return the first saved key. + // + Status = ConSplitterTextInExDequeueKey (Private, KeyData); + if (!EFI_ERROR (Status)) { + return Status; + } + ASSERT (Private->CurrentNumberOfKeys == 0); + + ZeroMem (&KeyState, sizeof (KeyState)); + + // + // Iterate through all physical consoles to get key state. + // Some physical consoles may return valid key. + // Queue the valid keys. // for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) { + ZeroMem (&CurrentKeyData, sizeof (EFI_KEY_DATA)); Status = Private->TextInExList[Index]->ReadKeyStrokeEx ( - Private->TextInExList[Index], - &CurrentKeyData - ); + Private->TextInExList[Index], + &CurrentKeyData + ); + if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) { + continue; + } + + // + // Consolidate the key state from all physical consoles. + // + if ((CurrentKeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) { + KeyState.KeyShiftState |= CurrentKeyData.KeyState.KeyShiftState; + } + if ((CurrentKeyData.KeyState.KeyToggleState & EFI_TOGGLE_STATE_VALID) != 0) { + KeyState.KeyToggleState |= CurrentKeyData.KeyState.KeyToggleState; + } + if (!EFI_ERROR (Status)) { - CopyMem (KeyData, &CurrentKeyData, sizeof (CurrentKeyData)); - return Status; + // + // If virtual KeyState has been required to be exposed, or it is not + // partial keystorke, queue the key. + // It's possible that user presses at multiple keyboards at the same moment, + // Private->KeyQueue[] are the storage to save all the keys. + // + if ((Private->VirtualKeyStateExported) || + (CurrentKeyData.Key.ScanCode != CHAR_NULL) || + (CurrentKeyData.Key.UnicodeChar != SCAN_NULL)) { + CopyMem ( + &Private->KeyQueue[Private->CurrentNumberOfKeys], + &CurrentKeyData, + sizeof (EFI_KEY_DATA) + ); + Private->CurrentNumberOfKeys++; + } } } + // + // Consolidate the key state for all keys in Private->KeyQueue[] + // + for (Index = 0; Index < Private->CurrentNumberOfKeys; Index++) { + CopyMem (&Private->KeyQueue[Index].KeyState, &KeyState, sizeof (EFI_KEY_STATE)); + } + + // + // Return the first saved key. + // + Status = ConSplitterTextInExDequeueKey (Private, KeyData); + if (!EFI_ERROR (Status)) { + return Status; + } + + // + // Always return the key state even there is no key pressed. + // + ZeroMem (&KeyData->Key, sizeof (KeyData->Key)); + CopyMem (&KeyData->KeyState, &KeyState, sizeof (KeyData->KeyState)); return EFI_NOT_READY; } @@ -3689,6 +3914,7 @@ ConSplitterTextInSetState ( TEXT_IN_SPLITTER_PRIVATE_DATA *Private; EFI_STATUS Status; UINTN Index; + EFI_KEY_TOGGLE_STATE PhysicalKeyToggleState; if (KeyToggleState == NULL) { return EFI_INVALID_PARAMETER; @@ -3696,6 +3922,12 @@ ConSplitterTextInSetState ( Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This); + // + // Always turn on physical TextInEx partial key report for + // toggle state sync. + // + PhysicalKeyToggleState = *KeyToggleState | EFI_KEY_STATE_EXPOSED; + // // if no physical console input device exists, return EFI_SUCCESS; // otherwise return the status of setting state of physical console input device @@ -3703,13 +3935,22 @@ ConSplitterTextInSetState ( for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) { Status = Private->TextInExList[Index]->SetState ( Private->TextInExList[Index], - KeyToggleState + &PhysicalKeyToggleState ); if (EFI_ERROR (Status)) { return Status; } } + // + // Record the physical KeyToggleState. + // + Private->PhysicalKeyToggleState = PhysicalKeyToggleState; + // + // Get if virtual KeyState has been required to be exposed. + // + Private->VirtualKeyStateExported = (((*KeyToggleState) & EFI_KEY_STATE_EXPOSED) != 0); + return EFI_SUCCESS; } @@ -3719,11 +3960,14 @@ ConSplitterTextInSetState ( Register a notification function for a particular keystroke for the input device. @param This Protocol instance pointer. - @param KeyData A pointer to a buffer that is filled in with the - keystroke information data for the key that was - pressed. + @param KeyData A pointer to a buffer that is filled in with + the keystroke information for the key that was + pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState + and KeyData.KeyState.KeyShiftState are 0, then any incomplete + keystroke will trigger a notification of the KeyNotificationFunction. @param KeyNotificationFunction Points to the function to be called when the key - sequence is typed specified by KeyData. + sequence is typed specified by KeyData. This notification function + should be called at <=TPL_CALLBACK. @param NotifyHandle Points to the unique handle assigned to the registered notification. @@ -3731,7 +3975,7 @@ ConSplitterTextInSetState ( successfully. @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures. - @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL. + @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL. **/ EFI_STATUS @@ -3740,7 +3984,7 @@ ConSplitterTextInRegisterKeyNotify ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_DATA *KeyData, IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, - OUT EFI_HANDLE *NotifyHandle + OUT VOID **NotifyHandle ) { TEXT_IN_SPLITTER_PRIVATE_DATA *Private; @@ -3757,27 +4001,14 @@ ConSplitterTextInRegisterKeyNotify ( Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This); - // - // if no physical console input device exists, - // return EFI_SUCCESS directly. - // - if (Private->CurrentNumberOfExConsoles <= 0) { - return EFI_SUCCESS; - } - // // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered. // for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) { - CurrentNotify = CR ( - Link, - TEXT_IN_EX_SPLITTER_NOTIFY, - NotifyEntry, - TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE - ); + CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link); if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) { - *NotifyHandle = CurrentNotify->NotifyHandle; + *NotifyHandle = CurrentNotify; return EFI_SUCCESS; } } @@ -3790,14 +4021,14 @@ ConSplitterTextInRegisterKeyNotify ( if (NewNotify == NULL) { return EFI_OUT_OF_RESOURCES; } - NewNotify->NotifyHandleList = (EFI_HANDLE *) AllocateZeroPool (sizeof (EFI_HANDLE) * Private->CurrentNumberOfExConsoles); + NewNotify->NotifyHandleList = (EFI_HANDLE *) AllocateZeroPool (sizeof (EFI_HANDLE) * Private->TextInExListCount); if (NewNotify->NotifyHandleList == NULL) { gBS->FreePool (NewNotify); return EFI_OUT_OF_RESOURCES; } NewNotify->Signature = TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE; NewNotify->KeyNotificationFn = KeyNotificationFunction; - CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData)); + CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA)); // // Return the wrong status of registering key notify of @@ -3811,26 +4042,24 @@ ConSplitterTextInRegisterKeyNotify ( &NewNotify->NotifyHandleList[Index] ); if (EFI_ERROR (Status)) { + // + // Un-register the key notify on all physical console input devices + // + while (Index-- != 0) { + Private->TextInExList[Index]->UnregisterKeyNotify ( + Private->TextInExList[Index], + NewNotify->NotifyHandleList[Index] + ); + } gBS->FreePool (NewNotify->NotifyHandleList); gBS->FreePool (NewNotify); return Status; } } - // - // Use gSimpleTextInExNotifyGuid to get a valid EFI_HANDLE - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &NewNotify->NotifyHandle, - &gSimpleTextInExNotifyGuid, - NULL, - NULL - ); - ASSERT_EFI_ERROR (Status); - - InsertTailList (&mConIn.NotifyList, &NewNotify->NotifyEntry); + InsertTailList (&Private->NotifyList, &NewNotify->NotifyEntry); - *NotifyHandle = NewNotify->NotifyHandle; + *NotifyHandle = NewNotify; return EFI_SUCCESS; @@ -3847,18 +4076,16 @@ ConSplitterTextInRegisterKeyNotify ( @retval EFI_SUCCESS The notification function was unregistered successfully. @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid. - @retval EFI_NOT_FOUND Can not find the matching entry in database. **/ EFI_STATUS EFIAPI ConSplitterTextInUnregisterKeyNotify ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, - IN EFI_HANDLE NotificationHandle + IN VOID *NotificationHandle ) { TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - EFI_STATUS Status; UINTN Index; TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify; LIST_ENTRY *Link; @@ -3867,56 +4094,29 @@ ConSplitterTextInUnregisterKeyNotify ( return EFI_INVALID_PARAMETER; } - Status = gBS->OpenProtocol ( - NotificationHandle, - &gSimpleTextInExNotifyGuid, - NULL, - NULL, - NULL, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return EFI_INVALID_PARAMETER; - } - Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This); - // - // if no physical console input device exists, - // return EFI_SUCCESS directly. - // - if (Private->CurrentNumberOfExConsoles <= 0) { - return EFI_SUCCESS; - } - for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) { - CurrentNotify = CR (Link, TEXT_IN_EX_SPLITTER_NOTIFY, NotifyEntry, TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE); - if (CurrentNotify->NotifyHandle == NotificationHandle) { + CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link); + if (CurrentNotify == NotificationHandle) { for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) { - Status = Private->TextInExList[Index]->UnregisterKeyNotify ( - Private->TextInExList[Index], - CurrentNotify->NotifyHandleList[Index] - ); - if (EFI_ERROR (Status)) { - return Status; - } + Private->TextInExList[Index]->UnregisterKeyNotify ( + Private->TextInExList[Index], + CurrentNotify->NotifyHandleList[Index] + ); } RemoveEntryList (&CurrentNotify->NotifyEntry); - Status = gBS->UninstallMultipleProtocolInterfaces ( - CurrentNotify->NotifyHandle, - &gSimpleTextInExNotifyGuid, - NULL, - NULL - ); - ASSERT_EFI_ERROR (Status); + gBS->FreePool (CurrentNotify->NotifyHandleList); gBS->FreePool (CurrentNotify); return EFI_SUCCESS; } } - return EFI_NOT_FOUND; - + // + // NotificationHandle is not found in database + // + return EFI_INVALID_PARAMETER; } @@ -4046,7 +4246,6 @@ ConSplitterSimplePointerPrivateGetState ( /** Reads the next keystroke from the input device. The WaitForKey Event can be used to test for existance of a keystroke via WaitForEvent () call. - If the ConIn is password locked make it look like no keystroke is availible @param This A pointer to protocol instance. @param State A pointer to state information on the pointer device @@ -4067,12 +4266,6 @@ ConSplitterSimplePointerGetState ( TEXT_IN_SPLITTER_PRIVATE_DATA *Private; Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This); - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return EFI_NOT_READY; - } Private->InputEventSignalState = FALSE; @@ -4082,7 +4275,6 @@ ConSplitterSimplePointerGetState ( /** This event agregates all the events of the ConIn devices in the spliter. - If the ConIn is password locked then return. If any events of physical ConIn devices are signaled, signal the ConIn spliter event. This will cause the calling code to call ConSplitterTextInReadKeyStroke (). @@ -4090,8 +4282,6 @@ ConSplitterSimplePointerGetState ( @param Event The Event assoicated with callback. @param Context Context registered when Event was created. - @return None - **/ VOID EFIAPI @@ -4105,12 +4295,6 @@ ConSplitterSimplePointerWaitForInput ( UINTN Index; Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context; - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return ; - } // // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke() @@ -4205,15 +4389,20 @@ ConSplitterAbsolutePointerGetState ( EFI_STATUS ReturnStatus; UINTN Index; EFI_ABSOLUTE_POINTER_STATE CurrentState; - + UINT64 MinX; + UINT64 MinY; + UINT64 MinZ; + UINT64 MaxX; + UINT64 MaxY; + UINT64 MaxZ; + UINT64 VirtualMinX; + UINT64 VirtualMinY; + UINT64 VirtualMinZ; + UINT64 VirtualMaxX; + UINT64 VirtualMaxY; + UINT64 VirtualMaxZ; Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This); - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return EFI_NOT_READY; - } Private->AbsoluteInputEventSignalState = FALSE; @@ -4222,6 +4411,13 @@ ConSplitterAbsolutePointerGetState ( State->CurrentZ = 0; State->ActiveButtons = 0; + VirtualMinX = Private->AbsolutePointerMode.AbsoluteMinX; + VirtualMinY = Private->AbsolutePointerMode.AbsoluteMinY; + VirtualMinZ = Private->AbsolutePointerMode.AbsoluteMinZ; + VirtualMaxX = Private->AbsolutePointerMode.AbsoluteMaxX; + VirtualMaxY = Private->AbsolutePointerMode.AbsoluteMaxY; + VirtualMaxZ = Private->AbsolutePointerMode.AbsoluteMaxZ; + // // if no physical pointer device exists, return EFI_NOT_READY; // if any physical pointer device has changed state, @@ -4239,16 +4435,47 @@ ConSplitterAbsolutePointerGetState ( ReturnStatus = EFI_SUCCESS; } + MinX = Private->AbsolutePointerList[Index]->Mode->AbsoluteMinX; + MinY = Private->AbsolutePointerList[Index]->Mode->AbsoluteMinY; + MinZ = Private->AbsolutePointerList[Index]->Mode->AbsoluteMinZ; + MaxX = Private->AbsolutePointerList[Index]->Mode->AbsoluteMaxX; + MaxY = Private->AbsolutePointerList[Index]->Mode->AbsoluteMaxY; + MaxZ = Private->AbsolutePointerList[Index]->Mode->AbsoluteMaxZ; + State->ActiveButtons = CurrentState.ActiveButtons; - if (!(Private->AbsolutePointerMode.AbsoluteMinX == 0 && Private->AbsolutePointerMode.AbsoluteMaxX == 0)) { - State->CurrentX = CurrentState.CurrentX; + // + // Rescale to Con Splitter virtual Absolute Pointer's resolution. + // + if (!(MinX == 0 && MaxX == 0)) { + State->CurrentX = VirtualMinX + DivU64x64Remainder ( + MultU64x64 ( + CurrentState.CurrentX, + VirtualMaxX - VirtualMinX + ), + MaxX - MinX, + NULL + ); } - if (!(Private->AbsolutePointerMode.AbsoluteMinY == 0 && Private->AbsolutePointerMode.AbsoluteMaxY == 0)) { - State->CurrentY = CurrentState.CurrentY; + if (!(MinY == 0 && MaxY == 0)) { + State->CurrentY = VirtualMinY + DivU64x64Remainder ( + MultU64x64 ( + CurrentState.CurrentY, + VirtualMaxY - VirtualMinY + ), + MaxY - MinY, + NULL + ); } - if (!(Private->AbsolutePointerMode.AbsoluteMinZ == 0 && Private->AbsolutePointerMode.AbsoluteMaxZ == 0)) { - State->CurrentZ = CurrentState.CurrentZ; + if (!(MinZ == 0 && MaxZ == 0)) { + State->CurrentZ = VirtualMinZ + DivU64x64Remainder ( + MultU64x64 ( + CurrentState.CurrentZ, + VirtualMaxZ - VirtualMinZ + ), + MaxZ - MinZ, + NULL + ); } } else if (Status == EFI_DEVICE_ERROR) { @@ -4262,7 +4489,6 @@ ConSplitterAbsolutePointerGetState ( /** This event agregates all the events of the pointer devices in the splitter. - If the ConIn is password locked then return. If any events of physical pointer devices are signaled, signal the pointer splitter event. This will cause the calling code to call ConSplitterAbsolutePointerGetState (). @@ -4270,8 +4496,6 @@ ConSplitterAbsolutePointerGetState ( @param Event The Event assoicated with callback. @param Context Context registered when Event was created. - @return None - **/ VOID EFIAPI @@ -4285,12 +4509,6 @@ ConSplitterAbsolutePointerWaitForInput ( UINTN Index; Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context; - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return ; - } // // if AbsoluteInputEventSignalState is flagged before, @@ -4343,25 +4561,21 @@ ConSplitterTextOutReset ( // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - - Status = Private->TextOutList[Index].TextOut->Reset ( - Private->TextOutList[Index].TextOut, - ExtendedVerification - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->Reset ( + Private->TextOutList[Index].TextOut, + ExtendedVerification + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BLACK)); - Status = DevNullTextOutSetMode (Private, 0); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + // + // reset all mode parameters + // + TextOutSetMode (Private, 0); return ReturnStatus; } @@ -4396,53 +4610,76 @@ ConSplitterTextOutOutputString ( EFI_STATUS Status; TEXT_OUT_SPLITTER_PRIVATE_DATA *Private; UINTN Index; - UINTN BackSpaceCount; EFI_STATUS ReturnStatus; - CHAR16 *TargetString; + UINTN MaxColumn; + UINTN MaxRow; This->SetAttribute (This, This->Mode->Attribute); Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This); - BackSpaceCount = 0; - for (TargetString = WString; *TargetString != L'\0'; TargetString++) { - if (*TargetString == CHAR_BACKSPACE) { - BackSpaceCount++; - } - - } - - if (BackSpaceCount == 0) { - TargetString = WString; - } else { - TargetString = AllocatePool (sizeof (CHAR16) * (StrLen (WString) + BackSpaceCount + 1)); - StrCpy (TargetString, WString); - } // // return the worst status met // - Status = DevNullTextOutOutputString (Private, TargetString); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; + for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { + Status = Private->TextOutList[Index].TextOut->OutputString ( + Private->TextOutList[Index].TextOut, + WString + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; + } } - for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { + if (Private->CurrentNumberOfConsoles > 0) { + Private->TextOutMode.CursorColumn = Private->TextOutList[0].TextOut->Mode->CursorColumn; + Private->TextOutMode.CursorRow = Private->TextOutList[0].TextOut->Mode->CursorRow; + } else { + // + // When there is no real console devices in system, + // update cursor position for the virtual device in consplitter. + // + Private->TextOut.QueryMode ( + &Private->TextOut, + Private->TextOutMode.Mode, + &MaxColumn, + &MaxRow + ); + for (; *WString != CHAR_NULL; WString++) { + switch (*WString) { + case CHAR_BACKSPACE: + if (Private->TextOutMode.CursorColumn == 0 && Private->TextOutMode.CursorRow > 0) { + Private->TextOutMode.CursorRow--; + Private->TextOutMode.CursorColumn = (INT32) (MaxColumn - 1); + } else if (Private->TextOutMode.CursorColumn > 0) { + Private->TextOutMode.CursorColumn--; + } + break; - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->OutputString ( - Private->TextOutList[Index].TextOut, - TargetString - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; + case CHAR_LINEFEED: + if (Private->TextOutMode.CursorRow < (INT32) (MaxRow - 1)) { + Private->TextOutMode.CursorRow++; + } + break; + + case CHAR_CARRIAGE_RETURN: + Private->TextOutMode.CursorColumn = 0; + break; + + default: + if (Private->TextOutMode.CursorColumn < (INT32) (MaxColumn - 1)) { + Private->TextOutMode.CursorColumn++; + } else { + Private->TextOutMode.CursorColumn = 0; + if (Private->TextOutMode.CursorRow < (INT32) (MaxRow - 1)) { + Private->TextOutMode.CursorRow++; + } + } + break; } } } - if (BackSpaceCount > 0) { - FreePool (TargetString); - } - return ReturnStatus; } @@ -4480,14 +4717,12 @@ ConSplitterTextOutTestString ( // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->TestString ( - Private->TextOutList[Index].TextOut, - WString - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->TestString ( + Private->TextOutList[Index].TextOut, + WString + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } // @@ -4614,32 +4849,19 @@ ConSplitterTextOutSetMode ( // TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber; for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->SetMode ( - Private->TextOutList[Index].TextOut, - TextOutModeMap[Index] - ); - // - // If this console device is based on a GOP or UGA device, then sync up the bitmap from - // the GOP/UGA splitter and reclear the text portion of the display in the new mode. - // - if ((Private->TextOutList[Index].GraphicsOutput != NULL) || (Private->TextOutList[Index].UgaDraw != NULL)) { - Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut); - } - - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->SetMode ( + Private->TextOutList[Index].TextOut, + TextOutModeMap[Index] + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } + // - // The DevNull Console will support any possible mode as it allocates memory + // Set mode parameter to specified mode number // - Status = DevNullTextOutSetMode (Private, ModeNumber); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + TextOutSetMode (Private, ModeNumber); return ReturnStatus; } @@ -4679,7 +4901,7 @@ ConSplitterTextOutSetAttribute ( // // Check whether param Attribute is valid. // - if ( (Attribute > (UINTN)(((UINT32)-1)>>1)) ) { + if ((Attribute | 0x7F) != 0x7F) { return EFI_UNSUPPORTED; } @@ -4687,15 +4909,12 @@ ConSplitterTextOutSetAttribute ( // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->SetAttribute ( - Private->TextOutList[Index].TextOut, - Attribute - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->SetAttribute ( + Private->TextOutList[Index].TextOut, + Attribute + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } @@ -4734,19 +4953,20 @@ ConSplitterTextOutClearScreen ( // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } - Status = DevNullTextOutClearScreen (Private); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + // + // No need to do extra check here as whether (Column, Row) is valid has + // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should + // always be supported. + // + Private->TextOutMode.CursorColumn = 0; + Private->TextOutMode.CursorRow = 0; + Private->TextOutMode.CursorVisible = TRUE; return ReturnStatus; } @@ -4813,20 +5033,23 @@ ConSplitterTextOutSetCursorPosition ( // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->SetCursorPosition ( - Private->TextOutList[Index].TextOut, - Column, - Row - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->SetCursorPosition ( + Private->TextOutList[Index].TextOut, + Column, + Row + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } - DevNullTextOutSetCursorPosition (Private, Column, Row); + // + // No need to do extra check here as whether (Column, Row) is valid has + // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should + // always be supported. + // + Private->TextOutMode.CursorColumn = (INT32) Column; + Private->TextOutMode.CursorRow = (INT32) Row; return ReturnStatus; } @@ -4864,20 +5087,16 @@ ConSplitterTextOutEnableCursor ( // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->EnableCursor ( - Private->TextOutList[Index].TextOut, - Visible - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->EnableCursor ( + Private->TextOutList[Index].TextOut, + Visible + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } - DevNullTextOutEnableCursor (Private, Visible); + Private->TextOutMode.CursorVisible = Visible; return ReturnStatus; } -