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*45805Sbostic #include "../include/pte.h" /* page table values */ 115*45805Sbostic #include "../include/mtpr.h" /* VAX register access stuff */ 11631807Smarc 117*45805Sbostic #include "sys/param.h" /* general system params & macros */ 118*45805Sbostic #include "sys/conf.h" /* "linesw" tty driver dispatch */ 119*45805Sbostic #include "sys/user.h" /* user structure (what else?) */ 12032014Smarc #include "qdioctl.h" /* ioctl call values */ 121*45805Sbostic #include "sys/tty.h" 122*45805Sbostic #include "sys/map.h" /* resource allocation map struct */ 123*45805Sbostic #include "sys/buf.h" /* buf structs */ 124*45805Sbostic #include "sys/vm.h" /* includes 'vm' header files */ 125*45805Sbostic #include "sys/clist.h" /* char list handling structs */ 126*45805Sbostic #include "sys/file.h" /* file I/O definitions */ 127*45805Sbostic #include "sys/uio.h" /* write/read call structs */ 128*45805Sbostic #include "sys/kernel.h" /* clock handling structs */ 129*45805Sbostic #include "../include/cpu.h" /* per cpu (pcpu) struct */ 13031807Smarc 131*45805Sbostic #include "../uba/ubareg.h" /* uba & 'qba' register structs */ 132*45805Sbostic #include "../uba/ubavar.h" /* uba structs & uba map externs */ 13331807Smarc 13432014Smarc #include "qduser.h" /* definitions shared with my client */ 13532014Smarc #include "qdreg.h" /* QDSS device register structures */ 13631807Smarc 13731807Smarc /*----------------------------------------------------------- 13831807Smarc * QDSS driver status flags for tracking operational state */ 13931807Smarc 14031807Smarc struct qdflags { 14131807Smarc 14231807Smarc u_int inuse; /* which minor dev's are in use now */ 14331807Smarc u_int config; /* I/O page register content */ 14431807Smarc u_int mapped; /* user mapping status word */ 14531807Smarc u_int kernel_loop; /* if kernel console is redirected */ 14631807Smarc u_int user_dma; /* DMA from user space in progress */ 14731807Smarc u_short pntr_id; /* type code of pointing device */ 14831807Smarc u_short duart_imask; /* shadowing for duart intrpt mask reg */ 14931807Smarc u_short adder_ie; /* shadowing for adder intrpt enbl reg */ 15031807Smarc u_short curs_acc; /* cursor acceleration factor */ 15131807Smarc u_short curs_thr; /* cursor acceleration threshold level */ 15231807Smarc u_short tab_res; /* tablet resolution factor */ 15331807Smarc u_short selmask; /* mask for active qd select entries */ 15431807Smarc }; 15531807Smarc 15631807Smarc /* bit definitions for "inuse" entry */ 15731807Smarc 15831807Smarc #define CONS_DEV 0x01 15931807Smarc #define ALTCONS_DEV 0x02 16031807Smarc #define GRAPHIC_DEV 0x04 16131807Smarc 16231807Smarc /* bit definitions for 'mapped' member of flag structure */ 16331807Smarc 16431807Smarc #define MAPDEV 0x01 /* hardware is mapped */ 16531807Smarc #define MAPDMA 0x02 /* DMA buffer mapped */ 16631807Smarc #define MAPEQ 0x04 /* event queue buffer mapped */ 16731807Smarc #define MAPSCR 0x08 /* scroll param area mapped */ 16831807Smarc #define MAPCOLOR 0x10 /* color map writing buffer mapped */ 16931807Smarc 17031807Smarc /* bit definitions for 'selmask' member of qdflag structure */ 17131807Smarc 17231807Smarc #define SEL_READ 0x01 /* read select is active */ 17331807Smarc #define SEL_WRITE 0x02 /* write select is active */ 17431807Smarc 17531807Smarc /*---------------------------------------------- 17631807Smarc * constants used in shared memory operations */ 17731807Smarc 17831807Smarc #define EVENT_BUFSIZE 1024 /* # of bytes per device's event buffer */ 17931807Smarc 18031807Smarc #define MAXEVENTS ( (EVENT_BUFSIZE - sizeof(struct qdinput)) \ 18131807Smarc / sizeof(struct _vs_event) ) 18231807Smarc 18331807Smarc #define DMA_BUFSIZ (1024 * 3) 18431807Smarc 18531807Smarc #define COLOR_BUFSIZ ((sizeof(struct color_buf) + 512) & ~0x01FF) 18631807Smarc 18731807Smarc /*******************************************************************/ 18831807Smarc 18931807Smarc #ifdef BINARY 19031807Smarc 19131807Smarc extern struct uba_device *qdinfo[]; /* array of pntrs to each QDSS */ 19231807Smarc /* uba structure */ 19331807Smarc extern struct tty qd_tty[]; 19431807Smarc 19531807Smarc extern struct qd_softc qd_softc[]; 19631807Smarc 19731807Smarc /*---------------------------------------------------------- 19831807Smarc * static storage used by multiple functions in this code */ 19931807Smarc 20031807Smarc extern int Qbus_unmap[]; /* Qbus mapper release key */ 20131807Smarc extern struct qdflags qdflags[]; /* QDSS device status flags */ 20231807Smarc extern struct qdmap qdmap[]; /* QDSS register map structure */ 20331807Smarc extern caddr_t qdbase[]; /* base address of each QDSS unit */ 20431807Smarc extern struct buf qdbuf[]; /* buf structs used by strategy */ 20531807Smarc extern char one_only[]; /* lock for single process access */ 20631807Smarc 20731807Smarc /*----------------------------- 20831807Smarc * shared memory allocation */ 20931807Smarc 21031807Smarc extern char event_shared[]; /* reserve event buf space */ 21131807Smarc extern struct qdinput *eq_header[]; /* event buf header ptrs */ 21231807Smarc 21331807Smarc extern char DMA_shared[]; /* reserve DMA buf space */ 21431807Smarc extern struct DMAreq_header *DMAheader[]; /* DMA buf header ptrs */ 21531807Smarc 21631807Smarc extern char scroll_shared[]; /* reserve space for scroll structs */ 21731807Smarc extern struct scroll *scroll[]; /* pointers to scroll structures */ 21831807Smarc 21931807Smarc extern char color_shared[]; /* reserve space: color bufs */ 22031807Smarc extern struct color_buf *color_buf[]; /* pointers to color bufs */ 22131807Smarc 22231807Smarc /*-------------------------------- 22331807Smarc * mouse input event structures */ 22431807Smarc 22531807Smarc extern struct mouse_report last_rep[]; 22631807Smarc extern struct mouse_report current_rep[]; 22731807Smarc 22831807Smarc /*---------------------------- 22931807Smarc * input event "select" use */ 23031807Smarc 23131807Smarc extern struct proc *rsel[]; /* process waiting for select */ 23231807Smarc 23331807Smarc extern int DMAbuf_size; 23431807Smarc 23531807Smarc /*---------------------------- 23631807Smarc * console cursor structure */ 23731807Smarc 23831807Smarc struct _vs_cursor cursor[]; 23931807Smarc 24031807Smarc 24131807Smarc /*********************************************************************/ 24231807Smarc 24331807Smarc #else 24431807Smarc 24531807Smarc /*-------------------------------------------------------------------------- 24631807Smarc * reference to an array of "uba_device" structures built by the auto 24731807Smarc * configuration program. The uba_device structure decribes the device 24831807Smarc * sufficiently for the driver to talk to it. The auto configuration code 24931807Smarc * fills in the uba_device structures (located in ioconf.c) from user 25031807Smarc * maintained info. */ 25131807Smarc 25231807Smarc struct uba_device *qdinfo[NQD]; /* array of pntrs to each QDSS's */ 25331807Smarc /* uba structures */ 25431807Smarc struct tty qd_tty[NQD*4]; /* teletype structures for each.. */ 25531807Smarc /* ..possible minor device */ 25631807Smarc 25731807Smarc struct qd_softc qd_softc[NQD]; 25831807Smarc 25931807Smarc /*---------------------------------------------------------- 26031807Smarc * static storage used by multiple functions in this code */ 26131807Smarc 26231807Smarc int Qbus_unmap[NQD]; /* Qbus mapper release code */ 26331807Smarc struct qdflags qdflags[NQD]; /* QDSS device status flags */ 26431807Smarc struct qdmap qdmap[NQD]; /* QDSS register map structure */ 26531807Smarc caddr_t qdbase[NQD]; /* base address of each QDSS unit */ 26631807Smarc struct buf qdbuf[NQD]; /* buf structs used by strategy */ 26731807Smarc char one_only[NQD]; /* lock for single process access */ 26831807Smarc 26931807Smarc /*------------------------------------------------------------------------ 27031807Smarc * the array "event_shared[]" is made up of a number of event queue buffers 27131807Smarc * equal to the number of QDSS's configured into the running kernel (NQD). 27231807Smarc * Each event queue buffer begins with an event queue header (struct qdinput) 27331807Smarc * followed by a group of event queue entries (struct _vs_event). The array 27431807Smarc * "*eq_header[]" is an array of pointers to the start of each event queue 27531807Smarc * buffer in "event_shared[]". */ 27631807Smarc 27731807Smarc #define EQSIZE ((EVENT_BUFSIZE * NQD) + 512) 27831807Smarc 27931807Smarc char event_shared[EQSIZE]; /* reserve space for event bufs */ 28031807Smarc struct qdinput *eq_header[NQD]; /* event queue header pntrs */ 28131807Smarc 28231807Smarc /*-------------------------------------------------------------------------- 28331807Smarc * This allocation method reserves enough memory pages for NQD shared DMA I/O 28431807Smarc * buffers. Each buffer must consume an integral number of memory pages to 28531807Smarc * guarantee that a following buffer will begin on a page boundary. Also, 28631807Smarc * enough space is allocated so that the FIRST I/O buffer can start at the 28731807Smarc * 1st page boundary after "&DMA_shared". Page boundaries are used so that 28831807Smarc * memory protections can be turned on/off for individual buffers. */ 28931807Smarc 29031807Smarc #define IOBUFSIZE ((DMA_BUFSIZ * NQD) + 512) 29131807Smarc 29231807Smarc char DMA_shared[IOBUFSIZE]; /* reserve I/O buffer space */ 29331807Smarc struct DMAreq_header *DMAheader[NQD]; /* DMA buffer header pntrs */ 29431807Smarc 29531807Smarc /*------------------------------------------------------------------------- 29631807Smarc * The driver assists a client in scroll operations by loading dragon 29731807Smarc * registers from an interrupt service routine. The loading is done using 29831807Smarc * parameters found in memory shrade between the driver and it's client. 29931807Smarc * The scroll parameter structures are ALL loacted in the same memory page 30031807Smarc * for reasons of memory economy. */ 30131807Smarc 30231807Smarc char scroll_shared[2 * 512]; /* reserve space for scroll structs */ 30331807Smarc struct scroll *scroll[NQD]; /* pointers to scroll structures */ 30431807Smarc 30531807Smarc /*----------------------------------------------------------------------- 30631807Smarc * the driver is programmable to provide the user with color map write 30731807Smarc * services at VSYNC interrupt time. At interrupt time the driver loads 30831807Smarc * the color map with any user-requested load data found in shared memory */ 30931807Smarc 31031807Smarc #define COLOR_SHARED ((COLOR_BUFSIZ * NQD) + 512) 31131807Smarc 31231807Smarc char color_shared[COLOR_SHARED]; /* reserve space: color bufs */ 31331807Smarc struct color_buf *color_buf[NQD]; /* pointers to color bufs */ 31431807Smarc 31531807Smarc /*-------------------------------- 31631807Smarc * mouse input event structures */ 31731807Smarc 31831807Smarc struct mouse_report last_rep[NQD]; 31931807Smarc struct mouse_report current_rep[NQD]; 32031807Smarc 32131807Smarc /*---------------------------- 32231807Smarc * input event "select" use */ 32331807Smarc 32431807Smarc struct proc *rsel[NQD]; /* process waiting for select */ 32531807Smarc 32631807Smarc /*---------------------------- 32731807Smarc * console cursor structure */ 32831807Smarc 32931807Smarc struct _vs_cursor cursor[NQD]; 33031807Smarc 33131807Smarc 33231807Smarc /************************************************************************/ 33331807Smarc 33431807Smarc int nNQD = NQD; 33531807Smarc 33631807Smarc int DMAbuf_size = DMA_BUFSIZ; 33731807Smarc 33831807Smarc #endif 33931807Smarc 34031807Smarc 341