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