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

Annotation of sys/arch/vax/bi/bi.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: bi.c,v 1.7 2004/07/07 23:10:43 deraadt Exp $ */
                      2: /*     $NetBSD: bi.c,v 1.17 2001/11/13 12:51:34 lukem Exp $ */
                      3: /*
                      4:  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
                      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:  * 3. All advertising materials mentioning features or use of this software
                     16:  *    must display the following acknowledgement:
                     17:  *      This product includes software developed at Ludd, University of
                     18:  *      Lule}, Sweden and its contributors.
                     19:  * 4. 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:
                     36: /*
                     37:  * VAXBI specific routines.
                     38:  */
                     39: /*
                     40:  * TODO
                     41:  *   handle BIbus errors more gracefully.
                     42:  */
                     43:
                     44: #include <sys/cdefs.h>
                     45: __KERNEL_RCSID(0, "$NetBSD: bi.c,v 1.17 2001/11/13 12:51:34 lukem Exp $");
                     46:
                     47: #include <sys/param.h>
                     48: #include <sys/systm.h>
                     49:
                     50: #include <machine/bus.h>
                     51: #include <machine/cpu.h>
                     52:
                     53: #include <dev/bi/bireg.h>
                     54: #include <dev/bi/bivar.h>
                     55:
                     56: static int bi_print(void *, const char *);
                     57:
                     58: struct bi_list bi_list[] = {
                     59:        {BIDT_MS820, DT_HAVDRV, "ms820"},
                     60:        {BIDT_DRB32, DT_UNSUPP, "drb32"},
                     61:        {BIDT_DWBUA, DT_HAVDRV|DT_ADAPT, "dwbua"},
                     62:        {BIDT_KLESI, DT_HAVDRV|DT_ADAPT, "klesi"},
                     63:        {BIDT_KA820, DT_HAVDRV, "ka820"},
                     64:        {BIDT_DB88,  DT_HAVDRV|DT_QUIET, "db88"},
                     65:        {BIDT_CIBCA, DT_UNSUPP, "cibca"},
                     66:        {BIDT_DMB32, DT_UNSUPP, "dmb32"},
                     67:        {BIDT_CIBCI, DT_UNSUPP, "cibci"},
                     68:        {BIDT_KA800, DT_UNSUPP, "ka800"},
                     69:        {BIDT_KDB50, DT_HAVDRV|DT_VEC, "kdb50"},
                     70:        {BIDT_DWMBA, DT_HAVDRV|DT_QUIET, "dwmba"},
                     71:        {BIDT_KFBTA, DT_UNSUPP, "kfbta"},
                     72:        {BIDT_DEBNK, DT_HAVDRV|DT_VEC, "debnk"},
                     73:        {BIDT_DEBNA, DT_HAVDRV|DT_VEC, "debna"},
                     74:        {0,0,0}
                     75: };
                     76:
                     77: int
                     78: bi_print(aux, name)
                     79:        void *aux;
                     80:        const char *name;
                     81: {
                     82:        struct bi_attach_args *ba = aux;
                     83:        struct bi_list *bl;
                     84:        u_int16_t nr;
                     85:
                     86:        nr = bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0);
                     87:        for (bl = &bi_list[0]; bl->bl_nr; bl++)
                     88:                if (bl->bl_nr == nr)
                     89:                        break;
                     90:
                     91:        if (name) {
                     92:                if (bl->bl_nr == 0)
                     93:                        printf("unknown device 0x%x", nr);
                     94:                else
                     95:                        printf(bl->bl_name);
                     96:                printf(" at %s", name);
                     97:        }
                     98:        printf(" node %d", ba->ba_nodenr);
                     99:        if (bl->bl_havedriver & DT_VEC)
                    100:                printf(" vec %d", ba->ba_ivec & 511);
                    101: #ifdef DEBUG
                    102:        if (bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR) &&
                    103:            bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR))
                    104:                printf(" [sadr %x eadr %x]",
                    105:                    bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR),
                    106:                    bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR));
                    107: #endif
                    108:        if (bl->bl_havedriver & DT_QUIET)
                    109:                printf("\n");
                    110:        return bl->bl_havedriver & DT_QUIET ? QUIET :
                    111:            bl->bl_havedriver & DT_HAVDRV ? UNCONF : UNSUPP;
                    112: }
                    113:
                    114: void
                    115: bi_attach(sc)
                    116:        struct bi_softc *sc;
                    117: {
                    118:        struct bi_attach_args ba;
                    119:        int nodenr;
                    120:
                    121:        printf("\n");
                    122:
                    123:        ba.ba_iot = sc->sc_iot;
                    124:        ba.ba_busnr = sc->sc_busnr;
                    125:        ba.ba_dmat = sc->sc_dmat;
                    126:        ba.ba_intcpu = sc->sc_intcpu;
                    127:        ba.ba_icookie = sc;
                    128:        /*
                    129:         * Interrupt numbers. Assign them as described in
                    130:         * VAX 8800 system maintenance manual; this means like nexus
                    131:         * adapters have them assigned.
                    132:         * XXX - must address Unibus adapters.
                    133:         */
                    134:        for (nodenr = 0; nodenr < NNODEBI; nodenr++) {
                    135:                if (bus_space_map(sc->sc_iot, sc->sc_addr + BI_NODE(nodenr),
                    136:                    BI_NODESIZE, 0, &ba.ba_ioh)) {
                    137:                        printf("bi_attach: bus_space_map failed, node %d\n",
                    138:                            nodenr);
                    139:                        return;
                    140:                }
                    141:                if (badaddr((caddr_t)ba.ba_ioh, 4) ||
                    142:                    (bus_space_read_2(ba.ba_iot, ba.ba_ioh, 0) == 0)) {
                    143:                        bus_space_unmap(ba.ba_iot, ba.ba_ioh, BI_NODESIZE);
                    144:                        continue;
                    145:                }
                    146:                ba.ba_nodenr = nodenr;
                    147:                ba.ba_ivec = sc->sc_lastiv + 64 + 4 * nodenr; /* all on spl5 */
                    148:                config_found(&sc->sc_dev, &ba, bi_print);
                    149:        }
                    150: }

CVSweb