lancevar.h revision 1.1 1 /* $NetBSD: lancevar.h,v 1.1 1998/07/21 17:26:46 drochner 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 #if NRND > 0
72 #include <sys/rnd.h>
73 #endif
74
75 struct lance_softc {
76 struct device sc_dev; /* base device glue */
77 struct ethercom sc_ethercom; /* Ethernet common part */
78 struct ifmedia sc_media; /* our supported media */
79
80 /*
81 * Memory functions:
82 *
83 * copy to/from descriptor
84 * copy to/from buffer
85 * zero bytes in buffer
86 */
87 void (*sc_copytodesc)
88 __P((struct lance_softc *, void *, int, int));
89 void (*sc_copyfromdesc)
90 __P((struct lance_softc *, void *, int, int));
91 void (*sc_copytobuf)
92 __P((struct lance_softc *, void *, int, int));
93 void (*sc_copyfrombuf)
94 __P((struct lance_softc *, void *, int, int));
95 void (*sc_zerobuf)
96 __P((struct lance_softc *, int, int));
97
98 /*
99 * Machine-dependent functions:
100 *
101 * read/write CSR
102 * hardware reset hook - may be NULL
103 * hardware init hook - may be NULL
104 * no carrier hook - may be NULL
105 * media change hook - may be NULL
106 */
107 u_int16_t (*sc_rdcsr)
108 __P((struct lance_softc *, u_int16_t));
109 void (*sc_wrcsr)
110 __P((struct lance_softc *, u_int16_t, u_int16_t));
111 void (*sc_hwreset) __P((struct lance_softc *));
112 void (*sc_hwinit) __P((struct lance_softc *));
113 void (*sc_nocarrier) __P((struct lance_softc *));
114 int (*sc_mediachange) __P((struct lance_softc *));
115 void (*sc_mediastatus) __P((struct lance_softc *,
116 struct ifmediareq *));
117
118 /*
119 * Media-supported by this interface. If this is NULL,
120 * the only supported media is assumed to be "manual".
121 */
122 int *sc_supmedia;
123 int sc_nsupmedia;
124 int sc_defaultmedia;
125
126 /* PCnet bit to use software selection of a port */
127 int sc_initmodemedia;
128
129 int sc_havecarrier; /* carrier status */
130
131 void *sc_sh; /* shutdownhook cookie */
132
133 u_int16_t sc_conf3; /* CSR3 value */
134 u_int16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */
135
136 void *sc_mem; /* base address of RAM -- CPU's view */
137 u_long sc_addr; /* base address of RAM -- LANCE's view */
138
139 u_long sc_memsize; /* size of RAM */
140
141 int sc_nrbuf; /* number of receive buffers */
142 int sc_ntbuf; /* number of transmit buffers */
143 int sc_last_rd;
144 int sc_first_td, sc_last_td, sc_no_td;
145
146 int sc_initaddr;
147 int sc_rmdaddr;
148 int sc_tmdaddr;
149 int *sc_rbufaddr;
150 int *sc_tbufaddr;
151
152 #ifdef LEDEBUG
153 int sc_debug;
154 #endif
155 u_int8_t sc_enaddr[6];
156 u_int8_t sc_pad[2];
157 #if NRND > 0
158 rndsource_element_t rnd_source;
159 #endif
160
161 void (*sc_meminit) __P((struct lance_softc *));
162 void (*sc_start) __P((struct ifnet *));
163 };
164
165 void lance_config __P((struct lance_softc *));
166 void lance_reset __P((struct lance_softc *));
167 void lance_init __P((struct lance_softc *));
168 int lance_put __P((struct lance_softc *, int, struct mbuf *));
169 void lance_read __P((struct lance_softc *, int, int));
170 void lance_setladrf __P((struct ethercom *, u_int16_t *));
171
172 /*
173 * The following functions are only useful on certain cpu/bus
174 * combinations. They should be written in assembly language for
175 * maximum efficiency, but machine-independent versions are provided
176 * for drivers that have not yet been optimized.
177 */
178 void lance_copytobuf_contig __P((struct lance_softc *, void *, int, int));
179 void lance_copyfrombuf_contig __P((struct lance_softc *, void *, int, int));
180 void lance_zerobuf_contig __P((struct lance_softc *, int, int));
181
182 #if 0 /* Example only - see lance.c */
183 void lance_copytobuf_gap2 __P((struct lance_softc *, void *, int, int));
184 void lance_copyfrombuf_gap2 __P((struct lance_softc *, void *, int, int));
185 void lance_zerobuf_gap2 __P((struct lance_softc *, int, int));
186
187 void lance_copytobuf_gap16 __P((struct lance_softc *, void *, int, int));
188 void lance_copyfrombuf_gap16 __P((struct lance_softc *, void *, int, int));
189 void lance_zerobuf_gap16 __P((struct lance_softc *, int, int));
190 #endif /* Example only */
191