X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FConsole%2FGraphicsConsoleDxe%2FGraphicsConsole.c;h=26ea19f300aab95788a89efce198f53bcdf92fb6;hb=9d510e61fceee7b92955ef9a3c20343752d8ce3f;hp=553a8146346076d50480e5e9bd351664c64242bd;hpb=b9b5e3078dfdcf0f9a8515f55a4eb44b6c55a9f5;p=mirror_edk2.git
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
index 553a814634..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 - 2011, 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
**/
@@ -35,26 +29,29 @@ GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate = {
},
{
0,
- 0,
+ -1,
EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_BLACK),
0,
0,
TRUE
},
- {
- { 80, 25, 0, 0, 0, 0, 0 }, // Mode 0
- { 80, 50, 0, 0, 0, 0, 0 }, // Mode 1
- { 100,31, 0, 0, 0, 0, 0 }, // Mode 2
- { 0, 0, 0, 0, 0, 0, 0 }, // Mode 3
- { 0, 0, 0, 0, 0, 0, 0 } // Mode 4
- },
+ (GRAPHICS_CONSOLE_MODE_DATA *) NULL,
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL
};
+GRAPHICS_CONSOLE_MODE_DATA mGraphicsConsoleModeData[] = {
+ {100, 31},
+ //
+ // New modes can be added here.
+ // The last entry is specific for full screen mode.
+ //
+ {0, 0}
+};
+
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}};
@@ -210,6 +207,148 @@ Error:
return Status;
}
+/**
+ Initialize all the text modes which the graphics console supports.
+
+ It returns information for available text modes that the graphics can support.
+
+ @param[in] HorizontalResolution The size of video screen in pixels in the X dimension.
+ @param[in] VerticalResolution The size of video screen in pixels in the Y dimension.
+ @param[in] GopModeNumber The graphics mode number which graphis console is based on.
+ @param[out] TextModeCount The total number of text modes that graphics console supports.
+ @param[out] TextModeData The buffer to the text modes column and row information.
+ Caller is responsible to free it when it's non-NULL.
+
+ @retval EFI_SUCCESS The supporting mode information is returned.
+ @retval EFI_INVALID_PARAMETER The parameters are invalid.
+
+**/
+EFI_STATUS
+InitializeGraphicsConsoleTextMode (
+ IN UINT32 HorizontalResolution,
+ IN UINT32 VerticalResolution,
+ IN UINT32 GopModeNumber,
+ OUT UINTN *TextModeCount,
+ OUT GRAPHICS_CONSOLE_MODE_DATA **TextModeData
+ )
+{
+ UINTN Index;
+ UINTN Count;
+ GRAPHICS_CONSOLE_MODE_DATA *ModeBuffer;
+ GRAPHICS_CONSOLE_MODE_DATA *NewModeBuffer;
+ UINTN ValidCount;
+ UINTN ValidIndex;
+ UINTN MaxColumns;
+ UINTN MaxRows;
+
+ if ((TextModeCount == NULL) || (TextModeData == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Count = sizeof (mGraphicsConsoleModeData) / sizeof (GRAPHICS_CONSOLE_MODE_DATA);
+
+ //
+ // Compute the maximum number of text Rows and Columns that this current graphics mode can support.
+ // To make graphics console work well, MaxColumns and MaxRows should not be zero.
+ //
+ MaxColumns = HorizontalResolution / EFI_GLYPH_WIDTH;
+ MaxRows = VerticalResolution / EFI_GLYPH_HEIGHT;
+
+ //
+ // According to UEFI spec, all output devices support at least 80x25 text mode.
+ //
+ ASSERT ((MaxColumns >= 80) && (MaxRows >= 25));
+
+ //
+ // Add full screen mode to the last entry.
+ //
+ mGraphicsConsoleModeData[Count - 1].Columns = MaxColumns;
+ mGraphicsConsoleModeData[Count - 1].Rows = MaxRows;
+
+ //
+ // Get defined mode buffer pointer.
+ //
+ ModeBuffer = mGraphicsConsoleModeData;
+
+ //
+ // Here we make sure that the final mode exposed does not include the duplicated modes,
+ // and does not include the invalid modes which exceed the max column and row.
+ // Reserve 2 modes for 80x25, 80x50 of graphics console.
+ //
+ NewModeBuffer = AllocateZeroPool (sizeof (GRAPHICS_CONSOLE_MODE_DATA) * (Count + 2));
+ ASSERT (NewModeBuffer != NULL);
+
+ //
+ // Mode 0 and mode 1 is for 80x25, 80x50 according to UEFI spec.
+ //
+ ValidCount = 0;
+
+ NewModeBuffer[ValidCount].Columns = 80;
+ NewModeBuffer[ValidCount].Rows = 25;
+ NewModeBuffer[ValidCount].GopWidth = HorizontalResolution;
+ 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;
+ 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].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.
+ //
+ for (Index = 0; Index < Count; Index++) {
+ if ((ModeBuffer[Index].Columns == 0) || (ModeBuffer[Index].Rows == 0) ||
+ (ModeBuffer[Index].Columns > MaxColumns) || (ModeBuffer[Index].Rows > MaxRows)) {
+ //
+ // Skip the pre-defined mode which is invalid or exceeds the max column and row.
+ //
+ continue;
+ }
+ for (ValidIndex = 0; ValidIndex < ValidCount; ValidIndex++) {
+ if ((ModeBuffer[Index].Columns == NewModeBuffer[ValidIndex].Columns) &&
+ (ModeBuffer[Index].Rows == NewModeBuffer[ValidIndex].Rows)) {
+ //
+ // Skip the duplicated mode.
+ //
+ break;
+ }
+ }
+ if (ValidIndex == ValidCount) {
+ NewModeBuffer[ValidCount].Columns = ModeBuffer[Index].Columns;
+ NewModeBuffer[ValidCount].Rows = ModeBuffer[Index].Rows;
+ NewModeBuffer[ValidCount].GopWidth = HorizontalResolution;
+ 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;
+ 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));
+ }
+ );
+
+ //
+ // Return valid mode count and mode information buffer.
+ //
+ *TextModeCount = ValidCount;
+ *TextModeData = NewModeBuffer;
+ return EFI_SUCCESS;
+}
/**
Start this driver on Controller by opening Graphics Output protocol or
@@ -241,15 +380,11 @@ GraphicsConsoleControllerDriverStart (
UINT32 RefreshRate;
UINT32 ModeIndex;
UINTN MaxMode;
- UINTN MaxColumns;
- UINTN MaxRows;
UINT32 ModeNumber;
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode;
- GRAPHICS_CONSOLE_MODE_DATA *ModeData;
- UINTN SizeOfInfo;
+ UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
- BOOLEAN TextModeFound;
-
+
ModeNumber = 0;
//
@@ -301,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,
@@ -312,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;
@@ -339,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;
@@ -356,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
@@ -392,87 +542,23 @@ GraphicsConsoleControllerDriverStart (
goto Error;
}
}
- } else {
- Status = EFI_UNSUPPORTED;
- goto Error;
}
}
- //
- // Include the existing pre-defined 80x25, 80x50 and 100x31
- // in mGraphicsConsoleDevTemplate.
- //
- MaxMode = 3;
-
- //
- // Compute the maximum number of text Rows and Columns that this current graphics mode can support
- //
- MaxColumns = HorizontalResolution / EFI_GLYPH_WIDTH;
- MaxRows = VerticalResolution / EFI_GLYPH_HEIGHT;
+ DEBUG ((EFI_D_INFO, "GraphicsConsole video resolution %d x %d\n", HorizontalResolution, VerticalResolution));
//
- // Add Mode #3 that uses the entire display for user-defined mode
- //
- Private->ModeData[MaxMode].Columns = MaxColumns;
- Private->ModeData[MaxMode].Rows = MaxRows;
- MaxMode++;
-
- //
- // Add Mode #4 that uses the PCD values
- //
- Private->ModeData[MaxMode].Columns = (UINTN) PcdGet32 (PcdConOutColumn);
- Private->ModeData[MaxMode].Rows = (UINTN) PcdGet32 (PcdConOutRow);
- if ((Private->ModeData[MaxMode].Columns != 0) && (Private->ModeData[MaxMode].Rows != 0)) {
- MaxMode++;
- }
-
+ // Initialize the mode which GraphicsConsole supports.
//
- // Here we make sure that mode 0 is valid
- //
- if (MaxColumns < Private->ModeData[0].Columns ||
- MaxRows < Private->ModeData[0].Rows) {
- //
- // 80x25 cannot be supported.
- //
- if ((Private->ModeData[4].Columns != 0) && (Private->ModeData[4].Rows != 0)) {
- //
- // Fallback to using the Mode 4 for mode 0 if PcdConOutColumn and PcdConOutRow
- // are not 0. If the PCDs are also too large, then mode 0
- // will be shrunk to fit as needed. If the PCDs are all 0,
- // then mode 0 will be the entire display.
- //
- Private->ModeData[0].Columns = MIN (Private->ModeData[4].Columns, MaxColumns);
- Private->ModeData[0].Rows = MIN (Private->ModeData[4].Rows, MaxRows);
- } else {
- Private->ModeData[0].Columns = MaxColumns;
- Private->ModeData[0].Rows = MaxRows;
- }
- }
-
- TextModeFound = FALSE;
- for (ModeIndex = 0; ModeIndex < GRAPHICS_MAX_MODE; ModeIndex++) {
- ModeData = &Private->ModeData[ModeIndex];
- ModeData->GopWidth = HorizontalResolution;
- ModeData->GopHeight = VerticalResolution;
- ModeData->GopModeNumber = ModeNumber;
- if ((ModeData->Columns != 0) && (ModeData->Rows != 0) &&
- (MaxColumns >= ModeData->Columns) && (MaxRows >= ModeData->Rows)) {
- ModeData->DeltaX = (HorizontalResolution - (ModeData->Columns * EFI_GLYPH_WIDTH)) >> 1;
- ModeData->DeltaY = (VerticalResolution - (ModeData->Rows * EFI_GLYPH_HEIGHT)) >> 1;
- TextModeFound = TRUE;
- } else {
- ModeData->Columns = 0;
- ModeData->Rows = 0;
- ModeData->DeltaX = 0;
- ModeData->DeltaY = 0;
- }
- }
+ Status = InitializeGraphicsConsoleTextMode (
+ HorizontalResolution,
+ VerticalResolution,
+ ModeNumber,
+ &MaxMode,
+ &Private->ModeData
+ );
- //
- // See if the resolution was too small to support any text modes
- //
- if (!TextModeFound) {
- Status = EFI_UNSUPPORTED;
+ if (EFI_ERROR (Status)) {
goto Error;
}
@@ -481,16 +567,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 ();
//
@@ -528,6 +613,10 @@ Error:
FreePool (Private->LineBuffer);
}
+ if (Private->ModeData != NULL) {
+ FreePool (Private->ModeData);
+ }
+
//
// Free private data
//
@@ -612,6 +701,10 @@ GraphicsConsoleControllerDriverStop (
FreePool (Private->LineBuffer);
}
+ if (Private->ModeData != NULL) {
+ FreePool (Private->ModeData);
+ }
+
//
// Free our instance data
//
@@ -672,6 +765,7 @@ CheckModeSupported (
//
// If video device has been set to this mode, we do not need to SetMode again
//
+ FreePool (Info);
break;
} else {
Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
@@ -708,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;
}
@@ -776,8 +842,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;
}
@@ -830,6 +901,13 @@ GraphicsConsoleConOutOutputString (
INT32 OriginAttribute;
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);
@@ -1162,7 +1240,7 @@ GraphicsConsoleConOutQueryMode (
*Columns = Private->ModeData[ModeNumber].Columns;
*Rows = Private->ModeData[ModeNumber].Rows;
- if (*Columns <= 0 && *Rows <= 0) {
+ if (*Columns <= 0 || *Rows <= 0) {
Status = EFI_UNSUPPORTED;
goto Done;
@@ -1213,7 +1291,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
@@ -1223,37 +1300,25 @@ GraphicsConsoleConOutSetMode (
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;
}
@@ -1265,6 +1330,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
//
@@ -1357,7 +1437,7 @@ GraphicsConsoleConOutSetMode (
This->Mode->CursorColumn = 0;
This->Mode->CursorRow = 0;
- FlushCursor (This);
+ FlushCursor (This);
Status = EFI_SUCCESS;
@@ -1392,7 +1472,7 @@ GraphicsConsoleConOutSetAttribute (
{
EFI_TPL OldTpl;
- if ((Attribute | 0xFF) != 0xFF) {
+ if ((Attribute | 0x7F) != 0x7F) {
return EFI_UNSUPPORTED;
}
@@ -1442,6 +1522,13 @@ GraphicsConsoleConOutClearScreen (
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);
Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
@@ -1523,6 +1610,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);
@@ -1564,6 +1658,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
@@ -1575,6 +1671,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);
@@ -1767,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.
@@ -1915,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.