From owner-svn-src-all@FreeBSD.ORG Sat Apr 4 04:27:55 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CE30DA8; Sat, 4 Apr 2015 04:27:55 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9F99E13F; Sat, 4 Apr 2015 04:27:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t344RtHl095523; Sat, 4 Apr 2015 04:27:55 GMT (envelope-from rpaulo@FreeBSD.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t344RtGZ095522; Sat, 4 Apr 2015 04:27:55 GMT (envelope-from rpaulo@FreeBSD.org) Message-Id: <201504040427.t344RtGZ095522@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: rpaulo set sender to rpaulo@FreeBSD.org using -f From: Rui Paulo Date: Sat, 4 Apr 2015 04:27:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281059 - head/sys/boot/efi/boot1 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Apr 2015 04:27:55 -0000 Author: rpaulo Date: Sat Apr 4 04:27:54 2015 New Revision: 281059 URL: https://svnweb.freebsd.org/changeset/base/281059 Log: boot1 EFI: reset the screen and select the best mode. It's necessary to reset the screen to make sure any vendor pixels are gone when we start boot1. In the Lenovo X1 (3rd gen), this is the only way to clear the screen. Previously, the Lenovo logo would only disappear after the kernel started scrolling the display. After resetting the screen, EFI could put us in the worst LCD mode (oversized characters), so we now find the largest mode we can use and hope it's the most appropriate one (it's not trivial to tell what's the correct LCD resolution at this point). It's worth noting that the final stage loader has a 'mode' command that can be used to switch text modes. While there, enable the software cursor, just like in the legacy boot mode. MFC after: 1 week Modified: head/sys/boot/efi/boot1/boot1.c Modified: head/sys/boot/efi/boot1/boot1.c ============================================================================== --- head/sys/boot/efi/boot1/boot1.c Sat Apr 4 04:18:52 2015 (r281058) +++ head/sys/boot/efi/boot1/boot1.c Sat Apr 4 04:27:54 2015 (r281059) @@ -108,11 +108,12 @@ EFI_STATUS efi_main(EFI_HANDLE Ximage, E { EFI_HANDLE handles[128]; EFI_BLOCK_IO *blkio; - UINTN i, nparts = sizeof(handles); + UINTN i, nparts = sizeof(handles), cols, rows, max_dim, best_mode; EFI_STATUS status; EFI_DEVICE_PATH *devpath; EFI_BOOT_SERVICES *BS; EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL; + SIMPLE_TEXT_OUTPUT_INTERFACE *conout = NULL; char *path = _PATH_LOADER; systab = Xsystab; @@ -124,6 +125,26 @@ EFI_STATUS efi_main(EFI_HANDLE Ximage, E if (status == EFI_SUCCESS) (void)ConsoleControl->SetMode(ConsoleControl, EfiConsoleControlScreenText); + /* + * Reset the console and find the best text mode. + */ + conout = systab->ConOut; + conout->Reset(conout, TRUE); + max_dim = best_mode = 0; + for (i = 0; ; i++) { + status = conout->QueryMode(conout, i, + &cols, &rows); + if (EFI_ERROR(status)) + break; + if (cols * rows > max_dim) { + max_dim = cols * rows; + best_mode = i; + } + } + if (max_dim > 0) + conout->SetMode(conout, best_mode); + conout->EnableCursor(conout, TRUE); + conout->ClearScreen(conout); printf(" \n>> FreeBSD EFI boot block\n"); printf(" Loader path: %s\n", path);