cgtworeg.h revision 1.1 1 1.1 deraadt /*
2 1.1 deraadt * Copyright (c) 1994 Dennis Ferguson
3 1.1 deraadt * All rights reserved.
4 1.1 deraadt *
5 1.1 deraadt * Redistribution and use in source and binary forms, with or without
6 1.1 deraadt * modification, are permitted provided that the following conditions
7 1.1 deraadt * are met:
8 1.1 deraadt * 1. Redistributions of source code must retain the above copyright
9 1.1 deraadt * notice, this list of conditions and the following disclaimer.
10 1.1 deraadt * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 deraadt * notice, this list of conditions and the following disclaimer in the
12 1.1 deraadt * documentation and/or other materials provided with the distribution.
13 1.1 deraadt *
14 1.1 deraadt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 1.1 deraadt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 1.1 deraadt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 1.1 deraadt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 1.1 deraadt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 1.1 deraadt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 1.1 deraadt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 1.1 deraadt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 1.1 deraadt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 1.1 deraadt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 1.1 deraadt *
25 1.1 deraadt * $Id: cgtworeg.h,v 1.1 1994/08/14 00:13:20 deraadt Exp $
26 1.1 deraadt */
27 1.1 deraadt
28 1.1 deraadt /* cgtworeg.h - CG2 colour frame buffer definitions
29 1.1 deraadt *
30 1.1 deraadt * The mapped memory looks like:
31 1.1 deraadt *
32 1.1 deraadt * offset contents
33 1.1 deraadt * 0x000000 bit plane map - 1st (of 8) plane used by the X server in -mono mode
34 1.1 deraadt * 0x100000 pixel map - used by the X server in color mode
35 1.1 deraadt * 0x200000 raster op mode memory map - unused by X server
36 1.1 deraadt * 0x300000 random control registers (lots of spaces in between)
37 1.1 deraadt * 0x310000 shadow colour map
38 1.1 deraadt */
39 1.1 deraadt
40 1.1 deraadt /* Frame buffer memory size and depth */
41 1.1 deraadt #define CG2_FBSIZE (1024 * 1024)
42 1.1 deraadt #define CG2_N_PLANE 8
43 1.1 deraadt
44 1.1 deraadt /* Screen dimensions */
45 1.1 deraadt #define CG2_WIDTH 1152
46 1.1 deraadt #define CG2_HEIGHT 900
47 1.1 deraadt
48 1.1 deraadt /* arrangement of bit plane mode memory */
49 1.1 deraadt union bitplane {
50 1.1 deraadt u_short word[CG2_HEIGHT][CG2_WIDTH/(CG2_N_PLANE * sizeof(u_short))];
51 1.1 deraadt u_short plane[CG2_FBSIZE/(CG2_N_PLANE * sizeof(u_short))];
52 1.1 deraadt };
53 1.1 deraadt
54 1.1 deraadt /* arrangement of pixel mode memory */
55 1.1 deraadt union byteplane {
56 1.1 deraadt u_char pixel[CG2_HEIGHT][CG2_WIDTH];
57 1.1 deraadt u_char frame[CG2_FBSIZE];
58 1.1 deraadt };
59 1.1 deraadt
60 1.1 deraadt
61 1.1 deraadt /*
62 1.1 deraadt * Structure describing the first two megabytes of the frame buffer.
63 1.1 deraadt * Normal memory maps in bit plane and pixel modes
64 1.1 deraadt */
65 1.1 deraadt struct cg2memfb {
66 1.1 deraadt union bitplane memplane[CG2_N_PLANE]; /* bit plane map */
67 1.1 deraadt union byteplane pixplane; /* pixel map */
68 1.1 deraadt };
69 1.1 deraadt
70 1.1 deraadt
71 1.1 deraadt /*
72 1.1 deraadt * Control/status register. The X server only appears to use update_cmap
73 1.1 deraadt * and video_enab.
74 1.1 deraadt */
75 1.1 deraadt struct cg2statusreg {
76 1.1 deraadt u_int reserved : 2; /* not used */
77 1.1 deraadt u_int fastread : 1; /* r/o: has some feature I don't understand */
78 1.1 deraadt u_int id : 1; /* r/o: ext status and ID registers exist */
79 1.1 deraadt u_int resolution : 4; /* screen resolution, 0 means 1152x900 */
80 1.1 deraadt u_int retrace : 1; /* r/o: retrace in progress */
81 1.1 deraadt u_int inpend : 1; /* r/o: interrupt request */
82 1.1 deraadt u_int ropmode : 3; /* ?? */
83 1.1 deraadt u_int inten : 1; /* interrupt enable (for end of retrace) */
84 1.1 deraadt u_int update_cmap : 1; /* copy/use shadow colour map */
85 1.1 deraadt u_int video_enab : 1; /* enable video */
86 1.1 deraadt };
87 1.1 deraadt
88 1.1 deraadt
89 1.1 deraadt /*
90 1.1 deraadt * Extended status register. Unused by X server
91 1.1 deraadt */
92 1.1 deraadt struct cg2_extstatus {
93 1.1 deraadt u_int gpintreq : 1; /* interrupt request */
94 1.1 deraadt u_int gpintdis : 1; /* interrupt disable */
95 1.1 deraadt u_int reserved : 13; /* unused */
96 1.1 deraadt u_int gpbus : 1; /* bus enabled */
97 1.1 deraadt };
98 1.1 deraadt
99 1.1 deraadt
100 1.1 deraadt /*
101 1.1 deraadt * Double buffer control register. It appears that (some of?) the
102 1.1 deraadt * cg2 cards support a pair of memory sets, referred to as `A' and
103 1.1 deraadt * `B', which can be swapped to allow atomic screen updates. This
104 1.1 deraadt * controls them.
105 1.1 deraadt */
106 1.1 deraadt struct dblbufreg {
107 1.1 deraadt u_int display_b : 1; /* display memory B (set) or A (reset) */
108 1.1 deraadt u_int read_b : 1; /* accesss memory B (set) or A (reset) */
109 1.1 deraadt u_int nowrite_b : 1; /* when set, writes don't update memory B */
110 1.1 deraadt u_int nowrite_a : 1; /* when set, writes don't update memory A */
111 1.1 deraadt u_int read_ecmap : 1; /* copy from(clear)/to(set) shadow colour map */
112 1.1 deraadt u_int fast_read : 1; /* fast reads, but wrong data */
113 1.1 deraadt u_int wait : 1; /* when set, remains so to end up v. retrace */
114 1.1 deraadt u_int update_ecmap : 1; /* copy/use shadow colour map */
115 1.1 deraadt u_int reserved : 8;
116 1.1 deraadt };
117 1.1 deraadt
118 1.1 deraadt
119 1.1 deraadt /*
120 1.1 deraadt * Zoom register, apparently present on Sun-2 colour boards only. See
121 1.1 deraadt * the Sun documentation, I don't know anyone who still has a Sun-2.
122 1.1 deraadt */
123 1.1 deraadt struct cg2_zoom {
124 1.1 deraadt union {
125 1.1 deraadt u_int short reg;
126 1.1 deraadt u_char reg_pad[4096];
127 1.1 deraadt } wordpan;
128 1.1 deraadt union {
129 1.1 deraadt struct {
130 1.1 deraadt u_int unused : 8;
131 1.1 deraadt u_int lineoff : 4;
132 1.1 deraadt u_int pixzoom : 4;
133 1.1 deraadt } reg;
134 1.1 deraadt u_short word;
135 1.1 deraadt u_char reg_pad[4096];
136 1.1 deraadt } zoom;
137 1.1 deraadt union {
138 1.1 deraadt struct {
139 1.1 deraadt u_int unused : 8;
140 1.1 deraadt u_int lorigin : 4;
141 1.1 deraadt u_int pixeloff : 4;
142 1.1 deraadt } reg;
143 1.1 deraadt u_short word;
144 1.1 deraadt u_char reg_pad[4096];
145 1.1 deraadt } pixpan;
146 1.1 deraadt union {
147 1.1 deraadt u_short reg;
148 1.1 deraadt u_char reg_pad[4096];
149 1.1 deraadt } varzoom;
150 1.1 deraadt };
151 1.1 deraadt
152 1.1 deraadt
153 1.1 deraadt /*
154 1.1 deraadt * Miscellany. On the Sun-3 these registers exist in place of the above.
155 1.1 deraadt */
156 1.1 deraadt struct cg2_nozoom {
157 1.1 deraadt union { /* double buffer register (see above) */
158 1.1 deraadt struct dblbufreg reg;
159 1.1 deraadt u_short word;
160 1.1 deraadt u_char reg_pad[4096];
161 1.1 deraadt } dblbuf;
162 1.1 deraadt union { /* start of dma window */
163 1.1 deraadt u_short reg;
164 1.1 deraadt u_char reg_pad[4096];
165 1.1 deraadt } dmabase;
166 1.1 deraadt union { /* dma window size */
167 1.1 deraadt u_short reg; /* actually 8 bits. reg*16 == size */
168 1.1 deraadt u_char reg_pad[4096];
169 1.1 deraadt } dmawidth;
170 1.1 deraadt union { /* frame count */
171 1.1 deraadt u_short reg; /* actually 8 bits only. r/o */
172 1.1 deraadt u_char reg_pad[4096];
173 1.1 deraadt } framecnt;
174 1.1 deraadt };
175 1.1 deraadt
176 1.1 deraadt
177 1.1 deraadt /*
178 1.1 deraadt * Raster op control registers. X doesn't use this, but documented here
179 1.1 deraadt * for future reference.
180 1.1 deraadt */
181 1.1 deraadt struct memropc {
182 1.1 deraadt u_short mrc_dest;
183 1.1 deraadt u_short mrc_source1;
184 1.1 deraadt u_short mrc_source2;
185 1.1 deraadt u_short mrc_pattern;
186 1.1 deraadt u_short mrc_mask1;
187 1.1 deraadt u_short mrc_mask2;
188 1.1 deraadt u_short mrc_shift;
189 1.1 deraadt u_short mrc_op;
190 1.1 deraadt u_short mrc_width;
191 1.1 deraadt u_short mrc_opcount;
192 1.1 deraadt u_short mrc_decoderout;
193 1.1 deraadt u_short mrc_x11;
194 1.1 deraadt u_short mrc_x12;
195 1.1 deraadt u_short mrc_x13;
196 1.1 deraadt u_short mrc_x14;
197 1.1 deraadt u_short mrc_x15;
198 1.1 deraadt };
199 1.1 deraadt
200 1.1 deraadt
201 1.1 deraadt /*
202 1.1 deraadt * Last chunk of the frame buffer (i.e. from offset 0x200000 and above).
203 1.1 deraadt * Exists separately from struct cg2memfb apparently because Sun software
204 1.1 deraadt * avoids mapping the latter, though X uses it.
205 1.1 deraadt */
206 1.1 deraadt struct cg2fb {
207 1.1 deraadt union { /* raster op mode frame memory */
208 1.1 deraadt union bitplane ropplane[CG2_N_PLANE];
209 1.1 deraadt union byteplane roppixel;
210 1.1 deraadt } ropio;
211 1.1 deraadt union { /* raster op control unit (1 per plane) */
212 1.1 deraadt struct memropc ropregs;
213 1.1 deraadt struct {
214 1.1 deraadt u_char pad[2048];
215 1.1 deraadt struct memropc ropregs;
216 1.1 deraadt } prime;
217 1.1 deraadt u_char reg_pad[4096];
218 1.1 deraadt } ropcontrol[9];
219 1.1 deraadt union { /* status register */
220 1.1 deraadt struct cg2statusreg reg;
221 1.1 deraadt u_short word;
222 1.1 deraadt u_char reg_pad[4096];
223 1.1 deraadt } status;
224 1.1 deraadt union { /* per-plane mask register */
225 1.1 deraadt u_short reg; /* 8 bit mask register - set means plane r/w */
226 1.1 deraadt u_char reg_pad[4096];
227 1.1 deraadt } ppmask;
228 1.1 deraadt union { /* miscellaneous registers */
229 1.1 deraadt struct cg2_zoom zoom;
230 1.1 deraadt struct cg2_nozoom nozoom;
231 1.1 deraadt } misc;
232 1.1 deraadt union { /* interrupt vector */
233 1.1 deraadt u_short reg;
234 1.1 deraadt u_char reg_pad[32];
235 1.1 deraadt } intrptvec;
236 1.1 deraadt union { /* board ID */
237 1.1 deraadt u_short reg;
238 1.1 deraadt u_char reg_pad[16];
239 1.1 deraadt } id;
240 1.1 deraadt union { /* extended status */
241 1.1 deraadt struct cg2_extstatus reg;
242 1.1 deraadt u_short word;
243 1.1 deraadt u_char reg_pad[16];
244 1.1 deraadt } extstatus;
245 1.1 deraadt union { /* auxiliary raster op mode register (?)*/
246 1.1 deraadt u_short reg;
247 1.1 deraadt u_char reg_pad[4032];
248 1.1 deraadt } ropmode;
249 1.1 deraadt u_short redmap[256]; /* shadow colour maps */
250 1.1 deraadt u_short greenmap[256];
251 1.1 deraadt u_short bluemap[256];
252 1.1 deraadt };
253