[BACK]Return to joy_isa.c CVS log [TXT][DIR] Up to [local] / sys / arch / i386 / isa

Annotation of sys/arch/i386/isa/joy_isa.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: joy_isa.c,v 1.7 2007/08/01 13:18:18 martin Exp $      */
                      2: /*     $NetBSD: joy.c,v 1.3 1996/05/05 19:46:15 christos Exp $ */
                      3:
                      4: /*-
                      5:  * Copyright (c) 1995 Jean-Marc Zucconi
                      6:  * All rights reserved.
                      7:  *
                      8:  * Ported to NetBSD by Matthieu Herrb <matthieu@laas.fr>
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer
                     15:  *    in this position and unchanged.
                     16:  * 2. Redistributions in binary form must reproduce the above copyright
                     17:  *    notice, this list of conditions and the following disclaimer in the
                     18:  *    documentation and/or other materials provided with the distribution.
                     19:  * 3. The name of the author may not be used to endorse or promote products
                     20:  *    derived from this software without specific prior written permission
                     21:  *
                     22:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     23:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     24:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     25:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     26:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     27:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     28:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     29:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     30:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     31:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     32:  *
                     33:  */
                     34:
                     35: #include <sys/param.h>
                     36: #include <sys/systm.h>
                     37: #include <sys/kernel.h>
                     38: #include <sys/device.h>
                     39: #include <sys/errno.h>
                     40:
                     41: #include <machine/cpu.h>
                     42: #include <machine/pio.h>
                     43: #include <machine/cpufunc.h>
                     44: #include <machine/joystick.h>
                     45: #include <machine/conf.h>
                     46:
                     47: #include <dev/isa/isavar.h>
                     48: #include <dev/isa/isareg.h>
                     49: #include <dev/ic/i8253reg.h>
                     50: #include <i386/isa/joyreg.h>
                     51:
                     52: int            joy_isa_probe(struct device *, void *, void *);
                     53: void           joy_isa_attach(struct device *, struct device *, void *);
                     54:
                     55: struct cfattach joy_isa_ca = {
                     56:        sizeof(struct joy_softc), joy_isa_probe, joy_isa_attach
                     57: };
                     58:
                     59: int
                     60: joy_isa_probe(struct device *parent, void *match, void *aux)
                     61: {
                     62:        struct isa_attach_args *ia = aux;
                     63: #ifdef WANT_JOYSTICK_CONNECTED
                     64:        int iobase = ia->ia_iobase;
                     65:
                     66:        outb(iobase, 0xff);
                     67:        DELAY(10000);           /* 10 ms delay */
                     68:        return (inb(iobase) & 0x0f) != 0x0f;
                     69: #else
                     70:        ia->ia_iosize = JOY_NPORTS;
                     71:        ia->ia_msize = 0;
                     72:        return 1;
                     73: #endif
                     74: }
                     75:
                     76: void
                     77: joy_isa_attach(struct device *parent, struct device *self, void *aux)
                     78: {
                     79:        struct joy_softc *sc = (void *) self;
                     80:        struct isa_attach_args *ia = aux;
                     81:        int iobase = ia->ia_iobase;
                     82:
                     83:        sc->port = iobase;
                     84:        sc->timeout[0] = sc->timeout[1] = 0;
                     85:        outb(iobase, 0xff);
                     86:        DELAY(10000);           /* 10 ms delay */
                     87: #if 0
                     88:        printf(": joystick%sconnected\n",
                     89:            (inb(iobase) & 0x0f) == 0x0f ? " not " : " ");
                     90: #else
                     91:        printf("\n");
                     92: #endif
                     93: }

CVSweb