diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -1443,6 +1443,7 @@ return (gfx_fb_color_map(c)); } +#if defined(EFI) || defined(FRAMEBUFFER_MODE) /* set pixel in framebuffer using gfx coordinates */ void gfx_fb_setpixel(uint32_t x, uint32_t y) @@ -1962,6 +1963,7 @@ free(data); return (0); } +#endif /* * Reset font flags to FONT_AUTO. diff --git a/stand/common/gfx_fb_stub.c b/stand/common/gfx_fb_stub.c --- a/stand/common/gfx_fb_stub.c +++ b/stand/common/gfx_fb_stub.c @@ -38,6 +38,74 @@ font_list_t fonts = STAILQ_HEAD_INITIALIZER(fonts); teken_gfx_t gfx_state = { 0 }; +struct text_pixel *screen_buffer; + +uint32_t cmap[NCMAP]; + +/* + * Between console's palette and VGA's one: + * - blue and red are swapped (1 <-> 4) + * - yellow and cyan are swapped (3 <-> 6) + */ +const int cons_to_vga_colors[NCOLORS] = { + 0, 4, 2, 6, 1, 5, 3, 7, + 8, 12, 10, 14, 9, 13, 11, 15 +}; + +static const int vga_to_cons_colors[NCOLORS] = { + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15 +}; + +bool +is_same_pixel(struct text_pixel *px1, struct text_pixel *px2) +{ + if (px1->c != px2->c) + return (false); + + /* Is there image stored? */ + if ((px1->a.ta_format & TF_IMAGE) || + (px2->a.ta_format & TF_IMAGE)) + return (false); + + if (px1->a.ta_format != px2->a.ta_format) + return (false); + if (px1->a.ta_fgcolor != px2->a.ta_fgcolor) + return (false); + if (px1->a.ta_bgcolor != px2->a.ta_bgcolor) + return (false); + + return (true); +} + +int +generate_cons_palette(uint32_t *palette, int format, + uint32_t rmax, int roffset, uint32_t gmax, int goffset, + uint32_t bmax, int boffset) +{ + int i; + + switch (format) { + case COLOR_FORMAT_VGA: + for (i = 0; i < NCOLORS; i++) + palette[i] = cons_to_vga_colors[i]; + for (; i < NCMAP; i++) + palette[i] = i; + break; + default: + return (ENODEV); + } + + return (0); +} + +/* + * Initialize gfx framework. + */ +void +gfx_framework_init(void) +{ +} void gfx_fb_setpixel(uint32_t x __unused, uint32_t y __unused) @@ -76,3 +144,7 @@ { return (1); } + +void autoload_font(bool bios __unused) +{ +} diff --git a/stand/i386/libi386/Makefile b/stand/i386/libi386/Makefile --- a/stand/i386/libi386/Makefile +++ b/stand/i386/libi386/Makefile @@ -30,6 +30,7 @@ # terminal emulation .if ${BOOT_FRAMEBUFFER_MODE:Uno} == "yes" CFLAGS.vidconsole.c+= -DFRAMEBUFFER_MODE +CFLAGS.vbe.c+= -DFRAMEBUFFER_MODE .endif CFLAGS.vidconsole.c+= -I${SRCTOP}/sys/teken -I${SRCTOP}/contrib/pnglite CFLAGS.teken.c+= -I${SRCTOP}/sys/teken diff --git a/stand/i386/libi386/vbe.c b/stand/i386/libi386/vbe.c --- a/stand/i386/libi386/vbe.c +++ b/stand/i386/libi386/vbe.c @@ -525,8 +525,10 @@ env_setenv("screen.textmode", EV_VOLATILE | EV_NOHOOK, value, NULL, NULL); if (v == 1) { +#if defined(FRAMEBUFFER_MODE) reset_font_flags(); bios_text_font(true); +#endif bios_set_text_mode(VGA_TEXT_MODE); (void) cons_update_mode(false); return (0); @@ -538,6 +540,7 @@ return (EINVAL); } +#if defined(FRAMEBUFFER_MODE) mode = vbe_default_mode(); if (gfx_state.tg_mode != mode) { reset_font_flags(); @@ -545,6 +548,7 @@ vbe_set_mode(mode); cons_update_mode(true); } +#endif return (0); } @@ -568,8 +572,10 @@ env_setenv("screen.textmode", EV_VOLATILE, "1", mode_set, env_nounset); +#if defined(FRAMEBUFFER_MODE) env_setenv("vbe_max_resolution", EV_VOLATILE, NULL, mode_set, env_nounset); +#endif if (vbe == NULL) { vbe = malloc(sizeof(*vbe)); @@ -761,6 +767,7 @@ return (0); } +#if defined(FRAMEBUFFER_MODE) /* * Verify existence of mode number or find mode by * dimensions. If depth is not given, walk values 32, 24, 16, 8. @@ -1270,3 +1277,4 @@ "set ", argv[0]); return (CMD_ERROR); } +#endif diff --git a/stand/i386/libi386/vidconsole.c b/stand/i386/libi386/vidconsole.c --- a/stand/i386/libi386/vidconsole.c +++ b/stand/i386/libi386/vidconsole.c @@ -778,6 +778,7 @@ return ('?'); } +#if defined(FRAMEBUFFER_MODE) /* * install font for text mode */ @@ -877,6 +878,7 @@ /* Screen on */ vga_set_seq(VGA_REG_BASE, VGA_SEQ_CLOCKING_MODE, reg[1] & 0xdf); } +#endif bool cons_update_mode(bool use_gfx_mode) @@ -894,6 +896,7 @@ gfx_state.tg_tp.tp_col = TEXT_COLS; if (use_gfx_mode) { +#if defined(FRAMEBUFFER_MODE) setup_font(&gfx_state, gfx_state.tg_fb.fb_height, gfx_state.tg_fb.fb_width); /* Point of origin in pixels. */ @@ -918,17 +921,20 @@ snprintf(env, sizeof (env), "%d", gfx_state.tg_fb.fb_bpp); env_setenv("screen.depth", EV_VOLATILE | EV_NOHOOK, env, env_noset, env_screen_nounset); +#endif } else { +#if defined(FRAMEBUFFER_MODE) /* Trigger loading of 8x16 font. */ setup_font(&gfx_state, 16 * gfx_state.tg_fb.fb_height, 8 * gfx_state.tg_fb.fb_width); + vidc_install_font(); +#endif gfx_state.tg_functions = &tf; /* ensure the following are not set for text mode */ unsetenv("screen.height"); unsetenv("screen.width"); unsetenv("screen.depth"); - vidc_install_font(); } free(screen_buffer); @@ -990,8 +996,10 @@ snprintf(env, sizeof (env), "%u", (unsigned)gfx_state.tg_tp.tp_col); setenv("COLUMNS", env, 1); +#if defined(FRAMEBUFFER_MODE) /* Draw frame around terminal area. */ cons_draw_frame(&attr); +#endif /* Erase display, this will also fill our screen buffer. */ teken_input(&gfx_state.tg_teken, "\e[2J", 4); gfx_state.tg_functions->tf_param(&gfx_state, TP_SHOWCURSOR, 1); diff --git a/stand/i386/loader/Makefile b/stand/i386/loader/Makefile --- a/stand/i386/loader/Makefile +++ b/stand/i386/loader/Makefile @@ -39,13 +39,22 @@ .PATH: ${BOOTSRC}/i386/loader # architecture-specific loader code -SRCS= main.c conf.c vers.c chain.c gfx_fb.c 8x16.c +SRCS= main.c conf.c vers.c chain.c + +.if ${BOOT_FRAMEBUFFER_MODE:Uno} == "yes" +SRCS+= gfx_fb.c 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 +.else +SRCS+= gfx_fb_stub.c + +CFLAGS.gfx_fb_stub.c += -I$(SRCTOP)/sys/teken +CFLAGS.gfx_fb_stub.c += -I${SRCTOP}/contrib/pnglite +.endif # Include bcache code. HAVE_BCACHE= yes