1 /* $NetBSD: lancevar.h,v 1.13 2009/09/04 16:21:24 tsutsui 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 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #include "rnd.h" 34 35 #if NRND > 0 36 #include <sys/rnd.h> 37 #endif 38 39 struct lance_softc { 40 device_t sc_dev; /* base device glue */ 41 struct ethercom sc_ethercom; /* Ethernet common part */ 42 struct ifmedia sc_media; /* our supported media */ 43 44 /* 45 * Memory functions: 46 * 47 * copy to/from descriptor 48 * copy to/from buffer 49 * zero bytes in buffer 50 */ 51 void (*sc_copytodesc) 52 (struct lance_softc *, void *, int, int); 53 void (*sc_copyfromdesc) 54 (struct lance_softc *, void *, int, int); 55 void (*sc_copytobuf) 56 (struct lance_softc *, void *, int, int); 57 void (*sc_copyfrombuf) 58 (struct lance_softc *, void *, int, int); 59 void (*sc_zerobuf) 60 (struct lance_softc *, int, int); 61 62 /* 63 * Machine-dependent functions: 64 * 65 * read/write CSR 66 * hardware reset hook - may be NULL 67 * hardware init hook - may be NULL 68 * no carrier hook - may be NULL 69 * media change hook - may be NULL 70 */ 71 uint16_t (*sc_rdcsr) 72 (struct lance_softc *, uint16_t); 73 void (*sc_wrcsr) 74 (struct lance_softc *, uint16_t, uint16_t); 75 void (*sc_hwreset)(struct lance_softc *); 76 void (*sc_hwinit)(struct lance_softc *); 77 void (*sc_nocarrier)(struct lance_softc *); 78 int (*sc_mediachange)(struct lance_softc *); 79 void (*sc_mediastatus)(struct lance_softc *, struct ifmediareq *); 80 81 /* 82 * Media-supported by this interface. If this is NULL, 83 * the only supported media is assumed to be "manual". 84 */ 85 const int *sc_supmedia; 86 int sc_nsupmedia; 87 int sc_defaultmedia; 88 89 /* PCnet bit to use software selection of a port */ 90 int sc_initmodemedia; 91 92 int sc_havecarrier; /* carrier status */ 93 94 uint16_t sc_conf3; /* CSR3 value */ 95 uint16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */ 96 97 void *sc_mem; /* base address of RAM -- CPU's view */ 98 u_long sc_addr; /* base address of RAM -- LANCE's view */ 99 100 u_long sc_memsize; /* size of RAM */ 101 102 int sc_nrbuf; /* number of receive buffers */ 103 int sc_ntbuf; /* number of transmit buffers */ 104 int sc_last_rd; 105 int sc_first_td, sc_last_td, sc_no_td; 106 107 int sc_initaddr; 108 int sc_rmdaddr; 109 int sc_tmdaddr; 110 int *sc_rbufaddr; 111 int *sc_tbufaddr; 112 113 #ifdef LEDEBUG 114 int sc_debug; 115 #endif 116 uint8_t sc_enaddr[ETHER_ADDR_LEN]; 117 uint8_t sc_pad[2]; 118 #if NRND > 0 119 rndsource_element_t rnd_source; 120 #endif 121 122 void (*sc_meminit)(struct lance_softc *); 123 void (*sc_start)(struct ifnet *); 124 }; 125 126 void lance_config(struct lance_softc *); 127 void lance_reset(struct lance_softc *); 128 int lance_init(struct ifnet *); 129 int lance_put(struct lance_softc *, int, struct mbuf *); 130 void lance_read(struct lance_softc *, int, int); 131 void lance_setladrf(struct ethercom *, uint16_t *); 132 133 /* 134 * The following functions are only useful on certain CPU/bus 135 * combinations. They should be written in assembly language for 136 * maximum efficiency, but machine-independent versions are provided 137 * for drivers that have not yet been optimized. 138 */ 139 void lance_copytobuf_contig(struct lance_softc *, void *, int, int); 140 void lance_copyfrombuf_contig(struct lance_softc *, void *, int, int); 141 void lance_zerobuf_contig(struct lance_softc *, int, int); 142 143 #if 0 /* Example only - see lance.c */ 144 void lance_copytobuf_gap2(struct lance_softc *, void *, int, int); 145 void lance_copyfrombuf_gap2(struct lance_softc *, void *, int, int); 146 void lance_zerobuf_gap2(struct lance_softc *, int, int); 147 148 void lance_copytobuf_gap16(struct lance_softc *, void *, int, int); 149 void lance_copyfrombuf_gap16(struct lance_softc *, void *, int, int); 150 void lance_zerobuf_gap16(struct lance_softc *, int, int); 151 #endif /* Example only */ 152