Applied, thanks!
Mike Kelly, le mer. 18 nov. 2026 19:47:11 +0000, a ecrit:
> Add a bitmapped display capability, initially used by the immediate
> console, when multiboot offers an RGB frame buffer.
> ---
> device/cons.c | 13 +-
> i386/Makefrag.am | 1 +
> i386/configfrag.ac | 6 +-
> i386/i386/multiboot2_hdr_asm.h | 2 +
> i386/i386at/cons_conf.c | 7 -
> i386/i386at/fb_disp.c | 386 +++++++++++++++++++++++++++++++++
> i386/i386at/fb_disp.h | 96 ++++++++
> i386/i386at/immc.c | 318 ++++++++++++++++++++++-----
> i386/i386at/immc.h | 14 +-
> i386/i386at/kd.c | 14 --
> i386/i386at/model_dep.c | 17 +-
> x86_64/Makefrag.am | 3 +
> 12 files changed, 784 insertions(+), 93 deletions(-)
> create mode 100644 i386/i386at/fb_disp.c
> create mode 100644 i386/i386at/fb_disp.h
>
> diff --git a/device/cons.c b/device/cons.c
> index e1bc1ae0..91284277 100644
> --- a/device/cons.c
> +++ b/device/cons.c
> @@ -167,13 +167,14 @@ cnputc(char c)
> (*cn_tab->cn_putc)(cn_tab->cn_dev, c);
> if (c == '\n')
> (*cn_tab->cn_putc)(cn_tab->cn_dev, '\r');
> - } else if (romputc) {
> - (*romputc)(c);
> - if (c == '\n')
> - (*romputc)('\r');
> - }
> + } else {
> + if (romputc) {
> + (*romputc)(c);
> + if (c == '\n')
> + (*romputc)('\r');
> + }
> +
> #if CONSBUFSIZE > 0
> - else {
> if (consbufused == FALSE) {
> consbp = consbuf;
> consbufused = TRUE;
> diff --git a/i386/Makefrag.am b/i386/Makefrag.am
> index ab46ca2e..b1151ab9 100644
> --- a/i386/Makefrag.am
> +++ b/i386/Makefrag.am
> @@ -55,6 +55,7 @@ libkernel_a_SOURCES += \
> i386/i386at/disk.h \
> i386/i386at/i8250.h \
> i386/i386at/immc.c \
> + i386/i386at/immc.h \
> i386/i386at/int_init.c \
> i386/i386at/int_init.h \
> i386/i386at/interrupt.S \
> diff --git a/i386/configfrag.ac b/i386/configfrag.ac
> index 4064680f..ce284127 100644
> --- a/i386/configfrag.ac
> +++ b/i386/configfrag.ac
> @@ -68,7 +68,11 @@ esac]
>
> # The immediate console, useful for debugging early system
> # initialization. Disabled by default.
> -AC_DEFINE([ENABLE_IMMEDIATE_CONSOLE], [0], [ENABLE_IMMEDIATE_CONSOLE])
> +AC_ARG_ENABLE([immc],
> + AS_HELP_STRING([--enable-immc], [enable immediate console (for
> debugging)]))
> +[if [ x"$enable_immc" = xyes ]; then]
> + AC_DEFINE([ENABLE_IMMEDIATE_CONSOLE], [1], [ENABLE_IMMEDIATE_CONSOLE])
> +[fi]
>
> AC_ARG_ENABLE([lpr],
> AS_HELP_STRING([--enable-lpr], [lpr device; on ix86-at enabled by
> default]))
> diff --git a/i386/i386/multiboot2_hdr_asm.h b/i386/i386/multiboot2_hdr_asm.h
> index ccb2a448..ca6c0cd2 100644
> --- a/i386/i386/multiboot2_hdr_asm.h
> +++ b/i386/i386/multiboot2_hdr_asm.h
> @@ -42,6 +42,7 @@ multiboot2_hdr:
> .short MULTIBOOT2_HEADER_TAG_MODULE_ALIGN
> .short 0
> .long 8
> +#if defined(__x86_64__) || !ENABLE_IMMEDIATE_CONSOLE
> /* Frame buffer specified with no preference for width, height
> and depth. */
> .short MULTIBOOT2_HEADER_TAG_FRAMEBUFFER
> @@ -51,6 +52,7 @@ multiboot2_hdr:
> .long 0 /* No preference. */
> .long 0 /* No preference. */
> .long 0 /* Padding */
> +#endif
> /* There must always be an 'end' (empty) tag */
> .short MULTIBOOT2_HEADER_TAG_END
> .short 0
> diff --git a/i386/i386at/cons_conf.c b/i386/i386at/cons_conf.c
> index 1d7dd387..cf42bb63 100644
> --- a/i386/i386at/cons_conf.c
> +++ b/i386/i386at/cons_conf.c
> @@ -39,10 +39,6 @@
> #endif
> #endif /* MACH_HYP */
>
> -#if ENABLE_IMMEDIATE_CONSOLE
> -#include "immc.h"
> -#endif /* ENABLE_IMMEDIATE_CONSOLE */
> -
> /*
> * The rest of the consdev fields are filled in by the respective
> * cnprobe routine.
> @@ -51,9 +47,6 @@ struct consdev constab[] = {
> #ifdef MACH_HYP
> {"hyp", hypcnprobe, hypcninit, hypcngetc, hypcnputc},
> #else /* MACH_HYP */
> -#if ENABLE_IMMEDIATE_CONSOLE
> - {"immc", immc_cnprobe, immc_cninit, immc_cngetc, immc_cnputc},
> -#endif /* ENABLE_IMMEDIATE_CONSOLE */
> {"kd", kdcnprobe, kdcninit, kdcngetc, kdcnputc},
> #if NCOM > 0
> {"com", comcnprobe, comcninit, comcngetc, comcnputc},
> diff --git a/i386/i386at/fb_disp.c b/i386/i386at/fb_disp.c
> new file mode 100644
> index 00000000..315bcce2
> --- /dev/null
> +++ b/i386/i386at/fb_disp.c
> @@ -0,0 +1,386 @@
> +/*
> + * Copyright (c) 2026 Free Software Foundation
> + *
> + * Permission to use, copy, modify and distribute this software and its
> + * documentation is hereby granted, provided that both the copyright
> + * notice and this permission notice appear in all copies of the
> + * software, derivative works or modified versions, and any portions
> + * thereof, and that both notices appear in supporting documentation.
> + *
> + * FSF ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
> + * CONDITION. FSF DISCLAIMS ANY LIABILITY OF ANY KIND FOR
> + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
> + */
> +
> +#include <i386at/fb_disp.h>
> +#include <kern/assert.h>
> +#include <string.h>
> +
> +/* This SeaBios font definition is taken from the Qemu source:
> + qemu-10.0.11+ds/roms/seabios-hppa/vgasrc/vgafonts.c
> +*/
> +static uint8_t vgafont14[] = {
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00,
> 0x00, 0x00,
> + 0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x00,
> 0x00, 0x00,
> + 0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, 0x06, 0x86, 0xc6, 0x7c, 0x18,
> 0x18, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x66, 0xc6, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0xcc, 0x76, 0x00,
> 0x00, 0x00,
> + 0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x7c, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0xc6, 0xc6, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, 0xc6, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x1e, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x06, 0x06, 0xc6, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x38, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xfe, 0xc6, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x0c, 0x78, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, 0xc0, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0xfc, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x62, 0x66, 0xfe, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0xf0, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0x66, 0x3a, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xe6, 0x66, 0x6c, 0x6c, 0x78, 0x6c, 0x6c, 0x66, 0xe6, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0xf0, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e,
> 0x00, 0x00,
> + 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0xe6, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0xc6, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x7e, 0x7e, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x10, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, 0xfe, 0x7c, 0x6c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x38, 0x38, 0x38, 0x6c, 0xc6, 0xc6, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xfe, 0xc6, 0x8c, 0x18, 0x30, 0x60, 0xc2, 0xc6, 0xfe, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00,
> 0x00, 0x00,
> + 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0xff, 0x00,
> + 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc6, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc6, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0xf0, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc,
> 0x78, 0x00,
> + 0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0xe6, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x66, 0x66,
> 0x3c, 0x00,
> + 0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0xc6, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60,
> 0xf0, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c,
> 0x1e, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0xf0, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x70, 0x1c, 0xc6, 0x7c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x38, 0x6c, 0xc6, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c,
> 0xf8, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x66, 0xfe, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00, 0x00,
> 0x00, 0x00,
> +};
> +
> +static void *fb_addr;
> +static uint32_t fb_pixels_w, fb_pixels_h;
> +static uint32_t fb_chars_w, fb_chars_h;
> +static uint8_t *fb_chars_buf;
> +static uint8_t fb_bpp; /* bytes per pixel (not bits) */
> +
> +static const uint32_t fb_font_h = 14;
> +static const uint32_t fb_font_w = 8;
> +static const char fb_font_cmin = ' ';
> +static const char fb_font_cmax =
> + (fb_font_cmin + (sizeof (vgafont14) / fb_font_h) - 1);
> +static uint8_t *fb_font_start = vgafont14;
> +
> +static const uint32_t fb_cursor_h = 2;
> +
> +#define fb_colbyte_white 0xaa
> +#define fb_colbyte_black 0x00
> +
> +boolean_t
> +fb_disp_init (void *addr, uint32_t width, uint32_t height, uint8_t bpp)
> +{
> + if (bpp != 24 && bpp != 32)
> + return FALSE;
> +
> + fb_pixels_w = width;
> + fb_pixels_h = height;
> + fb_bpp = (bpp / 8);
> +
> + fb_addr = addr;
> +
> + fb_chars_w = fb_disp_max_cols ();
> + fb_chars_h = fb_disp_max_rows ();
> +
> + return TRUE;
> +}
> +
> +inline
> +static fb_disp_pos_t
> +fb_pos2xc (fb_disp_pos_t pos)
> +{
> + return (pos % fb_chars_w);
> +}
> +
> +inline
> +static fb_disp_pos_t
> +fb_pos2yc (fb_disp_pos_t pos)
> +{
> + return (pos / fb_chars_w);
> +}
> +
> +inline
> +static short
> +fb_xc2xb (fb_disp_pos_t x)
> +{
> + return (x * fb_font_w);
> +}
> +
> +inline
> +static short
> +fb_yc2yb (fb_disp_pos_t y)
> +{
> + return (y * (fb_font_h + fb_cursor_h));
> +}
> +
> +inline
> +static uint8_t *
> +fb_xyb2addr (short x, short y)
> +{
> + return (fb_addr + (fb_bpp * (x + (y * fb_pixels_w))));
> +}
> +
> +uint32_t
> +fb_disp_max_cols (void)
> +{
> + return (fb_pixels_w / fb_font_w);
> +}
> +
> +uint32_t
> +fb_disp_max_rows (void)
> +{
> + return (fb_pixels_h / (fb_font_h + fb_cursor_h));
> +}
> +
> +boolean_t
> +fb_disp_set_dimensions (uint32_t cols, uint32_t rows, uint8_t *charsbuf)
> +{
> + if (cols <= fb_disp_max_cols ()
> + && rows <= fb_disp_max_rows ()
> + && charsbuf != NULL)
> + {
> + fb_chars_w = cols;
> + fb_chars_h = rows;
> + fb_chars_buf = charsbuf;
> +
> + memset (charsbuf, 0, fb_chars_w * fb_chars_h);
> +
> + return TRUE;
> + }
> +
> + return FALSE;
> +}
> +
> +static void
> +fb_paint_cursor (fb_disp_pos_t pos, uint8_t colour)
> +{
> + short i, j;
> +
> + uint8_t *addr = fb_xyb2addr (fb_xc2xb (fb_pos2xc (pos)),
> + fb_yc2yb (fb_pos2yc (pos)) + fb_font_h);
> +
> + for (i = 0; i < fb_cursor_h; i++)
> + {
> + for (j = 0; j < fb_font_w; j++)
> + {
> + addr[0] = colour;
> + addr[1] = colour;
> + addr[2] = colour;
> + addr += fb_bpp;
> + }
> + addr += (fb_bpp * (fb_pixels_w - fb_font_w));
> + }
> +}
> +
> +static void
> +fb_drawchar (fb_disp_pos_t x, fb_disp_pos_t y, char ch)
> +{
> + uint8_t *to, *from;
> + short i, j;
> +
> + if (ch < fb_font_cmin || ch > fb_font_cmax)
> + ch = '?';
> +
> + ch -= fb_font_cmin;
> +
> + to = fb_xyb2addr (fb_xc2xb (x), fb_yc2yb (y));
> +
> + from = fb_font_start + (ch * fb_font_h);
> +
> + for (i = 0; i < fb_font_h; ++i)
> + {
> + for (j = 0; j < fb_font_w; j++)
> + {
> + uint8_t colour = ((*from & (1 << (7 - j)))
> + ? fb_colbyte_white
> + : fb_colbyte_black);
> +
> + to[0] = colour;
> + to[1] = colour;
> + to[2] = colour;
> + to += fb_bpp;
> + }
> + to += (fb_bpp * (fb_pixels_w - fb_font_w));
> + from++;
> + }
> +}
> +
> +void
> +fb_disp_put (fb_disp_pos_t pos, char ch)
> +{
> + fb_disp_pos_t x = fb_pos2xc (pos);
> + fb_disp_pos_t y = fb_pos2yc (pos);
> +
> + assert (y < fb_chars_h);
> +
> + fb_chars_buf[x + (y * fb_chars_w)] = ch;
> + fb_drawchar (x, y, ch);
> +}
> +
> +void
> +fb_disp_mvup (fb_disp_pos_t from, fb_disp_pos_t to, int count)
> +{
> + assert (count > 0 &&
> + to >= 0 && from > 0 && to < from
> + && (from + count) <= (fb_chars_w * fb_chars_h));
> +
> + uint8_t *from_buf = &fb_chars_buf[from];
> + uint8_t *to_buf = &fb_chars_buf[to];
> +
> + while (count--)
> + {
> + fb_disp_pos_t x = fb_pos2xc (to);
> + fb_disp_pos_t y = fb_pos2yc (to);
> +
> + if (*to_buf)
> + fb_drawchar (x, y, (*from_buf ? *from_buf : ' '));
> + else if (*from_buf)
> + fb_drawchar (x, y, *from_buf);
> +
> + *to_buf = *from_buf;
> +
> + from_buf++;
> + to_buf++;
> + to++;
> + }
> +}
> +
> +void
> +fb_disp_mvdown (fb_disp_pos_t from, fb_disp_pos_t to, int count)
> +{
> + assert (from >= 0 && from < to
> + && to < (fb_chars_w * fb_chars_h)
> + && to >= count);
> +
> + uint8_t *from_buf = &fb_chars_buf[from];
> + uint8_t *to_buf = &fb_chars_buf[to];
> +
> + while (count--)
> + {
> + fb_disp_pos_t x = fb_pos2xc (to);
> + fb_disp_pos_t y = fb_pos2yc (to);
> +
> + if (*to_buf)
> + fb_drawchar (x, y, (*from_buf ? *from_buf : ' '));
> + else if (*from_buf)
> + fb_drawchar (x, y, *from_buf);
> +
> + *to_buf = *from_buf;
> +
> + from_buf--;
> + to_buf--;
> + to--;
> + }
> +}
> +
> +void
> +fb_disp_clear (fb_disp_pos_t from, int count)
> +{
> + assert (count > 0 && from >= 0
> + && (from + count) <= (fb_chars_w * fb_chars_h));
> +
> + uint8_t *char_buf = &fb_chars_buf[from];
> +
> + while (count--)
> + {
> + fb_disp_pos_t x = fb_pos2xc (from);
> + fb_disp_pos_t y = fb_pos2yc (from);
> +
> + if (*char_buf && *char_buf != ' ')
> + fb_drawchar (x, y, ' ');
> +
> + *char_buf = 0;
> +
> + char_buf++;
> + from++;
> + }
> +}
> +
> +void
> +fb_disp_show_cursor (fb_disp_pos_t pos)
> +{
> + fb_paint_cursor (pos, fb_colbyte_white);
> +}
> +
> +void
> +fb_disp_hide_cursor (fb_disp_pos_t pos)
> +{
> + fb_paint_cursor (pos, fb_colbyte_black);
> +}
> +
> +void
> +fb_disp_cls (void)
> +{
> + assert (fb_addr != NULL);
> +
> + memset (fb_addr, fb_colbyte_black, fb_pixels_w * fb_pixels_h * fb_bpp);
> +}
> diff --git a/i386/i386at/fb_disp.h b/i386/i386at/fb_disp.h
> new file mode 100644
> index 00000000..dd154eb6
> --- /dev/null
> +++ b/i386/i386at/fb_disp.h
> @@ -0,0 +1,96 @@
> +/*
> + * Copyright (c) 2026 Free Software Foundation
> + *
> + * Permission to use, copy, modify and distribute this software and its
> + * documentation is hereby granted, provided that both the copyright
> + * notice and this permission notice appear in all copies of the
> + * software, derivative works or modified versions, and any portions
> + * thereof, and that both notices appear in supporting documentation.
> + *
> + * FSF ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
> + * CONDITION. FSF DISCLAIMS ANY LIABILITY OF ANY KIND FOR
> + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
> + */
> +
> +#ifndef _FB_DISP_H_
> +#define _FB_DISP_H_
> +
> +#include <mach/boolean.h>
> +#include <stdint.h>
> +
> +/* This module provides a display for a visual console using an RGB
> + frame buffer of 24 or 32 bits per pixel. It only supports
> + characters even though the framebuffer is pixel scale. The font is
> + builtin and unconfigurable. The display only supports white
> + characters agains a black background and so there is no interface
> + to specify the colour properties. It is assumed that the bit size
> + for each of the RGB components is the same.
> +
> + Character position is the index into a linear array. Position 0 is
> + the top left corner of the display. In general, for a display of C
> + columns and R rows, the position of character (x, y) is (x + y*C)
> + and the buffer is of length C * R. This array, supplied as a memory
> + buffer by the user, stores the value of each character
> + displayed. Array elements can have the value 0 which indicates that
> + no character is needed at that position. It supports scrolling by
> + redrawing moved characters rather than requiring a read from the
> + video memory.
> +
> + The maximum number of rows and columns is determined by the frame
> + buffer size and the inbuilt font dimensions. It is possible to
> + restrict the display to a reduced number of rows or columns.
> +
> + It is mandatory to call fb_disp_init() followed by
> + fb_disp_set_dimensions() before writing to the frame buffer with
> + the remainder of the interface. Only a single display is supported
> + although it can be reinitialised with the same function sequence.
> +*/
> +
> +typedef short fb_disp_pos_t;
> +
> +/* Initialise the display with frame buffer's virtual address and
> + pixel dimensions. bpp must be 24 or 32. */
> +boolean_t
> +fb_disp_init (void *v_addr, uint32_t width, uint32_t height, uint8_t bpp);
> +
> +/* The maximum number of character columns and rows supported by the
> + frame buffer pixel dimensions. */
> +uint32_t
> +fb_disp_max_cols (void);
> +uint32_t
> +fb_disp_max_rows (void);
> +
> +/* Set the usable portion of the display. 'cols' must be less than
> + fb_disp_max_cols() and 'rows' less than fb_disp_max_rows().
> + 'charsbuf' is the memory buffer used to store the character linear
> + array and must be of a minimum size (cols * rows). */
> +boolean_t
> +fb_disp_set_dimensions (uint32_t cols, uint32_t rows, uint8_t *charsbuf);
> +
> +/* Move 'count' display characters up or down. Normally used for
> + scrolling but also permits creation of empty space within the
> + displayed content. */
> +void
> +fb_disp_mvup (fb_disp_pos_t from, fb_disp_pos_t to, int count);
> +void
> +fb_disp_mvdown (fb_disp_pos_t from, fb_disp_pos_t to, int count);
> +
> +/* Replace and draw the character at a given position. */
> +void
> +fb_disp_put (fb_disp_pos_t pos, char ch);
> +
> +/* Mark the display positions as having no character value and redraw
> + with empty space if necessary. */
> +void
> +fb_disp_clear (fb_disp_pos_t from, int count);
> +
> +/* Clears the entire frame buffer. */
> +void
> +fb_disp_cls (void);
> +
> +void
> +fb_disp_show_cursor (fb_disp_pos_t pos);
> +void
> +fb_disp_hide_cursor (fb_disp_pos_t pos);
> +
> +#endif /* _FB_DISP_H_ */
> diff --git a/i386/i386at/immc.c b/i386/i386at/immc.c
> index 00fc973d..c1dfe606 100644
> --- a/i386/i386at/immc.c
> +++ b/i386/i386at/immc.c
> @@ -25,9 +25,17 @@
>
> #include <device/cons.h>
> #include <mach/boolean.h>
> +#include <mach/machine/multiboot.h>
> +#include <mach/machine/multiboot2.h>
> #include <i386/vm_param.h>
> +#include <i386at/immc.h>
> +#include <vm/pmap.h>
> #include <string.h>
>
> +#ifdef __x86_64__
> +#include <i386at/fb_disp.h>
> +#endif
> +
> /* This is a special "feature" (read: kludge)
> intended for use only for kernel debugging.
> It enables an extremely simple console output mechanism
> @@ -36,67 +44,46 @@
> so it can be used to debug things that happen very early
> before any devices are initialized. */
>
> -boolean_t immediate_console_enable = TRUE;
> +static uint32_t immc_cols = 80;
> +#ifdef __x86_64__
> +static uint32_t immc_rows = 25;
> +#endif
>
> -/*
> - * XXX we assume that pcs *always* have a console
> - */
> -int
> -immc_cnprobe(struct consdev *cp)
> +static void
> +immc_ega_scroll (void)
> {
> - int maj, unit, pri;
> -
> - maj = 0;
> - unit = 0;
> - pri = CN_INTERNAL;
> -
> - cp->cn_dev = makedev(maj, unit);
> - cp->cn_pri = pri;
> - return 0;
> + memmove((void *) phystokv(0xb8000),
> + (void *) phystokv(0xb8000+80*2), 80*2*24);
> + memset((void *) phystokv((0xb8000+80*2*24)), 0, 80*2);
> }
>
> -int
> -immc_cninit(struct consdev *cp)
> +static void
> +immc_ega_putc (int col, char c)
> {
> - return 0;
> -}
> + volatile unsigned char *p;
>
> -int immc_cnmaygetc(void)
> -{
> - return -1;
> + p = (void *) phystokv(0xb8000 + 80*2*24 + col*2);
> + p[0] = c;
> + p[1] = 0x0f;
> }
>
> -int
> -immc_cngetc(dev_t dev, int wait)
> -{
> - if (wait) {
> - int c;
> - while ((c = immc_cnmaygetc()) < 0)
> - continue;
> - return c;
> - }
> - else
> - return immc_cnmaygetc();
> -}
> +void (*immc_disp_scroll) (void) = immc_ega_scroll;
> +void (*immc_disp_putc) (int col, char c) = immc_ega_putc;
>
> -int
> -immc_cnputc(dev_t dev, int c)
> +static void
> +immc_putc(char c)
> {
> static int ofs = -1;
>
> - if (!immediate_console_enable)
> - return -1;
> - if (ofs < 0 || ofs >= 80)
> + if (ofs < 0 || ofs >= immc_cols)
> {
> ofs = 0;
> - immc_cnputc(dev, '\n');
> + immc_putc('\n');
> }
>
> if (c == '\n')
> {
> - memmove((void *) phystokv(0xb8000),
> - (void *) phystokv(0xb8000+80*2), 80*2*24);
> - memset((void *) phystokv((0xb8000+80*2*24)), 0, 80*2);
> + immc_disp_scroll();
> ofs = 0;
> }
> else if (c == '\r')
> @@ -109,26 +96,249 @@ immc_cnputc(dev_t dev, int c)
> }
> else
> {
> - volatile unsigned char *p;
> -
> - if (ofs >= 80)
> + if (ofs >= immc_cols)
> {
> - immc_cnputc(dev, '\r');
> - immc_cnputc(dev, '\n');
> + immc_putc('\r');
> + immc_putc('\n');
> }
>
> - p = (void *) phystokv(0xb8000 + 80*2*24 + ofs*2);
> - p[0] = c;
> - p[1] = 0x0f;
> + immc_disp_putc (ofs, c);
> ofs++;
> }
> - return 0;
> }
>
> +/* The frame buffer immediate console is only supported on 64 bit. It
> + is assumed that any 32 bit kernel would be running on a traditional
> + BIOS with an EGA like display being available.
> + */
> +#ifdef __x86_64__
> +
> +/* Keep determination of the frame buffer mapping very simple by
> + choosing a page table L4 slot that is unused and map it there. */
> +#ifndef KERNEL_MAP_BASE
> +#error KERNEL_MAP_BASE undefined
> +#endif
> +
> +#if KERNEL_MAP_BASE >= (1U << L4SHIFT) && KERNEL_MAP_BASE < (2U << L4SHIFT)
> +#define IMMC_FB_L4_INDEX 0x1FFUL
> +#else
> +#define IMMC_FB_L4_INDEX 1UL
> +#endif
> +#define IMMC_FB_VADDR ((void *)(IMMC_FB_L4_INDEX << L4SHIFT))
> +
> +/* This definition of IMMC_FB_NUM_PAGETABLES is sufficient to map a
> + 32bpp frame buffer of size 1920x1080. */
> +#define IMMC_FB_NUM_PAGETABLES 4
> +#define IMMC_MAXCOLS 160
> +#define IMMC_MAXROWS 60
> +
> +static uint8_t immc_matrix[IMMC_MAXCOLS * IMMC_MAXROWS];
> +static uint8_t *immc_fb_vaddr;
> +
> +/* IMMC_SCROLL_DOWN can be defined to begin the output at the top of
> + the screen and scroll down. This is not particularly useful other
> + than to provide a means to test fb_disp_mvdown(). */
> +static void
> +immc_fb_scroll (void)
> +{
> +#ifndef IMMC_SCROLL_DOWN
> + fb_disp_mvup (immc_cols, 0, immc_cols * (immc_rows - 1));
> + fb_disp_clear ((immc_rows - 1) * immc_cols, immc_cols);
> +#else
> + fb_disp_mvdown((immc_cols * (immc_rows - 1)) - 1,
> + (immc_cols * immc_rows) - 1,
> + immc_cols * (immc_rows - 1));
> + fb_disp_clear(0, immc_cols);
> +#endif
> +}
> +
> +static void
> +immc_fb_putc (int col, char c)
> +{
> +#ifndef IMMC_SCROLL_DOWN
> + fb_disp_put(col + (immc_cols * (immc_rows - 1)), c);
> +#else
> + fb_disp_put(col, c);
> +#endif
> +}
> +
> +static pt_entry_t
> +immc_l3_table[NPTES] __aligned(PAGE_SIZE);
> +static pt_entry_t
> +immc_l2_table[NPTES] __aligned(PAGE_SIZE);
> +static pt_entry_t
> +immc_l1_tables[IMMC_FB_NUM_PAGETABLES][NPTES] __aligned(PAGE_SIZE);
> +
> +static void
> +immc_enable_fb(const uint64_t paddr,
> + const uint32_t width,
> + const uint32_t height,
> + const uint8_t bpp)
> +{
> + uint64_t fb_size = (width * height * (bpp / 8));
> +
> + const uint64_t paddr_end = round_page (paddr + fb_size);
> + uint64_t paddr_map = trunc_page (paddr);
> +
> + memset (immc_l3_table, 0, sizeof (immc_l3_table));
> + memset (immc_l2_table, 0, sizeof (immc_l2_table));
> +
> + static_assert (IMMC_FB_NUM_PAGETABLES < NPTES);
> +
> + /* Map as much of the frame buffer as possible given the limit of
> + IMMC_FB_NUM_PAGETABLES page tables. */
> + for (unsigned int i = 0;
> + i < IMMC_FB_NUM_PAGETABLES && paddr_map < paddr_end;
> + i++)
> + {
> + immc_l2_table[i] = (pa_to_pte (_kvtophys (&immc_l1_tables[i]))
> + | INTEL_PTE_VALID | INTEL_PTE_WRITE);
> +
> + for (unsigned int j = 0; j < NPTES; j++)
> + {
> + if (paddr_map < paddr_end)
> + {
> + immc_l1_tables[i][j] = (pa_to_pte (paddr_map)
> + | INTEL_PTE_NCACHE | INTEL_PTE_WTHRU
> + | INTEL_PTE_VALID | INTEL_PTE_WRITE);
> + paddr_map += PAGE_SIZE;
> + }
> + else
> + immc_l1_tables[i][j] = 0UL;
> + }
> + }
> +
> + immc_l3_table[0] = (pa_to_pte (_kvtophys (&immc_l2_table))
> + | INTEL_PTE_VALID | INTEL_PTE_WRITE);
> +
> + uint32_t mapped_height = ((paddr_map - paddr) / width / (bpp / 8));
> +
> + if (mapped_height > height)
> + mapped_height = height;
> +
> + pt_entry_t *l4_vaddr = (pt_entry_t *)phystokv (get_cr3 ());
> +
> + if (l4_vaddr != NULL && l4_vaddr[IMMC_FB_L4_INDEX] == 0)
> + {
> + l4_vaddr[IMMC_FB_L4_INDEX] =
> + (pa_to_pte (_kvtophys (&immc_l3_table))
> + | INTEL_PTE_VALID | INTEL_PTE_WRITE);
> +
> + if (fb_disp_init (IMMC_FB_VADDR, width, mapped_height, bpp))
> + {
> + immc_rows = fb_disp_max_rows();
> + immc_cols = fb_disp_max_cols();
> +
> + if (immc_rows > IMMC_MAXROWS)
> + immc_rows = IMMC_MAXROWS;
> +
> + if (immc_cols > IMMC_MAXCOLS)
> + immc_cols = IMMC_MAXCOLS;
> +
> + if (fb_disp_set_dimensions (immc_cols, immc_rows, immc_matrix))
> + immc_fb_vaddr = IMMC_FB_VADDR;
> + }
> +
> + if (immc_fb_vaddr == NULL)
> + {
> + l4_vaddr[IMMC_FB_L4_INDEX] = 0UL;
> + flush_tlb ();
> + }
> + }
> +}
> +#endif /* __x86_64__ */
> +
> void
> -immc_romputc(char c)
> +immc_enable(const void *mbi, const uint32_t magic)
> {
> - immc_cnputc (0, c);
> +#ifdef __x86_64__
> + if (magic == MULTIBOOT_LOADER_MAGIC)
> + {
> + const struct multiboot_raw_info *mb1 =
> + (const struct multiboot_raw_info *)mbi;
> +
> + if (mb1->flags & MULTIBOOT_FRAMEBUFFER
> + && mb1->fb_info.framebuffer_type == MULTIBOOT_FRAMEBUFFER_TYPE_RGB)
> + {
> + immc_enable_fb(mb1->fb_info.framebuffer_addr,
> + mb1->fb_info.framebuffer_width,
> + mb1->fb_info.framebuffer_height,
> + mb1->fb_info.framebuffer_bpp);
> + }
> + }
> + else if (magic == MULTIBOOT2_BOOTLOADER_MAGIC)
> + {
> + const struct multiboot2_raw_info *mb2 =
> + (const struct multiboot2_raw_info *)mbi;
> + const struct multiboot2_tag_framebuffer *fb_tag = NULL;
> + const uint32_t tags_len =
> + (mb2->total_size - offsetof(struct multiboot2_raw_info, content));
> + uint32_t offset = 0;
> +
> + while (offset < tags_len)
> + {
> + const struct multiboot2_tag *tag =
> + (const struct multiboot2_tag *)&mb2->content[offset];
> +
> + if (tag->type == MULTIBOOT2_TAG_TYPE_FRAMEBUFFER)
> + {
> + fb_tag = (const struct multiboot2_tag_framebuffer *)tag;
> +
> + if (fb_tag->common.framebuffer_type
> + == MULTIBOOT2_FRAMEBUFFER_TYPE_RGB)
> + {
> + immc_enable_fb(fb_tag->common.framebuffer_addr,
> + fb_tag->common.framebuffer_width,
> + fb_tag->common.framebuffer_height,
> + fb_tag->common.framebuffer_bpp);
> + break;
> + }
> + }
> +
> + offset += MULTIBOOT2_NEXT_TAG_OFFSET(tag->size);
> + }
> + }
> +
> + if (immc_fb_vaddr != NULL)
> + {
> + immc_disp_scroll = immc_fb_scroll;
> + immc_disp_putc = immc_fb_putc;
> +
> + fb_disp_cls();
> + }
> +#endif /* __x86_64__ */
> +
> + romputc = immc_putc;
> }
>
> +/* kernel_pmap is not locked in this module. The immediate console is
> + operational only during early boot when there is 1 active CPU. */
> +void
> +immc_pmap_configure (void)
> +{
> +#ifdef __x86_64__
> + if (immc_fb_vaddr != NULL &&
> + kernel_pmap->l4base[IMMC_FB_L4_INDEX] == 0UL)
> + {
> + kernel_pmap->l4base[IMMC_FB_L4_INDEX] =
> + (pa_to_pte (_kvtophys (&immc_l3_table))
> + | INTEL_PTE_VALID | INTEL_PTE_WRITE);
> + }
> +#endif /* __x86_64__ */
> +}
> +
> +void
> +immc_disable (void)
> +{
> +#ifdef __x86_64__
> + if (immc_fb_vaddr != NULL)
> + {
> + kernel_pmap->l4base[IMMC_FB_L4_INDEX] = 0UL;
> + flush_tlb();
> + immc_fb_vaddr = NULL;
> + }
> +#endif /* __x86_64__ */
> +
> + romputc = NULL;
> +}
> #endif /* ENABLE_IMMEDIATE_CONSOLE */
> diff --git a/i386/i386at/immc.h b/i386/i386at/immc.h
> index dc802c84..0fbc41bb 100644
> --- a/i386/i386at/immc.h
> +++ b/i386/i386at/immc.h
> @@ -20,12 +20,14 @@
> #ifndef _IMMC_H_
> #define _IMMC_H_
>
> -#include <sys/types.h>
> +#if ENABLE_IMMEDIATE_CONSOLE
>
> -int immc_cnprobe(struct consdev *cp);
> -int immc_cninit(struct consdev *cp);
> -int immc_cngetc(dev_t dev, int wait);
> -int immc_cnputc(dev_t dev, int c);
> -void immc_romputc(char c);
> +#include <stdint.h>
> +
> +void immc_enable (const void *mbi, const uint32_t magic);
> +void immc_disable (void);
> +void immc_pmap_configure (void);
> +
> +#endif /* ENABLE_IMMEDIATE_CONSOLE */
>
> #endif /* _IMMC_H_ */
> diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c
> index 90fc680e..a0c638a8 100644
> --- a/i386/i386at/kd.c
> +++ b/i386/i386at/kd.c
> @@ -1129,20 +1129,6 @@ kdinit(void)
> unmask_irq(KBD_IRQ);
> kd_initialized = TRUE;
>
> -#if ENABLE_IMMEDIATE_CONSOLE
> - /* Now that we're set up, we no longer need or want the
> - immediate console. */
> - {
> - extern boolean_t immediate_console_enable;
> - immediate_console_enable = FALSE;
> - }
> -
> - /* The immediate console printed stuff at the bottom of the
> - screen rather than at the cursor position, so that's where
> - we should start. */
> - kd_setpos(ONE_PAGE - ONE_LINE); printf("\n");
> -#endif /* ENABLE_IMMEDIATE_CONSOLE */
> -
> cnsetleds(kd_state = KS_NORMAL);
> /* clear the LEDs AFTER we
> enable the keyboard controller.
> diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
> index 84c8c966..94186f19 100644
> --- a/i386/i386at/model_dep.c
> +++ b/i386/i386at/model_dep.c
> @@ -74,6 +74,7 @@
> #include <i386at/elf.h>
> #include <i386at/idt.h>
> #include <i386at/int_init.h>
> +#include <i386at/immc.h>
> #include <i386at/kd.h>
> #include <i386at/rtc.h>
> #include <i386at/mbinfo.h>
> @@ -85,11 +86,10 @@
> #include <xen/store.h>
> #include <xen/evt.h>
> #include <xen/xen.h>
> -#endif /* MACH_XEN */
>
> -#if ENABLE_IMMEDIATE_CONSOLE
> -#include "immc.h"
> -#endif /* ENABLE_IMMEDIATE_CONSOLE */
> +/* The immediate console is not required or supported on XEN. */
> +#undef ENABLE_IMMEDIATE_CONSOLE
> +#endif /* MACH_XEN */
>
> /* Location of the kernel's symbol table.
> Both of these are 0 if none is available. */
> @@ -185,6 +185,9 @@ void machine_init(void)
> /*
> * Initialize the console.
> */
> +#if ENABLE_IMMEDIATE_CONSOLE
> + immc_disable();
> +#endif /* ENABLE_IMMEDIATE_CONSOLE */
> cninit();
>
> #ifdef LINUX_DEV
> @@ -735,6 +738,10 @@ i386at_init(const struct multiboot2_raw_info *mb2_info)
> */
> pmap_bootstrap();
>
> +#if ENABLE_IMMEDIATE_CONSOLE
> + immc_pmap_configure ();
> +#endif /* ENABLE_IMMEDIATE_CONSOLE */
> +
> /*
> * Load physical segments into the VM system.
> * The early allocation functions become unusable after
> @@ -802,7 +809,7 @@ void c_boot_entry(vm_offset_t bi, uint32_t magic)
> const struct multiboot2_raw_info *mb2_info = NULL;
>
> #if ENABLE_IMMEDIATE_CONSOLE
> - romputc = immc_romputc;
> + immc_enable((const void *)phystokv(bi), magic);
> #endif /* ENABLE_IMMEDIATE_CONSOLE */
>
> #ifndef MACH_XEN
> diff --git a/x86_64/Makefrag.am b/x86_64/Makefrag.am
> index c9d15ff1..c08a8fdf 100644
> --- a/x86_64/Makefrag.am
> +++ b/x86_64/Makefrag.am
> @@ -51,8 +51,11 @@ libkernel_a_SOURCES += \
> i386/i386at/cram.h \
> x86_64/cpuboot.S \
> i386/i386at/disk.h \
> + i386/i386at/fb_disp.c \
> + i386/i386at/fb_disp.h \
> i386/i386at/i8250.h \
> i386/i386at/immc.c \
> + i386/i386at/immc.h \
> i386/i386at/int_init.c \
> i386/i386at/int_init.h \
> x86_64/interrupt.S \
> --
> 2.47.3
>
>
--
Samuel
je n ai cité aucun message et sur irc on parle effectivement comme des
enfants de 5 ans na!
> 3. Quand tu cite un message, répond _après_ ce que tu cites !
-+- Yota in : Guide du Neuneu d'Usenet - A un Yota près c'était bon -+-