From aec072adb2af2bd1cc0677a25d4a099c8779c10d Mon Sep 17 00:00:00 2001 From: vanjeff Date: Wed, 9 Jan 2008 05:55:46 +0000 Subject: [PATCH] sync tracker to remove duplicate display mode in ConOut virtual handle GOP instance. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4533 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Console/ConSplitterDxe/ConSplitter.c | 128 ++++++++++++------ .../Console/ConSplitterDxe/ConSplitter.h | 68 +++++----- .../ConSplitterDxe/ConSplitterGraphics.c | 26 ++-- 3 files changed, 130 insertions(+), 92 deletions(-) diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c index babf3c6cd1..8e49c48097 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c @@ -170,7 +170,8 @@ STATIC TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = { NULL }, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL, - (TEXT_OUT_GOP_MODE *) NULL, + (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) NULL, + 0, 0, TRUE, { @@ -233,7 +234,8 @@ STATIC TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = { NULL }, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL, - (TEXT_OUT_GOP_MODE *) NULL, + (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) NULL, + 0, 0, TRUE, { @@ -663,6 +665,7 @@ ConSplitterTextOutConstructor ( ) { EFI_STATUS Status; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; // // Copy protocols template @@ -722,21 +725,24 @@ ConSplitterTextOutConstructor ( } // // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel + // DevNull will be updated to user-defined mode after driver has started. // - if ((ConOutPrivate->GraphicsOutputModeBuffer = AllocateZeroPool (sizeof (TEXT_OUT_GOP_MODE))) == NULL) { + if ((ConOutPrivate->GraphicsOutputModeBuffer = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION))) == NULL) { return EFI_OUT_OF_RESOURCES; } - ConOutPrivate->GraphicsOutputModeBuffer[0].HorizontalResolution = 800; - ConOutPrivate->GraphicsOutputModeBuffer[0].VerticalResolution = 600; + Info = &ConOutPrivate->GraphicsOutputModeBuffer[0]; + Info->Version = 0; + Info->HorizontalResolution = 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); // // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode() - // GraphicsOutputMode->Info->Version, GraphicsOutputMode->Info->PixelFormat - // GraphicsOutputMode->SizeOfInfo, GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize + // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize // - ConOutPrivate->GraphicsOutput.Mode->Info->Version = 0; - ConOutPrivate->GraphicsOutput.Mode->Info->PixelFormat = PixelBltOnly; - ConOutPrivate->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); ConOutPrivate->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) NULL; ConOutPrivate->GraphicsOutput.Mode->FrameBufferSize = 0; @@ -2464,14 +2470,15 @@ Returns: { EFI_STATUS Status; UINTN Index; - TEXT_OUT_GOP_MODE *Mode; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode; UINTN SizeOfInfo; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *CurrentGraphicsOutputMode; - TEXT_OUT_GOP_MODE *ModeBuffer; - TEXT_OUT_GOP_MODE *MatchedMode; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeBuffer; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *MatchedMode; UINTN NumberIndex; BOOLEAN Match; + BOOLEAN AlreadyExist; if ((GraphicsOutput == NULL) && (UgaDraw == NULL)) { return EFI_UNSUPPORTED; @@ -2479,6 +2486,17 @@ Returns: CurrentGraphicsOutputMode = Private->GraphicsOutput.Mode; + Index = 0; + + if (Private->CurrentNumberOfUgaDraw != 0) { + // + // If any UGA device has already been added, then there is no need to + // calculate intersection of display mode of different GOP/UGA device, + // since only one display mode will be exported (i.e. user-defined mode) + // + goto Done; + } + if (GraphicsOutput != NULL) { if (Private->CurrentNumberOfGraphicsOutput == 0) { // @@ -2494,7 +2512,7 @@ Returns: // // Allocate resource for the private mode buffer // - ModeBuffer = AllocatePool (sizeof (TEXT_OUT_GOP_MODE) * GraphicsOutput->Mode->MaxMode); + ModeBuffer = AllocatePool (GraphicsOutput->Mode->SizeOfInfo * GraphicsOutput->Mode->MaxMode); if (ModeBuffer == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -2510,8 +2528,7 @@ Returns: if (EFI_ERROR (Status)) { return Status; } - Mode->HorizontalResolution = Info->HorizontalResolution; - Mode->VerticalResolution = Info->VerticalResolution; + CopyMem (Mode, Info, SizeOfInfo); Mode++; FreePool (Info); } @@ -2519,7 +2536,7 @@ Returns: // // Check intersection of display mode // - ModeBuffer = AllocatePool (sizeof (TEXT_OUT_GOP_MODE) * CurrentGraphicsOutputMode->MaxMode); + ModeBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) * CurrentGraphicsOutputMode->MaxMode); if (ModeBuffer == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -2535,7 +2552,7 @@ Returns: return Status; } if ((Info->HorizontalResolution == Mode->HorizontalResolution) && - (Info->VerticalResolution == Mode->VerticalResolution)){ + (Info->VerticalResolution == Mode->VerticalResolution)) { Match = TRUE; FreePool (Info); break; @@ -2544,8 +2561,28 @@ Returns: } if (Match) { - CopyMem (MatchedMode, Mode, sizeof (TEXT_OUT_GOP_MODE)); - MatchedMode++; + AlreadyExist = FALSE; + + for (Info = ModeBuffer; Info < MatchedMode; Info++) { + if ((Info->HorizontalResolution == Mode->HorizontalResolution) && + (Info->VerticalResolution == Mode->VerticalResolution)) { + AlreadyExist = TRUE; + break; + } + } + + if (!AlreadyExist) { + CopyMem (MatchedMode, Mode, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); + + // + // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly + // + MatchedMode->Version = 0; + MatchedMode->PixelFormat = PixelBltOnly; + ZeroMem (&MatchedMode->PixelInformation, sizeof (EFI_PIXEL_BITMASK)); + + MatchedMode++; + } } Mode++; @@ -2560,7 +2597,7 @@ Returns: // // Physical frame buffer is no longer available when there are more than one physical GOP devices // - CurrentGraphicsOutputMode->MaxMode = (UINT32) (((UINTN) MatchedMode - (UINTN) ModeBuffer) / sizeof (TEXT_OUT_GOP_MODE)); + 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); @@ -2584,21 +2621,19 @@ Returns: Index = 0; } - // - // Current mode number may need update now, so set it to an invalide mode number - // - CurrentGraphicsOutputMode->Mode = 0xffff; - } else { + } + if (UgaDraw != NULL) { // // For UGA device, it's inconvenient to retrieve all the supported display modes. // To simplify the implementation, only add one resolution(800x600, 32bit color depth) as defined in UEFI spec // CurrentGraphicsOutputMode->MaxMode = 1; - CurrentGraphicsOutputMode->Info->Version = 0; - CurrentGraphicsOutputMode->Info->HorizontalResolution = 800; - CurrentGraphicsOutputMode->Info->VerticalResolution = 600; - CurrentGraphicsOutputMode->Info->PixelFormat = PixelBltOnly; - CurrentGraphicsOutputMode->Info->PixelsPerScanLine = 800; + Info = CurrentGraphicsOutputMode->Info; + Info->Version = 0; + Info->HorizontalResolution = 800; + Info->VerticalResolution = 600; + Info->PixelFormat = PixelBltOnly; + Info->PixelsPerScanLine = 800; CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) NULL; CurrentGraphicsOutputMode->FrameBufferSize = 0; @@ -2606,26 +2641,33 @@ Returns: // // Update the private mode buffer // - ModeBuffer = &Private->GraphicsOutputModeBuffer[0]; - ModeBuffer->HorizontalResolution = 800; - ModeBuffer->VerticalResolution = 600; + CopyMem (&Private->GraphicsOutputModeBuffer[0], Info, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); // - // Current mode is unknow now, set it to an invalid mode number 0xffff + // Only mode 0 is available to be set // - CurrentGraphicsOutputMode->Mode = 0xffff; Index = 0; } +Done: + + if (GraphicsOutput != NULL) { + Private->CurrentNumberOfGraphicsOutput++; + } + if (UgaDraw != NULL) { + Private->CurrentNumberOfUgaDraw++; + } + // // Force GraphicsOutput mode to be set, // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode // Private->HardwareNeedsStarting = TRUE; + // + // Current mode number may need update now, so set it to an invalid mode number + // Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, (UINT32) Index); - Private->CurrentNumberOfGraphicsOutput++; - return Status; } @@ -2737,7 +2779,7 @@ Returns: // // The new console supports the same mode of the current console so sync up // - DevNullSyncGopStdOut (Private); + DevNullSyncStdOut (Private); } else { // // If ConOut, then set the mode to Mode #0 which us 80 x 25 @@ -2781,6 +2823,14 @@ Returns: if (TextOutList->TextOut == TextOut) { CopyMem (TextOutList, TextOutList + 1, sizeof (TEXT_OUT_AND_GOP_DATA) * Index); CurrentNumOfConsoles--; + if (FeaturePcdGet (PcdConOutGopSupport)) { + if (TextOutList->UgaDraw != NULL) { + Private->CurrentNumberOfUgaDraw--; + } + if (TextOutList->GraphicsOutput != NULL) { + Private->CurrentNumberOfGraphicsOutput--; + } + } break; } diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h index 74d7b7dc76..587c6c115a 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h @@ -106,7 +106,7 @@ typedef struct { UINTN CurrentNumberOfExConsoles; EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL **TextInExList; UINTN TextInExListCount; - LIST_ENTRY NotifyList; + LIST_ENTRY NotifyList; EFI_SIMPLE_POINTER_PROTOCOL SimplePointer; @@ -120,7 +120,7 @@ typedef struct { UINTN CurrentNumberOfAbsolutePointers; EFI_ABSOLUTE_POINTER_PROTOCOL **AbsolutePointerList; UINTN AbsolutePointerListCount; - BOOLEAN AbsoluteInputEventSignalState; + BOOLEAN AbsoluteInputEventSignalState; BOOLEAN PasswordEnabled; CHAR16 Password[MAX_STD_IN_PASSWORD]; @@ -171,11 +171,6 @@ typedef struct { BOOLEAN TextOutEnabled; } TEXT_OUT_AND_GOP_DATA; -typedef struct { - UINT32 HorizontalResolution; - UINT32 VerticalResolution; -} TEXT_OUT_GOP_MODE; - typedef struct { UINT64 Signature; EFI_HANDLE VirtualHandle; @@ -191,8 +186,9 @@ typedef struct { EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput; EFI_GRAPHICS_OUTPUT_BLT_PIXEL *GraphicsOutputBlt; - TEXT_OUT_GOP_MODE *GraphicsOutputModeBuffer; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GraphicsOutputModeBuffer; UINTN CurrentNumberOfGraphicsOutput; + UINTN CurrentNumberOfUgaDraw; BOOLEAN HardwareNeedsStarting; EFI_CONSOLE_CONTROL_PROTOCOL ConsoleControl; @@ -446,14 +442,14 @@ ConSplitterAbsolutePointerReset ( Returns: EFI_SUCCESS - The device was reset. - EFI_DEVICE_ERROR - The device is not functioning correctly and could + EFI_DEVICE_ERROR - The device is not functioning correctly and could not be reset. - + --*/ ; EFI_STATUS -EFIAPI +EFIAPI ConSplitterAbsolutePointerGetState ( IN EFI_ABSOLUTE_POINTER_PROTOCOL *This, IN OUT EFI_ABSOLUTE_POINTER_STATE *State @@ -470,9 +466,9 @@ ConSplitterAbsolutePointerGetState ( Returns: EFI_SUCCESS - The state of the pointer device was returned in State.. EFI_NOT_READY - The state of the pointer device has not changed since the last call to - GetState(). + GetState(). EFI_DEVICE_ERROR - A device error occurred while attempting to retrieve the pointer - device's current state. + device's current state. --*/ ; @@ -964,7 +960,7 @@ ConSplitterTextInResetEx ( Returns: EFI_SUCCESS - The device was reset. - EFI_DEVICE_ERROR - The device is not functioning properly and could + EFI_DEVICE_ERROR - The device is not functioning properly and could not be reset. --*/ @@ -979,20 +975,20 @@ ConSplitterTextInReadKeyStrokeEx ( /*++ Routine Description: - Reads the next keystroke from the input device. The WaitForKey Event can + Reads the next keystroke from the input device. The WaitForKey Event can be used to test for existance of a keystroke via WaitForEvent () call. Arguments: This - Protocol instance pointer. - KeyData - A pointer to a buffer that is filled in with the keystroke + KeyData - A pointer to a buffer that is filled in with the keystroke state data for the key that was pressed. Returns: EFI_SUCCESS - The keystroke information was returned. EFI_NOT_READY - There was no keystroke data availiable. - EFI_DEVICE_ERROR - The keystroke information was not returned due to + EFI_DEVICE_ERROR - The keystroke information was not returned due to hardware errors. - EFI_INVALID_PARAMETER - KeyData is NULL. + EFI_INVALID_PARAMETER - KeyData is NULL. --*/ ; @@ -1010,17 +1006,17 @@ ConSplitterTextInSetState ( Arguments: This - Protocol instance pointer. - KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the + KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the state for the input device. - - Returns: + + Returns: EFI_SUCCESS - The device state was set successfully. - EFI_DEVICE_ERROR - The device is not functioning correctly and could + EFI_DEVICE_ERROR - The device is not functioning correctly and could not have the setting adjusted. EFI_UNSUPPORTED - The device does not have the ability to set its state. - EFI_INVALID_PARAMETER - KeyToggleState is NULL. + EFI_INVALID_PARAMETER - KeyToggleState is NULL. ---*/ +--*/ ; EFI_STATUS @@ -1038,18 +1034,18 @@ ConSplitterTextInRegisterKeyNotify ( Arguments: This - Protocol instance pointer. - KeyData - A pointer to a buffer that is filled in with the keystroke + KeyData - A pointer to a buffer that is filled in with the keystroke information data for the key that was pressed. - KeyNotificationFunction - Points to the function to be called when the key - sequence is typed specified by KeyData. - NotifyHandle - Points to the unique handle assigned to the registered notification. + KeyNotificationFunction - Points to the function to be called when the key + sequence is typed specified by KeyData. + NotifyHandle - Points to the unique handle assigned to the registered notification. Returns: EFI_SUCCESS - The notification function was registered successfully. EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures. - EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL. - ---*/ + EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL. + +--*/ ; EFI_STATUS @@ -1064,15 +1060,15 @@ ConSplitterTextInUnregisterKeyNotify ( Remove a registered notification function from a particular keystroke. Arguments: - This - Protocol instance pointer. + This - Protocol instance pointer. NotificationHandle - The handle of the notification function being unregistered. Returns: EFI_SUCCESS - The notification function was unregistered successfully. EFI_INVALID_PARAMETER - The NotificationHandle is invalid. - EFI_NOT_FOUND - Can not find the matching entry in database. - ---*/ + EFI_NOT_FOUND - Can not find the matching entry in database. + +--*/ ; VOID EFIAPI @@ -1369,7 +1365,7 @@ DevNullTextOutEnableCursor ( ; EFI_STATUS -DevNullSyncGopStdOut ( +DevNullSyncStdOut ( IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private ) ; diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c index d13d540070..3f720ac380 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2006 - 2007, Intel Corporation +Copyright (c) 2006 - 2008, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -15,7 +15,7 @@ Module Name: Abstract: - Support for ConsoleControl protocol. Support for UGA Draw spliter. + Support for ConsoleControl protocol. Support for Graphics output spliter. Support for DevNull Console Out. This console uses memory buffers to represnt the console. It allows a console to start very early and when a new console is added it is synced up with the current console @@ -39,13 +39,13 @@ ConSpliterConsoleControlGetMode ( Routine Description: Return the current video mode information. Also returns info about existence - of UGA Draw devices in system, and if the Std In device is locked. All the + of Graphics Output devices or UGA Draw devices in system, and if the Std In device is locked. All the arguments are optional and only returned if a non NULL pointer is passed in. Arguments: This - Protocol instance pointer. Mode - Are we in text of grahics mode. - UgaExists - TRUE if UGA Spliter has found a UGA device + GopExists - TRUE if GOP Spliter has found a GOP/UGA device StdInLocked - TRUE if StdIn device is keyboard locked Returns: @@ -155,7 +155,7 @@ ConSpliterConsoleControlSetMode ( } } if (Mode == EfiConsoleControlScreenText) { - DevNullSyncGopStdOut (Private); + DevNullSyncStdOut (Private); } return EFI_SUCCESS; } @@ -189,7 +189,6 @@ ConSpliterGraphicsOutputQueryMode ( --*/ { TEXT_OUT_SPLITTER_PRIVATE_DATA *Private; - TEXT_OUT_GOP_MODE *Mode; if (This == NULL || Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) { return EFI_INVALID_PARAMETER; @@ -212,11 +211,7 @@ ConSpliterGraphicsOutputQueryMode ( *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); - CopyMem (*Info, Private->GraphicsOutput.Mode->Info, *SizeOfInfo); - Mode = &Private->GraphicsOutputModeBuffer[ModeNumber]; - (*Info)->HorizontalResolution = Mode->HorizontalResolution; - (*Info)->VerticalResolution = Mode->VerticalResolution; - (*Info)->PixelsPerScanLine = Mode->HorizontalResolution; + CopyMem (*Info, &Private->GraphicsOutputModeBuffer[ModeNumber], *SizeOfInfo); return EFI_SUCCESS; } @@ -248,7 +243,7 @@ Routine Description: TEXT_OUT_SPLITTER_PRIVATE_DATA *Private; UINTN Index; EFI_STATUS ReturnStatus; - TEXT_OUT_GOP_MODE *Mode; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode; UINTN Size; EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; UINTN NumberIndex; @@ -335,10 +330,7 @@ Routine Description: This->Mode->Mode = ModeNumber; - Info = This->Mode->Info; - Info->HorizontalResolution = Mode->HorizontalResolution; - Info->VerticalResolution = Mode->VerticalResolution; - Info->PixelsPerScanLine = Mode->HorizontalResolution; + CopyMem (This->Mode->Info, &Private->GraphicsOutputModeBuffer[ModeNumber], This->Mode->SizeOfInfo); // // Information is not enough here, so the following items remain unchanged: @@ -1526,7 +1518,7 @@ DevNullTextOutEnableCursor ( } EFI_STATUS -DevNullSyncGopStdOut ( +DevNullSyncStdOut ( IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private ) /*++ -- 2.39.2