X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FConsole%2FConSplitterDxe%2FConSplitter.c;h=9c38271b65f9e0663825ed552d482da96cb80280;hp=af90d5e5e4c3b654d7fa5ea3970d03cd18cc19af;hb=HEAD;hpb=30ed3422ab2de03abf7c1433ebb482f6e5e16f45 diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c index af90d5e5e4..8b5e62e3a8 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c @@ -1,5 +1,5 @@ /** @file - Console Splitter Driver. Any Handle that attatched console I/O protocols + Console Splitter Driver. Any Handle that attached 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. @@ -13,25 +13,19 @@ 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 + never removed. Such design ensures system function well during none console device situation. -Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
-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. +SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include "ConSplitter.h" // -// Identify if ConIn is connected in PcdConInConnectOnDemand enabled mode. +// Identify if ConIn is connected in PcdConInConnectOnDemand enabled mode. // default not connect // BOOLEAN mConInIsConnect = FALSE; @@ -41,38 +35,42 @@ BOOLEAN mConInIsConnect = FALSE; // GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE, - (EFI_HANDLE) NULL, + (EFI_HANDLE)NULL, { ConSplitterTextInReset, ConSplitterTextInReadKeyStroke, - (EFI_EVENT) NULL + (EFI_EVENT)NULL }, 0, - (EFI_SIMPLE_TEXT_INPUT_PROTOCOL **) NULL, + (EFI_SIMPLE_TEXT_INPUT_PROTOCOL **)NULL, 0, { ConSplitterTextInResetEx, ConSplitterTextInReadKeyStrokeEx, - (EFI_EVENT) NULL, + (EFI_EVENT)NULL, ConSplitterTextInSetState, ConSplitterTextInRegisterKeyNotify, ConSplitterTextInUnregisterKeyNotify }, 0, - (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL **) NULL, + (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL **)NULL, 0, { - (LIST_ENTRY *) NULL, - (LIST_ENTRY *) NULL + (LIST_ENTRY *)NULL, + (LIST_ENTRY *)NULL }, + (EFI_KEY_DATA *)NULL, + 0, + 0, + FALSE, { ConSplitterSimplePointerReset, ConSplitterSimplePointerGetState, - (EFI_EVENT) NULL, - (EFI_SIMPLE_POINTER_MODE *) NULL + (EFI_EVENT)NULL, + (EFI_SIMPLE_POINTER_MODE *)NULL }, { 0x10000, @@ -82,14 +80,14 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { TRUE }, 0, - (EFI_SIMPLE_POINTER_PROTOCOL **) NULL, + (EFI_SIMPLE_POINTER_PROTOCOL **)NULL, 0, { ConSplitterAbsolutePointerReset, ConSplitterAbsolutePointerGetState, - (EFI_EVENT) NULL, - (EFI_ABSOLUTE_POINTER_MODE *) NULL + (EFI_EVENT)NULL, + (EFI_ABSOLUTE_POINTER_MODE *)NULL }, { 0, // AbsoluteMinX @@ -101,7 +99,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { 0 // Attributes }, 0, - (EFI_ABSOLUTE_POINTER_PROTOCOL **) NULL, + (EFI_ABSOLUTE_POINTER_PROTOCOL **)NULL, 0, FALSE, @@ -109,11 +107,10 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { FALSE }; - // // Uga Draw Protocol Private Data template // -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate = { +GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate = { ConSplitterUgaDrawGetMode, ConSplitterUgaDrawSetMode, ConSplitterUgaDrawBlt @@ -122,20 +119,19 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate = { // // Graphics Output Protocol Private Data template // -GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate = { +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate = { ConSplitterGraphicsOutputQueryMode, ConSplitterGraphicsOutputSetMode, ConSplitterGraphicsOutputBlt, NULL }; - // // Text Out Splitter Private Data template // -GLOBAL_REMOVE_IF_UNREFERENCED 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, + (EFI_HANDLE)NULL, { ConSplitterTextOutReset, ConSplitterTextOutOutputString, @@ -146,7 +142,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = { ConSplitterTextOutClearScreen, ConSplitterTextOutSetCursorPosition, ConSplitterTextOutEnableCursor, - (EFI_SIMPLE_TEXT_OUTPUT_MODE *) NULL + (EFI_SIMPLE_TEXT_OUTPUT_MODE *)NULL }, { 1, @@ -173,24 +169,25 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = { NULL, NULL }, - (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) NULL, + (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *)NULL, 0, 0, 0, - (TEXT_OUT_AND_GOP_DATA *) NULL, + (TEXT_OUT_AND_GOP_DATA *)NULL, 0, - (TEXT_OUT_SPLITTER_QUERY_DATA *) NULL, + (TEXT_OUT_SPLITTER_QUERY_DATA *)NULL, 0, - (INT32 *) NULL + (INT32 *)NULL, + FALSE }; // // Standard Error Text Out Splitter Data Template // -GLOBAL_REMOVE_IF_UNREFERENCED 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, + (EFI_HANDLE)NULL, { ConSplitterTextOutReset, ConSplitterTextOutOutputString, @@ -201,7 +198,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = { ConSplitterTextOutClearScreen, ConSplitterTextOutSetCursorPosition, ConSplitterTextOutEnableCursor, - (EFI_SIMPLE_TEXT_OUTPUT_MODE *) NULL + (EFI_SIMPLE_TEXT_OUTPUT_MODE *)NULL }, { 1, @@ -228,22 +225,23 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = { NULL, NULL }, - (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) NULL, + (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *)NULL, 0, 0, 0, - (TEXT_OUT_AND_GOP_DATA *) NULL, + (TEXT_OUT_AND_GOP_DATA *)NULL, 0, - (TEXT_OUT_SPLITTER_QUERY_DATA *) NULL, + (TEXT_OUT_SPLITTER_QUERY_DATA *)NULL, 0, - (INT32 *) NULL + (INT32 *)NULL, + FALSE }; // // Driver binding instance for Console Input Device // -EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding = { +EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding = { ConSplitterConInDriverBindingSupported, ConSplitterConInDriverBindingStart, ConSplitterConInDriverBindingStop, @@ -255,7 +253,7 @@ EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding = { // // Driver binding instance for Console Out device // -EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding = { +EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding = { ConSplitterConOutDriverBindingSupported, ConSplitterConOutDriverBindingStart, ConSplitterConOutDriverBindingStop, @@ -267,7 +265,7 @@ EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding = { // // Driver binding instance for Standard Error device // -EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding = { +EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding = { ConSplitterStdErrDriverBindingSupported, ConSplitterStdErrDriverBindingStart, ConSplitterStdErrDriverBindingStop, @@ -279,7 +277,7 @@ EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding = { // // Driver binding instance for Simple Pointer protocol // -EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding = { +EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding = { ConSplitterSimplePointerDriverBindingSupported, ConSplitterSimplePointerDriverBindingStart, ConSplitterSimplePointerDriverBindingStop, @@ -291,7 +289,7 @@ EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding = { // // Driver binding instance for Absolute Pointer protocol // -EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding = { +EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding = { ConSplitterAbsolutePointerDriverBindingSupported, ConSplitterAbsolutePointerDriverBindingStart, ConSplitterAbsolutePointerDriverBindingStop, @@ -300,6 +298,124 @@ EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding = NULL }; +/** + 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 ((DEBUG_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 + ); +} + +/** + Re-initialization 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. @@ -317,12 +433,12 @@ EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding = **/ EFI_STATUS EFIAPI -ConSplitterDriverEntry( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +ConSplitterDriverEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; + EFI_STATUS Status; // // Install driver model protocol(s). @@ -380,8 +496,10 @@ ConSplitterDriverEntry( // // Either Graphics Output protocol or UGA Draw protocol must be supported. // - ASSERT (FeaturePcdGet (PcdConOutGopSupport) || - FeaturePcdGet (PcdConOutUgaSupport)); + ASSERT ( + FeaturePcdGet (PcdConOutGopSupport) || + FeaturePcdGet (PcdConOutUgaSupport) + ); // // The driver creates virtual handles for ConIn, ConOut, StdErr. @@ -410,10 +528,11 @@ ConSplitterDriverEntry( // 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; + gST->ConsoleInHandle = mConIn.VirtualHandle; + gST->ConIn = &mConIn.TextIn; } } + // // Create virtual device handle for ConOut Splitter // @@ -433,7 +552,6 @@ ConSplitterDriverEntry( gST->ConsoleOutHandle = mConOut.VirtualHandle; gST->ConOut = &mConOut.TextOut; } - } // @@ -447,28 +565,27 @@ ConSplitterDriverEntry( &mStdErr.TextOut, NULL ); - if (!EFI_ERROR (Status)) { + if (!EFI_ERROR (Status)) { // // Update the EFI System Table with new virtual console // and update the pointer to Text Output protocol. // - gST->StandardErrorHandle = mStdErr.VirtualHandle; - gST->StdErr = &mStdErr.TextOut; + 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 - ); + (UINT8 *)&gST->Hdr, + gST->Hdr.HeaderSize, + &gST->Hdr.CRC32 + ); return EFI_SUCCESS; - } /** @@ -478,25 +595,26 @@ ConSplitterDriverEntry( structure. @retval EFI_OUT_OF_RESOURCES Out of resources. - @retval EFI_SUCCESS Text Input Devcie's private data has been constructed. + @retval EFI_SUCCESS Text Input Device's private data has been constructed. @retval other Failed to construct private data. **/ EFI_STATUS ConSplitterTextInConstructor ( - TEXT_IN_SPLITTER_PRIVATE_DATA *ConInPrivate + TEXT_IN_SPLITTER_PRIVATE_DATA *ConInPrivate ) { EFI_STATUS Status; + UINTN TextInExListCount; // // Allocate buffer for Simple Text Input device // Status = ConSplitterGrowBuffer ( - sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *), - &ConInPrivate->TextInListCount, - (VOID **) &ConInPrivate->TextInList - ); + sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *), + &ConInPrivate->TextInListCount, + (VOID **)&ConInPrivate->TextInList + ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } @@ -513,17 +631,31 @@ ConSplitterTextInConstructor ( ); ASSERT_EFI_ERROR (Status); + // + // 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 *), &ConInPrivate->TextInExListCount, - (VOID **) &ConInPrivate->TextInExList + (VOID **)&ConInPrivate->TextInExList ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } + // // Create Event to wait for a key Ex // @@ -538,28 +670,31 @@ ConSplitterTextInConstructor ( InitializeListHead (&ConInPrivate->NotifyList); + ToggleStateSyncInitialization (ConInPrivate); + ConInPrivate->AbsolutePointer.Mode = &ConInPrivate->AbsolutePointerMode; // // Allocate buffer for Absolute Pointer device // Status = ConSplitterGrowBuffer ( - sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *), - &ConInPrivate->AbsolutePointerListCount, - (VOID **) &ConInPrivate->AbsolutePointerList - ); + sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *), + &ConInPrivate->AbsolutePointerListCount, + (VOID **)&ConInPrivate->AbsolutePointerList + ); 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, - ConSplitterAbsolutePointerWaitForInput, - ConInPrivate, - &ConInPrivate->AbsolutePointer.WaitForInput - ); + EVT_NOTIFY_WAIT, + TPL_NOTIFY, + ConSplitterAbsolutePointerWaitForInput, + ConInPrivate, + &ConInPrivate->AbsolutePointer.WaitForInput + ); ASSERT_EFI_ERROR (Status); ConInPrivate->SimplePointer.Mode = &ConInPrivate->SimplePointerMode; @@ -567,13 +702,14 @@ ConSplitterTextInConstructor ( // Allocate buffer for Simple Pointer device // Status = ConSplitterGrowBuffer ( - sizeof (EFI_SIMPLE_POINTER_PROTOCOL *), - &ConInPrivate->PointerListCount, - (VOID **) &ConInPrivate->PointerList - ); + sizeof (EFI_SIMPLE_POINTER_PROTOCOL *), + &ConInPrivate->PointerListCount, + (VOID **)&ConInPrivate->PointerList + ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } + // // Create Event to wait for device input for Simple pointer device // @@ -591,7 +727,7 @@ ConSplitterTextInConstructor ( Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_CALLBACK, - ConSplitterEmptyCallbackFunction, + EfiEventEmptyFunction, NULL, &gConnectConInEventGuid, &ConInPrivate->ConnectConInEvent @@ -612,10 +748,10 @@ ConSplitterTextInConstructor ( **/ EFI_STATUS ConSplitterTextOutConstructor ( - TEXT_OUT_SPLITTER_PRIVATE_DATA *ConOutPrivate + TEXT_OUT_SPLITTER_PRIVATE_DATA *ConOutPrivate ) { - EFI_STATUS Status; + EFI_STATUS Status; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; // @@ -624,12 +760,13 @@ 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)); } // - // Initilize console output splitter's private data. + // Initialize console output splitter's private data. // ConOutPrivate->TextOut.Mode = &ConOutPrivate->TextOutMode; @@ -642,21 +779,22 @@ ConSplitterTextOutConstructor ( // Allocate buffer for Console Out device // Status = ConSplitterGrowBuffer ( - sizeof (TEXT_OUT_AND_GOP_DATA), - &ConOutPrivate->TextOutListCount, - (VOID **) &ConOutPrivate->TextOutList - ); + sizeof (TEXT_OUT_AND_GOP_DATA), + &ConOutPrivate->TextOutListCount, + (VOID **)&ConOutPrivate->TextOutList + ); 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, - (VOID **) &ConOutPrivate->TextOutQueryData - ); + sizeof (TEXT_OUT_SPLITTER_QUERY_DATA), + &ConOutPrivate->TextOutQueryDataCount, + (VOID **)&ConOutPrivate->TextOutQueryData + ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } @@ -664,17 +802,17 @@ ConSplitterTextOutConstructor ( // // Setup the default console to 80 x 25 and mode to 0 // - ConOutPrivate->TextOutQueryData[0].Columns = 80; - ConOutPrivate->TextOutQueryData[0].Rows = 25; + ConOutPrivate->TextOutQueryData[0].Columns = 80; + ConOutPrivate->TextOutQueryData[0].Rows = 25; TextOutSetMode (ConOutPrivate, 0); - if (FeaturePcdGet (PcdConOutUgaSupport)) { // // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz. // ConSplitterUgaDrawSetMode (&ConOutPrivate->UgaDraw, 800, 600, 32, 60); } + if (FeaturePcdGet (PcdConOutGopSupport)) { // // Setup resource for mode information in Graphics Output Protocol interface @@ -682,9 +820,11 @@ ConSplitterTextOutConstructor ( if ((ConOutPrivate->GraphicsOutput.Mode = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE))) == NULL) { return EFI_OUT_OF_RESOURCES; } + if ((ConOutPrivate->GraphicsOutput.Mode->Info = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION))) == NULL) { return EFI_OUT_OF_RESOURCES; } + // // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel // DevNull will be updated to user-defined mode after driver has started. @@ -692,12 +832,13 @@ ConSplitterTextOutConstructor ( if ((ConOutPrivate->GraphicsOutputModeBuffer = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION))) == NULL) { return EFI_OUT_OF_RESOURCES; } - Info = &ConOutPrivate->GraphicsOutputModeBuffer[0]; - Info->Version = 0; + + Info = &ConOutPrivate->GraphicsOutputModeBuffer[0]; + Info->Version = 0; Info->HorizontalResolution = 800; - Info->VerticalResolution = 600; - Info->PixelFormat = PixelBltOnly; - Info->PixelsPerScanLine = 800; + Info->VerticalResolution = 600; + Info->PixelFormat = PixelBltOnly; + Info->PixelsPerScanLine = 800; CopyMem (ConOutPrivate->GraphicsOutput.Mode->Info, Info, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); ConOutPrivate->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); @@ -705,7 +846,7 @@ ConSplitterTextOutConstructor ( // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode() // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize // - ConOutPrivate->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL; + ConOutPrivate->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS)(UINTN)NULL; ConOutPrivate->GraphicsOutput.Mode->FrameBufferSize = 0; ConOutPrivate->GraphicsOutput.Mode->MaxMode = 1; @@ -719,7 +860,6 @@ ConSplitterTextOutConstructor ( return EFI_SUCCESS; } - /** Test to see if the specified protocol could be supported on the specified device. @@ -728,15 +868,15 @@ ConSplitterTextOutConstructor ( @param Guid The specified protocol. @retval EFI_SUCCESS The specified protocol is supported on this device. - @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle. + @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtual handle. @retval other Failed to open specified protocol on this device. **/ EFI_STATUS ConSplitterSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_GUID *Guid + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_GUID *Guid ) { EFI_STATUS Status; @@ -745,10 +885,11 @@ ConSplitterSupported ( // // Make sure the Console Splitter does not attempt to attach to itself // - if (ControllerHandle == mConIn.VirtualHandle || - ControllerHandle == mConOut.VirtualHandle || - ControllerHandle == mStdErr.VirtualHandle - ) { + if ((ControllerHandle == mConIn.VirtualHandle) || + (ControllerHandle == mConOut.VirtualHandle) || + (ControllerHandle == mStdErr.VirtualHandle) + ) + { return EFI_UNSUPPORTED; } @@ -769,11 +910,11 @@ ConSplitterSupported ( } gBS->CloseProtocol ( - ControllerHandle, - Guid, - This->DriverBindingHandle, - ControllerHandle - ); + ControllerHandle, + Guid, + This->DriverBindingHandle, + ControllerHandle + ); return EFI_SUCCESS; } @@ -793,16 +934,16 @@ ConSplitterSupported ( EFI_STATUS EFIAPI ConSplitterConInDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { return ConSplitterSupported ( - This, - ControllerHandle, - &gEfiConsoleInDeviceGuid - ); + This, + ControllerHandle, + &gEfiConsoleInDeviceGuid + ); } /** @@ -820,16 +961,16 @@ ConSplitterConInDriverBindingSupported ( EFI_STATUS EFIAPI ConSplitterSimplePointerDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { return ConSplitterSupported ( - This, - ControllerHandle, - &gEfiSimplePointerProtocolGuid - ); + This, + ControllerHandle, + &gEfiSimplePointerProtocolGuid + ); } /** @@ -847,19 +988,18 @@ ConSplitterSimplePointerDriverBindingSupported ( EFI_STATUS EFIAPI ConSplitterAbsolutePointerDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { return ConSplitterSupported ( - This, - ControllerHandle, - &gEfiAbsolutePointerProtocolGuid - ); + This, + ControllerHandle, + &gEfiAbsolutePointerProtocolGuid + ); } - /** Test to see if Console Out Device could be supported on the Controller. @@ -875,16 +1015,16 @@ ConSplitterAbsolutePointerDriverBindingSupported ( EFI_STATUS EFIAPI ConSplitterConOutDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { return ConSplitterSupported ( - This, - ControllerHandle, - &gEfiConsoleOutDeviceGuid - ); + This, + ControllerHandle, + &gEfiConsoleOutDeviceGuid + ); } /** @@ -902,19 +1042,18 @@ ConSplitterConOutDriverBindingSupported ( EFI_STATUS EFIAPI ConSplitterStdErrDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { return ConSplitterSupported ( - This, - ControllerHandle, - &gEfiStandardErrorDeviceGuid - ); + This, + ControllerHandle, + &gEfiStandardErrorDeviceGuid + ); } - /** 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. @@ -934,12 +1073,12 @@ ConSplitterStdErrDriverBindingSupported ( **/ EFI_STATUS ConSplitterStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ConSplitterVirtualHandle, - IN EFI_GUID *DeviceGuid, - IN EFI_GUID *InterfaceGuid, - OUT VOID **Interface + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ConSplitterVirtualHandle, + IN EFI_GUID *DeviceGuid, + IN EFI_GUID *InterfaceGuid, + OUT VOID **Interface ) { EFI_STATUS Status; @@ -976,16 +1115,16 @@ ConSplitterStart ( } // - // Open InterfaceGuid on the virtul handle. + // Open InterfaceGuid on the virtual handle. // Status = gBS->OpenProtocol ( - ControllerHandle, - InterfaceGuid, - Interface, - This->DriverBindingHandle, - ConSplitterVirtualHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); + ControllerHandle, + InterfaceGuid, + Interface, + This->DriverBindingHandle, + ConSplitterVirtualHandle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); if (!EFI_ERROR (Status)) { return EFI_SUCCESS; @@ -995,27 +1134,26 @@ ConSplitterStart ( // close the DeviceGuid on ConSplitter VirtualHandle. // gBS->CloseProtocol ( - ControllerHandle, - DeviceGuid, - This->DriverBindingHandle, - ConSplitterVirtualHandle - ); + ControllerHandle, + DeviceGuid, + This->DriverBindingHandle, + ConSplitterVirtualHandle + ); Err: // // close the DeviceGuid on ControllerHandle. // gBS->CloseProtocol ( - ControllerHandle, - DeviceGuid, - This->DriverBindingHandle, - ControllerHandle - ); + ControllerHandle, + DeviceGuid, + This->DriverBindingHandle, + ControllerHandle + ); return Status; } - /** Start Console In Consplitter on device handle. @@ -1031,27 +1169,27 @@ Err: EFI_STATUS EFIAPI ConSplitterConInDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { - EFI_STATUS Status; - EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn; - EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx; + EFI_STATUS Status; + EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn; + EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx; // // Start ConSplitter on ControllerHandle, and create the virtual - // agrogated console device on first call Start for a SimpleTextIn handle. + // aggregated console device on first call Start for a SimpleTextIn handle. // Status = ConSplitterStart ( - This, - ControllerHandle, - mConIn.VirtualHandle, - &gEfiConsoleInDeviceGuid, - &gEfiSimpleTextInProtocolGuid, - (VOID **) &TextIn - ); + This, + ControllerHandle, + mConIn.VirtualHandle, + &gEfiConsoleInDeviceGuid, + &gEfiSimpleTextInProtocolGuid, + (VOID **)&TextIn + ); if (EFI_ERROR (Status)) { return Status; } @@ -1067,7 +1205,7 @@ ConSplitterConInDriverBindingStart ( Status = gBS->OpenProtocol ( ControllerHandle, &gEfiSimpleTextInputExProtocolGuid, - (VOID **) &TextInEx, + (VOID **)&TextInEx, This->DriverBindingHandle, mConIn.VirtualHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL @@ -1083,7 +1221,6 @@ ConSplitterConInDriverBindingStart ( return Status; } - /** Start Simple Pointer Consplitter on device handle. @@ -1099,26 +1236,26 @@ ConSplitterConInDriverBindingStart ( EFI_STATUS EFIAPI ConSplitterSimplePointerDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { - EFI_STATUS Status; - EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer; + EFI_STATUS Status; + EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer; // // Start ConSplitter on ControllerHandle, and create the virtual - // agrogated console device on first call Start for a SimplePointer handle. + // aggregated console device on first call Start for a SimplePointer handle. // Status = ConSplitterStart ( - This, - ControllerHandle, - mConIn.VirtualHandle, - &gEfiSimplePointerProtocolGuid, - &gEfiSimplePointerProtocolGuid, - (VOID **) &SimplePointer - ); + This, + ControllerHandle, + mConIn.VirtualHandle, + &gEfiSimplePointerProtocolGuid, + &gEfiSimplePointerProtocolGuid, + (VOID **)&SimplePointer + ); if (EFI_ERROR (Status)) { return Status; } @@ -1129,7 +1266,6 @@ ConSplitterSimplePointerDriverBindingStart ( return ConSplitterSimplePointerAddDevice (&mConIn, SimplePointer); } - /** Start Absolute Pointer Consplitter on device handle. @@ -1145,17 +1281,17 @@ ConSplitterSimplePointerDriverBindingStart ( EFI_STATUS EFIAPI ConSplitterAbsolutePointerDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { - EFI_STATUS Status; - EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer; + EFI_STATUS Status; + EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer; // // Start ConSplitter on ControllerHandle, and create the virtual - // agrogated console device on first call Start for a AbsolutePointer handle. + // aggregated console device on first call Start for a AbsolutePointer handle. // Status = ConSplitterStart ( This, @@ -1163,7 +1299,7 @@ ConSplitterAbsolutePointerDriverBindingStart ( mConIn.VirtualHandle, &gEfiAbsolutePointerProtocolGuid, &gEfiAbsolutePointerProtocolGuid, - (VOID **) &AbsolutePointer + (VOID **)&AbsolutePointer ); if (EFI_ERROR (Status)) { @@ -1176,7 +1312,6 @@ ConSplitterAbsolutePointerDriverBindingStart ( return ConSplitterAbsolutePointerAddDevice (&mConIn, AbsolutePointer); } - /** Start Console Out Consplitter on device handle. @@ -1192,30 +1327,30 @@ ConSplitterAbsolutePointerDriverBindingStart ( EFI_STATUS EFIAPI ConSplitterConOutDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + 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; - UINTN SizeOfInfo; - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; + 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 - // agrogated console device on first call Start for a ConsoleOut handle. + // aggregated console device on first call Start for a ConsoleOut handle. // Status = ConSplitterStart ( - This, - ControllerHandle, - mConOut.VirtualHandle, - &gEfiConsoleOutDeviceGuid, - &gEfiSimpleTextOutProtocolGuid, - (VOID **) &TextOut - ); + This, + ControllerHandle, + mConOut.VirtualHandle, + &gEfiConsoleOutDeviceGuid, + &gEfiSimpleTextOutProtocolGuid, + (VOID **)&TextOut + ); if (EFI_ERROR (Status)) { return Status; } @@ -1228,7 +1363,7 @@ ConSplitterConOutDriverBindingStart ( Status = gBS->OpenProtocol ( ControllerHandle, &gEfiGraphicsOutputProtocolGuid, - (VOID **) &GraphicsOutput, + (VOID **)&GraphicsOutput, This->DriverBindingHandle, mConOut.VirtualHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL @@ -1241,7 +1376,7 @@ ConSplitterConOutDriverBindingStart ( gBS->OpenProtocol ( ControllerHandle, &gEfiUgaDrawProtocolGuid, - (VOID **) &UgaDraw, + (VOID **)&UgaDraw, This->DriverBindingHandle, mConOut.VirtualHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL @@ -1270,7 +1405,8 @@ ConSplitterConOutDriverBindingStart ( if (EFI_ERROR (Status)) { return Status; } - ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); + + ASSERT (SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); mConOut.UgaHorizontalResolution = Info->HorizontalResolution; mConOut.UgaVerticalResolution = Info->VerticalResolution; @@ -1278,22 +1414,20 @@ ConSplitterConOutDriverBindingStart ( mConOut.UgaRefreshRate = 60; FreePool (Info); - } else if (UgaDraw != NULL) { Status = UgaDraw->GetMode ( - UgaDraw, - &mConOut.UgaHorizontalResolution, - &mConOut.UgaVerticalResolution, - &mConOut.UgaColorDepth, - &mConOut.UgaRefreshRate - ); + UgaDraw, + &mConOut.UgaHorizontalResolution, + &mConOut.UgaVerticalResolution, + &mConOut.UgaColorDepth, + &mConOut.UgaRefreshRate + ); } } return Status; } - /** Start Standard Error Consplitter on device handle. @@ -1309,9 +1443,9 @@ ConSplitterConOutDriverBindingStart ( EFI_STATUS EFIAPI ConSplitterStdErrDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { EFI_STATUS Status; @@ -1319,16 +1453,16 @@ ConSplitterStdErrDriverBindingStart ( // // Start ConSplitter on ControllerHandle, and create the virtual - // agrogated console device on first call Start for a StandardError handle. + // aggregated console device on first call Start for a StandardError handle. // Status = ConSplitterStart ( - This, - ControllerHandle, - mStdErr.VirtualHandle, - &gEfiStandardErrorDeviceGuid, - &gEfiSimpleTextOutProtocolGuid, - (VOID **) &TextOut - ); + This, + ControllerHandle, + mStdErr.VirtualHandle, + &gEfiStandardErrorDeviceGuid, + &gEfiSimpleTextOutProtocolGuid, + (VOID **)&TextOut + ); if (EFI_ERROR (Status)) { return Status; } @@ -1344,15 +1478,11 @@ ConSplitterStdErrDriverBindingStart ( // their MaxMode and QueryData should be the intersection of both. // Status = ConSplitterTextOutAddDevice (&mStdErr, TextOut, NULL, NULL); - ConSplitterTextOutSetAttribute (&mStdErr.TextOut, EFI_TEXT_ATTR (EFI_MAGENTA, EFI_BLACK)); - if (EFI_ERROR (Status)) { - return Status; - } + ConSplitterTextOutSetAttribute (&mStdErr.TextOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); return Status; } - /** Stop ConSplitter on device handle by closing Console Device Guid on device handle and the console virtual handle. @@ -1371,12 +1501,12 @@ ConSplitterStdErrDriverBindingStart ( **/ EFI_STATUS ConSplitterStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ConSplitterVirtualHandle, - IN EFI_GUID *DeviceGuid, - IN EFI_GUID *InterfaceGuid, - IN VOID **Interface + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ConSplitterVirtualHandle, + IN EFI_GUID *DeviceGuid, + IN EFI_GUID *InterfaceGuid, + IN VOID **Interface ) { EFI_STATUS Status; @@ -1392,29 +1522,29 @@ ConSplitterStop ( if (EFI_ERROR (Status)) { return Status; } + // - // close the protocol refered. + // close the protocol referred. // gBS->CloseProtocol ( - ControllerHandle, - DeviceGuid, - This->DriverBindingHandle, - ConSplitterVirtualHandle - ); + ControllerHandle, + DeviceGuid, + This->DriverBindingHandle, + ConSplitterVirtualHandle + ); gBS->CloseProtocol ( - ControllerHandle, - DeviceGuid, - This->DriverBindingHandle, - ControllerHandle - ); + ControllerHandle, + DeviceGuid, + This->DriverBindingHandle, + ControllerHandle + ); return EFI_SUCCESS; } - /** - Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID. + Stop Console In ConSplitter on ControllerHandle by closing Console In Device GUID. @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to stop driver on @@ -1429,15 +1559,15 @@ ConSplitterStop ( EFI_STATUS EFIAPI ConSplitterConInDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer ) { - EFI_STATUS Status; - EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn; - EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx; + EFI_STATUS Status; + EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn; + EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx; if (NumberOfChildren == 0) { return EFI_SUCCESS; @@ -1446,7 +1576,7 @@ ConSplitterConInDriverBindingStop ( Status = gBS->OpenProtocol ( ControllerHandle, &gEfiSimpleTextInputExProtocolGuid, - (VOID **) &TextInEx, + (VOID **)&TextInEx, This->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL @@ -1466,13 +1596,13 @@ ConSplitterConInDriverBindingStop ( // Close Simple Text In protocol on controller handle and virtual handle. // Status = ConSplitterStop ( - This, - ControllerHandle, - mConIn.VirtualHandle, - &gEfiConsoleInDeviceGuid, - &gEfiSimpleTextInProtocolGuid, - (VOID **) &TextIn - ); + This, + ControllerHandle, + mConIn.VirtualHandle, + &gEfiConsoleInDeviceGuid, + &gEfiSimpleTextInProtocolGuid, + (VOID **)&TextIn + ); if (EFI_ERROR (Status)) { return Status; } @@ -1483,7 +1613,6 @@ ConSplitterConInDriverBindingStop ( return ConSplitterTextInDeleteDevice (&mConIn, TextIn); } - /** Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing Simple Pointer protocol. @@ -1501,14 +1630,14 @@ ConSplitterConInDriverBindingStop ( EFI_STATUS EFIAPI ConSplitterSimplePointerDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer ) { - EFI_STATUS Status; - EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer; + EFI_STATUS Status; + EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer; if (NumberOfChildren == 0) { return EFI_SUCCESS; @@ -1518,13 +1647,13 @@ ConSplitterSimplePointerDriverBindingStop ( // Close Simple Pointer protocol on controller handle and virtual handle. // Status = ConSplitterStop ( - This, - ControllerHandle, - mConIn.VirtualHandle, - &gEfiSimplePointerProtocolGuid, - &gEfiSimplePointerProtocolGuid, - (VOID **) &SimplePointer - ); + This, + ControllerHandle, + mConIn.VirtualHandle, + &gEfiSimplePointerProtocolGuid, + &gEfiSimplePointerProtocolGuid, + (VOID **)&SimplePointer + ); if (EFI_ERROR (Status)) { return Status; } @@ -1535,7 +1664,6 @@ ConSplitterSimplePointerDriverBindingStop ( return ConSplitterSimplePointerDeleteDevice (&mConIn, SimplePointer); } - /** Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing Absolute Pointer protocol. @@ -1553,14 +1681,14 @@ ConSplitterSimplePointerDriverBindingStop ( EFI_STATUS EFIAPI ConSplitterAbsolutePointerDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer ) { - EFI_STATUS Status; - EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer; + EFI_STATUS Status; + EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer; if (NumberOfChildren == 0) { return EFI_SUCCESS; @@ -1575,7 +1703,7 @@ ConSplitterAbsolutePointerDriverBindingStop ( mConIn.VirtualHandle, &gEfiAbsolutePointerProtocolGuid, &gEfiAbsolutePointerProtocolGuid, - (VOID **) &AbsolutePointer + (VOID **)&AbsolutePointer ); if (EFI_ERROR (Status)) { return Status; @@ -1587,9 +1715,8 @@ ConSplitterAbsolutePointerDriverBindingStop ( return ConSplitterAbsolutePointerDeleteDevice (&mConIn, AbsolutePointer); } - /** - Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID. + Stop Console Out ConSplitter on device handle by closing Console Out Devcie GUID. @param This Driver Binding protocol instance pointer. @param ControllerHandle Handle of device to stop driver on @@ -1604,10 +1731,10 @@ ConSplitterAbsolutePointerDriverBindingStop ( EFI_STATUS EFIAPI ConSplitterConOutDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer ) { EFI_STATUS Status; @@ -1621,13 +1748,13 @@ ConSplitterConOutDriverBindingStop ( // Close Absolute Pointer protocol on controller handle and virtual handle. // Status = ConSplitterStop ( - This, - ControllerHandle, - mConOut.VirtualHandle, - &gEfiConsoleOutDeviceGuid, - &gEfiSimpleTextOutProtocolGuid, - (VOID **) &TextOut - ); + This, + ControllerHandle, + mConOut.VirtualHandle, + &gEfiConsoleOutDeviceGuid, + &gEfiSimpleTextOutProtocolGuid, + (VOID **)&TextOut + ); if (EFI_ERROR (Status)) { return Status; } @@ -1638,7 +1765,6 @@ ConSplitterConOutDriverBindingStop ( return ConSplitterTextOutDeleteDevice (&mConOut, TextOut); } - /** Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID. @@ -1655,10 +1781,10 @@ ConSplitterConOutDriverBindingStop ( EFI_STATUS EFIAPI ConSplitterStdErrDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer ) { EFI_STATUS Status; @@ -1672,23 +1798,23 @@ ConSplitterStdErrDriverBindingStop ( // Close Standard Error Device on controller handle and virtual handle. // Status = ConSplitterStop ( - This, - ControllerHandle, - mStdErr.VirtualHandle, - &gEfiStandardErrorDeviceGuid, - &gEfiSimpleTextOutProtocolGuid, - (VOID **) &TextOut - ); + This, + ControllerHandle, + mStdErr.VirtualHandle, + &gEfiStandardErrorDeviceGuid, + &gEfiSimpleTextOutProtocolGuid, + (VOID **)&TextOut + ); if (EFI_ERROR (Status)) { return Status; } + // // Delete this console error out device's data structures. // return ConSplitterTextOutDeleteDevice (&mStdErr, TextOut); } - /** Take the passed in Buffer of size ElementSize and grow the buffer by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes. @@ -1706,9 +1832,9 @@ ConSplitterStdErrDriverBindingStop ( **/ EFI_STATUS ConSplitterGrowBuffer ( - IN UINTN ElementSize, - IN OUT UINTN *Count, - IN OUT VOID **Buffer + IN UINTN ElementSize, + IN OUT UINTN *Count, + IN OUT VOID **Buffer ) { VOID *Ptr; @@ -1726,12 +1852,12 @@ ConSplitterGrowBuffer ( if (Ptr == NULL) { return EFI_OUT_OF_RESOURCES; } + *Count += CONSOLE_SPLITTER_ALLOC_UNIT; *Buffer = Ptr; return EFI_SUCCESS; } - /** Add Text Input Device in Consplitter Text Input list. @@ -1755,14 +1881,15 @@ ConSplitterTextInAddDevice ( // if (Private->CurrentNumberOfConsoles >= Private->TextInListCount) { Status = ConSplitterGrowBuffer ( - sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *), - &Private->TextInListCount, - (VOID **) &Private->TextInList - ); + sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *), + &Private->TextInListCount, + (VOID **)&Private->TextInList + ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } } + // // Add the new text-in device data structure into the Text In List. // @@ -1777,7 +1904,6 @@ ConSplitterTextInAddDevice ( return EFI_SUCCESS; } - /** Remove Text Input Device from Consplitter Text Input list. @@ -1794,14 +1920,15 @@ ConSplitterTextInDeleteDevice ( IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn ) { - UINTN Index; + 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. // for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) { if (Private->TextInList[Index] == TextIn) { - for (; Index < Private->CurrentNumberOfConsoles - 1; Index++) { + for ( ; Index < Private->CurrentNumberOfConsoles - 1; Index++) { Private->TextInList[Index] = Private->TextInList[Index + 1]; } @@ -1825,8 +1952,8 @@ ConSplitterTextInDeleteDevice ( **/ EFI_STATUS ConSplitterTextInExAddDevice ( - IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, - IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx + IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, + IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx ) { EFI_STATUS Status; @@ -1845,17 +1972,28 @@ ConSplitterTextInExAddDevice ( Status = ConSplitterGrowBuffer ( sizeof (EFI_HANDLE), &TextInExListCount, - (VOID **) &CurrentNotify->NotifyHandleList + (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, - (VOID **) &Private->TextInExList - ); + sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *), + &Private->TextInExListCount, + (VOID **)&Private->TextInExList + ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } @@ -1866,12 +2004,12 @@ ConSplitterTextInExAddDevice ( // 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] - ); + 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); @@ -1880,6 +2018,7 @@ ConSplitterTextInExAddDevice ( CurrentNotify->NotifyHandleList[Private->CurrentNumberOfExConsoles] ); } + return Status; } } @@ -1890,6 +2029,11 @@ ConSplitterTextInExAddDevice ( Private->TextInExList[Private->CurrentNumberOfExConsoles] = TextInEx; Private->CurrentNumberOfExConsoles++; + // + // Sync current toggle state to this new console input device. + // + TextInEx->SetState (TextInEx, &Private->PhysicalKeyToggleState); + // // Extra CheckEvent added to reduce the double CheckEvent(). // @@ -1910,18 +2054,19 @@ ConSplitterTextInExAddDevice ( **/ EFI_STATUS ConSplitterTextInExDeleteDevice ( - IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, - IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx + IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, + IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx ) { - UINTN Index; + UINTN Index; + // // 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 < Private->CurrentNumberOfExConsoles - 1; Index++) { + for ( ; Index < Private->CurrentNumberOfExConsoles - 1; Index++) { Private->TextInExList[Index] = Private->TextInExList[Index + 1]; } @@ -1933,7 +2078,6 @@ ConSplitterTextInExDeleteDevice ( return EFI_NOT_FOUND; } - /** Add Simple Pointer Device in Consplitter Simple Pointer list. @@ -1946,8 +2090,8 @@ ConSplitterTextInExDeleteDevice ( **/ EFI_STATUS ConSplitterSimplePointerAddDevice ( - IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, - IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer + IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, + IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer ) { EFI_STATUS Status; @@ -1957,14 +2101,15 @@ ConSplitterSimplePointerAddDevice ( // if (Private->CurrentNumberOfPointers >= Private->PointerListCount) { Status = ConSplitterGrowBuffer ( - sizeof (EFI_SIMPLE_POINTER_PROTOCOL *), - &Private->PointerListCount, - (VOID **) &Private->PointerList - ); + sizeof (EFI_SIMPLE_POINTER_PROTOCOL *), + &Private->PointerListCount, + (VOID **)&Private->PointerList + ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } } + // // Add the new text-in device data structure into the Simple Pointer List. // @@ -1974,7 +2119,6 @@ ConSplitterSimplePointerAddDevice ( return EFI_SUCCESS; } - /** Remove Simple Pointer Device from Consplitter Simple Pointer list. @@ -1987,18 +2131,19 @@ ConSplitterSimplePointerAddDevice ( **/ EFI_STATUS ConSplitterSimplePointerDeleteDevice ( - IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, - IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer + IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, + IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer ) { - UINTN Index; + UINTN Index; + // // 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 < Private->CurrentNumberOfPointers - 1; Index++) { + for ( ; Index < Private->CurrentNumberOfPointers - 1; Index++) { Private->PointerList[Index] = Private->PointerList[Index + 1]; } @@ -2010,7 +2155,6 @@ ConSplitterSimplePointerDeleteDevice ( return EFI_NOT_FOUND; } - /** Add Absolute Pointer Device in Consplitter Absolute Pointer list. @@ -2023,8 +2167,8 @@ ConSplitterSimplePointerDeleteDevice ( **/ EFI_STATUS ConSplitterAbsolutePointerAddDevice ( - IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, - IN EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer + IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, + IN EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer ) { EFI_STATUS Status; @@ -2034,14 +2178,15 @@ ConSplitterAbsolutePointerAddDevice ( // if (Private->CurrentNumberOfAbsolutePointers >= Private->AbsolutePointerListCount) { Status = ConSplitterGrowBuffer ( - sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *), - &Private->AbsolutePointerListCount, - (VOID **) &Private->AbsolutePointerList - ); + sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *), + &Private->AbsolutePointerListCount, + (VOID **)&Private->AbsolutePointerList + ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } } + // // Add the new text-in device data structure into the Absolute Pointer List. // @@ -2051,7 +2196,6 @@ ConSplitterAbsolutePointerAddDevice ( return EFI_SUCCESS; } - /** Remove Absolute Pointer Device from Consplitter Absolute Pointer list. @@ -2064,18 +2208,19 @@ ConSplitterAbsolutePointerAddDevice ( **/ EFI_STATUS ConSplitterAbsolutePointerDeleteDevice ( - IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, - IN EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer + IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, + IN EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer ) { - UINTN Index; + UINTN Index; + // // 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 < Private->CurrentNumberOfAbsolutePointers - 1; Index++) { + for ( ; Index < Private->CurrentNumberOfAbsolutePointers - 1; Index++) { Private->AbsolutePointerList[Index] = Private->AbsolutePointerList[Index + 1]; } @@ -2103,15 +2248,15 @@ ConSplitterGrowMapTable ( IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private ) { - UINTN Size; - UINTN NewSize; - UINTN TotalSize; - INT32 *TextOutModeMap; - INT32 *OldTextOutModeMap; - INT32 *SrcAddress; - INT32 Index; - UINTN OldStepSize; - UINTN NewStepSize; + UINTN Size; + UINTN NewSize; + UINTN TotalSize; + INT32 *TextOutModeMap; + INT32 *OldTextOutModeMap; + INT32 *SrcAddress; + INT32 Index; + UINTN OldStepSize; + UINTN NewStepSize; NewSize = Private->TextOutListCount * sizeof (INT32); OldTextOutModeMap = Private->TextOutModeMap; @@ -2120,7 +2265,7 @@ ConSplitterGrowMapTable ( // // Allocate new buffer for Text Out List. // - TextOutModeMap = AllocatePool (TotalSize); + TextOutModeMap = AllocatePool (TotalSize); if (TextOutModeMap == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -2145,11 +2290,10 @@ ConSplitterGrowMapTable ( // QueryDataCount // if (OldTextOutModeMap != NULL) { - Size = Private->CurrentNumberOfConsoles * sizeof (INT32); Index = 0; SrcAddress = OldTextOutModeMap; - NewStepSize = NewSize / sizeof(INT32); + 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. @@ -2171,6 +2315,7 @@ ConSplitterGrowMapTable ( SrcAddress += OldStepSize; Index++; } + // // Free the old buffer // @@ -2180,7 +2325,6 @@ ConSplitterGrowMapTable ( return EFI_SUCCESS; } - /** Add new device's output mode to console splitter's mode list. @@ -2193,8 +2337,8 @@ ConSplitterGrowMapTable ( **/ EFI_STATUS ConSplitterAddOutputMode ( - IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private, - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut + IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut ) { EFI_STATUS Status; @@ -2202,23 +2346,24 @@ ConSplitterAddOutputMode ( INT32 Mode; UINTN Index; - MaxMode = TextOut->Mode->MaxMode; - Private->TextOutMode.MaxMode = MaxMode; + MaxMode = TextOut->Mode->MaxMode; + Private->TextOutMode.MaxMode = MaxMode; // // Grow the buffer if query data buffer is not large enough to // hold all the mode supported by the first console. // - while (MaxMode > (INT32) Private->TextOutQueryDataCount) { + while (MaxMode > (INT32)Private->TextOutQueryDataCount) { Status = ConSplitterGrowBuffer ( - sizeof (TEXT_OUT_SPLITTER_QUERY_DATA), - &Private->TextOutQueryDataCount, - (VOID **) &Private->TextOutQueryData - ); + sizeof (TEXT_OUT_SPLITTER_QUERY_DATA), + &Private->TextOutQueryDataCount, + (VOID **)&Private->TextOutQueryData + ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } } + // // Allocate buffer for the output mode map // @@ -2226,6 +2371,7 @@ ConSplitterAddOutputMode ( if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } + // // As the first textout device, directly add the mode in to QueryData // and at the same time record the mapping between QueryData and TextOut. @@ -2234,19 +2380,20 @@ ConSplitterAddOutputMode ( Index = 0; while (Mode < MaxMode) { Status = TextOut->QueryMode ( - TextOut, - Mode, - &Private->TextOutQueryData[Mode].Columns, - &Private->TextOutQueryData[Mode].Rows - ); + TextOut, + Mode, + &Private->TextOutQueryData[Mode].Columns, + &Private->TextOutQueryData[Mode].Rows + ); // // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData // is clear to 0x0. // - if ((EFI_ERROR(Status)) && (Mode == 1)) { + if ((EFI_ERROR (Status)) && (Mode == 1)) { Private->TextOutQueryData[Mode].Columns = 0; - Private->TextOutQueryData[Mode].Rows = 0; + Private->TextOutQueryData[Mode].Rows = 0; } + Private->TextOutModeMap[Index] = Mode; Mode++; Index += Private->TextOutListCount; @@ -2273,20 +2420,20 @@ ConSplitterAddOutputMode ( **/ VOID ConSplitterGetIntersection ( - IN INT32 *TextOutModeMap, - IN INT32 *NewlyAddedMap, - IN UINTN MapStepSize, - IN UINTN NewMapStepSize, - IN OUT INT32 *MaxMode, - IN 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; + INT32 Index; + INT32 *CurrentMapEntry; + INT32 *NextMapEntry; + INT32 *NewMapEntry; + INT32 CurrentMaxMode; + INT32 Mode; // // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved @@ -2298,8 +2445,8 @@ ConSplitterGetIntersection ( NextMapEntry = CurrentMapEntry; NewMapEntry = &NewlyAddedMap[NewMapStepSize * 2]; - CurrentMaxMode = *MaxMode; - Mode = *CurrentMode; + CurrentMaxMode = *MaxMode; + Mode = *CurrentMode; while (Index < CurrentMaxMode) { if (*NewMapEntry == -1) { @@ -2312,6 +2459,7 @@ ConSplitterGetIntersection ( } else if (Index < *CurrentMode) { Mode--; } + (*MaxMode)--; } else { if (CurrentMapEntry != NextMapEntry) { @@ -2328,7 +2476,7 @@ ConSplitterGetIntersection ( *CurrentMode = Mode; - return ; + return; } /** @@ -2340,8 +2488,8 @@ ConSplitterGetIntersection ( **/ VOID ConSplitterSyncOutputMode ( - IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private, - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut + IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut ) { INT32 CurrentMaxMode; @@ -2359,32 +2507,34 @@ ConSplitterSyncOutputMode ( // // Must make sure that current mode won't change even if mode number changes // - CurrentMaxMode = Private->TextOutMode.MaxMode; - TextOutModeMap = Private->TextOutModeMap; - StepSize = Private->TextOutListCount; - TextOutQueryData = Private->TextOutQueryData; + CurrentMaxMode = Private->TextOutMode.MaxMode; + TextOutModeMap = Private->TextOutModeMap; + StepSize = Private->TextOutListCount; + TextOutQueryData = Private->TextOutQueryData; // // Query all the mode that the newly added TextOut supports // - Mode = 0; - MapTable = TextOutModeMap + Private->CurrentNumberOfConsoles; + Mode = 0; + MapTable = TextOutModeMap + Private->CurrentNumberOfConsoles; while (Mode < TextOut->Mode->MaxMode) { Status = TextOut->QueryMode (TextOut, Mode, &Columns, &Rows); - if (EFI_ERROR(Status)) { + 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; + MapTable[StepSize] = Mode; TextOutQueryData[Mode].Columns = 0; - TextOutQueryData[Mode].Rows = 0; + TextOutQueryData[Mode].Rows = 0; } + Mode++; continue; } + // // Search the intersection map and QueryData database to see if they intersects // @@ -2395,10 +2545,13 @@ ConSplitterSyncOutputMode ( MapTable[Index * StepSize] = Mode; break; } + Index++; } + Mode++; } + // // Now search the TextOutModeMap table to find the intersection of supported // mode between ConSplitter and the newly added device. @@ -2412,10 +2565,9 @@ ConSplitterSyncOutputMode ( &Private->TextOutMode.Mode ); - return ; + return; } - /** Sync output device between ConOut and StdErr output. @@ -2482,32 +2634,33 @@ ConSplitterGetIntersectionBetweenConOutAndStrErr ( if (!FoundTheSameTextOut) { return EFI_SUCCESS; } + // // Must make sure that current mode won't change even if mode number changes // - ConOutMaxMode = mConOut.TextOutMode.MaxMode; - ConOutModeMap = mConOut.TextOutModeMap; - ConOutStepSize = mConOut.TextOutListCount; - ConOutQueryData = mConOut.TextOutQueryData; + ConOutMaxMode = mConOut.TextOutMode.MaxMode; + ConOutModeMap = mConOut.TextOutModeMap; + ConOutStepSize = mConOut.TextOutListCount; + ConOutQueryData = mConOut.TextOutQueryData; - StdErrMaxMode = mStdErr.TextOutMode.MaxMode; - StdErrModeMap = mStdErr.TextOutModeMap; - StdErrStepSize = mStdErr.TextOutListCount; - StdErrQueryData = mStdErr.TextOutQueryData; + StdErrMaxMode = mStdErr.TextOutMode.MaxMode; + StdErrModeMap = mStdErr.TextOutModeMap; + StdErrStepSize = mStdErr.TextOutListCount; + StdErrQueryData = mStdErr.TextOutQueryData; // // Allocate the map table and set the map table's index to -1. // - ConOutMapTableSize = ConOutMaxMode * sizeof (INT32); - ConOutMapTable = AllocateZeroPool (ConOutMapTableSize); + ConOutMapTableSize = ConOutMaxMode * sizeof (INT32); + ConOutMapTable = AllocateZeroPool (ConOutMapTableSize); if (ConOutMapTable == NULL) { return EFI_OUT_OF_RESOURCES; } SetMem (ConOutMapTable, ConOutMapTableSize, 0xFF); - StdErrMapTableSize = StdErrMaxMode * sizeof (INT32); - StdErrMapTable = AllocateZeroPool (StdErrMapTableSize); + StdErrMapTableSize = StdErrMaxMode * sizeof (INT32); + StdErrMapTable = AllocateZeroPool (StdErrMapTableSize); if (StdErrMapTable == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -2516,14 +2669,14 @@ 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) { // // Search the intersection map and QueryData database to see if they intersect // - Index = 0; + Index = 0; ConOutMode = *(ConOutModeMap + Mode * ConOutStepSize); ConOutRows = ConOutQueryData[ConOutMode].Rows; ConOutColumns = ConOutQueryData[ConOutMode].Columns; @@ -2542,6 +2695,7 @@ ConSplitterGetIntersectionBetweenConOutAndStrErr ( Mode++; } + // // Now search the TextOutModeMap table to find the intersection of supported // mode between ConSplitter and the newly added device. @@ -2578,9 +2732,8 @@ ConSplitterGetIntersectionBetweenConOutAndStrErr ( return EFI_SUCCESS; } - /** - Add Grahpics Output modes into Consplitter Text Out list. + Add Graphics Output modes into Consplitter Text Out list. @param Private Text Out Splitter pointer. @param GraphicsOutput Graphics Output protocol pointer. @@ -2597,22 +2750,22 @@ ConSplitterAddGraphicsOutputMode ( IN EFI_UGA_DRAW_PROTOCOL *UgaDraw ) { - EFI_STATUS Status; - UINTN Index; - UINTN CurrentIndex; - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode; - UINTN SizeOfInfo; - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; - EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *CurrentGraphicsOutputMode; - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeBuffer; - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *MatchedMode; - UINTN NumberIndex; - BOOLEAN Match; - BOOLEAN AlreadyExist; - UINT32 UgaHorizontalResolution; - UINT32 UgaVerticalResolution; - UINT32 UgaColorDepth; - UINT32 UgaRefreshRate; + EFI_STATUS Status; + UINTN Index; + UINTN CurrentIndex; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode; + UINTN SizeOfInfo; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; + EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *CurrentGraphicsOutputMode; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeBuffer; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *MatchedMode; + UINTN NumberIndex; + BOOLEAN Match; + BOOLEAN AlreadyExist; + UINT32 UgaHorizontalResolution; + UINT32 UgaVerticalResolution; + UINT32 UgaColorDepth; + UINT32 UgaRefreshRate; ASSERT (GraphicsOutput != NULL || UgaDraw != NULL); @@ -2633,43 +2786,45 @@ ConSplitterAddGraphicsOutputMode ( if (GraphicsOutput != NULL) { if (Private->CurrentNumberOfGraphicsOutput == 0) { - // - // This is the first Graphics Output device added - // - CurrentGraphicsOutputMode->MaxMode = GraphicsOutput->Mode->MaxMode; - CurrentGraphicsOutputMode->Mode = GraphicsOutput->Mode->Mode; - CopyMem (CurrentGraphicsOutputMode->Info, GraphicsOutput->Mode->Info, GraphicsOutput->Mode->SizeOfInfo); - CurrentGraphicsOutputMode->SizeOfInfo = GraphicsOutput->Mode->SizeOfInfo; - CurrentGraphicsOutputMode->FrameBufferBase = GraphicsOutput->Mode->FrameBufferBase; - CurrentGraphicsOutputMode->FrameBufferSize = GraphicsOutput->Mode->FrameBufferSize; + // + // This is the first Graphics Output device added + // + CurrentGraphicsOutputMode->MaxMode = GraphicsOutput->Mode->MaxMode; + CurrentGraphicsOutputMode->Mode = GraphicsOutput->Mode->Mode; + CopyMem (CurrentGraphicsOutputMode->Info, GraphicsOutput->Mode->Info, GraphicsOutput->Mode->SizeOfInfo); + CurrentGraphicsOutputMode->SizeOfInfo = GraphicsOutput->Mode->SizeOfInfo; + CurrentGraphicsOutputMode->FrameBufferBase = GraphicsOutput->Mode->FrameBufferBase; + CurrentGraphicsOutputMode->FrameBufferSize = GraphicsOutput->Mode->FrameBufferSize; - // - // Allocate resource for the private mode buffer - // - ModeBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) * GraphicsOutput->Mode->MaxMode); - if (ModeBuffer == NULL) { - return EFI_OUT_OF_RESOURCES; - } - FreePool (Private->GraphicsOutputModeBuffer); - Private->GraphicsOutputModeBuffer = ModeBuffer; + // + // Allocate resource for the private mode buffer + // + ModeBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) * GraphicsOutput->Mode->MaxMode); + if (ModeBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + FreePool (Private->GraphicsOutputModeBuffer); + Private->GraphicsOutputModeBuffer = ModeBuffer; + + // + // Store all supported display modes to the private mode buffer + // + Mode = ModeBuffer; + for (Index = 0; Index < GraphicsOutput->Mode->MaxMode; Index++) { // - // Store all supported display modes to the private mode buffer + // The Info buffer would be allocated by callee // - 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); + 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); + } } else { // // Check intersection of display mode @@ -2680,7 +2835,7 @@ ConSplitterAddGraphicsOutputMode ( } MatchedMode = ModeBuffer; - Mode = &Private->GraphicsOutputModeBuffer[0]; + Mode = &Private->GraphicsOutputModeBuffer[0]; for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) { Match = FALSE; @@ -2688,12 +2843,14 @@ ConSplitterAddGraphicsOutputMode ( // // The Info buffer would be allocated by callee // - Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info); + Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32)NumberIndex, &SizeOfInfo, &Info); if (EFI_ERROR (Status)) { return Status; } + if ((Info->HorizontalResolution == Mode->HorizontalResolution) && - (Info->VerticalResolution == Mode->VerticalResolution)) { + (Info->VerticalResolution == Mode->VerticalResolution)) + { // // If GOP device supports one mode in current mode buffer, // it will be added into matched mode buffer @@ -2702,6 +2859,7 @@ ConSplitterAddGraphicsOutputMode ( FreePool (Info); break; } + FreePool (Info); } @@ -2713,7 +2871,8 @@ ConSplitterAddGraphicsOutputMode ( // for (Info = ModeBuffer; Info < MatchedMode; Info++) { if ((Info->HorizontalResolution == Mode->HorizontalResolution) && - (Info->VerticalResolution == Mode->VerticalResolution)) { + (Info->VerticalResolution == Mode->VerticalResolution)) + { AlreadyExist = TRUE; break; } @@ -2725,7 +2884,7 @@ ConSplitterAddGraphicsOutputMode ( // // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly // - MatchedMode->Version = 0; + MatchedMode->Version = 0; MatchedMode->PixelFormat = PixelBltOnly; ZeroMem (&MatchedMode->PixelInformation, sizeof (EFI_PIXEL_BITMASK)); @@ -2745,11 +2904,11 @@ ConSplitterAddGraphicsOutputMode ( // // Physical frame buffer is no longer available when there are more than one physical GOP devices // - CurrentGraphicsOutputMode->MaxMode = (UINT32) (((UINTN) MatchedMode - (UINTN) ModeBuffer) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); + CurrentGraphicsOutputMode->MaxMode = (UINT32)(((UINTN)MatchedMode - (UINTN)ModeBuffer) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); CurrentGraphicsOutputMode->Info->PixelFormat = PixelBltOnly; ZeroMem (&CurrentGraphicsOutputMode->Info->PixelInformation, sizeof (EFI_PIXEL_BITMASK)); - CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); - CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL; + CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); + CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS)(UINTN)NULL; CurrentGraphicsOutputMode->FrameBufferSize = 0; } @@ -2759,11 +2918,13 @@ ConSplitterAddGraphicsOutputMode ( for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) { Mode = &Private->GraphicsOutputModeBuffer[Index]; if ((Mode->HorizontalResolution == GraphicsOutput->Mode->Info->HorizontalResolution) && - (Mode->VerticalResolution == GraphicsOutput->Mode->Info->VerticalResolution)) { + (Mode->VerticalResolution == GraphicsOutput->Mode->Info->VerticalResolution)) + { CurrentIndex = Index; break; } } + if (Index >= CurrentGraphicsOutputMode->MaxMode) { // // if user defined mode is not found, set to default mode 800x600 @@ -2789,15 +2950,15 @@ ConSplitterAddGraphicsOutputMode ( &UgaRefreshRate ); - CurrentGraphicsOutputMode->MaxMode = 1; - Info = CurrentGraphicsOutputMode->Info; - Info->Version = 0; + 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); - CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL; + CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS)(UINTN)NULL; CurrentGraphicsOutputMode->FrameBufferSize = 0; // @@ -2816,6 +2977,7 @@ Done: if (GraphicsOutput != NULL) { Private->CurrentNumberOfGraphicsOutput++; } + if (UgaDraw != NULL) { Private->CurrentNumberOfUgaDraw++; } @@ -2823,30 +2985,35 @@ Done: // // Force GraphicsOutput mode to be set, // - + Mode = &Private->GraphicsOutputModeBuffer[CurrentIndex]; if ((GraphicsOutput != NULL) && (Mode->HorizontalResolution == CurrentGraphicsOutputMode->Info->HorizontalResolution) && - (Mode->VerticalResolution == CurrentGraphicsOutputMode->Info->VerticalResolution)) { - CurrentGraphicsOutputMode->Mode = (UINT32) CurrentIndex; + (Mode->VerticalResolution == CurrentGraphicsOutputMode->Info->VerticalResolution)) + { + CurrentGraphicsOutputMode->Mode = (UINT32)CurrentIndex; if ((Mode->HorizontalResolution != GraphicsOutput->Mode->Info->HorizontalResolution) || - (Mode->VerticalResolution != GraphicsOutput->Mode->Info->VerticalResolution)) { + (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); + 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); + + Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32)NumberIndex); } } else { // @@ -2856,14 +3023,14 @@ Done: // // 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)) { + 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); + Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, 0); } } @@ -2896,13 +3063,13 @@ ConsplitterSetConsoleOutMode ( CONSOLE_OUT_MODE MaxModeInfo; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut; - PreferMode = 0xFF; - BaseMode = 0xFF; - TextOut = &Private->TextOut; - MaxMode = (UINTN) (TextOut->Mode->MaxMode); + PreferMode = 0xFF; + BaseMode = 0xFF; + TextOut = &Private->TextOut; + MaxMode = (UINTN)(TextOut->Mode->MaxMode); MaxModeInfo.Column = 0; - MaxModeInfo.Row = 0; + MaxModeInfo.Row = 0; ModeInfo.Column = PcdGet32 (PcdConOutColumn); ModeInfo.Row = PcdGet32 (PcdConOutRow); @@ -2911,12 +3078,12 @@ ConsplitterSetConsoleOutMode ( // for (Mode = 0; Mode < MaxMode; Mode++) { Status = TextOut->QueryMode (TextOut, Mode, &Col, &Row); - if (!EFI_ERROR(Status)) { + if (!EFI_ERROR (Status)) { if ((ModeInfo.Column != 0) && (ModeInfo.Row != 0)) { // // Use user defined column and row // - if (Col == ModeInfo.Column && Row == ModeInfo.Row) { + if ((Col == ModeInfo.Column) && (Row == ModeInfo.Row)) { PreferMode = Mode; } } else { @@ -2925,12 +3092,13 @@ ConsplitterSetConsoleOutMode ( // find and set the highest text mode. // if ((Col >= MaxModeInfo.Column) && (Row >= MaxModeInfo.Row)) { - MaxModeInfo.Column = Col; - MaxModeInfo.Row = Row; - PreferMode = Mode; + MaxModeInfo.Column = Col; + MaxModeInfo.Row = Row; + PreferMode = Mode; } } - if (Col == 80 && Row == 25) { + + if ((Col == 80) && (Row == 25)) { BaseMode = Mode; } } @@ -2940,23 +3108,22 @@ ConsplitterSetConsoleOutMode ( // Set prefer mode to Text Out devices. // Status = TextOut->SetMode (TextOut, PreferMode); - if (EFI_ERROR(Status)) { + 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)); + ASSERT (!EFI_ERROR (Status)); Status = PcdSet32S (PcdConOutColumn, 80); - ASSERT(!EFI_ERROR(Status)); + ASSERT (!EFI_ERROR (Status)); Status = PcdSet32S (PcdConOutRow, 25); - ASSERT(!EFI_ERROR(Status)); + ASSERT (!EFI_ERROR (Status)); } - return ; + return; } - /** Add Text Output Device in Consplitter Text Output list. @@ -2971,39 +3138,41 @@ ConsplitterSetConsoleOutMode ( **/ EFI_STATUS ConSplitterTextOutAddDevice ( - IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private, - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut, - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput, - IN EFI_UGA_DRAW_PROTOCOL *UgaDraw + IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut, + IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput, + IN EFI_UGA_DRAW_PROTOCOL *UgaDraw ) { - 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; + 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; + Private->AddingConOutDevice = TRUE; // // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer(). // while (CurrentNumOfConsoles >= Private->TextOutListCount) { Status = ConSplitterGrowBuffer ( - sizeof (TEXT_OUT_AND_GOP_DATA), - &Private->TextOutListCount, - (VOID **) &Private->TextOutList - ); + sizeof (TEXT_OUT_AND_GOP_DATA), + &Private->TextOutListCount, + (VOID **)&Private->TextOutList + ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } + // // Also need to reallocate the TextOutModeMap table // @@ -3013,7 +3182,7 @@ ConSplitterTextOutAddDevice ( } } - TextAndGop = &Private->TextOutList[CurrentNumOfConsoles]; + TextAndGop = &Private->TextOutList[CurrentNumOfConsoles]; TextAndGop->TextOut = TextOut; TextAndGop->GraphicsOutput = GraphicsOutput; @@ -3037,12 +3206,12 @@ ConSplitterTextOutAddDevice ( // ConSplitterGetIntersectionBetweenConOutAndStrErr (); - MaxMode = Private->TextOutMode.MaxMode; + MaxMode = Private->TextOutMode.MaxMode; ASSERT (MaxMode >= 1); DeviceStatus = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR; - + // // This device display mode will be added into Graphics Ouput modes. // @@ -3059,50 +3228,52 @@ ConSplitterTextOutAddDevice ( if (EFI_ERROR (Status)) { return Status; } - ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); + + 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, - &UgaVerticalResolution, - &UgaColorDepth, - &UgaRefreshRate - ); + UgaDraw, + &UgaHorizontalResolution, + &UgaVerticalResolution, + &UgaColorDepth, + &UgaRefreshRate + ); 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, - UgaColorDepth, - UgaRefreshRate - ); + &Private->UgaDraw, + UgaHorizontalResolution, + UgaVerticalResolution, + UgaColorDepth, + UgaRefreshRate + ); } + // // If GetMode/SetMode is failed, set to 800x600 mode // - if(EFI_ERROR (Status)) { + if (EFI_ERROR (Status)) { Status = ConSplitterUgaDrawSetMode ( - &Private->UgaDraw, - 800, - 600, - 32, - 60 - ); + &Private->UgaDraw, + 800, + 600, + 32, + 60 + ); } } } if (((!EFI_ERROR (DeviceStatus)) || (!EFI_ERROR (Status))) && - ((Private->CurrentNumberOfGraphicsOutput + Private->CurrentNumberOfUgaDraw) == 1)) { + ((Private->CurrentNumberOfGraphicsOutput + Private->CurrentNumberOfUgaDraw) == 1)) + { if (!FeaturePcdGet (PcdConOutGopSupport)) { // // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed @@ -3147,10 +3318,11 @@ ConSplitterTextOutAddDevice ( // ConsplitterSetConsoleOutMode (Private); + Private->AddingConOutDevice = FALSE; + return Status; } - /** Remove Text Out Device in Consplitter Text Out list. @@ -3163,30 +3335,32 @@ ConSplitterTextOutAddDevice ( **/ EFI_STATUS ConSplitterTextOutDeleteDevice ( - IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private, - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut + IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut ) { - INT32 Index; - UINTN CurrentNumOfConsoles; - TEXT_OUT_AND_GOP_DATA *TextOutList; - EFI_STATUS Status; + INT32 Index; + UINTN CurrentNumOfConsoles; + TEXT_OUT_AND_GOP_DATA *TextOutList; + EFI_STATUS Status; // // Remove the specified text-out device data structure from the Text out List, // and rearrange the remaining data structures in the Text out List. // - CurrentNumOfConsoles = Private->CurrentNumberOfConsoles; - Index = (INT32) CurrentNumOfConsoles - 1; - TextOutList = Private->TextOutList; + CurrentNumOfConsoles = Private->CurrentNumberOfConsoles; + Index = (INT32)CurrentNumOfConsoles - 1; + TextOutList = Private->TextOutList; while (Index >= 0) { if (TextOutList->TextOut == TextOut) { 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; @@ -3195,6 +3369,7 @@ ConSplitterTextOutDeleteDevice ( Index--; TextOutList++; } + // // The specified TextOut is not managed by the ConSplitter driver // @@ -3212,7 +3387,7 @@ ConSplitterTextOutDeleteDevice ( Private->VirtualHandle, &gEfiUgaDrawProtocolGuid, &Private->UgaDraw - ); + ); } else if (!FeaturePcdGet (PcdConOutUgaSupport)) { Status = gBS->UninstallProtocolInterface ( Private->VirtualHandle, @@ -3221,13 +3396,13 @@ ConSplitterTextOutDeleteDevice ( ); } else { Status = gBS->UninstallMultipleProtocolInterfaces ( - Private->VirtualHandle, - &gEfiUgaDrawProtocolGuid, - &Private->UgaDraw, - &gEfiGraphicsOutputProtocolGuid, - &Private->GraphicsOutput, - NULL - ); + Private->VirtualHandle, + &gEfiUgaDrawProtocolGuid, + &Private->UgaDraw, + &gEfiGraphicsOutputProtocolGuid, + &Private->GraphicsOutput, + NULL + ); } } @@ -3235,16 +3410,17 @@ ConSplitterTextOutDeleteDevice ( // // 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; + Private->CurrentNumberOfConsoles = 0; + Private->TextOutMode.MaxMode = 1; + Private->TextOutQueryData[0].Columns = 80; + Private->TextOutQueryData[0].Rows = 25; TextOutSetMode (Private, 0); return EFI_SUCCESS; } + // - // Max Mode is realy an intersection of the QueryMode command to all + // Max Mode is really an intersection of the QueryMode command to all // devices. So we must copy the QueryMode of the first device to // QueryData. // @@ -3265,10 +3441,10 @@ ConSplitterTextOutDeleteDevice ( // // Now add one by one // - Index = 1; + Index = 1; Private->CurrentNumberOfConsoles = 1; TextOutList++; - while ((UINTN) Index < CurrentNumOfConsoles) { + while ((UINTN)Index < CurrentNumOfConsoles) { ConSplitterSyncOutputMode (Private, TextOutList->TextOut); Index++; Private->CurrentNumberOfConsoles++; @@ -3280,9 +3456,8 @@ ConSplitterTextOutDeleteDevice ( return Status; } - /** - Reset the input device and optionaly run diagnostics + Reset the input device and optionally run diagnostics @param This Protocol instance pointer. @param ExtendedVerification Driver may perform diagnostics on reset. @@ -3299,35 +3474,75 @@ ConSplitterTextInReset ( IN BOOLEAN ExtendedVerification ) { - EFI_STATUS Status; - EFI_STATUS ReturnStatus; - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - UINTN Index; + EFI_STATUS Status; + EFI_STATUS ReturnStatus; + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + UINTN Index; - Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This); + Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This); - Private->KeyEventSignalState = FALSE; + Private->KeyEventSignalState = FALSE; // // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { Status = Private->TextInList[Index]->Reset ( - Private->TextInList[Index], - ExtendedVerification - ); + Private->TextInList[Index], + ExtendedVerification + ); if (EFI_ERROR (Status)) { ReturnStatus = Status; } } + 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 - be used to test for existance of a keystroke via WaitForEvent () call. + be used to test for existence of a keystroke via WaitForEvent () call. @param Private Protocol instance pointer. @param Key Driver may perform diagnostics on reset. @@ -3341,41 +3556,65 @@ ConSplitterTextInReset ( EFI_STATUS EFIAPI ConSplitterTextInPrivateReadKeyStroke ( - IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, - OUT EFI_INPUT_KEY *Key + IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, + OUT EFI_INPUT_KEY *Key ) { EFI_STATUS Status; UINTN Index; - EFI_INPUT_KEY CurrentKey; + EFI_KEY_DATA KeyData; + + // + // Return the first saved non-NULL key. + // + while (TRUE) { + Status = ConSplitterTextInExDequeueKey (Private, &KeyData); + if (EFI_ERROR (Status)) { + break; + } + + if ((KeyData.Key.ScanCode != CHAR_NULL) || (KeyData.Key.UnicodeChar != SCAN_NULL)) { + CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY)); + return Status; + } + } - Key->UnicodeChar = 0; - Key->ScanCode = SCAN_NULL; + Key->UnicodeChar = 0; + Key->ScanCode = SCAN_NULL; // // 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. // - for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) { + for (Index = 0; Index < Private->CurrentNumberOfConsoles;) { Status = Private->TextInList[Index]->ReadKeyStroke ( - Private->TextInList[Index], - &CurrentKey - ); + Private->TextInList[Index], + &KeyData.Key + ); if (!EFI_ERROR (Status)) { - *Key = CurrentKey; - return 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_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. + be used to test for existence of a keystroke via WaitForEvent () call. @param This Protocol instance pointer. @param Key Driver may perform diagnostics on reset. @@ -3393,7 +3632,7 @@ ConSplitterTextInReadKeyStroke ( OUT EFI_INPUT_KEY *Key ) { - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This); @@ -3403,7 +3642,7 @@ ConSplitterTextInReadKeyStroke ( // 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")); + DEBUG ((DEBUG_INFO, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n")); gBS->SignalEvent (Private->ConnectConInEvent); mConInIsConnect = TRUE; } @@ -3411,7 +3650,6 @@ ConSplitterTextInReadKeyStroke ( return ConSplitterTextInPrivateReadKeyStroke (Private, Key); } - /** This event aggregates all the events of the ConIn devices in the spliter. @@ -3419,29 +3657,29 @@ ConSplitterTextInReadKeyStroke ( spliter event. This will cause the calling code to call ConSplitterTextInReadKeyStroke (). - @param Event The Event assoicated with callback. + @param Event The Event associated with callback. @param Context Context registered when Event was created. **/ VOID EFIAPI ConSplitterTextInWaitForKey ( - IN EFI_EVENT Event, - IN VOID *Context + IN EFI_EVENT Event, + IN VOID *Context ) { - EFI_STATUS Status; - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - UINTN Index; + EFI_STATUS Status; + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + UINTN Index; - Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context; + Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *)Context; if (Private->KeyEventSignalState) { // // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke() // gBS->SignalEvent (Event); - return ; + return; } // @@ -3456,8 +3694,6 @@ ConSplitterTextInWaitForKey ( } } - - /** Test if the key has been registered on input device. @@ -3469,7 +3705,7 @@ ConSplitterTextInWaitForKey ( pressed. @retval TRUE Key be pressed matches a registered key. - @retval FLASE Match failed. + @retval FALSE Match failed. **/ BOOLEAN @@ -3481,29 +3717,31 @@ IsKeyRegistered ( ASSERT (RegsiteredData != NULL && InputData != NULL); if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) || - (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) { + (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) + { return FALSE; } // // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored. // - if (RegsiteredData->KeyState.KeyShiftState != 0 && - RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) { + if ((RegsiteredData->KeyState.KeyShiftState != 0) && + (RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState)) + { return FALSE; } - if (RegsiteredData->KeyState.KeyToggleState != 0 && - RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) { + + if ((RegsiteredData->KeyState.KeyToggleState != 0) && + (RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState)) + { return FALSE; } return TRUE; - } - /** - Reset the input device and optionaly run diagnostics + Reset the input device and optionally run diagnostics @param This Protocol instance pointer. @param ExtendedVerification Driver may perform diagnostics on reset. @@ -3520,14 +3758,14 @@ ConSplitterTextInResetEx ( IN BOOLEAN ExtendedVerification ) { - EFI_STATUS Status; - EFI_STATUS ReturnStatus; - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - UINTN Index; + EFI_STATUS Status; + EFI_STATUS ReturnStatus; + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + UINTN Index; - Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This); + Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This); - Private->KeyEventSignalState = FALSE; + Private->KeyEventSignalState = FALSE; // // return the worst status met @@ -3542,14 +3780,20 @@ ConSplitterTextInResetEx ( } } - return ReturnStatus; + if (!EFI_ERROR (ReturnStatus)) { + ToggleStateSyncReInitialization (Private); + // + // Empty the key queue. + // + Private->CurrentNumberOfKeys = 0; + } + return ReturnStatus; } - /** Reads the next keystroke from the input device. The WaitForKey Event can - be used to test for existance of a keystroke via WaitForEvent () call. + be used to test for existence of a keystroke via WaitForEvent () call. @param This Protocol instance pointer. @param KeyData A pointer to a buffer that is filled in with the @@ -3566,15 +3810,15 @@ ConSplitterTextInResetEx ( EFI_STATUS EFIAPI ConSplitterTextInReadKeyStrokeEx ( - IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, - OUT EFI_KEY_DATA *KeyData + IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + OUT EFI_KEY_DATA *KeyData ) { - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - EFI_STATUS Status; - UINTN Index; - EFI_KEY_DATA CurrentKeyData; - + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + EFI_STATUS Status; + UINTN Index; + EFI_KEY_STATE KeyState; + EFI_KEY_DATA CurrentKeyData; if (KeyData == NULL) { return EFI_INVALID_PARAMETER; @@ -3584,38 +3828,97 @@ ConSplitterTextInReadKeyStrokeEx ( 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")); + DEBUG ((DEBUG_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; } - /** Set certain state for the input device. @@ -3638,9 +3941,10 @@ ConSplitterTextInSetState ( IN EFI_KEY_TOGGLE_STATE *KeyToggleState ) { - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - EFI_STATUS Status; - UINTN Index; + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + EFI_STATUS Status; + UINTN Index; + EFI_KEY_TOGGLE_STATE PhysicalKeyToggleState; if (KeyToggleState == NULL) { return EFI_INVALID_PARAMETER; @@ -3648,6 +3952,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 @@ -3655,33 +3965,43 @@ ConSplitterTextInSetState ( for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) { Status = Private->TextInExList[Index]->SetState ( Private->TextInExList[Index], - KeyToggleState + &PhysicalKeyToggleState ); if (EFI_ERROR (Status)) { return Status; } } - return EFI_SUCCESS; + // + // 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; } - /** 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. @retval EFI_SUCCESS The notification function was registered successfully. - @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data + @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necessary data structures. @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL. @@ -3695,15 +4015,14 @@ ConSplitterTextInRegisterKeyNotify ( OUT VOID **NotifyHandle ) { - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - EFI_STATUS Status; - UINTN Index; - TEXT_IN_EX_SPLITTER_NOTIFY *NewNotify; - LIST_ENTRY *Link; - TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify; - - - if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) { + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + EFI_STATUS Status; + UINTN Index; + TEXT_IN_EX_SPLITTER_NOTIFY *NewNotify; + LIST_ENTRY *Link; + TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify; + + if ((KeyData == NULL) || (NotifyHandle == NULL) || (KeyNotificationFunction == NULL)) { return EFI_INVALID_PARAMETER; } @@ -3725,15 +4044,17 @@ ConSplitterTextInRegisterKeyNotify ( // // Allocate resource to save the notification function // - NewNotify = (TEXT_IN_EX_SPLITTER_NOTIFY *) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY)); + NewNotify = (TEXT_IN_EX_SPLITTER_NOTIFY *)AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY)); if (NewNotify == NULL) { return EFI_OUT_OF_RESOURCES; } - NewNotify->NotifyHandleList = (EFI_HANDLE *) AllocateZeroPool (sizeof (EFI_HANDLE) * Private->TextInExListCount); + + NewNotify->NotifyHandleList = (VOID **)AllocateZeroPool (sizeof (VOID *) * 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 (EFI_KEY_DATA)); @@ -3759,21 +4080,20 @@ ConSplitterTextInRegisterKeyNotify ( NewNotify->NotifyHandleList[Index] ); } + gBS->FreePool (NewNotify->NotifyHandleList); gBS->FreePool (NewNotify); return Status; } } - InsertTailList (&mConIn.NotifyList, &NewNotify->NotifyEntry); + InsertTailList (&Private->NotifyList, &NewNotify->NotifyEntry); - *NotifyHandle = NewNotify; + *NotifyHandle = NewNotify; return EFI_SUCCESS; - } - /** Remove a registered notification function from a particular keystroke. @@ -3793,10 +4113,10 @@ ConSplitterTextInUnregisterKeyNotify ( IN VOID *NotificationHandle ) { - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - UINTN Index; - TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify; - LIST_ENTRY *Link; + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + UINTN Index; + TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify; + LIST_ENTRY *Link; if (NotificationHandle == NULL) { return EFI_INVALID_PARAMETER; @@ -3813,6 +4133,7 @@ ConSplitterTextInUnregisterKeyNotify ( CurrentNotify->NotifyHandleList[Index] ); } + RemoveEntryList (&CurrentNotify->NotifyEntry); gBS->FreePool (CurrentNotify->NotifyHandleList); @@ -3827,9 +4148,8 @@ ConSplitterTextInUnregisterKeyNotify ( return EFI_INVALID_PARAMETER; } - /** - Reset the input device and optionaly run diagnostics + Reset the input device and optionally run diagnostics @param This Protocol instance pointer. @param ExtendedVerification Driver may perform diagnostics on reset. @@ -3842,22 +4162,23 @@ ConSplitterTextInUnregisterKeyNotify ( EFI_STATUS EFIAPI ConSplitterSimplePointerReset ( - IN EFI_SIMPLE_POINTER_PROTOCOL *This, - IN BOOLEAN ExtendedVerification + IN EFI_SIMPLE_POINTER_PROTOCOL *This, + IN BOOLEAN ExtendedVerification ) { - EFI_STATUS Status; - EFI_STATUS ReturnStatus; - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - UINTN Index; + EFI_STATUS Status; + EFI_STATUS ReturnStatus; + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + UINTN Index; - Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This); + Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This); - Private->InputEventSignalState = FALSE; + Private->InputEventSignalState = FALSE; if (Private->CurrentNumberOfPointers == 0) { return EFI_SUCCESS; } + // // return the worst status met // @@ -3874,10 +4195,9 @@ ConSplitterSimplePointerReset ( return ReturnStatus; } - /** Reads the next keystroke from the input device. The WaitForKey Event can - be used to test for existance of a keystroke via WaitForEvent () call. + be used to test for existence of a keystroke via WaitForEvent () call. @param Private Protocol instance pointer. @param State The state information of simple pointer device. @@ -3891,8 +4211,8 @@ ConSplitterSimplePointerReset ( EFI_STATUS EFIAPI ConSplitterSimplePointerPrivateGetState ( - IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, - IN OUT EFI_SIMPLE_POINTER_STATE *State + IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, + IN OUT EFI_SIMPLE_POINTER_STATE *State ) { EFI_STATUS Status; @@ -3900,11 +4220,11 @@ ConSplitterSimplePointerPrivateGetState ( UINTN Index; EFI_SIMPLE_POINTER_STATE CurrentState; - State->RelativeMovementX = 0; - State->RelativeMovementY = 0; - State->RelativeMovementZ = 0; - State->LeftButton = FALSE; - State->RightButton = FALSE; + State->RelativeMovementX = 0; + State->RelativeMovementY = 0; + State->RelativeMovementZ = 0; + State->LeftButton = FALSE; + State->RightButton = FALSE; // // if no physical console input device exists, return EFI_NOT_READY; @@ -3913,7 +4233,6 @@ ConSplitterSimplePointerPrivateGetState ( // ReturnStatus = EFI_NOT_READY; for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) { - Status = Private->PointerList[Index]->GetState ( Private->PointerList[Index], &CurrentState @@ -3931,16 +4250,16 @@ ConSplitterSimplePointerPrivateGetState ( State->RightButton = TRUE; } - if (CurrentState.RelativeMovementX != 0 && Private->PointerList[Index]->Mode->ResolutionX != 0) { - State->RelativeMovementX += (CurrentState.RelativeMovementX * (INT32) Private->SimplePointerMode.ResolutionX) / (INT32) Private->PointerList[Index]->Mode->ResolutionX; + if ((CurrentState.RelativeMovementX != 0) && (Private->PointerList[Index]->Mode->ResolutionX != 0)) { + State->RelativeMovementX += (CurrentState.RelativeMovementX * (INT32)Private->SimplePointerMode.ResolutionX) / (INT32)Private->PointerList[Index]->Mode->ResolutionX; } - if (CurrentState.RelativeMovementY != 0 && Private->PointerList[Index]->Mode->ResolutionY != 0) { - State->RelativeMovementY += (CurrentState.RelativeMovementY * (INT32) Private->SimplePointerMode.ResolutionY) / (INT32) Private->PointerList[Index]->Mode->ResolutionY; + if ((CurrentState.RelativeMovementY != 0) && (Private->PointerList[Index]->Mode->ResolutionY != 0)) { + State->RelativeMovementY += (CurrentState.RelativeMovementY * (INT32)Private->SimplePointerMode.ResolutionY) / (INT32)Private->PointerList[Index]->Mode->ResolutionY; } - if (CurrentState.RelativeMovementZ != 0 && Private->PointerList[Index]->Mode->ResolutionZ != 0) { - State->RelativeMovementZ += (CurrentState.RelativeMovementZ * (INT32) Private->SimplePointerMode.ResolutionZ) / (INT32) Private->PointerList[Index]->Mode->ResolutionZ; + if ((CurrentState.RelativeMovementZ != 0) && (Private->PointerList[Index]->Mode->ResolutionZ != 0)) { + State->RelativeMovementZ += (CurrentState.RelativeMovementZ * (INT32)Private->SimplePointerMode.ResolutionZ) / (INT32)Private->PointerList[Index]->Mode->ResolutionZ; } } else if (Status == EFI_DEVICE_ERROR) { ReturnStatus = EFI_DEVICE_ERROR; @@ -3950,7 +4269,6 @@ ConSplitterSimplePointerPrivateGetState ( return ReturnStatus; } - /** Reads the next keystroke from the input device. The WaitForKey Event can be used to test for existance of a keystroke via WaitForEvent () call. @@ -3967,11 +4285,11 @@ ConSplitterSimplePointerPrivateGetState ( EFI_STATUS EFIAPI ConSplitterSimplePointerGetState ( - IN EFI_SIMPLE_POINTER_PROTOCOL *This, - IN OUT EFI_SIMPLE_POINTER_STATE *State + IN EFI_SIMPLE_POINTER_PROTOCOL *This, + IN OUT EFI_SIMPLE_POINTER_STATE *State ) { - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This); @@ -3980,37 +4298,37 @@ ConSplitterSimplePointerGetState ( return ConSplitterSimplePointerPrivateGetState (Private, State); } - /** - This event agregates all the events of the ConIn devices in the spliter. + 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 (). - @param Event The Event assoicated with callback. + @param Event The Event associated with callback. @param Context Context registered when Event was created. **/ VOID EFIAPI ConSplitterSimplePointerWaitForInput ( - IN EFI_EVENT Event, - IN VOID *Context + IN EFI_EVENT Event, + IN VOID *Context ) { - EFI_STATUS Status; - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - UINTN Index; + EFI_STATUS Status; + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + UINTN Index; - Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context; + Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *)Context; // // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke() // if (Private->InputEventSignalState) { gBS->SignalEvent (Event); - return ; + return; } + // // if any physical console input device has key input, signal the event. // @@ -4037,14 +4355,14 @@ ConSplitterSimplePointerWaitForInput ( EFI_STATUS EFIAPI ConSplitterAbsolutePointerReset ( - IN EFI_ABSOLUTE_POINTER_PROTOCOL *This, - IN BOOLEAN ExtendedVerification + IN EFI_ABSOLUTE_POINTER_PROTOCOL *This, + IN BOOLEAN ExtendedVerification ) { - EFI_STATUS Status; - EFI_STATUS ReturnStatus; - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - UINTN Index; + EFI_STATUS Status; + EFI_STATUS ReturnStatus; + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + UINTN Index; Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This); @@ -4053,6 +4371,7 @@ ConSplitterAbsolutePointerReset ( if (Private->CurrentNumberOfAbsolutePointers == 0) { return EFI_SUCCESS; } + // // return the worst status met // @@ -4069,7 +4388,6 @@ ConSplitterAbsolutePointerReset ( return ReturnStatus; } - /** Retrieves the current state of a pointer device. @@ -4092,32 +4410,32 @@ ConSplitterAbsolutePointerGetState ( IN OUT EFI_ABSOLUTE_POINTER_STATE *State ) { - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - EFI_STATUS Status; - 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; + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + EFI_STATUS Status; + 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); Private->AbsoluteInputEventSignalState = FALSE; - State->CurrentX = 0; - State->CurrentY = 0; - State->CurrentZ = 0; - State->ActiveButtons = 0; + State->CurrentX = 0; + State->CurrentY = 0; + State->CurrentZ = 0; + State->ActiveButtons = 0; VirtualMinX = Private->AbsolutePointerMode.AbsoluteMinX; VirtualMinY = Private->AbsolutePointerMode.AbsoluteMinY; @@ -4133,7 +4451,6 @@ ConSplitterAbsolutePointerGetState ( // ReturnStatus = EFI_NOT_READY; for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) { - Status = Private->AbsolutePointerList[Index]->GetState ( Private->AbsolutePointerList[Index], &CurrentState @@ -4155,16 +4472,38 @@ ConSplitterAbsolutePointerGetState ( // // Rescale to Con Splitter virtual Absolute Pointer's resolution. // - if (!(MinX == 0 && MaxX == 0)) { - State->CurrentX = VirtualMinX + (CurrentState.CurrentX * (VirtualMaxX - VirtualMinX)) / (MaxX - MinX); - } - if (!(MinY == 0 && MaxY == 0)) { - State->CurrentY = VirtualMinY + (CurrentState.CurrentY * (VirtualMaxY - VirtualMinY)) / (MaxY - MinY); + if (!((MinX == 0) && (MaxX == 0))) { + State->CurrentX = VirtualMinX + DivU64x64Remainder ( + MultU64x64 ( + CurrentState.CurrentX, + VirtualMaxX - VirtualMinX + ), + MaxX - MinX, + NULL + ); } - if (!(MinZ == 0 && MaxZ == 0)) { - State->CurrentZ = VirtualMinZ + (CurrentState.CurrentZ * (VirtualMaxZ - VirtualMinZ)) / (MaxZ - MinZ); + + if (!((MinY == 0) && (MaxY == 0))) { + State->CurrentY = VirtualMinY + DivU64x64Remainder ( + MultU64x64 ( + CurrentState.CurrentY, + VirtualMaxY - VirtualMinY + ), + MaxY - MinY, + NULL + ); } + if (!((MinZ == 0) && (MaxZ == 0))) { + State->CurrentZ = VirtualMinZ + DivU64x64Remainder ( + MultU64x64 ( + CurrentState.CurrentZ, + VirtualMaxZ - VirtualMinZ + ), + MaxZ - MinZ, + NULL + ); + } } else if (Status == EFI_DEVICE_ERROR) { ReturnStatus = EFI_DEVICE_ERROR; } @@ -4173,29 +4512,28 @@ ConSplitterAbsolutePointerGetState ( return ReturnStatus; } - /** - This event agregates all the events of the pointer devices in the splitter. + This event aggregates all the events of the pointer devices in the splitter. If any events of physical pointer devices are signaled, signal the pointer splitter event. This will cause the calling code to call ConSplitterAbsolutePointerGetState (). - @param Event The Event assoicated with callback. + @param Event The Event associated with callback. @param Context Context registered when Event was created. **/ VOID EFIAPI ConSplitterAbsolutePointerWaitForInput ( - IN EFI_EVENT Event, - IN VOID *Context + IN EFI_EVENT Event, + IN VOID *Context ) { - EFI_STATUS Status; - TEXT_IN_SPLITTER_PRIVATE_DATA *Private; - UINTN Index; + EFI_STATUS Status; + TEXT_IN_SPLITTER_PRIVATE_DATA *Private; + UINTN Index; - Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context; + Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *)Context; // // if AbsoluteInputEventSignalState is flagged before, @@ -4203,8 +4541,9 @@ ConSplitterAbsolutePointerWaitForInput ( // if (Private->AbsoluteInputEventSignalState) { gBS->SignalEvent (Event); - return ; + return; } + // // if any physical console input device has key input, signal the event. // @@ -4217,12 +4556,11 @@ ConSplitterAbsolutePointerWaitForInput ( } } - /** - Reset the text output device hardware and optionaly run diagnostics + Reset the text output device hardware and optionally run diagnostics @param This Protocol instance pointer. - @param ExtendedVerification Driver may perform more exhaustive verfication + @param ExtendedVerification Driver may perform more exhaustive verification operation of the device during reset. @retval EFI_SUCCESS The text output device was reset. @@ -4233,8 +4571,8 @@ ConSplitterAbsolutePointerWaitForInput ( EFI_STATUS EFIAPI ConSplitterTextOutReset ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN BOOLEAN ExtendedVerification + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN BOOLEAN ExtendedVerification ) { EFI_STATUS Status; @@ -4267,7 +4605,6 @@ ConSplitterTextOutReset ( return ReturnStatus; } - /** Write a Unicode string to the output device. @@ -4290,8 +4627,8 @@ ConSplitterTextOutReset ( EFI_STATUS EFIAPI ConSplitterTextOutOutputString ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN CHAR16 *WString + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN CHAR16 *WString ) { EFI_STATUS Status; @@ -4303,7 +4640,7 @@ ConSplitterTextOutOutputString ( This->SetAttribute (This, This->Mode->Attribute); - Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This); + Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This); // // return the worst status met @@ -4323,7 +4660,7 @@ ConSplitterTextOutOutputString ( Private->TextOutMode.CursorRow = Private->TextOutList[0].TextOut->Mode->CursorRow; } else { // - // When there is no real console devices in system, + // When there is no real console devices in system, // update cursor position for the virtual device in consplitter. // Private->TextOut.QueryMode ( @@ -4331,38 +4668,41 @@ ConSplitterTextOutOutputString ( Private->TextOutMode.Mode, &MaxColumn, &MaxRow - ); - for (; *WString != CHAR_NULL; WString++) { + ); + 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; - - 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)) { + 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; + + case CHAR_LINEFEED: + if (Private->TextOutMode.CursorRow < (INT32)(MaxRow - 1)) { Private->TextOutMode.CursorRow++; } - } - break; + + 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; } } } @@ -4370,7 +4710,6 @@ ConSplitterTextOutOutputString ( return ReturnStatus; } - /** Verifies that all characters in a Unicode string can be output to the target device. @@ -4389,8 +4728,8 @@ ConSplitterTextOutOutputString ( EFI_STATUS EFIAPI ConSplitterTextOutTestString ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN CHAR16 *WString + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN CHAR16 *WString ) { EFI_STATUS Status; @@ -4412,6 +4751,7 @@ ConSplitterTextOutTestString ( ReturnStatus = Status; } } + // // There is no DevNullTextOutTestString () since a Unicode buffer would // always return EFI_SUCCESS. @@ -4420,7 +4760,6 @@ ConSplitterTextOutTestString ( return ReturnStatus; } - /** Returns information for an available text mode that the output device(s) supports. @@ -4441,10 +4780,10 @@ ConSplitterTextOutTestString ( EFI_STATUS EFIAPI ConSplitterTextOutQueryMode ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN UINTN ModeNumber, - OUT UINTN *Columns, - OUT UINTN *Rows + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN UINTN ModeNumber, + OUT UINTN *Columns, + OUT UINTN *Rows ) { TEXT_OUT_SPLITTER_PRIVATE_DATA *Private; @@ -4457,11 +4796,11 @@ ConSplitterTextOutQueryMode ( // Check whether param ModeNumber is valid. // ModeNumber should be within range 0 ~ MaxMode - 1. // - if ( (ModeNumber > (UINTN)(((UINT32)-1)>>1)) ) { + if ((ModeNumber > (UINTN)(((UINT32)-1)>>1))) { return EFI_UNSUPPORTED; } - if ((INT32) ModeNumber >= This->Mode->MaxMode) { + if ((INT32)ModeNumber >= This->Mode->MaxMode) { return EFI_UNSUPPORTED; } @@ -4474,19 +4813,17 @@ ConSplitterTextOutQueryMode ( *Columns = Private->TextOutQueryData[CurrentMode].Columns; *Rows = Private->TextOutQueryData[CurrentMode].Rows; } else { - *Columns = Private->TextOutQueryData[ModeNumber].Columns; - *Rows = Private->TextOutQueryData[ModeNumber].Rows; + *Columns = Private->TextOutQueryData[ModeNumber].Columns; + *Rows = Private->TextOutQueryData[ModeNumber].Rows; } - if (*Columns <= 0 && *Rows <= 0) { + if ((*Columns <= 0) && (*Rows <= 0)) { return EFI_UNSUPPORTED; - } return EFI_SUCCESS; } - /** Sets the output device(s) to a specified mode. @@ -4502,8 +4839,8 @@ ConSplitterTextOutQueryMode ( EFI_STATUS EFIAPI ConSplitterTextOutSetMode ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN UINTN ModeNumber + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN UINTN ModeNumber ) { EFI_STATUS Status; @@ -4518,30 +4855,39 @@ ConSplitterTextOutSetMode ( // Check whether param ModeNumber is valid. // ModeNumber should be within range 0 ~ MaxMode - 1. // - if ( (ModeNumber > (UINTN)(((UINT32)-1)>>1)) ) { + if ((ModeNumber > (UINTN)(((UINT32)-1)>>1))) { return EFI_UNSUPPORTED; } - if ((INT32) ModeNumber >= This->Mode->MaxMode) { + if ((INT32)ModeNumber >= This->Mode->MaxMode) { return EFI_UNSUPPORTED; } + // // If the mode is being set to the curent mode, then just clear the screen and return. // - if (Private->TextOutMode.Mode == (INT32) ModeNumber) { + if (Private->TextOutMode.Mode == (INT32)ModeNumber) { return ConSplitterTextOutClearScreen (This); } + // // return the worst status met // TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber; for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - Status = Private->TextOutList[Index].TextOut->SetMode ( - Private->TextOutList[Index].TextOut, - TextOutModeMap[Index] - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; + // + // While adding a console out device do not set same mode again for the same device. + // + if ((!Private->AddingConOutDevice) || + (TextOutModeMap[Index] != Private->TextOutList[Index].TextOut->Mode->Mode)) + { + Status = Private->TextOutList[Index].TextOut->SetMode ( + Private->TextOutList[Index].TextOut, + TextOutModeMap[Index] + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; + } } } @@ -4553,7 +4899,6 @@ ConSplitterTextOutSetMode ( return ReturnStatus; } - /** Sets the background and foreground colors for the OutputString () and ClearScreen () functions. @@ -4574,8 +4919,8 @@ ConSplitterTextOutSetMode ( EFI_STATUS EFIAPI ConSplitterTextOutSetAttribute ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN UINTN Attribute + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN UINTN Attribute ) { EFI_STATUS Status; @@ -4605,12 +4950,11 @@ ConSplitterTextOutSetAttribute ( } } - Private->TextOutMode.Attribute = (INT32) Attribute; + Private->TextOutMode.Attribute = (INT32)Attribute; return ReturnStatus; } - /** Clears the output device(s) display to the currently selected background color. @@ -4626,7 +4970,7 @@ ConSplitterTextOutSetAttribute ( EFI_STATUS EFIAPI ConSplitterTextOutClearScreen ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This ) { EFI_STATUS Status; @@ -4651,14 +4995,13 @@ ConSplitterTextOutClearScreen ( // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should // always be supported. // - Private->TextOutMode.CursorColumn = 0; - Private->TextOutMode.CursorRow = 0; + Private->TextOutMode.CursorColumn = 0; + Private->TextOutMode.CursorRow = 0; Private->TextOutMode.CursorVisible = TRUE; return ReturnStatus; } - /** Sets the current coordinates of the cursor position @@ -4681,9 +5024,9 @@ ConSplitterTextOutClearScreen ( EFI_STATUS EFIAPI ConSplitterTextOutSetCursorPosition ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN UINTN Column, - IN UINTN Row + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN UINTN Column, + IN UINTN Row ) { EFI_STATUS Status; @@ -4696,9 +5039,9 @@ ConSplitterTextOutSetCursorPosition ( INT32 ModeNumber; INT32 CurrentMode; - Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This); - TextOutModeMap = NULL; - ModeNumber = Private->TextOutMode.Mode; + Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This); + TextOutModeMap = NULL; + ModeNumber = Private->TextOutMode.Mode; // // Get current MaxColumn and MaxRow from intersection map @@ -4713,9 +5056,10 @@ ConSplitterTextOutSetCursorPosition ( MaxColumn = Private->TextOutQueryData[CurrentMode].Columns; MaxRow = Private->TextOutQueryData[CurrentMode].Rows; - if (Column >= MaxColumn || Row >= MaxRow) { + if ((Column >= MaxColumn) || (Row >= MaxRow)) { return EFI_UNSUPPORTED; } + // // return the worst status met // @@ -4735,13 +5079,12 @@ ConSplitterTextOutSetCursorPosition ( // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should // always be supported. // - Private->TextOutMode.CursorColumn = (INT32) Column; - Private->TextOutMode.CursorRow = (INT32) Row; + Private->TextOutMode.CursorColumn = (INT32)Column; + Private->TextOutMode.CursorRow = (INT32)Row; return ReturnStatus; } - /** Makes the cursor visible or invisible @@ -4759,8 +5102,8 @@ ConSplitterTextOutSetCursorPosition ( EFI_STATUS EFIAPI ConSplitterTextOutEnableCursor ( - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN BOOLEAN Visible + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN BOOLEAN Visible ) { EFI_STATUS Status; @@ -4787,21 +5130,3 @@ ConSplitterTextOutEnableCursor ( return ReturnStatus; } - - -/** - An empty function to pass error checking of CreateEventEx (). - - @param Event Event whose notification function is being invoked. - @param Context Pointer to the notification function's context, - which is implementation-dependent. - -**/ -VOID -EFIAPI -ConSplitterEmptyCallbackFunction ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ -}