From nobody Tue Apr 16 20:13:01 2024 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 4VJwFn6w00z5H0kd; Tue, 16 Apr 2024 20:13:01 +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 4VJwFn5HpNz4tQ0; Tue, 16 Apr 2024 20:13:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713298381; 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=ornf5vcGgIQRT1NK22e5o10LqKzrbwfph0yCY23rC7I=; b=AFofWZJyn8Qu6VZ4LQdzeDFK19eZb5w03OH9hIjG/YFA/cRFxgSQuf0+xuCQ3OOW8xITwi G6w0F4UbnI1D79/ZNq7G60qxQ+5eXBeRqDKbVJ1yp5GI5aZYSVYS6kR+F3Svvb7Vi/DwEq V4mCvf7dHVFXtENqA7FISijiB13DHE4q14JNcJYYGFlaAlJPHSk113+aY7bUV1X5MVrW3c qzXR0sn23I1ufX2sKq3ixtrKsL5DSW0ddlhkoQeT6XBFXCOaV+pi9LdTUOhIbT1zJ3imJw zRc+y2YZu5z3IK7UmH69P0gL1WbrerOTVKBN0kgBvmhQmwwMeTqhWNd3P/5UXw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713298381; a=rsa-sha256; cv=none; b=SOJbZRaZlow+AsD92recmPPm2EswMv6hHUfAdjtCvtAZqo7E6pzKLzuryEgwRoK+w2bJLv 7LcIIZVeBWVpGW9hhhFzuo8TpP8TDJKPPMy8ZV83dg+eZN7SDfr9i6tYjOI9a1+mtL3B4/ t+bqfXH7dvgcMWyWK7Rm6II+7C7jndM6Go/jBLb+ojN+O/dI9YdlXz3sGLU/uim/TRKkSV kIZyhVVEH+4BVzN34IuhJOxQn4rC0LNUsC7pkezm+0ehKsBx96tNlx/kqjB16U0Ub63DvY L3VGs3OcXOLuXGo+4BHTnkNax+lT5CvslfcUCRJY+VdzVsPKn8IOJIcqgwlkeA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713298381; 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=ornf5vcGgIQRT1NK22e5o10LqKzrbwfph0yCY23rC7I=; b=rZ/oZlMkdy2xRrtqLvizCiB2ctzpbzAirrNtbF98VkDTr1pKwxuo6gafk2hD1hzHSVTI1S kzh9elsDSf/ri+WOYZhANPNJiYEwFRSDtJlYW2YVPUrDfzK4AAlMd49VOikHX9GAYXiQ9n lzuDljy4CHtu+wbM3koOnp+SDkUvLyMDUn3DZvzVFixOUR9/RkmbdeXpm4yOS9emKOlvj3 5kNrOyqPaUnpX09sGEwvKfbt4K8jzVPpP8J0eAnvUgbohhD28olnA6uqYjYJWRyDkRhZp3 GRyxgAWHKkdgot0dmrkqD+PUkPDrcXGWZ/wmA4VDYDzdK7Xql+BDKKP+QDRSAg== 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 4VJwFn3zwGzxWR; Tue, 16 Apr 2024 20:13:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43GKD1MZ038508; Tue, 16 Apr 2024 20:13:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43GKD1m8038505; Tue, 16 Apr 2024 20:13:01 GMT (envelope-from git) Date: Tue, 16 Apr 2024 20:13:01 GMT Message-Id: <202404162013.43GKD1m8038505@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 57ca2848c0aa - stable/14 - loader: Make MK_LOADER_BIOS_TEXTONLY work 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/stable/14 X-Git-Reftype: branch X-Git-Commit: 57ca2848c0aad6dbef66dbac5c0b0f0a6eb798c1 Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=57ca2848c0aad6dbef66dbac5c0b0f0a6eb798c1 commit 57ca2848c0aad6dbef66dbac5c0b0f0a6eb798c1 Author: Warner Losh AuthorDate: 2024-02-18 06:15:01 +0000 Commit: Warner Losh CommitDate: 2024-04-16 19:54:25 +0000 loader: Make MK_LOADER_BIOS_TEXTONLY work Select between text-only and graphical frame buffer consoles for the BIOS boot loader. Pull one or the other in with #ifdef in conf.c. Add gfx_bios.c for the few routines that are needed for the BIOS support of gfx. These are stubbed out for text-only mode. Move bi_load_vbe_data here since it's only used for the graphical frame buffer. Note: This setup also allows us to build multiple BIOS loaders if we have to, some with text-only and some graphical. We don't do this today. We may be forced to turn this on in the future if ZFS keeps growing. The size savings is 41k, which helps a lot with some of our users that want to enable more options in the BIOS boot loader than are normally safe to do, and they don't need graphics. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43917 (cherry picked from commit bbfc01c2d29c462a95346f7916a692de396438e6) --- stand/i386/libi386/bootinfo.c | 19 ------------ stand/i386/loader/Makefile | 16 +++++++++- stand/i386/loader/conf.c | 5 ++++ stand/i386/loader/gfx_bios.c | 68 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 20 deletions(-) diff --git a/stand/i386/libi386/bootinfo.c b/stand/i386/libi386/bootinfo.c index cc9a42164ed3..4f652632b755 100644 --- a/stand/i386/libi386/bootinfo.c +++ b/stand/i386/libi386/bootinfo.c @@ -36,25 +36,6 @@ #include "vbe.h" #include "btxv86.h" -void -bi_load_vbe_data(struct preloaded_file *kfp) -{ - if (!kfp->f_tg_kernel_support) { - /* - * Loaded kernel does not have vt/vbe backend, - * switch console to text mode. - */ - if (vbe_available()) - bios_set_text_mode(VGA_TEXT_MODE); - return; - } - - if (vbe_available()) { - file_addmetadata(kfp, MODINFOMD_VBE_FB, - sizeof(gfx_state.tg_fb), &gfx_state.tg_fb); - } -} - int bi_getboothowto(char *kargs) { diff --git a/stand/i386/loader/Makefile b/stand/i386/loader/Makefile index 525561b7c4d1..ab446d67225b 100644 --- a/stand/i386/loader/Makefile +++ b/stand/i386/loader/Makefile @@ -37,13 +37,27 @@ LOADERSIZE?= 560000 # Largest known safe size for loader.bin .PATH: ${BOOTSRC}/i386/loader # architecture-specific loader code -SRCS= main.c conf.c vers.c chain.c gfx_fb.c 8x16.c +SRCS+= chain.c +SRCS+= conf.c +SRCS+= gfx_bios.c +SRCS+= main.c +SRCS+= vers.c + +.if ${MK_LOADER_BIOS_TEXTONLY} == "no" +SRCS+= gfx_fb.c +SRCS+= 8x16.c CFLAGS.gfx_fb.c += -I${.CURDIR}/../libi386 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 CFLAGS.gfx_fb.c += -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib +CFLAGS.gfx_bios.c += -I$(SRCTOP)/sys/teken +CFLAGS.gfx_bios.c += -I${SRCTOP}/contrib/pnglite +.else +CFLAGS.gfx_bios.c += -DBIOS_TEXT_ONLY +CFLAGS.conf.c += -DBIOS_TEXT_ONLY +.endif # Include bcache code. HAVE_BCACHE= yes diff --git a/stand/i386/loader/conf.c b/stand/i386/loader/conf.c index 329bcd577fbe..b4e9f401ded7 100644 --- a/stand/i386/loader/conf.c +++ b/stand/i386/loader/conf.c @@ -128,13 +128,18 @@ struct file_format *file_formats[] = { * We don't prototype these in libi386.h because they require * data structures from bootstrap.h as well. */ +extern struct console textvidc; extern struct console vidconsole; extern struct console comconsole; extern struct console nullconsole; extern struct console spinconsole; struct console *consoles[] = { +#ifdef BIOS_TEXT_ONLY + &textvidc, +#else &vidconsole, +#endif &comconsole, &nullconsole, &spinconsole, diff --git a/stand/i386/loader/gfx_bios.c b/stand/i386/loader/gfx_bios.c new file mode 100644 index 000000000000..a0b08a7cbcde --- /dev/null +++ b/stand/i386/loader/gfx_bios.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Netflix, Inc. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +/* + * This file provides all the gfx glue, or stubs, so that we can build, if we + * want, two versions of the bios loader: one with graphics support and one + * without. This allows us to keep the calls in other places, like libraries + * that are tricky to compile twice. It also reduces the number of ifdefs we + * need to support the old text-only video console. This could also be two + * separate files, but it is short and having it all here helps to constrain + * dependency creap somewhat. + */ + +#include +#ifndef BIOS_TEXT_ONLY +#include "bootstrap.h" +#include "libi386/libi386.h" +#include "libi386/vbe.h" +#include +#endif + +#ifdef BIOS_TEXT_ONLY +void autoload_font(bool bios); + +void +autoload_font(bool bios) +{ +} + +vm_offset_t build_font_module(vm_offset_t addr); + +vm_offset_t +build_font_module(vm_offset_t addr) +{ + return addr; +} + +struct preloaded_file; +void bi_load_vbe_data(struct preloaded_file *kfp); + +void bi_load_vbe_data(struct preloaded_file *kfp) +{ +} + +#else + +void +bi_load_vbe_data(struct preloaded_file *kfp) +{ + if (!kfp->f_tg_kernel_support) { + /* + * Loaded kernel does not have vt/vbe backend, + * switch console to text mode. + */ + if (vbe_available()) + bios_set_text_mode(VGA_TEXT_MODE); + return; + } + + if (vbe_available()) { + file_addmetadata(kfp, MODINFOMD_VBE_FB, + sizeof(gfx_state.tg_fb), &gfx_state.tg_fb); + } +} +#endif