X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FConsole%2FConSplitterDxe%2FConSplitter.c;h=ab42b924dd55f8a163d9ca0fafe1f9c131a4362b;hp=78d9e9497f6d5d25094c0556c0a74c15ed939157;hb=fe3396514022ec798f304b9e28d4ac6a04e01946;hpb=7fc80d44841dbc1f1b68d75312ab7ec9e6d63613 diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c index 78d9e9497f..ab42b924dd 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c @@ -16,8 +16,8 @@ never removed. Such design ensures sytem function well during none console device situation. -Copyright (c) 2006 - 2008 Intel Corporation.
-All rights reserved. This program and the accompanying materials +Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -35,6 +35,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE, (EFI_HANDLE) NULL, + { ConSplitterTextInReset, ConSplitterTextInReadKeyStroke, @@ -43,6 +44,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { 0, (EFI_SIMPLE_TEXT_INPUT_PROTOCOL **) NULL, 0, + { ConSplitterTextInResetEx, ConSplitterTextInReadKeyStrokeEx, @@ -82,7 +84,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { (EFI_EVENT) NULL, (EFI_ABSOLUTE_POINTER_MODE *) NULL }, - { 0, // AbsoluteMinX 0, // AbsoluteMinY @@ -97,22 +98,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { 0, FALSE, - FALSE, - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }, - 0, - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }, - (EFI_EVENT) NULL, - FALSE, FALSE }; @@ -122,18 +107,18 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { // Uga Draw Protocol Private Data template // GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate = { - ConSpliterUgaDrawGetMode, - ConSpliterUgaDrawSetMode, - ConSpliterUgaDrawBlt + ConSplitterUgaDrawGetMode, + ConSplitterUgaDrawSetMode, + ConSplitterUgaDrawBlt }; // // Graphics Output Protocol Private Data template // GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate = { - ConSpliterGraphicsOutputQueryMode, - ConSpliterGraphicsOutputSetMode, - ConSpliterGraphicsOutputBlt, + ConSplitterGraphicsOutputQueryMode, + ConSplitterGraphicsOutputSetMode, + ConSplitterGraphicsOutputBlt, NULL }; @@ -164,6 +149,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = { 0, FALSE, }, + { NULL, NULL, @@ -173,35 +159,22 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = { 0, 0, 0, - (EFI_UGA_PIXEL *) NULL, + { NULL, NULL, NULL, NULL }, - (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL, (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) NULL, 0, 0, - TRUE, - { - ConSpliterConsoleControlGetMode, - ConSpliterConsoleControlSetMode, - ConSpliterConsoleControlLockStdIn - }, 0, (TEXT_OUT_AND_GOP_DATA *) NULL, 0, (TEXT_OUT_SPLITTER_QUERY_DATA *) NULL, 0, - (INT32 *) NULL, - - EfiConsoleControlScreenText, - 0, - 0, - (CHAR16 *) NULL, (INT32 *) NULL }; @@ -231,6 +204,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = { 0, FALSE, }, + { NULL, NULL, @@ -240,35 +214,22 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = { 0, 0, 0, - (EFI_UGA_PIXEL *) NULL, + { NULL, NULL, NULL, NULL }, - (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL, (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) NULL, 0, 0, - TRUE, - { - ConSpliterConsoleControlGetMode, - ConSpliterConsoleControlSetMode, - ConSpliterConsoleControlLockStdIn - }, 0, (TEXT_OUT_AND_GOP_DATA *) NULL, 0, (TEXT_OUT_SPLITTER_QUERY_DATA *) NULL, 0, - (INT32 *) NULL, - - EfiConsoleControlScreenText, - 0, - 0, - (CHAR16 *) NULL, (INT32 *) NULL }; @@ -416,25 +377,11 @@ ConSplitterDriverEntry( FeaturePcdGet (PcdConOutUgaSupport)); // - // The driver creates virtual handles for ConIn, ConOut, and StdErr. + // The driver creates virtual handles for ConIn, ConOut, StdErr. // The virtual handles will always exist even if no console exist in the // system. This is need to support hotplug devices like USB. // // - // Create virtual device handle for StdErr Splitter - // - Status = ConSplitterTextOutConstructor (&mStdErr); - if (!EFI_ERROR (Status)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &mStdErr.VirtualHandle, - &gEfiSimpleTextOutProtocolGuid, - &mStdErr.TextOut, - &gEfiPrimaryStandardErrorDeviceGuid, - NULL, - NULL - ); - } - // // Create virtual device handle for ConIn Splitter // Status = ConSplitterTextInConstructor (&mConIn); @@ -449,8 +396,6 @@ ConSplitterDriverEntry( &mConIn.SimplePointer, &gEfiAbsolutePointerProtocolGuid, &mConIn.AbsolutePointer, - &gEfiPrimaryConsoleInDeviceGuid, - NULL, NULL ); if (!EFI_ERROR (Status)) { @@ -478,10 +423,6 @@ ConSplitterDriverEntry( &mConOut.TextOut, &gEfiUgaDrawProtocolGuid, &mConOut.UgaDraw, - &gEfiConsoleControlProtocolGuid, - &mConOut.ConsoleControl, - &gEfiPrimaryConsoleOutDeviceGuid, - NULL, NULL ); } else if (!FeaturePcdGet (PcdConOutUgaSupport)) { @@ -495,10 +436,6 @@ ConSplitterDriverEntry( &mConOut.TextOut, &gEfiGraphicsOutputProtocolGuid, &mConOut.GraphicsOutput, - &gEfiConsoleControlProtocolGuid, - &mConOut.ConsoleControl, - &gEfiPrimaryConsoleOutDeviceGuid, - NULL, NULL ); } else { @@ -514,10 +451,6 @@ ConSplitterDriverEntry( &mConOut.GraphicsOutput, &gEfiUgaDrawProtocolGuid, &mConOut.UgaDraw, - &gEfiConsoleControlProtocolGuid, - &mConOut.ConsoleControl, - &gEfiPrimaryConsoleOutDeviceGuid, - NULL, NULL ); } @@ -532,6 +465,28 @@ ConSplitterDriverEntry( } } + + // + // Create virtual device handle for StdErr Splitter + // + Status = ConSplitterTextOutConstructor (&mStdErr); + if (!EFI_ERROR (Status)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &mStdErr.VirtualHandle, + &gEfiSimpleTextOutProtocolGuid, + &mStdErr.TextOut, + NULL + ); + if (!EFI_ERROR (Status)) { + // + // Update the EFI System Table with new virtual console + // and update the pointer to Text Output protocol. + // + gST->StandardErrorHandle = mStdErr.VirtualHandle; + gST->StdErr = &mStdErr.TextOut; + } + } + // // Update the CRC32 in the EFI System Table header // @@ -575,17 +530,7 @@ ConSplitterTextInConstructor ( if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } - // - // Create Event to support locking StdIn Device - // - Status = gBS->CreateEvent ( - EVT_TIMER | EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - ConSpliterConsoleControlLockStdInEvent, - NULL, - &ConInPrivate->LockEvent - ); - ASSERT_EFI_ERROR (Status); + // // Create Event to wait for a key // @@ -735,17 +680,18 @@ ConSplitterTextOutConstructor ( } // - // Setup the DevNullTextOut console to 80 x 25 + // Setup the default console to 80 x 25 and mode to 0 // ConOutPrivate->TextOutQueryData[0].Columns = 80; ConOutPrivate->TextOutQueryData[0].Rows = 25; - DevNullTextOutSetMode (ConOutPrivate, 0); + TextOutSetMode (ConOutPrivate, 0); + if (FeaturePcdGet (PcdConOutUgaSupport)) { // - // Setup the DevNullUgaDraw to 800 x 600 x 32 bits per pixel, 60Hz. + // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz. // - ConSpliterUgaDrawSetMode (&ConOutPrivate->UgaDraw, 800, 600, 32, 60); + ConSplitterUgaDrawSetMode (&ConOutPrivate->UgaDraw, 800, 600, 32, 60); } if (FeaturePcdGet (PcdConOutGopSupport)) { // @@ -1033,7 +979,7 @@ ConSplitterStart ( } // - // Create virtual handle and open DeviceGuid on the virtul handle. + // Open the Parent Handle for the child. // Status = gBS->OpenProtocol ( ControllerHandle, @@ -1421,20 +1367,6 @@ ConSplitterStdErrDriverBindingStart ( return Status; } - if (mStdErr.CurrentNumberOfConsoles == 1) { - gST->StandardErrorHandle = mStdErr.VirtualHandle; - gST->StdErr = &mStdErr.TextOut; - // - // Update the CRC32 in the EFI System Table header - // - gST->Hdr.CRC32 = 0; - gBS->CalculateCrc32 ( - (UINT8 *) &gST->Hdr, - gST->Hdr.HeaderSize, - &gST->Hdr.CRC32 - ); - } - return Status; } @@ -1771,26 +1703,7 @@ ConSplitterStdErrDriverBindingStop ( // // Delete this console error out device's data structures. // - Status = ConSplitterTextOutDeleteDevice (&mStdErr, TextOut); - if (EFI_ERROR (Status)) { - return Status; - } - - if (mStdErr.CurrentNumberOfConsoles == 0) { - gST->StandardErrorHandle = NULL; - gST->StdErr = NULL; - // - // Update the CRC32 in the EFI System Table header - // - gST->Hdr.CRC32 = 0; - gBS->CalculateCrc32 ( - (UINT8 *) &gST->Hdr, - gST->Hdr.HeaderSize, - &gST->Hdr.CRC32 - ); - } - - return Status; + return ConSplitterTextOutDeleteDevice (&mStdErr, TextOut); } @@ -1811,8 +1724,8 @@ ConSplitterStdErrDriverBindingStop ( **/ EFI_STATUS ConSplitterGrowBuffer ( - IN UINTN SizeOfCount, - IN UINTN *Count, + IN UINTN SizeOfCount, + IN OUT UINTN *Count, IN OUT VOID **Buffer ) { @@ -1906,7 +1819,7 @@ ConSplitterTextInDeleteDevice ( // for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) { if (Private->TextInList[Index] == TextIn) { - for (Index = Index; Index < Private->CurrentNumberOfConsoles - 1; Index++) { + for (; Index < Private->CurrentNumberOfConsoles - 1; Index++) { Private->TextInList[Index] = Private->TextInList[Index + 1]; } @@ -1986,7 +1899,7 @@ ConSplitterTextInExDeleteDevice ( // for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) { if (Private->TextInExList[Index] == TextInEx) { - for (Index = Index; Index < Private->CurrentNumberOfExConsoles - 1; Index++) { + for (; Index < Private->CurrentNumberOfExConsoles - 1; Index++) { Private->TextInExList[Index] = Private->TextInExList[Index + 1]; } @@ -2063,7 +1976,7 @@ ConSplitterSimplePointerDeleteDevice ( // for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) { if (Private->PointerList[Index] == SimplePointer) { - for (Index = Index; Index < Private->CurrentNumberOfPointers - 1; Index++) { + for (; Index < Private->CurrentNumberOfPointers - 1; Index++) { Private->PointerList[Index] = Private->PointerList[Index + 1]; } @@ -2140,7 +2053,7 @@ ConSplitterAbsolutePointerDeleteDevice ( // for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) { if (Private->AbsolutePointerList[Index] == AbsolutePointer) { - for (Index = Index; Index < Private->CurrentNumberOfAbsolutePointers - 1; Index++) { + for (; Index < Private->CurrentNumberOfAbsolutePointers - 1; Index++) { Private->AbsolutePointerList[Index] = Private->AbsolutePointerList[Index + 1]; } @@ -2671,6 +2584,7 @@ ConSplitterAddGraphicsOutputMode ( Index = 0; CurrentIndex = 0; + Status = EFI_SUCCESS; if (Private->CurrentNumberOfUgaDraw != 0) { // @@ -2692,7 +2606,7 @@ ConSplitterAddGraphicsOutputMode ( CurrentGraphicsOutputMode->SizeOfInfo = GraphicsOutput->Mode->SizeOfInfo; CurrentGraphicsOutputMode->FrameBufferBase = GraphicsOutput->Mode->FrameBufferBase; CurrentGraphicsOutputMode->FrameBufferSize = GraphicsOutput->Mode->FrameBufferSize; - + // // Allocate resource for the private mode buffer // @@ -2872,24 +2786,49 @@ Done: // // Force GraphicsOutput mode to be set, - // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode - // - Private->HardwareNeedsStarting = TRUE; - // - // Current mode number may need update now, so set it to an invalid mode number // - CurrentGraphicsOutputMode->Mode = 0xffff; - // - // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode. - // - Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, (UINT32) CurrentIndex); - if (EFI_ERROR(Status)) { + + Mode = &Private->GraphicsOutputModeBuffer[CurrentIndex]; + if ((GraphicsOutput != NULL) && + (Mode->HorizontalResolution == CurrentGraphicsOutputMode->Info->HorizontalResolution) && + (Mode->VerticalResolution == CurrentGraphicsOutputMode->Info->VerticalResolution)) { + CurrentGraphicsOutputMode->Mode = (UINT32) CurrentIndex; + if ((Mode->HorizontalResolution != GraphicsOutput->Mode->Info->HorizontalResolution) || + (Mode->VerticalResolution != GraphicsOutput->Mode->Info->VerticalResolution)) { + // + // If all existing video device has been set to common mode, only set new GOP device to + // the common mode + // + for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) { + Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info); + if (EFI_ERROR (Status)) { + return Status; + } + if ((Info->HorizontalResolution == Mode->HorizontalResolution) && (Info->VerticalResolution == Mode->VerticalResolution)) { + FreePool (Info); + break; + } + FreePool (Info); + } + Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex); + } + } else { + // + // Current mode number may need update now, so set it to an invalid mode number // - // If user defined mode is not valid for display device, set to the default mode 800x600. + CurrentGraphicsOutputMode->Mode = 0xffff; // - (Private->GraphicsOutputModeBuffer[0]).HorizontalResolution = 800; - (Private->GraphicsOutputModeBuffer[0]).VerticalResolution = 600; - Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, 0); + // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode. + // + Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, (UINT32) CurrentIndex); + if (EFI_ERROR(Status)) { + // + // If user defined mode is not valid for display device, set to the default mode 800x600. + // + (Private->GraphicsOutputModeBuffer[0]).HorizontalResolution = 800; + (Private->GraphicsOutputModeBuffer[0]).VerticalResolution = 600; + Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, 0); + } } return Status; @@ -2918,6 +2857,7 @@ ConsplitterSetConsoleOutMode ( UINTN MaxMode; EFI_STATUS Status; CONSOLE_OUT_MODE ModeInfo; + CONSOLE_OUT_MODE MaxModeInfo; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut; PreferMode = 0xFF; @@ -2925,8 +2865,10 @@ ConsplitterSetConsoleOutMode ( TextOut = &Private->TextOut; MaxMode = (UINTN) (TextOut->Mode->MaxMode); - ModeInfo.Column = PcdGet32 (PcdConOutColumn); - ModeInfo.Row = PcdGet32 (PcdConOutRow); + MaxModeInfo.Column = 0; + MaxModeInfo.Row = 0; + ModeInfo.Column = PcdGet32 (PcdConOutColumn); + ModeInfo.Row = PcdGet32 (PcdConOutRow); // // To find the prefer mode and basic mode from Text Out mode list @@ -2934,8 +2876,23 @@ ConsplitterSetConsoleOutMode ( for (Mode = 0; Mode < MaxMode; Mode++) { Status = TextOut->QueryMode (TextOut, Mode, &Col, &Row); if (!EFI_ERROR(Status)) { - if (Col == ModeInfo.Column && Row == ModeInfo.Row) { - PreferMode = Mode; + if ((ModeInfo.Column != 0) && (ModeInfo.Row != 0)) { + // + // Use user defined column and row + // + if (Col == ModeInfo.Column && Row == ModeInfo.Row) { + PreferMode = Mode; + } + } else { + // + // If user sets PcdConOutColumn or PcdConOutRow to 0, + // find and set the highest text mode. + // + if ((Col >= MaxModeInfo.Column) && (Row >= MaxModeInfo.Row)) { + MaxModeInfo.Column = Col; + MaxModeInfo.Row = Row; + PreferMode = Mode; + } } if (Col == 80 && Row == 25) { BaseMode = Mode; @@ -2953,7 +2910,7 @@ ConsplitterSetConsoleOutMode ( // Status = TextOut->SetMode (TextOut, BaseMode); ASSERT(!EFI_ERROR(Status)); - + PcdSet32 (PcdConOutColumn, 80); PcdSet32 (PcdConOutRow, 25); } @@ -2984,7 +2941,6 @@ ConSplitterTextOutAddDevice ( { EFI_STATUS Status; UINTN CurrentNumOfConsoles; - INT32 CurrentMode; INT32 MaxMode; UINT32 UgaHorizontalResolution; UINT32 UgaVerticalResolution; @@ -2993,6 +2949,7 @@ ConSplitterTextOutAddDevice ( TEXT_OUT_AND_GOP_DATA *TextAndGop; UINTN SizeOfInfo; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; + EFI_STATUS DeviceStatus; Status = EFI_SUCCESS; CurrentNumOfConsoles = Private->CurrentNumberOfConsoles; @@ -3024,18 +2981,6 @@ ConSplitterTextOutAddDevice ( TextAndGop->GraphicsOutput = GraphicsOutput; TextAndGop->UgaDraw = UgaDraw; - if ((GraphicsOutput == NULL) && (UgaDraw == NULL)) { - // - // If No GOP/UGA device then use the ConOut device - // - TextAndGop->TextOutEnabled = TRUE; - } else { - // - // If GOP/UGA device use ConOut device only used if screen is in Text mode - // - TextAndGop->TextOutEnabled = (BOOLEAN) (Private->ConsoleOutputMode == EfiConsoleControlScreenText); - } - if (CurrentNumOfConsoles == 0) { // // Add the first device's output mode to console splitter's mode list @@ -3054,26 +2999,20 @@ ConSplitterTextOutAddDevice ( // ConSplitterGetIntersectionBetweenConOutAndStrErr (); - CurrentMode = Private->TextOutMode.Mode; MaxMode = Private->TextOutMode.MaxMode; ASSERT (MaxMode >= 1); + DeviceStatus = EFI_DEVICE_ERROR; if (FeaturePcdGet (PcdConOutGopSupport)) { // // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes. // if ((GraphicsOutput != NULL) || (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport))) { - ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput, UgaDraw); + DeviceStatus = ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput, UgaDraw); } } if (FeaturePcdGet (PcdConOutUgaSupport)) { - UgaHorizontalResolution = 800; - UgaVerticalResolution = 600; - UgaColorDepth = 32; - UgaRefreshRate = 60; - - Status = EFI_DEVICE_ERROR; // // If UGA is produced by Consplitter // @@ -3097,46 +3036,31 @@ ConSplitterTextOutAddDevice ( &UgaColorDepth, &UgaRefreshRate ); - } - - // - // Set UGA Draw mode, - // if GetMode is failed, set to 800x600 mode - // - Status = ConSpliterUgaDrawSetMode ( - &Private->UgaDraw, - UgaHorizontalResolution, - UgaVerticalResolution, - UgaColorDepth, - UgaRefreshRate - ); - } - - if (Private->ConsoleOutputMode == EfiConsoleControlScreenGraphics && GraphicsOutput != NULL) { - // - // We just added a new GOP or UGA device in graphics mode - // - if (FeaturePcdGet (PcdConOutGopSupport)) { - // - // Sync display output on new device based on GOP settings. - // - DevNullGopSync (Private, TextAndGop->GraphicsOutput, TextAndGop->UgaDraw); - } else if (FeaturePcdGet (PcdConOutUgaSupport)) { + 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 + ); + } // - // Sync display output on new device based on UGA settings. + // If GetMode/SetMode is failed, set to 800x600 mode // - DevNullUgaSync (Private, TextAndGop->GraphicsOutput, TextAndGop->UgaDraw); + if(EFI_ERROR (Status)) { + Status = ConSplitterUgaDrawSetMode ( + &Private->UgaDraw, + 800, + 600, + 32, + 60 + ); + } } - } else if ((CurrentMode >= 0) && ((GraphicsOutput != NULL) || (UgaDraw != NULL)) && (CurrentMode < Private->TextOutMode.MaxMode)) { - // - // The new console supports the same mode of the current console so sync up - // - DevNullSyncStdOut (Private); - } else { - // - // If ConOut, then set the mode to Mode #0 which us 80 x 25 - // - Private->TextOut.SetMode (&Private->TextOut, 0); } // @@ -3179,14 +3103,14 @@ ConSplitterTextOutDeleteDevice ( TextOutList = Private->TextOutList; while (Index >= 0) { if (TextOutList->TextOut == TextOut) { - CopyMem (TextOutList, TextOutList + 1, sizeof (TEXT_OUT_AND_GOP_DATA) * Index); - CurrentNumOfConsoles--; if (TextOutList->UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) { Private->CurrentNumberOfUgaDraw--; } if (TextOutList->GraphicsOutput != NULL) { Private->CurrentNumberOfGraphicsOutput--; } + CopyMem (TextOutList, TextOutList + 1, sizeof (TEXT_OUT_AND_GOP_DATA) * Index); + CurrentNumOfConsoles--; break; } @@ -3202,13 +3126,13 @@ ConSplitterTextOutDeleteDevice ( if (CurrentNumOfConsoles == 0) { // - // If the number of consoles is zero clear the Dev NULL device + // If the number of consoles is zero, reset all parameters // Private->CurrentNumberOfConsoles = 0; Private->TextOutMode.MaxMode = 1; Private->TextOutQueryData[0].Columns = 80; Private->TextOutQueryData[0].Rows = 25; - DevNullTextOutSetMode (Private, 0); + TextOutSetMode (Private, 0); return EFI_SUCCESS; } @@ -3340,157 +3264,10 @@ ConSplitterTextInPrivateReadKeyStroke ( return EFI_NOT_READY; } -/** - Return TRUE if StdIn is locked. The ConIn device on the virtual handle is - the only device locked. - - @retval TRUE StdIn locked - @retval FALSE StdIn working normally - -**/ -BOOLEAN -ConSpliterConssoleControlStdInLocked ( - VOID - ) -{ - return mConIn.PasswordEnabled; -} - - -/** - Record and check key sequence on StdIn. - - This timer event will fire when StdIn is locked. It will record the key sequence - on StdIn and also check to see if it matches the password. Any error in the - password will cause the check to reset. As long as a mConIn.PasswordEnabled is - TRUE, the StdIn splitter will not report any input. - - @param Event The Event this notify function registered to. - @param Context Pointer to the context data registerd to the - Event. -**/ -VOID -EFIAPI -ConSpliterConsoleControlLockStdInEvent ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - EFI_INPUT_KEY Key; - CHAR16 BackSpaceString[2]; - CHAR16 SpaceString[2]; - - do { - Status = ConSplitterTextInPrivateReadKeyStroke (&mConIn, &Key); - if (!EFI_ERROR (Status)) { - // - // If key read successfully - // - if ((Key.UnicodeChar == CHAR_CARRIAGE_RETURN) && (Key.ScanCode == SCAN_NULL)) { - // - // If it's an ENTER, match password - // - mConIn.PwdAttempt[mConIn.PwdIndex] = CHAR_NULL; - if (StrCmp (mConIn.Password, mConIn.PwdAttempt) != 0) { - // - // Password not match - // - ConSplitterTextOutOutputString (&mConOut.TextOut, (CHAR16 *) L"\n\rPassword not correct\n\r"); - mConIn.PwdIndex = 0; - } else { - // - // Key matches password sequence - // - gBS->SetTimer (mConIn.LockEvent, TimerPeriodic, 0); - mConIn.PasswordEnabled = FALSE; - Status = EFI_NOT_READY; - } - } else if ((Key.UnicodeChar == CHAR_BACKSPACE) && (Key.ScanCode == SCAN_NULL)) { - // - // BackSpace met - // - if (mConIn.PwdIndex > 0) { - BackSpaceString[0] = CHAR_BACKSPACE; - BackSpaceString[1] = 0; - - SpaceString[0] = L' '; - SpaceString[1] = 0; - - ConSplitterTextOutOutputString (&mConOut.TextOut, BackSpaceString); - ConSplitterTextOutOutputString (&mConOut.TextOut, SpaceString); - ConSplitterTextOutOutputString (&mConOut.TextOut, BackSpaceString); - - mConIn.PwdIndex--; - } - } else if ((Key.ScanCode == SCAN_NULL) && (Key.UnicodeChar >= 32)) { - // - // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input, - // value 32 stands for a Blank Space key. - // - if (mConIn.PwdIndex < (MAX_STD_IN_PASSWORD - 1)) { - if (mConIn.PwdIndex == 0) { - ConSplitterTextOutOutputString (&mConOut.TextOut, (CHAR16 *) L"\n\r"); - } - - ConSplitterTextOutOutputString (&mConOut.TextOut, (CHAR16 *) L"*"); - mConIn.PwdAttempt[mConIn.PwdIndex] = Key.UnicodeChar; - mConIn.PwdIndex++; - } - } - } - } while (!EFI_ERROR (Status)); -} - - -/** - If Password is NULL or the Password is too big, then return an error. If the - Password is valid, then store the password, lock StdIn and arm the periodic timer. - - @param This Console Control protocol pointer. - @param Password The password input. - - @retval EFI_SUCCESS Lock the StdIn device. - @retval EFI_INVALID_PARAMETER Password is NULL. - @retval EFI_OUT_OF_RESOURCES Buffer allocation to store the password fails. - -**/ -EFI_STATUS -EFIAPI -ConSpliterConsoleControlLockStdIn ( - IN EFI_CONSOLE_CONTROL_PROTOCOL *This, - IN CHAR16 *Password - ) -{ - if (Password == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (StrLen (Password) >= MAX_STD_IN_PASSWORD) { - // - // Currently have a max password size - // - return EFI_OUT_OF_RESOURCES; - } - // - // Save the password, initialize state variables and arm event timer - // - StrCpy (mConIn.Password, Password); - mConIn.PasswordEnabled = TRUE; - mConIn.PwdIndex = 0; - // - // Lock Timer Periodic is 25ms. - // - gBS->SetTimer (mConIn.LockEvent, TimerPeriodic, 10000 * 25); - - 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. - If the ConIn is password locked make it look like no keystroke is availible @param This Protocol instance pointer. @param Key Driver may perform diagnostics on reset. @@ -3511,12 +3288,6 @@ ConSplitterTextInReadKeyStroke ( TEXT_IN_SPLITTER_PRIVATE_DATA *Private; Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This); - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return EFI_NOT_READY; - } Private->KeyEventSignalState = FALSE; @@ -3527,7 +3298,6 @@ ConSplitterTextInReadKeyStroke ( /** This event aggregates all the events of the ConIn devices in the spliter. - If the ConIn is password locked then return. If any events of physical ConIn devices are signaled, signal the ConIn spliter event. This will cause the calling code to call ConSplitterTextInReadKeyStroke (). @@ -3549,13 +3319,6 @@ ConSplitterTextInWaitForKey ( Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context; - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return ; - } - if (Private->KeyEventSignalState) { // // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke() @@ -3701,12 +3464,6 @@ ConSplitterTextInReadKeyStrokeEx ( } Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This); - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return EFI_NOT_READY; - } Private->KeyEventSignalState = FALSE; @@ -3862,7 +3619,7 @@ ConSplitterTextInRegisterKeyNotify ( NewNotify->Signature = TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE; NewNotify->KeyNotificationFn = KeyNotificationFunction; NewNotify->NotifyHandle = (EFI_HANDLE) NewNotify; - CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData)); + CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA)); // // Return the wrong status of registering key notify of @@ -3901,7 +3658,6 @@ ConSplitterTextInRegisterKeyNotify ( @retval EFI_SUCCESS The notification function was unregistered successfully. @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid. - @retval EFI_NOT_FOUND Can not find the matching entry in database. **/ EFI_STATUS @@ -3921,6 +3677,10 @@ ConSplitterTextInUnregisterKeyNotify ( return EFI_INVALID_PARAMETER; } + if (((TEXT_IN_EX_SPLITTER_NOTIFY *) NotificationHandle)->Signature != TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE) { + return EFI_INVALID_PARAMETER; + } + Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This); // @@ -3951,8 +3711,10 @@ ConSplitterTextInUnregisterKeyNotify ( } } - return EFI_NOT_FOUND; - + // + // NotificationHandle is not found in database + // + return EFI_INVALID_PARAMETER; } @@ -4082,7 +3844,6 @@ ConSplitterSimplePointerPrivateGetState ( /** Reads the next keystroke from the input device. The WaitForKey Event can be used to test for existance of a keystroke via WaitForEvent () call. - If the ConIn is password locked make it look like no keystroke is availible @param This A pointer to protocol instance. @param State A pointer to state information on the pointer device @@ -4103,12 +3864,6 @@ ConSplitterSimplePointerGetState ( TEXT_IN_SPLITTER_PRIVATE_DATA *Private; Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This); - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return EFI_NOT_READY; - } Private->InputEventSignalState = FALSE; @@ -4118,7 +3873,6 @@ ConSplitterSimplePointerGetState ( /** This event agregates all the events of the ConIn devices in the spliter. - If the ConIn is password locked then return. If any events of physical ConIn devices are signaled, signal the ConIn spliter event. This will cause the calling code to call ConSplitterTextInReadKeyStroke (). @@ -4139,12 +3893,6 @@ ConSplitterSimplePointerWaitForInput ( UINTN Index; Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context; - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return ; - } // // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke() @@ -4242,12 +3990,6 @@ ConSplitterAbsolutePointerGetState ( Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This); - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return EFI_NOT_READY; - } Private->AbsoluteInputEventSignalState = FALSE; @@ -4296,7 +4038,6 @@ ConSplitterAbsolutePointerGetState ( /** This event agregates all the events of the pointer devices in the splitter. - If the ConIn is password locked then return. If any events of physical pointer devices are signaled, signal the pointer splitter event. This will cause the calling code to call ConSplitterAbsolutePointerGetState (). @@ -4317,12 +4058,6 @@ ConSplitterAbsolutePointerWaitForInput ( UINTN Index; Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context; - if (Private->PasswordEnabled) { - // - // If StdIn Locked return not ready - // - return ; - } // // if AbsoluteInputEventSignalState is flagged before, @@ -4375,25 +4110,21 @@ ConSplitterTextOutReset ( // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - - Status = Private->TextOutList[Index].TextOut->Reset ( - Private->TextOutList[Index].TextOut, - ExtendedVerification - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->Reset ( + Private->TextOutList[Index].TextOut, + ExtendedVerification + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BLACK)); - Status = DevNullTextOutSetMode (Private, 0); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + // + // reset all mode parameters + // + TextOutSetMode (Private, 0); return ReturnStatus; } @@ -4428,53 +4159,74 @@ ConSplitterTextOutOutputString ( EFI_STATUS Status; TEXT_OUT_SPLITTER_PRIVATE_DATA *Private; UINTN Index; - UINTN BackSpaceCount; EFI_STATUS ReturnStatus; - CHAR16 *TargetString; + UINTN MaxColumn; + UINTN MaxRow; This->SetAttribute (This, This->Mode->Attribute); Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This); - BackSpaceCount = 0; - for (TargetString = WString; *TargetString != L'\0'; TargetString++) { - if (*TargetString == CHAR_BACKSPACE) { - BackSpaceCount++; - } - - } - - if (BackSpaceCount == 0) { - TargetString = WString; - } else { - TargetString = AllocatePool (sizeof (CHAR16) * (StrLen (WString) + BackSpaceCount + 1)); - ASSERT (TargetString != NULL); - - StrCpy (TargetString, WString); - } // // return the worst status met // - Status = DevNullTextOutOutputString (Private, TargetString); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } - for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->OutputString ( - Private->TextOutList[Index].TextOut, - TargetString - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->OutputString ( + Private->TextOutList[Index].TextOut, + WString + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } - if (BackSpaceCount > 0) { - FreePool (TargetString); + if (Private->CurrentNumberOfConsoles > 0) { + Private->TextOutMode.CursorColumn = Private->TextOutList[0].TextOut->Mode->CursorColumn; + Private->TextOutMode.CursorRow = Private->TextOutList[0].TextOut->Mode->CursorRow; + } else { + // + // When there is no real console devices in system, + // update cursor position for the virtual device in consplitter. + // + Private->TextOut.QueryMode ( + &Private->TextOut, + Private->TextOutMode.Mode, + &MaxColumn, + &MaxRow + ); + for (; *WString != CHAR_NULL; WString++) { + switch (*WString) { + case CHAR_BACKSPACE: + if (Private->TextOutMode.CursorColumn == 0 && Private->TextOutMode.CursorRow > 0) { + Private->TextOutMode.CursorRow--; + Private->TextOutMode.CursorColumn = (INT32) (MaxColumn - 1); + } else if (Private->TextOutMode.CursorColumn > 0) { + Private->TextOutMode.CursorColumn--; + } + break; + + case CHAR_LINEFEED: + if (Private->TextOutMode.CursorRow < (INT32) (MaxRow - 1)) { + Private->TextOutMode.CursorRow++; + } + break; + + case CHAR_CARRIAGE_RETURN: + Private->TextOutMode.CursorColumn = 0; + break; + + default: + if (Private->TextOutMode.CursorColumn < (INT32) (MaxColumn - 1)) { + Private->TextOutMode.CursorColumn++; + } else { + Private->TextOutMode.CursorColumn = 0; + if (Private->TextOutMode.CursorRow < (INT32) (MaxRow - 1)) { + Private->TextOutMode.CursorRow++; + } + } + break; + } + } } return ReturnStatus; @@ -4514,14 +4266,12 @@ ConSplitterTextOutTestString ( // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->TestString ( - Private->TextOutList[Index].TextOut, - WString - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->TestString ( + Private->TextOutList[Index].TextOut, + WString + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } // @@ -4648,32 +4398,19 @@ ConSplitterTextOutSetMode ( // TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber; for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->SetMode ( - Private->TextOutList[Index].TextOut, - TextOutModeMap[Index] - ); - // - // If this console device is based on a GOP or UGA device, then sync up the bitmap from - // the GOP/UGA splitter and reclear the text portion of the display in the new mode. - // - if ((Private->TextOutList[Index].GraphicsOutput != NULL) || (Private->TextOutList[Index].UgaDraw != NULL)) { - Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut); - } - - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->SetMode ( + Private->TextOutList[Index].TextOut, + TextOutModeMap[Index] + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } + // - // The DevNull Console will support any possible mode as it allocates memory + // Set mode parameter to specified mode number // - Status = DevNullTextOutSetMode (Private, ModeNumber); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + TextOutSetMode (Private, ModeNumber); return ReturnStatus; } @@ -4721,15 +4458,12 @@ ConSplitterTextOutSetAttribute ( // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->SetAttribute ( - Private->TextOutList[Index].TextOut, - Attribute - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->SetAttribute ( + Private->TextOutList[Index].TextOut, + Attribute + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } @@ -4768,19 +4502,20 @@ ConSplitterTextOutClearScreen ( // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } - Status = DevNullTextOutClearScreen (Private); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + // + // No need to do extra check here as whether (Column, Row) is valid has + // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should + // always be supported. + // + Private->TextOutMode.CursorColumn = 0; + Private->TextOutMode.CursorRow = 0; + Private->TextOutMode.CursorVisible = TRUE; return ReturnStatus; } @@ -4847,20 +4582,23 @@ ConSplitterTextOutSetCursorPosition ( // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->SetCursorPosition ( - Private->TextOutList[Index].TextOut, - Column, - Row - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->SetCursorPosition ( + Private->TextOutList[Index].TextOut, + Column, + Row + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } - DevNullTextOutSetCursorPosition (Private, Column, Row); + // + // No need to do extra check here as whether (Column, Row) is valid has + // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should + // always be supported. + // + Private->TextOutMode.CursorColumn = (INT32) Column; + Private->TextOutMode.CursorRow = (INT32) Row; return ReturnStatus; } @@ -4898,19 +4636,16 @@ ConSplitterTextOutEnableCursor ( // return the worst status met // for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) { - - if (Private->TextOutList[Index].TextOutEnabled) { - Status = Private->TextOutList[Index].TextOut->EnableCursor ( - Private->TextOutList[Index].TextOut, - Visible - ); - if (EFI_ERROR (Status)) { - ReturnStatus = Status; - } + Status = Private->TextOutList[Index].TextOut->EnableCursor ( + Private->TextOutList[Index].TextOut, + Visible + ); + if (EFI_ERROR (Status)) { + ReturnStatus = Status; } } - DevNullTextOutEnableCursor (Private, Visible); + Private->TextOutMode.CursorVisible = Visible; return ReturnStatus; }