void sc_vtb_append(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int count) { int len; if (vtb2->vtb_type != VTB_RINGBUFFER) return; while (count > 0) { len = imin(count, vtb2->vtb_size - vtb2->vtb_tail); #ifndef __sparc64__ if (vtb1->vtb_type == VTB_FRAMEBUFFER) bcopy_fromio(sc_vtb_pointer(vtb1, from), sc_vtb_pointer(vtb2, vtb2->vtb_tail), len*sizeof(u_int16_t)); else #endif bcopy((void *)sc_vtb_pointer(vtb1, from), (void *)sc_vtb_pointer(vtb2, vtb2->vtb_tail), len*sizeof(u_int16_t)); from += len; count -= len; vtb2->vtb_tail = vtb_wrap(vtb2, vtb2->vtb_tail, len); } }
void sc_vtb_clear(sc_vtb_t *vtb, int c, int attr) { #ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) fillw_io(attr | c, sc_vtb_pointer(vtb, 0), vtb->vtb_size); else #endif fillw(attr | c, (void *)sc_vtb_pointer(vtb, 0), vtb->vtb_size); }
void sc_vtb_putc(sc_vtb_t *vtb, int at, int c, int a) { #ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) writew(sc_vtb_pointer(vtb, at), a | c); else #endif *(u_int16_t *)sc_vtb_pointer(vtb, at) = a | c; }
int sc_vtb_geta(sc_vtb_t *vtb, int at) { #ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) return (readw(sc_vtb_pointer(vtb, at)) & 0xff00); else #endif return (*(u_int16_t *)sc_vtb_pointer(vtb, at) & 0xff00); }
void sc_vtb_erase(sc_vtb_t *vtb, int at, int count, int c, int attr) { if (at + count > vtb->vtb_size) count = vtb->vtb_size - at; #ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) fillw_io(attr | c, sc_vtb_pointer(vtb, at), count); else #endif fillw(attr | c, (void *)sc_vtb_pointer(vtb, at), count); }
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; attr = scteken_attr(a) << 8; #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)); }
void sc_vtb_move(sc_vtb_t *vtb, int from, int to, int count) { if (from + count > vtb->vtb_size) count = vtb->vtb_size - from; if (to + count > vtb->vtb_size) count = vtb->vtb_size - to; if (count <= 0) return; #ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) bcopy_io(sc_vtb_pointer(vtb, from), sc_vtb_pointer(vtb, to), count*sizeof(u_int16_t)); else #endif bcopy((void *)sc_vtb_pointer(vtb, from), (void *)sc_vtb_pointer(vtb, to), count*sizeof(u_int16_t)); }
void sc_vtb_delete(sc_vtb_t *vtb, int at, int count, int c, int attr) { int len; if (at + count > vtb->vtb_size) count = vtb->vtb_size - at; len = vtb->vtb_size - at - count; if (len > 0) { #ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) bcopy_io(sc_vtb_pointer(vtb, at + count), sc_vtb_pointer(vtb, at), len*sizeof(u_int16_t)); else #endif bcopy((void *)sc_vtb_pointer(vtb, at + count), (void *)sc_vtb_pointer(vtb, at), len*sizeof(u_int16_t)); } #ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) fillw_io(attr | c, sc_vtb_pointer(vtb, at + len), vtb->vtb_size - at - len); else #endif fillw(attr | c, (void *)sc_vtb_pointer(vtb, at + len), vtb->vtb_size - at - len); }
void sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows, void *buf, int wait) { vtb->vtb_flags = 0; vtb->vtb_type = type; vtb->vtb_cols = cols; vtb->vtb_rows = rows; vtb->vtb_size = cols*rows; vtb->vtb_buffer = 0; vtb->vtb_tail = 0; switch (type) { case VTB_MEMORY: case VTB_RINGBUFFER: if ((buf == NULL) && (cols*rows != 0)) { vtb->vtb_buffer = (vm_offset_t)malloc(cols*rows*sizeof(u_int16_t), M_DEVBUF, (wait) ? M_WAITOK : M_NOWAIT); if (vtb->vtb_buffer != 0) { bzero((void *)sc_vtb_pointer(vtb, 0), cols*rows*sizeof(u_int16_t)); vtb->vtb_flags |= VTB_ALLOCED; } } else { vtb->vtb_buffer = (vm_offset_t)buf; } vtb->vtb_flags |= VTB_VALID; break; #ifndef __sparc64__ case VTB_FRAMEBUFFER: vtb->vtb_buffer = (vm_offset_t)buf; vtb->vtb_flags |= VTB_VALID; break; #endif default: break; } }
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_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)); }
void sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to, int count) { #ifndef __sparc64__ /* XXX if both are VTB_VRAMEBUFFER... */ if (vtb2->vtb_type == VTB_FRAMEBUFFER) bcopy_toio(sc_vtb_pointer(vtb1, from), sc_vtb_pointer(vtb2, to), count*sizeof(u_int16_t)); else if (vtb1->vtb_type == VTB_FRAMEBUFFER) bcopy_fromio(sc_vtb_pointer(vtb1, from), sc_vtb_pointer(vtb2, to), count*sizeof(u_int16_t)); else #endif bcopy((void *)sc_vtb_pointer(vtb1, from), (void *)sc_vtb_pointer(vtb2, to), count*sizeof(u_int16_t)); }
void sc_vtb_ins(sc_vtb_t *vtb, int at, int count, int c, int attr) { if (at + count > vtb->vtb_size) count = vtb->vtb_size - at; else { #ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) bcopy_io(sc_vtb_pointer(vtb, at), sc_vtb_pointer(vtb, at + count), (vtb->vtb_size - at - count)*sizeof(u_int16_t)); else #endif bcopy((void *)sc_vtb_pointer(vtb, at), (void *)sc_vtb_pointer(vtb, at + count), (vtb->vtb_size - at - count)*sizeof(u_int16_t)); } #ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) fillw_io(attr | c, sc_vtb_pointer(vtb, at), count); else #endif fillw(attr | c, (void *)sc_vtb_pointer(vtb, at), count); }