X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FConsole%2FGraphicsConsoleDxe%2FGraphicsConsole.c;h=26ea19f300aab95788a89efce198f53bcdf92fb6;hb=9d510e61fceee7b92955ef9a3c20343752d8ce3f;hp=7167033841054962c0f1b7146bb9c4629f333330;hpb=d0d0c1b37038d51c2de3a498e952e2047f98660b;p=mirror_edk2.git
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
index 7167033841..26ea19f300 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 - 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
-
-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 - 2018, 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,9 @@ GraphicsConsoleControllerDriverStart (
UINTN MaxMode;
UINT32 ModeNumber;
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode;
- UINTN SizeOfInfo;
+ UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
-
+
ModeNumber = 0;
//
@@ -442,9 +436,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,
@@ -453,8 +447,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;
@@ -480,10 +474,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;
@@ -497,6 +493,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 +542,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.
//
@@ -567,7 +575,7 @@ GraphicsConsoleControllerDriverStart (
Status = GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r");
if (EFI_ERROR (Status)) {
goto Error;
- }
+ }
DEBUG_CODE_END ();
//
@@ -794,42 +802,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;
}
@@ -929,7 +909,7 @@ GraphicsConsoleConOutOutputString (
}
Status = EFI_SUCCESS;
-
+
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
//
// Current mode
@@ -1319,7 +1299,7 @@ GraphicsConsoleConOutSetMode (
Status = EFI_UNSUPPORTED;
goto Done;
}
-
+
ModeData = &(Private->ModeData[ModeNumber]);
if (ModeData->Columns <= 0 && ModeData->Rows <= 0) {
@@ -1457,7 +1437,7 @@ GraphicsConsoleConOutSetMode (
This->Mode->CursorColumn = 0;
This->Mode->CursorRow = 0;
- FlushCursor (This);
+ FlushCursor (This);
Status = EFI_SUCCESS;
@@ -1492,14 +1472,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;
}
@@ -1548,7 +1521,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.
@@ -1897,11 +1870,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.
@@ -2045,7 +2018,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.