if_le.c revision 1.34.8.3 1 1.34.8.3 nathanw /* $NetBSD: if_le.c,v 1.34.8.3 2002/10/18 02:34:58 nathanw Exp $ */
2 1.34.8.2 nathanw
3 1.34.8.2 nathanw /*-
4 1.34.8.2 nathanw * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 1.34.8.2 nathanw * All rights reserved.
6 1.34.8.2 nathanw *
7 1.34.8.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.34.8.2 nathanw * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
9 1.34.8.2 nathanw * Simulation Facility, NASA Ames Research Center.
10 1.34.8.2 nathanw *
11 1.34.8.2 nathanw * Redistribution and use in source and binary forms, with or without
12 1.34.8.2 nathanw * modification, are permitted provided that the following conditions
13 1.34.8.2 nathanw * are met:
14 1.34.8.2 nathanw * 1. Redistributions of source code must retain the above copyright
15 1.34.8.2 nathanw * notice, this list of conditions and the following disclaimer.
16 1.34.8.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
17 1.34.8.2 nathanw * notice, this list of conditions and the following disclaimer in the
18 1.34.8.2 nathanw * documentation and/or other materials provided with the distribution.
19 1.34.8.2 nathanw * 3. All advertising materials mentioning features or use of this software
20 1.34.8.2 nathanw * must display the following acknowledgement:
21 1.34.8.2 nathanw * This product includes software developed by the NetBSD
22 1.34.8.2 nathanw * Foundation, Inc. and its contributors.
23 1.34.8.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.34.8.2 nathanw * contributors may be used to endorse or promote products derived
25 1.34.8.2 nathanw * from this software without specific prior written permission.
26 1.34.8.2 nathanw *
27 1.34.8.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.34.8.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.34.8.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.34.8.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.34.8.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.34.8.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.34.8.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.34.8.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.34.8.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.34.8.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.34.8.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
38 1.34.8.2 nathanw */
39 1.34.8.2 nathanw
40 1.34.8.2 nathanw /*-
41 1.34.8.2 nathanw * Copyright (c) 1997 Bernd Ernesti. All rights reserved.
42 1.34.8.2 nathanw * Copyright (c) 1992, 1993
43 1.34.8.2 nathanw * The Regents of the University of California. All rights reserved.
44 1.34.8.2 nathanw *
45 1.34.8.2 nathanw * This code is derived from software contributed to Berkeley by
46 1.34.8.2 nathanw * Ralph Campbell and Rick Macklem.
47 1.34.8.2 nathanw *
48 1.34.8.2 nathanw * Redistribution and use in source and binary forms, with or without
49 1.34.8.2 nathanw * modification, are permitted provided that the following conditions
50 1.34.8.2 nathanw * are met:
51 1.34.8.2 nathanw * 1. Redistributions of source code must retain the above copyright
52 1.34.8.2 nathanw * notice, this list of conditions and the following disclaimer.
53 1.34.8.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
54 1.34.8.2 nathanw * notice, this list of conditions and the following disclaimer in the
55 1.34.8.2 nathanw * documentation and/or other materials provided with the distribution.
56 1.34.8.2 nathanw * 3. All advertising materials mentioning features or use of this software
57 1.34.8.2 nathanw * must display the following acknowledgement:
58 1.34.8.2 nathanw * This product includes software developed for the NetBSD Project
59 1.34.8.2 nathanw * by Bernd Ernesti.
60 1.34.8.2 nathanw * This product includes software developed by the University of
61 1.34.8.2 nathanw * California, Berkeley and its contributors.
62 1.34.8.2 nathanw * 4. Neither the name of the University nor the names of its contributors
63 1.34.8.2 nathanw * may be used to endorse or promote products derived from this software
64 1.34.8.2 nathanw * without specific prior written permission.
65 1.34.8.2 nathanw *
66 1.34.8.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
67 1.34.8.2 nathanw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
68 1.34.8.2 nathanw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
69 1.34.8.2 nathanw * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
70 1.34.8.2 nathanw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
71 1.34.8.2 nathanw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
72 1.34.8.2 nathanw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
73 1.34.8.2 nathanw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
74 1.34.8.2 nathanw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
75 1.34.8.2 nathanw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
76 1.34.8.2 nathanw * SUCH DAMAGE.
77 1.34.8.2 nathanw *
78 1.34.8.2 nathanw * @(#)if_le.c 8.2 (Berkeley) 11/16/93
79 1.34.8.2 nathanw */
80 1.34.8.2 nathanw
81 1.34.8.2 nathanw #include "opt_inet.h"
82 1.34.8.2 nathanw
83 1.34.8.2 nathanw #include <sys/cdefs.h>
84 1.34.8.3 nathanw __KERNEL_RCSID(0, "$NetBSD: if_le.c,v 1.34.8.3 2002/10/18 02:34:58 nathanw Exp $");
85 1.34.8.2 nathanw
86 1.34.8.2 nathanw #include "bpfilter.h"
87 1.34.8.2 nathanw
88 1.34.8.2 nathanw #include <sys/param.h>
89 1.34.8.2 nathanw #include <sys/systm.h>
90 1.34.8.2 nathanw #include <sys/mbuf.h>
91 1.34.8.2 nathanw #include <sys/syslog.h>
92 1.34.8.2 nathanw #include <sys/socket.h>
93 1.34.8.2 nathanw #include <sys/device.h>
94 1.34.8.2 nathanw
95 1.34.8.2 nathanw #include <net/if.h>
96 1.34.8.2 nathanw #include <net/if_ether.h>
97 1.34.8.2 nathanw #include <net/if_media.h>
98 1.34.8.2 nathanw
99 1.34.8.2 nathanw #ifdef INET
100 1.34.8.2 nathanw #include <netinet/in.h>
101 1.34.8.2 nathanw #include <netinet/if_inarp.h>
102 1.34.8.2 nathanw #endif
103 1.34.8.2 nathanw
104 1.34.8.2 nathanw #include <machine/cpu.h>
105 1.34.8.2 nathanw #include <machine/mtpr.h>
106 1.34.8.2 nathanw
107 1.34.8.2 nathanw #include <amiga/amiga/device.h>
108 1.34.8.2 nathanw #include <amiga/amiga/isr.h>
109 1.34.8.2 nathanw
110 1.34.8.2 nathanw #include <dev/ic/lancereg.h>
111 1.34.8.2 nathanw #include <dev/ic/lancevar.h>
112 1.34.8.2 nathanw #include <dev/ic/am7990reg.h>
113 1.34.8.2 nathanw #include <dev/ic/am7990var.h>
114 1.34.8.2 nathanw
115 1.34.8.2 nathanw #include <amiga/dev/zbusvar.h>
116 1.34.8.2 nathanw #include <amiga/dev/if_levar.h>
117 1.34.8.2 nathanw
118 1.34.8.2 nathanw int le_zbus_match(struct device *, struct cfdata *, void *);
119 1.34.8.2 nathanw void le_zbus_attach(struct device *, struct device *, void *);
120 1.34.8.2 nathanw
121 1.34.8.3 nathanw CFATTACH_DECL(le_zbus, sizeof(struct le_softc),
122 1.34.8.3 nathanw le_zbus_match, le_zbus_attach, NULL, NULL);
123 1.34.8.2 nathanw
124 1.34.8.2 nathanw #if defined(_KERNEL_OPT)
125 1.34.8.2 nathanw #include "opt_ddb.h"
126 1.34.8.2 nathanw #endif
127 1.34.8.2 nathanw
128 1.34.8.2 nathanw #ifdef DDB
129 1.34.8.2 nathanw #define integrate
130 1.34.8.2 nathanw #define hide
131 1.34.8.2 nathanw #else
132 1.34.8.2 nathanw #define integrate static __inline
133 1.34.8.2 nathanw #define hide static
134 1.34.8.2 nathanw #endif
135 1.34.8.2 nathanw
136 1.34.8.2 nathanw hide void lepcnet_reset(struct lance_softc *);
137 1.34.8.2 nathanw hide void lewrcsr(struct lance_softc *, u_int16_t, u_int16_t);
138 1.34.8.2 nathanw hide u_int16_t lerdcsr(struct lance_softc *, u_int16_t);
139 1.34.8.2 nathanw
140 1.34.8.2 nathanw hide u_int16_t ariadne_swapreg(u_int16_t);
141 1.34.8.2 nathanw hide void ariadne_wrcsr(struct lance_softc *, u_int16_t, u_int16_t);
142 1.34.8.2 nathanw hide u_int16_t ariadne_rdcsr(struct lance_softc *, u_int16_t);
143 1.34.8.2 nathanw hide void ariadne_wribcr(struct lance_softc *, u_int16_t, u_int16_t);
144 1.34.8.2 nathanw integrate void ariadne_copytodesc_word(struct lance_softc *, void *, int, int);
145 1.34.8.2 nathanw integrate void ariadne_copyfromdesc_word(struct lance_softc *, void *,
146 1.34.8.2 nathanw int, int);
147 1.34.8.2 nathanw integrate void ariadne_copytobuf_word(struct lance_softc *, void *, int, int);
148 1.34.8.2 nathanw integrate void ariadne_copyfrombuf_word(struct lance_softc *, void *, int, int);
149 1.34.8.2 nathanw integrate void ariadne_zerobuf_word(struct lance_softc *, int, int);
150 1.34.8.2 nathanw void ariadne_autoselect(struct lance_softc *, int);
151 1.34.8.2 nathanw int ariadne_mediachange(struct lance_softc *);
152 1.34.8.2 nathanw void ariadne_hwinit(struct lance_softc *);
153 1.34.8.2 nathanw
154 1.34.8.2 nathanw /*
155 1.34.8.2 nathanw * Media types supported by the Ariadne.
156 1.34.8.2 nathanw */
157 1.34.8.2 nathanw int lemedia_ariadne[] = {
158 1.34.8.2 nathanw IFM_ETHER | IFM_10_T,
159 1.34.8.2 nathanw IFM_ETHER | IFM_10_2,
160 1.34.8.2 nathanw IFM_ETHER | IFM_AUTO,
161 1.34.8.2 nathanw };
162 1.34.8.2 nathanw #define NLEMEDIA_ARIADNE (sizeof(lemedia_ariadne) / sizeof(lemedia_ariadne[0]))
163 1.34.8.2 nathanw
164 1.34.8.2 nathanw
165 1.34.8.2 nathanw hide u_int16_t
166 1.34.8.2 nathanw ariadne_swapreg(u_int16_t val)
167 1.34.8.2 nathanw {
168 1.34.8.2 nathanw
169 1.34.8.2 nathanw return (((val & 0xff) << 8 ) | (( val >> 8) & 0xff));
170 1.34.8.2 nathanw }
171 1.34.8.2 nathanw
172 1.34.8.2 nathanw hide void
173 1.34.8.2 nathanw ariadne_wrcsr(struct lance_softc *sc, u_int16_t port, u_int16_t val)
174 1.34.8.2 nathanw {
175 1.34.8.2 nathanw struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
176 1.34.8.2 nathanw
177 1.34.8.2 nathanw ler1->ler1_rap = ariadne_swapreg(port);
178 1.34.8.2 nathanw ler1->ler1_rdp = ariadne_swapreg(val);
179 1.34.8.2 nathanw }
180 1.34.8.2 nathanw
181 1.34.8.2 nathanw hide u_int16_t
182 1.34.8.2 nathanw ariadne_rdcsr(struct lance_softc *sc, u_int16_t port)
183 1.34.8.2 nathanw {
184 1.34.8.2 nathanw struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
185 1.34.8.2 nathanw u_int16_t val;
186 1.34.8.2 nathanw
187 1.34.8.2 nathanw ler1->ler1_rap = ariadne_swapreg(port);
188 1.34.8.2 nathanw val = ariadne_swapreg(ler1->ler1_rdp);
189 1.34.8.2 nathanw return (val);
190 1.34.8.2 nathanw }
191 1.34.8.2 nathanw
192 1.34.8.2 nathanw hide void
193 1.34.8.2 nathanw ariadne_wribcr(struct lance_softc *sc, u_int16_t port, u_int16_t val)
194 1.34.8.2 nathanw {
195 1.34.8.2 nathanw struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
196 1.34.8.2 nathanw
197 1.34.8.2 nathanw ler1->ler1_rap = ariadne_swapreg(port);
198 1.34.8.2 nathanw ler1->ler1_idp = ariadne_swapreg(val);
199 1.34.8.2 nathanw }
200 1.34.8.2 nathanw
201 1.34.8.2 nathanw hide void
202 1.34.8.2 nathanw lewrcsr(struct lance_softc *sc, u_int16_t port, u_int16_t val)
203 1.34.8.2 nathanw {
204 1.34.8.2 nathanw struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
205 1.34.8.2 nathanw
206 1.34.8.2 nathanw ler1->ler1_rap = port;
207 1.34.8.2 nathanw ler1->ler1_rdp = val;
208 1.34.8.2 nathanw }
209 1.34.8.2 nathanw
210 1.34.8.2 nathanw hide u_int16_t
211 1.34.8.2 nathanw lerdcsr(struct lance_softc *sc, u_int16_t port)
212 1.34.8.2 nathanw {
213 1.34.8.2 nathanw struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
214 1.34.8.2 nathanw u_int16_t val;
215 1.34.8.2 nathanw
216 1.34.8.2 nathanw ler1->ler1_rap = port;
217 1.34.8.2 nathanw val = ler1->ler1_rdp;
218 1.34.8.2 nathanw return (val);
219 1.34.8.2 nathanw }
220 1.34.8.2 nathanw
221 1.34.8.2 nathanw hide void
222 1.34.8.2 nathanw lepcnet_reset(struct lance_softc *sc)
223 1.34.8.2 nathanw {
224 1.34.8.2 nathanw struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
225 1.34.8.2 nathanw volatile int dummy;
226 1.34.8.2 nathanw
227 1.34.8.2 nathanw dummy = ler1->ler1_reset; /* Reset PCNet-ISA */
228 1.34.8.2 nathanw }
229 1.34.8.2 nathanw
230 1.34.8.2 nathanw void
231 1.34.8.2 nathanw ariadne_autoselect(struct lance_softc *sc, int on)
232 1.34.8.2 nathanw {
233 1.34.8.2 nathanw
234 1.34.8.2 nathanw /*
235 1.34.8.2 nathanw * on = 0: autoselect disabled
236 1.34.8.2 nathanw * on = 1: autoselect enabled
237 1.34.8.2 nathanw */
238 1.34.8.2 nathanw if (on == 0)
239 1.34.8.2 nathanw ariadne_wribcr(sc, LE_BCR_MC, 0x0000);
240 1.34.8.2 nathanw else
241 1.34.8.2 nathanw ariadne_wribcr(sc, LE_BCR_MC, LE_MC_ASEL);
242 1.34.8.2 nathanw }
243 1.34.8.2 nathanw
244 1.34.8.2 nathanw int
245 1.34.8.2 nathanw ariadne_mediachange(struct lance_softc *sc)
246 1.34.8.2 nathanw {
247 1.34.8.2 nathanw struct ifmedia *ifm = &sc->sc_media;
248 1.34.8.2 nathanw
249 1.34.8.2 nathanw if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
250 1.34.8.2 nathanw return (EINVAL);
251 1.34.8.2 nathanw
252 1.34.8.2 nathanw /*
253 1.34.8.2 nathanw * Switch to the selected media. If autoselect is
254 1.34.8.2 nathanw * set, switch it on otherwise disable it. We'll
255 1.34.8.2 nathanw * switch to the other media when we detect loss of
256 1.34.8.2 nathanw * carrier.
257 1.34.8.2 nathanw */
258 1.34.8.2 nathanw switch (IFM_SUBTYPE(ifm->ifm_media)) {
259 1.34.8.2 nathanw case IFM_10_T:
260 1.34.8.2 nathanw sc->sc_initmodemedia = 1;
261 1.34.8.2 nathanw lance_init(&sc->sc_ethercom.ec_if);
262 1.34.8.2 nathanw break;
263 1.34.8.2 nathanw
264 1.34.8.2 nathanw case IFM_10_2:
265 1.34.8.2 nathanw sc->sc_initmodemedia = 0;
266 1.34.8.2 nathanw lance_init(&sc->sc_ethercom.ec_if);
267 1.34.8.2 nathanw break;
268 1.34.8.2 nathanw
269 1.34.8.2 nathanw case IFM_AUTO:
270 1.34.8.2 nathanw sc->sc_initmodemedia = 2;
271 1.34.8.2 nathanw ariadne_hwinit(sc);
272 1.34.8.2 nathanw break;
273 1.34.8.2 nathanw
274 1.34.8.2 nathanw default:
275 1.34.8.2 nathanw return (EINVAL);
276 1.34.8.2 nathanw }
277 1.34.8.2 nathanw
278 1.34.8.2 nathanw return (0);
279 1.34.8.2 nathanw }
280 1.34.8.2 nathanw
281 1.34.8.2 nathanw void
282 1.34.8.2 nathanw ariadne_hwinit(struct lance_softc *sc)
283 1.34.8.2 nathanw {
284 1.34.8.2 nathanw
285 1.34.8.2 nathanw /*
286 1.34.8.2 nathanw * Re-program LEDs to match meaning used on the Ariadne board.
287 1.34.8.2 nathanw */
288 1.34.8.2 nathanw ariadne_wribcr(sc, LE_BCR_LED1, 0x0090);
289 1.34.8.2 nathanw ariadne_wribcr(sc, LE_BCR_LED2, 0x0081);
290 1.34.8.2 nathanw ariadne_wribcr(sc, LE_BCR_LED3, 0x0084);
291 1.34.8.2 nathanw
292 1.34.8.2 nathanw /*
293 1.34.8.2 nathanw * Enabel/Disable auto selection
294 1.34.8.2 nathanw */
295 1.34.8.2 nathanw if (sc->sc_initmodemedia == 2)
296 1.34.8.2 nathanw ariadne_autoselect(sc, 1);
297 1.34.8.2 nathanw else
298 1.34.8.2 nathanw ariadne_autoselect(sc, 0);
299 1.34.8.2 nathanw }
300 1.34.8.2 nathanw
301 1.34.8.2 nathanw int
302 1.34.8.2 nathanw le_zbus_match(struct device *parent, struct cfdata *cfp, void *aux)
303 1.34.8.2 nathanw {
304 1.34.8.2 nathanw struct zbus_args *zap = aux;
305 1.34.8.2 nathanw
306 1.34.8.2 nathanw /* Commodore ethernet card */
307 1.34.8.2 nathanw if (zap->manid == 514 && zap->prodid == 112)
308 1.34.8.2 nathanw return (1);
309 1.34.8.2 nathanw
310 1.34.8.2 nathanw /* Ameristar ethernet card */
311 1.34.8.2 nathanw if (zap->manid == 1053 && zap->prodid == 1)
312 1.34.8.2 nathanw return (1);
313 1.34.8.2 nathanw
314 1.34.8.2 nathanw /* Ariadne ethernet card */
315 1.34.8.2 nathanw if (zap->manid == 2167 && zap->prodid == 201)
316 1.34.8.2 nathanw return (1);
317 1.34.8.2 nathanw
318 1.34.8.2 nathanw return (0);
319 1.34.8.2 nathanw }
320 1.34.8.2 nathanw
321 1.34.8.2 nathanw void
322 1.34.8.2 nathanw le_zbus_attach(struct device *parent, struct device *self, void *aux)
323 1.34.8.2 nathanw {
324 1.34.8.2 nathanw struct le_softc *lesc = (struct le_softc *)self;
325 1.34.8.2 nathanw struct lance_softc *sc = &lesc->sc_am7990.lsc;
326 1.34.8.2 nathanw struct zbus_args *zap = aux;
327 1.34.8.2 nathanw u_long ser;
328 1.34.8.2 nathanw
329 1.34.8.2 nathanw /* This has no effect on PCnet-ISA LANCE chips */
330 1.34.8.2 nathanw sc->sc_conf3 = LE_C3_BSWP;
331 1.34.8.2 nathanw
332 1.34.8.2 nathanw /*
333 1.34.8.2 nathanw * Manufacturer decides the 3 first bytes, i.e. ethernet vendor ID.
334 1.34.8.2 nathanw */
335 1.34.8.2 nathanw switch (zap->manid) {
336 1.34.8.2 nathanw case 514:
337 1.34.8.2 nathanw /* Commodore */
338 1.34.8.2 nathanw sc->sc_memsize = 32768;
339 1.34.8.2 nathanw sc->sc_enaddr[0] = 0x00;
340 1.34.8.2 nathanw sc->sc_enaddr[1] = 0x80;
341 1.34.8.2 nathanw sc->sc_enaddr[2] = 0x10;
342 1.34.8.2 nathanw lesc->sc_r1 = (struct lereg1 *)(0x4000 + (int)zap->va);
343 1.34.8.2 nathanw sc->sc_mem = (void *)(0x8000 + (int)zap->va);
344 1.34.8.2 nathanw sc->sc_addr = 0x8000;
345 1.34.8.2 nathanw sc->sc_copytodesc = lance_copytobuf_contig;
346 1.34.8.2 nathanw sc->sc_copyfromdesc = lance_copyfrombuf_contig;
347 1.34.8.2 nathanw sc->sc_copytobuf = lance_copytobuf_contig;
348 1.34.8.2 nathanw sc->sc_copyfrombuf = lance_copyfrombuf_contig;
349 1.34.8.2 nathanw sc->sc_zerobuf = lance_zerobuf_contig;
350 1.34.8.2 nathanw sc->sc_rdcsr = lerdcsr;
351 1.34.8.2 nathanw sc->sc_wrcsr = lewrcsr;
352 1.34.8.2 nathanw sc->sc_hwreset = NULL;
353 1.34.8.2 nathanw sc->sc_hwinit = NULL;
354 1.34.8.2 nathanw break;
355 1.34.8.2 nathanw
356 1.34.8.2 nathanw case 1053:
357 1.34.8.2 nathanw /* Ameristar */
358 1.34.8.2 nathanw sc->sc_memsize = 32768;
359 1.34.8.2 nathanw sc->sc_enaddr[0] = 0x00;
360 1.34.8.2 nathanw sc->sc_enaddr[1] = 0x00;
361 1.34.8.2 nathanw sc->sc_enaddr[2] = 0x9f;
362 1.34.8.2 nathanw lesc->sc_r1 = (struct lereg1 *)(0x4000 + (int)zap->va);
363 1.34.8.2 nathanw sc->sc_mem = (void *)(0x8000 + (int)zap->va);
364 1.34.8.2 nathanw sc->sc_addr = 0x8000;
365 1.34.8.2 nathanw sc->sc_copytodesc = lance_copytobuf_contig;
366 1.34.8.2 nathanw sc->sc_copyfromdesc = lance_copyfrombuf_contig;
367 1.34.8.2 nathanw sc->sc_copytobuf = lance_copytobuf_contig;
368 1.34.8.2 nathanw sc->sc_copyfrombuf = lance_copyfrombuf_contig;
369 1.34.8.2 nathanw sc->sc_zerobuf = lance_zerobuf_contig;
370 1.34.8.2 nathanw sc->sc_rdcsr = lerdcsr;
371 1.34.8.2 nathanw sc->sc_wrcsr = lewrcsr;
372 1.34.8.2 nathanw sc->sc_hwreset = NULL;
373 1.34.8.2 nathanw sc->sc_hwinit = NULL;
374 1.34.8.2 nathanw break;
375 1.34.8.2 nathanw
376 1.34.8.2 nathanw case 2167:
377 1.34.8.2 nathanw /* Village Tronic */
378 1.34.8.2 nathanw sc->sc_memsize = 32768;
379 1.34.8.2 nathanw sc->sc_enaddr[0] = 0x00;
380 1.34.8.2 nathanw sc->sc_enaddr[1] = 0x60;
381 1.34.8.2 nathanw sc->sc_enaddr[2] = 0x30;
382 1.34.8.2 nathanw lesc->sc_r1 = (struct lereg1 *)(0x0370 + (int)zap->va);
383 1.34.8.2 nathanw sc->sc_mem = (void *)(0x8000 + (int)zap->va);
384 1.34.8.2 nathanw sc->sc_addr = 0x8000;
385 1.34.8.2 nathanw sc->sc_copytodesc = ariadne_copytodesc_word;
386 1.34.8.2 nathanw sc->sc_copyfromdesc = ariadne_copyfromdesc_word;
387 1.34.8.2 nathanw sc->sc_copytobuf = ariadne_copytobuf_word;
388 1.34.8.2 nathanw sc->sc_copyfrombuf = ariadne_copyfrombuf_word;
389 1.34.8.2 nathanw sc->sc_zerobuf = ariadne_zerobuf_word;
390 1.34.8.2 nathanw sc->sc_rdcsr = ariadne_rdcsr;
391 1.34.8.2 nathanw sc->sc_wrcsr = ariadne_wrcsr;
392 1.34.8.2 nathanw sc->sc_hwreset = lepcnet_reset;
393 1.34.8.2 nathanw sc->sc_hwinit = ariadne_hwinit;
394 1.34.8.2 nathanw sc->sc_mediachange = ariadne_mediachange;
395 1.34.8.2 nathanw sc->sc_supmedia = lemedia_ariadne;
396 1.34.8.2 nathanw sc->sc_nsupmedia = NLEMEDIA_ARIADNE;
397 1.34.8.2 nathanw sc->sc_defaultmedia = IFM_ETHER | IFM_AUTO;
398 1.34.8.2 nathanw sc->sc_initmodemedia = 2;
399 1.34.8.2 nathanw break;
400 1.34.8.2 nathanw
401 1.34.8.2 nathanw default:
402 1.34.8.2 nathanw panic("le_zbus_attach: bad manid");
403 1.34.8.2 nathanw }
404 1.34.8.2 nathanw
405 1.34.8.2 nathanw /*
406 1.34.8.2 nathanw * Serial number for board is used as host ID.
407 1.34.8.2 nathanw */
408 1.34.8.2 nathanw ser = (u_long)zap->serno;
409 1.34.8.2 nathanw sc->sc_enaddr[3] = (ser >> 16) & 0xff;
410 1.34.8.2 nathanw sc->sc_enaddr[4] = (ser >> 8) & 0xff;
411 1.34.8.2 nathanw sc->sc_enaddr[5] = (ser ) & 0xff;
412 1.34.8.2 nathanw
413 1.34.8.2 nathanw am7990_config(&lesc->sc_am7990);
414 1.34.8.2 nathanw
415 1.34.8.2 nathanw lesc->sc_isr.isr_intr = am7990_intr;
416 1.34.8.2 nathanw lesc->sc_isr.isr_arg = sc;
417 1.34.8.2 nathanw lesc->sc_isr.isr_ipl = 2;
418 1.34.8.2 nathanw add_isr(&lesc->sc_isr);
419 1.34.8.2 nathanw }
420 1.34.8.2 nathanw
421 1.34.8.2 nathanw
422 1.34.8.2 nathanw integrate void
423 1.34.8.2 nathanw ariadne_copytodesc_word(struct lance_softc *sc, void *from, int boff, int len)
424 1.34.8.2 nathanw {
425 1.34.8.2 nathanw u_short *b1 = from;
426 1.34.8.2 nathanw volatile u_short *b2 = (u_short *)((u_char *)sc->sc_mem + boff);
427 1.34.8.2 nathanw
428 1.34.8.2 nathanw for (len >>= 1; len > 0; len--)
429 1.34.8.2 nathanw *b2++ = ariadne_swapreg(*b1++);
430 1.34.8.2 nathanw }
431 1.34.8.2 nathanw
432 1.34.8.2 nathanw integrate void
433 1.34.8.2 nathanw ariadne_copyfromdesc_word(struct lance_softc *sc, void *to, int boff, int len)
434 1.34.8.2 nathanw {
435 1.34.8.2 nathanw volatile u_short *b1 = (u_short *)((u_char *)sc->sc_mem + boff);
436 1.34.8.2 nathanw u_short *b2 = to;
437 1.34.8.2 nathanw
438 1.34.8.2 nathanw for (len >>= 1; len > 0; len--)
439 1.34.8.2 nathanw *b2++ = ariadne_swapreg(*b1++);
440 1.34.8.2 nathanw }
441 1.34.8.2 nathanw
442 1.34.8.2 nathanw #define isodd(n) ((n) & 1)
443 1.34.8.2 nathanw
444 1.34.8.2 nathanw integrate void
445 1.34.8.2 nathanw ariadne_copytobuf_word(struct lance_softc *sc, void *from, int boff, int len)
446 1.34.8.2 nathanw {
447 1.34.8.2 nathanw u_char *a1 = from;
448 1.34.8.2 nathanw volatile u_char *a2 = (u_char *)sc->sc_mem + boff;
449 1.34.8.2 nathanw u_short *b1;
450 1.34.8.2 nathanw volatile u_short *b2;
451 1.34.8.2 nathanw int i;
452 1.34.8.2 nathanw
453 1.34.8.2 nathanw if (len > 0 && isodd(boff)) {
454 1.34.8.2 nathanw /* adjust source pointer */
455 1.34.8.2 nathanw b1 = (u_short *)(a1 + 1);
456 1.34.8.2 nathanw /* compute aligned destination pointer */
457 1.34.8.2 nathanw b2 = (u_short *)(a2 + 1);
458 1.34.8.2 nathanw /* copy first unaligned byte to buf */
459 1.34.8.2 nathanw b2[-1] = (b2[-1] & 0xff00) | *a1;
460 1.34.8.2 nathanw --len;
461 1.34.8.2 nathanw } else {
462 1.34.8.2 nathanw /* destination is aligned or length is zero */
463 1.34.8.2 nathanw b1 = (u_short *)a1;
464 1.34.8.2 nathanw b2 = (u_short *)a2;
465 1.34.8.2 nathanw }
466 1.34.8.2 nathanw
467 1.34.8.2 nathanw /* copy full words with aligned destination */
468 1.34.8.2 nathanw for (i = len >> 1; i > 0; i--)
469 1.34.8.2 nathanw *b2++ = *b1++;
470 1.34.8.2 nathanw
471 1.34.8.2 nathanw /* copy remaining byte */
472 1.34.8.2 nathanw if (isodd(len))
473 1.34.8.2 nathanw *b2 = (*b2 & 0x00ff) | (*(u_char *)b1) << 8;
474 1.34.8.2 nathanw }
475 1.34.8.2 nathanw
476 1.34.8.2 nathanw integrate void
477 1.34.8.2 nathanw ariadne_copyfrombuf_word(struct lance_softc *sc, void *to, int boff, int len)
478 1.34.8.2 nathanw {
479 1.34.8.2 nathanw volatile u_char *a1 = (u_char *)sc->sc_mem + boff;
480 1.34.8.2 nathanw u_char *a2 = to;
481 1.34.8.2 nathanw volatile u_short *b1;
482 1.34.8.2 nathanw u_short *b2;
483 1.34.8.2 nathanw int i;
484 1.34.8.2 nathanw
485 1.34.8.2 nathanw if (len > 0 && isodd(boff)) {
486 1.34.8.2 nathanw /* compute aligned source pointer */
487 1.34.8.2 nathanw b1 = (u_short *)(a1 + 1);
488 1.34.8.2 nathanw /* adjust destination pointer (possibly unaligned) */
489 1.34.8.2 nathanw b2 = (u_short *)(a2 + 1);
490 1.34.8.2 nathanw /* copy first unaligned byte from buf */
491 1.34.8.2 nathanw *a2 = b1[-1];
492 1.34.8.2 nathanw --len;
493 1.34.8.2 nathanw } else {
494 1.34.8.2 nathanw /* source is aligned or length is zero */
495 1.34.8.2 nathanw b1 = (u_short *)a1;
496 1.34.8.2 nathanw b2 = (u_short *)a2;
497 1.34.8.2 nathanw }
498 1.34.8.2 nathanw
499 1.34.8.2 nathanw /* copy full words with aligned source */
500 1.34.8.2 nathanw for (i = len >> 1; i > 0; i--)
501 1.34.8.2 nathanw *b2++ = *b1++;
502 1.34.8.2 nathanw
503 1.34.8.2 nathanw /* copy remaining byte */
504 1.34.8.2 nathanw if (isodd(len))
505 1.34.8.2 nathanw *(u_char *)b2 = *b1 >> 8;
506 1.34.8.2 nathanw }
507 1.34.8.2 nathanw
508 1.34.8.2 nathanw integrate void
509 1.34.8.2 nathanw ariadne_zerobuf_word(struct lance_softc *sc, int boff, int len)
510 1.34.8.2 nathanw {
511 1.34.8.2 nathanw volatile u_char *a1 = (u_char *)sc->sc_mem + boff;
512 1.34.8.2 nathanw volatile u_short *b1;
513 1.34.8.2 nathanw int i;
514 1.34.8.2 nathanw
515 1.34.8.2 nathanw if (len > 0 && isodd(boff)) {
516 1.34.8.2 nathanw b1 = (u_short *)(a1 + 1);
517 1.34.8.2 nathanw b1[-1] &= 0xff00;
518 1.34.8.2 nathanw --len;
519 1.34.8.2 nathanw } else {
520 1.34.8.2 nathanw b1 = (u_short *)a1;
521 1.34.8.2 nathanw }
522 1.34.8.2 nathanw
523 1.34.8.2 nathanw for (i = len >> 1; i > 0; i--)
524 1.34.8.2 nathanw *b1++ = 0;
525 1.34.8.2 nathanw
526 1.34.8.2 nathanw if (isodd(len))
527 1.34.8.2 nathanw *b1 &= 0x00ff;
528 1.34.8.2 nathanw }
529