The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/eisa/depca_eisa.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: depca_eisa.c,v 1.12 2008/04/28 20:23:48 martin Exp $   */
    2 
    3 /*-
    4  * Copyright (c) 2000 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Jason R. Thorpe.
    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  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 /*
   33  * EISA bus front-end for the Digital DEPCA Ethernet controller.
   34  */
   35 
   36 #include <sys/cdefs.h>
   37 __KERNEL_RCSID(0, "$NetBSD: depca_eisa.c,v 1.12 2008/04/28 20:23:48 martin Exp $");
   38 
   39 #include "opt_inet.h"
   40 #include "bpfilter.h"
   41 
   42 #include <sys/param.h>
   43 #include <sys/systm.h>
   44 #include <sys/mbuf.h>
   45 #include <sys/syslog.h>
   46 #include <sys/socket.h>
   47 #include <sys/device.h>
   48 
   49 #include <net/if.h>
   50 #include <net/if_media.h>
   51 #include <net/if_ether.h>
   52 
   53 #ifdef INET
   54 #include <netinet/in.h>
   55 #include <netinet/if_inarp.h>
   56 #endif
   57 
   58 #include <sys/bus.h>
   59 #include <sys/intr.h>
   60 
   61 #include <dev/eisa/eisareg.h>
   62 #include <dev/eisa/eisavar.h>
   63 #include <dev/eisa/eisadevs.h>
   64 
   65 #include <dev/ic/lancereg.h>
   66 #include <dev/ic/lancevar.h>
   67 #include <dev/ic/am7990reg.h>
   68 #include <dev/ic/am7990var.h>
   69 #include <dev/ic/depcareg.h>
   70 #include <dev/ic/depcavar.h>
   71 
   72 static int      depca_eisa_match(device_t, cfdata_t, void *);
   73 static void     depca_eisa_attach(device_t, device_t, void *);
   74 
   75 struct depca_eisa_softc {
   76         struct depca_softc sc_depca;
   77 
   78         eisa_chipset_tag_t sc_ec;
   79         int sc_irq;
   80         int sc_ist;
   81 };
   82 
   83 CFATTACH_DECL_NEW(depca_eisa, sizeof(struct depca_eisa_softc),
   84     depca_eisa_match, depca_eisa_attach, NULL, NULL);
   85 
   86 static void     *depca_eisa_intr_establish(struct depca_softc *,
   87                                            struct lance_softc *);
   88 
   89 static int
   90 depca_eisa_match(device_t parent, cfdata_t cf, void *aux)
   91 {
   92         struct eisa_attach_args *ea = aux;
   93 
   94         return (strcmp(ea->ea_idstring, "DEC4220") == 0);
   95 }
   96 
   97 #define DEPCA_ECU_FUNC_NETINTR  0
   98 #define DEPCA_ECU_FUNC_NETBUF   1
   99 
  100 static void
  101 depca_eisa_attach(device_t parent, device_t self, void *aux)
  102 {
  103         struct depca_eisa_softc *esc = device_private(self);
  104         struct depca_softc *sc = &esc->sc_depca;
  105         struct eisa_attach_args *ea = aux;
  106         struct eisa_cfg_mem ecm;
  107         struct eisa_cfg_irq eci;
  108 
  109         sc->sc_dev = self;
  110         aprint_error(": DEC DE422 Ethernet\n");
  111 
  112         sc->sc_iot = ea->ea_iot;
  113         sc->sc_memt = ea->ea_memt;
  114 
  115         esc->sc_ec = ea->ea_ec;
  116 
  117         sc->sc_intr_establish = depca_eisa_intr_establish;
  118 
  119         if (eisa_conf_read_mem(ea->ea_ec, ea->ea_slot,
  120             DEPCA_ECU_FUNC_NETBUF, 0, &ecm) != 0) {
  121                 aprint_error_dev(self, "unable to find network buffer\n");
  122                 return;
  123         }
  124 
  125         aprint_normal_dev(self, "shared memory at 0x%lx-0x%lx\n",
  126             ecm.ecm_addr, ecm.ecm_addr + ecm.ecm_size - 1);
  127 
  128         sc->sc_memsize = ecm.ecm_size;
  129 
  130         if (bus_space_map(sc->sc_iot, EISA_SLOT_ADDR(ea->ea_slot) + 0xc00, 16,
  131             0, &sc->sc_ioh) != 0) {
  132                 aprint_error_dev(self, "unable to map i/o space\n");
  133                 return;
  134         }
  135         if (bus_space_map(sc->sc_memt, ecm.ecm_addr, sc->sc_memsize,
  136             0, &sc->sc_memh) != 0) {
  137                 aprint_error_dev(self, "unable to map memory space\n");
  138                 return;
  139         }
  140 
  141         if (eisa_conf_read_irq(ea->ea_ec, ea->ea_slot,
  142             DEPCA_ECU_FUNC_NETINTR, 0, &eci) != 0) {
  143                 aprint_error_dev(self, "unable to determine IRQ\n");
  144                 return;
  145         }
  146 
  147         esc->sc_irq = eci.eci_irq;
  148         esc->sc_ist = eci.eci_ist;
  149 
  150         depca_attach(sc);
  151 }
  152 
  153 static void *
  154 depca_eisa_intr_establish(struct depca_softc *parent, struct lance_softc *child)
  155 {
  156         struct depca_eisa_softc *esc = (struct depca_eisa_softc *)parent;
  157         eisa_intr_handle_t ih;
  158         const char *intrstr;
  159         void *rv;
  160 
  161         if (eisa_intr_map(esc->sc_ec, esc->sc_irq, &ih)) {
  162                 aprint_error_dev(parent->sc_dev,
  163                     "unable to map interrupt (%d)\n", esc->sc_irq);
  164                 return (NULL);
  165         }
  166         intrstr = eisa_intr_string(esc->sc_ec, ih);
  167         rv = eisa_intr_establish(esc->sc_ec, ih, esc->sc_ist, IPL_NET,
  168             (esc->sc_ist == IST_LEVEL) ? am7990_intr : depca_intredge, child);
  169         if (rv == NULL) {
  170                 aprint_error_dev(parent->sc_dev,
  171                     "unable to establish interrupt");
  172                 if (intrstr != NULL)
  173                         aprint_error(" at %s", intrstr);
  174                 aprint_error("\n");
  175                 return (NULL);
  176         }
  177         if (intrstr != NULL)
  178                 aprint_normal_dev(parent->sc_dev, "interrupting at %s\n",
  179                     intrstr);
  180 
  181         return (rv);
  182 }

Cache object: 43e78b57040598ed5041f08d9eda1ee7


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.