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

Annotation of sys/arch/sparc/dev/if_en_sbus.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: if_en_sbus.c,v 1.7 2006/06/02 20:00:54 miod Exp $     */
                      2: /*     $NetBSD: if_en_sbus.c,v 1.4 1997/05/24 20:16:22 pk Exp $        */
                      3:
                      4: /*
                      5:  *
                      6:  * Copyright (c) 1996 Charles D. Cranor and Washington University.
                      7:  * All rights reserved.
                      8:  *
                      9:  * Redistribution and use in source and binary forms, with or without
                     10:  * modification, are permitted provided that the following conditions
                     11:  * are met:
                     12:  * 1. Redistributions of source code must retain the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer.
                     14:  * 2. Redistributions in binary form must reproduce the above copyright
                     15:  *    notice, this list of conditions and the following disclaimer in the
                     16:  *    documentation and/or other materials provided with the distribution.
                     17:  * 3. All advertising materials mentioning features or use of this software
                     18:  *    must display the following acknowledgement:
                     19:  *      This product includes software developed by Charles D. Cranor and
                     20:  *     Washington University.
                     21:  * 4. The name of the author may not be used to endorse or promote products
                     22:  *    derived from this software without specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     25:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     26:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     27:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     28:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     29:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     30:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     31:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     32:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     33:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     34:  */
                     35:
                     36: /*
                     37:  *
                     38:  * i f _ e n _ s b u s . c
                     39:  *
                     40:  * author: Chuck Cranor <chuck@ccrc.wustl.edu>
                     41:  * started: spring, 1996.
                     42:  *
                     43:  * SBUS glue for the eni155s card.
                     44:  */
                     45:
                     46: #include <sys/param.h>
                     47: #include <sys/types.h>
                     48: #include <sys/device.h>
                     49: #include <sys/mbuf.h>
                     50: #include <sys/socket.h>
                     51: #include <sys/socketvar.h>
                     52:
                     53: #include <net/if.h>
                     54:
                     55: #include <machine/autoconf.h>
                     56: #include <machine/cpu.h>
                     57:
                     58: #include <sparc/dev/sbusvar.h>
                     59:
                     60: #include <dev/ic/midwayreg.h>
                     61: #include <dev/ic/midwayvar.h>
                     62:
                     63:
                     64: /*
                     65:  * local structures
                     66:  */
                     67:
                     68: struct en_sbus_softc {
                     69:   /* bus independent stuff */
                     70:   struct en_softc esc;         /* includes "device" structure */
                     71:
                     72:   /* sbus glue */
                     73:   struct intrhand sc_ih;       /* interrupt vectoring */
                     74: };
                     75:
                     76: /*
                     77:  * local defines (SBUS specific stuff)
                     78:  */
                     79:
                     80: #define EN_IPL 5
                     81:
                     82: /*
                     83:  * prototypes
                     84:  */
                     85:
                     86: static int en_sbus_match(struct device *, void *, void *);
                     87: static void en_sbus_attach(struct device *, struct device *, void *);
                     88:
                     89: /*
                     90:  * SBUS autoconfig attachments
                     91:  */
                     92:
                     93: struct cfattach en_sbus_ca = {
                     94:     sizeof(struct en_sbus_softc), en_sbus_match, en_sbus_attach,
                     95: };
                     96:
                     97: /***********************************************************************/
                     98:
                     99: /*
                    100:  * autoconfig stuff
                    101:  */
                    102:
                    103: static int en_sbus_match(parent, match, aux)
                    104:
                    105: struct device *parent;
                    106: void *match;
                    107: void *aux;
                    108:
                    109: {
                    110:   struct cfdata *cf = match;
                    111:   struct confargs *ca = aux;
                    112:   register struct romaux *ra = &ca->ca_ra;
                    113:
                    114:   if (strcmp("ENI-155s", ra->ra_name))
                    115:     return 0;
                    116:   if (ca->ca_bustype == BUS_SBUS)
                    117:     return (1);
                    118:
                    119:   return 0;
                    120: }
                    121:
                    122:
                    123: static void en_sbus_attach(parent, self, aux)
                    124:
                    125: struct device *parent, *self;
                    126: void *aux;
                    127:
                    128: {
                    129:   struct en_softc *sc = (void *)self;
                    130:   struct en_sbus_softc *scs = (void *)self;
                    131:   struct confargs *ca = aux;
                    132:   int lcv, iplcode;
                    133:
                    134:   printf("\n");
                    135:
                    136:   if (CPU_ISSUN4M) {
                    137:     printf("%s: sun4m DMA not supported yet\n", sc->sc_dev.dv_xname);
                    138:     return;
                    139:   }
                    140:
                    141:   sc->en_base = (caddr_t) mapiodev(ca->ca_ra.ra_reg, 0, 4*1024*1024);
                    142:
                    143:   if (ca->ca_ra.ra_nintr == 1) {
                    144:     sc->ipl = ca->ca_ra.ra_intr[0].int_pri;
                    145:   } else {
                    146:     printf("%s: claims to be at the following IPLs: ", sc->sc_dev.dv_xname);
                    147:     iplcode = 0;
                    148:     for (lcv = 0 ; lcv < ca->ca_ra.ra_nintr ; lcv++) {
                    149:       printf("%d ", ca->ca_ra.ra_intr[lcv].int_pri);
                    150:       if (EN_IPL == ca->ca_ra.ra_intr[lcv].int_pri)
                    151:         iplcode = lcv;
                    152:     }
                    153:     if (!iplcode) {
                    154:       printf("%s: can't find the IPL we want (%d)\n", sc->sc_dev.dv_xname,
                    155:                EN_IPL);
                    156:       return;
                    157:     }
                    158:     printf("\n%s: we choose IPL %d\n", sc->sc_dev.dv_xname, EN_IPL);
                    159:     sc->ipl = iplcode;
                    160:   }
                    161:   scs->sc_ih.ih_fun = en_intr;
                    162:   scs->sc_ih.ih_arg = sc;
                    163:   intr_establish(EN_IPL, &scs->sc_ih, IPL_NET, self->dv_xname);
                    164:
                    165:   /*
                    166:    * done SBUS specific stuff
                    167:    */
                    168:
                    169:   en_attach(sc);
                    170:
                    171: }

CVSweb