1 /* $NetBSD: lancevar.h,v 1.10 2005/12/11 12:21:27 christos 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 (struct lance_softc *, void *, int, int); 60 void (*sc_copyfromdesc) 61 (struct lance_softc *, void *, int, int); 62 void (*sc_copytobuf) 63 (struct lance_softc *, void *, int, int); 64 void (*sc_copyfrombuf) 65 (struct lance_softc *, void *, int, int); 66 void (*sc_zerobuf) 67 (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 (struct lance_softc *, u_int16_t); 80 void (*sc_wrcsr) 81 (struct lance_softc *, u_int16_t, u_int16_t); 82 void (*sc_hwreset)(struct lance_softc *); 83 void (*sc_hwinit)(struct lance_softc *); 84 void (*sc_nocarrier)(struct lance_softc *); 85 int (*sc_mediachange)(struct lance_softc *); 86 void (*sc_mediastatus)(struct lance_softc *, struct ifmediareq *); 87 88 /* 89 * Media-supported by this interface. If this is NULL, 90 * the only supported media is assumed to be "manual". 91 */ 92 const int *sc_supmedia; 93 int sc_nsupmedia; 94 int sc_defaultmedia; 95 96 /* PCnet bit to use software selection of a port */ 97 int sc_initmodemedia; 98 99 int sc_havecarrier; /* carrier status */ 100 101 void *sc_sh; /* shutdownhook cookie */ 102 103 u_int16_t sc_conf3; /* CSR3 value */ 104 u_int16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */ 105 106 void *sc_mem; /* base address of RAM -- CPU's view */ 107 u_long sc_addr; /* base address of RAM -- LANCE's view */ 108 109 u_long sc_memsize; /* size of RAM */ 110 111 int sc_nrbuf; /* number of receive buffers */ 112 int sc_ntbuf; /* number of transmit buffers */ 113 int sc_last_rd; 114 int sc_first_td, sc_last_td, sc_no_td; 115 116 int sc_initaddr; 117 int sc_rmdaddr; 118 int sc_tmdaddr; 119 int *sc_rbufaddr; 120 int *sc_tbufaddr; 121 122 #ifdef LEDEBUG 123 int sc_debug; 124 #endif 125 u_int8_t sc_enaddr[ETHER_ADDR_LEN]; 126 u_int8_t sc_pad[2]; 127 #if NRND > 0 128 rndsource_element_t rnd_source; 129 #endif 130 131 void (*sc_meminit)(struct lance_softc *); 132 void (*sc_start)(struct ifnet *); 133 }; 134 135 void lance_config(struct lance_softc *); 136 void lance_reset(struct lance_softc *); 137 int lance_init(struct ifnet *); 138 int lance_put(struct lance_softc *, int, struct mbuf *); 139 void lance_read(struct lance_softc *, int, int); 140 void lance_setladrf(struct ethercom *, u_int16_t *); 141 142 /* 143 * The following functions are only useful on certain CPU/bus 144 * combinations. They should be written in assembly language for 145 * maximum efficiency, but machine-independent versions are provided 146 * for drivers that have not yet been optimized. 147 */ 148 void lance_copytobuf_contig(struct lance_softc *, void *, int, int); 149 void lance_copyfrombuf_contig(struct lance_softc *, void *, int, int); 150 void lance_zerobuf_contig(struct lance_softc *, int, int); 151 152 #if 0 /* Example only - see lance.c */ 153 void lance_copytobuf_gap2(struct lance_softc *, void *, int, int); 154 void lance_copyfrombuf_gap2(struct lance_softc *, void *, int, int); 155 void lance_zerobuf_gap2(struct lance_softc *, int, int); 156 157 void lance_copytobuf_gap16(struct lance_softc *, void *, int, int); 158 void lance_copyfrombuf_gap16(struct lance_softc *, void *, int, int); 159 void lance_zerobuf_gap16(struct lance_softc *, int, int); 160 #endif /* Example only */ 161