+ u_int inuse; /* which minor dev's are in use now */
+ u_int config; /* I/O page register content */
+ u_int mapped; /* user mapping status word */
+ u_int kernel_loop; /* if kernel console is redirected */
+ u_int user_dma; /* DMA from user space in progress */
+ u_short pntr_id; /* type code of pointing device */
+ u_short duart_imask; /* shadowing for duart intrpt mask reg */
+ u_short adder_ie; /* shadowing for adder intrpt enbl reg */
+ u_short curs_acc; /* cursor acceleration factor */
+ u_short curs_thr; /* cursor acceleration threshold level */
+ u_short tab_res; /* tablet resolution factor */
+ u_short selmask; /* mask for active qd select entries */
+};
+
+/* bit definitions for "inuse" entry */
+
+#define CONS_DEV 0x01
+#define ALTCONS_DEV 0x02
+#define GRAPHIC_DEV 0x04
+
+/* bit definitions for 'mapped' member of flag structure */
+
+#define MAPDEV 0x01 /* hardware is mapped */
+#define MAPDMA 0x02 /* DMA buffer mapped */
+#define MAPEQ 0x04 /* event queue buffer mapped */
+#define MAPSCR 0x08 /* scroll param area mapped */
+#define MAPCOLOR 0x10 /* color map writing buffer mapped */
+
+/* bit definitions for 'selmask' member of qdflag structure */
+
+#define SEL_READ 0x01 /* read select is active */
+#define SEL_WRITE 0x02 /* write select is active */
+
+/*
+* constants used in shared memory operations
+*/
+
+#define EVENT_BUFSIZE 1024 /* # of bytes per device's event buffer */
+
+#define MAXEVENTS ( (EVENT_BUFSIZE - sizeof(struct qdinput)) \
+ / sizeof(struct _vs_event) )
+
+#define DMA_BUFSIZ (1024 * 3)
+
+#define COLOR_BUFSIZ ((sizeof(struct color_buf) + 512) & ~0x01FF)
+
+
+
+/*
+* reference to an array of "uba_device" structures built by the auto
+* configuration program. The uba_device structure decribes the device
+* sufficiently for the driver to talk to it. The auto configuration code
+* fills in the uba_device structures (located in ioconf.c) from user
+* maintained info.
+*/
+
+struct uba_device *qdinfo[NQD]; /* array of pntrs to each QDSS's */
+ /* uba structures */
+struct tty qd_tty[NQD*4]; /* teletype structures for each.. */
+ /* ..possible minor device */
+
+struct qd_softc qd_softc[NQD];
+
+/*
+* static storage used by multiple functions in this code
+*/
+
+int Qbus_unmap[NQD]; /* Qbus mapper release code */
+struct qdflags qdflags[NQD]; /* QDSS device status flags */
+struct qdmap qdmap[NQD]; /* QDSS register map structure */
+caddr_t qdbase[NQD]; /* base address of each QDSS unit */
+struct buf qdbuf[NQD]; /* buf structs used by strategy */
+char one_only[NQD]; /* lock for single process access */
+
+/*
+* The array "event_shared[]" is made up of a number of event queue buffers
+* equal to the number of QDSS's configured into the running kernel (NQD).
+* Each event queue buffer begins with an event queue header (struct qdinput)
+* followed by a group of event queue entries (struct _vs_event). The array
+* "*eq_header[]" is an array of pointers to the start of each event queue
+* buffer in "event_shared[]".
+*/
+
+#define EQSIZE ((EVENT_BUFSIZE * NQD) + 512)
+
+char event_shared[EQSIZE]; /* reserve space for event bufs */
+struct qdinput *eq_header[NQD]; /* event queue header pntrs */
+
+/*
+* This allocation method reserves enough memory pages for NQD shared DMA I/O
+* buffers. Each buffer must consume an integral number of memory pages to
+* guarantee that a following buffer will begin on a page boundary. Also,
+* enough space is allocated so that the FIRST I/O buffer can start at the
+* 1st page boundary after "&DMA_shared". Page boundaries are used so that
+* memory protections can be turned on/off for individual buffers.
+*/
+
+#define IOBUFSIZE ((DMA_BUFSIZ * NQD) + 512)
+
+char DMA_shared[IOBUFSIZE]; /* reserve I/O buffer space */
+struct DMAreq_header *DMAheader[NQD]; /* DMA buffer header pntrs */
+
+/*
+* The driver assists a client in scroll operations by loading dragon
+* registers from an interrupt service routine. The loading is done using
+* parameters found in memory shrade between the driver and it's client.
+* The scroll parameter structures are ALL loacted in the same memory page
+* for reasons of memory economy.
+*/
+
+char scroll_shared[2 * 512]; /* reserve space for scroll structs */
+struct scroll *scroll[NQD]; /* pointers to scroll structures */
+
+/*
+* the driver is programmable to provide the user with color map write
+* services at VSYNC interrupt time. At interrupt time the driver loads
+* the color map with any user-requested load data found in shared memory
+*/
+
+#define COLOR_SHARED ((COLOR_BUFSIZ * NQD) + 512)
+
+char color_shared[COLOR_SHARED]; /* reserve space: color bufs */
+struct color_buf *color_buf[NQD]; /* pointers to color bufs */
+
+/*
+* mouse input event structures
+*/
+
+struct mouse_report last_rep[NQD];
+struct mouse_report current_rep[NQD];
+
+/*
+* input event "select" use
+*/
+
+struct proc *rsel[NQD]; /* process waiting for select */
+
+/*
+* console cursor structure
+*/
+
+struct _vs_cursor cursor[NQD];
+
+
+
+int nNQD = NQD;
+
+int DMAbuf_size = DMA_BUFSIZ;
+
+
+/*
+ * macro to get system time. Used to time stamp event queue entries
+ */