Home | History | Annotate | Line # | Download | only in ic
am7990var.h revision 1.14
      1 /*	$NetBSD: am7990var.h,v 1.14 1997/10/05 18:35:08 thorpej Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1997 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 of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the NetBSD
     22  *	Foundation, Inc. and its contributors.
     23  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  *    contributors may be used to endorse or promote products derived
     25  *    from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 /*
     41  * Copyright (c) 1995 Charles M. Hannum.  All rights reserved.
     42  *
     43  * Redistribution and use in source and binary forms, with or without
     44  * modification, are permitted provided that the following conditions
     45  * are met:
     46  * 1. Redistributions of source code must retain the above copyright
     47  *    notice, this list of conditions and the following disclaimer.
     48  * 2. Redistributions in binary form must reproduce the above copyright
     49  *    notice, this list of conditions and the following disclaimer in the
     50  *    documentation and/or other materials provided with the distribution.
     51  * 3. All advertising materials mentioning features or use of this software
     52  *    must display the following acknowledgement:
     53  *	This product includes software developed by Charles M. Hannum.
     54  * 4. The name of the author may not be used to endorse or promote products
     55  *    derived from this software without specific prior written permission.
     56  *
     57  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     58  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     59  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     60  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     61  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     62  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     63  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     64  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     65  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     66  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     67  */
     68 
     69 #ifdef DDB
     70 #define	integrate
     71 #define hide
     72 #else
     73 #define	integrate	static __inline
     74 #define hide		static
     75 #endif
     76 
     77 /*
     78  * Ethernet software status per device.
     79  *
     80  * Each interface is referenced by a network interface structure,
     81  * ethercom.ec_if, which the routing code uses to locate the interface.
     82  * This structure contains the output queue for the interface, its address, ...
     83  *
     84  * NOTE: this structure MUST be the first element in machine-dependent
     85  * le_softc structures!  This is designed SPECIFICALLY to make it possible
     86  * to simply cast a "void *" to "struct le_softc *" or to
     87  * "struct am7990_softc *".  Among other things, this saves a lot of hair
     88  * in the interrupt handlers.
     89  */
     90 struct am7990_softc {
     91 	struct	device sc_dev;		/* base device glue */
     92 	struct	ethercom sc_ethercom;	/* Ethernet common part */
     93 	struct	ifmedia sc_media;	/* our supported media */
     94 
     95 	/*
     96 	 * Memory functions:
     97 	 *
     98 	 *	copy to/from descriptor
     99 	 *	copy to/from buffer
    100 	 *	zero bytes in buffer
    101 	 */
    102 	void	(*sc_copytodesc)
    103 		    __P((struct am7990_softc *, void *, int, int));
    104 	void	(*sc_copyfromdesc)
    105 		    __P((struct am7990_softc *, void *, int, int));
    106 	void	(*sc_copytobuf)
    107 		    __P((struct am7990_softc *, void *, int, int));
    108 	void	(*sc_copyfrombuf)
    109 		    __P((struct am7990_softc *, void *, int, int));
    110 	void	(*sc_zerobuf)
    111 		    __P((struct am7990_softc *, int, int));
    112 
    113 	/*
    114 	 * Machine-dependent functions:
    115 	 *
    116 	 *	read/write CSR
    117 	 *	hardware reset hook - may be NULL
    118 	 *	hardware init hook - may be NULL
    119 	 *	no carrier hook - may be NULL
    120 	 *	media change hook - may be NULL
    121 	 */
    122 	u_int16_t (*sc_rdcsr)
    123 		    __P((struct am7990_softc *, u_int16_t));
    124 	void	(*sc_wrcsr)
    125 		    __P((struct am7990_softc *, u_int16_t, u_int16_t));
    126 	void	(*sc_hwreset) __P((struct am7990_softc *));
    127 	void	(*sc_hwinit) __P((struct am7990_softc *));
    128 	void	(*sc_nocarrier) __P((struct am7990_softc *));
    129 	int	(*sc_mediachange) __P((struct am7990_softc *));
    130 	void	(*sc_mediastatus) __P((struct am7990_softc *,
    131 		    struct ifmediareq *));
    132 
    133 	/*
    134 	 * Media-supported by this interface.  If this is NULL,
    135 	 * the only supported media is assumed to be "manual".
    136 	 */
    137 	int	*sc_supmedia;
    138 	int	sc_nsupmedia;
    139 	int	sc_defaultmedia;
    140 
    141 	/* PCnet bit to use software selection of a port */
    142 	int	sc_initmodemedia;
    143 
    144 	int	sc_havecarrier;	/* carrier status */
    145 
    146 	void	*sc_sh;		/* shutdownhook cookie */
    147 
    148 	u_int16_t sc_conf3;	/* CSR3 value */
    149 	u_int16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */
    150 
    151 	void	*sc_mem;	/* base address of RAM -- CPU's view */
    152 	u_long	sc_addr;	/* base address of RAM -- LANCE's view */
    153 
    154 	u_long	sc_memsize;	/* size of RAM */
    155 
    156 	int	sc_nrbuf;	/* number of receive buffers */
    157 	int	sc_ntbuf;	/* number of transmit buffers */
    158 	int	sc_last_rd;
    159 	int	sc_first_td, sc_last_td, sc_no_td;
    160 
    161 	int	sc_initaddr;
    162 	int	sc_rmdaddr;
    163 	int	sc_tmdaddr;
    164 	int	*sc_rbufaddr;
    165 	int	*sc_tbufaddr;
    166 
    167 #ifdef LEDEBUG
    168 	int	sc_debug;
    169 #endif
    170 	u_int8_t sc_enaddr[6];
    171 	u_int8_t sc_pad[2];
    172 };
    173 
    174 /* Export this to machine-dependent drivers. */
    175 extern struct cfdriver le_cd;
    176 
    177 void am7990_config __P((struct am7990_softc *));
    178 void am7990_init __P((struct am7990_softc *));
    179 int am7990_ioctl __P((struct ifnet *, u_long, caddr_t));
    180 void am7990_meminit __P((struct am7990_softc *));
    181 void am7990_reset __P((struct am7990_softc *));
    182 void am7990_setladrf __P((struct ethercom *, u_int16_t *));
    183 void am7990_start __P((struct ifnet *));
    184 void am7990_stop __P((struct am7990_softc *));
    185 void am7990_watchdog __P((struct ifnet *));
    186 int am7990_intr __P((void *));
    187 
    188 /*
    189  * The following functions are only useful on certain cpu/bus
    190  * combinations.  They should be written in assembly language for
    191  * maximum efficiency, but machine-independent versions are provided
    192  * for drivers that have not yet been optimized.
    193  */
    194 void am7990_copytobuf_contig __P((struct am7990_softc *, void *, int, int));
    195 void am7990_copyfrombuf_contig __P((struct am7990_softc *, void *, int, int));
    196 void am7990_zerobuf_contig __P((struct am7990_softc *, int, int));
    197 
    198 #if 0	/* Example only - see am7990.c */
    199 void am7990_copytobuf_gap2 __P((struct am7990_softc *, void *, int, int));
    200 void am7990_copyfrombuf_gap2 __P((struct am7990_softc *, void *, int, int));
    201 void am7990_zerobuf_gap2 __P((struct am7990_softc *, int, int));
    202 
    203 void am7990_copytobuf_gap16 __P((struct am7990_softc *, void *, int, int));
    204 void am7990_copyfrombuf_gap16 __P((struct am7990_softc *, void *, int, int));
    205 void am7990_zerobuf_gap16 __P((struct am7990_softc *, int, int));
    206 #endif /* Example only */
    207