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