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