From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: zhichao.gao@intel.com) Received: from mga02.intel.com (mga02.intel.com []) by groups.io with SMTP; Sat, 04 May 2019 19:18:18 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 May 2019 19:18:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,431,1549958400"; d="scan'208";a="343690280" Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga006.fm.intel.com with ESMTP; 04 May 2019 19:18:16 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jian J Wang , Hao Wu , Ray Ni , Star Zeng , Liming Gao , Sean Brogan , Michael Turner , Bret Barkelew , Laszlo Ersek Subject: [PATCH V3 2/2] MdeModulePkg/GraphicsConsoleDxe: Initialize the output mode Date: Sun, 5 May 2019 10:17:37 +0800 Message-Id: <20190505021738.17060-3-zhichao.gao@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190505021738.17060-1-zhichao.gao@intel.com> References: <20190505021738.17060-1-zhichao.gao@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1412 Original logic: Connect the graphics device -> connect it as graphics consoles and initialize its parameters(Mode = -1, invalid) -> connect it as console spliter and add the device to the list(use SetMode to set mode to the user defined mode or the best mode the devices supported if the mode is invalid. *clear the screen at this phase*) Changed logic: Connect the graphics device -> connect it as graphics consoles and initialize its parameters(initialize the mode to the user defined mode or the best mode. *directly set the mode value without using SetMode, that would not clear the screen) -> connect it as console spliter and add the device to the list(use SetMode to set mode to the user defined mode or the best mode the devices supported if the mode is invalid. *now the mode is already set, so it would not clear the screen*). Also remove the section of SetMode for debug version. But there would be no clear screen operation while reconnect the graphics device. Instead, clear the screen when stop the graphics console device. Cc: Jian J Wang Cc: Hao Wu Cc: Ray Ni Cc: Star Zeng Cc: Liming Gao Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Cc: Laszlo Ersek Signed-off-by: Zhichao Gao --- .../GraphicsConsoleDxe/GraphicsConsole.c | 44 ++++++++++++++----- .../GraphicsConsoleDxe/GraphicsConsoleDxe.inf | 2 + 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c index 26ea19f300..42386de3f5 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 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -384,6 +384,12 @@ GraphicsConsoleControllerDriverStart ( EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode; UINTN SizeOfInfo; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; + UINTN PreferMode; + UINTN Index; + UINTN Column; + UINTN Row; + UINTN DefaultColumn; + UINTN DefaultRow; ModeNumber = 0; @@ -567,16 +573,32 @@ GraphicsConsoleControllerDriverStart ( // Private->SimpleTextOutputMode.MaxMode = (INT32) MaxMode; - DEBUG_CODE_BEGIN (); - 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; + // + // Initialize the Mode of graphics console devices + // + PreferMode = 0; + DefaultColumn = PcdGet32 (PcdConOutColumn); + DefaultRow = PcdGet32 (PcdConOutRow); + Column = 0; + Row = 0; + for (Index = 0; Index < MaxMode; Index++) { + if (DefaultColumn != 0 && DefaultRow != 0) { + if ((Private->ModeData[Index].Columns == Column) && + (Private->ModeData[Index].Rows == Row)) { + 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; + } } - DEBUG_CODE_END (); + } + Private->SimpleTextOutput.Mode->Mode = (INT32)PreferMode; + DEBUG ((DEBUG_INFO, "Graphics Console Started, Mode: %x\n\r", PreferMode)); // // Install protocol interfaces for the Graphics Console device. @@ -669,6 +691,8 @@ GraphicsConsoleControllerDriverStop ( return EFI_NOT_STARTED; } + SimpleTextOutput->ClearScreen (SimpleTextOutput); + Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (SimpleTextOutput); Status = gBS->UninstallProtocolInterface ( diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf index f7caa65aa9..bcfd306eee 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf @@ -65,6 +65,8 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## SOMETIMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ## SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow ## SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn ## SOMETIMES_CONSUMES [UserExtensions.TianoCore."ExtraFiles"] GraphicsConsoleDxeExtra.uni -- 2.21.0.windows.1