Home | History | Annotate | Line # | Download | only in ic
pcdisplay_subr.c revision 1.5
      1 /* $NetBSD: pcdisplay_subr.c,v 1.5 1998/06/26 21:05:20 drochner Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      5  * All rights reserved.
      6  *
      7  * Author: Chris G. Demetriou
      8  *
      9  * Permission to use, copy, modify and distribute this software and
     10  * its documentation is hereby granted, provided that both the copyright
     11  * notice and this permission notice appear in all copies of the
     12  * software, derivative works or modified versions, and any portions
     13  * thereof, and that both notices appear in supporting documentation.
     14  *
     15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  *
     19  * Carnegie Mellon requests users of this software to return to
     20  *
     21  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22  *  School of Computer Science
     23  *  Carnegie Mellon University
     24  *  Pittsburgh PA 15213-3890
     25  *
     26  * any improvements or extensions that they make and grant Carnegie the
     27  * rights to redistribute these changes.
     28  */
     29 
     30 #include <sys/param.h>
     31 #include <sys/systm.h>
     32 #include <sys/device.h>
     33 #include <machine/bus.h>
     34 
     35 #include <dev/isa/isavar.h>
     36 #include <dev/isa/isareg.h>
     37 
     38 #include <dev/ic/mc6845reg.h>
     39 #include <dev/ic/pcdisplayvar.h>
     40 
     41 #include <dev/wscons/wsdisplayvar.h>
     42 
     43 void
     44 pcdisplay_cursor(id, on, row, col)
     45 	void *id;
     46 	int on, row, col;
     47 {
     48 	struct pcdisplayscreen *scr = id;
     49 	int pos;
     50 
     51 #if 0
     52 	printf("pcdisplay_cursor: %d %d\n", row, col);
     53 #endif
     54 	scr->vc_crow = row;
     55 	scr->vc_ccol = col;
     56 	scr->cursoron = on;
     57 
     58 	if (scr->active) {
     59 		if (!on) {
     60 			/* XXX disable cursor how??? */
     61 			row = col = -1;
     62 		}
     63 
     64 		pos = row * scr->type->ncols + col;
     65 
     66 		pcdisplay_6845_write(scr->hdl, cursorh, pos >> 8);
     67 		pcdisplay_6845_write(scr->hdl, cursorl, pos);
     68 	}
     69 }
     70 
     71 #if 0
     72 unsigned int
     73 pcdisplay_mapchar_simple(id, uni)
     74 	void *id;
     75 	int uni;
     76 {
     77 	if (uni < 128)
     78 		return (uni);
     79 
     80 	return (1); /* XXX ??? smiley */
     81 }
     82 #endif
     83 
     84 void
     85 pcdisplay_putchar(id, row, col, c, attr)
     86 	void *id;
     87 	int row, col;
     88 	u_int c;
     89 	long attr;
     90 {
     91 	struct pcdisplayscreen *scr = id;
     92 	bus_space_tag_t memt = scr->hdl->ph_memt;
     93 	bus_space_handle_t memh = scr->hdl->ph_memh;
     94 	int off;
     95 
     96 
     97 	off = row * scr->type->ncols + col;
     98 
     99 	if (scr->active)
    100 		bus_space_write_2(memt, memh, off * 2,
    101 				  c | (attr << 8));
    102 	else
    103 		scr->mem[off] = c | (attr << 8);
    104 }
    105 
    106 void
    107 pcdisplay_copycols(id, row, srccol, dstcol, ncols)
    108 	void *id;
    109 	int row, srccol, dstcol, ncols;
    110 {
    111 	struct pcdisplayscreen *scr = id;
    112 	bus_space_tag_t memt = scr->hdl->ph_memt;
    113 	bus_space_handle_t memh = scr->hdl->ph_memh;
    114 	bus_size_t srcoff, dstoff;
    115 
    116 	srcoff = dstoff = row * scr->type->ncols;
    117 	srcoff += srccol;
    118 	dstoff += dstcol;
    119 
    120 	if (scr->active)
    121 		bus_space_copy_region_2(memt, memh, srcoff * 2,
    122 					memh, dstoff * 2, ncols);
    123 	else
    124 		bcopy(&scr->mem[srcoff], &scr->mem[dstoff], ncols * 2);
    125 }
    126 
    127 void
    128 pcdisplay_erasecols(id, row, startcol, ncols, fillattr)
    129 	void *id;
    130 	int row, startcol, ncols;
    131 	long fillattr;
    132 {
    133 	struct pcdisplayscreen *scr = id;
    134 	bus_space_tag_t memt = scr->hdl->ph_memt;
    135 	bus_space_handle_t memh = scr->hdl->ph_memh;
    136 	bus_size_t off;
    137 	u_int16_t val;
    138 	int i;
    139 
    140 	off = row * scr->type->ncols + startcol;
    141 
    142 	val = (fillattr << 8) | ' ';
    143 
    144 	if (scr->active)
    145 		bus_space_set_region_2(memt, memh, off * 2, val, ncols);
    146 	else
    147 		for (i = 0; i < ncols; i++)
    148 			scr->mem[off + i] = val;
    149 }
    150 
    151 void
    152 pcdisplay_copyrows(id, srcrow, dstrow, nrows)
    153 	void *id;
    154 	int srcrow, dstrow, nrows;
    155 {
    156 	struct pcdisplayscreen *scr = id;
    157 	bus_space_tag_t memt = scr->hdl->ph_memt;
    158 	bus_space_handle_t memh = scr->hdl->ph_memh;
    159 	int ncols = scr->type->ncols;
    160 	bus_size_t srcoff, dstoff;
    161 
    162 	srcoff = srcrow * ncols + 0;
    163 	dstoff = dstrow * ncols + 0;
    164 
    165 	if (scr->active)
    166 		bus_space_copy_region_2(memt, memh, srcoff * 2,
    167 					memh, dstoff * 2, nrows * ncols);
    168 	else
    169 		bcopy(&scr->mem[srcoff], &scr->mem[dstoff],
    170 		      nrows * ncols * 2);
    171 }
    172 
    173 void
    174 pcdisplay_eraserows(id, startrow, nrows, fillattr)
    175 	void *id;
    176 	int startrow, nrows;
    177 	long fillattr;
    178 {
    179 	struct pcdisplayscreen *scr = id;
    180 	bus_space_tag_t memt = scr->hdl->ph_memt;
    181 	bus_space_handle_t memh = scr->hdl->ph_memh;
    182 	bus_size_t off, count;
    183 	u_int16_t val;
    184 	int i;
    185 
    186 	off = startrow * scr->type->ncols;
    187 	count = nrows * scr->type->ncols;
    188 
    189 	val = (fillattr << 8) | ' ';
    190 
    191 	if (scr->active)
    192 		bus_space_set_region_2(memt, memh, off * 2, val, count);
    193 	else
    194 		for (i = 0; i < count; i++)
    195 			scr->mem[off + i] = val;
    196 }
    197