BSD 4_3_Net_2 development
[unix-history] / .ref-BSD-4_3_Reno / usr / src / sys / hpdev / ite_gb.c
CommitLineData
60f56dfc
KM
1/*
2 * Copyright (c) 1988 University of Utah.
3 * Copyright (c) 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department.
9 *
1c15e888
C
10 * Redistribution is only permitted until one year after the first shipment
11 * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and
12 * binary forms are permitted provided that: (1) source distributions retain
13 * this entire copyright notice and comment, and (2) distributions including
14 * binaries display the following acknowledgement: This product includes
15 * software developed by the University of California, Berkeley and its
16 * contributors'' in the documentation or other materials provided with the
17 * distribution and in all advertising materials mentioning features or use
18 * of this software. Neither the name of the University nor the names of
19 * its contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
60f56dfc 24 *
1c15e888 25 * from: Utah $Hdr: ite_gb.c 1.17 89/04/11$
60f56dfc 26 *
1c15e888 27 * @(#)ite_gb.c 7.1 (Berkeley) 5/8/90
60f56dfc
KM
28 */
29
30#include "ite.h"
31#if NITE > 0
32
1c15e888
C
33#include "param.h"
34#include "conf.h"
35#include "user.h"
36#include "proc.h"
37#include "ioctl.h"
38#include "tty.h"
39#include "systm.h"
40#include "uio.h"
60f56dfc
KM
41
42#include "itevar.h"
43#include "itereg.h"
44#include "grf_gbreg.h"
45
1c15e888 46#include "machine/cpu.h"
60f56dfc
KM
47
48/* XXX */
49#include "grfioctl.h"
50#include "grfvar.h"
51
52#define REGBASE ((struct gboxfb *)(ip->regbase))
53#define WINDOWMOVER gatorbox_windowmove
54
55gatorbox_init(ip)
56 register struct ite_softc *ip;
57{
58 /* XXX */
59 if (ip->regbase == 0) {
60 struct grfinfo *gi = &grf_softc[ip - ite_softc].g_display;
61 ip->regbase = IOV(gi->gd_regaddr);
62 ip->fbbase = IOV(gi->gd_fbaddr);
63 }
64
65 REGBASE->write_protect = 0x0;
66 REGBASE->interrupt = 0x4;
67 REGBASE->rep_rule = RR_COPY;
68 REGBASE->blink1 = 0xff;
69 REGBASE->blink2 = 0xff;
70 gb_microcode(REGADDR);
71 REGBASE->sec_interrupt = 0x01;
72
73 /*
74 * Set up the color map entries. We use three entries in the
75 * color map. The first, is for black, the second is for
76 * white, and the very last entry is for the inverted cursor.
77 */
78 REGBASE->creg_select = 0x00;
79 REGBASE->cmap_red = 0x00;
80 REGBASE->cmap_grn = 0x00;
81 REGBASE->cmap_blu = 0x00;
82 REGBASE->cmap_write = 0x00;
83 gbcm_waitbusy(REGADDR);
84
85 REGBASE->creg_select = 0x01;
86 REGBASE->cmap_red = 0xFF;
87 REGBASE->cmap_grn = 0xFF;
88 REGBASE->cmap_blu = 0xFF;
89 REGBASE->cmap_write = 0x01;
90 gbcm_waitbusy(REGADDR);
91
92 REGBASE->creg_select = 0xFF;
93 REGBASE->cmap_red = 0xFF;
94 REGBASE->cmap_grn = 0xFF;
95 REGBASE->cmap_blu = 0xFF;
96 REGBASE->cmap_write = 0x01;
97 gbcm_waitbusy(REGADDR);
98
99 ite_devinfo(ip);
100 ite_fontinit(ip);
101
102 /*
103 * Clear the display. This used to be before the font unpacking
104 * but it crashes. Figure it out later.
105 */
106 gatorbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
107 tile_mover_waitbusy(REGADDR);
108
109 /*
110 * Stash the inverted cursor.
111 */
112 gatorbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
113 ip->cblanky, ip->cblankx, ip->ftheight,
114 ip->ftwidth, RR_COPYINVERTED);
115}
116
117gatorbox_deinit(ip)
118 struct ite_softc *ip;
119{
120 gatorbox_windowmove(ip, 0, 0, 0, 0,
121 ip->dheight, ip->dwidth, RR_CLEAR);
122 tile_mover_waitbusy(REGADDR);
123
124 ip->flags &= ~ITE_INITED;
125}
126
127gatorbox_putc(ip, c, dy, dx, mode)
128 register struct ite_softc *ip;
129 register int dy, dx;
130 int c, mode;
131{
132 register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
133
134 gatorbox_windowmove(ip, charY(ip, c), charX(ip, c),
135 dy * ip->ftheight, dx * ip->ftwidth,
136 ip->ftheight, ip->ftwidth, wrr);
137}
138
139gatorbox_cursor(ip, flag)
140 register struct ite_softc *ip;
141 register int flag;
142{
143 if (flag == DRAW_CURSOR)
144 draw_cursor(ip)
145 else if (flag == MOVE_CURSOR) {
146 erase_cursor(ip)
147 draw_cursor(ip)
148 }
149 else
150 erase_cursor(ip)
151}
152
153gatorbox_clear(ip, sy, sx, h, w)
154 struct ite_softc *ip;
155 register int sy, sx, h, w;
156{
157 gatorbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
158 sy * ip->ftheight, sx * ip->ftwidth,
159 h * ip->ftheight, w * ip->ftwidth,
160 RR_CLEAR);
161}
162#define gatorbox_blockmove(ip, sy, sx, dy, dx, h, w) \
163 gatorbox_windowmove((ip), \
164 (sy) * ip->ftheight, \
165 (sx) * ip->ftwidth, \
166 (dy) * ip->ftheight, \
167 (dx) * ip->ftwidth, \
168 (h) * ip->ftheight, \
169 (w) * ip->ftwidth, \
170 RR_COPY)
171
172gatorbox_scroll(ip, sy, sx, count, dir)
173 register struct ite_softc *ip;
174 register int sy;
175 int dir, sx, count;
176{
177 register int height, dy, i;
178
179 tile_mover_waitbusy(REGADDR);
180 REGBASE->write_protect = 0x0;
181
182 gatorbox_cursor(ip, ERASE_CURSOR);
183
184 if (dir == SCROLL_UP) {
185 dy = sy - count;
186 height = ip->rows - sy;
187 for (i = 0; i < height; i++)
188 gatorbox_blockmove(ip, sy + i, sx, dy + i, 0,
189 1, ip->cols);
190 }
191 else if (dir == SCROLL_DOWN) {
192 dy = sy + count;
193 height = ip->rows - dy;
194 for (i = (height - 1); i >= 0; i--)
195 gatorbox_blockmove(ip, sy + i, sx, dy + i, 0,
196 1, ip->cols);
197 }
198 else if (dir == SCROLL_RIGHT) {
199 gatorbox_blockmove(ip, sy, sx, sy, sx + count,
200 1, ip->cols - (sx + count));
201 }
202 else {
203 gatorbox_blockmove(ip, sy, sx, sy, sx - count,
204 1, ip->cols - sx);
205 }
206}
207
208gatorbox_windowmove(ip, sy, sx, dy, dx, h, w, mask)
209 register struct ite_softc *ip;
210 int sy, sx, dy, dx, mask;
211 register int h, w;
212{
213 register int src, dest;
214
215 src = (sy * 1024) + sx; /* upper left corner in pixels */
216 dest = (dy * 1024) + dx;
217
218 tile_mover_waitbusy(REGADDR);
219 REGBASE->width = -(w / 4);
220 REGBASE->height = -(h / 4);
221 if (src < dest)
222 REGBASE->rep_rule = MOVE_DOWN_RIGHT|mask;
223 else {
224 REGBASE->rep_rule = MOVE_UP_LEFT|mask;
225 /*
226 * Adjust to top of lower right tile of the block.
227 */
228 src = src + ((h - 4) * 1024) + (w - 4);
229 dest= dest + ((h - 4) * 1024) + (w - 4);
230 }
231 FBBASE[dest] = FBBASE[src];
232}
233#endif