pcdisplay_subr.c revision 1.6 1 /* $NetBSD: pcdisplay_subr.c,v 1.6 1998/07/24 16:12:18 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 pos = -1;
62 } else
63 pos = scr->dispoffset / 2
64 + 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, scr->dispoffset + 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,
122 scr->dispoffset + srcoff * 2,
123 memh, scr->dispoffset + dstoff * 2,
124 ncols);
125 else
126 bcopy(&scr->mem[srcoff], &scr->mem[dstoff], ncols * 2);
127 }
128
129 void
130 pcdisplay_erasecols(id, row, startcol, ncols, fillattr)
131 void *id;
132 int row, startcol, ncols;
133 long fillattr;
134 {
135 struct pcdisplayscreen *scr = id;
136 bus_space_tag_t memt = scr->hdl->ph_memt;
137 bus_space_handle_t memh = scr->hdl->ph_memh;
138 bus_size_t off;
139 u_int16_t val;
140 int i;
141
142 off = row * scr->type->ncols + startcol;
143
144 val = (fillattr << 8) | ' ';
145
146 if (scr->active)
147 bus_space_set_region_2(memt, memh, scr->dispoffset + off * 2,
148 val, ncols);
149 else
150 for (i = 0; i < ncols; i++)
151 scr->mem[off + i] = val;
152 }
153
154 void
155 pcdisplay_copyrows(id, srcrow, dstrow, nrows)
156 void *id;
157 int srcrow, dstrow, nrows;
158 {
159 struct pcdisplayscreen *scr = id;
160 bus_space_tag_t memt = scr->hdl->ph_memt;
161 bus_space_handle_t memh = scr->hdl->ph_memh;
162 int ncols = scr->type->ncols;
163 bus_size_t srcoff, dstoff;
164
165 srcoff = srcrow * ncols + 0;
166 dstoff = dstrow * ncols + 0;
167
168 if (scr->active)
169 bus_space_copy_region_2(memt, memh,
170 scr->dispoffset + srcoff * 2,
171 memh, scr->dispoffset + dstoff * 2,
172 nrows * ncols);
173 else
174 bcopy(&scr->mem[srcoff], &scr->mem[dstoff],
175 nrows * ncols * 2);
176 }
177
178 void
179 pcdisplay_eraserows(id, startrow, nrows, fillattr)
180 void *id;
181 int startrow, nrows;
182 long fillattr;
183 {
184 struct pcdisplayscreen *scr = id;
185 bus_space_tag_t memt = scr->hdl->ph_memt;
186 bus_space_handle_t memh = scr->hdl->ph_memh;
187 bus_size_t off, count;
188 u_int16_t val;
189 int i;
190
191 off = startrow * scr->type->ncols;
192 count = nrows * scr->type->ncols;
193
194 val = (fillattr << 8) | ' ';
195
196 if (scr->active)
197 bus_space_set_region_2(memt, memh, scr->dispoffset + off * 2,
198 val, count);
199 else
200 for (i = 0; i < count; i++)
201 scr->mem[off + i] = val;
202 }
203