PageRenderTime 26ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/src/netbsd/src/sys/dev/qbus/qduser.h

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