X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FConsole%2FGraphicsConsoleDxe%2FGraphicsConsole.c;h=037fb5adaa22fe1199593c57e00eac366b49e335;hp=bb279f985027e1cdc5c37b485b11ea604cce86da;hb=6cb9566f264e2fa2dcde695317945114e1b011c7;hpb=f44e8c16f84f1f662541c9dfe573cb67535942d5 diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c index bb279f9850..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 - 2010, 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,26 +35,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 +213,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 @@ -239,13 +384,13 @@ GraphicsConsoleControllerDriverStart ( UINT32 VerticalResolution; UINT32 ColorDepth; UINT32 RefreshRate; - UINTN ModeIndex; + UINT32 ModeIndex; UINTN MaxMode; - UINTN Columns; - UINTN Rows; UINT32 ModeNumber; EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode; - GRAPHICS_CONSOLE_MODE_DATA *ModeData; + UINTN SizeOfInfo; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; + ModeNumber = 0; // @@ -285,12 +430,8 @@ GraphicsConsoleControllerDriverStart ( goto Error; } - // - // If the current mode information can not be retrieved, then attempt to set the default mode - // of 800x600, 32 bit color, 60 Hz refresh. - // - HorizontalResolution = 800; - VerticalResolution = 600; + HorizontalResolution = PcdGet32 (PcdVideoHorizontalResolution); + VerticalResolution = PcdGet32 (PcdVideoVerticalResolution); if (Private->GraphicsOutput != NULL) { // @@ -298,39 +439,76 @@ GraphicsConsoleControllerDriverStart ( // for the user-defined mode; if there are multiple video devices, // graphic console driver will set all the video devices to the same mode. // - Status = CheckModeSupported ( - Private->GraphicsOutput, - CURRENT_HORIZONTAL_RESOLUTION, - CURRENT_VERTICAL_RESOLUTION, - &ModeNumber - ); - if (!EFI_ERROR(Status)) { - // - // Update default mode to current mode + if ((HorizontalResolution == 0x0) || (VerticalResolution == 0x0)) { // - HorizontalResolution = CURRENT_HORIZONTAL_RESOLUTION; - VerticalResolution = CURRENT_VERTICAL_RESOLUTION; + // Find the highest resolution which GOP supports. + // + MaxMode = Private->GraphicsOutput->Mode->MaxMode; + + for (ModeIndex = 0; ModeIndex < MaxMode; ModeIndex++) { + Status = Private->GraphicsOutput->QueryMode ( + Private->GraphicsOutput, + ModeIndex, + &SizeOfInfo, + &Info + ); + if (!EFI_ERROR (Status)) { + if ((Info->HorizontalResolution > HorizontalResolution) || + ((Info->HorizontalResolution == HorizontalResolution) && (Info->VerticalResolution > VerticalResolution))) { + HorizontalResolution = Info->HorizontalResolution; + VerticalResolution = Info->VerticalResolution; + ModeNumber = ModeIndex; + } + FreePool (Info); + } + } + if ((HorizontalResolution == 0x0) || (VerticalResolution == 0x0)) { + Status = EFI_UNSUPPORTED; + goto Error; + } } else { // - // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec + // Use user-defined resolution // Status = CheckModeSupported ( Private->GraphicsOutput, - 800, - 600, + HorizontalResolution, + VerticalResolution, &ModeNumber ); + if (EFI_ERROR (Status)) { + // + // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec + // + Status = CheckModeSupported ( + Private->GraphicsOutput, + 800, + 600, + &ModeNumber + ); + Mode = Private->GraphicsOutput->Mode; + if (EFI_ERROR (Status) && Mode->MaxMode != 0) { + // + // Set default mode failed or device don't support default mode, then get the current mode information + // + HorizontalResolution = Mode->Info->HorizontalResolution; + VerticalResolution = Mode->Info->VerticalResolution; + ModeNumber = Mode->Mode; + } + } } - - Mode = Private->GraphicsOutput->Mode; - - if (EFI_ERROR (Status) || (Mode->MaxMode != 0)) { + if (ModeNumber != Private->GraphicsOutput->Mode->Mode) { // - // Set default mode failed or device don't support default mode, then get the current mode information + // Current graphics mode is not set or is not set to the mode which we has found, + // set the new graphic mode. // - HorizontalResolution = Mode->Info->HorizontalResolution; - VerticalResolution = Mode->Info->VerticalResolution; - ModeNumber = Mode->Mode; + Status = Private->GraphicsOutput->SetMode (Private->GraphicsOutput, ModeNumber); + if (EFI_ERROR (Status)) { + // + // The mode set operation failed + // + goto Error; + } } } else if (FeaturePcdGet (PcdUgaConsumeSupport)) { // @@ -340,22 +518,19 @@ GraphicsConsoleControllerDriverStart ( RefreshRate = 60; Status = Private->UgaDraw->SetMode ( Private->UgaDraw, - CURRENT_HORIZONTAL_RESOLUTION, - CURRENT_VERTICAL_RESOLUTION, + HorizontalResolution, + VerticalResolution, ColorDepth, RefreshRate ); - if (!EFI_ERROR (Status)) { - HorizontalResolution = CURRENT_HORIZONTAL_RESOLUTION; - VerticalResolution = CURRENT_VERTICAL_RESOLUTION; - } else if (FeaturePcdGet (PcdUgaConsumeSupport)) { + if (EFI_ERROR (Status)) { // // Try to set 800*600 which is required by UEFI/EFI spec // Status = Private->UgaDraw->SetMode ( Private->UgaDraw, - HorizontalResolution, - VerticalResolution, + 800, + 600, ColorDepth, RefreshRate ); @@ -371,69 +546,23 @@ GraphicsConsoleControllerDriverStart ( goto Error; } } - } else { - Status = EFI_UNSUPPORTED; - goto Error; } } - // - // Add Mode #3 that uses the entire display for user-defined mode - // - Private->ModeData[3].Columns = HorizontalResolution / EFI_GLYPH_WIDTH; - Private->ModeData[3].Rows = VerticalResolution / EFI_GLYPH_HEIGHT; + DEBUG ((EFI_D_INFO, "GraphicsConsole video resolution %d x %d\n", HorizontalResolution, VerticalResolution)); // - // Add Mode #4 that uses the PCD values - // - Private->ModeData[4].Columns = (UINTN) PcdGet32 (PcdConOutColumn); - Private->ModeData[4].Rows = (UINTN) PcdGet32 (PcdConOutRow); - + // Initialize the mode which GraphicsConsole supports. // - // Compute the maximum number of text Rows and Columns that this current graphics mode can support - // - Columns = HorizontalResolution / EFI_GLYPH_WIDTH; - Rows = VerticalResolution / EFI_GLYPH_HEIGHT; - - // - // Here we make sure that mode 0 is valid - // - if (Columns < Private->ModeData[0].Columns || - Rows < Private->ModeData[0].Rows) { - // - // 80x25 cannot be supported. - // - // Fallback to using the PcdConOutColumn and PcdConOutRow - // for mode 0. If the PCDs are also to large, then mode 0 - // will be shrunk to fit as needed. - // - Private->ModeData[0].Columns = MIN (Private->ModeData[4].Columns, Columns); - Private->ModeData[0].Rows = MIN (Private->ModeData[4].Rows, Rows); - } - - MaxMode = 0; - for (ModeIndex = 0; ModeIndex < GRAPHICS_MAX_MODE; ModeIndex++) { - ModeData = &Private->ModeData[ModeIndex]; - ModeData->GopWidth = HorizontalResolution; - ModeData->GopHeight = VerticalResolution; - ModeData->GopModeNumber = ModeNumber; - if (Columns >= ModeData->Columns && - Rows >= ModeData->Rows) { - ModeData->DeltaX = (HorizontalResolution - (ModeData->Columns * EFI_GLYPH_WIDTH)) >> 1; - ModeData->DeltaY = (VerticalResolution - (ModeData->Rows * EFI_GLYPH_HEIGHT)) >> 1; - MaxMode = ModeIndex + 1; - } 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 (MaxMode == 0) { + if (EFI_ERROR (Status)) { goto Error; } @@ -442,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 (); // @@ -489,6 +617,10 @@ Error: FreePool (Private->LineBuffer); } + if (Private->ModeData != NULL) { + FreePool (Private->ModeData); + } + // // Free private data // @@ -573,6 +705,10 @@ GraphicsConsoleControllerDriverStop ( FreePool (Private->LineBuffer); } + if (Private->ModeData != NULL) { + FreePool (Private->ModeData); + } + // // Free our instance data // @@ -633,6 +769,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); @@ -669,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 - ); - + 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; } @@ -737,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; } @@ -791,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 @@ -1123,7 +1244,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; @@ -1174,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 @@ -1183,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; } @@ -1226,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 // @@ -1353,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; } @@ -1402,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); @@ -1484,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); @@ -1525,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 @@ -1536,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); @@ -1876,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.