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