1999-09-20 03:00:04 +04:00
|
|
|
/* $NetBSD: pcdisplay_subr.c,v 1.8 1999/09/19 23:00:04 ad Exp $ */
|
1998-05-28 20:48:40 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Chris G. Demetriou
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and
|
|
|
|
* its documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
|
|
|
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
*
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
#include <dev/isa/isareg.h>
|
|
|
|
|
|
|
|
#include <dev/ic/mc6845reg.h>
|
|
|
|
#include <dev/ic/pcdisplayvar.h>
|
|
|
|
|
|
|
|
#include <dev/wscons/wsdisplayvar.h>
|
|
|
|
|
|
|
|
void
|
|
|
|
pcdisplay_cursor(id, on, row, col)
|
|
|
|
void *id;
|
|
|
|
int on, row, col;
|
|
|
|
{
|
1999-09-20 01:48:08 +04:00
|
|
|
#ifdef PCDISPLAY_SOFTCURSOR
|
|
|
|
struct pcdisplayscreen *scr = id;
|
|
|
|
bus_space_tag_t memt = scr->hdl->ph_memt;
|
|
|
|
bus_space_handle_t memh = scr->hdl->ph_memh;
|
|
|
|
int off;
|
|
|
|
|
|
|
|
/* Remove old cursor image */
|
|
|
|
if (scr->cursoron) {
|
|
|
|
off = scr->vc_crow * scr->type->ncols + scr->vc_ccol;
|
|
|
|
if (scr->active)
|
|
|
|
bus_space_write_2(memt, memh, scr->dispoffset + off * 2,
|
|
|
|
scr->cursortmp);
|
|
|
|
else
|
|
|
|
scr->mem[off] = scr->cursortmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
scr->vc_crow = row;
|
|
|
|
scr->vc_ccol = col;
|
|
|
|
|
|
|
|
if ((scr->cursoron = on) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
off = (scr->vc_crow * scr->type->ncols + scr->vc_ccol);
|
1999-09-20 03:00:04 +04:00
|
|
|
if (scr->active) {
|
|
|
|
off <<= 1;
|
|
|
|
scr->cursortmp = bus_space_read_2(memt, memh,
|
|
|
|
scr->dispoffset + off);
|
|
|
|
bus_space_write_2(memt, memh, scr->dispoffset + off,
|
1999-09-20 01:48:08 +04:00
|
|
|
scr->cursortmp ^ 0x7000);
|
1999-09-20 03:00:04 +04:00
|
|
|
} else {
|
|
|
|
scr->cursortmp = scr->mem[off];
|
1999-09-20 01:48:08 +04:00
|
|
|
scr->mem[off] = scr->cursortmp ^ 0x7000;
|
1999-09-20 03:00:04 +04:00
|
|
|
}
|
1999-09-20 01:48:08 +04:00
|
|
|
#else /* PCDISPLAY_SOFTCURSOR */
|
1998-05-28 20:48:40 +04:00
|
|
|
struct pcdisplayscreen *scr = id;
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
scr->vc_crow = row;
|
|
|
|
scr->vc_ccol = col;
|
|
|
|
scr->cursoron = on;
|
|
|
|
|
|
|
|
if (scr->active) {
|
1999-09-20 01:48:08 +04:00
|
|
|
if (!on)
|
|
|
|
pos = 0x1010;
|
|
|
|
else
|
1998-07-24 20:12:18 +04:00
|
|
|
pos = scr->dispoffset / 2
|
|
|
|
+ row * scr->type->ncols + col;
|
1998-05-28 20:48:40 +04:00
|
|
|
|
|
|
|
pcdisplay_6845_write(scr->hdl, cursorh, pos >> 8);
|
|
|
|
pcdisplay_6845_write(scr->hdl, cursorl, pos);
|
|
|
|
}
|
1999-09-20 01:48:08 +04:00
|
|
|
#endif /* PCDISPLAY_SOFTCURSOR */
|
1998-05-28 20:48:40 +04:00
|
|
|
}
|
|
|
|
|
1998-06-27 01:05:20 +04:00
|
|
|
#if 0
|
|
|
|
unsigned int
|
|
|
|
pcdisplay_mapchar_simple(id, uni)
|
|
|
|
void *id;
|
|
|
|
int uni;
|
1998-06-21 01:55:05 +04:00
|
|
|
{
|
1998-06-27 01:05:20 +04:00
|
|
|
if (uni < 128)
|
|
|
|
return (uni);
|
|
|
|
|
|
|
|
return (1); /* XXX ??? smiley */
|
|
|
|
}
|
|
|
|
#endif
|
1998-06-21 01:55:05 +04:00
|
|
|
|
1998-05-28 20:48:40 +04:00
|
|
|
void
|
1998-06-21 01:55:05 +04:00
|
|
|
pcdisplay_putchar(id, row, col, c, attr)
|
1998-05-28 20:48:40 +04:00
|
|
|
void *id;
|
|
|
|
int row, col;
|
1998-06-21 01:55:05 +04:00
|
|
|
u_int c;
|
1998-05-28 20:48:40 +04:00
|
|
|
long attr;
|
|
|
|
{
|
|
|
|
struct pcdisplayscreen *scr = id;
|
|
|
|
bus_space_tag_t memt = scr->hdl->ph_memt;
|
|
|
|
bus_space_handle_t memh = scr->hdl->ph_memh;
|
1998-06-21 01:55:05 +04:00
|
|
|
int off;
|
1998-05-28 20:48:40 +04:00
|
|
|
|
|
|
|
|
1998-06-21 01:55:05 +04:00
|
|
|
off = row * scr->type->ncols + col;
|
1998-05-28 20:48:40 +04:00
|
|
|
|
1998-06-21 01:55:05 +04:00
|
|
|
if (scr->active)
|
1998-07-24 20:12:18 +04:00
|
|
|
bus_space_write_2(memt, memh, scr->dispoffset + off * 2,
|
1998-06-27 01:05:20 +04:00
|
|
|
c | (attr << 8));
|
1998-06-21 01:55:05 +04:00
|
|
|
else
|
1998-06-27 01:05:20 +04:00
|
|
|
scr->mem[off] = c | (attr << 8);
|
1998-05-28 20:48:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pcdisplay_copycols(id, row, srccol, dstcol, ncols)
|
|
|
|
void *id;
|
|
|
|
int row, srccol, dstcol, ncols;
|
|
|
|
{
|
|
|
|
struct pcdisplayscreen *scr = id;
|
|
|
|
bus_space_tag_t memt = scr->hdl->ph_memt;
|
|
|
|
bus_space_handle_t memh = scr->hdl->ph_memh;
|
|
|
|
bus_size_t srcoff, dstoff;
|
|
|
|
|
|
|
|
srcoff = dstoff = row * scr->type->ncols;
|
|
|
|
srcoff += srccol;
|
|
|
|
dstoff += dstcol;
|
|
|
|
|
|
|
|
if (scr->active)
|
1998-07-24 20:12:18 +04:00
|
|
|
bus_space_copy_region_2(memt, memh,
|
|
|
|
scr->dispoffset + srcoff * 2,
|
|
|
|
memh, scr->dispoffset + dstoff * 2,
|
|
|
|
ncols);
|
1998-05-28 20:48:40 +04:00
|
|
|
else
|
|
|
|
bcopy(&scr->mem[srcoff], &scr->mem[dstoff], ncols * 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pcdisplay_erasecols(id, row, startcol, ncols, fillattr)
|
|
|
|
void *id;
|
|
|
|
int row, startcol, ncols;
|
|
|
|
long fillattr;
|
|
|
|
{
|
|
|
|
struct pcdisplayscreen *scr = id;
|
|
|
|
bus_space_tag_t memt = scr->hdl->ph_memt;
|
|
|
|
bus_space_handle_t memh = scr->hdl->ph_memh;
|
|
|
|
bus_size_t off;
|
|
|
|
u_int16_t val;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
off = row * scr->type->ncols + startcol;
|
|
|
|
|
|
|
|
val = (fillattr << 8) | ' ';
|
|
|
|
|
|
|
|
if (scr->active)
|
1998-07-24 20:12:18 +04:00
|
|
|
bus_space_set_region_2(memt, memh, scr->dispoffset + off * 2,
|
|
|
|
val, ncols);
|
1998-05-28 20:48:40 +04:00
|
|
|
else
|
|
|
|
for (i = 0; i < ncols; i++)
|
|
|
|
scr->mem[off + i] = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pcdisplay_copyrows(id, srcrow, dstrow, nrows)
|
|
|
|
void *id;
|
|
|
|
int srcrow, dstrow, nrows;
|
|
|
|
{
|
|
|
|
struct pcdisplayscreen *scr = id;
|
|
|
|
bus_space_tag_t memt = scr->hdl->ph_memt;
|
|
|
|
bus_space_handle_t memh = scr->hdl->ph_memh;
|
|
|
|
int ncols = scr->type->ncols;
|
|
|
|
bus_size_t srcoff, dstoff;
|
|
|
|
|
|
|
|
srcoff = srcrow * ncols + 0;
|
|
|
|
dstoff = dstrow * ncols + 0;
|
|
|
|
|
|
|
|
if (scr->active)
|
1998-07-24 20:12:18 +04:00
|
|
|
bus_space_copy_region_2(memt, memh,
|
|
|
|
scr->dispoffset + srcoff * 2,
|
|
|
|
memh, scr->dispoffset + dstoff * 2,
|
|
|
|
nrows * ncols);
|
1998-05-28 20:48:40 +04:00
|
|
|
else
|
|
|
|
bcopy(&scr->mem[srcoff], &scr->mem[dstoff],
|
|
|
|
nrows * ncols * 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pcdisplay_eraserows(id, startrow, nrows, fillattr)
|
|
|
|
void *id;
|
|
|
|
int startrow, nrows;
|
|
|
|
long fillattr;
|
|
|
|
{
|
|
|
|
struct pcdisplayscreen *scr = id;
|
|
|
|
bus_space_tag_t memt = scr->hdl->ph_memt;
|
|
|
|
bus_space_handle_t memh = scr->hdl->ph_memh;
|
|
|
|
bus_size_t off, count;
|
|
|
|
u_int16_t val;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
off = startrow * scr->type->ncols;
|
|
|
|
count = nrows * scr->type->ncols;
|
|
|
|
|
|
|
|
val = (fillattr << 8) | ' ';
|
|
|
|
|
|
|
|
if (scr->active)
|
1998-07-24 20:12:18 +04:00
|
|
|
bus_space_set_region_2(memt, memh, scr->dispoffset + off * 2,
|
|
|
|
val, count);
|
1998-05-28 20:48:40 +04:00
|
|
|
else
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
scr->mem[off + i] = val;
|
|
|
|
}
|