summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2020-07-27 00:00:34 +0300
committerToomas Soome <tsoome@me.com>2020-08-25 22:32:26 +0300
commite0721d5ae1542c80097f6fcd487736fdfe601233 (patch)
tree31155f14b8ccb999c14087c89aeb8e18ed437f8b
parent6863ede29751efd2be66ec1b48c3c0ee705d7d61 (diff)
downloadillumos-joyent-e0721d5ae1542c80097f6fcd487736fdfe601233.tar.gz
13003 console: multiple issues related to colors and font loading and switching
Reviewed by: Robert Mustacchi <rm@fingolfin.org> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/boot/Makefile.version2
-rw-r--r--usr/src/boot/sys/boot/Makefile.inc2
-rw-r--r--usr/src/boot/sys/boot/common/bootstrap.h2
-rw-r--r--usr/src/boot/sys/boot/common/gfx_fb.c269
-rw-r--r--usr/src/boot/sys/boot/common/gfx_fb.h1
-rw-r--r--usr/src/boot/sys/boot/common/module.c9
-rw-r--r--usr/src/boot/sys/boot/common/tem.c95
-rw-r--r--usr/src/boot/sys/boot/efi/libefi/Makefile.com2
-rw-r--r--usr/src/boot/sys/boot/efi/loader/Makefile.com2
-rw-r--r--usr/src/boot/sys/boot/efi/loader/main.c2
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/Makefile2
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/vbe.c2
-rw-r--r--usr/src/boot/sys/boot/i386/loader/Makefile2
-rw-r--r--usr/src/boot/sys/boot/i386/loader/main.c2
-rw-r--r--usr/src/boot/sys/sys/tem_impl.h1
-rw-r--r--usr/src/common/font/font.c3
-rw-r--r--usr/src/uts/common/Makefile.files2
-rw-r--r--usr/src/uts/common/io/tem.c78
-rw-r--r--usr/src/uts/common/io/tem_safe.c19
-rw-r--r--usr/src/uts/common/sys/font.h8
-rw-r--r--usr/src/uts/i86pc/boot/boot_fb.c40
-rw-r--r--usr/src/uts/intel/tem/Makefile18
-rw-r--r--usr/src/uts/sparc/tem/Makefile26
23 files changed, 370 insertions, 219 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version
index d1fd2200d6..5c3e29449d 100644
--- a/usr/src/boot/Makefile.version
+++ b/usr/src/boot/Makefile.version
@@ -33,4 +33,4 @@ LOADER_VERSION = 1.1
# Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes.
# The version is processed from left to right, the version number can only
# be increased.
-BOOT_VERSION = $(LOADER_VERSION)-2020.08.22.1
+BOOT_VERSION = $(LOADER_VERSION)-2020.08.25.1
diff --git a/usr/src/boot/sys/boot/Makefile.inc b/usr/src/boot/sys/boot/Makefile.inc
index 674d41ce23..86ea9ca206 100644
--- a/usr/src/boot/sys/boot/Makefile.inc
+++ b/usr/src/boot/sys/boot/Makefile.inc
@@ -31,7 +31,7 @@ LDFLAGS += $(GLDTARGET)
# bare minimum for case we can not load font from the OS root.
FONT= 8x16
-FONT_SRC= ter-u16n.bdf
+FONT_SRC= ter-u16b.bdf
FONT_DIR= $(SRC)/data/consfonts
PNGLITE= $(SRC)/common/pnglite
diff --git a/usr/src/boot/sys/boot/common/bootstrap.h b/usr/src/boot/sys/boot/common/bootstrap.h
index 1da5d6ffe0..7cdeb6d1c4 100644
--- a/usr/src/boot/sys/boot/common/bootstrap.h
+++ b/usr/src/boot/sys/boot/common/bootstrap.h
@@ -123,7 +123,7 @@ struct console
extern struct console *consoles[];
void cons_probe(void);
void cons_mode(int);
-void autoload_font(void);
+void autoload_font(bool);
/*
* Plug-and-play enumerator/configurator interface.
diff --git a/usr/src/boot/sys/boot/common/gfx_fb.c b/usr/src/boot/sys/boot/common/gfx_fb.c
index 9389856ba8..84d5e50fe2 100644
--- a/usr/src/boot/sys/boot/common/gfx_fb.c
+++ b/usr/src/boot/sys/boot/common/gfx_fb.c
@@ -37,6 +37,15 @@
#include <gfx_fb.h>
#include <pnglite.h>
#include <bootstrap.h>
+#include <lz4.h>
+
+/* VGA text mode does use bold font. */
+#if !defined(VGA_8X16_FONT)
+#define VGA_8X16_FONT "/boot/fonts/8x16b.fnt"
+#endif
+#if !defined(DEFAULT_8X16_FONT)
+#define DEFAULT_8X16_FONT "/boot/fonts/8x16.fnt"
+#endif
/*
* Global framebuffer struct, to be updated with mode changes.
@@ -68,6 +77,8 @@ static void gfx_bm_cons_copy(struct vis_conscopy *);
static void gfx_bm_cons_display(struct vis_consdisplay *);
static void gfx_bm_display_cursor(struct vis_conscursor *);
+static bool insert_font(char *, FONT_FLAGS);
+
/*
* Set default operations to use bitmap based implementation.
* In case of UEFI, if GOP is available, we will switch to GOP based
@@ -399,6 +410,11 @@ gfx_framework_init(struct visual_ops *fb_ops)
snprintf(buf, sizeof (buf), "%d", gfx_bg);
env_setenv("tem.bg_color", EV_VOLATILE, buf, gfx_set_colors,
env_nounset);
+
+ /*
+ * Setup font list to have builtin font.
+ */
+ (void) insert_font(NULL, FONT_BUILTIN);
}
/*
@@ -1502,7 +1518,35 @@ load_mapping(int fd, struct font *fp, int n)
return (0);
}
-/* Load font from file. */
+static int
+builtin_mapping(struct font *fp, int n)
+{
+ size_t size;
+ struct font_map *mp;
+
+ if (n >= VFNT_MAPS)
+ return (EINVAL);
+
+ if (fp->vf_map_count[n] == 0)
+ return (0);
+
+ size = fp->vf_map_count[n] * sizeof (*mp);
+ mp = malloc(size);
+ if (mp == NULL)
+ return (ENOMEM);
+ fp->vf_map[n] = mp;
+
+ memcpy(mp, DEFAULT_FONT_DATA.font->vf_map[n], size);
+ return (0);
+}
+
+/*
+ * Load font from builtin or from file.
+ * We do need special case for builtin because the builtin font glyphs
+ * are compressed and we do need to uncompress them.
+ * Having single load_font() for both cases will help us to simplify
+ * font switch handling.
+ */
static bitmap_data_t *
load_font(char *path)
{
@@ -1510,7 +1554,7 @@ load_font(char *path)
uint32_t glyphs;
struct font_header fh;
struct fontlist *fl;
- bitmap_data_t *bp = NULL;
+ bitmap_data_t *bp;
struct font *fp;
size_t size;
ssize_t rv;
@@ -1522,9 +1566,52 @@ load_font(char *path)
}
if (fl == NULL)
return (NULL); /* Should not happen. */
+
bp = fl->font_data;
- if (bp->font != NULL)
+ if (bp->font != NULL && fl->font_flags != FONT_RELOAD)
+ return (bp);
+
+ fd = -1;
+ /*
+ * Special case for builtin font.
+ * Builtin font is the very first font we load, we do not have
+ * previous loads to be released.
+ */
+ if (fl->font_flags == FONT_BUILTIN) {
+ if ((fp = calloc(1, sizeof (struct font))) == NULL)
+ return (NULL);
+
+ fp->vf_width = DEFAULT_FONT_DATA.width;
+ fp->vf_height = DEFAULT_FONT_DATA.height;
+
+ fp->vf_bytes = malloc(DEFAULT_FONT_DATA.uncompressed_size);
+ if (fp->vf_bytes == NULL) {
+ free(fp);
+ return (NULL);
+ }
+
+ bp->uncompressed_size = DEFAULT_FONT_DATA.uncompressed_size;
+ bp->compressed_size = DEFAULT_FONT_DATA.compressed_size;
+
+ if (lz4_decompress(DEFAULT_FONT_DATA.compressed_data,
+ fp->vf_bytes,
+ DEFAULT_FONT_DATA.compressed_size,
+ DEFAULT_FONT_DATA.uncompressed_size, 0) != 0) {
+ free(fp->vf_bytes);
+ free(fp);
+ return (NULL);
+ }
+
+ for (i = 0; i < VFNT_MAPS; i++) {
+ fp->vf_map_count[i] =
+ DEFAULT_FONT_DATA.font->vf_map_count[i];
+ if (builtin_mapping(fp, i) != 0)
+ goto free_done;
+ }
+
+ bp->font = fp;
return (bp);
+ }
fd = open(path, O_RDONLY);
if (fd < 0) {
@@ -1552,8 +1639,8 @@ load_font(char *path)
fp->vf_width = fh.fh_width;
fp->vf_height = fh.fh_height;
- bp->uncompressed_size = howmany(bp->width, 8) * bp->height * glyphs;
- size = bp->uncompressed_size;
+ size = howmany(fp->vf_width, 8) * fp->vf_height * glyphs;
+ bp->uncompressed_size = size;
if ((fp->vf_bytes = malloc(size)) == NULL)
goto free_done;
@@ -1564,42 +1651,36 @@ load_font(char *path)
if (load_mapping(fd, fp, i) != 0)
goto free_done;
}
- bp->font = fp;
/*
- * Release previously loaded entry. We can do this now, as
+ * Reset builtin flag now as we have full font loaded.
+ */
+ if (fl->font_flags == FONT_BUILTIN)
+ fl->font_flags = FONT_AUTO;
+
+ /*
+ * Release previously loaded entries. We can do this now, as
* the new font is loaded. Note, there can be no console
* output till the new font is in place and tem is notified.
* We do need to keep fl->font_data for glyph dimensions.
*/
STAILQ_FOREACH(fl, &fonts, font_next) {
- if (fl->font_data->width == bp->width &&
- fl->font_data->height == bp->height)
+ if (fl->font_data->font == NULL)
continue;
- if (fl->font_data->font != NULL) {
- for (i = 0; i < VFNT_MAPS; i++)
- free(fl->font_data->font->vf_map[i]);
-
- /* Unset vf_bytes pointer in tem. */
- if (tems.ts_font.vf_bytes ==
- fl->font_data->font->vf_bytes) {
- tems.ts_font.vf_bytes = NULL;
- }
- free(fl->font_data->font->vf_bytes);
- free(fl->font_data->font);
- fl->font_data->font = NULL;
- fl->font_data->uncompressed_size = 0;
- fl->font_flags = FONT_AUTO;
- }
+ for (i = 0; i < VFNT_MAPS; i++)
+ free(fl->font_data->font->vf_map[i]);
+ free(fl->font_data->font->vf_bytes);
+ free(fl->font_data->font);
+ fl->font_data->font = NULL;
}
- /* free the uncompressed builtin font data in tem. */
- free(tems.ts_font.vf_bytes);
- tems.ts_font.vf_bytes = NULL;
+ bp->font = fp;
+ bp->compressed_size = 0;
done:
- close(fd);
+ if (fd != -1)
+ close(fd);
return (bp);
free_done:
@@ -1662,7 +1743,7 @@ read_list(char *fonts)
* The font list is built in descending order.
*/
static bool
-insert_font(char *name)
+insert_font(char *name, FONT_FLAGS flags)
{
struct font_header fh;
struct fontlist *fp, *previous, *entry, *next;
@@ -1671,30 +1752,51 @@ insert_font(char *name)
int fd;
char *font_name;
- fd = open(name, O_RDONLY);
- if (fd < 0)
- return (false);
- rv = read(fd, &fh, sizeof (fh));
- close(fd);
- if (rv < 0 || (size_t)rv != sizeof (fh))
- return (false);
+ font_name = NULL;
+ if (flags == FONT_BUILTIN) {
+ /*
+ * We only install builtin font once, while setting up
+ * initial console. Since this will happen very early,
+ * we assume asprintf will not fail. Once we have access to
+ * files, the builtin font will be replaced by font loaded
+ * from file.
+ */
+ if (!STAILQ_EMPTY(&fonts))
+ return (false);
- if (memcmp(fh.fh_magic, FONT_HEADER_MAGIC, sizeof (fh.fh_magic)) != 0)
- return (false);
+ fh.fh_width = DEFAULT_FONT_DATA.width;
+ fh.fh_height = DEFAULT_FONT_DATA.height;
+
+ (void) asprintf(&font_name, "%dx%d",
+ DEFAULT_FONT_DATA.width, DEFAULT_FONT_DATA.height);
+ } else {
+ fd = open(name, O_RDONLY);
+ if (fd < 0)
+ return (false);
+ rv = read(fd, &fh, sizeof (fh));
+ close(fd);
+ if (rv < 0 || (size_t)rv != sizeof (fh))
+ return (false);
+
+ if (memcmp(fh.fh_magic, FONT_HEADER_MAGIC,
+ sizeof (fh.fh_magic)) != 0)
+ return (false);
+ font_name = strdup(name);
+ }
- font_name = strdup(name);
if (font_name == NULL)
return (false);
/*
- * If we have an entry with the same glyph dimensions, just replace
- * the file name. We only support unique dimensions.
+ * If we have an entry with the same glyph dimensions, replace
+ * the file name and mark us. We only support unique dimensions.
*/
STAILQ_FOREACH(entry, &fonts, font_next) {
if (fh.fh_width == entry->font_data->width &&
fh.fh_height == entry->font_data->height) {
free(entry->font_name);
entry->font_name = font_name;
+ entry->font_flags = FONT_RELOAD;
return (true);
}
}
@@ -1711,7 +1813,7 @@ insert_font(char *name)
return (false);
}
fp->font_name = font_name;
- fp->font_flags = FONT_AUTO;
+ fp->font_flags = flags;
fp->font_load = load_font;
fp->font_data->width = fh.fh_width;
fp->font_data->height = fh.fh_height;
@@ -1726,8 +1828,7 @@ insert_font(char *name)
STAILQ_FOREACH(entry, &fonts, font_next) {
/* Should fp be inserted before the entry? */
- if (size >
- entry->font_data->width * entry->font_data->height) {
+ if (size > entry->font_data->width * entry->font_data->height) {
if (previous == NULL) {
STAILQ_INSERT_HEAD(&fonts, fp, font_next);
} else {
@@ -1789,7 +1890,17 @@ font_set(struct env_var *ev __unused, int flags __unused, const void *value)
}
void
-autoload_font(void)
+bios_text_font(bool use_vga_font)
+{
+ if (use_vga_font)
+ (void) insert_font(VGA_8X16_FONT, FONT_MANUAL);
+ else
+ (void) insert_font(DEFAULT_8X16_FONT, FONT_MANUAL);
+ tems.update_font = true;
+}
+
+void
+autoload_font(bool bios)
{
struct name_list *nl;
struct name_entry *np;
@@ -1801,7 +1912,7 @@ autoload_font(void)
while (!SLIST_EMPTY(nl)) {
np = SLIST_FIRST(nl);
SLIST_REMOVE_HEAD(nl, n_entry);
- if (insert_font(np->n_name) == false)
+ if (insert_font(np->n_name, FONT_AUTO) == false)
printf("failed to add font: %s\n", np->n_name);
free(np->n_name);
free(np);
@@ -1809,6 +1920,14 @@ autoload_font(void)
unsetenv("screen-font");
env_setenv("screen-font", EV_VOLATILE, NULL, font_set, env_nounset);
+
+ /*
+ * If vga text mode was requested, load vga.font (8x16 bold) font.
+ */
+ if (bios) {
+ bios_text_font(true);
+ }
+
/* Trigger tem update. */
tems.update_font = true;
plat_cons_update_mode(-1);
@@ -1819,44 +1938,62 @@ COMMAND_SET(load_font, "loadfont", "load console font from file", command_font);
static int
command_font(int argc, char *argv[])
{
- int i, rc = CMD_OK;
+ int i, c, rc = CMD_OK;
struct fontlist *fl;
- bitmap_data_t *bd;
+ bool list;
- if (argc > 2) {
- printf("Usage: loadfont [file.fnt]\n");
- return (CMD_ERROR);
+ list = false;
+ optind = 1;
+ optreset = 1;
+ rc = CMD_OK;
+
+ while ((c = getopt(argc, argv, "l")) != -1) {
+ switch (c) {
+ case 'l':
+ list = true;
+ break;
+ case '?':
+ default:
+ return (CMD_ERROR);
+ }
}
- if (argc == 2) {
- char *name = argv[1];
+ argc -= optind;
+ argv += optind;
- if (insert_font(name) == false) {
- printf("loadfont error: failed to load: %s\n", name);
- return (CMD_ERROR);
+ if (argc > 1 || (list && argc != 0)) {
+ printf("Usage: loadfont [-l] | [file.fnt]\n");
+ return (CMD_ERROR);
+ }
+
+ if (list) {
+ STAILQ_FOREACH(fl, &fonts, font_next) {
+ printf("font %s: %dx%d%s\n", fl->font_name,
+ fl->font_data->width,
+ fl->font_data->height,
+ fl->font_data->font == NULL? "" : " loaded");
}
+ return (CMD_OK);
+ }
+
+ if (argc == 1) {
+ char *name = argv[0];
- bd = load_font(name);
- if (bd == NULL) {
+ if (insert_font(name, FONT_MANUAL) == false) {
printf("loadfont error: failed to load: %s\n", name);
return (CMD_ERROR);
}
- /* Get the font list entry and mark it manually loaded. */
- STAILQ_FOREACH(fl, &fonts, font_next) {
- if (strcmp(fl->font_name, name) == 0)
- fl->font_flags = FONT_MANUAL;
- }
tems.update_font = true;
plat_cons_update_mode(-1);
return (CMD_OK);
}
- if (argc == 1) {
+ if (argc == 0) {
/*
* Walk entire font list, release any loaded font, and set
- * autoload flag. If the font list is empty, the tem will
- * get the builtin default.
+ * autoload flag. The font list does have at least the builtin
+ * default font.
*/
STAILQ_FOREACH(fl, &fonts, font_next) {
if (fl->font_data->font != NULL) {
diff --git a/usr/src/boot/sys/boot/common/gfx_fb.h b/usr/src/boot/sys/boot/common/gfx_fb.h
index 19227151f8..de199d1472 100644
--- a/usr/src/boot/sys/boot/common/gfx_fb.h
+++ b/usr/src/boot/sys/boot/common/gfx_fb.h
@@ -105,6 +105,7 @@ struct vesa_edid_info {
extern multiboot_tag_framebuffer_t gfx_fb;
+void bios_text_font(bool);
void gfx_framework_init(struct visual_ops *);
uint32_t gfx_fb_color_map(uint8_t);
void gfx_fb_display_cursor(struct vis_conscursor *);
diff --git a/usr/src/boot/sys/boot/common/module.c b/usr/src/boot/sys/boot/common/module.c
index 4936ec5a3c..481c07eb58 100644
--- a/usr/src/boot/sys/boot/common/module.c
+++ b/usr/src/boot/sys/boot/common/module.c
@@ -531,7 +531,14 @@ build_font_module(void)
/* helper pointers */
bd = NULL;
STAILQ_FOREACH(fl, &fonts, font_next) {
- if (fl->font_data->font != NULL) {
+ if (tems.ts_font.vf_width == fl->font_data->width &&
+ tems.ts_font.vf_height == fl->font_data->height) {
+ /*
+ * Kernel does have better built in font.
+ */
+ if (fl->font_flags == FONT_BUILTIN)
+ return;
+
bd = fl->font_data;
break;
}
diff --git a/usr/src/boot/sys/boot/common/tem.c b/usr/src/boot/sys/boot/common/tem.c
index 9f4a852286..97a7745285 100644
--- a/usr/src/boot/sys/boot/common/tem.c
+++ b/usr/src/boot/sys/boot/common/tem.c
@@ -68,7 +68,6 @@
#include <sys/consplat.h>
#include <sys/kd.h>
#include <stdbool.h>
-#include <lz4.h>
/* Terminal emulator internal helper functions */
static void tems_setup_terminal(struct vis_devinit *, size_t, size_t);
@@ -434,10 +433,9 @@ static void
tems_setup_font(screen_size_t height, screen_size_t width)
{
bitmap_data_t *font_data;
- int i;
/*
- * set_font() will select a appropriate sized font for
+ * set_font() will select an appropriate sized font for
* the number of rows and columns selected. If we don't
* have a font that will fit, then it will use the
* default builtin font and adjust the rows and columns
@@ -446,44 +444,24 @@ tems_setup_font(screen_size_t height, screen_size_t width)
font_data = set_font(&tems.ts_c_dimension.height,
&tems.ts_c_dimension.width, height, width);
+ if (font_data == NULL)
+ panic("out of memory");
+
/*
- * The built in font is compressed, to use it, we
- * uncompress it into the allocated buffer.
- * To use loaded font, we assign the loaded buffer.
- * In case of next load, the previously loaded data
- * is freed by the process of loading the new font.
+ * To use loaded font, we assign the loaded font data to tems.ts_font.
+ * In case of next load, the previously loaded data is freed
+ * when loading the new font.
*/
- if (tems.ts_font.vf_bytes == NULL) {
- for (i = 0; i < VFNT_MAPS; i++) {
- tems.ts_font.vf_map[i] =
- font_data->font->vf_map[i];
- }
-
- if (font_data->compressed_size != 0) {
- /*
- * We only expect this allocation to
- * happen at startup, and therefore not to fail.
- */
- tems.ts_font.vf_bytes =
- malloc(font_data->uncompressed_size);
- if (tems.ts_font.vf_bytes == NULL)
- panic("out of memory");
- (void) lz4_decompress(
- font_data->compressed_data,
- tems.ts_font.vf_bytes,
- font_data->compressed_size,
- font_data->uncompressed_size, 0);
- } else {
- tems.ts_font.vf_bytes =
- font_data->font->vf_bytes;
- }
- tems.ts_font.vf_width = font_data->font->vf_width;
- tems.ts_font.vf_height = font_data->font->vf_height;
- for (i = 0; i < VFNT_MAPS; i++) {
- tems.ts_font.vf_map_count[i] =
- font_data->font->vf_map_count[i];
- }
+ for (int i = 0; i < VFNT_MAPS; i++) {
+ tems.ts_font.vf_map[i] =
+ font_data->font->vf_map[i];
+ tems.ts_font.vf_map_count[i] =
+ font_data->font->vf_map_count[i];
}
+
+ tems.ts_font.vf_bytes = font_data->font->vf_bytes;
+ tems.ts_font.vf_width = font_data->font->vf_width;
+ tems.ts_font.vf_height = font_data->font->vf_height;
}
static void
@@ -900,24 +878,23 @@ tems_get_initial_color(tem_color_t *pcolor)
if (inverse_screen)
flags |= TEM_ATTR_SCREEN_REVERSE;
- /*
- * In case of black on white we want bright white for BG.
- * In case if white on black, to improve readability,
- * we want bold white.
- */
if (flags != 0) {
/*
- * If either reverse flag is set, the screen is in
- * white-on-black mode. We set the bold flag to
- * improve readability.
+ * The reverse attribute is set.
+ * In case of black on white we want bright white for BG.
+ */
+ if (pcolor->fg_color == ANSI_COLOR_WHITE)
+ flags |= TEM_ATTR_BRIGHT_BG;
+
+ /*
+ * For white on black, unset the bright attribute we
+ * had set to have bright white background.
*/
- flags |= TEM_ATTR_BOLD;
+ if (pcolor->fg_color == ANSI_COLOR_BLACK)
+ flags &= ~TEM_ATTR_BRIGHT_BG;
} else {
/*
- * Otherwise, the screen is in black-on-white mode.
- * The SPARC PROM console, which starts in this mode,
- * uses the bright white background colour so we
- * match it here.
+ * In case of black on white we want bright white for BG.
*/
if (pcolor->bg_color == ANSI_COLOR_WHITE)
flags |= TEM_ATTR_BRIGHT_BG;
@@ -2815,19 +2792,29 @@ tem_get_attr(struct tem_vt_state *tem, text_color_t *fg,
static void
tem_get_color(text_color_t *fg, text_color_t *bg, term_char_t c)
{
+ bool bold_font;
+
*fg = c.tc_fg_color;
*bg = c.tc_bg_color;
+ bold_font = tems.ts_font.vf_map_count[VFNT_MAP_BOLD] != 0;
+
+ /*
+ * If we have both normal and bold font components,
+ * we use bold font for TEM_ATTR_BOLD.
+ * The bright color is traditionally used with TEM_ATTR_BOLD,
+ * in case there is no bold font.
+ */
if (c.tc_fg_color < XLATE_NCOLORS) {
- if (TEM_CHAR_ATTR(c.tc_char) &
- (TEM_ATTR_BRIGHT_FG | TEM_ATTR_BOLD))
+ if (TEM_ATTR_ISSET(c.tc_char, TEM_ATTR_BRIGHT_FG) ||
+ (TEM_ATTR_ISSET(c.tc_char, TEM_ATTR_BOLD) && !bold_font))
*fg = brt_xlate[c.tc_fg_color];
else
*fg = dim_xlate[c.tc_fg_color];
}
if (c.tc_bg_color < XLATE_NCOLORS) {
- if (TEM_CHAR_ATTR(c.tc_char) & TEM_ATTR_BRIGHT_BG)
+ if (TEM_ATTR_ISSET(c.tc_char, TEM_ATTR_BRIGHT_BG))
*bg = brt_xlate[c.tc_bg_color];
else
*bg = dim_xlate[c.tc_bg_color];
diff --git a/usr/src/boot/sys/boot/efi/libefi/Makefile.com b/usr/src/boot/sys/boot/efi/libefi/Makefile.com
index 3e0219aa9a..5d3285db2c 100644
--- a/usr/src/boot/sys/boot/efi/libefi/Makefile.com
+++ b/usr/src/boot/sys/boot/efi/libefi/Makefile.com
@@ -47,7 +47,7 @@ CPPFLAGS += -I../../../../../lib/libstand
CPPFLAGS += -I$(ZFSSRC)
CPPFLAGS += -I../../../../cddl/boot/zfs
-gfx_fb.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR)
+gfx_fb.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR) -I$(LZ4)
pnglite.o := CPPFLAGS += -I$(ZLIB)
gfx_fb.o pnglite.o efi_console.o := CPPFLAGS += -I$(PNGLITE)
diff --git a/usr/src/boot/sys/boot/efi/loader/Makefile.com b/usr/src/boot/sys/boot/efi/loader/Makefile.com
index dd7141cf9c..1c8abe2a8d 100644
--- a/usr/src/boot/sys/boot/efi/loader/Makefile.com
+++ b/usr/src/boot/sys/boot/efi/loader/Makefile.com
@@ -59,7 +59,7 @@ OBJS= \
vers.o
module.o := CPPFLAGS += -I$(BOOTSRC)/libcrypto
-tem.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR) -I$(LZ4)
+tem.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR)
CPPFLAGS += -I../../../../../include -I../../..../
CPPFLAGS += -I../../../../../lib/libstand
diff --git a/usr/src/boot/sys/boot/efi/loader/main.c b/usr/src/boot/sys/boot/efi/loader/main.c
index 3fd902e78a..b5b310b9ad 100644
--- a/usr/src/boot/sys/boot/efi/loader/main.c
+++ b/usr/src/boot/sys/boot/efi/loader/main.c
@@ -694,7 +694,7 @@ main(int argc, CHAR16 *argv[])
if (!interactive_interrupt("Failed to find bootable partition"))
return (EFI_NOT_FOUND);
- autoload_font(); /* Set up the font list for console. */
+ autoload_font(false); /* Set up the font list for console. */
efi_init_environment();
setenv("ISADIR", "amd64", 1); /* we only build 64bit */
bi_isadir(); /* set ISADIR */
diff --git a/usr/src/boot/sys/boot/i386/libi386/Makefile b/usr/src/boot/sys/boot/i386/libi386/Makefile
index 35b98290aa..d28628c0dd 100644
--- a/usr/src/boot/sys/boot/i386/libi386/Makefile
+++ b/usr/src/boot/sys/boot/i386/libi386/Makefile
@@ -98,7 +98,7 @@ CPPFLAGS += -I$(PNGLITE)
SRCS += $(COMMON)/gfx_fb.c $(PNGLITE)/pnglite.c
OBJS += gfx_fb.o pnglite.o
-gfx_fb.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR)
+gfx_fb.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR) -I$(LZ4)
pnglite.o := CPPFLAGS += -I$(ZLIB)
SRCS += $(ZFSSRC)/devicename_stubs.c
diff --git a/usr/src/boot/sys/boot/i386/libi386/vbe.c b/usr/src/boot/sys/boot/i386/libi386/vbe.c
index ef8770f3c5..d8ad4ed643 100644
--- a/usr/src/boot/sys/boot/i386/libi386/vbe.c
+++ b/usr/src/boot/sys/boot/i386/libi386/vbe.c
@@ -758,6 +758,7 @@ command_vesa(int argc, char *argv[])
return (CMD_OK);
reset_font_flags();
+ bios_text_font(true);
bios_set_text_mode(VGA_TEXT_MODE);
plat_cons_update_mode(0);
return (CMD_OK);
@@ -805,6 +806,7 @@ command_vesa(int argc, char *argv[])
if (modenum >= 0x100) {
if (vbestate.vbe_mode != modenum) {
reset_font_flags();
+ bios_text_font(false);
vbe_set_mode(modenum);
plat_cons_update_mode(1);
}
diff --git a/usr/src/boot/sys/boot/i386/loader/Makefile b/usr/src/boot/sys/boot/i386/loader/Makefile
index b98e66456b..e8d796b7fd 100644
--- a/usr/src/boot/sys/boot/i386/loader/Makefile
+++ b/usr/src/boot/sys/boot/i386/loader/Makefile
@@ -61,7 +61,7 @@ SRCS += zfs_cmd.c
SRCS += font.c $(FONT).c tem.c
module.o := CPPFLAGS += -I$(BOOTSRC)/libcrypto
-tem.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR) -I$(LZ4)
+tem.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR)
SRCS += load_elf32.c load_elf32_obj.c reloc_elf32.c
SRCS += load_elf64.c load_elf64_obj.c reloc_elf64.c
diff --git a/usr/src/boot/sys/boot/i386/loader/main.c b/usr/src/boot/sys/boot/i386/loader/main.c
index 58ad05e106..169d0e1ce5 100644
--- a/usr/src/boot/sys/boot/i386/loader/main.c
+++ b/usr/src/boot/sys/boot/i386/loader/main.c
@@ -186,7 +186,7 @@ main(void)
printf("\n%s", bootprog_info);
extract_currdev(); /* set $currdev and $loaddev */
- autoload_font(); /* Set up the font list for console. */
+ autoload_font(OPT_CHECK(RBX_TEXT_MODE) != 0);
bi_isadir();
bios_getsmap();
diff --git a/usr/src/boot/sys/sys/tem_impl.h b/usr/src/boot/sys/sys/tem_impl.h
index d942aecdeb..ee0dcbb28f 100644
--- a/usr/src/boot/sys/sys/tem_impl.h
+++ b/usr/src/boot/sys/sys/tem_impl.h
@@ -63,6 +63,7 @@ typedef uint32_t tem_char_t; /* 32bit char to support UTF-8 */
#define TEM_CHAR(c) ((c) & 0x1fffff)
#define TEM_CHAR_ATTR(c) (((c) >> 21) & TEM_ATTR_MASK)
#define TEM_ATTR(c) (((c) & TEM_ATTR_MASK) << 21)
+#define TEM_ATTR_ISSET(c, a) ((TEM_CHAR_ATTR(c) & (a)) == (a))
#define TEM_MAXPARAMS 5 /* maximum number of ANSI paramters */
#define TEM_MAXTAB 40 /* maximum number of tab stops */
diff --git a/usr/src/common/font/font.c b/usr/src/common/font/font.c
index 3556f27cf8..f46c34a988 100644
--- a/usr/src/common/font/font.c
+++ b/usr/src/common/font/font.c
@@ -222,7 +222,8 @@ set_font(short *rows, short *cols, short h, short w)
font = fl->font_data;
if ((((*rows * font->height) + BORDER_PIXELS) <= height) &&
(((*cols * font->width) + BORDER_PIXELS) <= width)) {
- if (font->font == NULL) {
+ if (font->font == NULL ||
+ fl->font_flags == FONT_RELOAD) {
if (fl->font_load != NULL &&
fl->font_name != NULL) {
font = fl->font_load(fl->font_name);
diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files
index 39ee71dc58..4a44510cb8 100644
--- a/usr/src/uts/common/Makefile.files
+++ b/usr/src/uts/common/Makefile.files
@@ -1660,7 +1660,7 @@ TEM_OBJS += tem.o tem_safe.o
# Font data for generated console fonts
#
i386_FONT = 8x16
-i386_FONT_SRC= ter-u16n
+i386_FONT_SRC= ter-u16b
sparc_FONT = 12x22
sparc_FONT_SRC= Gallant19
FONT=$($(MACH)_FONT)
diff --git a/usr/src/uts/common/io/tem.c b/usr/src/uts/common/io/tem.c
index 573e10cd66..525aa5f585 100644
--- a/usr/src/uts/common/io/tem.c
+++ b/usr/src/uts/common/io/tem.c
@@ -524,10 +524,41 @@ tems_check_videomode(struct vis_devinit *tp)
}
static void
-tems_setup_terminal(struct vis_devinit *tp, size_t height, size_t width)
+tems_setup_font(screen_size_t height, screen_size_t width)
{
bitmap_data_t *font_data;
int i;
+
+ /*
+ * set_font() will select an appropriate sized font for
+ * the number of rows and columns selected. If we don't
+ * have a font that will fit, then it will use the
+ * default builtin font and adjust the rows and columns
+ * to fit on the screen.
+ */
+ font_data = set_font(&tems.ts_c_dimension.height,
+ &tems.ts_c_dimension.width, height, width);
+
+ /*
+ * To use loaded font, we assign the loaded font data to tems.ts_font.
+ * In case of next load, the previously loaded data is freed
+ * when loading the new font.
+ */
+ for (i = 0; i < VFNT_MAPS; i++) {
+ tems.ts_font.vf_map[i] =
+ font_data->font->vf_map[i];
+ tems.ts_font.vf_map_count[i] =
+ font_data->font->vf_map_count[i];
+ }
+
+ tems.ts_font.vf_bytes = font_data->font->vf_bytes;
+ tems.ts_font.vf_width = font_data->font->vf_width;
+ tems.ts_font.vf_height = font_data->font->vf_height;
+}
+
+static void
+tems_setup_terminal(struct vis_devinit *tp, size_t height, size_t width)
+{
int old_blank_buf_size = tems.ts_c_dimension.width *
sizeof (*tems.ts_blank_line);
@@ -546,6 +577,9 @@ tems_setup_terminal(struct vis_devinit *tp, size_t height, size_t width)
tems.ts_c_dimension.height = tp->height;
tems.ts_callbacks = &tem_safe_text_callbacks;
+ tems_setup_font(16 * tp->height + BORDER_PIXELS,
+ 8 * tp->width + BORDER_PIXELS);
+
break;
case VIS_PIXEL:
@@ -559,33 +593,11 @@ tems_setup_terminal(struct vis_devinit *tp, size_t height, size_t width)
}
tems.ts_c_dimension.height = (screen_size_t)height;
tems.ts_c_dimension.width = (screen_size_t)width;
-
tems.ts_p_dimension.height = tp->height;
tems.ts_p_dimension.width = tp->width;
-
tems.ts_callbacks = &tem_safe_pix_callbacks;
- /*
- * set_font() will select a appropriate sized font for
- * the number of rows and columns selected. If we don't
- * have a font that will fit, then it will use the
- * default builtin font. set_font() will adjust the rows
- * and columns to fit on the screen.
- */
- font_data = set_font(&tems.ts_c_dimension.height,
- &tems.ts_c_dimension.width,
- tems.ts_p_dimension.height,
- tems.ts_p_dimension.width);
-
- for (i = 0; i < VFNT_MAPS; i++) {
- tems.ts_font.vf_map[i] =
- font_data->font->vf_map[i];
- tems.ts_font.vf_map_count[i] =
- font_data->font->vf_map_count[i];
- }
- tems.ts_font.vf_bytes = font_data->font->vf_bytes;
- tems.ts_font.vf_width = font_data->font->vf_width;
- tems.ts_font.vf_height = font_data->font->vf_height;
+ tems_setup_font(tp->height, tp->width);
tems.ts_p_offset.y = (tems.ts_p_dimension.height -
(tems.ts_c_dimension.height * tems.ts_font.vf_height)) / 2;
@@ -594,9 +606,7 @@ tems_setup_terminal(struct vis_devinit *tp, size_t height, size_t width)
tems.ts_pix_data_size =
tems.ts_font.vf_width * tems.ts_font.vf_height;
-
tems.ts_pix_data_size *= 4;
-
tems.ts_pdepth = tp->depth;
break;
@@ -963,6 +973,7 @@ tems_get_initial_color(tem_color_t *pcolor)
if (inverse_screen)
flags |= TEM_ATTR_SCREEN_REVERSE;
+#ifdef _HAVE_TEM_FIRMWARE
if (flags != 0) {
/*
* If either reverse flag is set, the screen is in
@@ -980,6 +991,21 @@ tems_get_initial_color(tem_color_t *pcolor)
if (pcolor->bg_color == ANSI_COLOR_WHITE)
flags |= TEM_ATTR_BRIGHT_BG;
}
+#else
+ if (flags != 0) {
+ if (pcolor->fg_color == ANSI_COLOR_WHITE)
+ flags |= TEM_ATTR_BRIGHT_BG;
+
+ if (pcolor->fg_color == ANSI_COLOR_BLACK)
+ flags &= ~TEM_ATTR_BRIGHT_BG;
+ } else {
+ /*
+ * In case of black on white we want bright white for BG.
+ */
+ if (pcolor->bg_color == ANSI_COLOR_WHITE)
+ flags |= TEM_ATTR_BRIGHT_BG;
+ }
+#endif
pcolor->a_flags = flags;
}
diff --git a/usr/src/uts/common/io/tem_safe.c b/usr/src/uts/common/io/tem_safe.c
index 5008d4a4d6..8d47a00d5f 100644
--- a/usr/src/uts/common/io/tem_safe.c
+++ b/usr/src/uts/common/io/tem_safe.c
@@ -129,9 +129,12 @@ static void tem_safe_copy_area(struct tem_vt_state *tem,
screen_pos_t e_col, screen_pos_t e_row,
screen_pos_t t_col, screen_pos_t t_row,
cred_t *credp, enum called_from called_from);
+#if 0
+/* Currently unused */
static void tem_safe_image_display(struct tem_vt_state *, uchar_t *,
int, int, screen_pos_t, screen_pos_t,
cred_t *, enum called_from);
+#endif
static void tem_safe_bell(struct tem_vt_state *tem,
enum called_from called_from);
static void tem_safe_pix_clear_prom_output(struct tem_vt_state *tem,
@@ -1568,6 +1571,7 @@ tem_safe_text_display(struct tem_vt_state *tem, term_char_t *string,
}
}
+#if 0
/*
* This function is used to blit a rectangular color image,
* unperturbed on the underlying framebuffer, to render
@@ -1600,6 +1604,7 @@ tem_safe_image_display(struct tem_vt_state *tem, uchar_t *image,
mutex_exit(&tem->tvs_lock);
mutex_exit(&tems.ts_lock);
}
+#endif
/*ARGSUSED*/
void
@@ -2385,12 +2390,22 @@ tem_safe_get_attr(struct tem_vt_state *tem, text_color_t *fg,
static void
tem_safe_get_color(text_color_t *fg, text_color_t *bg, term_char_t c)
{
+ boolean_t bold_font;
+
*fg = c.tc_fg_color;
*bg = c.tc_bg_color;
+ bold_font = tems.ts_font.vf_map_count[VFNT_MAP_BOLD] != 0;
+
+ /*
+ * If we have both normal and bold font components,
+ * we use bold font for TEM_ATTR_BOLD.
+ * The bright color is traditionally used with TEM_ATTR_BOLD,
+ * in case there is no bold font.
+ */
if (c.tc_fg_color < XLATE_NCOLORS) {
- if (TEM_ATTR_ISSET(c.tc_char,
- TEM_ATTR_BRIGHT_FG | TEM_ATTR_BOLD))
+ if (TEM_ATTR_ISSET(c.tc_char, TEM_ATTR_BRIGHT_FG) ||
+ (TEM_ATTR_ISSET(c.tc_char, TEM_ATTR_BOLD) && !bold_font))
*fg = brt_xlate[c.tc_fg_color];
else
*fg = dim_xlate[c.tc_fg_color];
diff --git a/usr/src/uts/common/sys/font.h b/usr/src/uts/common/sys/font.h
index 5733686bf3..f8f154f428 100644
--- a/usr/src/uts/common/sys/font.h
+++ b/usr/src/uts/common/sys/font.h
@@ -84,9 +84,11 @@ typedef struct bitmap_data {
} bitmap_data_t;
typedef enum {
- FONT_AUTO,
- FONT_MANUAL,
- FONT_BOOT
+ FONT_AUTO, /* This font is loaded by software */
+ FONT_MANUAL, /* This font is loaded manually by user */
+ FONT_BOOT, /* This font was passed to kernel by bootloader */
+ FONT_BUILTIN, /* This font was built in at compile time */
+ FONT_RELOAD /* This font is marked to be re-read from file */
} FONT_FLAGS;
struct fontlist {
diff --git a/usr/src/uts/i86pc/boot/boot_fb.c b/usr/src/uts/i86pc/boot/boot_fb.c
index 1ac4789af7..e0e79bd14e 100644
--- a/usr/src/uts/i86pc/boot/boot_fb.c
+++ b/usr/src/uts/i86pc/boot/boot_fb.c
@@ -354,28 +354,44 @@ boot_get_color(uint32_t *fg, uint32_t *bg)
/* ansi to solaris colors, see also boot_console.c */
if (fb_info.inverse == B_TRUE ||
fb_info.inverse_screen == B_TRUE) {
- if (fb_info.fg_color < 16)
- *bg = dim_xlate[fb_info.fg_color];
- else
+ if (fb_info.fg_color < XLATE_NCOLORS) {
+ /*
+ * white fg -> bright white bg
+ */
+ if (fb_info.fg_color == pc_white)
+ *bg = brt_xlate[fb_info.fg_color];
+ else
+ *bg = dim_xlate[fb_info.fg_color];
+ } else {
*bg = fb_info.fg_color;
+ }
- if (fb_info.bg_color < 16)
- *fg = brt_xlate[fb_info.bg_color];
- else
+ if (fb_info.bg_color < XLATE_NCOLORS) {
+ if (fb_info.bg_color == pc_white)
+ *fg = brt_xlate[fb_info.bg_color];
+ else
+ *fg = dim_xlate[fb_info.bg_color];
+ } else {
*fg = fb_info.bg_color;
+ }
} else {
- if (fb_info.bg_color < 16) {
- if (fb_info.bg_color == 7)
+ if (fb_info.fg_color < XLATE_NCOLORS) {
+ if (fb_info.fg_color == pc_white)
+ *fg = brt_xlate[fb_info.fg_color];
+ else
+ *fg = dim_xlate[fb_info.fg_color];
+ } else {
+ *fg = fb_info.fg_color;
+ }
+
+ if (fb_info.bg_color < XLATE_NCOLORS) {
+ if (fb_info.bg_color == pc_white)
*bg = brt_xlate[fb_info.bg_color];
else
*bg = dim_xlate[fb_info.bg_color];
} else {
*bg = fb_info.bg_color;
}
- if (fb_info.fg_color < 16)
- *fg = dim_xlate[fb_info.fg_color];
- else
- *fg = fb_info.fg_color;
}
}
diff --git a/usr/src/uts/intel/tem/Makefile b/usr/src/uts/intel/tem/Makefile
index 9eca2e7d98..1165cf3264 100644
--- a/usr/src/uts/intel/tem/Makefile
+++ b/usr/src/uts/intel/tem/Makefile
@@ -38,7 +38,6 @@ UTSBASE = ../..
#
MODULE = tem
OBJECTS = $(TEM_OBJS:%=$(OBJS_DIR)/%)
-LINTS = $(TEM_OBJS:%.o=$(LINTS_DIR)/%.ln)
ROOTMODULE = $(ROOT_MISC_DIR)/$(MODULE)
#
@@ -50,22 +49,11 @@ include $(UTSBASE)/intel/Makefile.intel
# Define targets
#
ALL_TARGET = $(BINARY)
-LINT_TARGET = $(MODULE).lint
INSTALL_TARGET = $(BINARY) $(ROOTMODULE)
LDFLAGS += -dy -Ndacf/consconfig_dacf
#
-# For now, disable these lint checks; maintainers should endeavor
-# to investigate and remove these for maximum lint coverage.
-# Please do not carry these forward to new Makefiles.
-#
-LINTTAGS += -erroff=E_STATIC_UNUSED
-
-CERRWARN += -_gcc=-Wno-unused-function
-CERRWARN += $(CNOWARN_UNINIT)
-
-#
# Default build targets.
#
.KEEP_STATE:
@@ -78,12 +66,6 @@ clean: $(CLEAN_DEPS)
clobber: $(CLOBBER_DEPS)
-lint: $(LINT_DEPS)
-
-modlintlib: $(MODLINTLIB_DEPS)
-
-clean.lint: $(CLEAN_LINT_DEPS)
-
install: $(INSTALL_DEPS)
#
diff --git a/usr/src/uts/sparc/tem/Makefile b/usr/src/uts/sparc/tem/Makefile
index 12d9741c56..ee46e5852d 100644
--- a/usr/src/uts/sparc/tem/Makefile
+++ b/usr/src/uts/sparc/tem/Makefile
@@ -40,9 +40,6 @@ UTSBASE = ../..
#
MODULE = tem
OBJECTS = $(TEM_OBJS:%=$(OBJS_DIR)/%) $(FONT_OBJS:%=$(OBJS_DIR)/%)
-
-LINTS = $(TEM_OBJS:%.o=$(LINTS_DIR)/%.ln)
-LINTS += $(FONT_OBJS:%.o=$(LINTS_DIR)/%.ln)
ROOTMODULE = $(ROOT_MISC_DIR)/$(MODULE)
#
@@ -54,24 +51,11 @@ include $(UTSBASE)/sparc/Makefile.sparc
# Define targets
#
ALL_TARGET = $(BINARY)
-LINT_TARGET = $(MODULE).lint
INSTALL_TARGET = $(BINARY) $(ROOTMODULE)
-CFLAGS += $(CCVERBOSE)
-
LDFLAGS += -dy -Ndacf/consconfig_dacf
#
-# For now, disable these lint checks; maintainers should endeavor
-# to investigate and remove these for maximum lint coverage.
-# Please do not carry these forward to new Makefiles.
-#
-LINTTAGS += -erroff=E_STATIC_UNUSED
-
-CERRWARN += -_gcc=-Wno-unused-function
-CERRWARN += $(CNOWARN_UNINIT)
-
-#
# Default build targets.
#
.KEEP_STATE:
@@ -84,19 +68,9 @@ clean: $(CLEAN_DEPS)
clobber: $(CLOBBER_DEPS)
-lint: $(LINT_DEPS)
-
-modlintlib: $(MODLINTLIB_DEPS)
-
-clean.lint: $(CLEAN_LINT_DEPS)
-
install: $(INSTALL_DEPS)
#
# Include common targets.
#
include $(UTSBASE)/sparc/Makefile.targ
-
-CLOBBERFILES += \
- $(OBJS_DIR)/$(VGATEXT_FONT).o \
- $(OBJS_DIR)/$(VGATEXT_FONT).c