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/dec/if_le_dec.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: if_le_dec.c,v 1.13 2003/08/07 16:30:55 agc Exp $       */
    2 
    3 /*-
    4  * Copyright (c) 1992, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  *
    7  * This code is derived from software contributed to Berkeley by
    8  * Ralph Campbell and Rick Macklem.
    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  * 3. Neither the name of the University nor the names of its contributors
   19  *    may be used to endorse or promote products derived from this software
   20  *    without specific prior written permission.
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   32  * SUCH DAMAGE.
   33  *
   34  *      @(#)if_le.c     8.2 (Berkeley) 11/16/93
   35  */
   36 
   37 /*-
   38  * Copyright (c) 1997 Jonathan Stone. All rights reserved.
   39  * Copyright (c) 1995 Charles M. Hannum.  All rights reserved.
   40  *
   41  * This code is derived from software contributed to Berkeley by
   42  * Ralph Campbell and Rick Macklem.
   43  *
   44  * Redistribution and use in source and binary forms, with or without
   45  * modification, are permitted provided that the following conditions
   46  * are met:
   47  * 1. Redistributions of source code must retain the above copyright
   48  *    notice, this list of conditions and the following disclaimer.
   49  * 2. Redistributions in binary form must reproduce the above copyright
   50  *    notice, this list of conditions and the following disclaimer in the
   51  *    documentation and/or other materials provided with the distribution.
   52  * 3. All advertising materials mentioning features or use of this software
   53  *    must display the following acknowledgement:
   54  *      This product includes software developed by the University of
   55  *      California, Berkeley and its contributors.
   56  * 4. Neither the name of the University nor the names of its contributors
   57  *    may be used to endorse or promote products derived from this software
   58  *    without specific prior written permission.
   59  *
   60  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   61  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   62  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   63  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   64  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   65  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   66  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   67  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   68  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   69  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   70  * SUCH DAMAGE.
   71  *
   72  *      @(#)if_le.c     8.2 (Berkeley) 11/16/93
   73  */
   74 
   75 #include <sys/cdefs.h>
   76 __KERNEL_RCSID(0, "$NetBSD: if_le_dec.c,v 1.13 2003/08/07 16:30:55 agc Exp $");
   77 
   78 #include "opt_inet.h"
   79 #include "bpfilter.h"
   80 
   81 #include <sys/param.h>
   82 #include <sys/systm.h>
   83 #include <sys/mbuf.h>
   84 #include <sys/syslog.h>
   85 #include <sys/socket.h>
   86 #include <sys/device.h>
   87 
   88 #include <net/if.h>
   89 #include <net/if_ether.h>
   90 #include <net/if_media.h>
   91 
   92 #ifdef INET
   93 #include <netinet/in.h>
   94 #include <netinet/if_inarp.h>
   95 #endif
   96 
   97 #include <dev/ic/lancereg.h>
   98 #include <dev/ic/lancevar.h>
   99 #include <dev/ic/am7990reg.h>
  100 #include <dev/ic/am7990var.h>
  101 
  102 #include <dev/tc/if_levar.h>
  103 #include <dev/tc/tcvar.h>
  104 
  105 #include <machine/bus.h>
  106 
  107 /* access LANCE registers */
  108 void le_dec_writereg __P((volatile u_short *regptr, u_short val));
  109 #define LERDWR(cntl, src, dst)  { (dst) = (src); tc_mb(); }
  110 #define LEWREG(src, dst)        le_dec_writereg(&(dst), (src))
  111 
  112 #if defined(_KERNEL_OPT)
  113 #include "opt_ddb.h"
  114 #endif
  115 
  116 #ifdef DDB
  117 #define integrate
  118 #define hide
  119 #else
  120 #define integrate       static __inline
  121 #define hide            static
  122 #endif
  123 
  124 hide void le_dec_wrcsr __P((struct lance_softc *, u_int16_t, u_int16_t));
  125 hide u_int16_t le_dec_rdcsr __P((struct lance_softc *, u_int16_t));  
  126 
  127 void
  128 dec_le_common_attach(sc, eap)
  129         struct am7990_softc *sc;
  130         u_char *eap;
  131 {
  132         int i;
  133 
  134         sc->lsc.sc_rdcsr = le_dec_rdcsr;
  135         sc->lsc.sc_wrcsr = le_dec_wrcsr;
  136         sc->lsc.sc_hwinit = NULL;
  137 
  138         sc->lsc.sc_conf3 = 0;
  139         sc->lsc.sc_addr = 0;
  140         sc->lsc.sc_memsize = 65536;
  141 
  142         /*
  143          * Get the ethernet address out of rom
  144          */
  145         for (i = 0; i < sizeof(sc->lsc.sc_enaddr); i++) {
  146                 sc->lsc.sc_enaddr[i] = *eap;
  147                 eap += 4;
  148         }
  149 
  150         am7990_config(sc);
  151 }
  152 
  153 hide void
  154 le_dec_wrcsr(sc, port, val)
  155         struct lance_softc *sc;
  156         u_int16_t port, val;
  157 {
  158         struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
  159 
  160         LEWREG(port, ler1->ler1_rap);
  161         LERDWR(port, val, ler1->ler1_rdp);
  162 }
  163 
  164 hide u_int16_t
  165 le_dec_rdcsr(sc, port)
  166         struct lance_softc *sc;
  167         u_int16_t port;
  168 {
  169         struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
  170         u_int16_t val;
  171 
  172         LEWREG(port, ler1->ler1_rap);
  173         LERDWR(0, ler1->ler1_rdp, val);
  174         return (val);
  175 }
  176 
  177 /*
  178  * Write a lance register port, reading it back to ensure success. This seems
  179  * to be necessary during initialization, since the chip appears to be a bit
  180  * pokey sometimes.
  181  */
  182 void
  183 le_dec_writereg(regptr, val)
  184         register volatile u_short *regptr;
  185         register u_short val;
  186 {
  187         register int i = 0;
  188 
  189         while (*regptr != val) {
  190                 *regptr = val;
  191                 tc_mb();
  192                 if (++i > 10000) {
  193                         printf("le: Reg did not settle (to x%x): x%x\n", val,
  194                             *regptr);
  195                         return;
  196                 }
  197                 DELAY(100);
  198         }
  199 }
  200 
  201 /*
  202  * Routines for accessing the transmit and receive buffers are provided
  203  * by am7990.c, because of the LE_NEED_BUF_* macros defined above.
  204  * Unfortunately, CPU addressing of these buffers is done in one of
  205  * 3 ways:
  206  * - contiguous (for the 3max and turbochannel option card)
  207  * - gap2, which means shorts (2 bytes) interspersed with short (2 byte)
  208  *   spaces (for the pmax, vax 3400, and ioasic LANCE descriptors)
  209  * - gap16, which means 16bytes interspersed with 16byte spaces
  210  *   for buffers which must begin on a 32byte boundary (for 3min, maxine,
  211  *   and alpha)
  212  * The buffer offset is the logical byte offset, assuming contiguous storage.
  213  */

Cache object: 0b02bec99b708acb5f8a94e6c78de5fc


[ 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.