Home | History | Annotate | Line # | Download | only in ic
am7990var.h revision 1.16
      1 /*	$NetBSD: am7990var.h,v 1.16 1997/10/13 00:47:24 explorer 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 #include "rnd.h"
     70 
     71 #ifdef DDB
     72 #define	integrate
     73 #define hide
     74 #else
     75 #define	integrate	static __inline
     76 #define hide		static
     77 #endif
     78 
     79 #if NRND > 0
     80 #include <sys/rnd.h>
     81 #endif
     82 
     83 /*
     84  * Ethernet software status per device.
     85  *
     86  * Each interface is referenced by a network interface structure,
     87  * ethercom.ec_if, which the routing code uses to locate the interface.
     88  * This structure contains the output queue for the interface, its address, ...
     89  *
     90  * NOTE: this structure MUST be the first element in machine-dependent
     91  * le_softc structures!  This is designed SPECIFICALLY to make it possible
     92  * to simply cast a "void *" to "struct le_softc *" or to
     93  * "struct am7990_softc *".  Among other things, this saves a lot of hair
     94  * in the interrupt handlers.
     95  */
     96 struct am7990_softc {
     97 	struct	device sc_dev;		/* base device glue */
     98 	struct	ethercom sc_ethercom;	/* Ethernet common part */
     99 	struct	ifmedia sc_media;	/* our supported media */
    100 
    101 	/*
    102 	 * Memory functions:
    103 	 *
    104 	 *	copy to/from descriptor
    105 	 *	copy to/from buffer
    106 	 *	zero bytes in buffer
    107 	 */
    108 	void	(*sc_copytodesc)
    109 		    __P((struct am7990_softc *, void *, int, int));
    110 	void	(*sc_copyfromdesc)
    111 		    __P((struct am7990_softc *, void *, int, int));
    112 	void	(*sc_copytobuf)
    113 		    __P((struct am7990_softc *, void *, int, int));
    114 	void	(*sc_copyfrombuf)
    115 		    __P((struct am7990_softc *, void *, int, int));
    116 	void	(*sc_zerobuf)
    117 		    __P((struct am7990_softc *, int, int));
    118 
    119 	/*
    120 	 * Machine-dependent functions:
    121 	 *
    122 	 *	read/write CSR
    123 	 *	hardware reset hook - may be NULL
    124 	 *	hardware init hook - may be NULL
    125 	 *	no carrier hook - may be NULL
    126 	 *	media change hook - may be NULL
    127 	 */
    128 	u_int16_t (*sc_rdcsr)
    129 		    __P((struct am7990_softc *, u_int16_t));
    130 	void	(*sc_wrcsr)
    131 		    __P((struct am7990_softc *, u_int16_t, u_int16_t));
    132 	void	(*sc_hwreset) __P((struct am7990_softc *));
    133 	void	(*sc_hwinit) __P((struct am7990_softc *));
    134 	void	(*sc_nocarrier) __P((struct am7990_softc *));
    135 	int	(*sc_mediachange) __P((struct am7990_softc *));
    136 	void	(*sc_mediastatus) __P((struct am7990_softc *,
    137 		    struct ifmediareq *));
    138 
    139 	/*
    140 	 * Media-supported by this interface.  If this is NULL,
    141 	 * the only supported media is assumed to be "manual".
    142 	 */
    143 	int	*sc_supmedia;
    144 	int	sc_nsupmedia;
    145 	int	sc_defaultmedia;
    146 
    147 	/* PCnet bit to use software selection of a port */
    148 	int	sc_initmodemedia;
    149 
    150 	int	sc_havecarrier;	/* carrier status */
    151 
    152 	void	*sc_sh;		/* shutdownhook cookie */
    153 
    154 	u_int16_t sc_conf3;	/* CSR3 value */
    155 	u_int16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */
    156 
    157 	void	*sc_mem;	/* base address of RAM -- CPU's view */
    158 	u_long	sc_addr;	/* base address of RAM -- LANCE's view */
    159 
    160 	u_long	sc_memsize;	/* size of RAM */
    161 
    162 	int	sc_nrbuf;	/* number of receive buffers */
    163 	int	sc_ntbuf;	/* number of transmit buffers */
    164 	int	sc_last_rd;
    165 	int	sc_first_td, sc_last_td, sc_no_td;
    166 
    167 	int	sc_initaddr;
    168 	int	sc_rmdaddr;
    169 	int	sc_tmdaddr;
    170 	int	*sc_rbufaddr;
    171 	int	*sc_tbufaddr;
    172 
    173 #ifdef LEDEBUG
    174 	int	sc_debug;
    175 #endif
    176 	u_int8_t sc_enaddr[6];
    177 	u_int8_t sc_pad[2];
    178 #if NRND > 0
    179 	rndsource_element_t	rnd_source;
    180 #endif
    181 };
    182 
    183 /* Export this to machine-dependent drivers. */
    184 extern struct cfdriver le_cd;
    185 
    186 void am7990_config __P((struct am7990_softc *));
    187 void am7990_init __P((struct am7990_softc *));
    188 int am7990_ioctl __P((struct ifnet *, u_long, caddr_t));
    189 void am7990_meminit __P((struct am7990_softc *));
    190 void am7990_reset __P((struct am7990_softc *));
    191 void am7990_setladrf __P((struct ethercom *, u_int16_t *));
    192 void am7990_start __P((struct ifnet *));
    193 void am7990_stop __P((struct am7990_softc *));
    194 void am7990_watchdog __P((struct ifnet *));
    195 int am7990_intr __P((void *));
    196 
    197 /*
    198  * The following functions are only useful on certain cpu/bus
    199  * combinations.  They should be written in assembly language for
    200  * maximum efficiency, but machine-independent versions are provided
    201  * for drivers that have not yet been optimized.
    202  */
    203 void am7990_copytobuf_contig __P((struct am7990_softc *, void *, int, int));
    204 void am7990_copyfrombuf_contig __P((struct am7990_softc *, void *, int, int));
    205 void am7990_zerobuf_contig __P((struct am7990_softc *, int, int));
    206 
    207 #if 0	/* Example only - see am7990.c */
    208 void am7990_copytobuf_gap2 __P((struct am7990_softc *, void *, int, int));
    209 void am7990_copyfrombuf_gap2 __P((struct am7990_softc *, void *, int, int));
    210 void am7990_zerobuf_gap2 __P((struct am7990_softc *, int, int));
    211 
    212 void am7990_copytobuf_gap16 __P((struct am7990_softc *, void *, int, int));
    213 void am7990_copyfrombuf_gap16 __P((struct am7990_softc *, void *, int, int));
    214 void am7990_zerobuf_gap16 __P((struct am7990_softc *, int, int));
    215 #endif /* Example only */
    216