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