[BACK]Return to dzms.c CVS log [TXT][DIR] Up to [local] / sys / arch / vax / dec

Annotation of sys/arch/vax/dec/dzms.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: dzms.c,v 1.7 2006/08/27 16:52:15 miod Exp $   */
        !             2: /*     $NetBSD: dzms.c,v 1.1 2000/12/02 17:03:55 ragge Exp $   */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 1992, 1993
        !             6:  *     The Regents of the University of California.  All rights reserved.
        !             7:  *
        !             8:  * This software was developed by the Computer Systems Engineering group
        !             9:  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
        !            10:  * contributed to Berkeley.
        !            11:  *
        !            12:  * All advertising materials mentioning features or use of this software
        !            13:  * must display the following acknowledgement:
        !            14:  *     This product includes software developed by the University of
        !            15:  *     California, Lawrence Berkeley Laboratory.
        !            16:  *
        !            17:  * Redistribution and use in source and binary forms, with or without
        !            18:  * modification, are permitted provided that the following conditions
        !            19:  * are met:
        !            20:  * 1. Redistributions of source code must retain the above copyright
        !            21:  *    notice, this list of conditions and the following disclaimer.
        !            22:  * 2. Redistributions in binary form must reproduce the above copyright
        !            23:  *    notice, this list of conditions and the following disclaimer in the
        !            24:  *    documentation and/or other materials provided with the distribution.
        !            25:  * 3. Neither the name of the University nor the names of its contributors
        !            26:  *    may be used to endorse or promote products derived from this software
        !            27:  *    without specific prior written permission.
        !            28:  *
        !            29:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            30:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            31:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            32:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            33:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            34:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            35:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            36:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            37:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            38:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            39:  * SUCH DAMAGE.
        !            40:  *
        !            41:  *     @(#)ms.c        8.1 (Berkeley) 6/11/93
        !            42:  */
        !            43:
        !            44: /*
        !            45:  * VSXXX mice attached to line 1 of the DZ*
        !            46:  */
        !            47:
        !            48: #include <sys/param.h>
        !            49: #include <sys/systm.h>
        !            50: #include <sys/device.h>
        !            51: #include <sys/ioctl.h>
        !            52: #include <sys/syslog.h>
        !            53: #include <sys/kernel.h>
        !            54: #include <sys/proc.h>
        !            55: #include <sys/tty.h>
        !            56:
        !            57: #include <machine/bus.h>
        !            58:
        !            59: #include <vax/qbus/dzreg.h>
        !            60: #include <vax/qbus/dzvar.h>
        !            61:
        !            62: #include <vax/dec/dzkbdvar.h>
        !            63: #include <vax/dec/vsmsvar.h>
        !            64:
        !            65: #include <dev/wscons/wsconsio.h>
        !            66: #include <dev/wscons/wsmousevar.h>
        !            67:
        !            68: struct dzms_softc {            /* driver status information */
        !            69:        struct lkms_softc       sc_base;
        !            70:        struct dz_linestate *dzms_ls;
        !            71: };
        !            72:
        !            73: int    dzms_match(struct device *, struct cfdata *, void *);
        !            74: void   dzms_attach(struct device *, struct device *, void *);
        !            75:
        !            76: struct cfattach dzms_ca = {
        !            77:        sizeof(struct dzms_softc), (cfmatch_t)dzms_match, dzms_attach,
        !            78: };
        !            79:
        !            80: int    dzms_enable(void *);
        !            81: void   dzms_disable(void *);
        !            82:
        !            83: const struct wsmouse_accessops dzms_accessops = {
        !            84:        dzms_enable,
        !            85:        lkms_ioctl,
        !            86:        dzms_disable,
        !            87: };
        !            88:
        !            89: int
        !            90: dzms_match(struct device *parent, struct cfdata *cf, void *aux)
        !            91: {
        !            92:        struct dzkm_attach_args *daa = aux;
        !            93:
        !            94: #define DZCF_LINE 0
        !            95: #define DZCF_LINE_DEFAULT 1
        !            96:
        !            97:        /* Exact match is better than wildcard. */
        !            98:        if (cf->cf_loc[DZCF_LINE] == daa->daa_line)
        !            99:                return 2;
        !           100:
        !           101:        /* This driver accepts wildcard. */
        !           102:        if (cf->cf_loc[DZCF_LINE] == DZCF_LINE_DEFAULT)
        !           103:                return 1;
        !           104:
        !           105:        return 0;
        !           106: }
        !           107:
        !           108: void
        !           109: dzms_attach(struct device *parent, struct device *self, void *aux)
        !           110: {
        !           111:        struct dz_softc *dz = (void *)parent;
        !           112:        struct dzms_softc *dzms = (void *)self;
        !           113:        struct lkms_softc *sc = (void *)self;
        !           114:        struct dzkm_attach_args *daa = aux;
        !           115:        struct dz_linestate *ls;
        !           116:        struct wsmousedev_attach_args a;
        !           117:
        !           118:        dz->sc_dz[daa->daa_line].dz_catch = lkms_input;
        !           119:        dz->sc_dz[daa->daa_line].dz_private = dzms;
        !           120:        ls = &dz->sc_dz[daa->daa_line];
        !           121:        dzms->dzms_ls = ls;
        !           122:
        !           123:        printf("\n");
        !           124:
        !           125:        a.accessops = &dzms_accessops;
        !           126:        a.accesscookie = dzms;
        !           127:
        !           128:        sc->sc_enabled = 0;
        !           129:        sc->sc_selftest = 0;
        !           130:        sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
        !           131: }
        !           132:
        !           133: int
        !           134: dzms_enable(void *v)
        !           135: {
        !           136:        struct dzms_softc *dzms = v;
        !           137:        struct lkms_softc *sc = v;
        !           138:
        !           139:        if (sc->sc_enabled)
        !           140:                return EBUSY;
        !           141:
        !           142:        sc->sc_selftest = 4;    /* wait for 4 byte reply upto 1/2 sec */
        !           143:        dzputc(dzms->dzms_ls, MOUSE_SELF_TEST);
        !           144:        (void)tsleep(&sc->sc_enabled, TTIPRI, "dzmsopen", hz / 2);
        !           145:        if (sc->sc_selftest != 0) {
        !           146:                sc->sc_selftest = 0;
        !           147:                return ENXIO;
        !           148:        }
        !           149:        DELAY(150);
        !           150:        dzputc(dzms->dzms_ls, MOUSE_INCREMENTAL);
        !           151:        sc->sc_enabled = 1;
        !           152:        sc->inputstate = 0;
        !           153:        return 0;
        !           154: }
        !           155:
        !           156: void
        !           157: dzms_disable(void *v)
        !           158: {
        !           159:        struct lkms_softc *sc = v;
        !           160:
        !           161:        sc->sc_enabled = 0;
        !           162: }

CVSweb