X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FConsole%2FGraphicsConsoleDxe%2FGraphicsConsole.c;h=c042451a9b5234baf309d7626c5a41755355fb8e;hp=a13d1e3b627b4baf1558e32dbd1394c0f0270869;hb=0a35997643972d3b76a67547cbffeaa8a3d708c3;hpb=9fc94468970fa2762fc1a8cef748244127bd2d61 diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c index a13d1e3b62..c042451a9b 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c @@ -1,14 +1,8 @@ /** @file This is the main routine for initializing the Graphics Console support routines. -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -57,7 +51,7 @@ GRAPHICS_CONSOLE_MODE_DATA mGraphicsConsoleModeData[] = { EFI_HII_DATABASE_PROTOCOL *mHiiDatabase; EFI_HII_FONT_PROTOCOL *mHiiFont; EFI_HII_HANDLE mHiiHandle; -EFI_EVENT mHiiRegistration; +VOID *mHiiRegistration; EFI_GUID mFontPackageListGuid = {0xf5f219d3, 0x7006, 0x4648, {0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad}}; @@ -245,8 +239,8 @@ InitializeGraphicsConsoleTextMode ( UINTN ValidCount; UINTN ValidIndex; UINTN MaxColumns; - UINTN MaxRows; - + UINTN MaxRows; + if ((TextModeCount == NULL) || (TextModeData == NULL)) { return EFI_INVALID_PARAMETER; } @@ -287,7 +281,7 @@ InitializeGraphicsConsoleTextMode ( // // Mode 0 and mode 1 is for 80x25, 80x50 according to UEFI spec. // - ValidCount = 0; + ValidCount = 0; NewModeBuffer[ValidCount].Columns = 80; NewModeBuffer[ValidCount].Rows = 25; @@ -295,20 +289,20 @@ InitializeGraphicsConsoleTextMode ( NewModeBuffer[ValidCount].GopHeight = VerticalResolution; NewModeBuffer[ValidCount].GopModeNumber = GopModeNumber; NewModeBuffer[ValidCount].DeltaX = (HorizontalResolution - (NewModeBuffer[ValidCount].Columns * EFI_GLYPH_WIDTH)) >> 1; - NewModeBuffer[ValidCount].DeltaY = (VerticalResolution - (NewModeBuffer[ValidCount].Rows * EFI_GLYPH_HEIGHT)) >> 1; + NewModeBuffer[ValidCount].DeltaY = (VerticalResolution - (NewModeBuffer[ValidCount].Rows * EFI_GLYPH_HEIGHT)) >> 1; ValidCount++; if ((MaxColumns >= 80) && (MaxRows >= 50)) { NewModeBuffer[ValidCount].Columns = 80; NewModeBuffer[ValidCount].Rows = 50; NewModeBuffer[ValidCount].DeltaX = (HorizontalResolution - (80 * EFI_GLYPH_WIDTH)) >> 1; - NewModeBuffer[ValidCount].DeltaY = (VerticalResolution - (50 * EFI_GLYPH_HEIGHT)) >> 1; + NewModeBuffer[ValidCount].DeltaY = (VerticalResolution - (50 * EFI_GLYPH_HEIGHT)) >> 1; } NewModeBuffer[ValidCount].GopWidth = HorizontalResolution; NewModeBuffer[ValidCount].GopHeight = VerticalResolution; NewModeBuffer[ValidCount].GopModeNumber = GopModeNumber; ValidCount++; - + // // Start from mode 2 to put the valid mode other than 80x25 and 80x50 in the output mode buffer. // @@ -340,14 +334,14 @@ InitializeGraphicsConsoleTextMode ( ValidCount++; } } - + DEBUG_CODE ( for (Index = 0; Index < ValidCount; Index++) { - DEBUG ((EFI_D_INFO, "Graphics - Mode %d, Column = %d, Row = %d\n", - Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows)); + DEBUG ((EFI_D_INFO, "Graphics - Mode %d, Column = %d, Row = %d\n", + Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows)); } ); - + // // Return valid mode count and mode information buffer. // @@ -388,9 +382,15 @@ GraphicsConsoleControllerDriverStart ( UINTN MaxMode; UINT32 ModeNumber; EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode; - UINTN SizeOfInfo; + UINTN SizeOfInfo; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; - + INT32 PreferMode; + INT32 Index; + UINTN Column; + UINTN Row; + UINTN DefaultColumn; + UINTN DefaultRow; + ModeNumber = 0; // @@ -442,9 +442,9 @@ GraphicsConsoleControllerDriverStart ( if ((HorizontalResolution == 0x0) || (VerticalResolution == 0x0)) { // // Find the highest resolution which GOP supports. - // + // MaxMode = Private->GraphicsOutput->Mode->MaxMode; - + for (ModeIndex = 0; ModeIndex < MaxMode; ModeIndex++) { Status = Private->GraphicsOutput->QueryMode ( Private->GraphicsOutput, @@ -480,10 +480,12 @@ GraphicsConsoleControllerDriverStart ( // // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec // + HorizontalResolution = 800; + VerticalResolution = 600; Status = CheckModeSupported ( Private->GraphicsOutput, - 800, - 600, + HorizontalResolution, + VerticalResolution, &ModeNumber ); Mode = Private->GraphicsOutput->Mode; @@ -571,16 +573,32 @@ GraphicsConsoleControllerDriverStart ( // Private->SimpleTextOutputMode.MaxMode = (INT32) MaxMode; - DEBUG_CODE_BEGIN (); - Status = GraphicsConsoleConOutSetMode (&Private->SimpleTextOutput, 0); - if (EFI_ERROR (Status)) { - goto Error; + // + // Initialize the Mode of graphics console devices + // + PreferMode = -1; + DefaultColumn = PcdGet32 (PcdConOutColumn); + DefaultRow = PcdGet32 (PcdConOutRow); + Column = 0; + Row = 0; + for (Index = 0; Index < (INT32)MaxMode; Index++) { + if (DefaultColumn != 0 && DefaultRow != 0) { + if ((Private->ModeData[Index].Columns == DefaultColumn) && + (Private->ModeData[Index].Rows == DefaultRow)) { + PreferMode = Index; + break; + } + } else { + if ((Private->ModeData[Index].Columns > Column) && + (Private->ModeData[Index].Rows > Row)) { + Column = Private->ModeData[Index].Columns; + Row = Private->ModeData[Index].Rows; + PreferMode = Index; + } } - Status = GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r"); - if (EFI_ERROR (Status)) { - goto Error; - } - DEBUG_CODE_END (); + } + Private->SimpleTextOutput.Mode->Mode = (INT32)PreferMode; + DEBUG ((DEBUG_INFO, "Graphics Console Started, Mode: %d\n", PreferMode)); // // Install protocol interfaces for the Graphics Console device. @@ -806,42 +824,14 @@ EfiLocateHiiProtocol ( VOID ) { - EFI_HANDLE Handle; - UINTN Size; EFI_STATUS Status; - // - // There should only be one - so buffer size is this - // - Size = sizeof (EFI_HANDLE); - - Status = gBS->LocateHandle ( - ByProtocol, - &gEfiHiiDatabaseProtocolGuid, - NULL, - &Size, - (VOID **) &Handle - ); - + Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &mHiiDatabase); if (EFI_ERROR (Status)) { return Status; } - Status = gBS->HandleProtocol ( - Handle, - &gEfiHiiDatabaseProtocolGuid, - (VOID **) &mHiiDatabase - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - Status = gBS->HandleProtocol ( - Handle, - &gEfiHiiFontProtocolGuid, - (VOID **) &mHiiFont - ); + Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &mHiiFont); return Status; } @@ -941,7 +931,7 @@ GraphicsConsoleConOutOutputString ( } Status = EFI_SUCCESS; - + OldTpl = gBS->RaiseTPL (TPL_NOTIFY); // // Current mode @@ -1331,7 +1321,7 @@ GraphicsConsoleConOutSetMode ( Status = EFI_UNSUPPORTED; goto Done; } - + ModeData = &(Private->ModeData[ModeNumber]); if (ModeData->Columns <= 0 && ModeData->Rows <= 0) { @@ -1469,7 +1459,7 @@ GraphicsConsoleConOutSetMode ( This->Mode->CursorColumn = 0; This->Mode->CursorRow = 0; - FlushCursor (This); + FlushCursor (This); Status = EFI_SUCCESS; @@ -1504,14 +1494,7 @@ GraphicsConsoleConOutSetAttribute ( { EFI_TPL OldTpl; - if ((Attribute | 0xFF) != 0xFF) { - return EFI_UNSUPPORTED; - } - - if (This->Mode->Mode == -1) { - // - // If current mode is not valid, return error. - // + if ((Attribute | 0x7F) != 0x7F) { return EFI_UNSUPPORTED; } @@ -1560,7 +1543,7 @@ GraphicsConsoleConOutClearScreen ( EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background; EFI_TPL OldTpl; - + if (This->Mode->Mode == -1) { // // If current mode is not valid, return error. @@ -1909,11 +1892,11 @@ DrawUnicodeWeightAtCursorN ( /** Flush the cursor on the screen. - + If CursorVisible is FALSE, nothing to do and return directly. - If CursorVisible is TRUE, + If CursorVisible is TRUE, i) If the cursor shows on screen, it will be erased. - ii) If the cursor does not show on screen, it will be shown. + ii) If the cursor does not show on screen, it will be shown. @param This Protocol instance pointer. @@ -2057,7 +2040,9 @@ RegisterFontPackage ( NULL, (VOID **) &HiiDatabase ); - ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return; + } // // Add 4 bytes to the header for entire length for HiiAddPackages use only.