From nobody Sun Feb 18 06:30:35 2024 X-Original-To: dev-commits-src-main@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 4Tcwlb6K71z5BgHH; Sun, 18 Feb 2024 06:30:35 +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 4Tcwlb4S45z4jXj; Sun, 18 Feb 2024 06:30:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708237835; 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=Bswt9QWUnE497J8Z8QUR8D7OY5A4tZkKCikYKSV1mOs=; b=eFi7Ktfxho5ks/VyVSACSsSJqbxsF6Lmfo+N9nCxbfvfvravApDD6uwKgRh6KrARdtDovF WoWWM5axGSxmM/6kUOr8yEnrfa8sNprmjBpAvaGk5zlvrR6NdDSh8d1flgQmS+MktzDF23 xEPein15BwblIc9kEaXYYUezjdGXtxW63Ep1sQsMX+oRYeKLwCWrl0qT7P4mJPkGTxdg/e j+VvrTTvR6l/r2Cxax2BeCbdtU6v9IISOju6RdniYd/xpsKtG37tIg7FAmuTETxi8wcCH2 4Xkyv3xmdBp/CgoA8CMM79AT5KNOI5FejfbWblSAcG8swuZQpGNYNmPw3cmX0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708237835; 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=Bswt9QWUnE497J8Z8QUR8D7OY5A4tZkKCikYKSV1mOs=; b=hvb6IsnWL0dqUj/wC7g077o/0r5Gra+H+xczPaZ964qhI5/XBYjXHVr0gmUAtY1whuzSrn NLt1ixrPri5pDqsYaft51tJ5FBm1d4YRu95zwdPdzd4U0X3H6Ltnw928ESQAaf8ewlCmkx 7VLAIiMhrsp+ntiFP3TMaSchuqXp+NDFr90QnVeQdlaoWxNSr2apDWseNSUYr3buCDoSiO P2aXJ3LfhoYpQfF+GBSyX+Y+1Jsa+RtP6UjW+F2aSzmqv3UYZeQ9A18IJCdb8x1dZHcuIm Q9WqLZA6+v4KvrnO9GoqoKTm+ghSxZohtVcg2gyu//oIIUe6xhRwq4S6i5QuSg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708237835; a=rsa-sha256; cv=none; b=gbzW29HXNyi/58rp4HK1d7b/aibgtmFs/HlvA7gIAv87X/a3ecrGJUP3QGp+ESp88/H5Qv W3RnphM/2MNj9SURmOJXQzOWU+w1lRZ4cbEmNQKMXisy70cCAHSIsIg602vE0AQwWKk3s4 OyK+5Wk2DqpaD0cS0BDumHzWUG6JXDwcCEQKEQMs3egnYfjL4VApDI9BDQVwSNrU+RysMS a5v10dWKyTg74KK17AbbihovirAjMcal89xE9DYnKW79vr7ltGegrDh+jHXf1O/guTWlI2 SxRQO+5aZ5XlW0Ckq+yM/YXxWg1Jx4fy9x/BJEMbcDcfM3ADj3Q93Ryr/pGTsw== 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 4Tcwlb3XnNzg0w; Sun, 18 Feb 2024 06:30:35 +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 41I6UZMn023935; Sun, 18 Feb 2024 06:30:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41I6UZpR023932; Sun, 18 Feb 2024 06:30:35 GMT (envelope-from git) Date: Sun, 18 Feb 2024 06:30:35 GMT Message-Id: <202402180630.41I6UZpR023932@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: bbfc01c2d29c - main - loader: Make MK_LOADER_BIOS_TEXTONLY work List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: bbfc01c2d29c462a95346f7916a692de396438e6 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=bbfc01c2d29c462a95346f7916a692de396438e6 commit bbfc01c2d29c462a95346f7916a692de396438e6 Author: Warner Losh AuthorDate: 2024-02-18 06:15:01 +0000 Commit: Warner Losh CommitDate: 2024-02-18 06:29:07 +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 --- 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