Home | History | Annotate | Line # | Download | only in ic
lancevar.h revision 1.5
      1 /*	$NetBSD: lancevar.h,v 1.5 2003/06/29 14:42:58 jdolecek Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
      9  * Simulation Facility, 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 #include "rnd.h"
     41 
     42 #if NRND > 0
     43 #include <sys/rnd.h>
     44 #endif
     45 
     46 struct lance_softc {
     47 	struct	device sc_dev;		/* base device glue */
     48 	struct	ethercom sc_ethercom;	/* Ethernet common part */
     49 	struct	ifmedia sc_media;	/* our supported media */
     50 
     51 	/*
     52 	 * Memory functions:
     53 	 *
     54 	 *	copy to/from descriptor
     55 	 *	copy to/from buffer
     56 	 *	zero bytes in buffer
     57 	 */
     58 	void	(*sc_copytodesc)
     59 		    __P((struct lance_softc *, void *, int, int));
     60 	void	(*sc_copyfromdesc)
     61 		    __P((struct lance_softc *, void *, int, int));
     62 	void	(*sc_copytobuf)
     63 		    __P((struct lance_softc *, void *, int, int));
     64 	void	(*sc_copyfrombuf)
     65 		    __P((struct lance_softc *, void *, int, int));
     66 	void	(*sc_zerobuf)
     67 		    __P((struct lance_softc *, int, int));
     68 
     69 	/*
     70 	 * Machine-dependent functions:
     71 	 *
     72 	 *	read/write CSR
     73 	 *	hardware reset hook - may be NULL
     74 	 *	hardware init hook - may be NULL
     75 	 *	no carrier hook - may be NULL
     76 	 *	media change hook - may be NULL
     77 	 */
     78 	u_int16_t (*sc_rdcsr)
     79 		    __P((struct lance_softc *, u_int16_t));
     80 	void	(*sc_wrcsr)
     81 		    __P((struct lance_softc *, u_int16_t, u_int16_t));
     82 	void	(*sc_hwreset) __P((struct lance_softc *));
     83 	void	(*sc_hwinit) __P((struct lance_softc *));
     84 	void	(*sc_nocarrier) __P((struct lance_softc *));
     85 	int	(*sc_mediachange) __P((struct lance_softc *));
     86 	void	(*sc_mediastatus) __P((struct lance_softc *,
     87 		    struct ifmediareq *));
     88 
     89 	/*
     90 	 * Media-supported by this interface.  If this is NULL,
     91 	 * the only supported media is assumed to be "manual".
     92 	 */
     93 	const int	*sc_supmedia;
     94 	int	sc_nsupmedia;
     95 	int	sc_defaultmedia;
     96 
     97 	/* PCnet bit to use software selection of a port */
     98 	int	sc_initmodemedia;
     99 
    100 	int	sc_havecarrier;	/* carrier status */
    101 
    102 	void	*sc_sh;		/* shutdownhook cookie */
    103 
    104 	u_int16_t sc_conf3;	/* CSR3 value */
    105 	u_int16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */
    106 
    107 	void	*sc_mem;	/* base address of RAM -- CPU's view */
    108 	u_long	sc_addr;	/* base address of RAM -- LANCE's view */
    109 
    110 	u_long	sc_memsize;	/* size of RAM */
    111 
    112 	int	sc_nrbuf;	/* number of receive buffers */
    113 	int	sc_ntbuf;	/* number of transmit buffers */
    114 	int	sc_last_rd;
    115 	int	sc_first_td, sc_last_td, sc_no_td;
    116 
    117 	int	sc_initaddr;
    118 	int	sc_rmdaddr;
    119 	int	sc_tmdaddr;
    120 	int	*sc_rbufaddr;
    121 	int	*sc_tbufaddr;
    122 
    123 #ifdef LEDEBUG
    124 	int	sc_debug;
    125 #endif
    126 	u_int8_t sc_enaddr[ETHER_ADDR_LEN];
    127 	u_int8_t sc_pad[2];
    128 #if NRND > 0
    129 	rndsource_element_t	rnd_source;
    130 #endif
    131 
    132 	void (*sc_meminit) __P((struct lance_softc *));
    133 	void (*sc_start) __P((struct ifnet *));
    134 };
    135 
    136 void lance_config __P((struct lance_softc *));
    137 void lance_reset __P((struct lance_softc *));
    138 int lance_init __P((struct ifnet *));
    139 int lance_put __P((struct lance_softc *, int, struct mbuf *));
    140 void lance_read __P((struct lance_softc *, int, int));
    141 void lance_setladrf __P((struct ethercom *, u_int16_t *));
    142 
    143 /*
    144  * The following functions are only useful on certain cpu/bus
    145  * combinations.  They should be written in assembly language for
    146  * maximum efficiency, but machine-independent versions are provided
    147  * for drivers that have not yet been optimized.
    148  */
    149 void lance_copytobuf_contig __P((struct lance_softc *, void *, int, int));
    150 void lance_copyfrombuf_contig __P((struct lance_softc *, void *, int, int));
    151 void lance_zerobuf_contig __P((struct lance_softc *, int, int));
    152 
    153 #if 0	/* Example only - see lance.c */
    154 void lance_copytobuf_gap2 __P((struct lance_softc *, void *, int, int));
    155 void lance_copyfrombuf_gap2 __P((struct lance_softc *, void *, int, int));
    156 void lance_zerobuf_gap2 __P((struct lance_softc *, int, int));
    157 
    158 void lance_copytobuf_gap16 __P((struct lance_softc *, void *, int, int));
    159 void lance_copyfrombuf_gap16 __P((struct lance_softc *, void *, int, int));
    160 void lance_zerobuf_gap16 __P((struct lance_softc *, int, int));
    161 #endif /* Example only */
    162