xref: /original-bsd/sys/vax/uba/qd_data.c (revision 1c14281d)
1 /*
2  *	@(#)qd_data.c	1.16	(ULTRIX)	7/2/86
3  */
4 
5 /************************************************************************
6  *									*
7  *			Copyright (c) 1985, 1986 by			*
8  *		Digital Equipment Corporation, Maynard, MA		*
9  *			All rights reserved.				*
10  *									*
11  *   This software is furnished under a license and may be used and	*
12  *   copied  only  in accordance with the terms of such license and	*
13  *   with the  inclusion  of  the  above  copyright  notice.   This	*
14  *   software  or  any	other copies thereof may not be provided or	*
15  *   otherwise made available to any other person.  No title to and	*
16  *   ownership of the software is hereby transferred.			*
17  *									*
18  *   The information in this software is subject to change  without	*
19  *   notice  and should not be construed as a commitment by Digital	*
20  *   Equipment Corporation.						*
21  *									*
22  *   Digital assumes no responsibility for the use  or	reliability	*
23  *   of its software on equipment which is not supplied by Digital.	*
24  *									*
25  ************************************************************************/
26 
27 /*
28  * qd_data.c
29  *
30  * Modification history
31  *
32  * QDSS data file
33  *
34  *  3-Jul-85 - longo
35  *
36  *	Created file.
37  *
38  * 15-Jul-85 - longo
39  *
40  *	Added "qdfont.h" include and moved "mouse_report" struct
41  *	and definitions in from "qduser.h".
42  *
43  * 18-Aug-85 - longo
44  *
45  *	Added "duart_imask" entry to qdflags for shadowing.
46  *
47  *  4-Sep-85 - longo
48  *
49  *	Added storage "QBAreg[]" for DMA support.
50  *
51  * 11-Sep-85 - longo
52  *
53  *	Added constant for event buffer size (now 1k).
54  *
55  * 17-Sep-85 - longo
56  *
57  *	Changes for DMA support.
58  *
59  * 18-Sep-85 - longo
60  *
61  *	Changes for scroll interrupt support.
62  *
63  *  2-Oct-85 - longo
64  *
65  *	Added color map write buffer shared RAM stuff and adder
66  *	interrupt enable register shadowing to qdflags.
67  *
68  *  4-Oct-85 - longo
69  *
70  *	Added kernel loop back state flag to qdflags.
71  *
72  * 16-Oct-85 - longo
73  *
74  *	Added "pntr_id" entry to qdflags struct.
75  *
76  * 22-Oct-85 - longo
77  *
78  *	Added buf structures for use by driver strategy routines.
79  *
80  * 23-Oct-85 - longo
81  *
82  *	Added "user_dma" entry to qdflag structure.
83  *
84  *  8-Nov-85 - longo
85  *
86  *	Added "selmask" entry to qdflags structure.
87  *
88  * 11-Nov-85 - longo
89  *
90  *	Changed "_vs_eventqueue" struct references to "qdinput".
91  *
92  * 25-Nov-85 - longo
93  *
94  *	Added "one_only" lock switch for single process access.
95  *
96  * 18-Mar-86 - jaw
97  *
98  *	Add routines to cpu switch for nexus/unibus addreses.
99  *	Also got rid of some globals like nexnum.
100  *	ka8800 cleanup.
101  *
102  * 19-Mar-86 - ricky palmer
103  *
104  *	Added "devio.h" to include list. V2.0
105  *
106  * 02-Jul-86 -  Brian Stevens
107  *
108  *	Added cursor structure for each display
109  *
110  */
111 
112 #include "qd.h" 	/* # of QDSS's the system is configured for */
113 
114 #include "../include/pte.h"	/* page table values */
115 #include "../include/mtpr.h"	/* VAX register access stuff */
116 
117 #include "sys/param.h" 		/* general system params & macros */
118 #include "sys/conf.h"		/* "linesw" tty driver dispatch */
119 #include "sys/user.h"		/* user structure (what else?) */
120 #include "qdioctl.h" 		/* ioctl call values */
121 #include "sys/tty.h"
122 #include "sys/map.h"		/* resource allocation map struct */
123 #include "sys/buf.h"		/* buf structs */
124 #include "sys/vm.h"		/* includes 'vm' header files */
125 #include "sys/clist.h" 		/* char list handling structs */
126 #include "sys/file.h"		/* file I/O definitions */
127 #include "sys/uio.h"		/* write/read call structs */
128 #include "sys/kernel.h"		/* clock handling structs */
129 #include "../include/cpu.h" 	/* per cpu (pcpu) struct */
130 
131 #include "../uba/ubareg.h"	/* uba & 'qba' register structs */
132 #include "../uba/ubavar.h"	/* uba structs & uba map externs */
133 
134 #include "qduser.h"	/* definitions shared with my client */
135 #include "qdreg.h"	/* QDSS device register structures */
136 
137 /*-----------------------------------------------------------
138 * QDSS driver status flags for tracking operational state */
139 
140 	struct qdflags {
141 
142 	    u_int inuse;	    /* which minor dev's are in use now */
143 	    u_int config;	    /* I/O page register content */
144 	    u_int mapped;	    /* user mapping status word */
145 	    u_int kernel_loop;	    /* if kernel console is redirected */
146 	    u_int user_dma;	    /* DMA from user space in progress */
147 	    u_short pntr_id;	    /* type code of pointing device */
148 	    u_short duart_imask;    /* shadowing for duart intrpt mask reg */
149 	    u_short adder_ie;	    /* shadowing for adder intrpt enbl reg */
150 	    u_short curs_acc;	    /* cursor acceleration factor */
151 	    u_short curs_thr;	    /* cursor acceleration threshold level */
152 	    u_short tab_res;	    /* tablet resolution factor */
153 	    u_short selmask;	    /* mask for active qd select entries */
154 	};
155 
156 	/* bit definitions for "inuse" entry  */
157 
158 #define CONS_DEV	0x01
159 #define ALTCONS_DEV	0x02
160 #define GRAPHIC_DEV	0x04
161 
162 	/* bit definitions for 'mapped' member of flag structure */
163 
164 #define MAPDEV		0x01		/* hardware is mapped */
165 #define MAPDMA		0x02		/* DMA buffer mapped */
166 #define MAPEQ		0x04		/* event queue buffer mapped */
167 #define MAPSCR		0x08		/* scroll param area mapped */
168 #define MAPCOLOR	0x10		/* color map writing buffer mapped */
169 
170 	/* bit definitions for 'selmask' member of qdflag structure */
171 
172 #define SEL_READ	0x01		/* read select is active */
173 #define SEL_WRITE	0x02		/* write select is active */
174 
175 /*----------------------------------------------
176 * constants used in shared memory operations */
177 
178 #define EVENT_BUFSIZE  1024	/* # of bytes per device's event buffer */
179 
180 #define MAXEVENTS  ( (EVENT_BUFSIZE - sizeof(struct qdinput))	 \
181 		     / sizeof(struct _vs_event) )
182 
183 #define DMA_BUFSIZ	(1024 * 3)
184 
185 #define COLOR_BUFSIZ  ((sizeof(struct color_buf) + 512) & ~0x01FF)
186 
187 /*******************************************************************/
188 
189 #ifdef BINARY
190 
191 	extern struct uba_device *qdinfo[];  /* array of pntrs to each QDSS */
192 					     /* uba structure  */
193 	extern struct tty qd_tty[];
194 
195 	extern struct qd_softc qd_softc[];
196 
197 /*----------------------------------------------------------
198 * static storage used by multiple functions in this code  */
199 
200 	extern int Qbus_unmap[];	  /* Qbus mapper release key */
201 	extern struct qdflags qdflags[];  /* QDSS device status flags */
202 	extern struct qdmap qdmap[];	  /* QDSS register map structure */
203 	extern caddr_t qdbase[];	  /* base address of each QDSS unit */
204 	extern struct buf qdbuf[];	  /* buf structs used by strategy */
205 	extern char one_only[]; 	  /* lock for single process access */
206 
207 /*-----------------------------
208 * shared memory allocation  */
209 
210 	extern char event_shared[];		 /* reserve event buf space */
211 	extern struct qdinput *eq_header[];	 /* event buf header ptrs */
212 
213 	extern char DMA_shared[];		  /* reserve DMA buf space */
214 	extern struct DMAreq_header *DMAheader[]; /* DMA buf header ptrs */
215 
216 	extern char scroll_shared[];	/* reserve space for scroll structs */
217 	extern struct scroll *scroll[]; /* pointers to scroll structures */
218 
219 	extern char color_shared[];	      /* reserve space: color bufs */
220 	extern struct color_buf *color_buf[]; /* pointers to color bufs */
221 
222 /*--------------------------------
223 * mouse input event structures */
224 
225 	extern struct mouse_report last_rep[];
226 	extern struct mouse_report current_rep[];
227 
228 /*----------------------------
229 * input event "select" use */
230 
231 	extern struct proc *rsel[];	/* process waiting for select */
232 
233 	extern int DMAbuf_size;
234 
235 /*----------------------------
236 * console cursor structure */
237 
238 	struct _vs_cursor cursor[];
239 
240 
241 /*********************************************************************/
242 
243 #else
244 
245 /*--------------------------------------------------------------------------
246 * reference to an array of "uba_device" structures built by the auto
247 * configuration program.  The uba_device structure decribes the device
248 * sufficiently for the driver to talk to it.  The auto configuration code
249 * fills in the uba_device structures (located in ioconf.c) from user
250 * maintained info.  */
251 
252 	struct uba_device *qdinfo[NQD];  /* array of pntrs to each QDSS's */
253 					 /* uba structures  */
254 	struct tty qd_tty[NQD*4];	/* teletype structures for each.. */
255 					/* ..possible minor device */
256 
257 	struct qd_softc qd_softc[NQD];
258 
259 /*----------------------------------------------------------
260 * static storage used by multiple functions in this code  */
261 
262 	int Qbus_unmap[NQD];		/* Qbus mapper release code */
263 	struct qdflags qdflags[NQD];	/* QDSS device status flags */
264 	struct qdmap qdmap[NQD];	/* QDSS register map structure */
265 	caddr_t qdbase[NQD];		/* base address of each QDSS unit */
266 	struct buf qdbuf[NQD];		/* buf structs used by strategy */
267 	char one_only[NQD];		/* lock for single process access */
268 
269 /*------------------------------------------------------------------------
270 * the array "event_shared[]" is made up of a number of event queue buffers
271 * equal to the number of QDSS's configured into the running kernel (NQD).
272 * Each event queue buffer begins with an event queue header (struct qdinput)
273 * followed by a group of event queue entries (struct _vs_event).  The array
274 * "*eq_header[]" is an array of pointers to the start of each event queue
275 * buffer in "event_shared[]".  */
276 
277 #define EQSIZE ((EVENT_BUFSIZE * NQD) + 512)
278 
279 	char event_shared[EQSIZE];	    /* reserve space for event bufs */
280 	struct qdinput *eq_header[NQD];     /* event queue header pntrs */
281 
282 /*--------------------------------------------------------------------------
283 * This allocation method reserves enough memory pages for NQD shared DMA I/O
284 * buffers.  Each buffer must consume an integral number of memory pages to
285 * guarantee that a following buffer will begin on a page boundary.  Also,
286 * enough space is allocated so that the FIRST I/O buffer can start at the
287 * 1st page boundary after "&DMA_shared".  Page boundaries are used so that
288 * memory protections can be turned on/off for individual buffers. */
289 
290 #define IOBUFSIZE  ((DMA_BUFSIZ * NQD) + 512)
291 
292 	char DMA_shared[IOBUFSIZE];	    /* reserve I/O buffer space */
293 	struct DMAreq_header *DMAheader[NQD];  /* DMA buffer header pntrs */
294 
295 /*-------------------------------------------------------------------------
296 * The driver assists a client in scroll operations by loading dragon
297 * registers from an interrupt service routine.	The loading is done using
298 * parameters found in memory shrade between the driver and it's client.
299 * The scroll parameter structures are ALL loacted in the same memory page
300 * for reasons of memory economy.  */
301 
302 	char scroll_shared[2 * 512];	/* reserve space for scroll structs */
303 	struct scroll *scroll[NQD];	/* pointers to scroll structures */
304 
305 /*-----------------------------------------------------------------------
306 * the driver is programmable to provide the user with color map write
307 * services at VSYNC interrupt time.  At interrupt time the driver loads
308 * the color map with any user-requested load data found in shared memory */
309 
310 #define COLOR_SHARED  ((COLOR_BUFSIZ * NQD) + 512)
311 
312 	char color_shared[COLOR_SHARED];      /* reserve space: color bufs */
313 	struct color_buf *color_buf[NQD];     /* pointers to color bufs */
314 
315 /*--------------------------------
316 * mouse input event structures */
317 
318 	struct mouse_report last_rep[NQD];
319 	struct mouse_report current_rep[NQD];
320 
321 /*----------------------------
322 * input event "select" use */
323 
324 	struct proc *rsel[NQD]; 	/* process waiting for select */
325 
326 /*----------------------------
327 * console cursor structure */
328 
329 	struct _vs_cursor cursor[NQD];
330 
331 
332 /************************************************************************/
333 
334 	int nNQD = NQD;
335 
336 	int DMAbuf_size = DMA_BUFSIZ;
337 
338 #endif
339 
340 
341