xref: /netbsd-src/sys/arch/hp300/stand/common/ite_rb.c (revision f6330dd725c1f2d119707be88b31baed489568a4)
1 /*	$NetBSD: ite_rb.c,v 1.11 2011/02/10 12:46:22 tsutsui Exp $	*/
2 
3 /*
4  * Copyright (c) 1988 University of Utah.
5  * Copyright (c) 1990, 1993
6  *	The Regents of the University of California.  All rights reserved.
7  *
8  * This code is derived from software contributed to Berkeley by
9  * the Systems Programming Group of the University of Utah Computer
10  * Science Department.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  * from: Utah $Hdr: ite_rb.c 1.6 92/01/20$
37  *
38  *	@(#)ite_rb.c	8.1 (Berkeley) 6/10/93
39  */
40 
41 #ifdef ITECONSOLE
42 
43 #include <sys/param.h>
44 
45 #include <hp300/stand/common/itereg.h>
46 #include <hp300/stand/common/grf_rbreg.h>
47 
48 #include <hp300/stand/common/samachdep.h>
49 #include <hp300/stand/common/itevar.h>
50 
51 void rbox_windowmove(struct ite_data *, int, int, int, int, int, int, int);
52 
53 void
rbox_init(struct ite_data * ip)54 rbox_init(struct ite_data *ip)
55 {
56 	struct rboxfb *regbase = (void *)ip->regbase;
57 	int i;
58 
59 	ip->bmv = rbox_windowmove;
60 
61 	rb_waitbusy(regbase);
62 	DELAY(3000);
63 
64 	regbase->interrupt = 0x04;
65 	regbase->display_enable = 0x01;
66 	regbase->video_enable = 0x01;
67 	regbase->drive = 0x01;
68 	regbase->vdrive = 0x0;
69 
70 	ite_fontinfo(ip);
71 
72 	regbase->opwen = 0xFF;
73 
74 	/*
75 	 * Clear the framebuffer.
76 	 */
77 	rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
78 	rb_waitbusy(regbase);
79 
80 	for(i = 0; i < 16; i++) {
81 		*((char *)ip->regbase + 0x63c3 + i * 4) = 0x0;
82 		*((char *)ip->regbase + 0x6403 + i * 4) = 0x0;
83 		*((char *)ip->regbase + 0x6803 + i * 4) = 0x0;
84 		*((char *)ip->regbase + 0x6c03 + i * 4) = 0x0;
85 		*((char *)ip->regbase + 0x73c3 + i * 4) = 0x0;
86 		*((char *)ip->regbase + 0x7403 + i * 4) = 0x0;
87 		*((char *)ip->regbase + 0x7803 + i * 4) = 0x0;
88 		*((char *)ip->regbase + 0x7c03 + i * 4) = 0x0;
89 	}
90 
91 	regbase->rep_rule = 0x33;
92 
93 	/*
94 	 * I cannot figure out how to make the blink planes stop. So, we
95 	 * must set both colormaps so that when the planes blink, and
96 	 * the secondary colormap is active, we still get text.
97 	 */
98 	CM1RED[0x00].value = 0x00;
99 	CM1GRN[0x00].value = 0x00;
100 	CM1BLU[0x00].value = 0x00;
101 	CM1RED[0x01].value = 0xFF;
102 	CM1GRN[0x01].value = 0xFF;
103 	CM1BLU[0x01].value = 0xFF;
104 
105 	CM2RED[0x00].value = 0x00;
106 	CM2GRN[0x00].value = 0x00;
107 	CM2BLU[0x00].value = 0x00;
108 	CM2RED[0x01].value = 0xFF;
109 	CM2GRN[0x01].value = 0xFF;
110 	CM2BLU[0x01].value = 0xFF;
111 
112 	regbase->blink = 0x00;
113 	regbase->write_enable = 0x01;
114 	regbase->opwen = 0x00;
115 
116 	ite_fontinit8bpp(ip);
117 
118 	/*
119 	 * Stash the inverted cursor.
120 	 */
121 	rbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
122 			    ip->cblanky, ip->cblankx, ip->ftheight,
123 			    ip->ftwidth, RR_COPYINVERTED);
124 }
125 
126 void
rbox_windowmove(struct ite_data * ip,int sy,int sx,int dy,int dx,int h,int w,int func)127 rbox_windowmove(struct ite_data *ip, int sy, int sx, int dy, int dx, int h,
128     int w, int func)
129 {
130 	struct rboxfb *rp = (void *)ip->regbase;
131 
132 	if (h == 0 || w == 0)
133 		return;
134 
135 	rb_waitbusy(rp);
136 	rp->rep_rule = func << 4 | func;
137 	rp->source_y = sy;
138 	rp->source_x = sx;
139 	rp->dest_y = dy;
140 	rp->dest_x = dx;
141 	rp->wheight = h;
142 	rp->wwidth  = w;
143 	rp->wmove = 1;
144 }
145 #endif
146