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>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/tem_safe.c
          +++ new/usr/src/uts/common/io/tem_safe.c
↓ open down ↓ 79 lines elided ↑ open up ↑
  80   80          &tem_safe_text_cls
  81   81  };
  82   82  tem_safe_callbacks_t tem_safe_pix_callbacks = {
  83   83          &tem_safe_pix_display,
  84   84          &tem_safe_pix_copy,
  85   85          &tem_safe_pix_cursor,
  86   86          &tem_safe_pix_bit2pix,
  87   87          &tem_safe_pix_cls
  88   88  };
  89   89  
  90      -
  91      -static void     tem_safe_control(struct tem_vt_state *, uchar_t,
       90 +static void     tem_safe_control(struct tem_vt_state *, tem_char_t,
  92   91                          cred_t *, enum called_from);
  93   92  static void     tem_safe_setparam(struct tem_vt_state *, int, int);
  94   93  static void     tem_safe_selgraph(struct tem_vt_state *);
  95      -static void     tem_safe_chkparam(struct tem_vt_state *, uchar_t,
       94 +static void     tem_safe_chkparam(struct tem_vt_state *, tem_char_t,
  96   95                          cred_t *, enum called_from);
  97      -static void     tem_safe_getparams(struct tem_vt_state *, uchar_t,
       96 +static void     tem_safe_getparams(struct tem_vt_state *, tem_char_t,
  98   97                          cred_t *, enum called_from);
  99      -static void     tem_safe_outch(struct tem_vt_state *, uchar_t,
       98 +static void     tem_safe_outch(struct tem_vt_state *, tem_char_t,
 100   99                          cred_t *, enum called_from);
 101      -static void     tem_safe_parse(struct tem_vt_state *, uchar_t,
      100 +static void     tem_safe_parse(struct tem_vt_state *, tem_char_t,
 102  101                          cred_t *, enum called_from);
 103  102  
 104  103  static void     tem_safe_new_line(struct tem_vt_state *,
 105  104                          cred_t *, enum called_from);
 106  105  static void     tem_safe_cr(struct tem_vt_state *);
 107  106  static void     tem_safe_lf(struct tem_vt_state *,
 108  107                          cred_t *, enum called_from);
 109  108  static void     tem_safe_send_data(struct tem_vt_state *, cred_t *,
 110  109                          enum called_from);
 111  110  static void     tem_safe_cls(struct tem_vt_state *,
↓ open down ↓ 18 lines elided ↑ open up ↑
 130  129                          screen_pos_t e_col, screen_pos_t e_row,
 131  130                          screen_pos_t t_col, screen_pos_t t_row,
 132  131                          cred_t *credp, enum called_from called_from);
 133  132  static void     tem_safe_image_display(struct tem_vt_state *, uchar_t *,
 134  133                          int, int, screen_pos_t, screen_pos_t,
 135  134                          cred_t *, enum called_from);
 136  135  static void     tem_safe_bell(struct tem_vt_state *tem,
 137  136                          enum called_from called_from);
 138  137  static void     tem_safe_pix_clear_prom_output(struct tem_vt_state *tem,
 139  138                          cred_t *credp, enum called_from called_from);
      139 +static void     tem_safe_get_color(text_color_t *, text_color_t *, term_char_t);
 140  140  
 141  141  static void     tem_safe_virtual_cls(struct tem_vt_state *, int, screen_pos_t,
 142  142                      screen_pos_t);
 143  143  static void     tem_safe_virtual_display(struct tem_vt_state *,
 144      -                    unsigned char *, int, screen_pos_t, screen_pos_t,
 145      -                    text_color_t, text_color_t);
      144 +                    term_char_t *, int, screen_pos_t, screen_pos_t);
 146  145  static void     tem_safe_virtual_copy(struct tem_vt_state *, screen_pos_t,
 147  146                      screen_pos_t, screen_pos_t, screen_pos_t,
 148  147                      screen_pos_t, screen_pos_t);
 149  148  static void     tem_safe_align_cursor(struct tem_vt_state *tem);
 150      -static void     bit_to_pix4(struct tem_vt_state *tem, uchar_t c,
      149 +static void     bit_to_pix4(struct tem_vt_state *tem, tem_char_t c,
 151  150                      text_color_t fg_color, text_color_t bg_color);
 152      -static void     bit_to_pix8(struct tem_vt_state *tem, uchar_t c,
      151 +static void     bit_to_pix8(struct tem_vt_state *tem, tem_char_t c,
 153  152                      text_color_t fg_color, text_color_t bg_color);
 154      -static void     bit_to_pix24(struct tem_vt_state *tem, uchar_t c,
      153 +static void     bit_to_pix16(struct tem_vt_state *tem, tem_char_t c,
 155  154                      text_color_t fg_color, text_color_t bg_color);
      155 +static void     bit_to_pix24(struct tem_vt_state *tem, tem_char_t c,
      156 +                    text_color_t fg_color, text_color_t bg_color);
      157 +static void     bit_to_pix32(struct tem_vt_state *tem, tem_char_t c,
      158 +                    text_color_t fg_color, text_color_t bg_color);
 156  159  
 157      -/* BEGIN CSTYLED */
 158      -/*                                  Bk  Rd  Gr  Br  Bl  Mg  Cy  Wh */
 159      -static text_color_t dim_xlate[] = {  1,  5,  3,  7,  2,  6,  4,  8 };
 160      -static text_color_t brt_xlate[] = {  9, 13, 11, 15, 10, 14, 12,  0 };
 161      -/* END CSTYLED */
 162      -
 163      -
 164      -text_cmap_t cmap4_to_24 = {
 165      -/* BEGIN CSTYLED */
 166      -/* 0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15
 167      -  Wh+  Bk   Bl   Gr   Cy   Rd   Mg   Br   Wh   Bk+  Bl+  Gr+  Cy+  Rd+  Mg+  Yw */
 168      -  0xff,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x40,0x00,0x00,0x00,0xff,0xff,0xff,
 169      -  0xff,0x00,0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x40,0x00,0xff,0xff,0x00,0x00,0xff,
 170      -  0xff,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x40,0xff,0x00,0xff,0x00,0xff,0x00
 171      -/* END CSTYLED */
 172      -};
 173      -
 174  160  #define PIX4TO32(pix4) (uint32_t)(  \
 175  161      cmap4_to_24.red[pix4] << 16 |  \
 176  162      cmap4_to_24.green[pix4] << 8 | \
 177  163      cmap4_to_24.blue[pix4])
 178  164  
 179  165  #define INVERSE(ch) (ch ^ 0xff)
 180  166  
 181  167  #define tem_safe_callback_display       (*tems.ts_callbacks->tsc_display)
 182  168  #define tem_safe_callback_copy          (*tems.ts_callbacks->tsc_copy)
 183  169  #define tem_safe_callback_cursor        (*tems.ts_callbacks->tsc_cursor)
 184  170  #define tem_safe_callback_cls           (*tems.ts_callbacks->tsc_cls)
 185      -#define tem_safe_callback_bit2pix(tem, c, fg, bg)       {               \
      171 +#define tem_safe_callback_bit2pix(tem, c)       {               \
 186  172          ASSERT(tems.ts_callbacks->tsc_bit2pix != NULL);                 \
 187      -        (void) (*tems.ts_callbacks->tsc_bit2pix)((tem), (c), (fg), (bg));\
      173 +        (void) (*tems.ts_callbacks->tsc_bit2pix)((tem), (c));\
 188  174  }
 189  175  
 190  176  void
 191  177  tem_safe_check_first_time(
 192  178      struct tem_vt_state *tem,
 193  179      cred_t *credp,
 194  180      enum called_from called_from)
 195  181  {
 196  182          static int first_time = 1;
 197  183  
↓ open down ↓ 3 lines elided ↑ open up ↑
 201  187          /*
 202  188           * Realign the console cursor. We did this in tem_init().
 203  189           * However, drivers in the console stream may emit additional
 204  190           * messages before we are ready. This causes text overwrite
 205  191           * on the screen. This is a workaround.
 206  192           */
 207  193          if (!first_time)
 208  194                  return;
 209  195  
 210  196          first_time = 0;
 211      -        if (tems.ts_display_mode == VIS_TEXT) {
      197 +        if (tems.ts_display_mode == VIS_TEXT)
 212  198                  tem_safe_text_cursor(tem, VIS_GET_CURSOR, credp, called_from);
 213      -                tem_safe_align_cursor(tem);
 214      -        }
      199 +        else
      200 +                tem_safe_pix_cursor(tem, VIS_GET_CURSOR, credp, called_from);
      201 +        tem_safe_align_cursor(tem);
 215  202  }
 216  203  
 217  204  /*
 218  205   * This entry point handles output requests from restricted contexts like
 219  206   * kmdb, where services like mutexes are not available. This function
 220  207   * is entered when OBP or when a kernel debugger (such as kmdb)
 221  208   * are generating console output.  In those cases, power management
 222  209   * concerns are handled by the abort sequence initiation (ie. when
 223  210   * the user hits L1+A or the equivalent to enter OBP or the debugger.).
 224  211   * It is also entered when the kernel is panicing.
↓ open down ↓ 17 lines elided ↑ open up ↑
 242  229  
 243  230          tem_safe_check_first_time(tem, kcred, CALLED_FROM_STANDALONE);
 244  231          tem_safe_terminal_emulate(tem, buf, len, NULL, CALLED_FROM_STANDALONE);
 245  232  }
 246  233  
 247  234  /* Process partial UTF-8 sequence. */
 248  235  static void
 249  236  tem_safe_input_partial(struct tem_vt_state *tem, cred_t *credp,
 250  237      enum called_from called_from)
 251  238  {
 252      -        int i;
      239 +        unsigned i;
 253  240          uint8_t c;
 254  241  
 255  242          if (tem->tvs_utf8_left == 0)
 256  243                  return;
 257  244  
 258  245          for (i = 0; i < sizeof (tem->tvs_utf8_partial); i++) {
 259  246                  c = (tem->tvs_utf8_partial >> (24 - (i << 3))) & 0xff;
 260  247                  if (c != 0) {
 261  248                          tem_safe_parse(tem, c, credp, called_from);
 262  249                  }
↓ open down ↓ 74 lines elided ↑ open up ↑
 337  324                                  b = (u >> 8) & 0xff;
 338  325                                  v = (v << 6) | (b & 0x3f);
 339  326                                  b = u & 0xff;
 340  327                                  v = (v << 6) | (b & 0x3f);
 341  328                          } else if ((b = (u >> 8) & 0xff) != 0) {
 342  329                                  v = b & 0x1f;   /* Two-byte sequence */
 343  330                                  b = u & 0xff;
 344  331                                  v = (v << 6) | (b & 0x3f);
 345  332                          }
 346  333  
 347      -                        /* Use '?' as replacement if needed. */
 348      -                        if (v > 0xff)
 349      -                                v = '?';
 350  334                          tem_safe_parse(tem, v, credp, called_from);
 351  335                          tem->tvs_utf8_partial = 0;
 352  336                  }
 353  337                  return;
 354  338          }
 355  339          /* Anything left is illegal in UTF-8 sequence. */
 356  340          tem_safe_input_partial(tem, credp, called_from);
 357  341          tem_safe_parse(tem, c, credp, called_from);
 358  342  }
 359  343  
↓ open down ↓ 79 lines elided ↑ open up ↑
 439  423          else
 440  424                  tems_cursor_layered(pca, credp);
 441  425  }
 442  426  
 443  427  /*
 444  428   * send the appropriate control message or set state based on the
 445  429   * value of the control character ch
 446  430   */
 447  431  
 448  432  static void
 449      -tem_safe_control(struct tem_vt_state *tem, uchar_t ch, cred_t *credp,
      433 +tem_safe_control(struct tem_vt_state *tem, tem_char_t ch, cred_t *credp,
 450  434      enum called_from called_from)
 451  435  {
 452  436          tem->tvs_state = A_STATE_START;
 453  437          switch (ch) {
 454  438          case A_BEL:
 455  439                  tem_safe_bell(tem, called_from);
 456  440                  break;
 457  441  
 458  442          case A_BS:
 459  443                  tem_safe_mv_cursor(tem,
↓ open down ↓ 38 lines elided ↑ open up ↑
 498  482                          tem->tvs_curparam = 0;
 499  483                          tem->tvs_paramval = 0;
 500  484                          tem->tvs_gotparam = B_FALSE;
 501  485                          /* clear the parameters */
 502  486                          for (i = 0; i < TEM_MAXPARAMS; i++)
 503  487                                  tem->tvs_params[i] = -1;
 504  488                          tem->tvs_state = A_STATE_CSI;
 505  489                  }
 506  490                  break;
 507  491  
      492 +        case A_OSC:
      493 +                {
      494 +                        int i;
      495 +                        tem->tvs_curparam = 0;
      496 +                        tem->tvs_paramval = 0;
      497 +                        tem->tvs_gotparam = B_FALSE;
      498 +                        /* clear the parameters */
      499 +                        for (i = 0; i < TEM_MAXPARAMS; i++)
      500 +                                tem->tvs_params[i] = -1;
      501 +                        tem->tvs_state = A_STATE_OSC;
      502 +                }
      503 +                break;
      504 +
 508  505          case A_GS:
 509  506                  tem_safe_back_tab(tem, credp, called_from);
 510  507                  break;
 511  508  
 512  509          default:
 513  510                  break;
 514  511          }
 515  512  }
 516  513  
 517  514  
↓ open down ↓ 40 lines elided ↑ open up ↑
 558  555                          break;
 559  556  
 560  557                  case 1: /* Bold Intense */
 561  558                          tem->tvs_flags |= TEM_ATTR_BOLD;
 562  559                          break;
 563  560  
 564  561                  case 2: /* Faint Intense */
 565  562                          tem->tvs_flags &= ~TEM_ATTR_BOLD;
 566  563                          break;
 567  564  
      565 +                case 4: /* Underline */
      566 +                        tem->tvs_flags |= TEM_ATTR_UNDERLINE;
      567 +                        break;
 568  568                  case 5: /* Blink */
 569  569                          tem->tvs_flags |= TEM_ATTR_BLINK;
 570  570                          break;
 571  571  
 572  572                  case 7: /* Reverse video */
 573  573                          if (tem->tvs_flags & TEM_ATTR_SCREEN_REVERSE) {
 574  574                                  tem->tvs_flags &= ~TEM_ATTR_REVERSE;
 575  575                          } else {
 576  576                                  tem->tvs_flags |= TEM_ATTR_REVERSE;
 577  577                          }
 578  578                          break;
 579  579  
      580 +                case 22: /* Remove Bold */
      581 +                        tem->tvs_flags &= ~TEM_ATTR_BOLD;
      582 +                        break;
      583 +
      584 +                case 24: /* Remove Underline */
      585 +                        tem->tvs_flags &= ~TEM_ATTR_UNDERLINE;
      586 +                        break;
      587 +
      588 +                case 25: /* Remove Blink */
      589 +                        tem->tvs_flags &= ~TEM_ATTR_BLINK;
      590 +                        break;
      591 +
      592 +                case 27: /* Remove Reverse */
      593 +                        if (tem->tvs_flags & TEM_ATTR_SCREEN_REVERSE) {
      594 +                                tem->tvs_flags |= TEM_ATTR_REVERSE;
      595 +                        } else {
      596 +                                tem->tvs_flags &= ~TEM_ATTR_REVERSE;
      597 +                        }
      598 +                        break;
      599 +
 580  600                  case 30: /* black       (grey)          foreground */
 581  601                  case 31: /* red         (light red)     foreground */
 582  602                  case 32: /* green       (light green)   foreground */
 583  603                  case 33: /* brown       (yellow)        foreground */
 584  604                  case 34: /* blue        (light blue)    foreground */
 585  605                  case 35: /* magenta     (light magenta) foreground */
 586  606                  case 36: /* cyan        (light cyan)    foreground */
 587  607                  case 37: /* white       (bright white)  foreground */
 588  608                          tem->tvs_fg_color = param - 30;
 589  609                          tem->tvs_flags &= ~TEM_ATTR_BRIGHT_FG;
↓ open down ↓ 66 lines elided ↑ open up ↑
 656  676          } while (curparam > 0);
 657  677  }
 658  678  
 659  679  /*
 660  680   * perform the appropriate action for the escape sequence
 661  681   *
 662  682   * General rule:  This code does not validate the arguments passed.
 663  683   *                It assumes that the next lower level will do so.
 664  684   */
 665  685  static void
 666      -tem_safe_chkparam(struct tem_vt_state *tem, uchar_t ch, cred_t *credp,
      686 +tem_safe_chkparam(struct tem_vt_state *tem, tem_char_t ch, cred_t *credp,
 667  687      enum called_from called_from)
 668  688  {
 669  689          int     i;
 670  690          int     row;
 671  691          int     col;
 672  692  
 673  693          ASSERT((called_from == CALLED_FROM_STANDALONE) ||
 674  694              MUTEX_HELD(&tem->tvs_lock));
 675  695  
 676  696          row = tem->tvs_c_cursor.row;
↓ open down ↓ 242 lines elided ↑ open up ↑
 919  939                  break;
 920  940          }
 921  941          tem->tvs_state = A_STATE_START;
 922  942  }
 923  943  
 924  944  
 925  945  /*
 926  946   * Gather the parameters of an ANSI escape sequence
 927  947   */
 928  948  static void
 929      -tem_safe_getparams(struct tem_vt_state *tem, uchar_t ch,
      949 +tem_safe_getparams(struct tem_vt_state *tem, tem_char_t ch,
 930  950      cred_t *credp, enum called_from called_from)
 931  951  {
 932  952          ASSERT((called_from == CALLED_FROM_STANDALONE) ||
 933  953              MUTEX_HELD(&tem->tvs_lock));
 934  954  
 935  955          if (ch >= '0' && ch <= '9') {
 936  956                  tem->tvs_paramval = ((tem->tvs_paramval * 10) + (ch - '0'));
 937  957                  tem->tvs_gotparam = B_TRUE;  /* Remember got parameter */
 938  958                  return; /* Return immediately */
 939  959          } else if (tem->tvs_state == A_STATE_CSI_EQUAL ||
↓ open down ↓ 14 lines elided ↑ open up ↑
 954  974                          tem->tvs_gotparam = B_FALSE;
 955  975                          tem->tvs_paramval = 0; /* No parame value yet */
 956  976                  } else {
 957  977                          /* Handle escape sequence */
 958  978                          tem_safe_chkparam(tem, ch, credp, called_from);
 959  979                  }
 960  980          }
 961  981  }
 962  982  
 963  983  /*
      984 + * Gather the OSC string.
      985 + * OSC Ps ; Pt ST
      986 + * OSC Ps ; Pt BEL
      987 + * Ps is number sequence identifying the function. We only support
      988 + * Ps = 4 and Ps = 104.
      989 + * Quite obviously this is nowhere close to be done;)
      990 + */
      991 +/* ARGSUSED */
      992 +static void
      993 +tem_safe_get_oscstring(struct tem_vt_state *tem, uchar_t ch,
      994 +    cred_t *credp __unused, enum called_from called_from)
      995 +{
      996 +        ASSERT((called_from == CALLED_FROM_STANDALONE) ||
      997 +            MUTEX_HELD(&tem->tvs_lock));
      998 +
      999 +        /* Should we cancel? */
     1000 +        if (ch == A_CAN || ch == A_SUB || ch == A_ESC) {
     1001 +                tem->tvs_state = A_STATE_START;
     1002 +                return;
     1003 +        }
     1004 +
     1005 +        /* following two if statements will read in the numeric parameter */
     1006 +        if (ch >= '0' && ch <= '9') {
     1007 +                tem->tvs_paramval = ((tem->tvs_paramval * 10) + (ch - '0'));
     1008 +                tem->tvs_gotparam = B_TRUE;  /* Remember got parameter */
     1009 +                return; /* Return immediately */
     1010 +        }
     1011 +
     1012 +        if (tem->tvs_gotparam && ch == ';') {
     1013 +                /* get the parameter value */
     1014 +                tem->tvs_params[tem->tvs_curparam] = tem->tvs_paramval;
     1015 +                tem->tvs_curparam++;
     1016 +                tem->tvs_gotparam = B_FALSE;
     1017 +                tem->tvs_paramval = 0;
     1018 +        }
     1019 +
     1020 +        if (tem->tvs_curparam == 0) {
     1021 +                /* bad sequence */
     1022 +                tem->tvs_state = A_STATE_START;
     1023 +                return;
     1024 +        }
     1025 +        if (tem->tvs_gotparam == B_FALSE && tem->tvs_curparam > 0) {
     1026 +                if (tem->tvs_params[0] != 4 && tem->tvs_params[0] != 104) {
     1027 +                        /* make sure tvs_params will not get filled up */
     1028 +                        tem->tvs_curparam = 1;
     1029 +                }
     1030 +        }
     1031 +        if (ch == A_ST || ch == A_BEL) {
     1032 +                /* done */
     1033 +                tem->tvs_state = A_STATE_START;
     1034 +                return;
     1035 +        }
     1036 +}
     1037 +
     1038 +/*
 964 1039   * Add character to internal buffer.
 965 1040   * When its full, send it to the next layer.
 966 1041   */
 967 1042  
 968 1043  static void
 969      -tem_safe_outch(struct tem_vt_state *tem, uchar_t ch,
     1044 +tem_safe_outch(struct tem_vt_state *tem, tem_char_t ch,
 970 1045      cred_t *credp, enum called_from called_from)
 971 1046  {
     1047 +        text_color_t fg;
     1048 +        text_color_t bg;
     1049 +        text_attr_t attr;
 972 1050  
 973 1051          ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
 974 1052              called_from == CALLED_FROM_STANDALONE);
 975 1053  
 976 1054          /* buffer up the character until later */
 977      -
 978      -        tem->tvs_outbuf[tem->tvs_outindex++] = ch;
     1055 +        tem_safe_get_attr(tem, &fg, &bg, &attr, TEM_ATTR_REVERSE);
     1056 +        tem->tvs_outbuf[tem->tvs_outindex].tc_char = ch | TEM_ATTR(attr);
     1057 +        tem->tvs_outbuf[tem->tvs_outindex].tc_fg_color = fg;
     1058 +        tem->tvs_outbuf[tem->tvs_outindex].tc_bg_color = bg;
     1059 +        tem->tvs_outindex++;
 979 1060          tem->tvs_c_cursor.col++;
 980 1061          if (tem->tvs_c_cursor.col >= tems.ts_c_dimension.width) {
 981 1062                  tem_safe_send_data(tem, credp, called_from);
 982 1063                  tem_safe_new_line(tem, credp, called_from);
 983 1064          }
 984 1065  }
 985 1066  
 986 1067  static void
 987 1068  tem_safe_new_line(struct tem_vt_state *tem,
 988 1069      cred_t *credp, enum called_from called_from)
↓ open down ↓ 58 lines elided ↑ open up ↑
1047 1128  
1048 1129          }
1049 1130  
1050 1131          tem_safe_align_cursor(tem);
1051 1132  }
1052 1133  
1053 1134  static void
1054 1135  tem_safe_send_data(struct tem_vt_state *tem, cred_t *credp,
1055 1136      enum called_from called_from)
1056 1137  {
1057      -        text_color_t fg_color;
1058      -        text_color_t bg_color;
1059      -
1060 1138          ASSERT((called_from == CALLED_FROM_STANDALONE) ||
1061 1139              MUTEX_HELD(&tem->tvs_lock));
1062 1140  
1063 1141          if (tem->tvs_outindex == 0) {
1064 1142                  tem_safe_align_cursor(tem);
1065 1143                  return;
1066 1144          }
1067 1145  
1068      -        tem_safe_get_color(tem, &fg_color, &bg_color, TEM_ATTR_REVERSE);
1069 1146          tem_safe_virtual_display(tem,
1070 1147              tem->tvs_outbuf, tem->tvs_outindex,
1071      -            tem->tvs_s_cursor.row, tem->tvs_s_cursor.col,
1072      -            fg_color, bg_color);
     1148 +            tem->tvs_s_cursor.row, tem->tvs_s_cursor.col);
1073 1149  
1074 1150          if (tem->tvs_isactive) {
1075 1151                  /*
1076 1152                   * Call the primitive to render this data.
1077 1153                   */
1078 1154                  tem_safe_callback_display(tem,
1079 1155                      tem->tvs_outbuf, tem->tvs_outindex,
1080 1156                      tem->tvs_s_cursor.row, tem->tvs_s_cursor.col,
1081      -                    fg_color, bg_color,
1082 1157                      credp, called_from);
1083 1158          }
1084 1159  
1085 1160          tem->tvs_outindex = 0;
1086 1161  
1087 1162          tem_safe_align_cursor(tem);
1088 1163  }
1089 1164  
1090 1165  
1091 1166  /*
↓ open down ↓ 7 lines elided ↑ open up ↑
1099 1174          tem->tvs_s_cursor.row = tem->tvs_c_cursor.row;
1100 1175          tem->tvs_s_cursor.col = tem->tvs_c_cursor.col;
1101 1176  }
1102 1177  
1103 1178  /*
1104 1179   * State machine parser based on the current state and character input
1105 1180   * major terminations are to control character or normal character
1106 1181   */
1107 1182  
1108 1183  static void
1109      -tem_safe_parse(struct tem_vt_state *tem, uchar_t ch,
     1184 +tem_safe_parse(struct tem_vt_state *tem, tem_char_t ch,
1110 1185      cred_t *credp, enum called_from called_from)
1111 1186  {
1112 1187          int     i;
1113 1188  
1114 1189          ASSERT((called_from == CALLED_FROM_STANDALONE) ||
1115 1190              MUTEX_HELD(&tem->tvs_lock));
1116 1191  
1117 1192          if (tem->tvs_state == A_STATE_START) {  /* Normal state? */
1118      -                if (ch == A_CSI || ch == A_ESC || ch < ' ') {
     1193 +                if (ch == A_CSI || ch == A_OSC || ch == A_ESC || ch < ' ') {
1119 1194                          /* Control */
1120 1195                          tem_safe_control(tem, ch, credp, called_from);
1121 1196                  } else {
1122 1197                          /* Display */
1123 1198                          tem_safe_outch(tem, ch, credp, called_from);
1124 1199                  }
1125 1200                  return;
1126 1201          }
1127 1202  
1128 1203          /* In <ESC> sequence */
1129 1204          if (tem->tvs_state != A_STATE_ESC) {    /* Need to get parameters? */
     1205 +                if (tem->tvs_state == A_STATE_OSC) {
     1206 +                        tem_safe_get_oscstring(tem, ch, credp, called_from);
     1207 +                        return;
     1208 +                }
     1209 +
1130 1210                  if (tem->tvs_state != A_STATE_CSI) {
1131 1211                          tem_safe_getparams(tem, ch, credp, called_from);
1132 1212                          return;
1133 1213                  }
1134 1214  
1135 1215                  switch (ch) {
1136 1216                  case '?':
1137 1217                          tem->tvs_state = A_STATE_CSI_QMARK;
1138 1218                          return;
1139 1219                  case '=':
↓ open down ↓ 90 lines elided ↑ open up ↑
1230 1310  
1231 1311          /* Previous char was <ESC> */
1232 1312          if (ch == '[') {
1233 1313                  tem->tvs_curparam = 0;
1234 1314                  tem->tvs_paramval = 0;
1235 1315                  tem->tvs_gotparam = B_FALSE;
1236 1316                  /* clear the parameters */
1237 1317                  for (i = 0; i < TEM_MAXPARAMS; i++)
1238 1318                          tem->tvs_params[i] = -1;
1239 1319                  tem->tvs_state = A_STATE_CSI;
     1320 +        } else if (ch == ']') {
     1321 +                tem->tvs_curparam = 0;
     1322 +                tem->tvs_paramval = 0;
     1323 +                tem->tvs_gotparam = B_FALSE;
     1324 +                /* clear the parameters */
     1325 +                for (i = 0; i < TEM_MAXPARAMS; i++)
     1326 +                        tem->tvs_params[i] = -1;
     1327 +                tem->tvs_state = A_STATE_OSC;
1240 1328          } else if (ch == 'Q') { /* <ESC>Q ? */
1241 1329                  tem->tvs_state = A_STATE_START;
1242 1330          } else if (ch == 'C') { /* <ESC>C ? */
1243 1331                  tem->tvs_state = A_STATE_START;
1244 1332          } else {
1245 1333                  tem->tvs_state = A_STATE_START;
1246 1334                  if (ch == 'c') {
1247 1335                          /* ESC c resets display */
1248 1336                          tem_safe_reset_display(tem, credp, called_from,
1249 1337                              B_TRUE, B_TRUE);
↓ open down ↓ 140 lines elided ↑ open up ↑
1390 1478          tem_safe_virtual_cls(tem, count, row, col);
1391 1479  
1392 1480          if (!tem->tvs_isactive)
1393 1481                  return;
1394 1482  
1395 1483          tem_safe_callback_cls(tem, count, row, col, credp, called_from);
1396 1484  }
1397 1485  
1398 1486  /*ARGSUSED*/
1399 1487  void
1400      -tem_safe_text_display(struct tem_vt_state *tem, uchar_t *string,
     1488 +tem_safe_text_display(struct tem_vt_state *tem, term_char_t *string,
1401 1489      int count, screen_pos_t row, screen_pos_t col,
1402      -    text_color_t fg_color, text_color_t bg_color,
1403 1490      cred_t *credp, enum called_from called_from)
1404 1491  {
1405 1492          struct vis_consdisplay da;
     1493 +        int i;
     1494 +        tem_char_t c;
1406 1495  
1407 1496          ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
1408 1497              called_from == CALLED_FROM_STANDALONE);
1409 1498  
1410      -        da.data = string;
1411      -        da.width = (screen_size_t)count;
     1499 +        da.data = (uint8_t *)&c;
     1500 +        da.width = 1;
1412 1501          da.row = row;
1413 1502          da.col = col;
1414 1503  
1415      -        da.fg_color = fg_color;
1416      -        da.bg_color = bg_color;
1417      -
1418      -        tems_safe_display(&da, credp, called_from);
     1504 +        for (i = 0; i < count; i++) {
     1505 +                tem_safe_get_color(&da.fg_color, &da.bg_color, string[i]);
     1506 +                c = TEM_CHAR(string[i].tc_char);
     1507 +                tems_safe_display(&da, credp, called_from);
     1508 +                da.col++;
     1509 +        }
1419 1510  }
1420 1511  
1421 1512  /*
1422 1513   * This function is used to blit a rectangular color image,
1423 1514   * unperturbed on the underlying framebuffer, to render
1424 1515   * icons and pictures.  The data is a pixel pattern that
1425 1516   * fills a rectangle bounded to the width and height parameters.
1426 1517   * The color pixel data must to be pre-adjusted by the caller
1427 1518   * for the current video depth.
1428 1519   *
↓ open down ↓ 15 lines elided ↑ open up ↑
1444 1535          da.height = (screen_size_t)height;
1445 1536          da.row = row;
1446 1537          da.col = col;
1447 1538  
1448 1539          tems_safe_display(&da, credp, called_from);
1449 1540  
1450 1541          mutex_exit(&tem->tvs_lock);
1451 1542          mutex_exit(&tems.ts_lock);
1452 1543  }
1453 1544  
1454      -
1455 1545  /*ARGSUSED*/
1456 1546  void
1457 1547  tem_safe_text_copy(struct tem_vt_state *tem,
1458 1548      screen_pos_t s_col, screen_pos_t s_row,
1459 1549      screen_pos_t e_col, screen_pos_t e_row,
1460 1550      screen_pos_t t_col, screen_pos_t t_row,
1461 1551      cred_t *credp, enum called_from called_from)
1462 1552  {
1463 1553          struct vis_conscopy da;
1464 1554  
↓ open down ↓ 8 lines elided ↑ open up ↑
1473 1563          da.t_col = t_col;
1474 1564  
1475 1565          tems_safe_copy(&da, credp, called_from);
1476 1566  }
1477 1567  
1478 1568  void
1479 1569  tem_safe_text_cls(struct tem_vt_state *tem,
1480 1570      int count, screen_pos_t row, screen_pos_t col, cred_t *credp,
1481 1571      enum called_from called_from)
1482 1572  {
1483      -        struct vis_consdisplay da;
     1573 +        text_attr_t attr;
     1574 +        term_char_t c;
     1575 +        int i;
1484 1576  
1485 1577          ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
1486 1578              called_from == CALLED_FROM_STANDALONE);
1487 1579  
1488      -        da.data = tems.ts_blank_line;
1489      -        da.width = (screen_size_t)count;
1490      -        da.row = row;
1491      -        da.col = col;
1492      -
1493      -        tem_safe_get_color(tem, &da.fg_color, &da.bg_color,
     1580 +        tem_safe_get_attr(tem, &c.tc_fg_color, &c.tc_bg_color, &attr,
1494 1581              TEM_ATTR_SCREEN_REVERSE);
1495      -        tems_safe_display(&da, credp, called_from);
     1582 +        c.tc_char = TEM_ATTR(attr & ~TEM_ATTR_UNDERLINE) | ' ';
     1583 +
     1584 +        if (count > tems.ts_c_dimension.width ||
     1585 +            col + count > tems.ts_c_dimension.width)
     1586 +                count = tems.ts_c_dimension.width - col;
     1587 +
     1588 +        for (i = 0; i < count; i++)
     1589 +                tems.ts_blank_line[i] = c;
     1590 +
     1591 +        tem_safe_text_display(tem, tems.ts_blank_line, count, row, col,
     1592 +                credp, called_from);
1496 1593  }
1497 1594  
1498 1595  void
1499 1596  tem_safe_pix_display(struct tem_vt_state *tem,
1500      -    uchar_t *string, int count,
     1597 +    term_char_t *string, int count,
1501 1598      screen_pos_t row, screen_pos_t col,
1502      -    text_color_t fg_color, text_color_t bg_color,
1503 1599      cred_t *credp, enum called_from called_from)
1504 1600  {
1505 1601          struct vis_consdisplay da;
1506 1602          int     i;
1507 1603  
1508 1604          ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
1509 1605              called_from == CALLED_FROM_STANDALONE);
1510 1606  
1511 1607          da.data = (uchar_t *)tem->tvs_pix_data;
1512      -        da.width = tems.ts_font.width;
1513      -        da.height = tems.ts_font.height;
     1608 +        da.width = (screen_size_t)tems.ts_font.vf_width;
     1609 +        da.height = (screen_size_t)tems.ts_font.vf_height;
1514 1610          da.row = (row * da.height) + tems.ts_p_offset.y;
1515 1611          da.col = (col * da.width) + tems.ts_p_offset.x;
1516 1612  
1517 1613          for (i = 0; i < count; i++) {
1518      -                tem_safe_callback_bit2pix(tem, string[i], fg_color, bg_color);
     1614 +                tem_safe_callback_bit2pix(tem, string[i]);
1519 1615                  tems_safe_display(&da, credp, called_from);
1520 1616                  da.col += da.width;
1521 1617          }
1522 1618  }
1523 1619  
1524 1620  void
1525 1621  tem_safe_pix_copy(struct tem_vt_state *tem,
1526 1622      screen_pos_t s_col, screen_pos_t s_row,
1527 1623      screen_pos_t e_col, screen_pos_t e_row,
1528 1624      screen_pos_t t_col, screen_pos_t t_row,
↓ open down ↓ 12 lines elided ↑ open up ↑
1541 1637                   * when our kernel console term begins to scroll up,
1542 1638                   * we hope it is user friendly.
1543 1639                   * (Also see comments on tem_safe_pix_clear_prom_output)
1544 1640                   *
1545 1641                   * This is only one time call.
1546 1642                   */
1547 1643                  tem_safe_pix_clear_prom_output(tem, credp, called_from);
1548 1644          }
1549 1645          need_clear = B_FALSE;
1550 1646  
1551      -        ma.s_row = s_row * tems.ts_font.height + tems.ts_p_offset.y;
1552      -        ma.e_row = (e_row + 1) * tems.ts_font.height + tems.ts_p_offset.y - 1;
1553      -        ma.t_row = t_row * tems.ts_font.height + tems.ts_p_offset.y;
     1647 +        ma.s_row = s_row * tems.ts_font.vf_height + tems.ts_p_offset.y;
     1648 +        ma.e_row = (e_row + 1) * tems.ts_font.vf_height +
     1649 +            tems.ts_p_offset.y - 1;
     1650 +        ma.t_row = t_row * tems.ts_font.vf_height + tems.ts_p_offset.y;
1554 1651  
1555 1652          /*
1556 1653           * Check if we're in process of clearing OBP's columns area,
1557 1654           * which only happens when term scrolls up a whole line.
1558 1655           */
1559 1656          if (tem->tvs_first_line > 0 && t_row < s_row && t_col == 0 &&
1560 1657              e_col == tems.ts_c_dimension.width - 1) {
1561 1658                  /*
1562 1659                   * We need to clear OBP's columns area outside our kernel
1563 1660                   * console term. So that we set ma.e_col to entire row here.
1564 1661                   */
1565      -                ma.s_col = s_col * tems.ts_font.width;
     1662 +                ma.s_col = s_col * tems.ts_font.vf_width;
1566 1663                  ma.e_col = tems.ts_p_dimension.width - 1;
1567 1664  
1568      -                ma.t_col = t_col * tems.ts_font.width;
     1665 +                ma.t_col = t_col * tems.ts_font.vf_width;
1569 1666          } else {
1570      -                ma.s_col = s_col * tems.ts_font.width + tems.ts_p_offset.x;
1571      -                ma.e_col = (e_col + 1) * tems.ts_font.width +
     1667 +                ma.s_col = s_col * tems.ts_font.vf_width + tems.ts_p_offset.x;
     1668 +                ma.e_col = (e_col + 1) * tems.ts_font.vf_width +
1572 1669                      tems.ts_p_offset.x - 1;
1573      -                ma.t_col = t_col * tems.ts_font.width + tems.ts_p_offset.x;
     1670 +                ma.t_col = t_col * tems.ts_font.vf_width + tems.ts_p_offset.x;
1574 1671          }
1575 1672  
1576 1673          tems_safe_copy(&ma, credp, called_from);
1577 1674  
1578 1675          if (tem->tvs_first_line > 0 && t_row < s_row) {
1579 1676                  /* We have scrolled up (s_row - t_row) rows. */
1580 1677                  tem->tvs_first_line -= (s_row - t_row);
1581 1678                  if (tem->tvs_first_line <= 0) {
1582 1679                          /* All OBP rows have been cleared. */
1583 1680                          tem->tvs_first_line = 0;
1584 1681                  }
1585 1682          }
1586 1683  
1587 1684  }
1588 1685  
1589 1686  void
1590      -tem_safe_pix_bit2pix(struct tem_vt_state *tem, unsigned char c,
1591      -    unsigned char fg, unsigned char bg)
     1687 +tem_safe_pix_bit2pix(struct tem_vt_state *tem, term_char_t c)
1592 1688  {
1593      -        void (*fp)(struct tem_vt_state *, unsigned char,
     1689 +        text_color_t fg, bg;
     1690 +        void (*fp)(struct tem_vt_state *, tem_char_t,
1594 1691              unsigned char, unsigned char);
1595 1692  
     1693 +        tem_safe_get_color(&fg, &bg, c);
1596 1694          switch (tems.ts_pdepth) {
1597 1695          case 4:
1598 1696                  fp = bit_to_pix4;
1599 1697                  break;
1600 1698          case 8:
1601 1699                  fp = bit_to_pix8;
1602 1700                  break;
     1701 +        case 15:
     1702 +        case 16:
     1703 +                fp = bit_to_pix16;
     1704 +                break;
1603 1705          case 24:
1604      -        case 32:
1605 1706                  fp = bit_to_pix24;
     1707 +                break;
     1708 +        case 32:
     1709 +                fp = bit_to_pix32;
     1710 +                break;
     1711 +        default:
     1712 +                return;
1606 1713          }
1607 1714  
1608      -        fp(tem, c, fg, bg);
     1715 +        fp(tem, c.tc_char, fg, bg);
1609 1716  }
1610 1717  
1611 1718  
1612 1719  /*
1613 1720   * This function only clears count of columns in one row
1614 1721   */
1615 1722  void
1616 1723  tem_safe_pix_cls(struct tem_vt_state *tem, int count,
1617 1724      screen_pos_t row, screen_pos_t col, cred_t *credp,
1618 1725      enum called_from called_from)
↓ open down ↓ 25 lines elided ↑ open up ↑
1644 1751   *        |---> columns area to be cleared
1645 1752   *
1646 1753   * This function only takes care of the output above our kernel console term,
1647 1754   * and tem_prom_scroll_up takes care of columns area outside of our kernel
1648 1755   * console term.
1649 1756   */
1650 1757  static void
1651 1758  tem_safe_pix_clear_prom_output(struct tem_vt_state *tem, cred_t *credp,
1652 1759      enum called_from called_from)
1653 1760  {
1654      -        int     nrows, ncols, width, height;
     1761 +        int     nrows, ncols, width, height, offset;
1655 1762  
1656 1763          ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
1657 1764              called_from == CALLED_FROM_STANDALONE);
1658 1765  
1659      -        width = tems.ts_font.width;
1660      -        height = tems.ts_font.height;
     1766 +        width = tems.ts_font.vf_width;
     1767 +        height = tems.ts_font.vf_height;
     1768 +        offset = tems.ts_p_offset.y % height;
1661 1769  
1662      -        nrows = (tems.ts_p_offset.y + (height - 1))/ height;
     1770 +        nrows = tems.ts_p_offset.y / height;
1663 1771          ncols = (tems.ts_p_dimension.width + (width - 1))/ width;
1664 1772  
1665      -        tem_safe_pix_cls_range(tem, 0, nrows, 0, 0, ncols, 0,
1666      -            B_FALSE, credp, called_from);
     1773 +        if (nrows > 0)
     1774 +                tem_safe_pix_cls_range(tem, 0, nrows, offset, 0, ncols, 0,
     1775 +                    B_FALSE, credp, called_from);
1667 1776  }
1668 1777  
1669 1778  /*
1670 1779   * clear the whole screen for pixel mode, just clear the
1671 1780   * physical screen.
1672 1781   */
1673 1782  void
1674 1783  tem_safe_pix_clear_entire_screen(struct tem_vt_state *tem, cred_t *credp,
1675 1784      enum called_from called_from)
1676 1785  {
1677      -        int     nrows, ncols, width, height;
     1786 +        struct vis_consclear cl;
     1787 +        text_color_t fg_color;
     1788 +        text_color_t bg_color;
     1789 +        text_attr_t attr;
     1790 +        term_char_t c;
     1791 +        int nrows, ncols, width, height;
1678 1792  
1679 1793          ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
1680 1794              called_from == CALLED_FROM_STANDALONE);
1681 1795  
1682      -        width = tems.ts_font.width;
1683      -        height = tems.ts_font.height;
     1796 +        /* call driver first, if error, clear terminal area */
     1797 +        tem_safe_get_attr(tem, &c.tc_fg_color, &c.tc_bg_color, &attr,
     1798 +            TEM_ATTR_SCREEN_REVERSE);
     1799 +        c.tc_char = TEM_ATTR(attr);
1684 1800  
     1801 +        tem_safe_get_color(&fg_color, &bg_color, c);
     1802 +        cl.bg_color = bg_color;
     1803 +        if (tems_cls_layered(&cl, credp) == 0)
     1804 +                return;
     1805 +
     1806 +        width = tems.ts_font.vf_width;
     1807 +        height = tems.ts_font.vf_height;
     1808 +
1685 1809          nrows = (tems.ts_p_dimension.height + (height - 1))/ height;
1686 1810          ncols = (tems.ts_p_dimension.width + (width - 1))/ width;
1687 1811  
1688      -        tem_safe_pix_cls_range(tem, 0, nrows, 0, 0, ncols, 0,
1689      -            B_FALSE, credp, called_from);
     1812 +        tem_safe_pix_cls_range(tem, 0, nrows, tems.ts_p_offset.y, 0, ncols,
     1813 +            tems.ts_p_offset.x, B_FALSE, credp, called_from);
1690 1814  
1691 1815          /*
1692 1816           * Since the whole screen is cleared, we don't need
1693 1817           * to clear OBP output later.
1694 1818           */
1695 1819          if (tem->tvs_first_line > 0)
1696 1820                  tem->tvs_first_line = 0;
1697 1821  }
1698 1822  
1699 1823  /*
↓ open down ↓ 297 lines elided ↑ open up ↑
1997 2121                  tem->tvs_c_cursor.row = ca.row;
1998 2122                  tem->tvs_c_cursor.col = ca.col;
1999 2123          }
2000 2124  }
2001 2125  
2002 2126  void
2003 2127  tem_safe_pix_cursor(struct tem_vt_state *tem, short action,
2004 2128      cred_t *credp, enum called_from called_from)
2005 2129  {
2006 2130          struct vis_conscursor   ca;
     2131 +        uint32_t color;
     2132 +        text_color_t fg, bg;
     2133 +        term_char_t c;
     2134 +        text_attr_t attr;
2007 2135  
2008 2136          ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
2009 2137              called_from == CALLED_FROM_STANDALONE);
2010 2138  
2011      -        ca.row = tem->tvs_c_cursor.row * tems.ts_font.height +
     2139 +        ca.row = tem->tvs_c_cursor.row * tems.ts_font.vf_height +
2012 2140              tems.ts_p_offset.y;
2013      -        ca.col = tem->tvs_c_cursor.col * tems.ts_font.width +
     2141 +        ca.col = tem->tvs_c_cursor.col * tems.ts_font.vf_width +
2014 2142              tems.ts_p_offset.x;
2015      -        ca.width = tems.ts_font.width;
2016      -        ca.height = tems.ts_font.height;
2017      -        if (tems.ts_pdepth == 8 || tems.ts_pdepth == 4) {
     2143 +        ca.width = (screen_size_t)tems.ts_font.vf_width;
     2144 +        ca.height = (screen_size_t)tems.ts_font.vf_height;
     2145 +
     2146 +        tem_safe_get_attr(tem, &c.tc_fg_color, &c.tc_bg_color, &attr,
     2147 +            TEM_ATTR_REVERSE);
     2148 +        c.tc_char = TEM_ATTR(attr);
     2149 +
     2150 +        tem_safe_get_color(&fg, &bg, c);
     2151 +
     2152 +        switch (tems.ts_pdepth) {
     2153 +        case 4:
     2154 +                ca.fg_color.mono = fg;
     2155 +                ca.bg_color.mono = bg;
     2156 +                break;
     2157 +        case 8:
     2158 +                ca.fg_color.mono = tems.ts_color_map(fg);
     2159 +                ca.bg_color.mono = tems.ts_color_map(bg);
     2160 +                break;
     2161 +        case 15:
     2162 +        case 16:
     2163 +                color = tems.ts_color_map(fg);
     2164 +                ca.fg_color.sixteen[0] = (color >> 8) & 0xFF;
     2165 +                ca.fg_color.sixteen[1] = color & 0xFF;
     2166 +                color = tems.ts_color_map(bg);
     2167 +                ca.bg_color.sixteen[0] = (color >> 8) & 0xFF;
     2168 +                ca.bg_color.sixteen[1] = color & 0xFF;
     2169 +                break;
     2170 +        case 24:
     2171 +        case 32:
     2172 +#ifdef _HAVE_TEM_FIRMWARE
     2173 +                /* Keeping this block to support old binary only drivers */
2018 2174                  if (tem->tvs_flags & TEM_ATTR_REVERSE) {
2019      -                        ca.fg_color.mono = TEM_TEXT_WHITE;
2020      -                        ca.bg_color.mono = TEM_TEXT_BLACK;
2021      -                } else {
2022      -                        ca.fg_color.mono = TEM_TEXT_BLACK;
2023      -                        ca.bg_color.mono = TEM_TEXT_WHITE;
2024      -                }
2025      -        } else if (tems.ts_pdepth == 24 || tems.ts_pdepth == 32) {
2026      -                if (tem->tvs_flags & TEM_ATTR_REVERSE) {
2027 2175                          ca.fg_color.twentyfour[0] = TEM_TEXT_WHITE24_RED;
2028 2176                          ca.fg_color.twentyfour[1] = TEM_TEXT_WHITE24_GREEN;
2029 2177                          ca.fg_color.twentyfour[2] = TEM_TEXT_WHITE24_BLUE;
2030 2178  
2031 2179                          ca.bg_color.twentyfour[0] = TEM_TEXT_BLACK24_RED;
2032 2180                          ca.bg_color.twentyfour[1] = TEM_TEXT_BLACK24_GREEN;
2033 2181                          ca.bg_color.twentyfour[2] = TEM_TEXT_BLACK24_BLUE;
2034 2182                  } else {
2035 2183                          ca.fg_color.twentyfour[0] = TEM_TEXT_BLACK24_RED;
2036 2184                          ca.fg_color.twentyfour[1] = TEM_TEXT_BLACK24_GREEN;
2037 2185                          ca.fg_color.twentyfour[2] = TEM_TEXT_BLACK24_BLUE;
2038 2186  
2039 2187                          ca.bg_color.twentyfour[0] = TEM_TEXT_WHITE24_RED;
2040 2188                          ca.bg_color.twentyfour[1] = TEM_TEXT_WHITE24_GREEN;
2041 2189                          ca.bg_color.twentyfour[2] = TEM_TEXT_WHITE24_BLUE;
2042 2190                  }
     2191 +#else
     2192 +                color = tems.ts_color_map(fg);
     2193 +                ca.fg_color.twentyfour[0] = (color >> 16) & 0xFF;
     2194 +                ca.fg_color.twentyfour[1] = (color >> 8) & 0xFF;
     2195 +                ca.fg_color.twentyfour[2] = color & 0xFF;
     2196 +                color = tems.ts_color_map(bg);
     2197 +                ca.bg_color.twentyfour[0] = (color >> 16) & 0xFF;
     2198 +                ca.bg_color.twentyfour[1] = (color >> 8) & 0xFF;
     2199 +                ca.bg_color.twentyfour[2] = color & 0xFF;
     2200 +                break;
     2201 +#endif
2043 2202          }
2044 2203  
2045 2204          ca.action = action;
2046 2205  
2047 2206          tems_safe_cursor(&ca, credp, called_from);
     2207 +
     2208 +        if (action == VIS_GET_CURSOR) {
     2209 +                tem->tvs_c_cursor.row = 0;
     2210 +                tem->tvs_c_cursor.col = 0;
     2211 +
     2212 +                if (ca.row != 0) {
     2213 +                        tem->tvs_c_cursor.row = (ca.row - tems.ts_p_offset.y) /
     2214 +                            tems.ts_font.vf_height;
     2215 +                }
     2216 +                if (ca.col != 0) {
     2217 +                        tem->tvs_c_cursor.col = (ca.col - tems.ts_p_offset.x) /
     2218 +                            tems.ts_font.vf_width;
     2219 +                }
     2220 +        }
2048 2221  }
2049 2222  
2050 2223  static void
2051      -bit_to_pix4(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color,
     2224 +bit_to_pix4(struct tem_vt_state *tem, tem_char_t c, text_color_t fg_color,
2052 2225      text_color_t bg_color)
2053 2226  {
2054 2227          uint8_t *dest = (uint8_t *)tem->tvs_pix_data;
2055 2228          font_bit_to_pix4(&tems.ts_font, dest, c, fg_color, bg_color);
2056 2229  }
2057 2230  
2058 2231  static void
2059      -bit_to_pix8(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color,
     2232 +bit_to_pix8(struct tem_vt_state *tem, tem_char_t c, text_color_t fg_color,
2060 2233      text_color_t bg_color)
2061 2234  {
2062 2235          uint8_t *dest = (uint8_t *)tem->tvs_pix_data;
     2236 +
     2237 +        fg_color = (text_color_t)tems.ts_color_map(fg_color);
     2238 +        bg_color = (text_color_t)tems.ts_color_map(bg_color);
2063 2239          font_bit_to_pix8(&tems.ts_font, dest, c, fg_color, bg_color);
2064 2240  }
2065 2241  
2066 2242  static void
2067      -bit_to_pix24(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color4,
     2243 +bit_to_pix16(struct tem_vt_state *tem, tem_char_t c, text_color_t fg_color4,
2068 2244      text_color_t bg_color4)
2069 2245  {
2070      -        uint32_t fg_color32, bg_color32, *dest;
     2246 +        uint16_t fg_color16, bg_color16;
     2247 +        uint16_t *dest;
2071 2248  
2072 2249          ASSERT(fg_color4 < 16 && bg_color4 < 16);
2073 2250  
     2251 +        fg_color16 = (uint16_t)tems.ts_color_map(fg_color4);
     2252 +        bg_color16 = (uint16_t)tems.ts_color_map(bg_color4);
     2253 +
     2254 +        dest = (uint16_t *)tem->tvs_pix_data;
     2255 +        font_bit_to_pix16(&tems.ts_font, dest, c, fg_color16, bg_color16);
     2256 +}
     2257 +
     2258 +static void
     2259 +bit_to_pix24(struct tem_vt_state *tem, tem_char_t c, text_color_t fg_color4,
     2260 +    text_color_t bg_color4)
     2261 +{
     2262 +        uint32_t fg_color32, bg_color32;
     2263 +        uint8_t *dest;
     2264 +
     2265 +        ASSERT(fg_color4 < 16 && bg_color4 < 16);
     2266 +
     2267 +#ifdef _HAVE_TEM_FIRMWARE
2074 2268          fg_color32 = PIX4TO32(fg_color4);
2075 2269          bg_color32 = PIX4TO32(bg_color4);
     2270 +#else
     2271 +        fg_color32 = tems.ts_color_map(fg_color4);
     2272 +        bg_color32 = tems.ts_color_map(bg_color4);
     2273 +#endif
2076 2274  
2077      -        dest = (uint32_t *)tem->tvs_pix_data;
     2275 +        dest = (uint8_t *)tem->tvs_pix_data;
2078 2276          font_bit_to_pix24(&tems.ts_font, dest, c, fg_color32, bg_color32);
2079 2277  }
2080 2278  
2081      -static text_color_t
2082      -ansi_bg_to_solaris(struct tem_vt_state *tem, int ansi)
     2279 +static void
     2280 +bit_to_pix32(struct tem_vt_state *tem, tem_char_t c, text_color_t fg_color4,
     2281 +    text_color_t bg_color4)
2083 2282  {
2084      -        if (tem->tvs_flags & TEM_ATTR_BRIGHT_BG)
2085      -                return (brt_xlate[ansi]);
2086      -        else
2087      -                return (dim_xlate[ansi]);
2088      -}
     2283 +        uint32_t fg_color32, bg_color32, *dest;
2089 2284  
2090      -static text_color_t
2091      -ansi_fg_to_solaris(struct tem_vt_state *tem, int ansi)
2092      -{
2093      -        if (tem->tvs_flags & TEM_ATTR_BRIGHT_FG ||
2094      -            tem->tvs_flags & TEM_ATTR_BOLD) {
2095      -                return (brt_xlate[ansi]);
2096      -        } else {
2097      -                return (dim_xlate[ansi]);
2098      -        }
     2285 +        ASSERT(fg_color4 < 16 && bg_color4 < 16);
     2286 +
     2287 +#ifdef _HAVE_TEM_FIRMWARE
     2288 +        fg_color32 = PIX4TO32(fg_color4);
     2289 +        bg_color32 = PIX4TO32(bg_color4);
     2290 +#else
     2291 +        fg_color32 = ((uint32_t)0xFF << 24) | tems.ts_color_map(fg_color4);
     2292 +        bg_color32 = ((uint32_t)0xFF << 24) | tems.ts_color_map(bg_color4);
     2293 +#endif
     2294 +
     2295 +        dest = (uint32_t *)tem->tvs_pix_data;
     2296 +        font_bit_to_pix32(&tems.ts_font, dest, c, fg_color32, bg_color32);
2099 2297  }
2100 2298  
2101 2299  /*
2102 2300   * flag: TEM_ATTR_SCREEN_REVERSE or TEM_ATTR_REVERSE
2103 2301   */
2104 2302  void
2105      -tem_safe_get_color(struct tem_vt_state *tem, text_color_t *fg,
2106      -    text_color_t *bg, uint8_t flag)
     2303 +tem_safe_get_attr(struct tem_vt_state *tem, text_color_t *fg,
     2304 +    text_color_t *bg, text_attr_t *attr, uint8_t flag)
2107 2305  {
2108 2306          if (tem->tvs_flags & flag) {
2109      -                *fg = ansi_fg_to_solaris(tem,
2110      -                    tem->tvs_bg_color);
2111      -                *bg = ansi_bg_to_solaris(tem,
2112      -                    tem->tvs_fg_color);
     2307 +                *fg = tem->tvs_bg_color;
     2308 +                *bg = tem->tvs_fg_color;
2113 2309          } else {
2114      -                *fg = ansi_fg_to_solaris(tem,
2115      -                    tem->tvs_fg_color);
2116      -                *bg = ansi_bg_to_solaris(tem,
2117      -                    tem->tvs_bg_color);
     2310 +                *fg = tem->tvs_fg_color;
     2311 +                *bg = tem->tvs_bg_color;
2118 2312          }
     2313 +
     2314 +        if (attr == NULL)
     2315 +                return;
     2316 +
     2317 +        *attr = tem->tvs_flags;
2119 2318  }
2120 2319  
     2320 +static void
     2321 +tem_safe_get_color(text_color_t *fg, text_color_t *bg, term_char_t c)
     2322 +{
     2323 +        if (TEM_CHAR_ATTR(c.tc_char) & (TEM_ATTR_BRIGHT_FG | TEM_ATTR_BOLD))
     2324 +                *fg = brt_xlate[c.tc_fg_color];
     2325 +        else
     2326 +                *fg = dim_xlate[c.tc_fg_color];
     2327 +
     2328 +        if (TEM_CHAR_ATTR(c.tc_char) & TEM_ATTR_BRIGHT_BG)
     2329 +                *bg = brt_xlate[c.tc_bg_color];
     2330 +        else
     2331 +                *bg = dim_xlate[c.tc_bg_color];
     2332 +}
     2333 +
2121 2334  /*
2122 2335   * Clear a rectangle of screen for pixel mode.
2123 2336   *
2124 2337   * arguments:
2125 2338   *    row:      start row#
2126 2339   *    nrows:    the number of rows to clear
2127 2340   *    offset_y: the offset of height in pixels to begin clear
2128 2341   *    col:      start col#
2129 2342   *    ncols:    the number of cols to clear
2130 2343   *    offset_x: the offset of width in pixels to begin clear
↓ open down ↓ 3 lines elided ↑ open up ↑
2134 2347  void
2135 2348  tem_safe_pix_cls_range(struct tem_vt_state *tem,
2136 2349      screen_pos_t row, int nrows, int offset_y,
2137 2350      screen_pos_t col, int ncols, int offset_x,
2138 2351      boolean_t sroll_up, cred_t *credp,
2139 2352      enum called_from called_from)
2140 2353  {
2141 2354          struct vis_consdisplay da;
2142 2355          int     i, j;
2143 2356          int     row_add = 0;
2144      -        text_color_t fg_color;
2145      -        text_color_t bg_color;
     2357 +        term_char_t c;
     2358 +        text_attr_t attr;
2146 2359  
2147 2360          ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
2148 2361              called_from == CALLED_FROM_STANDALONE);
2149 2362  
2150 2363          if (sroll_up)
2151 2364                  row_add = tems.ts_c_dimension.height - 1;
2152 2365  
2153      -        da.width = tems.ts_font.width;
2154      -        da.height = tems.ts_font.height;
     2366 +        da.width = (screen_size_t)tems.ts_font.vf_width;
     2367 +        da.height = (screen_size_t)tems.ts_font.vf_height;
2155 2368  
2156      -        tem_safe_get_color(tem, &fg_color, &bg_color, TEM_ATTR_SCREEN_REVERSE);
     2369 +        tem_safe_get_attr(tem, &c.tc_fg_color, &c.tc_bg_color, &attr,
     2370 +            TEM_ATTR_SCREEN_REVERSE);
     2371 +        /* Make sure we will not draw underlines */
     2372 +        c.tc_char = TEM_ATTR(attr & ~TEM_ATTR_UNDERLINE) | ' ';
2157 2373  
2158      -        tem_safe_callback_bit2pix(tem, ' ', fg_color, bg_color);
     2374 +        tem_safe_callback_bit2pix(tem, c);
2159 2375          da.data = (uchar_t *)tem->tvs_pix_data;
2160 2376  
2161 2377          for (i = 0; i < nrows; i++, row++) {
2162 2378                  da.row = (row + row_add) * da.height + offset_y;
2163 2379                  da.col = col * da.width + offset_x;
2164 2380                  for (j = 0; j < ncols; j++) {
2165 2381                          tems_safe_display(&da, credp, called_from);
2166 2382                          da.col += da.width;
2167 2383                  }
2168 2384          }
2169 2385  }
2170 2386  
2171 2387  /*
2172 2388   * virtual screen operations
2173 2389   */
2174 2390  static void
2175      -tem_safe_virtual_display(struct tem_vt_state *tem, unsigned char *string,
2176      -    int count, screen_pos_t row, screen_pos_t col,
2177      -    text_color_t fg_color, text_color_t bg_color)
     2391 +tem_safe_virtual_display(struct tem_vt_state *tem, term_char_t *string,
     2392 +    int count, screen_pos_t row, screen_pos_t col)
2178 2393  {
2179 2394          int i, width;
2180      -        unsigned char *addr;
2181      -        text_color_t *pfgcolor;
2182      -        text_color_t *pbgcolor;
     2395 +        term_char_t *addr;
2183 2396  
2184 2397          if (row < 0 || row >= tems.ts_c_dimension.height ||
2185 2398              col < 0 || col >= tems.ts_c_dimension.width ||
2186 2399              col + count > tems.ts_c_dimension.width)
2187 2400                  return;
2188 2401  
2189 2402          width = tems.ts_c_dimension.width;
2190      -        addr = tem->tvs_screen_buf +  (row * width + col);
2191      -        pfgcolor = tem->tvs_fg_buf + (row * width + col);
2192      -        pbgcolor = tem->tvs_bg_buf + (row * width + col);
     2403 +        addr = tem->tvs_screen_buf + (row * width + col);
2193 2404          for (i = 0; i < count; i++) {
2194 2405                  *addr++ = string[i];
2195      -                *pfgcolor++ = fg_color;
2196      -                *pbgcolor++ = bg_color;
2197 2406          }
2198 2407  }
2199 2408  
2200 2409  static void
2201      -i_virtual_copy(unsigned char *base,
     2410 +i_virtual_copy_tem_chars(term_char_t *base,
2202 2411      screen_pos_t s_col, screen_pos_t s_row,
2203 2412      screen_pos_t e_col, screen_pos_t e_row,
2204 2413      screen_pos_t t_col, screen_pos_t t_row)
2205 2414  {
2206      -        unsigned char   *from;
2207      -        unsigned char   *to;
     2415 +        term_char_t     *from;
     2416 +        term_char_t     *to;
2208 2417          int             cnt;
2209 2418          screen_size_t chars_per_row;
2210      -        unsigned char   *to_row_start;
2211      -        unsigned char   *from_row_start;
     2419 +        term_char_t     *to_row_start;
     2420 +        term_char_t     *from_row_start;
2212 2421          screen_size_t   rows_to_move;
2213 2422          int             cols = tems.ts_c_dimension.width;
2214 2423  
2215 2424          chars_per_row = e_col - s_col + 1;
2216 2425          rows_to_move = e_row - s_row + 1;
2217 2426  
2218 2427          to_row_start = base + ((t_row * cols) + t_col);
2219 2428          from_row_start = base + ((s_row * cols) + s_col);
2220 2429  
2221 2430          if (to_row_start < from_row_start) {
↓ open down ↓ 46 lines elided ↑ open up ↑
2268 2477                  return;
2269 2478  
2270 2479          chars_per_row = e_col - s_col + 1;
2271 2480          rows_to_move = e_row - s_row + 1;
2272 2481  
2273 2482          /* More sanity checks. */
2274 2483          if (t_row + rows_to_move > rows ||
2275 2484              t_col + chars_per_row > cols)
2276 2485                  return;
2277 2486  
2278      -        i_virtual_copy(tem->tvs_screen_buf, s_col, s_row,
     2487 +        i_virtual_copy_tem_chars(tem->tvs_screen_buf, s_col, s_row,
2279 2488              e_col, e_row, t_col, t_row);
2280      -
2281      -        /* text_color_t is the same size as char */
2282      -        i_virtual_copy((unsigned char *)tem->tvs_fg_buf,
2283      -            s_col, s_row, e_col, e_row, t_col, t_row);
2284      -        i_virtual_copy((unsigned char *)tem->tvs_bg_buf,
2285      -            s_col, s_row, e_col, e_row, t_col, t_row);
2286      -
2287 2489  }
2288 2490  
2289 2491  static void
2290 2492  tem_safe_virtual_cls(struct tem_vt_state *tem,
2291 2493      int count, screen_pos_t row, screen_pos_t col)
2292 2494  {
2293      -        text_color_t fg_color;
2294      -        text_color_t bg_color;
     2495 +        int i;
     2496 +        text_attr_t attr;
     2497 +        term_char_t c;
2295 2498  
2296      -        tem_safe_get_color(tem, &fg_color, &bg_color, TEM_ATTR_SCREEN_REVERSE);
2297      -        tem_safe_virtual_display(tem, tems.ts_blank_line, count, row, col,
2298      -            fg_color, bg_color);
     2499 +        tem_safe_get_attr(tem, &c.tc_fg_color, &c.tc_bg_color, &attr,
     2500 +            TEM_ATTR_SCREEN_REVERSE);
     2501 +        c.tc_char = TEM_ATTR(attr & ~TEM_ATTR_UNDERLINE) | ' ';
     2502 +
     2503 +        for (i = 0; i < tems.ts_c_dimension.width; i++)
     2504 +                tems.ts_blank_line[i] = c;
     2505 +
     2506 +        tem_safe_virtual_display(tem, tems.ts_blank_line, count, row, col);
2299 2507  }
2300 2508  
2301 2509  /*
2302 2510   * only blank screen, not clear our screen buffer
2303 2511   */
2304 2512  void
2305 2513  tem_safe_blank_screen(struct tem_vt_state *tem, cred_t *credp,
2306 2514      enum called_from called_from)
2307 2515  {
2308 2516          int     row;
↓ open down ↓ 13 lines elided ↑ open up ↑
2322 2530          }
2323 2531  }
2324 2532  
2325 2533  /*
2326 2534   * unblank screen with associated tem from its screen buffer
2327 2535   */
2328 2536  void
2329 2537  tem_safe_unblank_screen(struct tem_vt_state *tem, cred_t *credp,
2330 2538      enum called_from called_from)
2331 2539  {
2332      -        text_color_t fg_color, fg_last;
2333      -        text_color_t bg_color, bg_last;
2334      -        size_t  tc_size = sizeof (text_color_t);
2335      -        int     row, col, count, col_start;
2336      -        int     width;
2337      -        unsigned char *buf;
     2540 +        int     row;
2338 2541  
2339 2542          ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
2340 2543              called_from == CALLED_FROM_STANDALONE);
2341 2544  
2342 2545          if (tems.ts_display_mode == VIS_PIXEL)
2343 2546                  tem_safe_pix_clear_entire_screen(tem, credp, called_from);
2344 2547  
2345 2548          tem_safe_callback_cursor(tem, VIS_HIDE_CURSOR, credp, called_from);
2346 2549  
2347      -        width = tems.ts_c_dimension.width;
2348      -
2349 2550          /*
2350 2551           * Display data in tvs_screen_buf to the actual framebuffer in a
2351 2552           * row by row way.
2352 2553           * When dealing with one row, output data with the same foreground
2353 2554           * and background color all together.
2354 2555           */
2355 2556          for (row = 0; row < tems.ts_c_dimension.height; row++) {
2356      -                buf = tem->tvs_screen_buf + (row * width);
2357      -                count = col_start = 0;
2358      -                for (col = 0; col < width; col++) {
2359      -                        fg_color =
2360      -                            tem->tvs_fg_buf[(row * width + col) * tc_size];
2361      -                        bg_color =
2362      -                            tem->tvs_bg_buf[(row * width + col) * tc_size];
2363      -                        if (col == 0) {
2364      -                                fg_last = fg_color;
2365      -                                bg_last = bg_color;
2366      -                        }
2367      -
2368      -                        if ((fg_color != fg_last) || (bg_color != bg_last)) {
2369      -                                /*
2370      -                                 * Call the primitive to render this data.
2371      -                                 */
2372      -                                tem_safe_callback_display(tem,
2373      -                                    buf, count, row, col_start,
2374      -                                    fg_last, bg_last, credp, called_from);
2375      -                                buf += count;
2376      -                                count = 1;
2377      -                                col_start = col;
2378      -                                fg_last = fg_color;
2379      -                                bg_last = bg_color;
2380      -                        } else {
2381      -                                count++;
2382      -                        }
2383      -                }
2384      -
2385      -                if (col_start == (width - 1))
2386      -                        continue;
2387      -
2388      -                /*
2389      -                 * Call the primitive to render this data.
2390      -                 */
2391      -                tem_safe_callback_display(tem,
2392      -                    buf, count, row, col_start,
2393      -                    fg_last, bg_last, credp, called_from);
     2557 +                tem_safe_callback_display(tem, tem->tvs_screen_rows[row],
     2558 +                    tems.ts_c_dimension.width, row, 0, credp, called_from);
2394 2559          }
2395 2560  
2396 2561          tem_safe_callback_cursor(tem, VIS_DISPLAY_CURSOR, credp, called_from);
2397 2562  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX