Print this page
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
    loader: pxe receive cleanup
    9475 libefi: Do not return only if ReceiveFilter
    installboot: should support efi system partition
    8931 boot1.efi: scan all display modes rather than
    loader: spinconsole updates
    loader: gfx experiment to try GOP Blt() function.
    sha1 build test
    loader: add sha1 hash calculation
    common/sha1: update for loader build
    loader: biosdisk rework
    uts: 32-bit kernel FB needs mapping in low memory
    uts: add diag-device
    uts: boot console mirror with diag-device
    uts: enable very early console on ttya
    kmdb: add diag-device as input/output device
    uts: test VGA memory exclusion from mapping
    uts: clear boot mapping and protect boot pages test
    uts: add dboot map debug printf
    uts: need to release FB pages in release_bootstrap()
    uts: add screenmap ioctl
    uts: update sys/queue.h
    loader: add illumos uts/common to include path
    loader: tem/gfx font cleanup
    loader: vbe checks
    uts: gfx_private set KD_TEXT when KD_RESETTEXT is
    uts: gfx 8-bit update
    loader: gfx 8-bit fix
    loader: always set media size from partition.
    uts: MB2 support for 32-bit kernel
    loader: x86 should have tem 80x25
    uts: x86 should have tem 80x25
    uts: font update
    loader: font update
    uts: tem attributes
    loader: tem.c comment added
    uts: use font module
    loader: add font module
    loader: build rules for new font setup
    uts: gfx_private update for new font structure
    uts: early boot update for new font structure
    uts: font update
    uts: font build rules update for new fonts
    uts: tem update to new font structure
    loader: module.c needs to include tem_impl.h
    uts: gfx_private 8x16 font rework
    uts: make font_lookup public
    loader: font rework
    uts: font rework
    9259 libefi: efi_alloc_and_read should check for PMBR
    uts: tem utf-8 support
    loader: implement tem utf-8 support
    loader: tem should be able to display UTF-8
    7784 uts: console input should support utf-8
    7796 uts: ldterm default to utf-8
    uts: do not reset serial console
    uts: set up colors even if tem is not console
    uts: add type for early boot properties
    uts: gfx_private experiment with drm and vga
    uts: gfx_private should use setmode drm callback.
    uts: identify FB types and set up gfx_private based
    loader: replace gop and vesa with framebuffer
    uts: boot needs simple tem to support mdb
    uts: boot_keyboard should emit esc sequences for
    uts: gfx_private FB showuld be written by line
    kmdb: set terminal window size
    uts: gfx_private needs to keep track of early boot FB
    pnglite: move pnglite to usr/src/common
    loader: gfx_fb
    ficl-sys: add gfx primitives
    loader: add illumos.png logo
    ficl: add fb-putimage
    loader: add png support
    loader: add alpha blending for gfx_fb
    loader: use term-drawrect for menu frame
    ficl: add simple gfx words
    uts: provide fb_info via fbgattr dev_specific array.
    uts: gfx_private add alpha blending
    uts: update sys/ascii.h
    uts: tem OSC support (incomplete)
    uts: implement env module support and use data from
    uts: tem get colors from early boot data
    loader: use crc32 from libstand (libz)
    loader: optimize for size
    loader: pass tem info to the environment
    loader: import tem for loader console
    loader: UEFI loader needs to set ISADIR based on
    loader: need UEFI32 support
    8918 loader.efi: add vesa edid support
    uts: tem_safe_pix_clear_prom_output() should only
    uts: tem_safe_pix_clear_entire_screen() should use
    uts: tem_safe_check_first_time() should query cursor
    uts: tem implement cls callback & visual_io v4
    uts: gfx_vgatext use block cursor for vgatext
    uts: gfx_private implement cls callback & visual_io
    uts: gfx_private bitmap framebuffer implementation
    uts: early start frame buffer console support
    uts: font functions should check the input char
    uts: font rendering should support 16/24/32bit depths
    uts: use smallest font as fallback default.
    uts: update terminal dimensions based on selected
    7834 uts: vgatext should use gfx_private
    uts: add spacing property to 8859-1.bdf
    terminfo: add underline for sun-color
    terminfo: sun-color has 16 colors
    uts: add font load callback type
    loader: do not repeat int13 calls with error 0x20 and
    8905 loader: add skein/edonr support
    8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Revert "NEX-16819 loader UEFI support"
This reverts commit ec06b9fc617b99234e538bf2e7e4d02a24993e0c.
Reverting due to failures in the zfs-tests and the sharefs-tests
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
    loader: pxe receive cleanup
    9475 libefi: Do not return only if ReceiveFilter
    installboot: should support efi system partition
    8931 boot1.efi: scan all display modes rather than
    loader: spinconsole updates
    loader: gfx experiment to try GOP Blt() function.
    sha1 build test
    loader: add sha1 hash calculation
    common/sha1: update for loader build
    loader: biosdisk rework
    uts: 32-bit kernel FB needs mapping in low memory
    uts: add diag-device
    uts: boot console mirror with diag-device
    uts: enable very early console on ttya
    kmdb: add diag-device as input/output device
    uts: test VGA memory exclusion from mapping
    uts: clear boot mapping and protect boot pages test
    uts: add dboot map debug printf
    uts: need to release FB pages in release_bootstrap()
    uts: add screenmap ioctl
    uts: update sys/queue.h
    loader: add illumos uts/common to include path
    loader: tem/gfx font cleanup
    loader: vbe checks
    uts: gfx_private set KD_TEXT when KD_RESETTEXT is
    uts: gfx 8-bit update
    loader: gfx 8-bit fix
    loader: always set media size from partition.
    uts: MB2 support for 32-bit kernel
    loader: x86 should have tem 80x25
    uts: x86 should have tem 80x25
    uts: font update
    loader: font update
    uts: tem attributes
    loader: tem.c comment added
    uts: use font module
    loader: add font module
    loader: build rules for new font setup
    uts: gfx_private update for new font structure
    uts: early boot update for new font structure
    uts: font update
    uts: font build rules update for new fonts
    uts: tem update to new font structure
    loader: module.c needs to include tem_impl.h
    uts: gfx_private 8x16 font rework
    uts: make font_lookup public
    loader: font rework
    uts: font rework
    libefi: efi_alloc_and_read should check for PMBR
    uts: tem utf-8 support
    loader: implement tem utf-8 support
    loader: tem should be able to display UTF-8
    7784 uts: console input should support utf-8
    7796 uts: ldterm default to utf-8
    uts: do not reset serial console
    uts: set up colors even if tem is not console
    uts: add type for early boot properties
    uts: gfx_private experiment with drm and vga
    uts: gfx_private should use setmode drm callback.
    uts: identify FB types and set up gfx_private based
    loader: replace gop and vesa with framebuffer
    uts: boot needs simple tem to support mdb
    uts: boot_keyboard should emit esc sequences for
    uts: gfx_private FB showuld be written by line
    kmdb: set terminal window size
    uts: gfx_private needs to keep track of early boot FB
    pnglite: move pnglite to usr/src/common
    loader: gfx_fb
    ficl-sys: add gfx primitives
    loader: add illumos.png logo
    ficl: add fb-putimage
    loader: add png support
    loader: add alpha blending for gfx_fb
    loader: use term-drawrect for menu frame
    ficl: add simple gfx words
    uts: provide fb_info via fbgattr dev_specific array.
    uts: gfx_private add alpha blending
    uts: update sys/ascii.h
    uts: tem OSC support (incomplete)
    uts: implement env module support and use data from
    uts: tem get colors from early boot data
    loader: use crc32 from libstand (libz)
    loader: optimize for size
    loader: pass tem info to the environment
    loader: import tem for loader console
    loader: UEFI loader needs to set ISADIR based on
    loader: need UEFI32 support
    8918 loader.efi: add vesa edid support
    uts: tem_safe_pix_clear_prom_output() should only
    uts: tem_safe_pix_clear_entire_screen() should use
    uts: tem_safe_check_first_time() should query cursor
    uts: tem implement cls callback & visual_io v4
    uts: gfx_vgatext use block cursor for vgatext
    uts: gfx_private implement cls callback & visual_io
    uts: gfx_private bitmap framebuffer implementation
    uts: early start frame buffer console support
    uts: font functions should check the input char
    uts: font rendering should support 16/24/32bit depths
    uts: use smallest font as fallback default.
    uts: update terminal dimensions based on selected
    7834 uts: vgatext should use gfx_private
    uts: add spacing property to 8859-1.bdf
    terminfo: add underline for sun-color
    terminfo: sun-color has 16 colors
    uts: add font load callback type
    loader: do not repeat int13 calls with error 0x20 and
    8905 loader: add skein/edonr support
    8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>

@@ -119,11 +119,11 @@
         &mod_miscops,   /* modops */
         "ANSI Terminal Emulator", /* name */
 };
 
 static struct modlinkage modlinkage = {
-        MODREV_1, (void *)&modlmisc, NULL
+        MODREV_1, { (void *)&modlmisc, NULL }
 };
 
 int
 _init(void)
 {

@@ -207,66 +207,68 @@
 
 static void
 tem_internal_init(struct tem_vt_state *ptem, cred_t *credp,
     boolean_t init_color, boolean_t clear_screen)
 {
-        int i, j;
-        int width, height;
-        int total;
+        unsigned i, j, width, height;
+        text_attr_t attr;
         text_color_t fg;
         text_color_t bg;
-        size_t  tc_size = sizeof (text_color_t);
 
         ASSERT(MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&ptem->tvs_lock));
 
         if (tems.ts_display_mode == VIS_PIXEL) {
                 ptem->tvs_pix_data_size = tems.ts_pix_data_size;
                 ptem->tvs_pix_data =
                     kmem_alloc(ptem->tvs_pix_data_size, KM_SLEEP);
         }
 
-        ptem->tvs_outbuf_size = tems.ts_c_dimension.width;
-        ptem->tvs_outbuf =
-            (unsigned char *)kmem_alloc(ptem->tvs_outbuf_size, KM_SLEEP);
+        ptem->tvs_outbuf_size = tems.ts_c_dimension.width *
+            sizeof (*ptem->tvs_outbuf);
+        ptem->tvs_outbuf = kmem_alloc(ptem->tvs_outbuf_size, KM_SLEEP);
 
         width = tems.ts_c_dimension.width;
         height = tems.ts_c_dimension.height;
-        ptem->tvs_screen_buf_size = width * height;
-        ptem->tvs_screen_buf =
-            (unsigned char *)kmem_alloc(width * height, KM_SLEEP);
+        ptem->tvs_screen_history_size = height;
 
-        total = width * height * tc_size;
-        ptem->tvs_fg_buf = (text_color_t *)kmem_alloc(total, KM_SLEEP);
-        ptem->tvs_bg_buf = (text_color_t *)kmem_alloc(total, KM_SLEEP);
-        ptem->tvs_color_buf_size = total;
+        ptem->tvs_screen_buf_size = width * ptem->tvs_screen_history_size *
+            sizeof (*ptem->tvs_screen_buf);
+        ptem->tvs_screen_buf = kmem_alloc(ptem->tvs_screen_buf_size, KM_SLEEP);
+        ptem->tvs_screen_rows = kmem_alloc(ptem->tvs_screen_history_size *
+            sizeof (term_char_t *), KM_SLEEP);
 
         tem_safe_reset_display(ptem, credp, CALLED_FROM_NORMAL,
             clear_screen, init_color);
 
         ptem->tvs_utf8_left = 0;
         ptem->tvs_utf8_partial = 0;
 
-        tem_safe_get_color(ptem, &fg, &bg, TEM_ATTR_SCREEN_REVERSE);
-        for (i = 0; i < height; i++)
+        /* Get default attributes and fill up the screen buffer. */
+        tem_safe_get_attr(ptem, &fg, &bg, &attr, TEM_ATTR_SCREEN_REVERSE);
+        for (i = 0; i < ptem->tvs_screen_history_size; i++) {
+                ptem->tvs_screen_rows[i] = &ptem->tvs_screen_buf[i * width];
+
                 for (j = 0; j < width; j++) {
-                        ptem->tvs_screen_buf[i * width + j] = ' ';
-                        ptem->tvs_fg_buf[(i * width +j) * tc_size] = fg;
-                        ptem->tvs_bg_buf[(i * width +j) * tc_size] = bg;
+                        ptem->tvs_screen_rows[i][j].tc_fg_color = fg;
+                        ptem->tvs_screen_rows[i][j].tc_bg_color = bg;
+                        ptem->tvs_screen_rows[i][j].tc_char =
+                            TEM_ATTR(attr) | ' ';
 
                 }
+        }
 
-        ptem->tvs_initialized  = 1;
+        ptem->tvs_initialized = B_TRUE;
 }
 
 int
 tem_initialized(tem_vt_state_t tem_arg)
 {
         struct tem_vt_state *ptem = (struct tem_vt_state *)tem_arg;
         int ret;
 
         mutex_enter(&ptem->tvs_lock);
-        ret = ptem->tvs_initialized;
+        ret = ptem->tvs_initialized == B_TRUE? 1 : 0;
         mutex_exit(&ptem->tvs_lock);
 
         return (ret);
 }
 

@@ -286,11 +288,11 @@
 
         /*
          * A tem is regarded as initialized only after tem_internal_init(),
          * will be set at the end of tem_internal_init().
          */
-        ptem->tvs_initialized = 0;
+        ptem->tvs_initialized = B_FALSE;
 
 
         if (!tems.ts_initialized) {
                 /*
                  * Only happens during early console configuration.

@@ -333,14 +335,14 @@
                 kmem_free(tem->tvs_outbuf, tem->tvs_outbuf_size);
         if (tem->tvs_pix_data != NULL)
                 kmem_free(tem->tvs_pix_data, tem->tvs_pix_data_size);
         if (tem->tvs_screen_buf != NULL)
                 kmem_free(tem->tvs_screen_buf, tem->tvs_screen_buf_size);
-        if (tem->tvs_fg_buf != NULL)
-                kmem_free(tem->tvs_fg_buf, tem->tvs_color_buf_size);
-        if (tem->tvs_bg_buf != NULL)
-                kmem_free(tem->tvs_bg_buf, tem->tvs_color_buf_size);
+        if (tem->tvs_screen_rows != NULL) {
+                kmem_free(tem->tvs_screen_rows, tem->tvs_screen_history_size *
+                    sizeof (term_char_t *));
+        }
 }
 
 void
 tem_destroy(tem_vt_state_t tem_arg, cred_t *credp)
 {

@@ -456,10 +458,11 @@
                 return (ret);
         }
 
         /* other sanity checks */
         if (!((temargs.depth == 4) || (temargs.depth == 8) ||
+            (temargs.depth == 15) || (temargs.depth == 16) ||
             (temargs.depth == 24) || (temargs.depth == 32))) {
                 cmn_err(CE_WARN, "terminal emulator: unsupported depth");
                 ret = tems_failed(credp, B_TRUE);
                 mutex_exit(&tems.ts_lock);
                 return (ret);

@@ -523,18 +526,21 @@
 }
 
 static void
 tems_setup_terminal(struct vis_devinit *tp, size_t height, size_t width)
 {
+        bitmap_data_t *font_data;
         int i;
-        int old_blank_buf_size = tems.ts_c_dimension.width;
+        int old_blank_buf_size = tems.ts_c_dimension.width *
+            sizeof (*tems.ts_blank_line);
 
         ASSERT(MUTEX_HELD(&tems.ts_lock));
 
         tems.ts_pdepth = tp->depth;
         tems.ts_linebytes = tp->linebytes;
         tems.ts_display_mode = tp->mode;
+        tems.ts_color_map = tp->color_map;
 
         switch (tp->mode) {
         case VIS_TEXT:
                 tems.ts_p_dimension.width = 0;
                 tems.ts_p_dimension.height = 0;

@@ -566,23 +572,32 @@
                  * 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.
                  */
-                set_font(&tems.ts_font,
-                    &tems.ts_c_dimension.height,
+                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.ts_p_offset.y = (tems.ts_p_dimension.height -
-                    (tems.ts_c_dimension.height * tems.ts_font.height)) / 2;
+                    (tems.ts_c_dimension.height * tems.ts_font.vf_height)) / 2;
                 tems.ts_p_offset.x = (tems.ts_p_dimension.width -
-                    (tems.ts_c_dimension.width * tems.ts_font.width)) / 2;
+                    (tems.ts_c_dimension.width * tems.ts_font.vf_width)) / 2;
 
                 tems.ts_pix_data_size =
-                    tems.ts_font.width * tems.ts_font.height;
+                    tems.ts_font.vf_width * tems.ts_font.vf_height;
 
                 tems.ts_pix_data_size *= 4;
 
                 tems.ts_pdepth = tp->depth;
 

@@ -591,14 +606,12 @@
 
         /* Now virtual cls also uses the blank_line buffer */
         if (tems.ts_blank_line)
                 kmem_free(tems.ts_blank_line, old_blank_buf_size);
 
-        tems.ts_blank_line = (unsigned char *)
-            kmem_alloc(tems.ts_c_dimension.width, KM_SLEEP);
-        for (i = 0; i < tems.ts_c_dimension.width; i++)
-                tems.ts_blank_line[i] = ' ';
+        tems.ts_blank_line = kmem_alloc(tems.ts_c_dimension.width *
+            sizeof (*tems.ts_blank_line), KM_SLEEP);
 }
 
 /*
  * This is a callback function that we register with the frame
  * buffer driver layered underneath.  It gets invoked from

@@ -677,17 +690,31 @@
         mutex_exit(&tems.ts_lock);
         cb(cb_arg);
 }
 
 /*
+ * This function is used to clear entire screen via the underlying framebuffer
+ * driver.
+ */
+int
+tems_cls_layered(struct vis_consclear *pda,
+    cred_t *credp)
+{
+        int rval;
+
+        (void) ldi_ioctl(tems.ts_hdl, VIS_CONSCLEAR,
+            (intptr_t)pda, FKIOCTL, credp, &rval);
+        return (rval);
+}
+
+/*
  * This function is used to display a rectangular blit of data
  * of a given size and location via the underlying framebuffer driver.
  * The blit can be as small as a pixel or as large as the screen.
  */
 void
-tems_display_layered(
-        struct vis_consdisplay *pda,
+tems_display_layered(struct vis_consdisplay *pda,
         cred_t *credp)
 {
         int rval;
 
         (void) ldi_ioctl(tems.ts_hdl, VIS_CONSDISPLAY,

@@ -699,12 +726,11 @@
  * underlying framebuffer driver.  Rectangle copies are how scrolling
  * is implemented, as well as horizontal text shifting escape seqs.
  * such as from vi when deleting characters and words.
  */
 void
-tems_copy_layered(
-        struct vis_conscopy *pma,
+tems_copy_layered(struct vis_conscopy *pma,
         cred_t *credp)
 {
         int rval;
 
         (void) ldi_ioctl(tems.ts_hdl, VIS_CONSCOPY,

@@ -714,12 +740,11 @@
 /*
  * This function is used to show or hide a rectangluar monochrom
  * pixel inverting, text block cursor via the underlying framebuffer.
  */
 void
-tems_cursor_layered(
-        struct vis_conscursor *pca,
+tems_cursor_layered(struct vis_conscursor *pca,
         cred_t *credp)
 {
         int rval;
 
         (void) ldi_ioctl(tems.ts_hdl, VIS_CONSCURSOR,

@@ -747,13 +772,16 @@
 
         switch (tems.ts_pdepth) {
         case 8:
                 cm.index = 0;
                 cm.count = 16;
-                cm.red   = cmap4_to_24.red;   /* 8-bits (1/3 of TrueColor 24) */
-                cm.blue  = cmap4_to_24.blue;  /* 8-bits (1/3 of TrueColor 24) */
-                cm.green = cmap4_to_24.green; /* 8-bits (1/3 of TrueColor 24) */
+                /* 8-bits (1/3 of TrueColor 24) */
+                cm.red   = (uint8_t *)cmap4_to_24.red;
+                /* 8-bits (1/3 of TrueColor 24) */
+                cm.blue  = (uint8_t *)cmap4_to_24.blue;
+                /* 8-bits (1/3 of TrueColor 24) */
+                cm.green = (uint8_t *)cmap4_to_24.green;
                 (void) ldi_ioctl(tems.ts_hdl, VIS_PUTCMAP, (intptr_t)&cm,
                     FKIOCTL, credp, &rval);
                 break;
         }
 }

@@ -790,11 +818,11 @@
 {
         struct vis_conscopy     ma;
         int     ncols, width;
 
         /* copy */
-        ma.s_row = nrows * tems.ts_font.height;
+        ma.s_row = nrows * tems.ts_font.vf_height;
         ma.e_row = tems.ts_p_dimension.height - 1;
         ma.t_row = 0;
 
         ma.s_col = 0;
         ma.e_col = tems.ts_p_dimension.width - 1;

@@ -801,11 +829,11 @@
         ma.t_col = 0;
 
         tems_safe_copy(&ma, credp, called_from);
 
         /* clear */
-        width = tems.ts_font.width;
+        width = tems.ts_font.vf_width;
         ncols = (tems.ts_p_dimension.width + (width - 1))/ width;
 
         tem_safe_pix_cls_range(tem, 0, nrows, tems.ts_p_offset.y,
             0, ncols, 0, B_TRUE, credp, called_from);
 }

@@ -833,12 +861,12 @@
         if (prom_window_top == 0)
                 prom_window_top = PROM_DEFAULT_WINDOW_TOP;
 
         tem_y = (prom_row + 1) * prom_charheight + prom_window_top -
             tems.ts_p_offset.y;
-        tem_row = (tem_y + tems.ts_font.height - 1) /
-            tems.ts_font.height - 1;
+        tem_row = (tem_y + tems.ts_font.vf_height - 1) /
+            tems.ts_font.vf_height - 1;
 
         if (tem_row < 0) {
                 tem_row = 0;
         } else if (tem_row >= (tems.ts_c_dimension.height - 1)) {
                 /*

@@ -912,12 +940,14 @@
         boolean_t inverse, inverse_screen;
         unsigned short  flags = 0;
 
         pcolor->fg_color = DEFAULT_ANSI_FOREGROUND;
         pcolor->bg_color = DEFAULT_ANSI_BACKGROUND;
+#ifndef _HAVE_TEM_FIRMWARE
+        plat_tem_get_colors(&pcolor->fg_color, &pcolor->bg_color);
+#endif
 
-        if (plat_stdout_is_framebuffer()) {
                 tems_get_inverses(&inverse, &inverse_screen);
                 if (inverse)
                         flags |= TEM_ATTR_REVERSE;
                 if (inverse_screen)
                         flags |= TEM_ATTR_SCREEN_REVERSE;

@@ -937,11 +967,10 @@
                          * match it here.
                          */
                         if (pcolor->bg_color == ANSI_COLOR_WHITE)
                                 flags |= TEM_ATTR_BRIGHT_BG;
                 }
-        }
 
         pcolor->a_flags = flags;
 }
 
 uchar_t