From nobody Sat Aug 27 04:18:46 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MF3Nk6YGyz4ZQXR; Sat, 27 Aug 2022 04:18:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MF3Nk5mJ0z3Nnc; Sat, 27 Aug 2022 04:18:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661573926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9WJMJbQvOXAE2X7xZFH68oCADKxkclirqlQafFtvn9Y=; b=TepASr8WP8UbkLtGmO33yXVwyQi7eLX1ual9r/n2IM2+ndnJM355He4Uakj9VyfOr8u0Qv D7a3AbekN+R2sL3TRkMOXQmDnd1U33vZrmipKenht8VFlQP8eNYOyhx3ye+1Y+InZnkfD8 5yC7hBnE34xp4S9DDyo0R3zYc+1a+3uruSq07kAe0K3DoyQZFYUYTWOSBc1KpPdyYQa6qu WObvWe2QppqhYjax1J4rdgMIy3lj4aex1UGuL01DEtqF8NcmBpXg3qUS/kOe1wN94zA5ED b3E2qYuGSl7evzwZl3Uge9bTmrW29OYZSwThosDH5L3bEW3R/BEwFcpMMp+y5Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MF3Nk4qtLzdTQ; Sat, 27 Aug 2022 04:18:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27R4IkJf078155; Sat, 27 Aug 2022 04:18:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27R4IkeL078154; Sat, 27 Aug 2022 04:18:46 GMT (envelope-from git) Date: Sat, 27 Aug 2022 04:18:46 GMT Message-Id: <202208270418.27R4IkeL078154@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: df065f699f1f - main - stand: More sensible defaults when ConOut is missing List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: df065f699f1ff819bb9607c44a6754275ab335ed Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661573926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9WJMJbQvOXAE2X7xZFH68oCADKxkclirqlQafFtvn9Y=; b=tMpR5Zf2zr75Jm0wRppczNZFiydNLjgGGvcAysX7eoPpt0+UqEZywEXJ4rJ8UPhVVxJ3+6 PY+l11Dq5ZbeMLOUj7iYvU7u8EuHqVKrMuVk9yyR5tDsDHt3g4tCob1whjeYjQOkfS5QOz FYPYaKilUe/BvPvuv7sWFnFhZVGjivG8AYGzDJp/RGUSNsyISrACLSUz+CNulMZ2FBidQe McETZoM4/O8xwgXGP/SP+Eifyup3Jfilber/HbNqZf0PUpbe9XBBmz4z4v1+zr+IPCEIh5 an5Uic5zqQ/wWsBc2H5s45Q9qH3udXDdaZJ1uMvBivwfHxxUABajNiFKx2+ekA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661573926; a=rsa-sha256; cv=none; b=avQvhfAHJMqVhYJNf+96T+2h2WnnhNmNW33lzPpyBojJIaTnf9W3HJMCTVU9TjyaEDJXFY cHfN+Ra/t8W/MzsZXSu0afVkgGQEI3CAbsWSwUSzg80HM6wmti5mPHp3ERiw0uy6Vimtso y7g3wRVgB9bv7yOP5dZ0+1GjFuLxT9polSZZghIQox6A/fcpTNu59CmtJwRpRtV8MrRVzE qvSaxhscMkorfPWuq97pG4QF3/Y5v4lujdv7kn42EGz6BEy3sLhiduczBB4PI2Nak0+/jU Rb2UE8zq1K9cYo3p+mc808tke8SW33YGhNrZKJmoCms2Mr35zK5UFUoh5q1DLg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=df065f699f1ff819bb9607c44a6754275ab335ed commit df065f699f1ff819bb9607c44a6754275ab335ed Author: Warner Losh AuthorDate: 2022-08-26 21:46:33 +0000 Commit: Warner Losh CommitDate: 2022-08-27 04:17:56 +0000 stand: More sensible defaults when ConOut is missing When ConOut is missing, we used to default to serial. Except we did it in the worst way possible by just setting the howto bits and not updating the console setting, which lead to weird behavior where we'd get some things on the video port, others on serial. Instead, set console to "efi,comconsole" for this case. Also set RB_MULTIPLE always (so we get dual consoles from the kernel) and or in RB_SERIAL when we can't find GOPs that suggest the precense of a video console. This will put output in the most places and have a sensible default for 'primary' console. Sponsored by: Netflix Reviewed by: emaste, manu Differential Revision: https://reviews.freebsd.org/D36299 --- stand/efi/loader/Makefile | 2 ++ stand/efi/loader/framebuffer.c | 15 +++++++++++++++ stand/efi/loader/framebuffer.h | 2 ++ stand/efi/loader/main.c | 20 ++++++++++++++++++-- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile index 1edb5674712e..e6083c2dd450 100644 --- a/stand/efi/loader/Makefile +++ b/stand/efi/loader/Makefile @@ -39,6 +39,8 @@ CFLAGS.bootinfo.c += -I$(SRCTOP)/sys/teken CFLAGS.bootinfo.c += -I${SRCTOP}/contrib/pnglite CFLAGS.framebuffer.c += -I$(SRCTOP)/sys/teken CFLAGS.framebuffer.c += -I${SRCTOP}/contrib/pnglite +CFLAGS.main.c += -I$(SRCTOP)/sys/teken +CFLAGS.main.c += -I${SRCTOP}/contrib/pnglite CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4 CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite diff --git a/stand/efi/loader/framebuffer.c b/stand/efi/loader/framebuffer.c index afae18603f9e..9dfe547d7557 100644 --- a/stand/efi/loader/framebuffer.c +++ b/stand/efi/loader/framebuffer.c @@ -535,6 +535,21 @@ efifb_get_edid(edid_res_list_t *res) return (rv); } +bool +efi_has_gop(void) +{ + EFI_STATUS status; + EFI_HANDLE *hlist; + UINTN hsize; + + hsize = 0; + hlist = NULL; + status = BS->LocateHandle(ByProtocol, &gop_guid, NULL, &hsize, hlist); + + return (status == EFI_BUFFER_TOO_SMALL); +} + + int efi_find_framebuffer(teken_gfx_t *gfx_state) { diff --git a/stand/efi/loader/framebuffer.h b/stand/efi/loader/framebuffer.h index 6c47a136f7be..a9377984de2b 100644 --- a/stand/efi/loader/framebuffer.h +++ b/stand/efi/loader/framebuffer.h @@ -27,11 +27,13 @@ * $FreeBSD$ */ +#include #include #ifndef _EFIFB_H_ #define _EFIFB_H_ +bool efi_has_gop(void); int efi_find_framebuffer(teken_gfx_t *gfx_state); #endif /* _EFIFB_H_ */ diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index 346c600da3df..a6fccf9e93c5 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include "efizfs.h" +#include "framebuffer.h" #include "loader_efi.h" @@ -760,8 +761,20 @@ parse_uefi_con_out(void) if (rv != EFI_SUCCESS) rv = efi_global_getenv("ConOutDev", buf, &sz); if (rv != EFI_SUCCESS) { - /* If we don't have any ConOut default to serial */ - how = RB_SERIAL; + /* + * If we don't have any ConOut default to both. If we have GOP + * make video primary, otherwise just make serial primary. In + * either case, try to use both the 'efi' console which will use + * the GOP, if present and serial. If there's an EFI BIOS that + * omits this, but has a serial port redirect, we'll + * unavioidably get doubled characters (but we'll be right in + * all the other more common cases). + */ + if (efi_has_gop()) + how = RB_MULTIPLE; + else + how = RB_MULTIPLE | RB_SERIAL; + setenv("console", "efi,comconsole", 1); goto out; } ep = buf + sz; @@ -949,6 +962,9 @@ main(int argc, CHAR16 *argv[]) setenv("console", "efi", 1); uhowto = parse_uefi_con_out(); #if defined(__riscv) + /* + * This workaround likely is papering over a real issue + */ if ((uhowto & RB_SERIAL) != 0) setenv("console", "comconsole", 1); #endif