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/ic/dm9000var.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: dm9000var.h,v 1.7 2020/05/29 09:05:19 rin Exp $        */
    2 
    3 /*
    4  * Copyright (c) 2009 Paul Fleischer
    5  * All rights reserved.
    6  *
    7  * 1. Redistributions of source code must retain the above copyright
    8  *    notice, this list of conditions and the following disclaimer.
    9  * 2. Redistributions in binary form must reproduce the above copyright
   10  *    notice, this list of conditions and the following disclaimer in the
   11  *    documentation and/or other materials provided with the distribution.
   12  * 3. The name of the company nor the name of the author may be used to
   13  *    endorse or promote products derived from this software without specific
   14  *    prior written permission.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
   17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   19  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   22  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  */
   28 
   29 /* Based on sys/dev/ic/cs89x0var.h */
   30 /*
   31  * Copyright 1997
   32  * Digital Equipment Corporation. All rights reserved.
   33  *
   34  * This software is furnished under license and may be used and
   35  * copied only in accordance with the following terms and conditions.
   36  * Subject to these conditions, you may download, copy, install,
   37  * use, modify and distribute this software in source and/or binary
   38  * form. No title or ownership is transferred hereby.
   39  *
   40  * 1) Any source code used, modified or distributed must reproduce
   41  *    and retain this copyright notice and list of conditions as
   42  *    they appear in the source file.
   43  *
   44  * 2) No right is granted to use any trade name, trademark, or logo of
   45  *    Digital Equipment Corporation. Neither the "Digital Equipment
   46  *    Corporation" name nor any trademark or logo of Digital Equipment
   47  *    Corporation may be used to endorse or promote products derived
   48  *    from this software without the prior written permission of
   49  *    Digital Equipment Corporation.
   50  *
   51  * 3) This software is provided "AS-IS" and any express or implied
   52  *    warranties, including but not limited to, any implied warranties
   53  *    of merchantability, fitness for a particular purpose, or
   54  *    non-infringement are disclaimed. In no event shall DIGITAL be
   55  *    liable for any damages whatsoever, and in particular, DIGITAL
   56  *    shall not be liable for special, indirect, consequential, or
   57  *    incidental damages or damages for lost profits, loss of
   58  *    revenue or loss of use, whether such damages arise in contract,
   59  *    negligence, tort, under statute, in equity, at law or otherwise,
   60  *    even if advised of the possibility of such damage.
   61  */
   62 
   63 #ifndef _DEV_IC_DM9000VAR_H_
   64 #define _DEV_IC_DM9000VAR_H_
   65 
   66 #include <sys/callout.h>
   67 #include <sys/rndsource.h>
   68 
   69 #include <dev/mii/mii.h>
   70 #include <dev/mii/miivar.h>
   71 
   72 #define DM9000_MODE_8BIT 2
   73 #define DM9000_MODE_16BIT 0
   74 #define DM9000_MODE_32BIT 1
   75 
   76 struct dme_softc {
   77         device_t        sc_dev;         /* Generic Base Device */
   78         struct ethercom sc_ethercom;    /* Ethernet common data */
   79         struct mii_data sc_mii;         /* MII/media information */
   80         bus_space_tag_t         sc_iot;
   81         bus_space_handle_t      sc_ioh;
   82         void            *sc_ih;
   83 
   84         uint            dme_io;
   85         uint            dme_data;
   86 
   87         uint16_t        sc_vendor_id;
   88         uint16_t        sc_product_id;
   89 
   90         uint8_t         sc_data_width;
   91 
   92         uint8_t         sc_enaddr[ETHER_ADDR_LEN];
   93 
   94         int             txbusy;         /* A packet is being transmitted. */
   95         int             txready;        /* A packet has been sent to the DM9000
   96                                            for transmission. */
   97         uint16_t        txready_length;
   98 
   99         int (*sc_pkt_write)(struct dme_softc *, struct mbuf *);
  100         int (*sc_pkt_read)(struct dme_softc *, struct mbuf **);
  101 
  102         callout_t       sc_link_callout;
  103 
  104         bool            sc_phy_initialized;
  105 
  106 #ifdef DIAGNOSTIC
  107         bool            sc_inside_interrupt;
  108 #endif
  109         krndsource_t rnd_source;
  110 };
  111 
  112 /* Function declarations */
  113 int     dme_attach(struct dme_softc *, const uint8_t *);
  114 int     dme_detach(struct dme_softc *);
  115 int     dme_intr(void *);
  116 
  117 /* Inline memory access methods */
  118 static __inline uint8_t
  119 dme_read(struct dme_softc *sc, int reg)
  120 {
  121         bus_space_write_1(sc->sc_iot, sc->sc_ioh, sc->dme_io, reg);
  122         return (bus_space_read_1(sc->sc_iot, sc->sc_ioh, sc->dme_data));
  123 }
  124 
  125 static __inline void
  126 dme_write(struct dme_softc *sc, int reg, uint8_t value)
  127 {
  128         bus_space_write_1(sc->sc_iot, sc->sc_ioh, sc->dme_io, reg);
  129         bus_space_write_1(sc->sc_iot, sc->sc_ioh, sc->dme_data, value);
  130 }
  131 
  132 static __inline void
  133 dme_write2(struct dme_softc *sc, int reg, uint16_t value)
  134 {
  135         bus_space_write_1(sc->sc_iot, sc->sc_ioh, sc->dme_io, reg);
  136         bus_space_write_2(sc->sc_iot, sc->sc_ioh, sc->dme_data, value);
  137 }
  138 
  139 static __inline void
  140 dme_write_c(struct dme_softc *sc, int reg, const uint8_t value[], uint count)
  141 {
  142         for(int i=0; i<count; i++) {
  143                 dme_write(sc, reg+i, value[i]);
  144         }
  145 }
  146 
  147 static __inline void
  148 dme_read_c(struct dme_softc *sc, int reg, uint8_t *value, uint count)
  149 {
  150         for(int i=0; i<count; i++) {
  151                 value[i] = dme_read(sc, reg+i);
  152         }
  153 }
  154 
  155 #endif /* _DEV_IC_DM9000VAR_H_ */

Cache object: b4f107e4be33d08186229ca0bdee49b1


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