if_ef.c revision 1.3 1 /* $NetBSD: if_ef.c,v 1.3 1998/03/02 23:12:18 pk Exp $ */
2 /* $Id: if_ef.c,v 1.3 1998/03/02 23:12:18 pk Exp $ */
3
4 /*-
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Rafal K. Boni.
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 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/mbuf.h>
43 #include <sys/errno.h>
44 #include <sys/device.h>
45 #include <sys/protosw.h>
46 #include <sys/socket.h>
47
48 #include <net/if.h>
49 #include <net/if_dl.h>
50 #include <net/if_types.h>
51 #include <net/if_media.h>
52 #include <net/if_ether.h>
53
54 #include <vm/vm.h>
55
56 #include <machine/cpu.h>
57 #include <machine/bus.h>
58 #include <machine/intr.h>
59
60 #include <dev/isa/isareg.h>
61 #include <dev/isa/isavar.h>
62
63 #include <dev/ic/i82586reg.h>
64 #include <dev/ic/i82586var.h>
65 #include <dev/isa/if_efreg.h>
66 #include <dev/isa/elink.h>
67
68 #ifdef EF_DEBUG
69 #define DPRINTF(x) printf x
70 #else
71 #define DPRINTF(x)
72 #endif
73
74 struct ef_softc {
75 struct ie_softc sc_ie;
76
77 bus_space_tag_t sc_regt; /* space tag for registers */
78 bus_space_handle_t sc_regh; /* space handle for registers */
79
80 void* sc_ih; /* interrupt handle */
81
82 u_int8_t card_rev; /* hardware revision */
83 u_int8_t card_type; /* card model -- AUI/BNC or TP */
84 };
85
86 int ef_media[] = {
87 IFM_ETHER | IFM_10_5,
88 IFM_ETHER | IFM_10_2,
89 };
90 #define NEF_MEDIA (sizeof(ef_media) / sizeof(ef_media[0]))
91
92 int eftp_media[] = {
93 IFM_ETHER | IFM_10_T,
94 };
95 #define NEFTP_MEDIA (sizeof(eftp_media) / sizeof(eftp_media[0]))
96
97 /* Routines required by the MI i82586 driver API */
98 static void ef_reset __P((struct ie_softc *, int));
99 static void ef_hwinit __P((struct ie_softc *));
100 static void ef_atten __P((struct ie_softc *));
101 static int ef_intrhook __P((struct ie_softc *, int));
102
103 static void ef_copyin __P((struct ie_softc *, void *, int, size_t));
104 static void ef_copyout __P((struct ie_softc *, const void *, int, size_t));
105
106 static u_int16_t ef_read_16 __P((struct ie_softc *, int));
107 static void ef_write_16 __P((struct ie_softc *, int, u_int16_t));
108 static void ef_write_24 __P((struct ie_softc *, int, int));
109
110 static void ef_mediastatus __P((struct ie_softc *, struct ifmediareq *));
111
112 /* Local routines */
113 static int ef_port_check __P((bus_space_tag_t, bus_space_handle_t));
114
115 #ifdef __BROKEN_INDIRECT_CONFIG
116 int ef_match __P((struct device *, void*, void *));
117 #else
118 int ef_match __P((struct device *, struct cfdata *, void *));
119 #endif
120 void ef_attach __P((struct device *, struct device *, void *));
121
122 /*
123 * This keeps track of which ISAs have been through an ie probe sequence.
124 * A simple static variable isn't enough, since it's conceivable that
125 * a system might have more than one ISA bus.
126 *
127 * The "isa_bus" member is a pointer to the parent ISA bus device struct
128 * which will unique per ISA bus.
129 */
130
131 #define MAXCARDS_PER_ISABUS 8 /* if you have more than 8, you lose */
132
133 struct ef_isabus {
134 LIST_ENTRY(ef_isabus) isa_link;
135 struct device *isa_bus;
136
137 int bus_state;
138
139 struct card {
140 bus_addr_t iobase;
141 bus_addr_t maddr;
142 bus_size_t msize;
143 int irq;
144 int available;
145 } isa_cards[MAXCARDS_PER_ISABUS];
146 };
147
148 static LIST_HEAD(, ef_isabus) ef_isa_buses;
149 static int ef_isa_buses_inited;
150
151 static void
152 ef_card_add(
153 struct ef_isabus *bus,
154 bus_addr_t iobase,
155 bus_addr_t maddr,
156 bus_size_t msize,
157 int irq)
158 {
159 int idx;
160
161 DPRINTF(("Adding 3c507 at 0x%x, IRQ %d, Mem 0x%lx/%ld\n",
162 (u_int) iobase, irq, (u_long) maddr, msize));
163
164 for (idx = 0; idx < MAXCARDS_PER_ISABUS; idx++) {
165 if (bus->isa_cards[idx].available == 0) {
166 bus->isa_cards[idx].iobase = iobase;
167 bus->isa_cards[idx].maddr = maddr;
168 bus->isa_cards[idx].msize = msize;
169 bus->isa_cards[idx].irq = irq;
170 bus->isa_cards[idx].available = 1;
171 break;
172 }
173 }
174 }
175
176 /*
177 * 3C507 support routines
178 */
179 static void
180 ef_reset(sc, why)
181 struct ie_softc *sc;
182 int why;
183 {
184 struct ef_softc* esc = (struct ef_softc *) sc;
185
186 switch (why) {
187 case CHIP_PROBE:
188 /* reset to chip to see if it responds */
189 bus_space_write_1(esc->sc_regt, esc->sc_regh,
190 EF_CTRL, EF_CTRL_RESET);
191 DELAY(100);
192 bus_space_write_1(esc->sc_regt, esc->sc_regh,
193 EF_CTRL, EF_CTRL_NORMAL);
194 DELAY(100);
195 break;
196
197 case CARD_RESET:
198 /*
199 * this takes around 10sec, and we can get
200 * by quite well w/out it...
201 */
202 break;
203 }
204 }
205
206 static void
207 ef_atten(sc)
208 struct ie_softc *sc;
209 {
210 struct ef_softc* esc = (struct ef_softc *) sc;
211 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_ATTN, 1);
212 }
213
214 static void
215 ef_hwinit(sc)
216 struct ie_softc *sc;
217 {
218 struct ef_softc* esc = (struct ef_softc *) sc;
219 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_ICTRL, 1);
220 }
221
222 static int
223 ef_intrhook(sc, where)
224 struct ie_softc *sc;
225 int where;
226 {
227 unsigned char cr;
228 struct ef_softc* esc = (struct ef_softc *) sc;
229
230 switch (where) {
231 case INTR_ENTER:
232 /* entering ISR: disable, ack card interrupts */
233 cr = bus_space_read_1(esc->sc_regt, esc->sc_regh, EF_CTRL);
234 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_CTRL,
235 cr & ~EF_CTRL_IEN);
236 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_ICTRL, 1);
237 break;
238
239 case INTR_EXIT:
240 /* exiting ISR: re-enable card interrupts */
241 cr = bus_space_read_1(esc->sc_regt, esc->sc_regh, EF_CTRL);
242 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_CTRL,
243 cr | EF_CTRL_IEN);
244 break;
245
246 case INTR_LOOP:
247 /* looping in ISR: ack new interrupts */
248 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_ICTRL, 1);
249 break;
250 }
251
252 return 1;
253 }
254
255 static u_int16_t
256 ef_read_16 (sc, offset)
257 struct ie_softc *sc;
258 int offset;
259 {
260 bus_space_barrier(sc->bt, sc->bh, offset, 2, BUS_SPACE_BARRIER_READ);
261 return bus_space_read_2(sc->bt, sc->bh, offset);
262 }
263
264 static void
265 ef_copyin (sc, dst, offset, size)
266 struct ie_softc *sc;
267 void *dst;
268 int offset;
269 size_t size;
270 {
271 int dribble;
272 u_int8_t* bptr = dst;
273
274 bus_space_barrier(sc->bt, sc->bh, offset, size,
275 BUS_SPACE_BARRIER_READ);
276
277 if (offset % 2) {
278 *bptr = bus_space_read_1(sc->bt, sc->bh, offset);
279 offset++; bptr++; size--;
280 }
281
282 dribble = size % 2;
283 bus_space_read_region_2(sc->bt, sc->bh, offset, (u_int16_t *) bptr,
284 size >> 1);
285
286 if (dribble) {
287 bptr += size - 1;
288 offset += size - 1;
289 *bptr = bus_space_read_1(sc->bt, sc->bh, offset);
290 }
291 }
292
293 static void
294 ef_copyout (sc, src, offset, size)
295 struct ie_softc *sc;
296 const void *src;
297 int offset;
298 size_t size;
299 {
300 int dribble;
301 int osize = size;
302 int ooffset = offset;
303 const u_int8_t* bptr = src;
304
305 if (offset % 2) {
306 bus_space_write_1(sc->bt, sc->bh, offset, *bptr);
307 offset++; bptr++; size--;
308 }
309
310 dribble = size % 2;
311 bus_space_write_region_2(sc->bt, sc->bh, offset, (u_int16_t *)bptr,
312 size >> 1);
313 if (dribble) {
314 bptr += size - 1;
315 offset += size - 1;
316 bus_space_write_1(sc->bt, sc->bh, offset, *bptr);
317 }
318
319 bus_space_barrier(sc->bt, sc->bh, ooffset, osize,
320 BUS_SPACE_BARRIER_WRITE);
321 }
322
323 static void
324 ef_write_16 (sc, offset, value)
325 struct ie_softc *sc;
326 int offset;
327 u_int16_t value;
328 {
329 bus_space_write_2(sc->bt, sc->bh, offset, value);
330 bus_space_barrier(sc->bt, sc->bh, offset, 2, BUS_SPACE_BARRIER_WRITE);
331 }
332
333 static void
334 ef_write_24 (sc, offset, addr)
335 struct ie_softc *sc;
336 int offset, addr;
337 {
338 bus_space_write_4(sc->bt, sc->bh, offset, addr +
339 (u_long) sc->sc_maddr - (u_long) sc->sc_iobase);
340 bus_space_barrier(sc->bt, sc->bh, offset, 4, BUS_SPACE_BARRIER_WRITE);
341 }
342
343 static void
344 ef_mediastatus(sc, ifmr)
345 struct ie_softc *sc;
346 struct ifmediareq *ifmr;
347 {
348 struct ifmedia *ifm = &sc->sc_media;
349
350 /*
351 * The currently selected media is always the active media.
352 */
353 ifmr->ifm_active = ifm->ifm_cur->ifm_media;
354 }
355
356 int
357 ef_match(parent, cf, aux)
358 struct device *parent;
359 #ifdef __BROKEN_INDIRECT_CONFIG
360 void *cf;
361 #else
362 struct cfdata *cf;
363 #endif
364 void *aux;
365 {
366 struct isa_attach_args * const ia = aux;
367
368 int idx;
369 struct ef_isabus *bus;
370
371 bus_space_handle_t ioh;
372 bus_space_tag_t iot = ia->ia_iot;
373
374 if (ef_isa_buses_inited == 0) {
375 LIST_INIT(&ef_isa_buses);
376 ef_isa_buses_inited = 1;
377 }
378
379 /*
380 * Probe this bus if we haven't done so already.
381 */
382 for (bus = ef_isa_buses.lh_first; bus != NULL;
383 bus = bus->isa_link.le_next) {
384 if (bus->isa_bus == parent)
385 break;
386 }
387
388 if (bus == NULL) {
389 bus_addr_t iobase;
390
391 /*
392 * Mark this bus so we don't probe it again.
393 */
394 bus = (struct ef_isabus *)
395 malloc(sizeof(struct ef_isabus), M_DEVBUF, M_NOWAIT);
396 if (bus == NULL)
397 panic("ef_isa_probe: can't allocate state storage for %s",
398 parent->dv_xname);
399
400 bus->bus_state = 0; /* nothing done yet */
401 bus->isa_bus = parent;
402
403 LIST_INSERT_HEAD(&ef_isa_buses, bus, isa_link);
404
405 if (bus_space_map(iot, ELINK_ID_PORT, 1, 0, &ioh)) {
406 DPRINTF(("3c507 probe: can't map Etherlink ID port\n"));
407 return 0;
408 }
409
410 /*
411 * Reset and put card in CONFIG state without
412 * changing address.
413 */
414 elink_reset(iot, ioh, parent->dv_unit);
415 elink_idseq(iot, ioh, ELINK_507_POLY);
416 elink_idseq(iot, ioh, ELINK_507_POLY);
417 bus_space_write_1(iot, ioh, 0, 0xff);
418
419 /* Unmap the ID port */
420 bus_space_unmap(iot, ioh, 1);
421
422 bus->bus_state++; /* cards now in CONFIG state */
423
424 for (iobase = EF_IOBASE_LOW; iobase <= EF_IOBASE_HIGH;
425 iobase += EF_IOSIZE) {
426 /*
427 * Map the 507's port-space for the probe sequence.
428 */
429 if (bus_space_map(iot, iobase, EF_IOSIZE,
430 0, &ioh) != 0)
431 continue;
432
433 /* Now look for the 3Com magic bytes */
434
435 if (ef_port_check(iot, ioh)) {
436 int irq;
437 u_int8_t v;
438 bus_addr_t maddr;
439 bus_addr_t msize;
440 bus_space_handle_t memh;
441
442 irq = bus_space_read_1(iot, ioh, EF_IRQ) &
443 EF_IRQ_MASK;
444
445 v = bus_space_read_1(iot, ioh, EF_MADDR);
446 maddr = EF_MADDR_BASE +
447 ((v & EF_MADDR_MASK) << EF_MADDR_SHIFT);
448 msize = ((v & EF_MSIZE_MASK) + 1) *
449 EF_MSIZE_STEP;
450
451 if (bus_space_map(ia->ia_memt, maddr,
452 msize, 0, &memh) == 0) {
453 ef_card_add(bus, iobase, maddr,
454 msize, irq);
455 bus_space_unmap(ia->ia_memt,
456 memh, msize);
457 }
458 }
459 bus_space_unmap(iot, ioh, EF_IOSIZE);
460 }
461 }
462
463 for (idx = 0; idx < MAXCARDS_PER_ISABUS; idx++) {
464 if (bus->isa_cards[idx].available != 1)
465 continue;
466
467 if (ia->ia_iobase != IOBASEUNK &&
468 ia->ia_iobase != bus->isa_cards[idx].iobase)
469 continue;
470
471 if (ia->ia_maddr != MADDRUNK &&
472 ia->ia_maddr != bus->isa_cards[idx].maddr)
473 continue;
474
475 if (ia->ia_irq != IRQUNK &&
476 ia->ia_irq != bus->isa_cards[idx].irq)
477 continue;
478
479 break;
480 }
481
482 if (idx == MAXCARDS_PER_ISABUS)
483 return (0);
484
485 bus->isa_cards[idx].available++;
486 ia->ia_iobase = bus->isa_cards[idx].iobase;
487 ia->ia_irq = bus->isa_cards[idx].irq;
488 ia->ia_iosize = EF_IOSIZE;
489 ia->ia_maddr = bus->isa_cards[idx].maddr;
490 ia->ia_msize = bus->isa_cards[idx].msize;
491 return (1);
492 }
493
494 void
495 ef_attach(parent, self, aux)
496 struct device *parent;
497 struct device *self;
498 void *aux;
499 {
500 struct ef_softc *esc = (void *)self;
501 struct ie_softc *sc = &esc->sc_ie;
502 struct isa_attach_args *ia = aux;
503 bus_space_tag_t iot = ia->ia_iot;
504
505 int i;
506 char version[20];
507 struct ef_isabus *bus;
508 u_int8_t partno[EF_TYPE_LEN];
509 bus_space_handle_t ioh, memh;
510 u_int8_t ethaddr[ETHER_ADDR_LEN];
511
512 sc->hwinit = ef_hwinit;
513 sc->hwreset = ef_reset;
514 sc->chan_attn = ef_atten;
515 sc->intrhook = ef_intrhook;
516
517 sc->memcopyin = ef_copyin;
518 sc->memcopyout = ef_copyout;
519 sc->ie_bus_read16 = ef_read_16;
520 sc->ie_bus_write16 = ef_write_16;
521 sc->ie_bus_write24 = ef_write_24;
522
523 sc->sc_msize = 0;
524
525 /*
526 * NOP chains don't give any advantage on this card, in fact they
527 * seem to slow it down some. As the doctor says, "if it hurts,
528 * don't do it".
529 */
530 sc->do_xmitnopchain = 0;
531
532 sc->sc_mediachange = NULL;
533 sc->sc_mediastatus = ef_mediastatus;
534
535 /* Find the cards parent bus */
536 for (bus = ef_isa_buses.lh_first; bus != NULL;
537 bus = bus->isa_link.le_next) {
538
539 if (bus->isa_bus == parent)
540 break;
541 }
542
543 if (bus == NULL)
544 panic("%s: Can't find parent bus!", sc->sc_dev.dv_xname);
545
546
547 /* If the bus hasn't been transitioned to the RUN state, do so now */
548 if (bus->bus_state == 1) {
549 if (bus_space_map(iot, ELINK_ID_PORT, 1, 0, &ioh) != 0) {
550 DPRINTF(("\n%s: Can't map Elink ID port!\n",
551 sc->sc_dev.dv_xname));
552 return;
553 }
554
555 bus_space_write_1(ia->ia_iot, ioh, 0, 0x00);
556 elink_idseq(ia->ia_iot, ioh, ELINK_507_POLY);
557 bus_space_write_1(ia->ia_iot, ioh, 0, 0x00);
558 bus_space_unmap(ia->ia_iot, ioh, 1);
559
560 bus->bus_state++;
561 }
562
563 /* Map i/o space. */
564 if (bus_space_map(ia->ia_iot, ia->ia_iobase,
565 ia->ia_iosize, 0, &ioh) != 0) {
566
567 DPRINTF(("\n%s: can't map i/o space 0x%x-0x%x\n",
568 sc->sc_dev.dv_xname, ia->ia_iobase,
569 ia->ia_iobase + ia->ia_iosize - 1));
570 return;
571 }
572
573 esc->sc_regt = ia->ia_iot;
574 esc->sc_regh = ioh;
575
576 if (bus_space_map(ia->ia_memt, ia->ia_maddr,
577 ia->ia_msize, 0, &memh) != 0) {
578
579 DPRINTF(("\n%s: can't map iomem space 0x%x-0x%x\n",
580 sc->sc_dev.dv_xname, ia->ia_maddr,
581 ia->ia_maddr + ia->ia_msize - 1));
582 bus_space_unmap(ia->ia_iot, ioh, ia->ia_iosize);
583 return;
584 }
585
586 sc->bt = ia->ia_memt;
587 sc->bh = memh;
588
589 sc->sc_msize = ia->ia_msize;
590 sc->sc_maddr = (void *) memh;
591 sc->sc_iobase = sc->sc_maddr + sc->sc_msize - (1 << 24);
592
593 /* set up pointers to important on-card control structures */
594 sc->iscp = 0;
595 sc->scb = IE_ISCP_SZ;
596 sc->scp = sc->sc_msize + IE_SCP_ADDR - (1 << 24);
597
598 sc->buf_area = sc->scb + IE_SCB_SZ;
599 sc->buf_area_sz = sc->sc_msize - IE_ISCP_SZ - IE_SCB_SZ - IE_SCP_SZ;
600
601 /* zero card memory */
602 bus_space_set_region_1(sc->bt, sc->bh, 0, 0, sc->sc_msize);
603
604 /* set card to 16-bit bus mode */
605 bus_space_write_1(sc->bt, sc->bh, IE_SCP_BUS_USE((u_long)sc->scp), 0);
606
607 /* set up pointers to key structures */
608 ef_write_24(sc, IE_SCP_ISCP((u_long)sc->scp), (u_long) sc->iscp);
609 ef_write_16(sc, IE_ISCP_SCB((u_long)sc->iscp), (u_long) sc->scb);
610 ef_write_24(sc, IE_ISCP_BASE((u_long)sc->iscp), (u_long) sc->iscp);
611
612 /* flush setup of pointers, check if chip answers */
613 bus_space_barrier(sc->bt, sc->bh, 0, sc->sc_msize,
614 BUS_SPACE_BARRIER_WRITE);
615 if (!i82586_proberam(sc)) {
616 DPRINTF(("\n%s: can't talk to i82586!\n",
617 sc->sc_dev.dv_xname));
618 bus_space_unmap(ia->ia_iot, ioh, ia->ia_iosize);
619 bus_space_unmap(ia->ia_memt, memh, ia->ia_msize);
620 return;
621 }
622
623 /* set bank 2 for card part number and revision */
624 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_CTRL,
625 EF_CTRL_NRST | EF_CTRL_BNK2);
626
627 /* card revision is encoded in BCD */
628 i = bus_space_read_1(esc->sc_regt, esc->sc_regh, EF_REV);
629 esc->card_rev = 10 * (i / 16) + (i % 16);
630
631 for (i = 0; i < EF_TYPE_LEN; i++)
632 partno[i] = bus_space_read_1(esc->sc_regt, esc->sc_regh,
633 EF_TYPE + i);
634
635 /* use part number to guess if card is TP or AUI/BNC model */
636 esc->card_type = EF_IS_TP(partno) ? EF_CARD_TP : EF_CARD_BNC;
637
638 /* set bank 0 for ethernet address */
639 bus_space_write_1(esc->sc_regt, esc->sc_regh,
640 EF_CTRL, EF_CTRL_NORMAL);
641
642 for (i = 0; i < EF_ADDR_LEN; i++)
643 ethaddr[i] = bus_space_read_1(esc->sc_regt, esc->sc_regh,
644 EF_ADDR + i);
645
646 sprintf(version, "%s, rev. %d",
647 (esc->card_type == EF_CARD_TP) ? "3C507-TP" : "3C507",
648 esc->card_rev);
649
650 if (esc->card_type == EF_CARD_TP)
651 i82586_attach(sc, version, ethaddr, eftp_media, NEFTP_MEDIA,
652 eftp_media[0]);
653 else {
654 u_int8_t media = bus_space_read_1(esc->sc_regt, esc->sc_regh,
655 EF_MEDIA);
656 media = (media & EF_MEDIA_MASK) >> EF_MEDIA_SHIFT;
657
658 i82586_attach(sc, version, ethaddr, ef_media, NEF_MEDIA,
659 ef_media[media]);
660 }
661
662 /* Clear the interrupt latch just in case. */
663 bus_space_write_1(esc->sc_regt, esc->sc_regh, EF_ICTRL, 1);
664
665 esc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
666 IPL_NET, i82586_intr, sc);
667 if (esc->sc_ih == NULL) {
668 DPRINTF(("\n%s: can't establish interrupt\n",
669 sc->sc_dev.dv_xname));
670 }
671 }
672
673 static int
674 ef_port_check(iot, ioh)
675 bus_space_tag_t iot;
676 bus_space_handle_t ioh;
677 {
678 int i;
679 u_char ch;
680 u_char* signature = EF_SIGNATURE;
681
682 for (i = 0; i < strlen(signature); i++) {
683 ch = bus_space_read_1(iot, ioh, i);
684 if (ch != signature[i])
685 return 0;
686 }
687
688 /* If card is mapped in high memory (above 15Meg), we can't use it */
689 ch = bus_space_read_1(iot, ioh, EF_MADDR);
690 if (ch & EF_MADDR_HIGH)
691 return 0; /* XXX: maybe we should panic?? */
692
693 return 1;
694 }
695
696 struct cfattach ef_ca = {
697 sizeof(struct ef_softc), ef_match, ef_attach
698 };
699
700