From owner-svn-src-head@freebsd.org Sat Mar 24 01:53:44 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 352D7F606E2; Sat, 24 Mar 2018 01:53:44 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D52E270EAC; Sat, 24 Mar 2018 01:53:43 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CE6D025F; Sat, 24 Mar 2018 01:53:43 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2O1rhnQ088235; Sat, 24 Mar 2018 01:53:43 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2O1rhck088233; Sat, 24 Mar 2018 01:53:43 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201803240153.w2O1rhck088233@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 24 Mar 2018 01:53:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331474 - head/stand/efi/loader X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/efi/loader X-SVN-Commit-Revision: 331474 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Mar 2018 01:53:44 -0000 Author: kevans Date: Sat Mar 24 01:53:43 2018 New Revision: 331474 URL: https://svnweb.freebsd.org/changeset/base/331474 Log: efi loader: Choose a console mode instead if hw.vga.textmode is set Not all systems use efifb; pull hw.vga.textmode and choose a good console mode instead if it's set to something non-zero. This is basically a revival of the code that used to live in boot1, but instead rebased onto this different way of doing mode selection in loader.efi. Interestingly enough, the regression that was previously introduced where GOP would not reflect the console setting does not seem to exist when console mode selection is done here. I've not done any investigation as to why this is the case. Nevertheless, boot1.efi is still not the best place to do mode selection. Modified: head/stand/efi/loader/framebuffer.c Modified: head/stand/efi/loader/framebuffer.c ============================================================================== --- head/stand/efi/loader/framebuffer.c Sat Mar 24 01:15:38 2018 (r331473) +++ head/stand/efi/loader/framebuffer.c Sat Mar 24 01:53:43 2018 (r331474) @@ -588,6 +588,29 @@ gop_autoresize(EFI_GRAPHICS_OUTPUT *gop) } static int +text_autoresize() +{ + SIMPLE_TEXT_OUTPUT_INTERFACE *conout; + EFI_STATUS status; + UINTN i, max_dim, best_mode, cols, rows; + + conout = ST->ConOut; + max_dim = best_mode = 0; + for (i = 0; i < conout->Mode->MaxMode; i++) { + status = conout->QueryMode(conout, i, &cols, &rows); + if (EFI_ERROR(status)) + continue; + if (cols * rows > max_dim) { + max_dim = cols * rows; + best_mode = i; + } + } + if (max_dim > 0) + conout->SetMode(conout, best_mode); + return (CMD_OK); +} + +static int uga_autoresize(EFI_UGA_DRAW_PROTOCOL *gop) { @@ -601,8 +624,14 @@ command_autoresize(int argc, char *argv[]) { EFI_GRAPHICS_OUTPUT *gop; EFI_UGA_DRAW_PROTOCOL *uga; + char *textmode; EFI_STATUS status; u_int mode; + + textmode = getenv("hw.vga.textmode"); + /* If it's set and non-zero, we'll select a console mode instead */ + if (textmode != NULL && strcmp(textmode, "0") != 0) + return (text_autoresize()); gop = NULL; uga = NULL;