Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Feb 2024 06:30:35 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: bbfc01c2d29c - main - loader: Make MK_LOADER_BIOS_TEXTONLY work
Message-ID:  <202402180630.41I6UZpR023932@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=bbfc01c2d29c462a95346f7916a692de396438e6

commit bbfc01c2d29c462a95346f7916a692de396438e6
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-02-18 06:15:01 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
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 <stand.h>
+#ifndef BIOS_TEXT_ONLY
+#include "bootstrap.h"
+#include "libi386/libi386.h"
+#include "libi386/vbe.h"
+#include <gfx_fb.h>
+#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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202402180630.41I6UZpR023932>