Home | History | Annotate | Line # | Download | only in ic
pcdisplay_subr.c revision 1.4
      1  1.4  drochner /* $NetBSD: pcdisplay_subr.c,v 1.4 1998/06/20 21:55:05 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.4  drochner static u_char iso2ibm437[] =
     72  1.4  drochner {
     73  1.4  drochner            0,     0,     0,     0,     0,     0,     0,     0,
     74  1.4  drochner            0,     0,     0,     0,     0,     0,     0,     0,
     75  1.4  drochner            0,     0,     0,     0,     0,     0,     0,     0,
     76  1.4  drochner            0,     0,     0,     0,     0,     0,     0,     0,
     77  1.4  drochner         0xff,  0xad,  0x9b,  0x9c,     0,  0x9d,     0,  0x40,
     78  1.4  drochner         0x6f,  0x63,  0x61,  0xae,     0,     0,     0,     0,
     79  1.4  drochner         0xf8,  0xf1,  0xfd,  0x33,     0,  0xe6,     0,  0xfa,
     80  1.4  drochner            0,  0x31,  0x6f,  0xaf,  0xac,  0xab,     0,  0xa8,
     81  1.4  drochner         0x41,  0x41,  0x41,  0x41,  0x8e,  0x8f,  0x92,  0x80,
     82  1.4  drochner         0x45,  0x90,  0x45,  0x45,  0x49,  0x49,  0x49,  0x49,
     83  1.4  drochner         0x81,  0xa5,  0x4f,  0x4f,  0x4f,  0x4f,  0x99,  0x4f,
     84  1.4  drochner         0x4f,  0x55,  0x55,  0x55,  0x9a,  0x59,     0,  0xe1,
     85  1.4  drochner         0x85,  0xa0,  0x83,  0x61,  0x84,  0x86,  0x91,  0x87,
     86  1.4  drochner         0x8a,  0x82,  0x88,  0x89,  0x8d,  0xa1,  0x8c,  0x8b,
     87  1.4  drochner            0,  0xa4,  0x95,  0xa2,  0x93,  0x6f,  0x94,  0x6f,
     88  1.4  drochner         0x6f,  0x97,  0xa3,  0x96,  0x81,  0x98,     0,     0
     89  1.4  drochner };
     90  1.4  drochner 
     91  1.1  drochner void
     92  1.4  drochner pcdisplay_putchar(id, row, col, c, attr)
     93  1.1  drochner 	void *id;
     94  1.1  drochner 	int row, col;
     95  1.4  drochner 	u_int c;
     96  1.1  drochner 	long attr;
     97  1.1  drochner {
     98  1.1  drochner 	struct pcdisplayscreen *scr = id;
     99  1.1  drochner 	bus_space_tag_t memt = scr->hdl->ph_memt;
    100  1.1  drochner 	bus_space_handle_t memh = scr->hdl->ph_memh;
    101  1.4  drochner 	u_char dc;
    102  1.4  drochner 	int off;
    103  1.4  drochner 
    104  1.4  drochner 	if (c < 128)
    105  1.4  drochner 		dc = c;
    106  1.4  drochner 	else if (c < 256)
    107  1.4  drochner 		dc = iso2ibm437[c - 128];
    108  1.4  drochner 	else
    109  1.4  drochner 		return;
    110  1.1  drochner 
    111  1.1  drochner 	off = row * scr->type->ncols + col;
    112  1.1  drochner 
    113  1.4  drochner 	if (scr->active)
    114  1.4  drochner 		bus_space_write_2(memt, memh, off * 2,
    115  1.4  drochner 				  dc | (attr << 8));
    116  1.4  drochner 	else
    117  1.4  drochner 		scr->mem[off] = dc | (attr << 8);
    118  1.1  drochner }
    119  1.1  drochner 
    120  1.1  drochner void
    121  1.1  drochner pcdisplay_copycols(id, row, srccol, dstcol, ncols)
    122  1.1  drochner 	void *id;
    123  1.1  drochner 	int row, srccol, dstcol, ncols;
    124  1.1  drochner {
    125  1.1  drochner 	struct pcdisplayscreen *scr = id;
    126  1.1  drochner 	bus_space_tag_t memt = scr->hdl->ph_memt;
    127  1.1  drochner 	bus_space_handle_t memh = scr->hdl->ph_memh;
    128  1.1  drochner 	bus_size_t srcoff, dstoff;
    129  1.1  drochner 
    130  1.1  drochner 	srcoff = dstoff = row * scr->type->ncols;
    131  1.1  drochner 	srcoff += srccol;
    132  1.1  drochner 	dstoff += dstcol;
    133  1.1  drochner 
    134  1.1  drochner 	if (scr->active)
    135  1.1  drochner 		bus_space_copy_region_2(memt, memh, srcoff * 2,
    136  1.1  drochner 					memh, dstoff * 2, ncols);
    137  1.1  drochner 	else
    138  1.1  drochner 		bcopy(&scr->mem[srcoff], &scr->mem[dstoff], ncols * 2);
    139  1.1  drochner }
    140  1.1  drochner 
    141  1.1  drochner void
    142  1.1  drochner pcdisplay_erasecols(id, row, startcol, ncols, fillattr)
    143  1.1  drochner 	void *id;
    144  1.1  drochner 	int row, startcol, ncols;
    145  1.1  drochner 	long fillattr;
    146  1.1  drochner {
    147  1.1  drochner 	struct pcdisplayscreen *scr = id;
    148  1.1  drochner 	bus_space_tag_t memt = scr->hdl->ph_memt;
    149  1.1  drochner 	bus_space_handle_t memh = scr->hdl->ph_memh;
    150  1.1  drochner 	bus_size_t off;
    151  1.1  drochner 	u_int16_t val;
    152  1.1  drochner 	int i;
    153  1.1  drochner 
    154  1.1  drochner 	off = row * scr->type->ncols + startcol;
    155  1.1  drochner 
    156  1.1  drochner 	val = (fillattr << 8) | ' ';
    157  1.1  drochner 
    158  1.1  drochner 	if (scr->active)
    159  1.1  drochner 		bus_space_set_region_2(memt, memh, off * 2, val, ncols);
    160  1.1  drochner 	else
    161  1.1  drochner 		for (i = 0; i < ncols; i++)
    162  1.1  drochner 			scr->mem[off + i] = val;
    163  1.1  drochner }
    164  1.1  drochner 
    165  1.1  drochner void
    166  1.1  drochner pcdisplay_copyrows(id, srcrow, dstrow, nrows)
    167  1.1  drochner 	void *id;
    168  1.1  drochner 	int srcrow, dstrow, nrows;
    169  1.1  drochner {
    170  1.1  drochner 	struct pcdisplayscreen *scr = id;
    171  1.1  drochner 	bus_space_tag_t memt = scr->hdl->ph_memt;
    172  1.1  drochner 	bus_space_handle_t memh = scr->hdl->ph_memh;
    173  1.1  drochner 	int ncols = scr->type->ncols;
    174  1.1  drochner 	bus_size_t srcoff, dstoff;
    175  1.1  drochner 
    176  1.1  drochner 	srcoff = srcrow * ncols + 0;
    177  1.1  drochner 	dstoff = dstrow * ncols + 0;
    178  1.1  drochner 
    179  1.1  drochner 	if (scr->active)
    180  1.1  drochner 		bus_space_copy_region_2(memt, memh, srcoff * 2,
    181  1.1  drochner 					memh, dstoff * 2, nrows * ncols);
    182  1.1  drochner 	else
    183  1.1  drochner 		bcopy(&scr->mem[srcoff], &scr->mem[dstoff],
    184  1.1  drochner 		      nrows * ncols * 2);
    185  1.1  drochner }
    186  1.1  drochner 
    187  1.1  drochner void
    188  1.1  drochner pcdisplay_eraserows(id, startrow, nrows, fillattr)
    189  1.1  drochner 	void *id;
    190  1.1  drochner 	int startrow, nrows;
    191  1.1  drochner 	long fillattr;
    192  1.1  drochner {
    193  1.1  drochner 	struct pcdisplayscreen *scr = id;
    194  1.1  drochner 	bus_space_tag_t memt = scr->hdl->ph_memt;
    195  1.1  drochner 	bus_space_handle_t memh = scr->hdl->ph_memh;
    196  1.1  drochner 	bus_size_t off, count;
    197  1.1  drochner 	u_int16_t val;
    198  1.1  drochner 	int i;
    199  1.1  drochner 
    200  1.1  drochner 	off = startrow * scr->type->ncols;
    201  1.1  drochner 	count = nrows * scr->type->ncols;
    202  1.1  drochner 
    203  1.1  drochner 	val = (fillattr << 8) | ' ';
    204  1.1  drochner 
    205  1.1  drochner 	if (scr->active)
    206  1.1  drochner 		bus_space_set_region_2(memt, memh, off * 2, val, count);
    207  1.1  drochner 	else
    208  1.1  drochner 		for (i = 0; i < count; i++)
    209  1.1  drochner 			scr->mem[off + i] = val;
    210  1.1  drochner }
    211