[BACK]Return to ipic.c CVS log [TXT][DIR] Up to [local] / sys / arch / mvme68k / dev

Annotation of sys/arch/mvme68k/dev/ipic.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: ipic.c,v 1.17 2005/11/27 14:19:08 miod Exp $ */
                      2:
                      3: /*
                      4:  * Copyright (c) 1995 Theo de Raadt
                      5:  * All rights reserved.
                      6:  *
                      7:  * Redistribution and use in source and binary forms, with or without
                      8:  * modification, are permitted provided that the following conditions
                      9:  * are met:
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
                     15:  *
                     16:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     17:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     18:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     19:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     20:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     21:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     22:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     23:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     24:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     25:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     26:  */
                     27:
                     28: #include <sys/param.h>
                     29: #include <sys/conf.h>
                     30: #include <sys/ioctl.h>
                     31: #include <sys/proc.h>
                     32: #include <sys/user.h>
                     33: #include <sys/tty.h>
                     34: #include <sys/uio.h>
                     35: #include <sys/systm.h>
                     36: #include <sys/kernel.h>
                     37: #include <sys/syslog.h>
                     38: #include <sys/fcntl.h>
                     39: #include <sys/device.h>
                     40:
                     41: #include <machine/autoconf.h>
                     42: #include <machine/cpu.h>
                     43:
                     44: #include <mvme68k/dev/ipicreg.h>
                     45: #include <mvme68k/dev/mcreg.h>
                     46:
                     47: void   ipicattach(struct device *, struct device *, void *);
                     48: int    ipicmatch(struct device *, void *, void *);
                     49:
                     50: int    ipicprint(void *, const char *);
                     51: int    ipicscan(struct device *, void *, void *);
                     52: caddr_t        ipicmap(struct ipicsoftc *, caddr_t, int);
                     53: void   ipicunmap(struct ipicsoftc *, caddr_t, int);
                     54:
                     55: struct cfattach ipic_ca = {
                     56:        sizeof(struct ipicsoftc), ipicmatch, ipicattach
                     57: };
                     58:
                     59: struct cfdriver ipic_cd = {
                     60:        NULL, "ipic", DV_DULL
                     61: };
                     62:
                     63: int
                     64: ipicmatch(parent, cf, args)
                     65:        struct device *parent;
                     66:        void *cf;
                     67:        void *args;
                     68: {
                     69:        struct confargs *ca = args;
                     70:        struct ipicreg *ipic = (struct ipicreg *)ca->ca_vaddr;
                     71:
                     72:        if (badvaddr((vaddr_t)ipic, 1) || ipic->ipic_chipid != IPIC_CHIPID)
                     73:                return (0);
                     74:        return (1);
                     75: }
                     76:
                     77: int
                     78: ipicprint(args, bus)
                     79:        void *args;
                     80:        const char *bus;
                     81: {
                     82:        struct confargs *ca = args;
                     83:
                     84:        printf(" slot %d", ca->ca_offset);
                     85:        if (ca->ca_vec > 0)
                     86:                printf(" vec %d", ca->ca_vec);
                     87:        if (ca->ca_ipl > 0)
                     88:                printf(" ipl %d", ca->ca_ipl);
                     89:        return (UNCONF);
                     90: }
                     91:
                     92: int
                     93: ipicscan(parent, child, args)
                     94:        struct device *parent;
                     95:        void *child, *args;
                     96: {
                     97:        struct cfdata *cf = child;
                     98:        struct ipicsoftc *sc = (struct ipicsoftc *)parent;
                     99:        struct confargs oca;
                    100:        int slot, n = 0;
                    101:        vaddr_t ipv;
                    102:        paddr_t ipp;
                    103:        struct ipid *ipid;
                    104:
                    105:        /* XXX can we determine IPIC_IPSPACE automatically? */
                    106:        for (slot = 0; slot < sc->sc_nip; slot++) {
                    107:                ipp = sc->sc_ipspace + (slot * IPIC_IP_MODSIZE);
                    108:                if (badpaddr((paddr_t)ipp + IPIC_IP_IDOFFSET, 2))
                    109:                        continue;
                    110:
                    111:                ipv = mapiodev(ipp, NBPG);
                    112:                if (ipv == 0)
                    113:                        continue;
                    114:
                    115:                ipid = (struct ipid *)(ipv + IPIC_IP_IDOFFSET);
                    116:                if (ipid->ipid_A != 'A' || ipid->ipid_P != 'P' ||
                    117:                    ipid->ipid_I != 'I' || ipid->ipid_C != 'C' ||
                    118:                    (u_char)cf->cf_loc[0] != ipid->ipid_manu ||
                    119:                    (u_char)cf->cf_loc[1] != ipid->ipid_prod) {
                    120:                        unmapiodev(ipv, NBPG);
                    121:                        continue;
                    122:                }
                    123:
                    124:                bzero(&oca, sizeof oca);
                    125:                oca.ca_bustype = BUS_IP;
                    126:                oca.ca_offset = slot;           /* slot number */
                    127:                oca.ca_paddr = ipp;
                    128:                oca.ca_vaddr = ipv;
                    129:                oca.ca_ipl = cf->cf_loc[2];
                    130:                oca.ca_vec = cf->cf_loc[3];
                    131:                if (oca.ca_ipl > 0 && oca.ca_vec == -1)
                    132:                        oca.ca_vec = intr_findvec(255, 0);
                    133:
                    134:                oca.ca_name = cf->cf_driver->cd_name;
                    135:
                    136:                if ((*cf->cf_attach->ca_match)(parent, cf, &oca) == 0) {
                    137:                        unmapiodev(ipv, NBPG);
                    138:                        continue;
                    139:                }
                    140:                config_attach(parent, cf, &oca, ipicprint);
                    141:                n++;
                    142:        }
                    143:        return (n);
                    144: }
                    145:
                    146: void
                    147: ipicattach(parent, self, args)
                    148:        struct device *parent, *self;
                    149:        void *args;
                    150: {
                    151:        struct ipicsoftc *sc = (struct ipicsoftc *)self;
                    152:        struct confargs *ca = args;
                    153:
                    154:        sc->sc_ipic = (struct ipicreg *)ca->ca_vaddr;
                    155:        sc->sc_ipspace = IPIC_IPSPACE;
                    156:        sc->sc_nip = 2;
                    157:
                    158:        /*
                    159:         * Bug in IP2 chip. ipic_chiprev should be 0x01 if
                    160:         * the MC chip is rev 1. XXX - smurph
                    161:         */
                    162:        if (sys_mc->mc_chiprev == 0x01)
                    163:                printf(": rev 1\n");
                    164:        else
                    165:                printf(": rev %d\n", sc->sc_ipic->ipic_chiprev);
                    166:
                    167:        sc->sc_ipic->ipic_reset = IPIC_RESET;
                    168:        delay(2);
                    169:
                    170:        config_search(ipicscan, self, args);
                    171: }
                    172:
                    173: caddr_t
                    174: ipicmap(sc, addr, len)
                    175:        struct ipicsoftc *sc;
                    176:        caddr_t addr;
                    177:        int len;
                    178: {
                    179:        return (NULL);
                    180: }
                    181:
                    182: void
                    183: ipicunmap(sc, addr, len)
                    184:        struct ipicsoftc *sc;
                    185:        caddr_t addr;
                    186:        int len;
                    187: {
                    188: }
                    189:
                    190: int
                    191: ipicintr_establish(vec, ih, name)
                    192:        int vec;
                    193:        struct intrhand *ih;
                    194:        const char *name;
                    195: {
                    196:        return intr_establish(vec, ih, name);
                    197: }

CVSweb