X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=MdeModulePkg%2FUniversal%2FConsole%2FGraphicsConsoleDxe%2FGraphicsConsole.c;h=037fb5adaa22fe1199593c57e00eac366b49e335;hb=6cb9566f264e2fa2dcde695317945114e1b011c7;hp=117569fa624aa6e333ef02c2b208e3ea6142d6f7;hpb=7c9fbd79d1fc8b817acb72c61cc19605d2f24907;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c index 117569fa62..037fb5adaa 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c @@ -1,7 +1,7 @@ /** @file This is the main routine for initializing the Graphics Console support routines. -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2014, 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 @@ -35,7 +35,7 @@ GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate = { }, { 0, - 0, + -1, EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_BLACK), 0, 0, @@ -57,7 +57,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}}; @@ -453,8 +453,8 @@ GraphicsConsoleControllerDriverStart ( &Info ); if (!EFI_ERROR (Status)) { - if ((Info->HorizontalResolution >= HorizontalResolution) && - (Info->VerticalResolution >= VerticalResolution)) { + if ((Info->HorizontalResolution > HorizontalResolution) || + ((Info->HorizontalResolution == HorizontalResolution) && (Info->VerticalResolution > VerticalResolution))) { HorizontalResolution = Info->HorizontalResolution; VerticalResolution = Info->VerticalResolution; ModeNumber = ModeIndex; @@ -497,6 +497,19 @@ GraphicsConsoleControllerDriverStart ( } } } + if (ModeNumber != Private->GraphicsOutput->Mode->Mode) { + // + // Current graphics mode is not set or is not set to the mode which we has found, + // set the new graphic mode. + // + Status = Private->GraphicsOutput->SetMode (Private->GraphicsOutput, ModeNumber); + if (EFI_ERROR (Status)) { + // + // The mode set operation failed + // + goto Error; + } + } } else if (FeaturePcdGet (PcdUgaConsumeSupport)) { // // At first try to set user-defined resolution @@ -533,12 +546,11 @@ GraphicsConsoleControllerDriverStart ( goto Error; } } - } else { - Status = EFI_UNSUPPORTED; - goto Error; } } + DEBUG ((EFI_D_INFO, "GraphicsConsole video resolution %d x %d\n", HorizontalResolution, VerticalResolution)); + // // Initialize the mode which GraphicsConsole supports. // @@ -559,16 +571,15 @@ GraphicsConsoleControllerDriverStart ( // Private->SimpleTextOutputMode.MaxMode = (INT32) MaxMode; - // - // Determine the number of text modes that this protocol can support - // - Status = GraphicsConsoleConOutSetMode (&Private->SimpleTextOutput, 0); - if (EFI_ERROR (Status)) { - goto Error; - } - DEBUG_CODE_BEGIN (); - GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r"); + Status = GraphicsConsoleConOutSetMode (&Private->SimpleTextOutput, 0); + if (EFI_ERROR (Status)) { + goto Error; + } + Status = GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r"); + if (EFI_ERROR (Status)) { + goto Error; + } DEBUG_CODE_END (); // @@ -795,42 +806,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 - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - Status = gBS->HandleProtocol ( - Handle, - &gEfiHiiDatabaseProtocolGuid, - (VOID **) &mHiiDatabase - ); - + Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &mHiiDatabase); if (EFI_ERROR (Status)) { return Status; } - Status = gBS->HandleProtocol ( - Handle, - &gEfiHiiFontProtocolGuid, - (VOID **) &mHiiFont - ); + Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &mHiiFont); return Status; } @@ -863,8 +846,13 @@ GraphicsConsoleConOutReset ( IN BOOLEAN ExtendedVerification ) { - This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK)); - return This->SetMode (This, 0); + EFI_STATUS Status; + Status = This->SetMode (This, 0); + if (EFI_ERROR (Status)) { + return Status; + } + Status = This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK)); + return Status; } @@ -917,8 +905,15 @@ GraphicsConsoleConOutOutputString ( INT32 OriginAttribute; EFI_TPL OldTpl; - Status = EFI_SUCCESS; + if (This->Mode->Mode == -1) { + // + // If current mode is not valid, return error. + // + return EFI_UNSUPPORTED; + } + Status = EFI_SUCCESS; + OldTpl = gBS->RaiseTPL (TPL_NOTIFY); // // Current mode @@ -1300,7 +1295,6 @@ GraphicsConsoleConOutSetMode ( Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This); GraphicsOutput = Private->GraphicsOutput; UgaDraw = Private->UgaDraw; - ModeData = &(Private->ModeData[ModeNumber]); // // Make sure the requested mode number is supported @@ -1309,38 +1303,26 @@ GraphicsConsoleConOutSetMode ( Status = EFI_UNSUPPORTED; goto Done; } + + ModeData = &(Private->ModeData[ModeNumber]); if (ModeData->Columns <= 0 && ModeData->Rows <= 0) { Status = EFI_UNSUPPORTED; goto Done; } - // - // Attempt to allocate a line buffer for the requested mode number - // - NewLineBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * ModeData->Columns * EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT); - if (NewLineBuffer == NULL) { - // - // The new line buffer could not be allocated, so return an error. - // No changes to the state of the current console have been made, so the current console is still valid - // - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } // // If the mode has been set at least one other time, then LineBuffer will not be NULL // if (Private->LineBuffer != NULL) { - // - // Clear the current text window on the current graphics console - // - This->ClearScreen (This); - // // If the new mode is the same as the old mode, then just return EFI_SUCCESS // if ((INT32) ModeNumber == This->Mode->Mode) { - FreePool (NewLineBuffer); + // + // Clear the current text window on the current graphics console + // + This->ClearScreen (This); Status = EFI_SUCCESS; goto Done; } @@ -1352,6 +1334,21 @@ GraphicsConsoleConOutSetMode ( FreePool (Private->LineBuffer); } + + // + // Attempt to allocate a line buffer for the requested mode number + // + NewLineBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * ModeData->Columns * EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT); + + if (NewLineBuffer == NULL) { + // + // The new line buffer could not be allocated, so return an error. + // No changes to the state of the current console have been made, so the current console is still valid + // + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } + // // Assign the current line buffer to the newly allocated line buffer // @@ -1479,7 +1476,14 @@ GraphicsConsoleConOutSetAttribute ( { EFI_TPL OldTpl; - if ((Attribute | 0xFF) != 0xFF) { + if ((Attribute | 0x7F) != 0x7F) { + return EFI_UNSUPPORTED; + } + + if (This->Mode->Mode == -1) { + // + // If current mode is not valid, return error. + // return EFI_UNSUPPORTED; } @@ -1528,6 +1532,13 @@ 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. + // + return EFI_UNSUPPORTED; + } OldTpl = gBS->RaiseTPL (TPL_NOTIFY); @@ -1610,6 +1621,13 @@ GraphicsConsoleConOutSetCursorPosition ( EFI_STATUS Status; EFI_TPL OldTpl; + if (This->Mode->Mode == -1) { + // + // If current mode is not valid, return error. + // + return EFI_UNSUPPORTED; + } + Status = EFI_SUCCESS; OldTpl = gBS->RaiseTPL (TPL_NOTIFY); @@ -1651,6 +1669,8 @@ Done: the cursor is set to be invisible. @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_UNSUPPORTED The output device's mode is not currently in a + defined text mode. **/ EFI_STATUS @@ -1662,6 +1682,13 @@ GraphicsConsoleConOutEnableCursor ( { EFI_TPL OldTpl; + if (This->Mode->Mode == -1) { + // + // If current mode is not valid, return error. + // + return EFI_UNSUPPORTED; + } + OldTpl = gBS->RaiseTPL (TPL_NOTIFY); FlushCursor (This); @@ -2002,7 +2029,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.