diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/uts/common/io/tem.c | 32 | ||||
-rw-r--r-- | usr/src/uts/common/io/tem_safe.c | 85 | ||||
-rw-r--r-- | usr/src/uts/common/sys/tem_impl.h | 13 |
3 files changed, 104 insertions, 26 deletions
diff --git a/usr/src/uts/common/io/tem.c b/usr/src/uts/common/io/tem.c index 29bd71e95c..e6a3e2edd6 100644 --- a/usr/src/uts/common/io/tem.c +++ b/usr/src/uts/common/io/tem.c @@ -458,6 +458,7 @@ tem_info_init(char *pathname, cred_t *credp) /* 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); @@ -533,6 +534,7 @@ tems_setup_terminal(struct vis_devinit *tp, size_t height, size_t width) 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: @@ -679,14 +681,28 @@ tems_modechange_callback(struct vis_modechg_arg *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, - cred_t *credp) +tems_display_layered(struct vis_consdisplay *pda, + cred_t *credp) { int rval; @@ -701,9 +717,8 @@ tems_display_layered( * such as from vi when deleting characters and words. */ void -tems_copy_layered( - struct vis_conscopy *pma, - cred_t *credp) +tems_copy_layered(struct vis_conscopy *pma, + cred_t *credp) { int rval; @@ -716,9 +731,8 @@ tems_copy_layered( * pixel inverting, text block cursor via the underlying framebuffer. */ void -tems_cursor_layered( - struct vis_conscursor *pca, - cred_t *credp) +tems_cursor_layered(struct vis_conscursor *pca, + cred_t *credp) { int rval; diff --git a/usr/src/uts/common/io/tem_safe.c b/usr/src/uts/common/io/tem_safe.c index b039a816de..a0e30ffa3f 100644 --- a/usr/src/uts/common/io/tem_safe.c +++ b/usr/src/uts/common/io/tem_safe.c @@ -151,6 +151,8 @@ static void bit_to_pix4(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color, text_color_t bg_color); static void bit_to_pix8(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color, text_color_t bg_color); +static void bit_to_pix16(struct tem_vt_state *tem, uchar_t c, + text_color_t fg_color, text_color_t bg_color); static void bit_to_pix24(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color, text_color_t bg_color); static void bit_to_pix32(struct tem_vt_state *tem, uchar_t c, @@ -1603,6 +1605,10 @@ tem_safe_pix_bit2pix(struct tem_vt_state *tem, unsigned char c, case 8: fp = bit_to_pix8; break; + case 15: + case 16: + fp = bit_to_pix16; + break; case 24: fp = bit_to_pix24; break; @@ -1682,11 +1688,20 @@ void tem_safe_pix_clear_entire_screen(struct tem_vt_state *tem, cred_t *credp, enum called_from called_from) { + struct vis_consclear cl; + text_color_t fg_color; + text_color_t bg_color; int nrows, ncols, width, height; ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) || called_from == CALLED_FROM_STANDALONE); + /* call driver first, if error, clear terminal area */ + tem_safe_get_color(tem, &fg_color, &bg_color, TEM_ATTR_SCREEN_REVERSE); + cl.bg_color = bg_color; + if (tems_cls_layered(&cl, credp) == 0) + return; + width = tems.ts_font.width; height = tems.ts_font.height; @@ -2012,6 +2027,8 @@ tem_safe_pix_cursor(struct tem_vt_state *tem, short action, cred_t *credp, enum called_from called_from) { struct vis_conscursor ca; + uint32_t color; + text_color_t fg, bg; ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) || called_from == CALLED_FROM_STANDALONE); @@ -2022,15 +2039,28 @@ tem_safe_pix_cursor(struct tem_vt_state *tem, short action, tems.ts_p_offset.x; ca.width = tems.ts_font.width; ca.height = tems.ts_font.height; - if (tems.ts_pdepth == 8 || tems.ts_pdepth == 4) { - if (tem->tvs_flags & TEM_ATTR_REVERSE) { - ca.fg_color.mono = TEM_TEXT_WHITE; - ca.bg_color.mono = TEM_TEXT_BLACK; - } else { - ca.fg_color.mono = TEM_TEXT_BLACK; - ca.bg_color.mono = TEM_TEXT_WHITE; - } - } else if (tems.ts_pdepth == 24 || tems.ts_pdepth == 32) { + + tem_safe_get_color(tem, &fg, &bg, TEM_ATTR_REVERSE); + + switch (tems.ts_pdepth) { + case 4: + case 8: + ca.fg_color.mono = fg; + ca.bg_color.mono = bg; + break; + case 15: + case 16: + color = tems.ts_color_map(fg); + ca.fg_color.sixteen[0] = (color >> 8) & 0xFF; + ca.fg_color.sixteen[1] = color & 0xFF; + color = tems.ts_color_map(bg); + ca.bg_color.sixteen[0] = (color >> 8) & 0xFF; + ca.bg_color.sixteen[1] = color & 0xFF; + break; + case 24: + case 32: +#ifdef _HAVE_TEM_FIRMWARE + /* Keeping this block to support old binary only drivers */ if (tem->tvs_flags & TEM_ATTR_REVERSE) { ca.fg_color.twentyfour[0] = TEM_TEXT_WHITE24_RED; ca.fg_color.twentyfour[1] = TEM_TEXT_WHITE24_GREEN; @@ -2048,6 +2078,17 @@ tem_safe_pix_cursor(struct tem_vt_state *tem, short action, ca.bg_color.twentyfour[1] = TEM_TEXT_WHITE24_GREEN; ca.bg_color.twentyfour[2] = TEM_TEXT_WHITE24_BLUE; } +#else + color = tems.ts_color_map(fg); + ca.fg_color.twentyfour[0] = (color >> 16) & 0xFF; + ca.fg_color.twentyfour[1] = (color >> 8) & 0xFF; + ca.fg_color.twentyfour[2] = color & 0xFF; + color = tems.ts_color_map(bg); + ca.bg_color.twentyfour[0] = (color >> 16) & 0xFF; + ca.bg_color.twentyfour[1] = (color >> 8) & 0xFF; + ca.bg_color.twentyfour[2] = color & 0xFF; + break; +#endif } ca.action = action; @@ -2079,6 +2120,22 @@ bit_to_pix8(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color, } static void +bit_to_pix16(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color4, + text_color_t bg_color4) +{ + uint16_t fg_color16, bg_color16; + uint16_t *dest; + + ASSERT(fg_color4 < 16 && bg_color4 < 16); + + fg_color16 = (uint16_t)tems.ts_color_map(fg_color4); + bg_color16 = (uint16_t)tems.ts_color_map(bg_color4); + + dest = (uint16_t *)tem->tvs_pix_data; + font_bit_to_pix16(&tems.ts_font, dest, c, fg_color16, bg_color16); +} + +static void bit_to_pix24(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color4, text_color_t bg_color4) { @@ -2087,8 +2144,13 @@ bit_to_pix24(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color4, ASSERT(fg_color4 < 16 && bg_color4 < 16); +#ifdef _HAVE_TEM_FIRMWARE fg_color32 = PIX4TO32(fg_color4); bg_color32 = PIX4TO32(bg_color4); +#else + fg_color32 = tems.ts_color_map(fg_color4); + bg_color32 = tems.ts_color_map(bg_color4); +#endif dest = (uint8_t *)tem->tvs_pix_data; font_bit_to_pix24(&tems.ts_font, dest, c, fg_color32, bg_color32); @@ -2102,8 +2164,13 @@ bit_to_pix32(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color4, ASSERT(fg_color4 < 16 && bg_color4 < 16); +#ifdef _HAVE_TEM_FIRMWARE fg_color32 = PIX4TO32(fg_color4); bg_color32 = PIX4TO32(bg_color4); +#else + fg_color32 = ((uint32_t)0xFF << 24) | tems.ts_color_map(fg_color4); + bg_color32 = ((uint32_t)0xFF << 24) | tems.ts_color_map(bg_color4); +#endif dest = (uint32_t *)tem->tvs_pix_data; font_bit_to_pix32(&tems.ts_font, dest, c, fg_color32, bg_color32); diff --git a/usr/src/uts/common/sys/tem_impl.h b/usr/src/uts/common/sys/tem_impl.h index 70fe126132..de7f43be0d 100644 --- a/usr/src/uts/common/sys/tem_impl.h +++ b/usr/src/uts/common/sys/tem_impl.h @@ -27,7 +27,7 @@ /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ #ifndef _SYS_TEM_IMPL_H #define _SYS_TEM_IMPL_H @@ -101,14 +101,8 @@ extern "C" { * Default foreground/background color */ -#ifdef _HAVE_TEM_FIRMWARE #define DEFAULT_ANSI_FOREGROUND ANSI_COLOR_BLACK #define DEFAULT_ANSI_BACKGROUND ANSI_COLOR_WHITE -#else /* _HAVE_TEM_FIRMWARE */ -#define DEFAULT_ANSI_FOREGROUND ANSI_COLOR_WHITE -#define DEFAULT_ANSI_BACKGROUND ANSI_COLOR_BLACK -#endif - #define BUF_LEN 160 /* Two lines of data can be processed at a time */ @@ -170,7 +164,7 @@ struct tem_vt_state { unsigned char *tvs_outbuf; /* place to keep incomplete lines */ int tvs_outbuf_size; int tvs_outindex; /* index into a_outbuf */ - void *tvs_pix_data; /* pointer to tmp bitmap area */ + void *tvs_pix_data; /* pointer to tmp bitmap area */ int tvs_pix_data_size; text_color_t tvs_fg_color; text_color_t tvs_bg_color; @@ -233,6 +227,8 @@ typedef struct tem_state { tem_modechg_cb_t ts_modechg_cb; tem_modechg_cb_arg_t ts_modechg_arg; + color_map_fn_t ts_color_map; + tem_color_t ts_init_color; /* initial color and attributes */ struct tem_vt_state *ts_active; @@ -250,6 +246,7 @@ extern tem_safe_callbacks_t tem_safe_pix_callbacks; * (tem_state_t), and tem_* functions mean that they operate on the * per-tem structure (tem_vt_state). All "safe" interfaces are in tem_safe.c. */ +int tems_cls_layered(struct vis_consclear *, cred_t *); void tems_display_layered(struct vis_consdisplay *, cred_t *); void tems_copy_layered(struct vis_conscopy *, cred_t *); void tems_cursor_layered(struct vis_conscursor *, cred_t *); |