Index: stable/11/sys/dev/syscons/scgfbrndr.c =================================================================== --- stable/11/sys/dev/syscons/scgfbrndr.c (revision 330919) +++ stable/11/sys/dev/syscons/scgfbrndr.c (revision 330920) @@ -1,368 +1,352 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 1999 Kazutaka YOKOTA * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer as * the first lines of this file unmodified. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (c) 2000 Andrew Miklic */ #include __FBSDID("$FreeBSD$"); #include "opt_syscons.h" #include "opt_gfb.h" #ifdef __powerpc__ #include "opt_ofwfb.h" #endif #include #include #include #include #include #include #include #include #ifndef SC_RENDER_DEBUG #define SC_RENDER_DEBUG 0 #endif static vr_clear_t gfb_clear; static vr_draw_border_t gfb_border; static vr_draw_t gfb_draw; static vr_set_cursor_t gfb_cursor_shape; static vr_draw_cursor_t gfb_cursor; static vr_blink_cursor_t gfb_blink; #ifndef SC_NO_CUTPASTE static vr_draw_mouse_t gfb_mouse; #else #define gfb_mouse (vr_draw_mouse_t *)gfb_nop #endif static void gfb_nop(scr_stat *scp); sc_rndr_sw_t txtrndrsw = { (vr_init_t *)gfb_nop, gfb_clear, gfb_border, gfb_draw, gfb_cursor_shape, gfb_cursor, gfb_blink, (vr_set_mouse_t *)gfb_nop, gfb_mouse, }; #ifdef SC_PIXEL_MODE sc_rndr_sw_t gfbrndrsw = { (vr_init_t *)gfb_nop, gfb_clear, gfb_border, gfb_draw, gfb_cursor_shape, gfb_cursor, gfb_blink, (vr_set_mouse_t *)gfb_nop, gfb_mouse, }; #endif /* SC_PIXEL_MODE */ #ifndef SC_NO_MODE_CHANGE sc_rndr_sw_t grrndrsw = { (vr_init_t *)gfb_nop, (vr_clear_t *)gfb_nop, gfb_border, (vr_draw_t *)gfb_nop, (vr_set_cursor_t *)gfb_nop, (vr_draw_cursor_t *)gfb_nop, (vr_blink_cursor_t *)gfb_nop, (vr_set_mouse_t *)gfb_nop, (vr_draw_mouse_t *)gfb_nop, }; #endif /* SC_NO_MODE_CHANGE */ #ifndef SC_NO_CUTPASTE #ifdef __sparc64__ static u_char mouse_pointer[22 * 2] = { 0x00, 0x00, /* ............ */ 0x80, 0x00, /* *........... */ 0xc0, 0x00, /* **.......... */ 0xe0, 0x00, /* ***......... */ 0xf0, 0x00, /* ****........ */ 0xf8, 0x00, /* *****....... */ 0xfc, 0x00, /* ******...... */ 0xfe, 0x00, /* *******..... */ 0xff, 0x00, /* ********.... */ 0xff, 0x80, /* *********... */ 0xfc, 0xc0, /* ******..**.. */ 0xdc, 0x00, /* **.***...... */ 0x8e, 0x00, /* *...***..... */ 0x0e, 0x00, /* ....***..... */ 0x07, 0x00, /* .....***.... */ 0x04, 0x00, /* .....*...... */ 0x00, 0x00, /* ............ */ 0x00, 0x00, /* ............ */ 0x00, 0x00, /* ............ */ 0x00, 0x00, /* ............ */ 0x00, 0x00, /* ............ */ 0x00, 0x00 /* ............ */ }; #else static u_char mouse_pointer[16] = { 0x00, 0x40, 0x60, 0x70, 0x78, 0x7c, 0x7e, 0x68, 0x0c, 0x0c, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00 }; #endif #endif static void gfb_nop(scr_stat *scp) { } /* text mode renderer */ static void gfb_clear(scr_stat *scp, int c, int attr) { vidd_clear(scp->sc->adp); } static void gfb_border(scr_stat *scp, int color) { vidd_set_border(scp->sc->adp, color); } static void gfb_draw(scr_stat *scp, int from, int count, int flip) { int c; int a; int i, n; video_adapter_t *adp; adp = scp->sc->adp; /* Determine if we need to scroll based on the offset and the number of characters to be displayed... */ if (from + count > scp->xsize*scp->ysize) { /* Calculate the number of characters past the end of the visible screen... */ count = (from + count) - (adp->va_info.vi_width * adp->va_info.vi_height); /* Calculate the number of rows past the end of the visible screen... */ n = (count / adp->va_info.vi_width) + 1; /* Scroll to make room for new text rows... */ vidd_copy(adp, n, 0, n); #if 0 vidd_clear(adp, n); #endif /* Display new text rows... */ vidd_puts(adp, from, (u_int16_t *)sc_vtb_pointer(&scp->vtb, from), count); } /* We don't need to scroll, so we can just put the characters all-at-once... */ else { /* Determine the method by which we are to display characters (are we going to print forwards or backwards? do we need to do a character-by-character copy, then?)... */ if (flip) for (i = count; i-- > 0; ++from) { c = sc_vtb_getc(&scp->vtb, from); a = sc_vtb_geta(&scp->vtb, from) >> 8; vidd_putc(adp, from, c, (a >> 4) | ((a & 0xf) << 4)); } else { vidd_puts(adp, from, (u_int16_t *)sc_vtb_pointer(&scp->vtb, from), count); } } } static void gfb_cursor_shape(scr_stat *scp, int base, int height, int blink) { if (base < 0 || base >= scp->font_size) return; /* the caller may set height <= 0 in order to disable the cursor */ #if 0 scp->cursor_base = base; scp->cursor_height = height; #endif vidd_set_hw_cursor_shape(scp->sc->adp, base, height, scp->font_size, blink); } static int pxlblinkrate = 0; #if defined(__sparc64__) || defined(SC_OFWFB) static void gfb_cursor(scr_stat *scp, int at, int blink, int on, int flip) { video_adapter_t *adp; int a, c; if (scp->curs_attr.height <= 0) /* the text cursor is disabled */ return; adp = scp->sc->adp; if(blink) { scp->status |= VR_CURSOR_BLINK; if (on) { scp->status |= VR_CURSOR_ON; vidd_set_hw_cursor(adp, at%scp->xsize, at/scp->xsize); } else { if (scp->status & VR_CURSOR_ON) vidd_set_hw_cursor(adp, -1, -1); scp->status &= ~VR_CURSOR_ON; } } else { scp->status &= ~VR_CURSOR_BLINK; if(on) { scp->status |= VR_CURSOR_ON; vidd_putc(scp->sc->adp, scp->cursor_oldpos, sc_vtb_getc(&scp->vtb, scp->cursor_oldpos), sc_vtb_geta(&scp->vtb, scp->cursor_oldpos) >> 8); a = sc_vtb_geta(&scp->vtb, at) >> 8; c = sc_vtb_getc(&scp->vtb, at); vidd_putc(scp->sc->adp, at, c, (a >> 4) | ((a & 0xf) << 4)); - scp->cursor_saveunder_attr = a; - scp->cursor_saveunder_char = c; } else { if (scp->status & VR_CURSOR_ON) vidd_putc(scp->sc->adp, at, - scp->cursor_saveunder_char, - scp->cursor_saveunder_attr); + sc_vtb_getc(&scp->vtb, at), + sc_vtb_geta(&scp->vtb, at) >> 8); scp->status &= ~VR_CURSOR_ON; } } } #else static void gfb_cursor(scr_stat *scp, int at, int blink, int on, int flip) { video_adapter_t *adp; adp = scp->sc->adp; if (scp->curs_attr.height <= 0) /* the text cursor is disabled */ return; if (on) { if (!blink) { scp->status |= VR_CURSOR_ON; vidd_set_hw_cursor(adp, at%scp->xsize, at/scp->xsize); } else if (++pxlblinkrate & 4) { pxlblinkrate = 0; scp->status ^= VR_CURSOR_ON; if(scp->status & VR_CURSOR_ON) vidd_set_hw_cursor(adp, at%scp->xsize, at/scp->xsize); else vidd_set_hw_cursor(adp, -1, -1); } } else { if (scp->status & VR_CURSOR_ON) vidd_set_hw_cursor(adp, at%scp->xsize, at/scp->xsize); scp->status &= ~VR_CURSOR_ON; } if (blink) scp->status |= VR_CURSOR_BLINK; else scp->status &= ~VR_CURSOR_BLINK; } #endif static void gfb_blink(scr_stat *scp, int at, int flip) { if (!(scp->status & VR_CURSOR_BLINK)) return; if (!(++pxlblinkrate & 4)) return; pxlblinkrate = 0; scp->status ^= VR_CURSOR_ON; gfb_cursor(scp, at, scp->status & VR_CURSOR_BLINK, scp->status & VR_CURSOR_ON, flip); } #ifndef SC_NO_CUTPASTE static void gfb_mouse(scr_stat *scp, int x, int y, int on) { #ifdef __sparc64__ - vidd_putm(scp->sc->adp, x, y, mouse_pointer, - on ? 0xffffffff : 0x0, 22, 12); + vidd_putm(scp->sc->adp, x, y, mouse_pointer, + on ? 0xffffffff : 0x0, 22, 12); #else - int i, pos; - if (on) { - - /* Display the mouse pointer image... */ vidd_putm(scp->sc->adp, x, y, mouse_pointer, 0xffffffff, 16, 8); } else { - - /* - Erase the mouse cursor image by redrawing the text - underneath it... - */ - return; - pos = x*scp->xsize + y; - i = (y < scp->xsize - 1) ? 2 : 1; - (*scp->rndr->draw)(scp, pos, i, FALSE); - if (x < scp->ysize - 1) - (*scp->rndr->draw)(scp, pos + scp->xsize, i, FALSE); + /* XXX: removal is incomplete for h/w cursors and borders. */ } #endif } #endif /* SC_NO_CUTPASTE */ Index: stable/11/sys/dev/syscons/scterm-teken.c =================================================================== --- stable/11/sys/dev/syscons/scterm-teken.c (revision 330919) +++ stable/11/sys/dev/syscons/scterm-teken.c (revision 330920) @@ -1,703 +1,709 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 1999 Kazutaka YOKOTA * All rights reserved. * * Copyright (c) 2008-2009 Ed Schouten * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer as * the first lines of this file unmodified. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include "opt_syscons.h" #include "opt_teken.h" #include #include #include #include #include #include #if defined(__arm__) || defined(__mips__) || \ defined(__powerpc__) || defined(__sparc64__) #include #else #include #endif #include #include static void scteken_sc_to_te_attr(unsigned char, teken_attr_t *); static int scteken_te_to_sc_attr(const teken_attr_t *); static sc_term_init_t scteken_init; static sc_term_term_t scteken_term; static sc_term_puts_t scteken_puts; static sc_term_ioctl_t scteken_ioctl; static sc_term_default_attr_t scteken_default_attr; static sc_term_clear_t scteken_clear; static sc_term_input_t scteken_input; static sc_term_fkeystr_t scteken_fkeystr; static sc_term_sync_t scteken_sync; static void scteken_nop(void); typedef struct { teken_t ts_teken; int ts_busy; } teken_stat; static teken_stat reserved_teken_stat; +static void scteken_sync_internal(scr_stat *, teken_stat *); + static sc_term_sw_t sc_term_scteken = { { NULL, NULL }, "scteken", /* emulator name */ "teken terminal", /* description */ "*", /* matching renderer */ sizeof(teken_stat), /* softc size */ 0, scteken_init, scteken_term, scteken_puts, scteken_ioctl, (sc_term_reset_t *)scteken_nop, scteken_default_attr, scteken_clear, (sc_term_notify_t *)scteken_nop, scteken_input, scteken_fkeystr, scteken_sync, }; SCTERM_MODULE(scteken, sc_term_scteken); static tf_bell_t scteken_bell; static tf_cursor_t scteken_cursor; static tf_putchar_t scteken_putchar; static tf_fill_t scteken_fill; static tf_copy_t scteken_copy; static tf_param_t scteken_param; static tf_respond_t scteken_respond; static const teken_funcs_t scteken_funcs = { .tf_bell = scteken_bell, .tf_cursor = scteken_cursor, .tf_putchar = scteken_putchar, .tf_fill = scteken_fill, .tf_copy = scteken_copy, .tf_param = scteken_param, .tf_respond = scteken_respond, }; static int scteken_init(scr_stat *scp, void **softc, int code) { teken_stat *ts; - teken_pos_t tp; + teken_attr_t ta; if (*softc == NULL) { if (reserved_teken_stat.ts_busy) return (EINVAL); *softc = &reserved_teken_stat; } ts = *softc; switch (code) { case SC_TE_COLD_INIT: ++sc_term_scteken.te_refcount; ts->ts_busy = 1; /* FALLTHROUGH */ case SC_TE_WARM_INIT: + ta = *teken_get_defattr(&ts->ts_teken); teken_init(&ts->ts_teken, &scteken_funcs, scp); + teken_set_defattr(&ts->ts_teken, &ta); #ifndef TEKEN_UTF8 teken_set_8bit(&ts->ts_teken); #endif /* !TEKEN_UTF8 */ #ifdef TEKEN_CONS25 teken_set_cons25(&ts->ts_teken); #endif /* TEKEN_CONS25 */ - - tp.tp_row = scp->ysize; - tp.tp_col = scp->xsize; - teken_set_winsize(&ts->ts_teken, &tp); + scteken_sync_internal(scp, ts); break; } return (0); } static int scteken_term(scr_stat *scp, void **softc) { if (*softc == &reserved_teken_stat) { *softc = NULL; reserved_teken_stat.ts_busy = 0; } --sc_term_scteken.te_refcount; return (0); } static void scteken_puts(scr_stat *scp, u_char *buf, int len) { teken_stat *ts = scp->ts; scp->sc->write_in_progress++; teken_input(&ts->ts_teken, buf, len); scp->sc->write_in_progress--; } static int scteken_ioctl(scr_stat *scp, struct tty *tp, u_long cmd, caddr_t data, struct thread *td) { teken_stat *ts = scp->ts; vid_info_t *vi; int attr; switch (cmd) { case GIO_ATTR: /* get current attributes */ *(int*)data = scteken_te_to_sc_attr(teken_get_curattr(&ts->ts_teken)); return (0); case CONS_GETINFO: /* get current (virtual) console info */ vi = (vid_info_t *)data; if (vi->size != sizeof(struct vid_info)) return EINVAL; attr = scteken_te_to_sc_attr(teken_get_defattr(&ts->ts_teken)); vi->mv_norm.fore = attr & 0x0f; vi->mv_norm.back = (attr >> 4) & 0x0f; vi->mv_rev.fore = vi->mv_norm.back; vi->mv_rev.back = vi->mv_norm.fore; /* * The other fields are filled by the upper routine. XXX */ return (ENOIOCTL); } return (ENOIOCTL); } static void scteken_default_attr(scr_stat *scp, int color, int rev_color) { teken_stat *ts = scp->ts; teken_attr_t ta; scteken_sc_to_te_attr(color, &ta); teken_set_defattr(&ts->ts_teken, &ta); } static void scteken_clear(scr_stat *scp) { teken_stat *ts = scp->ts; sc_move_cursor(scp, 0, 0); - scteken_sync(scp); + scteken_sync_internal(scp, ts); sc_vtb_clear(&scp->vtb, scp->sc->scr_map[0x20], scteken_te_to_sc_attr(teken_get_curattr(&ts->ts_teken)) << 8); mark_all(scp); } static int scteken_input(scr_stat *scp, int c, struct tty *tp) { return FALSE; } static const char * scteken_fkeystr(scr_stat *scp, int c) { teken_stat *ts = scp->ts; unsigned int k; switch (c) { case FKEY | F(1): case FKEY | F(2): case FKEY | F(3): case FKEY | F(4): case FKEY | F(5): case FKEY | F(6): case FKEY | F(7): case FKEY | F(8): case FKEY | F(9): case FKEY | F(10): case FKEY | F(11): case FKEY | F(12): k = TKEY_F1 + c - (FKEY | F(1)); break; case FKEY | F(49): k = TKEY_HOME; break; case FKEY | F(50): k = TKEY_UP; break; case FKEY | F(51): k = TKEY_PAGE_UP; break; case FKEY | F(53): k = TKEY_LEFT; break; case FKEY | F(55): k = TKEY_RIGHT; break; case FKEY | F(57): k = TKEY_END; break; case FKEY | F(58): k = TKEY_DOWN; break; case FKEY | F(59): k = TKEY_PAGE_DOWN; break; case FKEY | F(60): k = TKEY_INSERT; break; case FKEY | F(61): k = TKEY_DELETE; break; default: return (NULL); } return (teken_get_sequence(&ts->ts_teken, k)); } static void -scteken_sync(scr_stat *scp) +scteken_sync_internal(scr_stat *scp, teken_stat *ts) { - teken_stat *ts = scp->ts; teken_pos_t tp; tp.tp_col = scp->xsize; tp.tp_row = scp->ysize; teken_set_winsize_noreset(&ts->ts_teken, &tp); tp.tp_col = scp->xpos; tp.tp_row = scp->ypos; teken_set_cursor(&ts->ts_teken, &tp); +} + +static void +scteken_sync(scr_stat *scp) +{ + scteken_sync_internal(scp, scp->ts); } static void scteken_nop(void) { } /* * libteken routines. */ static const teken_color_t sc_to_te_color[] = { TC_BLACK, TC_BLUE, TC_GREEN, TC_CYAN, TC_RED, TC_MAGENTA, TC_BROWN, TC_WHITE, }; static const unsigned char te_to_sc_color[] = { FG_BLACK, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE, FG_MAGENTA, FG_CYAN, FG_LIGHTGREY, }; static void scteken_sc_to_te_attr(unsigned char color, teken_attr_t *a) { /* * Conversions of attrs are not reversible. Since sc attrs are * pure colors in the simplest mode (16-color graphics) and the * API is too deficient to tell us the mode, always convert to * pure colors. The conversion is essentially the identity except * for reordering the non-brightness bits in the 2 color numbers. */ a->ta_format = 0; a->ta_fgcolor = sc_to_te_color[color & 7] | (color & 8); a->ta_bgcolor = sc_to_te_color[(color >> 4) & 7] | ((color >> 4) & 8); } static int scteken_te_to_sc_attr(const teken_attr_t *a) { int attr; teken_color_t fg, bg; if (a->ta_format & TF_REVERSE) { fg = a->ta_bgcolor; bg = a->ta_fgcolor; } else { fg = a->ta_fgcolor; bg = a->ta_bgcolor; } if (fg >= 16) fg = teken_256to16(fg); if (bg >= 16) bg = teken_256to16(bg); attr = te_to_sc_color[fg & 7] | (fg & 8) | ((te_to_sc_color[bg & 7] | (bg & 8)) << 4); /* XXX: underline mapping for Hercules adapter can be better. */ if (a->ta_format & (TF_BOLD | TF_UNDERLINE)) attr ^= 8; if (a->ta_format & TF_BLINK) attr ^= 0x80; return (attr); } static void scteken_bell(void *arg) { scr_stat *scp = arg; sc_bell(scp, scp->bell_pitch, scp->bell_duration); } static void scteken_cursor(void *arg, const teken_pos_t *p) { scr_stat *scp = arg; sc_move_cursor(scp, p->tp_col, p->tp_row); } #ifdef TEKEN_UTF8 struct unicp437 { uint16_t unicode_base; uint8_t cp437_base; uint8_t length; }; static const struct unicp437 cp437table[] = { { 0x0020, 0x20, 0x5e }, { 0x00a0, 0x20, 0x00 }, { 0x00a1, 0xad, 0x00 }, { 0x00a2, 0x9b, 0x00 }, { 0x00a3, 0x9c, 0x00 }, { 0x00a5, 0x9d, 0x00 }, { 0x00a7, 0x15, 0x00 }, { 0x00aa, 0xa6, 0x00 }, { 0x00ab, 0xae, 0x00 }, { 0x00ac, 0xaa, 0x00 }, { 0x00b0, 0xf8, 0x00 }, { 0x00b1, 0xf1, 0x00 }, { 0x00b2, 0xfd, 0x00 }, { 0x00b5, 0xe6, 0x00 }, { 0x00b6, 0x14, 0x00 }, { 0x00b7, 0xfa, 0x00 }, { 0x00ba, 0xa7, 0x00 }, { 0x00bb, 0xaf, 0x00 }, { 0x00bc, 0xac, 0x00 }, { 0x00bd, 0xab, 0x00 }, { 0x00bf, 0xa8, 0x00 }, { 0x00c0, 0x41, 0x00 }, { 0x00c1, 0x41, 0x00 }, { 0x00c2, 0x41, 0x00 }, { 0x00c4, 0x8e, 0x01 }, { 0x00c6, 0x92, 0x00 }, { 0x00c7, 0x80, 0x00 }, { 0x00c8, 0x45, 0x00 }, { 0x00c9, 0x90, 0x00 }, { 0x00ca, 0x45, 0x00 }, { 0x00cb, 0x45, 0x00 }, { 0x00cc, 0x49, 0x00 }, { 0x00cd, 0x49, 0x00 }, { 0x00ce, 0x49, 0x00 }, { 0x00cf, 0x49, 0x00 }, { 0x00d1, 0xa5, 0x00 }, { 0x00d2, 0x4f, 0x00 }, { 0x00d3, 0x4f, 0x00 }, { 0x00d4, 0x4f, 0x00 }, { 0x00d6, 0x99, 0x00 }, { 0x00d9, 0x55, 0x00 }, { 0x00da, 0x55, 0x00 }, { 0x00db, 0x55, 0x00 }, { 0x00dc, 0x9a, 0x00 }, { 0x00df, 0xe1, 0x00 }, { 0x00e0, 0x85, 0x00 }, { 0x00e1, 0xa0, 0x00 }, { 0x00e2, 0x83, 0x00 }, { 0x00e4, 0x84, 0x00 }, { 0x00e5, 0x86, 0x00 }, { 0x00e6, 0x91, 0x00 }, { 0x00e7, 0x87, 0x00 }, { 0x00e8, 0x8a, 0x00 }, { 0x00e9, 0x82, 0x00 }, { 0x00ea, 0x88, 0x01 }, { 0x00ec, 0x8d, 0x00 }, { 0x00ed, 0xa1, 0x00 }, { 0x00ee, 0x8c, 0x00 }, { 0x00ef, 0x8b, 0x00 }, { 0x00f0, 0xeb, 0x00 }, { 0x00f1, 0xa4, 0x00 }, { 0x00f2, 0x95, 0x00 }, { 0x00f3, 0xa2, 0x00 }, { 0x00f4, 0x93, 0x00 }, { 0x00f6, 0x94, 0x00 }, { 0x00f7, 0xf6, 0x00 }, { 0x00f8, 0xed, 0x00 }, { 0x00f9, 0x97, 0x00 }, { 0x00fa, 0xa3, 0x00 }, { 0x00fb, 0x96, 0x00 }, { 0x00fc, 0x81, 0x00 }, { 0x00ff, 0x98, 0x00 }, { 0x013f, 0x4c, 0x00 }, { 0x0140, 0x6c, 0x00 }, { 0x0192, 0x9f, 0x00 }, { 0x0393, 0xe2, 0x00 }, { 0x0398, 0xe9, 0x00 }, { 0x03a3, 0xe4, 0x00 }, { 0x03a6, 0xe8, 0x00 }, { 0x03a9, 0xea, 0x00 }, { 0x03b1, 0xe0, 0x01 }, { 0x03b4, 0xeb, 0x00 }, { 0x03b5, 0xee, 0x00 }, { 0x03bc, 0xe6, 0x00 }, { 0x03c0, 0xe3, 0x00 }, { 0x03c3, 0xe5, 0x00 }, { 0x03c4, 0xe7, 0x00 }, { 0x03c6, 0xed, 0x00 }, { 0x03d5, 0xed, 0x00 }, { 0x2010, 0x2d, 0x00 }, { 0x2014, 0x2d, 0x00 }, { 0x2018, 0x60, 0x00 }, { 0x2019, 0x27, 0x00 }, { 0x201c, 0x22, 0x00 }, { 0x201d, 0x22, 0x00 }, { 0x2022, 0x07, 0x00 }, { 0x203c, 0x13, 0x00 }, { 0x207f, 0xfc, 0x00 }, { 0x20a7, 0x9e, 0x00 }, { 0x20ac, 0xee, 0x00 }, { 0x2126, 0xea, 0x00 }, { 0x2190, 0x1b, 0x00 }, { 0x2191, 0x18, 0x00 }, { 0x2192, 0x1a, 0x00 }, { 0x2193, 0x19, 0x00 }, { 0x2194, 0x1d, 0x00 }, { 0x2195, 0x12, 0x00 }, { 0x21a8, 0x17, 0x00 }, { 0x2202, 0xeb, 0x00 }, { 0x2208, 0xee, 0x00 }, { 0x2211, 0xe4, 0x00 }, { 0x2212, 0x2d, 0x00 }, { 0x2219, 0xf9, 0x00 }, { 0x221a, 0xfb, 0x00 }, { 0x221e, 0xec, 0x00 }, { 0x221f, 0x1c, 0x00 }, { 0x2229, 0xef, 0x00 }, { 0x2248, 0xf7, 0x00 }, { 0x2261, 0xf0, 0x00 }, { 0x2264, 0xf3, 0x00 }, { 0x2265, 0xf2, 0x00 }, { 0x2302, 0x7f, 0x00 }, { 0x2310, 0xa9, 0x00 }, { 0x2320, 0xf4, 0x00 }, { 0x2321, 0xf5, 0x00 }, { 0x2500, 0xc4, 0x00 }, { 0x2502, 0xb3, 0x00 }, { 0x250c, 0xda, 0x00 }, { 0x2510, 0xbf, 0x00 }, { 0x2514, 0xc0, 0x00 }, { 0x2518, 0xd9, 0x00 }, { 0x251c, 0xc3, 0x00 }, { 0x2524, 0xb4, 0x00 }, { 0x252c, 0xc2, 0x00 }, { 0x2534, 0xc1, 0x00 }, { 0x253c, 0xc5, 0x00 }, { 0x2550, 0xcd, 0x00 }, { 0x2551, 0xba, 0x00 }, { 0x2552, 0xd5, 0x00 }, { 0x2553, 0xd6, 0x00 }, { 0x2554, 0xc9, 0x00 }, { 0x2555, 0xb8, 0x00 }, { 0x2556, 0xb7, 0x00 }, { 0x2557, 0xbb, 0x00 }, { 0x2558, 0xd4, 0x00 }, { 0x2559, 0xd3, 0x00 }, { 0x255a, 0xc8, 0x00 }, { 0x255b, 0xbe, 0x00 }, { 0x255c, 0xbd, 0x00 }, { 0x255d, 0xbc, 0x00 }, { 0x255e, 0xc6, 0x01 }, { 0x2560, 0xcc, 0x00 }, { 0x2561, 0xb5, 0x00 }, { 0x2562, 0xb6, 0x00 }, { 0x2563, 0xb9, 0x00 }, { 0x2564, 0xd1, 0x01 }, { 0x2566, 0xcb, 0x00 }, { 0x2567, 0xcf, 0x00 }, { 0x2568, 0xd0, 0x00 }, { 0x2569, 0xca, 0x00 }, { 0x256a, 0xd8, 0x00 }, { 0x256b, 0xd7, 0x00 }, { 0x256c, 0xce, 0x00 }, { 0x2580, 0xdf, 0x00 }, { 0x2584, 0xdc, 0x00 }, { 0x2588, 0xdb, 0x00 }, { 0x258c, 0xdd, 0x00 }, { 0x2590, 0xde, 0x00 }, { 0x2591, 0xb0, 0x02 }, { 0x25a0, 0xfe, 0x00 }, { 0x25ac, 0x16, 0x00 }, { 0x25ae, 0xdb, 0x00 }, { 0x25b2, 0x1e, 0x00 }, { 0x25ba, 0x10, 0x00 }, { 0x25bc, 0x1f, 0x00 }, { 0x25c4, 0x11, 0x00 }, { 0x25cb, 0x09, 0x00 }, { 0x25d8, 0x08, 0x00 }, { 0x25d9, 0x0a, 0x00 }, { 0x263a, 0x01, 0x01 }, { 0x263c, 0x0f, 0x00 }, { 0x2640, 0x0c, 0x00 }, { 0x2642, 0x0b, 0x00 }, { 0x2660, 0x06, 0x00 }, { 0x2663, 0x05, 0x00 }, { 0x2665, 0x03, 0x01 }, { 0x266a, 0x0d, 0x01 }, }; static void scteken_get_cp437(teken_char_t *c, int *attr) { int min, mid, max; min = 0; max = (sizeof(cp437table) / sizeof(struct unicp437)) - 1; if (*c < cp437table[0].unicode_base || *c > cp437table[max].unicode_base + cp437table[max].length) goto bad; while (max >= min) { mid = (min + max) / 2; if (*c < cp437table[mid].unicode_base) { max = mid - 1; } else if (*c > cp437table[mid].unicode_base + cp437table[mid].length) { min = mid + 1; } else { *c -= cp437table[mid].unicode_base; *c += cp437table[mid].cp437_base; return; } } bad: /* Character not present in CP437. */ *attr = (FG_RED|BG_BLACK) << 8; *c = '?'; } #endif /* TEKEN_UTF8 */ static void scteken_putchar(void *arg, const teken_pos_t *tp, teken_char_t c, const teken_attr_t *a) { scr_stat *scp = arg; u_char *map; u_char ch; vm_offset_t p; int cursor, attr; /* * No support for printing right hand sides for CJK fullwidth * characters. Simply print a space and assume that the left * hand side describes the entire character. */ attr = scteken_te_to_sc_attr(a) << 8; if (a->ta_format & TF_CJK_RIGHT) c = ' '; #ifdef TEKEN_UTF8 scteken_get_cp437(&c, &attr); #endif /* TEKEN_UTF8 */ ch = c; map = scp->sc->scr_map; cursor = tp->tp_row * scp->xsize + tp->tp_col; p = sc_vtb_pointer(&scp->vtb, cursor); sc_vtb_putchar(&scp->vtb, p, map[ch], attr); mark_for_update(scp, cursor); /* * XXX: Why do we need this? Only marking `cursor' should be * enough. Without this line, we get artifacts. */ mark_for_update(scp, imin(cursor + 1, scp->xsize * scp->ysize - 1)); } static void scteken_fill(void *arg, const teken_rect_t *r, teken_char_t c, const teken_attr_t *a) { scr_stat *scp = arg; u_char *map; u_char ch; unsigned int width; int attr, row; attr = scteken_te_to_sc_attr(a) << 8; #ifdef TEKEN_UTF8 scteken_get_cp437(&c, &attr); #endif /* TEKEN_UTF8 */ ch = c; map = scp->sc->scr_map; if (r->tr_begin.tp_col == 0 && r->tr_end.tp_col == scp->xsize) { /* Single contiguous region to fill. */ sc_vtb_erase(&scp->vtb, r->tr_begin.tp_row * scp->xsize, (r->tr_end.tp_row - r->tr_begin.tp_row) * scp->xsize, map[ch], attr); } else { /* Fill display line by line. */ width = r->tr_end.tp_col - r->tr_begin.tp_col; for (row = r->tr_begin.tp_row; row < r->tr_end.tp_row; row++) { sc_vtb_erase(&scp->vtb, r->tr_begin.tp_row * scp->xsize + r->tr_begin.tp_col, width, map[ch], attr); } } /* Mark begin and end positions to be refreshed. */ mark_for_update(scp, r->tr_begin.tp_row * scp->xsize + r->tr_begin.tp_col); mark_for_update(scp, (r->tr_end.tp_row - 1) * scp->xsize + (r->tr_end.tp_col - 1)); sc_remove_cutmarking(scp); } static void scteken_copy(void *arg, const teken_rect_t *r, const teken_pos_t *p) { scr_stat *scp = arg; unsigned int width; int src, dst, end; #ifndef SC_NO_HISTORY /* * We count a line of input as history if we perform a copy of * one whole line upward. In other words: if a line of text gets * overwritten by a rectangle that's right below it. */ if (scp->history != NULL && r->tr_begin.tp_col == 0 && r->tr_end.tp_col == scp->xsize && r->tr_begin.tp_row == p->tp_row + 1) { sc_hist_save_one_line(scp, p->tp_row); } #endif if (r->tr_begin.tp_col == 0 && r->tr_end.tp_col == scp->xsize) { /* Single contiguous region to copy. */ sc_vtb_move(&scp->vtb, r->tr_begin.tp_row * scp->xsize, p->tp_row * scp->xsize, (r->tr_end.tp_row - r->tr_begin.tp_row) * scp->xsize); } else { /* Copy line by line. */ width = r->tr_end.tp_col - r->tr_begin.tp_col; if (p->tp_row < r->tr_begin.tp_row) { /* Copy from top to bottom. */ src = r->tr_begin.tp_row * scp->xsize + r->tr_begin.tp_col; end = r->tr_end.tp_row * scp->xsize + r->tr_end.tp_col; dst = p->tp_row * scp->xsize + p->tp_col; while (src < end) { sc_vtb_move(&scp->vtb, src, dst, width); src += scp->xsize; dst += scp->xsize; } } else { /* Copy from bottom to top. */ src = (r->tr_end.tp_row - 1) * scp->xsize + r->tr_begin.tp_col; end = r->tr_begin.tp_row * scp->xsize + r->tr_begin.tp_col; dst = (p->tp_row + r->tr_end.tp_row - r->tr_begin.tp_row - 1) * scp->xsize + p->tp_col; while (src >= end) { sc_vtb_move(&scp->vtb, src, dst, width); src -= scp->xsize; dst -= scp->xsize; } } } /* Mark begin and end positions to be refreshed. */ mark_for_update(scp, p->tp_row * scp->xsize + p->tp_col); mark_for_update(scp, (p->tp_row + r->tr_end.tp_row - r->tr_begin.tp_row - 1) * scp->xsize + (p->tp_col + r->tr_end.tp_col - r->tr_begin.tp_col - 1)); sc_remove_cutmarking(scp); } static void scteken_param(void *arg, int cmd, unsigned int value) { scr_stat *scp = arg; switch (cmd) { case TP_SHOWCURSOR: if (value) { sc_change_cursor_shape(scp, CONS_RESET_CURSOR|CONS_LOCAL_CURSOR, -1, -1); } else { sc_change_cursor_shape(scp, CONS_HIDDEN_CURSOR|CONS_LOCAL_CURSOR, -1, -1); } break; case TP_SWITCHVT: sc_switch_scr(scp->sc, value); break; case TP_SETBELLPD: scp->bell_pitch = TP_SETBELLPD_PITCH(value); scp->bell_duration = TP_SETBELLPD_DURATION(value); break; case TP_MOUSE: scp->mouse_level = value; break; } } static void scteken_respond(void *arg, const void *buf, size_t len) { scr_stat *scp = arg; sc_respond(scp, buf, len, 0); } Index: stable/11/sys/dev/syscons/scvgarndr.c =================================================================== --- stable/11/sys/dev/syscons/scvgarndr.c (revision 330919) +++ stable/11/sys/dev/syscons/scvgarndr.c (revision 330920) @@ -1,1284 +1,1252 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 1999 Kazutaka YOKOTA * All rights reserved. * * This code is derived from software contributed to The DragonFly Project * by Sascha Wildner * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer as * the first lines of this file unmodified. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include __FBSDID("$FreeBSD$"); #include "opt_syscons.h" #include "opt_vga.h" #include #include #include #include #include #include #include #include #include #include #include #ifndef SC_RENDER_DEBUG #define SC_RENDER_DEBUG 0 #endif static vr_clear_t vga_txtclear; static vr_draw_border_t vga_txtborder; static vr_draw_t vga_txtdraw; static vr_set_cursor_t vga_txtcursor_shape; static vr_draw_cursor_t vga_txtcursor; static vr_blink_cursor_t vga_txtblink; #ifndef SC_NO_CUTPASTE static vr_draw_mouse_t vga_txtmouse; #else #define vga_txtmouse (vr_draw_mouse_t *)vga_nop #endif #ifdef SC_PIXEL_MODE static vr_init_t vga_rndrinit; static vr_clear_t vga_pxlclear_direct; static vr_clear_t vga_pxlclear_planar; static vr_draw_border_t vga_pxlborder_direct; static vr_draw_border_t vga_pxlborder_planar; static vr_draw_t vga_egadraw; static vr_draw_t vga_vgadraw_direct; static vr_draw_t vga_vgadraw_planar; static vr_set_cursor_t vga_pxlcursor_shape; static vr_draw_cursor_t vga_pxlcursor_direct; static vr_draw_cursor_t vga_pxlcursor_planar; static vr_blink_cursor_t vga_pxlblink_direct; static vr_blink_cursor_t vga_pxlblink_planar; #ifndef SC_NO_CUTPASTE static vr_draw_mouse_t vga_pxlmouse_direct; static vr_draw_mouse_t vga_pxlmouse_planar; #else #define vga_pxlmouse_direct (vr_draw_mouse_t *)vga_nop #define vga_pxlmouse_planar (vr_draw_mouse_t *)vga_nop #endif #endif /* SC_PIXEL_MODE */ #ifndef SC_NO_MODE_CHANGE static vr_draw_border_t vga_grborder; #endif static void vga_nop(scr_stat *scp); static sc_rndr_sw_t txtrndrsw = { (vr_init_t *)vga_nop, vga_txtclear, vga_txtborder, vga_txtdraw, vga_txtcursor_shape, vga_txtcursor, vga_txtblink, (vr_set_mouse_t *)vga_nop, vga_txtmouse, }; RENDERER(mda, 0, txtrndrsw, vga_set); RENDERER(cga, 0, txtrndrsw, vga_set); RENDERER(ega, 0, txtrndrsw, vga_set); RENDERER(vga, 0, txtrndrsw, vga_set); #ifdef SC_PIXEL_MODE static sc_rndr_sw_t egarndrsw = { (vr_init_t *)vga_nop, vga_pxlclear_planar, vga_pxlborder_planar, vga_egadraw, vga_pxlcursor_shape, vga_pxlcursor_planar, vga_pxlblink_planar, (vr_set_mouse_t *)vga_nop, vga_pxlmouse_planar, }; RENDERER(ega, PIXEL_MODE, egarndrsw, vga_set); static sc_rndr_sw_t vgarndrsw = { vga_rndrinit, (vr_clear_t *)vga_nop, (vr_draw_border_t *)vga_nop, (vr_draw_t *)vga_nop, vga_pxlcursor_shape, (vr_draw_cursor_t *)vga_nop, (vr_blink_cursor_t *)vga_nop, (vr_set_mouse_t *)vga_nop, (vr_draw_mouse_t *)vga_nop, }; RENDERER(vga, PIXEL_MODE, vgarndrsw, vga_set); #endif /* SC_PIXEL_MODE */ #ifndef SC_NO_MODE_CHANGE static sc_rndr_sw_t grrndrsw = { (vr_init_t *)vga_nop, (vr_clear_t *)vga_nop, vga_grborder, (vr_draw_t *)vga_nop, (vr_set_cursor_t *)vga_nop, (vr_draw_cursor_t *)vga_nop, (vr_blink_cursor_t *)vga_nop, (vr_set_mouse_t *)vga_nop, (vr_draw_mouse_t *)vga_nop, }; RENDERER(cga, GRAPHICS_MODE, grrndrsw, vga_set); RENDERER(ega, GRAPHICS_MODE, grrndrsw, vga_set); RENDERER(vga, GRAPHICS_MODE, grrndrsw, vga_set); #endif /* SC_NO_MODE_CHANGE */ RENDERER_MODULE(vga, vga_set); #ifndef SC_NO_CUTPASTE #if !defined(SC_ALT_MOUSE_IMAGE) || defined(SC_PIXEL_MODE) +#define MOUSE_IMAGE_HEIGHT 13 +#define MOUSE_IMAGE_WIDTH 9 static u_short mouse_and_mask[16] = { 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, 0xff80, 0xfe00, 0x1e00, 0x1f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000 }; static u_short mouse_or_mask[16] = { 0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7c00, 0x7e00, 0x6800, 0x0c00, 0x0c00, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000 }; #endif #endif #ifdef SC_PIXEL_MODE #define GET_PIXEL(scp, pos, x, w) \ ({ \ (scp)->sc->adp->va_window + \ (x) * (scp)->xoff + \ (scp)->yoff * (scp)->font_size * (w) + \ (x) * ((pos) % (scp)->xsize) + \ (scp)->font_size * (w) * ((pos) / (scp)->xsize); \ }) #define DRAW_PIXEL(scp, pos, color) do { \ switch ((scp)->sc->adp->va_info.vi_depth) { \ case 32: \ writel((pos), vga_palette32[color]); \ break; \ case 24: \ if (((pos) & 1) == 0) { \ writew((pos), vga_palette32[color]); \ writeb((pos) + 2, vga_palette32[color] >> 16); \ } else { \ writeb((pos), vga_palette32[color]); \ writew((pos) + 1, vga_palette32[color] >> 8); \ } \ break; \ case 16: \ if ((scp)->sc->adp->va_info.vi_pixel_fsizes[1] == 5) \ writew((pos), vga_palette15[color]); \ else \ writew((pos), vga_palette16[color]); \ break; \ case 15: \ writew((pos), vga_palette15[color]); \ break; \ case 8: \ writeb((pos), (uint8_t)(color)); \ } \ } while (0) static uint32_t vga_palette32[16] = { 0x000000, 0x0000ad, 0x00ad00, 0x00adad, 0xad0000, 0xad00ad, 0xad5200, 0xadadad, 0x525252, 0x5252ff, 0x52ff52, 0x52ffff, 0xff5252, 0xff52ff, 0xffff52, 0xffffff }; static uint16_t vga_palette16[16] = { 0x0000, 0x0016, 0x0560, 0x0576, 0xb000, 0xb016, 0xb2a0, 0xb576, 0x52aa, 0x52bf, 0x57ea, 0x57ff, 0xfaaa, 0xfabf, 0xffea, 0xffff }; static uint16_t vga_palette15[16] = { 0x0000, 0x0016, 0x02c0, 0x02d6, 0x5800, 0x5816, 0x5940, 0x5ad6, 0x294a, 0x295f, 0x2bea, 0x2bff, 0x7d4a, 0x7d5f, 0x7fea, 0x7fff }; #ifndef SC_NO_CUTPASTE static uint32_t mouse_buf32[256]; static uint16_t mouse_buf16[256]; static uint8_t mouse_buf8[256]; #endif #endif static void vga_nop(scr_stat *scp) { } /* text mode renderer */ static void vga_txtclear(scr_stat *scp, int c, int attr) { sc_vtb_clear(&scp->scr, c, attr); } static void vga_txtborder(scr_stat *scp, int color) { vidd_set_border(scp->sc->adp, color); } static void vga_txtdraw(scr_stat *scp, int from, int count, int flip) { vm_offset_t p; int c; int a; if (from + count > scp->xsize*scp->ysize) count = scp->xsize*scp->ysize - from; if (flip) { for (p = sc_vtb_pointer(&scp->scr, from); count-- > 0; ++from) { c = sc_vtb_getc(&scp->vtb, from); a = sc_vtb_geta(&scp->vtb, from); a = (a & 0x8800) | ((a & 0x7000) >> 4) | ((a & 0x0700) << 4); p = sc_vtb_putchar(&scp->scr, p, c, a); } } else { sc_vtb_copy(&scp->vtb, from, &scp->scr, from, count); } } static void vga_txtcursor_shape(scr_stat *scp, int base, int height, int blink) { if (base < 0 || base >= scp->font_size) return; /* the caller may set height <= 0 in order to disable the cursor */ #if 0 scp->curs_attr.base = base; scp->curs_attr.height = height; #endif vidd_set_hw_cursor_shape(scp->sc->adp, base, height, scp->font_size, blink); } static void draw_txtcharcursor(scr_stat *scp, int at, u_short c, u_short a, int flip) { sc_softc_t *sc; sc = scp->sc; - scp->cursor_saveunder_char = c; - scp->cursor_saveunder_attr = a; #ifndef SC_NO_FONT_LOADING if (scp->curs_attr.flags & CONS_CHAR_CURSOR) { unsigned char *font; int h; int i; if (scp->font_size < 14) { font = sc->font_8; h = 8; } else if (scp->font_size >= 16) { font = sc->font_16; h = 16; } else { font = sc->font_14; h = 14; } if (scp->curs_attr.base >= h) return; if (flip) a = (a & 0x8800) | ((a & 0x7000) >> 4) | ((a & 0x0700) << 4); bcopy(font + c*h, font + sc->cursor_char*h, h); font = font + sc->cursor_char*h; for (i = imax(h - scp->curs_attr.base - scp->curs_attr.height, 0); i < h - scp->curs_attr.base; ++i) { font[i] ^= 0xff; } /* XXX */ vidd_load_font(sc->adp, 0, h, 8, font, sc->cursor_char, 1); sc_vtb_putc(&scp->scr, at, sc->cursor_char, a); } else #endif /* SC_NO_FONT_LOADING */ { if ((a & 0x7000) == 0x7000) { a &= 0x8f00; if ((a & 0x0700) == 0) a |= 0x0700; } else { a |= 0x7000; if ((a & 0x0700) == 0x0700) a &= 0xf000; } if (flip) a = (a & 0x8800) | ((a & 0x7000) >> 4) | ((a & 0x0700) << 4); sc_vtb_putc(&scp->scr, at, c, a); } } static void vga_txtcursor(scr_stat *scp, int at, int blink, int on, int flip) { video_adapter_t *adp; int cursor_attr; if (scp->curs_attr.height <= 0) /* the text cursor is disabled */ return; adp = scp->sc->adp; if (blink) { scp->status |= VR_CURSOR_BLINK; if (on) { scp->status |= VR_CURSOR_ON; vidd_set_hw_cursor(adp, at%scp->xsize, at/scp->xsize); } else { if (scp->status & VR_CURSOR_ON) vidd_set_hw_cursor(adp, -1, -1); scp->status &= ~VR_CURSOR_ON; } } else { scp->status &= ~VR_CURSOR_BLINK; if (on) { scp->status |= VR_CURSOR_ON; draw_txtcharcursor(scp, at, - sc_vtb_getc(&scp->scr, at), - sc_vtb_geta(&scp->scr, at), + sc_vtb_getc(&scp->vtb, at), + sc_vtb_geta(&scp->vtb, at), flip); } else { - cursor_attr = scp->cursor_saveunder_attr; + cursor_attr = sc_vtb_geta(&scp->vtb, at); if (flip) cursor_attr = (cursor_attr & 0x8800) | ((cursor_attr & 0x7000) >> 4) | ((cursor_attr & 0x0700) << 4); if (scp->status & VR_CURSOR_ON) sc_vtb_putc(&scp->scr, at, - scp->cursor_saveunder_char, + sc_vtb_getc(&scp->vtb, at), cursor_attr); scp->status &= ~VR_CURSOR_ON; } } } static void vga_txtblink(scr_stat *scp, int at, int flip) { } int sc_txtmouse_no_retrace_wait; #ifndef SC_NO_CUTPASTE static void draw_txtmouse(scr_stat *scp, int x, int y) { #ifndef SC_ALT_MOUSE_IMAGE if (ISMOUSEAVAIL(scp->sc->adp->va_flags)) { u_char font_buf[128]; u_short cursor[32]; u_char c; int pos; int xoffset, yoffset; int crtc_addr; int i; /* prepare mousepointer char's bitmaps */ pos = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff; bcopy(scp->font + sc_vtb_getc(&scp->scr, pos)*scp->font_size, &font_buf[0], scp->font_size); bcopy(scp->font + sc_vtb_getc(&scp->scr, pos + 1)*scp->font_size, &font_buf[32], scp->font_size); bcopy(scp->font + sc_vtb_getc(&scp->scr, pos + scp->xsize)*scp->font_size, &font_buf[64], scp->font_size); bcopy(scp->font + sc_vtb_getc(&scp->scr, pos + scp->xsize + 1)*scp->font_size, &font_buf[96], scp->font_size); for (i = 0; i < scp->font_size; ++i) { cursor[i] = font_buf[i]<<8 | font_buf[i+32]; cursor[i + scp->font_size] = font_buf[i+64]<<8 | font_buf[i+96]; } /* now and-or in the mousepointer image */ xoffset = x%8; yoffset = y%scp->font_size; for (i = 0; i < 16; ++i) { cursor[i + yoffset] = (cursor[i + yoffset] & ~(mouse_and_mask[i] >> xoffset)) | (mouse_or_mask[i] >> xoffset); } for (i = 0; i < scp->font_size; ++i) { font_buf[i] = (cursor[i] & 0xff00) >> 8; font_buf[i + 32] = cursor[i] & 0xff; font_buf[i + 64] = (cursor[i + scp->font_size] & 0xff00) >> 8; font_buf[i + 96] = cursor[i + scp->font_size] & 0xff; } #if 1 /* wait for vertical retrace to avoid jitter on some videocards */ crtc_addr = scp->sc->adp->va_crtc_addr; while (!sc_txtmouse_no_retrace_wait && !(inb(crtc_addr + 6) & 0x08)) /* idle */ ; #endif c = scp->sc->mouse_char; vidd_load_font(scp->sc->adp, 0, 32, 8, font_buf, c, 4); sc_vtb_putc(&scp->scr, pos, c, sc_vtb_geta(&scp->scr, pos)); /* FIXME: may be out of range! */ sc_vtb_putc(&scp->scr, pos + scp->xsize, c + 2, sc_vtb_geta(&scp->scr, pos + scp->xsize)); if (x < (scp->xsize - 1)*8) { sc_vtb_putc(&scp->scr, pos + 1, c + 1, sc_vtb_geta(&scp->scr, pos + 1)); sc_vtb_putc(&scp->scr, pos + scp->xsize + 1, c + 3, sc_vtb_geta(&scp->scr, pos + scp->xsize + 1)); } } else #endif /* SC_ALT_MOUSE_IMAGE */ { /* Red, magenta and brown are mapped to green to keep it readable */ static const int col_conv[16] = { 6, 6, 6, 6, 2, 2, 2, 6, 14, 14, 14, 14, 10, 10, 10, 14 }; int pos; int color; int a; pos = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff; a = sc_vtb_geta(&scp->scr, pos); if (scp->sc->adp->va_flags & V_ADP_COLOR) color = (col_conv[(a & 0xf000) >> 12] << 12) | ((a & 0x0f00) | 0x0800); else color = ((a & 0xf000) >> 4) | ((a & 0x0f00) << 4); sc_vtb_putc(&scp->scr, pos, sc_vtb_getc(&scp->scr, pos), color); } } static void remove_txtmouse(scr_stat *scp, int x, int y) { } static void vga_txtmouse(scr_stat *scp, int x, int y, int on) { if (on) draw_txtmouse(scp, x, y); else remove_txtmouse(scp, x, y); } #endif /* SC_NO_CUTPASTE */ #ifdef SC_PIXEL_MODE /* pixel (raster text) mode renderer */ static void vga_rndrinit(scr_stat *scp) { if (scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_PLANAR) { scp->rndr->clear = vga_pxlclear_planar; scp->rndr->draw_border = vga_pxlborder_planar; scp->rndr->draw = vga_vgadraw_planar; scp->rndr->draw_cursor = vga_pxlcursor_planar; scp->rndr->blink_cursor = vga_pxlblink_planar; scp->rndr->draw_mouse = vga_pxlmouse_planar; } else if (scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_DIRECT || scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_PACKED) { scp->rndr->clear = vga_pxlclear_direct; scp->rndr->draw_border = vga_pxlborder_direct; scp->rndr->draw = vga_vgadraw_direct; scp->rndr->draw_cursor = vga_pxlcursor_direct; scp->rndr->blink_cursor = vga_pxlblink_direct; scp->rndr->draw_mouse = vga_pxlmouse_direct; } } static void vga_pxlclear_direct(scr_stat *scp, int c, int attr) { vm_offset_t p; int line_width; int pixel_size; int lines; int i; line_width = scp->sc->adp->va_line_width; pixel_size = scp->sc->adp->va_info.vi_pixel_size; lines = scp->ysize * scp->font_size; p = scp->sc->adp->va_window + line_width * scp->yoff * scp->font_size + scp->xoff * 8 * pixel_size; for (i = 0; i < lines; ++i) { bzero_io((void *)p, scp->xsize * 8 * pixel_size); p += line_width; } } static void vga_pxlclear_planar(scr_stat *scp, int c, int attr) { vm_offset_t p; int line_width; int lines; int i; /* XXX: we are just filling the screen with the background color... */ outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ outw(GDCIDX, 0x0003); /* data rotate/function select */ outw(GDCIDX, 0x0f01); /* set/reset enable */ outw(GDCIDX, 0xff08); /* bit mask */ outw(GDCIDX, ((attr & 0xf000) >> 4) | 0x00); /* set/reset */ line_width = scp->sc->adp->va_line_width; lines = scp->ysize*scp->font_size; p = scp->sc->adp->va_window + line_width*scp->yoff*scp->font_size + scp->xoff; for (i = 0; i < lines; ++i) { bzero_io((void *)p, scp->xsize); p += line_width; } outw(GDCIDX, 0x0000); /* set/reset */ outw(GDCIDX, 0x0001); /* set/reset enable */ } static void vga_pxlborder_direct(scr_stat *scp, int color) { vm_offset_t s; vm_offset_t e; vm_offset_t f; int line_width; int pixel_size; int x; int y; int i; line_width = scp->sc->adp->va_line_width; pixel_size = scp->sc->adp->va_info.vi_pixel_size; if (scp->yoff > 0) { s = scp->sc->adp->va_window; e = s + line_width * scp->yoff * scp->font_size; for (f = s; f < e; f += pixel_size) DRAW_PIXEL(scp, f, color); } y = (scp->yoff + scp->ysize) * scp->font_size; if (scp->ypixel > y) { s = scp->sc->adp->va_window + line_width * y; e = s + line_width * (scp->ypixel - y); for (f = s; f < e; f += pixel_size) DRAW_PIXEL(scp, f, color); } y = scp->yoff * scp->font_size; x = scp->xpixel / 8 - scp->xoff - scp->xsize; for (i = 0; i < scp->ysize * scp->font_size; ++i) { if (scp->xoff > 0) { s = scp->sc->adp->va_window + line_width * (y + i); e = s + scp->xoff * 8 * pixel_size; for (f = s; f < e; f += pixel_size) DRAW_PIXEL(scp, f, color); } if (x > 0) { s = scp->sc->adp->va_window + line_width * (y + i) + scp->xoff * 8 * pixel_size + scp->xsize * 8 * pixel_size; e = s + x * 8 * pixel_size; for (f = s; f < e; f += pixel_size) DRAW_PIXEL(scp, f, color); } } } static void vga_pxlborder_planar(scr_stat *scp, int color) { vm_offset_t p; int line_width; int x; int y; int i; vidd_set_border(scp->sc->adp, color); outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ outw(GDCIDX, 0x0003); /* data rotate/function select */ outw(GDCIDX, 0x0f01); /* set/reset enable */ outw(GDCIDX, 0xff08); /* bit mask */ outw(GDCIDX, (color << 8) | 0x00); /* set/reset */ line_width = scp->sc->adp->va_line_width; p = scp->sc->adp->va_window; if (scp->yoff > 0) bzero_io((void *)p, line_width*scp->yoff*scp->font_size); y = (scp->yoff + scp->ysize)*scp->font_size; if (scp->ypixel > y) bzero_io((void *)(p + line_width*y), line_width*(scp->ypixel - y)); y = scp->yoff*scp->font_size; x = scp->xpixel/8 - scp->xoff - scp->xsize; for (i = 0; i < scp->ysize*scp->font_size; ++i) { if (scp->xoff > 0) bzero_io((void *)(p + line_width*(y + i)), scp->xoff); if (x > 0) bzero_io((void *)(p + line_width*(y + i) + scp->xoff + scp->xsize), x); } outw(GDCIDX, 0x0000); /* set/reset */ outw(GDCIDX, 0x0001); /* set/reset enable */ } static void vga_egadraw(scr_stat *scp, int from, int count, int flip) { vm_offset_t d; vm_offset_t e; u_char *f; u_short bg; u_short col1, col2; int line_width; int i, j; int a; u_char c; line_width = scp->sc->adp->va_line_width; d = GET_PIXEL(scp, from, 1, line_width); outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ outw(GDCIDX, 0x0003); /* data rotate/function select */ outw(GDCIDX, 0x0f01); /* set/reset enable */ bg = -1; if (from + count > scp->xsize*scp->ysize) count = scp->xsize*scp->ysize - from; for (i = from; count-- > 0; ++i) { a = sc_vtb_geta(&scp->vtb, i); if (flip) { col1 = ((a & 0x7000) >> 4) | (a & 0x0800); col2 = ((a & 0x8000) >> 4) | (a & 0x0700); } else { col1 = (a & 0x0f00); col2 = (a & 0xf000) >> 4; } /* set background color in EGA/VGA latch */ if (bg != col2) { bg = col2; outw(GDCIDX, bg | 0x00); /* set/reset */ outw(GDCIDX, 0xff08); /* bit mask */ writeb(d, 0); c = readb(d); /* set bg color in the latch */ } /* foreground color */ outw(GDCIDX, col1 | 0x00); /* set/reset */ e = d; f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]); for (j = 0; j < scp->font_size; ++j, ++f) { outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */ writeb(e, 0); e += line_width; } ++d; if ((i % scp->xsize) == scp->xsize - 1) d += scp->font_size * line_width - scp->xsize; } outw(GDCIDX, 0x0000); /* set/reset */ outw(GDCIDX, 0x0001); /* set/reset enable */ outw(GDCIDX, 0xff08); /* bit mask */ } static void vga_vgadraw_direct(scr_stat *scp, int from, int count, int flip) { vm_offset_t d; vm_offset_t e; u_char *f; u_short col1, col2, color; int line_width, pixel_size; int i, j, k; int a; line_width = scp->sc->adp->va_line_width; pixel_size = scp->sc->adp->va_info.vi_pixel_size; d = GET_PIXEL(scp, from, 8 * pixel_size, line_width); if (from + count > scp->xsize * scp->ysize) count = scp->xsize * scp->ysize - from; for (i = from; count-- > 0; ++i) { a = sc_vtb_geta(&scp->vtb, i); if (flip) { col1 = (((a & 0x7000) >> 4) | (a & 0x0800)) >> 8; col2 = (((a & 0x8000) >> 4) | (a & 0x0700)) >> 8; } else { col1 = (a & 0x0f00) >> 8; col2 = (a & 0xf000) >> 12; } e = d; f = &(scp->font[sc_vtb_getc(&scp->vtb, i) * scp->font_size]); for (j = 0; j < scp->font_size; ++j, ++f) { for (k = 0; k < 8; ++k) { color = *f & (1 << (7 - k)) ? col1 : col2; DRAW_PIXEL(scp, e + pixel_size * k, color); } e += line_width; } d += 8 * pixel_size; if ((i % scp->xsize) == scp->xsize - 1) d += scp->font_size * line_width - scp->xsize * 8 * pixel_size; } } static void vga_vgadraw_planar(scr_stat *scp, int from, int count, int flip) { vm_offset_t d; vm_offset_t e; u_char *f; u_short bg; u_short col1, col2; int line_width; int i, j; int a; u_char c; line_width = scp->sc->adp->va_line_width; d = GET_PIXEL(scp, from, 1, line_width); outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */ outw(GDCIDX, 0x0003); /* data rotate/function select */ outw(GDCIDX, 0x0f01); /* set/reset enable */ outw(GDCIDX, 0xff08); /* bit mask */ bg = -1; if (from + count > scp->xsize*scp->ysize) count = scp->xsize*scp->ysize - from; for (i = from; count-- > 0; ++i) { a = sc_vtb_geta(&scp->vtb, i); if (flip) { col1 = ((a & 0x7000) >> 4) | (a & 0x0800); col2 = ((a & 0x8000) >> 4) | (a & 0x0700); } else { col1 = (a & 0x0f00); col2 = (a & 0xf000) >> 4; } /* set background color in EGA/VGA latch */ if (bg != col2) { bg = col2; outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ outw(GDCIDX, bg | 0x00); /* set/reset */ writeb(d, 0); c = readb(d); /* set bg color in the latch */ outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */ } /* foreground color */ outw(GDCIDX, col1 | 0x00); /* set/reset */ e = d; f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]); for (j = 0; j < scp->font_size; ++j, ++f) { writeb(e, *f); e += line_width; } ++d; if ((i % scp->xsize) == scp->xsize - 1) d += scp->font_size * line_width - scp->xsize; } outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ outw(GDCIDX, 0x0000); /* set/reset */ outw(GDCIDX, 0x0001); /* set/reset enable */ } static void vga_pxlcursor_shape(scr_stat *scp, int base, int height, int blink) { if (base < 0 || base >= scp->font_size) return; /* the caller may set height <= 0 in order to disable the cursor */ #if 0 scp->curs_attr.base = base; scp->curs_attr.height = height; #endif } static void draw_pxlcursor_direct(scr_stat *scp, int at, int on, int flip) { vm_offset_t d; u_char *f; int line_width, pixel_size; int height; int col1, col2, color; int a; int i, j; line_width = scp->sc->adp->va_line_width; pixel_size = scp->sc->adp->va_info.vi_pixel_size; d = GET_PIXEL(scp, at, 8 * pixel_size, line_width) + (scp->font_size - scp->curs_attr.base - 1) * line_width; a = sc_vtb_geta(&scp->vtb, at); if (flip) { col1 = ((on) ? (a & 0x0f00) : ((a & 0xf000) >> 4)) >> 8; col2 = ((on) ? ((a & 0xf000) >> 4) : (a & 0x0f00)) >> 8; } else { col1 = ((on) ? ((a & 0xf000) >> 4) : (a & 0x0f00)) >> 8; col2 = ((on) ? (a & 0x0f00) : ((a & 0xf000) >> 4)) >> 8; } f = &(scp->font[sc_vtb_getc(&scp->vtb, at) * scp->font_size + scp->font_size - scp->curs_attr.base - 1]); height = imin(scp->curs_attr.height, scp->font_size); for (i = 0; i < height; ++i, --f) { for (j = 0; j < 8; ++j) { color = *f & (1 << (7 - j)) ? col1 : col2; DRAW_PIXEL(scp, d + pixel_size * j, color); } d -= line_width; } } static void draw_pxlcursor_planar(scr_stat *scp, int at, int on, int flip) { vm_offset_t d; u_char *f; int line_width; int height; int col; int a; int i; u_char c; line_width = scp->sc->adp->va_line_width; d = GET_PIXEL(scp, at, 1, line_width) + (scp->font_size - scp->curs_attr.base - 1) * line_width; outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ outw(GDCIDX, 0x0003); /* data rotate/function select */ outw(GDCIDX, 0x0f01); /* set/reset enable */ /* set background color in EGA/VGA latch */ a = sc_vtb_geta(&scp->vtb, at); if (flip) col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00); else col = (on) ? (a & 0x0f00) : ((a & 0xf000) >> 4); outw(GDCIDX, col | 0x00); /* set/reset */ outw(GDCIDX, 0xff08); /* bit mask */ writeb(d, 0); c = readb(d); /* set bg color in the latch */ /* foreground color */ if (flip) col = (on) ? (a & 0x0f00) : ((a & 0xf000) >> 4); else col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00); outw(GDCIDX, col | 0x00); /* set/reset */ f = &(scp->font[sc_vtb_getc(&scp->vtb, at)*scp->font_size + scp->font_size - scp->curs_attr.base - 1]); height = imin(scp->curs_attr.height, scp->font_size); for (i = 0; i < height; ++i, --f) { outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */ writeb(d, 0); d -= line_width; } outw(GDCIDX, 0x0000); /* set/reset */ outw(GDCIDX, 0x0001); /* set/reset enable */ outw(GDCIDX, 0xff08); /* bit mask */ } static int pxlblinkrate = 0; static void vga_pxlcursor_direct(scr_stat *scp, int at, int blink, int on, int flip) { if (scp->curs_attr.height <= 0) /* the text cursor is disabled */ return; if (on) { if (!blink) { scp->status |= VR_CURSOR_ON; draw_pxlcursor_direct(scp, at, on, flip); } else if (++pxlblinkrate & 4) { pxlblinkrate = 0; scp->status ^= VR_CURSOR_ON; draw_pxlcursor_direct(scp, at, scp->status & VR_CURSOR_ON, flip); } } else { if (scp->status & VR_CURSOR_ON) draw_pxlcursor_direct(scp, at, on, flip); scp->status &= ~VR_CURSOR_ON; } if (blink) scp->status |= VR_CURSOR_BLINK; else scp->status &= ~VR_CURSOR_BLINK; } static void vga_pxlcursor_planar(scr_stat *scp, int at, int blink, int on, int flip) { if (scp->curs_attr.height <= 0) /* the text cursor is disabled */ return; if (on) { if (!blink) { scp->status |= VR_CURSOR_ON; draw_pxlcursor_planar(scp, at, on, flip); } else if (++pxlblinkrate & 4) { pxlblinkrate = 0; scp->status ^= VR_CURSOR_ON; draw_pxlcursor_planar(scp, at, scp->status & VR_CURSOR_ON, flip); } } else { if (scp->status & VR_CURSOR_ON) draw_pxlcursor_planar(scp, at, on, flip); scp->status &= ~VR_CURSOR_ON; } if (blink) scp->status |= VR_CURSOR_BLINK; else scp->status &= ~VR_CURSOR_BLINK; } static void vga_pxlblink_direct(scr_stat *scp, int at, int flip) { if (!(scp->status & VR_CURSOR_BLINK)) return; if (!(++pxlblinkrate & 4)) return; pxlblinkrate = 0; scp->status ^= VR_CURSOR_ON; draw_pxlcursor_direct(scp, at, scp->status & VR_CURSOR_ON, flip); } static void vga_pxlblink_planar(scr_stat *scp, int at, int flip) { if (!(scp->status & VR_CURSOR_BLINK)) return; if (!(++pxlblinkrate & 4)) return; pxlblinkrate = 0; scp->status ^= VR_CURSOR_ON; draw_pxlcursor_planar(scp, at, scp->status & VR_CURSOR_ON, flip); } #ifndef SC_NO_CUTPASTE static void draw_pxlmouse_planar(scr_stat *scp, int x, int y) { vm_offset_t p; int line_width; int xoff, yoff; int ymax; - u_short m; - int i, j; + uint32_t m; + int i, j, k; + uint8_t m1; line_width = scp->sc->adp->va_line_width; xoff = (x - scp->xoff*8)%8; yoff = y - rounddown(y, line_width); ymax = imin(y + 16, scp->ypixel); - outw(GDCIDX, 0x0805); /* read mode 1, write mode 0 */ + outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ outw(GDCIDX, 0x0001); /* set/reset enable */ - outw(GDCIDX, 0x0002); /* color compare */ - outw(GDCIDX, 0x0007); /* color don't care */ outw(GDCIDX, 0xff08); /* bit mask */ outw(GDCIDX, 0x0803); /* data rotate/function select (and) */ p = scp->sc->adp->va_window + line_width*y + x/8; - if (x < scp->xpixel - 8) { - for (i = y, j = 0; i < ymax; ++i, ++j) { - m = ~(mouse_and_mask[j] >> xoff); -#if defined(__i386__) || defined(__amd64__) - *(u_char *)p &= m >> 8; - *(u_char *)(p + 1) &= m; -#else - writeb(p, readb(p) & (m >> 8)); - writeb(p + 1, readb(p + 1) & (m >> 8)); -#endif - p += line_width; + for (i = y, j = 0; i < ymax; ++i, ++j) { + m = ~((mouse_and_mask[j] & ~mouse_or_mask[j]) << 8 >> xoff); + for (k = 0; k < 3; ++k) { + m1 = m >> (8 * (2 - k)); + if (m1 != 0xff && x + 8 * k < scp->xpixel) { + readb(p + k); + writeb(p + k, m1); + } } - } else { - xoff += 8; - for (i = y, j = 0; i < ymax; ++i, ++j) { - m = ~(mouse_and_mask[j] >> xoff); -#if defined(__i386__) || defined(__amd64__) - *(u_char *)p &= m; -#else - writeb(p, readb(p) & (m >> 8)); -#endif - p += line_width; - } + p += line_width; } outw(GDCIDX, 0x1003); /* data rotate/function select (or) */ p = scp->sc->adp->va_window + line_width*y + x/8; - if (x < scp->xpixel - 8) { - for (i = y, j = 0; i < ymax; ++i, ++j) { - m = mouse_or_mask[j] >> xoff; -#if defined(__i386__) || defined(__amd64__) - *(u_char *)p &= m >> 8; - *(u_char *)(p + 1) &= m; -#else - writeb(p, readb(p) & (m >> 8)); - writeb(p + 1, readb(p + 1) & (m >> 8)); -#endif - p += line_width; + for (i = y, j = 0; i < ymax; ++i, ++j) { + m = mouse_or_mask[j] << 8 >> xoff; + for (k = 0; k < 3; ++k) { + m1 = m >> (8 * (2 - k)); + if (m1 != 0 && x + 8 * k < scp->xpixel) { + readb(p + k); + writeb(p + k, m1); + } } - } else { - for (i = y, j = 0; i < ymax; ++i, ++j) { - m = mouse_or_mask[j] >> xoff; -#if defined(__i386__) || defined(__amd64__) - *(u_char *)p &= m; -#else - writeb(p, readb(p) & (m >> 8)); -#endif - p += line_width; - } + p += line_width; } - outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ outw(GDCIDX, 0x0003); /* data rotate/function select */ } static void remove_pxlmouse_planar(scr_stat *scp, int x, int y) { vm_offset_t p; - int col, row; - int pos; - int line_width; - int ymax; - int i; + int bx, by, i, line_width, xend, xoff, yend, yoff; - /* erase the mouse cursor image */ - col = x/8 - scp->xoff; - row = y/scp->font_size - scp->yoff; - pos = row*scp->xsize + col; - i = (col < scp->xsize - 1) ? 2 : 1; - (*scp->rndr->draw)(scp, pos, i, FALSE); - if (row < scp->ysize - 1) - (*scp->rndr->draw)(scp, pos + scp->xsize, i, FALSE); + /* + * It is only necessary to remove the mouse image where it overlaps + * the border. Determine the overlap, and do nothing if it is empty. + */ + bx = (scp->xoff + scp->xsize) * 8; + by = (scp->yoff + scp->ysize) * scp->font_size; + xend = imin(x + MOUSE_IMAGE_WIDTH, scp->xpixel); + yend = imin(y + MOUSE_IMAGE_HEIGHT, scp->ypixel); + if (xend <= bx && yend <= by) + return; - /* paint border if necessary */ + /* Repaint the non-empty overlap. */ line_width = scp->sc->adp->va_line_width; outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ outw(GDCIDX, 0x0003); /* data rotate/function select */ outw(GDCIDX, 0x0f01); /* set/reset enable */ outw(GDCIDX, 0xff08); /* bit mask */ outw(GDCIDX, (scp->border << 8) | 0x00); /* set/reset */ - if (row == scp->ysize - 1) { - i = (scp->ysize + scp->yoff)*scp->font_size; - ymax = imin(i + scp->font_size, scp->ypixel); - p = scp->sc->adp->va_window + i*line_width + scp->xoff + col; - if (col < scp->xsize - 1) { - for (; i < ymax; ++i) { - writeb(p, 0); - writeb(p + 1, 0); - p += line_width; - } - } else { - for (; i < ymax; ++i) { - writeb(p, 0); - p += line_width; - } - } - } - if ((col == scp->xsize - 1) && (scp->xoff > 0)) { - i = (row + scp->yoff)*scp->font_size; - ymax = imin(i + scp->font_size*2, scp->ypixel); - p = scp->sc->adp->va_window + i*line_width - + scp->xoff + scp->xsize; - for (; i < ymax; ++i) { + for (i = x / 8, xoff = i * 8; xoff < xend; ++i, xoff += 8) { + yoff = (xoff >= bx) ? y : by; + p = scp->sc->adp->va_window + yoff * line_width + i; + for (; yoff < yend; ++yoff, p += line_width) writeb(p, 0); - p += line_width; - } } outw(GDCIDX, 0x0000); /* set/reset */ outw(GDCIDX, 0x0001); /* set/reset enable */ } static void vga_pxlmouse_direct(scr_stat *scp, int x, int y, int on) { vm_offset_t p; int line_width, pixel_size; int xend, yend; static int x_old = 0, xend_old = 0; static int y_old = 0, yend_old = 0; int i, j; uint32_t *u32; uint16_t *u16; uint8_t *u8; int bpp; - if (!on) + /* + * Determine overlap with the border and then if removing, do nothing + * if the overlap is empty. + */ + xend = imin(x + 16, scp->xpixel); + yend = imin(y + 16, scp->ypixel); + if (!on && xend <= (scp->xoff + scp->xsize) * 8 && + yend <= (scp->yoff + scp->ysize) * scp->font_size) return; bpp = scp->sc->adp->va_info.vi_depth; if ((bpp == 16) && (scp->sc->adp->va_info.vi_pixel_fsizes[1] == 5)) bpp = 15; line_width = scp->sc->adp->va_line_width; pixel_size = scp->sc->adp->va_info.vi_pixel_size; - xend = imin(x + 16, scp->xpixel); - yend = imin(y + 16, scp->ypixel); + if (on) + goto do_on; + /* + * Repaint overlap with the border and nearby. Unlike in the planar + * case, we kept track of everything under the cursor so can restore + * it all, but we don't completely trust the saved state to be still + * relevant, so do nothing if it is obviously stale. + */ + if (x != x_old || y != y_old || xend != xend_old || yend != yend_old) + return; + p = scp->sc->adp->va_window + y_old * line_width + x_old * pixel_size; for (i = 0; i < (yend_old - y_old); i++) { for (j = (xend_old - x_old - 1); j >= 0; j--) { switch (bpp) { case 32: u32 = (uint32_t*)(p + j * pixel_size); writel(u32, mouse_buf32[i * 16 + j]); break; case 16: /* FALLTHROUGH */ case 15: u16 = (uint16_t*)(p + j * pixel_size); writew(u16, mouse_buf16[i * 16 + j]); break; case 8: u8 = (uint8_t*)(p + j * pixel_size); writeb(u8, mouse_buf8[i * 16 + j]); break; } } p += line_width; } + return; +do_on: p = scp->sc->adp->va_window + y * line_width + x * pixel_size; for (i = 0; i < (yend - y); i++) { for (j = (xend - x - 1); j >= 0; j--) { switch (bpp) { case 32: u32 = (uint32_t*)(p + j * pixel_size); mouse_buf32[i * 16 + j] = *u32; if (mouse_or_mask[i] & (1 << (15 - j))) writel(u32, vga_palette32[15]); else if (mouse_and_mask[i] & (1 << (15 - j))) writel(u32, 0); break; case 16: u16 = (uint16_t*)(p + j * pixel_size); mouse_buf16[i * 16 + j] = *u16; if (mouse_or_mask[i] & (1 << (15 - j))) writew(u16, vga_palette16[15]); else if (mouse_and_mask[i] & (1 << (15 - j))) writew(u16, 0); break; case 15: u16 = (uint16_t*)(p + j * pixel_size); mouse_buf16[i * 16 + j] = *u16; if (mouse_or_mask[i] & (1 << (15 - j))) writew(u16, vga_palette15[15]); else if (mouse_and_mask[i] & (1 << (15 - j))) writew(u16, 0); break; case 8: u8 = (uint8_t*)(p + j * pixel_size); mouse_buf8[i * 16 + j] = *u8; if (mouse_or_mask[i] & (1 << (15 - j))) writeb(u8, 15); else if (mouse_and_mask[i] & (1 << (15 - j))) writeb(u8, 0); break; } } p += line_width; } x_old = x; y_old = y; xend_old = xend; yend_old = yend; } static void vga_pxlmouse_planar(scr_stat *scp, int x, int y, int on) { if (on) draw_pxlmouse_planar(scp, x, y); else remove_pxlmouse_planar(scp, x, y); } #endif /* SC_NO_CUTPASTE */ #endif /* SC_PIXEL_MODE */ #ifndef SC_NO_MODE_CHANGE /* graphics mode renderer */ static void vga_grborder(scr_stat *scp, int color) { vidd_set_border(scp->sc->adp, color); } #endif Index: stable/11/sys/dev/syscons/syscons.h =================================================================== --- stable/11/sys/dev/syscons/syscons.h (revision 330919) +++ stable/11/sys/dev/syscons/syscons.h (revision 330920) @@ -1,701 +1,699 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1995-1998 Søren Schmidt * All rights reserved. * * This code is derived from software contributed to The DragonFly Project * by Sascha Wildner * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer, * without modification, immediately at the beginning of the file. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _DEV_SYSCONS_SYSCONS_H_ #define _DEV_SYSCONS_SYSCONS_H_ #include /* XXX */ #include #include /* machine-dependent part of the header */ #ifdef PC98 #include #elif defined(__i386__) /* nothing for the moment */ #endif /* default values for configuration options */ #ifndef MAXCONS #define MAXCONS 16 #endif #ifdef SC_NO_SYSMOUSE #undef SC_NO_CUTPASTE #define SC_NO_CUTPASTE 1 #endif #ifdef SC_NO_MODE_CHANGE #undef SC_PIXEL_MODE #endif /* Always load font data if the pixel (raster text) mode is to be used. */ #ifdef SC_PIXEL_MODE #undef SC_NO_FONT_LOADING #endif /* * If font data is not available, the `arrow'-shaped mouse cursor cannot * be drawn. Use the alternative drawing method. */ #ifdef SC_NO_FONT_LOADING #undef SC_ALT_MOUSE_IMAGE #define SC_ALT_MOUSE_IMAGE 1 #endif #ifndef SC_CURSOR_CHAR #define SC_CURSOR_CHAR (0x07) #endif #ifndef SC_MOUSE_CHAR #define SC_MOUSE_CHAR (0xd0) #endif #if SC_MOUSE_CHAR <= SC_CURSOR_CHAR && SC_CURSOR_CHAR < (SC_MOUSE_CHAR + 4) #undef SC_CURSOR_CHAR #define SC_CURSOR_CHAR (SC_MOUSE_CHAR + 4) #endif #ifndef SC_DEBUG_LEVEL #define SC_DEBUG_LEVEL 0 #endif #define DPRINTF(l, p) if (SC_DEBUG_LEVEL >= (l)) printf p #ifndef __sparc64__ #define SC_DRIVER_NAME "sc" #else /* * Use a different driver name on sparc64 so it does not get confused * with the system controller devices which are also termed 'sc' in OFW. */ #define SC_DRIVER_NAME "syscons" #endif #define SC_VTY(dev) (((sc_ttysoftc *)tty_softc(tp))->st_index) #define SC_DEV(sc, vty) ((sc)->dev[(vty) - (sc)->first_vty]) #define SC_STAT(tp) (*((scr_stat **)&((sc_ttysoftc *)tty_softc(tp))->st_stat)) /* printable chars */ #ifndef PRINTABLE #define PRINTABLE(ch) ((ch) > 0x1b || ((ch) > 0x0d && (ch) < 0x1b) \ || (ch) < 0x07) #endif /* macros for "intelligent" screen update */ #define mark_for_update(scp, x) {\ if ((x) < scp->start) scp->start = (x);\ else if ((x) > scp->end) scp->end = (x);\ } #define mark_all(scp) {\ scp->start = 0;\ scp->end = scp->xsize * scp->ysize - 1;\ } /* vty status flags (scp->status) */ #define UNKNOWN_MODE 0x00010 /* unknown video mode */ #define SWITCH_WAIT_REL 0x00080 /* waiting for vty release */ #define SWITCH_WAIT_ACQ 0x00100 /* waiting for vty ack */ #define BUFFER_SAVED 0x00200 /* vty buffer is saved */ #define CURSOR_ENABLED 0x00400 /* text cursor is enabled */ #define MOUSE_MOVED 0x01000 /* mouse cursor has moved */ #define MOUSE_CUTTING 0x02000 /* mouse cursor is cutting text */ #define MOUSE_VISIBLE 0x04000 /* mouse cursor is showing */ #define GRAPHICS_MODE 0x08000 /* vty is in a graphics mode */ #define PIXEL_MODE 0x10000 /* vty is in a raster text mode */ #define SAVER_RUNNING 0x20000 /* screen saver is running */ #define VR_CURSOR_BLINK 0x40000 /* blinking text cursor */ #define VR_CURSOR_ON 0x80000 /* text cursor is on */ #define MOUSE_HIDDEN 0x100000 /* mouse cursor is temporarily hidden */ /* misc defines */ #define FALSE 0 #define TRUE 1 /* The following #defines are hard-coded for a maximum text resolution corresponding to a maximum framebuffer resolution of 1920x1200 with an 8x8 font... */ #define COL 240 #define ROW 150 #define PCBURST 128 #ifndef BELL_DURATION #define BELL_DURATION ((5 * hz + 99) / 100) #define BELL_PITCH 800 #endif /* virtual terminal buffer */ typedef struct sc_vtb { int vtb_flags; #define VTB_VALID (1 << 0) #define VTB_ALLOCED (1 << 1) int vtb_type; #define VTB_INVALID 0 #define VTB_MEMORY 1 #define VTB_FRAMEBUFFER 2 #define VTB_RINGBUFFER 3 int vtb_cols; int vtb_rows; int vtb_size; vm_offset_t vtb_buffer; int vtb_tail; /* valid for VTB_RINGBUFFER only */ } sc_vtb_t; /* text cursor attributes */ struct cursor_attr { int flags; int base; int height; }; /* softc */ struct keyboard; struct video_adapter; struct scr_stat; struct tty; struct sc_cnstate { u_char kbd_locked; u_char kdb_locked; u_char mtx_locked; u_char kbd_opened; u_char scr_opened; }; typedef struct sc_softc { int unit; /* unit # */ int config; /* configuration flags */ #define SC_VESAMODE (1 << 7) #define SC_AUTODETECT_KBD (1 << 8) #define SC_KERNEL_CONSOLE (1 << 9) int flags; /* status flags */ #define SC_VISUAL_BELL (1 << 0) #define SC_QUIET_BELL (1 << 1) #if 0 /* not used anymore */ #define SC_BLINK_CURSOR (1 << 2) #define SC_CHAR_CURSOR (1 << 3) #endif #define SC_MOUSE_ENABLED (1 << 4) #define SC_SCRN_IDLE (1 << 5) #define SC_SCRN_BLANKED (1 << 6) #define SC_SAVER_FAILED (1 << 7) #define SC_SCRN_VTYLOCK (1 << 8) #define SC_INIT_DONE (1 << 16) #define SC_SPLASH_SCRN (1 << 17) int keyboard; /* -1 if unavailable */ struct keyboard *kbd; int adapter; struct video_adapter *adp; int initial_mode; /* initial video mode */ int first_vty; int vtys; struct tty **dev; struct scr_stat *cur_scp; struct scr_stat *new_scp; struct scr_stat *old_scp; int delayed_next_scr; char font_loading_in_progress; char switch_in_progress; char write_in_progress; char blink_in_progress; int grab_level; /* 2 is just enough for kdb to grab for stepping normal grabbing: */ struct sc_cnstate grab_state[2]; int kbd_open_level; struct mtx video_mtx; long scrn_time_stamp; struct cursor_attr dflt_curs_attr; struct cursor_attr curs_attr; u_char scr_map[256]; u_char scr_rmap[256]; #ifdef _SC_MD_SOFTC_DECLARED_ sc_md_softc_t md; /* machine dependent vars */ #endif #ifndef SC_NO_PALETTE_LOADING u_char palette[256 * 3]; #ifdef SC_PIXEL_MODE u_char palette2[256 * 3]; #endif #endif #ifndef SC_NO_FONT_LOADING int fonts_loaded; #define FONT_8 2 #define FONT_14 4 #define FONT_16 8 #define FONT_22 8 u_char *font_8; u_char *font_14; u_char *font_16; u_char *font_22; #endif u_char cursor_char; u_char mouse_char; #ifdef KDB int sc_altbrk; #endif struct callout ctimeout; struct callout cblink; } sc_softc_t; /* virtual screen */ typedef struct scr_stat { int index; /* index of this vty */ struct sc_softc *sc; /* pointer to softc */ struct sc_rndr_sw *rndr; /* renderer */ #ifndef __sparc64__ sc_vtb_t scr; #endif sc_vtb_t vtb; int xpos; /* current X position */ int ypos; /* current Y position */ int xsize; /* X text size */ int ysize; /* Y text size */ int xpixel; /* X graphics size */ int ypixel; /* Y graphics size */ int xoff; /* X offset in pixel mode */ int yoff; /* Y offset in pixel mode */ u_char *font; /* current font */ int font_size; /* fontsize in Y direction */ int font_width; /* fontsize in X direction */ int start; /* modified area start */ int end; /* modified area end */ struct sc_term_sw *tsw; void *ts; int status; /* status (bitfield) */ int kbd_mode; /* keyboard I/O mode */ int cursor_pos; /* cursor buffer position */ int cursor_oldpos; /* cursor old buffer position */ - u_short cursor_saveunder_char; /* saved char under cursor */ - u_short cursor_saveunder_attr; /* saved attr under cursor */ struct cursor_attr dflt_curs_attr; struct cursor_attr curr_curs_attr; struct cursor_attr curs_attr; int mouse_pos; /* mouse buffer position */ int mouse_oldpos; /* mouse old buffer position */ short mouse_xpos; /* mouse x coordinate */ short mouse_ypos; /* mouse y coordinate */ short mouse_oldxpos; /* mouse previous x coordinate */ short mouse_oldypos; /* mouse previous y coordinate */ short mouse_buttons; /* mouse buttons */ int mouse_cut_start; /* mouse cut start pos */ int mouse_cut_end; /* mouse cut end pos */ int mouse_level; /* xterm mouse protocol */ struct proc *mouse_proc; /* proc* of controlling proc */ pid_t mouse_pid; /* pid of controlling proc */ int mouse_signal; /* signal # to report with */ u_short bell_duration; u_short bell_pitch; u_char border; /* border color */ int mode; /* mode */ pid_t pid; /* pid of controlling proc */ struct proc *proc; /* proc* of controlling proc */ struct vt_mode smode; /* switch mode */ sc_vtb_t *history; /* circular history buffer */ int history_pos; /* position shown on screen */ int history_size; /* size of history buffer */ int splash_save_mode; /* saved mode for splash screen */ int splash_save_status; /* saved status for splash screen */ #ifdef _SCR_MD_STAT_DECLARED_ scr_md_stat_t md; /* machine dependent vars */ #endif } scr_stat; /* TTY softc. */ typedef struct sc_ttysoftc { int st_index; scr_stat *st_stat; } sc_ttysoftc; #ifndef SC_NORM_ATTR #define SC_NORM_ATTR (FG_LIGHTGREY | BG_BLACK) #endif #ifndef SC_NORM_REV_ATTR #define SC_NORM_REV_ATTR (FG_BLACK | BG_LIGHTGREY) #endif #ifndef SC_KERNEL_CONS_ATTR #define SC_KERNEL_CONS_ATTR (FG_WHITE | BG_BLACK) #endif #ifndef SC_KERNEL_CONS_REV_ATTR #define SC_KERNEL_CONS_REV_ATTR (FG_BLACK | BG_LIGHTGREY) #endif /* terminal emulator */ #ifndef SC_DFLT_TERM #define SC_DFLT_TERM "*" /* any */ #endif typedef int sc_term_init_t(scr_stat *scp, void **tcp, int code); #define SC_TE_COLD_INIT 0 #define SC_TE_WARM_INIT 1 typedef int sc_term_term_t(scr_stat *scp, void **tcp); typedef void sc_term_puts_t(scr_stat *scp, u_char *buf, int len); typedef int sc_term_ioctl_t(scr_stat *scp, struct tty *tp, u_long cmd, caddr_t data, struct thread *td); typedef int sc_term_reset_t(scr_stat *scp, int code); #define SC_TE_HARD_RESET 0 #define SC_TE_SOFT_RESET 1 typedef void sc_term_default_attr_t(scr_stat *scp, int norm, int rev); typedef void sc_term_clear_t(scr_stat *scp); typedef void sc_term_notify_t(scr_stat *scp, int event); #define SC_TE_NOTIFY_VTSWITCH_IN 0 #define SC_TE_NOTIFY_VTSWITCH_OUT 1 typedef int sc_term_input_t(scr_stat *scp, int c, struct tty *tp); typedef const char *sc_term_fkeystr_t(scr_stat *scp, int c); typedef void sc_term_sync_t(scr_stat *scp); typedef struct sc_term_sw { LIST_ENTRY(sc_term_sw) link; char *te_name; /* name of the emulator */ char *te_desc; /* description */ char *te_renderer; /* matching renderer */ size_t te_size; /* size of internal buffer */ int te_refcount; /* reference counter */ sc_term_init_t *te_init; sc_term_term_t *te_term; sc_term_puts_t *te_puts; sc_term_ioctl_t *te_ioctl; sc_term_reset_t *te_reset; sc_term_default_attr_t *te_default_attr; sc_term_clear_t *te_clear; sc_term_notify_t *te_notify; sc_term_input_t *te_input; sc_term_fkeystr_t *te_fkeystr; sc_term_sync_t *te_sync; } sc_term_sw_t; #define SCTERM_MODULE(name, sw) \ DATA_SET(scterm_set, sw); \ static int \ scterm_##name##_event(module_t mod, int type, void *data) \ { \ switch (type) { \ case MOD_LOAD: \ return sc_term_add(&sw); \ case MOD_UNLOAD: \ if (sw.te_refcount > 0) \ return EBUSY; \ return sc_term_remove(&sw); \ default: \ return EOPNOTSUPP; \ break; \ } \ return 0; \ } \ static moduledata_t scterm_##name##_mod = { \ "scterm-" #name, \ scterm_##name##_event, \ NULL, \ }; \ DECLARE_MODULE(scterm_##name, scterm_##name##_mod, \ SI_SUB_DRIVERS, SI_ORDER_MIDDLE) /* renderer function table */ typedef void vr_init_t(scr_stat *scp); typedef void vr_clear_t(scr_stat *scp, int c, int attr); typedef void vr_draw_border_t(scr_stat *scp, int color); typedef void vr_draw_t(scr_stat *scp, int from, int count, int flip); typedef void vr_set_cursor_t(scr_stat *scp, int base, int height, int blink); typedef void vr_draw_cursor_t(scr_stat *scp, int at, int blink, int on, int flip); typedef void vr_blink_cursor_t(scr_stat *scp, int at, int flip); typedef void vr_set_mouse_t(scr_stat *scp); typedef void vr_draw_mouse_t(scr_stat *scp, int x, int y, int on); typedef struct sc_rndr_sw { vr_init_t *init; vr_clear_t *clear; vr_draw_border_t *draw_border; vr_draw_t *draw; vr_set_cursor_t *set_cursor; vr_draw_cursor_t *draw_cursor; vr_blink_cursor_t *blink_cursor; vr_set_mouse_t *set_mouse; vr_draw_mouse_t *draw_mouse; } sc_rndr_sw_t; typedef struct sc_renderer { char *name; int mode; sc_rndr_sw_t *rndrsw; LIST_ENTRY(sc_renderer) link; } sc_renderer_t; #define RENDERER(name, mode, sw, set) \ static struct sc_renderer scrndr_##name##_##mode = { \ #name, mode, &sw \ }; \ DATA_SET(scrndr_set, scrndr_##name##_##mode); \ DATA_SET(set, scrndr_##name##_##mode) #define RENDERER_MODULE(name, set) \ SET_DECLARE(set, sc_renderer_t); \ static int \ scrndr_##name##_event(module_t mod, int type, void *data) \ { \ sc_renderer_t **list; \ int error = 0; \ switch (type) { \ case MOD_LOAD: \ SET_FOREACH(list, set) { \ error = sc_render_add(*list); \ if (error) \ break; \ } \ break; \ case MOD_UNLOAD: \ SET_FOREACH(list, set) { \ error = sc_render_remove(*list);\ if (error) \ break; \ } \ break; \ default: \ return EOPNOTSUPP; \ break; \ } \ return error; \ } \ static moduledata_t scrndr_##name##_mod = { \ "scrndr-" #name, \ scrndr_##name##_event, \ NULL, \ }; \ DECLARE_MODULE(scrndr_##name, scrndr_##name##_mod, \ SI_SUB_DRIVERS, SI_ORDER_MIDDLE) typedef struct { int cursor_start; int cursor_end; int shift_state; int bell_pitch; } bios_values_t; /* other macros */ #define ISTEXTSC(scp) (!((scp)->status \ & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))) #define ISGRAPHSC(scp) (((scp)->status \ & (UNKNOWN_MODE | GRAPHICS_MODE))) #define ISPIXELSC(scp) (((scp)->status \ & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))\ == PIXEL_MODE) #define ISUNKNOWNSC(scp) ((scp)->status & UNKNOWN_MODE) #define ISMOUSEAVAIL(af) ((af) & V_ADP_FONT) #define ISFONTAVAIL(af) ((af) & V_ADP_FONT) #define ISPALAVAIL(af) ((af) & V_ADP_PALETTE) #define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG) #define SC_VIDEO_LOCKINIT(sc) \ mtx_init(&(sc)->video_mtx, "syscons video lock", NULL, \ MTX_SPIN | MTX_RECURSE); #define SC_VIDEO_LOCK(sc) \ do { \ if (!kdb_active) \ mtx_lock_spin(&(sc)->video_mtx); \ } while(0) #define SC_VIDEO_UNLOCK(sc) \ do { \ if (!kdb_active) \ mtx_unlock_spin(&(sc)->video_mtx); \ } while(0) /* syscons.c */ extern int (*sc_user_ioctl)(struct tty *tp, u_long cmd, caddr_t data, struct thread *td); int sc_probe_unit(int unit, int flags); int sc_attach_unit(int unit, int flags); int set_mode(scr_stat *scp); void sc_set_border(scr_stat *scp, int color); void sc_load_font(scr_stat *scp, int page, int size, int width, u_char *font, int base, int count); void sc_save_font(scr_stat *scp, int page, int size, int width, u_char *font, int base, int count); void sc_show_font(scr_stat *scp, int page); void sc_touch_scrn_saver(void); void sc_draw_cursor_image(scr_stat *scp); void sc_remove_cursor_image(scr_stat *scp); void sc_set_cursor_image(scr_stat *scp); void sc_change_cursor_shape(scr_stat *scp, int flags, int base, int height); int sc_clean_up(scr_stat *scp); int sc_switch_scr(sc_softc_t *sc, u_int next_scr); void sc_alloc_scr_buffer(scr_stat *scp, int wait, int discard); int sc_init_emulator(scr_stat *scp, char *name); void sc_paste(scr_stat *scp, const u_char *p, int count); void sc_respond(scr_stat *scp, const u_char *p, int count, int wakeup); void sc_bell(scr_stat *scp, int pitch, int duration); /* schistory.c */ #ifndef SC_NO_HISTORY int sc_alloc_history_buffer(scr_stat *scp, int lines, int prev_ysize, int wait); void sc_free_history_buffer(scr_stat *scp, int prev_ysize); void sc_hist_save(scr_stat *scp); #define sc_hist_save_one_line(scp, from) \ sc_vtb_append(&(scp)->vtb, (from), (scp)->history, (scp)->xsize) int sc_hist_restore(scr_stat *scp); void sc_hist_home(scr_stat *scp); void sc_hist_end(scr_stat *scp); int sc_hist_up_line(scr_stat *scp); int sc_hist_down_line(scr_stat *scp); int sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td); #endif /* SC_NO_HISTORY */ /* scmouse.c */ #ifndef SC_NO_CUTPASTE void sc_alloc_cut_buffer(scr_stat *scp, int wait); void sc_draw_mouse_image(scr_stat *scp); void sc_remove_mouse_image(scr_stat *scp); int sc_inside_cutmark(scr_stat *scp, int pos); void sc_remove_cutmarking(scr_stat *scp); void sc_remove_all_cutmarkings(sc_softc_t *scp); void sc_remove_all_mouse(sc_softc_t *scp); void sc_mouse_paste(scr_stat *scp); #else #define sc_draw_mouse_image(scp) #define sc_remove_mouse_image(scp) #define sc_inside_cutmark(scp, pos) FALSE #define sc_remove_cutmarking(scp) #define sc_remove_all_cutmarkings(scp) #define sc_remove_all_mouse(scp) #define sc_mouse_paste(scp) #endif /* SC_NO_CUTPASTE */ #ifndef SC_NO_SYSMOUSE void sc_mouse_move(scr_stat *scp, int x, int y); int sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td); #endif /* SC_NO_SYSMOUSE */ /* scvidctl.c */ int sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize, int fontsize, int font_width); int sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode); int sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize, int fontsize, int font_width); int sc_support_pixel_mode(void *arg); int sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td); int sc_render_add(sc_renderer_t *rndr); int sc_render_remove(sc_renderer_t *rndr); sc_rndr_sw_t *sc_render_match(scr_stat *scp, char *name, int mode); /* scvtb.c */ void sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows, void *buffer, int wait); void sc_vtb_destroy(sc_vtb_t *vtb); size_t sc_vtb_size(int cols, int rows); void sc_vtb_clear(sc_vtb_t *vtb, int c, int attr); int sc_vtb_getc(sc_vtb_t *vtb, int at); int sc_vtb_geta(sc_vtb_t *vtb, int at); void sc_vtb_putc(sc_vtb_t *vtb, int at, int c, int a); vm_offset_t sc_vtb_putchar(sc_vtb_t *vtb, vm_offset_t p, int c, int a); vm_offset_t sc_vtb_pointer(sc_vtb_t *vtb, int at); int sc_vtb_pos(sc_vtb_t *vtb, int pos, int offset); #define sc_vtb_tail(vtb) ((vtb)->vtb_tail) #define sc_vtb_rows(vtb) ((vtb)->vtb_rows) #define sc_vtb_cols(vtb) ((vtb)->vtb_cols) void sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to, int count); void sc_vtb_append(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int count); void sc_vtb_seek(sc_vtb_t *vtb, int pos); void sc_vtb_erase(sc_vtb_t *vtb, int at, int count, int c, int attr); void sc_vtb_move(sc_vtb_t *vtb, int from, int to, int count); void sc_vtb_delete(sc_vtb_t *vtb, int at, int count, int c, int attr); void sc_vtb_ins(sc_vtb_t *vtb, int at, int count, int c, int attr); /* sysmouse.c */ int sysmouse_event(mouse_info_t *info); /* scterm.c */ void sc_move_cursor(scr_stat *scp, int x, int y); void sc_clear_screen(scr_stat *scp); int sc_term_add(sc_term_sw_t *sw); int sc_term_remove(sc_term_sw_t *sw); sc_term_sw_t *sc_term_match(char *name); sc_term_sw_t *sc_term_match_by_number(int index); /* machine dependent functions */ int sc_max_unit(void); sc_softc_t *sc_get_softc(int unit, int flags); sc_softc_t *sc_find_softc(struct video_adapter *adp, struct keyboard *kbd); int sc_get_cons_priority(int *unit, int *flags); void sc_get_bios_values(bios_values_t *values); int sc_tone(int herz); #endif /* !_DEV_SYSCONS_SYSCONS_H_ */ Index: stable/11 =================================================================== --- stable/11 (revision 330919) +++ stable/11 (revision 330920) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r316636,316642,316675,316733,316737,316741,316827,316830,316865,316878