Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/qbus Copied from ../../arch/vax/uba/qd.c,v



details:   https://anonhg.NetBSD.org/src/rev/95a8ab7be747
branches:  trunk
changeset: 473879:95a8ab7be747
user:      ragge <ragge%NetBSD.org@localhost>
date:      Sun Jun 20 17:53:33 1999 +0000

description:
Copied from ../../arch/vax/uba/qd.c,v

diffstat:

 sys/dev/qbus/qd.c |  3804 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 3804 insertions(+), 0 deletions(-)

diffs (truncated from 3808 to 300 lines):

diff -r b9fdb2007961 -r 95a8ab7be747 sys/dev/qbus/qd.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/qbus/qd.c Sun Jun 20 17:53:33 1999 +0000
@@ -0,0 +1,3804 @@
+/*     $NetBSD: qd.c,v 1.14 1999/06/20 17:53:33 ragge Exp $    */
+
+/*-
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)qd.c        7.1 (Berkeley) 6/28/91
+ */
+
+/************************************************************************
+*                                                                      *
+*                      Copyright (c) 1985-1988 by                      *
+*              Digital Equipment Corporation, Maynard, MA              *
+*                      All rights reserved.                            *
+*                                                                      *
+*   This software is furnished under a license and may be used and     *
+*   copied  only  in accordance with the terms of such license and     *
+*   with the  inclusion  of  the  above  copyright  notice.   This     *
+*   software  or  any  other copies thereof may not be provided or     *
+*   otherwise made available to any other person.  No title to and     *
+*   ownership of the software is hereby transferred.                   *
+*                                                                      *
+*   The information in this software is subject to change  without     *
+*   notice  and should not be construed as a commitment by Digital     *
+*   Equipment Corporation.                                             *
+*                                                                      *
+*   Digital assumes no responsibility for the use  or  reliability     *
+*   of its software on equipment which is not supplied by Digital.     *
+*                                                                      *
+*************************************************************************/
+
+/*
+ * qd.c - QDSS display driver for VAXSTATION-II GPX workstation
+ */
+
+#include "opt_ddb.h"
+
+#define KERNEL 1
+
+#include "qd.h"
+
+#if NQD > 0
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/tty.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/poll.h>
+
+#include <vm/vm.h>
+
+#include <dev/cons.h>
+
+#include <machine/pte.h>
+#include <machine/cpu.h>
+#include <machine/qdioctl.h>
+#include <machine/qduser.h>    /* definitions shared with user level client */
+#include <machine/qdreg.h>     /* QDSS device register structures */
+#include <machine/sid.h>
+#include <machine/scb.h>
+
+#include <vax/uba/ubareg.h>
+#include <vax/uba/ubavar.h>
+
+#include "ioconf.h"
+
+/*
+ * QDSS driver status flags for tracking operational state 
+ */
+struct qdflags {
+       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 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 * 10)
+#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 */
+struct tty *qd_tty[NQD*4];     /* teletype structures for each.. */
+volatile char *qvmem[NQD];
+volatile struct pte *QVmap[NQD];
+#define CHUNK    (64 * 1024)
+#define QMEMSIZE  (1024 * 1024 * 4)    /* 4 meg */
+
+/*
+ * 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 */
+short qdopened[NQD];           /* graphics device is open exclusive use */
+
+/*
+ * 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];
+
+struct selinfo qdrsel[NQD];    /* process waiting for select */
+struct _vs_cursor cursor[NQD]; /* console cursor */
+int qdcount = 0;               /* count of successfully probed qd's */
+int nNQD = NQD;
+int DMAbuf_size = DMA_BUFSIZ;
+int QDlast_DMAtype;             /* type of the last DMA operation */
+
+/* #define QDSSMAJOR   41 */   /* QDSS major device number.  We don't care! */
+
+/*
+ * macro to get system time.  Used to time stamp event queue entries 
+ */
+#define TOY ((time.tv_sec * 100) + (time.tv_usec / 10000))
+
+void qd_attach __P((struct device *, struct device *, void *));
+static int qd_match __P((struct device *, struct cfdata *, void *));
+
+static void qddint(int);                       /* DMA gate array intrpt service */
+static void qdaint(int);                       /* Dragon ADDER intrpt service */
+static void qdiint(int);
+
+#define QDPRIOR (PZERO-1)              /* must be negative */
+#define FALSE  0
+#ifdef TRUE
+#undef TRUE
+#endif
+#define TRUE   ~FALSE
+#define BAD    -1
+#define GOOD   0
+
+/*
+ * macro to create a system virtual page number from system virtual adrs 
+ */
+#define VTOP(x)  (((int)x & ~0xC0000000) >> VAX_PGSHIFT)
+
+/*
+ * QDSS register address offsets from start of QDSS address space 
+ */
+#define QDSIZE  (52 * 1024)    /* size of entire QDSS foot print */
+#define TMPSIZE  (16 * 1024)   /* template RAM is 8k SHORT WORDS */
+#define TMPSTART 0x8000        /* offset of template RAM from base adrs */
+#define REGSIZE  (5 * 512)     /* regs touch 2.5k (5 pages) of addr space */
+#define REGSTART 0xC000        /* offset of reg pages from base adrs */
+#define ADDER  (REGSTART+0x000)
+#define DGA    (REGSTART+0x200)
+#define DUART  (REGSTART+0x400)
+#define MEMCSR (REGSTART+0x800)
+#define CLRSIZE  (3 * 512)             /* color map size */
+#define CLRSTART (REGSTART+0xA00)      /* color map start offset from base */
+/*  0x0C00 really */
+#define RED    (CLRSTART+0x000)
+#define BLUE   (CLRSTART+0x200)
+#define GREEN  (CLRSTART+0x400)
+
+
+/*
+ * QDSS minor device numbers.  The *real* minor device numbers are in
+ * the bottom two bits of the major/minor device spec.  Bits 2 and up are
+ * used to specify the QDSS device number (ie: which one?) 
+ */
+
+#define CONS           0
+#define GRAPHIC        2
+
+/*
+ * console cursor bitmap (white block cursor)  
+ */
+short cons_cursor[32] = {
+       /* A */ 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF,
+       0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF,
+       /* B */ 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF,
+       0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF
+};
+
+/*
+ * constants used in font operations 
+ */



Home | Main Index | Thread Index | Old Index