if_le_vme.c revision 1.17 1 /* $NetBSD: if_le_vme.c,v 1.17 2003/07/15 01:19:56 lukem Exp $ */
2
3 /*-
4 * Copyright (c) 1998 maximum entropy. All rights reserved.
5 * Copyright (c) 1997 Leo Weppelman. All rights reserved.
6 * Copyright (c) 1995 Charles M. Hannum. All rights reserved.
7 * Copyright (c) 1992, 1993
8 * The Regents of the University of California. All rights reserved.
9 *
10 * This code is derived from software contributed to Berkeley by
11 * Ralph Campbell and Rick Macklem.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by the University of
24 * California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 *
41 * @(#)if_le.c 8.2 (Berkeley) 11/16/93
42 */
43
44 #include <sys/cdefs.h>
45 __KERNEL_RCSID(0, "$NetBSD: if_le_vme.c,v 1.17 2003/07/15 01:19:56 lukem Exp $");
46
47 #include "opt_inet.h"
48 #include "bpfilter.h"
49
50 #include <sys/param.h>
51 #include <sys/systm.h>
52 #include <sys/mbuf.h>
53 #include <sys/syslog.h>
54 #include <sys/socket.h>
55 #include <sys/device.h>
56
57 #include <net/if.h>
58 #include <net/if_media.h>
59 #include <net/if_ether.h>
60
61 #ifdef INET
62 #include <netinet/in.h>
63 #include <netinet/if_inarp.h>
64 #endif
65
66 #include <machine/cpu.h>
67 #include <machine/bus.h>
68 #include <machine/iomap.h>
69 #include <machine/scu.h>
70
71 #include <atari/atari/device.h>
72 #include <atari/atari/intr.h>
73
74 #include <dev/ic/lancereg.h>
75 #include <dev/ic/lancevar.h>
76 #include <dev/ic/am7990reg.h>
77 #include <dev/ic/am7990var.h>
78
79 #include <atari/vme/vmevar.h>
80 #include <atari/vme/if_levar.h>
81
82 /*
83 * All cards except BVME410 have 64KB RAM. However.... On the Riebl cards the
84 * area between the offsets 0xee70-0xeec0 is used to store config data.
85 */
86 struct le_addresses {
87 u_long reg_addr;
88 u_long mem_addr;
89 int irq;
90 int reg_size;
91 int mem_size;
92 int type_hint;
93 } lestd[] = {
94 { 0xfe00fff0, 0xfe010000, IRQUNK, 16, 64*1024,
95 LE_OLD_RIEBL|LE_NEW_RIEBL }, /* Riebl */
96 { 0xffcffff0, 0xffcf0000, 5, 16, 64*1024,
97 LE_PAM }, /* PAM */
98 { 0xfecffff0, 0xfecf0000, 5, 16, 64*1024,
99 LE_ROTHRON }, /* Rhotron */
100 { 0xfeff4100, 0xfe000000, 4, 8, VMECF_MEMSIZ_DEFAULT,
101 LE_BVME410 } /* BVME410 */
102 };
103
104 #define NLESTD (sizeof(lestd) / sizeof(lestd[0]))
105
106 /*
107 * Default mac for RIEBL cards without a (working) battery. The first 4 bytes
108 * are the manufacturer id.
109 */
110 static u_char riebl_def_mac[] = {
111 0x00, 0x00, 0x36, 0x04, 0x00, 0x00
112 };
113
114 static int le_intr __P((struct le_softc *, int));
115 static void lepseudointr __P((struct le_softc *, void *));
116 static int le_vme_match __P((struct device *, struct cfdata *, void *));
117 static void le_vme_attach __P((struct device *, struct device *, void *));
118 static int probe_addresses __P((bus_space_tag_t *, bus_space_tag_t *,
119 bus_space_handle_t *, bus_space_handle_t *));
120 static void riebl_skip_reserved_area __P((struct lance_softc *));
121 static int nm93c06_read __P((bus_space_tag_t, bus_space_handle_t, int));
122 static int bvme410_probe __P((bus_space_tag_t, bus_space_handle_t));
123 static int bvme410_mem_size __P((bus_space_tag_t, u_long));
124 static void bvme410_copytobuf __P((struct lance_softc *, void *, int, int));
125 static void bvme410_zerobuf __P((struct lance_softc *, int, int));
126
127 CFATTACH_DECL(le_vme, sizeof(struct le_softc),
128 le_vme_match, le_vme_attach, NULL, NULL);
129
130 #if defined(_KERNEL_OPT)
131 #include "opt_ddb.h"
132 #endif
133
134 #ifdef DDB
135 #define integrate
136 #define hide
137 #else
138 #define integrate static __inline
139 #define hide static
140 #endif
141
142 hide void lewrcsr __P((struct lance_softc *, u_int16_t, u_int16_t));
143 hide u_int16_t lerdcsr __P((struct lance_softc *, u_int16_t));
144
145 hide void
146 lewrcsr(sc, port, val)
147 struct lance_softc *sc;
148 u_int16_t port, val;
149 {
150 struct le_softc *lesc = (struct le_softc *)sc;
151 int s;
152
153 s = splhigh();
154 bus_space_write_2(lesc->sc_iot, lesc->sc_ioh, LER_RAP, port);
155 bus_space_write_2(lesc->sc_iot, lesc->sc_ioh, LER_RDP, val);
156 splx(s);
157 }
158
159 hide u_int16_t
160 lerdcsr(sc, port)
161 struct lance_softc *sc;
162 u_int16_t port;
163 {
164 struct le_softc *lesc = (struct le_softc *)sc;
165 u_int16_t val;
166 int s;
167
168 s = splhigh();
169 bus_space_write_2(lesc->sc_iot, lesc->sc_ioh, LER_RAP, port);
170 val = bus_space_read_2(lesc->sc_iot, lesc->sc_ioh, LER_RDP);
171 splx(s);
172
173 return (val);
174 }
175
176 static int
177 le_vme_match(parent, cfp, aux)
178 struct device *parent;
179 struct cfdata *cfp;
180 void *aux;
181 {
182 struct vme_attach_args *va = aux;
183 int i;
184 bus_space_tag_t iot;
185 bus_space_tag_t memt;
186 bus_space_handle_t ioh;
187 bus_space_handle_t memh;
188
189 iot = va->va_iot;
190 memt = va->va_memt;
191
192 for (i = 0; i < NLESTD; i++) {
193 struct le_addresses *le_ap = &lestd[i];
194 int found = 0;
195
196 if ((va->va_iobase != IOBASEUNK)
197 && (va->va_iobase != le_ap->reg_addr))
198 continue;
199
200 if ((va->va_maddr != MADDRUNK)
201 && (va->va_maddr != le_ap->mem_addr))
202 continue;
203
204 if ((le_ap->irq != IRQUNK) && (va->va_irq != le_ap->irq))
205 continue;
206
207 if (bus_space_map(iot, le_ap->reg_addr, le_ap->reg_size, 0, &ioh)) {
208 printf("leprobe: cannot map io-area\n");
209 return (0);
210 }
211 if (le_ap->mem_size == VMECF_MEMSIZ_DEFAULT) {
212 if (bvme410_probe(iot, ioh)) {
213 bus_space_write_2(iot, ioh, BVME410_BAR, 0x1); /* XXX */
214 le_ap->mem_size = bvme410_mem_size(memt, le_ap->mem_addr);
215 }
216 }
217 if (le_ap->mem_size == VMECF_MEMSIZ_DEFAULT) {
218 bus_space_unmap(iot, ioh, le_ap->reg_size);
219 continue;
220 }
221
222 if (bus_space_map(memt, le_ap->mem_addr, le_ap->mem_size, 0, &memh)) {
223 bus_space_unmap(iot, ioh, le_ap->reg_size);
224 printf("leprobe: cannot map memory-area\n");
225 return (0);
226 }
227 found = probe_addresses(&iot, &memt, &ioh, &memh);
228 bus_space_unmap(iot, ioh, le_ap->reg_size);
229 bus_space_unmap(memt, memh, le_ap->mem_size);
230
231 if (found) {
232 va->va_iobase = le_ap->reg_addr;
233 va->va_iosize = le_ap->reg_size;
234 va->va_maddr = le_ap->mem_addr;
235 va->va_msize = le_ap->mem_size;
236 va->va_aux = le_ap;
237 if (va->va_irq == IRQUNK)
238 va->va_irq = le_ap->irq;
239 return 1;
240 }
241 }
242 return (0);
243 }
244
245 static int
246 probe_addresses(iot, memt, ioh, memh)
247 bus_space_tag_t *iot;
248 bus_space_tag_t *memt;
249 bus_space_handle_t *ioh;
250 bus_space_handle_t *memh;
251 {
252 /*
253 * Test accesibility of register and memory area
254 */
255 if(!bus_space_peek_2(*iot, *ioh, LER_RDP))
256 return 0;
257 if(!bus_space_peek_1(*memt, *memh, 0))
258 return 0;
259
260 /*
261 * Test for writable memory
262 */
263 bus_space_write_2(*memt, *memh, 0, 0xa5a5);
264 if (bus_space_read_2(*memt, *memh, 0) != 0xa5a5)
265 return 0;
266
267 /*
268 * Test writability of selector port.
269 */
270 bus_space_write_2(*iot, *ioh, LER_RAP, LE_CSR1);
271 if (bus_space_read_2(*iot, *ioh, LER_RAP) != LE_CSR1)
272 return 0;
273
274 /*
275 * Do a small register test
276 */
277 bus_space_write_2(*iot, *ioh, LER_RAP, LE_CSR0);
278 bus_space_write_2(*iot, *ioh, LER_RDP, LE_C0_INIT | LE_C0_STOP);
279 if (bus_space_read_2(*iot, *ioh, LER_RDP) != LE_C0_STOP)
280 return 0;
281
282 bus_space_write_2(*iot, *ioh, LER_RDP, LE_C0_STOP);
283 if (bus_space_read_2(*iot, *ioh, LER_RDP) != LE_C0_STOP)
284 return 0;
285
286 return 1;
287 }
288
289 /*
290 * Interrupt mess. Because the card's interrupt is hardwired to either
291 * ipl5 or ipl3 (mostly on ipl5) and raising splnet to spl5() just won't do
292 * (it kills the serial at the least), we use a 2-level interrupt scheme. The
293 * card interrupt is routed to 'le_intr'. If the previous ipl was below
294 * splnet, just call the mi-function. If not, save the interrupt status,
295 * turn off card interrupts (the card is *very* persistent) and arrange
296 * for a softint 'callback' through 'lepseudointr'.
297 */
298 static int
299 le_intr(lesc, sr)
300 struct le_softc *lesc;
301 int sr;
302 {
303 struct lance_softc *sc = &lesc->sc_am7990.lsc;
304 u_int16_t csr0;
305
306 if ((sr & PSL_IPL) < (IPL_NET & PSL_IPL))
307 am7990_intr(sc);
308 else {
309 sc->sc_saved_csr0 = csr0 = lerdcsr(sc, LE_CSR0);
310 lewrcsr(sc, LE_CSR0, csr0 & ~LE_C0_INEA);
311 add_sicallback((si_farg)lepseudointr, lesc, sc);
312 }
313 return 1;
314 }
315
316
317 static void
318 lepseudointr(lesc, sc)
319 struct le_softc *lesc;
320 void *sc;
321 {
322 int s;
323
324 s = splx(lesc->sc_splval);
325 am7990_intr(sc);
326 splx(s);
327 }
328
329 static void
330 le_vme_attach(parent, self, aux)
331 struct device *parent, *self;
332 void *aux;
333 {
334 struct le_softc *lesc = (struct le_softc *)self;
335 struct lance_softc *sc = &lesc->sc_am7990.lsc;
336 struct vme_attach_args *va = aux;
337 bus_space_handle_t ioh;
338 bus_space_handle_t memh;
339 struct le_addresses *le_ap;
340 int i;
341
342 printf("\n%s: ", sc->sc_dev.dv_xname);
343
344 if (bus_space_map(va->va_iot, va->va_iobase, va->va_iosize, 0, &ioh))
345 panic("leattach: cannot map io-area");
346 if (bus_space_map(va->va_memt, va->va_maddr, va->va_msize, 0, &memh))
347 panic("leattach: cannot map mem-area");
348
349 lesc->sc_iot = va->va_iot;
350 lesc->sc_ioh = ioh;
351 lesc->sc_memt = va->va_memt;
352 lesc->sc_memh = memh;
353 lesc->sc_splval = (va->va_irq << 8) | PSL_S; /* XXX */
354 le_ap = (struct le_addresses *)va->va_aux;
355
356 /*
357 * Go on to find board type
358 */
359 if ((le_ap->type_hint & LE_PAM)
360 && bus_space_peek_1(va->va_iot, ioh, LER_EEPROM)) {
361 printf("PAM card");
362 lesc->sc_type = LE_PAM;
363 bus_space_read_1(va->va_iot, ioh, LER_MEME);
364 }
365 else if((le_ap->type_hint & LE_BVME410)
366 && bvme410_probe(va->va_iot, ioh)) {
367 printf("BVME410");
368 lesc->sc_type = LE_BVME410;
369 }
370 else if (le_ap->type_hint & (LE_NEW_RIEBL|LE_OLD_RIEBL)) {
371 printf("Riebl card");
372 if(bus_space_read_4(va->va_memt, memh, RIEBL_MAGIC_ADDR)
373 == RIEBL_MAGIC)
374 lesc->sc_type = LE_NEW_RIEBL;
375 else {
376 printf("(without battery) ");
377 lesc->sc_type = LE_OLD_RIEBL;
378 }
379 }
380 else printf("le_vme_attach: Unsupported card!");
381
382 switch (lesc->sc_type) {
383 case LE_BVME410:
384 sc->sc_copytodesc = bvme410_copytobuf;
385 sc->sc_copyfromdesc = lance_copyfrombuf_contig;
386 sc->sc_copytobuf = bvme410_copytobuf;
387 sc->sc_copyfrombuf = lance_copyfrombuf_contig;
388 sc->sc_zerobuf = bvme410_zerobuf;
389 break;
390 default:
391 sc->sc_copytodesc = lance_copytobuf_contig;
392 sc->sc_copyfromdesc = lance_copyfrombuf_contig;
393 sc->sc_copytobuf = lance_copytobuf_contig;
394 sc->sc_copyfrombuf = lance_copyfrombuf_contig;
395 sc->sc_zerobuf = lance_zerobuf_contig;
396 break;
397 }
398
399 sc->sc_rdcsr = lerdcsr;
400 sc->sc_wrcsr = lewrcsr;
401 sc->sc_hwinit = NULL;
402 sc->sc_conf3 = LE_C3_BSWP;
403 sc->sc_addr = 0;
404 sc->sc_memsize = va->va_msize;
405 sc->sc_mem = (void *)memh; /* XXX */
406
407 /*
408 * Get MAC address
409 */
410 switch (lesc->sc_type) {
411 case LE_OLD_RIEBL:
412 bcopy(riebl_def_mac, sc->sc_enaddr,
413 sizeof(sc->sc_enaddr));
414 break;
415 case LE_NEW_RIEBL:
416 for (i = 0; i < sizeof(sc->sc_enaddr); i++)
417 sc->sc_enaddr[i] =
418 bus_space_read_1(va->va_memt, memh, i + RIEBL_MAC_ADDR);
419 break;
420 case LE_PAM:
421 i = bus_space_read_1(va->va_iot, ioh, LER_EEPROM);
422 for (i = 0; i < sizeof(sc->sc_enaddr); i++) {
423 sc->sc_enaddr[i] =
424 (bus_space_read_2(va->va_memt, memh, 2 * i) << 4) |
425 (bus_space_read_2(va->va_memt, memh, 2 * i + 1) & 0xf);
426 }
427 i = bus_space_read_1(va->va_iot, ioh, LER_MEME);
428 break;
429 case LE_BVME410:
430 for (i = 0; i < (sizeof(sc->sc_enaddr) >> 1); i++) {
431 u_int16_t tmp;
432
433 tmp = nm93c06_read(va->va_iot, ioh, i);
434 sc->sc_enaddr[2 * i] = (tmp >> 8) & 0xff;
435 sc->sc_enaddr[2 * i + 1] = tmp & 0xff;
436 }
437 bus_space_write_2(va->va_iot, ioh, BVME410_BAR, 0x1); /* XXX */
438 }
439
440 am7990_config(&lesc->sc_am7990);
441
442 if ((lesc->sc_type == LE_OLD_RIEBL) || (lesc->sc_type == LE_NEW_RIEBL))
443 riebl_skip_reserved_area(sc);
444
445 /*
446 * XXX: We always use uservector 64....
447 */
448 if ((lesc->sc_intr = intr_establish(64, USER_VEC, 0,
449 (hw_ifun_t)le_intr, lesc)) == NULL) {
450 printf("le_vme_attach: Can't establish interrupt\n");
451 return;
452 }
453
454 /*
455 * Notify the card of the vector
456 */
457 switch (lesc->sc_type) {
458 case LE_OLD_RIEBL:
459 case LE_NEW_RIEBL:
460 bus_space_write_2(va->va_memt, memh, RIEBL_IVEC_ADDR,
461 64 + 64);
462 break;
463 case LE_PAM:
464 bus_space_write_1(va->va_iot, ioh, LER_IVEC, 64 + 64);
465 break;
466 case LE_BVME410:
467 bus_space_write_2(va->va_iot, ioh, BVME410_IVEC, 64 + 64);
468 break;
469 }
470
471 /*
472 * Unmask the VME-interrupt we're on
473 */
474 if (machineid & ATARI_TT)
475 SCU->vme_mask |= 1 << va->va_irq;
476 }
477
478 /*
479 * True if 'addr' containe within [start,len]
480 */
481 #define WITHIN(start, len, addr) \
482 ((addr >= start) && ((addr) <= ((start) + (len))))
483 static void
484 riebl_skip_reserved_area(sc)
485 struct lance_softc *sc;
486 {
487 int offset = 0;
488 int i;
489
490 for(i = 0; i < sc->sc_nrbuf; i++) {
491 if (WITHIN(sc->sc_rbufaddr[i], LEBLEN, RIEBL_RES_START)
492 || WITHIN(sc->sc_rbufaddr[i], LEBLEN, RIEBL_RES_END)) {
493 offset = RIEBL_RES_END - sc->sc_rbufaddr[i];
494 }
495 sc->sc_rbufaddr[i] += offset;
496 }
497
498 for(i = 0; i < sc->sc_ntbuf; i++) {
499 if (WITHIN(sc->sc_tbufaddr[i], LEBLEN, RIEBL_RES_START)
500 || WITHIN(sc->sc_tbufaddr[i], LEBLEN, RIEBL_RES_END)) {
501 offset = RIEBL_RES_END - sc->sc_tbufaddr[i];
502 }
503 sc->sc_tbufaddr[i] += offset;
504 }
505 }
506
507 static int
508 nm93c06_read(iot, ioh, nm93c06reg)
509 bus_space_tag_t iot;
510 bus_space_handle_t ioh;
511 int nm93c06reg;
512 {
513 int bar;
514 int shift;
515 int bits = 0x180 | (nm93c06reg & 0xf);
516 int data = 0;
517
518 bar = 1<<BVME410_CS_SHIFT;
519 bus_space_write_2(iot, ioh, BVME410_BAR, bar);
520 delay(1); /* tCSS = 1 us */
521 for (shift = 9; shift >= 0; shift--) {
522 if (((bits >> shift) & 1) == 1)
523 bar |= 1<<BVME410_DIN_SHIFT;
524 else
525 bar &= ~(1<<BVME410_DIN_SHIFT);
526 bus_space_write_2(iot, ioh, BVME410_BAR, bar);
527 delay(1); /* tDIS = 0.4 us */
528 bar |= 1<<BVME410_CLK_SHIFT;
529 bus_space_write_2(iot, ioh, BVME410_BAR, bar);
530 delay(2); /* tSKH = 1 us, tSKH + tSKL >= 4 us */
531 bar &= ~(1<<BVME410_CLK_SHIFT);
532 bus_space_write_2(iot, ioh, BVME410_BAR, bar);
533 delay(2); /* tSKL = 1 us, tSKH + tSKL >= 4 us */
534 }
535 bar &= ~(1<<BVME410_DIN_SHIFT);
536 for (shift = 15; shift >= 0; shift--) {
537 delay(1); /* tDIS = 100 ns, BVM manual says 0.4 us */
538 bar |= 1<<BVME410_CLK_SHIFT;
539 bus_space_write_2(iot, ioh, BVME410_BAR, bar);
540 delay(2); /* tSKH = 1 us, tSKH + tSKL >= 4 us */
541 data |= (bus_space_read_2(iot, ioh, BVME410_BAR) & 1) << shift;
542 bar &= ~(1<<BVME410_CLK_SHIFT);
543 bus_space_write_2(iot, ioh, BVME410_BAR, bar);
544 delay(2); /* tSKL = 1 us, tSKH + tSKL >= 4 us */
545 }
546 bar &= ~(1<<BVME410_CS_SHIFT);
547 bus_space_write_2(iot, ioh, BVME410_BAR, bar);
548 delay(1); /* tCS = 1 us */
549 return data;
550 }
551
552 static int
553 bvme410_probe(iot, ioh)
554 bus_space_tag_t iot;
555 bus_space_handle_t ioh;
556 {
557 if (!bus_space_peek_2(iot, ioh, BVME410_IVEC))
558 return 0;
559
560 bus_space_write_2(iot, ioh, BVME410_IVEC, 0x0000);
561 if (bus_space_read_2(iot, ioh, BVME410_IVEC) != 0xff00)
562 return 0;
563
564 bus_space_write_2(iot, ioh, BVME410_IVEC, 0xffff);
565 if (bus_space_read_2(iot, ioh, BVME410_IVEC) != 0xffff)
566 return 0;
567
568 bus_space_write_2(iot, ioh, BVME410_IVEC, 0xa5a5);
569 if (bus_space_read_2(iot, ioh, BVME410_IVEC) != 0xffa5)
570 return 0;
571
572 return 1;
573 }
574
575 static int
576 bvme410_mem_size(memt, mem_addr)
577 bus_space_tag_t memt;
578 u_long mem_addr;
579 {
580 bus_space_handle_t memh;
581 int r;
582
583 if (bus_space_map(memt, mem_addr, 256*1024, 0, &memh))
584 return VMECF_MEMSIZ_DEFAULT;
585 if (!bus_space_peek_1(memt, memh, 0)) {
586 bus_space_unmap(memt, memh, 256*1024);
587 return VMECF_MEMSIZ_DEFAULT;
588 }
589 bus_space_write_1(memt, memh, 0, 128);
590 bus_space_write_1(memt, memh, 64*1024, 32);
591 bus_space_write_1(memt, memh, 32*1024, 8);
592 r = (int)(bus_space_read_1(memt, memh, 0) * 2048);
593 bus_space_unmap(memt, memh, 256*1024);
594 return r;
595 }
596
597 /*
598 * Need to be careful when writing to the bvme410 dual port memory.
599 * Continue writing each byte until it reads back the same.
600 */
601
602 static void
603 bvme410_copytobuf(sc, from, boff, len)
604 struct lance_softc *sc;
605 void *from;
606 int boff, len;
607 {
608 volatile char *buf = (volatile char *) sc->sc_mem;
609 char *f = (char *) from;
610
611 for (buf += boff; len; buf++,f++,len--)
612 do {
613 *buf = *f;
614 } while (*buf != *f);
615 }
616
617 static void
618 bvme410_zerobuf(sc, boff, len)
619 struct lance_softc *sc;
620 int boff, len;
621 {
622 volatile char *buf = (volatile char *)sc->sc_mem;
623
624 for (buf += boff; len; buf++,len--)
625 do {
626 *buf = '\0';
627 } while (*buf != '\0');
628 }
629
630