grf_rhreg.h revision 1.4 1 /* $NetBSD: grf_rhreg.h,v 1.4 1995/02/16 21:57:38 chopps Exp $ */
2
3 /*
4 * Copyright (c) 1994 Markus Wild
5 * Copyright (c) 1994 Lutz Vieweg
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Lutz Vieweg.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 #ifndef _GRF_RHREG_H
34 #define _GRF_RHREG_H
35
36 #define EMPTY_ALPHA 0x2010 /* this is the char and the attribute
37 that AlphaErase will fill into the
38 text-screen */
39
40 #define MEMCLK 65000000 /* this is the memory clock value, you shouldn't
41 set it to less than 65000000, higher values may
42 speed up blits a little bit, if you raise this
43 value too much, some trash will appear on your
44 screen. */
45
46 #define MEMSIZE 4 /* Set this to 1 or 4 (MB), according to the
47 RAM on your Retina BLT Z3 board */
48 /*
49 * The following definitions are places in the frame-buffer memory
50 * which are used for special purposes. While the displayed screen
51 * itself is always beginning at the start of the frame-buffer
52 * memory, the following special places are located at the end
53 * of the memory to keep free as much space as possible for the
54 * screen - the user might want to use monitor-definitions with
55 * huge logical dimensions (e.g. 2048x2000 ?). This way of defining
56 * special locations in the frame-buffer memory is far from being
57 * elegant - you may want to use you own, real memory-management...
58 * but remember that some routines in RZ3_BSD.cc REALLY NEED those
59 * memory locations to function properly, so if you manage the
60 * frame-buffer memory on your own, make sure to change those
61 * definitions appropriately.
62 */
63
64 /* reserve some space for one pattern line */
65 #define PAT_MEM_SIZE 16*3
66 #define PAT_MEM_OFF (MEMSIZE*1024*1024 - PAT_MEM_SIZE)
67
68 /* reserve some space for the hardware cursor (up to 64x64 pixels) */
69 #define HWC_MEM_SIZE 1024
70 #define HWC_MEM_OFF ((PAT_MEM_OFF - HWC_MEM_SIZE) & 0xffffff00)
71
72 /*
73 * The following structure is passed to RZ3Init() and holds the
74 * monitor-definition. You may either use one of the ready-made
75 * definitions in RZ3_monitors.cc or you can define them on your
76 * own, take a look at RZ3_monitors.cc for more information.
77 */
78 struct MonDef {
79
80 /* first the general monitor characteristics */
81
82 unsigned long FQ;
83 unsigned char FLG;
84
85 unsigned short MW; /* physical screen width in pixels */
86 /* has to be at least a multiple of 8 */
87 unsigned short MH; /* physical screen height in pixels */
88
89 unsigned short HBS;
90 unsigned short HSS;
91 unsigned short HSE;
92 unsigned short HBE;
93 unsigned short HT;
94 unsigned short VBS;
95 unsigned short VSS;
96 unsigned short VSE;
97 unsigned short VBE;
98 unsigned short VT;
99
100 unsigned short DEP; /* Color-depth, 4 enables text-mode */
101 /* 8 enables 256-color graphics-mode, */
102 /* 16 and 24bit gfx not supported yet */
103
104 unsigned char * PAL; /* points to 16*3 byte RGB-palette data */
105 /* use LoadPalette() to set colors 0..255 */
106 /* in 256-color-gfx mode */
107
108 /*
109 * all following entries are font-specific in
110 * text-mode. Make sure your monitor
111 * parameters are calculated for the
112 * appropriate font width and height!
113 */
114
115 unsigned short TX; /* Text-mode (DEP=4): */
116 /* screen-width in characters */
117
118 /* Gfx-mode (DEP > 4) */
119 /* "logical" screen-width, */
120 /* use values > MW to allow */
121 /* hardware-panning */
122
123 unsigned short TY; /* Text-mode: */
124 /* screen-height in characters */
125
126 /* Gfx-mode: "logical" screen */
127 /* height for panning */
128
129 /* the following values are currently unused for gfx-mode */
130
131 unsigned short XY; /* TX*TY (speeds up some calcs.) */
132
133 unsigned short FX; /* font-width (valid values: 4,7-16) */
134 unsigned short FY; /* font-height (valid range: 1-32) */
135 unsigned char * FData; /* pointer to the font-data */
136
137 /*
138 * The font data is simply an array of bytes defining
139 * the chars in ascending order, line by line. If your
140 * font is wider than 8 pixel, FData has to be an
141 * array of words.
142 */
143
144 unsigned short FLo; /* lowest character defined */
145 unsigned short FHi; /* highest char. defined */
146
147 };
148
149
150 /*
151 * The following are the prototypes for the low-level
152 * routines you may want to call.
153 */
154
155 #if 0
156
157 #ifdef __GNUG__
158
159 /* The prototypes for C++, prototypes for C (with explanations) below */
160
161 "C" unsigned char * RZ3Init (volatile void * HardWareAdress, struct MonDef * md);
162 "C" void RZ3SetCursorPos (unsigned short pos);
163 "C" void RZ3AlphaErase (unsigned short xd, unsigned short yd,
164 unsigned short w, unsigned short h );
165 "C" void RZ3AlphaCopy (unsigned short xs, unsigned short ys,
166 unsigned short xd, unsigned short yd,
167 unsigned short w, unsigned short h );
168 "C" void RZ3BitBlit (struct grf_bitblt * gbb );
169 "C" void RZ3BitBlit16 (struct grf_bitblt * gbb );
170 "C" void RZ3LoadPalette (unsigned char * pal, unsigned char firstcol, unsigned char colors);
171 "C" void RZ3SetPalette (unsigned char colornum, unsigned char red, unsigned char green, unsigned char blue);
172 "C" void RZ3SetPanning (unsigned short xoff, unsigned short yoff);
173 "C" void RZ3SetupHWC (unsigned char col1, unsigned col2,
174 unsigned char hsx, unsigned char hsy,
175 const unsigned long * data);
176 "C" void RZ3DisableHWC (void);
177 "C" void RZ3SetHWCloc (unsigned short x, unsigned short y);
178 #else
179
180 /* The prototypes for C */
181 /* with a little explanation */
182
183 unsigned char * RZ3Init(volatile void * BoardAdress, struct MonDef * md);
184
185 /*
186 * This routine initialises the Retina Z3 hardware, opens a
187 * text- or gfx-mode screen, depending on the the value of
188 * MonDef.DEP, and sets the cursor to position 0.
189 * It takes as arguments a pointer to the hardware-base
190 * address as it is denoted in the DevConf structure
191 * of the AmigaDOS, and a pointer to a struct MonDef
192 * which describes the screen-mode parameters.
193 *
194 * The routine returns 0 if it was unable to open the screen,
195 * or an unsigned char * to the display memory when it
196 * succeeded.
197 *
198 * The organisation of the display memory in text-mode is a
199 * little strange (Intel-typically...) :
200 *
201 * Byte 00 01 02 03 04 05 06 etc.
202 * Char0 Attr0 -- -- Char1 Attr1 -- etc.
203 *
204 * You may set a character and its associated attribute byte
205 * with a single word-access, or you may perform to byte writes
206 * for the char and attribute. Each 2. word has no meaning,
207 * and writes to theese locations are ignored.
208 *
209 * The attribute byte for each character has the following
210 * structure:
211 *
212 * Bit 7 6 5 4 3 2 1 0
213 * BLINK BACK2 BACK1 BACK0 FORE3 FORE2 FORE1 FORE0
214 *
215 * Were FORE is the foreground-color index (0-15) and
216 * BACK is the background color index (0-7). BLINK
217 * enables blinking for the associated character.
218 * The higher 8 colors in the standard palette are
219 * lighter than the lower 8, so you may see FORE3 as
220 * an intensity bit. If FORE == 1 or FORE == 9 and
221 * BACK == 0 the character is underlined. Since I don't
222 * think this looks good, it will probably change in a
223 * future release.
224 *
225 * There's no routine "SetChar" or "SetAttr" provided,
226 * because I think it's so trivial... a function call
227 * would be pure overhead. As an example, a routine
228 * to set the char code and attribute at position x,y:
229 * (assumed the value returned by RZ3Init was stored
230 * into "DispMem", the actual MonDef struct * is hold
231 * in "MDef")
232 *
233 * void SetChar(unsigned char chr, unsigned char attr,
234 * unsigned short x, unsigned short y) {
235 *
236 * unsigned struct MonDef * md = MDef;
237 * unsigned char * c = DispMem + x*4 + y*md->TX*4;
238 *
239 * *c++ = chr;
240 * *c = attr;
241 *
242 * }
243 *
244 * In gfx-mode, the memory organisation is rather simple,
245 * 1 byte per pixel in 256-color mode, one pixel after
246 * each other, line by line.
247 *
248 * When 16-bits per pixel are used, each two bytes represent
249 * one pixel. The meaning of the bits is the following:
250 *
251 * Bit 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
252 * Component g2 g1 g0 b4 b3 b2 b1 b0 r4 r3 r2 r1 r0 g5 g4 g3
253 *
254 * Please note that the memory layout in gfx-mode depends
255 * on the logical screen-size, panning does only affect
256 * the appearance of the physical screen.
257 *
258 * Currently, RZ3Init() disables the Retina Z3 VBLANK IRQ,
259 * but beware: When running the Retina WB-Emu under
260 * AmigaDOS, the VBLANK IRQ is ENABLED...
261 *
262 */
263
264 void RZ3LoadPalette(unsigned char * pal, unsigned char firstcol, unsigned char colors);
265
266 /*
267 * Loads the palette-registers. "pal" points to an array of unsigned char
268 * triplets, for the red, green and blue component. "firstcol" determines the
269 * number of the first palette-register to load (256 available). "colors" is
270 * the number of colors you want to put in the palette registers.
271 */
272
273 void RZ3SetPalette(unsigned char colornum, unsigned char red, unsigned char green, unsigned char blue);
274
275 /*
276 * Allows you to set a single color in the palette, "colornum" is the number
277 * of the palette entry (256 available), "red", "green" and "blue" are the
278 * three components.
279 */
280
281 void RZ3SetCursorPos(unsigned short pos);
282
283 /*
284 * This routine sets the text-mode hardware-cursor position to the screen
285 * location pos. pos can be calculated as (x + y * md->TY).
286 * Text-mode only!
287 */
288
289 void RZ3AlphaCopy (unsigned short xs, unsigned short ys,
290 unsigned short xd, unsigned short yd,
291 unsigned short w, unsigned short h );
292
293 /*
294 * This Routine utilizes the blitter to perform fast copies
295 * in the text-display. The paramters are:
296 * xs - source x-coordinate
297 * ys - source y-coordinate
298 * xd - destination x-coordinate
299 * yd - destination y-coordinate
300 * w - the width of the area to copy
301 * h - the height of the area to copy
302 * All coordinates are in characters. RZ3AlphaCopy does not
303 * check for boundaries - you've got to make sure that the
304 * parameters have sensible values. Text-mode only!
305 */
306
307
308 void RZ3AlphaErase (unsigned short xd, unsigned short yd,
309 unsigned short w, unsigned short h );
310
311 /*
312 * RZ3AlphaErase utilizes the blitter to erase portions of
313 * the text-display. The parameters are:
314 * xd - destination x-coordinate
315 * yd - destination y-coordinate
316 * w - the width of the area to erase
317 * h - the height of the area to erase
318 * All coordinates are in characters. RZ3AlphaCopy does not
319 * check for boundaries - you've got to make sure that the
320 * parameters have sensible values. Text-mode only!
321 *
322 * Since the blitter is unable to use a mask-pattern and a
323 * certain fill-value at the same time, this routine uses
324 * a simple trick: RZ3Init() clears a memory area twice as
325 * large as the text-display needs, and RZ3AlphaErase then
326 * simply uses RZ3AlphaCopy to copy the desired area from
327 * the empty text-screen to the actually displayed screen.
328 */
329
330 void RZ3BitBlit (struct grf_bitblt * gbb );
331
332 /*
333 * RZ3BitBlit utilizes the blitter to perform one of 16
334 * available logical operations on the display memory,
335 * among them ordinary fill- and copy operations.
336 * The only parameter is a pointer to a struct grf_bitblt:
337 *
338 * struct grf_bitblt {
339 * unsigned short op; see above definitions of GRFBBOPxxx
340 * unsigned short src_x, src_y; upper left corner of source-region
341 * unsigned short dst_x, dst_y; upper left corner of dest-region
342 * unsigned short w, h; width, height of region
343 * unsigned short mask; bitmask to apply
344 * };
345 *
346 * All coordinates are in pixels. RZ3BitBlit does not
347 * check for boundaries - you've got to make sure that the
348 * parameters have sensible values. 8 bit gfx-mode only!
349 *
350 * The blitter has a lot more capabilities, which aren't
351 * currently used by theese routines, among them color-expanded
352 * and text-blits, which can speed up GUIs like X11 a lot.
353 * If you've got any idea how to make use of them within
354 * your routines, contact me, and I'll implement the necessary
355 * blit-operations.
356 */
357
358 void RZ3BitBlit16( struct grf_bitblt * gbb );
359
360 /* Does the same as RZ3BitBlit(), but for 16-bit screens */
361
362 void RZ3SetPanning(unsigned short xoff, unsigned short yoff);
363
364 /*
365 * Moves the logical coordinate (xoff, yoff) to the upper left corner
366 * of your screen. Of course, you shouldn't specify excess values that would
367 * show garbage in the lower right area of your screen... SetPanning()
368 * does NOT check for boundaries.
369 * Please read the documentation of RZ3SetHWCloc, too.
370 */
371
372 void RZ3SetupHWC (unsigned char col1, unsigned col2,
373 unsigned char hsx, unsigned char hsy,
374 const unsigned long * data);
375
376 /*
377 * Initializes and switches on the hardware-cursor sprite.
378 * The parameters are:
379 * col1 - the first color
380 * col2 - the second color
381 * hsx - hot-spot location offset x
382 * hsy - hot-spot location offset y
383 * data - a pointer to the bitmap data to be used for the sprite
384 *
385 * The organization of the data is - as always with MSDOS related
386 * products - rather strange: The first and the second long-word
387 * represent bitplane0 for the first 64 pixels. The following two
388 * long-words represent bitplane1 for the first 64 pixels. But
389 * the long-words are organized in Intel-fashion, beginning with
390 * the least significant byte, ending with the most significant
391 * one. The most significant bit of each byte is the leftmost,
392 * as one would expect it. Now the weird color-assignments:
393 *
394 * bitplane0 bitplane1 result
395 * 0 0 col2
396 * 0 1 col1
397 * 1 0 transparent
398 * 1 1 background-color XOR 0xff
399 *
400 * The size of the data has to be 64*64*2/8 = 1024 byte,
401 * obviously, the size of the sprite is 64x64 pixels.
402 */
403
404
405 void RZ3DisableHWC (void);
406
407 /* simply disables the hardware-cursor sprite */
408
409 void RZ3SetHWCloc (unsigned short x, unsigned short y);
410
411 /*
412 * sets the location of the hardwar-cursor sprite to x,y
413 * relative to the logical screen beginning.
414 * IMPORTANT: If you use RZ3SetHWCloc() to set the position
415 * of the hardware-cursor sprite, all necessary panning is
416 * done automatically - you can treat the display without
417 * even knowing about the physical screen size that is
418 * displayed.
419 */
420
421 #endif
422
423 #endif /* RZ3_BSD_h */
424
425
426 /* -------------- START OF CODE -------------- */
427
428 /* read VGA register */
429 #define vgar(ba, reg) (*(((volatile unsigned char *)ba)+reg))
430
431 /* write VGA register */
432 #define vgaw(ba, reg, val) \
433 *(((volatile unsigned char *)ba)+reg) = val
434
435 /*
436 * defines for the used register addresses (mw)
437 *
438 * NOTE: there are some registers that have different addresses when
439 * in mono or color mode. We only support color mode, and thus
440 * some addresses won't work in mono-mode!
441 */
442
443 /* General Registers: */
444 #define GREG_STATUS0_R 0x03C2
445 #define GREG_STATUS1_R 0x03DA
446 #define GREG_MISC_OUTPUT_R 0x03CC
447 #define GREG_MISC_OUTPUT_W 0x03C2
448 #define GREG_FEATURE_CONTROL_R 0x03CA
449 #define GREG_FEATURE_CONTROL_W 0x03DA
450 #define GREG_POS 0x0102
451
452 /* Attribute Controller: */
453 #define ACT_ADDRESS 0x03C0
454 #define ACT_ADDRESS_R 0x03C0
455 #define ACT_ADDRESS_W 0x03C0
456 #define ACT_ADDRESS_RESET 0x03DA
457 #define ACT_ID_PALETTE0 0x00
458 #define ACT_ID_PALETTE1 0x01
459 #define ACT_ID_PALETTE2 0x02
460 #define ACT_ID_PALETTE3 0x03
461 #define ACT_ID_PALETTE4 0x04
462 #define ACT_ID_PALETTE5 0x05
463 #define ACT_ID_PALETTE6 0x06
464 #define ACT_ID_PALETTE7 0x07
465 #define ACT_ID_PALETTE8 0x08
466 #define ACT_ID_PALETTE9 0x09
467 #define ACT_ID_PALETTE10 0x0A
468 #define ACT_ID_PALETTE11 0x0B
469 #define ACT_ID_PALETTE12 0x0C
470 #define ACT_ID_PALETTE13 0x0D
471 #define ACT_ID_PALETTE14 0x0E
472 #define ACT_ID_PALETTE15 0x0F
473 #define ACT_ID_ATTR_MODE_CNTL 0x10
474 #define ACT_ID_OVERSCAN_COLOR 0x11
475 #define ACT_ID_COLOR_PLANE_ENA 0x12
476 #define ACT_ID_HOR_PEL_PANNING 0x13
477 #define ACT_ID_COLOR_SELECT 0x14
478
479 /* Graphics Controller: */
480 #define GCT_ADDRESS 0x03CE
481 #define GCT_ADDRESS_R 0x03CE
482 #define GCT_ADDRESS_W 0x03CF
483 #define GCT_ID_SET_RESET 0x00
484 #define GCT_ID_ENABLE_SET_RESET 0x01
485 #define GCT_ID_COLOR_COMPARE 0x02
486 #define GCT_ID_DATA_ROTATE 0x03
487 #define GCT_ID_READ_MAP_SELECT 0x04
488 #define GCT_ID_GRAPHICS_MODE 0x05
489 #define GCT_ID_MISC 0x06
490 #define GCT_ID_COLOR_XCARE 0x07
491 #define GCT_ID_BITMASK 0x08
492
493 /* Sequencer: */
494 #define SEQ_ADDRESS 0x03C4
495 #define SEQ_ADDRESS_R 0x03C4
496 #define SEQ_ADDRESS_W 0x03C5
497 #define SEQ_ID_RESET 0x00
498 #define SEQ_ID_CLOCKING_MODE 0x01
499 #define SEQ_ID_MAP_MASK 0x02
500 #define SEQ_ID_CHAR_MAP_SELECT 0x03
501 #define SEQ_ID_MEMORY_MODE 0x04
502 #define SEQ_ID_EXTENDED_ENABLE 0x05 /* down from here, all seq registers are NCR extensions */
503 #define SEQ_ID_UNKNOWN1 0x06
504 #define SEQ_ID_UNKNOWN2 0x07
505 #define SEQ_ID_CHIP_ID 0x08
506 #define SEQ_ID_UNKNOWN3 0x09
507 #define SEQ_ID_CURSOR_COLOR1 0x0A
508 #define SEQ_ID_CURSOR_COLOR0 0x0B
509 #define SEQ_ID_CURSOR_CONTROL 0x0C
510 #define SEQ_ID_CURSOR_X_LOC_HI 0x0D
511 #define SEQ_ID_CURSOR_X_LOC_LO 0x0E
512 #define SEQ_ID_CURSOR_Y_LOC_HI 0x0F
513 #define SEQ_ID_CURSOR_Y_LOC_LO 0x10
514 #define SEQ_ID_CURSOR_X_INDEX 0x11
515 #define SEQ_ID_CURSOR_Y_INDEX 0x12
516 #define SEQ_ID_CURSOR_STORE_HI 0x13 /* manual still wrong here.. argl! */
517 #define SEQ_ID_CURSOR_STORE_LO 0x14 /* downto 0x16 */
518 #define SEQ_ID_CURSOR_ST_OFF_HI 0x15
519 #define SEQ_ID_CURSOR_ST_OFF_LO 0x16
520 #define SEQ_ID_CURSOR_PIXELMASK 0x17
521 #define SEQ_ID_PRIM_HOST_OFF_HI 0x18
522 #define SEQ_ID_PRIM_HOST_OFF_LO 0x19
523 #define SEQ_ID_LINEAR_0 0x1A
524 #define SEQ_ID_LINEAR_1 0x1B
525 #define SEQ_ID_SEC_HOST_OFF_HI 0x1C
526 #define SEQ_ID_SEC_HOST_OFF_LO 0x1D
527 #define SEQ_ID_EXTENDED_MEM_ENA 0x1E
528 #define SEQ_ID_EXT_CLOCK_MODE 0x1F
529 #define SEQ_ID_EXT_VIDEO_ADDR 0x20
530 #define SEQ_ID_EXT_PIXEL_CNTL 0x21
531 #define SEQ_ID_BUS_WIDTH_FEEDB 0x22
532 #define SEQ_ID_PERF_SELECT 0x23
533 #define SEQ_ID_COLOR_EXP_WFG 0x24
534 #define SEQ_ID_COLOR_EXP_WBG 0x25
535 #define SEQ_ID_EXT_RW_CONTROL 0x26
536 #define SEQ_ID_MISC_FEATURE_SEL 0x27
537 #define SEQ_ID_COLOR_KEY_CNTL 0x28
538 #define SEQ_ID_COLOR_KEY_MATCH0 0x29
539 #define SEQ_ID_COLOR_KEY_MATCH1 0x2A
540 #define SEQ_ID_COLOR_KEY_MATCH2 0x2B
541 #define SEQ_ID_UNKNOWN6 0x2C
542 #define SEQ_ID_CRC_CONTROL 0x2D
543 #define SEQ_ID_CRC_DATA_LOW 0x2E
544 #define SEQ_ID_CRC_DATA_HIGH 0x2F
545 #define SEQ_ID_MEMORY_MAP_CNTL 0x30
546 #define SEQ_ID_ACM_APERTURE_1 0x31
547 #define SEQ_ID_ACM_APERTURE_2 0x32
548 #define SEQ_ID_ACM_APERTURE_3 0x33
549 #define SEQ_ID_BIOS_UTILITY_0 0x3e
550 #define SEQ_ID_BIOS_UTILITY_1 0x3f
551
552 /* CRT Controller: */
553 #define CRT_ADDRESS 0x03D4
554 #define CRT_ADDRESS_R 0x03D5
555 #define CRT_ADDRESS_W 0x03D5
556 #define CRT_ID_HOR_TOTAL 0x00
557 #define CRT_ID_HOR_DISP_ENA_END 0x01
558 #define CRT_ID_START_HOR_BLANK 0x02
559 #define CRT_ID_END_HOR_BLANK 0x03
560 #define CRT_ID_START_HOR_RETR 0x04
561 #define CRT_ID_END_HOR_RETR 0x05
562 #define CRT_ID_VER_TOTAL 0x06
563 #define CRT_ID_OVERFLOW 0x07
564 #define CRT_ID_PRESET_ROW_SCAN 0x08
565 #define CRT_ID_MAX_SCAN_LINE 0x09
566 #define CRT_ID_CURSOR_START 0x0A
567 #define CRT_ID_CURSOR_END 0x0B
568 #define CRT_ID_START_ADDR_HIGH 0x0C
569 #define CRT_ID_START_ADDR_LOW 0x0D
570 #define CRT_ID_CURSOR_LOC_HIGH 0x0E
571 #define CRT_ID_CURSOR_LOC_LOW 0x0F
572 #define CRT_ID_START_VER_RETR 0x10
573 #define CRT_ID_END_VER_RETR 0x11
574 #define CRT_ID_VER_DISP_ENA_END 0x12
575 #define CRT_ID_OFFSET 0x13
576 #define CRT_ID_UNDERLINE_LOC 0x14
577 #define CRT_ID_START_VER_BLANK 0x15
578 #define CRT_ID_END_VER_BLANK 0x16
579 #define CRT_ID_MODE_CONTROL 0x17
580 #define CRT_ID_LINE_COMPARE 0x18
581 #define CRT_ID_UNKNOWN1 0x19 /* are these register really void ? */
582 #define CRT_ID_UNKNOWN2 0x1A
583 #define CRT_ID_UNKNOWN3 0x1B
584 #define CRT_ID_UNKNOWN4 0x1C
585 #define CRT_ID_UNKNOWN5 0x1D
586 #define CRT_ID_UNKNOWN6 0x1E
587 #define CRT_ID_UNKNOWN7 0x1F
588 #define CRT_ID_UNKNOWN8 0x20
589 #define CRT_ID_UNKNOWN9 0x21
590 #define CRT_ID_UNKNOWN10 0x22
591 #define CRT_ID_UNKNOWN11 0x23
592 #define CRT_ID_UNKNOWN12 0x24
593 #define CRT_ID_UNKNOWN13 0x25
594 #define CRT_ID_UNKNOWN14 0x26
595 #define CRT_ID_UNKNOWN15 0x27
596 #define CRT_ID_UNKNOWN16 0x28
597 #define CRT_ID_UNKNOWN17 0x29
598 #define CRT_ID_UNKNOWN18 0x2A
599 #define CRT_ID_UNKNOWN19 0x2B
600 #define CRT_ID_UNKNOWN20 0x2C
601 #define CRT_ID_UNKNOWN21 0x2D
602 #define CRT_ID_UNKNOWN22 0x2E
603 #define CRT_ID_UNKNOWN23 0x2F
604 #define CRT_ID_EXT_HOR_TIMING1 0x30 /* down from here, all crt registers are NCR extensions */
605 #define CRT_ID_EXT_START_ADDR 0x31
606 #define CRT_ID_EXT_HOR_TIMING2 0x32
607 #define CRT_ID_EXT_VER_TIMING 0x33
608 #define CRT_ID_MONITOR_POWER 0x34
609
610 /* PLL chip (clock frequency synthesizer) I'm guessing here... */
611 #define PLL_ADDRESS 0x83c8
612 #define PLL_ADDRESS_W 0x83c9
613
614
615 /* Video DAC */
616 #define VDAC_ADDRESS 0x03c8
617 #define VDAC_ADDRESS_W 0x03c8
618 #define VDAC_ADDRESS_R 0x03c7
619 #define VDAC_STATE 0x03c7
620 #define VDAC_DATA 0x03c9
621 #define VDAC_MASK 0x03c6
622
623
624 /* Accelerator Control Menu (memory mapped registers, includes blitter) */
625 #define ACM_PRIMARY_OFFSET 0x00
626 #define ACM_SECONDARY_OFFSET 0x04
627 #define ACM_MODE_CONTROL 0x08
628 #define ACM_CURSOR_POSITION 0x0c
629 #define ACM_START_STATUS 0x30
630 #define ACM_CONTROL 0x34
631 #define ACM_RASTEROP_ROTATION 0x38
632 #define ACM_BITMAP_DIMENSION 0x3c
633 #define ACM_DESTINATION 0x40
634 #define ACM_SOURCE 0x44
635 #define ACM_PATTERN 0x48
636 #define ACM_FOREGROUND 0x4c
637 #define ACM_BACKGROUND 0x50
638
639
640 #define WGfx(ba, idx, val) \
641 do { vgaw(ba, GCT_ADDRESS, idx); vgaw(ba, GCT_ADDRESS_W , val); } while (0)
642
643 #define WSeq(ba, idx, val) \
644 do { vgaw(ba, SEQ_ADDRESS, idx); vgaw(ba, SEQ_ADDRESS_W , val); } while (0)
645
646 #define WCrt(ba, idx, val) \
647 do { vgaw(ba, CRT_ADDRESS, idx); vgaw(ba, CRT_ADDRESS_W , val); } while (0)
648
649 #define WAttr(ba, idx, val) \
650 do { vgaw(ba, ACT_ADDRESS, idx); vgaw(ba, ACT_ADDRESS_W, val); } while (0)
651
652 #define Map(m) \
653 do { WGfx(ba, GCT_ID_READ_MAP_SELECT, m & 3 ); WSeq(ba, SEQ_ID_MAP_MASK, (1 << (m & 3))); } while (0)
654
655 #define WPLL(ba, idx, val) \
656 do { vgaw(ba, PLL_ADDRESS, idx);\
657 vgaw(ba, PLL_ADDRESS_W, (val & 0xff));\
658 vgaw(ba, PLL_ADDRESS_W, (val >> 8)); } while (0)
659
660
661 static inline unsigned char RAttr(volatile void * ba, short idx) {
662 vgaw (ba, ACT_ADDRESS, idx);
663 return vgar (ba, ACT_ADDRESS_R);
664 }
665
666 static inline unsigned char RSeq(volatile void * ba, short idx) {
667 vgaw (ba, SEQ_ADDRESS, idx);
668 return vgar (ba, SEQ_ADDRESS_R);
669 }
670
671 static inline unsigned char RCrt(volatile void * ba, short idx) {
672 vgaw (ba, CRT_ADDRESS, idx);
673 return vgar (ba, CRT_ADDRESS_R);
674 }
675
676 static inline unsigned char RGfx(volatile void * ba, short idx) {
677 vgaw(ba, GCT_ADDRESS, idx);
678 return vgar (ba, GCT_ADDRESS_R);
679 }
680
681 void RZ3DisableHWC __P((struct grf_softc *gp));
682 void RZ3SetupHWC __P((struct grf_softc *gp, unsigned char col1, unsigned int col2, unsigned char hsx, unsigned char hsy, const long unsigned int *data));
683 void RZ3AlphaErase __P((struct grf_softc *gp, short unsigned int xd, short unsigned int yd, short unsigned int w, short unsigned int h));
684 void RZ3AlphaCopy __P((struct grf_softc *gp, short unsigned int xs, short unsigned int ys, short unsigned int xd, short unsigned int yd, short unsigned int w, short unsigned int h));
685 void RZ3BitBlit __P((struct grf_softc *gp, struct grf_bitblt *gbb));
686 void RZ3BitBlit16 __P((struct grf_softc *gp, struct grf_bitblt *gbb));
687 void RZ3SetCursorPos __P((struct grf_softc *gp, short unsigned int pos));
688 void RZ3LoadPalette __P((struct grf_softc *gp, unsigned char *pal, unsigned char firstcol, unsigned char colors));
689 void RZ3SetPalette __P((struct grf_softc *gp, unsigned char colornum, unsigned char red, unsigned char green, unsigned char blue));
690 void RZ3SetPanning __P((struct grf_softc *gp, short unsigned int xoff, short unsigned int yoff));
691 void RZ3SetHWCloc __P((struct grf_softc *gp, short unsigned int x, short unsigned int y));
692 int rh_mode __P((register struct grf_softc *gp, int cmd, void *arg, int a2, int a3));
693 int rh_ioctl __P((register struct grf_softc *gp, u_long cmd, void *data));
694 int rh_getcmap __P((struct grf_softc *gfp, struct grf_colormap *cmap));
695 int rh_putcmap __P((struct grf_softc *gfp, struct grf_colormap *cmap));
696 int rh_getspritepos __P((struct grf_softc *gp, struct grf_position *pos));
697 int rh_setspritepos __P((struct grf_softc *gp, struct grf_position *pos));
698 int rh_getspriteinfo __P((struct grf_softc *gp, struct grf_spriteinfo *info));
699 int rh_setspriteinfo __P((struct grf_softc *gp, struct grf_spriteinfo *info));
700 int rh_getspritemax __P((struct grf_softc *gp, struct grf_position *pos));
701 int rh_bitblt __P((struct grf_softc *gp, struct grf_bitblt *bb));
702
703
704 struct ite_softc;
705 void rh_init __P((struct ite_softc *));
706 void rh_cursor __P((struct ite_softc *, int));
707 void rh_deinit __P((struct ite_softc *));
708 void rh_putc __P((struct ite_softc *, int, int, int, int));
709 void rh_clear __P((struct ite_softc *, int, int, int, int));
710 void rh_scroll __P((struct ite_softc *, int, int, int, int));
711
712 #endif /* _GRF_RHREG_H */
713