131807Smarc /* 231807Smarc * @(#)qd_data.c 1.16 (ULTRIX) 7/2/86 331807Smarc */ 431807Smarc 531807Smarc /************************************************************************ 631807Smarc * * 731807Smarc * Copyright (c) 1985, 1986 by * 831807Smarc * Digital Equipment Corporation, Maynard, MA * 931807Smarc * All rights reserved. * 1031807Smarc * * 1131807Smarc * This software is furnished under a license and may be used and * 1231807Smarc * copied only in accordance with the terms of such license and * 1331807Smarc * with the inclusion of the above copyright notice. This * 1431807Smarc * software or any other copies thereof may not be provided or * 1531807Smarc * otherwise made available to any other person. No title to and * 1631807Smarc * ownership of the software is hereby transferred. * 1731807Smarc * * 1831807Smarc * The information in this software is subject to change without * 1931807Smarc * notice and should not be construed as a commitment by Digital * 2031807Smarc * Equipment Corporation. * 2131807Smarc * * 2231807Smarc * Digital assumes no responsibility for the use or reliability * 2331807Smarc * of its software on equipment which is not supplied by Digital. * 2431807Smarc * * 2531807Smarc ************************************************************************/ 2631807Smarc 2731807Smarc /* 2831807Smarc * qd_data.c 2931807Smarc * 3031807Smarc * Modification history 3131807Smarc * 3231807Smarc * QDSS data file 3331807Smarc * 3431807Smarc * 3-Jul-85 - longo 3531807Smarc * 3631807Smarc * Created file. 3731807Smarc * 3831807Smarc * 15-Jul-85 - longo 3931807Smarc * 4031807Smarc * Added "qdfont.h" include and moved "mouse_report" struct 4131807Smarc * and definitions in from "qduser.h". 4231807Smarc * 4331807Smarc * 18-Aug-85 - longo 4431807Smarc * 4531807Smarc * Added "duart_imask" entry to qdflags for shadowing. 4631807Smarc * 4731807Smarc * 4-Sep-85 - longo 4831807Smarc * 4931807Smarc * Added storage "QBAreg[]" for DMA support. 5031807Smarc * 5131807Smarc * 11-Sep-85 - longo 5231807Smarc * 5331807Smarc * Added constant for event buffer size (now 1k). 5431807Smarc * 5531807Smarc * 17-Sep-85 - longo 5631807Smarc * 5731807Smarc * Changes for DMA support. 5831807Smarc * 5931807Smarc * 18-Sep-85 - longo 6031807Smarc * 6131807Smarc * Changes for scroll interrupt support. 6231807Smarc * 6331807Smarc * 2-Oct-85 - longo 6431807Smarc * 6531807Smarc * Added color map write buffer shared RAM stuff and adder 6631807Smarc * interrupt enable register shadowing to qdflags. 6731807Smarc * 6831807Smarc * 4-Oct-85 - longo 6931807Smarc * 7031807Smarc * Added kernel loop back state flag to qdflags. 7131807Smarc * 7231807Smarc * 16-Oct-85 - longo 7331807Smarc * 7431807Smarc * Added "pntr_id" entry to qdflags struct. 7531807Smarc * 7631807Smarc * 22-Oct-85 - longo 7731807Smarc * 7831807Smarc * Added buf structures for use by driver strategy routines. 7931807Smarc * 8031807Smarc * 23-Oct-85 - longo 8131807Smarc * 8231807Smarc * Added "user_dma" entry to qdflag structure. 8331807Smarc * 8431807Smarc * 8-Nov-85 - longo 8531807Smarc * 8631807Smarc * Added "selmask" entry to qdflags structure. 8731807Smarc * 8831807Smarc * 11-Nov-85 - longo 8931807Smarc * 9031807Smarc * Changed "_vs_eventqueue" struct references to "qdinput". 9131807Smarc * 9231807Smarc * 25-Nov-85 - longo 9331807Smarc * 9431807Smarc * Added "one_only" lock switch for single process access. 9531807Smarc * 9631807Smarc * 18-Mar-86 - jaw 9731807Smarc * 9831807Smarc * Add routines to cpu switch for nexus/unibus addreses. 9931807Smarc * Also got rid of some globals like nexnum. 10031807Smarc * ka8800 cleanup. 10131807Smarc * 10231807Smarc * 19-Mar-86 - ricky palmer 10331807Smarc * 10431807Smarc * Added "devio.h" to include list. V2.0 10531807Smarc * 10631807Smarc * 02-Jul-86 - Brian Stevens 10731807Smarc * 10831807Smarc * Added cursor structure for each display 10931807Smarc * 11031807Smarc */ 11131807Smarc 11231807Smarc #include "qd.h" /* # of QDSS's the system is configured for */ 11331807Smarc 114*32014Smarc #include "../vax/pte.h" /* page table values */ 115*32014Smarc #include "../vax/mtpr.h" /* VAX register access stuff */ 11631807Smarc 11731807Smarc #include "../h/param.h" /* general system params & macros */ 11831807Smarc #include "../h/conf.h" /* "linesw" tty driver dispatch */ 11931807Smarc #include "../h/dir.h" /* for directory handling */ 12031807Smarc #include "../h/user.h" /* user structure (what else?) */ 121*32014Smarc #include "qdioctl.h" /* ioctl call values */ 12231807Smarc #include "../h/tty.h" 12331807Smarc #include "../h/map.h" /* resource allocation map struct */ 12431807Smarc #include "../h/buf.h" /* buf structs */ 12531807Smarc #include "../h/vm.h" /* includes 'vm' header files */ 12631807Smarc #include "../h/clist.h" /* char list handling structs */ 12731807Smarc #include "../h/file.h" /* file I/O definitions */ 12831807Smarc #include "../h/uio.h" /* write/read call structs */ 12931807Smarc #include "../h/kernel.h" /* clock handling structs */ 13031807Smarc #include "../vax/cpu.h" /* per cpu (pcpu) struct */ 13131807Smarc 13231807Smarc #include "../vaxuba/ubareg.h" /* uba & 'qba' register structs */ 13331807Smarc #include "../vaxuba/ubavar.h" /* uba structs & uba map externs */ 13431807Smarc 135*32014Smarc #include "qduser.h" /* definitions shared with my client */ 136*32014Smarc #include "qdreg.h" /* QDSS device register structures */ 13731807Smarc 13831807Smarc /*----------------------------------------------------------- 13931807Smarc * QDSS driver status flags for tracking operational state */ 14031807Smarc 14131807Smarc struct qdflags { 14231807Smarc 14331807Smarc u_int inuse; /* which minor dev's are in use now */ 14431807Smarc u_int config; /* I/O page register content */ 14531807Smarc u_int mapped; /* user mapping status word */ 14631807Smarc u_int kernel_loop; /* if kernel console is redirected */ 14731807Smarc u_int user_dma; /* DMA from user space in progress */ 14831807Smarc u_short pntr_id; /* type code of pointing device */ 14931807Smarc u_short duart_imask; /* shadowing for duart intrpt mask reg */ 15031807Smarc u_short adder_ie; /* shadowing for adder intrpt enbl reg */ 15131807Smarc u_short curs_acc; /* cursor acceleration factor */ 15231807Smarc u_short curs_thr; /* cursor acceleration threshold level */ 15331807Smarc u_short tab_res; /* tablet resolution factor */ 15431807Smarc u_short selmask; /* mask for active qd select entries */ 15531807Smarc }; 15631807Smarc 15731807Smarc /* bit definitions for "inuse" entry */ 15831807Smarc 15931807Smarc #define CONS_DEV 0x01 16031807Smarc #define ALTCONS_DEV 0x02 16131807Smarc #define GRAPHIC_DEV 0x04 16231807Smarc 16331807Smarc /* bit definitions for 'mapped' member of flag structure */ 16431807Smarc 16531807Smarc #define MAPDEV 0x01 /* hardware is mapped */ 16631807Smarc #define MAPDMA 0x02 /* DMA buffer mapped */ 16731807Smarc #define MAPEQ 0x04 /* event queue buffer mapped */ 16831807Smarc #define MAPSCR 0x08 /* scroll param area mapped */ 16931807Smarc #define MAPCOLOR 0x10 /* color map writing buffer mapped */ 17031807Smarc 17131807Smarc /* bit definitions for 'selmask' member of qdflag structure */ 17231807Smarc 17331807Smarc #define SEL_READ 0x01 /* read select is active */ 17431807Smarc #define SEL_WRITE 0x02 /* write select is active */ 17531807Smarc 17631807Smarc /*---------------------------------------------- 17731807Smarc * constants used in shared memory operations */ 17831807Smarc 17931807Smarc #define EVENT_BUFSIZE 1024 /* # of bytes per device's event buffer */ 18031807Smarc 18131807Smarc #define MAXEVENTS ( (EVENT_BUFSIZE - sizeof(struct qdinput)) \ 18231807Smarc / sizeof(struct _vs_event) ) 18331807Smarc 18431807Smarc #define DMA_BUFSIZ (1024 * 3) 18531807Smarc 18631807Smarc #define COLOR_BUFSIZ ((sizeof(struct color_buf) + 512) & ~0x01FF) 18731807Smarc 18831807Smarc /*******************************************************************/ 18931807Smarc 19031807Smarc #ifdef BINARY 19131807Smarc 19231807Smarc extern struct uba_device *qdinfo[]; /* array of pntrs to each QDSS */ 19331807Smarc /* uba structure */ 19431807Smarc extern struct tty qd_tty[]; 19531807Smarc 19631807Smarc extern struct qd_softc qd_softc[]; 19731807Smarc 19831807Smarc /*---------------------------------------------------------- 19931807Smarc * static storage used by multiple functions in this code */ 20031807Smarc 20131807Smarc extern int Qbus_unmap[]; /* Qbus mapper release key */ 20231807Smarc extern struct qdflags qdflags[]; /* QDSS device status flags */ 20331807Smarc extern struct qdmap qdmap[]; /* QDSS register map structure */ 20431807Smarc extern caddr_t qdbase[]; /* base address of each QDSS unit */ 20531807Smarc extern struct buf qdbuf[]; /* buf structs used by strategy */ 20631807Smarc extern char one_only[]; /* lock for single process access */ 20731807Smarc 20831807Smarc /*----------------------------- 20931807Smarc * shared memory allocation */ 21031807Smarc 21131807Smarc extern char event_shared[]; /* reserve event buf space */ 21231807Smarc extern struct qdinput *eq_header[]; /* event buf header ptrs */ 21331807Smarc 21431807Smarc extern char DMA_shared[]; /* reserve DMA buf space */ 21531807Smarc extern struct DMAreq_header *DMAheader[]; /* DMA buf header ptrs */ 21631807Smarc 21731807Smarc extern char scroll_shared[]; /* reserve space for scroll structs */ 21831807Smarc extern struct scroll *scroll[]; /* pointers to scroll structures */ 21931807Smarc 22031807Smarc extern char color_shared[]; /* reserve space: color bufs */ 22131807Smarc extern struct color_buf *color_buf[]; /* pointers to color bufs */ 22231807Smarc 22331807Smarc /*-------------------------------- 22431807Smarc * mouse input event structures */ 22531807Smarc 22631807Smarc extern struct mouse_report last_rep[]; 22731807Smarc extern struct mouse_report current_rep[]; 22831807Smarc 22931807Smarc /*---------------------------- 23031807Smarc * input event "select" use */ 23131807Smarc 23231807Smarc extern struct proc *rsel[]; /* process waiting for select */ 23331807Smarc 23431807Smarc extern int DMAbuf_size; 23531807Smarc 23631807Smarc /*---------------------------- 23731807Smarc * console cursor structure */ 23831807Smarc 23931807Smarc struct _vs_cursor cursor[]; 24031807Smarc 24131807Smarc 24231807Smarc /*********************************************************************/ 24331807Smarc 24431807Smarc #else 24531807Smarc 24631807Smarc /*-------------------------------------------------------------------------- 24731807Smarc * reference to an array of "uba_device" structures built by the auto 24831807Smarc * configuration program. The uba_device structure decribes the device 24931807Smarc * sufficiently for the driver to talk to it. The auto configuration code 25031807Smarc * fills in the uba_device structures (located in ioconf.c) from user 25131807Smarc * maintained info. */ 25231807Smarc 25331807Smarc struct uba_device *qdinfo[NQD]; /* array of pntrs to each QDSS's */ 25431807Smarc /* uba structures */ 25531807Smarc struct tty qd_tty[NQD*4]; /* teletype structures for each.. */ 25631807Smarc /* ..possible minor device */ 25731807Smarc 25831807Smarc struct qd_softc qd_softc[NQD]; 25931807Smarc 26031807Smarc /*---------------------------------------------------------- 26131807Smarc * static storage used by multiple functions in this code */ 26231807Smarc 26331807Smarc int Qbus_unmap[NQD]; /* Qbus mapper release code */ 26431807Smarc struct qdflags qdflags[NQD]; /* QDSS device status flags */ 26531807Smarc struct qdmap qdmap[NQD]; /* QDSS register map structure */ 26631807Smarc caddr_t qdbase[NQD]; /* base address of each QDSS unit */ 26731807Smarc struct buf qdbuf[NQD]; /* buf structs used by strategy */ 26831807Smarc char one_only[NQD]; /* lock for single process access */ 26931807Smarc 27031807Smarc /*------------------------------------------------------------------------ 27131807Smarc * the array "event_shared[]" is made up of a number of event queue buffers 27231807Smarc * equal to the number of QDSS's configured into the running kernel (NQD). 27331807Smarc * Each event queue buffer begins with an event queue header (struct qdinput) 27431807Smarc * followed by a group of event queue entries (struct _vs_event). The array 27531807Smarc * "*eq_header[]" is an array of pointers to the start of each event queue 27631807Smarc * buffer in "event_shared[]". */ 27731807Smarc 27831807Smarc #define EQSIZE ((EVENT_BUFSIZE * NQD) + 512) 27931807Smarc 28031807Smarc char event_shared[EQSIZE]; /* reserve space for event bufs */ 28131807Smarc struct qdinput *eq_header[NQD]; /* event queue header pntrs */ 28231807Smarc 28331807Smarc /*-------------------------------------------------------------------------- 28431807Smarc * This allocation method reserves enough memory pages for NQD shared DMA I/O 28531807Smarc * buffers. Each buffer must consume an integral number of memory pages to 28631807Smarc * guarantee that a following buffer will begin on a page boundary. Also, 28731807Smarc * enough space is allocated so that the FIRST I/O buffer can start at the 28831807Smarc * 1st page boundary after "&DMA_shared". Page boundaries are used so that 28931807Smarc * memory protections can be turned on/off for individual buffers. */ 29031807Smarc 29131807Smarc #define IOBUFSIZE ((DMA_BUFSIZ * NQD) + 512) 29231807Smarc 29331807Smarc char DMA_shared[IOBUFSIZE]; /* reserve I/O buffer space */ 29431807Smarc struct DMAreq_header *DMAheader[NQD]; /* DMA buffer header pntrs */ 29531807Smarc 29631807Smarc /*------------------------------------------------------------------------- 29731807Smarc * The driver assists a client in scroll operations by loading dragon 29831807Smarc * registers from an interrupt service routine. The loading is done using 29931807Smarc * parameters found in memory shrade between the driver and it's client. 30031807Smarc * The scroll parameter structures are ALL loacted in the same memory page 30131807Smarc * for reasons of memory economy. */ 30231807Smarc 30331807Smarc char scroll_shared[2 * 512]; /* reserve space for scroll structs */ 30431807Smarc struct scroll *scroll[NQD]; /* pointers to scroll structures */ 30531807Smarc 30631807Smarc /*----------------------------------------------------------------------- 30731807Smarc * the driver is programmable to provide the user with color map write 30831807Smarc * services at VSYNC interrupt time. At interrupt time the driver loads 30931807Smarc * the color map with any user-requested load data found in shared memory */ 31031807Smarc 31131807Smarc #define COLOR_SHARED ((COLOR_BUFSIZ * NQD) + 512) 31231807Smarc 31331807Smarc char color_shared[COLOR_SHARED]; /* reserve space: color bufs */ 31431807Smarc struct color_buf *color_buf[NQD]; /* pointers to color bufs */ 31531807Smarc 31631807Smarc /*-------------------------------- 31731807Smarc * mouse input event structures */ 31831807Smarc 31931807Smarc struct mouse_report last_rep[NQD]; 32031807Smarc struct mouse_report current_rep[NQD]; 32131807Smarc 32231807Smarc /*---------------------------- 32331807Smarc * input event "select" use */ 32431807Smarc 32531807Smarc struct proc *rsel[NQD]; /* process waiting for select */ 32631807Smarc 32731807Smarc /*---------------------------- 32831807Smarc * console cursor structure */ 32931807Smarc 33031807Smarc struct _vs_cursor cursor[NQD]; 33131807Smarc 33231807Smarc 33331807Smarc /************************************************************************/ 33431807Smarc 33531807Smarc int nNQD = NQD; 33631807Smarc 33731807Smarc int DMAbuf_size = DMA_BUFSIZ; 33831807Smarc 33931807Smarc #endif 34031807Smarc 34131807Smarc 342