Home | History | Annotate | Line # | Download | only in isapnp
if_ep_isapnp.c revision 1.3
      1 /*	$NetBSD: if_ep_isapnp.c,v 1.3 1997/02/18 10:51:10 jonathan Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1997 Charles M. Hannum.  All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *      This product includes software developed by Charles M. Hannum.
     17  * 4. The name of the author may not be used to endorse or promote products
     18  *    derived from this software without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #include "bpfilter.h"
     33 
     34 #include <sys/param.h>
     35 #include <sys/systm.h>
     36 #include <sys/mbuf.h>
     37 #include <sys/socket.h>
     38 #include <sys/ioctl.h>
     39 #include <sys/errno.h>
     40 #include <sys/syslog.h>
     41 #include <sys/select.h>
     42 #include <sys/device.h>
     43 
     44 #include <net/if.h>
     45 #include <net/if_dl.h>
     46 #include <net/if_types.h>
     47 
     48 #ifdef INET
     49 #include <netinet/in.h>
     50 #include <netinet/in_systm.h>
     51 #include <netinet/in_var.h>
     52 #include <netinet/ip.h>
     53 #include <netinet/if_ether.h>
     54 #endif
     55 
     56 #ifdef NS
     57 #include <netns/ns.h>
     58 #include <netns/ns_if.h>
     59 #endif
     60 
     61 #if NBPFILTER > 0
     62 #include <net/bpf.h>
     63 #include <net/bpfdesc.h>
     64 #endif
     65 
     66 #include <machine/cpu.h>
     67 #include <machine/bus.h>
     68 #include <machine/intr.h>
     69 
     70 #include <dev/ic/elink3var.h>
     71 #include <dev/ic/elink3reg.h>
     72 
     73 #include <dev/isa/isavar.h>
     74 
     75 #include <dev/isapnp/isapnpreg.h>
     76 #include <dev/isapnp/isapnpvar.h>
     77 
     78 #ifdef __BROKEN_INDIRECT_CONFIG
     79 int ep_isapnp_match __P((struct device *, void *, void *));
     80 #else
     81 int ep_isapnp_match __P((struct device *, struct cfdata *, void *));
     82 #endif
     83 void ep_isapnp_attach __P((struct device *, struct device *, void *));
     84 
     85 struct cfattach ep_isapnp_ca = {
     86 	sizeof(struct ep_softc), ep_isapnp_match, ep_isapnp_attach
     87 };
     88 
     89 int
     90 ep_isapnp_match(parent, match, aux)
     91 	struct device *parent;
     92 #ifdef __BROKEN_INDIRECT_CONFIG
     93 	void *match;
     94 #else
     95 	struct cfdata *match;
     96 #endif
     97 	void *aux;
     98 {
     99 	struct isapnp_attach_args *ipa = aux;
    100 
    101 	return (!strcmp(ipa->ipa_devlogic, "TCM5094"));
    102 }
    103 
    104 void
    105 ep_isapnp_attach(parent, self, aux)
    106 	struct device *parent, *self;
    107 	void *aux;
    108 {
    109 	struct ep_softc *sc = (void *)self;
    110 	struct isapnp_attach_args *ipa = aux;
    111 	u_short conn = 0;
    112 
    113 	sc->sc_iot = ipa->ipa_iot;
    114 	sc->sc_ioh = ipa->ipa_io[0].h;
    115 	sc->bustype = EP_BUS_ISA;
    116 
    117 	GO_WINDOW(0);
    118 	conn = bus_space_read_2(sc->sc_iot, sc->sc_ioh, EP_W0_CONFIG_CTRL);
    119 
    120 	printf("\n");
    121 
    122 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
    123 		printf("%s: error in region allocation\n", sc->sc_dev.dv_xname);
    124 		return;
    125 	}
    126 
    127 	printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident,
    128 	    ipa->ipa_devclass);
    129 
    130 	sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
    131 	    IST_EDGE, IPL_NET, epintr, sc);
    132 
    133 	/* we can't easily tell if this is a 3c509B or 3c515 */
    134 	epconfig(sc, EP_CHIPSET_UNKNOWN);	/* XXX */
    135 }
    136