Annotation of sys/arch/vax/qbus/qduser.h, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: qduser.h,v 1.4 2006/01/17 20:26:16 miod Exp $ */
! 2: /* $NetBSD: qduser.h,v 1.1 1998/03/21 10:02:39 ragge Exp $ */
! 3: /*-
! 4: * Copyright (c) 1982, 1986 The Regents of the University of California.
! 5: * All rights reserved.
! 6: *
! 7: * Redistribution and use in source and binary forms, with or without
! 8: * modification, are permitted provided that the following conditions
! 9: * are met:
! 10: * 1. Redistributions of source code must retain the above copyright
! 11: * notice, this list of conditions and the following disclaimer.
! 12: * 2. Redistributions in binary form must reproduce the above copyright
! 13: * notice, this list of conditions and the following disclaimer in the
! 14: * documentation and/or other materials provided with the distribution.
! 15: * 3. Neither the name of the University nor the names of its contributors
! 16: * may be used to endorse or promote products derived from this software
! 17: * without specific prior written permission.
! 18: *
! 19: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 20: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 21: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 22: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 23: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 24: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 25: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 26: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 27: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 28: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 29: * SUCH DAMAGE.
! 30: *
! 31: * @(#)qduser.h 7.1 (Berkeley) 5/9/91
! 32: */
! 33:
! 34: /* derived from: @(#)qduser.h 6.1 (ULTRIX) 11/24/87 */
! 35: /************************************************************************
! 36: * *
! 37: * Copyright (c) 1986 by *
! 38: * Digital Equipment Corporation, Maynard, MA *
! 39: * All rights reserved. *
! 40: * *
! 41: * This software is furnished under a license and may be used and *
! 42: * copied only in accordance with the terms of such license and *
! 43: * with the inclusion of the above copyright notice. This *
! 44: * software or any other copies thereof may not be provided or *
! 45: * otherwise made available to any other person. No title to and *
! 46: * ownership of the software is hereby transferred. *
! 47: * *
! 48: * The information in this software is subject to change without *
! 49: * notice and should not be construed as a commitment by Digital *
! 50: * Equipment Corporation. *
! 51: * *
! 52: * Digital assumes no responsibility for the use or reliability *
! 53: * of its software on equipment which is not supplied by Digital. *
! 54: * *
! 55: ************************************************************************/
! 56:
! 57: /***************************************************************************
! 58: *
! 59: * QDUSER...
! 60: * This file defines values shared between the driver and a client
! 61: *
! 62: ***************************************************************************/
! 63:
! 64: /***************************************************************************
! 65: * revision history:
! 66: ****************************************************************************
! 67: *
! 68: * 21 jul 86 ram fixed define of CURSOR_MIN_Y
! 69: * 25 nov 85 longo added macro and bit defines for DMA error flags
! 70: * 11 nov 85 longo renamed _vs_eventqueue to "qdinput" struct
! 71: * 23 oct 85 longo added more defines to the DMA stuff
! 72: * 17 oct 85 longo changed "struct rgb" chars to be unsigned
! 73: * 16 oct 85 longo added new TABLET support definitions
! 74: * 15 oct 85 longo re-wrote DMA queue access macros
! 75: * 08 oct 85 longo added status flag manipulation macros to DMA stuff
! 76: * 02 oct 85 longo added support for color map write buffer loading
! 77: * 26 sep 85 longo removed adder sertup params from DMA request struct
! 78: * 23 sep 85 longo added DMA queue access macros
! 79: * 30 aug 85 longo fixed crock in "qdiobuf" struct compile-time sizing. Also
! 80: * removed DMAcontrol struct from DMA buffer for field test
! 81: * 26 aug 85 longo put in conditional include of "qevent.h" for user prg's
! 82: * 18 jul 85 longo changed semantics so that head is tail and tail is head
! 83: * 12 jul 85 longo moved "mouse_report" struct and defs over to qd_data.c
! 84: * 11 jul 85 longo added device coordinate to gate array cursor coordinate
! 85: * transformation macros
! 86: * 03 jul 85 longo changed kernel typdef's for data types to long-hand
! 87: * 10 may 85 longo created
! 88: *
! 89: ***************************************************************************/
! 90:
! 91: #include <vax/uba/qevent.h>
! 92:
! 93: /*---------------------
! 94: * QDSS device map */
! 95:
! 96: struct qdmap { /* map of register blocks in QDSS */
! 97:
! 98: char *template;
! 99: char *adder;
! 100: char *dga;
! 101: char *duart;
! 102: char *memcsr;
! 103: char *red;
! 104: char *blue;
! 105: char *green;
! 106: };
! 107:
! 108: /*--------------------------------------------
! 109: * DGA CSR bit definitions and register map */
! 110:
! 111: #define DMADONE 0x8000 /* DMA done status */
! 112: #define SET_DONE_FIFO 0x4000 /* set DMADONE when FIFO empty.. */
! 113: /* ..AND count = 0 */
! 114:
! 115: #define PTOB_ENB 0x0600 /* host-to-bitmap DMA xfer */
! 116: #define BTOP_ENB 0x0400 /* bitmap-to-host DMA xfer */
! 117: #define DL_ENB 0x0200 /* display list DMA xfer */
! 118: #define HALT 0x0000 /* halt DGA */
! 119:
! 120: #define BYTE_DMA 0x0100 /* byte/word DMA xfer */
! 121:
! 122: #define DMA_ERR 0x0080 /* DMA error bits */
! 123: #define PARITY_ERR 0x0040 /* memory parity error in DMA */
! 124: #define BUS_ERR 0x0020 /* bus timeout error in DMA */
! 125:
! 126: #define GLOBAL_IE 0x0004 /* global interrupt enable */
! 127: #define DMA_IE 0x0002 /* DMA interrupt enable */
! 128: #define CURS_ENB 0x0001 /* cursor enable */
! 129:
! 130: /* QDSS memcsr bit definitions */
! 131:
! 132: #define UNBLANK 0x0020
! 133: #define SYNC_ON 0x0008
! 134:
! 135: struct dga {
! 136:
! 137: unsigned short csr;
! 138: unsigned short adrs_lo; /* destination address of bitmap to */
! 139: unsigned short adrs_hi; /* host DMA */
! 140: unsigned short bytcnt_lo; /* byte length of requested DMA */
! 141: unsigned short bytcnt_hi; /* (WO = bytcnt) (RO = fifo count) */
! 142: unsigned short fifo; /* FIFO register */
! 143: unsigned short x_cursor; /* cursor position registers */
! 144: unsigned short y_cursor;
! 145: unsigned short ivr; /* interrupt vector register */
! 146: unsigned short memadr; /* memory base address register */
! 147: };
! 148:
! 149: /*-------------------------------------------------------------------------
! 150: * macros to transform device coordinates to hardware cursor coordinates */
! 151:
! 152: #define CURS_MIN_X 232 /* device coordinate x = 0 */
! 153: #define CURS_MIN_Y 16 /* device coordinate y = 0 */
! 154:
! 155: #define TRANX(x) ( -(((int)(x)+CURS_MIN_X) & ~0x0003) | \
! 156: (((int)(x)+CURS_MIN_X) & 0x0003) )
! 157:
! 158: #define TRANY(y) ( -((y)+CURS_MIN_Y) )
! 159:
! 160: /*********************************************************************
! 161: *
! 162: * EVENT QUEUE DEFINITIONS
! 163: *
! 164: **********************************************************************
! 165: * most of the event queue definitions are found in "qevent.h". But a
! 166: * few things not found there are here. */
! 167:
! 168: /* The event queue header */
! 169:
! 170: struct qdinput {
! 171:
! 172: struct _vs_eventqueue header; /* event queue ring handling */
! 173:
! 174: /* for VS100 and QVSS compatibility reasons, additions to this
! 175: * structure must be made below this point. */
! 176:
! 177: struct _vs_cursor curs_pos; /* current mouse position */
! 178: struct _vs_box curs_box; /* cursor reporting box */
! 179:
! 180: };
! 181:
! 182: /* vse_key field. definitions for mouse buttons */
! 183:
! 184: #define VSE_LEFT_BUTTON 0
! 185: #define VSE_MIDDLE_BUTTON 1
! 186: #define VSE_RIGHT_BUTTON 2
! 187:
! 188: /* vse_key field. definitions for mouse buttons */
! 189:
! 190: #define VSE_T_LEFT_BUTTON 0
! 191: #define VSE_T_FRONT_BUTTON 1
! 192: #define VSE_T_RIGHT_BUTTON 2
! 193: #define VSE_T_BACK_BUTTON 4
! 194:
! 195: #define VSE_T_BARREL_BUTTON VSE_T_LEFT_BUTTON
! 196: #define VSE_T_TIP_BUTTON VSE_T_FRONT_BUTTON
! 197:
! 198: /*--------------------------------------------------------------------------
! 199: * These are the macros to be used for loading and extracting from the event
! 200: * queue. It is presumed that the macro user will only use the access macros
! 201: * if the event queue is non-empty ( ISEMPTY(eq) == FALSE ), and that the
! 202: * driver will only load the event queue after checking that it is not full
! 203: * ( ISFULL(eq) == FALSE ). ("eq" is a pointer to the event queue header.)
! 204: *
! 205: * Before an event access session for a particular event, the macro users
! 206: * must use the xxxBEGIN macro, and the xxxEND macro after an event is through
! 207: * with. As seen below, the xxxBEGIN and xxxEND macros maintain the event
! 208: * queue access mechanism.
! 209: *
! 210: * First, the macros to be used by the event queue reader
! 211: */
! 212:
! 213: #define ISEMPTY(eq) ((eq)->header.head == (eq)->header.tail)
! 214: #define GETBEGIN(eq) (&(eq)->header.events[(eq)->header.head])
! 215:
! 216: #define GET_X(event) ((event)->vse_x) /* get x position */
! 217: #define GET_Y(event) ((event)->vse_y) /* get y position */
! 218: #define GET_TIME(event) ((event)->vse_time) /* get time */
! 219: #define GET_TYPE(event) ((event)->vse_type) /* get entry type */
! 220: #define GET_KEY(event) ((event)->vse_key) /* get keycode */
! 221: #define GET_DIR(event) ((event)->vse_direction) /* get direction */
! 222: #define GET_DEVICE(event) ((event)->vse_device) /* get device */
! 223:
! 224: #define GETEND(eq) (++(eq)->header.head >= (eq)->header.size ? \
! 225: (eq)->header.head = 0 : 0 )
! 226:
! 227: /*------------------------------------------------
! 228: * macros to be used by the event queue loader */
! 229:
! 230: /* ISFULL yields TRUE if queue is full */
! 231:
! 232: #define ISFULL(eq) ((eq)->header.tail+1 == (eq)->header.head || \
! 233: ((eq)->header.tail+1 == (eq)->header.size && \
! 234: (eq)->header.head == 0))
! 235:
! 236: /* get address of the billet for NEXT event */
! 237:
! 238: #define PUTBEGIN(eq) (&(eq)->header.events[(eq)->header.tail])
! 239:
! 240: #define PUT_X(event, value) ((event)->vse_x = value) /* put X pos */
! 241: #define PUT_Y(event, value) ((event)->vse_y = value) /* put Y pos */
! 242: #define PUT_TIME(event, value) ((event)->vse_time = value) /* put time */
! 243: #define PUT_TYPE(event, value) ((event)->vse_type = value) /* put type */
! 244: #define PUT_KEY(event, value) ((event)->vse_key = value) /* put input key */
! 245: #define PUT_DIR(event, value) ((event)->vse_direction = value) /* put dir */
! 246: #define PUT_DEVICE(event, value) ((event)->vse_device = value) /* put dev */
! 247:
! 248: #define PUTEND(eq) (++(eq)->header.tail >= (eq)->header.size ? \
! 249: (eq)->header.tail = 0 : 0)
! 250:
! 251: /******************************************************************
! 252: *
! 253: * DMA I/O DEFINITIONS
! 254: *
! 255: ******************************************************************/
! 256:
! 257: /*---------------------------------------------------------------------
! 258: * The DMA request queue is implemented as a ring buffer of "DMAreq"
! 259: structures. The queue is accessed using ring indices located in the
! 260: "DMAreq_header" structure. Access is implemented using access macros
! 261: similar to the event queue access macros above. */
! 262:
! 263: struct DMAreq {
! 264:
! 265: short DMAtype; /* DMA type code (for QDSS) */
! 266: short DMAdone; /* DMA done parameter */
! 267: char *bufp; /* virtual adrs of buffer */
! 268: int length; /* transfer buffer length */
! 269: };
! 270:
! 271: /* DMA type command codes */
! 272:
! 273: #define DISPLIST 1 /* display list DMA */
! 274: #define PTOB 2 /* 1 plane Qbus to bitmap DMA */
! 275: #define BTOP 3 /* 1 plane bitmap to Qbus DMA */
! 276:
! 277: /* DMA done notification code */
! 278:
! 279: #define FIFO_EMPTY 0x01 /* DONE when FIFO becomes empty */
! 280: #define COUNT_ZERO 0x02 /* DONE when count becomes zero */
! 281: #define WORD_PACK 0x04 /* program the gate array for word packing */
! 282: #define BYTE_PACK 0x08 /* program gate array for byte packing */
! 283: #define REQUEST_DONE 0x100 /* clear when driver has processed request */
! 284: #define HARD_ERROR 0x200 /* DMA hardware error occurred */
! 285:
! 286: /* DMA request queue is a ring buffer of request structures */
! 287:
! 288: struct DMAreq_header {
! 289:
! 290: int QBAreg; /* cookie Qbus map reg for this buffer */
! 291: short status; /* master DMA status word */
! 292: int shared_size; /* size of shared memory in bytes */
! 293: struct DMAreq *DMAreq; /* start address of request queue */
! 294: int used; /* # of queue entries currently used */
! 295: int size; /* # of "DMAreq"'s in the request queue */
! 296: int oldest; /* index to oldest queue'd request */
! 297: int newest; /* index to newest queue'd request */
! 298: };
! 299:
! 300: /* bit definitions for DMAstatus word in DMAreq_header */
! 301:
! 302: #define DMA_ACTIVE 0x0004 /* DMA in progress */
! 303: #define DMA_ERROR 0x0080 /* DMA hardware error */
! 304: #define DMA_IGNORE 0x0002 /* flag to ignore this interrupt */
! 305:
! 306: /*------------------------------------------
! 307: * macros for DMA request queue fiddling */
! 308:
! 309: /* DMA status set/check macros */
! 310:
! 311: #define DMA_SETACTIVE(header) ((header)->status |= DMA_ACTIVE)
! 312: #define DMA_CLRACTIVE(header) ((header)->status &= ~DMA_ACTIVE)
! 313: #define DMA_ISACTIVE(header) ((header)->status & DMA_ACTIVE)
! 314:
! 315: #define DMA_SETERROR(header) ((header)->status |= DMA_ERROR)
! 316: #define DMA_CLRERROR(header) ((header)->status &= ~DMA_ERROR)
! 317: #define DMA_ISERROR(header) ((header)->status & DMA_ERROR)
! 318:
! 319: #define DMA_SETIGNORE(header) ((header)->status |= DMA_IGNORE)
! 320: #define DMA_CLRIGNORE(header) ((header)->status &= ~DMA_IGNORE)
! 321: #define DMA_ISIGNORE(header) ((header)->status & DMA_IGNORE)
! 322:
! 323: /* yields TRUE if queue is empty (ISEMPTY) or full (ISFULL) */
! 324:
! 325: #define DMA_ISEMPTY(header) ((header)->used == 0)
! 326: #define DMA_ISFULL(header) ((header)->used >= (header)->size)
! 327:
! 328: /* returns address of the billet for next (PUT)
! 329: * or oldest (GET) request */
! 330:
! 331: #define DMA_PUTBEGIN(header) (&(header)->DMAreq[(header)->newest])
! 332: #define DMA_GETBEGIN(header) (&(header)->DMAreq[(header)->oldest])
! 333:
! 334: /* does queue access pointer maintenance */
! 335:
! 336: #define DMA_GETEND(header) (++(header)->oldest >= (header)->size \
! 337: ? (header)->oldest = 0 : 0); \
! 338: --(header)->used;
! 339:
! 340: #define DMA_PUTEND(header) (++(header)->newest >= (header)->size \
! 341: ? (header)->newest = 0 : 0); \
! 342: ++(header)->used;
! 343:
! 344: /******************************************************************
! 345: *
! 346: * COLOR MAP WRITE BUFFER DEFINITIONS
! 347: *
! 348: ******************************************************************/
! 349:
! 350: struct rgb {
! 351:
! 352: unsigned char offset; /* color map address for load */
! 353: unsigned char red; /* data for red map */
! 354: unsigned char green; /* data for green map */
! 355: unsigned char blue; /* data for blue map */
! 356: };
! 357:
! 358: struct color_buf {
! 359:
! 360: char status; /* load request/service status */
! 361: short count; /* number of entries to br loaded */
! 362: struct rgb rgb[256];
! 363: };
! 364:
! 365: #define LOAD_COLOR_MAP 0x0001
! 366:
! 367: /******************************************************************
! 368: *
! 369: * SCROLL ASSIST DEFINITIONS
! 370: *
! 371: ******************************************************************/
! 372:
! 373: struct scroll {
! 374:
! 375: short status;
! 376: short viper_constant;
! 377: short y_scroll_constant;
! 378: short y_offset;
! 379: short x_index_pending;
! 380: short y_index_pending;
! 381: };
! 382:
! 383: #define LOAD_REGS 0x0001
! 384: #define LOAD_INDEX 0x0002
! 385:
! 386: /******************************************************************
! 387: *
! 388: * MOUSE/TABLET/KBD PROGRAMMING DEFINITIONS
! 389: *
! 390: ******************************************************************/
! 391:
! 392: /*-----------------------------------
! 393: * LK201 programmming definitions */
! 394:
! 395: #define LK_UPDOWN 0x86 /* bits for setting lk201 modes */
! 396: #define LK_AUTODOWN 0x82
! 397: #define LK_DOWN 0x80
! 398: #define LK_DEFAULTS 0xD3 /* reset (some) default settings */
! 399: #define LK_AR_ENABLE 0xE3 /* global auto repeat enable */
! 400: #define LK_CL_ENABLE 0x1B /* keyclick enable */
! 401: #define LK_KBD_ENABLE 0x8B /* keyboard enable */
! 402: #define LK_BELL_ENABLE 0x23 /* the bell */
! 403: #define LK_RING_BELL 0xA7 /* ring keyboard bell */
! 404:
! 405: #define LK_LED_ENABLE 0x13 /* light led */
! 406: #define LK_LED_DISABLE 0x11 /* turn off led */
! 407: #define LED_1 0x81 /* led bits */
! 408: #define LED_2 0x82
! 409: #define LED_3 0x84
! 410: #define LED_4 0x88
! 411: #define LED_ALL 0x8F
! 412: #define LK_LED_HOLD LED_4
! 413: #define LK_LED_LOCK LED_3
! 414: #define LK_LED_COMPOSE LED_2
! 415: #define LK_LED_WAIT LED_1
! 416:
! 417: #define LK_KDOWN_ERROR 0x3D /* key down on powerup error */
! 418: #define LK_POWER_ERROR 0x3E /* keyboard failure on powerup test */
! 419: #define LK_OUTPUT_ERROR 0xB5 /* keystrokes lost during inhibit */
! 420: #define LK_INPUT_ERROR 0xB6 /* garbage command to keyboard */
! 421: #define LK_LOWEST 0x56 /* lowest significant keycode */
! 422: #define LK_DIV6_START 0xAD /* start of div 6 */
! 423: #define LK_DIV5_END 0xB2 /* end of div 5 */
! 424:
! 425: #define LAST_PARAM 0x80 /* "no more params" bit */
! 426:
! 427: struct prgkbd {
! 428:
! 429: short cmd; /* LK201 command opcode */
! 430: short param1; /* 1st cmd parameter (can be null) */
! 431: short param2; /* 2nd cmd parameter (can be null) */
! 432: };
! 433:
! 434: /*-------------------------
! 435: * "special" LK-201 keys */
! 436:
! 437: #define SHIFT 174
! 438: #define LOCK 176
! 439: #define REPEAT 180
! 440: #define CNTRL 175
! 441: #define ALLUP 179
! 442:
! 443: /*--------------------------------
! 444: * cursor programming structure */
! 445:
! 446: struct prg_cursor {
! 447:
! 448: unsigned short acc_factor; /* cursor aceleration factor */
! 449: unsigned short threshold; /* threshold to trigger acc at */
! 450: };
! 451:
! 452: /*---------------------
! 453: * mouse definitions */
! 454:
! 455: #define INC_STREAM_MODE 'R' /* stream mode reports (55 hz) */
! 456: #define PROMPT_MODE 'D' /* report when prompted */
! 457: #define REQUEST_POS 'P' /* request position report */
! 458: #define SELF_TEST 'T' /* request self test */
! 459:
! 460: #define MOUSE_ID 0x2 /* mouse ID in lo 4 bits */
! 461:
! 462: #define START_FRAME 0x80 /* start of report frame bit */
! 463: #define X_SIGN 0x10 /* position sign bits */
! 464: #define Y_SIGN 0x08
! 465:
! 466: #define RIGHT_BUTTON 0x01 /* mouse buttons */
! 467: #define MIDDLE_BUTTON 0x02
! 468: #define LEFT_BUTTON 0x04
! 469:
! 470: /* mouse report structure definition */
! 471:
! 472: struct mouse_report {
! 473:
! 474: char state; /* buttons and sign bits */
! 475: short dx; /* delta X since last change */
! 476: short dy; /* delta Y since last change */
! 477: char bytcnt; /* mouse report byte count */
! 478: };
! 479:
! 480: /*-----------------------------------------
! 481: * tablet command/interface definitions */
! 482:
! 483: #define T_STREAM 'R' /* continuous stream report mode */
! 484: #define T_POINT 'D' /* enter report-on-request mode */
! 485: #define T_REQUEST 'P' /* request position report */
! 486:
! 487: #define T_BAUD 'B' /* increase baud to 9600 from 4800 */
! 488: #define T_RATE_55 'K' /* report rate: 55/sec */
! 489: #define T_RATE_72 'L' /* report rate: 72/sec */
! 490: #define T_RATE_120 'M' /* report rate: 120/sec (9600 only) */
! 491:
! 492: #define T_TEST SELF_TEST /* do self test */
! 493:
! 494: #define TABLET_ID 0x4 /* tablet ID in lo 4 bits */
! 495:
! 496: #define T_START_FRAME 0x80 /* start of report frame bit */
! 497: #define T_PROXIMITY 0x01 /* state pointer in proximity */
! 498:
! 499: #define T_LEFT_BUTTON 0x02 /* puck buttons */
! 500: #define T_FRONT_BUTTON 0x04
! 501: #define T_RIGHT_BUTTON 0x08
! 502: #define T_BACK_BUTTON 0x10
! 503:
! 504: #define T_BARREL_BUTTON T_LEFT_BUTTON /* stylus buttons */
! 505: #define T_TIP_BUTTON T_FRONT_BUTTON
! 506:
CVSweb